Skip to content

Commit c87db44

Browse files
authored
Docs: Add markdownlint and convert trailing spaces for newlines backslashes (#494)
1 parent 81dda6d commit c87db44

37 files changed

+1678
-89
lines changed

.devcontainer/devcontainer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
88
// Append -bullseye or -buster to pin to an OS version.
99
// Use -bullseye variants on local on arm64/Apple Silicon.
10-
"args": {
10+
"args": {
1111
"VARIANT": "14"
1212
}
1313
},
@@ -29,4 +29,4 @@
2929

3030
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
3131
"remoteUser": "node"
32-
}
32+
}

.markdownlint.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"line-length": false,
3+
"no-inline-html": false,
4+
"single-title": false
5+
}

.markdownlintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CHANGELOG.md
2+
LICENSE
3+
node_modules

CONTRIBUTING.md

+8-16
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,22 @@
22

33
👍🎉 First off, thanks for taking the time to contribute! 🎉👍
44

5-
65
## Reporting bugs
76

87
To report a bug, [open an issue][new-issue].
98

109
If you are unsure whether something is a bug or not, please [open an issue][new-issue]. Insufficient documentation is also a bug.
1110

12-
1311
## Suggesting new features
1412

1513
New features can be a new rule, anew option for an existing rule, or new functionality for existing rules.
1614

1715
To suggest a new feature, [open an issue][new-issue].
1816

19-
2017
## Making pull requests
2118

2219
(If this is your first pull request on GitHub, checkout [this guide](https://github.com/firstcontributions/first-contributions).)
2320

24-
2521
### Getting started
2622

2723
- 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].
3026

3127
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.
3228

33-
3429
### Creating a new rule
3530

3631
The following steps will walk you through the process of creating a new rule.
3732

38-
1. Run `npm run new <rule-name>`:
33+
1. Run `npm run new <rule-name>`:
3934

4035
This will automatically create 3 files:
4136

@@ -45,33 +40,32 @@ The following steps will walk you through the process of creating a new rule.
4540

4641
These 3 files contain all the information about your new rule. You only need to touch these 3 files to add your rule.
4742

48-
1. Add meta information:
43+
1. Add meta information:
4944

5045
Fill in the rule's meta information in the `meta` object. This includes a short description, its category, type, and more.
5146

5247
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.
5348

5449
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.
5550

56-
1. Implement your rule:
51+
1. Implement your rule:
5752

5853
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.
5954

6055
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.
6156

62-
1. Test your rule:
57+
1. Test your rule:
6358

6459
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.)
6560

6661
Use `npm test` to run all tests.
6762

68-
1. Document your rule:
63+
1. Document your rule:
6964

7065
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.
7166

7267
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.
7368

74-
7569
### Updating documentation
7670

7771
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
9387

9488
You can view changes to the website locally by running `npm run docs:watch`.
9589

96-
9790
### Testing
9891

9992
Aside from `npm test`, there are also a few other ways to manually test new features, changes, and new rules.
10093

101-
1. `npm run docs:watch`:
94+
1. `npm run docs:watch`:
10295

10396
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.
10497

105-
1. Test your rule and the whole plugin by installing it.
98+
1. Test your rule and the whole plugin by installing it.
10699

107100
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.
108101

109102
[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.
110103

111104
Example:
112105

113-
```
106+
```plaintext
114107
projects/
115108
├── target/
116109
| └── package.json
@@ -124,7 +117,6 @@ Aside from `npm test`, there are also a few other ways to manually test new feat
124117
125118
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.
126119
127-
128120
<!-- Important links -->
129121
130122
[new-issue]: https://github.com/ota-meshi/eslint-plugin-regexp/issues/new/choose

docs/rules/confusing-quantifier.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Nothing.
4444

4545
## :heart: Compatibility
4646

47-
This rule was taken from [eslint-plugin-clean-regex].
47+
This rule was taken from [eslint-plugin-clean-regex].\
4848
This rule is compatible with [clean-regex/confusing-quantifier] rule.
4949

5050
[eslint-plugin-clean-regex]: https://github.com/RunDevelopment/eslint-plugin-clean-regex

docs/rules/control-character-escape.md

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ This rule reports control characters that were not escaped using a control escap
1818

1919
<eslint-code-block fix>
2020

21+
<!-- markdownlint-disable no-hard-tabs -->
22+
2123
```js
2224
/* eslint regexp/control-character-escape: "error" */
2325

@@ -33,6 +35,8 @@ var foo = /\u{a}/u;
3335
var foo = RegExp("\\u000a");
3436
```
3537

38+
<!-- markdownlint-enable no-hard-tabs -->
39+
3640
</eslint-code-block>
3741

3842
## :wrench: Options

docs/rules/hexadecimal-escape.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var foo = /\u{a}/u;
3737
```json5
3838
{
3939
"regexp/hexadecimal-escape": [
40-
"error",
40+
"error",
4141
"always", // or "never"
4242
]
4343
}

docs/rules/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ sidebarDepth: 0
44

55
# Available Rules
66

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.\
88
The rules with the following star :star: are included in the `plugin:regexp/recommended` config.
99

10+
<!-- markdownlint-disable heading-increment -->
1011
<!-- This file is automatically generated in tools/update-docs-rules-index.js, do not change! -->
1112

1213
### Possible Errors

docs/rules/match-any.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ since: "v0.1.0"
1414

1515
## :book: Rule Details
1616

17-
This rule enforces the regular expression notation to match any character.
17+
This rule enforces the regular expression notation to match any character.\
1818
e.g. `[\s\S]`, `[^]`, `/./s` (dotAll) and more.
1919

2020
<eslint-code-block fix>
@@ -45,7 +45,7 @@ var foo = /[\w\W]/;
4545
}
4646
```
4747

48-
- `"allows"` ... An array of notations that any characters that are allowed.
48+
- `"allows"` ... An array of notations that any characters that are allowed.\
4949
`"[\\s\\S]"`, `"[\\S\\s]"`, `"[^]"` and `"dotAll"` can be set.
5050

5151
### `{ "allows": ["[^]"] }`

docs/rules/no-contradiction-with-assertion.md

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ This rule reports elements that contradict an assertion. All elements reported b
4545

4646
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.
4747

48-
4948
<eslint-code-block>
5049

5150
```js

docs/rules/no-empty-alternative.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ Nothing.
4040

4141
## :heart: Compatibility
4242

43-
This rule was taken from [eslint-plugin-clean-regex].
43+
This rule was taken from [eslint-plugin-clean-regex].\
4444
This rule is compatible with [clean-regex/no-empty-alternative] rule.
4545

4646
[eslint-plugin-clean-regex]: https://github.com/RunDevelopment/eslint-plugin-clean-regex
4747
[clean-regex/no-empty-alternative]: https://github.com/RunDevelopment/eslint-plugin-clean-regex/blob/master/docs/rules/no-empty-alternative.md
4848

49-
5049
## :rocket: Version
5150

5251
This rule was introduced in eslint-plugin-regexp v0.8.0

docs/rules/no-empty-lookarounds-assertion.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ An empty lookaround is a lookaround for which at least one path in the lookaroun
2121

2222
**Examples:**
2323

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.
2828

2929
### Why are empty lookarounds a problem?
3030

docs/rules/no-escape-backspace.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ since: "v0.1.0"
1313

1414
## :book: Rule Details
1515

16-
This rule reports `[\b]`.
16+
This rule reports `[\b]`.\
1717
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.
1818

1919
<eslint-code-block>

docs/rules/no-invisible-character.md

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ This rule disallows using invisible characters other than SPACE (`U+0020`) witho
1818

1919
<eslint-code-block fix>
2020

21+
<!-- markdownlint-disable no-hard-tabs -->
22+
2123
```js
2224
/* eslint regexp/no-invisible-character: "error" */
2325

@@ -35,6 +37,8 @@ var foo = / /;
3537
var foo = / /;
3638
```
3739

40+
<!-- markdownlint-enable no-hard-tabs -->
41+
3842
</eslint-code-block>
3943

4044
## :wrench: Options

docs/rules/no-lazy-ends.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ var foo = /a(?:c|ab+?)?/.test(str)
110110

111111
## :heart: Compatibility
112112

113-
This rule was taken from [eslint-plugin-clean-regex].
113+
This rule was taken from [eslint-plugin-clean-regex].\
114114
This rule is compatible with [clean-regex/no-lazy-ends] rule.
115115

116116
[eslint-plugin-clean-regex]: https://github.com/RunDevelopment/eslint-plugin-clean-regex

docs/rules/no-legacy-features.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ regexObj.compile('new foo', 'g');
6060
"rightContext", "$'",
6161
"$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9"
6262
],
63-
"prototypeMethods": ["compile"]
63+
"prototypeMethods": ["compile"]
6464
}]
6565
}
6666
```

docs/rules/no-missing-g-flag.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var newText = text.replaceAll(/Dog/i, 'cat');
4848
}
4949
```
5050

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`.\
5252
This option is always on when using TypeScript.
5353

5454
## :books: Further reading

docs/rules/no-obscure-range.md

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var foo = /[😀-😄]/u;
4141

4242
## :wrench: Options
4343

44-
4544
```json5
4645
{
4746
"regexp/no-obscure-range": ["error",

docs/rules/no-optional-assertion.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Nothing.
4646

4747
## :heart: Compatibility
4848

49-
This rule was taken from [eslint-plugin-clean-regex].
49+
This rule was taken from [eslint-plugin-clean-regex].\
5050
This rule is compatible with [clean-regex/no-optional-assertion] rule.
5151

5252
[eslint-plugin-clean-regex]: https://github.com/RunDevelopment/eslint-plugin-clean-regex

docs/rules/no-potentially-useless-backreference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Nothing.
4747

4848
## :heart: Compatibility
4949

50-
This rule was taken from [eslint-plugin-clean-regex].
50+
This rule was taken from [eslint-plugin-clean-regex].\
5151
This rule is compatible with [clean-regex/no-potentially-empty-backreference] rule.
5252

5353
[eslint-plugin-clean-regex]: https://github.com/RunDevelopment/eslint-plugin-clean-regex

docs/rules/no-super-linear-backtracking.md

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ The rule only implements a very simplistic detection method and can only detect
4444

4545
While the detection will improve in the future, this rule will never be able to perfectly detect all cases super-linear backtracking.
4646

47-
4847
## :wrench: Options
4948

5049
```json

docs/rules/no-super-linear-move.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ This rule implements a simple detection method. It is unable to find certain cas
149149

150150
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.
151151

152-
153152
## :wrench: Options
154153

155154
```json
@@ -179,7 +178,7 @@ This option determines whether this rule will ignore regexes with sticky (`y`) f
179178

180179
All regexes will be analysed.
181180

182-
### `ignorePartial: boolean`:
181+
### `ignorePartial: boolean`
183182

184183
Some regexes are used as fragments to build more complex regexes. Example:
185184

@@ -198,7 +197,6 @@ Even if a fragment had exploitable quantifiers, it might not cause super-linear
198197

199198
The rule checks all regexes regardless of how they are used.
200199

201-
202200
## :books: Further reading
203201

204202
- [Regular expression Denial of Service - ReDoS][1]

docs/rules/no-useless-assertions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Nothing.
4747

4848
## :heart: Compatibility
4949

50-
This rule was taken from [eslint-plugin-clean-regex].
50+
This rule was taken from [eslint-plugin-clean-regex].\
5151
This rule is compatible with [clean-regex/no-unnecessary-assertions] rule.
5252

5353
[eslint-plugin-clean-regex]: https://github.com/RunDevelopment/eslint-plugin-clean-regex

docs/rules/no-useless-escape.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ since: "v0.4.0"
1414

1515
## :book: Rule Details
1616

17-
This rule reports unnecessary escape characters in RegExp.
17+
This rule reports unnecessary escape characters in RegExp.\
1818
You may be able to find another mistake by finding unnecessary escapes.
1919

2020
<eslint-code-block fix>

docs/rules/no-useless-flag.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ No other flags will be checked.
166166
```
167167

168168
- `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.\
170170
This option is always on when using TypeScript.
171171

172172
### `"ignore": ["s", "g"]`

docs/rules/optimal-lookaround-quantifier.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Nothing.
6363

6464
## :heart: Compatibility
6565

66-
This rule was taken from [eslint-plugin-clean-regex].
66+
This rule was taken from [eslint-plugin-clean-regex].\
6767
This rule is compatible with [clean-regex/optimal-lookaround-quantifier] rule.
6868

6969
[eslint-plugin-clean-regex]: https://github.com/RunDevelopment/eslint-plugin-clean-regex

0 commit comments

Comments
 (0)