Roadmap

Milestone 2.0 (Active)

Plugins (with ecological niche explanation)

  • eslint-plugin-react-x (DOM Irrelevant, Render Target Agnostic, Formatting Independent).
  • eslint-plugin-react-dom (DOM Specific rules for React DOM).
  • eslint-plugin-react-hooks (The official one from React).
  • eslint-plugin-react-hooks-extra (Extra rules for eslint-plugin-react-hooks).
  • eslint-plugin-react-naming-convention (Optional, only naming convention rules, can be replaced with other plugins depending on the project).
  • … (Free to combine with other plugins from the community).

Rules in eslint-plugin-react-x

RuleDescription
avoid-shorthand-booleanEnforces using shorthand syntax for boolean attributes.
avoid-shorthand-fragmentEnforces using shorthand syntax for fragments.
ensure-forward-ref-using-refRequires that components wrapped with forwardRef must have a ref parameter.
no-access-state-in-setstatePrevents accessing this.state inside setState calls.
no-array-index-keyPrevents using array index as key.
no-children-countPrevents using Children.count.
no-children-for-eachPrevents using Children.forEach.
no-children-mapPrevents using Children.map.
no-children-onlyPrevents using Children.only.
no-children-propPrevents using children as a prop.
no-children-to-arrayPrevents using Children.toArray.
no-class-componentPrevents using class component.
no-clone-elementPrevents using cloneElement.
no-comment-textnodesPrevents comments from being inserted as text nodes.
no-complex-conditional-renderingPrevents complex conditional rendering in JSX.
no-component-will-mountPrevents using componentWillMount.
no-component-will-receive-propsPrevents using componentWillReceiveProps.
no-component-will-updatePrevents using componentWillUpdate.
no-create-refPrevents using createRef.
no-default-propsPrevents using defaultProps property in favor of ES6 default parameters.
no-direct-mutation-statePrevents direct mutation of this.state.
no-duplicate-keyPrevents duplicate key props on elements in the same array or a list of children.
no-implicit-keyPrevents key prop from not being explicitly specified (e.g. spreading key prop from objects).
no-leaked-conditional-renderingPrevents problematic leaked values from being rendered.
no-missing-component-display-nameEnforces that all components have a displayName which can be used in devtools.
no-missing-keyPrevents missing key prop on items in list rendering.
no-nested-componentsPrevents nesting component definitions inside other components.
no-props-typesPrevents using propTypes in favor of TypeScript or another type-checking solution.
no-redundant-should-component-updatePrevents using shouldComponentUpdate when extending React.PureComponent.
no-set-state-in-component-did-mountPrevents calling this.setState in componentDidMount outside of functions, such as callbacks.
no-set-state-in-component-did-updatePrevents calling this.setState in componentDidUpdate outside of functions, such as callbacks.
no-set-state-in-component-will-updatePrevents calling this.setState in componentWillUpdate outside of functions, such as callbacks.
no-string-refsPrevents using deprecated string refs.
no-unsafe-component-will-mountWarns the usage of UNSAFE_componentWillMount in class components.
no-unsafe-component-will-receive-propsWarns the usage of UNSAFE_componentWillReceiveProps in class components.
no-unsafe-component-will-updateWarns the usage of UNSAFE_componentWillUpdate in class components.
no-unstable-context-valuePrevents non-stable values (i.e. object literals) from being used as a value for Context.Provider.
no-unstable-default-propsPrevents using referential-type values as default props in object destructuring.
no-unused-class-component-membersWarns unused class component methods and properties.
no-unused-stateWarns unused class component state.
no-useless-fragmentPrevents using useless fragment components or <> syntax.
prefer-destructuring-assignmentEnforces using destructuring assignment over property assignment.
prefer-read-only-propsEnforce read-only props in components.
prefer-shorthand-booleanEnforces using shorthand syntax for boolean attributes.
prefer-shorthand-fragmentEnforces using shorthand syntax for fragments.

Rules in eslint-plugin-react-dom

RuleDescription
no-children-in-void-dom-elementsPrevents the use of children in void DOM elements.
no-dangerously-set-innerhtmlPrevents DOM element using dangerouslySetInnerHTML.
no-dangerously-set-innerhtml-with-childrenPrevents DOM element using dangerouslySetInnerHTML and children at the same time.
no-find-dom-nodePrevents usage of findDOMNode.
no-missing-button-typeEnforces explicit type attribute for <button> elements.
no-missing-iframe-sandboxEnforces explicit sandbox attribute for iframe elements.
no-namespaceEnforces the absence of a namespace in React elements.
no-render-return-valuePrevents usage of the return value of ReactDOM.render.
no-script-urlPrevents usage of javascript: URLs as the value of certain attributes.
no-unsafe-iframe-sandboxEnforces sandbox attribute for iframe elements is not set to unsafe combinations.
no-unsafe-target-blankPrevents the use of target="_blank" without rel="noreferrer noopener".

Rules in eslint-plugin-react-hooks-extra

RuleDescription
ensure-custom-hooks-using-other-hooksWarns when custom Hooks that don’t use other Hooks.
ensure-use-memo-has-non-empty-depsWarns when useMemo is used without a non-empty dependencies array.
ensure-use-callback-has-non-empty-depsWarns when useCallback is used without a non-empty dependencies array.
no-direct-set-state-in-use-effectDisallow direct calls to set function of useState in useEffect.
no-direct-set-state-in-use-layout-effectDisallow direct calls to set function of useState in useLayoutEffect.
prefer-use-state-lazy-initializationWarns function calls made inside useState calls.

Rules in eslint-plugin-react-naming-convention

RuleDescription
component-nameEnforces naming conventions for components.
filenameEnforces naming convention for JSX files.
filename-extensionEnforces consistent use of the JSX file extension.
use-stateEnforces destructuring and symmetric naming of useState hook value and setter variables.

Advanced Configuration features

  • Additional components (settings["react-x"].additionalComponents) transitions from experimental to stable.

Milestone 3.0 (Draft)

Plugins (with ecological niche explanation)

  • eslint-plugin-react-x (DOM Irrelevant, Render Target Agnostic, Formatting Independent).
  • eslint-plugin-react-dom (DOM Specific rules for React DOM).
  • eslint-plugin-react-dom-a11y (Accessibility rules for React DOM).
  • eslint-plugin-react-hooks (The official one from React).
  • eslint-plugin-react-hooks-extra (Extra rules for eslint-plugin-react-hooks).
  • eslint-plugin-react-naming-convention (Optional, only naming convention rules, can be replaced with other plugins depending on the project).
  • … (Free to combine with other plugins from the community).

Rules in eslint-plugin-react-dom-a11y (port open-wc’s a11y rules)

RuleDescription
alt-textEnforce that all elements that require alternative text have meaningful information to relay back to the end user.
anchor-has-contentEnforce that anchors have content and that the content is accessible to screen readers.
anchor-is-validPerforms validity check on anchor hrefs. Warns when anchors are used as buttons.
aria-activedescendant-has-tabindexEnforce that an element with aria-activedescendant has a tabindex.
aria-attr-valid-valueARIA state and property values must be valid.
aria-attrsElements cannot use an invalid ARIA attribute. This will fail if it finds an aria-* property that is not listed in WAI-ARIA States and Properties spec.
aria-roleElements with ARIA roles must use a valid, non-abstract ARIA role. A reference to role definitions can be found at WAI-ARIA site.
aria-unsupported-elementsEnforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
autocomplete-validEnsure the autocomplete attribute is correct and suitable for the form field it is used with.
click-events-have-key-eventsEnforce onClick is accompanied by at least one of the following: onKeyUp, onKeyDown, onKeyPress.
heading-has-contentEnforce that heading elements (h1, h2, etc.) have content and that the content is accessible to screen readers.
iframe-title<iframe> elements must have a unique title property to indicate its content to the user.
img-redundant-altEnforce img alt attribute does not contain the words image, picture, or photo.
mouse-events-have-key-eventsEnforce onMouseover/onMouseout are accompanied by onFocus/onBlur.
no-access-keyEnforce no accesskey attribute on element.
no-autofocusEnforce that autofocus attribute is not used on elements.
no-distracting-elementsEnforces that no distracting <marquee> or <blink> elements are used.
no-redundant-roleEnforce explicit role property is not the same as implicit/default role property on element.
role-has-required-aria-attrsEnforce that elements with ARIA roles must have all required attributes for that role.
role-supports-aria-attrEnforce that elements with a defined role contain only supported ARIA attributes for that role.
scopeEnforce scope attribute is only used on <th> elements.
tabindex-no-positiveEnforce tabIndex value is not greater than zero.
valid-langEnforce the lang attribute on the html element. The lang attribute will only be populated with a value that’s BCP 47 compliant