Rules Overview
Legend
- βοΈ - Configurable
- π - Linting
- π§ - Fixable
- π - Codemod
- π - Type Chcking
- π - Debug
- ποΈ - Deprecated
- 0οΈβ£ - Severity 0
- 1οΈβ£ - Severity 1
- 2οΈβ£ - Severity 2
- β - Severity in recommended presets
Core Rules
Rule | β | Features | Description | React |
---|---|---|---|---|
ensure-forward-ref-using-ref | 1οΈβ£ | π | Requires that components wrapped with forwardRef must have a ref parameter. | |
no-access-state-in-setstate | 2οΈβ£ | π | Prevents accessing this.state inside setState calls. | |
no-array-index-key | 1οΈβ£ | π | Prevents using array index as key . | |
no-children-count | 1οΈβ£ | π | Prevents using Children.count . | |
no-children-for-each | 1οΈβ£ | π | Prevents using Children.forEach . | |
no-children-map | 1οΈβ£ | π | Prevents using Children.map . | |
no-children-only | 1οΈβ£ | π | Prevents using Children.only . | |
no-children-prop | 0οΈβ£ | π | Prevents using children as a prop. | |
no-children-to-array | 1οΈβ£ | π | Prevents using Children.toArray . | |
no-class-component | 0οΈβ£ | π | Prevents using class component. | |
no-clone-element | 1οΈβ£ | π | Prevents using cloneElement . | |
no-comment-textnodes | 1οΈβ£ | π | Prevents comments from being inserted as text nodes. | |
no-complex-conditional-rendering | 0οΈβ£ | π | Prevents complex conditional rendering in JSX. | |
no-component-will-mount | 2οΈβ£ | π π | Prevents using componentWillMount . | >=16.3.0 |
no-component-will-receive-props | 2οΈβ£ | π π | Prevents using componentWillReceiveProps . | >=16.3.0 |
no-component-will-update | 2οΈβ£ | π π | Prevents using componentWillUpdate . | >=16.3.0 |
no-context-provider | 1οΈβ£ | π π | Prevents using <Context.Provider> . | >=19.0.0 |
no-create-ref | 2οΈβ£ | π | Prevents using createRef . | |
no-default-props | 2οΈβ£ | π | Prevents using defaultProps property in favor of ES6 default parameters. | |
no-direct-mutation-state | 2οΈβ£ | π | Prevents direct mutation of this.state . | |
no-duplicate-jsx-props | 1οΈβ£ | π | Prevents duplicate props in JSX. | |
no-duplicate-key | 2οΈβ£ | π | Prevents duplicate key on elements in the same array or a list of children . | |
no-forward-ref | 1οΈβ£ | π π | Prevents using React.forwardRef . | >=19.0.0 |
no-implicit-key | 1οΈβ£ | π | Prevents key from not being explicitly specified (e.g. spreading key from objects). | |
no-leaked-conditional-rendering | 1οΈβ£ | π π | Prevents problematic leaked values from being rendered. | |
no-missing-component-display-name | 0οΈβ£ | π | Enforces that all components have a displayName which can be used in devtools. | |
no-missing-key | 2οΈβ£ | π | Prevents missing key on items in list rendering. | |
no-nested-components | 2οΈβ£ | π | Prevents nesting component definitions inside other components. | |
no-prop-types | 2οΈβ£ | π | Prevents using propTypes in favor of TypeScript or another type-checking solution. | |
no-redundant-should-component-update | 2οΈβ£ | π | Prevents using shouldComponentUpdate when extending React.PureComponent . | |
no-set-state-in-component-did-mount | 1οΈβ£ | π | Prevents calling this.setState in componentDidMount outside of functions, such as callbacks. | |
no-set-state-in-component-did-update | 1οΈβ£ | π | Prevents calling this.setState in componentDidUpdate outside of functions, such as callbacks. | |
no-set-state-in-component-will-update | 1οΈβ£ | π | Prevents calling this.setState in componentWillUpdate outside of functions, such as callbacks. | |
no-string-refs | 2οΈβ£ | π | Prevents using deprecated string refs . | |
no-unsafe-component-will-mount | 1οΈβ£ | π | Warns the usage of UNSAFE_componentWillMount in class components. | |
no-unsafe-component-will-receive-props | 1οΈβ£ | π | Warns the usage of UNSAFE_componentWillReceiveProps in class components. | |
no-unsafe-component-will-update | 1οΈβ£ | π | Warns the usage of UNSAFE_componentWillUpdate in class components. | |
no-unstable-context-value | 1οΈβ£ | π | Prevents non-stable values (i.e. object literals) from being used as a value for Context.Provider . | |
no-unstable-default-props | 1οΈβ£ | π | Prevents using referential-type values as default props in object destructuring. | |
no-unused-class-component-members | 0οΈβ£ | π | Warns unused class component methods and properties. | |
no-unused-state | 1οΈβ£ | π | Warns unused class component state. | |
no-useless-fragment | 1οΈβ£ | π βοΈ | Prevents using useless fragment components or <> syntax. | |
prefer-destructuring-assignment | 0οΈβ£ | π | Enforces using destructuring assignment over property assignment. | |
prefer-react-namespace-import | 0οΈβ£ | π π§ | Enforces React is imported via a namespace import | |
prefer-read-only-props | 0οΈβ£ | π π | Enforces read-only props in components. | |
prefer-shorthand-boolean | 0οΈβ£ | π π§ | Enforces using shorthand syntax for boolean attributes. | |
prefer-shorthand-fragment | 0οΈβ£ | π | Enforces using shorthand syntax for fragments. | |
use-jsx-vars | 1οΈβ£ | Helpes eslint/no-unused-vars to correctly detect variables used in JSX. |
Deprecated
Rule | Replaced by |
---|---|
jsx-uses-vars | use-jsx-vars |
jsx-no-duplicate-props | no-duplicate-jsx-props |
no-complicated-conditional-rendering | no-complex-conditional-rendering |
DOM Rules
Rule | β | Features | Description |
---|---|---|---|
no-void-elements-with-children | 2οΈβ£ | π | Prevents using children in void DOM elements . |
no-dangerously-set-innerhtml-with-children | 2οΈβ£ | π | Prevents DOM element using dangerouslySetInnerHTML and children at the same time. |
no-dangerously-set-innerhtml | 1οΈβ£ | π | Prevents DOM element using dangerouslySetInnerHTML . |
no-find-dom-node | 2οΈβ£ | π | Prevents using findDOMNode . |
no-missing-button-type | 1οΈβ£ | π | Enforces explicit type attribute for button elements. |
no-missing-iframe-sandbox | 1οΈβ£ | π | Enforces explicit sandbox attribute for iframe elements. |
no-namespace | 2οΈβ£ | π | Enforces the absence of a namespace in React elements. |
no-render-return-value | 2οΈβ£ | π | Prevents using the return value of ReactDOM.render . |
no-script-url | 1οΈβ£ | π | Prevents using javascript: URLs as the value of certain attributes. |
no-unknown-property | 0οΈβ£ | π π§ βοΈ | Prevents using unknown DOM property |
no-unsafe-iframe-sandbox | 1οΈβ£ | π | Enforces sandbox attribute for iframe elements is not set to unsafe combinations. |
no-unsafe-target-blank | 1οΈβ£ | π | Prevents using target="_blank" without rel="noreferrer noopener" . |
Deprecated
Rule | Replaced by |
---|---|
dom-no-children-in-void-dom-elements | no-void-elements-with-children |
Web API Rules
Rule | β | Features | Description |
---|---|---|---|
no-leaked-event-listener | 1οΈβ£ | π | Prevents leaked addEventListener in a component or custom hook. |
no-leaked-interval | 1οΈβ£ | π | Prevents leaked setInterval in a component or custom hook. |
no-leaked-resize-observer | 1οΈβ£ | π | Prevents leaked ResizeObserver in a component or custom hook. |
no-leaked-timeout | 1οΈβ£ | π | Prevents leaked setTimeout in a component or custom hook. |
Hooks Extra Rules
Rule | β | Features | Description |
---|---|---|---|
no-direct-set-state-in-use-effect | 1οΈβ£ | π | Disallow direct calls to the set function of useState in useEffect . |
no-direct-set-state-in-use-layout-effect | 0οΈβ£ | π | Disallow direct calls to the set function of useState in useLayoutEffect . |
no-unnecessary-use-callback | 0οΈβ£ | π | Disallow unnecessary usage of useCallback . |
no-unnecessary-use-memo | 0οΈβ£ | π | Disallow unnecessary usage of useMemo . |
no-useless-custom-hooks | 1οΈβ£ | π | Disallow redundant custom hooks definitions. |
prefer-use-state-lazy-initialization | 1οΈβ£ | π | Warns function calls made inside useState calls. |
Deprecated
Naming Convention Rules
Rule | β | Features | Description |
---|---|---|---|
component-name | 0οΈβ£ | π βοΈ | Enforces naming conventions for components. |
filename | 0οΈβ£ | π βοΈ | Enforces naming convention for JSX files. |
filename-extension | 0οΈβ£ | π βοΈ | Enforces consistent use of the JSX file extension. |
use-state | 0οΈβ£ | π | Enforces destructuring and symmetric naming of useState hook value and setter variables. |
Debug Rules
Rule | β | Features | Description |
---|---|---|---|
class-component | 0οΈβ£ | π | Reports all class components. |
function-component | 0οΈβ£ | π | Reports all function components. |
hook | 0οΈβ£ | π | Reports all react hooks. |
is-from-react | 0οΈβ£ | π | Reports all identifiers that are initialized from React. |