💼 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 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;
}
This rule takes an optional object containing:
boolean
--catchRouterMicrolib
-- whether the rule should catch usages of the private property_routerMicrolib
(defaulttrue
)boolean
--catchRouterMain
-- whether the rule should catch usages of the private propertyrouter:main
(defaulttrue
)