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