Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 1.59 KB

no-unnecessary-service-injection-argument.md

File metadata and controls

51 lines (35 loc) · 1.59 KB

no-unnecessary-service-injection-argument

🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

Disallow unnecessary argument when injecting service.

It's not necessary to specify an injected service's name as an argument when the property name matches the service name.

Note: this rule is not in the recommended configuration because this is more of a stylistic preference and some developers may prefer to use the explicit service injection argument to avoid potentially costly lookup/normalization of the service name.

Examples

Examples of incorrect code for this rule:

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

export default Component.extend({
  myServiceName: service('myServiceName')
});

Examples of correct code for this rule:

export default Component.extend({
  myServiceName: service()
});
export default Component.extend({
  myServiceName: service('my-service-name')
});
export default Component.extend({
  otherSpecialName: service('my-service-name')
});

Related Rules

References