You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
18
19
19
-
# Configuration
20
-
20
+
## Configuration
21
21
22
22
Use [our preset](#recommended) to get reasonable defaults:
23
23
@@ -109,7 +109,7 @@ Enable the rules that you would like to use.
109
109
}
110
110
```
111
111
112
-
# List of supported rules
112
+
##List of supported rules
113
113
114
114
✔: Enabled in the [`recommended`](#recommended) configuration.\
115
115
🔧: 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.
179
179
||||[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 |
180
180
<!-- AUTO-GENERATED-CONTENT:END -->
181
181
182
-
## JSX-specific rules
182
+
###JSX-specific rules
183
183
184
184
<!-- AUTO-GENERATED-CONTENT:START (JSX_RULES) -->
185
185
| ✔ | 🔧 | 💡 | Rule | Description |
@@ -225,15 +225,15 @@ Enable the rules that you would like to use.
225
225
|| 🔧 ||[react/jsx-wrap-multilines](docs/rules/jsx-wrap-multilines.md)| Disallow missing parentheses around multiline JSX |
226
226
<!-- AUTO-GENERATED-CONTENT:END -->
227
227
228
-
## Other useful plugins
228
+
###Other useful plugins
229
229
230
230
- Rules of Hooks: [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks)
This plugin exports a `recommended` configuration that enforces React good practices.
239
239
@@ -247,7 +247,7 @@ To enable this configuration use the `extends` property in your `.eslintrc` conf
247
247
248
248
See [`eslint` documentation](https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files) for more information about extending configuration files.
249
249
250
-
## All
250
+
###All
251
251
252
252
This plugin also exports an `all` configuration that includes every available rule.
253
253
This pairs well with the `eslint:all` rule.
@@ -263,11 +263,10 @@ This pairs well with the `eslint:all` rule.
263
263
264
264
**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).
265
265
266
-
# License
266
+
##License
267
267
268
268
`eslint-plugin-react` is licensed under the [MIT License](https://opensource.org/licenses/mit-license.php).
Copy file name to clipboardExpand all lines: SECURITY.md
-1
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,6 @@ This is the list of versions of `eslint-plugin-react` which are currently being
9
9
| 7.x |:white_check_mark:|
10
10
| < 7.x |:x:|
11
11
12
-
13
12
## Reporting a Vulnerability
14
13
15
14
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
Copy file name to clipboardExpand all lines: docs/rules/boolean-prop-naming.md
+4-3
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,7 @@ var Hello = createReactClass({
36
36
render:function() { return<div />; };
37
37
});
38
38
```
39
+
39
40
```jsx
40
41
type Props = {
41
42
isEnabled: boolean
@@ -94,8 +95,8 @@ The custom message to display upon failure to match the rule. This overrides the
94
95
95
96
If you choose to use a custom message, you have access to two template variables.
96
97
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
99
100
100
101
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:
101
102
@@ -105,7 +106,7 @@ message: 'It is better if your prop ({{ propName }}) matches this pattern: ({{ p
105
106
106
107
And the failure would look like so:
107
108
108
-
```
109
+
```plaintext
109
110
It is better if your prop (something) matches this pattern: (^is[A-Z]([A-Za-z0-9]?)+)
Copy file name to clipboardExpand all lines: docs/rules/destructuring-assignment.md
+1
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
🔧 This rule is automatically fixable using the `--fix`[flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
Copy file name to clipboardExpand all lines: docs/rules/iframe-missing-sandbox.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The sandbox attribute enables an extra set of restrictions for the content in the iframe. Using sandbox attribute is considered a good security practice.
4
4
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>
The fix also deals with template literals, strings with quotes, and strings with escapes characters.
136
139
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:
138
141
139
142
```jsx
140
143
<App prop={`Hello world`}>{`Hello world`}</App>;
@@ -146,11 +149,10 @@ will be warned and fixed to:
146
149
<App prop="Hello world">Hello world</App>;
147
150
```
148
151
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.
* 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.
165
167
166
168
Examples of **correct** code for this rule, even when configured with `"never"`:
Copy file name to clipboardExpand all lines: docs/rules/jsx-curly-spacing.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -14,14 +14,14 @@ It either requires or disallows spaces between those braces and the values insid
14
14
15
15
There are two main options for the rule:
16
16
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)
19
19
20
20
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:
21
21
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
25
25
26
26
### never
27
27
@@ -203,7 +203,7 @@ You can specify an additional `spacing` property that is an object with the foll
203
203
}}]
204
204
```
205
205
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.
207
207
208
208
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.
Copy file name to clipboardExpand all lines: docs/rules/jsx-first-prop-new-line.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,10 @@ Note: The fixer does not include indentation. Please rerun lint to correct those
10
10
11
11
This rule checks whether the first property of all JSX elements is correctly placed. There are the possible configurations:
12
12
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.
17
17
18
18
Examples of **incorrect** code for this rule, when configured with `"always"`:
Copy file name to clipboardExpand all lines: docs/rules/jsx-fragments.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
🔧 This rule is automatically fixable using the `--fix`[flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
4
4
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, `<>...</>`.
6
6
7
7
## Rule Details
8
8
@@ -58,6 +58,6 @@ Examples of **correct** code for this rule:
0 commit comments