Skip to content

Commit c501be4

Browse files
authored
Update docs/user-guide/README.md (#195)
* Update docs/user-guide/README.md * update
1 parent 2a85fc0 commit c501be4

File tree

3 files changed

+55
-17
lines changed

3 files changed

+55
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ and either use the recommended configuration or configure the rules you want:
5050

5151
### The recommended configuration
5252

53-
The `regexp/recommended` config enables a subset of [the core rules](#white_check_mark-rules) that should be most useful to most users.
54-
*See https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/recommended.ts for more details.*
53+
The `plugin:regexp/recommended` config enables a subset of [the rules](#white_check_mark-rules) that should be most useful to most users.
54+
*See [https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/recommended.ts](https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/recommended.ts) for more details.*
5555

5656
```js
5757
// .eslintrc.js

docs/user-guide/README.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,48 @@ npm install --save-dev eslint eslint-plugin-regexp
1515

1616
## :book: Usage
1717

18-
### Configuration
18+
<!--USAGE_SECTION_START-->
1919

20-
Use `.eslintrc.*` file to configure rules. See also: [https://eslint.org/docs/user-guide/configuring](https://eslint.org/docs/user-guide/configuring).
20+
Add `regexp` to the plugins section of your `.eslintrc` configuration file (you can omit the `eslint-plugin-` prefix)
21+
and either use the recommended configuration or configure the rules you want:
2122

22-
Example **.eslintrc.js**:
23+
### The recommended configuration
24+
25+
The `plugin:regexp/recommended` config enables a subset of [the rules](../rules/README.md) that should be most useful to most users.
26+
*See [https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/recommended.ts](https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/recommended.ts) for more details.*
2327

2428
```js
29+
// .eslintrc.js
2530
module.exports = {
26-
extends: [
27-
// add more generic rulesets here, such as:
28-
// 'eslint:recommended',
29-
'plugin:regexp/recommended'
30-
],
31-
rules: {
32-
// override/add rules settings here, such as:
33-
// 'regexp/no-dupe-characters-character-class': 'error'
34-
}
31+
"plugins": [
32+
"regexp"
33+
],
34+
"extends": [
35+
// add more generic rulesets here, such as:
36+
// 'eslint:recommended',
37+
"plugin:regexp/recommended"
38+
]
3539
}
3640
```
3741

38-
This plugin provides one config:
42+
### Advanced Configuration
43+
44+
Override/add specific rules configurations. *See also: [http://eslint.org/docs/user-guide/configuring](http://eslint.org/docs/user-guide/configuring)*.
45+
46+
```js
47+
// .eslintrc.js
48+
module.exports = {
49+
"plugins": [
50+
"regexp"
51+
],
52+
"rules": {
53+
// Override/add rules settings here, such as:
54+
"regexp/rule-name": "error"
55+
}
56+
}
57+
```
3958

40-
- `plugin:regexp/recommended` ... This is the recommended configuration for this plugin.
41-
See [lib/configs/recommended.ts](https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/recommended.ts) for details.
59+
<!--USAGE_SECTION_END-->
4260

4361
See [the rule list](../rules/README.md) to get the `rules` that this plugin provides.
4462

tools/update-readme.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,23 @@ fs.writeFileSync(
5252
)
5353
.replace(/\n{3,}/gu, "\n\n"),
5454
)
55+
56+
const userGuideReadmeFilePath = path.resolve(
57+
__dirname,
58+
"../docs/user-guide/README.md",
59+
)
60+
const newUserGuideReadme = fs
61+
.readFileSync(userGuideReadmeFilePath, "utf8")
62+
.replace(
63+
/<!--USAGE_SECTION_START-->[\s\S]*<!--USAGE_SECTION_END-->/u,
64+
/<!--USAGE_SECTION_START-->[\s\S]*<!--USAGE_SECTION_END-->/u.exec(
65+
newReadme,
66+
)![0],
67+
)
68+
69+
fs.writeFileSync(
70+
userGuideReadmeFilePath,
71+
newUserGuideReadme
72+
.replace(/\(#white_check_mark-rules\)/g, "(../rules/README.md)")
73+
.replace(/\n{3,}/gu, "\n\n"),
74+
)

0 commit comments

Comments
 (0)