3.0 KiB
3.0 KiB
Contributing to cypress-io/eslint-plugin-cypress
Thanks for taking the time to contribute! 😄
Preparation
- Fork and clone this repository
- Branch from the default
masterbranch using a descriptive new branch name - Install dependencies with
npm ci
Rule references
- Refer to the ESLint documentation and the Custom Rules page
New rule
To add a new rule:
- Follow the instructions in the ESLint generator-eslint documentation to install Yeoman and the generator
- Run the new rule generator
yo eslint:ruleand answer the questions- select "ESLint Plugin"
- for "Type a short description of this rule" provide text which starts with one of "enforce", "require" or "disallow" (all lower case)
- Yeoman creates three boilerplate files:
docs/rules/<rule-id>.mdlib/rules/<rule-id>.jstest/rules/<rule-id>.js
- Run
npm run lint-fix - Address the linting errors by editing
lib/rules/<rule-id>.js- Add a
meta.messagesproperty (see MessageIds) - Select the appropriate
meta.typeproperty usingproblem,suggestion, orlayout
- Add a
- Complete the new rule by adding content to the three files previously created
- Run
eslint-doc-generatorto generate automated documentation sections (see Document generation below) - Review documentation changes
- Run
npm run lint - Run
npm testto run Jest (or runnpm startto run Jest in watchAll mode where it remains active and reruns when source changes are made) - Make sure all tests are passing
- Add the rule to legacy.js and to flat.js
- Create a git commit with a commit message similar to:
feat: add rule <description>(see commit message conventions) - Create a PR from your branch
Document generation
This plugin uses the ESLint eslint-doc-generator to generate consistent documentation.
- Install with
npm install eslint-doc-generator -g - Run
eslint-doc-generatorin the root directory of the plugin
Legacy tests
- The directory tests-legacy contains tests which are compatible with the legacy ESLint v8 RuleTester utility. It is not expected to add new rules to this set of tests.
- The directory tests is for tests compatible with the current ESLint RuleTester.