eslint-plugin-netguru-ember
ESlint plugin that provides set of rules for Ember Applications based on Netguru's Ember Styleguide.
Summary
It's made to help you keep good practices mentioned in our Ember Styleguide.
Requirements
You need to have ember-cli-eslint
installed in your app. More info here.
Usage
With shareable config
The easiest way to use this plugin is through our shareable config. More about shareable configs here.
1. Install all dependencies by simply pasting code below in your terminal
(
export PKG=eslint-config-netguru-ember;
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
)
This command will basically produce and call something like this:
npm install --save-dev eslint-config-netguru-ember eslint-plugin-netguru-ember@1.x eslint-config-airbnb-base@^7.1.0 eslint-plugin-import@^1.15.0
2. Change your .eslintrc
, so it looks like this:
extends: netguru-ember
Without shareable config (only plugin)
1. Install plugin:
npm install --save-dev eslint-plugin-netguru-ember
2. Add plugin to your .eslintrc
:
plugins:
- netguru-ember
3. Configure rules in your .eslintrc
:
rules:
- netguru-ember/local-modules: 1
All rules from our plugin have to be prefixed with netguru-ember/
Rules
-
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
- order-in-components - Organize your components (more)
- order-in-models - Organize your models (more)
- order-in-routes - Organize your routes (more)
- order-in-controllers - Organize your controllers (more)
-
Controllers
- alias-model-in-controller - Alias your model (more)
- query-params-on-top - Query params should always be on top (more)
-
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:
netguru-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
All Rules in JSON
"netguru-ember/alias-model-in-controller": 0,
"netguru-ember/avoid-leaking-state-in-components": 0,
"netguru-ember/closure-actions": 0,
"netguru-ember/jquery-ember-run": 0,
"netguru-ember/local-modules": 0,
"netguru-ember/named-functions-in-promises": 0,
"netguru-ember/no-empty-attrs": 0,
"netguru-ember/no-function-prototype-extensions": 0,
"netguru-ember/no-observers": 0,
"netguru-ember/no-on-calls-in-components": 0,
"netguru-ember/no-side-effects": 0,
"netguru-ember/order-in-components": 0,
"netguru-ember/order-in-controllers": 0,
"netguru-ember/order-in-models": 0,
"netguru-ember/order-in-routes": 0,
"netguru-ember/query-params-on-top": 0,
"netguru-ember/routes-segments-snake-case": 0,
"netguru-ember/use-brace-expansion": 0,
"netguru-ember/use-ember-get-and-set": 0,
Contribution guide
TBD. For now feel free to add any suggestions in issues. Any involvement highly appreciated.