Repository navigation
fix(codemod): report retained hooks before component output - #2654
domgan-oai merged 5 commits into
Conversation
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 141 measured values. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit 8c9c37f. Configure here.
…demod-retained-hooks-local-output

Summary
Extend the retained React hook check from #2462 to native setup that returns another component or a fragment, and to calls after ordinary state setup. An unchanged local hook still executes under the enclosing renderer before the returned child runs.
In production, a small React caller rendered its label normally. The same caller compiled as clean Strong and then threw in the unchanged React
useStateunder Octane SSR. The error now names the retained import. The existing path for generating a native external-store hook is unchanged for executable declarations.Validation
pnpm format:checkpnpm typecheckpnpm testpnpm sync, andgit diff --check.Risk / follow-ups
The diagnostic covers reachable setup. Earlier state initialization can still fail for particular inputs, and arbitrary control flow or lazy initializers remain outside the new check. The exact 7,902-file recipe-free replay on the signed revision, including the review fixes for named wrappers and co-declared state, reported 1,323 clean Strong files (16.74%), down from 1,361. The new errors identify retained React calls in 38 previously clean rows. Compiler Strong and Compat totals are unchanged.
Provenance
agent-authored)Codex task · host
com-79386Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Migration-only diagnostic tightening in the codemod; no runtime compiler changes, though more files may fail Strong verification.
Overview
Extends the retained local hook diagnostic so codemod flags unchanged hooks (e.g.
useLabelstill calling ReactuseState) when they run in component setup before the return value is a child component, fragment, or intrinsic—not only when setup ends with a lowercase native element and literal/useRefprefixes.nativeSetupHooknow treats prior ordinaryuseStatedeclarations (safe literals, props, etc.) as valid setup, recognizes memo/forwardRef callers, and applies a separate diagnostic path whenoriginalReactis enabled.transform.tspassesoriginalReact()into that checker; a changeset records a patch bump for@octanejs/codemod.Adds a parameterized project test suite (21+ TSX shapes) asserting the expected error on safe callers and no erroneous rewrites.
Reviewed by Cursor Bugbot for commit fc54dde. Bugbot is set up for automated code reviews on this repo. Configure here.