ember/no-private-routing-service

January 29, 2026 ยท View on GitHub

๐Ÿ’ผ This rule is enabled in the โœ… recommended config.

Disallow the use of:

  • The private -routing service
  • The private _routerMicrolib property
  • The private router:main property

There has been a public router service since Ember 2.16 and using the private routing service should be unnecessary.

Examples

Examples of incorrect code for this rule:

import Component from '@ember/component';
import { inject as service } from '@ember/service';

export default Component.extend({
  routing: service('-routing'),
});
import Component from '@ember/component';

export default class MyComponent extends Component {
  @service('-routing') routing;
}
// When `catchRouterMicrolib` option is enabled.

import Component from '@ember/component';

export default class MyComponent extends Component {
  @service('router') router;

  get someMethod() {
    return this.router._routerMicrolib.activeTransition;
  }
}
// When `catchRouterMain` option is enabled.

import Component from '@ember/component';
import { getOwner } from '@ember/application';

export default class MyComponent extends Component {
  someFunction() {
    const router = getOwner(this).lookup('router:main');
    // ...
  }
}

Examples of correct code for this rule:

import Component from '@ember/component';
import { inject as service } from '@ember/service';

export default Component.extend({
  router: service('router'),
});
import Component from '@ember/component';

export default class MyComponent extends Component {
  @service
  router;
}

Configuration

NameDescriptionTypeDefault
catchRouterMainWhether the rule should catch usages of the private property router:main.Booleantrue
catchRouterMicrolibWhether the rule should catch usages of the private property _routerMicrolib.Booleantrue

References

Router RFC