Skip to content

Commit b4946cd

Browse files
committed
[eprh] Check for namespaced useEffectEvent
1 parent e33071c commit b4946cd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,17 @@ const allTests = {
17551755
},
17561756
errors: [useEffectEventError('onClick', true)],
17571757
},
1758+
{
1759+
code: normalizeIndent`
1760+
function MyComponent({ theme }) {
1761+
const onClick = React.useEffectEvent(() => {
1762+
showNotification(theme);
1763+
});
1764+
return <Child onClick={onClick}></Child>;
1765+
}
1766+
`,
1767+
errors: [useEffectEventError('onClick', false)],
1768+
},
17581769
{
17591770
code: normalizeIndent`
17601771
function MyComponent({ theme }) {

packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ const rule = {
235235
parent.init &&
236236
parent.init.type === 'CallExpression' &&
237237
parent.init.callee &&
238-
isUseEffectEventIdentifier(parent.init.callee)
238+
isUseEffectEventIdentifier(
239+
getNodeWithoutReactNamespace(parent.init.callee),
240+
)
239241
) {
240242
if (reference.resolved === null) {
241243
throw new Error('Unexpected null reference.resolved');

0 commit comments

Comments
 (0)