An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
ESLint is required to use this plugin.
npm install --save-dev eslint-plugin-ember
// .eslintrc.js
module.exports = {
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
rules: {
// override rules' settings here
}
}
Possible configurations:
- plugin:ember/base - contains only recommended settings for custom rules defined in this plugin.
- plugin:ember/recommended - extends base configuration with extra rules' settings provided by eslint
If you don't want to use predefined settings, you can use it as a plain plugin and choose which rules you'd like to use by yourself like this:
module.exports = {
extends: [
'eslint:recommended'
],
plugins: [
'ember'
],
rules: {
// add rules' settings here, eg.:
'ember/local-modules': 2
}
}
All rules from this plugin have to be prefixed with ember/
-
General
- local-modules - Create local version of Ember.* and DS.* (more)
- no-observers - Don't use observers (more)
- no-side-effect - Don't introduce side-effects in computed properties (more)
- jquery-ember-run - Don’t use jQuery without Ember Run Loop (more)
- named-functions-in-promises - Use named functions defined on objects to handle promises (more)
- no-function-prototype-extensions - Don't use Ember's function prototype extensions (more)
- use-ember-get-and-set - Use Ember get/set (more)
- use-brace-expansion - Use brace expansion (more)
-
Organizing
-
Controllers
-
Ember Data
- no-empty-attrs - Be explicit with Ember data attribute types (more)
-
Components
-
closure-actions - Always use closure actions (more)
-
no-on-calls-in-components - Don't use .on() in components (more)
-
* avoid-leaking-state-in-components - Don't use objects and arrays as default properties (more)
Example config:
ember/avoid-leaking-state-in-components: [1, ['array', 'of', 'ignored', 'properties']]
-
-
Routing
- routes-segments-snake-case - Route's dynamic segments should use snake case (more)
* Rule with optional settings
"ember/alias-model-in-controller": 0,
"ember/avoid-leaking-state-in-components": 0,
"ember/closure-actions": 0,
"ember/jquery-ember-run": 0,
"ember/local-modules": 0,
"ember/named-functions-in-promises": 0,
"ember/no-empty-attrs": 0,
"ember/no-function-prototype-extensions": 0,
"ember/no-observers": 0,
"ember/no-on-calls-in-components": 0,
"ember/no-side-effects": 0,
"ember/order-in-components": 0,
"ember/order-in-controllers": 0,
"ember/order-in-models": 0,
"ember/order-in-routes": 0,
"ember/query-params-on-top": 0,
"ember/routes-segments-snake-case": 0,
"ember/use-brace-expansion": 0,
"ember/use-ember-get-and-set": 0,
In order to add a new rule, you should:
- generate a new rule using the official yeoman generator
- describe the rule in the generated
docs
file - link to the new
docs
file indocs/RULES.md
- add the rule in README.md
Recommended way of creating new rules:
- Create issue on GH with description of proposed rule
- Write sufficient test scenarios
- Run
gulp watch
- Implement logic for the new rule
- Make sure all tests are passing
- Add documentation and update README
- 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](https://github.com/netguru/eslint-plugin-ember/issues, 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
- Dockyard team - for great inspiration with their styleguide
- Rob Hilgefort - for making it possible to redeploy new plugin under existing
eslint-plugin-ember
package name
See the LICENSE file for license rights and limitations (MIT).