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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CHANGELOG.md
2+
LICENSE
3+
node_modules

CONTRIBUTING.md

Lines changed: 8 additions & 16 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

0 commit comments

Comments
 (0)