react-doctor 0.5.1-dev.2f26228 → 0.5.1-dev.7c88165

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.
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]="4db91f1b-d88c-5feb-a6d7-b4b1a94b2537")}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]="ecc7e4af-d176-5569-bc51-c3fbe220a76b")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as NodeChildProcess from "node:child_process";
5
5
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
@@ -41712,6 +41712,7 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
41712
41712
  };
41713
41713
  const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
41714
41714
  const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
41715
+ const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
41715
41716
  const REACT_COMPILER_MESSAGE = "This component misses React Compiler's automatic memoization & re-renders more than it should. Rewrite the flagged code so the compiler can optimize it.";
41716
41717
  const PLUGIN_CATEGORY_MAP = {
41717
41718
  react: "Bugs",
@@ -41739,7 +41740,10 @@ const getRuleRecommendation = (ruleName, project) => {
41739
41740
  };
41740
41741
  const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
41741
41742
  const getRuleTitle = (ruleName) => reactDoctorPlugin.rules[ruleName]?.title;
41742
- const resolveDiagnosticTitle = (plugin, rule) => plugin === "react-hooks-js" ? REACT_COMPILER_TITLE : getRuleTitle(rule);
41743
+ const resolveDiagnosticTitle = (plugin, rule) => {
41744
+ if (plugin !== "react-hooks-js") return getRuleTitle(rule);
41745
+ return rule === "todo" ? REACT_COMPILER_TODO_TITLE : REACT_COMPILER_TITLE;
41746
+ };
41743
41747
  const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
41744
41748
  const cleaned = resolveCleanedDiagnostic(typeof message === "string" ? message : "", typeof help === "string" ? help : "", plugin, rule, project);
41745
41749
  return {
@@ -42498,25 +42502,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
42498
42502
  const SCORE_AXES = [
42499
42503
  {
42500
42504
  key: "supplyChain",
42501
- label: "supply chain"
42505
+ label: "supply chain",
42506
+ gates: true
42502
42507
  },
42503
42508
  {
42504
42509
  key: "vulnerability",
42505
- label: "vulnerability"
42510
+ label: "vulnerability",
42511
+ gates: true
42506
42512
  },
42507
42513
  {
42508
42514
  key: "maintenance",
42509
- label: "maintenance"
42515
+ label: "maintenance",
42516
+ gates: false
42510
42517
  },
42511
42518
  {
42512
42519
  key: "quality",
42513
- label: "quality"
42520
+ label: "quality",
42521
+ gates: false
42514
42522
  },
42515
42523
  {
42516
42524
  key: "license",
42517
- label: "license"
42525
+ label: "license",
42526
+ gates: false
42518
42527
  }
42519
42528
  ];
42529
+ const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
42530
+ const worstGatedAxis = (score) => {
42531
+ let worst = GATED_AXES[0];
42532
+ for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
42533
+ return worst;
42534
+ };
42520
42535
  const clampScore = (value) => {
42521
42536
  if (!Number.isFinite(value)) return 50;
42522
42537
  return Math.min(Math.max(value, 0), 100);
@@ -42657,15 +42672,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
42657
42672
  "socket.purl": toPurl(dependency)
42658
42673
  } }));
42659
42674
  const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
42660
- const buildLowScoreDiagnostic = (dependency, score, options) => {
42661
- const overall = toHundred(score.overall);
42675
+ const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
42662
42676
  const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
42663
42677
  return {
42664
42678
  filePath: "package.json",
42665
42679
  plugin: SUPPLY_CHAIN_PLUGIN,
42666
42680
  rule: SUPPLY_CHAIN_RULE,
42667
42681
  severity: options.severity,
42668
- message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket supply-chain score of ${overall}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
42682
+ message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
42669
42683
  help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
42670
42684
  url: packagePageUrl,
42671
42685
  line: dependency.line,
@@ -42700,7 +42714,9 @@ const collectSupplyChainScores = (input) => gen(function* () {
42700
42714
  * Scores every direct dependency in the project's `package.json` against
42701
42715
  * Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
42702
42716
  * uses — no API key) and returns a diagnostic for each dependency whose
42703
- * Socket `overall` score is below the configured `minScore`.
42717
+ * worst Socket *security* axis — supply chain or vulnerability — is below
42718
+ * the configured `minScore`. The quality / maintenance / license axes are
42719
+ * reported as context but never gate (see GATED_AXES).
42704
42720
  *
42705
42721
  * Lookups run with bounded concurrency via `Effect.forEach`. The check is
42706
42722
  * total/fail-open: each per-package lookup already recovers to `null`
@@ -42718,8 +42734,9 @@ const checkSupplyChain = (input) => gen(function* () {
42718
42734
  for (let index = 0; index < dependencies.length; index += 1) {
42719
42735
  const score = scores[index];
42720
42736
  if (!score) continue;
42721
- if (toHundred(score.overall) >= options.minScore) continue;
42722
- diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, options));
42737
+ const worstAxis = worstGatedAxis(score);
42738
+ if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
42739
+ diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
42723
42740
  }
42724
42741
  return diagnostics;
42725
42742
  });
@@ -42727,7 +42744,8 @@ const checkSupplyChain = (input) => gen(function* () {
42727
42744
  * `SupplyChain` scores the project's direct dependencies against Socket.dev's
42728
42745
  * free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
42729
42746
  * (`sfw`) performs — and streams a diagnostic for each dependency whose
42730
- * Socket score falls below the configured `supplyChain.minScore`.
42747
+ * worst Socket security axis (supply chain or vulnerability) falls below
42748
+ * the configured `supplyChain.minScore`.
42731
42749
  *
42732
42750
  * Runs by default (one network request per dependency); the orchestrator
42733
42751
  * provides `layerOf([])` only when the user opts out via
@@ -43482,6 +43500,48 @@ const groupBy = (items, keyFn) => {
43482
43500
  * a 404. Gate the directive on this predicate.
43483
43501
  */
43484
43502
  const hasPublishedFixRecipe = (diagnostic) => diagnostic.plugin === "react-doctor" && Object.hasOwn(reactDoctorPlugin.rules, diagnostic.rule);
43503
+ const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
43504
+ const mergeIgnores = (baseIgnore, overrideIgnore) => {
43505
+ const mergedIgnore = {
43506
+ ...baseIgnore,
43507
+ ...overrideIgnore
43508
+ };
43509
+ if (baseIgnore.rules && overrideIgnore.rules) mergedIgnore.rules = unionValues(baseIgnore.rules, overrideIgnore.rules);
43510
+ if (baseIgnore.files && overrideIgnore.files) mergedIgnore.files = unionValues(baseIgnore.files, overrideIgnore.files);
43511
+ if (baseIgnore.tags && overrideIgnore.tags) mergedIgnore.tags = unionValues(baseIgnore.tags, overrideIgnore.tags);
43512
+ if (baseIgnore.overrides && overrideIgnore.overrides) mergedIgnore.overrides = [...baseIgnore.overrides, ...overrideIgnore.overrides];
43513
+ return mergedIgnore;
43514
+ };
43515
+ /**
43516
+ * Layer one `ReactDoctorConfig` on top of another, additively: `rules` /
43517
+ * `categories` / `supplyChain` merge per key, `ignore` lists union
43518
+ * (`ignore.overrides` concatenate), and every other field is a scalar the
43519
+ * override simply wins on when set. Returns the base unchanged when there
43520
+ * is no override, and vice versa — so callers can thread `null` /
43521
+ * `undefined` through without special-casing.
43522
+ */
43523
+ const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
43524
+ if (overrideConfig === void 0) return baseConfig;
43525
+ if (baseConfig === null) return overrideConfig;
43526
+ const mergedConfig = {
43527
+ ...baseConfig,
43528
+ ...overrideConfig
43529
+ };
43530
+ if (baseConfig.rules && overrideConfig.rules) mergedConfig.rules = {
43531
+ ...baseConfig.rules,
43532
+ ...overrideConfig.rules
43533
+ };
43534
+ if (baseConfig.categories && overrideConfig.categories) mergedConfig.categories = {
43535
+ ...baseConfig.categories,
43536
+ ...overrideConfig.categories
43537
+ };
43538
+ if (baseConfig.supplyChain && overrideConfig.supplyChain) mergedConfig.supplyChain = {
43539
+ ...baseConfig.supplyChain,
43540
+ ...overrideConfig.supplyChain
43541
+ };
43542
+ if (baseConfig.ignore && overrideConfig.ignore) mergedConfig.ignore = mergeIgnores(baseConfig.ignore, overrideConfig.ignore);
43543
+ return mergedConfig;
43544
+ };
43485
43545
  //#endregion
43486
43546
  //#region src/cli/utils/is-ci-environment.ts
43487
43547
  const CI_ENVIRONMENT_VARIABLES = [
@@ -43590,6 +43650,8 @@ const METRIC = {
43590
43650
  cliInvoked: "cli.invoked",
43591
43651
  cliError: "cli.error",
43592
43652
  projectDetected: "project.detected",
43653
+ projectPathSelected: "project.path_selected",
43654
+ projectConfigSelected: "project.config_selected",
43593
43655
  scanCompleted: "scan.completed",
43594
43656
  scanDuration: "scan.duration",
43595
43657
  scanPhaseDuration: "scan.phase_duration",
@@ -43659,7 +43721,7 @@ const makeNoopConsole = () => ({
43659
43721
  });
43660
43722
  //#endregion
43661
43723
  //#region src/cli/utils/version.ts
43662
- const VERSION = "0.5.1-dev.2f26228";
43724
+ const VERSION = "0.5.1-dev.7c88165";
43663
43725
  //#endregion
43664
43726
  //#region src/cli/utils/json-mode.ts
43665
43727
  let context = null;
@@ -44017,13 +44079,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
44017
44079
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
44018
44080
  * standard `SENTRY_RELEASE` override.
44019
44081
  */
44020
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.2f26228`;
44082
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.7c88165`;
44021
44083
  /**
44022
44084
  * Deployment environment shown in Sentry's environment filter. Defaults to
44023
44085
  * `production` for tagged releases and `development` for dev/unbuilt versions,
44024
44086
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
44025
44087
  */
44026
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.2f26228") ? "development" : "production");
44088
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.7c88165") ? "development" : "production");
44027
44089
  /**
44028
44090
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
44029
44091
  * (set to `0` to disable tracing) and falls back to
@@ -47321,12 +47383,13 @@ const toSpanAttributes = (tags) => {
47321
47383
  /**
47322
47384
  * Clears the module-level run-scoped Sentry state — the current scanned project
47323
47385
  * and the active run trace. `inspect()` calls this at the start of every run and
47324
- * again after a clean one (it's invoked once per project in a workspace scan),
47325
- * so a prior or just-finished scan can't attach its project tags / trace to a
47326
- * later run or to a non-scan error (e.g. inspectAction's post-loop
47327
- * finalize/handoff steps). A thrown scan error skips the post-run reset, leaving
47328
- * the state for the command catch to attribute and link the crash. Safe to call
47329
- * when Sentry is off (the refs are read only when an event is built).
47386
+ * again after a clean one, so a prior or just-finished scan can't attach its
47387
+ * project tags / trace to a later run or to a non-scan error (e.g.
47388
+ * inspectAction's post-loop finalize/handoff steps). A thrown scan error skips
47389
+ * the post-run reset, leaving the state for the command catch to attribute and
47390
+ * link the crash. Concurrent batch members (`concurrentScan`) never touch this
47391
+ * state — they neither write nor reset it. Safe to call when Sentry is off (the
47392
+ * refs are read only when an event is built).
47330
47393
  */
47331
47394
  const resetSentryRunState = () => {
47332
47395
  setSentryProjectInfo(null);
@@ -47349,8 +47412,13 @@ const resetSentryRunState = () => {
47349
47412
  * state right after a clean run and at the start of the next one, so the trace
47350
47413
  * is never attached to a non-scan error; on a thrown error the state is left in
47351
47414
  * place for the command catch, then the process exits.
47415
+ *
47416
+ * A `concurrentScan` (one member of the CLI's multi-project pool) still gets
47417
+ * its own root span, but skips recording the active run trace — the module-
47418
+ * level handle has single-scan semantics, and overlapping writers would link a
47419
+ * crash to an arbitrary sibling's trace.
47352
47420
  */
47353
- const withSentryRunSpan = (run) => {
47421
+ const withSentryRunSpan = (run, options = {}) => {
47354
47422
  if (!isSentryTracingEnabled()) return run(void 0);
47355
47423
  const { tags } = buildSentryScope();
47356
47424
  const command = typeof tags.command === "string" ? tags.command : "inspect";
@@ -47359,12 +47427,14 @@ const withSentryRunSpan = (run) => {
47359
47427
  op: "cli.inspect",
47360
47428
  attributes: toSpanAttributes(tags)
47361
47429
  }, (rootSpan) => {
47362
- const spanContext = rootSpan.spanContext();
47363
- setActiveRunTrace({
47364
- traceId: spanContext.traceId,
47365
- spanId: spanContext.spanId,
47366
- sampled: (spanContext.traceFlags & 1) === 1
47367
- });
47430
+ if (options.concurrentScan !== true) {
47431
+ const spanContext = rootSpan.spanContext();
47432
+ setActiveRunTrace({
47433
+ traceId: spanContext.traceId,
47434
+ spanId: spanContext.spanId,
47435
+ sampled: (spanContext.traceFlags & 1) === 1
47436
+ });
47437
+ }
47368
47438
  return run(rootSpan);
47369
47439
  });
47370
47440
  };
@@ -47375,9 +47445,15 @@ const withSentryRunSpan = (run) => {
47375
47445
  * run's root span so the transaction/trace carries the project shape too.
47376
47446
  * Always cheap — the span attribute set is skipped when `rootSpan` is absent
47377
47447
  * (tracing off), and storing the info is a plain assignment.
47448
+ *
47449
+ * A `concurrentScan` only sets the span attributes: the module-level project
47450
+ * ref has single-scan semantics, and overlapping writers would stamp events
47451
+ * and metrics with an arbitrary sibling's project. Wide events keep full
47452
+ * attribution (they ride the span); per-emit metrics simply omit the project
47453
+ * shape during a concurrent batch (absent, never wrong).
47378
47454
  */
47379
- const recordSentryProjectContext = (projectInfo, rootSpan) => {
47380
- setSentryProjectInfo(projectInfo);
47455
+ const recordSentryProjectContext = (projectInfo, rootSpan, options = {}) => {
47456
+ if (options.concurrentScan !== true) setSentryProjectInfo(projectInfo);
47381
47457
  rootSpan?.setAttributes(toSpanAttributes(buildSentryProjectContext(projectInfo).tags));
47382
47458
  };
47383
47459
  //#endregion
@@ -47671,6 +47747,7 @@ const buildConfigAttributes = (input) => {
47671
47747
  noScore: input.noScore,
47672
47748
  respectInlineDisables: input.respectInlineDisables,
47673
47749
  showWarnings: input.showWarnings,
47750
+ usedOutputDir: input.usedOutputDir,
47674
47751
  ignoredTagCount: input.ignoredTagCount,
47675
47752
  hasCustomConfig: input.hasCustomConfig,
47676
47753
  rulesConfigured: ruleKeys.length,
@@ -48488,15 +48565,22 @@ const printNoScoreHeader = (noScoreMessage) => gen(function* () {
48488
48565
  });
48489
48566
  //#endregion
48490
48567
  //#region src/cli/utils/write-diagnostics-directory.ts
48491
- const writeDiagnosticsDirectory = (diagnostics) => {
48492
- const outputDirectory = Path.join(tmpdir(), `react-doctor-${randomUUID()}`);
48493
- NFS.mkdirSync(outputDirectory, { recursive: true });
48494
- for (const [ruleKey, ruleDiagnostics] of buildSortedRuleGroups(diagnostics)) {
48495
- const fileName = ruleKey.replace(/\//g, "--") + ".txt";
48496
- NFS.writeFileSync(Path.join(outputDirectory, fileName), formatRuleSummary(ruleKey, ruleDiagnostics));
48568
+ const ruleDumpFileName = (ruleKey) => ruleKey.replace(/\//g, "--") + ".txt";
48569
+ const readPreviousRuleDumpFileNames = (directory) => {
48570
+ try {
48571
+ const previous = JSON.parse(NFS.readFileSync(Path.join(directory, "diagnostics.json"), "utf8"));
48572
+ return new Set(previous.filter((d) => typeof d?.plugin === "string" && typeof d?.rule === "string").map((d) => ruleDumpFileName(`${d.plugin}/${d.rule}`)));
48573
+ } catch {
48574
+ return /* @__PURE__ */ new Set();
48497
48575
  }
48498
- NFS.writeFileSync(Path.join(outputDirectory, "diagnostics.json"), JSON.stringify(diagnostics));
48499
- return outputDirectory;
48576
+ };
48577
+ const writeDiagnosticsDirectory = (diagnostics, outputDirectory) => {
48578
+ const directory = outputDirectory ? Path.resolve(outputDirectory) : Path.join(tmpdir(), `react-doctor-${randomUUID()}`);
48579
+ if (outputDirectory) for (const fileName of readPreviousRuleDumpFileNames(directory)) NFS.rmSync(Path.join(directory, fileName), { force: true });
48580
+ NFS.mkdirSync(directory, { recursive: true });
48581
+ for (const [ruleKey, ruleDiagnostics] of buildSortedRuleGroups(diagnostics)) NFS.writeFileSync(Path.join(directory, ruleDumpFileName(ruleKey)), formatRuleSummary(ruleKey, ruleDiagnostics));
48582
+ NFS.writeFileSync(Path.join(directory, "diagnostics.json"), JSON.stringify(diagnostics));
48583
+ return directory;
48500
48584
  };
48501
48585
  //#endregion
48502
48586
  //#region src/cli/utils/render-summary.ts
@@ -48533,6 +48617,16 @@ const printFooter = (input) => gen(function* () {
48533
48617
  yield* log(` ${highlighter.bold("GitHub:")} ${highlighter.info(CANONICAL_GITHUB_URL)}`);
48534
48618
  yield* printFooterDescription("Report issues and star the repository!");
48535
48619
  });
48620
+ const printDiagnosticsDump = (diagnostics, outputDirectory, verbose, stream = "stdout") => gen(function* () {
48621
+ const writtenDirectory = yield* try_({
48622
+ try: () => writeDiagnosticsDirectory(diagnostics, outputDirectory),
48623
+ catch: (cause) => cause
48624
+ }).pipe(orElseSucceed(() => null));
48625
+ if (writtenDirectory !== null && (verbose || outputDirectory)) {
48626
+ const pathLine = highlighter.gray(` Full diagnostics written to ${writtenDirectory}`);
48627
+ yield* stream === "stderr" || Boolean(outputDirectory) && isJsonModeActive() ? sync(() => process.stderr.write(`${pathLine}\n`)) : log(pathLine);
48628
+ }
48629
+ });
48536
48630
  const printSummary = (input) => gen(function* () {
48537
48631
  if (input.scoreResult) {
48538
48632
  const animateProjection = Boolean(input.animateProjection) && input.potentialScore != null && !input.verbose;
@@ -48543,11 +48637,7 @@ const printSummary = (input) => gen(function* () {
48543
48637
  if (animateProjection) yield* animateScoreProjection(input.scoreResult, input.potentialScore, 5);
48544
48638
  }
48545
48639
  } else yield* printNoScoreHeader(input.noScoreMessage);
48546
- const diagnosticsDirectory = yield* try_({
48547
- try: () => writeDiagnosticsDirectory(input.diagnostics),
48548
- catch: (cause) => cause
48549
- }).pipe(orElseSucceed(() => null));
48550
- if (diagnosticsDirectory !== null && input.verbose) yield* log(highlighter.gray(` Full diagnostics written to ${diagnosticsDirectory}`));
48640
+ yield* printDiagnosticsDump(input.diagnostics, input.outputDirectory, input.verbose);
48551
48641
  });
48552
48642
  //#endregion
48553
48643
  //#region src/cli/utils/should-auto-select-current-choice.ts
@@ -48937,6 +49027,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
48937
49027
  lint: inputOptions.lint ?? userConfig?.lint ?? true,
48938
49028
  deadCode: inputOptions.deadCode ?? userConfig?.deadCode ?? true,
48939
49029
  verbose: inputOptions.verbose ?? userConfig?.verbose ?? false,
49030
+ outputDirectory: inputOptions.outputDirectory || null,
48940
49031
  scoreOnly: inputOptions.scoreOnly ?? false,
48941
49032
  noScore: inputOptions.noScore ?? userConfig?.noScore ?? false,
48942
49033
  isCi: inputOptions.isCi ?? false,
@@ -48953,6 +49044,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
48953
49044
  ignoredTags: buildIgnoredTags(userConfig),
48954
49045
  outputSurface: inputOptions.outputSurface ?? "cli",
48955
49046
  suppressRendering: inputOptions.suppressRendering ?? false,
49047
+ concurrentScan: inputOptions.concurrentScan ?? false,
48956
49048
  concurrency: inputOptions.concurrency,
48957
49049
  baseline: inputOptions.baseline ?? null,
48958
49050
  changedLineRanges: inputOptions.changedLineRanges ?? null,
@@ -48973,13 +49065,15 @@ const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
48973
49065
  noScore: options.noScore,
48974
49066
  respectInlineDisables: options.respectInlineDisables,
48975
49067
  showWarnings: options.warnings,
49068
+ usedOutputDir: options.outputDirectory !== null,
48976
49069
  ignoredTagCount: options.ignoredTags.size,
48977
49070
  hasCustomConfig,
48978
49071
  userConfig
48979
49072
  });
48980
49073
  const inspect = async (directory, inputOptions = {}) => {
48981
49074
  const startTime = performance$1.now();
48982
- resetSentryRunState();
49075
+ const isConcurrentScan = inputOptions.concurrentScan === true;
49076
+ if (!isConcurrentScan) resetSentryRunState();
48983
49077
  const hasConfigOverride = inputOptions.configOverride !== void 0;
48984
49078
  let scanDirectory;
48985
49079
  let userConfig;
@@ -48987,7 +49081,7 @@ const inspect = async (directory, inputOptions = {}) => {
48987
49081
  if (hasConfigOverride) {
48988
49082
  scanDirectory = directory;
48989
49083
  userConfig = inputOptions.configOverride ?? null;
48990
- configSourceDirectory = null;
49084
+ configSourceDirectory = inputOptions.configSourceDirectory ?? null;
48991
49085
  } else {
48992
49086
  const scanTarget = await resolveScanTarget(directory);
48993
49087
  scanDirectory = scanTarget.resolvedDirectory;
@@ -48995,8 +49089,9 @@ const inspect = async (directory, inputOptions = {}) => {
48995
49089
  configSourceDirectory = scanTarget.configSourceDirectory;
48996
49090
  }
48997
49091
  const options = mergeInspectOptions(inputOptions, userConfig);
49092
+ const ownsSpinnerSilence = options.silent && !isConcurrentScan;
48998
49093
  const wasSpinnerSilent = isSpinnerSilent();
48999
- if (options.silent) setSpinnerSilent(true);
49094
+ if (ownsSpinnerSilence) setSpinnerSilent(true);
49000
49095
  try {
49001
49096
  const result = await withSentryRunSpan(async (rootSentrySpan) => {
49002
49097
  try {
@@ -49009,11 +49104,11 @@ const inspect = async (directory, inputOptions = {}) => {
49009
49104
  });
49010
49105
  throw error;
49011
49106
  }
49012
- });
49013
- resetSentryRunState();
49107
+ }, { concurrentScan: isConcurrentScan });
49108
+ if (!isConcurrentScan) resetSentryRunState();
49014
49109
  return result;
49015
49110
  } finally {
49016
- if (options.silent) setSpinnerSilent(wasSpinnerSilent);
49111
+ if (ownsSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
49017
49112
  }
49018
49113
  };
49019
49114
  /**
@@ -49102,7 +49197,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
49102
49197
  const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
49103
49198
  const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
49104
49199
  if (cachedPayload) {
49105
- recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
49200
+ recordSentryProjectContext(cachedPayload.project, rootSentrySpan, { concurrentScan: options.concurrentScan });
49106
49201
  recordCount(METRIC.projectDetected, 1);
49107
49202
  await renderCachedProjectDetection({
49108
49203
  payload: cachedPayload,
@@ -49124,7 +49219,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
49124
49219
  recordOnboardingCompletion(options);
49125
49220
  return result;
49126
49221
  }
49127
- const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && options.lint && Boolean(resolvedNodeBinaryPath);
49222
+ const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && !options.suppressRendering && options.lint && Boolean(resolvedNodeBinaryPath);
49128
49223
  const layers = buildRuntimeLayers({
49129
49224
  directory,
49130
49225
  hasConfigOverride,
@@ -49153,7 +49248,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
49153
49248
  suppressScanSummary: options.suppressRendering,
49154
49249
  supplyChainManifestChanged: options.supplyChainManifestChanged
49155
49250
  }, { beforeLint: (projectInfo, lintIncludePaths) => gen(function* () {
49156
- recordSentryProjectContext(projectInfo, rootSentrySpan);
49251
+ recordSentryProjectContext(projectInfo, rootSentrySpan, { concurrentScan: options.concurrentScan });
49157
49252
  recordCount(METRIC.projectDetected, 1);
49158
49253
  if (options.scoreOnly || options.suppressRendering) return;
49159
49254
  const lintSourceFileCount = lintIncludePaths?.length ?? projectInfo.sourceFileCount;
@@ -49303,15 +49398,16 @@ const finalizeAndRender = (input) => gen(function* () {
49303
49398
  ...baselineDelta ? { baselineDelta } : {}
49304
49399
  });
49305
49400
  if (options.suppressRendering) return buildResult();
49401
+ const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
49402
+ const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
49306
49403
  if (options.scoreOnly) {
49404
+ if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory, false, "stderr");
49307
49405
  if (score) yield* log(`${score.score}`);
49308
- else yield* log(highlighter.gray(noScoreMessage));
49406
+ else yield* error$1(highlighter.gray(noScoreMessage));
49309
49407
  return buildResult();
49310
49408
  }
49311
49409
  const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
49312
49410
  const pause = onboardingSectionPause(animateRender);
49313
- const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
49314
- const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
49315
49411
  const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
49316
49412
  const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
49317
49413
  if (printedDiagnostics.length === 0) {
@@ -49329,6 +49425,7 @@ const finalizeAndRender = (input) => gen(function* () {
49329
49425
  yield* log(highlighter.gray(" Score not shown — some checks could not complete."));
49330
49426
  } else if (score) yield* printScoreHeader(score);
49331
49427
  else yield* printNoScoreHeader(noScoreMessage);
49428
+ if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory);
49332
49429
  return buildResult();
49333
49430
  }
49334
49431
  yield* pause;
@@ -49353,6 +49450,7 @@ const finalizeAndRender = (input) => gen(function* () {
49353
49450
  totalSourceFileCount: lintSourceFileCount,
49354
49451
  noScoreMessage,
49355
49452
  verbose: options.verbose,
49453
+ outputDirectory: options.outputDirectory,
49356
49454
  animateProjection: animateRender
49357
49455
  });
49358
49456
  if (hasSkippedChecks) {
@@ -49524,9 +49622,9 @@ const isExpectedUserError = (error) => error instanceof CliInputError || isProje
49524
49622
  //#region src/cli/utils/build-handoff-payload.ts
49525
49623
  const buildHandoffPayload = (input) => {
49526
49624
  const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
49527
- let diagnosticsDirectory = null;
49625
+ let outputDirectory = null;
49528
49626
  try {
49529
- diagnosticsDirectory = writeDiagnosticsDirectory([...input.diagnostics]);
49627
+ outputDirectory = writeDiagnosticsDirectory([...input.diagnostics], input.outputDirectory);
49530
49628
  } catch {}
49531
49629
  const lines = [
49532
49630
  "Before fixing anything, first ask me whether I'd like to add React Doctor to CI so every pull request is scanned automatically. Explain that:",
@@ -49553,7 +49651,7 @@ const buildHandoffPayload = (input) => {
49553
49651
  if (remainingFiles > 0) lines.push(` - +${remainingFiles} more files`);
49554
49652
  });
49555
49653
  lines.push("");
49556
- if (diagnosticsDirectory) lines.push(`Full results for all ${input.diagnostics.length} issues (diagnostics.json + a .txt per rule): ${diagnosticsDirectory}`, "");
49654
+ if (outputDirectory) lines.push(`Full results for all ${input.diagnostics.length} issues (diagnostics.json + a .txt per rule): ${outputDirectory}`, "");
49557
49655
  lines.push("Read each file and fix the root cause — don't suppress or silence the rule.", "", "Verify against the real thing, don't assume: confirm each change matches the canonical fix recipe you fetched for that rule, then re-run `npx react-doctor@latest --verbose` and check the issue is actually gone against the real tool before moving on.", "", "Teach me as you go: for every issue you touch, explain it in plain language (no jargon) — what the problem is, why it's a problem, and how serious it is in human terms. Describe the real-world impact and severity concretely (e.g. \"this crashes the page for users on Safari\" vs. \"this is a minor cleanup with no user impact\") so I understand why it matters, not just what changed.", "", "Then work through the rest from the full results above.");
49558
49656
  return lines.join("\n");
49559
49657
  };
@@ -51452,7 +51550,8 @@ const handoffToAgent = async (input) => {
51452
51550
  if (handoffTarget === void 0 || handoffTarget === SKIP_CHOICE) return;
51453
51551
  const payload = buildHandoffPayload({
51454
51552
  diagnostics: input.diagnostics,
51455
- projectName: input.projectName
51553
+ projectName: input.projectName,
51554
+ outputDirectory: input.outputDirectory
51456
51555
  });
51457
51556
  if (handoffTarget === CLIPBOARD_CHOICE) {
51458
51557
  if (await copyToClipboard(payload)) cliLogger.log("Copied the prompt to your clipboard.");
@@ -51673,6 +51772,9 @@ const readChangedFilesFrom = (filePath) => {
51673
51772
  return [...uniqueFiles];
51674
51773
  };
51675
51774
  //#endregion
51775
+ //#region src/cli/utils/filter-scans-for-surface.ts
51776
+ const filterScansForSurface = (completedScans, surface) => completedScans.flatMap((scan) => filterDiagnosticsForSurface([...scan.result.diagnostics], surface, scan.config));
51777
+ //#endregion
51676
51778
  //#region src/cli/utils/render-multi-project-summary.ts
51677
51779
  const getScoreLabel = (score) => {
51678
51780
  if (score >= 75) return "Great";
@@ -51700,10 +51802,10 @@ const findLowestScoredScan = (completedScans) => {
51700
51802
  return scoredScans.reduce((worst, scan) => scan.result.score.score < worst.result.score.score ? scan : worst);
51701
51803
  };
51702
51804
  const printMultiProjectSummary = (input) => gen(function* () {
51703
- const { completedScans, userConfig, verbose, isOffline, projectName } = input;
51805
+ const { completedScans, verbose, isOffline, projectName, totalElapsedMilliseconds } = input;
51704
51806
  const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
51705
51807
  const animateRender = !verbose && canAnimateOnboarding(process.stdout);
51706
- const displayDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(completedScans.flatMap((scan) => scan.result.diagnostics), "cli", userConfig), categoryFilters);
51808
+ const displayDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, "cli"), categoryFilters);
51707
51809
  const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
51708
51810
  for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
51709
51811
  const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
@@ -51715,8 +51817,7 @@ const printMultiProjectSummary = (input) => gen(function* () {
51715
51817
  else fileCountFromScansWithoutPaths += scan.result.scannedFileCount ?? scan.result.project.sourceFileCount;
51716
51818
  }
51717
51819
  const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
51718
- const totalScanElapsedMilliseconds = completedScans.reduce((sum, scan) => sum + (scan.result.scanElapsedMilliseconds ?? scan.result.elapsedMilliseconds), 0);
51719
- yield* log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalScanElapsedMilliseconds)}`);
51820
+ yield* log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalElapsedMilliseconds)}`);
51720
51821
  if (displayDiagnostics.length > 0) {
51721
51822
  yield* log("");
51722
51823
  yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
@@ -51726,16 +51827,17 @@ const printMultiProjectSummary = (input) => gen(function* () {
51726
51827
  const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
51727
51828
  yield* printSummary({
51728
51829
  diagnostics: displayDiagnostics,
51729
- elapsedMilliseconds: completedScans.reduce((sum, scan) => sum + scan.result.elapsedMilliseconds, 0),
51830
+ elapsedMilliseconds: totalElapsedMilliseconds,
51730
51831
  scoreResult: aggregateScore,
51731
- potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics, filterDiagnosticsForSurface(lowestScoredScan.result.diagnostics, "cli", userConfig), lowestScoredScan.result.score)) : null,
51832
+ potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics, filterScansForSurface([lowestScoredScan], "cli"), lowestScoredScan.result.score)) : null,
51732
51833
  totalSourceFileCount,
51733
51834
  noScoreMessage: "Score unavailable.",
51734
51835
  verbose,
51836
+ outputDirectory: input.outputDirectory,
51735
51837
  animateProjection: animateRender
51736
51838
  });
51737
51839
  const entries = completedScans.map((scan) => {
51738
- const projectDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface([...scan.result.diagnostics], "cli", userConfig), categoryFilters);
51840
+ const projectDiagnostics = filterDiagnosticsByCategories(filterScansForSurface([scan], "cli"), categoryFilters);
51739
51841
  const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
51740
51842
  return {
51741
51843
  projectName: scan.result.project.projectName,
@@ -51832,6 +51934,7 @@ const resolveCliInspectOptions = (flags, userConfig) => {
51832
51934
  lint: flags.lint,
51833
51935
  deadCode: flags.deadCode,
51834
51936
  verbose: flags.verbose,
51937
+ outputDirectory: flags.outputDir,
51835
51938
  respectInlineDisables: flags.respectInlineDisables === false ? false : void 0,
51836
51939
  warnings: wantsWarningGate ? true : flags.warnings,
51837
51940
  scoreOnly: flags.score === true,
@@ -52081,16 +52184,22 @@ const parseFileLineArgument = (rawArgument) => {
52081
52184
  };
52082
52185
  //#endregion
52083
52186
  //#region src/cli/utils/select-projects.ts
52084
- const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
52187
+ const selectProjects = async (rootDirectory, projectFlag, skipPrompts, configProjects) => {
52085
52188
  const hasRootPackageJson = isFile(Path.join(rootDirectory, "package.json"));
52086
52189
  let packages = listWorkspacePackages(rootDirectory);
52087
52190
  if (packages.length === 0 && (!hasRootPackageJson || isMonorepoRoot(rootDirectory))) packages = discoverReactSubprojects(rootDirectory);
52191
+ if (projectFlag) return resolveProjectFlag(projectFlag, packages, rootDirectory);
52192
+ const configRequestedNames = (configProjects ?? []).map((requestedName) => requestedName.trim()).filter((requestedName) => requestedName.length > 0);
52193
+ if (configRequestedNames.length > 0) {
52194
+ const resolvedDirectories = resolveRequestedProjects(configRequestedNames, packages, rootDirectory, "config");
52195
+ recordCount(METRIC.projectConfigSelected, resolvedDirectories.length);
52196
+ return resolvedDirectories;
52197
+ }
52088
52198
  if (packages.length === 0) return [rootDirectory];
52089
52199
  if (packages.length === 1) {
52090
52200
  cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages[0].name}`);
52091
52201
  return [packages[0].directory];
52092
52202
  }
52093
- if (projectFlag) return resolveProjectFlag(projectFlag, packages);
52094
52203
  if (skipPrompts) {
52095
52204
  printDiscoveredProjects(packages);
52096
52205
  return packages.map((workspacePackage) => workspacePackage.directory);
@@ -52098,17 +52207,25 @@ const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
52098
52207
  return promptProjectSelection(packages, rootDirectory);
52099
52208
  };
52100
52209
  const ALL_PROJECTS_SENTINEL = "*";
52101
- const resolveProjectFlag = (projectFlag, workspacePackages) => {
52210
+ const resolveProjectFlag = (projectFlag, workspacePackages, rootDirectory) => {
52102
52211
  const requestedNames = projectFlag.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
52103
52212
  if (requestedNames.length === 0) throw new CliInputError(`--project "${projectFlag}" did not name any project. Pass a project name, a comma-separated list, or "*" for all.`);
52104
- if (requestedNames.includes(ALL_PROJECTS_SENTINEL)) return workspacePackages.map((workspacePackage) => workspacePackage.directory);
52105
- const resolvedDirectories = [];
52106
- for (const requestedName of requestedNames) {
52213
+ return resolveRequestedProjects(requestedNames, workspacePackages, rootDirectory, "flag");
52214
+ };
52215
+ const resolveRequestedProjects = (requestedNames, workspacePackages, rootDirectory, source) => {
52216
+ if (requestedNames.includes(ALL_PROJECTS_SENTINEL)) return workspacePackages.length > 0 ? workspacePackages.map((workspacePackage) => workspacePackage.directory) : [rootDirectory];
52217
+ const sourceLabel = source === "flag" ? "Project" : "Config \"projects\" entry";
52218
+ return requestedNames.map((requestedName) => {
52107
52219
  const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || Path.basename(workspacePackage.directory) === requestedName);
52108
- if (!matched) throw new CliInputError(`Project "${requestedName}" not found. Available: ${workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
52109
- resolvedDirectories.push(matched.directory);
52110
- }
52111
- return resolvedDirectories;
52220
+ if (matched) return matched.directory;
52221
+ const candidateDirectory = Path.resolve(rootDirectory, requestedName);
52222
+ if (isDirectory(candidateDirectory)) {
52223
+ recordCount(METRIC.projectPathSelected);
52224
+ return candidateDirectory;
52225
+ }
52226
+ const availableNames = workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ");
52227
+ throw new CliInputError(workspacePackages.length > 0 ? `${sourceLabel} "${requestedName}" is not a workspace project or a directory. Available projects: ${availableNames}` : `${sourceLabel} "${requestedName}" is not a directory under ${rootDirectory}.`);
52228
+ });
52112
52229
  };
52113
52230
  const printDiscoveredProjects = (packages) => {
52114
52231
  cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
@@ -52303,7 +52420,7 @@ const finalizeScans = (input) => {
52303
52420
  }));
52304
52421
  }
52305
52422
  if (input.isScoreOnly || baselineDegraded) return;
52306
- if (shouldBlockCi(filterDiagnosticsForSurface(input.diagnostics, "ciFailure", input.userConfig), resolveBlockingLevel(input.flags, input.userConfig))) process.exitCode = 1;
52423
+ if (shouldBlockCi(filterScansForSurface(input.completedScans, "ciFailure"), resolveBlockingLevel(input.flags, input.userConfig))) process.exitCode = 1;
52307
52424
  };
52308
52425
  const buildChangedFilesDiffInfo = (changedFiles) => ({
52309
52426
  currentBranch: process.env.GITHUB_HEAD_REF?.trim() || null,
@@ -52436,7 +52553,6 @@ const inspectAction = async (directory, flags) => {
52436
52553
  filePath: Path.isAbsolute(diagnostic.filePath) ? diagnostic.filePath.replaceAll(snapshot.tempDirectory, () => resolvedDirectory) : diagnostic.filePath
52437
52554
  }));
52438
52555
  finalizeScans({
52439
- diagnostics: remappedDiagnostics,
52440
52556
  completedScans: [{
52441
52557
  directory: resolvedDirectory,
52442
52558
  result: {
@@ -52446,7 +52562,8 @@ const inspectAction = async (directory, flags) => {
52446
52562
  ...scanResult.project,
52447
52563
  rootDirectory: resolvedDirectory
52448
52564
  }
52449
- }
52565
+ },
52566
+ config: userConfig
52450
52567
  }],
52451
52568
  mode: "staged",
52452
52569
  diff: null,
@@ -52464,7 +52581,7 @@ const inspectAction = async (directory, flags) => {
52464
52581
  }
52465
52582
  return;
52466
52583
  }
52467
- const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
52584
+ const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts, userConfig?.projects);
52468
52585
  const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
52469
52586
  const requestedScope = resolveScope(flags, userConfig);
52470
52587
  const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
@@ -52502,56 +52619,87 @@ const inspectAction = async (directory, flags) => {
52502
52619
  }
52503
52620
  cliLogger.break();
52504
52621
  }
52505
- const allDiagnostics = [];
52506
52622
  const completedScans = [];
52507
52623
  const isMultiProject = projectDirectories.length > 1;
52508
- const supplyChainEnabled = userConfig?.supplyChain?.enabled !== false;
52509
- for (const projectDirectory of projectDirectories) {
52624
+ const scanProject = async (projectDirectory) => {
52625
+ const projectScanTarget = projectDirectory === resolvedDirectory ? scanTarget : await resolveScanTarget(projectDirectory, { allowAmbiguous: true });
52626
+ const scanDirectory = projectScanTarget.resolvedDirectory;
52627
+ const projectConfig = projectDirectory === resolvedDirectory ? userConfig : mergeReactDoctorConfigs(userConfig, projectScanTarget.userConfig ?? void 0);
52628
+ const projectConfigSourceDirectory = projectScanTarget.userConfig?.plugins === void 0 ? scanTarget.configSourceDirectory : projectScanTarget.configSourceDirectory;
52629
+ const supplyChainEnabled = projectConfig?.supplyChain?.enabled !== false;
52510
52630
  let includePaths;
52511
52631
  let supplyChainManifestChanged = false;
52512
52632
  if (isDiffMode) {
52513
- const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory, projectDirectory, diffInfo);
52514
- supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory, projectDirectory, diffInfo);
52633
+ const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory, scanDirectory, diffInfo);
52634
+ supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory, scanDirectory, diffInfo);
52515
52635
  if (changedSourceFiles.length === 0 && !supplyChainManifestChanged) {
52516
52636
  if (!isQuiet) {
52517
- cliLogger.dim(`No changed source files in ${projectDirectory}, skipping.`);
52637
+ cliLogger.dim(`No changed source files in ${scanDirectory}, skipping.`);
52518
52638
  cliLogger.break();
52519
52639
  }
52520
- continue;
52640
+ return null;
52521
52641
  }
52522
52642
  includePaths = [...changedSourceFiles];
52523
52643
  if (supplyChainManifestChanged) includePaths.push("package.json");
52524
52644
  }
52525
52645
  if (!isQuiet && !isMultiProject) cliLogger.dim(" ");
52526
- const scanResult = await inspect(projectDirectory, {
52646
+ const scanResult = await inspect(scanDirectory, {
52527
52647
  ...scanOptions,
52528
52648
  includePaths,
52529
- configOverride: userConfig,
52649
+ configOverride: projectConfig,
52650
+ configSourceDirectory: projectConfigSourceDirectory ?? void 0,
52530
52651
  suppressRendering: isMultiProject,
52652
+ concurrentScan: isMultiProject,
52531
52653
  baseline: baselineRef ? { ref: baselineRef } : void 0,
52532
- changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, projectDirectory, changedLineRanges) : void 0,
52654
+ changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, scanDirectory, changedLineRanges) : void 0,
52533
52655
  supplyChainManifestChanged
52534
52656
  });
52535
- allDiagnostics.push(...scanResult.diagnostics);
52536
- completedScans.push({
52537
- directory: projectDirectory,
52538
- result: scanResult
52539
- });
52540
52657
  if (!isQuiet && !isMultiProject) cliLogger.break();
52658
+ return {
52659
+ directory: scanDirectory,
52660
+ result: scanResult,
52661
+ config: projectConfig
52662
+ };
52663
+ };
52664
+ const scanLoopStartTime = performance$1.now();
52665
+ const projectCount = projectDirectories.length;
52666
+ const batchSpinner = isMultiProject && !isQuiet ? spinner(`Scanning ${projectCount} projects…`).start() : null;
52667
+ const ownsBatchSpinnerSilence = isMultiProject && scanOptions.silent === true;
52668
+ const wasSpinnerSilent = isSpinnerSilent();
52669
+ if (ownsBatchSpinnerSilence) setSpinnerSilent(true);
52670
+ let finishedProjectCount = 0;
52671
+ let scanOutcomes;
52672
+ try {
52673
+ scanOutcomes = await mapWithConcurrency(projectDirectories, isMultiProject ? 4 : 1, async (projectDirectory) => {
52674
+ const scanOutcome = await scanProject(projectDirectory);
52675
+ finishedProjectCount += 1;
52676
+ batchSpinner?.update(`Scanning ${projectCount} projects… (${finishedProjectCount}/${projectCount})`);
52677
+ return scanOutcome;
52678
+ });
52679
+ } finally {
52680
+ if (ownsBatchSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
52681
+ batchSpinner?.stop();
52682
+ }
52683
+ for (const scanOutcome of scanOutcomes) {
52684
+ if (scanOutcome === null) continue;
52685
+ completedScans.push(scanOutcome);
52541
52686
  }
52542
52687
  if (!isQuiet && isMultiProject && completedScans.length > 0) {
52543
52688
  const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
52544
52689
  await runPromise(printMultiProjectSummary({
52545
52690
  completedScans,
52546
52691
  categoryFilters,
52547
- userConfig,
52548
52692
  verbose: Boolean(flags.verbose),
52693
+ outputDirectory: flags.outputDir,
52549
52694
  isOffline: !shouldShowShareLink,
52550
- projectName: Path.basename(resolvedDirectory)
52695
+ projectName: Path.basename(resolvedDirectory),
52696
+ totalElapsedMilliseconds: performance$1.now() - scanLoopStartTime
52551
52697
  }));
52552
52698
  }
52699
+ const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, scanOptions.outputSurface ?? "cli"), categoryFilters);
52700
+ const didScansWriteDump = isMultiProject ? !isQuiet && completedScans.length > 0 : completedScans.length > 0;
52701
+ if (flags.outputDir && !didScansWriteDump) await runPromise(printDiagnosticsDump(selectedSurfaceDiagnostics, flags.outputDir, false, isQuiet ? "stderr" : "stdout"));
52553
52702
  finalizeScans({
52554
- diagnostics: allDiagnostics,
52555
52703
  completedScans,
52556
52704
  mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
52557
52705
  diff: isDiffMode ? diffInfo : null,
@@ -52564,13 +52712,13 @@ const inspectAction = async (directory, flags) => {
52564
52712
  resolvedDirectory,
52565
52713
  startTime
52566
52714
  });
52567
- const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
52568
52715
  if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
52569
52716
  await handoffToAgent({
52570
52717
  diagnostics: selectedSurfaceDiagnostics,
52571
52718
  projectName: Path.basename(resolvedDirectory),
52572
52719
  rootDirectory: resolvedDirectory,
52573
- interactive: true
52720
+ interactive: true,
52721
+ outputDirectory: flags.outputDir
52574
52722
  });
52575
52723
  return;
52576
52724
  }
@@ -53366,6 +53514,7 @@ const ROOT_FLAG_SPEC = {
53366
53514
  "--category",
53367
53515
  "--changed-files-from",
53368
53516
  "--blocking",
53517
+ "--output-dir",
53369
53518
  "--fail-on",
53370
53519
  "--project",
53371
53520
  "--scope"
@@ -53520,6 +53669,7 @@ ${formatExampleLines([
53520
53669
  ["react-doctor", "scan the current project"],
53521
53670
  ["react-doctor ./apps/web", "scan a specific directory"],
53522
53671
  ["react-doctor --diff main", "scan only files changed vs. main"],
53672
+ ["react-doctor --project modules/a,modules/b", "score each module separately (names or paths)"],
53523
53673
  ["react-doctor --staged", "scan staged files (pre-commit hook)"],
53524
53674
  ["react-doctor --category Security", "show only one diagnostic category"],
53525
53675
  ["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
@@ -53551,9 +53701,9 @@ ${highlighter.dim("Learn more:")}
53551
53701
  ${highlighter.info(CANONICAL_GITHUB_URL)}
53552
53702
  `;
53553
53703
  const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
53554
- 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("--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("--scope <value>", "how much to scan/report: full (default), files, changed (only new issues vs base), or lines (only changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).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("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).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("--sfw", "demo: print the Socket.dev supply-chain score of every direct dependency, then exit").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
53704
+ 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("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").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("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple); overrides the `projects` config field").option("--scope <value>", "how much to scan/report: full (default), files, changed (only new issues vs base), or lines (only changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).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("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).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("--sfw", "demo: print the Socket.dev supply-chain score of every direct dependency, then exit").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
53555
53705
  program.action(inspectAction);
53556
- program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select workspace project (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
53706
+ program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
53557
53707
  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);
53558
53708
  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);
53559
53709
  const rules = program.command("rules").description("List, explain, and configure which React Doctor rules run");
@@ -53594,4 +53744,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
53594
53744
  export {};
53595
53745
 
53596
53746
  //# sourceMappingURL=cli.js.map
53597
- //# debugId=4db91f1b-d88c-5feb-a6d7-b4b1a94b2537
53747
+ //# debugId=ecc7e4af-d176-5569-bc51-c3fbe220a76b