Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/eslint-config-airbnb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.36.1",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-hooks": "^7.0.0",
"in-publish": "^2.0.1",
"react": ">= 0.13.0",
"safe-publish-latest": "^2.0.0",
Expand All @@ -89,7 +89,7 @@
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.36.1",
"eslint-plugin-react-hooks": "^5.1.0"
"eslint-plugin-react-hooks": "^7.0.0"
},
"engines": {
"node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0"
Expand Down
64 changes: 62 additions & 2 deletions packages/eslint-config-airbnb/rules/react-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,71 @@ module.exports = {

rules: {
// Enforce Rules of Hooks
// https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
// https://react.dev/reference/eslint-plugin-react-hooks/lints/rules-of-hooks
'react-hooks/rules-of-hooks': 'error',

// Verify the list of the dependencies for Hooks like useEffect and similar
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
// https://react.dev/reference/eslint-plugin-react-hooks/lints/exhaustive-deps
'react-hooks/exhaustive-deps': 'error',

// Validates higher order functions defining nested components or hooks
// https://react.dev/reference/eslint-plugin-react-hooks/lints/component-hook-factories
'react-hooks/component-hook-factories': 'error',

// Validates the compiler configuration options
// https://react.dev/reference/eslint-plugin-react-hooks/lints/config
'react-hooks/config': 'error',

// Validates usage of Error Boundaries instead of try/catch for child errors
// https://react.dev/reference/eslint-plugin-react-hooks/lints/error-boundaries
'react-hooks/error-boundaries': 'error',

// Validates configuration of gating mode
// https://react.dev/reference/eslint-plugin-react-hooks/lints/gating
'react-hooks/gating': 'error',

// Validates against assignment/mutation of globals during render
// https://react.dev/reference/eslint-plugin-react-hooks/lints/globals
'react-hooks/globals': 'error',

// Validates against mutating props, state, and other immutable values
// https://react.dev/reference/eslint-plugin-react-hooks/lints/immutability
'react-hooks/immutability': 'error',

// Validates against usage of libraries which are incompatible with memoization
// https://react.dev/reference/eslint-plugin-react-hooks/lints/incompatible-library
'react-hooks/incompatible-library': 'warn',

// Validates that existing manual memoization is preserved by the compiler
// https://react.dev/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization
'react-hooks/preserve-manual-memoization': 'error',

// Validates that existing manual memoization is preserved by the compiler
// https://react.dev/reference/eslint-plugin-react-hooks/lints/purity
'react-hooks/purity': 'error',

// Validates correct usage of refs, not reading/writing during render
// https://react.dev/reference/eslint-plugin-react-hooks/lints/refs
'react-hooks/refs': 'error',

// Validates against calling setState synchronously in an effect
// https://react.dev/reference/eslint-plugin-react-hooks/lints/set-state-in-effect
'react-hooks/set-state-in-effect': 'error',

// Validates against setting state during render
// https://react.dev/reference/eslint-plugin-react-hooks/lints/set-state-in-render
'react-hooks/set-state-in-render': 'error',

// Validates that components are static, not recreated every render
// https://react.dev/reference/eslint-plugin-react-hooks/lints/static-components
'react-hooks/static-components': 'error',

// Validates against syntax that React Compiler does not support
// https://react.dev/reference/eslint-plugin-react-hooks/lints/unsupported-syntax
'react-hooks/unsupported-syntax': 'warn',

// Validates usage of the `useMemo` hook without a return value
// https://react.dev/reference/eslint-plugin-react-hooks/lints/use-memo
'react-hooks/use-memo': 'error',
},
};