From 2f53460b1527a0d383c1dba5dadb18468b3da8d8 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Fri, 19 Aug 2022 15:56:29 -0400 Subject: [PATCH] [Docs] Add config notice to rule docs --- docs/rules/boolean-prop-naming.md | 2 ++ docs/rules/button-has-type.md | 2 ++ docs/rules/default-props-match-prop-types.md | 2 ++ docs/rules/destructuring-assignment.md | 2 ++ docs/rules/display-name.md | 2 ++ docs/rules/forbid-component-props.md | 2 ++ docs/rules/forbid-dom-props.md | 2 ++ docs/rules/forbid-elements.md | 2 ++ docs/rules/forbid-foreign-prop-types.md | 2 ++ docs/rules/forbid-prop-types.md | 2 ++ docs/rules/function-component-definition.md | 2 ++ docs/rules/hook-use-state.md | 2 ++ docs/rules/iframe-missing-sandbox.md | 2 ++ docs/rules/jsx-boolean-value.md | 2 ++ docs/rules/jsx-child-element-spacing.md | 2 ++ docs/rules/jsx-closing-bracket-location.md | 2 ++ docs/rules/jsx-closing-tag-location.md | 2 ++ docs/rules/jsx-curly-brace-presence.md | 2 ++ docs/rules/jsx-curly-newline.md | 2 ++ docs/rules/jsx-curly-spacing.md | 2 ++ docs/rules/jsx-equals-spacing.md | 2 ++ docs/rules/jsx-filename-extension.md | 2 ++ docs/rules/jsx-first-prop-new-line.md | 2 ++ docs/rules/jsx-fragments.md | 2 ++ docs/rules/jsx-handler-names.md | 2 ++ docs/rules/jsx-indent-props.md | 2 ++ docs/rules/jsx-indent.md | 2 ++ docs/rules/jsx-key.md | 2 ++ docs/rules/jsx-max-depth.md | 2 ++ docs/rules/jsx-max-props-per-line.md | 2 ++ docs/rules/jsx-newline.md | 2 ++ docs/rules/jsx-no-bind.md | 2 ++ docs/rules/jsx-no-comment-textnodes.md | 2 ++ .../jsx-no-constructed-context-values.md | 2 ++ docs/rules/jsx-no-duplicate-props.md | 2 ++ docs/rules/jsx-no-leaked-render.md | 2 ++ docs/rules/jsx-no-literals.md | 2 ++ docs/rules/jsx-no-script-url.md | 2 ++ docs/rules/jsx-no-target-blank.md | 2 ++ docs/rules/jsx-no-undef.md | 2 ++ docs/rules/jsx-no-useless-fragment.md | 2 ++ docs/rules/jsx-one-expression-per-line.md | 2 ++ docs/rules/jsx-pascal-case.md | 2 ++ docs/rules/jsx-props-no-multi-spaces.md | 2 ++ docs/rules/jsx-props-no-spreading.md | 2 ++ docs/rules/jsx-sort-default-props.md | 2 ++ docs/rules/jsx-sort-props.md | 2 ++ docs/rules/jsx-tag-spacing.md | 2 ++ docs/rules/jsx-uses-react.md | 2 ++ docs/rules/jsx-uses-vars.md | 2 ++ docs/rules/jsx-wrap-multilines.md | 2 ++ docs/rules/no-access-state-in-setstate.md | 2 ++ docs/rules/no-adjacent-inline-elements.md | 2 ++ docs/rules/no-array-index-key.md | 2 ++ docs/rules/no-arrow-function-lifecycle.md | 2 ++ docs/rules/no-children-prop.md | 2 ++ docs/rules/no-danger-with-children.md | 2 ++ docs/rules/no-danger.md | 2 ++ docs/rules/no-deprecated.md | 2 ++ docs/rules/no-did-mount-set-state.md | 2 ++ docs/rules/no-did-update-set-state.md | 2 ++ docs/rules/no-direct-mutation-state.md | 2 ++ docs/rules/no-find-dom-node.md | 2 ++ docs/rules/no-invalid-html-attribute.md | 2 ++ docs/rules/no-is-mounted.md | 2 ++ docs/rules/no-multi-comp.md | 2 ++ docs/rules/no-namespace.md | 2 ++ .../no-redundant-should-component-update.md | 2 ++ docs/rules/no-render-return-value.md | 2 ++ docs/rules/no-set-state.md | 2 ++ docs/rules/no-string-refs.md | 2 ++ docs/rules/no-this-in-sfc.md | 2 ++ docs/rules/no-typos.md | 2 ++ docs/rules/no-unescaped-entities.md | 2 ++ docs/rules/no-unknown-property.md | 2 ++ docs/rules/no-unsafe.md | 2 ++ docs/rules/no-unstable-nested-components.md | 2 ++ .../no-unused-class-component-methods.md | 2 ++ docs/rules/no-unused-prop-types.md | 2 ++ docs/rules/no-unused-state.md | 2 ++ docs/rules/no-will-update-set-state.md | 2 ++ docs/rules/prefer-es6-class.md | 2 ++ docs/rules/prefer-exact-props.md | 2 ++ docs/rules/prefer-read-only-props.md | 2 ++ docs/rules/prefer-stateless-function.md | 2 ++ docs/rules/prop-types.md | 2 ++ docs/rules/react-in-jsx-scope.md | 2 ++ docs/rules/require-default-props.md | 2 ++ docs/rules/require-optimization.md | 2 ++ docs/rules/require-render-return.md | 2 ++ docs/rules/self-closing-comp.md | 2 ++ docs/rules/sort-comp.md | 2 ++ docs/rules/sort-prop-types.md | 2 ++ docs/rules/state-in-constructor.md | 2 ++ docs/rules/static-property-placement.md | 2 ++ docs/rules/style-prop-object.md | 2 ++ docs/rules/void-dom-elements-no-children.md | 2 ++ tests/index.js | 20 +++++++++++++++++++ 98 files changed, 214 insertions(+) diff --git a/docs/rules/boolean-prop-naming.md b/docs/rules/boolean-prop-naming.md index ff642f7abc..3d12e8c519 100644 --- a/docs/rules/boolean-prop-naming.md +++ b/docs/rules/boolean-prop-naming.md @@ -1,5 +1,7 @@ # Enforces consistent naming for boolean props (react/boolean-prop-naming) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Allows you to enforce a consistent naming pattern for props which expect a boolean value. > **Note**: You can provide types in runtime types using [PropTypes] and/or diff --git a/docs/rules/button-has-type.md b/docs/rules/button-has-type.md index 13d0115b58..56c0cd7804 100644 --- a/docs/rules/button-has-type.md +++ b/docs/rules/button-has-type.md @@ -1,5 +1,7 @@ # Disallow usage of `button` elements without an explicit `type` attribute (react/button-has-type) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + The default value of `type` attribute for `button` HTML element is `"submit"` which is often not the desired behavior and may lead to unexpected page reloads. This rules enforces an explicit `type` attribute for all the `button` elements and checks that its value is valid per spec (i.e., is one of `"button"`, `"submit"`, and `"reset"`). diff --git a/docs/rules/default-props-match-prop-types.md b/docs/rules/default-props-match-prop-types.md index 2992221e2a..ba8589c8b6 100644 --- a/docs/rules/default-props-match-prop-types.md +++ b/docs/rules/default-props-match-prop-types.md @@ -1,5 +1,7 @@ # Enforce all defaultProps have a corresponding non-required PropType (react/default-props-match-prop-types) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + This rule aims to ensure that any prop in `defaultProps` has a non-required type definition. diff --git a/docs/rules/destructuring-assignment.md b/docs/rules/destructuring-assignment.md index a6b516d31f..a819e9fc37 100644 --- a/docs/rules/destructuring-assignment.md +++ b/docs/rules/destructuring-assignment.md @@ -1,5 +1,7 @@ # Enforce consistent usage of destructuring assignment of props, state, and context (react/destructuring-assignment) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Rule can be set to either of `always` or `never`; diff --git a/docs/rules/display-name.md b/docs/rules/display-name.md index 0c7d18f03e..a0c46fefd4 100644 --- a/docs/rules/display-name.md +++ b/docs/rules/display-name.md @@ -1,5 +1,7 @@ # Disallow missing displayName in a React component definition (react/display-name) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + DisplayName allows you to name your component. This name is used by React in debugging messages. ## Rule Details diff --git a/docs/rules/forbid-component-props.md b/docs/rules/forbid-component-props.md index 6c4c2cc327..9ef422f163 100644 --- a/docs/rules/forbid-component-props.md +++ b/docs/rules/forbid-component-props.md @@ -1,5 +1,7 @@ # Disallow certain props on components (react/forbid-component-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + By default this rule prevents passing of [props that add lots of complexity](https://medium.com/brigade-engineering/don-t-pass-css-classes-between-components-e9f7ab192785) (`className`, `style`) to Components. This rule only applies to Components (e.g. ``) and not DOM nodes (e.g. `
`). The list of forbidden props can be customized with the `forbid` option. ## Rule Details diff --git a/docs/rules/forbid-dom-props.md b/docs/rules/forbid-dom-props.md index f37e376682..00d865365a 100644 --- a/docs/rules/forbid-dom-props.md +++ b/docs/rules/forbid-dom-props.md @@ -1,5 +1,7 @@ # Disallow certain props on DOM Nodes (react/forbid-dom-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + This rule prevents passing of props to elements. This rule only applies to DOM Nodes (e.g. `
`) and not Components (e.g. ``). The list of forbidden props can be customized with the `forbid` option. diff --git a/docs/rules/forbid-elements.md b/docs/rules/forbid-elements.md index 4eaae2468d..7541dfcf63 100644 --- a/docs/rules/forbid-elements.md +++ b/docs/rules/forbid-elements.md @@ -1,5 +1,7 @@ # Disallow certain elements (react/forbid-elements) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + You may want to forbid usage of certain elements in favor of others, (e.g. forbid all `
` and use `` instead). This rule allows you to configure a list of forbidden elements and to specify their desired replacements. ## Rule Details diff --git a/docs/rules/forbid-foreign-prop-types.md b/docs/rules/forbid-foreign-prop-types.md index 51ea8a909a..e56709a693 100644 --- a/docs/rules/forbid-foreign-prop-types.md +++ b/docs/rules/forbid-foreign-prop-types.md @@ -1,5 +1,7 @@ # Disallow using another component's propTypes (react/forbid-foreign-prop-types) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + This rule forbids using another component's prop types unless they are explicitly imported/exported. This allows people who want to use [babel-plugin-transform-react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) to remove propTypes from their components in production builds, to do so safely. In order to ensure that imports are explicitly exported it is recommended to use the ["named" rule in eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import/blob/HEAD/docs/rules/named.md) in conjunction with this rule. diff --git a/docs/rules/forbid-prop-types.md b/docs/rules/forbid-prop-types.md index 01898c21ae..fb442634c7 100644 --- a/docs/rules/forbid-prop-types.md +++ b/docs/rules/forbid-prop-types.md @@ -1,5 +1,7 @@ # Disallow certain propTypes (react/forbid-prop-types) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + By default this rule prevents vague prop types with more specific alternatives available (`any`, `array`, `object`), but any prop type can be disabled if desired. The defaults are chosen because they have obvious replacements. `any` should be replaced with, well, anything. `array` and `object` can be replaced with `arrayOf` and `shape`, respectively. ## Rule Details diff --git a/docs/rules/function-component-definition.md b/docs/rules/function-component-definition.md index 12ec29e9b9..d4196e2ea5 100644 --- a/docs/rules/function-component-definition.md +++ b/docs/rules/function-component-definition.md @@ -1,5 +1,7 @@ # Enforce a specific function type for function components (react/function-component-definition) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. This option enforces a specific function type for function components. diff --git a/docs/rules/hook-use-state.md b/docs/rules/hook-use-state.md index 7f66bbddb4..da99b84b9e 100644 --- a/docs/rules/hook-use-state.md +++ b/docs/rules/hook-use-state.md @@ -1,5 +1,7 @@ # Ensure destructuring and symmetric naming of useState hook value and setter variables (react/hook-use-state) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 💡 This rule provides editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). ## Rule Details diff --git a/docs/rules/iframe-missing-sandbox.md b/docs/rules/iframe-missing-sandbox.md index 2f5fad8b58..54bce5930c 100644 --- a/docs/rules/iframe-missing-sandbox.md +++ b/docs/rules/iframe-missing-sandbox.md @@ -1,5 +1,7 @@ # Enforce sandbox attribute on iframe elements (react/iframe-missing-sandbox) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + The sandbox attribute enables an extra set of restrictions for the content in the iframe. Using sandbox attribute is considered a good security practice. See diff --git a/docs/rules/jsx-boolean-value.md b/docs/rules/jsx-boolean-value.md index ddcbc44215..ba0ec7d5af 100644 --- a/docs/rules/jsx-boolean-value.md +++ b/docs/rules/jsx-boolean-value.md @@ -1,5 +1,7 @@ # Enforce boolean attributes notation in JSX (react/jsx-boolean-value) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. [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. diff --git a/docs/rules/jsx-child-element-spacing.md b/docs/rules/jsx-child-element-spacing.md index c53aacf23c..def78dfd02 100644 --- a/docs/rules/jsx-child-element-spacing.md +++ b/docs/rules/jsx-child-element-spacing.md @@ -1,5 +1,7 @@ # Enforce or disallow spaces inside of curly braces in JSX attributes and expressions (react/jsx-child-element-spacing) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + ## Rule Details Since React removes extraneous new lines between elements when possible, it is possible to end up with inline elements that are not rendered with spaces between them and adjacent text. This is often indicative of an error, so this rule attempts to detect JSX markup with ambiguous spacing. diff --git a/docs/rules/jsx-closing-bracket-location.md b/docs/rules/jsx-closing-bracket-location.md index c75131b8ff..f1f03e14b5 100644 --- a/docs/rules/jsx-closing-bracket-location.md +++ b/docs/rules/jsx-closing-bracket-location.md @@ -1,5 +1,7 @@ # Enforce closing bracket location in JSX (react/jsx-closing-bracket-location) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Enforce the closing bracket location for JSX multiline elements. diff --git a/docs/rules/jsx-closing-tag-location.md b/docs/rules/jsx-closing-tag-location.md index d86e97b58a..6cfb87505f 100644 --- a/docs/rules/jsx-closing-tag-location.md +++ b/docs/rules/jsx-closing-tag-location.md @@ -1,5 +1,7 @@ # Enforce closing tag location for multiline JSX (react/jsx-closing-tag-location) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Enforce the closing tag location for multiline JSX elements. diff --git a/docs/rules/jsx-curly-brace-presence.md b/docs/rules/jsx-curly-brace-presence.md index d9842581e1..f8a13c86de 100644 --- a/docs/rules/jsx-curly-brace-presence.md +++ b/docs/rules/jsx-curly-brace-presence.md @@ -1,5 +1,7 @@ # Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes (react/jsx-curly-brace-presence) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. This rule allows you to enforce curly braces or disallow unnecessary curly braces in JSX props and/or children. diff --git a/docs/rules/jsx-curly-newline.md b/docs/rules/jsx-curly-newline.md index 1946179bd8..29140a2e7b 100644 --- a/docs/rules/jsx-curly-newline.md +++ b/docs/rules/jsx-curly-newline.md @@ -1,5 +1,7 @@ # Enforce consistent linebreaks in curly braces in JSX attributes and expressions (react/jsx-curly-newline) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Many style guides require or disallow newlines inside of jsx curly expressions. diff --git a/docs/rules/jsx-curly-spacing.md b/docs/rules/jsx-curly-spacing.md index bf6b661526..e043253adb 100644 --- a/docs/rules/jsx-curly-spacing.md +++ b/docs/rules/jsx-curly-spacing.md @@ -1,5 +1,7 @@ # Enforce or disallow spaces inside of curly braces in JSX attributes and expressions (react/jsx-curly-spacing) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. While formatting preferences are very personal, a number of style guides require or disallow spaces between curly braces. diff --git a/docs/rules/jsx-equals-spacing.md b/docs/rules/jsx-equals-spacing.md index e0b328a44c..89f030a1d4 100644 --- a/docs/rules/jsx-equals-spacing.md +++ b/docs/rules/jsx-equals-spacing.md @@ -1,5 +1,7 @@ # Enforce or disallow spaces around equal signs in JSX attributes (react/jsx-equals-spacing) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Some style guides require or disallow spaces around equal signs. diff --git a/docs/rules/jsx-filename-extension.md b/docs/rules/jsx-filename-extension.md index 0260c2db2c..46d04e7a5d 100644 --- a/docs/rules/jsx-filename-extension.md +++ b/docs/rules/jsx-filename-extension.md @@ -1,5 +1,7 @@ # Disallow file extensions that may contain JSX (react/jsx-filename-extension) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + ## Rule Details Examples of **incorrect** code for this rule: diff --git a/docs/rules/jsx-first-prop-new-line.md b/docs/rules/jsx-first-prop-new-line.md index e6cf10a305..0078fe75dd 100644 --- a/docs/rules/jsx-first-prop-new-line.md +++ b/docs/rules/jsx-first-prop-new-line.md @@ -1,5 +1,7 @@ # Enforce proper position of the first property in JSX (react/jsx-first-prop-new-line) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Ensure correct position of the first property. diff --git a/docs/rules/jsx-fragments.md b/docs/rules/jsx-fragments.md index 7b9e72d36f..6a1dd288b3 100644 --- a/docs/rules/jsx-fragments.md +++ b/docs/rules/jsx-fragments.md @@ -1,5 +1,7 @@ # Enforce shorthand or standard form for React fragments (react/jsx-fragments) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. In JSX, a React [fragment] is created either with `...`, or, using the shorthand syntax, `<>...`. diff --git a/docs/rules/jsx-handler-names.md b/docs/rules/jsx-handler-names.md index ec0881bdcc..0206526f0d 100644 --- a/docs/rules/jsx-handler-names.md +++ b/docs/rules/jsx-handler-names.md @@ -1,5 +1,7 @@ # Enforce event handler naming conventions in JSX (react/jsx-handler-names) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Ensures that any component or prop methods used to handle events are correctly prefixed. ## Rule Details diff --git a/docs/rules/jsx-indent-props.md b/docs/rules/jsx-indent-props.md index 6800f5aa31..0cd82fea10 100644 --- a/docs/rules/jsx-indent-props.md +++ b/docs/rules/jsx-indent-props.md @@ -1,5 +1,7 @@ # Enforce props indentation in JSX (react/jsx-indent-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. This option validates a specific indentation style for props. diff --git a/docs/rules/jsx-indent.md b/docs/rules/jsx-indent.md index d177073de8..5c6485bc14 100644 --- a/docs/rules/jsx-indent.md +++ b/docs/rules/jsx-indent.md @@ -1,5 +1,7 @@ # Enforce JSX indentation (react/jsx-indent) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. This option validates a specific indentation style for JSX. diff --git a/docs/rules/jsx-key.md b/docs/rules/jsx-key.md index 17c71c433d..3496dca205 100644 --- a/docs/rules/jsx-key.md +++ b/docs/rules/jsx-key.md @@ -1,5 +1,7 @@ # Disallow missing `key` props in iterators/collection literals (react/jsx-key) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + Warn if an element that likely requires a `key` prop--namely, one present in an array literal or an arrow function expression. diff --git a/docs/rules/jsx-max-depth.md b/docs/rules/jsx-max-depth.md index 1ddeaec24a..0336f198bc 100644 --- a/docs/rules/jsx-max-depth.md +++ b/docs/rules/jsx-max-depth.md @@ -1,5 +1,7 @@ # Enforce JSX maximum depth (react/jsx-max-depth) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + This option validates a specific depth for JSX. ## Rule Details diff --git a/docs/rules/jsx-max-props-per-line.md b/docs/rules/jsx-max-props-per-line.md index c4110ba465..612e3f702f 100644 --- a/docs/rules/jsx-max-props-per-line.md +++ b/docs/rules/jsx-max-props-per-line.md @@ -1,5 +1,7 @@ # Enforce maximum of props on a single line in JSX (react/jsx-max-props-per-line) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Limiting the maximum of props on a single line can improve readability. diff --git a/docs/rules/jsx-newline.md b/docs/rules/jsx-newline.md index 8842204235..7394a1e93d 100644 --- a/docs/rules/jsx-newline.md +++ b/docs/rules/jsx-newline.md @@ -1,5 +1,7 @@ # Require or prevent a new line after jsx elements and expressions. (react/jsx-newline) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. ## Rule Details diff --git a/docs/rules/jsx-no-bind.md b/docs/rules/jsx-no-bind.md index e36c69e7b9..52f5663858 100644 --- a/docs/rules/jsx-no-bind.md +++ b/docs/rules/jsx-no-bind.md @@ -1,5 +1,7 @@ # Disallow `.bind()` or arrow functions in JSX props (react/jsx-no-bind) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + A `bind` call or [arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) in a JSX prop will create a brand new function on every single render. This is bad for performance, as it may cause unnecessary re-renders if a brand new function is passed as a prop to a component that uses reference equality check on the prop to determine if it should update. Note that this behavior is different for `ref` props, which is a special case in React that **does not** cause re-renders when a brand new function is passed. See [`ignore-refs`](#ignorerefs) below for more information. diff --git a/docs/rules/jsx-no-comment-textnodes.md b/docs/rules/jsx-no-comment-textnodes.md index 4a1f1ff310..45608961f3 100644 --- a/docs/rules/jsx-no-comment-textnodes.md +++ b/docs/rules/jsx-no-comment-textnodes.md @@ -1,5 +1,7 @@ # Disallow comments from being inserted as text nodes (react/jsx-no-comment-textnodes) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + This rule prevents comment strings (e.g. beginning with `//` or `/*`) from being accidentally injected as a text node in JSX statements. diff --git a/docs/rules/jsx-no-constructed-context-values.md b/docs/rules/jsx-no-constructed-context-values.md index a08e415cf0..51f6d8b66a 100644 --- a/docs/rules/jsx-no-constructed-context-values.md +++ b/docs/rules/jsx-no-constructed-context-values.md @@ -1,5 +1,7 @@ # Disallows JSX context provider values from taking values that will cause needless rerenders (react/jsx-no-constructed-context-values) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + This rule prevents non-stable values (i.e. object identities) from being used as a value for `Context.Provider`. ## Rule Details diff --git a/docs/rules/jsx-no-duplicate-props.md b/docs/rules/jsx-no-duplicate-props.md index 22c462fefd..be5770e6d9 100644 --- a/docs/rules/jsx-no-duplicate-props.md +++ b/docs/rules/jsx-no-duplicate-props.md @@ -1,5 +1,7 @@ # Disallow duplicate properties in JSX (react/jsx-no-duplicate-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + Creating JSX elements with duplicate props can cause unexpected behavior in your application. ## Rule Details diff --git a/docs/rules/jsx-no-leaked-render.md b/docs/rules/jsx-no-leaked-render.md index 0934ec69ba..89174ae351 100644 --- a/docs/rules/jsx-no-leaked-render.md +++ b/docs/rules/jsx-no-leaked-render.md @@ -1,5 +1,7 @@ # Disallow problematic leaked values from being rendered (react/jsx-no-leaked-render) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Using the `&&` operator to render some element conditionally in JSX can cause unexpected values being rendered, or even crashing the rendering. diff --git a/docs/rules/jsx-no-literals.md b/docs/rules/jsx-no-literals.md index 0970652996..07fd7031f3 100644 --- a/docs/rules/jsx-no-literals.md +++ b/docs/rules/jsx-no-literals.md @@ -1,5 +1,7 @@ # Disallow usage of string literals in JSX (react/jsx-no-literals) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + There are a few scenarios where you want to avoid string literals in JSX. You may want to enforce consistency, reduce syntax highlighting issues, or ensure that strings are part of a translation system. ## Rule Details diff --git a/docs/rules/jsx-no-script-url.md b/docs/rules/jsx-no-script-url.md index 86535f4ad1..3e94428f4c 100644 --- a/docs/rules/jsx-no-script-url.md +++ b/docs/rules/jsx-no-script-url.md @@ -1,5 +1,7 @@ # Disallow usage of `javascript:` URLs (react/jsx-no-script-url) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + **In React 16.9** any URLs starting with `javascript:` [scheme](https://wiki.whatwg.org/wiki/URL_schemes#javascript:_URLs) log a warning. React considers the pattern as a dangerous attack surface, see [details](https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#deprecating-javascript-urls). **In a future major release**, React will throw an error if it encounters a `javascript:` URL. diff --git a/docs/rules/jsx-no-target-blank.md b/docs/rules/jsx-no-target-blank.md index be7f15877e..3d6ea853d0 100644 --- a/docs/rules/jsx-no-target-blank.md +++ b/docs/rules/jsx-no-target-blank.md @@ -1,5 +1,7 @@ # Disallow `target="_blank"` attribute without `rel="noreferrer"` (react/jsx-no-target-blank) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. 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) diff --git a/docs/rules/jsx-no-undef.md b/docs/rules/jsx-no-undef.md index 4ce62e880d..28839398ba 100644 --- a/docs/rules/jsx-no-undef.md +++ b/docs/rules/jsx-no-undef.md @@ -1,5 +1,7 @@ # Disallow undeclared variables in JSX (react/jsx-no-undef) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + This rule helps locate potential ReferenceErrors resulting from misspellings or missing components. ## Rule Details diff --git a/docs/rules/jsx-no-useless-fragment.md b/docs/rules/jsx-no-useless-fragment.md index 987efde561..7e0884e553 100644 --- a/docs/rules/jsx-no-useless-fragment.md +++ b/docs/rules/jsx-no-useless-fragment.md @@ -1,5 +1,7 @@ # Disallow unnecessary fragments (react/jsx-no-useless-fragment) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. 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). diff --git a/docs/rules/jsx-one-expression-per-line.md b/docs/rules/jsx-one-expression-per-line.md index f922f03383..a733f8df0c 100644 --- a/docs/rules/jsx-one-expression-per-line.md +++ b/docs/rules/jsx-one-expression-per-line.md @@ -1,5 +1,7 @@ # Require one JSX element per line (react/jsx-one-expression-per-line) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. This option limits every line in JSX to one expression each. diff --git a/docs/rules/jsx-pascal-case.md b/docs/rules/jsx-pascal-case.md index 1fef7d42cd..cf851229bf 100644 --- a/docs/rules/jsx-pascal-case.md +++ b/docs/rules/jsx-pascal-case.md @@ -1,5 +1,7 @@ # Enforce PascalCase for user-defined JSX components (react/jsx-pascal-case) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Enforces coding style that user-defined JSX components are defined and referenced in PascalCase. Note that since React's JSX uses the upper vs. lower case convention to distinguish between local component classes and HTML tags this rule will not warn on components that start with a lower case letter. diff --git a/docs/rules/jsx-props-no-multi-spaces.md b/docs/rules/jsx-props-no-multi-spaces.md index e957641903..f00399bace 100644 --- a/docs/rules/jsx-props-no-multi-spaces.md +++ b/docs/rules/jsx-props-no-multi-spaces.md @@ -1,5 +1,7 @@ # Disallow multiple spaces between inline JSX props (react/jsx-props-no-multi-spaces) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Enforces that there is exactly one space between all attributes and after tag name and the first attribute in the same line. diff --git a/docs/rules/jsx-props-no-spreading.md b/docs/rules/jsx-props-no-spreading.md index ce7c4e48b5..c7b0de9676 100644 --- a/docs/rules/jsx-props-no-spreading.md +++ b/docs/rules/jsx-props-no-spreading.md @@ -1,5 +1,7 @@ # Disallow JSX prop spreading (react/jsx-props-no-spreading) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Enforces that there is no spreading for any JSX attribute. This enhances readability of code by being more explicit about what props are received by the component. It is also good for maintainability by avoiding passing unintentional extra props and allowing react to emit warnings when invalid HTML props are passed to HTML elements. ## Rule Details diff --git a/docs/rules/jsx-sort-default-props.md b/docs/rules/jsx-sort-default-props.md index b57c52080b..ef0bace988 100644 --- a/docs/rules/jsx-sort-default-props.md +++ b/docs/rules/jsx-sort-default-props.md @@ -1,5 +1,7 @@ # Enforce defaultProps declarations alphabetical sorting (react/jsx-sort-default-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Some developers prefer to sort `defaultProps` declarations alphabetically to be able to find necessary declarations easier at a later time. Others feel that it adds complexity and becomes a burden to maintain. ## Rule Details diff --git a/docs/rules/jsx-sort-props.md b/docs/rules/jsx-sort-props.md index d7085b3370..e0541b5690 100644 --- a/docs/rules/jsx-sort-props.md +++ b/docs/rules/jsx-sort-props.md @@ -1,5 +1,7 @@ # Enforce props alphabetical sorting (react/jsx-sort-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. 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. diff --git a/docs/rules/jsx-tag-spacing.md b/docs/rules/jsx-tag-spacing.md index 2f74294d91..bfad5b7955 100644 --- a/docs/rules/jsx-tag-spacing.md +++ b/docs/rules/jsx-tag-spacing.md @@ -1,5 +1,7 @@ # Enforce whitespace in and around the JSX opening and closing brackets (react/jsx-tag-spacing) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. 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. diff --git a/docs/rules/jsx-uses-react.md b/docs/rules/jsx-uses-react.md index df88fc3337..d01963215f 100644 --- a/docs/rules/jsx-uses-react.md +++ b/docs/rules/jsx-uses-react.md @@ -1,5 +1,7 @@ # Disallow React to be incorrectly marked as unused (react/jsx-uses-react) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + JSX expands to a call to `React.createElement`, a file which includes `React` but only uses JSX should consider the `React` variable as used. diff --git a/docs/rules/jsx-uses-vars.md b/docs/rules/jsx-uses-vars.md index b5acbf8c2e..eb87f1f094 100644 --- a/docs/rules/jsx-uses-vars.md +++ b/docs/rules/jsx-uses-vars.md @@ -1,5 +1,7 @@ # Disallow variables used in JSX to be incorrectly marked as unused (react/jsx-uses-vars) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + 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. This rule only has an effect when the `no-unused-vars` rule is enabled. diff --git a/docs/rules/jsx-wrap-multilines.md b/docs/rules/jsx-wrap-multilines.md index 0941eef45d..cd1a758e62 100644 --- a/docs/rules/jsx-wrap-multilines.md +++ b/docs/rules/jsx-wrap-multilines.md @@ -1,5 +1,7 @@ # Disallow missing parentheses around multiline JSX (react/jsx-wrap-multilines) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Wrapping multiline JSX in parentheses can improve readability and/or convenience. diff --git a/docs/rules/no-access-state-in-setstate.md b/docs/rules/no-access-state-in-setstate.md index e65f7f4bce..7d710c3bcd 100644 --- a/docs/rules/no-access-state-in-setstate.md +++ b/docs/rules/no-access-state-in-setstate.md @@ -1,5 +1,7 @@ # Disallow when this.state is accessed within setState (react/no-access-state-in-setstate) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Usage of `this.state` inside `setState` calls might result in errors when two state calls are called in batch and thus referencing old state and not the current state. ## Rule Details diff --git a/docs/rules/no-adjacent-inline-elements.md b/docs/rules/no-adjacent-inline-elements.md index ef14fdfc5b..c9194e65a3 100644 --- a/docs/rules/no-adjacent-inline-elements.md +++ b/docs/rules/no-adjacent-inline-elements.md @@ -1,5 +1,7 @@ # Disallow adjacent inline elements not separated by whitespace. (react/no-adjacent-inline-elements) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Adjacent inline elements not separated by whitespace will bump up against each other when viewed in an unstyled manner, which usually isn't desirable. diff --git a/docs/rules/no-array-index-key.md b/docs/rules/no-array-index-key.md index 7181bfda00..8c601c8c01 100644 --- a/docs/rules/no-array-index-key.md +++ b/docs/rules/no-array-index-key.md @@ -1,5 +1,7 @@ # Disallow usage of Array index in keys (react/no-array-index-key) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Warn if an element uses an Array index in its `key`. The `key` is used by React to [identify which items have changed, are added, or are removed and should be stable](https://facebook.github.io/react/docs/lists-and-keys.html#keys). diff --git a/docs/rules/no-arrow-function-lifecycle.md b/docs/rules/no-arrow-function-lifecycle.md index cffcc01972..ab2d6e173f 100644 --- a/docs/rules/no-arrow-function-lifecycle.md +++ b/docs/rules/no-arrow-function-lifecycle.md @@ -1,5 +1,7 @@ # Lifecycle methods should be methods on the prototype, not class fields (react/no-arrow-function-lifecycle) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. It is not necessary 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. diff --git a/docs/rules/no-children-prop.md b/docs/rules/no-children-prop.md index cca47f152a..fb6c7b5b99 100644 --- a/docs/rules/no-children-prop.md +++ b/docs/rules/no-children-prop.md @@ -1,5 +1,7 @@ # Disallow passing of children as props (react/no-children-prop) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + Children should always be actual children, not passed in as a prop. When using JSX, the children should be nested between the opening and closing diff --git a/docs/rules/no-danger-with-children.md b/docs/rules/no-danger-with-children.md index c7705a91ca..e749669cd9 100644 --- a/docs/rules/no-danger-with-children.md +++ b/docs/rules/no-danger-with-children.md @@ -1,5 +1,7 @@ # Disallow when a DOM element is using both children and dangerouslySetInnerHTML (react/no-danger-with-children) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + This rule helps prevent problems caused by using children and the dangerouslySetInnerHTML prop at the same time. React will throw a warning if this rule is ignored. diff --git a/docs/rules/no-danger.md b/docs/rules/no-danger.md index 4b205a9ffa..57e3490fc7 100644 --- a/docs/rules/no-danger.md +++ b/docs/rules/no-danger.md @@ -1,5 +1,7 @@ # Disallow usage of dangerous JSX properties (react/no-danger) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Dangerous properties in React are those whose behavior is known to be a common source of application vulnerabilities. The properties names clearly indicate they are dangerous and should be avoided unless great care is taken. See diff --git a/docs/rules/no-deprecated.md b/docs/rules/no-deprecated.md index 078d27b796..76850635a4 100644 --- a/docs/rules/no-deprecated.md +++ b/docs/rules/no-deprecated.md @@ -1,5 +1,7 @@ # Disallow usage of deprecated methods (react/no-deprecated) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + 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. ## Rule Details diff --git a/docs/rules/no-did-mount-set-state.md b/docs/rules/no-did-mount-set-state.md index edee2669c2..41612d302e 100644 --- a/docs/rules/no-did-mount-set-state.md +++ b/docs/rules/no-did-mount-set-state.md @@ -1,5 +1,7 @@ # Disallow usage of setState in componentDidMount (react/no-did-mount-set-state) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Updating the state after a component mount will trigger a second `render()` call and can lead to property/layout thrashing. ## Rule Details diff --git a/docs/rules/no-did-update-set-state.md b/docs/rules/no-did-update-set-state.md index 56ea075cdb..9595937167 100644 --- a/docs/rules/no-did-update-set-state.md +++ b/docs/rules/no-did-update-set-state.md @@ -1,5 +1,7 @@ # Disallow usage of setState in componentDidUpdate (react/no-did-update-set-state) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Updating the state after a component update will trigger a second `render()` call and can lead to property/layout thrashing. ## Rule Details diff --git a/docs/rules/no-direct-mutation-state.md b/docs/rules/no-direct-mutation-state.md index 921f4037f0..2d34831c58 100644 --- a/docs/rules/no-direct-mutation-state.md +++ b/docs/rules/no-direct-mutation-state.md @@ -1,5 +1,7 @@ # Disallow direct mutation of this.state (react/no-direct-mutation-state) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + NEVER mutate `this.state` directly, as calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable. diff --git a/docs/rules/no-find-dom-node.md b/docs/rules/no-find-dom-node.md index f95bbec7a7..b1715237e4 100644 --- a/docs/rules/no-find-dom-node.md +++ b/docs/rules/no-find-dom-node.md @@ -1,5 +1,7 @@ # Disallow usage of findDOMNode (react/no-find-dom-node) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + Facebook will eventually deprecate `findDOMNode` as it blocks certain improvements in React in the future. 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). diff --git a/docs/rules/no-invalid-html-attribute.md b/docs/rules/no-invalid-html-attribute.md index cb94390599..762537dcf9 100644 --- a/docs/rules/no-invalid-html-attribute.md +++ b/docs/rules/no-invalid-html-attribute.md @@ -1,5 +1,7 @@ # Disallow usage of invalid attributes (react/no-invalid-html-attribute) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Some HTML elements have a specific set of valid values for some attributes. diff --git a/docs/rules/no-is-mounted.md b/docs/rules/no-is-mounted.md index cbf7d7b69d..02a17e64f9 100644 --- a/docs/rules/no-is-mounted.md +++ b/docs/rules/no-is-mounted.md @@ -1,5 +1,7 @@ # Disallow usage of isMounted (react/no-is-mounted) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + [`isMounted` is an anti-pattern][anti-pattern], is not available when using ES6 classes, and it is on its way to being officially deprecated. [anti-pattern]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html diff --git a/docs/rules/no-multi-comp.md b/docs/rules/no-multi-comp.md index e32e1d3fa4..2c9bce724d 100644 --- a/docs/rules/no-multi-comp.md +++ b/docs/rules/no-multi-comp.md @@ -1,5 +1,7 @@ # Disallow multiple component definition per file (react/no-multi-comp) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Declaring only one component per file improves readability and reusability of components. ## Rule Details diff --git a/docs/rules/no-namespace.md b/docs/rules/no-namespace.md index ee202f62c0..84a2ff560e 100644 --- a/docs/rules/no-namespace.md +++ b/docs/rules/no-namespace.md @@ -1,5 +1,7 @@ # Enforce that namespaces are not used in React elements (react/no-namespace) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Enforces the absence of a namespace in React elements, such as with `svg:circle`, as they are not supported in React. ## Rule Details diff --git a/docs/rules/no-redundant-should-component-update.md b/docs/rules/no-redundant-should-component-update.md index c629bd6869..4658db5c6e 100644 --- a/docs/rules/no-redundant-should-component-update.md +++ b/docs/rules/no-redundant-should-component-update.md @@ -1,5 +1,7 @@ # Disallow usage of shouldComponentUpdate when extending React.PureComponent (react/no-redundant-should-component-update) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Warns if you have `shouldComponentUpdate` defined when defining a component that extends React.PureComponent. While having `shouldComponentUpdate` will still work, it becomes pointless to extend PureComponent. diff --git a/docs/rules/no-render-return-value.md b/docs/rules/no-render-return-value.md index 904d901c8a..7ba80f2ac2 100644 --- a/docs/rules/no-render-return-value.md +++ b/docs/rules/no-render-return-value.md @@ -1,5 +1,7 @@ # Disallow usage of the return value of ReactDOM.render (react/no-render-return-value) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + > `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. Source: [ReactDOM documentation](https://facebook.github.io/react/docs/react-dom.html#render) diff --git a/docs/rules/no-set-state.md b/docs/rules/no-set-state.md index 9eeace3a1c..19ee90b18d 100644 --- a/docs/rules/no-set-state.md +++ b/docs/rules/no-set-state.md @@ -1,5 +1,7 @@ # Disallow usage of setState (react/no-set-state) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + When using an architecture that separates your application state from your UI components (e.g. Flux), it may be desirable to forbid the use of local component state. This rule is especially helpful in read-only applications (that don't use forms), since local component state should rarely be necessary in such cases. ## Rule Details diff --git a/docs/rules/no-string-refs.md b/docs/rules/no-string-refs.md index 577f494bc8..07764d5ed8 100644 --- a/docs/rules/no-string-refs.md +++ b/docs/rules/no-string-refs.md @@ -1,5 +1,7 @@ # Disallow using string references (react/no-string-refs) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + 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. ## Rule Details diff --git a/docs/rules/no-this-in-sfc.md b/docs/rules/no-this-in-sfc.md index 328914369f..6e1d738a76 100644 --- a/docs/rules/no-this-in-sfc.md +++ b/docs/rules/no-this-in-sfc.md @@ -1,5 +1,7 @@ # Disallow `this` from being used in stateless functional components (react/no-this-in-sfc) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + In React, there are two styles of component. One is a class component: `class Foo extends React.Component {...}`, which accesses its props, context, and state as properties of `this`: `this.props.foo`, etc. The other are stateless functional components (SFCs): `function Foo(props, context) {...}`. As you can see, there's no `state` (hence the name - hooks do not change this), and the props and context are provided as its two functional arguments. In an SFC, state is usually best implements with a [React hook](https://reactjs.org/docs/hooks-overview.html) such as `React.useState()`. Attempting to access properties on `this` can sometimes be valid, but it's very commonly an error caused by unfamiliarity with the differences between the two styles of components, or a missed reference when converting a class component to an SFC. diff --git a/docs/rules/no-typos.md b/docs/rules/no-typos.md index e26a1dbb32..d5ca302725 100644 --- a/docs/rules/no-typos.md +++ b/docs/rules/no-typos.md @@ -1,5 +1,7 @@ # Disallow common typos (react/no-typos) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Ensure no casing typos were made declaring static class properties and lifecycle methods. Checks that declared `propTypes`, `contextTypes` and `childContextTypes` is supported by [react-props](https://github.com/facebook/prop-types) diff --git a/docs/rules/no-unescaped-entities.md b/docs/rules/no-unescaped-entities.md index d722b5942d..79eb1325df 100644 --- a/docs/rules/no-unescaped-entities.md +++ b/docs/rules/no-unescaped-entities.md @@ -1,5 +1,7 @@ # Disallow unescaped HTML entities from appearing in markup (react/no-unescaped-entities) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + This rule prevents characters that you may have meant as JSX escape characters from being accidentally injected as a text node in JSX statements. diff --git a/docs/rules/no-unknown-property.md b/docs/rules/no-unknown-property.md index 65f8a40916..79720754c2 100644 --- a/docs/rules/no-unknown-property.md +++ b/docs/rules/no-unknown-property.md @@ -1,5 +1,7 @@ # Disallow usage of unknown DOM property (react/no-unknown-property) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. 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. diff --git a/docs/rules/no-unsafe.md b/docs/rules/no-unsafe.md index 5770a93df9..d5d5872b83 100644 --- a/docs/rules/no-unsafe.md +++ b/docs/rules/no-unsafe.md @@ -1,5 +1,7 @@ # Disallow usage of unsafe lifecycle methods (react/no-unsafe) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Certain legacy lifecycle methods are [unsafe for use in async React applications][async_rendering] and cause warnings in [_strict mode_][strict_mode]. These also happen to be the lifecycles that cause the most [confusion within the React community][component_lifecycle_changes]. [async_rendering]: https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html diff --git a/docs/rules/no-unstable-nested-components.md b/docs/rules/no-unstable-nested-components.md index eb60731ebc..24b0fbb280 100644 --- a/docs/rules/no-unstable-nested-components.md +++ b/docs/rules/no-unstable-nested-components.md @@ -1,5 +1,7 @@ # Disallow creating unstable components inside components (react/no-unstable-nested-components) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Creating components inside components without memoization leads to unstable components. The nested component and all its children are recreated during each re-render. Given stateful children of the nested component will lose their state on each re-render. React reconciliation performs element type comparison with [reference equality](https://github.com/facebook/react/blob/v16.13.1/packages/react-reconciler/src/ReactChildFiber.js#L407). The reference to the same element changes on each re-render when defining components inside the render block. This leads to complete recreation of the current node and all its children. As a result the virtual DOM has to do extra unnecessary work and [possible bugs are introduced](https://codepen.io/ariperkkio/pen/vYLodLB). diff --git a/docs/rules/no-unused-class-component-methods.md b/docs/rules/no-unused-class-component-methods.md index abe2f8ae21..d7bfac617f 100644 --- a/docs/rules/no-unused-class-component-methods.md +++ b/docs/rules/no-unused-class-component-methods.md @@ -1,5 +1,7 @@ # Disallow declaring unused methods of component class (react/no-unused-class-component-methods) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Warns you if you have defined a method or property but it is never being used anywhere. ## Rule Details diff --git a/docs/rules/no-unused-prop-types.md b/docs/rules/no-unused-prop-types.md index 5bfa621f0e..18de3901dc 100644 --- a/docs/rules/no-unused-prop-types.md +++ b/docs/rules/no-unused-prop-types.md @@ -1,5 +1,7 @@ # Disallow definitions of unused propTypes (react/no-unused-prop-types) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Warns if a prop with a defined type isn't being used. > **Note**: You can provide types in runtime types using [PropTypes] and/or diff --git a/docs/rules/no-unused-state.md b/docs/rules/no-unused-state.md index 0cf052fe24..d5bcde7748 100644 --- a/docs/rules/no-unused-state.md +++ b/docs/rules/no-unused-state.md @@ -1,5 +1,7 @@ # Disallow definitions of unused state (react/no-unused-state) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Warns you if you have defined a property on the state, but it is not being used anywhere. ## Rule Details diff --git a/docs/rules/no-will-update-set-state.md b/docs/rules/no-will-update-set-state.md index bdcb07a38b..f85b227219 100644 --- a/docs/rules/no-will-update-set-state.md +++ b/docs/rules/no-will-update-set-state.md @@ -1,5 +1,7 @@ # Disallow usage of setState in componentWillUpdate (react/no-will-update-set-state) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Updating the state during the componentWillUpdate step can lead to indeterminate component state and is not allowed. ## Rule Details diff --git a/docs/rules/prefer-es6-class.md b/docs/rules/prefer-es6-class.md index 93871536d6..d0a6f12b34 100644 --- a/docs/rules/prefer-es6-class.md +++ b/docs/rules/prefer-es6-class.md @@ -1,5 +1,7 @@ # Enforce ES5 or ES6 class for React Components (react/prefer-es6-class) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + React offers you two ways to create traditional components: using the ES5 `create-react-class` module or the new ES6 class system. ## Rule Details diff --git a/docs/rules/prefer-exact-props.md b/docs/rules/prefer-exact-props.md index 297a5204ef..274f601c73 100644 --- a/docs/rules/prefer-exact-props.md +++ b/docs/rules/prefer-exact-props.md @@ -1,5 +1,7 @@ # Prefer exact proptype definitions (react/prefer-exact-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Recommends options to ensure only exact prop definitions are used when writing components. This recommends solutions for PropTypes or for Flow types. In React, you can define prop types for components using propTypes. Such an example is below: diff --git a/docs/rules/prefer-read-only-props.md b/docs/rules/prefer-read-only-props.md index 5d117d7baa..e3a3d36163 100644 --- a/docs/rules/prefer-read-only-props.md +++ b/docs/rules/prefer-read-only-props.md @@ -1,5 +1,7 @@ # Enforce that props are read-only (react/prefer-read-only-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Using Flow, one can define types for props. This rule enforces that prop types are read-only (covariant). diff --git a/docs/rules/prefer-stateless-function.md b/docs/rules/prefer-stateless-function.md index 8521a0b045..4626b4ef98 100644 --- a/docs/rules/prefer-stateless-function.md +++ b/docs/rules/prefer-stateless-function.md @@ -1,5 +1,7 @@ # Enforce stateless components to be written as a pure function (react/prefer-stateless-function) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Stateless functional components are simpler than class based components and will benefit from future React performance optimizations specific to these components. ## Rule Details diff --git a/docs/rules/prop-types.md b/docs/rules/prop-types.md index e8764ae456..7067b4ffb2 100644 --- a/docs/rules/prop-types.md +++ b/docs/rules/prop-types.md @@ -1,5 +1,7 @@ # Disallow missing props validation in a React component definition (react/prop-types) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + Defining types for component props improves reusability of your components by validating received data. It can warn other developers if they make a mistake while reusing the component with improper data type. diff --git a/docs/rules/react-in-jsx-scope.md b/docs/rules/react-in-jsx-scope.md index 6af904b2c0..6247a2bff8 100644 --- a/docs/rules/react-in-jsx-scope.md +++ b/docs/rules/react-in-jsx-scope.md @@ -1,5 +1,7 @@ # Disallow missing React when using JSX (react/react-in-jsx-scope) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + When using JSX, `` expands to `React.createElement("a")`. Therefore the `React` variable must be in scope. If you are using the @jsx pragma this rule will check the designated variable and not the `React` one. diff --git a/docs/rules/require-default-props.md b/docs/rules/require-default-props.md index 6a35c670e6..c3e9a48be9 100644 --- a/docs/rules/require-default-props.md +++ b/docs/rules/require-default-props.md @@ -1,5 +1,7 @@ # Enforce a defaultProps definition for every prop that is not a required prop (react/require-default-props) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + This rule aims to ensure that any non-required prop types of a component has a corresponding `defaultProps` value. diff --git a/docs/rules/require-optimization.md b/docs/rules/require-optimization.md index 59f2eda2b0..55c25287c3 100644 --- a/docs/rules/require-optimization.md +++ b/docs/rules/require-optimization.md @@ -1,5 +1,7 @@ # Enforce React components to have a shouldComponentUpdate method (react/require-optimization) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + This rule prevents you from creating React components without declaring a `shouldComponentUpdate` method. ## Rule Details diff --git a/docs/rules/require-render-return.md b/docs/rules/require-render-return.md index 009d8f7628..beb37d04ce 100644 --- a/docs/rules/require-render-return.md +++ b/docs/rules/require-render-return.md @@ -1,5 +1,7 @@ # Enforce ES5 or ES6 class for returning value in render function (react/require-render-return) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all`, `recommended` + 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. ## Rule Details diff --git a/docs/rules/self-closing-comp.md b/docs/rules/self-closing-comp.md index 0dd0b2de51..422639d6b1 100644 --- a/docs/rules/self-closing-comp.md +++ b/docs/rules/self-closing-comp.md @@ -1,5 +1,7 @@ # Disallow extra closing tags for components without children (react/self-closing-comp) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line. Components without children can be self-closed to avoid unnecessary extra closing tag. diff --git a/docs/rules/sort-comp.md b/docs/rules/sort-comp.md index f8ce13103e..9d12f01c8e 100644 --- a/docs/rules/sort-comp.md +++ b/docs/rules/sort-comp.md @@ -1,5 +1,7 @@ # Enforce component methods order (react/sort-comp) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + 🔧 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). 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. diff --git a/docs/rules/sort-prop-types.md b/docs/rules/sort-prop-types.md index 5009c1e493..d452830002 100644 --- a/docs/rules/sort-prop-types.md +++ b/docs/rules/sort-prop-types.md @@ -1,5 +1,7 @@ # Enforce propTypes declarations alphabetical sorting (react/sort-prop-types) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Some developers prefer to sort prop type declarations alphabetically to be able to find necessary declaration easier at the later time. Others feel that it adds complexity and becomes burden to maintain. ## Rule Details diff --git a/docs/rules/state-in-constructor.md b/docs/rules/state-in-constructor.md index a4069bdc9f..27c2a84f2c 100644 --- a/docs/rules/state-in-constructor.md +++ b/docs/rules/state-in-constructor.md @@ -1,5 +1,7 @@ # Enforce class component state initialization style (react/state-in-constructor) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + ## Rule Details This rule will enforce the state initialization style to be either in a constructor or with a class property. diff --git a/docs/rules/static-property-placement.md b/docs/rules/static-property-placement.md index 95ed62fe95..e343b8bfb2 100644 --- a/docs/rules/static-property-placement.md +++ b/docs/rules/static-property-placement.md @@ -1,5 +1,7 @@ # Enforces where React component static properties should be positioned. (react/static-property-placement) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + This rule allows you to enforce where `childContextTypes`, `contextTypes`, `contextType`, `defaultProps`, `displayName`, and `propTypes` are declared in an ES6 class. diff --git a/docs/rules/style-prop-object.md b/docs/rules/style-prop-object.md index 36f38a7fc9..4b93c36063 100644 --- a/docs/rules/style-prop-object.md +++ b/docs/rules/style-prop-object.md @@ -1,5 +1,7 @@ # Enforce style prop value is an object (react/style-prop-object) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + Require that the value of the prop `style` be an object or a variable that is an object. diff --git a/docs/rules/void-dom-elements-no-children.md b/docs/rules/void-dom-elements-no-children.md index b8218565b1..8757fb4455 100644 --- a/docs/rules/void-dom-elements-no-children.md +++ b/docs/rules/void-dom-elements-no-children.md @@ -1,5 +1,7 @@ # Disallow void DOM elements (e.g. ``, `
`) from receiving children (react/void-dom-elements-no-children) +💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs: `all` + There are some HTML elements that are only self-closing (e.g. `img`, `br`, `hr`). These are collectively known as void DOM elements. If you try to give these children, React will give you a warning like: > Invariant Violation: img is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`. diff --git a/tests/index.js b/tests/index.js index 751ab579cb..604cf91cf2 100644 --- a/tests/index.js +++ b/tests/index.js @@ -24,11 +24,24 @@ describe('all rule files should be exported by the plugin', () => { describe('rule documentation files have the correct content', () => { const MESSAGES = { + config: '💼 This rule is part of the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations) configs:', deprecated: '❌ This rule is deprecated.', 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.', hasSuggestions: '💡 This rule provides editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).', }; + function getConfigsForRules(ruleName) { + const configNames = []; + Object.keys(plugin.configs).forEach((configName) => { + // Check that the rule is enabled in this config. + const value = plugin.configs[configName].rules[`react/${ruleName}`]; + if (value && ![0, 'off'].includes(value)) { + configNames.push(configName); + } + }); + return configNames.sort(); + } + ruleFiles.forEach((ruleName) => { it(ruleName, () => { const rule = plugin.rules[ruleName]; @@ -48,6 +61,9 @@ describe('rule documentation files have the correct content', () => { } else { unexpectedNotices.push('deprecated'); } + if (!rule.meta.deprecated) { + expectedNotices.push('config'); + } if (rule.meta.fixable) { expectedNotices.push('fixable'); } else { @@ -66,6 +82,10 @@ describe('rule documentation files have the correct content', () => { if (expectedNotice === 'deprecated' && documentLines[currentLineNumber + 1] !== MESSAGES[expectedNotice] && documentLines[currentLineNumber + 1].startsWith(MESSAGES[expectedNotice])) { // Allow additional rule-specific information at the end of the deprecation notice line. assert.ok(true, `includes ${expectedNotice} notice`); + } else if (expectedNotice === 'config') { + // Check that the rule specifies its configs. + const expectedConfigs = `\`${getConfigsForRules(ruleName).join('`, `')}\``; + assert.strictEqual(documentLines[currentLineNumber + 1], `${MESSAGES[expectedNotice]} ${expectedConfigs}`, `includes ${expectedNotice} notice`); } else { // Otherwise, just check the whole line. assert.strictEqual(documentLines[currentLineNumber + 1], MESSAGES[expectedNotice], `includes ${expectedNotice} notice`);