Skip to content

feat: carry the React Compiler bail-out reason in the primary diagnostic message#793

Open
devin-ai-integration[bot] wants to merge 7 commits into
mainfrom
devin/1781243831-compiler-reason-in-message
Open

feat: carry the React Compiler bail-out reason in the primary diagnostic message#793
devin-ai-integration[bot] wants to merge 7 commits into
mainfrom
devin/1781243831-compiler-reason-in-message

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Every react-hooks-js/* (React Compiler) diagnostic rendered the same generic primary message ("This component misses React Compiler's automatic memoization…"); the specific bail-out reason lived only in help, so contexts that show just the message gave no clue why the compiler bailed.

parse-output.ts now weaves the compiler's reason summary (first line of the upstream message) into the primary message:

This component misses React Compiler's automatic memoization & re-renders more than it should: useMemo() callbacks may not be async or generator functions. Rewrite the flagged code so the compiler can optimize it.
  • buildReactCompilerMessage(bailoutReason) falls back to the unchanged generic message when the compiler emits no reason, and dedupes a trailing period on the reason summary.
  • help still carries the full reason text plus the Reanimated .get()/.set() hint — unchanged.
  • Tests added to packages/core/tests/append-reanimated-shared-value-hint.test.ts via the existing parseOxlintOutput harness, including an async-useMemo fixture (react-hooks-js(use-memo) with the real upstream reason string).

Link to Devin session: https://app.devin.ai/sessions/641d9fce603f48d380f9d667171b7a02
Requested by: @aidenybai


Note

Low Risk
User-facing diagnostic copy and reporting only; no auth, runtime, or lint rule behavior changes beyond clearer messages and possible slightly higher deduped counts.

Overview
React Compiler (react-hooks-js/*) diagnostics no longer share one generic primary message. parse-output.ts puts the compiler bail-out first line into the main message (via buildReactCompilerMessage), keeps extra reason lines in help without duplicating the summary, strips leading Error:/Warning: labels, and leaves todo rules on the generic wording with internal reasons only in help.

formatRuleSummary lists every distinct per-site message for a rule so on-disk rule summaries do not imply one site's reason applies to all findings.

Tests move oxlint parse fixtures into oxlint-parse-harness, add react-compiler-bailout-message.test.ts and format-rule-summary.test.ts, and extend immutability/Reanimated expectations so the reason summary appears in the message. Patch changeset documents that message-based dedupe can surface slightly higher counts when different bail-out reasons share a location.

Reviewed by Cursor Bugbot for commit 90fce17. Bugbot is set up for automated code reviews on this repo. Configure here.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 90fce17

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

No React Doctor issues found. 🎉

Reviewed by React Doctor for commit 90fce17.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

End-to-end CLI test results

Tested the PR-built CLI against a fixture project with an async useMemo callback (babel-plugin-react-compiler + eslint-plugin-react-hooks installed), compared against published react-doctor@0.5.1 as the before-baseline. Shell-only testing, so evidence is terminal output.

  • Primary message carries the specific bail-out reason — passed
  • No leaked Error: severity prefix in message or help — passed (caught during testing; fixed in 2nd commit)
  • Generic fallback preserved when compiler emits no reason — passed (unit test)
  • Regression baseline (react-doctor@0.5.1): generic-only message, reason only in help with Error: prefix — confirmed
🟢 After (this PR)
✖ Performance: React Compiler can't optimize this
  This component misses React Compiler's automatic
  memoization & re-renders more than it should: useMemo()
  callbacks may not be async or generator functions. Rewrite
  the flagged code so the compiler can optimize it.
  → useMemo() callbacks may not be async or generator
  functions
🔴 Before (react-doctor@0.5.1)
✖ Performance: React Compiler can't optimize this
  This component misses React Compiler's automatic
  memoization & re-renders more than it should. Rewrite the
  flagged code so the compiler can optimize it.
  → Error: useMemo() callbacks may not be async or generator
  functions
Fixture
export const App = () => {
  const data = useMemo(async () => fetchData(), []);
  return <div>{String(data)}</div>;
};

CI: 19/19 green. Devin session

devin-ai-integration Bot and others added 4 commits June 12, 2026 07:19
…c message

Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1781243831-compiler-reason-in-message branch from 4e51106 to 0e81642 Compare June 12, 2026 07:21
devin-ai-integration Bot and others added 3 commits June 12, 2026 07:24
Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
The reason's first line moves into the primary message and only the
remaining elaboration stays in help, so renderers that print both never
repeat the same sentence back-to-back. `todo` diagnostics keep the
generic message — their reasons are compiler-internal work notes, not
user-facing copy. Also trims before stripping the leading severity
label, and moves the bail-out message tests into their own file with a
shared oxlint parse harness.
Per-site messages (React Compiler bail-out reasons) vary within one
rule, so the on-disk rule summary no longer presents the first site's
reason as if it described all N sites. Also documents in the changeset
that distinct same-site reasons now survive dedup as separate
diagnostics.
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