An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
yarn add --dev eslint-plugin-ember
Or
npm install --save-dev eslint-plugin-ember
// .eslintrc.js
module.exports = {
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended' // or other configuration
],
rules: {
// override rule settings here
'ember/no-jquery': 'error'
}
};
Name | Description | |
---|---|---|
base | contains no rules settings, but the basic eslint configuration suitable for any ember project. You can use it to configure rules as you wish. | |
β | recommended | extends the base configuration by enabling the recommended rules. |
π | octane | extends the recommended configuration by enabling octane rules. This ruleset is currently considered unstable and experimental |
Rules are grouped by category to help you understand their purpose. Each rule has emojis denoting:
- What configuration it belongs to
- π§ if some problems reported by the rule are automatically fixable by the
--fix
command line option
Rule ID | Description | |
---|---|---|
β | no-attrs-in-components | disallow usage of this.attrs in components |
β | no-attrs-snapshot | disallow use of attrs snapshot in the didReceiveAttrs and didUpdateAttrs component hooks |
π | no-classic-components | enforce using Glimmer components |
π | no-component-lifecycle-hooks | disallow usage of "classic" ember component lifecycle hooks. Render modifiers or custom functional modifiers should be used instead. |
β | no-on-calls-in-components | disallow usage of on to call lifecycle hooks in components |
π | require-tagless-components | disallow using the wrapper element of a component |
Rule ID | Description | |
---|---|---|
computed-property-getters | enforce the consistent use of getters in computed properties | |
β | no-arrow-function-computed-properties | disallow arrow functions in computed properties |
π§ | no-assignment-of-untracked-properties-used-in-tracking-contexts | disallow assignment of untracked properties that are used as computed property dependencies |
π | no-computed-properties-in-native-classes | disallow using computed properties in native classes |
β | no-deeply-nested-dependent-keys-with-each | disallow usage of deeply-nested computed property dependent keys with @each |
β π§ | no-duplicate-dependent-keys | disallow repeating computed property dependent keys |
β π§ | no-incorrect-computed-macros | disallow incorrect usage of computed property macros |
β π§ | no-invalid-dependent-keys | disallow invalid dependent keys in computed properties |
β | no-side-effects | disallow unexpected side effects in computed properties |
β | no-volatile-computed-properties | disallow volatile computed properties |
β π§ | require-computed-macros | require using computed property macros when possible |
β π§ | require-computed-property-dependencies | require dependencies to be declared statically in computed properties |
β | require-return-from-computed | disallow missing return statements in computed properties |
β | use-brace-expansion | enforce usage of brace expansion in computed property dependent keys |
Rule ID | Description | |
---|---|---|
alias-model-in-controller | enforce aliasing model in controllers | |
β | avoid-using-needs-in-controllers | disallow using needs in controllers |
no-controllers | disallow non-essential controllers |
Rule ID | Description | |
---|---|---|
β | closure-actions | enforce usage of closure actions |
β | new-module-imports | enforce using "New Module Imports" from Ember RFC #176 |
β | no-function-prototype-extensions | disallow usage of Ember's function prototype extensions |
β | no-mixins | disallow the usage of mixins |
β | no-new-mixins | disallow the creation of new mixins |
β | no-observers | disallow usage of observers |
β π§ | no-old-shims | disallow usage of old shims for modules |
Rule ID | Description | |
---|---|---|
no-empty-attrs | disallow usage of empty attributes in Ember Data models | |
β π§ | use-ember-data-rfc-395-imports | enforce usage of @ember-data/ package imports instead ember-data |
Rule ID | Description | |
---|---|---|
β | avoid-leaking-state-in-ember-objects | disallow state leakage |
β π§ | no-get-with-default | disallow usage of the Ember's getWithDefault function |
β π§ | no-get | require using ES5 getters instead of Ember's get / getProperties functions |
no-proxies | disallow using array or object proxies | |
β | require-super-in-init | require this._super to be called in init hooks |
π§ | use-ember-get-and-set | enforce usage of Ember.get and Ember.set |
Rule ID | Description | |
---|---|---|
π | classic-decorator-hooks | enforce using correct hooks for both classic and non-classic classes |
π | classic-decorator-no-classic-methods | disallow usage of classic APIs such as get /set in classes that aren't explicitly decorated with @classic |
π | no-actions-hash | disallow the actions hash in components, controllers, and routes |
π | no-classic-classes | disallow "classic" classes in favor of native JS classes |
β π§ | no-ember-super-in-es-classes | disallow use of this._super in ES class methods |
Rule ID | Description | |
---|---|---|
β | jquery-ember-run | disallow usage of jQuery without an Ember run loop |
β | no-global-jquery | disallow usage of global jQuery object |
β | no-jquery | disallow any usage of jQuery |
Rule ID | Description | |
---|---|---|
named-functions-in-promises | enforce usage of named functions in promises | |
β | no-incorrect-calls-with-inline-anonymous-functions | disallow inline anonymous functions as arguments to debounce , once , and scheduleOnce |
β | no-invalid-debug-function-arguments | disallow usages of Ember's assert() / warn() / deprecate() functions that have the arguments passed in the wrong order. |
no-restricted-service-injections | disallow injecting certain services under certain paths |
Rule ID | Description | |
---|---|---|
β | no-capital-letters-in-routes | disallow routes with uppercased letters in router.js |
β | no-private-routing-service | disallow injecting the private routing service |
no-unnecessary-index-route | disallow unnecessary index route definition |
|
β π§ | no-unnecessary-route-path-option | disallow unnecessary usage of the route path option |
route-path-style | enforce usage of kebab-case (instead of snake_case or camelCase) in route paths | |
β | routes-segments-snake-case | enforce usage of snake_cased dynamic segments in routes |
Rule ID | Description | |
---|---|---|
π§ | no-unnecessary-service-injection-argument | disallow unnecessary argument when injecting services |
π§ | order-in-components | enforce proper order of properties in components |
π§ | order-in-controllers | enforce proper order of properties in controllers |
π§ | order-in-models | enforce proper order of properties in models |
π§ | order-in-routes | enforce proper order of properties in routes |
Rule ID | Description | |
---|---|---|
β | no-ember-testing-in-module-scope | disallow use of Ember.testing in module scope |
no-invalid-test-waiters | disallow incorrect usage of test waiter APIs | |
β | no-legacy-test-waiters | disallow the use of the legacy test waiter APIs |
β | no-pause-test | disallow usage of the pauseTest helper in tests |
no-replace-test-comments | disallow 'Replace this with your real tests' comments in test files | |
β | no-restricted-resolver-tests | disallow the use of patterns that use the restricted resolver in tests |
β | no-test-and-then | disallow usage of the andThen test wait helper |
β | no-test-import-export | disallow importing of "-test.js" in a test file and exporting from a test file |
β | no-test-module-for | disallow usage of moduleFor , moduleForComponent , etc |
no-test-this-render | disallow usage of the this.render in tests, recommending to use @ember/test-helpers' render instead. |
|
prefer-ember-test-helpers | enforce usage of @ember/test-helpers methods over native window methods |
For the simplified list of rules, go here.
If you have any suggestions, ideas, or problems, feel free to create an issue, but first please make sure your question does not repeat previous ones.
- Create an issue with a description of the proposed rule
- Create files for the new rule:
lib/rules/new-rule.js
(implementation, see no-proxies for an example)docs/rules/new-rule.md
(documentation, start from the template -- raw, rendered)tests/lib/rules/new-rule.js
(tests, see no-proxies for an example)
- Run
yarn update
to automatically update the README and other files (and re-run this if you change the rule name or description) - Make sure your changes will pass CI by running:
yarn test
yarn lint
(yarn lint:js --fix
can fix many errors)
- Create a PR and link the created issue in the description
Note that new rules should not immediately be added to the recommended configuration, as we only consider such breaking changes during major version updates.
See the LICENSE file for license rights and limitations (MIT).