Skip to content

fix(react-doctor): restore React Compiler rules to error severity#182

Merged
aidenybai merged 1 commit into
mainfrom
cursor/restore-react-compiler-error-severity-7dfc
May 9, 2026
Merged

fix(react-doctor): restore React Compiler rules to error severity#182
aidenybai merged 1 commit into
mainfrom
cursor/restore-react-compiler-error-severity-7dfc

Conversation

@aidenybai
Copy link
Copy Markdown
Member

Summary

"React Compiler can't optimize this code" diagnostics are no longer triggering as errors — they were silently downgraded to warnings in PR #140 ("Address review-report.md findings + self-review regressions"). Restored to "error" so they fail CI again.

Investigation

git log -S '"react-hooks-js/set-state-in-render": "warn"' on packages/react-doctor/src/oxlint-config.ts points at exactly one commit:

03a9435 Address review-report.md findings + self-review regressions (#140)

That commit's diff on oxlint-config.ts mass-converted the entire REACT_COMPILER_RULES map from "error" to "warn" (16 entries), as part of a broader 88-file refactor. The PR description doesn't justify the severity change for these specific rules — it only mentions rule severity types tightened to RuleSeverity (a TypeScript typing change). Other rule sets that had been "error" (e.g. react/rules-of-hooks, react-doctor/no-mutable-in-deps) were preserved at error in the same commit; only REACT_COMPILER_RULES was uniformly downgraded.

Effects of the regression

Reproduced with a minimal fixture (useState + in-place push + setN(n + 1) at render time, with babel-plugin-react-compiler listed as a dep so detection fires):

Before this PR:

summary: { errorCount: 0, warningCount: 6, ... }
warning set-state-in-render React Compiler can't optimize this code
warning todo            React Compiler can't optimize this code

After this PR:

summary: { errorCount: 2, warningCount: 4, ... }
error set-state-in-render React Compiler can't optimize this code
error todo            React Compiler can't optimize this code

So the user-visible regression triggered by PR #140 was:

  • The CLI rendered React Compiler diagnostics with (warning) instead of (error).
  • errorCount in the JSON summary stopped counting them.
  • The GitHub Action defaults to fail-on: error (action.yml); compiler-blocked code stopped failing CI.

Fix

packages/react-doctor/src/oxlint-config.ts — every react-hooks-js/* entry in REACT_COMPILER_RULES set back to "error", with a HACK comment explaining why so a future refactor doesn't accidentally undo it. Each compiler diagnostic represents a code shape that prevents memoization of the surrounding component, so the previous "if the compiler can't handle it, fail CI" contract is correct.

Regression test

packages/react-doctor/tests/regressions/scan-resilience.test.ts — new assertion that every react-hooks-js/* rule emitted by createOxlintConfig is at error severity. A future mass-rewrite that downgrades them again will fail this test.

Validation

  • pnpm typecheck — passes
  • pnpm test — 673/673 pass (added 1 regression)
  • pnpm lint — 0 warnings, 0 errors
  • pnpm format:check — clean
  • Manual CLI reproduction on a fixture with React Compiler detected confirms errorCount: 2 (was 0).
Open in Web Open in Cursor 

PR #140 silently downgraded every `react-hooks-js/*` (React Compiler)
rule from `"error"` to `"warn"` as part of a broader review pass,
without justifying the severity change in the PR description. This
made "React Compiler can't optimize this code" diagnostics:

- show with the warning glyph instead of the error glyph in the CLI,
- stop counting toward `errorCount` in the JSON summary, and
- stop tripping the GitHub Action's default `--fail-on error`, so
  unoptimizable component shapes silently slipped through CI.

Each compiler diagnostic represents code the React Compiler cannot
memoize — leaving the surrounding component un-optimized at runtime.
Restore them to `"error"` so the original "if the compiler can't
handle it, fail CI" contract works again.

A regression test in `scan-resilience.test.ts` asserts that every
`react-hooks-js/*` rule emitted by `createOxlintConfig` is at
`error` severity, so a future mass-rewrite can't silently undo this.

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-doctor-website Ready Ready Preview, Comment May 8, 2026 11:55pm

@aidenybai aidenybai marked this pull request as ready for review May 9, 2026 02:49
@aidenybai aidenybai merged commit cfa2380 into main May 9, 2026
5 of 6 checks passed
@aidenybai aidenybai deleted the cursor/restore-react-compiler-error-severity-7dfc branch May 9, 2026 02:50
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.

2 participants