[go: up one dir, main page]

Skip to content

Turbo87/eslint-plugin-ember

 
 

Repository files navigation

eslint-plugin-ember

NPM version NPM downloads Build Status

An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.

❗️ Requirements

ESLint is required to use this plugin.

🚀 Usage

1. Install plugin

  npm install --save-dev eslint-plugin-ember

2. Modify your .eslintrc.js:

Use with predefined settings:

// .eslintrc.js
module.exports = {
  extends: [
    'eslint:recommended',
    'plugin:ember/recommended'
  ],
  rules: {
    // override rules' settings here
  }
}

Possible configurations:

Use plain plugin:

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/

🍟 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:

      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

"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,

🍻 Contribution guide

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 in docs/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.

⭐️ Contributors

🙌 Credits

🔓 License

See the LICENSE file for license rights and limitations (MIT).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%