Skip to content

Commit 7568e71

Browse files
authored
[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
1 parent 9724e3e commit 7568e71

8 files changed

Lines changed: 60 additions & 74 deletions

File tree

‎ReactVersions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
3333
constrcNumber=0;
3434

3535
conststablePackages={
36-
'eslint-plugin-react-hooks': '6.2.0',
36+
'eslint-plugin-react-hooks': '7.0.0',
3737
'jest-react': '0.18.0',
3838
react: ReactVersion,
3939
'react-art': ReactVersion,

‎fixtures/eslint-v6/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v7/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v8/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎packages/eslint-plugin-react-hooks/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17
## 6.1.1
28

39
**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‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
44

55
## Installation
66

7-
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8-
97
Assuming you already have ESLint installed, run:
108

119
```sh
@@ -18,71 +16,40 @@ yarn add eslint-plugin-react-hooks --dev
1816

1917
### Flat Config (eslint.config.js|ts)
2018

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:
2420

2521
```js
2622
// eslint.config.js
2723
importreactHooksfrom'eslint-plugin-react-hooks';
2824
import { defineConfig } from'eslint/config';
2925

3026
exportdefaultdefineConfig([
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,
3828
]);
3929
```
4030

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`.
4432

4533
```js
34+
// eslint.config.js
4635
importreactHooksfrom'eslint-plugin-react-hooks';
4736
import { defineConfig } from'eslint/config';
4837

4938
exportdefaultdefineConfig([
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'],
5740
]);
5841
```
5942

6043
### Legacy Config (.eslintrc)
6144

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.
6546

6647
```js
6748
{
68-
"extends": [
69-
// ...
70-
"plugin:react-hooks/recommended-legacy"
71-
]
49+
"extends": ["plugin:react-hooks/recommended"],
50+
// ...
7251
}
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`.
7852

79-
```js
80-
{
81-
"extends": [
82-
// ...
83-
"plugin:react-hooks/recommended"
84-
]
85-
}
8653
```
8754

8855
### Custom Configuration
@@ -92,16 +59,34 @@ If you want more fine-grained configuration, you can instead choose to enable sp
9259
#### Flat Config (eslint.config.js|ts)
9360

9461
```js
95-
import*asreactHooksfrom'eslint-plugin-react-hooks';
62+
importreactHooksfrom'eslint-plugin-react-hooks';
9663

9764
exportdefault [
9865
{
9966
files: ['**/*.{js,jsx}'],
10067
plugins: { 'react-hooks': reactHooks },
10168
// ...
10269
rules: {
70+
// Core hooks rules
10371
'react-hooks/rules-of-hooks':'error',
10472
'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',
10590
}
10691
},
10792
];
@@ -116,8 +101,26 @@ export default [
116101
],
117102
"rules": {
118103
// ...
104+
// Core hooks rules
119105
"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"
121124
}
122125
}
123126
```

‎packages/eslint-plugin-react-hooks/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "5.2.0",
4+
"version": "7.0.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

‎packages/eslint-plugin-react-hooks/src/index.ts‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
4444
constplugins=['react-hooks'];
4545

4646
typeReactHooksFlatConfig={
47-
plugins: Record<string,any>;
47+
plugins: {react:any};
4848
rules: Linter.RulesRecord;
4949
};
5050

5151
constconfigs={
52-
'recommended-legacy': {
53-
plugins,
54-
rules: basicRuleConfigs,
55-
},
56-
'recommended-latest-legacy': {
52+
recommended: {
5753
plugins,
5854
rules: allRuleConfigs,
5955
},
60-
'flat/recommended': {
61-
plugins,
62-
rules: basicRuleConfigs,
63-
},
6456
'recommended-latest': {
6557
plugins,
6658
rules: allRuleConfigs,
6759
},
68-
recommended: {
69-
plugins,
70-
rules: basicRuleConfigs,
71-
},
7260
flat: {}asRecord<string,ReactHooksFlatConfig>,
7361
};
7462

7563
constplugin={
7664
meta: {
7765
name: 'eslint-plugin-react-hooks',
66+
version: '7.0.0',
7867
},
7968
rules,
8069
configs,
8170
};
8271

8372
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-
},
9673
'recommended-latest': {
9774
plugins: {'react-hooks': plugin},
9875
rules: configs['recommended-latest'].rules,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
[eprh] Prepare for 7.0.0 (#34757) · react/react@7568e71 · GitHub
Skip to content

Commit 7568e71

Browse files
authored
[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
1 parent 9724e3e commit 7568e71

8 files changed

Lines changed: 60 additions & 74 deletions

File tree

‎ReactVersions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
3333
constrcNumber=0;
3434

3535
conststablePackages={
36-
'eslint-plugin-react-hooks': '6.2.0',
36+
'eslint-plugin-react-hooks': '7.0.0',
3737
'jest-react': '0.18.0',
3838
react: ReactVersion,
3939
'react-art': ReactVersion,

‎fixtures/eslint-v6/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v7/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v8/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎packages/eslint-plugin-react-hooks/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17
## 6.1.1
28

39
**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‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
44

55
## Installation
66

7-
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8-
97
Assuming you already have ESLint installed, run:
108

119
```sh
@@ -18,71 +16,40 @@ yarn add eslint-plugin-react-hooks --dev
1816

1917
### Flat Config (eslint.config.js|ts)
2018

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:
2420

2521
```js
2622
// eslint.config.js
2723
importreactHooksfrom'eslint-plugin-react-hooks';
2824
import { defineConfig } from'eslint/config';
2925

3026
exportdefaultdefineConfig([
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,
3828
]);
3929
```
4030

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`.
4432

4533
```js
34+
// eslint.config.js
4635
importreactHooksfrom'eslint-plugin-react-hooks';
4736
import { defineConfig } from'eslint/config';
4837

4938
exportdefaultdefineConfig([
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'],
5740
]);
5841
```
5942

6043
### Legacy Config (.eslintrc)
6144

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.
6546

6647
```js
6748
{
68-
"extends": [
69-
// ...
70-
"plugin:react-hooks/recommended-legacy"
71-
]
49+
"extends": ["plugin:react-hooks/recommended"],
50+
// ...
7251
}
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`.
7852

79-
```js
80-
{
81-
"extends": [
82-
// ...
83-
"plugin:react-hooks/recommended"
84-
]
85-
}
8653
```
8754

8855
### Custom Configuration
@@ -92,16 +59,34 @@ If you want more fine-grained configuration, you can instead choose to enable sp
9259
#### Flat Config (eslint.config.js|ts)
9360

9461
```js
95-
import*asreactHooksfrom'eslint-plugin-react-hooks';
62+
importreactHooksfrom'eslint-plugin-react-hooks';
9663

9764
exportdefault [
9865
{
9966
files: ['**/*.{js,jsx}'],
10067
plugins: { 'react-hooks': reactHooks },
10168
// ...
10269
rules: {
70+
// Core hooks rules
10371
'react-hooks/rules-of-hooks':'error',
10472
'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',
10590
}
10691
},
10792
];
@@ -116,8 +101,26 @@ export default [
116101
],
117102
"rules": {
118103
// ...
104+
// Core hooks rules
119105
"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"
121124
}
122125
}
123126
```

‎packages/eslint-plugin-react-hooks/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "5.2.0",
4+
"version": "7.0.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

‎packages/eslint-plugin-react-hooks/src/index.ts‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
4444
constplugins=['react-hooks'];
4545

4646
typeReactHooksFlatConfig={
47-
plugins: Record<string,any>;
47+
plugins: {react:any};
4848
rules: Linter.RulesRecord;
4949
};
5050

5151
constconfigs={
52-
'recommended-legacy': {
53-
plugins,
54-
rules: basicRuleConfigs,
55-
},
56-
'recommended-latest-legacy': {
52+
recommended: {
5753
plugins,
5854
rules: allRuleConfigs,
5955
},
60-
'flat/recommended': {
61-
plugins,
62-
rules: basicRuleConfigs,
63-
},
6456
'recommended-latest': {
6557
plugins,
6658
rules: allRuleConfigs,
6759
},
68-
recommended: {
69-
plugins,
70-
rules: basicRuleConfigs,
71-
},
7260
flat: {}asRecord<string,ReactHooksFlatConfig>,
7361
};
7462

7563
constplugin={
7664
meta: {
7765
name: 'eslint-plugin-react-hooks',
66+
version: '7.0.0',
7867
},
7968
rules,
8069
configs,
8170
};
8271

8372
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-
},
9673
'recommended-latest': {
9774
plugins: {'react-hooks': plugin},
9875
rules: configs['recommended-latest'].rules,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [eprh] Prepare for 7.0.0 (#34757) · react/react@7568e71 · GitHub
Skip to content

Commit 7568e71

Browse files
authored
[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
1 parent 9724e3e commit 7568e71

8 files changed

Lines changed: 60 additions & 74 deletions

File tree

‎ReactVersions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
3333
constrcNumber=0;
3434

3535
conststablePackages={
36-
'eslint-plugin-react-hooks': '6.2.0',
36+
'eslint-plugin-react-hooks': '7.0.0',
3737
'jest-react': '0.18.0',
3838
react: ReactVersion,
3939
'react-art': ReactVersion,

‎fixtures/eslint-v6/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v7/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v8/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎packages/eslint-plugin-react-hooks/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17
## 6.1.1
28

39
**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‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
44

55
## Installation
66

7-
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8-
97
Assuming you already have ESLint installed, run:
108

119
```sh
@@ -18,71 +16,40 @@ yarn add eslint-plugin-react-hooks --dev
1816

1917
### Flat Config (eslint.config.js|ts)
2018

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:
2420

2521
```js
2622
// eslint.config.js
2723
importreactHooksfrom'eslint-plugin-react-hooks';
2824
import { defineConfig } from'eslint/config';
2925

3026
exportdefaultdefineConfig([
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,
3828
]);
3929
```
4030

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`.
4432

4533
```js
34+
// eslint.config.js
4635
importreactHooksfrom'eslint-plugin-react-hooks';
4736
import { defineConfig } from'eslint/config';
4837

4938
exportdefaultdefineConfig([
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'],
5740
]);
5841
```
5942

6043
### Legacy Config (.eslintrc)
6144

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.
6546

6647
```js
6748
{
68-
"extends": [
69-
// ...
70-
"plugin:react-hooks/recommended-legacy"
71-
]
49+
"extends": ["plugin:react-hooks/recommended"],
50+
// ...
7251
}
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`.
7852

79-
```js
80-
{
81-
"extends": [
82-
// ...
83-
"plugin:react-hooks/recommended"
84-
]
85-
}
8653
```
8754

8855
### Custom Configuration
@@ -92,16 +59,34 @@ If you want more fine-grained configuration, you can instead choose to enable sp
9259
#### Flat Config (eslint.config.js|ts)
9360

9461
```js
95-
import*asreactHooksfrom'eslint-plugin-react-hooks';
62+
importreactHooksfrom'eslint-plugin-react-hooks';
9663

9764
exportdefault [
9865
{
9966
files: ['**/*.{js,jsx}'],
10067
plugins: { 'react-hooks': reactHooks },
10168
// ...
10269
rules: {
70+
// Core hooks rules
10371
'react-hooks/rules-of-hooks':'error',
10472
'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',
10590
}
10691
},
10792
];
@@ -116,8 +101,26 @@ export default [
116101
],
117102
"rules": {
118103
// ...
104+
// Core hooks rules
119105
"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"
121124
}
122125
}
123126
```

‎packages/eslint-plugin-react-hooks/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "5.2.0",
4+
"version": "7.0.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

‎packages/eslint-plugin-react-hooks/src/index.ts‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
4444
constplugins=['react-hooks'];
4545

4646
typeReactHooksFlatConfig={
47-
plugins: Record<string,any>;
47+
plugins: {react:any};
4848
rules: Linter.RulesRecord;
4949
};
5050

5151
constconfigs={
52-
'recommended-legacy': {
53-
plugins,
54-
rules: basicRuleConfigs,
55-
},
56-
'recommended-latest-legacy': {
52+
recommended: {
5753
plugins,
5854
rules: allRuleConfigs,
5955
},
60-
'flat/recommended': {
61-
plugins,
62-
rules: basicRuleConfigs,
63-
},
6456
'recommended-latest': {
6557
plugins,
6658
rules: allRuleConfigs,
6759
},
68-
recommended: {
69-
plugins,
70-
rules: basicRuleConfigs,
71-
},
7260
flat: {}asRecord<string,ReactHooksFlatConfig>,
7361
};
7462

7563
constplugin={
7664
meta: {
7765
name: 'eslint-plugin-react-hooks',
66+
version: '7.0.0',
7867
},
7968
rules,
8069
configs,
8170
};
8271

8372
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-
},
9673
'recommended-latest': {
9774
plugins: {'react-hooks': plugin},
9875
rules: configs['recommended-latest'].rules,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [eprh] Prepare for 7.0.0 (#34757) · react/react@7568e71 · GitHub
Skip to content

Commit 7568e71

Browse files
authored
[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
1 parent 9724e3e commit 7568e71

8 files changed

Lines changed: 60 additions & 74 deletions

File tree

‎ReactVersions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
3333
constrcNumber=0;
3434

3535
conststablePackages={
36-
'eslint-plugin-react-hooks': '6.2.0',
36+
'eslint-plugin-react-hooks': '7.0.0',
3737
'jest-react': '0.18.0',
3838
react: ReactVersion,
3939
'react-art': ReactVersion,

‎fixtures/eslint-v6/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v7/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v8/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎packages/eslint-plugin-react-hooks/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17
## 6.1.1
28

39
**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‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
44

55
## Installation
66

7-
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8-
97
Assuming you already have ESLint installed, run:
108

119
```sh
@@ -18,71 +16,40 @@ yarn add eslint-plugin-react-hooks --dev
1816

1917
### Flat Config (eslint.config.js|ts)
2018

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:
2420

2521
```js
2622
// eslint.config.js
2723
importreactHooksfrom'eslint-plugin-react-hooks';
2824
import { defineConfig } from'eslint/config';
2925

3026
exportdefaultdefineConfig([
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,
3828
]);
3929
```
4030

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`.
4432

4533
```js
34+
// eslint.config.js
4635
importreactHooksfrom'eslint-plugin-react-hooks';
4736
import { defineConfig } from'eslint/config';
4837

4938
exportdefaultdefineConfig([
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'],
5740
]);
5841
```
5942

6043
### Legacy Config (.eslintrc)
6144

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.
6546

6647
```js
6748
{
68-
"extends": [
69-
// ...
70-
"plugin:react-hooks/recommended-legacy"
71-
]
49+
"extends": ["plugin:react-hooks/recommended"],
50+
// ...
7251
}
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`.
7852

79-
```js
80-
{
81-
"extends": [
82-
// ...
83-
"plugin:react-hooks/recommended"
84-
]
85-
}
8653
```
8754

8855
### Custom Configuration
@@ -92,16 +59,34 @@ If you want more fine-grained configuration, you can instead choose to enable sp
9259
#### Flat Config (eslint.config.js|ts)
9360

9461
```js
95-
import*asreactHooksfrom'eslint-plugin-react-hooks';
62+
importreactHooksfrom'eslint-plugin-react-hooks';
9663

9764
exportdefault [
9865
{
9966
files: ['**/*.{js,jsx}'],
10067
plugins: { 'react-hooks': reactHooks },
10168
// ...
10269
rules: {
70+
// Core hooks rules
10371
'react-hooks/rules-of-hooks':'error',
10472
'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',
10590
}
10691
},
10792
];
@@ -116,8 +101,26 @@ export default [
116101
],
117102
"rules": {
118103
// ...
104+
// Core hooks rules
119105
"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"
121124
}
122125
}
123126
```

‎packages/eslint-plugin-react-hooks/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "5.2.0",
4+
"version": "7.0.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

‎packages/eslint-plugin-react-hooks/src/index.ts‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
4444
constplugins=['react-hooks'];
4545

4646
typeReactHooksFlatConfig={
47-
plugins: Record<string,any>;
47+
plugins: {react:any};
4848
rules: Linter.RulesRecord;
4949
};
5050

5151
constconfigs={
52-
'recommended-legacy': {
53-
plugins,
54-
rules: basicRuleConfigs,
55-
},
56-
'recommended-latest-legacy': {
52+
recommended: {
5753
plugins,
5854
rules: allRuleConfigs,
5955
},
60-
'flat/recommended': {
61-
plugins,
62-
rules: basicRuleConfigs,
63-
},
6456
'recommended-latest': {
6557
plugins,
6658
rules: allRuleConfigs,
6759
},
68-
recommended: {
69-
plugins,
70-
rules: basicRuleConfigs,
71-
},
7260
flat: {}asRecord<string,ReactHooksFlatConfig>,
7361
};
7462

7563
constplugin={
7664
meta: {
7765
name: 'eslint-plugin-react-hooks',
66+
version: '7.0.0',
7867
},
7968
rules,
8069
configs,
8170
};
8271

8372
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-
},
9673
'recommended-latest': {
9774
plugins: {'react-hooks': plugin},
9875
rules: configs['recommended-latest'].rules,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' [eprh] Prepare for 7.0.0 (#34757) · react/react@7568e71 · GitHub
Skip to content

Commit 7568e71

Browse files
authored
[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
1 parent 9724e3e commit 7568e71

8 files changed

Lines changed: 60 additions & 74 deletions

File tree

‎ReactVersions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
3333
constrcNumber=0;
3434

3535
conststablePackages={
36-
'eslint-plugin-react-hooks': '6.2.0',
36+
'eslint-plugin-react-hooks': '7.0.0',
3737
'jest-react': '0.18.0',
3838
react: ReactVersion,
3939
'react-art': ReactVersion,

‎fixtures/eslint-v6/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v7/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v8/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎packages/eslint-plugin-react-hooks/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17
## 6.1.1
28

39
**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‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
44

55
## Installation
66

7-
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8-
97
Assuming you already have ESLint installed, run:
108

119
```sh
@@ -18,71 +16,40 @@ yarn add eslint-plugin-react-hooks --dev
1816

1917
### Flat Config (eslint.config.js|ts)
2018

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:
2420

2521
```js
2622
// eslint.config.js
2723
importreactHooksfrom'eslint-plugin-react-hooks';
2824
import { defineConfig } from'eslint/config';
2925

3026
exportdefaultdefineConfig([
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,
3828
]);
3929
```
4030

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`.
4432

4533
```js
34+
// eslint.config.js
4635
importreactHooksfrom'eslint-plugin-react-hooks';
4736
import { defineConfig } from'eslint/config';
4837

4938
exportdefaultdefineConfig([
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'],
5740
]);
5841
```
5942

6043
### Legacy Config (.eslintrc)
6144

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.
6546

6647
```js
6748
{
68-
"extends": [
69-
// ...
70-
"plugin:react-hooks/recommended-legacy"
71-
]
49+
"extends": ["plugin:react-hooks/recommended"],
50+
// ...
7251
}
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`.
7852

79-
```js
80-
{
81-
"extends": [
82-
// ...
83-
"plugin:react-hooks/recommended"
84-
]
85-
}
8653
```
8754

8855
### Custom Configuration
@@ -92,16 +59,34 @@ If you want more fine-grained configuration, you can instead choose to enable sp
9259
#### Flat Config (eslint.config.js|ts)
9360

9461
```js
95-
import*asreactHooksfrom'eslint-plugin-react-hooks';
62+
importreactHooksfrom'eslint-plugin-react-hooks';
9663

9764
exportdefault [
9865
{
9966
files: ['**/*.{js,jsx}'],
10067
plugins: { 'react-hooks': reactHooks },
10168
// ...
10269
rules: {
70+
// Core hooks rules
10371
'react-hooks/rules-of-hooks':'error',
10472
'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',
10590
}
10691
},
10792
];
@@ -116,8 +101,26 @@ export default [
116101
],
117102
"rules": {
118103
// ...
104+
// Core hooks rules
119105
"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"
121124
}
122125
}
123126
```

‎packages/eslint-plugin-react-hooks/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "5.2.0",
4+
"version": "7.0.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

‎packages/eslint-plugin-react-hooks/src/index.ts‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
4444
constplugins=['react-hooks'];
4545

4646
typeReactHooksFlatConfig={
47-
plugins: Record<string,any>;
47+
plugins: {react:any};
4848
rules: Linter.RulesRecord;
4949
};
5050

5151
constconfigs={
52-
'recommended-legacy': {
53-
plugins,
54-
rules: basicRuleConfigs,
55-
},
56-
'recommended-latest-legacy': {
52+
recommended: {
5753
plugins,
5854
rules: allRuleConfigs,
5955
},
60-
'flat/recommended': {
61-
plugins,
62-
rules: basicRuleConfigs,
63-
},
6456
'recommended-latest': {
6557
plugins,
6658
rules: allRuleConfigs,
6759
},
68-
recommended: {
69-
plugins,
70-
rules: basicRuleConfigs,
71-
},
7260
flat: {}asRecord<string,ReactHooksFlatConfig>,
7361
};
7462

7563
constplugin={
7664
meta: {
7765
name: 'eslint-plugin-react-hooks',
66+
version: '7.0.0',
7867
},
7968
rules,
8069
configs,
8170
};
8271

8372
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-
},
9673
'recommended-latest': {
9774
plugins: {'react-hooks': plugin},
9875
rules: configs['recommended-latest'].rules,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [eprh] Prepare for 7.0.0 (#34757) · react/react@7568e71 · GitHub
Skip to content

Commit 7568e71

Browse files
authored
[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
1 parent 9724e3e commit 7568e71

8 files changed

Lines changed: 60 additions & 74 deletions

File tree

‎ReactVersions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
3333
constrcNumber=0;
3434

3535
conststablePackages={
36-
'eslint-plugin-react-hooks': '6.2.0',
36+
'eslint-plugin-react-hooks': '7.0.0',
3737
'jest-react': '0.18.0',
3838
react: ReactVersion,
3939
'react-art': ReactVersion,

‎fixtures/eslint-v6/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v7/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v8/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎packages/eslint-plugin-react-hooks/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17
## 6.1.1
28

39
**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‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
44

55
## Installation
66

7-
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8-
97
Assuming you already have ESLint installed, run:
108

119
```sh
@@ -18,71 +16,40 @@ yarn add eslint-plugin-react-hooks --dev
1816

1917
### Flat Config (eslint.config.js|ts)
2018

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:
2420

2521
```js
2622
// eslint.config.js
2723
importreactHooksfrom'eslint-plugin-react-hooks';
2824
import { defineConfig } from'eslint/config';
2925

3026
exportdefaultdefineConfig([
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,
3828
]);
3929
```
4030

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`.
4432

4533
```js
34+
// eslint.config.js
4635
importreactHooksfrom'eslint-plugin-react-hooks';
4736
import { defineConfig } from'eslint/config';
4837

4938
exportdefaultdefineConfig([
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'],
5740
]);
5841
```
5942

6043
### Legacy Config (.eslintrc)
6144

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.
6546

6647
```js
6748
{
68-
"extends": [
69-
// ...
70-
"plugin:react-hooks/recommended-legacy"
71-
]
49+
"extends": ["plugin:react-hooks/recommended"],
50+
// ...
7251
}
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`.
7852

79-
```js
80-
{
81-
"extends": [
82-
// ...
83-
"plugin:react-hooks/recommended"
84-
]
85-
}
8653
```
8754

8855
### Custom Configuration
@@ -92,16 +59,34 @@ If you want more fine-grained configuration, you can instead choose to enable sp
9259
#### Flat Config (eslint.config.js|ts)
9360

9461
```js
95-
import*asreactHooksfrom'eslint-plugin-react-hooks';
62+
importreactHooksfrom'eslint-plugin-react-hooks';
9663

9764
exportdefault [
9865
{
9966
files: ['**/*.{js,jsx}'],
10067
plugins: { 'react-hooks': reactHooks },
10168
// ...
10269
rules: {
70+
// Core hooks rules
10371
'react-hooks/rules-of-hooks':'error',
10472
'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',
10590
}
10691
},
10792
];
@@ -116,8 +101,26 @@ export default [
116101
],
117102
"rules": {
118103
// ...
104+
// Core hooks rules
119105
"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"
121124
}
122125
}
123126
```

‎packages/eslint-plugin-react-hooks/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "5.2.0",
4+
"version": "7.0.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

‎packages/eslint-plugin-react-hooks/src/index.ts‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
4444
constplugins=['react-hooks'];
4545

4646
typeReactHooksFlatConfig={
47-
plugins: Record<string,any>;
47+
plugins: {react:any};
4848
rules: Linter.RulesRecord;
4949
};
5050

5151
constconfigs={
52-
'recommended-legacy': {
53-
plugins,
54-
rules: basicRuleConfigs,
55-
},
56-
'recommended-latest-legacy': {
52+
recommended: {
5753
plugins,
5854
rules: allRuleConfigs,
5955
},
60-
'flat/recommended': {
61-
plugins,
62-
rules: basicRuleConfigs,
63-
},
6456
'recommended-latest': {
6557
plugins,
6658
rules: allRuleConfigs,
6759
},
68-
recommended: {
69-
plugins,
70-
rules: basicRuleConfigs,
71-
},
7260
flat: {}asRecord<string,ReactHooksFlatConfig>,
7361
};
7462

7563
constplugin={
7664
meta: {
7765
name: 'eslint-plugin-react-hooks',
66+
version: '7.0.0',
7867
},
7968
rules,
8069
configs,
8170
};
8271

8372
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-
},
9673
'recommended-latest': {
9774
plugins: {'react-hooks': plugin},
9875
rules: configs['recommended-latest'].rules,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [eprh] Prepare for 7.0.0 (#34757) · react/react@7568e71 · GitHub
Skip to content

Commit 7568e71

Browse files
authored
[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
1 parent 9724e3e commit 7568e71

8 files changed

Lines changed: 60 additions & 74 deletions

File tree

‎ReactVersions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
3333
constrcNumber=0;
3434

3535
conststablePackages={
36-
'eslint-plugin-react-hooks': '6.2.0',
36+
'eslint-plugin-react-hooks': '7.0.0',
3737
'jest-react': '0.18.0',
3838
react: ReactVersion,
3939
'react-art': ReactVersion,

‎fixtures/eslint-v6/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v7/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v8/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎packages/eslint-plugin-react-hooks/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17
## 6.1.1
28

39
**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‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
44

55
## Installation
66

7-
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8-
97
Assuming you already have ESLint installed, run:
108

119
```sh
@@ -18,71 +16,40 @@ yarn add eslint-plugin-react-hooks --dev
1816

1917
### Flat Config (eslint.config.js|ts)
2018

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:
2420

2521
```js
2622
// eslint.config.js
2723
importreactHooksfrom'eslint-plugin-react-hooks';
2824
import { defineConfig } from'eslint/config';
2925

3026
exportdefaultdefineConfig([
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,
3828
]);
3929
```
4030

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`.
4432

4533
```js
34+
// eslint.config.js
4635
importreactHooksfrom'eslint-plugin-react-hooks';
4736
import { defineConfig } from'eslint/config';
4837

4938
exportdefaultdefineConfig([
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'],
5740
]);
5841
```
5942

6043
### Legacy Config (.eslintrc)
6144

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.
6546

6647
```js
6748
{
68-
"extends": [
69-
// ...
70-
"plugin:react-hooks/recommended-legacy"
71-
]
49+
"extends": ["plugin:react-hooks/recommended"],
50+
// ...
7251
}
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`.
7852

79-
```js
80-
{
81-
"extends": [
82-
// ...
83-
"plugin:react-hooks/recommended"
84-
]
85-
}
8653
```
8754

8855
### Custom Configuration
@@ -92,16 +59,34 @@ If you want more fine-grained configuration, you can instead choose to enable sp
9259
#### Flat Config (eslint.config.js|ts)
9360

9461
```js
95-
import*asreactHooksfrom'eslint-plugin-react-hooks';
62+
importreactHooksfrom'eslint-plugin-react-hooks';
9663

9764
exportdefault [
9865
{
9966
files: ['**/*.{js,jsx}'],
10067
plugins: { 'react-hooks': reactHooks },
10168
// ...
10269
rules: {
70+
// Core hooks rules
10371
'react-hooks/rules-of-hooks':'error',
10472
'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',
10590
}
10691
},
10792
];
@@ -116,8 +101,26 @@ export default [
116101
],
117102
"rules": {
118103
// ...
104+
// Core hooks rules
119105
"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"
121124
}
122125
}
123126
```

‎packages/eslint-plugin-react-hooks/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "5.2.0",
4+
"version": "7.0.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

‎packages/eslint-plugin-react-hooks/src/index.ts‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
4444
constplugins=['react-hooks'];
4545

4646
typeReactHooksFlatConfig={
47-
plugins: Record<string,any>;
47+
plugins: {react:any};
4848
rules: Linter.RulesRecord;
4949
};
5050

5151
constconfigs={
52-
'recommended-legacy': {
53-
plugins,
54-
rules: basicRuleConfigs,
55-
},
56-
'recommended-latest-legacy': {
52+
recommended: {
5753
plugins,
5854
rules: allRuleConfigs,
5955
},
60-
'flat/recommended': {
61-
plugins,
62-
rules: basicRuleConfigs,
63-
},
6456
'recommended-latest': {
6557
plugins,
6658
rules: allRuleConfigs,
6759
},
68-
recommended: {
69-
plugins,
70-
rules: basicRuleConfigs,
71-
},
7260
flat: {}asRecord<string,ReactHooksFlatConfig>,
7361
};
7462

7563
constplugin={
7664
meta: {
7765
name: 'eslint-plugin-react-hooks',
66+
version: '7.0.0',
7867
},
7968
rules,
8069
configs,
8170
};
8271

8372
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-
},
9673
'recommended-latest': {
9774
plugins: {'react-hooks': plugin},
9875
rules: configs['recommended-latest'].rules,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); [eprh] Prepare for 7.0.0 (#34757) · react/react@7568e71 · GitHub
Skip to content

Commit 7568e71

Browse files
authored
[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
1 parent 9724e3e commit 7568e71

8 files changed

Lines changed: 60 additions & 74 deletions

File tree

‎ReactVersions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
3333
constrcNumber=0;
3434

3535
conststablePackages={
36-
'eslint-plugin-react-hooks': '6.2.0',
36+
'eslint-plugin-react-hooks': '7.0.0',
3737
'jest-react': '0.18.0',
3838
react: ReactVersion,
3939
'react-art': ReactVersion,

‎fixtures/eslint-v6/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v7/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎fixtures/eslint-v8/.eslintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"extends": ["plugin:react-hooks/recommended-latest-legacy"],
3+
"extends": ["plugin:react-hooks/recommended"],
44
"parserOptions": {
55
"ecmaVersion": 2020,
66
"sourceType": "module",

‎packages/eslint-plugin-react-hooks/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17
## 6.1.1
28

39
**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‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
44

55
## Installation
66

7-
**Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8-
97
Assuming you already have ESLint installed, run:
108

119
```sh
@@ -18,71 +16,40 @@ yarn add eslint-plugin-react-hooks --dev
1816

1917
### Flat Config (eslint.config.js|ts)
2018

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:
2420

2521
```js
2622
// eslint.config.js
2723
importreactHooksfrom'eslint-plugin-react-hooks';
2824
import { defineConfig } from'eslint/config';
2925

3026
exportdefaultdefineConfig([
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,
3828
]);
3929
```
4030

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`.
4432

4533
```js
34+
// eslint.config.js
4635
importreactHooksfrom'eslint-plugin-react-hooks';
4736
import { defineConfig } from'eslint/config';
4837

4938
exportdefaultdefineConfig([
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'],
5740
]);
5841
```
5942

6043
### Legacy Config (.eslintrc)
6144

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.
6546

6647
```js
6748
{
68-
"extends": [
69-
// ...
70-
"plugin:react-hooks/recommended-legacy"
71-
]
49+
"extends": ["plugin:react-hooks/recommended"],
50+
// ...
7251
}
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`.
7852

79-
```js
80-
{
81-
"extends": [
82-
// ...
83-
"plugin:react-hooks/recommended"
84-
]
85-
}
8653
```
8754

8855
### Custom Configuration
@@ -92,16 +59,34 @@ If you want more fine-grained configuration, you can instead choose to enable sp
9259
#### Flat Config (eslint.config.js|ts)
9360

9461
```js
95-
import*asreactHooksfrom'eslint-plugin-react-hooks';
62+
importreactHooksfrom'eslint-plugin-react-hooks';
9663

9764
exportdefault [
9865
{
9966
files: ['**/*.{js,jsx}'],
10067
plugins: { 'react-hooks': reactHooks },
10168
// ...
10269
rules: {
70+
// Core hooks rules
10371
'react-hooks/rules-of-hooks':'error',
10472
'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',
10590
}
10691
},
10792
];
@@ -116,8 +101,26 @@ export default [
116101
],
117102
"rules": {
118103
// ...
104+
// Core hooks rules
119105
"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"
121124
}
122125
}
123126
```

‎packages/eslint-plugin-react-hooks/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "eslint-plugin-react-hooks",
33
"description": "ESLint rules for React Hooks",
4-
"version": "5.2.0",
4+
"version": "7.0.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/facebook/react.git",

‎packages/eslint-plugin-react-hooks/src/index.ts‎

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,32 @@ const allRuleConfigs: Linter.RulesRecord = {
4444
constplugins=['react-hooks'];
4545

4646
typeReactHooksFlatConfig={
47-
plugins: Record<string,any>;
47+
plugins: {react:any};
4848
rules: Linter.RulesRecord;
4949
};
5050

5151
constconfigs={
52-
'recommended-legacy': {
53-
plugins,
54-
rules: basicRuleConfigs,
55-
},
56-
'recommended-latest-legacy': {
52+
recommended: {
5753
plugins,
5854
rules: allRuleConfigs,
5955
},
60-
'flat/recommended': {
61-
plugins,
62-
rules: basicRuleConfigs,
63-
},
6456
'recommended-latest': {
6557
plugins,
6658
rules: allRuleConfigs,
6759
},
68-
recommended: {
69-
plugins,
70-
rules: basicRuleConfigs,
71-
},
7260
flat: {}asRecord<string,ReactHooksFlatConfig>,
7361
};
7462

7563
constplugin={
7664
meta: {
7765
name: 'eslint-plugin-react-hooks',
66+
version: '7.0.0',
7867
},
7968
rules,
8069
configs,
8170
};
8271

8372
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-
},
9673
'recommended-latest': {
9774
plugins: {'react-hooks': plugin},
9875
rules: configs['recommended-latest'].rules,

0 commit comments

Comments
 (0)