Skip to content

feat(cli): align CLI with clig.dev and 12-factor guidelines#623

Merged
rayhanadev merged 7 commits into
mainfrom
ray/6cd0689c
Jun 1, 2026
Merged

feat(cli): align CLI with clig.dev and 12-factor guidelines#623
rayhanadev merged 7 commits into
mainfrom
ray/6cd0689c

Conversation

@rayhanadev
Copy link
Copy Markdown
Member

@rayhanadev rayhanadev commented Jun 1, 2026

Why

Bring the react-doctor CLI in line with the clig.dev and 12-factor CLI Apps guidelines. Three concrete gaps:

  1. help was brokenreact-doctor help tried to scan a directory named help and errored.
  2. No color control — picocolors auto-detected NO_COLOR/TTY, but there was no --color/--no-color override or app-specific env toggle.
  3. Thin version surface + example-less help — only terse -v/--version; no version subcommand, no -V, and --help had zero examples (clig.dev's top Help guideline is "lead with examples").

Before:

$ react-doctor help
Something went wrong…
No React project found in /…/help. Expected a package.json…

$ react-doctor --no-color    # silently stripped, no effect
$ react-doctor version       # tried to scan ./version

After:

$ react-doctor help                 # root help
$ react-doctor help install         # install help
$ react-doctor --no-color           # disables color across all output
$ react-doctor version
react-doctor/0.2.14 darwin-arm64 node-v24.14.0
$ react-doctor -V
0.2.14

What changed

  • Color control--color / --no-color flags plus app-specific REACT_DOCTOR_NO_COLOR / REACT_DOCTOR_FORCE_COLOR env vars, resolved before Commander parses so the choice reaches every surface (scan report, branded header, score, prompts, errors). Flags win over env vars, which win over picocolors' built-in NO_COLOR/FORCE_COLOR/TERM/TTY detection. Backed by a new @react-doctor/core setColorEnabled() toggle.
  • Examples-led help — root and install --help now open with aligned Examples: blocks and a "Feedback & bug reports" link (rendered lazily so they honor the color preference).
  • version subcommand + -Vreact-doctor version prints version + Node + platform for debugging; -v / -V / --version stay terse for scripts.
  • help / help <command> — normalized in the bootstrap to the existing --help paths instead of being swallowed by the default scan action.
  • Allowed the new flags through the pre-parse flag stripper and consolidated the shared NODE_ARGUMENT_COUNT argv constant into constants.ts.

Eval results

Not applicable — this is a CLI/UX change, not a lint rule, so the RDE rule-eval harness was not run.

Test plan

  • react-doctor suite green — pnpm --filter react-doctor exec vp test run tests/ (1453 passed)
  • New unit tests pass (22): apply-color-preference, normalize-help-command, version-command, extended strip-unknown-cli-flags
  • pnpm --filter react-doctor typecheck
  • pnpm exec vp lint (changed files) + pnpm exec vp fmt --check
  • pnpm smoke:json-report
  • Manual smoke: help, help install, version, -v/-V/--version, --color/--no-color (ANSI on/off verified when piped), REACT_DOCTOR_FORCE_COLOR=1

Pre-existing failures on the merged base — core/check-expo-project (environment-specific: a global ~/.config/git/ignore that lists .env.local) and oxlint-plugin-react-doctor/no-multi-comp — are in files untouched by this PR and unrelated to it.

Made with Cursor


Note

Low Risk
Changes are limited to CLI bootstrap, help text, and output coloring; telemetry opt-out extends existing --no-score behavior without altering scan logic.

Overview
Aligns the react-doctor CLI with clig.dev / 12-factor UX: explicit color control, fixed help routing, richer version output, and clearer opt-out wording for score/telemetry.

Color — Adds --color / --no-color on the default scan, install, and version flows, plus REACT_DOCTOR_FORCE_COLOR / REACT_DOCTOR_NO_COLOR. Preference is resolved from stripped argv before Commander runs (so help epilogs respect it), updates the shared highlighter via new setColorEnabled() in @react-doctor/core, and mirrors the choice onto FORCE_COLOR / NO_COLOR for spinners and prompts. Last flag wins; tokens after -- are ignored.

Help — Rewrites leading help / help <command> to --help / <command> --help so users no longer scan a directory named help. Root and install help now lead with example commands (lazy epilog renderers) and add a feedback/issues link.

Version — New react-doctor version prints react-doctor/<ver> <platform>-<arch> node-<node>; standalone -V prints the bare version before parse (alongside existing -v / --version).

Telemetry alias--no-telemetry aliases --no-score (score API, share URL, Sentry); inspect resolution and early Sentry init honor it; --score + --no-telemetry is rejected. Flag stripper knows the new flags and version subcommand spec.

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

rayhanadev and others added 2 commits May 31, 2026 23:11
- add `--color` / `--no-color` plus `REACT_DOCTOR_NO_COLOR` /
  `REACT_DOCTOR_FORCE_COLOR` env overrides, resolved before parse so the
  choice reaches all output
- lead `--help` (root + install) with worked examples and a feedback link
- add a `version` subcommand (version + node + platform) and a `-V` alias
- make `help` / `help <command>` show help instead of scanning a
  directory named "help"

Co-authored-by: Cursor <cursoragent@cursor.com>
… help)

Co-authored-by: Cursor <cursoragent@cursor.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 1, 2026

Open in StackBlitz

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

commit: a931264

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

React Doctor

React Doctor found 18 files changed in this pull request, but none matched the files covered by its enabled checks.

Scope: 18 files changed on ray/6cd0689c vs. main.

View workflow run

Generated by React Doctor. Questions? Contact founders@million.dev.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Address review findings:
- resolve `--color`/`--no-color` from the stripped argv before help
  normalization drops trailing tokens, so `react-doctor help --no-color`
  is respected
- register a `version` flag spec and add `--color`/`--no-color` options to
  the `version` command so `react-doctor version --no-color` no longer
  aborts with an unknown-option error

Co-authored-by: Cursor <cursoragent@cursor.com>
cursor[bot]

This comment was marked as resolved.

Address a second review round:
- `-V` no longer misfires when passed as an option value (e.g.
  `--cwd -V`); a standalone `-V` is the only form `stripUnknownCliFlags`
  drops, so "in raw argv but stripped out" distinguishes flag from value
- `help <flag> <command>` now resolves the subcommand past intervening
  flags (first non-flag token after `help`)
- mirror the resolved color choice onto `NO_COLOR` / `FORCE_COLOR` so the
  `ora` spinner and `prompts` honor `--no-color` / `--color` too, not just
  the picocolors-based report highlighter

Co-authored-by: Cursor <cursoragent@cursor.com>
cursor[bot]

This comment was marked as resolved.

rayhanadev and others added 2 commits June 1, 2026 00:06
`--no-score` already disables the score API, the share URL, and (since
crash reporting landed) Sentry, so expose that opt-out under the clearer
`--no-telemetry` name. Both resolve to `noScore` and gate crash reporting
off via the raw-argv check in instrument.ts.

Co-authored-by: Cursor <cursoragent@cursor.com>
The previous commit accidentally overwrote the existing CI-behavior
(#302) and warnings/--fail-on tests while adding the --no-telemetry
case. Restore them alongside the new alias test.

Co-authored-by: Cursor <cursoragent@cursor.com>
cursor[bot]

This comment was marked as resolved.

`--score` (score-only output) combined with `--no-telemetry` (skip
scoring) previously printed a confusing "Score disabled" line in
score-only mode. Validate it up front with a clear error, matching the
existing mutual-exclusion checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@rayhanadev
Copy link
Copy Markdown
Member Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit a931264. Configure here.

@rayhanadev rayhanadev merged commit b9e9bcb into main Jun 1, 2026
19 of 20 checks passed
@rayhanadev rayhanadev deleted the ray/6cd0689c branch June 1, 2026 08:46
@github-actions github-actions Bot mentioned this pull request Jun 1, 2026
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