diff --git a/README.md b/README.md index 555ac19..eccc0e1 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ All peer dependencies used by `@code-pushup/eslint-config` are listed below, alo |  | [eslint-plugin-cypress](https://www.npmjs.com/package/eslint-plugin-cypress) | `>=3.3.0` | | |  | [eslint-plugin-jest](https://www.npmjs.com/package/eslint-plugin-jest) | `^28.8.0` | | |  | [eslint-plugin-jest-formatting](https://www.npmjs.com/package/eslint-plugin-jest-formatting) | `^3.0.0` | | +|  | [eslint-plugin-jsx-a11y](https://www.npmjs.com/package/eslint-plugin-jsx-a11y) | `^6.10.0` | | |  | [eslint-plugin-n](https://www.npmjs.com/package/eslint-plugin-n) | `>=17.0.0` | | |  | [eslint-plugin-playwright](https://www.npmjs.com/package/eslint-plugin-playwright) | `^2.1.0` | | |  | [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) | `^7.36.0` | | diff --git a/docs/icons/icons8/accessibility.png b/docs/icons/icons8/accessibility.png new file mode 100644 index 0000000..2c78241 Binary files /dev/null and b/docs/icons/icons8/accessibility.png differ diff --git a/docs/react.md b/docs/react.md index 81910f9..6ecfdd0 100644 --- a/docs/react.md +++ b/docs/react.md @@ -8,7 +8,7 @@ Config for **React** projects. 2. Since this plugin requires additional peer dependencies, you have to install them as well: ```sh - npm install -D eslint-plugin-{react,react-hooks} + npm install -D eslint-plugin-{jsx-a11y,react,react-hooks} ``` 3. Add to your `eslint.config.js` file: @@ -20,85 +20,117 @@ Config for **React** projects. export default tseslint.config(...react); ``` -## ๐ Rules (69) +## ๐ Rules (101) > ๐ง Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).๐ก Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).๐งช๐ซ Disabled for [test files](../README.md#๐งช-test-overrides).๐งชโ ๏ธ Severity lessened to warning for [test files](../README.md#๐งช-test-overrides). -### ๐จ Errors (43) +### ๐จ Errors (72) -| Plugin | Rule | Options | Autofix | Overrides | -| :------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :-----: | :-------: | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [button-has-type](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/button-has-type.md)Disallow usage of `button` elements without an explicit `type` attribute | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [default-props-match-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/default-props-match-prop-types.md)Enforce all defaultProps have a corresponding non-required PropType | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [forbid-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-prop-types.md)Disallow certain propTypes | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [forward-ref-uses-ref](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forward-ref-uses-ref.md)Require all forwardRef components include a ref parameter | | ๐ก | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [iframe-missing-sandbox](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/iframe-missing-sandbox.md)Enforce sandbox attribute on iframe elements | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-key.md)Disallow missing `key` props in iterators/collection literals | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-bind](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-bind.md)Disallow `.bind()` or arrow functions in JSX props | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-comment-textnodes](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-comment-textnodes.md)Disallow comments from being inserted as text nodes | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-constructed-context-values](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-constructed-context-values.md)Disallows JSX context provider values from taking values that will cause needless rerenders | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-duplicate-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-duplicate-props.md)Disallow duplicate properties in JSX | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-script-url](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-script-url.md)Disallow usage of `javascript:` URLs | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-target-blank](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-target-blank.md)Disallow `target="_blank"` attribute without `rel="noreferrer"` | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-undef](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-undef.md)Disallow undeclared variables in JSX | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-uses-react](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-react.md)Disallow React to be incorrectly marked as unused | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-uses-vars](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-vars.md)Disallow variables used in JSX to be incorrectly marked as unused | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-access-state-in-setstate](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-access-state-in-setstate.md)Disallow when this.state is accessed within setState | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-array-index-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-array-index-key.md)Disallow usage of Array index in keys | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-children-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-children-prop.md)Disallow passing of children as props | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-danger](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger.md)Disallow usage of dangerous JSX properties | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-danger-with-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger-with-children.md)Disallow when a DOM element is using both children and dangerouslySetInnerHTML | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-deprecated](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-deprecated.md)Disallow usage of deprecated methods | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-did-mount-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-mount-set-state.md)Disallow usage of setState in componentDidMount | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-did-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-update-set-state.md)Disallow usage of setState in componentDidUpdate | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-direct-mutation-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-direct-mutation-state.md)Disallow direct mutation of this.state | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-find-dom-node](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-find-dom-node.md)Disallow usage of findDOMNode | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-invalid-html-attribute](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-invalid-html-attribute.md)Disallow usage of invalid attributes | | ๐ก | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-is-mounted](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-is-mounted.md)Disallow usage of isMounted | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-namespace](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-namespace.md)Enforce that namespaces are not used in React elements | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-object-type-as-default-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-object-type-as-default-prop.md)Disallow usage of referential-type variables as default param in functional component | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-render-return-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-render-return-value.md)Disallow usage of the return value of ReactDOM.render | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-string-refs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-string-refs.md)Disallow using string references | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-this-in-sfc](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-this-in-sfc.md)Disallow `this` from being used in stateless functional components | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-typos](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-typos.md)Disallow common typos | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unescaped-entities](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unescaped-entities.md)Disallow unescaped HTML entities from appearing in markup | | ๐ก | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unknown-property](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unknown-property.md)Disallow usage of unknown DOM property | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unstable-nested-components](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unstable-nested-components.md)Disallow creating unstable components inside components | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-will-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-will-update-set-state.md)Disallow usage of setState in componentWillUpdate | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prop-types.md)Disallow missing props validation in a React component definition | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [react-in-jsx-scope](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/react-in-jsx-scope.md)Disallow missing React when using JSX | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [require-render-return](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-render-return.md)Enforce ES5 or ES6 class for returning value in render function | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [void-dom-elements-no-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/void-dom-elements-no-children.md)Disallow void DOM elements (e.g. ``, ``) from receiving children | | | | -| [](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#readme) | [exhaustive-deps](https://github.com/facebook/react/issues/14920)verifies the list of dependencies for Hooks like useEffect and similar | | ๐ง, ๐ก | | -| [](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#readme) | [rules-of-hooks](https://reactjs.org/docs/hooks-rules.html)enforces the Rules of Hooks | | | | +| Plugin | Rule | Options | Autofix | Overrides | +| :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-------: | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [alt-text](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/alt-text.md)Enforce all elements that require alternative text have meaningful information to relay back to end user. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [anchor-has-content](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-has-content.md)Enforce all anchors to contain accessible content. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [anchor-is-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/anchor-is-valid.md)Enforce all anchors are valid, navigable elements. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [aria-activedescendant-has-tabindex](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-activedescendant-has-tabindex.md)Enforce elements with aria-activedescendant are tabbable. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-props.md)Enforce all `aria-*` props are valid. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [aria-proptypes](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-proptypes.md)Enforce ARIA state and property values are valid. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [aria-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-role.md)Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [aria-unsupported-elements](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/aria-unsupported-elements.md)Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [autocomplete-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/autocomplete-valid.md)Enforce that autocomplete attributes are used correctly. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [click-events-have-key-events](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/click-events-have-key-events.md)Enforce a clickable non-interactive element has at least one keyboard event listener. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [heading-has-content](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/heading-has-content.md)Enforce heading (`h1`, `h2`, etc) elements contain accessible content. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [html-has-lang](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/html-has-lang.md)Enforce `` element has `lang` prop. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [iframe-has-title](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/iframe-has-title.md)Enforce iframe elements have a title attribute. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [img-redundant-alt](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/img-redundant-alt.md)Enforce `` alt prop does not contain the word "image", "picture", or "photo". | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [interactive-supports-focus](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/interactive-supports-focus.md)Enforce that elements with interactive handlers like `onClick` must be focusable. | tabbable: button, checkbox,...{ "tabbable": [ "button", "checkbox", "link", "searchbox", "spinbutton", "switch", "textbox" ] } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [label-has-associated-control](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/label-has-associated-control.md)Enforce that a `label` tag has a text label and an associated control. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [media-has-caption](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/media-has-caption.md)Enforces that `` and `` elements must have a `` for captions. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [mouse-events-have-key-events](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/mouse-events-have-key-events.md)Enforce that `onMouseOver`/`onMouseOut` are accompanied by `onFocus`/`onBlur` for keyboard-only users. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-access-key](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-access-key.md)Enforce that the `accessKey` prop is not used on any element to avoid complications with keyboard commands used by a screen reader. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-distracting-elements](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-distracting-elements.md)Enforce distracting elements are not used. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-interactive-element-to-noninteractive-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-interactive-element-to-noninteractive-role.md)Interactive elements should not be assigned non-interactive roles. | tr: none, presentation, can...{ "tr": [ "none", "presentation" ], "canvas": [ "img" ] } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-noninteractive-element-interactions](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-noninteractive-element-interactions.md)Non-interactive elements should not be assigned mouse or keyboard event listeners. | handlers: onClick, onError,...{ "handlers": [ "onClick", "onError", "onLoad", "onMouseDown", "onMouseUp", "onKeyPress", "onKeyDown", "onKeyUp" ], "alert": [ "onKeyUp", "onKeyDown", "onKeyPress" ], "body": [ "onError", "onLoad" ], "dialog": [ "onKeyUp", "onKeyDown", "onKeyPress" ], "iframe": [ "onError", "onLoad" ], "img": [ "onError", "onLoad" ] } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-noninteractive-element-to-interactive-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-noninteractive-element-to-interactive-role.md)Non-interactive elements should not be assigned interactive roles. | ul: listbox, menu, menubar,...{ "ul": [ "listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid" ], "ol": [ "listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid" ], "li": [ "menuitem", "menuitemradio", "menuitemcheckbox", "option", "row", "tab", "treeitem" ], "table": [ "grid" ], "td": [ "gridcell" ], "fieldset": [ "radiogroup", "presentation" ] } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-noninteractive-tabindex](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-noninteractive-tabindex.md)`tabIndex` should only be declared on interactive elements. | tags: , roles: tabpanel, al...{ "tags": [], "roles": [ "tabpanel" ], "allowExpressionValues": true } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-static-element-interactions](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-static-element-interactions.md)Enforce that non-interactive, visible elements (such as ``) that have click handlers use the role attribute. | allowExpressionValues: true...{ "allowExpressionValues": true, "handlers": [ "onClick", "onMouseDown", "onMouseUp", "onKeyPress", "onKeyDown", "onKeyUp" ] } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [role-has-required-aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/role-has-required-aria-props.md)Enforce that elements with ARIA roles must have all required attributes for that role. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [role-supports-aria-props](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/role-supports-aria-props.md)Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [scope](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/scope.md)Enforce `scope` prop is only used on `` elements. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [tabindex-no-positive](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/tabindex-no-positive.md)Enforce `tabIndex` value is not greater than zero. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [button-has-type](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/button-has-type.md)Disallow usage of `button` elements without an explicit `type` attribute | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [default-props-match-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/default-props-match-prop-types.md)Enforce all defaultProps have a corresponding non-required PropType | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [forbid-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-prop-types.md)Disallow certain propTypes | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [forward-ref-uses-ref](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forward-ref-uses-ref.md)Require all forwardRef components include a ref parameter | | ๐ก | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [iframe-missing-sandbox](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/iframe-missing-sandbox.md)Enforce sandbox attribute on iframe elements | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-key.md)Disallow missing `key` props in iterators/collection literals | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-bind](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-bind.md)Disallow `.bind()` or arrow functions in JSX props | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-comment-textnodes](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-comment-textnodes.md)Disallow comments from being inserted as text nodes | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-constructed-context-values](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-constructed-context-values.md)Disallows JSX context provider values from taking values that will cause needless rerenders | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-duplicate-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-duplicate-props.md)Disallow duplicate properties in JSX | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-script-url](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-script-url.md)Disallow usage of `javascript:` URLs | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-target-blank](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-target-blank.md)Disallow `target="_blank"` attribute without `rel="noreferrer"` | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-undef](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-undef.md)Disallow undeclared variables in JSX | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-uses-react](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-react.md)Disallow React to be incorrectly marked as unused | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-uses-vars](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-uses-vars.md)Disallow variables used in JSX to be incorrectly marked as unused | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-access-state-in-setstate](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-access-state-in-setstate.md)Disallow when this.state is accessed within setState | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-array-index-key](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-array-index-key.md)Disallow usage of Array index in keys | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-children-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-children-prop.md)Disallow passing of children as props | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-danger](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger.md)Disallow usage of dangerous JSX properties | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-danger-with-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-danger-with-children.md)Disallow when a DOM element is using both children and dangerouslySetInnerHTML | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-deprecated](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-deprecated.md)Disallow usage of deprecated methods | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-did-mount-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-mount-set-state.md)Disallow usage of setState in componentDidMount | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-did-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-did-update-set-state.md)Disallow usage of setState in componentDidUpdate | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-direct-mutation-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-direct-mutation-state.md)Disallow direct mutation of this.state | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-find-dom-node](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-find-dom-node.md)Disallow usage of findDOMNode | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-invalid-html-attribute](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-invalid-html-attribute.md)Disallow usage of invalid attributes | | ๐ก | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-is-mounted](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-is-mounted.md)Disallow usage of isMounted | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-namespace](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-namespace.md)Enforce that namespaces are not used in React elements | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-object-type-as-default-prop](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-object-type-as-default-prop.md)Disallow usage of referential-type variables as default param in functional component | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-render-return-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-render-return-value.md)Disallow usage of the return value of ReactDOM.render | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-string-refs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-string-refs.md)Disallow using string references | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-this-in-sfc](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-this-in-sfc.md)Disallow `this` from being used in stateless functional components | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-typos](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-typos.md)Disallow common typos | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unescaped-entities](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unescaped-entities.md)Disallow unescaped HTML entities from appearing in markup | | ๐ก | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unknown-property](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unknown-property.md)Disallow usage of unknown DOM property | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unstable-nested-components](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unstable-nested-components.md)Disallow creating unstable components inside components | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-will-update-set-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-will-update-set-state.md)Disallow usage of setState in componentWillUpdate | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prop-types.md)Disallow missing props validation in a React component definition | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [react-in-jsx-scope](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/react-in-jsx-scope.md)Disallow missing React when using JSX | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [require-render-return](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/require-render-return.md)Enforce ES5 or ES6 class for returning value in render function | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [void-dom-elements-no-children](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/void-dom-elements-no-children.md)Disallow void DOM elements (e.g. ``, ``) from receiving children | | | | +| [](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#readme) | [exhaustive-deps](https://github.com/facebook/react/issues/14920)verifies the list of dependencies for Hooks like useEffect and similar | | ๐ง, ๐ก | | +| [](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#readme) | [rules-of-hooks](https://reactjs.org/docs/hooks-rules.html)enforces the Rules of Hooks | | | | -### โ ๏ธ Warnings (26) +### โ ๏ธ Warnings (29) -| Plugin | Rule | Options | Autofix | Overrides | -| :----------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-------: | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [display-name](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/display-name.md)Disallow missing displayName in a React component definition | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [forbid-component-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-component-props.md)Disallow certain props on components | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [function-component-definition](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/function-component-definition.md)Enforce a specific function type for function components | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [hook-use-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/hook-use-state.md)Ensure destructuring and symmetric naming of useState hook value and setter variables | | ๐ก | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-boolean-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-boolean-value.md)Enforce boolean attributes notation in JSX | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-curly-brace-presence](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-brace-presence.md)Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes | props: never, children: nev...{ "props": "never", "children": "never", "propElementValues": "always" } | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-filename-extension](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-filename-extension.md)Disallow file extensions that may contain JSX | extensions: .jsx, .tsx{ "extensions": [ ".jsx", ".tsx" ] } | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-fragments](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-fragments.md)Enforce shorthand or standard form for React fragments | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-handler-names](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-handler-names.md)Enforce event handler naming conventions in JSX | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-max-depth](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-depth.md)Enforce JSX maximum depth | max: 10{ "max": 10 } | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-leaked-render](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-leaked-render.md)Disallow problematic leaked values from being rendered | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-useless-fragment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-useless-fragment.md)Disallow unnecessary fragments | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-pascal-case](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-pascal-case.md)Enforce PascalCase for user-defined JSX components | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-props-no-spread-multi](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-spread-multi.md)Disallow JSX prop spreading the same identifier multiple times | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-arrow-function-lifecycle](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-arrow-function-lifecycle.md)Lifecycle methods should be methods on the prototype, not class fields | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-multi-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-multi-comp.md)Disallow multiple component definition per file | ignoreStateless: true{ "ignoreStateless": true } | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-redundant-should-component-update](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-redundant-should-component-update.md)Disallow usage of shouldComponentUpdate when extending React.PureComponent | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unused-class-component-methods](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-class-component-methods.md)Disallow declaring unused methods of component class | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unused-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-prop-types.md)Disallow definitions of unused propTypes | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unused-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-state.md)Disallow definitions of unused state | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [prefer-es6-class](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-es6-class.md)Enforce ES5 or ES6 class for React Components | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [prefer-stateless-function](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-stateless-function.md)Enforce stateless components to be written as a pure function | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [self-closing-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/self-closing-comp.md)Disallow extra closing tags for components without children | | ๐ง | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [state-in-constructor](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/state-in-constructor.md)Enforce class component state initialization style | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [static-property-placement](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/static-property-placement.md)Enforces where React component static properties should be positioned. | | | | -| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [style-prop-object](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/style-prop-object.md)Enforce style prop value is an object | | | | +| Plugin | Rule | Options | Autofix | Overrides | +| :----------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-------: | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-autofocus](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-autofocus.md)Enforce autoFocus prop is not used. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [no-redundant-roles](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-redundant-roles.md)Enforce explicit role property is not the same as implicit/default role property on element. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme) | [prefer-tag-over-role](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/prefer-tag-over-role.md)Enforces using semantic DOM elements over the ARIA `role` property. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [display-name](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/display-name.md)Disallow missing displayName in a React component definition | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [forbid-component-props](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/forbid-component-props.md)Disallow certain props on components | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [function-component-definition](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/function-component-definition.md)Enforce a specific function type for function components | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [hook-use-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/hook-use-state.md)Ensure destructuring and symmetric naming of useState hook value and setter variables | | ๐ก | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-boolean-value](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-boolean-value.md)Enforce boolean attributes notation in JSX | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-curly-brace-presence](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-curly-brace-presence.md)Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes | props: never, children: nev...{ "props": "never", "children": "never", "propElementValues": "always" } | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-filename-extension](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-filename-extension.md)Disallow file extensions that may contain JSX | extensions: .jsx, .tsx{ "extensions": [ ".jsx", ".tsx" ] } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-fragments](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-fragments.md)Enforce shorthand or standard form for React fragments | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-handler-names](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-handler-names.md)Enforce event handler naming conventions in JSX | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-max-depth](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-max-depth.md)Enforce JSX maximum depth | max: 10{ "max": 10 } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-leaked-render](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-leaked-render.md)Disallow problematic leaked values from being rendered | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-no-useless-fragment](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-no-useless-fragment.md)Disallow unnecessary fragments | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-pascal-case](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-pascal-case.md)Enforce PascalCase for user-defined JSX components | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [jsx-props-no-spread-multi](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/jsx-props-no-spread-multi.md)Disallow JSX prop spreading the same identifier multiple times | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-arrow-function-lifecycle](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-arrow-function-lifecycle.md)Lifecycle methods should be methods on the prototype, not class fields | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-multi-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-multi-comp.md)Disallow multiple component definition per file | ignoreStateless: true{ "ignoreStateless": true } | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-redundant-should-component-update](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-redundant-should-component-update.md)Disallow usage of shouldComponentUpdate when extending React.PureComponent | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unused-class-component-methods](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-class-component-methods.md)Disallow declaring unused methods of component class | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unused-prop-types](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-prop-types.md)Disallow definitions of unused propTypes | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [no-unused-state](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/no-unused-state.md)Disallow definitions of unused state | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [prefer-es6-class](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-es6-class.md)Enforce ES5 or ES6 class for React Components | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [prefer-stateless-function](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/prefer-stateless-function.md)Enforce stateless components to be written as a pure function | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [self-closing-comp](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/self-closing-comp.md)Disallow extra closing tags for components without children | | ๐ง | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [state-in-constructor](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/state-in-constructor.md)Enforce class component state initialization style | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [static-property-placement](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/static-property-placement.md)Enforces where React component static properties should be positioned. | | | | +| [](https://github.com/jsx-eslint/eslint-plugin-react#readme) | [style-prop-object](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/style-prop-object.md)Enforce style prop value is an object | | | | diff --git a/package-lock.json b/package-lock.json index b3d7f8e..4784e62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "eslint-plugin-import": "^2.31.0", "eslint-plugin-jest": "^28.8.0", "eslint-plugin-jest-formatting": "^3.1.0", + "eslint-plugin-jsx-a11y": "^6.10.2", "eslint-plugin-n": "^17.0.0", "eslint-plugin-playwright": "^2.1.0", "eslint-plugin-promise": "^6.4.0", @@ -56,9 +57,12 @@ "eslint-plugin-import": "^2.31.0", "eslint-plugin-jest": "^28.8.0", "eslint-plugin-jest-formatting": "^3.0.0", + "eslint-plugin-jsx-a11y": "^6.10.0", "eslint-plugin-n": ">=17.0.0", "eslint-plugin-playwright": "^2.1.0", "eslint-plugin-promise": ">=6.4.0", + "eslint-plugin-react": "^7.36.0", + "eslint-plugin-react-hooks": ">=5.0.0", "eslint-plugin-rxjs-x": ">=0.6.0", "eslint-plugin-sonarjs": "^1.0.4", "eslint-plugin-storybook": ">=0.10.0", @@ -90,12 +94,21 @@ "eslint-plugin-jest-formatting": { "optional": true }, + "eslint-plugin-jsx-a11y": { + "optional": true + }, "eslint-plugin-n": { "optional": true }, "eslint-plugin-playwright": { "optional": true }, + "eslint-plugin-react": { + "optional": true + }, + "eslint-plugin-react-hooks": { + "optional": true + }, "eslint-plugin-rxjs-x": { "optional": true }, @@ -3692,6 +3705,12 @@ "node": ">=4" } }, + "node_modules/ast-types-flow": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz", + "integrity": "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==", + "dev": true + }, "node_modules/async": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", @@ -3728,6 +3747,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/axe-core": { + "version": "4.10.2", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.10.2.tgz", + "integrity": "sha512-RE3mdQ7P3FRSe7eqCWoeQ/Z9QXrtniSjp1wUjt5nRC3WIpz5rSCve6o3fsZ2aCpJtrZjSZgjwXAoTO5k4tEI0w==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/axios": { "version": "1.7.7", "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", @@ -4518,6 +4546,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/damerau-levenshtein": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", + "integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==", + "dev": true + }, "node_modules/data-uri-to-buffer": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.1.tgz", @@ -5706,6 +5740,59 @@ "eslint": ">=0.8.0" } }, + "node_modules/eslint-plugin-jsx-a11y": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.2.tgz", + "integrity": "sha512-scB3nz4WmG75pV8+3eRUQOHZlNSUhFNq37xnpgRkCCELU3XMvXAxLk1eqWWyE22Ki4Q01Fnsw9BA3cJHDPgn2Q==", + "dev": true, + "dependencies": { + "aria-query": "^5.3.2", + "array-includes": "^3.1.8", + "array.prototype.flatmap": "^1.3.2", + "ast-types-flow": "^0.0.8", + "axe-core": "^4.10.0", + "axobject-query": "^4.1.0", + "damerau-levenshtein": "^1.0.8", + "emoji-regex": "^9.2.2", + "hasown": "^2.0.2", + "jsx-ast-utils": "^3.3.5", + "language-tags": "^1.0.9", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.8", + "safe-regex-test": "^1.0.3", + "string.prototype.includes": "^2.0.1" + }, + "engines": { + "node": ">=4.0" + }, + "peerDependencies": { + "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9" + } + }, + "node_modules/eslint-plugin-jsx-a11y/node_modules/aria-query": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz", + "integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/eslint-plugin-jsx-a11y/node_modules/axobject-query": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/eslint-plugin-jsx-a11y/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, "node_modules/eslint-plugin-n": { "version": "17.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-17.0.0.tgz", @@ -8536,6 +8623,24 @@ "json-buffer": "3.0.1" } }, + "node_modules/language-subtag-registry": { + "version": "0.3.23", + "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz", + "integrity": "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==", + "dev": true + }, + "node_modules/language-tags": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.9.tgz", + "integrity": "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==", + "dev": true, + "dependencies": { + "language-subtag-registry": "^0.3.20" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/latest-version": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-7.0.0.tgz", @@ -11343,6 +11448,20 @@ "node": ">=8" } }, + "node_modules/string.prototype.includes": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.includes/-/string.prototype.includes-2.0.1.tgz", + "integrity": "sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.3" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/string.prototype.matchall": { "version": "4.0.12", "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.12.tgz", diff --git a/package.json b/package.json index ae7185f..868ede8 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "eslint-plugin-import": "^2.31.0", "eslint-plugin-jest": "^28.8.0", "eslint-plugin-jest-formatting": "^3.0.0", + "eslint-plugin-jsx-a11y": "^6.10.0", "eslint-plugin-n": ">=17.0.0", "eslint-plugin-playwright": "^2.1.0", "eslint-plugin-promise": ">=6.4.0", @@ -85,6 +86,9 @@ "eslint-plugin-jest-formatting": { "optional": true }, + "eslint-plugin-jsx-a11y": { + "optional": true + }, "eslint-plugin-n": { "optional": true }, @@ -126,6 +130,7 @@ "eslint-plugin-import": "^2.31.0", "eslint-plugin-jest": "^28.8.0", "eslint-plugin-jest-formatting": "^3.1.0", + "eslint-plugin-jsx-a11y": "^6.10.2", "eslint-plugin-n": "^17.0.0", "eslint-plugin-playwright": "^2.1.0", "eslint-plugin-promise": "^6.4.0", diff --git a/scripts/helpers/plugins.js b/scripts/helpers/plugins.js index ad84ac9..5709927 100644 --- a/scripts/helpers/plugins.js +++ b/scripts/helpers/plugins.js @@ -14,6 +14,7 @@ const pluginIcons = { import: 'icons8/import', jest: 'material/jest', 'jest-formatting': 'icons8/test', + 'jsx-a11y': 'icons8/accessibility', n: 'material/nodejs', 'no-secrets': 'icons8/secure', playwright: 'material/playwright', @@ -47,6 +48,7 @@ const pluginDocsUrls = { jest: 'https://github.com/jest-community/eslint-plugin-jest#readme', 'jest-formatting': 'https://github.com/dangreenisrael/eslint-plugin-jest-formatting#readme', + 'jsx-a11y': 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#readme', n: 'https://github.com/eslint-community/eslint-plugin-n#readme', 'no-secrets': 'https://github.com/nickdeis/eslint-plugin-no-secrets#readme', playwright: diff --git a/scripts/helpers/types.d.ts b/scripts/helpers/types.d.ts index 2118152..7109967 100644 --- a/scripts/helpers/types.d.ts +++ b/scripts/helpers/types.d.ts @@ -30,6 +30,7 @@ export type PeerDep = { // corresponds to PNG file names in docs/icons export type Icon = + | 'icons8/accessibility' | 'icons8/expired' | 'icons8/global' | 'icons8/import' diff --git a/src/configs/react.js b/src/configs/react.js index 4fc1098..ff2ec4d 100644 --- a/src/configs/react.js +++ b/src/configs/react.js @@ -1,5 +1,6 @@ // @ts-check +import jsxA11y from 'eslint-plugin-jsx-a11y'; import react from 'eslint-plugin-react'; import reactHooks from 'eslint-plugin-react-hooks'; import globals from 'globals'; @@ -14,6 +15,7 @@ export default tseslint.config({ extends: [ // @ts-expect-error types inferred as possibly undefined react.configs.flat.recommended, + jsxA11y.flatConfigs.recommended, { name: 'code-pushup/react/react-hooks', plugins: { @@ -29,6 +31,8 @@ export default tseslint.config({ name: 'code-pushup/react/customized', rules: { 'react/display-name': 'warn', + 'jsx-a11y/no-autofocus': 'warn', + 'jsx-a11y/no-redundant-roles': 'warn', }, }, { @@ -88,6 +92,7 @@ export default tseslint.config({ 'react/static-property-placement': 'warn', 'react/style-prop-object': 'warn', 'react/void-dom-elements-no-children': 'error', + 'jsx-a11y/prefer-tag-over-role': 'warn', }, }, ], diff --git a/tests/configs/react.spec.js b/tests/configs/react.spec.js index 4ed85be..7ebd6c8 100644 --- a/tests/configs/react.spec.js +++ b/tests/configs/react.spec.js @@ -34,4 +34,9 @@ describe('react config', () => { const config = await loadConfig(); expect(Object.keys(config.rules ?? {}).join(',')).toContain('react-hooks/'); }); + + it('should have rule from extended recommended jsx-a11y config', async () => { + const config = await loadConfig(); + expect(config.rules).toHaveProperty('jsx-a11y/alt-text'); + }); });
{ "tabbable": [ "button", "checkbox", "link", "searchbox", "spinbutton", "switch", "textbox" ] }
{ "tr": [ "none", "presentation" ], "canvas": [ "img" ] }
{ "handlers": [ "onClick", "onError", "onLoad", "onMouseDown", "onMouseUp", "onKeyPress", "onKeyDown", "onKeyUp" ], "alert": [ "onKeyUp", "onKeyDown", "onKeyPress" ], "body": [ "onError", "onLoad" ], "dialog": [ "onKeyUp", "onKeyDown", "onKeyPress" ], "iframe": [ "onError", "onLoad" ], "img": [ "onError", "onLoad" ] }
{ "ul": [ "listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid" ], "ol": [ "listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid" ], "li": [ "menuitem", "menuitemradio", "menuitemcheckbox", "option", "row", "tab", "treeitem" ], "table": [ "grid" ], "td": [ "gridcell" ], "fieldset": [ "radiogroup", "presentation" ] }
{ "tags": [], "roles": [ "tabpanel" ], "allowExpressionValues": true }
{ "allowExpressionValues": true, "handlers": [ "onClick", "onMouseDown", "onMouseUp", "onKeyPress", "onKeyDown", "onKeyUp" ] }
{ "props": "never", "children": "never", "propElementValues": "always" }
{ "extensions": [ ".jsx", ".tsx" ] }
{ "max": 10 }
{ "ignoreStateless": true }