react-doctor 0.2.17-dev.5614b32 → 0.2.18-dev.08e1d55

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/README.md CHANGED
@@ -64,7 +64,13 @@ jobs:
64
64
  runs-on: ubuntu-latest
65
65
  steps:
66
66
  - uses: actions/checkout@v5
67
- - uses: millionco/react-doctor@main
67
+ - uses: millionco/react-doctor@v1
68
+ ```
69
+
70
+ `@v1` always resolves to the latest `v1.x` release of the Action. For hardened CI — recommended whenever the workflow is granted `pull-requests: write` — pin to a full commit SHA instead and let Dependabot or Renovate keep it current:
71
+
72
+ ```yaml
73
+ - uses: millionco/react-doctor@b612664043a9be414166e3c6a69b355e39a8dcf4 # v1.1.1
68
74
  ```
69
75
 
70
76
  [Add GitHub Action →](https://github.com/marketplace/actions/react-doctor)
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]="f83fc141-ff41-5c96-8a8e-f4ea0399b0f2")}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]="32d58bb2-956f-5f5d-9f5b-3c3e922c17d2")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import { execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import * as Path from "node:path";
@@ -36,13 +36,13 @@ import * as ts from "typescript";
36
36
  import { gzipSync } from "node:zlib";
37
37
  import * as Sentry from "@sentry/node";
38
38
  import { performance } from "node:perf_hooks";
39
+ import { createHash, randomUUID } from "node:crypto";
39
40
  import * as Tracer from "effect/Tracer";
40
41
  import * as Exit from "effect/Exit";
41
42
  import { stripVTControlCharacters } from "node:util";
42
43
  import tty from "node:tty";
43
44
  import { codeFrameColumns } from "@babel/code-frame";
44
45
  import Conf from "conf";
45
- import { createHash, randomUUID } from "node:crypto";
46
46
  import basePrompts from "prompts";
47
47
  import { SKILL_MANIFEST_FILE, detectInstalledSkillAgents, getSkillAgentConfig, getSkillAgentTypes, installSkillsFromSource } from "agent-install";
48
48
  import { fileURLToPath } from "node:url";
@@ -5054,33 +5054,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
5054
5054
  value: mod,
5055
5055
  enumerable: true
5056
5056
  }) : target, mod));
5057
- /**
5058
- * Narrow errors raised by the project-discovery helpers
5059
- * (`discoverProject` / `resolveDiagnoseTarget` / `readPackageJson`).
5060
- *
5061
- * These extend `Error` directly — they are NOT the tagged
5062
- * `ReactDoctorError` from `../errors.js` (that one wraps every
5063
- * runtime-pipeline failure as a `Schema.TaggedErrorClass` for
5064
- * `Effect.catchReasons` dispatch). The split is intentional:
5065
- *
5066
- * - Discovery happens BEFORE the Effect runtime takes over — at the
5067
- * `diagnose()` / CLI entry point — and throws plain JS exceptions
5068
- * so callers can `try/catch` without an Effect-layer-aware
5069
- * `instanceof` check.
5070
- * - The Project service (`services/project.ts → translateProjectInfoError`)
5071
- * translates each of these into the equivalent tagged-error
5072
- * `reason` before re-raising inside the Effect pipeline, so the
5073
- * runtime never sees a non-tagged failure.
5074
- *
5075
- * If you're inside the Effect runtime, use the tagged
5076
- * `ReactDoctorError` from `../errors.js` instead.
5077
- */
5078
5057
  var ProjectNotFoundError = class extends Error {
5079
5058
  name = "ProjectNotFoundError";
5080
5059
  directory;
5060
+ kind;
5081
5061
  constructor(directory, options) {
5082
- super(`No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
5062
+ const kind = options?.kind ?? "no-project";
5063
+ super(kind === "missing-path" ? `Scan target "${directory}" does not exist. Check the path and try again.` : `No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
5083
5064
  this.directory = directory;
5065
+ this.kind = kind;
5084
5066
  }
5085
5067
  };
5086
5068
  var NoReactDependencyError = class extends Error {
@@ -5117,6 +5099,7 @@ var AmbiguousProjectError = class extends Error {
5117
5099
  this.candidates = candidates;
5118
5100
  }
5119
5101
  };
5102
+ const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
5120
5103
  const isFile = (filePath) => {
5121
5104
  try {
5122
5105
  return fs.statSync(filePath).isFile();
@@ -5174,7 +5157,10 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
5174
5157
  "EACCES",
5175
5158
  "EPERM",
5176
5159
  "ENOENT",
5177
- "ENOTDIR"
5160
+ "ENOTDIR",
5161
+ "EINVAL",
5162
+ "ELOOP",
5163
+ "ENAMETOOLONG"
5178
5164
  ]);
5179
5165
  const isIgnorableReaddirError = (error) => {
5180
5166
  if (typeof error !== "object" || error === null) return false;
@@ -5957,6 +5943,23 @@ const getExpoDependencySpec = (packageJson) => {
5957
5943
  return typeof spec === "string" ? spec : null;
5958
5944
  };
5959
5945
  const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
5946
+ const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
5947
+ const getShopifyFlashListDependencySpec = (packageJson) => {
5948
+ const spec = packageJson.dependencies?.["@shopify/flash-list"] ?? packageJson.devDependencies?.["@shopify/flash-list"] ?? packageJson.peerDependencies?.["@shopify/flash-list"] ?? packageJson.optionalDependencies?.["@shopify/flash-list"];
5949
+ return typeof spec === "string" ? spec : null;
5950
+ };
5951
+ const findShopifyFlashListVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getShopifyFlashListDependencySpec);
5952
+ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
5953
+ if (version === null || !isCatalogReference(version)) return version;
5954
+ const catalogName = extractCatalogName(version);
5955
+ const resolvedLocalVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
5956
+ if (resolvedLocalVersion) return resolvedLocalVersion;
5957
+ const monorepoRoot = findMonorepoRoot(rootDirectory);
5958
+ if (!monorepoRoot) return version;
5959
+ const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
5960
+ if (!isFile(monorepoPackageJsonPath)) return version;
5961
+ return resolveCatalogVersion(readPackageJson$1(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
5962
+ };
5960
5963
  const getPreactVersion = (packageJson) => {
5961
5964
  return {
5962
5965
  ...packageJson.peerDependencies,
@@ -6193,19 +6196,18 @@ const discoverProject = (directory) => {
6193
6196
  const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
6194
6197
  const sourceFileCount = countSourceFiles(directory);
6195
6198
  const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
6196
- let expoVersion = hasReactNativeWorkspace ? findExpoVersion(directory, packageJson) : null;
6197
- if (expoVersion !== null && isCatalogReference(expoVersion)) {
6198
- const catalogName = extractCatalogName(expoVersion);
6199
- let resolvedExpoVersion = resolveCatalogVersion(packageJson, "expo", directory, catalogName);
6200
- if (!resolvedExpoVersion) {
6201
- const monorepoRoot = findMonorepoRoot(directory);
6202
- if (monorepoRoot) {
6203
- const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
6204
- if (isFile(monorepoPackageJsonPath)) resolvedExpoVersion = resolveCatalogVersion(readPackageJson$1(monorepoPackageJsonPath), "expo", monorepoRoot, catalogName);
6205
- }
6206
- }
6207
- expoVersion = resolvedExpoVersion ?? expoVersion;
6208
- }
6199
+ const expoVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
6200
+ rootDirectory: directory,
6201
+ rootPackageJson: packageJson,
6202
+ packageName: "expo",
6203
+ version: findExpoVersion(directory, packageJson)
6204
+ }) : null;
6205
+ const shopifyFlashListVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
6206
+ rootDirectory: directory,
6207
+ rootPackageJson: packageJson,
6208
+ packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
6209
+ version: findShopifyFlashListVersion(directory, packageJson)
6210
+ }) : null;
6209
6211
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
6210
6212
  const preactVersion = getPreactVersion(packageJson);
6211
6213
  const projectInfo = {
@@ -6224,6 +6226,8 @@ const discoverProject = (directory) => {
6224
6226
  preactMajorVersion: parseReactMajor(preactVersion),
6225
6227
  hasReactNativeWorkspace,
6226
6228
  expoVersion,
6229
+ shopifyFlashListVersion,
6230
+ shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
6227
6231
  hasReanimated,
6228
6232
  sourceFileCount
6229
6233
  };
@@ -7701,7 +7705,7 @@ const resolveScanTarget = async (requestedDirectory, options = {}) => {
7701
7705
  const redirectedDirectory = resolveConfigRootDir(userConfig, configSourceDirectory);
7702
7706
  const directoryAfterRedirect = redirectedDirectory ?? absoluteRequested;
7703
7707
  const resolvedDirectory = resolveDiagnoseTarget(directoryAfterRedirect, options) ?? directoryAfterRedirect;
7704
- if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory);
7708
+ if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory, { kind: "missing-path" });
7705
7709
  return {
7706
7710
  resolvedDirectory,
7707
7711
  requestedDirectory: absoluteRequested,
@@ -8535,6 +8539,63 @@ const collectIgnorePatterns = (rootDirectory) => {
8535
8539
  cachedPatternsByRoot.set(rootDirectory, patterns);
8536
8540
  return patterns;
8537
8541
  };
8542
+ const KNIP_JSON_FILENAME = "knip.json";
8543
+ const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8544
+ const readJsonFileSafe = (filePath) => {
8545
+ let rawContents;
8546
+ try {
8547
+ rawContents = fs.readFileSync(filePath, "utf-8");
8548
+ } catch {
8549
+ return null;
8550
+ }
8551
+ try {
8552
+ return JSON.parse(rawContents);
8553
+ } catch {
8554
+ return null;
8555
+ }
8556
+ };
8557
+ const readKnipConfig = (rootDirectory) => {
8558
+ const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
8559
+ if (isRecord$1(knipJson)) return knipJson;
8560
+ const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
8561
+ const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
8562
+ return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
8563
+ };
8564
+ const normalizePatternList = (value) => {
8565
+ if (typeof value === "string" && value.length > 0) return [value];
8566
+ if (!Array.isArray(value)) return [];
8567
+ return value.filter((entry) => typeof entry === "string" && entry.length > 0);
8568
+ };
8569
+ const prefixWorkspacePatterns = (workspacePattern, patterns) => {
8570
+ const normalizedWorkspacePattern = workspacePattern.replace(/\/+$/, "");
8571
+ return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
8572
+ };
8573
+ const collectKnipWorkspacePatterns = (workspaces, settingName) => {
8574
+ if (!isRecord$1(workspaces)) return [];
8575
+ const patterns = [];
8576
+ for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
8577
+ if (!isRecord$1(workspaceConfig)) continue;
8578
+ patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
8579
+ }
8580
+ return patterns;
8581
+ };
8582
+ const collectKnipPatterns = (rootDirectory, settingName) => {
8583
+ const config = readKnipConfig(rootDirectory);
8584
+ if (!config) return [];
8585
+ return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
8586
+ };
8587
+ const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
8588
+ const seen = /* @__PURE__ */ new Set();
8589
+ const sources = [
8590
+ readIgnoreFile(path.join(rootDirectory, ".gitignore")),
8591
+ collectIgnorePatterns(rootDirectory),
8592
+ userConfig?.ignore?.files ?? [],
8593
+ collectKnipPatterns(rootDirectory, "ignore")
8594
+ ];
8595
+ for (const source of sources) for (const pattern of source) seen.add(pattern);
8596
+ return [...seen].filter((pattern) => pattern.length > 0);
8597
+ };
8598
+ const collectDeadCodeEntryPatterns = (rootDirectory) => [...new Set(collectKnipPatterns(rootDirectory, "entry"))].filter((pattern) => pattern.length > 0);
8538
8599
  /**
8539
8600
  * Resolves a path to its canonical, symlink-free form, falling back to
8540
8601
  * the input when it cannot be realpath'd (broken symlink, permission
@@ -8560,6 +8621,7 @@ const toCanonicalPath = (filePath) => {
8560
8621
  const DEAD_CODE_PLUGIN = "deslop";
8561
8622
  const DEAD_CODE_CATEGORY = "Maintainability";
8562
8623
  const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
8624
+ const isRecord$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8563
8625
  const DEAD_CODE_WORKER_SCRIPT = `
8564
8626
  const inputChunks = [];
8565
8627
  process.stdin.on("data", (chunk) => inputChunks.push(chunk));
@@ -8600,6 +8662,9 @@ process.stdin.on("end", () => {
8600
8662
  const { analyze, defineConfig } = await import(workerInput.deslopJsModuleSpecifier);
8601
8663
  const config = {
8602
8664
  rootDir: workerInput.rootDirectory,
8665
+ ...(workerInput.entryPatterns.length > 0
8666
+ ? { entryPatterns: workerInput.entryPatterns }
8667
+ : {}),
8603
8668
  ...(workerInput.tsConfigPath ? { tsConfigPath: workerInput.tsConfigPath } : {}),
8604
8669
  ...(workerInput.ignorePatterns.length > 0
8605
8670
  ? { ignorePatterns: workerInput.ignorePatterns }
@@ -8619,21 +8684,10 @@ const resolveTsConfigPath = (rootDirectory) => {
8619
8684
  if (fs.existsSync(candidate)) return candidate;
8620
8685
  }
8621
8686
  };
8622
- const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
8623
- const seen = /* @__PURE__ */ new Set();
8624
- const sources = [
8625
- readIgnoreFile(path.join(rootDirectory, ".gitignore")),
8626
- collectIgnorePatterns(rootDirectory),
8627
- userConfig?.ignore?.files ?? []
8628
- ];
8629
- for (const source of sources) for (const pattern of source) seen.add(pattern);
8630
- return [...seen].filter((pattern) => pattern.length > 0);
8631
- };
8632
8687
  const toRelativeFilePath = (rootDirectory, filePath) => {
8633
8688
  const relative = toRelativePath(filePath, rootDirectory);
8634
8689
  return relative.length > 0 ? relative : filePath.replace(/\\/g, "/");
8635
8690
  };
8636
- const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8637
8691
  const parseArray = (value, label) => {
8638
8692
  if (!Array.isArray(value)) throw new Error(`Dead-code worker returned invalid ${label}.`);
8639
8693
  return value;
@@ -8657,7 +8711,7 @@ const parseUnusedFiles = (value) => {
8657
8711
  const values = parseArray(value, "unusedFiles");
8658
8712
  const unusedFiles = [];
8659
8713
  for (const [index, entry] of values.entries()) {
8660
- if (!isRecord$1(entry)) throw new Error(`Dead-code worker returned invalid unusedFiles[${index}].`);
8714
+ if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedFiles[${index}].`);
8661
8715
  unusedFiles.push({ path: parseString(entry.path, `unusedFiles[${index}].path`) });
8662
8716
  }
8663
8717
  return unusedFiles;
@@ -8666,7 +8720,7 @@ const parseUnusedExports = (value) => {
8666
8720
  const values = parseArray(value, "unusedExports");
8667
8721
  const unusedExports = [];
8668
8722
  for (const [index, entry] of values.entries()) {
8669
- if (!isRecord$1(entry)) throw new Error(`Dead-code worker returned invalid unusedExports[${index}].`);
8723
+ if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedExports[${index}].`);
8670
8724
  unusedExports.push({
8671
8725
  path: parseString(entry.path, `unusedExports[${index}].path`),
8672
8726
  name: parseString(entry.name, `unusedExports[${index}].name`),
@@ -8681,7 +8735,7 @@ const parseUnusedDependencies = (value) => {
8681
8735
  const values = parseArray(value, "unusedDependencies");
8682
8736
  const unusedDependencies = [];
8683
8737
  for (const [index, entry] of values.entries()) {
8684
- if (!isRecord$1(entry)) throw new Error(`Dead-code worker returned invalid unusedDependencies[${index}].`);
8738
+ if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedDependencies[${index}].`);
8685
8739
  unusedDependencies.push({
8686
8740
  name: parseString(entry.name, `unusedDependencies[${index}].name`),
8687
8741
  isDevDependency: parseBoolean(entry.isDevDependency, `unusedDependencies[${index}].isDevDependency`)
@@ -8693,13 +8747,13 @@ const parseCircularDependencies = (value) => {
8693
8747
  const values = parseArray(value, "circularDependencies");
8694
8748
  const circularDependencies = [];
8695
8749
  for (const [index, entry] of values.entries()) {
8696
- if (!isRecord$1(entry)) throw new Error(`Dead-code worker returned invalid circularDependencies[${index}].`);
8750
+ if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid circularDependencies[${index}].`);
8697
8751
  circularDependencies.push({ files: parseStringArray(entry.files, `circularDependencies[${index}].files`) });
8698
8752
  }
8699
8753
  return circularDependencies;
8700
8754
  };
8701
8755
  const parseDeadCodeWorkerResult = (value) => {
8702
- if (!isRecord$1(value)) throw new Error("Dead-code worker returned an invalid result.");
8756
+ if (!isRecord$2(value)) throw new Error("Dead-code worker returned an invalid result.");
8703
8757
  return {
8704
8758
  unusedFiles: parseUnusedFiles(value.unusedFiles),
8705
8759
  unusedExports: parseUnusedExports(value.unusedExports),
@@ -8708,7 +8762,7 @@ const parseDeadCodeWorkerResult = (value) => {
8708
8762
  };
8709
8763
  };
8710
8764
  const parseDeadCodeWorkerError = (value) => {
8711
- if (!isRecord$1(value) || typeof value.message !== "string") return { message: "Dead-code worker failed." };
8765
+ if (!isRecord$2(value) || typeof value.message !== "string") return { message: "Dead-code worker failed." };
8712
8766
  return {
8713
8767
  ...typeof value.name === "string" ? { name: value.name } : {},
8714
8768
  message: value.message,
@@ -8716,7 +8770,7 @@ const parseDeadCodeWorkerError = (value) => {
8716
8770
  };
8717
8771
  };
8718
8772
  const parseDeadCodeWorkerMessage = (value) => {
8719
- if (!isRecord$1(value)) throw new Error("Dead-code worker returned an invalid message.");
8773
+ if (!isRecord$2(value)) throw new Error("Dead-code worker returned an invalid message.");
8720
8774
  if (value.ok === true) return {
8721
8775
  ok: true,
8722
8776
  result: value.result
@@ -8816,9 +8870,11 @@ const checkDeadCode = async (options) => {
8816
8870
  const { userConfig } = options;
8817
8871
  const rootDirectory = toCanonicalPath(options.rootDirectory);
8818
8872
  if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
8873
+ const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
8819
8874
  const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
8820
8875
  const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
8821
8876
  rootDirectory,
8877
+ entryPatterns,
8822
8878
  tsConfigPath: resolveTsConfigPath(rootDirectory),
8823
8879
  ignorePatterns,
8824
8880
  deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js")
@@ -9203,7 +9259,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
9203
9259
  if (result.status !== 0) return null;
9204
9260
  const branch = trimOrNull(result.stdout);
9205
9261
  return branch === "HEAD" ? null : branch;
9206
- }));
9262
+ }), Effect.orElseSucceed(() => null));
9207
9263
  const defaultBranch = (directory) => Effect.gen(function* () {
9208
9264
  const symref = yield* runGit(directory, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
9209
9265
  if (symref.status === 0) {
@@ -9892,6 +9948,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
9892
9948
  settings: { "react-doctor": {
9893
9949
  framework: project.framework,
9894
9950
  rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
9951
+ ...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
9895
9952
  ...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
9896
9953
  } },
9897
9954
  rules: {
@@ -11113,6 +11170,7 @@ const calculateScore = async (diagnostics, options = {}) => {
11113
11170
  ...typeof options.metadata?.sourceFileCount === "number" ? { sourceFileCount: options.metadata.sourceFileCount } : {},
11114
11171
  ...options.metadata?.defaultBranch ? { defaultBranch: options.metadata.defaultBranch } : {},
11115
11172
  ...options.metadata?.doctorVersion ? { doctorVersion: options.metadata.doctorVersion } : {},
11173
+ ...options.metadata?.runId ? { runId: options.metadata.runId } : {},
11116
11174
  ...options.metadata?.githubEventName ? { githubEventName: options.metadata.githubEventName } : {},
11117
11175
  ...options.metadata?.githubActorAssociation ? { githubActorAssociation: options.metadata.githubActorAssociation } : {},
11118
11176
  ...options.metadata?.githubViewerPermission ? { githubViewerPermission: options.metadata.githubViewerPermission } : {}
@@ -11352,6 +11410,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
11352
11410
  sourceFileCount: project.sourceFileCount,
11353
11411
  ...defaultBranch !== null ? { defaultBranch } : {},
11354
11412
  ...input.doctorVersion !== void 0 ? { doctorVersion: input.doctorVersion } : {},
11413
+ ...input.runId !== void 0 ? { runId: input.runId } : {},
11355
11414
  ...githubActionsScoreMetadata,
11356
11415
  ...githubViewerPermission !== null ? { githubViewerPermission } : {}
11357
11416
  };
@@ -11808,6 +11867,14 @@ const CI_PROVIDER_BY_ENVIRONMENT_VARIABLE = [
11808
11867
  ["TRAVIS", "travis"],
11809
11868
  ["DRONE", "drone"]
11810
11869
  ];
11870
+ const GITHUB_ACTION_MARKER_ENVIRONMENT_VARIABLE = "REACT_DOCTOR_GITHUB_ACTION";
11871
+ const ACTION_INPUT_ENVIRONMENT_VARIABLES = {
11872
+ failOn: "REACT_DOCTOR_ACTION_FAIL_ON",
11873
+ nonBlocking: "REACT_DOCTOR_ACTION_NON_BLOCKING",
11874
+ comment: "REACT_DOCTOR_ACTION_COMMENT",
11875
+ annotations: "REACT_DOCTOR_ACTION_ANNOTATIONS",
11876
+ version: "REACT_DOCTOR_ACTION_VERSION"
11877
+ };
11811
11878
  const CODING_AGENT_BY_ENVIRONMENT_VARIABLE = [
11812
11879
  ["CLAUDECODE", "claude-code"],
11813
11880
  ["CLAUDE_CODE", "claude-code"],
@@ -11834,6 +11901,9 @@ const detectCiProvider = () => {
11834
11901
  for (const [environmentVariable, provider] of CI_PROVIDER_BY_ENVIRONMENT_VARIABLE) if (process.env[environmentVariable]) return provider;
11835
11902
  return isCiFlagSet(process.env.CI) ? "unknown" : null;
11836
11903
  };
11904
+ const isOfficialGithubAction = () => Boolean(process.env[GITHUB_ACTION_MARKER_ENVIRONMENT_VARIABLE]);
11905
+ const detectCiEventName = () => process.env.GITHUB_EVENT_NAME?.trim() || null;
11906
+ const detectRunnerOs = () => process.env.RUNNER_OS?.trim() || null;
11837
11907
  const detectCodingAgentFromValue = () => {
11838
11908
  for (const environmentVariable of CODING_AGENT_ENVIRONMENT_VALUE_VARIABLES) {
11839
11909
  const value = process.env[environmentVariable]?.toLowerCase();
@@ -11948,7 +12018,7 @@ const makeNoopConsole = () => ({
11948
12018
  });
11949
12019
  //#endregion
11950
12020
  //#region src/cli/utils/version.ts
11951
- const VERSION = "0.2.17-dev.5614b32";
12021
+ const VERSION = "0.2.18-dev.08e1d55";
11952
12022
  //#endregion
11953
12023
  //#region src/cli/utils/json-mode.ts
11954
12024
  let context = null;
@@ -12021,6 +12091,13 @@ const writeJsonErrorReport = (error) => {
12021
12091
  }
12022
12092
  };
12023
12093
  //#endregion
12094
+ //#region src/cli/utils/run-id.ts
12095
+ let cachedRunId;
12096
+ const getRunId = () => {
12097
+ cachedRunId ??= randomUUID();
12098
+ return cachedRunId;
12099
+ };
12100
+ //#endregion
12024
12101
  //#region src/cli/utils/scrub-sensitive-text.ts
12025
12102
  const HOME_DIRECTORY = os.homedir();
12026
12103
  const USER_HOME_PATTERNS = [/[A-Za-z]:[\\/]Users[\\/][^\\/]+/gi, /(?:\/Users\/|\/home\/)[^/\\]+/gi];
@@ -12075,6 +12152,7 @@ const buildRunContext = () => {
12075
12152
  const userArguments = process.argv.slice(2);
12076
12153
  return {
12077
12154
  version: VERSION,
12155
+ runId: getRunId(),
12078
12156
  origin: detectOrigin(),
12079
12157
  command: detectCommand(userArguments),
12080
12158
  argv: scrubSensitivePaths(userArguments.join(" ")),
@@ -12085,6 +12163,8 @@ const buildRunContext = () => {
12085
12163
  arch: process.arch,
12086
12164
  ci: isCiEnvironment(),
12087
12165
  ciProvider: detectCiProvider(),
12166
+ eventName: detectCiEventName(),
12167
+ viaAction: isOfficialGithubAction(),
12088
12168
  codingAgent: detectCodingAgent(),
12089
12169
  interactive: !isNonInteractiveEnvironment(),
12090
12170
  jsonMode: isJsonModeActive(),
@@ -12153,6 +12233,8 @@ const buildSentryScope = (runContext = buildRunContext()) => {
12153
12233
  command: runContext.command,
12154
12234
  ci: runContext.ci,
12155
12235
  ciProvider: runContext.ciProvider,
12236
+ eventName: runContext.eventName,
12237
+ viaAction: runContext.viaAction,
12156
12238
  codingAgent: runContext.codingAgent,
12157
12239
  interactive: runContext.interactive,
12158
12240
  jsonMode: runContext.jsonMode,
@@ -12294,13 +12376,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12294
12376
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12295
12377
  * standard `SENTRY_RELEASE` override.
12296
12378
  */
12297
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.17-dev.5614b32`;
12379
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.08e1d55`;
12298
12380
  /**
12299
12381
  * Deployment environment shown in Sentry's environment filter. Defaults to
12300
12382
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12301
12383
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12302
12384
  */
12303
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.17-dev.5614b32") ? "development" : "production");
12385
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.08e1d55") ? "development" : "production");
12304
12386
  /**
12305
12387
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12306
12388
  * (set to `0` to disable tracing) and falls back to
@@ -15757,6 +15839,152 @@ const recordScanMetrics = (input) => {
15757
15839
  });
15758
15840
  };
15759
15841
  //#endregion
15842
+ //#region src/cli/utils/should-fail-for-diagnostics.ts
15843
+ const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
15844
+ if (failOnLevel === "none") return false;
15845
+ if (failOnLevel === "warning") return diagnostics.length > 0;
15846
+ return diagnostics.some((diagnostic) => diagnostic.severity === "error");
15847
+ };
15848
+ //#endregion
15849
+ //#region src/cli/utils/build-run-event.ts
15850
+ const FAIL_ON_LEVELS = new Set([
15851
+ "error",
15852
+ "warning",
15853
+ "none"
15854
+ ]);
15855
+ const readEnvBoolean = (name) => {
15856
+ const value = process.env[name];
15857
+ if (value === void 0) return null;
15858
+ return value.toLowerCase() === "true" || value === "1";
15859
+ };
15860
+ const resolveVersionPin = (versionInput) => {
15861
+ if (versionInput === void 0 || versionInput.trim() === "") return null;
15862
+ if (versionInput === "latest") return "latest";
15863
+ if (/^(\.\.?\/|\/)/.test(versionInput)) return "local";
15864
+ return "pinned";
15865
+ };
15866
+ const resolveTelemetryFailOn = (userConfig) => {
15867
+ const fromAction = process.env[ACTION_INPUT_ENVIRONMENT_VARIABLES.failOn];
15868
+ if (fromAction !== void 0 && FAIL_ON_LEVELS.has(fromAction)) return fromAction;
15869
+ return userConfig?.failOn ?? "none";
15870
+ };
15871
+ const toCategoryKey = (category) => category.toLowerCase().replace(/[^a-z0-9]+/g, "_");
15872
+ const buildOutcomeAttributes = (input) => {
15873
+ if (input.result === void 0) {
15874
+ const error = input.error;
15875
+ const known = isReactDoctorError(error);
15876
+ return {
15877
+ outcome: "error",
15878
+ exitCode: 1,
15879
+ knownError: known,
15880
+ errorTag: known ? error.reason._tag : error instanceof Error ? error.name : null
15881
+ };
15882
+ }
15883
+ const result = input.result;
15884
+ const summary = summarizeDiagnostics(result.diagnostics);
15885
+ const failOnLevel = resolveTelemetryFailOn(input.userConfig);
15886
+ const gateDiagnostics = filterDiagnosticsForSurface(result.diagnostics, "ciFailure", input.userConfig);
15887
+ const wouldBlock = !input.scoreOnly && shouldFailForDiagnostics(gateDiagnostics, failOnLevel);
15888
+ const hasSkippedChecks = result.skippedChecks.length > 0;
15889
+ const isClean = result.diagnostics.length === 0 && !hasSkippedChecks;
15890
+ const outcome = wouldBlock ? "blocked" : isClean ? "clean" : "ok";
15891
+ const firings = summarizeRuleFirings(result.diagnostics);
15892
+ const countByRule = /* @__PURE__ */ new Map();
15893
+ const countByCategory = /* @__PURE__ */ new Map();
15894
+ for (const firing of firings) {
15895
+ countByRule.set(firing.rule, (countByRule.get(firing.rule) ?? 0) + firing.count);
15896
+ countByCategory.set(firing.category, (countByCategory.get(firing.category) ?? 0) + firing.count);
15897
+ }
15898
+ let topRule = null;
15899
+ let topRuleCount = 0;
15900
+ for (const [rule, count] of countByRule) if (count > topRuleCount) {
15901
+ topRule = rule;
15902
+ topRuleCount = count;
15903
+ }
15904
+ const attributes = {
15905
+ outcome,
15906
+ exitCode: wouldBlock ? 1 : 0,
15907
+ wouldBlock,
15908
+ failOn: failOnLevel,
15909
+ scanClean: isClean,
15910
+ totalDiagnostics: summary.totalDiagnosticCount,
15911
+ errorCount: summary.errorCount,
15912
+ warningCount: summary.warningCount,
15913
+ affectedFiles: summary.affectedFileCount,
15914
+ distinctRulesFired: countByRule.size,
15915
+ topRule,
15916
+ scannedFileCount: result.scannedFileCount ?? null,
15917
+ elapsedMs: result.elapsedMilliseconds,
15918
+ scanPhaseMs: result.scanElapsedMilliseconds ?? null,
15919
+ score: result.score ? result.score.score : null,
15920
+ scoreLabel: result.score ? result.score.label : null,
15921
+ scoreAvailable: result.score !== null,
15922
+ skippedCheckCount: result.skippedChecks.length,
15923
+ didLintFail: input.didLintFail ?? null,
15924
+ lintFailureReasonKind: input.lintFailureReasonKind ?? null,
15925
+ lintPartialFailureCount: input.lintPartialFailureCount ?? null,
15926
+ didDeadCodeFail: input.didDeadCodeFail ?? null
15927
+ };
15928
+ for (const [category, count] of countByCategory) attributes[`diag.category.${toCategoryKey(category)}`] = count;
15929
+ return attributes;
15930
+ };
15931
+ const buildCiAttributes = () => {
15932
+ const { githubActorAssociation } = resolveGithubActionsScoreMetadata();
15933
+ return {
15934
+ actorAssociation: githubActorAssociation ?? null,
15935
+ runnerOs: detectRunnerOs(),
15936
+ nonBlocking: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.nonBlocking),
15937
+ comment: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.comment),
15938
+ annotations: readEnvBoolean(ACTION_INPUT_ENVIRONMENT_VARIABLES.annotations),
15939
+ versionPin: resolveVersionPin(process.env[ACTION_INPUT_ENVIRONMENT_VARIABLES.version])
15940
+ };
15941
+ };
15942
+ const buildConfigAttributes = (input) => {
15943
+ const ruleOverrides = input.userConfig?.rules ?? {};
15944
+ const ruleKeys = Object.keys(ruleOverrides);
15945
+ return {
15946
+ mode: input.mode,
15947
+ parallel: input.parallel,
15948
+ workerCount: input.workerCount ?? null,
15949
+ lint: input.lint,
15950
+ deadCode: input.deadCode,
15951
+ scoreOnly: input.scoreOnly,
15952
+ noScore: input.noScore,
15953
+ respectInlineDisables: input.respectInlineDisables,
15954
+ showWarnings: input.showWarnings,
15955
+ ignoredTagCount: input.ignoredTagCount,
15956
+ hasCustomConfig: input.hasCustomConfig,
15957
+ rulesConfigured: ruleKeys.length,
15958
+ rulesDisabled: ruleKeys.filter((key) => ruleOverrides[key] === "off").length
15959
+ };
15960
+ };
15961
+ /**
15962
+ * Projects a scan into the flat attribute set for its root span — the canonical
15963
+ * per-scan "wide event". Pure and exported so the projection (outcome
15964
+ * precedence, rule/category rollups, CI knobs, config shape) is unit-testable
15965
+ * without a live Sentry client. `null` values are dropped so absent signals
15966
+ * never become misleading `"null"` attributes. The run + project base context
15967
+ * (version, command, ci/provider, framework, …) is already on the span from
15968
+ * `withSentryRunSpan` / `recordSentryProjectContext`, so this adds only what
15969
+ * those don't carry.
15970
+ */
15971
+ const buildRunEventAttributes = (input) => toSpanAttributes({
15972
+ ...buildConfigAttributes(input),
15973
+ ...buildCiAttributes(),
15974
+ ...buildOutcomeAttributes(input)
15975
+ });
15976
+ /**
15977
+ * Stamps the wide-event attributes onto the run's root span. A guarded no-op
15978
+ * when tracing is off (no `rootSpan`) and swallow-on-throw, so telemetry can
15979
+ * never break the run.
15980
+ */
15981
+ const recordRunEvent = (rootSpan, input) => {
15982
+ if (!rootSpan) return;
15983
+ try {
15984
+ rootSpan.setAttributes(buildRunEventAttributes(input));
15985
+ } catch {}
15986
+ };
15987
+ //#endregion
15760
15988
  //#region src/cli/utils/build-no-score-message.ts
15761
15989
  const ENTERPRISE_CONTACT_HINT = `Want something custom to your company? Contact us at ${ENTERPRISE_CONTACT_URL}.`;
15762
15990
  const buildNoScoreMessage = (isScoreDisabled) => {
@@ -16061,7 +16289,7 @@ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, rende
16061
16289
  const fixRecipeLine = formatFixRecipeLine(representative);
16062
16290
  if (fixRecipeLine) lines.push(highlighter.gray(`${TOP_ERROR_DETAIL_INDENT}${fixRecipeLine}`));
16063
16291
  }
16064
- const renderCodeFrame = severity === "error" || renderEverySite;
16292
+ const renderCodeFrame = severity === "error";
16065
16293
  const sites = renderEverySite ? ruleDiagnostics : [representative];
16066
16294
  for (const cluster of clusterNearbyDiagnostics(sites)) lines.push(...buildDiagnosticClusterLines(cluster, resolveSourceRoot, renderCodeFrame));
16067
16295
  return lines;
@@ -16687,6 +16915,19 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
16687
16915
  suppressRendering: inputOptions.suppressRendering ?? false,
16688
16916
  concurrency: inputOptions.concurrency
16689
16917
  });
16918
+ const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
16919
+ parallel: options.concurrency !== void 0,
16920
+ workerCount: options.concurrency,
16921
+ lint: options.lint,
16922
+ deadCode: options.deadCode,
16923
+ scoreOnly: options.scoreOnly,
16924
+ noScore: options.noScore,
16925
+ respectInlineDisables: options.respectInlineDisables,
16926
+ showWarnings: options.warnings,
16927
+ ignoredTagCount: options.ignoredTags.size,
16928
+ hasCustomConfig,
16929
+ userConfig
16930
+ });
16690
16931
  const inspect = async (directory, inputOptions = {}) => {
16691
16932
  const startTime = performance.now();
16692
16933
  resetSentryRunState();
@@ -16708,7 +16949,18 @@ const inspect = async (directory, inputOptions = {}) => {
16708
16949
  const wasSpinnerSilent = isSpinnerSilent();
16709
16950
  if (options.silent) setSpinnerSilent(true);
16710
16951
  try {
16711
- const result = await withSentryRunSpan((rootSentrySpan) => runInspectWithRuntime(scanDirectory, options, userConfig, hasConfigOverride, configSourceDirectory, startTime, rootSentrySpan));
16952
+ const result = await withSentryRunSpan(async (rootSentrySpan) => {
16953
+ try {
16954
+ return await runInspectWithRuntime(scanDirectory, options, userConfig, hasConfigOverride, configSourceDirectory, startTime, rootSentrySpan);
16955
+ } catch (error) {
16956
+ recordRunEvent(rootSentrySpan, {
16957
+ ...buildRunEventConfig(options, userConfig, userConfig !== null),
16958
+ mode: options.includePaths.length > 0 ? "diff" : "full",
16959
+ error
16960
+ });
16961
+ throw error;
16962
+ }
16963
+ });
16712
16964
  resetSentryRunState();
16713
16965
  return result;
16714
16966
  } finally {
@@ -16743,6 +16995,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
16743
16995
  runDeadCode: options.deadCode,
16744
16996
  isCi: options.isCi,
16745
16997
  doctorVersion: VERSION,
16998
+ runId: getRunId(),
16746
16999
  resolveLocalGithubViewerPermission: !options.noScore,
16747
17000
  suppressScanSummary: options.suppressRendering
16748
17001
  }, { beforeLint: (projectInfo, lintIncludePaths) => Effect.gen(function* () {
@@ -16806,6 +17059,15 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
16806
17059
  lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
16807
17060
  didDeadCodeFail: output.didDeadCodeFail
16808
17061
  });
17062
+ recordRunEvent(rootSentrySpan, {
17063
+ ...buildRunEventConfig(options, userConfig, userConfig !== null),
17064
+ result,
17065
+ mode: isDiffMode ? "diff" : "full",
17066
+ didLintFail,
17067
+ lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
17068
+ lintPartialFailureCount: output.lintPartialFailures.length,
17069
+ didDeadCodeFail: output.didDeadCodeFail
17070
+ });
16809
17071
  return result;
16810
17072
  };
16811
17073
  const finalizeAndRender = (input) => Effect.gen(function* () {
@@ -17019,6 +17281,49 @@ const handleUserError = (error, options = {}) => {
17019
17281
  process.exitCode = 1;
17020
17282
  };
17021
17283
  //#endregion
17284
+ //#region src/cli/utils/cli-input-error.ts
17285
+ /**
17286
+ * A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
17287
+ * argument, mutually exclusive flags, or an unknown `--project` name. This is
17288
+ * user input, not a react-doctor bug, so `isExpectedUserError` routes it
17289
+ * through `handleUserError`: a clean, single-line message with no Sentry
17290
+ * report and no "Something went wrong, open a prefilled issue" block.
17291
+ *
17292
+ * The `message` is rendered verbatim, so it must read as a complete,
17293
+ * human-readable sentence that tells the user how to fix their invocation.
17294
+ */
17295
+ var CliInputError = class extends Error {
17296
+ name = "CliInputError";
17297
+ };
17298
+ //#endregion
17299
+ //#region src/cli/utils/is-expected-user-error.ts
17300
+ /**
17301
+ * Whether `error` is an expected, user-actionable failure — the user's project
17302
+ * or input, not a react-doctor bug. Such failures must be kept out of crash
17303
+ * reporting (Sentry + the alertable error-rate metric) and rendered via
17304
+ * `handleUserError` (a plain message — no "Something went wrong", prefilled
17305
+ * issue, Discord link, or Sentry reference), since there is no bug to report.
17306
+ *
17307
+ * Three distinct shapes reach the CLI's catch blocks:
17308
+ *
17309
+ * - **Project-discovery failures** (`NoReactDependencyError`,
17310
+ * `ProjectNotFoundError`, `PackageJsonNotFoundError`, `NotADirectoryError`,
17311
+ * `AmbiguousProjectError`) arrive as their plain legacy classes (so
17312
+ * `isReactDoctorError` is `false` for them) — narrow with
17313
+ * `isProjectDiscoveryError`. Running react-doctor against a directory that
17314
+ * has no React, or a path that doesn't exist, is the canonical example.
17315
+ * - **CLI invocation mistakes** (`CliInputError`): a malformed
17316
+ * `<file>:<line>` argument, mutually exclusive flags, or an unknown
17317
+ * `--project` name.
17318
+ * - **Bad `--diff` input** (`GitBaseBranchInvalid` / `GitBaseBranchMissing`)
17319
+ * stays the tagged `ReactDoctorError`, so dispatch on the reason `_tag`.
17320
+ *
17321
+ * This composes the existing core narrowers rather than introducing a new
17322
+ * error-shape helper (AGENTS.md): it encodes CLI-layer reporting policy, not
17323
+ * knowledge of the `ReactDoctorError` shape.
17324
+ */
17325
+ const isExpectedUserError = (error) => error instanceof CliInputError || isProjectDiscoveryError(error) || isReactDoctorError(error) && (error.reason._tag === "GitBaseBranchInvalid" || error.reason._tag === "GitBaseBranchMissing");
17326
+ //#endregion
17022
17327
  //#region src/cli/utils/build-handoff-payload.ts
17023
17328
  const buildHandoffPayload = (input) => {
17024
17329
  const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
@@ -18543,6 +18848,7 @@ const playWelcomeScene = () => Effect.gen(function* () {
18543
18848
  */
18544
18849
  const reportErrorToSentry = async (error) => {
18545
18850
  if (!Sentry.isInitialized()) return void 0;
18851
+ if (isExpectedUserError(error)) return void 0;
18546
18852
  try {
18547
18853
  const { tags, contexts } = buildSentryScope();
18548
18854
  let reason = "unknown";
@@ -18584,7 +18890,13 @@ const isSafeRelativePath = (filePath) => {
18584
18890
  return normalized === filePath;
18585
18891
  };
18586
18892
  const readChangedFilesFrom = (filePath) => {
18587
- const raw = fs.readFileSync(filePath, "utf8");
18893
+ let raw;
18894
+ try {
18895
+ raw = fs.readFileSync(filePath, "utf8");
18896
+ } catch (error) {
18897
+ const errorCode = error?.code;
18898
+ throw new CliInputError(`Could not read the --changed-files-from file "${filePath}"${errorCode ? ` (${errorCode})` : ""}. Pass a path to a readable text file that lists changed files, one per line.`);
18899
+ }
18588
18900
  const uniqueFiles = /* @__PURE__ */ new Set();
18589
18901
  for (const line of raw.split(/\r?\n/)) {
18590
18902
  const candidate = toForwardSlashes(line.trim());
@@ -18682,7 +18994,11 @@ const getSetupPromptStore = (options = {}) => new Conf({
18682
18994
  });
18683
18995
  const getSetupPromptProjectKey = (projectRoot) => createHash("sha256").update(path.resolve(projectRoot)).digest("hex");
18684
18996
  const hasDisabledSetupPrompt = (projectRoot, storeOptions = {}) => {
18685
- return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
18997
+ try {
18998
+ return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
18999
+ } catch {
19000
+ return false;
19001
+ }
18686
19002
  };
18687
19003
  const resolveInstallSetupProjectRoot = (options) => {
18688
19004
  if (options.scanDirectories.length === 0) return findNearestPackageDirectory(options.scanRoot) ?? options.scanRoot;
@@ -18900,12 +19216,12 @@ const findOwningProjectDirectory = (rootDirectory, filePath) => {
18900
19216
  //#region src/cli/utils/parse-file-line-argument.ts
18901
19217
  const parseFileLineArgument = (rawArgument) => {
18902
19218
  const lastColonIndex = rawArgument.lastIndexOf(":");
18903
- if (lastColonIndex < 0) throw new Error(`Expected "<file>:<line>" (e.g. "src/foo.tsx:42"), got "${rawArgument}".`);
19219
+ if (lastColonIndex < 0) throw new CliInputError(`Expected "<file>:<line>" (e.g. "src/foo.tsx:42"), got "${rawArgument}".`);
18904
19220
  const filePath = rawArgument.slice(0, lastColonIndex);
18905
19221
  const lineText = rawArgument.slice(lastColonIndex + 1);
18906
- if (filePath.length === 0) throw new Error(`Missing file path in "${rawArgument}".`);
19222
+ if (filePath.length === 0) throw new CliInputError(`Missing file path in "${rawArgument}".`);
18907
19223
  const line = Number.parseInt(lineText, 10);
18908
- if (!Number.isFinite(line) || line <= 0 || String(line) !== lineText.trim()) throw new Error(`Expected a positive line number in "${rawArgument}".`);
19224
+ if (!Number.isFinite(line) || line <= 0 || String(line) !== lineText.trim()) throw new CliInputError(`Expected a positive line number in "${rawArgument}".`);
18909
19225
  return {
18910
19226
  filePath,
18911
19227
  line
@@ -18934,10 +19250,7 @@ const resolveProjectFlag = (projectFlag, workspacePackages) => {
18934
19250
  const resolvedDirectories = [];
18935
19251
  for (const requestedName of requestedNames) {
18936
19252
  const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || path.basename(workspacePackage.directory) === requestedName);
18937
- if (!matched) {
18938
- const availableNames = workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ");
18939
- throw new Error(`Project "${requestedName}" not found. Available: ${availableNames}`);
18940
- }
19253
+ if (!matched) throw new CliInputError(`Project "${requestedName}" not found. Available: ${workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
18941
19254
  resolvedDirectories.push(matched.directory);
18942
19255
  }
18943
19256
  return resolvedDirectories;
@@ -19006,25 +19319,17 @@ const runExplain = async (fileLineArgument, context) => {
19006
19319
  }
19007
19320
  };
19008
19321
  //#endregion
19009
- //#region src/cli/utils/should-fail-for-diagnostics.ts
19010
- const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
19011
- if (failOnLevel === "none") return false;
19012
- if (failOnLevel === "warning") return diagnostics.length > 0;
19013
- return diagnostics.some((diagnostic) => diagnostic.severity === "error");
19014
- };
19015
- //#endregion
19016
19322
  //#region src/cli/utils/validate-mode-flags.ts
19017
19323
  const validateModeFlags = (flags) => {
19018
19324
  const coercedDiff = coerceDiffValue(flags.diff);
19019
19325
  const exclusiveModes = [flags.staged ? "--staged" : null, coercedDiff !== void 0 && coercedDiff !== false ? "--diff" : null].filter((modeName) => modeName !== null);
19020
- if (exclusiveModes.length > 1) throw new Error(`Cannot combine ${exclusiveModes.join(" and ")}; pick one mode.`);
19021
- if (flags.yes && flags.full) throw new Error("Cannot combine --yes and --full; pick one.");
19022
- if (flags.score && flags.json) throw new Error("Cannot combine --score and --json; pick one output mode.");
19023
- if (flags.score && flags.telemetry === false) throw new Error("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
19024
- if (flags.prComment && (flags.json || flags.score)) throw new Error("--pr-comment cannot be combined with --json or --score.");
19025
- if (flags.annotations && flags.score) throw new Error("--annotations cannot be combined with --score.");
19026
- if (flags.explain !== void 0 && flags.why !== void 0) throw new Error("Use --explain or --why, not both — they're aliases of the same flag.");
19027
- if ((flags.explain ?? flags.why) !== void 0 && (flags.json || flags.score || flags.annotations || flags.staged)) throw new Error("--explain cannot be combined with --json, --score, --annotations, or --staged.");
19326
+ if (exclusiveModes.length > 1) throw new CliInputError(`Cannot combine ${exclusiveModes.join(" and ")}; pick one mode.`);
19327
+ if (flags.score && flags.json) throw new CliInputError("Cannot combine --score and --json; pick one output mode.");
19328
+ if (flags.score && flags.telemetry === false) throw new CliInputError("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
19329
+ if (flags.prComment && (flags.json || flags.score)) throw new CliInputError("--pr-comment cannot be combined with --json or --score.");
19330
+ if (flags.annotations && flags.score) throw new CliInputError("--annotations cannot be combined with --score.");
19331
+ if (flags.explain !== void 0 && flags.why !== void 0) throw new CliInputError("Use --explain or --why, not both — they're aliases of the same flag.");
19332
+ if ((flags.explain ?? flags.why) !== void 0 && (flags.json || flags.score || flags.annotations || flags.staged)) throw new CliInputError("--explain cannot be combined with --json, --score, --annotations, or --staged.");
19028
19333
  };
19029
19334
  //#endregion
19030
19335
  //#region src/cli/commands/inspect.ts
@@ -19272,7 +19577,7 @@ const inspectAction = async (directory, flags) => {
19272
19577
  }
19273
19578
  }
19274
19579
  } catch (error) {
19275
- const isUserError = isReactDoctorError(error) && (error.reason._tag === "GitBaseBranchInvalid" || error.reason._tag === "GitBaseBranchMissing");
19580
+ const isUserError = isExpectedUserError(error);
19276
19581
  const sentryEventId = isUserError ? void 0 : await reportErrorToSentry(error);
19277
19582
  if (isJsonMode) {
19278
19583
  writeJsonErrorReport(error);
@@ -19908,6 +20213,30 @@ const exitGracefully = () => {
19908
20213
  process.exit(130);
19909
20214
  };
19910
20215
  //#endregion
20216
+ //#region src/cli/utils/guard-stdin.ts
20217
+ const TERMINAL_HANGUP_CODES = new Set(["EIO", "ENXIO"]);
20218
+ /**
20219
+ * Handles a `process.stdin` `'error'` event. A terminal hangup mid-read
20220
+ * (`read EIO`) is environmental, not a bug, so exit like an interrupted run
20221
+ * instead of crashing. Re-throws anything else so genuine stdin failures keep
20222
+ * funneling to the crash reporter exactly as they did before this guard.
20223
+ */
20224
+ const handleStdinError = (error) => {
20225
+ if (error.code !== void 0 && TERMINAL_HANGUP_CODES.has(error.code)) process.exit(129);
20226
+ throw error;
20227
+ };
20228
+ /**
20229
+ * Arms a `process.stdin` error guard at startup. The only thing that reads
20230
+ * stdin is the interactive `prompts` UI, which opens the TTY in raw mode and
20231
+ * never attaches an `'error'` listener of its own. Without a listener Node
20232
+ * turns a `read EIO` from a vanished terminal into a fatal uncaught exception
20233
+ * (reported to Sentry as a crash); with one, {@link handleStdinError} exits
20234
+ * cleanly on a hangup. Mirrors the stdout EPIPE guard in `cli/index.ts`.
20235
+ */
20236
+ const guardStdin = () => {
20237
+ process.stdin.on("error", handleStdinError);
20238
+ };
20239
+ //#endregion
19911
20240
  //#region src/cli/utils/normalize-help-command.ts
19912
20241
  /**
19913
20242
  * 12-factor CLI Apps (#1, "Great help is essential"): `mycli help` and
@@ -20102,6 +20431,7 @@ initializeSentry();
20102
20431
  process.on("SIGINT", exitGracefully);
20103
20432
  process.on("SIGTERM", exitGracefully);
20104
20433
  unrefStdin();
20434
+ guardStdin();
20105
20435
  const formatExampleLines = (examples) => {
20106
20436
  const width = Math.max(...examples.map(([command]) => command.length));
20107
20437
  return examples.map(([command, description]) => ` $ ${command.padEnd(width)} ${highlighter.dim(`# ${description}`)}`).join("\n");
@@ -20166,15 +20496,20 @@ if (process.argv.includes("-V") && !strippedArgv.includes("-V")) {
20166
20496
  applyColorPreference(strippedArgv);
20167
20497
  const argv = normalizeHelpInvocation(strippedArgv, knownCommands);
20168
20498
  program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
20169
- const sentryEventId = await reportErrorToSentry(error);
20499
+ const isUserError = isExpectedUserError(error);
20500
+ const sentryEventId = isUserError ? void 0 : await reportErrorToSentry(error);
20170
20501
  if (isJsonModeActive()) {
20171
20502
  writeJsonErrorReport(error);
20172
20503
  process.exit(1);
20173
20504
  }
20505
+ if (isUserError) {
20506
+ handleUserError(error);
20507
+ return;
20508
+ }
20174
20509
  handleError(error, { sentryEventId });
20175
20510
  });
20176
20511
  //#endregion
20177
20512
  export {};
20178
20513
 
20179
20514
  //# sourceMappingURL=cli.js.map
20180
- //# debugId=f83fc141-ff41-5c96-8a8e-f4ea0399b0f2
20515
+ //# debugId=32d58bb2-956f-5f5d-9f5b-3c3e922c17d2
package/dist/index.d.ts CHANGED
@@ -407,6 +407,15 @@ interface ProjectInfo {
407
407
  * rule) and the ported expo-doctor checks.
408
408
  */
409
409
  expoVersion: string | null;
410
+ /**
411
+ * The declared `@shopify/flash-list` package version spec, or `null` when
412
+ * absent. FlashList v2 removed the need for `estimatedItemSize`, so this
413
+ * lets the RN list sizing rule stay scoped to versions where the prop is
414
+ * still useful.
415
+ */
416
+ shopifyFlashListVersion: string | null;
417
+ /** Parsed major from `shopifyFlashListVersion`, or `null` when absent/unparseable. */
418
+ shopifyFlashListMajorVersion: number | null;
410
419
  /**
411
420
  * `true` when the project (or any of its workspace packages) declares
412
421
  * `react-native-reanimated`. Lets diagnostics surface reanimated's
@@ -610,10 +619,25 @@ interface JsonReport {
610
619
  * If you're inside the Effect runtime, use the tagged
611
620
  * `ReactDoctorError` from `../errors.js` instead.
612
621
  */
622
+ /**
623
+ * Distinguishes the two situations that both surface as "no project here", so
624
+ * the rendered message matches reality:
625
+ *
626
+ * - `no-project` (default): the path exists but has no React project — no
627
+ * `package.json` at the root and no discoverable nested React subproject.
628
+ * - `missing-path`: the resolved scan target does not exist on disk at all
629
+ * (a typo, a stale temp path, a monorepo subdir that isn't present). The
630
+ * generic "expected a package.json" guidance is misleading here, so point
631
+ * at the missing path instead.
632
+ */
633
+ interface ProjectNotFoundOptions extends ErrorOptions {
634
+ readonly kind?: "no-project" | "missing-path";
635
+ }
613
636
  declare class ProjectNotFoundError extends Error {
614
637
  readonly name = "ProjectNotFoundError";
615
638
  readonly directory: string;
616
- constructor(directory: string, options?: ErrorOptions);
639
+ readonly kind: "no-project" | "missing-path";
640
+ constructor(directory: string, options?: ProjectNotFoundOptions);
617
641
  }
618
642
  declare class NoReactDependencyError extends Error {
619
643
  readonly name = "NoReactDependencyError";
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]="de59ec3d-8219-56e6-b16a-5aed5d046e99")}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]="ee53eb02-91ef-5d50-b736-4734e9a14f5d")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as Schema from "effect/Schema";
5
5
  import * as fs$1 from "node:fs";
@@ -2027,33 +2027,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
2027
2027
  value: mod,
2028
2028
  enumerable: true
2029
2029
  }) : target, mod));
2030
- /**
2031
- * Narrow errors raised by the project-discovery helpers
2032
- * (`discoverProject` / `resolveDiagnoseTarget` / `readPackageJson`).
2033
- *
2034
- * These extend `Error` directly — they are NOT the tagged
2035
- * `ReactDoctorError` from `../errors.js` (that one wraps every
2036
- * runtime-pipeline failure as a `Schema.TaggedErrorClass` for
2037
- * `Effect.catchReasons` dispatch). The split is intentional:
2038
- *
2039
- * - Discovery happens BEFORE the Effect runtime takes over — at the
2040
- * `diagnose()` / CLI entry point — and throws plain JS exceptions
2041
- * so callers can `try/catch` without an Effect-layer-aware
2042
- * `instanceof` check.
2043
- * - The Project service (`services/project.ts → translateProjectInfoError`)
2044
- * translates each of these into the equivalent tagged-error
2045
- * `reason` before re-raising inside the Effect pipeline, so the
2046
- * runtime never sees a non-tagged failure.
2047
- *
2048
- * If you're inside the Effect runtime, use the tagged
2049
- * `ReactDoctorError` from `../errors.js` instead.
2050
- */
2051
2030
  var ProjectNotFoundError = class extends Error {
2052
2031
  name = "ProjectNotFoundError";
2053
2032
  directory;
2033
+ kind;
2054
2034
  constructor(directory, options) {
2055
- super(`No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
2035
+ const kind = options?.kind ?? "no-project";
2036
+ super(kind === "missing-path" ? `Scan target "${directory}" does not exist. Check the path and try again.` : `No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
2056
2037
  this.directory = directory;
2038
+ this.kind = kind;
2057
2039
  }
2058
2040
  };
2059
2041
  var NoReactDependencyError = class extends Error {
@@ -2148,7 +2130,10 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
2148
2130
  "EACCES",
2149
2131
  "EPERM",
2150
2132
  "ENOENT",
2151
- "ENOTDIR"
2133
+ "ENOTDIR",
2134
+ "EINVAL",
2135
+ "ELOOP",
2136
+ "ENAMETOOLONG"
2152
2137
  ]);
2153
2138
  const isIgnorableReaddirError = (error) => {
2154
2139
  if (typeof error !== "object" || error === null) return false;
@@ -2934,6 +2919,23 @@ const getExpoDependencySpec = (packageJson) => {
2934
2919
  return typeof spec === "string" ? spec : null;
2935
2920
  };
2936
2921
  const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
2922
+ const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
2923
+ const getShopifyFlashListDependencySpec = (packageJson) => {
2924
+ const spec = packageJson.dependencies?.["@shopify/flash-list"] ?? packageJson.devDependencies?.["@shopify/flash-list"] ?? packageJson.peerDependencies?.["@shopify/flash-list"] ?? packageJson.optionalDependencies?.["@shopify/flash-list"];
2925
+ return typeof spec === "string" ? spec : null;
2926
+ };
2927
+ const findShopifyFlashListVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getShopifyFlashListDependencySpec);
2928
+ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
2929
+ if (version === null || !isCatalogReference(version)) return version;
2930
+ const catalogName = extractCatalogName(version);
2931
+ const resolvedLocalVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
2932
+ if (resolvedLocalVersion) return resolvedLocalVersion;
2933
+ const monorepoRoot = findMonorepoRoot(rootDirectory);
2934
+ if (!monorepoRoot) return version;
2935
+ const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
2936
+ if (!isFile(monorepoPackageJsonPath)) return version;
2937
+ return resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
2938
+ };
2937
2939
  const getPreactVersion = (packageJson) => {
2938
2940
  return {
2939
2941
  ...packageJson.peerDependencies,
@@ -3173,19 +3175,18 @@ const discoverProject = (directory) => {
3173
3175
  const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
3174
3176
  const sourceFileCount = countSourceFiles(directory);
3175
3177
  const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
3176
- let expoVersion = hasReactNativeWorkspace ? findExpoVersion(directory, packageJson) : null;
3177
- if (expoVersion !== null && isCatalogReference(expoVersion)) {
3178
- const catalogName = extractCatalogName(expoVersion);
3179
- let resolvedExpoVersion = resolveCatalogVersion(packageJson, "expo", directory, catalogName);
3180
- if (!resolvedExpoVersion) {
3181
- const monorepoRoot = findMonorepoRoot(directory);
3182
- if (monorepoRoot) {
3183
- const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
3184
- if (isFile(monorepoPackageJsonPath)) resolvedExpoVersion = resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), "expo", monorepoRoot, catalogName);
3185
- }
3186
- }
3187
- expoVersion = resolvedExpoVersion ?? expoVersion;
3188
- }
3178
+ const expoVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
3179
+ rootDirectory: directory,
3180
+ rootPackageJson: packageJson,
3181
+ packageName: "expo",
3182
+ version: findExpoVersion(directory, packageJson)
3183
+ }) : null;
3184
+ const shopifyFlashListVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
3185
+ rootDirectory: directory,
3186
+ rootPackageJson: packageJson,
3187
+ packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
3188
+ version: findShopifyFlashListVersion(directory, packageJson)
3189
+ }) : null;
3189
3190
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
3190
3191
  const preactVersion = getPreactVersion(packageJson);
3191
3192
  const projectInfo = {
@@ -3204,6 +3205,8 @@ const discoverProject = (directory) => {
3204
3205
  preactMajorVersion: parseReactMajor(preactVersion),
3205
3206
  hasReactNativeWorkspace,
3206
3207
  expoVersion,
3208
+ shopifyFlashListVersion,
3209
+ shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
3207
3210
  hasReanimated,
3208
3211
  sourceFileCount
3209
3212
  };
@@ -4651,7 +4654,7 @@ const resolveScanTarget = async (requestedDirectory, options = {}) => {
4651
4654
  const redirectedDirectory = resolveConfigRootDir(userConfig, configSourceDirectory);
4652
4655
  const directoryAfterRedirect = redirectedDirectory ?? absoluteRequested;
4653
4656
  const resolvedDirectory = resolveDiagnoseTarget(directoryAfterRedirect, options) ?? directoryAfterRedirect;
4654
- if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory);
4657
+ if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory, { kind: "missing-path" });
4655
4658
  return {
4656
4659
  resolvedDirectory,
4657
4660
  requestedDirectory: absoluteRequested,
@@ -5469,6 +5472,63 @@ const collectIgnorePatterns = (rootDirectory) => {
5469
5472
  cachedPatternsByRoot.set(rootDirectory, patterns);
5470
5473
  return patterns;
5471
5474
  };
5475
+ const KNIP_JSON_FILENAME = "knip.json";
5476
+ const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5477
+ const readJsonFileSafe = (filePath) => {
5478
+ let rawContents;
5479
+ try {
5480
+ rawContents = fs.readFileSync(filePath, "utf-8");
5481
+ } catch {
5482
+ return null;
5483
+ }
5484
+ try {
5485
+ return JSON.parse(rawContents);
5486
+ } catch {
5487
+ return null;
5488
+ }
5489
+ };
5490
+ const readKnipConfig = (rootDirectory) => {
5491
+ const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
5492
+ if (isRecord$1(knipJson)) return knipJson;
5493
+ const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
5494
+ const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
5495
+ return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
5496
+ };
5497
+ const normalizePatternList = (value) => {
5498
+ if (typeof value === "string" && value.length > 0) return [value];
5499
+ if (!Array.isArray(value)) return [];
5500
+ return value.filter((entry) => typeof entry === "string" && entry.length > 0);
5501
+ };
5502
+ const prefixWorkspacePatterns = (workspacePattern, patterns) => {
5503
+ const normalizedWorkspacePattern = workspacePattern.replace(/\/+$/, "");
5504
+ return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
5505
+ };
5506
+ const collectKnipWorkspacePatterns = (workspaces, settingName) => {
5507
+ if (!isRecord$1(workspaces)) return [];
5508
+ const patterns = [];
5509
+ for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
5510
+ if (!isRecord$1(workspaceConfig)) continue;
5511
+ patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
5512
+ }
5513
+ return patterns;
5514
+ };
5515
+ const collectKnipPatterns = (rootDirectory, settingName) => {
5516
+ const config = readKnipConfig(rootDirectory);
5517
+ if (!config) return [];
5518
+ return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
5519
+ };
5520
+ const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
5521
+ const seen = /* @__PURE__ */ new Set();
5522
+ const sources = [
5523
+ readIgnoreFile(path.join(rootDirectory, ".gitignore")),
5524
+ collectIgnorePatterns(rootDirectory),
5525
+ userConfig?.ignore?.files ?? [],
5526
+ collectKnipPatterns(rootDirectory, "ignore")
5527
+ ];
5528
+ for (const source of sources) for (const pattern of source) seen.add(pattern);
5529
+ return [...seen].filter((pattern) => pattern.length > 0);
5530
+ };
5531
+ const collectDeadCodeEntryPatterns = (rootDirectory) => [...new Set(collectKnipPatterns(rootDirectory, "entry"))].filter((pattern) => pattern.length > 0);
5472
5532
  /**
5473
5533
  * Resolves a path to its canonical, symlink-free form, falling back to
5474
5534
  * the input when it cannot be realpath'd (broken symlink, permission
@@ -5494,6 +5554,7 @@ const toCanonicalPath = (filePath) => {
5494
5554
  const DEAD_CODE_PLUGIN = "deslop";
5495
5555
  const DEAD_CODE_CATEGORY = "Maintainability";
5496
5556
  const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
5557
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5497
5558
  const DEAD_CODE_WORKER_SCRIPT = `
5498
5559
  const inputChunks = [];
5499
5560
  process.stdin.on("data", (chunk) => inputChunks.push(chunk));
@@ -5534,6 +5595,9 @@ process.stdin.on("end", () => {
5534
5595
  const { analyze, defineConfig } = await import(workerInput.deslopJsModuleSpecifier);
5535
5596
  const config = {
5536
5597
  rootDir: workerInput.rootDirectory,
5598
+ ...(workerInput.entryPatterns.length > 0
5599
+ ? { entryPatterns: workerInput.entryPatterns }
5600
+ : {}),
5537
5601
  ...(workerInput.tsConfigPath ? { tsConfigPath: workerInput.tsConfigPath } : {}),
5538
5602
  ...(workerInput.ignorePatterns.length > 0
5539
5603
  ? { ignorePatterns: workerInput.ignorePatterns }
@@ -5553,21 +5617,10 @@ const resolveTsConfigPath = (rootDirectory) => {
5553
5617
  if (fs.existsSync(candidate)) return candidate;
5554
5618
  }
5555
5619
  };
5556
- const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
5557
- const seen = /* @__PURE__ */ new Set();
5558
- const sources = [
5559
- readIgnoreFile(path.join(rootDirectory, ".gitignore")),
5560
- collectIgnorePatterns(rootDirectory),
5561
- userConfig?.ignore?.files ?? []
5562
- ];
5563
- for (const source of sources) for (const pattern of source) seen.add(pattern);
5564
- return [...seen].filter((pattern) => pattern.length > 0);
5565
- };
5566
5620
  const toRelativeFilePath = (rootDirectory, filePath) => {
5567
5621
  const relative = toRelativePath(filePath, rootDirectory);
5568
5622
  return relative.length > 0 ? relative : filePath.replace(/\\/g, "/");
5569
5623
  };
5570
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5571
5624
  const parseArray = (value, label) => {
5572
5625
  if (!Array.isArray(value)) throw new Error(`Dead-code worker returned invalid ${label}.`);
5573
5626
  return value;
@@ -5750,9 +5803,11 @@ const checkDeadCode = async (options) => {
5750
5803
  const { userConfig } = options;
5751
5804
  const rootDirectory = toCanonicalPath(options.rootDirectory);
5752
5805
  if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
5806
+ const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
5753
5807
  const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
5754
5808
  const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
5755
5809
  rootDirectory,
5810
+ entryPatterns,
5756
5811
  tsConfigPath: resolveTsConfigPath(rootDirectory),
5757
5812
  ignorePatterns,
5758
5813
  deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js")
@@ -6137,7 +6192,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6137
6192
  if (result.status !== 0) return null;
6138
6193
  const branch = trimOrNull(result.stdout);
6139
6194
  return branch === "HEAD" ? null : branch;
6140
- }));
6195
+ }), Effect.orElseSucceed(() => null));
6141
6196
  const defaultBranch = (directory) => Effect.gen(function* () {
6142
6197
  const symref = yield* runGit(directory, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
6143
6198
  if (symref.status === 0) {
@@ -6826,6 +6881,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
6826
6881
  settings: { "react-doctor": {
6827
6882
  framework: project.framework,
6828
6883
  rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
6884
+ ...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
6829
6885
  ...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
6830
6886
  } },
6831
6887
  rules: {
@@ -8047,6 +8103,7 @@ const calculateScore = async (diagnostics, options = {}) => {
8047
8103
  ...typeof options.metadata?.sourceFileCount === "number" ? { sourceFileCount: options.metadata.sourceFileCount } : {},
8048
8104
  ...options.metadata?.defaultBranch ? { defaultBranch: options.metadata.defaultBranch } : {},
8049
8105
  ...options.metadata?.doctorVersion ? { doctorVersion: options.metadata.doctorVersion } : {},
8106
+ ...options.metadata?.runId ? { runId: options.metadata.runId } : {},
8050
8107
  ...options.metadata?.githubEventName ? { githubEventName: options.metadata.githubEventName } : {},
8051
8108
  ...options.metadata?.githubActorAssociation ? { githubActorAssociation: options.metadata.githubActorAssociation } : {},
8052
8109
  ...options.metadata?.githubViewerPermission ? { githubViewerPermission: options.metadata.githubViewerPermission } : {}
@@ -8286,6 +8343,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
8286
8343
  sourceFileCount: project.sourceFileCount,
8287
8344
  ...defaultBranch !== null ? { defaultBranch } : {},
8288
8345
  ...input.doctorVersion !== void 0 ? { doctorVersion: input.doctorVersion } : {},
8346
+ ...input.runId !== void 0 ? { runId: input.runId } : {},
8289
8347
  ...githubActionsScoreMetadata,
8290
8348
  ...githubViewerPermission !== null ? { githubViewerPermission } : {}
8291
8349
  };
@@ -8742,4 +8800,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8742
8800
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8743
8801
 
8744
8802
  //# sourceMappingURL=index.js.map
8745
- //# debugId=de59ec3d-8219-56e6-b16a-5aed5d046e99
8803
+ //# debugId=ee53eb02-91ef-5d50-b736-4734e9a14f5d
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.2.17-dev.5614b32",
3
+ "version": "0.2.18-dev.08e1d55",
4
4
  "description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -55,7 +55,7 @@
55
55
  "agent-install": "0.0.5",
56
56
  "conf": "^15.1.0",
57
57
  "confbox": "^0.2.4",
58
- "deslop-js": "^0.0.14",
58
+ "deslop-js": "^0.0.17",
59
59
  "effect": "4.0.0-beta.70",
60
60
  "eslint-plugin-react-hooks": "^7.1.1",
61
61
  "jiti": "^2.7.0",
@@ -63,7 +63,7 @@
63
63
  "oxlint": "^1.66.0",
64
64
  "prompts": "^2.4.2",
65
65
  "typescript": ">=5.0.4 <7",
66
- "oxlint-plugin-react-doctor": "0.2.17-dev.5614b32"
66
+ "oxlint-plugin-react-doctor": "0.2.18-dev.08e1d55"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/babel__code-frame": "^7.27.0",
@@ -71,8 +71,8 @@
71
71
  "@xterm/headless": "^6.0.0",
72
72
  "commander": "^14.0.3",
73
73
  "ora": "^9.4.0",
74
- "@react-doctor/api": "0.2.17",
75
- "@react-doctor/core": "0.2.17"
74
+ "@react-doctor/core": "0.2.18",
75
+ "@react-doctor/api": "0.2.18"
76
76
  },
77
77
  "engines": {
78
78
  "node": "^20.19.0 || >=22.12.0"