Skip to content

Commit 0fb820d

Browse files
Merge pull request #209 from MikeMcC399/docs/contributor
docs: rework contributor instructions
2 parents a980b1f + ead38bb commit 0fb820d

File tree

1 file changed

+45
-11
lines changed

1 file changed

+45
-11
lines changed

CONTRIBUTING.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,49 @@
22

33
Thanks for taking the time to contribute! :smile:
44

5+
## Preparation
6+
7+
* Fork and clone this repository
8+
* Branch from the default `master` branch using a descriptive new branch name
9+
* Install dependencies with `npm ci`
10+
11+
## Rule references
12+
13+
* Refer to the [ESLint documentation](https://eslint.org/docs/latest/) and the [Custom Rules](https://eslint.org/docs/latest/extend/custom-rules) page
14+
15+
## New rule
16+
517
To add a new rule:
6-
* Fork and clone this repository
7-
* Generate a new rule (a [yeoman generator](https://github.com/eslint/generator-eslint) is available)
8-
* Write test scenarios then implement logic
9-
* Describe the rule in the generated `docs` file
10-
* Run `npm test` to run [Jest](https://jestjs.io/) or
11-
* Run `npm start` to run [Jest](https://jestjs.io/) in [watchAll](https://jestjs.io/docs/cli#--watchall) mode where it remains active and reruns when source changes are made
12-
* Make sure all tests are passing
13-
* Add the rule to the [README](README.md) file
14-
* Create a PR
15-
16-
Use the following commit message conventions: https://github.com/semantic-release/semantic-release#commit-message-format
18+
19+
* Follow the instructions in the ESLint [generator-eslint](https://www.npmjs.com/package/generator-eslint) documentation to install [Yeoman](https://www.npmjs.com/package/yo) and the generator
20+
* Run the new rule generator `yo eslint:rule` and answer the questions
21+
- select "ESLint Plugin"
22+
- for "Type a short description of this rule" provide text which starts with one of "enforce", "require" or "disallow" (all lower case)
23+
* Yeoman creates three boilerplate files:
24+
- `docs/rules/<rule-id>.md`
25+
- `lib/rules/<rule-id>.js`
26+
- `test/rules/<rule-id>.js`
27+
* Run `npm run lint-fix`
28+
* Address the linting errors by editing `lib/rules/<rule-id>.js`
29+
- Add a `meta.messages` property (see [MessageIds](https://eslint.org/docs/latest/extend/custom-rules#messageids))
30+
- Select the appropriate `meta.type` property using `problem`, `suggestion`, or `layout`
31+
* Complete the new rule by adding content to the three files previously created
32+
* Run `eslint-doc-generator` to generate automated documentation sections (see [Document generation](#document-generation) below)
33+
* Review documentation changes
34+
* Run `npm run lint`
35+
* Run `npm test` to run [Jest](https://jestjs.io/) (or run `npm start` to run [Jest](https://jestjs.io/) in [watchAll](https://jestjs.io/docs/cli#--watchall) mode where it remains active and reruns when source changes are made)
36+
* Make sure all tests are passing
37+
* Add the rule to [index.js](https://github.com/cypress-io/eslint-plugin-cypress/blob/master/index.js)
38+
* Create a git commit with a commit message similar to: `feat: add rule <description>` (see [commit message conventions](https://github.com/semantic-release/semantic-release#commit-message-format))
39+
* Create a PR from your branch
40+
41+
## Document generation
42+
43+
This plugin uses the ESLint [eslint-doc-generator](https://www.npmjs.com/package/eslint-doc-generator) to generate consistent documentation.
44+
* Install with `npm install eslint-doc-generator -g`
45+
* Run `eslint-doc-generator` in the root directory of the plugin
46+
47+
## Legacy tests
48+
49+
* The directory [tests-legacy](https://github.com/cypress-io/eslint-plugin-cypress/tree/master/tests-legacy) contains tests which are compatible with the legacy [ESLint v8 RuleTester](https://eslint.org/docs/v8.x/integrate/nodejs-api#ruletester) utility. It is not expected to add new rules to this set of tests.
50+
* The directory [tests](https://github.com/cypress-io/eslint-plugin-cypress/tree/master/tests) is for tests compatible with the current [ESLint RuleTester](https://eslint.org/docs/latest/integrate/nodejs-api#ruletester).

0 commit comments

Comments
 (0)