react-doctor 0.5.1-dev.038aaf7 → 0.5.1-dev.19d99ee

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]="60598d2a-66c7-5091-a013-028926866fbd")}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 {
@@ -43496,6 +43500,48 @@ const groupBy = (items, keyFn) => {
43496
43500
  * a 404. Gate the directive on this predicate.
43497
43501
  */
43498
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
+ };
43499
43545
  //#endregion
43500
43546
  //#region src/cli/utils/is-ci-environment.ts
43501
43547
  const CI_ENVIRONMENT_VARIABLES = [
@@ -43604,6 +43650,8 @@ const METRIC = {
43604
43650
  cliInvoked: "cli.invoked",
43605
43651
  cliError: "cli.error",
43606
43652
  projectDetected: "project.detected",
43653
+ projectPathSelected: "project.path_selected",
43654
+ projectConfigSelected: "project.config_selected",
43607
43655
  scanCompleted: "scan.completed",
43608
43656
  scanDuration: "scan.duration",
43609
43657
  scanPhaseDuration: "scan.phase_duration",
@@ -43673,7 +43721,7 @@ const makeNoopConsole = () => ({
43673
43721
  });
43674
43722
  //#endregion
43675
43723
  //#region src/cli/utils/version.ts
43676
- const VERSION = "0.5.1-dev.038aaf7";
43724
+ const VERSION = "0.5.1-dev.19d99ee";
43677
43725
  //#endregion
43678
43726
  //#region src/cli/utils/json-mode.ts
43679
43727
  let context = null;
@@ -44031,13 +44079,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
44031
44079
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
44032
44080
  * standard `SENTRY_RELEASE` override.
44033
44081
  */
44034
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.038aaf7`;
44082
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.19d99ee`;
44035
44083
  /**
44036
44084
  * Deployment environment shown in Sentry's environment filter. Defaults to
44037
44085
  * `production` for tagged releases and `development` for dev/unbuilt versions,
44038
44086
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
44039
44087
  */
44040
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.038aaf7") ? "development" : "production");
44088
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.19d99ee") ? "development" : "production");
44041
44089
  /**
44042
44090
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
44043
44091
  * (set to `0` to disable tracing) and falls back to
@@ -47335,12 +47383,13 @@ const toSpanAttributes = (tags) => {
47335
47383
  /**
47336
47384
  * Clears the module-level run-scoped Sentry state — the current scanned project
47337
47385
  * and the active run trace. `inspect()` calls this at the start of every run and
47338
- * again after a clean one (it's invoked once per project in a workspace scan),
47339
- * so a prior or just-finished scan can't attach its project tags / trace to a
47340
- * later run or to a non-scan error (e.g. inspectAction's post-loop
47341
- * finalize/handoff steps). A thrown scan error skips the post-run reset, leaving
47342
- * the state for the command catch to attribute and link the crash. Safe to call
47343
- * 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).
47344
47393
  */
47345
47394
  const resetSentryRunState = () => {
47346
47395
  setSentryProjectInfo(null);
@@ -47363,8 +47412,13 @@ const resetSentryRunState = () => {
47363
47412
  * state right after a clean run and at the start of the next one, so the trace
47364
47413
  * is never attached to a non-scan error; on a thrown error the state is left in
47365
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.
47366
47420
  */
47367
- const withSentryRunSpan = (run) => {
47421
+ const withSentryRunSpan = (run, options = {}) => {
47368
47422
  if (!isSentryTracingEnabled()) return run(void 0);
47369
47423
  const { tags } = buildSentryScope();
47370
47424
  const command = typeof tags.command === "string" ? tags.command : "inspect";
@@ -47373,12 +47427,14 @@ const withSentryRunSpan = (run) => {
47373
47427
  op: "cli.inspect",
47374
47428
  attributes: toSpanAttributes(tags)
47375
47429
  }, (rootSpan) => {
47376
- const spanContext = rootSpan.spanContext();
47377
- setActiveRunTrace({
47378
- traceId: spanContext.traceId,
47379
- spanId: spanContext.spanId,
47380
- sampled: (spanContext.traceFlags & 1) === 1
47381
- });
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
+ }
47382
47438
  return run(rootSpan);
47383
47439
  });
47384
47440
  };
@@ -47389,9 +47445,15 @@ const withSentryRunSpan = (run) => {
47389
47445
  * run's root span so the transaction/trace carries the project shape too.
47390
47446
  * Always cheap — the span attribute set is skipped when `rootSpan` is absent
47391
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).
47392
47454
  */
47393
- const recordSentryProjectContext = (projectInfo, rootSpan) => {
47394
- setSentryProjectInfo(projectInfo);
47455
+ const recordSentryProjectContext = (projectInfo, rootSpan, options = {}) => {
47456
+ if (options.concurrentScan !== true) setSentryProjectInfo(projectInfo);
47395
47457
  rootSpan?.setAttributes(toSpanAttributes(buildSentryProjectContext(projectInfo).tags));
47396
47458
  };
47397
47459
  //#endregion
@@ -47685,6 +47747,7 @@ const buildConfigAttributes = (input) => {
47685
47747
  noScore: input.noScore,
47686
47748
  respectInlineDisables: input.respectInlineDisables,
47687
47749
  showWarnings: input.showWarnings,
47750
+ usedOutputDir: input.usedOutputDir,
47688
47751
  ignoredTagCount: input.ignoredTagCount,
47689
47752
  hasCustomConfig: input.hasCustomConfig,
47690
47753
  rulesConfigured: ruleKeys.length,
@@ -48502,15 +48565,22 @@ const printNoScoreHeader = (noScoreMessage) => gen(function* () {
48502
48565
  });
48503
48566
  //#endregion
48504
48567
  //#region src/cli/utils/write-diagnostics-directory.ts
48505
- const writeDiagnosticsDirectory = (diagnostics) => {
48506
- const outputDirectory = Path.join(tmpdir(), `react-doctor-${randomUUID()}`);
48507
- NFS.mkdirSync(outputDirectory, { recursive: true });
48508
- for (const [ruleKey, ruleDiagnostics] of buildSortedRuleGroups(diagnostics)) {
48509
- const fileName = ruleKey.replace(/\//g, "--") + ".txt";
48510
- 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();
48511
48575
  }
48512
- NFS.writeFileSync(Path.join(outputDirectory, "diagnostics.json"), JSON.stringify(diagnostics));
48513
- 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;
48514
48584
  };
48515
48585
  //#endregion
48516
48586
  //#region src/cli/utils/render-summary.ts
@@ -48547,6 +48617,16 @@ const printFooter = (input) => gen(function* () {
48547
48617
  yield* log(` ${highlighter.bold("GitHub:")} ${highlighter.info(CANONICAL_GITHUB_URL)}`);
48548
48618
  yield* printFooterDescription("Report issues and star the repository!");
48549
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
+ });
48550
48630
  const printSummary = (input) => gen(function* () {
48551
48631
  if (input.scoreResult) {
48552
48632
  const animateProjection = Boolean(input.animateProjection) && input.potentialScore != null && !input.verbose;
@@ -48557,11 +48637,7 @@ const printSummary = (input) => gen(function* () {
48557
48637
  if (animateProjection) yield* animateScoreProjection(input.scoreResult, input.potentialScore, 5);
48558
48638
  }
48559
48639
  } else yield* printNoScoreHeader(input.noScoreMessage);
48560
- const diagnosticsDirectory = yield* try_({
48561
- try: () => writeDiagnosticsDirectory(input.diagnostics),
48562
- catch: (cause) => cause
48563
- }).pipe(orElseSucceed(() => null));
48564
- if (diagnosticsDirectory !== null && input.verbose) yield* log(highlighter.gray(` Full diagnostics written to ${diagnosticsDirectory}`));
48640
+ yield* printDiagnosticsDump(input.diagnostics, input.outputDirectory, input.verbose);
48565
48641
  });
48566
48642
  //#endregion
48567
48643
  //#region src/cli/utils/should-auto-select-current-choice.ts
@@ -48951,6 +49027,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
48951
49027
  lint: inputOptions.lint ?? userConfig?.lint ?? true,
48952
49028
  deadCode: inputOptions.deadCode ?? userConfig?.deadCode ?? true,
48953
49029
  verbose: inputOptions.verbose ?? userConfig?.verbose ?? false,
49030
+ outputDirectory: inputOptions.outputDirectory || null,
48954
49031
  scoreOnly: inputOptions.scoreOnly ?? false,
48955
49032
  noScore: inputOptions.noScore ?? userConfig?.noScore ?? false,
48956
49033
  isCi: inputOptions.isCi ?? false,
@@ -48967,6 +49044,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
48967
49044
  ignoredTags: buildIgnoredTags(userConfig),
48968
49045
  outputSurface: inputOptions.outputSurface ?? "cli",
48969
49046
  suppressRendering: inputOptions.suppressRendering ?? false,
49047
+ concurrentScan: inputOptions.concurrentScan ?? false,
48970
49048
  concurrency: inputOptions.concurrency,
48971
49049
  baseline: inputOptions.baseline ?? null,
48972
49050
  changedLineRanges: inputOptions.changedLineRanges ?? null,
@@ -48987,13 +49065,15 @@ const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
48987
49065
  noScore: options.noScore,
48988
49066
  respectInlineDisables: options.respectInlineDisables,
48989
49067
  showWarnings: options.warnings,
49068
+ usedOutputDir: options.outputDirectory !== null,
48990
49069
  ignoredTagCount: options.ignoredTags.size,
48991
49070
  hasCustomConfig,
48992
49071
  userConfig
48993
49072
  });
48994
49073
  const inspect = async (directory, inputOptions = {}) => {
48995
49074
  const startTime = performance$1.now();
48996
- resetSentryRunState();
49075
+ const isConcurrentScan = inputOptions.concurrentScan === true;
49076
+ if (!isConcurrentScan) resetSentryRunState();
48997
49077
  const hasConfigOverride = inputOptions.configOverride !== void 0;
48998
49078
  let scanDirectory;
48999
49079
  let userConfig;
@@ -49001,7 +49081,7 @@ const inspect = async (directory, inputOptions = {}) => {
49001
49081
  if (hasConfigOverride) {
49002
49082
  scanDirectory = directory;
49003
49083
  userConfig = inputOptions.configOverride ?? null;
49004
- configSourceDirectory = null;
49084
+ configSourceDirectory = inputOptions.configSourceDirectory ?? null;
49005
49085
  } else {
49006
49086
  const scanTarget = await resolveScanTarget(directory);
49007
49087
  scanDirectory = scanTarget.resolvedDirectory;
@@ -49009,8 +49089,9 @@ const inspect = async (directory, inputOptions = {}) => {
49009
49089
  configSourceDirectory = scanTarget.configSourceDirectory;
49010
49090
  }
49011
49091
  const options = mergeInspectOptions(inputOptions, userConfig);
49092
+ const ownsSpinnerSilence = options.silent && !isConcurrentScan;
49012
49093
  const wasSpinnerSilent = isSpinnerSilent();
49013
- if (options.silent) setSpinnerSilent(true);
49094
+ if (ownsSpinnerSilence) setSpinnerSilent(true);
49014
49095
  try {
49015
49096
  const result = await withSentryRunSpan(async (rootSentrySpan) => {
49016
49097
  try {
@@ -49023,11 +49104,11 @@ const inspect = async (directory, inputOptions = {}) => {
49023
49104
  });
49024
49105
  throw error;
49025
49106
  }
49026
- });
49027
- resetSentryRunState();
49107
+ }, { concurrentScan: isConcurrentScan });
49108
+ if (!isConcurrentScan) resetSentryRunState();
49028
49109
  return result;
49029
49110
  } finally {
49030
- if (options.silent) setSpinnerSilent(wasSpinnerSilent);
49111
+ if (ownsSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
49031
49112
  }
49032
49113
  };
49033
49114
  /**
@@ -49116,7 +49197,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
49116
49197
  const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
49117
49198
  const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
49118
49199
  if (cachedPayload) {
49119
- recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
49200
+ recordSentryProjectContext(cachedPayload.project, rootSentrySpan, { concurrentScan: options.concurrentScan });
49120
49201
  recordCount(METRIC.projectDetected, 1);
49121
49202
  await renderCachedProjectDetection({
49122
49203
  payload: cachedPayload,
@@ -49138,7 +49219,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
49138
49219
  recordOnboardingCompletion(options);
49139
49220
  return result;
49140
49221
  }
49141
- 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);
49142
49223
  const layers = buildRuntimeLayers({
49143
49224
  directory,
49144
49225
  hasConfigOverride,
@@ -49167,7 +49248,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
49167
49248
  suppressScanSummary: options.suppressRendering,
49168
49249
  supplyChainManifestChanged: options.supplyChainManifestChanged
49169
49250
  }, { beforeLint: (projectInfo, lintIncludePaths) => gen(function* () {
49170
- recordSentryProjectContext(projectInfo, rootSentrySpan);
49251
+ recordSentryProjectContext(projectInfo, rootSentrySpan, { concurrentScan: options.concurrentScan });
49171
49252
  recordCount(METRIC.projectDetected, 1);
49172
49253
  if (options.scoreOnly || options.suppressRendering) return;
49173
49254
  const lintSourceFileCount = lintIncludePaths?.length ?? projectInfo.sourceFileCount;
@@ -49317,15 +49398,16 @@ const finalizeAndRender = (input) => gen(function* () {
49317
49398
  ...baselineDelta ? { baselineDelta } : {}
49318
49399
  });
49319
49400
  if (options.suppressRendering) return buildResult();
49401
+ const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
49402
+ const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
49320
49403
  if (options.scoreOnly) {
49404
+ if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory, false, "stderr");
49321
49405
  if (score) yield* log(`${score.score}`);
49322
- else yield* log(highlighter.gray(noScoreMessage));
49406
+ else yield* error$1(highlighter.gray(noScoreMessage));
49323
49407
  return buildResult();
49324
49408
  }
49325
49409
  const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
49326
49410
  const pause = onboardingSectionPause(animateRender);
49327
- const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
49328
- const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
49329
49411
  const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
49330
49412
  const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
49331
49413
  if (printedDiagnostics.length === 0) {
@@ -49343,6 +49425,7 @@ const finalizeAndRender = (input) => gen(function* () {
49343
49425
  yield* log(highlighter.gray(" Score not shown — some checks could not complete."));
49344
49426
  } else if (score) yield* printScoreHeader(score);
49345
49427
  else yield* printNoScoreHeader(noScoreMessage);
49428
+ if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory);
49346
49429
  return buildResult();
49347
49430
  }
49348
49431
  yield* pause;
@@ -49367,6 +49450,7 @@ const finalizeAndRender = (input) => gen(function* () {
49367
49450
  totalSourceFileCount: lintSourceFileCount,
49368
49451
  noScoreMessage,
49369
49452
  verbose: options.verbose,
49453
+ outputDirectory: options.outputDirectory,
49370
49454
  animateProjection: animateRender
49371
49455
  });
49372
49456
  if (hasSkippedChecks) {
@@ -49538,9 +49622,9 @@ const isExpectedUserError = (error) => error instanceof CliInputError || isProje
49538
49622
  //#region src/cli/utils/build-handoff-payload.ts
49539
49623
  const buildHandoffPayload = (input) => {
49540
49624
  const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
49541
- let diagnosticsDirectory = null;
49625
+ let outputDirectory = null;
49542
49626
  try {
49543
- diagnosticsDirectory = writeDiagnosticsDirectory([...input.diagnostics]);
49627
+ outputDirectory = writeDiagnosticsDirectory([...input.diagnostics], input.outputDirectory);
49544
49628
  } catch {}
49545
49629
  const lines = [
49546
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:",
@@ -49567,7 +49651,7 @@ const buildHandoffPayload = (input) => {
49567
49651
  if (remainingFiles > 0) lines.push(` - +${remainingFiles} more files`);
49568
49652
  });
49569
49653
  lines.push("");
49570
- 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}`, "");
49571
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.");
49572
49656
  return lines.join("\n");
49573
49657
  };
@@ -51466,7 +51550,8 @@ const handoffToAgent = async (input) => {
51466
51550
  if (handoffTarget === void 0 || handoffTarget === SKIP_CHOICE) return;
51467
51551
  const payload = buildHandoffPayload({
51468
51552
  diagnostics: input.diagnostics,
51469
- projectName: input.projectName
51553
+ projectName: input.projectName,
51554
+ outputDirectory: input.outputDirectory
51470
51555
  });
51471
51556
  if (handoffTarget === CLIPBOARD_CHOICE) {
51472
51557
  if (await copyToClipboard(payload)) cliLogger.log("Copied the prompt to your clipboard.");
@@ -51687,6 +51772,9 @@ const readChangedFilesFrom = (filePath) => {
51687
51772
  return [...uniqueFiles];
51688
51773
  };
51689
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
51690
51778
  //#region src/cli/utils/render-multi-project-summary.ts
51691
51779
  const getScoreLabel = (score) => {
51692
51780
  if (score >= 75) return "Great";
@@ -51714,10 +51802,10 @@ const findLowestScoredScan = (completedScans) => {
51714
51802
  return scoredScans.reduce((worst, scan) => scan.result.score.score < worst.result.score.score ? scan : worst);
51715
51803
  };
51716
51804
  const printMultiProjectSummary = (input) => gen(function* () {
51717
- const { completedScans, userConfig, verbose, isOffline, projectName } = input;
51805
+ const { completedScans, verbose, isOffline, projectName, totalElapsedMilliseconds } = input;
51718
51806
  const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
51719
51807
  const animateRender = !verbose && canAnimateOnboarding(process.stdout);
51720
- const displayDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(completedScans.flatMap((scan) => scan.result.diagnostics), "cli", userConfig), categoryFilters);
51808
+ const displayDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, "cli"), categoryFilters);
51721
51809
  const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
51722
51810
  for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
51723
51811
  const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
@@ -51729,8 +51817,7 @@ const printMultiProjectSummary = (input) => gen(function* () {
51729
51817
  else fileCountFromScansWithoutPaths += scan.result.scannedFileCount ?? scan.result.project.sourceFileCount;
51730
51818
  }
51731
51819
  const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
51732
- const totalScanElapsedMilliseconds = completedScans.reduce((sum, scan) => sum + (scan.result.scanElapsedMilliseconds ?? scan.result.elapsedMilliseconds), 0);
51733
- 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)}`);
51734
51821
  if (displayDiagnostics.length > 0) {
51735
51822
  yield* log("");
51736
51823
  yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
@@ -51740,16 +51827,17 @@ const printMultiProjectSummary = (input) => gen(function* () {
51740
51827
  const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
51741
51828
  yield* printSummary({
51742
51829
  diagnostics: displayDiagnostics,
51743
- elapsedMilliseconds: completedScans.reduce((sum, scan) => sum + scan.result.elapsedMilliseconds, 0),
51830
+ elapsedMilliseconds: totalElapsedMilliseconds,
51744
51831
  scoreResult: aggregateScore,
51745
- 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,
51746
51833
  totalSourceFileCount,
51747
51834
  noScoreMessage: "Score unavailable.",
51748
51835
  verbose,
51836
+ outputDirectory: input.outputDirectory,
51749
51837
  animateProjection: animateRender
51750
51838
  });
51751
51839
  const entries = completedScans.map((scan) => {
51752
- const projectDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface([...scan.result.diagnostics], "cli", userConfig), categoryFilters);
51840
+ const projectDiagnostics = filterDiagnosticsByCategories(filterScansForSurface([scan], "cli"), categoryFilters);
51753
51841
  const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
51754
51842
  return {
51755
51843
  projectName: scan.result.project.projectName,
@@ -51846,6 +51934,7 @@ const resolveCliInspectOptions = (flags, userConfig) => {
51846
51934
  lint: flags.lint,
51847
51935
  deadCode: flags.deadCode,
51848
51936
  verbose: flags.verbose,
51937
+ outputDirectory: flags.outputDir,
51849
51938
  respectInlineDisables: flags.respectInlineDisables === false ? false : void 0,
51850
51939
  warnings: wantsWarningGate ? true : flags.warnings,
51851
51940
  scoreOnly: flags.score === true,
@@ -52095,16 +52184,22 @@ const parseFileLineArgument = (rawArgument) => {
52095
52184
  };
52096
52185
  //#endregion
52097
52186
  //#region src/cli/utils/select-projects.ts
52098
- const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
52187
+ const selectProjects = async (rootDirectory, projectFlag, skipPrompts, configProjects) => {
52099
52188
  const hasRootPackageJson = isFile(Path.join(rootDirectory, "package.json"));
52100
52189
  let packages = listWorkspacePackages(rootDirectory);
52101
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
+ }
52102
52198
  if (packages.length === 0) return [rootDirectory];
52103
52199
  if (packages.length === 1) {
52104
52200
  cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages[0].name}`);
52105
52201
  return [packages[0].directory];
52106
52202
  }
52107
- if (projectFlag) return resolveProjectFlag(projectFlag, packages);
52108
52203
  if (skipPrompts) {
52109
52204
  printDiscoveredProjects(packages);
52110
52205
  return packages.map((workspacePackage) => workspacePackage.directory);
@@ -52112,17 +52207,25 @@ const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
52112
52207
  return promptProjectSelection(packages, rootDirectory);
52113
52208
  };
52114
52209
  const ALL_PROJECTS_SENTINEL = "*";
52115
- const resolveProjectFlag = (projectFlag, workspacePackages) => {
52210
+ const resolveProjectFlag = (projectFlag, workspacePackages, rootDirectory) => {
52116
52211
  const requestedNames = projectFlag.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
52117
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.`);
52118
- if (requestedNames.includes(ALL_PROJECTS_SENTINEL)) return workspacePackages.map((workspacePackage) => workspacePackage.directory);
52119
- const resolvedDirectories = [];
52120
- 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) => {
52121
52219
  const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || Path.basename(workspacePackage.directory) === requestedName);
52122
- if (!matched) throw new CliInputError(`Project "${requestedName}" not found. Available: ${workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
52123
- resolvedDirectories.push(matched.directory);
52124
- }
52125
- 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
+ });
52126
52229
  };
52127
52230
  const printDiscoveredProjects = (packages) => {
52128
52231
  cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
@@ -52317,7 +52420,7 @@ const finalizeScans = (input) => {
52317
52420
  }));
52318
52421
  }
52319
52422
  if (input.isScoreOnly || baselineDegraded) return;
52320
- 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;
52321
52424
  };
52322
52425
  const buildChangedFilesDiffInfo = (changedFiles) => ({
52323
52426
  currentBranch: process.env.GITHUB_HEAD_REF?.trim() || null,
@@ -52450,7 +52553,6 @@ const inspectAction = async (directory, flags) => {
52450
52553
  filePath: Path.isAbsolute(diagnostic.filePath) ? diagnostic.filePath.replaceAll(snapshot.tempDirectory, () => resolvedDirectory) : diagnostic.filePath
52451
52554
  }));
52452
52555
  finalizeScans({
52453
- diagnostics: remappedDiagnostics,
52454
52556
  completedScans: [{
52455
52557
  directory: resolvedDirectory,
52456
52558
  result: {
@@ -52460,7 +52562,8 @@ const inspectAction = async (directory, flags) => {
52460
52562
  ...scanResult.project,
52461
52563
  rootDirectory: resolvedDirectory
52462
52564
  }
52463
- }
52565
+ },
52566
+ config: userConfig
52464
52567
  }],
52465
52568
  mode: "staged",
52466
52569
  diff: null,
@@ -52478,7 +52581,7 @@ const inspectAction = async (directory, flags) => {
52478
52581
  }
52479
52582
  return;
52480
52583
  }
52481
- const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
52584
+ const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts, userConfig?.projects);
52482
52585
  const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
52483
52586
  const requestedScope = resolveScope(flags, userConfig);
52484
52587
  const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
@@ -52516,56 +52619,87 @@ const inspectAction = async (directory, flags) => {
52516
52619
  }
52517
52620
  cliLogger.break();
52518
52621
  }
52519
- const allDiagnostics = [];
52520
52622
  const completedScans = [];
52521
52623
  const isMultiProject = projectDirectories.length > 1;
52522
- const supplyChainEnabled = userConfig?.supplyChain?.enabled !== false;
52523
- 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;
52524
52630
  let includePaths;
52525
52631
  let supplyChainManifestChanged = false;
52526
52632
  if (isDiffMode) {
52527
- const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory, projectDirectory, diffInfo);
52528
- 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);
52529
52635
  if (changedSourceFiles.length === 0 && !supplyChainManifestChanged) {
52530
52636
  if (!isQuiet) {
52531
- cliLogger.dim(`No changed source files in ${projectDirectory}, skipping.`);
52637
+ cliLogger.dim(`No changed source files in ${scanDirectory}, skipping.`);
52532
52638
  cliLogger.break();
52533
52639
  }
52534
- continue;
52640
+ return null;
52535
52641
  }
52536
52642
  includePaths = [...changedSourceFiles];
52537
52643
  if (supplyChainManifestChanged) includePaths.push("package.json");
52538
52644
  }
52539
52645
  if (!isQuiet && !isMultiProject) cliLogger.dim(" ");
52540
- const scanResult = await inspect(projectDirectory, {
52646
+ const scanResult = await inspect(scanDirectory, {
52541
52647
  ...scanOptions,
52542
52648
  includePaths,
52543
- configOverride: userConfig,
52649
+ configOverride: projectConfig,
52650
+ configSourceDirectory: projectConfigSourceDirectory ?? void 0,
52544
52651
  suppressRendering: isMultiProject,
52652
+ concurrentScan: isMultiProject,
52545
52653
  baseline: baselineRef ? { ref: baselineRef } : void 0,
52546
- changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, projectDirectory, changedLineRanges) : void 0,
52654
+ changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, scanDirectory, changedLineRanges) : void 0,
52547
52655
  supplyChainManifestChanged
52548
52656
  });
52549
- allDiagnostics.push(...scanResult.diagnostics);
52550
- completedScans.push({
52551
- directory: projectDirectory,
52552
- result: scanResult
52553
- });
52554
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);
52555
52686
  }
52556
52687
  if (!isQuiet && isMultiProject && completedScans.length > 0) {
52557
52688
  const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
52558
52689
  await runPromise(printMultiProjectSummary({
52559
52690
  completedScans,
52560
52691
  categoryFilters,
52561
- userConfig,
52562
52692
  verbose: Boolean(flags.verbose),
52693
+ outputDirectory: flags.outputDir,
52563
52694
  isOffline: !shouldShowShareLink,
52564
- projectName: Path.basename(resolvedDirectory)
52695
+ projectName: Path.basename(resolvedDirectory),
52696
+ totalElapsedMilliseconds: performance$1.now() - scanLoopStartTime
52565
52697
  }));
52566
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"));
52567
52702
  finalizeScans({
52568
- diagnostics: allDiagnostics,
52569
52703
  completedScans,
52570
52704
  mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
52571
52705
  diff: isDiffMode ? diffInfo : null,
@@ -52578,13 +52712,13 @@ const inspectAction = async (directory, flags) => {
52578
52712
  resolvedDirectory,
52579
52713
  startTime
52580
52714
  });
52581
- const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
52582
52715
  if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
52583
52716
  await handoffToAgent({
52584
52717
  diagnostics: selectedSurfaceDiagnostics,
52585
52718
  projectName: Path.basename(resolvedDirectory),
52586
52719
  rootDirectory: resolvedDirectory,
52587
- interactive: true
52720
+ interactive: true,
52721
+ outputDirectory: flags.outputDir
52588
52722
  });
52589
52723
  return;
52590
52724
  }
@@ -53380,6 +53514,7 @@ const ROOT_FLAG_SPEC = {
53380
53514
  "--category",
53381
53515
  "--changed-files-from",
53382
53516
  "--blocking",
53517
+ "--output-dir",
53383
53518
  "--fail-on",
53384
53519
  "--project",
53385
53520
  "--scope"
@@ -53534,6 +53669,7 @@ ${formatExampleLines([
53534
53669
  ["react-doctor", "scan the current project"],
53535
53670
  ["react-doctor ./apps/web", "scan a specific directory"],
53536
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)"],
53537
53673
  ["react-doctor --staged", "scan staged files (pre-commit hook)"],
53538
53674
  ["react-doctor --category Security", "show only one diagnostic category"],
53539
53675
  ["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
@@ -53565,9 +53701,9 @@ ${highlighter.dim("Learn more:")}
53565
53701
  ${highlighter.info(CANONICAL_GITHUB_URL)}
53566
53702
  `;
53567
53703
  const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
53568
- 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);
53569
53705
  program.action(inspectAction);
53570
- 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));
53571
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);
53572
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);
53573
53709
  const rules = program.command("rules").description("List, explain, and configure which React Doctor rules run");
@@ -53608,4 +53744,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
53608
53744
  export {};
53609
53745
 
53610
53746
  //# sourceMappingURL=cli.js.map
53611
- //# debugId=60598d2a-66c7-5091-a013-028926866fbd
53747
+ //# debugId=ecc7e4af-d176-5569-bc51-c3fbe220a76b
package/dist/index.d.ts CHANGED
@@ -9237,6 +9237,22 @@ interface ReactDoctorConfig {
9237
9237
  * requested directory).
9238
9238
  */
9239
9239
  rootDir?: string;
9240
+ /**
9241
+ * Projects to scan and score separately — the config-file equivalent of
9242
+ * the CLI `--project` flag, for repos that always want per-module scoring
9243
+ * (e.g. a monorepo dashboard tracking each module's score daily) without
9244
+ * passing the flag on every run.
9245
+ *
9246
+ * Entries resolve exactly like `--project` values: workspace package
9247
+ * names (or directory basenames) first, then directory paths relative to
9248
+ * the scanned root. `"*"` selects every discovered workspace project.
9249
+ * Invalid entries fail the run with the same error as the flag.
9250
+ *
9251
+ * Precedence: an explicit `--project` flag overrides this list. Only the
9252
+ * config at the invocation root is consulted — `projects` inside a
9253
+ * module's own config is ignored (modules can't redirect the scan).
9254
+ */
9255
+ projects?: string[];
9240
9256
  textComponents?: string[];
9241
9257
  /**
9242
9258
  * Names of components that safely route string-only children through a
@@ -9601,12 +9617,55 @@ interface DiagnoseResult {
9601
9617
  elapsedMilliseconds: number;
9602
9618
  }
9603
9619
  /**
9604
- * A single project to scan as part of a `diagnoseProjects()` batch.
9620
+ * A single project to scan as part of a `diagnose({ projects })` batch.
9605
9621
  * Scan options (`deadCode`, `lint`, etc.) are flat on the entry and
9606
9622
  * layer on top of the global defaults — omitted fields fall through.
9607
- * `config` is a full `ReactDoctorConfig` override that replaces the
9608
- * on-disk `doctor.config.*` for this project's scan.
9609
9623
  */
9624
+ interface ProjectDefinition extends DiagnoseOptions {
9625
+ directory: string;
9626
+ /**
9627
+ * Per-project config overrides, layered additively (see
9628
+ * `mergeReactDoctorConfigs`) on top of the project's on-disk
9629
+ * `doctor.config.*` and the batch-level `DiagnoseProjectsInput.config`
9630
+ * — so disabling one rule here keeps every base rule intact.
9631
+ */
9632
+ config?: ReactDoctorConfig;
9633
+ }
9634
+ interface ProjectResultOk extends DiagnoseResult {
9635
+ ok: true;
9636
+ directory: string;
9637
+ }
9638
+ interface ProjectResultError {
9639
+ ok: false;
9640
+ directory: string;
9641
+ error: Error;
9642
+ }
9643
+ type ProjectResult = ProjectResultOk | ProjectResultError;
9644
+ interface DiagnoseProjectsInput extends DiagnoseOptions {
9645
+ projects: ProjectDefinition[];
9646
+ /**
9647
+ * Config overrides applied to every project in the batch, layered
9648
+ * additively (see `mergeReactDoctorConfigs`) between each project's
9649
+ * on-disk `doctor.config.*` and its `ProjectDefinition.config` — one
9650
+ * base rule set for the batch, overridden per project only where needed.
9651
+ */
9652
+ config?: ReactDoctorConfig;
9653
+ /**
9654
+ * Maximum number of projects to scan concurrently. Defaults to
9655
+ * `DEFAULT_PROJECT_SCAN_CONCURRENCY` (4) — each project scan fans out
9656
+ * its own lint workers, so the batch is bounded rather than fully
9657
+ * parallel. Set to `1` for sequential execution. Values below 1 are
9658
+ * clamped to 1.
9659
+ */
9660
+ concurrency?: number;
9661
+ }
9662
+ interface DiagnoseProjectsResult {
9663
+ projects: ProjectResult[];
9664
+ diagnostics: Diagnostic[];
9665
+ score: ScoreResult | null;
9666
+ elapsedMilliseconds: number;
9667
+ } //#endregion
9668
+ //#region src/types/handle-error.d.ts
9610
9669
  //#endregion
9611
9670
  //#region src/types/inspect.d.ts
9612
9671
  interface InspectResult {
@@ -10027,41 +10086,20 @@ declare const defineConfig: (config: ReactDoctorConfig) => ReactDoctorConfig; //
10027
10086
  //#endregion
10028
10087
  //#region ../api/dist/index.d.ts
10029
10088
  //#region src/diagnose.d.ts
10030
- declare const diagnose: (directory: string, options?: DiagnoseOptions) => Promise<DiagnoseResult>;
10031
- /**
10032
- * Scan multiple projects in parallel and return per-project scores,
10033
- * diagnostics, and an aggregate score (worst-of across all projects).
10034
- *
10035
- * Each project runs its own independent `runInspect` pipeline — the
10036
- * same pipeline `diagnose()` uses — so per-project config overrides,
10037
- * dead-code analysis, and scoring all work identically to a single
10038
- * `diagnose()` call.
10039
- *
10040
- * Projects that fail (e.g. missing `package.json`, no React dependency)
10041
- * are included in the result with `ok: false` rather than aborting the
10042
- * entire batch, so callers always receive partial results.
10043
- *
10044
- * ```ts
10045
- * const result = await diagnoseProjects({
10046
- * projects: [
10047
- * { directory: "packages/app" },
10048
- * { directory: "packages/shared", deadCode: false },
10049
- * { directory: "packages/admin", config: {
10050
- * rules: { "react-doctor/no-array-index-as-key": "off" },
10051
- * }},
10052
- * ],
10053
- * concurrency: 4,
10054
- * });
10055
- *
10056
- * for (const project of result.projects) {
10057
- * if (project.ok) {
10058
- * console.log(project.directory, project.score);
10059
- * } else {
10060
- * console.error(project.directory, project.error);
10061
- * }
10062
- * }
10063
- * ```
10064
- */
10089
+ interface Diagnose {
10090
+ /** Scan a single project directory and return diagnostics + score. */
10091
+ (directory: string, options?: DiagnoseOptions): Promise<DiagnoseResult>;
10092
+ /**
10093
+ * Scan multiple projects in parallel — each through the same pipeline as
10094
+ * the single-directory form — and return per-project results plus an
10095
+ * aggregate worst-of score. A failing project (e.g. no `package.json`)
10096
+ * comes back with `ok: false` instead of aborting the batch. Per-project
10097
+ * `config` layers on the batch `config`, which layers on each project's
10098
+ * on-disk config (see `mergeReactDoctorConfigs`).
10099
+ */
10100
+ (input: DiagnoseProjectsInput): Promise<DiagnoseProjectsResult>;
10101
+ }
10102
+ declare const diagnose: Diagnose; //#endregion
10065
10103
  //#endregion
10066
10104
  //#region src/index.d.ts
10067
10105
  declare const clearCaches: () => void;
@@ -10072,5 +10110,5 @@ interface ToJsonReportOptions {
10072
10110
  }
10073
10111
  declare const toJsonReport: (result: DiagnoseResult, options: ToJsonReportOptions) => JsonReport;
10074
10112
  //#endregion
10075
- export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
10113
+ export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseProjectsInput, type DiagnoseProjectsResult, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectDefinition, type ProjectInfo, ProjectNotFoundError, type ProjectResult, type ProjectResultError, type ProjectResultOk, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
10076
10114
  //# sourceMappingURL=index.d.ts.map
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]="0090e471-3c19-51d5-8774-cc4c6a98e591")}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]="d789108a-ddf2-5b61-a479-4c797dba74cb")}catch(e){}}();
3
3
  import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
4
4
  import { createRequire } from "node:module";
5
5
  import * as NFS from "node:fs";
@@ -38475,6 +38475,7 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
38475
38475
  };
38476
38476
  const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
38477
38477
  const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
38478
+ const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
38478
38479
  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.";
38479
38480
  const PLUGIN_CATEGORY_MAP = {
38480
38481
  react: "Bugs",
@@ -38502,7 +38503,10 @@ const getRuleRecommendation = (ruleName, project) => {
38502
38503
  };
38503
38504
  const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
38504
38505
  const getRuleTitle = (ruleName) => reactDoctorPlugin.rules[ruleName]?.title;
38505
- const resolveDiagnosticTitle = (plugin, rule) => plugin === "react-hooks-js" ? REACT_COMPILER_TITLE : getRuleTitle(rule);
38506
+ const resolveDiagnosticTitle = (plugin, rule) => {
38507
+ if (plugin !== "react-hooks-js") return getRuleTitle(rule);
38508
+ return rule === "todo" ? REACT_COMPILER_TODO_TITLE : REACT_COMPILER_TITLE;
38509
+ };
38506
38510
  const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
38507
38511
  const cleaned = resolveCleanedDiagnostic(typeof message === "string" ? message : "", typeof help === "string" ? help : "", plugin, rule, project);
38508
38512
  return {
@@ -40099,13 +40103,55 @@ const clearAutoSuppressionCaches = () => {};
40099
40103
  * untouched so the loader sees the same plain object either way.
40100
40104
  */
40101
40105
  const defineConfig = (config) => config;
40106
+ const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
40107
+ const mergeIgnores = (baseIgnore, overrideIgnore) => {
40108
+ const mergedIgnore = {
40109
+ ...baseIgnore,
40110
+ ...overrideIgnore
40111
+ };
40112
+ if (baseIgnore.rules && overrideIgnore.rules) mergedIgnore.rules = unionValues(baseIgnore.rules, overrideIgnore.rules);
40113
+ if (baseIgnore.files && overrideIgnore.files) mergedIgnore.files = unionValues(baseIgnore.files, overrideIgnore.files);
40114
+ if (baseIgnore.tags && overrideIgnore.tags) mergedIgnore.tags = unionValues(baseIgnore.tags, overrideIgnore.tags);
40115
+ if (baseIgnore.overrides && overrideIgnore.overrides) mergedIgnore.overrides = [...baseIgnore.overrides, ...overrideIgnore.overrides];
40116
+ return mergedIgnore;
40117
+ };
40118
+ /**
40119
+ * Layer one `ReactDoctorConfig` on top of another, additively: `rules` /
40120
+ * `categories` / `supplyChain` merge per key, `ignore` lists union
40121
+ * (`ignore.overrides` concatenate), and every other field is a scalar the
40122
+ * override simply wins on when set. Returns the base unchanged when there
40123
+ * is no override, and vice versa — so callers can thread `null` /
40124
+ * `undefined` through without special-casing.
40125
+ */
40126
+ const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
40127
+ if (overrideConfig === void 0) return baseConfig;
40128
+ if (baseConfig === null) return overrideConfig;
40129
+ const mergedConfig = {
40130
+ ...baseConfig,
40131
+ ...overrideConfig
40132
+ };
40133
+ if (baseConfig.rules && overrideConfig.rules) mergedConfig.rules = {
40134
+ ...baseConfig.rules,
40135
+ ...overrideConfig.rules
40136
+ };
40137
+ if (baseConfig.categories && overrideConfig.categories) mergedConfig.categories = {
40138
+ ...baseConfig.categories,
40139
+ ...overrideConfig.categories
40140
+ };
40141
+ if (baseConfig.supplyChain && overrideConfig.supplyChain) mergedConfig.supplyChain = {
40142
+ ...baseConfig.supplyChain,
40143
+ ...overrideConfig.supplyChain
40144
+ };
40145
+ if (baseConfig.ignore && overrideConfig.ignore) mergedConfig.ignore = mergeIgnores(baseConfig.ignore, overrideConfig.ignore);
40146
+ return mergedConfig;
40147
+ };
40102
40148
  //#endregion
40103
40149
  //#region ../api/dist/index.js
40104
- const buildDiagnoseLayer = (config, configOverride) => {
40105
- const configLayer = configOverride === void 0 ? Config.layerNode : Config.layerOf({
40150
+ const buildDiagnoseLayer = (config, configOverrideTarget) => {
40151
+ const configLayer = configOverrideTarget === void 0 ? Config.layerNode : Config.layerOf({
40106
40152
  config,
40107
- resolvedDirectory: configOverride.resolvedDirectory,
40108
- configSourceDirectory: null
40153
+ resolvedDirectory: configOverrideTarget.resolvedDirectory,
40154
+ configSourceDirectory: configOverrideTarget.configSourceDirectory
40109
40155
  });
40110
40156
  return mergeAll$1(Project.layerNode, configLayer, DeadCode.layerNode, Files.layerNode, Git.layerNode, Linter.layerOxlint, LintPartialFailures.layerLive, Progress.layerNoop, Reporter.layerNoop, Score.layerHttp, config?.supplyChain?.enabled !== false ? SupplyChain.layerNode : SupplyChain.layerOf([]));
40111
40157
  };
@@ -40137,11 +40183,64 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
40137
40183
  elapsedMilliseconds
40138
40184
  };
40139
40185
  };
40140
- const diagnose = async (directory, options = {}) => {
40186
+ const diagnoseDirectory = async (directory, options) => {
40141
40187
  const startTime = globalThis.performance.now();
40142
40188
  const scanTarget = await resolveScanTarget(directory);
40143
40189
  return outputToDiagnoseResult(await runPromise(restoreLegacyThrow(buildInspectProgram(scanTarget, options).pipe(provide(buildDiagnoseLayer(scanTarget.userConfig)), provide(layerOtlp)))), globalThis.performance.now() - startTime);
40144
40190
  };
40191
+ const findWorstScore = (projectResults) => {
40192
+ let worstResult = null;
40193
+ let worstScore = Number.POSITIVE_INFINITY;
40194
+ for (const projectResult of projectResults) {
40195
+ if (!projectResult.ok || projectResult.score === null) continue;
40196
+ if (projectResult.score.score < worstScore) {
40197
+ worstScore = projectResult.score.score;
40198
+ worstResult = projectResult.score;
40199
+ }
40200
+ }
40201
+ return worstResult;
40202
+ };
40203
+ const diagnoseProject = async (projectDefinition, baseOptions, batchConfig) => {
40204
+ const startTime = globalThis.performance.now();
40205
+ try {
40206
+ const scanTarget = await resolveScanTarget(projectDefinition.directory);
40207
+ const { directory: _, config: projectConfig, ...perProjectOptions } = projectDefinition;
40208
+ const didOverrideConfig = batchConfig !== void 0 || projectConfig !== void 0;
40209
+ const effectiveConfig = mergeReactDoctorConfigs(mergeReactDoctorConfigs(scanTarget.userConfig, batchConfig), projectConfig);
40210
+ const program = buildInspectProgram(scanTarget, {
40211
+ ...baseOptions,
40212
+ ...perProjectOptions
40213
+ }, effectiveConfig ?? void 0);
40214
+ const didOverridePlugins = batchConfig?.plugins !== void 0 || projectConfig?.plugins !== void 0;
40215
+ const layer = buildDiagnoseLayer(effectiveConfig, didOverrideConfig ? {
40216
+ resolvedDirectory: scanTarget.resolvedDirectory,
40217
+ configSourceDirectory: didOverridePlugins ? null : scanTarget.configSourceDirectory
40218
+ } : void 0);
40219
+ return {
40220
+ ok: true,
40221
+ ...outputToDiagnoseResult(await runPromise(restoreLegacyThrow(program.pipe(provide(layer), provide(layerOtlp)))), globalThis.performance.now() - startTime),
40222
+ directory: scanTarget.resolvedDirectory
40223
+ };
40224
+ } catch (error) {
40225
+ return {
40226
+ ok: false,
40227
+ directory: projectDefinition.directory,
40228
+ error: error instanceof Error ? error : new Error(String(error))
40229
+ };
40230
+ }
40231
+ };
40232
+ const diagnoseProjectBatch = async (input) => {
40233
+ const startTime = globalThis.performance.now();
40234
+ const { projects, concurrency, config: batchConfig, ...baseOptions } = input;
40235
+ const projectResults = await mapWithConcurrency(projects, concurrency ?? 4, (projectDefinition) => diagnoseProject(projectDefinition, baseOptions, batchConfig));
40236
+ return {
40237
+ projects: projectResults,
40238
+ diagnostics: projectResults.flatMap((projectResult) => projectResult.ok ? projectResult.diagnostics : []),
40239
+ score: findWorstScore(projectResults),
40240
+ elapsedMilliseconds: globalThis.performance.now() - startTime
40241
+ };
40242
+ };
40243
+ const diagnose = (async (directoryOrInput, options = {}) => typeof directoryOrInput === "string" ? diagnoseDirectory(directoryOrInput, options) : diagnoseProjectBatch(directoryOrInput));
40145
40244
  //#endregion
40146
40245
  //#region src/index.ts
40147
40246
  const clearCaches = () => {
@@ -40174,4 +40273,4 @@ const toJsonReport = (result, options) => buildJsonReport({
40174
40273
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
40175
40274
 
40176
40275
  //# sourceMappingURL=index.js.map
40177
- //# debugId=0090e471-3c19-51d5-8774-cc4c6a98e591
40276
+ //# debugId=d789108a-ddf2-5b61-a479-4c797dba74cb
package/dist/lsp.js CHANGED
@@ -38461,6 +38461,7 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
38461
38461
  };
38462
38462
  const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
38463
38463
  const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
38464
+ const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
38464
38465
  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.";
38465
38466
  const PLUGIN_CATEGORY_MAP = {
38466
38467
  react: "Bugs",
@@ -38488,7 +38489,10 @@ const getRuleRecommendation = (ruleName, project) => {
38488
38489
  };
38489
38490
  const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
38490
38491
  const getRuleTitle = (ruleName) => reactDoctorPlugin.rules[ruleName]?.title;
38491
- const resolveDiagnosticTitle = (plugin, rule) => plugin === "react-hooks-js" ? REACT_COMPILER_TITLE : getRuleTitle(rule);
38492
+ const resolveDiagnosticTitle = (plugin, rule) => {
38493
+ if (plugin !== "react-hooks-js") return getRuleTitle(rule);
38494
+ return rule === "todo" ? REACT_COMPILER_TODO_TITLE : REACT_COMPILER_TITLE;
38495
+ };
38492
38496
  const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
38493
38497
  const cleaned = resolveCleanedDiagnostic(typeof message === "string" ? message : "", typeof help === "string" ? help : "", plugin, rule, project);
38494
38498
  return {
@@ -41709,6 +41713,8 @@ const METRIC = {
41709
41713
  cliInvoked: "cli.invoked",
41710
41714
  cliError: "cli.error",
41711
41715
  projectDetected: "project.detected",
41716
+ projectPathSelected: "project.path_selected",
41717
+ projectConfigSelected: "project.config_selected",
41712
41718
  scanCompleted: "scan.completed",
41713
41719
  scanDuration: "scan.duration",
41714
41720
  scanPhaseDuration: "scan.phase_duration",
@@ -42052,5 +42058,5 @@ const startLanguageServer = () => {
42052
42058
  };
42053
42059
  //#endregion
42054
42060
  export { startLanguageServer };
42055
- !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]="3f2681f1-5caf-5b77-a639-8334ae51b66f")}catch(e){}}();
42056
- //# debugId=3f2681f1-5caf-5b77-a639-8334ae51b66f
42061
+ !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]="1e6dd9cd-7bbf-509d-9302-bdf56d4cf879")}catch(e){}}();
42062
+ //# debugId=1e6dd9cd-7bbf-509d-9302-bdf56d4cf879
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.5.1-dev.038aaf7",
3
+ "version": "0.5.1-dev.19d99ee",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -54,17 +54,17 @@
54
54
  "agent-install": "0.0.5",
55
55
  "conf": "^15.1.0",
56
56
  "confbox": "^0.2.4",
57
- "deslop-js": "^0.0.21",
57
+ "deslop-js": "^0.0.23",
58
58
  "eslint-plugin-react-hooks": "^7.1.1",
59
59
  "jiti": "^2.7.0",
60
60
  "magicast": "^0.5.3",
61
- "oxlint": "^1.66.0",
61
+ "oxlint": ">=1.66.0 <1.67.0",
62
62
  "prompts": "^2.4.2",
63
63
  "typescript": ">=5.0.4 <7",
64
64
  "vscode-languageserver": "^9.0.1",
65
65
  "vscode-languageserver-textdocument": "^1.0.12",
66
66
  "vscode-uri": "^3.1.0",
67
- "oxlint-plugin-react-doctor": "0.5.1-dev.038aaf7"
67
+ "oxlint-plugin-react-doctor": "0.5.1-dev.19d99ee"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/babel__code-frame": "^7.27.0",
@@ -72,9 +72,9 @@
72
72
  "@xterm/headless": "^6.0.0",
73
73
  "commander": "^14.0.3",
74
74
  "ora": "^9.4.0",
75
- "@react-doctor/core": "0.5.1",
75
+ "@react-doctor/api": "0.5.1",
76
76
  "@react-doctor/language-server": "0.5.1",
77
- "@react-doctor/api": "0.5.1"
77
+ "@react-doctor/core": "0.5.1"
78
78
  },
79
79
  "engines": {
80
80
  "node": "^20.19.0 || >=22.13.0"