Skip to content

Commit 777f19c

Browse files
committed
[eslint config] [deps] [breaking] update eslint-plugin-react-hooks
1 parent 0e2ef17 commit 777f19c

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

packages/eslint-config-airbnb/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"eslint-plugin-import": "^2.30.0",
7979
"eslint-plugin-jsx-a11y": "^6.10.0",
8080
"eslint-plugin-react": "^7.36.1",
81-
"eslint-plugin-react-hooks": "^5.1.0",
81+
"eslint-plugin-react-hooks": "^7.0.0",
8282
"in-publish": "^2.0.1",
8383
"react": ">= 0.13.0",
8484
"safe-publish-latest": "^2.0.0",
@@ -89,7 +89,7 @@
8989
"eslint-plugin-import": "^2.30.0",
9090
"eslint-plugin-jsx-a11y": "^6.10.0",
9191
"eslint-plugin-react": "^7.36.1",
92-
"eslint-plugin-react-hooks": "^5.1.0"
92+
"eslint-plugin-react-hooks": "^7.0.0"
9393
},
9494
"engines": {
9595
"node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0"

packages/eslint-config-airbnb/rules/react-hooks.js

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,71 @@ module.exports = {
1111

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

1717
// Verify the list of the dependencies for Hooks like useEffect and similar
18-
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
18+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/exhaustive-deps
1919
'react-hooks/exhaustive-deps': 'error',
20+
21+
// Validates higher order functions defining nested components or hooks
22+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/component-hook-factories
23+
'react-hooks/component-hook-factories': 'error',
24+
25+
// Validates the compiler configuration options
26+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/config
27+
'react-hooks/config': 'error',
28+
29+
// Validates usage of Error Boundaries instead of try/catch for child errors
30+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/error-boundaries
31+
'react-hooks/error-boundaries': 'error',
32+
33+
// Validates configuration of gating mode
34+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/gating
35+
'react-hooks/gating': 'error',
36+
37+
// Validates against assignment/mutation of globals during render
38+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/globals
39+
'react-hooks/globals': 'error',
40+
41+
// Validates against mutating props, state, and other immutable values
42+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/immutability
43+
'react-hooks/immutability': 'error',
44+
45+
// Validates against usage of libraries which are incompatible with memoization
46+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/incompatible-library
47+
'react-hooks/incompatible-library': 'warn',
48+
49+
// Validates that existing manual memoization is preserved by the compiler
50+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization
51+
'react-hooks/preserve-manual-memoization': 'error',
52+
53+
// Validates that existing manual memoization is preserved by the compiler
54+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/purity
55+
'react-hooks/purity': 'error',
56+
57+
// Validates correct usage of refs, not reading/writing during render
58+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/refs
59+
'react-hooks/refs': 'error',
60+
61+
// Validates against calling setState synchronously in an effect
62+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/set-state-in-effect
63+
'react-hooks/set-state-in-effect': 'error',
64+
65+
// Validates against setting state during render
66+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/set-state-in-render
67+
'react-hooks/set-state-in-render': 'error',
68+
69+
// Validates that components are static, not recreated every render
70+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/static-components
71+
'react-hooks/static-components': 'error',
72+
73+
// Validates against syntax that React Compiler does not support
74+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/unsupported-syntax
75+
'react-hooks/unsupported-syntax': 'warn',
76+
77+
// Validates usage of the `useMemo` hook without a return value
78+
// https://react.dev/reference/eslint-plugin-react-hooks/lints/use-memo
79+
'react-hooks/use-memo': 'error',
2080
},
2181
};

0 commit comments

Comments
 (0)