Skip to content

[eslint-plugin-react-hooks] Check for namespaced useEffectEvent#614

Open
everettbu wants to merge 1 commit into
mainfrom
eprh/check-for-namespaced-useeffectevent
Open

[eslint-plugin-react-hooks] Check for namespaced useEffectEvent#614
everettbu wants to merge 1 commit into
mainfrom
eprh/check-for-namespaced-useeffectevent

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35901
Original author: chirokas


Summary

Previously, we only checked for useEffectEvent but we should also check for the namespaced version, React.useEffectEvent.

How did you test this change?

Added unit test.

@greptile-apps

greptile-apps Bot commented Feb 25, 2026

Copy link
Copy Markdown

Greptile Summary

Fixes a bug where React.useEffectEvent (the namespaced form) was not recognized inside recordAllUseEffectEventFunctions. This meant that variables assigned from React.useEffectEvent(...) weren't tracked, so passing them as props or calling them outside effects would silently pass the lint rule. The fix wraps the callee with getNodeWithoutReactNamespace() — the same pattern already used at the other two call sites of isUseEffectEventIdentifier.

  • Bug fix in RulesOfHooks.ts: Added getNodeWithoutReactNamespace() around parent.init.callee in recordAllUseEffectEventFunctions so that React.useEffectEvent is treated identically to useEffectEvent
  • New test case: Added an invalid test for React.useEffectEvent assigned to a variable and passed as a prop, verifying the correct error is reported

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, well-scoped bug fix with a corresponding test.
  • The change is a one-line fix applying an existing utility function (getNodeWithoutReactNamespace) to the only remaining call site that was missing it. All three usages of isUseEffectEventIdentifier now consistently handle the namespaced form. The test covers the exact scenario. No new patterns or risks introduced.
  • No files require special attention.

Important Files Changed

Filename Overview
packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts Wraps the callee in getNodeWithoutReactNamespace() before passing to isUseEffectEventIdentifier() in recordAllUseEffectEventFunctions, fixing the last call site that didn't handle the React.useEffectEvent namespace.
packages/eslint-plugin-react-hooks/tests/ESLintRulesOfHooks-test.js Adds an invalid test case for React.useEffectEvent ensuring the namespaced form is properly detected and flagged when passed as a prop.

Last reviewed commit: 2c89e5e

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@everettbu
everettbu force-pushed the eprh/check-for-namespaced-useeffectevent branch from b4946cd to 2c89e5e Compare February 27, 2026 01:48
@everettbu everettbu changed the title [eprh] Check for namespaced useEffectEvent [eslint-plugin-react-hooks] Check for namespaced useEffectEvent Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants