Additional ember linting rules
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-ember-extra-linting
:
$ npm install eslint-plugin-ember-extra-linting --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-ember-extra-linting
globally.
Add ember-extra-linting
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"ember-extra-linting"
]
}
You can the specify the rules you wish to implement. If you want to use the recommended rule set see below.
Add the plugin's recommended
configuration to the list of extensions:
// .eslintrc.js
module.exports = {
// ...
extends: [
'eslint:recommended',
'plugin:ember-extra-linting/recommended'
],
rules: {
}
};
Then configure the rules you want to use under the rules section.
{
"rules": {
"ember-extra-linting/rule-name": 2
}
}
ember-no-autogenerated-comments
: Errors if any of the testing autogenerated comments are left in files. These should either be removed or replaced with specific comments. Note: this rule is only configured for ember 3.0+ currently.
ember-no-double-gets
: Errors if trying to get from the same object twice in a single block. This informs the user that they should be using the getProperties
method.
ember-no-double-sets
: Errors if trying to get from the same object twice in a single block. This informs the user that they should be using the getProperties
method.
ember-no-get-properties
: Errors if using the getProperties
function. Not recommended unless using Ember 3.1+.
ember-no-pointless-gets
: Errors if trying to use the get
function on the object without using the ability to check for properties. Informs the user that property access is not preferred (since 3.1);
ember-require-inject-as-service
: Requires import { inject as service } from '@ember/service
for consistency, does not allow plain inject
.
ember-require-service-used
: Errors if a service is injected and never used.
ember-no-pointless-service-arguments
: Errors if a service name is specified when it is not required.