eslint-plugin-react-hooks 6.2.0-canary-9724e3e6-20251008 → 6.2.0-canary-03c6454d-20251008

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,8 +4,6 @@ The official ESLint plugin for [React](https://react.dev) which enforces the [Ru
4
4
 
5
5
  ## Installation
6
6
 
7
- **Note: If you're using Create React App, please use `react-scripts` >= 3 instead of adding it directly.**
8
-
9
7
  Assuming you already have ESLint installed, run:
10
8
 
11
9
  ```sh
@@ -18,9 +16,7 @@ yarn add eslint-plugin-react-hooks --dev
18
16
 
19
17
  ### Flat Config (eslint.config.js|ts)
20
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:
24
20
 
25
21
  ```js
26
22
  // eslint.config.js
@@ -28,61 +24,32 @@ import reactHooks from 'eslint-plugin-react-hooks';
28
24
  import { defineConfig } from 'eslint/config';
29
25
 
30
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,
38
28
  ]);
39
29
  ```
40
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`.
44
32
 
45
33
  ```js
34
+ // eslint.config.js
46
35
  import reactHooks from 'eslint-plugin-react-hooks';
47
36
  import { defineConfig } from 'eslint/config';
48
37
 
49
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'],
57
40
  ]);
58
41
  ```
59
42
 
60
43
  ### Legacy Config (.eslintrc)
61
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.
65
46
 
66
47
  ```js
67
48
  {
68
- "extends": [
69
- // ...
70
- "plugin:react-hooks/recommended-legacy"
71
- ]
49
+ "extends": ["plugin:react-hooks/recommended"],
50
+ // ...
72
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`.
78
52
 
79
- ```js
80
- {
81
- "extends": [
82
- // ...
83
- "plugin:react-hooks/recommended"
84
- ]
85
- }
86
53
  ```
87
54
 
88
55
  ### Custom Configuration
@@ -92,7 +59,7 @@ If you want more fine-grained configuration, you can instead choose to enable sp
92
59
  #### Flat Config (eslint.config.js|ts)
93
60
 
94
61
  ```js
95
- import * as reactHooks from 'eslint-plugin-react-hooks';
62
+ import reactHooks from 'eslint-plugin-react-hooks';
96
63
 
97
64
  export default [
98
65
  {
@@ -100,8 +67,26 @@ export default [
100
67
  plugins: { 'react-hooks': reactHooks },
101
68
  // ...
102
69
  rules: {
70
+ // Core hooks rules
103
71
  'react-hooks/rules-of-hooks': 'error',
104
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',
105
90
  }
106
91
  },
107
92
  ];
@@ -116,8 +101,26 @@ export default [
116
101
  ],
117
102
  "rules": {
118
103
  // ...
104
+ // Core hooks rules
119
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"
121
124
  }
122
125
  }
123
126
  ```
@@ -2,12 +2,15 @@ import * as estree from 'estree';
2
2
  import { Rule, Linter } from 'eslint';
3
3
 
4
4
  type ReactHooksFlatConfig = {
5
- plugins: Record<string, any>;
5
+ plugins: {
6
+ react: any;
7
+ };
6
8
  rules: Linter.RulesRecord;
7
9
  };
8
10
  declare const plugin: {
9
11
  meta: {
10
12
  name: string;
13
+ version: string;
11
14
  };
12
15
  rules: {
13
16
  'exhaustive-deps': {
@@ -77,35 +80,14 @@ declare const plugin: {
77
80
  };
78
81
  };
79
82
  configs: {
80
- 'recommended-legacy': {
81
- plugins: string[];
82
- rules: {
83
- readonly 'react-hooks/rules-of-hooks': "error";
84
- readonly 'react-hooks/exhaustive-deps': "warn";
85
- };
86
- };
87
- 'recommended-latest-legacy': {
83
+ recommended: {
88
84
  plugins: string[];
89
85
  rules: Linter.RulesRecord;
90
86
  };
91
- 'flat/recommended': {
92
- plugins: string[];
93
- rules: {
94
- readonly 'react-hooks/rules-of-hooks': "error";
95
- readonly 'react-hooks/exhaustive-deps': "warn";
96
- };
97
- };
98
87
  'recommended-latest': {
99
88
  plugins: string[];
100
89
  rules: Linter.RulesRecord;
101
90
  };
102
- recommended: {
103
- plugins: string[];
104
- rules: {
105
- readonly 'react-hooks/rules-of-hooks': "error";
106
- readonly 'react-hooks/exhaustive-deps': "warn";
107
- };
108
- };
109
91
  flat: Record<string, ReactHooksFlatConfig>;
110
92
  };
111
93
  };
@@ -57708,48 +57708,25 @@ const compilerRuleConfigs = Object.fromEntries(Object.entries(recommendedRules).
57708
57708
  const allRuleConfigs = Object.assign(Object.assign({}, basicRuleConfigs), compilerRuleConfigs);
57709
57709
  const plugins = ['react-hooks'];
57710
57710
  const configs = {
57711
- 'recommended-legacy': {
57712
- plugins,
57713
- rules: basicRuleConfigs,
57714
- },
57715
- 'recommended-latest-legacy': {
57711
+ recommended: {
57716
57712
  plugins,
57717
57713
  rules: allRuleConfigs,
57718
57714
  },
57719
- 'flat/recommended': {
57720
- plugins,
57721
- rules: basicRuleConfigs,
57722
- },
57723
57715
  'recommended-latest': {
57724
57716
  plugins,
57725
57717
  rules: allRuleConfigs,
57726
57718
  },
57727
- recommended: {
57728
- plugins,
57729
- rules: basicRuleConfigs,
57730
- },
57731
57719
  flat: {},
57732
57720
  };
57733
57721
  const plugin = {
57734
57722
  meta: {
57735
57723
  name: 'eslint-plugin-react-hooks',
57724
+ version: '7.0.0',
57736
57725
  },
57737
57726
  rules,
57738
57727
  configs,
57739
57728
  };
57740
57729
  Object.assign(configs.flat, {
57741
- 'recommended-legacy': {
57742
- plugins: { 'react-hooks': plugin },
57743
- rules: configs['recommended-legacy'].rules,
57744
- },
57745
- 'recommended-latest-legacy': {
57746
- plugins: { 'react-hooks': plugin },
57747
- rules: configs['recommended-latest-legacy'].rules,
57748
- },
57749
- 'flat/recommended': {
57750
- plugins: { 'react-hooks': plugin },
57751
- rules: configs['flat/recommended'].rules,
57752
- },
57753
57730
  'recommended-latest': {
57754
57731
  plugins: { 'react-hooks': plugin },
57755
57732
  rules: configs['recommended-latest'].rules,
@@ -57535,48 +57535,25 @@ const compilerRuleConfigs = Object.fromEntries(Object.entries(recommendedRules).
57535
57535
  const allRuleConfigs = Object.assign(Object.assign({}, basicRuleConfigs), compilerRuleConfigs);
57536
57536
  const plugins = ['react-hooks'];
57537
57537
  const configs = {
57538
- 'recommended-legacy': {
57539
- plugins,
57540
- rules: basicRuleConfigs,
57541
- },
57542
- 'recommended-latest-legacy': {
57538
+ recommended: {
57543
57539
  plugins,
57544
57540
  rules: allRuleConfigs,
57545
57541
  },
57546
- 'flat/recommended': {
57547
- plugins,
57548
- rules: basicRuleConfigs,
57549
- },
57550
57542
  'recommended-latest': {
57551
57543
  plugins,
57552
57544
  rules: allRuleConfigs,
57553
57545
  },
57554
- recommended: {
57555
- plugins,
57556
- rules: basicRuleConfigs,
57557
- },
57558
57546
  flat: {},
57559
57547
  };
57560
57548
  const plugin = {
57561
57549
  meta: {
57562
57550
  name: 'eslint-plugin-react-hooks',
57551
+ version: '7.0.0',
57563
57552
  },
57564
57553
  rules,
57565
57554
  configs,
57566
57555
  };
57567
57556
  Object.assign(configs.flat, {
57568
- 'recommended-legacy': {
57569
- plugins: { 'react-hooks': plugin },
57570
- rules: configs['recommended-legacy'].rules,
57571
- },
57572
- 'recommended-latest-legacy': {
57573
- plugins: { 'react-hooks': plugin },
57574
- rules: configs['recommended-latest-legacy'].rules,
57575
- },
57576
- 'flat/recommended': {
57577
- plugins: { 'react-hooks': plugin },
57578
- rules: configs['flat/recommended'].rules,
57579
- },
57580
57557
  'recommended-latest': {
57581
57558
  plugins: { 'react-hooks': plugin },
57582
57559
  rules: configs['recommended-latest'].rules,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks",
3
3
  "description": "ESLint rules for React Hooks",
4
- "version": "6.2.0-canary-9724e3e6-20251008",
4
+ "version": "6.2.0-canary-03c6454d-20251008",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/facebook/react.git",