Skip to content

Commit bb999c2

Browse files
bmishljharb
authored andcommitted
[Docs] document which rules provide suggestions
1 parent 8306a7b commit bb999c2

35 files changed

+219
-150
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
3636
* [Refactor] [`jsx-closing-bracket-location`], [`jsx-no-bind`]: fix eslint issues ([#3351][] @caroline223)
3737
* [Tests] [`function-component-definition`]: add passing test cases ([#3355][] @TildaDares)
3838
* [Docs] [`jsx-no-target-blank`]: Fix link to link-type-noreferrer ([#3319][] @Luccasoli)
39+
* [Docs] document which rules provide suggestions ([#3359][] @bmish)
3940

41+
[#3359]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3359
4042
[#3355]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3355
4143
[#3353]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3353
4244
[#3351]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3351

README.md

+104-103
Large diffs are not rendered by default.

docs/rules/destructuring-assignment.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce consistent usage of destructuring assignment of props, state, and context (react/destructuring-assignment)
22

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+
35
Rule can be set to either of `always` or `never`;
46
```js
57
"react/destructuring-assignment": [<enabled>, 'always']

docs/rules/function-component-definition.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enforce a specific function type for function components (react/function-component-definition)
22

3-
This option enforces a specific function type for function components.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
This option enforces a specific function type for function components.
66

77
## Rule Details
88

docs/rules/hook-use-state.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Ensure destructuring and symmetric naming of useState hook value and setter variables (react/hook-use-state)
22

3+
💡 This rule provides editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
4+
35
## Rule Details
46

57
This rule checks whether the value and setter variables destructured from a `React.useState()` call are named symmetrically.

docs/rules/jsx-boolean-value.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enforce boolean attributes notation in JSX (react/jsx-boolean-value)
22

3-
[When using a boolean attribute in JSX](https://facebook.github.io/react/docs/jsx-in-depth.html#boolean-attributes), you can set the attribute value to `true` or omit the value. This rule will enforce one or the other to keep consistency in your code.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
[When using a boolean attribute in JSX](https://facebook.github.io/react/docs/jsx-in-depth.html#boolean-attributes), you can set the attribute value to `true` or omit the value. This rule will enforce one or the other to keep consistency in your code.
66

77
## Rule Details
88

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Validate closing bracket location in JSX (react/jsx-closing-bracket-location)
22

3-
Enforce the closing bracket location for JSX multiline elements.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Enforce the closing bracket location for JSX multiline elements.
66

77
## Rule Details
88

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Validate closing tag location in JSX (react/jsx-closing-tag-location)
22

3-
Enforce the closing tag location for multiline JSX elements.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Enforce the closing tag location for multiline JSX elements.
66

77
## Rule Details
88

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children. (react/jsx-curly-brace-presence)
22

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+
35
This rule allows you to enforce curly braces or disallow unnecessary curly braces in JSX props and/or children.
46

57
For situations where JSX expressions are unnecessary, please refer to [the React doc](https://facebook.github.io/react/docs/jsx-in-depth.html) and [this page about JSX gotchas](https://github.com/facebook/react/blob/v15.4.0-rc.3/docs/docs/02.3-jsx-gotchas.md#html-entities).
@@ -175,7 +177,7 @@ Examples of **correct** code for this rule, even when configured with `"never"`:
175177
*/
176178
<App>{' '}</App>
177179
<App>{' '}</App>
178-
<App>{/* comment */ <Bpp />}</App> // the comment makes the container necessary
180+
<App>{/* comment */ <Bpp />}</App> // the comment makes the container necessary
179181
```
180182

181183
## When Not To Use It

docs/rules/jsx-curly-newline.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enforce linebreaks in curly braces in JSX attributes and expressions. (react/jsx-curly-newline)
22

3-
Many style guides require or disallow newlines inside of jsx curly expressions.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Many style guides require or disallow newlines inside of jsx curly expressions.
66

77
## Rule Details
88

docs/rules/jsx-curly-spacing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. (react/jsx-curly-spacing)
22

3-
While formatting preferences are very personal, a number of style guides require or disallow spaces between curly braces.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
While formatting preferences are very personal, a number of style guides require or disallow spaces between curly braces.
66

77
## Rule Details
88

docs/rules/jsx-equals-spacing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enforce or disallow spaces around equal signs in JSX attributes. (react/jsx-equals-spacing)
22

3-
Some style guides require or disallow spaces around equal signs.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Some style guides require or disallow spaces around equal signs.
66

77
## Rule Details
88

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Configure the position of the first property (react/jsx-first-prop-new-line)
22

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+
35
Ensure correct position of the first property.
46

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line. However, fix does not include indentation. Please rerun lint to correct those errors.
7+
Note: The fixer does not include indentation. Please rerun lint to correct those errors.
68

79
## Rule Details
810

docs/rules/jsx-fragments.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Enforce shorthand or standard form for React fragments (react/jsx-fragments)
22

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+
35
In JSX, a React fragment is created either with `<React.Fragment>...</React.Fragment>`, or, using the shorthand syntax, `<>...</>`. This rule allows you to enforce one way or the other.
46

57
Support for fragments was added in React v16.2, so the rule will warn on either of these forms if an older React version is specified in [shared settings][shared_settings].
68

7-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
8-
99
## Rule Options
1010

1111
```js

docs/rules/jsx-indent-props.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Validate props indentation in JSX (react/jsx-indent-props)
22

3-
This option validates a specific indentation style for props.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
This option validates a specific indentation style for props.
66

77
## Rule Details
88

docs/rules/jsx-indent.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Validate JSX indentation (react/jsx-indent)
22

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+
35
This option validates a specific indentation style for JSX.
46

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
6-
Fixer will fix whitespace and tabs indentation.
7+
Note: The fixer will fix whitespace and tabs indentation.
78

89
## Rule Details
910

docs/rules/jsx-max-props-per-line.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Limit maximum of props on a single line in JSX (react/jsx-max-props-per-line)
22

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+
35
Limiting the maximum of props on a single line can improve readability.
46

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line. However, fix does not include indentation. Please rerun lint to correct those errors.
7+
Note: The fixer does not include indentation. Please rerun lint to correct those errors.
68

79
## Rule Details
810

docs/rules/jsx-newline.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Require or prevent a new line after jsx elements and expressions. (react/jsx-newline)
22

3-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
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.
44

55
## Rule Details
66

docs/rules/jsx-no-leaked-render.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Prevent problematic leaked values from being rendered (react/jsx-no-leaked-render)
22

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+
35
Using the `&&` operator to render some element conditionally in JSX can cause unexpected values being rendered, or even crashing the rendering.
46

57

@@ -16,11 +18,11 @@ const Example = () => {
1618
{0 && <Something/>}
1719
{/* React: renders undesired 0 */}
1820
{/* React Native: crashes 💥 */}
19-
21+
2022
{'' && <Something/>}
2123
{/* React: renders nothing */}
2224
{/* React Native: crashes 💥 */}
23-
25+
2426
{NaN && <Something/>}
2527
{/* React: renders undesired NaN */}
2628
{/* React Native: crashes 💥 */}

docs/rules/jsx-no-target-blank.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Prevent usage of unsafe `target='_blank'` (react/jsx-no-target-blank)
22

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+
35
When creating a JSX element that has an `a` tag, it is often desired to have the link open in a new tab using the `target='_blank'` attribute. Using this attribute unaccompanied by `rel='noreferrer'`, however, is a severe security vulnerability (see [noreferrer docs](https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer) and [noopener docs](https://html.spec.whatwg.org/multipage/links.html#link-type-noopener) for more details)
46
This rules requires that you accompany `target='_blank'` attributes with `rel='noreferrer'`.
57

docs/rules/jsx-no-useless-fragment.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow unnecessary fragments (react/jsx-no-useless-fragment)
22

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+
35
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a [keyed fragment](https://reactjs.org/docs/fragments.html#keyed-fragments).
46

57
**Fixable:** This rule is sometimes automatically fixable using the `--fix` flag on the command line.

docs/rules/jsx-one-expression-per-line.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# One JSX Element Per Line (react/jsx-one-expression-per-line)
22

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+
35
This option limits every line in JSX to one expression each.
46

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
6-
Fixer will insert line breaks between any expression that are on the same line.
7+
Note: The fixer will insert line breaks between any expression that are on the same line.
78

89
## Rule Details
910

docs/rules/jsx-props-no-multi-spaces.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Disallow multiple spaces between inline JSX props (react/jsx-props-no-multi-spaces)
22

3-
Enforces that there is exactly one space between all attributes and after tag name and the first attribute in the same line.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Enforces that there is exactly one space between all attributes and after tag name and the first attribute in the same line.
66

77
## Rule Details
88

docs/rules/jsx-sort-props.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enforce props alphabetical sorting (react/jsx-sort-props)
22

3-
Some developers prefer to sort props names alphabetically to be able to find necessary props easier at the later time. Others feel that it adds complexity and becomes burden to maintain.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Some developers prefer to sort props names alphabetically to be able to find necessary props easier at the later time. Others feel that it adds complexity and becomes burden to maintain.
66

77
## Rule Details
88

docs/rules/jsx-space-before-closing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Validate spacing before closing bracket in JSX (react/jsx-space-before-closing)
22

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+
35
**Deprecation notice**: This rule is deprecated. Please use the `"beforeSelfClosing"` option of the [jsx-tag-spacing](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md) rule instead.
46

57
Enforce or forbid spaces before the closing bracket of self-closing JSX elements.
68

7-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
8-
99
## Rule Details
1010

1111
This rule checks if there is one or more spaces before the closing bracket of self-closing JSX elements.

docs/rules/jsx-tag-spacing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Validate whitespace in and around the JSX opening and closing brackets (react/jsx-tag-spacing)
22

3-
Enforce or forbid spaces after the opening bracket, before the closing bracket, before the closing bracket of self-closing elements, and between the angle bracket and slash of JSX closing or self-closing elements.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Enforce or forbid spaces after the opening bracket, before the closing bracket, before the closing bracket of self-closing elements, and between the angle bracket and slash of JSX closing or self-closing elements.
66

77
## Rule Details
88

docs/rules/jsx-wrap-multilines.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Prevent missing parentheses around multiline JSX (react/jsx-wrap-multilines)
22

3-
Wrapping multiline JSX in parentheses can improve readability and/or convenience.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Wrapping multiline JSX in parentheses can improve readability and/or convenience.
66

77
## Rule Details
88

docs/rules/no-arrow-function-lifecycle.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Lifecycle methods should be methods on the prototype, not class fields (react/no-arrow-function-lifecycle)
22

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+
35
It is not neccessary to use arrow function for lifecycle methods. This makes things harder to test, conceptually less performant (although in practice, performance will not be affected, since most engines will optimize efficiently), and can break hot reloading patterns.
46

57
## Rule Details

docs/rules/no-invalid-html-attribute.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Prevent usage of invalid attributes (react/no-invalid-html-attribute)
22

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+
35
Some HTML elements have a specific set of valid values for some attributes.
46
For instance the elements: `a`, `area`, `link`, or `form` all have an attribute called `rel`.
57
There is a fixed list of values that have any meaning for this attribute on these tags (see [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel)).

docs/rules/no-unknown-property.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Prevent usage of unknown DOM property (react/no-unknown-property)
22

3-
In JSX all DOM properties and attributes should be camelCased to be consistent with standard JavaScript style. This can be a possible source of error if you are used to writing plain HTML.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
In JSX all DOM properties and attributes should be camelCased to be consistent with standard JavaScript style. This can be a possible source of error if you are used to writing plain HTML.
66

77
## Rule Details
88

docs/rules/prefer-read-only-props.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce that props are read-only (react/prefer-read-only-props)
22

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+
35
Using Flow, one can define types for props. This rule enforces that prop types are read-only (covariant).
46

57
## Rule Details

docs/rules/self-closing-comp.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Prevent extra closing tags for components without children (react/self-closing-comp)
22

3-
Components without children can be self-closed to avoid unnecessary extra closing tag.
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.
44

5-
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
5+
Components without children can be self-closed to avoid unnecessary extra closing tag.
66

77
## Rule Details
88

docs/rules/sort-comp.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enforce component methods order (react/sort-comp)
22

3-
When creating React components it is more convenient to always follow the same organisation for method order to help you easily find lifecycle methods, event handlers, etc.
3+
🔧 This rule is automatically fixable using the [`sort-comp` transform](https://github.com/reactjs/react-codemod/blob/master/transforms/sort-comp.js) in [react-codemod](https://www.npmjs.com/package/react-codemod).
44

5-
**Fixable:** This rule is automatically fixable using the [`sort-comp` transform](https://github.com/reactjs/react-codemod/blob/master/transforms/sort-comp.js) in [react-codemod](https://www.npmjs.com/package/react-codemod).
5+
When creating React components it is more convenient to always follow the same organisation for method order to help you easily find lifecycle methods, event handlers, etc.
66

77
## Rule Details
88

0 commit comments

Comments
 (0)