eslint-plugin-react-hooks 6.2.0-canary-3025aa39-20251007 → 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
  ```
@@ -1,13 +1,16 @@
1
1
  import * as estree from 'estree';
2
2
  import { Rule, Linter } from 'eslint';
3
3
 
4
- type FlatConfig = {
5
- plugins: Record<string, any>;
4
+ type ReactHooksFlatConfig = {
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,17 +80,15 @@ declare const plugin: {
77
80
  };
78
81
  };
79
82
  configs: {
80
- "recommended-legacy": {
81
- plugins: Array<string>;
83
+ recommended: {
84
+ plugins: string[];
82
85
  rules: Linter.RulesRecord;
83
86
  };
84
- "recommended-latest-legacy": {
85
- plugins: Array<string>;
87
+ 'recommended-latest': {
88
+ plugins: string[];
86
89
  rules: Linter.RulesRecord;
87
90
  };
88
- "flat/recommended": Array<FlatConfig>;
89
- "recommended-latest": Array<FlatConfig>;
90
- recommended: Array<FlatConfig>;
91
+ flat: Record<string, ReactHooksFlatConfig>;
91
92
  };
92
93
  };
93
94
 
@@ -57706,46 +57706,35 @@ const compilerRuleConfigs = Object.fromEntries(Object.entries(recommendedRules).
57706
57706
  ];
57707
57707
  }));
57708
57708
  const allRuleConfigs = Object.assign(Object.assign({}, basicRuleConfigs), compilerRuleConfigs);
57709
+ const plugins = ['react-hooks'];
57710
+ const configs = {
57711
+ recommended: {
57712
+ plugins,
57713
+ rules: allRuleConfigs,
57714
+ },
57715
+ 'recommended-latest': {
57716
+ plugins,
57717
+ rules: allRuleConfigs,
57718
+ },
57719
+ flat: {},
57720
+ };
57709
57721
  const plugin = {
57710
57722
  meta: {
57711
57723
  name: 'eslint-plugin-react-hooks',
57724
+ version: '7.0.0',
57712
57725
  },
57713
57726
  rules,
57714
- configs: {},
57727
+ configs,
57715
57728
  };
57716
- Object.assign(plugin.configs, {
57717
- 'recommended-legacy': {
57718
- plugins: ['react-hooks'],
57719
- rules: basicRuleConfigs,
57729
+ Object.assign(configs.flat, {
57730
+ 'recommended-latest': {
57731
+ plugins: { 'react-hooks': plugin },
57732
+ rules: configs['recommended-latest'].rules,
57720
57733
  },
57721
- 'recommended-latest-legacy': {
57722
- plugins: ['react-hooks'],
57723
- rules: allRuleConfigs,
57734
+ recommended: {
57735
+ plugins: { 'react-hooks': plugin },
57736
+ rules: configs.recommended.rules,
57724
57737
  },
57725
- 'flat/recommended': [
57726
- {
57727
- plugins: {
57728
- 'react-hooks': plugin,
57729
- },
57730
- rules: basicRuleConfigs,
57731
- },
57732
- ],
57733
- 'recommended-latest': [
57734
- {
57735
- plugins: {
57736
- 'react-hooks': plugin,
57737
- },
57738
- rules: allRuleConfigs,
57739
- },
57740
- ],
57741
- recommended: [
57742
- {
57743
- plugins: {
57744
- 'react-hooks': plugin,
57745
- },
57746
- rules: basicRuleConfigs,
57747
- },
57748
- ],
57749
57738
  });
57750
57739
 
57751
57740
  module.exports = plugin;
@@ -57533,46 +57533,35 @@ const compilerRuleConfigs = Object.fromEntries(Object.entries(recommendedRules).
57533
57533
  ];
57534
57534
  }));
57535
57535
  const allRuleConfigs = Object.assign(Object.assign({}, basicRuleConfigs), compilerRuleConfigs);
57536
+ const plugins = ['react-hooks'];
57537
+ const configs = {
57538
+ recommended: {
57539
+ plugins,
57540
+ rules: allRuleConfigs,
57541
+ },
57542
+ 'recommended-latest': {
57543
+ plugins,
57544
+ rules: allRuleConfigs,
57545
+ },
57546
+ flat: {},
57547
+ };
57536
57548
  const plugin = {
57537
57549
  meta: {
57538
57550
  name: 'eslint-plugin-react-hooks',
57551
+ version: '7.0.0',
57539
57552
  },
57540
57553
  rules,
57541
- configs: {},
57554
+ configs,
57542
57555
  };
57543
- Object.assign(plugin.configs, {
57544
- 'recommended-legacy': {
57545
- plugins: ['react-hooks'],
57546
- rules: basicRuleConfigs,
57556
+ Object.assign(configs.flat, {
57557
+ 'recommended-latest': {
57558
+ plugins: { 'react-hooks': plugin },
57559
+ rules: configs['recommended-latest'].rules,
57547
57560
  },
57548
- 'recommended-latest-legacy': {
57549
- plugins: ['react-hooks'],
57550
- rules: allRuleConfigs,
57561
+ recommended: {
57562
+ plugins: { 'react-hooks': plugin },
57563
+ rules: configs.recommended.rules,
57551
57564
  },
57552
- 'flat/recommended': [
57553
- {
57554
- plugins: {
57555
- 'react-hooks': plugin,
57556
- },
57557
- rules: basicRuleConfigs,
57558
- },
57559
- ],
57560
- 'recommended-latest': [
57561
- {
57562
- plugins: {
57563
- 'react-hooks': plugin,
57564
- },
57565
- rules: allRuleConfigs,
57566
- },
57567
- ],
57568
- recommended: [
57569
- {
57570
- plugins: {
57571
- 'react-hooks': plugin,
57572
- },
57573
- rules: basicRuleConfigs,
57574
- },
57575
- ],
57576
57565
  });
57577
57566
 
57578
57567
  module.exports = plugin;
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-3025aa39-20251007",
4
+ "version": "6.2.0-canary-03c6454d-20251008",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/facebook/react.git",
@@ -50,7 +50,7 @@
50
50
  "@babel/preset-typescript": "^7.26.0",
51
51
  "@babel/types": "^7.19.0",
52
52
  "@tsconfig/strictest": "^2.0.5",
53
- "@types/eslint": "^8.56.12",
53
+ "@types/eslint": "^9.6.1",
54
54
  "@types/estree": "^1.0.6",
55
55
  "@types/estree-jsx": "^1.0.5",
56
56
  "@types/node": "^20.2.5",