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-16
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-1
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
-1
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.
Copy file name to clipboardexpand all lines: docs/rules/no-empty-lookarounds-assertion.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -21,10 +21,10 @@ An empty lookaround is a lookaround for which at least one path in the lookaroun
21
21
22
22
**Examples:**
23
23
24
-
-`(?=)`: One of simplest empty lookarounds.
25
-
-`(?=a*)`: It is possible for `a*` to not consume characters, therefore the lookahead is _empty_.
26
-
-`(?=a|b*)`: Only one path has to not consume characters. Since it is possible for `b*` to not consume characters, the lookahead is _empty_.
27
-
-`(?=a|$)`: This is **not** an empty lookaround. `$` does not _consume_ characters but it does _assert_ characters. Similarly, all other standard assertions (`\b`, `\B`, `^`) are also not empty.
24
+
-`(?=)`: One of simplest empty lookarounds.
25
+
-`(?=a*)`: It is possible for `a*` to not consume characters, therefore the lookahead is _empty_.
26
+
-`(?=a|b*)`: Only one path has to not consume characters. Since it is possible for `b*` to not consume characters, the lookahead is _empty_.
27
+
-`(?=a|$)`: This is **not** an empty lookaround. `$` does not _consume_ characters but it does _assert_ characters. Similarly, all other standard assertions (`\b`, `\B`, `^`) are also not empty.
Copy file name to clipboardexpand all lines: docs/rules/no-escape-backspace.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ since: "v0.1.0"
13
13
14
14
## :book: Rule Details
15
15
16
-
This rule reports `[\b]`.
16
+
This rule reports `[\b]`.\
17
17
The word boundaries (`\b`) and the escape backspace (`[\b]`) are indistinguishable at a glance. This rule does not allow backspace (`[\b]`). Use unicode escapes (`\u0008`) instead.
Copy file name to clipboardexpand all lines: docs/rules/no-missing-g-flag.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ var newText = text.replaceAll(/Dog/i, 'cat');
48
48
}
49
49
```
50
50
51
-
-`strictTypes` ... If `true`, strictly check the type of object to determine if the regex instance was used in `matchAll()` and `replaceAll()`. Default is `true`.
51
+
-`strictTypes` ... If `true`, strictly check the type of object to determine if the regex instance was used in `matchAll()` and `replaceAll()`. Default is `true`.\
Copy file name to clipboardexpand all lines: docs/rules/no-super-linear-move.md
+1-3
Original file line number
Diff line number
Diff line change
@@ -149,7 +149,6 @@ This rule implements a simple detection method. It is unable to find certain cas
149
149
150
150
This means that this rule might not be able to verify fixed regexes. This rule might be unable to detect that supposedly fixed regexes are actually still vulnerable.
151
151
152
-
153
152
## :wrench: Options
154
153
155
154
```json
@@ -179,7 +178,7 @@ This option determines whether this rule will ignore regexes with sticky (`y`) f
179
178
180
179
All regexes will be analysed.
181
180
182
-
### `ignorePartial: boolean`:
181
+
### `ignorePartial: boolean`
183
182
184
183
Some regexes are used as fragments to build more complex regexes. Example:
185
184
@@ -198,7 +197,6 @@ Even if a fragment had exploitable quantifiers, it might not cause super-linear
198
197
199
198
The rule checks all regexes regardless of how they are used.
200
199
201
-
202
200
## :books: Further reading
203
201
204
202
-[Regular expression Denial of Service - ReDoS][1]
Copy file name to clipboardexpand all lines: docs/rules/no-useless-flag.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,7 @@ No other flags will be checked.
166
166
```
167
167
168
168
-`ignore` ... An array of flags to ignore from the check.
169
-
-`strictTypes` ... If `true`, strictly check the type of object to determine if the regex instance was used in `search()` and `split()`. Default is `true`. This option is only effective for verifying the `g` and `y` flags.
169
+
-`strictTypes` ... If `true`, strictly check the type of object to determine if the regex instance was used in `search()` and `split()`. Default is `true`. This option is only effective for verifying the `g` and `y` flags.\
0 commit comments