Roadmap

Milestone 2.0

Plugins (with ecological niche explanation)

  • eslint-plugin-react-x - Core rules (renderer-agnostic, compatible with x-platform).
  • eslint-plugin-react-dom - DOM Specific rules for React DOM.
  • eslint-plugin-react-web-api - Rules for interacting with Web APIs.
  • 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 naming convention rules (can be replaced with other plugins depending on the project).

Rules in eslint-plugin-react-x

RuleDescription
avoid-shorthand-booleanPrevents using shorthand syntax for boolean attributes.
avoid-shorthand-fragmentPrevents 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 on elements in the same array or a list of children.
no-implicit-keyPrevents key from not being explicitly specified (e.g. spreading key 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 on items in list rendering.
no-nested-componentsPrevents nesting component definitions inside other components.
no-prop-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-web-api

RuleDescription
no-leaked-timeoutPrevents leaked setTimeout
no-leaked-intervalPrevents leaked setInterval
no-leaked-idle-callbackPrevents leaked requestIdleCallback
no-leaked-animation-framePrevents leaked requestAnimationFrame
no-leaked-event-sourcePrevents leaked EventSource
no-leaked-event-listenerPrevents leaked addEventListener
no-leaked-resize-observerPrevents leaked ResizeObserver
no-leaked-intersection-observerPrevents leaked IntersectionObserver
no-leaked-mutation-observerPrevents leaked MutationObserver
no-leaked-performance-observerPrevents leaked PerformanceObserver
no-leaked-websocketPrevents leaked WebSocket
no-leaked-broadcast-channelPrevents leaked BroadcastChannel
no-leaked-geolocationPrevents leaked Geolocation.watchPosition()
no-leaked-absolute-orientation-sensorPrevents leaked AbsoluteOrientationSensor
no-leaked-relative-accelerometerPrevents leaked Accelerometer
no-leaked-ambient-light-sensorPrevents leaked AmbientLightSensor
no-leaked-gravity-sensorPrevents leaked GravitySensor
no-leaked-gyroscopePrevents leaked Gyroscope
no-leaked-linear-acceleration-sensorPrevents leaked LinearAccelerationSensor
no-leaked-magnetometerPrevents leaked Magnetometer
no-leaked-orientation-sensorPrevents leaked OrientationSensor

Rules in eslint-plugin-react-hooks-extra

RuleDescription
no-direct-set-state-in-use-effectDisallow direct calls to set function of useState in useEffect.
no-redundant-custom-hookWarns when custom Hooks that don’t use other Hooks.
no-unnecessary-use-callbackDisallow unnecessary usage of useCallback.
no-unnecessary-use-memoDisallow unnecessary usage of useMemo.
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 - Core rules (renderer-agnostic, compatible with x-platform).
  • eslint-plugin-react-dom - DOM Specific rules for React DOM.
  • eslint-plugin-react-dom-a11y - Accessibility rules for React DOM.
  • eslint-plugin-react-web-api - Rules for interacting with Web APIs.
  • 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 naming convention rules (can be replaced with other plugins depending on the project).
  • … (Free to combine with other plugins from the community).

Additional context

Rules in eslint-plugin-react-dom-a11y (if port Svelte’s Accessibility warnings)

RuleDescription
accesskeyEnforce no accesskey on element.
aria-activedescendant-has-tabindexEnforce aria-activedescendant has tabindex.
aria-propsEnforce valid aria-* props.
autofocusEnforce no autofocus on element.
click-events-have-key-eventsEnforce elements with click handlers must have key handlers.
distracting-elementsEnforce no distracting elements.
hiddenEnforce no hidden on element.
img-redundant-altEnforce img alt attribute does not contain the word image, picture, or photo.
incorrect-aria-attribute-typeEnforce correct aria-* attribute type.
invalid-attributeEnforce no invalid attribute.
interactive-supports-focusEnforce interactive elements support focus.
label-has-associated-controlEnforce label has associated control.
media-has-captionEnforce media elements have captions.
misplaced-roleEnforce no misplaced role.
misplaced-scopeEnforce no misplaced scope.
missing-attributeEnforce that attributes required for accessibility are present on an element.
missing-contentEnforce that heading elements (h1, h2, etc.) and anchors have content and that the content is accessible to screen readers.
mouse-events-have-key-eventsEnforce elements with mouse handlers must have key handlers.
no-redundant-rolesEnforce no redundant roles.
no-interactive-element-to-noninteractive-roleEnforce no interactive element to non-interactive role.
no-noninteractive-element-interactionsEnforce no non-interactive element interactions.
no-noninteractive-element-to-interactive-roleEnforce no non-interactive element to interactive role.
no-noninteractive-tabindexEnforce no non-interactive tabindex.
no-static-element-interactionsEnforce no static element interactions.
positive-tabindexEnforce no positive tabindex property values.
role-has-required-aria-propsEnforce role has required aria-* props.
role-supports-aria-propsEnforce role supports aria-* props.
structureEnforce correct structure.
unknown-aria-attributeEnforce no unknown aria-* attribute.
unknown-roleEnforce no unknown role.

Rules in eslint-plugin-react-dom-a11y (if 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