[eprh] Prepare for 7.0.0 (#34757)
For 7.0.0: Slim down presets to just 2 configurations: - `recommended`: legacy and flat config with all recommended rules, and - `recommended-latest`: legacy and flat config with all recommended rules plus new bleeding edge experimental compiler rules Removed: - `recommended-latest-legacy` - `flat/recommended` Please see the README for new install instructions. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34757). * #34783 * #34782 * __->__ #34757
lauren committed
Oct 8, 2025 at 15:17 UTC
7568e718549b85f60e3943f02d079d20d077077f
8 files changed
+60
-74
ReactVersions.js
+1
-1
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
33
const rcNumber = 0;
34
35
const stablePackages = {
36
- 'eslint-plugin-react-hooks': '6.2.0',
36
+ 'eslint-plugin-react-hooks': '7.0.0',
37
'jest-react': '0.18.0',
38
react: ReactVersion,
39
'react-art': ReactVersion,
fixtures/eslint-v6/.eslintrc.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"root": true,
3
- "extends": ["plugin:react-hooks/recommended-latest-legacy"],
3
+ "extends": ["plugin:react-hooks/recommended"],
4
"parserOptions": {
5
"ecmaVersion": 2020,
6
"sourceType": "module",
fixtures/eslint-v7/.eslintrc.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"root": true,
3
- "extends": ["plugin:react-hooks/recommended-latest-legacy"],
3
+ "extends": ["plugin:react-hooks/recommended"],
4
"parserOptions": {
5
"ecmaVersion": 2020,
6
"sourceType": "module",
fixtures/eslint-v8/.eslintrc.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"root": true,
3
- "extends": ["plugin:react-hooks/recommended-latest-legacy"],
3
+ "extends": ["plugin:react-hooks/recommended"],
4
"parserOptions": {
5
"ecmaVersion": 2020,
6
"sourceType": "module",
packages/eslint-plugin-react-hooks/CHANGELOG.md
+6
@@ -1,3 +1,9 @@
1
+## 7.0.0
2
+
3
+This release slims down presets to just 2 configurations (`recommended` and `recommended-latest`), and all compiler rules are enabled by default.
4
+
5
+- **Breaking:** Removed `recommended-latest-legacy` and `flat/recommended` configs. The plugin now provides `recommended` (legacy and flat configs with all recommended rules), and `recommended-latest` (legacy and flat configs with all recommended rules plus new bleeding edge experimental compiler rules). ([@poteto](https://github.com/poteto) in [#34757](https://github.com/facebook/react/pull/34757))
6
+
7
## 6.1.1
8
9
**Note:** 6.1.0 accidentally allowed use of `recommended` without flat config, causing errors when used with ESLint v9's `defineConfig()` helper. This has been fixed in 6.1.1.
packages/eslint-plugin-react-hooks/README.md
+46
-43
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
4
5
## Installation
6
7
-**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8
-
7
Assuming you already have ESLint installed, run:
8
9
```sh
@@ -18,9 +16,7 @@ yarn add eslint-plugin-react-hooks --dev
16
17
### Flat Config (eslint.config.js|ts)
18
21
-#### >= 6.0.0
22
-
23
-For users of 6.0 and beyond, add the `recommended` config.
19
+Add the `recommended` config for all recommended rules:
20
21
```js
22
// eslint.config.js
@@ -28,61 +24,32 @@ import reactHooks from 'eslint-plugin-react-hooks';
24
import { defineConfig } from 'eslint/config';
25
26
export default defineConfig([
31
- {
32
- files: ["src/**/*.{js,jsx,ts,tsx}"],
33
- plugins: {
34
- 'react-hooks': reactHooks,
35
- },
36
- extends: ['react-hooks/recommended'],
37
- },
27
+ reactHooks.configs.flat.recommended,
28
]);
29
```
30
41
-#### 5.2.0
42
-
43
-For users of 5.2.0 (the first version with flat config support), add the `recommended-latest` config.
31
+If you want to try bleeding edge experimental compiler rules, use `recommended-latest`.
32
33
```js
34
+// eslint.config.js
35
import reactHooks from 'eslint-plugin-react-hooks';
36
import { defineConfig } from 'eslint/config';
37
38
export default defineConfig([
50
- {
51
- files: ["src/**/*.{js,jsx,ts,tsx}"],
52
- plugins: {
53
- 'react-hooks': reactHooks,
54
- },
55
- extends: ['react-hooks/recommended-latest'],
56
- },
39
+ reactHooks.configs.flat['recommended-latest'],
40
]);
41
```
42
43
### Legacy Config (.eslintrc)
44
62
-#### >= 5.2.0
63
-
64
-If you are still using ESLint below 9.0.0, you can use `recommended-legacy` for accessing a legacy version of the recommended config.
45
+If you are still using ESLint below 9.0.0, the `recommended` preset can also be used to enable all recommended rules.
46
47
```js
48
{
68
- "extends": [
69
- // ...
70
- "plugin:react-hooks/recommended-legacy"
71
- ]
49
+ "extends": ["plugin:react-hooks/recommended"],
50
+ // ...
51
}
73
-```
74
-
75
-#### < 5.2.0
76
-
77
-If you're using a version earlier than 5.2.0, the legacy config was simply `recommended`.
52
79
-```js
80
-{
81
- "extends": [
82
- // ...
83
- "plugin:react-hooks/recommended"
84
- ]
85
-}
53
```
54
55
### Custom Configuration
@@ -92,7 +59,7 @@ If you want more fine-grained configuration, you can instead choose to enable sp
59
#### Flat Config (eslint.config.js|ts)
60
61
```js
95
-import * as reactHooks from 'eslint-plugin-react-hooks';
62
+import reactHooks from 'eslint-plugin-react-hooks';
63
64
export default [
65
{
@@ -100,8 +67,26 @@ export default [
67
plugins: { 'react-hooks': reactHooks },
68
// ...
69
rules: {
70
+ // Core hooks rules
71
'react-hooks/rules-of-hooks': 'error',
72
'react-hooks/exhaustive-deps': 'warn',
73
+
74
+ // React Compiler rules
75
+ 'react-hooks/config': 'error',
76
+ 'react-hooks/error-boundaries': 'error',
77
+ 'react-hooks/component-hook-factories': 'error',
78
+ 'react-hooks/gating': 'error',
79
+ 'react-hooks/globals': 'error',
80
+ 'react-hooks/immutability': 'error',
81
+ 'react-hooks/preserve-manual-memoization': 'error',
82
+ 'react-hooks/purity': 'error',
83
+ 'react-hooks/refs': 'error',
84
+ 'react-hooks/set-state-in-effect': 'error',
85
+ 'react-hooks/set-state-in-render': 'error',
86
+ 'react-hooks/static-components': 'error',
87
+ 'react-hooks/unsupported-syntax': 'warn',
88
+ 'react-hooks/use-memo': 'error',
89
+ 'react-hooks/incompatible-library': 'warn',
90
}
91
},
92
];
@@ -116,8 +101,26 @@ export default [
101
],
102
"rules": {
103
// ...
104
+ // Core hooks rules
105
"react-hooks/rules-of-hooks": "error",
120
- "react-hooks/exhaustive-deps": "warn"
106
+ "react-hooks/exhaustive-deps": "warn",
107
+
108
+ // React Compiler rules
109
+ "react-hooks/config": "error",
110
+ "react-hooks/error-boundaries": "error",
111
+ "react-hooks/component-hook-factories": "error",
112
+ "react-hooks/gating": "error",
113
+ "react-hooks/globals": "error",
114
+ "react-hooks/immutability": "error",
115
+ "react-hooks/preserve-manual-memoization": "error",
116
+ "react-hooks/purity": "error",
117
+ "react-hooks/refs": "error",
118
+ "react-hooks/set-state-in-effect": "error",
119
+ "react-hooks/set-state-in-render": "error",
120
+ "react-hooks/static-components": "error",
121
+ "react-hooks/unsupported-syntax": "warn",
122
+ "react-hooks/use-memo": "error",
123
+ "react-hooks/incompatible-library": "warn"
124
}
125
}
126
```
packages/eslint-plugin-react-hooks/package.json
+1
-1
@@ -1,7 +1,7 @@
1
{
2
"name": "eslint-plugin-react-hooks",
3
"description": "ESLint rules for React Hooks",
4
- "version": "5.2.0",
4
+ "version": "7.0.0",
5
"repository": {
6
"type": "git",
7
"url": "https://github.com/facebook/react.git",
packages/eslint-plugin-react-hooks/src/index.ts
+3
-26
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
44
const plugins = ['react-hooks'];
45
46
type ReactHooksFlatConfig = {
47
- plugins: Record<string, any>;
47
+ plugins: {react: any};
48
rules: Linter.RulesRecord;
49
};
50
51
const configs = {
52
- 'recommended-legacy': {
53
- plugins,
54
- rules: basicRuleConfigs,
55
- },
56
- 'recommended-latest-legacy': {
52
+ recommended: {
53
plugins,
54
rules: allRuleConfigs,
55
},
60
- 'flat/recommended': {
61
- plugins,
62
- rules: basicRuleConfigs,
63
- },
56
'recommended-latest': {
57
plugins,
58
rules: allRuleConfigs,
59
},
68
- recommended: {
69
- plugins,
70
- rules: basicRuleConfigs,
71
- },
60
flat: {} as Record<string, ReactHooksFlatConfig>,
61
};
62
63
const plugin = {
64
meta: {
65
name: 'eslint-plugin-react-hooks',
66
+ version: '7.0.0',
67
},
68
rules,
69
configs,
70
};
71
72
Object.assign(configs.flat, {
84
- 'recommended-legacy': {
85
- plugins: {'react-hooks': plugin},
86
- rules: configs['recommended-legacy'].rules,
87
- },
88
- 'recommended-latest-legacy': {
89
- plugins: {'react-hooks': plugin},
90
- rules: configs['recommended-latest-legacy'].rules,
91
- },
92
- 'flat/recommended': {
93
- plugins: {'react-hooks': plugin},
94
- rules: configs['flat/recommended'].rules,
95
- },
73
'recommended-latest': {
74
plugins: {'react-hooks': plugin},
75
rules: configs['recommended-latest'].rules,