Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 2.04 KB

new-rule.md

File metadata and controls

23 lines (15 loc) · 2.04 KB

Creating a new rule

Prerequisite

Tip

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.

Steps

  • Go to the test directory and duplicate the no-hex-escape.js file and rename it to the name of your rule. Then write some tests before starting to implement the rule.
  • Go to the rules directory and duplicate the no-hex-escape.js file and rename it to the name of your rule. Then start implementing the new rule logic.
  • Go to the docs/rules directory and duplicate the no-hex-escape.md file and rename it to the name of your rule. Then write some documentation.
  • Add the rule to the recommended config, the recommended config in the readme, and the rule listing in the readme (The description should be the same as the heading of the documentation file).
  • 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 like 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.