feat: add --show-errors flag to show detailed compiler errors#41
feat: add --show-errors flag to show detailed compiler errors#41frankieyan merged 7 commits intomainfrom
Conversation
Moves CLI argument parsing logic into src/args.mts with unit tests. Prepares for adding new flags without complicating index.mts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds a --show-errors flag that works with --check-files to display exact violation reasons and line numbers instead of just counts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The --show-errors flag was parsed but only used with --check-files. Now it works with all commands: default check-all, --overwrite, and --stage-record-file. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Group tests into describe blocks by flag category for better readability: - no flag (default check-all) - --check-files - --overwrite - --stage-record-file Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| } else if (event.kind === 'CompileSkip') { | ||
| reason = event.reason | ||
| } else { | ||
| reason = String(event.data) |
There was a problem hiding this comment.
[P3] String(event.data) may result in [object Object] if PipelineError carries an object payload. Consider checking if event.data is an Error instance to use its .message, or using JSON.stringify for generic objects, to ensure the detailed error message is actionable.
|
I did not get to this on time. Please re-roll the dice. |
|
💭 (Out of my curiosity/for my own understanding) @frankieyan Do you plan to use this flag in |
💭 (Not related to this PR specifically, but I'll note it regardless) It seems to me that, for this specific file, it'd make more sense (ideally) to output the "Cannot access refs during render" error only once (+1) instead of 3 times (since it's the same error, on the same line number, etc.), right? |
|
💭 I think the code and the unit tests provide enough "self-documentation", so very option to add the |
IMO by default (for our pre-commit and CI hooks), we don't need to show the exact errors, but this would be helpful for LLMs when planning what to fix. Despite having the records file and being able to run Babel to extract the exact errors, I found that it goes off on fixes that don't actually target the violations. I'll update this section of the docs to reference this flag and hopefully we'll have better results.
That was bugging me a bit too, but wasn't enough for me to fix it. I'll throw this at my robot helper now that we have real user (i.e. you) feedback about this 😁 Thank you for the reminder about the readme too. Slipped my mind but I'll add it now 🙌 |
Consolidate duplicate errors by line and reason, displaying a count suffix (e.g., "x3") instead of repeating the same error multiple times. Extract formatErrorDetails() helper to reduce code duplication. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
All callers pass this parameter explicitly, so making it required improves type consistency. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When React Compiler errors increase, the current output only shows counts like
src/bad-hook.ts: +3. This makes it hard to know what actually broke. The new--show-errorsflag displays the exact violation messages and line numbers:Test plan
Test locally by running against the sample project fixtures:
npm run build cd src/__fixtures__/sample-projectWithout
--show-errors(baseline behavior) — shows only error countsWith
--show-errors— includes detailed error messagesMultiple files — shows errors from all files
Files with no errors — no detailed errors section shown
Flag position flexibility —
--show-errorsworks anywhere in the commandSimilarly,
--show-errorscan be used together with other flags like--overwrite,--stage-record-file, or when no mode flag is set