feat(react-doctor): collapse non-verbose diagnostics to top 3 rules#170
Merged
feat(react-doctor): collapse non-verbose diagnostics to top 3 rules#170
Conversation
When --verbose is not set, only show the 3 most important rule groups (sorted by severity, then by issue count). Collapse the remaining diagnostics into a single summary line and point users at --verbose for full details. Closes the noisy default output when many rules fire — typical scans hide dozens of repeated warnings behind a one-line hint instead of flooding the terminal. Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Move the hidden-diagnostics summary text construction (including pluralization and severity ordering) into a pure utility so it can be unit-tested without crafting a fixture project that triggers more than three rule groups. scan.ts now wraps the returned parts with severity colors and prints them. Adds focused unit tests covering pluralization, single-severity collapse, and mixed-severity ordering. Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
Update the CLI flag description and README so users discover that without --verbose, only the top 3 rule groups are shown and the remainder collapses into a summary line. Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
Drop the locally-redefined buildDiagnostic in build-hidden-diagnostics-summary.test.ts and import the shared one from tests/regressions/_helpers.ts (already used by merge-and-filter-diagnostics.test.ts). Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
This reverts commit e52fd83. Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When
react-doctoris run without--verbose, only print the 3 most important rule groups (sorted by severity, then by issue count). Collapse the remaining rule groups into a single summary line that points users at--verbosefor full details.In
--verbosemode, the output is unchanged — every rule group with its per-file sites is still shown.Before
(All rule groups dumped at once — noisy on real codebases where dozens of rules can fire.)
After
If hidden diagnostics include both severities, both counts are shown side by side, e.g.
✗ 2 more errors ⚠ 64 more warnings.How
MAX_RULE_GROUPS_SHOWN_NON_VERBOSE = 3inconstants.ts.printDiagnosticsslices the sorted rule groups when not verbose and delegates the remainder to a newprintHiddenDiagnosticsSummaryhelper.sortBySeverity→sortByImportanceand added a secondary sort by descending diagnostic count so the 3 visible groups are the most impactful within their severity tier.utils/build-hidden-diagnostics-summary.tsso the pluralization and severity-ordering logic is unit-tested directly (no need to craft a fixture project that triggers 4+ rules).buildDiagnostichelper fromtests/regressions/_helpers.tsrather than redefining it locally.--verboseflag description in both the CLI help text andREADME.mdso users discover the new truncation behavior.Verification
pnpm typecheck— passpnpm lint— 0 warnings, 0 errorspnpm test— 623/623 pass (46 test files; +6 new unit tests for the summary builder)--helpshows the updated flag description and wraps cleanly.