[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.
This commit is contained in:
mofeiZ
2026-04-17 12:31:24 -04:00
committed by GitHub
parent 0d791a8bd1
commit 2c42a0a127
2 changed files with 17 additions and 2 deletions
@@ -74,7 +74,6 @@ export default [
// React Compiler rules
'react-hooks/config': 'error',
'react-hooks/error-boundaries': 'error',
'react-hooks/component-hook-factories': 'error',
'react-hooks/gating': 'error',
'react-hooks/globals': 'error',
'react-hooks/immutability': 'error',
@@ -108,7 +107,6 @@ export default [
// React Compiler rules
"react-hooks/config": "error",
"react-hooks/error-boundaries": "error",
"react-hooks/component-hook-factories": "error",
"react-hooks/gating": "error",
"react-hooks/globals": "error",
"react-hooks/immutability": "error",
@@ -15,12 +15,29 @@ import {
} from './shared/ReactCompiler';
import RulesOfHooks from './rules/RulesOfHooks';
function makeDeprecatedRule(version: string): Rule.RuleModule {
return {
meta: {
type: 'suggestion',
docs: {
description: `Deprecated: this rule has been removed in ${version}.`,
},
schema: [],
deprecated: true,
},
create() {
return {};
},
};
}
const rules = {
'exhaustive-deps': ExhaustiveDeps,
'rules-of-hooks': RulesOfHooks,
...Object.fromEntries(
Object.entries(allRules).map(([name, config]) => [name, config.rule]),
),
'component-hook-factories': makeDeprecatedRule('7.1.0'),
} satisfies Record<string, Rule.RuleModule>;
const basicRuleConfigs = {