react-doctor 0.2.15-dev.520b0a9 → 0.2.15-dev.8162bfb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +8 -5
  2. package/dist/cli.js +283 -287
  3. package/dist/index.js +176 -133
  4. package/package.json +4 -4
package/README.md CHANGED
@@ -96,14 +96,17 @@ Prefer JSON? Use `doctor.config.json`:
96
96
 
97
97
  ## Telemetry
98
98
 
99
- The CLI reports crashes, basic run traces, and anonymous usage counters to [Sentry](https://sentry.io) to help us fix bugs and prioritize what to build. Events and metrics include the version, platform, Node version, how the CLI was invoked (which command, package manager, and whether it ran locally vs. CI vs. a coding agent), the detected project shape (framework, React version, TypeScript, project size — never the contents of your files), which rules fired (rule names only, e.g. `react-doctor/no-array-index-as-key`, with counts — never your code or specific findings), and de-minified stack traces.
99
+ The CLI reports crashes, basic run traces, and anonymous usage counters to [Sentry](https://sentry.io/) to help us fix bugs and prioritize work.
100
100
 
101
- Telemetry is **anonymized** before it leaves your machine: no IP address is collected, your hostname and machine name are stripped, your OS username is removed from every path (your home directory is replaced with `~`), captured local variables are dropped, and known secrets/API keys/emails are masked. No source code or diagnostic findings are sent.
101
+ We collect:
102
102
 
103
- Opt out at any time:
103
+ - Environment: CLI version, platform, Node version
104
+ - Invocation: which command, package manager, and run context (whether it's local vs. CI vs. coding agent)
105
+ - Project shape: framework, React version, TypeScript, project size NO file contents)
106
+ - Rules fired: rule names and counts only (e.g. `react-doctor/no-array-index-as-key`) (NO code or specific findings)
107
+ - De-minified React Doctor CLI stack traces
104
108
 
105
- - `npx react-doctor@latest --no-telemetry` disables Sentry entirely (crash reporting, tracing, and usage counters) for that run, alongside the hosted score API.
106
- - `SENTRY_TRACES_SAMPLE_RATE=0` keeps crash reporting and usage counters but turns off performance tracing.
109
+ To opt out, run: `npx react-doctor@latest --no-telemetry`
107
110
 
108
111
  ## Contributing
109
112
 
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c8bf2d99-8f0b-55f1-a894-63e600bf000b")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e5345c0f-0e42-5045-8127-8f9f7a251f64")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import { execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import * as Path from "node:path";
@@ -7338,27 +7338,30 @@ var OxlintSpawnTimeoutMs = class extends Context.Reference("react-doctor/OxlintS
7338
7338
  var OxlintOutputMaxBytes = class extends Context.Reference("react-doctor/OxlintOutputMaxBytes", { defaultValue: () => OXLINT_OUTPUT_MAX_BYTES }) {};
7339
7339
  /**
7340
7340
  * Number of oxlint subprocesses the lint pass runs in parallel. Defaults
7341
- * to `1` (serial — the historical behavior) so resource usage is opt-in.
7342
- * The CLI's `--experimental-parallel` flag overrides this via `Layer.succeed`; the
7343
- * `REACT_DOCTOR_PARALLEL` env var seeds the default for programmatic /
7344
- * CI callers that never touch the flag:
7341
+ * to auto-detected CPU cores (parallel) so large repos scan fast out of
7342
+ * the box; `spawnLintBatches` transparently falls back to a single worker
7343
+ * if a parallel run exhausts system resources. The CLI's `--no-parallel`
7344
+ * flag forces serial via `Layer.succeed`; the `REACT_DOCTOR_PARALLEL` env
7345
+ * var seeds the default for programmatic / CI callers that never touch the
7346
+ * flag — parallelism is opt-OUT, so only the explicit serial values pin
7347
+ * one worker:
7345
7348
  *
7346
- * - unset / `0` / `false` / `off` → `1` (serial)
7347
- * - `auto` / `true` / `on` → available CPU cores (clamped)
7348
- * - a positive integer → that many workers (clamped)
7349
+ * - unset / `auto` / `true` / `on` → available CPU cores (clamped)
7350
+ * - `0` / `false` / `off` → `1` (serial)
7351
+ * - a positive integer → that many workers (clamped)
7352
+ * - any other value → available CPU cores (clamped)
7349
7353
  *
7350
7354
  * The resolved value is always within
7351
7355
  * `[MIN_SCAN_CONCURRENCY, MAX_SCAN_CONCURRENCY]`.
7352
7356
  */
7353
7357
  var OxlintConcurrency = class extends Context.Reference("react-doctor/OxlintConcurrency", { defaultValue: () => {
7354
7358
  const raw = process.env["REACT_DOCTOR_PARALLEL"];
7355
- if (raw === void 0) return 1;
7359
+ if (raw === void 0) return resolveScanConcurrency("auto");
7356
7360
  const normalized = raw.trim().toLowerCase();
7357
- if (normalized === "" || normalized === "0" || normalized === "false" || normalized === "off") return 1;
7358
- if (normalized === "auto" || normalized === "true" || normalized === "on") return resolveScanConcurrency("auto");
7361
+ if (normalized === "0" || normalized === "false" || normalized === "off") return 1;
7359
7362
  const parsed = Number.parseInt(normalized, 10);
7360
- if (!Number.isInteger(parsed) || parsed <= 0) return 1;
7361
- return resolveScanConcurrency(parsed);
7363
+ if (Number.isInteger(parsed) && parsed > 0) return resolveScanConcurrency(parsed);
7364
+ return resolveScanConcurrency("auto");
7362
7365
  } }) {};
7363
7366
  const DIAGNOSTIC_SURFACES = [
7364
7367
  "cli",
@@ -8359,6 +8362,100 @@ const checkReducedMotion = (rootDirectory) => {
8359
8362
  if (result.status === 0) return [];
8360
8363
  return [MISSING_REDUCED_MOTION_DIAGNOSTIC];
8361
8364
  };
8365
+ var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
8366
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
8367
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
8368
+ let formatter = (open, close, replace = open) => (input) => {
8369
+ let string = "" + input, index = string.indexOf(close, open.length);
8370
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
8371
+ };
8372
+ let replaceClose = (string, close, replace, index) => {
8373
+ let result = "", cursor = 0;
8374
+ do {
8375
+ result += string.substring(cursor, index) + replace;
8376
+ cursor = index + close.length;
8377
+ index = string.indexOf(close, cursor);
8378
+ } while (~index);
8379
+ return result + string.substring(cursor);
8380
+ };
8381
+ let createColors = (enabled = isColorSupported) => {
8382
+ let f = enabled ? formatter : () => String;
8383
+ return {
8384
+ isColorSupported: enabled,
8385
+ reset: f("\x1B[0m", "\x1B[0m"),
8386
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
8387
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
8388
+ italic: f("\x1B[3m", "\x1B[23m"),
8389
+ underline: f("\x1B[4m", "\x1B[24m"),
8390
+ inverse: f("\x1B[7m", "\x1B[27m"),
8391
+ hidden: f("\x1B[8m", "\x1B[28m"),
8392
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
8393
+ black: f("\x1B[30m", "\x1B[39m"),
8394
+ red: f("\x1B[31m", "\x1B[39m"),
8395
+ green: f("\x1B[32m", "\x1B[39m"),
8396
+ yellow: f("\x1B[33m", "\x1B[39m"),
8397
+ blue: f("\x1B[34m", "\x1B[39m"),
8398
+ magenta: f("\x1B[35m", "\x1B[39m"),
8399
+ cyan: f("\x1B[36m", "\x1B[39m"),
8400
+ white: f("\x1B[37m", "\x1B[39m"),
8401
+ gray: f("\x1B[90m", "\x1B[39m"),
8402
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
8403
+ bgRed: f("\x1B[41m", "\x1B[49m"),
8404
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
8405
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
8406
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
8407
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
8408
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
8409
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
8410
+ blackBright: f("\x1B[90m", "\x1B[39m"),
8411
+ redBright: f("\x1B[91m", "\x1B[39m"),
8412
+ greenBright: f("\x1B[92m", "\x1B[39m"),
8413
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
8414
+ blueBright: f("\x1B[94m", "\x1B[39m"),
8415
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
8416
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
8417
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
8418
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
8419
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
8420
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
8421
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
8422
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
8423
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
8424
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
8425
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
8426
+ };
8427
+ };
8428
+ module.exports = createColors();
8429
+ module.exports.createColors = createColors;
8430
+ })))(), 1);
8431
+ const highlighter = {
8432
+ error: import_picocolors.default.red,
8433
+ warn: import_picocolors.default.yellow,
8434
+ info: import_picocolors.default.cyan,
8435
+ success: import_picocolors.default.green,
8436
+ dim: import_picocolors.default.dim,
8437
+ gray: import_picocolors.default.gray,
8438
+ bold: import_picocolors.default.bold
8439
+ };
8440
+ /**
8441
+ * Override picocolors' automatic color detection. picocolors decides
8442
+ * once, at import time, from `NO_COLOR` / `FORCE_COLOR` / `TERM` / TTY.
8443
+ * This lets the CLI honor an explicit `--color` / `--no-color` flag
8444
+ * (clig.dev, Output: "Disable color … if the user requested it") by
8445
+ * swapping in a fresh set of formatters. Call it before any colored
8446
+ * output is produced. Every call site reads `highlighter.<method>` at
8447
+ * call time, so reassigning the properties propagates everywhere.
8448
+ */
8449
+ const setColorEnabled = (enabled) => {
8450
+ const colors = import_picocolors.default.createColors(enabled);
8451
+ highlighter.error = colors.red;
8452
+ highlighter.warn = colors.yellow;
8453
+ highlighter.info = colors.cyan;
8454
+ highlighter.success = colors.green;
8455
+ highlighter.dim = colors.dim;
8456
+ highlighter.gray = colors.gray;
8457
+ highlighter.bold = colors.bold;
8458
+ };
8362
8459
  const computeJsxIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter((filePath) => JSX_FILE_PATTERN.test(filePath)) : void 0;
8363
8460
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
8364
8461
  const FALSY_VALUES = new Set([
@@ -10532,6 +10629,21 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
10532
10629
  resolve(output);
10533
10630
  });
10534
10631
  });
10632
+ const PARALLELISM_EXHAUSTION_ERROR_CODES = new Set([
10633
+ "EAGAIN",
10634
+ "EMFILE",
10635
+ "ENFILE",
10636
+ "ENOMEM"
10637
+ ]);
10638
+ const isParallelismRelatedSpawnError = (error) => {
10639
+ if (!(error instanceof ReactDoctorError)) return false;
10640
+ const { reason } = error;
10641
+ if (reason._tag !== "OxlintSpawnFailed") return false;
10642
+ const { cause } = reason;
10643
+ if (typeof cause !== "object" || cause === null || !("code" in cause)) return false;
10644
+ const { code } = cause;
10645
+ return typeof code === "string" && PARALLELISM_EXHAUSTION_ERROR_CODES.has(code);
10646
+ };
10535
10647
  /**
10536
10648
  * Runs every prebuilt file batch through oxlint, with binary-split
10537
10649
  * retry on the splittable error classes (timeout / output-too-large /
@@ -10540,66 +10652,83 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
10540
10652
  * (surfaced via `onPartialFailure`) so JSON-mode consumers see WHICH
10541
10653
  * files were skipped instead of silently losing them.
10542
10654
  *
10543
- * Errors that aren't splittable (oxlint config crash, JS plugin
10544
- * resolution failure, etc.) propagate to the caller — the
10545
- * `runOxlint` retry-without-extends fallback re-spawns this loop
10546
- * with a slimmer config in that case.
10655
+ * Parallel runs (concurrency > 1) get one extra safety net: if the pass
10656
+ * fails with a resource-exhaustion error that's exclusive to running
10657
+ * many oxlint subprocesses at once (EAGAIN / EMFILE / ENFILE / ENOMEM —
10658
+ * see `isParallelismRelatedSpawnError`), the whole pass replays once
10659
+ * with a single worker. That's the only failure a serial replay can
10660
+ * clear, so every other error class is left to propagate.
10661
+ *
10662
+ * Errors that aren't splittable and aren't parallelism-related (oxlint
10663
+ * config crash, JS plugin resolution failure, etc.) propagate to the
10664
+ * caller — the `runOxlint` retry-without-extends fallback re-spawns this
10665
+ * loop with a slimmer config in that case.
10547
10666
  */
10548
10667
  const spawnLintBatches = async (input) => {
10549
10668
  const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes } = input;
10550
- const concurrency = resolveScanConcurrency(input.concurrency ?? 1);
10669
+ const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
10551
10670
  const totalFileCount = fileBatches.reduce((sum, batch) => sum + batch.length, 0);
10552
- const allDiagnostics = [];
10553
- const droppedFiles = [];
10554
- let firstDropReason = null;
10555
- const spawnLintBatch = async (batch) => {
10556
- const batchArgs = [...baseArgs, ...batch];
10557
- try {
10558
- return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes), project, rootDirectory);
10559
- } catch (error) {
10560
- if (!isSplittableReactDoctorError(error)) throw error;
10561
- if (batch.length <= 1) {
10562
- droppedFiles.push(...batch);
10563
- if (firstDropReason === null) firstDropReason = error.message;
10564
- return [];
10671
+ const runBatchPass = async (concurrency) => {
10672
+ const allDiagnostics = [];
10673
+ const droppedFiles = [];
10674
+ let firstDropReason = null;
10675
+ const spawnLintBatch = async (batch) => {
10676
+ const batchArgs = [...baseArgs, ...batch];
10677
+ try {
10678
+ return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes), project, rootDirectory);
10679
+ } catch (error) {
10680
+ if (!isSplittableReactDoctorError(error)) throw error;
10681
+ if (batch.length <= 1) {
10682
+ droppedFiles.push(...batch);
10683
+ if (firstDropReason === null) firstDropReason = error.message;
10684
+ return [];
10685
+ }
10686
+ const splitIndex = Math.ceil(batch.length / 2);
10687
+ return [...await spawnLintBatch(batch.slice(0, splitIndex)), ...await spawnLintBatch(batch.slice(splitIndex))];
10565
10688
  }
10566
- const splitIndex = Math.ceil(batch.length / 2);
10567
- return [...await spawnLintBatch(batch.slice(0, splitIndex)), ...await spawnLintBatch(batch.slice(splitIndex))];
10689
+ };
10690
+ let startedFileCount = 0;
10691
+ let scannedFileCount = 0;
10692
+ let displayedFileCount = 0;
10693
+ const progressTimer = onFileProgress && totalFileCount > 1 ? setInterval(() => {
10694
+ const ceiling = Math.min(startedFileCount, totalFileCount - 1);
10695
+ if (displayedFileCount < ceiling) {
10696
+ displayedFileCount += 1;
10697
+ onFileProgress(displayedFileCount, totalFileCount);
10698
+ }
10699
+ }, 50) : null;
10700
+ progressTimer?.unref?.();
10701
+ try {
10702
+ const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
10703
+ startedFileCount += batch.length;
10704
+ const batchDiagnostics = await spawnLintBatch(batch);
10705
+ scannedFileCount += batch.length;
10706
+ if (onFileProgress) {
10707
+ displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
10708
+ onFileProgress(displayedFileCount, totalFileCount);
10709
+ }
10710
+ return batchDiagnostics;
10711
+ });
10712
+ for (const batchDiagnostics of batchResults) allDiagnostics.push(...batchDiagnostics);
10713
+ } finally {
10714
+ if (progressTimer !== null) clearInterval(progressTimer);
10568
10715
  }
10716
+ if (droppedFiles.length > 0 && onPartialFailure) {
10717
+ const previewFiles = droppedFiles.slice(0, 3).join(", ");
10718
+ const remainderHint = droppedFiles.length > 3 ? `, +${droppedFiles.length - 3} more` : "";
10719
+ const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
10720
+ onPartialFailure(`${droppedFiles.length} file(s) failed to lint and were skipped (${previewFiles}${remainderHint})${reasonHint}`);
10721
+ }
10722
+ return allDiagnostics;
10569
10723
  };
10570
- let startedFileCount = 0;
10571
- let scannedFileCount = 0;
10572
- let displayedFileCount = 0;
10573
- const progressTimer = onFileProgress && totalFileCount > 1 ? setInterval(() => {
10574
- const ceiling = Math.min(startedFileCount, totalFileCount - 1);
10575
- if (displayedFileCount < ceiling) {
10576
- displayedFileCount += 1;
10577
- onFileProgress(displayedFileCount, totalFileCount);
10578
- }
10579
- }, 50) : null;
10580
- progressTimer?.unref?.();
10724
+ let diagnostics;
10581
10725
  try {
10582
- const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
10583
- startedFileCount += batch.length;
10584
- const batchDiagnostics = await spawnLintBatch(batch);
10585
- scannedFileCount += batch.length;
10586
- if (onFileProgress) {
10587
- displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
10588
- onFileProgress(displayedFileCount, totalFileCount);
10589
- }
10590
- return batchDiagnostics;
10591
- });
10592
- for (const batchDiagnostics of batchResults) allDiagnostics.push(...batchDiagnostics);
10593
- } finally {
10594
- if (progressTimer !== null) clearInterval(progressTimer);
10595
- }
10596
- if (droppedFiles.length > 0 && onPartialFailure) {
10597
- const previewFiles = droppedFiles.slice(0, 3).join(", ");
10598
- const remainderHint = droppedFiles.length > 3 ? `, +${droppedFiles.length - 3} more` : "";
10599
- const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
10600
- onPartialFailure(`${droppedFiles.length} file(s) failed to lint and were skipped (${previewFiles}${remainderHint})${reasonHint}`);
10726
+ diagnostics = await runBatchPass(requestedConcurrency);
10727
+ } catch (error) {
10728
+ if (requestedConcurrency <= 1 || !isParallelismRelatedSpawnError(error)) throw error;
10729
+ diagnostics = await runBatchPass(1);
10601
10730
  }
10602
- return dedupeDiagnostics(allDiagnostics);
10731
+ return dedupeDiagnostics(diagnostics);
10603
10732
  };
10604
10733
  let didValidate = false;
10605
10734
  /**
@@ -11158,7 +11287,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
11158
11287
  reason: null
11159
11288
  });
11160
11289
  const scanConcurrency = yield* OxlintConcurrency;
11161
- const workerCountSuffix = scanConcurrency > 1 ? ` · ${scanConcurrency} workers` : "";
11290
+ const workerCountSuffix = scanConcurrency > 1 ? ` ${highlighter.dim(`[~${scanConcurrency} workers]`)}` : "";
11162
11291
  const scanProgress = yield* progressService.start("Scanning...");
11163
11292
  const scanStartTime = Date.now();
11164
11293
  let lastReportedTotalFileCount = 0;
@@ -11627,100 +11756,6 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
11627
11756
  };
11628
11757
  }).pipe(Effect.provide(Git.layerNode)));
11629
11758
  const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
11630
- var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
11631
- let p = process || {}, argv = p.argv || [], env = p.env || {};
11632
- let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
11633
- let formatter = (open, close, replace = open) => (input) => {
11634
- let string = "" + input, index = string.indexOf(close, open.length);
11635
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
11636
- };
11637
- let replaceClose = (string, close, replace, index) => {
11638
- let result = "", cursor = 0;
11639
- do {
11640
- result += string.substring(cursor, index) + replace;
11641
- cursor = index + close.length;
11642
- index = string.indexOf(close, cursor);
11643
- } while (~index);
11644
- return result + string.substring(cursor);
11645
- };
11646
- let createColors = (enabled = isColorSupported) => {
11647
- let f = enabled ? formatter : () => String;
11648
- return {
11649
- isColorSupported: enabled,
11650
- reset: f("\x1B[0m", "\x1B[0m"),
11651
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
11652
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
11653
- italic: f("\x1B[3m", "\x1B[23m"),
11654
- underline: f("\x1B[4m", "\x1B[24m"),
11655
- inverse: f("\x1B[7m", "\x1B[27m"),
11656
- hidden: f("\x1B[8m", "\x1B[28m"),
11657
- strikethrough: f("\x1B[9m", "\x1B[29m"),
11658
- black: f("\x1B[30m", "\x1B[39m"),
11659
- red: f("\x1B[31m", "\x1B[39m"),
11660
- green: f("\x1B[32m", "\x1B[39m"),
11661
- yellow: f("\x1B[33m", "\x1B[39m"),
11662
- blue: f("\x1B[34m", "\x1B[39m"),
11663
- magenta: f("\x1B[35m", "\x1B[39m"),
11664
- cyan: f("\x1B[36m", "\x1B[39m"),
11665
- white: f("\x1B[37m", "\x1B[39m"),
11666
- gray: f("\x1B[90m", "\x1B[39m"),
11667
- bgBlack: f("\x1B[40m", "\x1B[49m"),
11668
- bgRed: f("\x1B[41m", "\x1B[49m"),
11669
- bgGreen: f("\x1B[42m", "\x1B[49m"),
11670
- bgYellow: f("\x1B[43m", "\x1B[49m"),
11671
- bgBlue: f("\x1B[44m", "\x1B[49m"),
11672
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
11673
- bgCyan: f("\x1B[46m", "\x1B[49m"),
11674
- bgWhite: f("\x1B[47m", "\x1B[49m"),
11675
- blackBright: f("\x1B[90m", "\x1B[39m"),
11676
- redBright: f("\x1B[91m", "\x1B[39m"),
11677
- greenBright: f("\x1B[92m", "\x1B[39m"),
11678
- yellowBright: f("\x1B[93m", "\x1B[39m"),
11679
- blueBright: f("\x1B[94m", "\x1B[39m"),
11680
- magentaBright: f("\x1B[95m", "\x1B[39m"),
11681
- cyanBright: f("\x1B[96m", "\x1B[39m"),
11682
- whiteBright: f("\x1B[97m", "\x1B[39m"),
11683
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
11684
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
11685
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
11686
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
11687
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
11688
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
11689
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
11690
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
11691
- };
11692
- };
11693
- module.exports = createColors();
11694
- module.exports.createColors = createColors;
11695
- })))(), 1);
11696
- const highlighter = {
11697
- error: import_picocolors.default.red,
11698
- warn: import_picocolors.default.yellow,
11699
- info: import_picocolors.default.cyan,
11700
- success: import_picocolors.default.green,
11701
- dim: import_picocolors.default.dim,
11702
- gray: import_picocolors.default.gray,
11703
- bold: import_picocolors.default.bold
11704
- };
11705
- /**
11706
- * Override picocolors' automatic color detection. picocolors decides
11707
- * once, at import time, from `NO_COLOR` / `FORCE_COLOR` / `TERM` / TTY.
11708
- * This lets the CLI honor an explicit `--color` / `--no-color` flag
11709
- * (clig.dev, Output: "Disable color … if the user requested it") by
11710
- * swapping in a fresh set of formatters. Call it before any colored
11711
- * output is produced. Every call site reads `highlighter.<method>` at
11712
- * call time, so reassigning the properties propagates everywhere.
11713
- */
11714
- const setColorEnabled = (enabled) => {
11715
- const colors = import_picocolors.default.createColors(enabled);
11716
- highlighter.error = colors.red;
11717
- highlighter.warn = colors.yellow;
11718
- highlighter.info = colors.cyan;
11719
- highlighter.success = colors.green;
11720
- highlighter.dim = colors.dim;
11721
- highlighter.gray = colors.gray;
11722
- highlighter.bold = colors.bold;
11723
- };
11724
11759
  /**
11725
11760
  * Canonical URL for a rule's documentation page — its reviewer-tested fix
11726
11761
  * recipe rendered for humans — served at
@@ -11907,7 +11942,7 @@ const makeNoopConsole = () => ({
11907
11942
  });
11908
11943
  //#endregion
11909
11944
  //#region src/cli/utils/version.ts
11910
- const VERSION = "0.2.15-dev.520b0a9";
11945
+ const VERSION = "0.2.15-dev.8162bfb";
11911
11946
  //#endregion
11912
11947
  //#region src/cli/utils/json-mode.ts
11913
11948
  let context = null;
@@ -12253,13 +12288,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12253
12288
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12254
12289
  * standard `SENTRY_RELEASE` override.
12255
12290
  */
12256
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.15-dev.520b0a9`;
12291
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.15-dev.8162bfb`;
12257
12292
  /**
12258
12293
  * Deployment environment shown in Sentry's environment filter. Defaults to
12259
12294
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12260
12295
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12261
12296
  */
12262
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.15-dev.520b0a9") ? "development" : "production");
12297
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.15-dev.8162bfb") ? "development" : "production");
12263
12298
  /**
12264
12299
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12265
12300
  * (set to `0` to disable tracing) and falls back to
@@ -15839,6 +15874,9 @@ const buildCodeFrame = (input) => {
15839
15874
  });
15840
15875
  };
15841
15876
  //#endregion
15877
+ //#region src/cli/utils/build-section-divider.ts
15878
+ const buildSectionDivider = () => highlighter.dim(` ${"─".repeat(60)}`);
15879
+ //#endregion
15842
15880
  //#region src/cli/utils/indent-multiline-text.ts
15843
15881
  const indentMultilineText = (text, linePrefix) => text.split("\n").map((lineText) => `${linePrefix}${lineText}`).join("\n");
15844
15882
  //#endregion
@@ -15921,7 +15959,6 @@ const buildCompactCategoryLine = (categoryGroup) => {
15921
15959
  };
15922
15960
  const TOP_ERROR_DETAIL_INDENT = " ";
15923
15961
  const pickRepresentativeDiagnostic = (ruleDiagnostics) => ruleDiagnostics.find((diagnostic) => diagnostic.line > 0) ?? ruleDiagnostics[0];
15924
- const isErrorRuleGroup = (ruleDiagnostics) => pickRepresentativeDiagnostic(ruleDiagnostics).severity === "error";
15925
15962
  const FRAME_CONTEXT_REACH_LINES = 3;
15926
15963
  const clusterNearbyDiagnostics = (diagnostics) => {
15927
15964
  const byFile = groupBy(diagnostics, (diagnostic) => diagnostic.filePath);
@@ -15972,89 +16009,60 @@ const buildDiagnosticClusterLines = (cluster, resolveSourceRoot, renderCodeFrame
15972
16009
  }
15973
16010
  return lines;
15974
16011
  };
15975
- const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, renderEverySite) => {
16012
+ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, renderEverySite, isAgentEnvironment) => {
15976
16013
  const representative = pickRepresentativeDiagnostic(ruleDiagnostics);
15977
16014
  const { severity } = representative;
15978
16015
  const trailingBadge = formatTrailingSiteBadge(ruleDiagnostics.length);
15979
16016
  const headline = colorizeBySeverity(`${representative.category}: ${representative.title ?? ruleKey}`, severity);
15980
16017
  const lines = [` ${colorizeBySeverity(severity === "error" ? "✗" : "⚠", severity)} ${headline}${trailingBadge}`];
15981
- if (!renderEverySite) for (const explanationLine of wrapTextToWidth(representative.message, 60, { breakLongWords: false })) lines.push(`${TOP_ERROR_DETAIL_INDENT}${explanationLine}`);
15982
- if (representative.help) for (const fixLine of wrapTextToWidth(`→ ${representative.help}`, 60, { breakLongWords: false })) lines.push(highlighter.dim(`${TOP_ERROR_DETAIL_INDENT}${fixLine}`));
15983
- const renderCodeFrame = severity === "error";
15984
- const sites = renderEverySite ? ruleDiagnostics : [representative];
15985
- for (const cluster of clusterNearbyDiagnostics(sites)) lines.push(...buildDiagnosticClusterLines(cluster, resolveSourceRoot, renderCodeFrame));
15986
- return lines;
15987
- };
15988
- const WARNING_DETAIL_INDENT = " ";
15989
- const computeRuleNameColumnWidth = (ruleKeys) => ruleKeys.reduce((widest, ruleKey) => Math.max(widest, ruleKey.length), 36);
15990
- const padRuleNameToColumn = (ruleName, columnWidth) => ruleName.length >= columnWidth ? ruleName : ruleName + " ".repeat(columnWidth - ruleName.length);
15991
- const buildWarningHeaderLine = (ruleKey, siteCount, ruleNameColumnWidth) => {
15992
- const ruleName = formatSiteCountBadge(siteCount).length > 0 ? padRuleNameToColumn(ruleKey, ruleNameColumnWidth) : ruleKey;
15993
- return ` ${highlighter.warn("⚠")} ${ruleName}${formatTrailingSiteBadge(siteCount)}`;
15994
- };
15995
- const buildWarningRuleBlock = (ruleKey, ruleDiagnostics, ruleNameColumnWidth, isAgentEnvironment) => {
15996
- const representative = pickRepresentativeDiagnostic(ruleDiagnostics);
15997
- const lines = [buildWarningHeaderLine(ruleKey, ruleDiagnostics.length, ruleNameColumnWidth)];
15998
- if (!isAgentEnvironment) {
16018
+ if (renderEverySite && !isAgentEnvironment) {
15999
16019
  const learnMoreLine = formatLearnMoreLine(representative);
16000
- if (learnMoreLine) lines.push(`${WARNING_DETAIL_INDENT}${highlighter.info(learnMoreLine)}`);
16020
+ if (learnMoreLine) lines.push(`${TOP_ERROR_DETAIL_INDENT}${highlighter.info(learnMoreLine)}`);
16001
16021
  }
16002
- lines.push(highlighter.gray(indentMultilineText(representative.message, WARNING_DETAIL_INDENT)));
16003
- if (representative.help) lines.push(highlighter.gray(indentMultilineText(`→ ${representative.help}`, WARNING_DETAIL_INDENT)));
16004
- if (isAgentEnvironment) {
16022
+ if (!renderEverySite) for (const explanationLine of wrapTextToWidth(representative.message, 60, { breakLongWords: false })) lines.push(`${TOP_ERROR_DETAIL_INDENT}${explanationLine}`);
16023
+ if (representative.help) for (const fixLine of wrapTextToWidth(`→ ${representative.help}`, 60, { breakLongWords: false })) lines.push(highlighter.dim(`${TOP_ERROR_DETAIL_INDENT}${fixLine}`));
16024
+ if (renderEverySite && isAgentEnvironment) {
16005
16025
  const fixRecipeLine = formatFixRecipeLine(representative);
16006
- if (fixRecipeLine) lines.push(highlighter.gray(`${WARNING_DETAIL_INDENT}${fixRecipeLine}`));
16007
- }
16008
- for (const [filePath, sites] of buildVerboseSiteMap(ruleDiagnostics)) {
16009
- if (sites.length === 0) {
16010
- lines.push(highlighter.gray(`${WARNING_DETAIL_INDENT}${filePath}`));
16011
- continue;
16012
- }
16013
- for (const site of sites) {
16014
- lines.push(highlighter.gray(`${WARNING_DETAIL_INDENT}${filePath}:${site.line}`));
16015
- if (site.suppressionHint) lines.push(highlighter.gray(`${WARNING_DETAIL_INDENT} ↳ ${site.suppressionHint}`));
16016
- }
16026
+ if (fixRecipeLine) lines.push(highlighter.gray(`${TOP_ERROR_DETAIL_INDENT}${fixRecipeLine}`));
16017
16027
  }
16028
+ const renderCodeFrame = severity === "error" || renderEverySite;
16029
+ const sites = renderEverySite ? ruleDiagnostics : [representative];
16030
+ for (const cluster of clusterNearbyDiagnostics(sites)) lines.push(...buildDiagnosticClusterLines(cluster, resolveSourceRoot, renderCodeFrame));
16018
16031
  return lines;
16019
16032
  };
16020
16033
  const selectErrorRuleGroups = (diagnostics, rulePriority) => buildSortedRuleGroups(diagnostics.filter((diagnostic) => diagnostic.severity === "error"), rulePriority);
16021
16034
  const selectTopErrorRuleGroups = (diagnostics, limit, rulePriority) => selectErrorRuleGroups(diagnostics, rulePriority).slice(0, limit);
16022
- const buildMoreRulesLine = (hiddenRuleCount, severityNoun, accent) => {
16023
- const ruleNoun = hiddenRuleCount === 1 ? "rule" : "rules";
16024
- return ` ${highlighter.bold(accent(`+${hiddenRuleCount} more ${ruleNoun}`))} ${highlighter.dim("— run")} ${highlighter.bold(highlighter.info("--verbose"))} ${highlighter.dim(`to view the rest of the ${severityNoun} and details about each`)}`;
16035
+ const buildOverflowSummaryLine = (diagnostics, rulePriority) => {
16036
+ const errorRuleGroups = selectErrorRuleGroups(diagnostics, rulePriority);
16037
+ const shownErrorRuleCount = Math.min(3, errorRuleGroups.length);
16038
+ if (diagnostics.length <= shownErrorRuleCount) return void 0;
16039
+ const hiddenErrorRuleCount = errorRuleGroups.length - shownErrorRuleCount;
16040
+ const warningCount = diagnostics.filter((diagnostic) => diagnostic.severity === "warning").length;
16041
+ const parts = [];
16042
+ if (hiddenErrorRuleCount > 0) {
16043
+ const ruleNoun = hiddenErrorRuleCount === 1 ? "rule" : "rules";
16044
+ parts.push(highlighter.bold(highlighter.error(`+${hiddenErrorRuleCount} more ${ruleNoun}`)));
16045
+ }
16046
+ if (warningCount > 0) {
16047
+ const warningNoun = warningCount === 1 ? "warning" : "warnings";
16048
+ parts.push(highlighter.bold(highlighter.warn(`+${warningCount} optional ${warningNoun}`)));
16049
+ }
16050
+ const command = highlighter.bold(highlighter.info("npx react-doctor@latest --verbose"));
16051
+ return ` ${parts.length > 0 ? `${parts.join(highlighter.dim(" and "))} ${highlighter.dim("— run")}` : highlighter.dim("Run")} ${command} ${highlighter.dim("for details")}`;
16025
16052
  };
16026
16053
  const getTopErrorRuleKeys = (diagnostics, limit, rulePriority) => new Set(selectTopErrorRuleGroups(diagnostics, limit, rulePriority).map(([ruleKey]) => ruleKey));
16027
16054
  const buildTopErrorsLines = (diagnostics, resolveSourceRoot, rulePriority) => {
16028
- const errorRuleGroups = selectErrorRuleGroups(diagnostics, rulePriority);
16029
- const topRuleGroups = errorRuleGroups.slice(0, 3);
16055
+ const topRuleGroups = selectErrorRuleGroups(diagnostics, rulePriority).slice(0, 3);
16030
16056
  if (topRuleGroups.length === 0) return [];
16031
- const hiddenRuleCount = errorRuleGroups.length - topRuleGroups.length;
16032
16057
  const lines = [
16033
- highlighter.dim(` ${"─".repeat(60)}`),
16058
+ buildSectionDivider(),
16034
16059
  ` ${highlighter.bold(`Top ${topRuleGroups.length} ${topRuleGroups.length === 1 ? "error" : "errors"} you should fix`)}`,
16035
16060
  ""
16036
16061
  ];
16037
16062
  for (const [ruleKey, ruleDiagnostics] of topRuleGroups) {
16038
- lines.push(...buildRuleDetailBlock(ruleKey, ruleDiagnostics, resolveSourceRoot, false));
16063
+ lines.push(...buildRuleDetailBlock(ruleKey, ruleDiagnostics, resolveSourceRoot, false, false));
16039
16064
  lines.push("");
16040
16065
  }
16041
- if (hiddenRuleCount > 0) lines.push(buildMoreRulesLine(hiddenRuleCount, "errors", highlighter.error));
16042
- return lines;
16043
- };
16044
- const buildWarningsListLines = (diagnostics, rulePriority) => {
16045
- const warningDiagnostics = diagnostics.filter((diagnostic) => diagnostic.severity === "warning");
16046
- if (warningDiagnostics.length === 0) return [];
16047
- const sortedRuleGroups = buildSortedRuleGroups(warningDiagnostics, rulePriority);
16048
- const shownRuleGroups = sortedRuleGroups.slice(0, 10);
16049
- const hiddenRuleCount = sortedRuleGroups.length - shownRuleGroups.length;
16050
- const ruleNameColumnWidth = computeRuleNameColumnWidth(shownRuleGroups.map(([ruleKey]) => ruleKey));
16051
- const lines = [
16052
- highlighter.dim(` ${"─".repeat(60)}`),
16053
- ` ${highlighter.bold(`${warningDiagnostics.length} ${warningDiagnostics.length === 1 ? "warning" : "warnings"}`)}`,
16054
- ""
16055
- ];
16056
- for (const [ruleKey, ruleDiagnostics] of shownRuleGroups) lines.push(buildWarningHeaderLine(ruleKey, ruleDiagnostics.length, ruleNameColumnWidth));
16057
- if (hiddenRuleCount > 0) lines.push(buildMoreRulesLine(hiddenRuleCount, "warnings", highlighter.warn));
16058
16066
  return lines;
16059
16067
  };
16060
16068
  const buildCategoryBreakdownLines = (diagnostics, rulePriority) => buildCategoryDiagnosticGroups(diagnostics, rulePriority).map(buildCompactCategoryLine);
@@ -16085,14 +16093,11 @@ const printDiagnostics = (diagnostics, isVerbose, sourceRoot, rulePriority, isAg
16085
16093
  const resolveSourceRoot = typeof sourceRoot === "function" ? sourceRoot : () => sourceRoot;
16086
16094
  let detailLines;
16087
16095
  if (!isVerbose) detailLines = buildTopErrorsLines(diagnostics, resolveSourceRoot, rulePriority);
16088
- else {
16089
- const sortedRuleGroups = buildSortedRuleGroups(diagnostics, rulePriority);
16090
- const warningRuleNameColumnWidth = computeRuleNameColumnWidth(sortedRuleGroups.filter(([, ruleDiagnostics]) => !isErrorRuleGroup(ruleDiagnostics)).map(([ruleKey]) => ruleKey));
16091
- detailLines = sortedRuleGroups.flatMap(([ruleKey, ruleDiagnostics]) => {
16092
- return [...isErrorRuleGroup(ruleDiagnostics) ? buildRuleDetailBlock(ruleKey, ruleDiagnostics, resolveSourceRoot, true) : buildWarningRuleBlock(ruleKey, ruleDiagnostics, warningRuleNameColumnWidth, isAgentEnvironment), ""];
16093
- });
16094
- }
16095
- const lines = joinSections(buildCategoryBreakdownLines(diagnostics, rulePriority), buildCountsSummaryLines(diagnostics), detailLines, isVerbose ? [] : buildWarningsListLines(diagnostics, rulePriority));
16096
+ else detailLines = buildSortedRuleGroups(diagnostics, rulePriority).flatMap(([ruleKey, ruleDiagnostics]) => {
16097
+ return [...buildRuleDetailBlock(ruleKey, ruleDiagnostics, resolveSourceRoot, true, isAgentEnvironment), ""];
16098
+ });
16099
+ const overflowLine = isVerbose ? void 0 : buildOverflowSummaryLine(diagnostics, rulePriority);
16100
+ const lines = joinSections(buildCategoryBreakdownLines(diagnostics, rulePriority), buildCountsSummaryLines(diagnostics), detailLines, overflowLine ? [overflowLine] : []);
16096
16101
  for (const line of lines) yield* Console.log(line);
16097
16102
  });
16098
16103
  const formatElapsedTime = (elapsedMilliseconds) => {
@@ -16352,16 +16357,21 @@ const buildShareUrl = (diagnostics, scoreResult, projectName) => {
16352
16357
  if (affectedFileCount > 0) params.set("f", String(affectedFileCount));
16353
16358
  return `${SHARE_BASE_URL}?${params.toString()}`;
16354
16359
  };
16355
- const printVerboseTip = (diagnostics, isVerbose) => Effect.gen(function* () {
16356
- if (isVerbose || diagnostics.length === 0) return;
16357
- const command = highlighter.info("npx react-doctor@latest --verbose");
16358
- const message = diagnostics.some((diagnostic) => diagnostic.severity === "warning") ? `Run ${command} to see each warning explained with its fix` : `Run ${command} to see each issue explained with its fix`;
16359
- yield* Console.log(highlighter.dim(` Tip: ${message}`));
16360
- });
16361
- const printDocsNote = () => Effect.gen(function* () {
16360
+ const printFooter = (input) => Effect.gen(function* () {
16362
16361
  yield* Console.log("");
16362
+ yield* Console.log(buildSectionDivider());
16363
+ yield* Console.log("");
16364
+ if (!input.isOffline) {
16365
+ const shareUrl = buildShareUrl(input.diagnostics, input.scoreResult, input.projectName);
16366
+ yield* Console.log(` ${highlighter.bold("Share:")} ${highlighter.info(shareUrl)}`);
16367
+ yield* Console.log(highlighter.dim(" Tell others how you did on socials"));
16368
+ yield* Console.log("");
16369
+ }
16363
16370
  yield* Console.log(` ${highlighter.bold("Docs:")} ${highlighter.info(DOCS_URL)}`);
16364
- yield* Console.log(highlighter.dim(" Set up CI/CD, suppress rules with a config file, and scan diffs or PRs."));
16371
+ yield* Console.log(highlighter.dim(" Learn more about fixing issues, setting up CI/CD, and configuring rules with a config file"));
16372
+ yield* Console.log("");
16373
+ yield* Console.log(` ${highlighter.bold("GitHub:")} ${highlighter.info(CANONICAL_GITHUB_URL)}`);
16374
+ yield* Console.log(highlighter.dim(" Report issues and star the repository!"));
16365
16375
  });
16366
16376
  const printSummary = (input) => Effect.gen(function* () {
16367
16377
  if (input.scoreResult) {
@@ -16376,12 +16386,6 @@ const printSummary = (input) => Effect.gen(function* () {
16376
16386
  catch: (cause) => cause
16377
16387
  }).pipe(Effect.orElseSucceed(() => null));
16378
16388
  if (diagnosticsDirectory !== null && input.verbose) yield* Console.log(highlighter.gray(` Full diagnostics written to ${diagnosticsDirectory}`));
16379
- if (!input.isOffline) {
16380
- yield* Console.log("");
16381
- const shareUrl = buildShareUrl(input.diagnostics, input.scoreResult, input.projectName);
16382
- yield* Console.log(` ${highlighter.bold("Share:")} ${highlighter.info(shareUrl)}`);
16383
- yield* Console.log("");
16384
- }
16385
16389
  });
16386
16390
  //#endregion
16387
16391
  //#region src/cli/utils/cli-logger.ts
@@ -16734,10 +16738,8 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
16734
16738
  elapsedMilliseconds,
16735
16739
  scoreResult: score,
16736
16740
  potentialScore,
16737
- projectName: project.projectName,
16738
16741
  totalSourceFileCount: lintSourceFileCount,
16739
16742
  noScoreMessage,
16740
- isOffline: !shouldShowShareLink,
16741
16743
  verbose: options.verbose
16742
16744
  });
16743
16745
  if (hasSkippedChecks) {
@@ -16745,8 +16747,12 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
16745
16747
  yield* Console.log("");
16746
16748
  yield* Console.warn(highlighter.warn(` Note: ${skippedLabel} checks failed — score may be incomplete.`));
16747
16749
  }
16748
- yield* printVerboseTip([...surfaceDiagnostics], options.verbose);
16749
- yield* printDocsNote();
16750
+ yield* printFooter({
16751
+ diagnostics: [...surfaceDiagnostics],
16752
+ scoreResult: score,
16753
+ projectName: project.projectName,
16754
+ isOffline: !shouldShowShareLink
16755
+ });
16750
16756
  return buildResult();
16751
16757
  });
16752
16758
  //#endregion
@@ -18197,6 +18203,7 @@ const detectLaunchableAgents = async () => {
18197
18203
  };
18198
18204
  const handoffToAgent = async (input) => {
18199
18205
  if (!input.interactive || input.diagnostics.length === 0) return;
18206
+ cliLogger.break();
18200
18207
  const { handoffTarget } = await prompts({
18201
18208
  type: "select",
18202
18209
  name: "handoffTarget",
@@ -18456,7 +18463,7 @@ const findLowestScoredScan = (completedScans) => {
18456
18463
  return scoredScans.reduce((worst, scan) => scan.result.score.score < worst.result.score.score ? scan : worst);
18457
18464
  };
18458
18465
  const printMultiProjectSummary = (input) => Effect.gen(function* () {
18459
- const { completedScans, userConfig, verbose } = input;
18466
+ const { completedScans, userConfig, verbose, isOffline, projectName } = input;
18460
18467
  const surfaceDiagnostics = filterDiagnosticsForSurface(completedScans.flatMap((scan) => scan.result.diagnostics), "cli", userConfig);
18461
18468
  const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
18462
18469
  for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
@@ -18483,10 +18490,8 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
18483
18490
  elapsedMilliseconds: completedScans.reduce((sum, scan) => sum + scan.result.elapsedMilliseconds, 0),
18484
18491
  scoreResult: aggregateScore,
18485
18492
  potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(surfaceDiagnostics, lowestScoredScan.result.diagnostics, lowestScoredScan.result.score)) : null,
18486
- projectName: completedScans.map((scan) => scan.result.project.projectName).join(", "),
18487
18493
  totalSourceFileCount,
18488
18494
  noScoreMessage: "Score unavailable.",
18489
- isOffline: true,
18490
18495
  verbose
18491
18496
  });
18492
18497
  const entries = completedScans.map((scan) => {
@@ -18501,9 +18506,12 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
18501
18506
  const longestProjectNameLength = Math.max(...entries.map((entry) => entry.projectName.length));
18502
18507
  yield* Console.log("");
18503
18508
  for (const entry of entries) yield* Console.log(buildSummaryLine(entry, longestProjectNameLength));
18504
- yield* Console.log("");
18505
- yield* printVerboseTip(surfaceDiagnostics, verbose);
18506
- yield* printDocsNote();
18509
+ yield* printFooter({
18510
+ diagnostics: surfaceDiagnostics,
18511
+ scoreResult: aggregateScore,
18512
+ projectName,
18513
+ isOffline
18514
+ });
18507
18515
  });
18508
18516
  //#endregion
18509
18517
  //#region src/cli/utils/prompt-install-setup.ts
@@ -18553,31 +18561,13 @@ const printAgentInstallHint = (writeLine = defaultWriteLine) => {
18553
18561
  //#endregion
18554
18562
  //#region src/cli/utils/resolve-parallel-flag.ts
18555
18563
  /**
18556
- * Translates the `--experimental-parallel [workers]` flag into a concrete
18557
- * worker count for `InspectOptions.concurrency`:
18558
- *
18559
- * - flag absent (`undefined`) → `undefined` (defer to the ambient
18560
- * default: serial unless `REACT_DOCTOR_PARALLEL` is set)
18561
- * - bare flag / `auto` → auto-detect CPU cores
18562
- * - `--experimental-parallel <n>` → `n` workers (clamped)
18563
- * - `false` / `off` / `0` → serial (an explicit opt-out, so
18564
- * it overrides an env-enabled default rather than deferring to it)
18565
- * - an unparseable value → auto-detect cores
18566
- *
18567
- * Commander yields `true` for a bare flag, the raw string for an explicit
18568
- * value, and `undefined` when the flag is omitted.
18564
+ * Maps the `--no-parallel` flag to an `InspectOptions.concurrency` value.
18565
+ * `--no-parallel` (`parallel === false`) pins serial, overriding any
18566
+ * env-enabled default; otherwise `undefined` defers to the ambient
18567
+ * `OxlintConcurrency` default (parallel, unless `REACT_DOCTOR_PARALLEL`
18568
+ * sets a worker count — the flag itself no longer takes one).
18569
18569
  */
18570
- const resolveParallelFlag = (parallel) => {
18571
- if (parallel === void 0) return void 0;
18572
- if (parallel === true) return resolveScanConcurrency("auto");
18573
- if (parallel === false) return 1;
18574
- const normalized = parallel.trim().toLowerCase();
18575
- if (normalized === "" || normalized === "auto" || normalized === "true") return resolveScanConcurrency("auto");
18576
- if (normalized === "false" || normalized === "off" || normalized === "0") return 1;
18577
- const parsed = Number.parseInt(normalized, 10);
18578
- if (!Number.isInteger(parsed) || parsed <= 0) return resolveScanConcurrency("auto");
18579
- return resolveScanConcurrency(parsed);
18580
- };
18570
+ const resolveParallelFlag = (parallel) => parallel === false ? 1 : void 0;
18581
18571
  //#endregion
18582
18572
  //#region src/cli/utils/resolve-cli-inspect-options.ts
18583
18573
  /**
@@ -18605,7 +18595,7 @@ const resolveCliInspectOptions = (flags, userConfig) => {
18605
18595
  isCi: isCiEnvironment(),
18606
18596
  silent: Boolean(flags.json),
18607
18597
  outputSurface: flags.prComment ? "prComment" : "cli",
18608
- concurrency: resolveParallelFlag(flags.experimentalParallel)
18598
+ concurrency: resolveParallelFlag(flags.parallel)
18609
18599
  };
18610
18600
  };
18611
18601
  //#endregion
@@ -19072,11 +19062,16 @@ const inspectAction = async (directory, flags) => {
19072
19062
  });
19073
19063
  if (!isQuiet && !isMultiProject) cliLogger.break();
19074
19064
  }
19075
- if (!isQuiet && isMultiProject && completedScans.length > 0) await Effect.runPromise(printMultiProjectSummary({
19076
- completedScans,
19077
- userConfig,
19078
- verbose: Boolean(flags.verbose)
19079
- }));
19065
+ if (!isQuiet && isMultiProject && completedScans.length > 0) {
19066
+ const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
19067
+ await Effect.runPromise(printMultiProjectSummary({
19068
+ completedScans,
19069
+ userConfig,
19070
+ verbose: Boolean(flags.verbose),
19071
+ isOffline: !shouldShowShareLink,
19072
+ projectName: path.basename(resolvedDirectory)
19073
+ }));
19074
+ }
19080
19075
  finalizeScans({
19081
19076
  diagnostics: allDiagnostics,
19082
19077
  completedScans,
@@ -19797,6 +19792,7 @@ const ROOT_FLAG_SPEC = {
19797
19792
  "--no-color",
19798
19793
  "--no-dead-code",
19799
19794
  "--no-lint",
19795
+ "--no-parallel",
19800
19796
  "--no-respect-inline-disables",
19801
19797
  "--no-score",
19802
19798
  "--no-telemetry",
@@ -19817,7 +19813,7 @@ const ROOT_FLAG_SPEC = {
19817
19813
  "--project",
19818
19814
  "--why"
19819
19815
  ]),
19820
- longOptionsWithOptionalValues: new Set(["--diff", "--experimental-parallel"]),
19816
+ longOptionsWithOptionalValues: new Set(["--diff"]),
19821
19817
  shortOptionsWithoutValues: new Set([
19822
19818
  "-h",
19823
19819
  "-v",
@@ -19984,7 +19980,7 @@ ${formatExampleLines([
19984
19980
  ${highlighter.dim("Learn more:")}
19985
19981
  ${highlighter.info(CANONICAL_GITHUB_URL)}
19986
19982
  `;
19987
- const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--full", "force a full scan (overrides any `diff` value in config or `--diff`)").option("--experimental-parallel [workers]", "experimental: lint with N parallel workers (default: auto-detect CPU cores) — speeds up large repos").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--diff [base]", "scan only files changed vs base branch (pass `false` to disable; overridden by --full)").option("--changed-files-from <file>", "internal: scan source files listed in a newline-delimited changed-files file").option("--no-score", "skip the score API, the share URL, and crash reporting").option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--fail-on <level>", "exit with error code on diagnostics: error, warning, none (default: none)").option("--annotations", "output diagnostics as GitHub Actions annotations").option("--pr-comment", "tune CLI output for sticky PR comments (drops weak-signal rule families like `design` from the printed list and the fail-on gate; configure via config.surfaces)").option("--explain <file:line>", "diagnose why a rule fired or why a suppression didn't apply at a specific location").option("--why <file:line>", "alias for --explain").option("--respect-inline-disables", "respect inline `// eslint-disable*` / `// oxlint-disable*` comments (default)").option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
19983
+ const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--full", "force a full scan (overrides any `diff` value in config or `--diff`)").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--diff [base]", "scan only files changed vs base branch (pass `false` to disable; overridden by --full)").option("--changed-files-from <file>", "internal: scan source files listed in a newline-delimited changed-files file").option("--no-score", "skip the score API, the share URL, and crash reporting").option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--fail-on <level>", "exit with error code on diagnostics: error, warning, none (default: none)").option("--annotations", "output diagnostics as GitHub Actions annotations").option("--pr-comment", "tune CLI output for sticky PR comments (drops weak-signal rule families like `design` from the printed list and the fail-on gate; configure via config.surfaces)").option("--explain <file:line>", "diagnose why a rule fired or why a suppression didn't apply at a specific location").option("--why <file:line>", "alias for --explain").option("--respect-inline-disables", "respect inline `// eslint-disable*` / `// oxlint-disable*` comments (default)").option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
19988
19984
  program.action(inspectAction);
19989
19985
  program.command("install").alias("setup").description("Install the react-doctor skill into your coding agents and optional git hook").option("-y, --yes", "skip prompts, install for all detected agents").option("--dry-run", "show what would be installed without writing files").option("--agent-hooks", "install native non-blocking agent hooks for Claude Code and Cursor").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderInstallHelpEpilog).action(installAction);
19990
19986
  program.command("version").description("show the version with Node and platform info").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action(versionAction);
@@ -20020,4 +20016,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
20020
20016
  export {};
20021
20017
 
20022
20018
  //# sourceMappingURL=cli.js.map
20023
- //# debugId=c8bf2d99-8f0b-55f1-a894-63e600bf000b
20019
+ //# debugId=e5345c0f-0e42-5045-8127-8f9f7a251f64
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3967254f-df21-5398-99d5-ee0d17b33e7b")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a56b86f0-1c28-52ae-9677-12f5e67df34f")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as Schema from "effect/Schema";
5
5
  import * as fs$1 from "node:fs";
@@ -4314,27 +4314,30 @@ var OxlintSpawnTimeoutMs = class extends Context.Reference("react-doctor/OxlintS
4314
4314
  var OxlintOutputMaxBytes = class extends Context.Reference("react-doctor/OxlintOutputMaxBytes", { defaultValue: () => OXLINT_OUTPUT_MAX_BYTES }) {};
4315
4315
  /**
4316
4316
  * Number of oxlint subprocesses the lint pass runs in parallel. Defaults
4317
- * to `1` (serial — the historical behavior) so resource usage is opt-in.
4318
- * The CLI's `--experimental-parallel` flag overrides this via `Layer.succeed`; the
4319
- * `REACT_DOCTOR_PARALLEL` env var seeds the default for programmatic /
4320
- * CI callers that never touch the flag:
4317
+ * to auto-detected CPU cores (parallel) so large repos scan fast out of
4318
+ * the box; `spawnLintBatches` transparently falls back to a single worker
4319
+ * if a parallel run exhausts system resources. The CLI's `--no-parallel`
4320
+ * flag forces serial via `Layer.succeed`; the `REACT_DOCTOR_PARALLEL` env
4321
+ * var seeds the default for programmatic / CI callers that never touch the
4322
+ * flag — parallelism is opt-OUT, so only the explicit serial values pin
4323
+ * one worker:
4321
4324
  *
4322
- * - unset / `0` / `false` / `off` → `1` (serial)
4323
- * - `auto` / `true` / `on` → available CPU cores (clamped)
4324
- * - a positive integer → that many workers (clamped)
4325
+ * - unset / `auto` / `true` / `on` → available CPU cores (clamped)
4326
+ * - `0` / `false` / `off` → `1` (serial)
4327
+ * - a positive integer → that many workers (clamped)
4328
+ * - any other value → available CPU cores (clamped)
4325
4329
  *
4326
4330
  * The resolved value is always within
4327
4331
  * `[MIN_SCAN_CONCURRENCY, MAX_SCAN_CONCURRENCY]`.
4328
4332
  */
4329
4333
  var OxlintConcurrency = class extends Context.Reference("react-doctor/OxlintConcurrency", { defaultValue: () => {
4330
4334
  const raw = process.env["REACT_DOCTOR_PARALLEL"];
4331
- if (raw === void 0) return 1;
4335
+ if (raw === void 0) return resolveScanConcurrency("auto");
4332
4336
  const normalized = raw.trim().toLowerCase();
4333
- if (normalized === "" || normalized === "0" || normalized === "false" || normalized === "off") return 1;
4334
- if (normalized === "auto" || normalized === "true" || normalized === "on") return resolveScanConcurrency("auto");
4337
+ if (normalized === "0" || normalized === "false" || normalized === "off") return 1;
4335
4338
  const parsed = Number.parseInt(normalized, 10);
4336
- if (!Number.isInteger(parsed) || parsed <= 0) return 1;
4337
- return resolveScanConcurrency(parsed);
4339
+ if (Number.isInteger(parsed) && parsed > 0) return resolveScanConcurrency(parsed);
4340
+ return resolveScanConcurrency("auto");
4338
4341
  } }) {};
4339
4342
  const DIAGNOSTIC_SURFACES = [
4340
4343
  "cli",
@@ -5309,6 +5312,81 @@ const checkReducedMotion = (rootDirectory) => {
5309
5312
  if (result.status === 0) return [];
5310
5313
  return [MISSING_REDUCED_MOTION_DIAGNOSTIC];
5311
5314
  };
5315
+ var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
5316
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
5317
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
5318
+ let formatter = (open, close, replace = open) => (input) => {
5319
+ let string = "" + input, index = string.indexOf(close, open.length);
5320
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
5321
+ };
5322
+ let replaceClose = (string, close, replace, index) => {
5323
+ let result = "", cursor = 0;
5324
+ do {
5325
+ result += string.substring(cursor, index) + replace;
5326
+ cursor = index + close.length;
5327
+ index = string.indexOf(close, cursor);
5328
+ } while (~index);
5329
+ return result + string.substring(cursor);
5330
+ };
5331
+ let createColors = (enabled = isColorSupported) => {
5332
+ let f = enabled ? formatter : () => String;
5333
+ return {
5334
+ isColorSupported: enabled,
5335
+ reset: f("\x1B[0m", "\x1B[0m"),
5336
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
5337
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
5338
+ italic: f("\x1B[3m", "\x1B[23m"),
5339
+ underline: f("\x1B[4m", "\x1B[24m"),
5340
+ inverse: f("\x1B[7m", "\x1B[27m"),
5341
+ hidden: f("\x1B[8m", "\x1B[28m"),
5342
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
5343
+ black: f("\x1B[30m", "\x1B[39m"),
5344
+ red: f("\x1B[31m", "\x1B[39m"),
5345
+ green: f("\x1B[32m", "\x1B[39m"),
5346
+ yellow: f("\x1B[33m", "\x1B[39m"),
5347
+ blue: f("\x1B[34m", "\x1B[39m"),
5348
+ magenta: f("\x1B[35m", "\x1B[39m"),
5349
+ cyan: f("\x1B[36m", "\x1B[39m"),
5350
+ white: f("\x1B[37m", "\x1B[39m"),
5351
+ gray: f("\x1B[90m", "\x1B[39m"),
5352
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
5353
+ bgRed: f("\x1B[41m", "\x1B[49m"),
5354
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
5355
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
5356
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
5357
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
5358
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
5359
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
5360
+ blackBright: f("\x1B[90m", "\x1B[39m"),
5361
+ redBright: f("\x1B[91m", "\x1B[39m"),
5362
+ greenBright: f("\x1B[92m", "\x1B[39m"),
5363
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
5364
+ blueBright: f("\x1B[94m", "\x1B[39m"),
5365
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
5366
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
5367
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
5368
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
5369
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
5370
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
5371
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
5372
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
5373
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
5374
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
5375
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
5376
+ };
5377
+ };
5378
+ module.exports = createColors();
5379
+ module.exports.createColors = createColors;
5380
+ })))(), 1);
5381
+ const highlighter = {
5382
+ error: import_picocolors.default.red,
5383
+ warn: import_picocolors.default.yellow,
5384
+ info: import_picocolors.default.cyan,
5385
+ success: import_picocolors.default.green,
5386
+ dim: import_picocolors.default.dim,
5387
+ gray: import_picocolors.default.gray,
5388
+ bold: import_picocolors.default.bold
5389
+ };
5312
5390
  const computeJsxIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter((filePath) => JSX_FILE_PATTERN.test(filePath)) : void 0;
5313
5391
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
5314
5392
  const FALSY_VALUES = new Set([
@@ -7485,6 +7563,21 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
7485
7563
  resolve(output);
7486
7564
  });
7487
7565
  });
7566
+ const PARALLELISM_EXHAUSTION_ERROR_CODES = new Set([
7567
+ "EAGAIN",
7568
+ "EMFILE",
7569
+ "ENFILE",
7570
+ "ENOMEM"
7571
+ ]);
7572
+ const isParallelismRelatedSpawnError = (error) => {
7573
+ if (!(error instanceof ReactDoctorError)) return false;
7574
+ const { reason } = error;
7575
+ if (reason._tag !== "OxlintSpawnFailed") return false;
7576
+ const { cause } = reason;
7577
+ if (typeof cause !== "object" || cause === null || !("code" in cause)) return false;
7578
+ const { code } = cause;
7579
+ return typeof code === "string" && PARALLELISM_EXHAUSTION_ERROR_CODES.has(code);
7580
+ };
7488
7581
  /**
7489
7582
  * Runs every prebuilt file batch through oxlint, with binary-split
7490
7583
  * retry on the splittable error classes (timeout / output-too-large /
@@ -7493,66 +7586,83 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
7493
7586
  * (surfaced via `onPartialFailure`) so JSON-mode consumers see WHICH
7494
7587
  * files were skipped instead of silently losing them.
7495
7588
  *
7496
- * Errors that aren't splittable (oxlint config crash, JS plugin
7497
- * resolution failure, etc.) propagate to the caller — the
7498
- * `runOxlint` retry-without-extends fallback re-spawns this loop
7499
- * with a slimmer config in that case.
7589
+ * Parallel runs (concurrency > 1) get one extra safety net: if the pass
7590
+ * fails with a resource-exhaustion error that's exclusive to running
7591
+ * many oxlint subprocesses at once (EAGAIN / EMFILE / ENFILE / ENOMEM —
7592
+ * see `isParallelismRelatedSpawnError`), the whole pass replays once
7593
+ * with a single worker. That's the only failure a serial replay can
7594
+ * clear, so every other error class is left to propagate.
7595
+ *
7596
+ * Errors that aren't splittable and aren't parallelism-related (oxlint
7597
+ * config crash, JS plugin resolution failure, etc.) propagate to the
7598
+ * caller — the `runOxlint` retry-without-extends fallback re-spawns this
7599
+ * loop with a slimmer config in that case.
7500
7600
  */
7501
7601
  const spawnLintBatches = async (input) => {
7502
7602
  const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes } = input;
7503
- const concurrency = resolveScanConcurrency(input.concurrency ?? 1);
7603
+ const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
7504
7604
  const totalFileCount = fileBatches.reduce((sum, batch) => sum + batch.length, 0);
7505
- const allDiagnostics = [];
7506
- const droppedFiles = [];
7507
- let firstDropReason = null;
7508
- const spawnLintBatch = async (batch) => {
7509
- const batchArgs = [...baseArgs, ...batch];
7510
- try {
7511
- return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes), project, rootDirectory);
7512
- } catch (error) {
7513
- if (!isSplittableReactDoctorError(error)) throw error;
7514
- if (batch.length <= 1) {
7515
- droppedFiles.push(...batch);
7516
- if (firstDropReason === null) firstDropReason = error.message;
7517
- return [];
7605
+ const runBatchPass = async (concurrency) => {
7606
+ const allDiagnostics = [];
7607
+ const droppedFiles = [];
7608
+ let firstDropReason = null;
7609
+ const spawnLintBatch = async (batch) => {
7610
+ const batchArgs = [...baseArgs, ...batch];
7611
+ try {
7612
+ return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes), project, rootDirectory);
7613
+ } catch (error) {
7614
+ if (!isSplittableReactDoctorError(error)) throw error;
7615
+ if (batch.length <= 1) {
7616
+ droppedFiles.push(...batch);
7617
+ if (firstDropReason === null) firstDropReason = error.message;
7618
+ return [];
7619
+ }
7620
+ const splitIndex = Math.ceil(batch.length / 2);
7621
+ return [...await spawnLintBatch(batch.slice(0, splitIndex)), ...await spawnLintBatch(batch.slice(splitIndex))];
7622
+ }
7623
+ };
7624
+ let startedFileCount = 0;
7625
+ let scannedFileCount = 0;
7626
+ let displayedFileCount = 0;
7627
+ const progressTimer = onFileProgress && totalFileCount > 1 ? setInterval(() => {
7628
+ const ceiling = Math.min(startedFileCount, totalFileCount - 1);
7629
+ if (displayedFileCount < ceiling) {
7630
+ displayedFileCount += 1;
7631
+ onFileProgress(displayedFileCount, totalFileCount);
7518
7632
  }
7519
- const splitIndex = Math.ceil(batch.length / 2);
7520
- return [...await spawnLintBatch(batch.slice(0, splitIndex)), ...await spawnLintBatch(batch.slice(splitIndex))];
7633
+ }, 50) : null;
7634
+ progressTimer?.unref?.();
7635
+ try {
7636
+ const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
7637
+ startedFileCount += batch.length;
7638
+ const batchDiagnostics = await spawnLintBatch(batch);
7639
+ scannedFileCount += batch.length;
7640
+ if (onFileProgress) {
7641
+ displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
7642
+ onFileProgress(displayedFileCount, totalFileCount);
7643
+ }
7644
+ return batchDiagnostics;
7645
+ });
7646
+ for (const batchDiagnostics of batchResults) allDiagnostics.push(...batchDiagnostics);
7647
+ } finally {
7648
+ if (progressTimer !== null) clearInterval(progressTimer);
7521
7649
  }
7522
- };
7523
- let startedFileCount = 0;
7524
- let scannedFileCount = 0;
7525
- let displayedFileCount = 0;
7526
- const progressTimer = onFileProgress && totalFileCount > 1 ? setInterval(() => {
7527
- const ceiling = Math.min(startedFileCount, totalFileCount - 1);
7528
- if (displayedFileCount < ceiling) {
7529
- displayedFileCount += 1;
7530
- onFileProgress(displayedFileCount, totalFileCount);
7650
+ if (droppedFiles.length > 0 && onPartialFailure) {
7651
+ const previewFiles = droppedFiles.slice(0, 3).join(", ");
7652
+ const remainderHint = droppedFiles.length > 3 ? `, +${droppedFiles.length - 3} more` : "";
7653
+ const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
7654
+ onPartialFailure(`${droppedFiles.length} file(s) failed to lint and were skipped (${previewFiles}${remainderHint})${reasonHint}`);
7531
7655
  }
7532
- }, 50) : null;
7533
- progressTimer?.unref?.();
7656
+ return allDiagnostics;
7657
+ };
7658
+ let diagnostics;
7534
7659
  try {
7535
- const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
7536
- startedFileCount += batch.length;
7537
- const batchDiagnostics = await spawnLintBatch(batch);
7538
- scannedFileCount += batch.length;
7539
- if (onFileProgress) {
7540
- displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
7541
- onFileProgress(displayedFileCount, totalFileCount);
7542
- }
7543
- return batchDiagnostics;
7544
- });
7545
- for (const batchDiagnostics of batchResults) allDiagnostics.push(...batchDiagnostics);
7546
- } finally {
7547
- if (progressTimer !== null) clearInterval(progressTimer);
7548
- }
7549
- if (droppedFiles.length > 0 && onPartialFailure) {
7550
- const previewFiles = droppedFiles.slice(0, 3).join(", ");
7551
- const remainderHint = droppedFiles.length > 3 ? `, +${droppedFiles.length - 3} more` : "";
7552
- const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
7553
- onPartialFailure(`${droppedFiles.length} file(s) failed to lint and were skipped (${previewFiles}${remainderHint})${reasonHint}`);
7660
+ diagnostics = await runBatchPass(requestedConcurrency);
7661
+ } catch (error) {
7662
+ if (requestedConcurrency <= 1 || !isParallelismRelatedSpawnError(error)) throw error;
7663
+ diagnostics = await runBatchPass(1);
7554
7664
  }
7555
- return dedupeDiagnostics(allDiagnostics);
7665
+ return dedupeDiagnostics(diagnostics);
7556
7666
  };
7557
7667
  let didValidate = false;
7558
7668
  /**
@@ -8111,7 +8221,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
8111
8221
  reason: null
8112
8222
  });
8113
8223
  const scanConcurrency = yield* OxlintConcurrency;
8114
- const workerCountSuffix = scanConcurrency > 1 ? ` · ${scanConcurrency} workers` : "";
8224
+ const workerCountSuffix = scanConcurrency > 1 ? ` ${highlighter.dim(`[~${scanConcurrency} workers]`)}` : "";
8115
8225
  const scanProgress = yield* progressService.start("Scanning...");
8116
8226
  const scanStartTime = Date.now();
8117
8227
  let lastReportedTotalFileCount = 0;
@@ -8556,73 +8666,6 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
8556
8666
  };
8557
8667
  }).pipe(Effect.provide(Git.layerNode)));
8558
8668
  const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
8559
- var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
8560
- let p = process || {}, argv = p.argv || [], env = p.env || {};
8561
- let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
8562
- let formatter = (open, close, replace = open) => (input) => {
8563
- let string = "" + input, index = string.indexOf(close, open.length);
8564
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
8565
- };
8566
- let replaceClose = (string, close, replace, index) => {
8567
- let result = "", cursor = 0;
8568
- do {
8569
- result += string.substring(cursor, index) + replace;
8570
- cursor = index + close.length;
8571
- index = string.indexOf(close, cursor);
8572
- } while (~index);
8573
- return result + string.substring(cursor);
8574
- };
8575
- let createColors = (enabled = isColorSupported) => {
8576
- let f = enabled ? formatter : () => String;
8577
- return {
8578
- isColorSupported: enabled,
8579
- reset: f("\x1B[0m", "\x1B[0m"),
8580
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
8581
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
8582
- italic: f("\x1B[3m", "\x1B[23m"),
8583
- underline: f("\x1B[4m", "\x1B[24m"),
8584
- inverse: f("\x1B[7m", "\x1B[27m"),
8585
- hidden: f("\x1B[8m", "\x1B[28m"),
8586
- strikethrough: f("\x1B[9m", "\x1B[29m"),
8587
- black: f("\x1B[30m", "\x1B[39m"),
8588
- red: f("\x1B[31m", "\x1B[39m"),
8589
- green: f("\x1B[32m", "\x1B[39m"),
8590
- yellow: f("\x1B[33m", "\x1B[39m"),
8591
- blue: f("\x1B[34m", "\x1B[39m"),
8592
- magenta: f("\x1B[35m", "\x1B[39m"),
8593
- cyan: f("\x1B[36m", "\x1B[39m"),
8594
- white: f("\x1B[37m", "\x1B[39m"),
8595
- gray: f("\x1B[90m", "\x1B[39m"),
8596
- bgBlack: f("\x1B[40m", "\x1B[49m"),
8597
- bgRed: f("\x1B[41m", "\x1B[49m"),
8598
- bgGreen: f("\x1B[42m", "\x1B[49m"),
8599
- bgYellow: f("\x1B[43m", "\x1B[49m"),
8600
- bgBlue: f("\x1B[44m", "\x1B[49m"),
8601
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
8602
- bgCyan: f("\x1B[46m", "\x1B[49m"),
8603
- bgWhite: f("\x1B[47m", "\x1B[49m"),
8604
- blackBright: f("\x1B[90m", "\x1B[39m"),
8605
- redBright: f("\x1B[91m", "\x1B[39m"),
8606
- greenBright: f("\x1B[92m", "\x1B[39m"),
8607
- yellowBright: f("\x1B[93m", "\x1B[39m"),
8608
- blueBright: f("\x1B[94m", "\x1B[39m"),
8609
- magentaBright: f("\x1B[95m", "\x1B[39m"),
8610
- cyanBright: f("\x1B[96m", "\x1B[39m"),
8611
- whiteBright: f("\x1B[97m", "\x1B[39m"),
8612
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
8613
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
8614
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
8615
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
8616
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
8617
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
8618
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
8619
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
8620
- };
8621
- };
8622
- module.exports = createColors();
8623
- module.exports.createColors = createColors;
8624
- })))(), 1);
8625
- import_picocolors.default.red, import_picocolors.default.yellow, import_picocolors.default.cyan, import_picocolors.default.green, import_picocolors.default.dim, import_picocolors.default.gray, import_picocolors.default.bold;
8626
8669
  /**
8627
8670
  * Back-compat alias: the streaming pipeline holds its caches in
8628
8671
  * per-pipeline closures that are garbage-collected when the pipeline
@@ -8699,4 +8742,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8699
8742
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8700
8743
 
8701
8744
  //# sourceMappingURL=index.js.map
8702
- //# debugId=3967254f-df21-5398-99d5-ee0d17b33e7b
8745
+ //# debugId=a56b86f0-1c28-52ae-9677-12f5e67df34f
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.2.15-dev.520b0a9",
3
+ "version": "0.2.15-dev.8162bfb",
4
4
  "description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -63,7 +63,7 @@
63
63
  "oxlint": "^1.66.0",
64
64
  "prompts": "^2.4.2",
65
65
  "typescript": ">=5.0.4 <7",
66
- "oxlint-plugin-react-doctor": "0.2.15-dev.520b0a9"
66
+ "oxlint-plugin-react-doctor": "0.2.15-dev.8162bfb"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/babel__code-frame": "^7.27.0",
@@ -71,8 +71,8 @@
71
71
  "@xterm/headless": "^6.0.0",
72
72
  "commander": "^14.0.3",
73
73
  "ora": "^9.4.0",
74
- "@react-doctor/core": "0.2.15",
75
- "@react-doctor/api": "0.2.15"
74
+ "@react-doctor/api": "0.2.15",
75
+ "@react-doctor/core": "0.2.15"
76
76
  },
77
77
  "engines": {
78
78
  "node": "^20.19.0 || >=22.12.0"