Skip to content

FPFNFIXAPEX catch eager Hook dependencies before initialization - #2251

Draft
aidenybai wants to merge 1 commit into
fix/imported-timer-class-cleanupfrom
fix/eager-hook-dependency-initialization
Draft

aidenybai wants to merge 1 commit into
fix/imported-timer-class-cleanupfrom
fix/eager-hook-dependency-initialization

Conversation

@aidenybai

@aidenybai aidenybai commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Why

A dependency array reads its identifiers while the Hook call is evaluated. For example, useCallback(() => later(), [later]) throws when the same component declares later afterwards, even though the callback itself is deferred.

What changed

  • Add the bounded no-use-before-define rule for direct runtime React imports and same-body const/let dependency reads.
  • Underline the eager identifier and retain both the Hook call and declaration as contextual diff owners.
  • Preserve initialized values, deferred captures, hoisted declarations, type-only providers, and unsupported control flow.
  • Reuse the dependency-Hook set in the existing Valtio rule and add a patch changeset.

Stacked on #2249 to keep this diff to one mechanism. Broader local source sampling is complete; keep this PR draft. Remote parity was waived by request.

Test plan

  • Full uncached suite: 38,728 passed, 1,119 skipped, all 12 tasks successful. A private QA-only Turbo config passes through TMPDIR; other environment filtering remains strict.
  • 64 rule controls, contextual diff coverage, and the rule liveness fixture pass.
  • Strict fuzzing: 500 iterations, seed 42, nonzero rule firing required.
  • Typecheck, lint, format check, all-package build, and JSON-report smoke pass.
  • Lint includes four expected warnings in the two intentionally invalid synthetic fuzz fixtures.

@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@2251
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@2251
npm i https://pkg.pr.new/react-doctor@2251

commit: 6065cae

This branch has not been deployed

No deployments
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.

1 participant