What is eslint-plugin-ember?
eslint-plugin-ember is an ESLint plugin that provides linting rules specific to Ember.js applications. It helps developers follow best practices and maintain consistency in their Ember.js codebase.
What are eslint-plugin-ember's main functionalities?
Best Practices
This rule enforces the best practice of avoiding the use of observers in Ember.js applications. Observers can lead to unpredictable behavior and are generally discouraged.
module.exports = {
rules: {
'ember/no-observers': 'error'
}
};
Stylistic Issues
This rule ensures that developers use Ember's `get` and `set` methods for property access and assignment, which is a stylistic convention in Ember.js.
module.exports = {
rules: {
'ember/use-ember-get-and-set': 'error'
}
};
Ember-Specific Rules
This rule disallows the use of jQuery in Ember.js applications, encouraging developers to use native DOM APIs or Ember's own abstractions.
module.exports = {
rules: {
'ember/no-jquery': 'error'
}
};
Other packages similar to eslint-plugin-ember
eslint-plugin-react
eslint-plugin-react provides linting rules for React applications. It helps enforce best practices and coding standards specific to React, similar to how eslint-plugin-ember does for Ember.js.
eslint-plugin-vue
eslint-plugin-vue offers linting rules for Vue.js applications. It ensures that Vue.js code adheres to best practices and stylistic conventions, much like eslint-plugin-ember does for Ember.js.
eslint-plugin-angular
eslint-plugin-angular provides linting rules for Angular applications. It helps maintain code quality and consistency in Angular projects, similar to the role of eslint-plugin-ember in Ember.js projects.
eslint-plugin-ember
An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
βοΈRequirements
π Usage
1. Install plugin
yarn add --dev eslint-plugin-ember
Or
npm install --save-dev eslint-plugin-ember
2. Modify your .eslintrc.js
module.exports = {
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
rules: {
'ember/no-jquery': 'error'
}
};
π§° Configurations
| 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. |
π Rules
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 - π‘ if some problems reported by the rule are manually fixable by editor suggestions
Components
Computed Properties
Controllers
Deprecations
Ember Data
Ember Object
Ember Octane
jQuery
Miscellaneous
Routes
Services
Stylistic Issues
Testing
For the simplified list of rules, go here.
π» Contribution Guide
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.
Creating a New Rule
- 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.
π License
See the LICENSE file for license rights and limitations (MIT).