Skip to content

Commit 0307999

Browse files
committed
[Docs] Add recommended notice to rule docs
1 parent 13d23b8 commit 0307999

22 files changed

+48
-0
lines changed

docs/rules/display-name.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow missing displayName in a React component definition (react/display-name)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
DisplayName allows you to name your component. This name is used by React in debugging messages.
46

57
## Rule Details

docs/rules/jsx-key.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow missing `key` props in iterators/collection literals (react/jsx-key)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
Warn if an element that likely requires a `key` prop--namely, one present in an
46
array literal or an arrow function expression.
57

docs/rules/jsx-no-comment-textnodes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow comments from being inserted as text nodes (react/jsx-no-comment-textnodes)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
This rule prevents comment strings (e.g. beginning with `//` or `/*`) from being accidentally
46
injected as a text node in JSX statements.
57

docs/rules/jsx-no-duplicate-props.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow duplicate properties in JSX (react/jsx-no-duplicate-props)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
Creating JSX elements with duplicate props can cause unexpected behavior in your application.
46

57
## Rule Details

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow `target="_blank"` attribute without `rel="noreferrer"` (react/jsx-no-target-blank)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
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)

docs/rules/jsx-no-undef.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow undeclared variables in JSX (react/jsx-no-undef)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
This rule helps locate potential ReferenceErrors resulting from misspellings or missing components.
46

57
## Rule Details

docs/rules/jsx-uses-react.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow React to be incorrectly marked as unused (react/jsx-uses-react)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
JSX expands to a call to `React.createElement`, a file which includes `React`
46
but only uses JSX should consider the `React` variable as used.
57

docs/rules/jsx-uses-vars.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow variables used in JSX to be incorrectly marked as unused (react/jsx-uses-vars)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
Since 0.17.0 the `eslint` `no-unused-vars` rule does not detect variables used in JSX ([see details](https://eslint.org/blog/2015/03/eslint-0.17.0-released#changes-to-jsxreact-handling)). This rule will find variables used in JSX and mark them as used.
46

57
This rule only has an effect when the `no-unused-vars` rule is enabled.

docs/rules/no-children-prop.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow passing of children as props (react/no-children-prop)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
Children should always be actual children, not passed in as a prop.
46

57
When using JSX, the children should be nested between the opening and closing

docs/rules/no-danger-with-children.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow when a DOM element is using both children and dangerouslySetInnerHTML (react/no-danger-with-children)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
This rule helps prevent problems caused by using children and the dangerouslySetInnerHTML prop at the same time.
46
React will throw a warning if this rule is ignored.
57

docs/rules/no-deprecated.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow usage of deprecated methods (react/no-deprecated)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
Several methods are deprecated between React versions. This rule will warn you if you try to use a deprecated method. Use the [shared settings](/README.md#configuration) to specify the React version.
46

57
## Rule Details

docs/rules/no-direct-mutation-state.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow direct mutation of this.state (react/no-direct-mutation-state)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
NEVER mutate `this.state` directly, as calling `setState()` afterwards may replace
46
the mutation you made. Treat `this.state` as if it were immutable.
57

docs/rules/no-find-dom-node.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow usage of findDOMNode (react/no-find-dom-node)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
Facebook will eventually deprecate `findDOMNode` as it blocks certain improvements in React in the future.
46

57
It is recommended to use callback refs instead. See [Dan Abramov comments and examples](https://github.com/jsx-eslint/eslint-plugin-react/issues/678#issue-165177220).

docs/rules/no-is-mounted.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow usage of isMounted (react/no-is-mounted)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
[`isMounted` is an anti-pattern][anti-pattern], is not available when using ES6 classes, and it is on its way to being officially deprecated.
46

57
[anti-pattern]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html

docs/rules/no-render-return-value.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow usage of the return value of ReactDOM.render (react/no-render-return-value)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
> `ReactDOM.render()` currently returns a reference to the root `ReactComponent` instance. However, using this return value is legacy and should be avoided because future versions of React may render components asynchronously in some cases. If you need a reference to the root `ReactComponent` instance, the preferred solution is to attach a [callback ref](https://reactjs.org/docs/refs-and-the-dom.html#callback-refs) to the root element.
46
57
Source: [ReactDOM documentation](https://facebook.github.io/react/docs/react-dom.html#render)

docs/rules/no-string-refs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow using string references (react/no-string-refs)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
Currently, two ways are supported by React to refer to components. The first way, providing a string identifier, is now considered legacy in the official documentation. The documentation now prefers a second method -- referring to components by setting a property on the `this` object in the reference callback.
46

57
## Rule Details

docs/rules/no-unescaped-entities.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow unescaped HTML entities from appearing in markup (react/no-unescaped-entities)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
This rule prevents characters that you may have meant as JSX escape characters
46
from being accidentally injected as a text node in JSX statements.
57

docs/rules/no-unknown-property.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow usage of unknown DOM property (react/no-unknown-property)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
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.

docs/rules/prop-types.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow missing props validation in a React component definition (react/prop-types)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
Defining types for component props improves reusability of your components by
46
validating received data. It can warn other developers if they make a mistake while reusing the component with improper data type.
57

docs/rules/react-in-jsx-scope.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow missing React when using JSX (react/react-in-jsx-scope)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
When using JSX, `<a />` expands to `React.createElement("a")`. Therefore the `React` variable must be in scope.
46

57
If you are using the @jsx pragma this rule will check the designated variable and not the `React` one.

docs/rules/require-render-return.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce ES5 or ES6 class for returning value in render function (react/require-render-return)
22

3+
✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.
4+
35
When writing the `render` method in a component it is easy to forget to return the JSX content. This rule will warn if the `return` statement is missing.
46

57
## Rule Details

tests/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('rule documentation files have the correct content', () => {
2626
const MESSAGES = {
2727
fixable: '🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.',
2828
hasSuggestions: '💡 This rule provides editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).',
29+
recommended: '✔️ This rule is part of the [recommended](https://github.com/jsx-eslint/eslint-plugin-react#recommended) config.',
2930
};
3031

3132
ruleFiles.forEach((ruleName) => {
@@ -42,6 +43,11 @@ describe('rule documentation files have the correct content', () => {
4243
// Decide which notices should be shown at the top of the doc.
4344
const expectedNotices = [];
4445
const unexpectedNotices = [];
46+
if (rule.meta.docs.recommended) {
47+
expectedNotices.push('recommended');
48+
} else {
49+
unexpectedNotices.push('recommended');
50+
}
4551
if (rule.meta.fixable) {
4652
expectedNotices.push('fixable');
4753
} else {

0 commit comments

Comments
 (0)