- Ensure ESLint doesn't already have the rule built-in.
- Read the ESLint docs on creating a new rule.
- Look at the commit for how previous rules were added as inspiration. For example, the
no-unused-properties
rule.
Use the astexplorer
site with the espree
parser and ESLint v4
transform to interactively create the initial rule implementation. It lets you inspect the full AST as you would get from ESLint and you can even see the result of your auto-fixer implementation.
- Run
$ npm run create-rule
to create files for the new rule. - Open “test/{RULE_ID}.mjs” and write some tests before implementing the rule.
- Open “rules/{RULE_ID}.js” and implement the rule logic.
- Add the correct
meta.type
to the rule. - Open “docs/rules/{RULE_ID}.js” and write some documentation.
- Double check
configs/recommended.js
andreadme.md
, make sure the new rule is correctly added. - Run
$ npm test
to ensure the tests pass. - Run
$ npm run integration
to run the rules against real projects to ensure your rule does not fail on real-world code. - Open a pull request with a title in exactly the format
Add `rule-name` rule
, for example,Add `no-unused-properties` rule
. - The pull request description should include the issue it fixes, for example,
Fixes #123
. - Run
$ npm run run-rules-on-codebase
to run the rules against codebase to ensure code in the repository are following your rule, you can ignore this step until your PR is reviewed.