eslint-plugin-react-hooks
eslint-plugin-react-hooks
provides ESLint rules to enforce the Rules of React.
This plugin helps you catch violations of React’s rules at build time, ensuring your components and hooks follow React’s rules for correctness and performance. The lints cover both fundamental React patterns (exhaustive-deps and rules-of-hooks) and issues flagged by React Compiler. React Compiler diagnostics are automatically surfaced by this ESLint plugin, and can be used even if your app hasn’t adopted the compiler yet.
Available Lints
component-hook-factories
- Validates against higher order functions defining nested components or hooksconfig
- Validates the compiler configuration optionserror-boundaries
- Validates usage of Error Boundaries instead of try/catch for child errorsexhaustive-deps
- Validates that dependency arrays for React hooks contain all necessary dependenciesgating
- Validates configuration of gating modeglobals
- Validates against assignment/mutation of globals during renderimmutability
- Validates against mutating props, state, and other immutable valuesincompatible-library
- Validates against usage of libraries which are incompatible with memoizationpreserve-manual-memoization
- Validates that existing manual memoization is preserved by the compilerpurity
- Validates that components/hooks are pure by checking known-impure functionsrefs
- Validates correct usage of refs, not reading/writing during renderrules-of-hooks
- Validates that components and hooks follow the Rules of Hooksset-state-in-effect
- Validates against calling setState synchronously in an effectset-state-in-render
- Validates against setting state during renderstatic-components
- Validates that components are static, not recreated every renderunsupported-syntax
- Validates against syntax that React Compiler does not supportuse-memo
- Validates usage of theuseMemo
hook without a return value