Skip to content

Commit 015c207

Browse files
chore: postprocess with prettier in eslint-doc-generator (#435)
1 parent d7331ca commit 015c207

24 files changed

+169
-162
lines changed

Diff for: .eslint-doc-generatorrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const prettier = require('prettier');
4+
35
/** @type {import('eslint-doc-generator').GenerateOptions} */
46
module.exports = {
57
ignoreConfig: [
@@ -9,6 +11,11 @@ module.exports = {
911
'tests',
1012
'tests-recommended',
1113
],
14+
postprocess: async (content, path) =>
15+
prettier.format(content, {
16+
...(await prettier.resolveConfig(path)),
17+
parser: 'markdown',
18+
}),
1219
ruleDocSectionInclude: ['Rule Details'],
1320
ruleListSplit: 'meta.docs.category',
1421
urlConfigs:

Diff for: README.md

+73-76
Large diffs are not rendered by default.

Diff for: docs/rules/consistent-output.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ new RuleTester().run('example-rule', rule, {
6666

6767
This rule takes an optional string enum option with one of the following values:
6868

69-
* `"consistent"` - (default) if any invalid test cases have output assertions, then all invalid test cases must have output assertions
70-
* `"always"` - always require invalid test cases to have output assertions
69+
- `"consistent"` - (default) if any invalid test cases have output assertions, then all invalid test cases must have output assertions
70+
- `"always"` - always require invalid test cases to have output assertions
7171

7272
## When Not To Use It
7373

@@ -77,4 +77,4 @@ As mentioned in the introduction, the need for this rule is reduced as of ESLint
7777

7878
## Further Reading
7979

80-
* [`RuleTester` documentation](http://eslint.org/docs/developer-guide/working-with-plugins#testing)
80+
- [`RuleTester` documentation](http://eslint.org/docs/developer-guide/working-with-plugins#testing)

Diff for: docs/rules/meta-property-ordering.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This rule enforces that meta properties of a rule are placed in a consistent ord
1212

1313
This rule has an array option:
1414

15-
* `['type', 'docs', 'fixable', 'hasSuggestions', 'schema', 'messages', 'deprecated', 'replacedBy']` (default): The order that the properties of `meta` should be placed in.
15+
- `['type', 'docs', 'fixable', 'hasSuggestions', 'schema', 'messages', 'deprecated', 'replacedBy']` (default): The order that the properties of `meta` should be placed in.
1616

1717
Examples of **incorrect** code for this rule:
1818

Diff for: docs/rules/no-deprecated-context-methods.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ This rule disallows the use of deprecated methods on rule `context` objects.
1010

1111
The deprecated methods are:
1212

13-
* `getSource`
14-
* `getSourceLines`
15-
* `getAllComments`
16-
* `getNodeByRangeIndex`
17-
* `getComments`
18-
* `getCommentsBefore`
19-
* `getCommentsAfter`
20-
* `getCommentsInside`
21-
* `getJSDocComment`
22-
* `getFirstToken`
23-
* `getFirstTokens`
24-
* `getLastToken`
25-
* `getLastTokens`
26-
* `getTokenAfter`
27-
* `getTokenBefore`
28-
* `getTokenByRangeStart`
29-
* `getTokens`
30-
* `getTokensAfter`
31-
* `getTokensBefore`
32-
* `getTokensBetween`
13+
- `getSource`
14+
- `getSourceLines`
15+
- `getAllComments`
16+
- `getNodeByRangeIndex`
17+
- `getComments`
18+
- `getCommentsBefore`
19+
- `getCommentsAfter`
20+
- `getCommentsInside`
21+
- `getJSDocComment`
22+
- `getFirstToken`
23+
- `getFirstTokens`
24+
- `getLastToken`
25+
- `getLastTokens`
26+
- `getTokenAfter`
27+
- `getTokenBefore`
28+
- `getTokenByRangeStart`
29+
- `getTokens`
30+
- `getTokensAfter`
31+
- `getTokensBefore`
32+
- `getTokensBetween`
3333

3434
Instead of using these methods, you should use the equivalent methods on [`SourceCode`](https://eslint.org/docs/developer-guide/working-with-rules#contextgetsourcecode), e.g. `context.getSourceCode().getText()` instead of `context.getSource()`.
3535

@@ -71,4 +71,4 @@ If you need to support very old versions of ESLint where `SourceCode` doesn't ex
7171

7272
## Further Reading
7373

74-
* [`SourceCode` API](https://eslint.org/docs/developer-guide/working-with-rules#contextgetsourcecode)
74+
- [`SourceCode` API](https://eslint.org/docs/developer-guide/working-with-rules#contextgetsourcecode)

Diff for: docs/rules/no-deprecated-report-api.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
ESLint has two APIs that rules can use to report problems.
1010

11-
* The [deprecated API](http://eslint.org/docs/developer-guide/working-with-rules-deprecated) accepts multiple arguments: `context.report(node, [loc], message)`.
12-
* The ["new API"](http://eslint.org/docs/developer-guide/working-with-rules#contextreport) accepts a single argument: an object containing information about the reported problem.
11+
- The [deprecated API](http://eslint.org/docs/developer-guide/working-with-rules-deprecated) accepts multiple arguments: `context.report(node, [loc], message)`.
12+
- The ["new API"](http://eslint.org/docs/developer-guide/working-with-rules#contextreport) accepts a single argument: an object containing information about the reported problem.
1313

1414
It is recommended that all rules use the new API.
1515

@@ -41,5 +41,5 @@ module.exports = {
4141

4242
## Further Reading
4343

44-
* [Deprecated rule API](http://eslint.org/docs/developer-guide/working-with-rules-deprecated)
45-
* [New rule API](http://eslint.org/docs/developer-guide/working-with-rules)
44+
- [Deprecated rule API](http://eslint.org/docs/developer-guide/working-with-rules-deprecated)
45+
- [New rule API](http://eslint.org/docs/developer-guide/working-with-rules)

Diff for: docs/rules/no-missing-message-ids.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ module.exports = {
5858

5959
## Further Reading
6060

61-
* [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
62-
* [no-unused-message-ids](./no-unused-message-ids.md) rule
63-
* [prefer-message-ids](./prefer-message-ids.md) rule
61+
- [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
62+
- [no-unused-message-ids](./no-unused-message-ids.md) rule
63+
- [prefer-message-ids](./prefer-message-ids.md) rule

Diff for: docs/rules/no-missing-placeholders.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ If you want to use rule messages that actually contain double-curly bracket text
7474

7575
## Further Reading
7676

77-
* [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)
77+
- [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)

Diff for: docs/rules/no-unused-message-ids.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ module.exports = {
5959

6060
## Further Reading
6161

62-
* [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
63-
* [no-missing-message-ids](./no-missing-message-ids.md) rule
64-
* [prefer-message-ids](./prefer-message-ids.md) rule
62+
- [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
63+
- [no-missing-message-ids](./no-missing-message-ids.md) rule
64+
- [prefer-message-ids](./prefer-message-ids.md) rule

Diff for: docs/rules/no-unused-placeholders.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ If you want to allow unused placeholders, you should turn off this rule.
5757

5858
## Further Reading
5959

60-
* [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)
61-
* [no-missing-placeholders](https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-missing-placeholders.md)
60+
- [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)
61+
- [no-missing-placeholders](https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-missing-placeholders.md)

Diff for: docs/rules/no-useless-token-range.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ module.exports = {
4444

4545
## Known Limitations
4646

47-
* To ensure that your `SourceCode` instances can be detected, your rule must assign `context.getSourceCode()` to a variable somewhere.
47+
- To ensure that your `SourceCode` instances can be detected, your rule must assign `context.getSourceCode()` to a variable somewhere.
4848

4949
## Further Reading
5050

51-
* [`SourceCode` API](https://eslint.org/docs/developer-guide/working-with-rules#contextgetsourcecode)
51+
- [`SourceCode` API](https://eslint.org/docs/developer-guide/working-with-rules#contextgetsourcecode)

Diff for: docs/rules/prefer-message-ids.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
When reporting a rule violation, it's preferred to provide the violation message with the `messageId` property instead of the `message` property. Message IDs provide the following benefits:
88

9-
* Rule violation messages can be stored in a central `meta.messages` object for convenient management
10-
* Rule violation messages do not need to be repeated in both the rule file and rule test file
11-
* As a result, the barrier for changing rule violation messages is lower, encouraging more frequent contributions to improve and optimize them for the greatest clarity and usefulness
9+
- Rule violation messages can be stored in a central `meta.messages` object for convenient management
10+
- Rule violation messages do not need to be repeated in both the rule file and rule test file
11+
- As a result, the barrier for changing rule violation messages is lower, encouraging more frequent contributions to improve and optimize them for the greatest clarity and usefulness
1212

1313
## Rule Details
1414

@@ -59,6 +59,6 @@ module.exports = {
5959

6060
## Further Reading
6161

62-
* [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
63-
* [no-invalid-message-ids](./no-invalid-message-ids.md) rule
64-
* [no-missing-message-ids](./no-missing-message-ids.md) rule
62+
- [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
63+
- [no-invalid-message-ids](./no-invalid-message-ids.md) rule
64+
- [no-missing-message-ids](./no-missing-message-ids.md) rule

Diff for: docs/rules/prefer-object-rule.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ Examples of **correct** code for this rule:
3434
/* eslint eslint-plugin/prefer-object-rule: error */
3535

3636
module.exports = {
37-
meta: { /* ... */ },
37+
meta: {
38+
/* ... */
39+
},
3840
create(context) {
3941
return {
4042
Program() {

Diff for: docs/rules/prefer-placeholders.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ context.report({
1414

1515
Using placeholders is often preferred over using dynamic report messages, for a few reasons:
1616

17-
* They can help enforce a separation of the message and the data.
18-
* It will be easier to migrate when ESLint starts supporting placing lint messages in metadata (see [#6740](https://github.com/eslint/eslint/issues/6740))
17+
- They can help enforce a separation of the message and the data.
18+
- It will be easier to migrate when ESLint starts supporting placing lint messages in metadata (see [#6740](https://github.com/eslint/eslint/issues/6740))
1919

2020
## Rule Details
2121

@@ -63,4 +63,4 @@ If you need to use string concatenation in your report messages for some reason,
6363

6464
## Further Reading
6565

66-
* [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)
66+
- [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)

Diff for: docs/rules/prefer-replace-text.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ module.exports = {
5353

5454
## Further Reading
5555

56-
* [Applying Fixes](https://eslint.org/docs/developer-guide/working-with-rules#applying-fixes)
56+
- [Applying Fixes](https://eslint.org/docs/developer-guide/working-with-rules#applying-fixes)

Diff for: docs/rules/report-message-format.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ For example, in order to mandate that all report messages begin with a capital l
1616

1717
```json
1818
{
19-
"rules": {
20-
"eslint-plugin/report-message-format": ["error", "^[A-Z].*\\.$"]
21-
},
22-
"plugins": [
23-
"eslint-plugin"
24-
]
19+
"rules": {
20+
"eslint-plugin/report-message-format": ["error", "^[A-Z].*\\.$"]
21+
},
22+
"plugins": ["eslint-plugin"]
2523
}
2624
```
2725

28-
Note that since this rule uses static analysis and does not actually run your code, it will attempt to match report messages *before* placeholders are inserted.
26+
Note that since this rule uses static analysis and does not actually run your code, it will attempt to match report messages _before_ placeholders are inserted.
2927

3028
Examples of **incorrect** code for this rule:
3129

Diff for: docs/rules/require-meta-docs-description.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Defining a clear and consistent description for each rule helps developers under
66

77
In particular, each rule description should begin with an allowed prefix:
88

9-
* `enforce`
10-
* `require`
11-
* `disallow`
9+
- `enforce`
10+
- `require`
11+
- `disallow`
1212

1313
## Rule Details
1414

@@ -59,4 +59,4 @@ module.exports = {
5959

6060
## Further Reading
6161

62-
* [working-with-rules#options-schemas](https://eslint.org/docs/developer-guide/working-with-rules#options-schemas)
62+
- [working-with-rules#options-schemas](https://eslint.org/docs/developer-guide/working-with-rules#options-schemas)

Diff for: docs/rules/require-meta-docs-url.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ module.exports = {
8787

8888
```json
8989
{
90-
"eslint-plugin/require-meta-docs-url": ["error", {
91-
"pattern": "https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/master/docs/rules/{{name}}.md"
92-
}]
90+
"eslint-plugin/require-meta-docs-url": [
91+
"error",
92+
{
93+
"pattern": "https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/master/docs/rules/{{name}}.md"
94+
}
95+
]
9396
}
9497
```
9598

Diff for: docs/rules/require-meta-fixable.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,5 @@ module.exports = {
102102

103103
## Further Reading
104104

105-
* [ESLint's autofix API](http://eslint.org/docs/developer-guide/working-with-rules#applying-fixes)
106-
* [ESLint's rule basics mentioning `meta.fixable`](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)
105+
- [ESLint's autofix API](http://eslint.org/docs/developer-guide/working-with-rules#applying-fixes)
106+
- [ESLint's rule basics mentioning `meta.fixable`](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)

Diff for: docs/rules/require-meta-has-suggestions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ module.exports = {
8888

8989
## Further Reading
9090

91-
* [ESLint's suggestion API](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
92-
* [ESLint rule basics describing the `meta.hasSuggestions` property](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)
91+
- [ESLint's suggestion API](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
92+
- [ESLint rule basics describing the `meta.hasSuggestions` property](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)

Diff for: docs/rules/require-meta-schema.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ As mentioned in the introduction, the need for this rule is reduced as of ESLint
8989

9090
## Further Reading
9191

92-
* [working-with-rules#options-schemas](https://eslint.org/docs/developer-guide/working-with-rules#options-schemas)
92+
- [working-with-rules#options-schemas](https://eslint.org/docs/developer-guide/working-with-rules#options-schemas)

Diff for: docs/rules/require-meta-type.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Fixes in custom rules will not be applied when using `--fix-type` unless they in
1212

1313
This rule aims to require ESLint rules to have a valid `meta.type` property with one of the following values:
1414

15-
* `"problem"` means the rule is identifying code that either will cause an error or may cause a confusing behavior. Developers should consider this a high priority to resolve.
16-
* `"suggestion"` means the rule is identifying something that could be done in a better way but no errors will occur if the code isn't changed.
17-
* `"layout"` means the rule cares primarily about whitespace, semicolons, commas, and parentheses, all the parts of the program that determine how the code looks rather than how it executes. These rules work on parts of the code that aren't specified in the AST.
15+
- `"problem"` means the rule is identifying code that either will cause an error or may cause a confusing behavior. Developers should consider this a high priority to resolve.
16+
- `"suggestion"` means the rule is identifying something that could be done in a better way but no errors will occur if the code isn't changed.
17+
- `"layout"` means the rule cares primarily about whitespace, semicolons, commas, and parentheses, all the parts of the program that determine how the code looks rather than how it executes. These rules work on parts of the code that aren't specified in the AST.
1818

1919
Examples of **incorrect** code for this rule:
2020

@@ -51,6 +51,6 @@ module.exports = {
5151

5252
## Further Reading
5353

54-
* [command-line-interface#--fix-type](https://eslint.org/docs/user-guide/command-line-interface#--fix-type)
55-
* [working-with-rules#rule-basics](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)
56-
* [ESLint v5.9.0 released](https://eslint.org/blog/2018/11/eslint-v5.9.0-released#the-fix-type-option)
54+
- [command-line-interface#--fix-type](https://eslint.org/docs/user-guide/command-line-interface#--fix-type)
55+
- [working-with-rules#rule-basics](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)
56+
- [ESLint v5.9.0 released](https://eslint.org/blog/2018/11/eslint-v5.9.0-released#the-fix-type-option)

Diff for: docs/rules/test-case-property-ordering.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This rule enforces that the properties of RuleTester test cases are arranged in
1212

1313
This rule has an array option:
1414

15-
* `["code", "output", "options", "parserOptions", "errors"]` (default): The properties of a test case should be placed in a consistent order.
15+
- `["code", "output", "options", "parserOptions", "errors"]` (default): The properties of a test case should be placed in a consistent order.
1616

1717
Examples of **incorrect** code for this rule:
1818

Diff for: docs/rules/test-case-shorthand-strings.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ This rule aims to enforce or disallow the use of strings as test cases.
3333

3434
This rule has a string option:
3535

36-
* `as-needed` (default): Requires the use of shorthand strings wherever possible.
37-
* `never`: Disallows the use of shorthand strings.
38-
* `consistent`: Requires that either all valid test cases use shorthand strings, or that no valid test cases use them.
39-
* `consistent-as-needed`: Requires that all valid test cases use the longer object form if there are any valid test cases that require the object form. Otherwise, requires all valid test cases to use shorthand strings.
36+
- `as-needed` (default): Requires the use of shorthand strings wherever possible.
37+
- `never`: Disallows the use of shorthand strings.
38+
- `consistent`: Requires that either all valid test cases use shorthand strings, or that no valid test cases use them.
39+
- `consistent-as-needed`: Requires that all valid test cases use the longer object form if there are any valid test cases that require the object form. Otherwise, requires all valid test cases to use shorthand strings.
4040

4141
#### `as-needed`
4242

@@ -237,15 +237,15 @@ ruleTester.run('example-rule', rule, {
237237

238238
## Known Limitations
239239

240-
* Test cases which are neither object literals nor string literals are ignored by this rule.
241-
* In order to find your test cases, your test file needs to match the following common pattern:
242-
* `new RuleTester()` or `new (require('eslint')).RuleTester()` is called at the top level of the file
243-
* `ruleTester.run` is called at the top level with the same variable (or in the same expression) as the `new RuleTester` instantiation
240+
- Test cases which are neither object literals nor string literals are ignored by this rule.
241+
- In order to find your test cases, your test file needs to match the following common pattern:
242+
- `new RuleTester()` or `new (require('eslint')).RuleTester()` is called at the top level of the file
243+
- `ruleTester.run` is called at the top level with the same variable (or in the same expression) as the `new RuleTester` instantiation
244244

245245
## When Not To Use It
246246

247247
If you don't care about consistent usage of shorthand strings, you should not turn on this rule.
248248

249249
## Further Reading
250250

251-
* [`RuleTester` documentation](http://eslint.org/docs/developer-guide/working-with-plugins#testing)
251+
- [`RuleTester` documentation](http://eslint.org/docs/developer-guide/working-with-plugins#testing)

0 commit comments

Comments
 (0)