react-doctor 0.4.2-dev.42c339f → 0.4.2-dev.571ca9c

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]="92822f58-92ef-58d5-8850-2746c0b48fc0")}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]="e5634721-88db-51c8-93e5-137793125d7a")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import * as path$1 from "node:path";
@@ -34,7 +34,7 @@ import * as ChildProcess from "effect/unstable/process/ChildProcess";
34
34
  import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
35
35
  import * as ts from "typescript";
36
36
  import { gzipSync } from "node:zlib";
37
- import { createHash, randomUUID } from "node:crypto";
37
+ import crypto, { createHash, randomUUID } from "node:crypto";
38
38
  import * as Exit from "effect/Exit";
39
39
  import * as Sentry from "@sentry/node";
40
40
  import { performance } from "node:perf_hooks";
@@ -5151,8 +5151,8 @@ const isFile = (filePath) => {
5151
5151
  return false;
5152
5152
  }
5153
5153
  };
5154
- const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?)$/;
5155
- const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.js$/i;
5154
+ const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
5155
+ const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
5156
5156
  const MINIFIED_SNIFF_BYTES = 65536;
5157
5157
  const GIT_LS_FILES_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
5158
5158
  const IGNORED_DIRECTORIES = new Set([
@@ -6392,6 +6392,29 @@ const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
6392
6392
  "oxlint.json",
6393
6393
  ".oxlintrc.json"
6394
6394
  ];
6395
+ const CONFIG_FINGERPRINT_FILENAMES = [
6396
+ "doctor.config.ts",
6397
+ "doctor.config.mts",
6398
+ "doctor.config.cts",
6399
+ "doctor.config.js",
6400
+ "doctor.config.mjs",
6401
+ "doctor.config.cjs",
6402
+ "doctor.config.json",
6403
+ "doctor.config.jsonc",
6404
+ "react-doctor.config.json",
6405
+ "package.json",
6406
+ "pnpm-workspace.yaml",
6407
+ "tsconfig.json",
6408
+ "tsconfig.base.json",
6409
+ ".oxlintrc.json",
6410
+ ".eslintrc.json",
6411
+ "pnpm-lock.yaml",
6412
+ "package-lock.json",
6413
+ "yarn.lock",
6414
+ "bun.lock",
6415
+ "bun.lockb",
6416
+ ".gitignore"
6417
+ ];
6395
6418
  const CANONICAL_GITHUB_URL = "https://github.com/millionco/react-doctor";
6396
6419
  const CANONICAL_DISCORD_URL = "https://react.doctor/discord";
6397
6420
  const SKILL_NAME = "react-doctor";
@@ -6725,7 +6748,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
6725
6748
  "react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
6726
6749
  "react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
6727
6750
  "react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
6728
- "react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
6729
6751
  "react/jsx-no-undef": "react-doctor/jsx-no-undef",
6730
6752
  "react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
6731
6753
  "react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
@@ -7921,51 +7943,51 @@ const FLAGGED_DEPENDENCIES = [
7921
7943
  {
7922
7944
  packageName: "expo-modules-autolinking",
7923
7945
  rule: "expo-no-redundant-dependency",
7924
- message: "\"expo-modules-autolinking\" should not be a direct dependency — Expo installs it transitively as needed",
7946
+ message: "\"expo-modules-autolinking\" should not be a direct dependency. Expo pins the compatible version through the SDK, and a direct entry can drift to a version that breaks prebuild, Metro, or native builds",
7925
7947
  help: "Remove `expo-modules-autolinking` from your package.json"
7926
7948
  },
7927
7949
  {
7928
7950
  packageName: "expo-dev-launcher",
7929
7951
  rule: "expo-no-redundant-dependency",
7930
- message: "\"expo-dev-launcher\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
7952
+ message: "\"expo-dev-launcher\" should not be a direct dependency. `expo-dev-client` pins the compatible launcher, and a direct entry can drift to a version that breaks native builds",
7931
7953
  help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
7932
7954
  },
7933
7955
  {
7934
7956
  packageName: "expo-dev-menu",
7935
7957
  rule: "expo-no-redundant-dependency",
7936
- message: "\"expo-dev-menu\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
7958
+ message: "\"expo-dev-menu\" should not be a direct dependency. `expo-dev-client` pins the compatible dev menu, and a direct entry can drift to a version that breaks native builds",
7937
7959
  help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
7938
7960
  },
7939
7961
  {
7940
7962
  packageName: "expo-modules-core",
7941
7963
  rule: "expo-no-redundant-dependency",
7942
- message: "\"expo-modules-core\" should not be a direct dependency — use the API re-exported from the `expo` package",
7964
+ message: "\"expo-modules-core\" should not be a direct dependency. Expo pins the compatible native core, and a direct entry can drift to a version that breaks prebuild or native builds",
7943
7965
  help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
7944
7966
  },
7945
7967
  {
7946
7968
  packageName: "@expo/metro-config",
7947
7969
  rule: "expo-no-redundant-dependency",
7948
- message: "\"@expo/metro-config\" should not be a direct dependency — use the `expo/metro-config` sub-export of the `expo` package",
7970
+ message: "\"@expo/metro-config\" should not be a direct dependency. Expo pins the compatible Metro config, and a direct entry can drift to a version that breaks bundling",
7949
7971
  help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
7950
7972
  },
7951
7973
  {
7952
7974
  packageName: "@types/react-native",
7953
7975
  rule: "expo-no-redundant-dependency",
7954
- message: "\"@types/react-native\" should not be installed — React Native ships its own types since SDK 48",
7976
+ message: "\"@types/react-native\" should not be installed. React Native ships its own types since SDK 48, so the extra package can introduce duplicate or stale type definitions",
7955
7977
  help: "Remove `@types/react-native` from your package.json",
7956
7978
  minSdkMajor: 48
7957
7979
  },
7958
7980
  {
7959
7981
  packageName: "@expo/config-plugins",
7960
7982
  rule: "expo-no-redundant-dependency",
7961
- message: "\"@expo/config-plugins\" should not be a direct dependency — use the `expo/config-plugins` sub-export of the `expo` package",
7983
+ message: "\"@expo/config-plugins\" should not be a direct dependency. Expo pins the compatible config-plugin API, and a direct entry can drift to a version that breaks prebuild",
7962
7984
  help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
7963
7985
  minSdkMajor: 48
7964
7986
  },
7965
7987
  {
7966
7988
  packageName: "@expo/prebuild-config",
7967
7989
  rule: "expo-no-redundant-dependency",
7968
- message: "\"@expo/prebuild-config\" should not be a direct dependency — Expo installs it transitively",
7990
+ message: "\"@expo/prebuild-config\" should not be a direct dependency. Expo pins the compatible prebuild config, and a direct entry can drift to a version that breaks prebuild",
7969
7991
  help: "Remove `@expo/prebuild-config` from your package.json",
7970
7992
  minSdkMajor: 53
7971
7993
  },
@@ -7979,28 +8001,28 @@ const FLAGGED_DEPENDENCIES = [
7979
8001
  {
7980
8002
  packageName: "expo-app-loading",
7981
8003
  rule: "expo-no-redundant-dependency",
7982
- message: "\"expo-app-loading\" was removed in SDK 49",
8004
+ message: "\"expo-app-loading\" was removed in SDK 49, so keeping it can leave imports unresolved after upgrading Expo",
7983
8005
  help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
7984
8006
  minSdkMajor: 49
7985
8007
  },
7986
8008
  {
7987
8009
  packageName: "expo-firebase-analytics",
7988
8010
  rule: "expo-no-redundant-dependency",
7989
- message: "\"expo-firebase-analytics\" was removed in SDK 48",
8011
+ message: "\"expo-firebase-analytics\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
7990
8012
  help: FIREBASE_HELP,
7991
8013
  minSdkMajor: 48
7992
8014
  },
7993
8015
  {
7994
8016
  packageName: "expo-firebase-recaptcha",
7995
8017
  rule: "expo-no-redundant-dependency",
7996
- message: "\"expo-firebase-recaptcha\" was removed in SDK 48",
8018
+ message: "\"expo-firebase-recaptcha\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
7997
8019
  help: FIREBASE_HELP,
7998
8020
  minSdkMajor: 48
7999
8021
  },
8000
8022
  {
8001
8023
  packageName: "expo-firebase-core",
8002
8024
  rule: "expo-no-redundant-dependency",
8003
- message: "\"expo-firebase-core\" was removed in SDK 48",
8025
+ message: "\"expo-firebase-core\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
8004
8026
  help: FIREBASE_HELP,
8005
8027
  minSdkMajor: 48
8006
8028
  }
@@ -8041,7 +8063,7 @@ const checkExpoGitignore = (context) => {
8041
8063
  }));
8042
8064
  if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
8043
8065
  rule: "expo-gitignore",
8044
- message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored — usually caused by an overly broad `ios`/`android` ignore rule",
8066
+ message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored, so required native code can be missing from CI or teammate checkouts.",
8045
8067
  help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
8046
8068
  }));
8047
8069
  return diagnostics;
@@ -8103,17 +8125,16 @@ const checkExpoPackageJsonConflicts = (context) => {
8103
8125
  const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
8104
8126
  if (conflictingScriptNames.length > 0) {
8105
8127
  const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
8106
- const shadowsExpoCli = conflictingScriptNames.includes("expo");
8107
8128
  diagnostics.push(buildExpoDiagnostic({
8108
8129
  rule: "expo-package-json-conflict",
8109
- message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that conflicts" : "as scripts that conflict"} with binaries in node_modules/.bin${shadowsExpoCli ? " — a `expo` script shadows the Expo CLI and will likely cause build failures" : ""}`,
8130
+ message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that shadows" : "as scripts that shadow"} Expo/React Native binaries in node_modules/.bin, so tooling can run the local script instead of the expected CLI and fail builds.`,
8110
8131
  help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
8111
8132
  }));
8112
8133
  }
8113
8134
  const packageName = packageJson.name;
8114
8135
  if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
8115
8136
  rule: "expo-package-json-conflict",
8116
- message: `package.json "name" is "${packageName}", which collides with a dependency of the same name`,
8137
+ message: `package.json "name" is "${packageName}", which collides with a dependency of the same name, so package self-resolution can shadow the dependency and break imports that expect the installed package.`,
8117
8138
  help: "Rename your package so it no longer matches one of its dependencies"
8118
8139
  }));
8119
8140
  return diagnostics;
@@ -8184,7 +8205,7 @@ const checkExpoRouterReactNavigation = (context) => {
8184
8205
  if (reactNavigationNames.length === 0) return [];
8185
8206
  return [buildExpoDiagnostic({
8186
8207
  rule: "expo-router-no-react-navigation",
8187
- message: `As of SDK 56, expo-router is no longer compatible with react-navigation, but ${reactNavigationNames.map((name) => `"${name}"`).join(", ")} ${reactNavigationNames.length === 1 ? "is" : "are"} installed as direct ${reactNavigationNames.length === 1 ? "dependency" : "dependencies"}`,
8208
+ message: `As of SDK 56, expo-router is no longer compatible with directly installed @react-navigation packages, so keeping ${reactNavigationNames.map((name) => `"${name}"`).join(", ")} can break routing or linking behavior after the SDK upgrade.`,
8188
8209
  help: "Remove these `@react-navigation/*` packages and replace direct imports with their expo-router equivalents. See https://docs.expo.dev/router/migrate/sdk-55-to-56/"
8189
8210
  })];
8190
8211
  };
@@ -8556,7 +8577,9 @@ const setColorEnabled = (enabled) => {
8556
8577
  highlighter.gray = colors.gray;
8557
8578
  highlighter.bold = colors.bold;
8558
8579
  };
8559
- const computeJsxIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter((filePath) => JSX_FILE_PATTERN.test(filePath)) : void 0;
8580
+ const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
8581
+ const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
8582
+ const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
8560
8583
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
8561
8584
  const FALSY_VALUES = new Set([
8562
8585
  "false",
@@ -8636,7 +8659,7 @@ const collectIgnorePatterns = (rootDirectory) => {
8636
8659
  return patterns;
8637
8660
  };
8638
8661
  const KNIP_JSON_FILENAME = "knip.json";
8639
- const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8662
+ const isRecord$1$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8640
8663
  const readJsonFileSafe = (filePath) => {
8641
8664
  let rawContents;
8642
8665
  try {
@@ -8652,10 +8675,10 @@ const readJsonFileSafe = (filePath) => {
8652
8675
  };
8653
8676
  const readKnipConfig = (rootDirectory) => {
8654
8677
  const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
8655
- if (isRecord$1(knipJson)) return knipJson;
8678
+ if (isRecord$1$1(knipJson)) return knipJson;
8656
8679
  const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
8657
- const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
8658
- return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
8680
+ const packageKnipConfig = isRecord$1$1(packageJson) ? packageJson.knip : null;
8681
+ return isRecord$1$1(packageKnipConfig) ? packageKnipConfig : null;
8659
8682
  };
8660
8683
  const normalizePatternList = (value) => {
8661
8684
  if (typeof value === "string" && value.length > 0) return [value];
@@ -8667,10 +8690,10 @@ const prefixWorkspacePatterns = (workspacePattern, patterns) => {
8667
8690
  return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
8668
8691
  };
8669
8692
  const collectKnipWorkspacePatterns = (workspaces, settingName) => {
8670
- if (!isRecord$1(workspaces)) return [];
8693
+ if (!isRecord$1$1(workspaces)) return [];
8671
8694
  const patterns = [];
8672
8695
  for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
8673
- if (!isRecord$1(workspaceConfig)) continue;
8696
+ if (!isRecord$1$1(workspaceConfig)) continue;
8674
8697
  patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
8675
8698
  }
8676
8699
  return patterns;
@@ -8982,7 +9005,7 @@ const checkDeadCode = async (options) => {
8982
9005
  plugin: DEAD_CODE_PLUGIN,
8983
9006
  rule: "unused-file",
8984
9007
  severity: "warning",
8985
- message: "Unused file — not reachable from any entry point",
9008
+ message: "Unused file is not reachable from any entry point, so it adds maintenance surface without shipping any code.",
8986
9009
  help: "Delete the file if it is truly unreachable, or import it from an entry point.",
8987
9010
  line: 0,
8988
9011
  column: 0,
@@ -8995,7 +9018,7 @@ const checkDeadCode = async (options) => {
8995
9018
  plugin: DEAD_CODE_PLUGIN,
8996
9019
  rule: unusedExport.isTypeOnly ? "unused-type" : "unused-export",
8997
9020
  severity: "warning",
8998
- message: `Unused ${label}: \`${unusedExport.name}\``,
9021
+ message: `Unused ${label}: \`${unusedExport.name}\` is exported but no module imports it, so it expands the public surface and can mislead callers about supported API.`,
8999
9022
  help: "Drop the `export` keyword (or remove the declaration) if no other module uses this symbol.",
9000
9023
  line: unusedExport.line,
9001
9024
  column: unusedExport.column,
@@ -9009,7 +9032,7 @@ const checkDeadCode = async (options) => {
9009
9032
  plugin: DEAD_CODE_PLUGIN,
9010
9033
  rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
9011
9034
  severity: "warning",
9012
- message: `Unused ${label}: \`${unusedDependency.name}\``,
9035
+ message: `Unused ${label}: \`${unusedDependency.name}\` is not imported by the project, so it adds install time and supply-chain surface without being used.`,
9013
9036
  help: "Remove the dependency from package.json if it is genuinely unused.",
9014
9037
  line: 0,
9015
9038
  column: 0,
@@ -9023,7 +9046,7 @@ const checkDeadCode = async (options) => {
9023
9046
  plugin: DEAD_CODE_PLUGIN,
9024
9047
  rule: "circular-dependency",
9025
9048
  severity: "warning",
9026
- message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}`,
9049
+ message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}. Modules in the cycle can observe partially initialized exports, causing order-dependent bugs.`,
9027
9050
  help: "Break the cycle by extracting the shared code into a third module that both files import.",
9028
9051
  line: 0,
9029
9052
  column: 0,
@@ -9106,11 +9129,11 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
9106
9129
  return filePaths;
9107
9130
  };
9108
9131
  const listSourceFiles = (rootDirectory) => excludeMinifiedFiles(rootDirectory, listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory));
9109
- const resolveLintIncludePaths = (rootDirectory, userConfig) => {
9132
+ const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
9110
9133
  if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
9111
9134
  const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
9112
9135
  return listSourceFiles(rootDirectory).filter((filePath) => {
9113
- if (!JSX_FILE_PATTERN.test(filePath)) return false;
9136
+ if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
9114
9137
  return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
9115
9138
  });
9116
9139
  };
@@ -9890,16 +9913,16 @@ const readPluginShape = (pluginSpecifier, loadModule) => {
9890
9913
  ruleNames: new Set(Object.keys(rules))
9891
9914
  };
9892
9915
  };
9893
- const bundledRequire = createRequire(import.meta.url);
9916
+ const bundledRequire$1 = createRequire(import.meta.url);
9894
9917
  const resolveReactHooksJsPlugin = (hasReactCompiler, customRulesOnly) => {
9895
9918
  if (!hasReactCompiler || customRulesOnly) return null;
9896
9919
  let pluginSpecifier;
9897
9920
  try {
9898
- pluginSpecifier = bundledRequire.resolve("eslint-plugin-react-hooks");
9921
+ pluginSpecifier = bundledRequire$1.resolve("eslint-plugin-react-hooks");
9899
9922
  } catch {
9900
9923
  return null;
9901
9924
  }
9902
- const { ruleNames } = readPluginShape(pluginSpecifier, (spec) => bundledRequire(spec));
9925
+ const { ruleNames } = readPluginShape(pluginSpecifier, (spec) => bundledRequire$1(spec));
9903
9926
  return {
9904
9927
  entry: {
9905
9928
  name: "react-hooks-js",
@@ -11462,7 +11485,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
11462
11485
  directory: scanDirectory,
11463
11486
  repo
11464
11487
  }).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
11465
- const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeJsxIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
11488
+ const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
11466
11489
  const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
11467
11490
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
11468
11491
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
@@ -12048,6 +12071,22 @@ const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
12048
12071
  * instead of being improvised per diagnostic.
12049
12072
  */
12050
12073
  const buildRuleDocsUrl = (plugin, rule) => `${DOCS_RULES_BASE_URL}/${plugin}/${rule}`;
12074
+ const computeConfigFingerprint = (projectDirectory, version) => {
12075
+ const parts = [`v=${version}`];
12076
+ let directory = projectDirectory;
12077
+ for (;;) {
12078
+ for (const filename of CONFIG_FINGERPRINT_FILENAMES) try {
12079
+ const stat = fs.statSync(path.join(directory, filename));
12080
+ parts.push(`${directory}/${filename}=${stat.mtimeMs}:${stat.size}`);
12081
+ } catch {
12082
+ continue;
12083
+ }
12084
+ const parent = path.dirname(directory);
12085
+ if (parent === directory) break;
12086
+ directory = parent;
12087
+ }
12088
+ return crypto.createHash("sha1").update(parts.join("|")).digest("hex");
12089
+ };
12051
12090
  const groupBy = (items, keyFn) => {
12052
12091
  const groups = /* @__PURE__ */ new Map();
12053
12092
  for (const item of items) {
@@ -12248,7 +12287,7 @@ const makeNoopConsole = () => ({
12248
12287
  });
12249
12288
  //#endregion
12250
12289
  //#region src/cli/utils/version.ts
12251
- const VERSION = "0.4.2-dev.42c339f";
12290
+ const VERSION = "0.4.2-dev.571ca9c";
12252
12291
  //#endregion
12253
12292
  //#region src/cli/utils/json-mode.ts
12254
12293
  let context = null;
@@ -12606,13 +12645,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12606
12645
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12607
12646
  * standard `SENTRY_RELEASE` override.
12608
12647
  */
12609
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.2-dev.42c339f`;
12648
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.2-dev.571ca9c`;
12610
12649
  /**
12611
12650
  * Deployment environment shown in Sentry's environment filter. Defaults to
12612
12651
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12613
12652
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12614
12653
  */
12615
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.2-dev.42c339f") ? "development" : "production");
12654
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.2-dev.571ca9c") ? "development" : "production");
12616
12655
  /**
12617
12656
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12618
12657
  * (set to `0` to disable tracing) and falls back to
@@ -15875,13 +15914,14 @@ const buildRuntimeLayers = (input) => {
15875
15914
  const linterLayer = input.shouldSkipLint ? Linter.layerOf([]) : Linter.layerOxlint;
15876
15915
  const deadCodeLayer = input.shouldRunDeadCode ? DeadCode.layerNode : DeadCode.layerOf([]);
15877
15916
  const scoreLayer = input.shouldComputeScore ? Score.layerHttp : Score.layerOf(null);
15917
+ const projectLayer = input.projectInfoOverride === void 0 ? Project.layerNode : Project.layerOf(input.projectInfoOverride);
15878
15918
  const progressLayer = input.shouldShowProgressSpinners ? Progress.layerOra(buildSpinnerProgressHandle) : Progress.layerNoop;
15879
15919
  const configLayer = input.hasConfigOverride ? Config.layerOf({
15880
15920
  config: input.userConfig,
15881
15921
  resolvedDirectory: input.directory,
15882
15922
  configSourceDirectory: input.configSourceDirectory
15883
15923
  }) : Config.layerNode;
15884
- const baseLayers = Layer.mergeAll(Project.layerNode, configLayer, Files.layerNode, Git.layerNode, linterLayer, LintPartialFailures.layerLive, deadCodeLayer, progressLayer, Reporter.layerNoop, scoreLayer);
15924
+ const baseLayers = Layer.mergeAll(projectLayer, configLayer, Files.layerNode, Git.layerNode, linterLayer, LintPartialFailures.layerLive, deadCodeLayer, progressLayer, Reporter.layerNoop, scoreLayer);
15885
15925
  return input.oxlintConcurrency === void 0 ? baseLayers : Layer.mergeAll(baseLayers, Layer.succeed(OxlintConcurrency, input.oxlintConcurrency));
15886
15926
  };
15887
15927
  //#endregion
@@ -16670,7 +16710,7 @@ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, rende
16670
16710
  const learnMoreLine = formatLearnMoreLine(representative);
16671
16711
  if (learnMoreLine) lines.push(`${TOP_ERROR_DETAIL_INDENT}${highlighter.info(learnMoreLine)}`);
16672
16712
  }
16673
- if (!renderEverySite) for (const explanationLine of wrapTextToWidth(representative.message, resolveMeasureWidth(4), { breakLongWords: false })) lines.push(`${TOP_ERROR_DETAIL_INDENT}${explanationLine}`);
16713
+ for (const explanationLine of wrapTextToWidth(representative.message, resolveMeasureWidth(4), { breakLongWords: false })) lines.push(`${TOP_ERROR_DETAIL_INDENT}${explanationLine}`);
16674
16714
  if (representative.help) for (const fixLine of wrapTextToWidth(`→ ${representative.help}`, resolveMeasureWidth(4), { breakLongWords: false })) lines.push(highlighter.dim(`${TOP_ERROR_DETAIL_INDENT}${fixLine}`));
16675
16715
  if (renderEverySite && isAgentEnvironment) {
16676
16716
  const fixRecipeLine = formatFixRecipeLine(representative);
@@ -16807,6 +16847,9 @@ const computeProjectedScore = async (topErrorSource, rescoreSource, currentScore
16807
16847
  if (!potentialScore || potentialScore.score <= currentScore.score) return null;
16808
16848
  return potentialScore.score;
16809
16849
  };
16850
+ //#endregion
16851
+ //#region src/cli/utils/filter-diagnostics-by-categories.ts
16852
+ const filterDiagnosticsByCategories = (diagnostics, categories) => categories.size === 0 ? [...diagnostics] : diagnostics.filter((diagnostic) => categories.has(diagnostic.category));
16810
16853
  const FORCE_ONBOARDING_ENV_VAR = "REACT_DOCTOR_FORCE_ONBOARDING";
16811
16854
  const FALSY_FLAG_VALUES = new Set([
16812
16855
  "",
@@ -17237,11 +17280,259 @@ const resolveOxlintNodeEffect = (isLintEnabled, isQuiet) => Effect.gen(function*
17237
17280
  });
17238
17281
  const resolveOxlintNode = (isLintEnabled, isQuiet) => Effect.runPromise(resolveOxlintNodeEffect(isLintEnabled, isQuiet).pipe(Effect.provide(NodeResolver.layerNode)));
17239
17282
  //#endregion
17283
+ //#region src/cli/utils/cli-input-error.ts
17284
+ /**
17285
+ * A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
17286
+ * argument, mutually exclusive flags, or an unknown `--project` name. This is
17287
+ * user input, not a react-doctor bug, so `isExpectedUserError` routes it
17288
+ * through `handleUserError`: a clean, single-line message with no Sentry
17289
+ * report and no "Something went wrong, open a prefilled issue" block.
17290
+ *
17291
+ * The `message` is rendered verbatim, so it must read as a complete,
17292
+ * human-readable sentence that tells the user how to fix their invocation.
17293
+ */
17294
+ var CliInputError = class extends Error {
17295
+ name = "CliInputError";
17296
+ };
17297
+ //#endregion
17298
+ //#region src/cli/utils/resolve-cli-categories.ts
17299
+ const categoryByLowercase = new Map(DIAGNOSTIC_CATEGORY_BUCKETS.map((category) => [category.toLowerCase(), category]));
17300
+ const knownCategoryList = DIAGNOSTIC_CATEGORY_BUCKETS.join(", ");
17301
+ const splitCategoryFlagValue = (value) => value.split(",").map((category) => category.trim()).filter((category) => category.length > 0);
17302
+ const resolveCliCategories = (categoryFlag) => {
17303
+ const rawCategoryValues = categoryFlag === void 0 ? [] : Array.isArray(categoryFlag) ? categoryFlag : [categoryFlag];
17304
+ const resolvedCategories = [];
17305
+ const seenCategories = /* @__PURE__ */ new Set();
17306
+ for (const rawCategoryValue of rawCategoryValues) for (const categoryQuery of splitCategoryFlagValue(rawCategoryValue)) {
17307
+ const matchedCategory = categoryByLowercase.get(categoryQuery.toLowerCase());
17308
+ if (matchedCategory === void 0) throw new CliInputError(`Unknown category "${categoryQuery}". Expected one of: ${knownCategoryList}.`);
17309
+ if (!seenCategories.has(matchedCategory)) {
17310
+ seenCategories.add(matchedCategory);
17311
+ resolvedCategories.push(matchedCategory);
17312
+ }
17313
+ }
17314
+ if (rawCategoryValues.length > 0 && resolvedCategories.length === 0) throw new CliInputError(`--category requires one of: ${knownCategoryList}.`);
17315
+ return resolvedCategories.length > 0 ? resolvedCategories : void 0;
17316
+ };
17317
+ //#endregion
17318
+ //#region src/cli/utils/scan-result-cache.ts
17319
+ const CACHE_DISABLED_VALUES = new Set(["1", "true"]);
17320
+ const TOOLCHAIN_PACKAGE_SPECIFIERS = [
17321
+ "oxlint",
17322
+ "oxlint/package.json",
17323
+ "oxlint-plugin-react-doctor",
17324
+ "deslop-js/package.json",
17325
+ "eslint-plugin-react-hooks/package.json"
17326
+ ];
17327
+ const bundledRequire = createRequire(import.meta.url);
17328
+ const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
17329
+ const normalizeForStableJson = (value) => {
17330
+ if (value === null) return null;
17331
+ if (value === void 0) return void 0;
17332
+ const valueType = typeof value;
17333
+ if (valueType === "string" || valueType === "number" || valueType === "boolean") return value;
17334
+ if (valueType === "bigint" || valueType === "function" || valueType === "symbol") throw new Error("Unsupported cache key value");
17335
+ if (Array.isArray(value)) return value.map((item) => {
17336
+ const normalized = normalizeForStableJson(item);
17337
+ return normalized === void 0 ? null : normalized;
17338
+ });
17339
+ const prototype = Object.getPrototypeOf(value);
17340
+ if (prototype !== Object.prototype && prototype !== null) throw new Error("Unsupported cache key object");
17341
+ const record = value;
17342
+ const normalizedRecord = {};
17343
+ for (const key of Object.keys(record).sort()) {
17344
+ const normalized = normalizeForStableJson(record[key]);
17345
+ if (normalized !== void 0) normalizedRecord[key] = normalized;
17346
+ }
17347
+ return normalizedRecord;
17348
+ };
17349
+ const stringifyStableJson = (value) => {
17350
+ try {
17351
+ return JSON.stringify(normalizeForStableJson(value));
17352
+ } catch {
17353
+ return null;
17354
+ }
17355
+ };
17356
+ const hashString = (value) => crypto.createHash("sha1").update(value).digest("hex");
17357
+ const runGit$1 = (directory, args) => {
17358
+ try {
17359
+ return execFileSync("git", [...args], {
17360
+ cwd: directory,
17361
+ encoding: "utf8",
17362
+ stdio: [
17363
+ "ignore",
17364
+ "pipe",
17365
+ "ignore"
17366
+ ]
17367
+ }).trim();
17368
+ } catch {
17369
+ return null;
17370
+ }
17371
+ };
17372
+ const readHeadSha = (projectDirectory) => runGit$1(projectDirectory, ["rev-parse", "HEAD"]);
17373
+ const isWorktreeClean = (projectDirectory) => {
17374
+ const status = runGit$1(projectDirectory, [
17375
+ "status",
17376
+ "--porcelain=v1",
17377
+ "--untracked-files=normal"
17378
+ ]);
17379
+ return status !== null && status.length === 0;
17380
+ };
17381
+ const hasHiddenTrackedFileState = (projectDirectory) => {
17382
+ const output = runGit$1(projectDirectory, ["ls-files", "-v"]);
17383
+ if (output === null) return true;
17384
+ return output.split("\n").some((line) => line.length > 0 && line[0] !== "H");
17385
+ };
17386
+ const resolveCacheFilePath = (projectDirectory) => {
17387
+ const nodeModulesDirectory = path.join(projectDirectory, "node_modules");
17388
+ if (fs.existsSync(nodeModulesDirectory)) return path.join(nodeModulesDirectory, ".cache", "react-doctor", "scan-cache.json");
17389
+ const projectHash = hashString(projectDirectory).slice(0, 16);
17390
+ return path.join(os.tmpdir(), "react-doctor-cache", `scan-${projectHash}.json`);
17391
+ };
17392
+ const readPersistedCache = (cacheFilePath) => {
17393
+ try {
17394
+ const parsed = JSON.parse(fs.readFileSync(cacheFilePath, "utf8"));
17395
+ if (!isRecord$1(parsed) || parsed.version !== 1) return {
17396
+ version: 1,
17397
+ entries: []
17398
+ };
17399
+ if (!Array.isArray(parsed.entries)) return {
17400
+ version: 1,
17401
+ entries: []
17402
+ };
17403
+ const entries = [];
17404
+ for (const entry of parsed.entries) {
17405
+ if (!isRecord$1(entry) || typeof entry.key !== "string" || typeof entry.createdAtMs !== "number") continue;
17406
+ if (!isRecord$1(entry.payload) || !Array.isArray(entry.payload.diagnostics)) continue;
17407
+ entries.push(entry);
17408
+ }
17409
+ return {
17410
+ version: 1,
17411
+ entries
17412
+ };
17413
+ } catch {
17414
+ return {
17415
+ version: 1,
17416
+ entries: []
17417
+ };
17418
+ }
17419
+ };
17420
+ const writePersistedCache = (cacheFilePath, cache) => {
17421
+ try {
17422
+ fs.mkdirSync(path.dirname(cacheFilePath), { recursive: true });
17423
+ const tempPath = `${cacheFilePath}.${process.pid}.tmp`;
17424
+ fs.writeFileSync(tempPath, JSON.stringify(cache));
17425
+ fs.renameSync(tempPath, cacheFilePath);
17426
+ } catch {
17427
+ return;
17428
+ }
17429
+ };
17430
+ const isScanResultCacheDisabled = () => CACHE_DISABLED_VALUES.has(process.env.REACT_DOCTOR_NO_CACHE?.toLowerCase() ?? "");
17431
+ const resolveProjectIdentity = (projectDirectory) => {
17432
+ try {
17433
+ return fs.realpathSync.native(projectDirectory);
17434
+ } catch {
17435
+ return path.resolve(projectDirectory);
17436
+ }
17437
+ };
17438
+ const fileFingerprint = (filePath) => {
17439
+ try {
17440
+ const stat = fs.statSync(filePath);
17441
+ return `${filePath}:${stat.mtimeMs}:${stat.size}`;
17442
+ } catch {
17443
+ return null;
17444
+ }
17445
+ };
17446
+ const resolveToolchainFingerprint = (nodeBinaryPath) => {
17447
+ const fingerprints = [];
17448
+ if (nodeBinaryPath !== null) {
17449
+ const fingerprint = fileFingerprint(nodeBinaryPath);
17450
+ if (fingerprint !== null) fingerprints.push(`node=${fingerprint}`);
17451
+ }
17452
+ for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
17453
+ const fingerprint = fileFingerprint(bundledRequire.resolve(specifier));
17454
+ if (fingerprint !== null) fingerprints.push(`${specifier}=${fingerprint}`);
17455
+ } catch {
17456
+ continue;
17457
+ }
17458
+ return fingerprints;
17459
+ };
17460
+ const buildScanResultCacheKey = (input) => {
17461
+ if (isScanResultCacheDisabled()) return null;
17462
+ if (!isWorktreeClean(input.projectDirectory)) return null;
17463
+ if (hasHiddenTrackedFileState(input.projectDirectory)) return null;
17464
+ const headSha = readHeadSha(input.projectDirectory);
17465
+ if (headSha === null) return null;
17466
+ if (stringifyStableJson(input.userConfig) === null) return null;
17467
+ const cacheKeyJson = stringifyStableJson({
17468
+ schemaVersion: 1,
17469
+ projectIdentity: resolveProjectIdentity(input.projectDirectory),
17470
+ headSha,
17471
+ reactDoctorVersion: input.version,
17472
+ nodeVersion: process.version,
17473
+ toolchainFingerprint: resolveToolchainFingerprint(input.nodeBinaryPath),
17474
+ configFingerprint: computeConfigFingerprint(input.projectDirectory, input.version),
17475
+ hasConfigOverride: input.hasConfigOverride,
17476
+ configSourceDirectory: input.configSourceDirectory,
17477
+ userConfig: input.userConfig,
17478
+ engineOptions: {
17479
+ lint: input.options.lint,
17480
+ deadCode: input.options.deadCode,
17481
+ includePaths: [...input.options.includePaths].sort(),
17482
+ customRulesOnly: input.options.customRulesOnly,
17483
+ respectInlineDisables: input.options.respectInlineDisables,
17484
+ warnings: input.options.warnings,
17485
+ adoptExistingLintConfig: input.options.adoptExistingLintConfig,
17486
+ ignoredTags: [...input.options.ignoredTags].sort(),
17487
+ concurrency: input.options.concurrency,
17488
+ baselineRef: input.options.baseline?.ref,
17489
+ noScore: input.options.noScore,
17490
+ isCi: input.options.isCi,
17491
+ suppressRendering: input.options.suppressRendering
17492
+ }
17493
+ });
17494
+ return cacheKeyJson === null ? null : hashString(cacheKeyJson);
17495
+ };
17496
+ const createScanResultCache = (projectDirectory) => {
17497
+ const cacheFilePath = resolveCacheFilePath(projectDirectory);
17498
+ const persistedCache = readPersistedCache(cacheFilePath);
17499
+ const entries = /* @__PURE__ */ new Map();
17500
+ for (const entry of persistedCache.entries) entries.set(entry.key, entry);
17501
+ const persist = () => {
17502
+ writePersistedCache(cacheFilePath, {
17503
+ version: 1,
17504
+ entries: [...entries.values()].sort((firstEntry, secondEntry) => secondEntry.createdAtMs - firstEntry.createdAtMs).slice(0, 20)
17505
+ });
17506
+ };
17507
+ return {
17508
+ lookup: (key) => entries.get(key)?.payload ?? null,
17509
+ store: (key, payload) => {
17510
+ entries.set(key, {
17511
+ key,
17512
+ createdAtMs: Date.now(),
17513
+ payload
17514
+ });
17515
+ persist();
17516
+ }
17517
+ };
17518
+ };
17519
+ const shouldStoreScanPayload = (payload) => !payload.didLintFail && !payload.didDeadCodeFail && payload.lintPartialFailures.length === 0;
17520
+ //#endregion
17240
17521
  //#region src/inspect.ts
17241
17522
  const silentConsole = makeNoopConsole();
17242
17523
  const runConsole = (effect) => {
17243
17524
  Effect.runSync(effect);
17244
17525
  };
17526
+ const recordOnboardingCompletion = (options) => {
17527
+ const forceOnboarding = isOnboardingForced();
17528
+ if (shouldRecordOnboarding({
17529
+ paceOnboardingSections: !options.silent && !options.scoreOnly && !options.suppressRendering && !options.verbose && canAnimateOnboarding(process.stdout) && (forceOnboarding || !hasCompletedOnboarding()),
17530
+ forceOnboarding,
17531
+ verbose: options.verbose,
17532
+ isNonInteractiveEnvironment: options.isNonInteractiveEnvironment
17533
+ })) markOnboardingComplete();
17534
+ };
17535
+ const formatCategorySelection = (categoryFilters) => [...categoryFilters].join(", ");
17245
17536
  const buildIgnoredTags = (userConfig) => {
17246
17537
  const tags = /* @__PURE__ */ new Set();
17247
17538
  if (userConfig?.ignore?.tags) for (const tag of userConfig.ignore.tags) tags.add(tag);
@@ -17262,6 +17553,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
17262
17553
  share: userConfig?.share ?? true,
17263
17554
  respectInlineDisables: inputOptions.respectInlineDisables ?? userConfig?.respectInlineDisables ?? true,
17264
17555
  warnings: inputOptions.warnings ?? userConfig?.warnings ?? true,
17556
+ categoryFilters: new Set(resolveCliCategories(inputOptions.categoryFilters) ?? []),
17265
17557
  adoptExistingLintConfig: userConfig?.adoptExistingLintConfig ?? true,
17266
17558
  ignoredTags: buildIgnoredTags(userConfig),
17267
17559
  outputSurface: inputOptions.outputSurface ?? "cli",
@@ -17348,6 +17640,7 @@ const runBaselineComparison = async (params) => {
17348
17640
  hasConfigOverride: true,
17349
17641
  userConfig: params.userConfig,
17350
17642
  configSourceDirectory: null,
17643
+ projectInfoOverride: params.headProjectInfo,
17351
17644
  shouldSkipLint: !params.options.lint || !params.resolvedNodeBinaryPath,
17352
17645
  shouldRunDeadCode: false,
17353
17646
  shouldComputeScore: false,
@@ -17394,6 +17687,40 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
17394
17687
  const isDiffMode = options.includePaths.length > 0;
17395
17688
  const resolvedNodeBinaryPath = await resolveOxlintNode(options.lint, options.scoreOnly || options.silent);
17396
17689
  const lintBindingMissing = options.lint && !resolvedNodeBinaryPath;
17690
+ const cacheKey = buildScanResultCacheKey({
17691
+ projectDirectory: directory,
17692
+ version: VERSION,
17693
+ nodeBinaryPath: resolvedNodeBinaryPath,
17694
+ options,
17695
+ userConfig,
17696
+ hasConfigOverride,
17697
+ configSourceDirectory
17698
+ });
17699
+ const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
17700
+ const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
17701
+ if (cachedPayload) {
17702
+ recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
17703
+ recordCount(METRIC.projectDetected, 1);
17704
+ await renderCachedProjectDetection({
17705
+ payload: cachedPayload,
17706
+ options,
17707
+ userConfig,
17708
+ isDiffMode
17709
+ });
17710
+ const baselineDegraded = Boolean(options.baseline) && isDiffMode && cachedPayload.baselineDelta === void 0;
17711
+ const result = await renderAndRecordScan({
17712
+ payload: cachedPayload,
17713
+ options,
17714
+ userConfig,
17715
+ hasCustomConfig: userConfig !== null,
17716
+ startTime,
17717
+ rootSentrySpan,
17718
+ scanMode: cachedPayload.baselineDelta ? "baseline" : isDiffMode ? "diff" : "full",
17719
+ baselineDegraded
17720
+ });
17721
+ recordOnboardingCompletion(options);
17722
+ return result;
17723
+ }
17397
17724
  const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && options.lint && Boolean(resolvedNodeBinaryPath);
17398
17725
  const layers = buildRuntimeLayers({
17399
17726
  directory,
@@ -17447,6 +17774,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
17447
17774
  directory,
17448
17775
  options,
17449
17776
  userConfig,
17777
+ headProjectInfo: output.project,
17450
17778
  headDiagnostics: output.diagnostics,
17451
17779
  resolvedNodeBinaryPath,
17452
17780
  baselineRef: options.baseline.ref
@@ -17458,12 +17786,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
17458
17786
  }
17459
17787
  const baselineDegraded = Boolean(options.baseline) && isDiffMode && baselineDelta === void 0;
17460
17788
  const score = didLintFail ? null : output.score;
17461
- const elapsedMilliseconds = performance.now() - startTime;
17462
- const forceOnboarding = isOnboardingForced();
17463
- const paceOnboardingSections = !options.silent && !options.scoreOnly && !options.suppressRendering && !options.verbose && canAnimateOnboarding(process.stdout) && (forceOnboarding || !hasCompletedOnboarding());
17464
- const finalizeInput = {
17465
- options,
17466
- elapsedMilliseconds,
17789
+ const payload = {
17467
17790
  diagnostics: inspectDiagnostics,
17468
17791
  score,
17469
17792
  project: output.project,
@@ -17477,39 +17800,77 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
17477
17800
  scannedFileCount: output.scannedFileCount,
17478
17801
  scannedFilePaths: output.scannedFilePaths,
17479
17802
  scanElapsedMilliseconds: output.scanElapsedMilliseconds,
17480
- baselineDelta
17803
+ baselineDelta,
17804
+ lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind
17481
17805
  };
17482
- const result = await Effect.runPromise(finalizeAndRender(finalizeInput).pipe(options.silent ? Effect.provideService(Console.Console, silentConsole) : (program) => program));
17483
- if (shouldRecordOnboarding({
17484
- paceOnboardingSections,
17485
- forceOnboarding,
17486
- verbose: options.verbose,
17487
- isNonInteractiveEnvironment: options.isNonInteractiveEnvironment
17488
- })) markOnboardingComplete();
17489
- const scanMode = baselineDelta ? "baseline" : isDiffMode ? "diff" : "full";
17806
+ if (cacheKey !== null && scanResultCache !== null && shouldStoreScanPayload(payload)) scanResultCache.store(cacheKey, payload);
17807
+ const result = await renderAndRecordScan({
17808
+ payload,
17809
+ options,
17810
+ userConfig,
17811
+ hasCustomConfig: userConfig !== null,
17812
+ startTime,
17813
+ rootSentrySpan,
17814
+ scanMode: baselineDelta ? "baseline" : isDiffMode ? "diff" : "full",
17815
+ baselineDegraded
17816
+ });
17817
+ recordOnboardingCompletion(options);
17818
+ return result;
17819
+ };
17820
+ const runMaybeSilent = (effect, silent) => silent ? effect.pipe(Effect.provideService(Console.Console, silentConsole)) : effect;
17821
+ const renderCachedProjectDetection = async (input) => {
17822
+ if (input.options.scoreOnly || input.options.suppressRendering) return;
17823
+ await Effect.runPromise(runMaybeSilent(printProjectDetection({
17824
+ projectInfo: input.payload.project,
17825
+ userConfig: input.userConfig,
17826
+ isDiffMode: input.isDiffMode,
17827
+ includePaths: input.options.includePaths,
17828
+ lintSourceFileCount: input.payload.scannedFileCount
17829
+ }), input.options.silent));
17830
+ };
17831
+ const renderAndRecordScan = async (input) => {
17832
+ const finalizeInput = {
17833
+ options: input.options,
17834
+ elapsedMilliseconds: performance.now() - input.startTime,
17835
+ diagnostics: input.payload.diagnostics,
17836
+ score: input.payload.score,
17837
+ project: input.payload.project,
17838
+ userConfig: input.payload.userConfig,
17839
+ didLintFail: input.payload.didLintFail,
17840
+ lintFailureReason: input.payload.lintFailureReason,
17841
+ lintPartialFailures: input.payload.lintPartialFailures,
17842
+ didDeadCodeFail: input.payload.didDeadCodeFail,
17843
+ deadCodeFailureReason: input.payload.deadCodeFailureReason,
17844
+ directory: input.payload.directory,
17845
+ scannedFileCount: input.payload.scannedFileCount,
17846
+ scannedFilePaths: input.payload.scannedFilePaths,
17847
+ scanElapsedMilliseconds: input.payload.scanElapsedMilliseconds,
17848
+ baselineDelta: input.payload.baselineDelta
17849
+ };
17850
+ const result = await Effect.runPromise(runMaybeSilent(finalizeAndRender(finalizeInput), input.options.silent));
17490
17851
  recordScanMetrics({
17491
17852
  result,
17492
- mode: scanMode,
17493
- baselineDegraded,
17494
- parallel: options.concurrency !== void 0,
17495
- workerCount: options.concurrency,
17496
- lint: options.lint,
17497
- deadCode: options.deadCode,
17498
- scoreOnly: options.scoreOnly,
17499
- noScore: options.noScore,
17500
- didLintFail,
17501
- lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
17502
- didDeadCodeFail: output.didDeadCodeFail
17853
+ mode: input.scanMode,
17854
+ baselineDegraded: input.baselineDegraded,
17855
+ parallel: input.options.concurrency !== void 0,
17856
+ workerCount: input.options.concurrency,
17857
+ lint: input.options.lint,
17858
+ deadCode: input.options.deadCode,
17859
+ scoreOnly: input.options.scoreOnly,
17860
+ noScore: input.options.noScore,
17861
+ didLintFail: input.payload.didLintFail,
17862
+ lintFailureReasonKind: input.payload.lintFailureReasonKind,
17863
+ didDeadCodeFail: input.payload.didDeadCodeFail
17503
17864
  });
17504
- recordRunEvent(rootSentrySpan, {
17505
- ...buildRunEventConfig(options, userConfig, userConfig !== null),
17865
+ recordRunEvent(input.rootSentrySpan, {
17866
+ ...buildRunEventConfig(input.options, input.userConfig, input.hasCustomConfig),
17506
17867
  result,
17507
- mode: scanMode,
17508
- gateExempt: baselineDegraded,
17509
- didLintFail,
17510
- lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
17511
- lintPartialFailureCount: output.lintPartialFailures.length,
17512
- didDeadCodeFail: output.didDeadCodeFail
17868
+ mode: input.scanMode,
17869
+ gateExempt: input.baselineDegraded,
17870
+ didLintFail: input.payload.didLintFail,
17871
+ lintFailureReasonKind: input.payload.lintFailureReasonKind,
17872
+ lintPartialFailureCount: input.payload.lintPartialFailures.length,
17873
+ didDeadCodeFail: input.payload.didDeadCodeFail
17513
17874
  });
17514
17875
  return result;
17515
17876
  };
@@ -17545,14 +17906,16 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
17545
17906
  const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
17546
17907
  const pause = onboardingSectionPause(animateRender);
17547
17908
  const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
17909
+ const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
17548
17910
  const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
17549
17911
  const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
17550
- if (surfaceDiagnostics.length === 0) {
17912
+ if (printedDiagnostics.length === 0) {
17551
17913
  yield* pause;
17552
17914
  if (hasSkippedChecks) {
17553
17915
  const skippedLabel = skippedChecks.join(" and ");
17554
17916
  yield* Console.warn(highlighter.warn(`No issues detected, but ${skippedLabel} checks failed — results are incomplete.`));
17555
- } else if (demotedDiagnosticCount > 0) yield* Console.log(highlighter.success(`No issues found! (${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface — see config.surfaces.)`));
17917
+ } else if (options.categoryFilters.size > 0) yield* Console.log(highlighter.success(`No issues found in category ${formatCategorySelection(options.categoryFilters)}!`));
17918
+ else if (demotedDiagnosticCount > 0) yield* Console.log(highlighter.success(`No issues found! (${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface — see config.surfaces.)`));
17556
17919
  else yield* Console.log(highlighter.success("No issues found!"));
17557
17920
  yield* Console.log("");
17558
17921
  yield* pause;
@@ -17565,20 +17928,20 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
17565
17928
  }
17566
17929
  yield* pause;
17567
17930
  yield* Console.log("");
17568
- yield* printDiagnostics([...surfaceDiagnostics], options.verbose, directory, buildRulePriorityMap([score]), isCodingAgentEnvironment(), {
17931
+ yield* printDiagnostics([...printedDiagnostics], options.verbose, directory, buildRulePriorityMap([score]), isCodingAgentEnvironment(), {
17569
17932
  sectionPause: pause,
17570
17933
  animateCountUp: animateRender
17571
17934
  });
17572
17935
  if (options.isNonInteractiveEnvironment && options.outputSurface !== "prComment") yield* printAgentGuidance();
17573
- if (demotedDiagnosticCount > 0) {
17936
+ if (options.categoryFilters.size === 0 && demotedDiagnosticCount > 0) {
17574
17937
  yield* Console.log(highlighter.gray(` ${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface (e.g. design cleanup) — run \`npx react-doctor@latest .\` locally for the full list.`));
17575
17938
  yield* Console.log("");
17576
17939
  }
17577
- const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...surfaceDiagnostics], [...surfaceDiagnostics], score)) : null;
17940
+ const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...printedDiagnostics], [...surfaceDiagnostics], score)) : null;
17578
17941
  const shouldShowShareLink = !options.noScore && options.share && !options.isCi;
17579
17942
  yield* pause;
17580
17943
  yield* printSummary({
17581
- diagnostics: [...surfaceDiagnostics],
17944
+ diagnostics: [...printedDiagnostics],
17582
17945
  elapsedMilliseconds,
17583
17946
  scoreResult: score,
17584
17947
  potentialScore,
@@ -17594,7 +17957,7 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
17594
17957
  }
17595
17958
  yield* pause;
17596
17959
  yield* printFooter({
17597
- diagnostics: [...surfaceDiagnostics],
17960
+ diagnostics: [...printedDiagnostics],
17598
17961
  scoreResult: score,
17599
17962
  projectName: project.projectName,
17600
17963
  isOffline: !shouldShowShareLink
@@ -17725,21 +18088,6 @@ const handleUserError = (error, options = {}) => {
17725
18088
  process.exitCode = 1;
17726
18089
  };
17727
18090
  //#endregion
17728
- //#region src/cli/utils/cli-input-error.ts
17729
- /**
17730
- * A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
17731
- * argument, mutually exclusive flags, or an unknown `--project` name. This is
17732
- * user input, not a react-doctor bug, so `isExpectedUserError` routes it
17733
- * through `handleUserError`: a clean, single-line message with no Sentry
17734
- * report and no "Something went wrong, open a prefilled issue" block.
17735
- *
17736
- * The `message` is rendered verbatim, so it must read as a complete,
17737
- * human-readable sentence that tells the user how to fix their invocation.
17738
- */
17739
- var CliInputError = class extends Error {
17740
- name = "CliInputError";
17741
- };
17742
- //#endregion
17743
18091
  //#region src/cli/utils/is-expected-user-error.ts
17744
18092
  /**
17745
18093
  * Whether `error` is an expected, user-actionable failure — the user's project
@@ -18041,37 +18389,20 @@ const buildWorkflowContent = () => `# React Doctor — finds security, performan
18041
18389
  name: React Doctor
18042
18390
 
18043
18391
  on:
18392
+ # Scans the PR's changed files and posts a sticky summary comment listing only the new issues introduced relative to the merge base of the target branch.
18044
18393
  pull_request:
18045
18394
  types: [opened, synchronize, reopened, ready_for_review]
18046
- # Scans \`main\` on every push so you get a health-score trend on the
18047
- # default branch — useful for tracking the overall number commit-by-commit
18048
- # and catching regressions that slipped past PR review. PR-specific steps
18049
- # (the sticky summary comment) are skipped automatically on \`push\` events.
18050
- # Comment this block out if you only want PR-time scans.
18395
+ # Scans \`main\` on every push to track the health-score trend and catch regressions that slipped past PR review.
18051
18396
  push:
18052
18397
  branches: [main]
18053
18398
 
18054
18399
  permissions:
18055
- # \`actions/checkout\` needs this to read the repo source.
18056
18400
  contents: read
18057
- # Two uses: (1) reads the PR's changed-file list so the scan only checks
18058
- # what the PR touched (faster, scoped to the diff), and (2) posts/updates
18059
- # the sticky React Doctor summary comment on the PR. Downgrade \`write\` to
18060
- # \`read\` to keep the changed-file scan but disable comment posting.
18061
18401
  pull-requests: write
18062
- # The sticky-comment step uses GitHub's \`issues.createComment\` /
18063
- # \`issues.updateComment\` endpoints — those are the same APIs that back PR
18064
- # comments (PRs are issues under the hood). Not exercised on \`push\`
18065
- # events, so safe to drop if you only run on \`main\`.
18066
18402
  issues: write
18067
- # Lets the action publish a commit status with the score + error/warning
18068
- # counts (links to the run). This is how a \`push\` to \`main\` surfaces its
18069
- # result, since the PR comment is skipped off pull requests. Drop it to
18070
- # disable the status (or set \`commit-status: false\` below).
18071
18403
  statuses: write
18072
18404
 
18073
- # Cancels any in-flight scan for the same PR (or branch, on push) the moment
18074
- # a new commit arrives, so reviewers only ever see the latest run.
18405
+ # Cancels any in-flight scan for the same PR (or branch, on push) the moment a new commit arrives, so reviewers only ever see the latest run.
18075
18406
  concurrency:
18076
18407
  group: react-doctor-\${{ github.event.pull_request.number || github.ref }}
18077
18408
  cancel-in-progress: true
@@ -19301,29 +19632,6 @@ const getSkillSourceDirectory = () => {
19301
19632
  const distDirectory = path$1.dirname(fileURLToPath(import.meta.url));
19302
19633
  return path$1.join(distDirectory, "skills", SKILL_NAME);
19303
19634
  };
19304
- const findBundledSiblingSkills = (primarySkillDir) => {
19305
- const skillsParent = path$1.dirname(primarySkillDir);
19306
- if (!fs$1.existsSync(skillsParent)) return [];
19307
- const resolvedPrimary = path$1.resolve(primarySkillDir);
19308
- return fs$1.readdirSync(skillsParent, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => ({
19309
- name: entry.name,
19310
- source: path$1.join(skillsParent, entry.name)
19311
- })).filter((sibling) => path$1.resolve(sibling.source) !== resolvedPrimary && fs$1.existsSync(path$1.join(sibling.source, SKILL_MANIFEST_FILE)));
19312
- };
19313
- const installBundledSiblingSkills = async (primarySkillDir, agents, projectRoot) => {
19314
- const installedSkillNames = [];
19315
- for (const sibling of findBundledSiblingSkills(primarySkillDir)) {
19316
- const result = await installSkillsFromSource({
19317
- source: sibling.source,
19318
- agents: [...agents],
19319
- cwd: projectRoot,
19320
- mode: "copy"
19321
- });
19322
- if (result.failed.length > 0) throw new Error(result.failed.map((failure) => `${getSkillAgentConfig(failure.agent).displayName}: ${failure.error}`).join("\n"));
19323
- if (result.skills.length > 0) installedSkillNames.push(sibling.name);
19324
- }
19325
- return installedSkillNames;
19326
- };
19327
19635
  const canInstallNativeAgentHooks = (agents) => agents.some((agent) => agent === "claude-code" || agent === "cursor");
19328
19636
  const installReactDoctorSkillStep = async (sourceDir, selectedAgents, projectRoot) => {
19329
19637
  const installSpinner = spinner(`Installing ${SKILL_NAME} skill...`).start();
@@ -19341,12 +19649,6 @@ const installReactDoctorSkillStep = async (sourceDir, selectedAgents, projectRoo
19341
19649
  installSpinner.fail(`Failed to install ${SKILL_NAME} skill.`);
19342
19650
  throw error;
19343
19651
  }
19344
- try {
19345
- const installedSiblingSkills = await installBundledSiblingSkills(sourceDir, selectedAgents, projectRoot);
19346
- if (installedSiblingSkills.length > 0) cliLogger.dim(` Also installed the ${installedSiblingSkills.join(", ")} skill.`);
19347
- } catch {
19348
- cliLogger.dim(" Skipped bundled sibling skills (install error).");
19349
- }
19350
19652
  };
19351
19653
  const installReactDoctorGitHookStep = (gitHookTarget) => {
19352
19654
  const hookSpinner = spinner("Installing React Doctor pre-commit hook...").start();
@@ -19490,7 +19792,6 @@ const runInstallReactDoctor = async (options = {}) => {
19490
19792
  cliLogger.log(`Dry run — would install ${SKILL_NAME} skill for:`);
19491
19793
  for (const agent of selectedAgents) cliLogger.dim(` - ${getSkillAgentConfig(agent).displayName}`);
19492
19794
  cliLogger.dim(` Source: ${sourceDir}`);
19493
- for (const sibling of findBundledSiblingSkills(sourceDir)) cliLogger.dim(` Also installs skill: ${sibling.name}`);
19494
19795
  cliLogger.dim(" Package script: doctor (or react-doctor if doctor exists)");
19495
19796
  cliLogger.dim(" Dev dependency: react-doctor");
19496
19797
  if (shouldInstallGitHook) cliLogger.dim(` Git hook: ${gitHookPath}`);
@@ -19975,8 +20276,9 @@ const findLowestScoredScan = (completedScans) => {
19975
20276
  };
19976
20277
  const printMultiProjectSummary = (input) => Effect.gen(function* () {
19977
20278
  const { completedScans, userConfig, verbose, isOffline, projectName } = input;
20279
+ const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
19978
20280
  const animateRender = !verbose && canAnimateOnboarding(process.stdout);
19979
- const surfaceDiagnostics = filterDiagnosticsForSurface(completedScans.flatMap((scan) => scan.result.diagnostics), "cli", userConfig);
20281
+ const displayDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(completedScans.flatMap((scan) => scan.result.diagnostics), "cli", userConfig), categoryFilters);
19980
20282
  const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
19981
20283
  for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
19982
20284
  const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
@@ -19990,29 +20292,30 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
19990
20292
  const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
19991
20293
  const totalScanElapsedMilliseconds = completedScans.reduce((sum, scan) => sum + (scan.result.scanElapsedMilliseconds ?? scan.result.elapsedMilliseconds), 0);
19992
20294
  yield* Console.log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalScanElapsedMilliseconds)}`);
19993
- if (surfaceDiagnostics.length > 0) {
20295
+ if (displayDiagnostics.length > 0) {
19994
20296
  yield* Console.log("");
19995
- yield* printDiagnostics(surfaceDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
20297
+ yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
19996
20298
  }
19997
20299
  const lowestScoredScan = findLowestScoredScan(completedScans);
19998
20300
  const aggregateScore = lowestScoredScan?.result.score ?? null;
19999
20301
  const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
20000
20302
  yield* printSummary({
20001
- diagnostics: surfaceDiagnostics,
20303
+ diagnostics: displayDiagnostics,
20002
20304
  elapsedMilliseconds: completedScans.reduce((sum, scan) => sum + scan.result.elapsedMilliseconds, 0),
20003
20305
  scoreResult: aggregateScore,
20004
- potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(surfaceDiagnostics, lowestScoredScan.result.diagnostics, lowestScoredScan.result.score)) : null,
20306
+ potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(displayDiagnostics, filterDiagnosticsForSurface(lowestScoredScan.result.diagnostics, "cli", userConfig), lowestScoredScan.result.score)) : null,
20005
20307
  totalSourceFileCount,
20006
20308
  noScoreMessage: "Score unavailable.",
20007
20309
  verbose,
20008
20310
  animateProjection: animateRender
20009
20311
  });
20010
20312
  const entries = completedScans.map((scan) => {
20011
- const errorCount = scan.result.diagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
20313
+ const projectDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface([...scan.result.diagnostics], "cli", userConfig), categoryFilters);
20314
+ const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
20012
20315
  return {
20013
20316
  projectName: scan.result.project.projectName,
20014
20317
  score: scan.result.score?.score ?? null,
20015
- issueCount: scan.result.diagnostics.length,
20318
+ issueCount: projectDiagnostics.length,
20016
20319
  errorCount
20017
20320
  };
20018
20321
  });
@@ -20020,7 +20323,7 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
20020
20323
  yield* Console.log("");
20021
20324
  for (const entry of entries) yield* Console.log(buildSummaryLine(entry, longestProjectNameLength));
20022
20325
  yield* printFooter({
20023
- diagnostics: surfaceDiagnostics,
20326
+ diagnostics: displayDiagnostics,
20024
20327
  scoreResult: aggregateScore,
20025
20328
  projectName,
20026
20329
  isOffline
@@ -20110,7 +20413,8 @@ const resolveCliInspectOptions = (flags, userConfig) => {
20110
20413
  noScore: flags.score === false || flags.telemetry === false || (userConfig?.noScore ?? false),
20111
20414
  isCi: isCiEnvironment(),
20112
20415
  silent: Boolean(flags.json),
20113
- concurrency: resolveParallelFlag(flags.parallel)
20416
+ concurrency: resolveParallelFlag(flags.parallel),
20417
+ categoryFilters: resolveCliCategories(flags.category)
20114
20418
  };
20115
20419
  };
20116
20420
  //#endregion
@@ -20363,6 +20667,16 @@ const validateModeFlags = (flags) => {
20363
20667
  };
20364
20668
  //#endregion
20365
20669
  //#region src/cli/commands/inspect.ts
20670
+ const filterCompletedScansByCategories = (completedScans, categoryFilters) => {
20671
+ if (categoryFilters.size === 0) return [...completedScans];
20672
+ return completedScans.map((scan) => ({
20673
+ ...scan,
20674
+ result: {
20675
+ ...scan.result,
20676
+ diagnostics: filterDiagnosticsByCategories(scan.result.diagnostics, categoryFilters)
20677
+ }
20678
+ }));
20679
+ };
20366
20680
  /**
20367
20681
  * Post-scan finalization shared by the staged-arm and project-loop
20368
20682
  * paths of `inspectAction`: emit the JSON report (when in JSON mode)
@@ -20375,6 +20689,7 @@ const finalizeScans = (input) => {
20375
20689
  const baselineComputed = input.completedScans.length > 0 && input.completedScans.every((scan) => scan.result.baselineDelta !== void 0);
20376
20690
  const baselineDegraded = input.baselineIntended && !baselineComputed;
20377
20691
  const mode = baselineDegraded ? "diff" : input.mode;
20692
+ const jsonCompletedScans = filterCompletedScansByCategories(input.completedScans, input.categoryFilters);
20378
20693
  if (input.isJsonMode) {
20379
20694
  const baseline = baselineComputed && baselineDeltas.length > 0 ? {
20380
20695
  baseRef: baselineDeltas[0].baseRef,
@@ -20386,7 +20701,7 @@ const finalizeScans = (input) => {
20386
20701
  directory: input.resolvedDirectory,
20387
20702
  mode,
20388
20703
  diff: input.diff,
20389
- scans: input.completedScans,
20704
+ scans: jsonCompletedScans,
20390
20705
  totalElapsedMilliseconds: performance.now() - input.startTime,
20391
20706
  baseline
20392
20707
  }));
@@ -20460,6 +20775,7 @@ const inspectAction = async (directory, flags) => {
20460
20775
  await Effect.runPromise(playWelcomeScene({ speedMultiplier: isReturningUser ? 2 : 1 }));
20461
20776
  } else Effect.runSync(printBrandedHeader);
20462
20777
  const scanOptions = resolveCliInspectOptions(flags, userConfig);
20778
+ const categoryFilters = new Set(scanOptions.categoryFilters ?? []);
20463
20779
  const skipPrompts = shouldSkipPrompts({
20464
20780
  yes: flags.yes,
20465
20781
  json: flags.json
@@ -20520,6 +20836,7 @@ const inspectAction = async (directory, flags) => {
20520
20836
  isJsonMode,
20521
20837
  isScoreOnly,
20522
20838
  flags,
20839
+ categoryFilters,
20523
20840
  userConfig,
20524
20841
  resolvedDirectory,
20525
20842
  startTime
@@ -20579,6 +20896,7 @@ const inspectAction = async (directory, flags) => {
20579
20896
  const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
20580
20897
  await Effect.runPromise(printMultiProjectSummary({
20581
20898
  completedScans,
20899
+ categoryFilters,
20582
20900
  userConfig,
20583
20901
  verbose: Boolean(flags.verbose),
20584
20902
  isOffline: !shouldShowShareLink,
@@ -20594,14 +20912,15 @@ const inspectAction = async (directory, flags) => {
20594
20912
  isJsonMode,
20595
20913
  isScoreOnly,
20596
20914
  flags,
20915
+ categoryFilters,
20597
20916
  userConfig,
20598
20917
  resolvedDirectory,
20599
20918
  startTime
20600
20919
  });
20601
- const surfaceDiagnostics = filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig);
20602
- if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && surfaceDiagnostics.length > 0) {
20920
+ const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
20921
+ if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
20603
20922
  await handoffToAgent({
20604
- diagnostics: surfaceDiagnostics,
20923
+ diagnostics: selectedSurfaceDiagnostics,
20605
20924
  projectName: path$1.basename(resolvedDirectory),
20606
20925
  rootDirectory: resolvedDirectory,
20607
20926
  interactive: true
@@ -21032,7 +21351,7 @@ const rulesListAction = async (options) => {
21032
21351
  });
21033
21352
  const catalog = buildRuleCatalog();
21034
21353
  const config = validateConfigTypes((await resolveRuleConfigTarget(resolveProjectRoot(options))).config);
21035
- const categoryFilter = options.category?.toLowerCase();
21354
+ const categoryFilter = typeof options.category === "string" ? options.category.toLowerCase() : void 0;
21036
21355
  const frameworkFilter = options.framework?.toLowerCase();
21037
21356
  const rows = catalog.filter((entry) => {
21038
21357
  if (categoryFilter && entry.category.toLowerCase() !== categoryFilter) return false;
@@ -21395,6 +21714,7 @@ const ROOT_FLAG_SPEC = {
21395
21714
  "--yes"
21396
21715
  ]),
21397
21716
  longOptionsWithRequiredValues: new Set([
21717
+ "--category",
21398
21718
  "--changed-files-from",
21399
21719
  "--blocking",
21400
21720
  "--fail-on",
@@ -21551,6 +21871,7 @@ ${formatExampleLines([
21551
21871
  ["react-doctor ./apps/web", "scan a specific directory"],
21552
21872
  ["react-doctor --diff main", "scan only files changed vs. main"],
21553
21873
  ["react-doctor --staged", "scan staged files (pre-commit hook)"],
21874
+ ["react-doctor --category Security", "show only one diagnostic category"],
21554
21875
  ["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
21555
21876
  ["react-doctor --json > report.json", "write a machine-readable report"],
21556
21877
  ["react-doctor why src/App.tsx:42", "explain why a rule fired there"],
@@ -21579,7 +21900,8 @@ ${formatExampleLines([
21579
21900
  ${highlighter.dim("Learn more:")}
21580
21901
  ${highlighter.info(CANONICAL_GITHUB_URL)}
21581
21902
  `;
21582
- 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("--diff [base]", "scan only files changed vs base branch (pass `false` to force a full scan, overriding config)").addOption(new Option$1("--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").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$1("--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("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
21903
+ const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
21904
+ 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("--diff [base]", "scan only files changed vs base branch (pass `false` to force a full scan, overriding config)").addOption(new Option$1("--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$1("--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$1("--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("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
21583
21905
  program.action(inspectAction);
21584
21906
  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));
21585
21907
  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);
@@ -21622,4 +21944,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
21622
21944
  export {};
21623
21945
 
21624
21946
  //# sourceMappingURL=cli.js.map
21625
- //# debugId=92822f58-92ef-58d5-8850-2746c0b48fc0
21947
+ //# debugId=e5634721-88db-51c8-93e5-137793125d7a