You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+8-16Lines changed: 8 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,26 +2,22 @@
2
2
3
3
👍🎉 First off, thanks for taking the time to contribute! 🎉👍
4
4
5
-
6
5
## Reporting bugs
7
6
8
7
To report a bug, [open an issue][new-issue].
9
8
10
9
If you are unsure whether something is a bug or not, please [open an issue][new-issue]. Insufficient documentation is also a bug.
11
10
12
-
13
11
## Suggesting new features
14
12
15
13
New features can be a new rule, anew option for an existing rule, or new functionality for existing rules.
16
14
17
15
To suggest a new feature, [open an issue][new-issue].
18
16
19
-
20
17
## Making pull requests
21
18
22
19
(If this is your first pull request on GitHub, checkout [this guide](https://github.com/firstcontributions/first-contributions).)
23
20
24
-
25
21
### Getting started
26
22
27
23
- This is a TypeScript project. You need to have a recentish version of [Node.js](https://nodejs.org/) and npm installed.
@@ -30,12 +26,11 @@ To suggest a new feature, [open an issue][new-issue].
30
26
31
27
We use [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/) to lint and format our code base. They will be automatically installed as dependencies but you might need additional editor plugins for a good IDE experience. We recommend using [VSCode](https://code.visualstudio.com/) together with the [ESLint plugin](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) for a great editing experience.
32
28
33
-
34
29
### Creating a new rule
35
30
36
31
The following steps will walk you through the process of creating a new rule.
37
32
38
-
1.Run `npm run new <rule-name>`:
33
+
1. Run `npm run new <rule-name>`:
39
34
40
35
This will automatically create 3 files:
41
36
@@ -45,33 +40,32 @@ The following steps will walk you through the process of creating a new rule.
45
40
46
41
These 3 files contain all the information about your new rule. You only need to touch these 3 files to add your rule.
47
42
48
-
1.Add meta information:
43
+
1. Add meta information:
49
44
50
45
Fill in the rule's meta information in the `meta` object. This includes a short description, its category, type, and more.
51
46
52
47
Note: Do not set `recommended: true`. This will add your rule to the `regex/recommended` configuration. We view additions to the `regex/recommended` configuration as breaking changes. If you want your rule to be included in the `regex/recommended` configuration in the next major release, leave the generated TODO comment as is.
53
48
54
49
Once you added a short description and the category, run `npm run update`. This will update a few generated files to include your rule in the website and more.
55
50
56
-
1.Implement your rule:
51
+
1. Implement your rule:
57
52
58
53
The `createVisitor` function will be where you implement your rule. The `regexpContext` object contains information and methods that you will need for static analysis, reporting, and fixing. Use `messageId`s for report and suggestion messages.
59
54
60
55
The [`no-empty-capturing-group`](./lib/rules/no-empty-capturing-group.ts) and [`no-octal`](./lib/rules/no-octal.ts) rules are good examples to see how we usually implement rules.
61
56
62
-
1.Test your rule:
57
+
1. Test your rule:
63
58
64
59
Add test for every feature and option of your rule. (We use [ESLint's `RuleTester`](https://eslint.org/docs/developer-guide/nodejs-api#ruletester) for testing rules.)
65
60
66
61
Use `npm test` to run all tests.
67
62
68
-
1.Document your rule:
63
+
1. Document your rule:
69
64
70
65
The documentation should contain a description of the rule and the problem it detects/solves, examples, all features, all options, and any additional information relevant to the rule.
71
66
72
67
You can view the documentation live in your browser by running `npm run docs:watch`. The live view will automatically update when you make changes to the documentation. However, you have to re-load the browser to see changes to the rule implementation.
73
68
74
-
75
69
### Updating documentation
76
70
77
71
Almost all Markdown files of our website and the project `README.md` are partially or completely generated.
@@ -93,24 +87,23 @@ After you changed the documentation, run `npm run update` to update all generate
93
87
94
88
You can view changes to the website locally by running `npm run docs:watch`.
95
89
96
-
97
90
### Testing
98
91
99
92
Aside from `npm test`, there are also a few other ways to manually test new features, changes, and new rules.
100
93
101
-
1.`npm run docs:watch`:
94
+
1.`npm run docs:watch`:
102
95
103
96
The documentation page of each rule includes interactive examples. You can also use your local version of [the playground](https://ota-meshi.github.io/eslint-plugin-regexp/playground/) to for testing.
104
97
105
-
1.Test your rule and the whole plugin by installing it.
98
+
1. Test your rule and the whole plugin by installing it.
106
99
107
100
If there is a project/code base you want to test your rule/the entire plugin on, then installing this project will be the right solution.
108
101
109
102
[Setup ESLint](https://eslint.org/docs/user-guide/getting-started) in the target project. Instead of installing the `eslint-plugin-regexp` from the npm registry, install your local `eslint-plugin-regexp` project using the relative path to the project.
110
103
111
104
Example:
112
105
113
-
```
106
+
```plaintext
114
107
projects/
115
108
├── target/
116
109
| └── package.json
@@ -124,7 +117,6 @@ Aside from `npm test`, there are also a few other ways to manually test new feat
124
117
125
118
Note: If you make changes to the implementation of a rule, you'll have to run `npm run build` before these changes show up in the target project.
Copy file name to clipboardExpand all lines: docs/rules/index.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,10 @@ sidebarDepth: 0
4
4
5
5
# Available Rules
6
6
7
-
The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) automatically fixes problems reported by rules which have a wrench :wrench: below.
7
+
The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) automatically fixes problems reported by rules which have a wrench :wrench: below.\
8
8
The rules with the following star :star: are included in the `plugin:regexp/recommended` config.
9
9
10
+
<!-- markdownlint-disable heading-increment -->
10
11
<!-- This file is automatically generated in tools/update-docs-rules-index.js, do not change! -->
Copy file name to clipboardExpand all lines: docs/rules/no-contradiction-with-assertion.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,6 @@ This rule reports elements that contradict an assertion. All elements reported b
45
45
46
46
This rule is quite similar to [regexp/no-useless-assertions]. While [regexp/no-useless-assertions] tries to find assertions that contradict the pattern, this rule tries to find parts of the pattern that contradict assertions.
0 commit comments