Skip to content

Commit bc24980

Browse files
authored
[eprh] Add back a no-op for removed component-hook-factories rule (#36307)
The `component-hook-factories` rule was removed in #35825 as part of a feature flag cleanup, but was listed in the README as part of the manual config example. This broke users who used a manual config (copied from the old README) in eslint-plugin-react-hooks 7.1.0. This adds back a deprecated no-op rule as a fix. #35825 removed other rules (`automatic-effect-dependencies` and `fire`), but these were for experimental features that did not ship. These were also not referenced in the README.
1 parent da9325b commit bc24980

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/eslint-plugin-react-hooks/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export default [
7474
// React Compiler rules
7575
'react-hooks/config': 'error',
7676
'react-hooks/error-boundaries': 'error',
77-
'react-hooks/component-hook-factories': 'error',
7877
'react-hooks/gating': 'error',
7978
'react-hooks/globals': 'error',
8079
'react-hooks/immutability': 'error',
@@ -108,7 +107,6 @@ export default [
108107
// React Compiler rules
109108
"react-hooks/config": "error",
110109
"react-hooks/error-boundaries": "error",
111-
"react-hooks/component-hook-factories": "error",
112110
"react-hooks/gating": "error",
113111
"react-hooks/globals": "error",
114112
"react-hooks/immutability": "error",

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,29 @@ import {
1515
} from './shared/ReactCompiler';
1616
import RulesOfHooks from './rules/RulesOfHooks';
1717

18+
function makeDeprecatedRule(version: string): Rule.RuleModule {
19+
return {
20+
meta: {
21+
type: 'suggestion',
22+
docs: {
23+
description: `Deprecated: this rule has been removed in ${version}.`,
24+
},
25+
schema: [],
26+
deprecated: true,
27+
},
28+
create() {
29+
return {};
30+
},
31+
};
32+
}
33+
1834
const rules = {
1935
'exhaustive-deps': ExhaustiveDeps,
2036
'rules-of-hooks': RulesOfHooks,
2137
...Object.fromEntries(
2238
Object.entries(allRules).map(([name, config]) => [name, config.rule]),
2339
),
40+
'component-hook-factories': makeDeprecatedRule('7.1.0'),
2441
} satisfies Record<string, Rule.RuleModule>;
2542

2643
const basicRuleConfigs = {

0 commit comments

Comments
 (0)