An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
- ESLint is required to use this plugin.
- Rules provided by this plugin should be runnable under latest stable, v4 LTS and v6 LTS Node.js versions.
1. Install plugin
yarn add --dev eslint-plugin-ember
npm install --save-dev eslint-plugin-ember
2. Modify your
Use with predefined settings:
// .eslintrc.jsmoduleexports =plugins:'ember'extends:'eslint:recommended''plugin:ember/recommended' // or 'plugin:ember/base'rules:// override rules' settings here
- plugin:ember/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.
- plugin:ember/recommended - extends base configuration with recommended rules' settings
Use plain plugin:
If you don't want to use predefined settings, you can use it as a plain plugin:
moduleexports =plugins:'ember'extends:'eslint:recommended'rules:// add rules' settings here, eg.:'ember/local-modules': 2
All rules from this plugin have to be prefixed with
Rules are grouped by category to help you understand their purpose.
All rules below with a check mark ✅ are enabled by default while using
--fix option on the command line automatically fixes problems reported by rules which have a wrench 🔧 below.
|alias-model-in-controller||Enforces aliasing model in controller|
|✅||avoid-using-needs-in-controllers||Avoids using needs in controllers|
|✅||closure-actions||Enforces usage of closure actions|
|named-functions-in-promises||Enforces usage of named functions in promises|
|✅||new-module-imports||Use "New Module Imports" from Ember RFC #176|
|no-empty-attrs||Prevents usage of empty attributes in ember data models|
|✅||no-function-prototype-extensions||Prevents usage of Ember's
|✅||no-global-jquery||Prevents usage of global jQuery object|
|no-jquery||Disallow any usage of jQuery|
|no-new-mixins||Prevents creation of new mixins|
|✅||no-observers||Prevents usage of observers|
|✅🔧||no-old-shims||Prevents usage of old shims for modules|
|✅||no-on-calls-in-components||Prevents usage of
|✅||no-restricted-resolver-tests||Prevents the use of patterns that use the restricted resolver in tests.|
|🔧||use-ember-get-and-set||Enforces usage of Ember.get and Ember.set|
|✅||jquery-ember-run||Prevents usage of jQuery without Ember Run Loop|
|✅||no-attrs-in-components||Disallow usage of this.attrs in components|
|✅||no-attrs-snapshot||Disallow use of attrs snapshot in
|✅||no-capital-letters-in-routes||Raise an error when there is a route with uppercased letters in router.js|
|✅||no-duplicate-dependent-keys||Disallow repeating dependent keys|
|🔧||no-ember-super-in-es-classes||Prevents use of
|✅||no-ember-testing-in-module-scope||Prevents use of Ember.testing in module scope|
|✅||no-side-effects||Warns about unexpected side effects in computed properties|
|✅||require-super-in-init||Enforces super calls in init hooks|
|✅||routes-segments-snake-case||Enforces usage of snake_cased dynamic segments in routes|
|✅||avoid-leaking-state-in-ember-objects||Avoids state leakage|
|no-test-import-export||Disallow importing of "-test.js" in a test file and exporting from a test file.|
|🔧||order-in-components||Enforces proper order of properties in components|
|🔧||order-in-controllers||Enforces proper order of properties in controllers|
|🔧||order-in-models||Enforces proper order of properties in models|
|🔧||order-in-routes||Enforces proper order of properties in routes|
|✅||use-brace-expansion||Enforces usage of brace expansion|
⚠️ We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
|Rule ID||Replaced by|
For the simplified list of rules, go here.
🍻 Contribution guide
In order to add a new rule, you should:
- Create issue on GH with description of proposed rule
- Generate a new rule using the official yeoman generator
- Write test scenarios & implement logic
- Describe the rule in the generated
- Make sure all tests are passing
yarn run updatein order to update readme and recommended configuration
- Create PR and link created issue in description
Please be aware that we're using
yarn in this repository, so if you plan to add some dependencies - make sure you commit
yarn.lock file too.
If you have any suggestions, ideas or problems feel free to add new issue, but first please make sure your question does not repeat previous ones.
- Michał Sajnóg
- Rafał Leszczyński
- Adrian Zalewski
- Kamil Ejsymont
- Casey Watts
- Steve Gargan
- Alex LaFroscia
- Tobias Bieniek
- Robert Wagner
- Jacek Bandura
- DockYard team - for great inspiration with their styleguide
- Rob Hilgefort - for making it possible to redeploy new plugin under existing
See the LICENSE file for license rights and limitations (MIT).