Skip to content

Commit ae34341

Browse files
bmishljharb
authored andcommitted
[Docs] Add markdownlint for documentation formatting consistency
1 parent 11306e1 commit ae34341

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+215
-180
lines changed

.markdownlint.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"line-length": false,
3+
"no-inline-html": false,
4+
"no-hard-tabs": { "spaces_per_tab": 2 },
5+
"ul-style": { "style": "dash" }
6+
}

.markdownlintignore

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

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
4040
* [Docs] Consistent rule descriptions and doc sections ([#3361][] @bmish)
4141
* [Docs] Standardize deprecated rule notice ([#3364][] @bmish)
4242
* [Docs] Fix typos ([#3366][] @bmish)
43+
* [Docs] Add markdownlint for documentation formatting consistency ([#3367][] @bmish)
4344

45+
[#3367]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3367
4446
[#3366]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3366
4547
[#3365]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3365
4648
[#3364]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3364

README.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# `eslint-plugin-react` <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2+
23
===================
34

45
[![github actions][actions-image]][actions-url]
@@ -8,16 +9,15 @@
89

910
React specific linting rules for `eslint`
1011

11-
# Installation
12+
## Installation
1213

1314
```sh
14-
$ npm install eslint eslint-plugin-react --save-dev
15+
npm install eslint eslint-plugin-react --save-dev
1516
```
1617

1718
It is also possible to install ESLint globally rather than locally (using npm install eslint --global). However, this is not recommended, and any plugins or shareable configs that you use must be installed locally in either case.
1819

19-
# Configuration
20-
20+
## Configuration
2121

2222
Use [our preset](#recommended) to get reasonable defaults:
2323

@@ -109,7 +109,7 @@ Enable the rules that you would like to use.
109109
}
110110
```
111111

112-
# List of supported rules
112+
## List of supported rules
113113

114114
✔: Enabled in the [`recommended`](#recommended) configuration.\
115115
🔧: Fixable with [`eslint --fix`](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).\
@@ -179,7 +179,7 @@ Enable the rules that you would like to use.
179179
| | | | [react/void-dom-elements-no-children](docs/rules/void-dom-elements-no-children.md) | Disallow void DOM elements (e.g. `<img />`, `<br />`) from receiving children |
180180
<!-- AUTO-GENERATED-CONTENT:END -->
181181

182-
## JSX-specific rules
182+
### JSX-specific rules
183183

184184
<!-- AUTO-GENERATED-CONTENT:START (JSX_RULES) -->
185185
|| 🔧 | 💡 | Rule | Description |
@@ -225,15 +225,15 @@ Enable the rules that you would like to use.
225225
| | 🔧 | | [react/jsx-wrap-multilines](docs/rules/jsx-wrap-multilines.md) | Disallow missing parentheses around multiline JSX |
226226
<!-- AUTO-GENERATED-CONTENT:END -->
227227

228-
## Other useful plugins
228+
### Other useful plugins
229229

230230
- Rules of Hooks: [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks)
231231
- JSX accessibility: [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y)
232232
- React Native: [eslint-plugin-react-native](https://github.com/Intellicode/eslint-plugin-react-native)
233233

234-
# Shareable configurations
234+
## Shareable configurations
235235

236-
## Recommended
236+
### Recommended
237237

238238
This plugin exports a `recommended` configuration that enforces React good practices.
239239

@@ -247,7 +247,7 @@ To enable this configuration use the `extends` property in your `.eslintrc` conf
247247

248248
See [`eslint` documentation](https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files) for more information about extending configuration files.
249249

250-
## All
250+
### All
251251

252252
This plugin also exports an `all` configuration that includes every available rule.
253253
This pairs well with the `eslint:all` rule.
@@ -263,11 +263,10 @@ This pairs well with the `eslint:all` rule.
263263

264264
**Note**: These configurations will import `eslint-plugin-react` and enable JSX in [parser options](https://eslint.org/docs/user-guide/configuring/language-options#specifying-parser-options).
265265

266-
# License
266+
## License
267267

268268
`eslint-plugin-react` is licensed under the [MIT License](https://opensource.org/licenses/mit-license.php).
269269

270-
271270
[npm-url]: https://npmjs.org/package/eslint-plugin-react
272271
[npm-image]: https://img.shields.io/npm/v/eslint-plugin-react.svg
273272

SECURITY.md

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ This is the list of versions of `eslint-plugin-react` which are currently being
99
| 7.x | :white_check_mark: |
1010
| < 7.x | :x: |
1111

12-
1312
## Reporting a Vulnerability
1413

1514
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.

docs/rules/boolean-prop-naming.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var Hello = createReactClass({
3636
render: function() { return <div />; };
3737
});
3838
```
39+
3940
```jsx
4041
type Props = {
4142
isEnabled: boolean
@@ -94,8 +95,8 @@ The custom message to display upon failure to match the rule. This overrides the
9495

9596
If you choose to use a custom message, you have access to two template variables.
9697

97-
* `propName` – the name of the prop that does not match the pattern
98-
* `pattern` – the pattern against which all prop names are tested
98+
- `propName` – the name of the prop that does not match the pattern
99+
- `pattern` – the pattern against which all prop names are tested
99100

100101
For example, if a prop is named `something`, and if the rule's pattern is set to `"^(is|has)[A-Z]([A-Za-z0-9]?)+"`, you could set the custom message as follows:
101102

@@ -105,7 +106,7 @@ message: 'It is better if your prop ({{ propName }}) matches this pattern: ({{ p
105106

106107
And the failure would look like so:
107108

108-
```
109+
```plaintext
109110
It is better if your prop (something) matches this pattern: (^is[A-Z]([A-Za-z0-9]?)+)
110111
```
111112

docs/rules/default-props-match-prop-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ If you don't care about stray `defaultsProps` in your components, you can disabl
192192

193193
- [require-default-props](./require-default-props.md)
194194

195-
# Resources
195+
## Resources
196196

197197
- [Official React documentation on defaultProps](https://facebook.github.io/react/docs/typechecking-with-proptypes.html#default-prop-values)
198198

docs/rules/destructuring-assignment.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
44

55
Rule can be set to either of `always` or `never`;
6+
67
```js
78
"react/destructuring-assignment": [<enabled>, 'always']
89
```

docs/rules/display-name.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ For this rule to work we need to detect React components, this could be very har
130130

131131
For now we should detect components created with:
132132

133-
* `createReactClass()`
134-
* an ES6 class that inherit from `React.Component` or `Component`
135-
* a stateless function that return JSX or the result of a `React.createElement` call.
133+
- `createReactClass()`
134+
- an ES6 class that inherit from `React.Component` or `Component`
135+
- a stateless function that return JSX or the result of a `React.createElement` call.

docs/rules/forbid-elements.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ This rule checks all JSX elements and `React.createElement` calls and verifies t
1818

1919
An array of strings and/or objects. An object in this array may have the following properties:
2020

21-
* `element` (required): the name of the forbidden element (e.g. `'button'`, `'Modal'`)
22-
* `message`: additional message that gets reported
21+
- `element` (required): the name of the forbidden element (e.g. `'button'`, `'Modal'`)
22+
- `message`: additional message that gets reported
2323

2424
A string item in the array is a shorthand for `{ element: string }`.
2525

docs/rules/iframe-missing-sandbox.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The sandbox attribute enables an extra set of restrictions for the content in the iframe. Using sandbox attribute is considered a good security practice.
44

5-
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox
5+
See <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox>
66

77
## Rule Details
88

docs/rules/jsx-closing-bracket-location.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ The second form allows you to distinguish between non-empty and self-closing tag
5656

5757
Enforced location for the closing bracket.
5858

59-
* `tag-aligned`: must be aligned with the opening tag.
60-
* `line-aligned`: must be aligned with the line containing the opening tag.
61-
* `after-props`: must be placed right after the last prop.
62-
* `props-aligned`: must be aligned with the last prop.
59+
- `tag-aligned`: must be aligned with the opening tag.
60+
- `line-aligned`: must be aligned with the line containing the opening tag.
61+
- `after-props`: must be placed right after the last prop.
62+
- `props-aligned`: must be aligned with the last prop.
6363

6464
Defaults to `tag-aligned`.
6565

docs/rules/jsx-curly-brace-presence.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ or alternatively
3030
...
3131
```
3232

33-
### Valid options for <string>
33+
### Valid options for `<string>`
3434

3535
They are `always`, `never` and `ignore` for checking on JSX props and children.
3636

37-
* `always`: always enforce curly braces inside JSX props, children, and/or JSX prop values that are JSX Elements
38-
* `never`: never allow unnecessary curly braces inside JSX props, children, and/or JSX prop values that are JSX Elements
39-
* `ignore`: ignore the rule for JSX props, children, and/or JSX prop values that are JSX Elements
37+
- `always`: always enforce curly braces inside JSX props, children, and/or JSX prop values that are JSX Elements
38+
- `never`: never allow unnecessary curly braces inside JSX props, children, and/or JSX prop values that are JSX Elements
39+
- `ignore`: ignore the rule for JSX props, children, and/or JSX prop values that are JSX Elements
4040

4141
If passed in the option to fix, this is how a style violation will get fixed
4242

43-
* `always`: wrap a JSX attribute in curly braces/JSX expression and/or a JSX child the same way but also with double quotes
44-
* `never`: get rid of curly braces from a JSX attribute and/or a JSX child
43+
- `always`: wrap a JSX attribute in curly braces/JSX expression and/or a JSX child the same way but also with double quotes
44+
- `never`: get rid of curly braces from a JSX attribute and/or a JSX child
4545

4646
- All fixing operations use double quotes.
4747

@@ -76,6 +76,7 @@ They can be fixed to:
7676
```
7777

7878
Examples of **incorrect** code for this rule, when configured with `{ props: "always", children: "always", "propElementValues": "always" }`:
79+
7980
```jsx
8081
<App prop=<div /> />;
8182
```
@@ -87,6 +88,7 @@ They can be fixed to:
8788
```
8889

8990
Examples of **incorrect** code for this rule, when configured with `{ props: "never", children: "never", "propElementValues": "never" }`:
91+
9092
```jsx
9193
<App prop={<div />} />;
9294
```
@@ -113,6 +115,7 @@ Examples of **incorrect** code for this rule, when configured with `"always"`:
113115
```
114116

115117
They can be fixed to:
118+
116119
```jsx
117120
<App>{"Hello world"}</App>;
118121
<App prop={"Hello world"} attr={"foo"}>{"Hello world"}</App>;
@@ -134,7 +137,7 @@ It can fixed to:
134137

135138
The fix also deals with template literals, strings with quotes, and strings with escapes characters.
136139

137-
* If the rule is set to get rid of unnecessary curly braces and the template literal inside a JSX expression has no expression, it will throw a warning and be fixed with double quotes. For example:
140+
- If the rule is set to get rid of unnecessary curly braces and the template literal inside a JSX expression has no expression, it will throw a warning and be fixed with double quotes. For example:
138141

139142
```jsx
140143
<App prop={`Hello world`}>{`Hello world`}</App>;
@@ -146,11 +149,10 @@ will be warned and fixed to:
146149
<App prop="Hello world">Hello world</App>;
147150
```
148151

149-
* If the rule is set to enforce curly braces and the strings have quotes, it will be fixed with double quotes for JSX children and the normal way for JSX attributes. Also, double quotes will be escaped in the fix.
152+
- If the rule is set to enforce curly braces and the strings have quotes, it will be fixed with double quotes for JSX children and the normal way for JSX attributes. Also, double quotes will be escaped in the fix.
150153

151154
For example:
152155

153-
154156
```jsx
155157
<App prop='Hello "foo" world'>Hello 'foo' "bar" world</App>;
156158
```
@@ -161,7 +163,7 @@ will warned and fixed to:
161163
<App prop={"Hello \"foo\" world"}>{"Hello 'foo' \"bar\" world"}</App>;
162164
```
163165

164-
* If the rule is set to get rid of unnecessary curly braces(JSX expression) and there are characters that need to be escaped in its JSX form, such as quote characters, [forbidden JSX text characters](https://facebook.github.io/jsx/), escaped characters and anything that looks like HTML entity names, the code will not be warned because the fix may make the code less readable.
166+
- If the rule is set to get rid of unnecessary curly braces(JSX expression) and there are characters that need to be escaped in its JSX form, such as quote characters, [forbidden JSX text characters](https://facebook.github.io/jsx/), escaped characters and anything that looks like HTML entity names, the code will not be warned because the fix may make the code less readable.
165167

166168
Examples of **correct** code for this rule, even when configured with `"never"`:
167169

docs/rules/jsx-curly-newline.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ This rule accepts either an object option:
1818
singleline: "consistent" | "forbid" | "require", // default to 'consistent'
1919
}
2020
```
21+
2122
Option `multiline` takes effect when the jsx expression inside the curlies occupies multiple lines.
2223

2324
Option `singleline` takes effect when the jsx expression inside the curlies occupies a single line.
2425

25-
* `consistent` enforces either both curly braces have a line break directly inside them, or no line breaks are present.
26-
* `forbid` disallows linebreaks directly inside curly braces.
27-
* `require` enforces the presence of linebreaks directly inside curlies.
26+
- `consistent` enforces either both curly braces have a line break directly inside them, or no line breaks are present.
27+
- `forbid` disallows linebreaks directly inside curly braces.
28+
- `require` enforces the presence of linebreaks directly inside curlies.
2829

2930
or a string option:
3031

31-
* `consistent` (default) is an alias for `{ multiline: "consistent", singleline: "consistent" }`.
32-
* `never` is an alias for `{ multiline: "forbid", singleline: "forbid" }`
32+
- `consistent` (default) is an alias for `{ multiline: "consistent", singleline: "consistent" }`.
33+
- `never` is an alias for `{ multiline: "forbid", singleline: "forbid" }`
3334

3435
or an
3536

@@ -143,7 +144,6 @@ Examples of **correct** code for this rule:
143144
</div>
144145
```
145146

146-
147147
## When Not To Use It
148148

149149
You can turn this rule off if you are not concerned with the consistency of padding linebreaks inside of JSX attributes or expressions.

docs/rules/jsx-curly-spacing.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ It either requires or disallows spaces between those braces and the values insid
1414

1515
There are two main options for the rule:
1616

17-
* `{"when": "always"}` enforces a space inside of curly braces
18-
* `{"when": "never"}` disallows spaces inside of curly braces (default)
17+
- `{"when": "always"}` enforces a space inside of curly braces
18+
- `{"when": "never"}` disallows spaces inside of curly braces (default)
1919

2020
There are also two properties that allow specifying how the rule should work with the attributes (`attributes`) and the expressions (`children`). The possible values are:
2121

22-
* `true` enables checking for the spacing using the options (default for `attributes`), e.g. `{"attributes": false}` disables checking the attributes
23-
* `false` disables checking for the spacing (default for `children`, for backward compatibility), e.g. `{"children": true}` enables checking the expressions
24-
* an object containing options that override the global options, e.g. `{"when": "always", "children": {"when": "never"}}` enforces a space inside attributes, but disallows spaces inside expressions
22+
- `true` enables checking for the spacing using the options (default for `attributes`), e.g. `{"attributes": false}` disables checking the attributes
23+
- `false` disables checking for the spacing (default for `children`, for backward compatibility), e.g. `{"children": true}` enables checking the expressions
24+
- an object containing options that override the global options, e.g. `{"when": "always", "children": {"when": "never"}}` enforces a space inside attributes, but disallows spaces inside expressions
2525

2626
### never
2727

@@ -203,7 +203,7 @@ You can specify an additional `spacing` property that is an object with the foll
203203
}}]
204204
```
205205

206-
* `objectLiterals`: This controls different spacing requirements when the value inside the jsx curly braces is an object literal.
206+
- `objectLiterals`: This controls different spacing requirements when the value inside the jsx curly braces is an object literal.
207207

208208
All spacing options accept either the string `"always"` or the string `"never"`. Note that the default value for all "spacing" options matches the first "always"/"never" option provided.
209209

docs/rules/jsx-equals-spacing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ This rule will enforce consistency of spacing around equal signs in JSX attribut
1212

1313
There are two options for the rule:
1414

15-
* `"always"` enforces spaces around the equal sign
16-
* `"never"` disallows spaces around the equal sign (default)
15+
- `"always"` enforces spaces around the equal sign
16+
- `"never"` disallows spaces around the equal sign (default)
1717

1818
Depending on your coding conventions, you can choose either option by specifying it in your configuration:
1919

docs/rules/jsx-first-prop-new-line.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Note: The fixer does not include indentation. Please rerun lint to correct those
1010

1111
This rule checks whether the first property of all JSX elements is correctly placed. There are the possible configurations:
1212

13-
* `always`: The first property should always be placed on a new line.
14-
* `never` : The first property should never be placed on a new line, e.g. should always be on the same line as the Component opening tag.
15-
* `multiline`: The first property should always be placed on a new line when the JSX tag takes up multiple lines.
16-
* `multiline-multiprop`: The first property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties. This is the `default` value.
13+
- `always`: The first property should always be placed on a new line.
14+
- `never` : The first property should never be placed on a new line, e.g. should always be on the same line as the Component opening tag.
15+
- `multiline`: The first property should always be placed on a new line when the JSX tag takes up multiple lines.
16+
- `multiline-multiprop`: The first property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties. This is the `default` value.
1717

1818
Examples of **incorrect** code for this rule, when configured with `"always"`:
1919

docs/rules/jsx-fragments.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
44

5-
In JSX, a React fragment is created either with `<React.Fragment>...</React.Fragment>`, or, using the shorthand syntax, `<>...</>`.
5+
In JSX, a React [fragment] is created either with `<React.Fragment>...</React.Fragment>`, or, using the shorthand syntax, `<>...</>`.
66

77
## Rule Details
88

@@ -58,6 +58,6 @@ Examples of **correct** code for this rule:
5858
<React.Fragment key="key"><Foo /></React.Fragment>
5959
```
6060

61-
[fragments]: https://reactjs.org/docs/fragments.html
61+
[fragment]: https://reactjs.org/docs/fragments.html
6262
[shared_settings]: /README.md#configuration
6363
[short_syntax]: https://reactjs.org/docs/fragments.html#short-syntax

0 commit comments

Comments
 (0)