Skip to content

Commit d95c939

Browse files
feat(cli): expose --why as documented public alias for --explain (#161) (#198)
The MVP requested by #161 — a single-site suppression diagnosis at `react-doctor --why <file:line>` — was already implemented as a hidden alias for `--explain`. Promote it to a documented option so users can reach it without reading the source. Updates the README's CLI reference and suppressions section to make the discovery story explicit: - `--explain <file:line>` (and its `--why` alias) classify what the scanner sees at a single location, matching every status in the issue's classifier table (MISSING, WRONG_RULE, GAP_CODE, etc.). - `--verbose` mode already surfaces the same suppression hint inline next to every flagged site, and `--json` mode includes it on each diagnostic as `suppressionHint`. A single scan therefore doubles as a suppression audit without a separate flag, which covers the "Bonus" and most of the "Maximum" goals from the request. Removes the unused `Option` import that the previous `addOption(...).hideHelp()` wiring left behind. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
1 parent 7db0805 commit d95c939

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/react-doctor/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ Options:
151151
--fail-on <level> exit with error on diagnostics: error, warning, none
152152
--annotations output diagnostics as GitHub Actions annotations
153153
--explain <file:line> diagnose why a rule fired or why a suppression didn't apply
154+
--why <file:line> alias for --explain
154155
-h, --help display help
155156
```
156157
157-
When a suppression isn't working, `--explain <file:line>` reports what the scanner sees at that location, including why a nearby `react-doctor-disable-next-line` didn't apply. The same hint surfaces inline with `--verbose` and in `--json` output as `diagnostic.suppressionHint`.
158+
When a suppression isn't working, `--explain <file:line>` (or its alias `--why <file:line>`) reports what the scanner sees at that location, including why a nearby `react-doctor-disable-next-line` didn't apply. The diagnosis distinguishes the common failure modes — adjacent comment for a different rule (use the comma form), a code line between the comment and the diagnostic (the chain is broken), or no nearby suppression at all. The same hint surfaces inline with `--verbose` for every flagged site, and in `--json` output as `diagnostic.suppressionHint`, so a single scan doubles as a suppression audit without a separate flag.
158159
159160
`--json` produces a parsable object on stdout with all human-readable output suppressed. Errors still produce a JSON object with `ok: false`, so stdout is always a valid document.
160161

packages/react-doctor/src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { mkdtempSync } from "node:fs";
22
import { tmpdir } from "node:os";
33
import path from "node:path";
44
import { performance } from "node:perf_hooks";
5-
import { Command, Option } from "commander";
5+
import { Command } from "commander";
66
import { CANONICAL_GITHUB_URL } from "./constants.js";
77
import { runInstallSkill } from "./install-skill.js";
88
import { scan } from "./scan.js";
@@ -400,7 +400,7 @@ const program = new Command()
400400
"--explain <file:line>",
401401
"diagnose why a rule fired or why a suppression didn't apply at a specific location",
402402
)
403-
.addOption(new Option("--why <file:line>", "alias for --explain").hideHelp())
403+
.option("--why <file:line>", "alias for --explain")
404404
.option(
405405
"--respect-inline-disables",
406406
"respect inline `// eslint-disable*` / `// oxlint-disable*` comments (default)",

0 commit comments

Comments
 (0)