Skip to content

fix: detect namespace hook calls (React.useEffect, React.useState)#118

Open
Akshay090 wants to merge 2 commits intomillionco:mainfrom
Akshay090:fix/namespace-hook-calls
Open

fix: detect namespace hook calls (React.useEffect, React.useState)#118
Akshay090 wants to merge 2 commits intomillionco:mainfrom
Akshay090:fix/namespace-hook-calls

Conversation

@Akshay090
Copy link
Copy Markdown
Contributor

@Akshay090 Akshay090 commented Apr 6, 2026

Summary

Fixes #117

  • isHookCall only checked Identifier callee nodes, silently missing MemberExpression calls like React.useEffect(...) and React.useState(...)
  • Added getCalleeName helper that extracts function names from both Identifier and MemberExpression nodes
  • Updated all setter detection sites (countSetStateCalls, noDerivedStateEffect, rerenderFunctionalSetstate, renderingHydrationNoFlicker) to use the same pattern

Test plan

  • pnpm build — passes (3 entry points built successfully)
  • Unit tests for getCalleeName — 5/5 passing (Identifier, MemberExpression, null, unsupported types)
  • Unit tests for isHookCall — 7/7 passing (direct calls, namespace calls, string vs Set hookName, non-CallExpression rejection)
  • Unit tests for countSetStateCalls — 3/3 passing (direct setters, namespace setters, non-setter calls)
  • npx react-doctor . --verbose on namespace imports (import * as React) — no-derived-state-effect, no-fetch-in-effect, no-cascading-set-state all fire on React.useEffect/React.useState calls
  • npx react-doctor . --verbose on named imports (import { useEffect }) — same rules fire, existing behavior unchanged

🤖 Generated with Claude Code

Fixes millionco#117. isHookCall only checked for Identifier callee nodes, missing
MemberExpression calls (React.useEffect, React.useState, etc.). Added
getCalleeName helper that extracts function names from both patterns and
updated all setter detection sites across helpers, state-and-effects,
and performance rules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

@Akshay090 is attempting to deploy a commit to the Million Team on Vercel.

A member of the Team first needs to authorize it.

…Calls

Tests cover both Identifier (useEffect) and MemberExpression
(React.useEffect) patterns to validate namespace hook call detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isHookCall doesn't detect namespace hook calls (React.useState, React.useEffect, etc.)

1 participant