Rules
Overview
Legend
- ⚙️ - Configurable
- 🔍 - Linting
- 🔧 - Fixable
- 🔄 - Codemod
- 💭 - Type Chcking
- 🐞 - Debug
- 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-use-context | 1️⃣ | 🔍 🔄 | Prevents using useContext in favor of use . | >=19.0.0 |
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 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
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️⃣ | 🔍 | Enforces custom Hooks to use at least one other Hook inside. |
prefer-use-state-lazy-initialization | 1️⃣ | 🔍 | Enforces function calls made inside useState to be wrapped in an initializer function . |
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. |