From 44d24045749b750068b8bc0d94b4305e586c18fb Mon Sep 17 00:00:00 2001 From: chirokas <157580465+chirokas@users.noreply.github.com> Date: Wed, 24 Dec 2025 08:16:53 +0000 Subject: [PATCH] [eprh] Check for namespaced useEffectEvent --- .../__tests__/ESLintRulesOfHooks-test.js | 11 +++++++++++ .../src/rules/RulesOfHooks.ts | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js index 3d60a36824d..fc6d80201ed 100644 --- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js +++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js @@ -1755,6 +1755,17 @@ const allTests = { }, errors: [useEffectEventError('onClick', true)], }, + { + code: normalizeIndent` + function MyComponent({ theme }) { + const onClick = React.useEffectEvent(() => { + showNotification(theme); + }); + return ; + } + `, + errors: [useEffectEventError('onClick', false)], + }, { code: normalizeIndent` function MyComponent({ theme }) { diff --git a/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts b/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts index ca82c99e2f5..bba50d29eb1 100644 --- a/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts +++ b/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts @@ -235,7 +235,9 @@ const rule = { parent.init && parent.init.type === 'CallExpression' && parent.init.callee && - isUseEffectEventIdentifier(parent.init.callee) + isUseEffectEventIdentifier( + getNodeWithoutReactNamespace(parent.init.callee), + ) ) { if (reference.resolved === null) { throw new Error('Unexpected null reference.resolved');