react-doctor 0.2.18-dev.8d13ba3 → 0.2.18-dev.8e7fb33

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]="07713237-df07-5858-b7a4-7b12c0e7b293")}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]="abae260a-5485-52a6-9af5-5259ba942f1b")}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";
@@ -5157,7 +5157,10 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
5157
5157
  "EACCES",
5158
5158
  "EPERM",
5159
5159
  "ENOENT",
5160
- "ENOTDIR"
5160
+ "ENOTDIR",
5161
+ "EINVAL",
5162
+ "ELOOP",
5163
+ "ENAMETOOLONG"
5161
5164
  ]);
5162
5165
  const isIgnorableReaddirError = (error) => {
5163
5166
  if (typeof error !== "object" || error === null) return false;
@@ -5940,6 +5943,23 @@ const getExpoDependencySpec = (packageJson) => {
5940
5943
  return typeof spec === "string" ? spec : null;
5941
5944
  };
5942
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
+ };
5943
5963
  const getPreactVersion = (packageJson) => {
5944
5964
  return {
5945
5965
  ...packageJson.peerDependencies,
@@ -6176,19 +6196,18 @@ const discoverProject = (directory) => {
6176
6196
  const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
6177
6197
  const sourceFileCount = countSourceFiles(directory);
6178
6198
  const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
6179
- let expoVersion = hasReactNativeWorkspace ? findExpoVersion(directory, packageJson) : null;
6180
- if (expoVersion !== null && isCatalogReference(expoVersion)) {
6181
- const catalogName = extractCatalogName(expoVersion);
6182
- let resolvedExpoVersion = resolveCatalogVersion(packageJson, "expo", directory, catalogName);
6183
- if (!resolvedExpoVersion) {
6184
- const monorepoRoot = findMonorepoRoot(directory);
6185
- if (monorepoRoot) {
6186
- const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
6187
- if (isFile(monorepoPackageJsonPath)) resolvedExpoVersion = resolveCatalogVersion(readPackageJson$1(monorepoPackageJsonPath), "expo", monorepoRoot, catalogName);
6188
- }
6189
- }
6190
- expoVersion = resolvedExpoVersion ?? expoVersion;
6191
- }
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;
6192
6211
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
6193
6212
  const preactVersion = getPreactVersion(packageJson);
6194
6213
  const projectInfo = {
@@ -6207,6 +6226,8 @@ const discoverProject = (directory) => {
6207
6226
  preactMajorVersion: parseReactMajor(preactVersion),
6208
6227
  hasReactNativeWorkspace,
6209
6228
  expoVersion,
6229
+ shopifyFlashListVersion,
6230
+ shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
6210
6231
  hasReanimated,
6211
6232
  sourceFileCount
6212
6233
  };
@@ -8518,6 +8539,63 @@ const collectIgnorePatterns = (rootDirectory) => {
8518
8539
  cachedPatternsByRoot.set(rootDirectory, patterns);
8519
8540
  return patterns;
8520
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);
8521
8599
  /**
8522
8600
  * Resolves a path to its canonical, symlink-free form, falling back to
8523
8601
  * the input when it cannot be realpath'd (broken symlink, permission
@@ -8543,6 +8621,7 @@ const toCanonicalPath = (filePath) => {
8543
8621
  const DEAD_CODE_PLUGIN = "deslop";
8544
8622
  const DEAD_CODE_CATEGORY = "Maintainability";
8545
8623
  const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
8624
+ const isRecord$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8546
8625
  const DEAD_CODE_WORKER_SCRIPT = `
8547
8626
  const inputChunks = [];
8548
8627
  process.stdin.on("data", (chunk) => inputChunks.push(chunk));
@@ -8583,6 +8662,9 @@ process.stdin.on("end", () => {
8583
8662
  const { analyze, defineConfig } = await import(workerInput.deslopJsModuleSpecifier);
8584
8663
  const config = {
8585
8664
  rootDir: workerInput.rootDirectory,
8665
+ ...(workerInput.entryPatterns.length > 0
8666
+ ? { entryPatterns: workerInput.entryPatterns }
8667
+ : {}),
8586
8668
  ...(workerInput.tsConfigPath ? { tsConfigPath: workerInput.tsConfigPath } : {}),
8587
8669
  ...(workerInput.ignorePatterns.length > 0
8588
8670
  ? { ignorePatterns: workerInput.ignorePatterns }
@@ -8602,21 +8684,10 @@ const resolveTsConfigPath = (rootDirectory) => {
8602
8684
  if (fs.existsSync(candidate)) return candidate;
8603
8685
  }
8604
8686
  };
8605
- const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
8606
- const seen = /* @__PURE__ */ new Set();
8607
- const sources = [
8608
- readIgnoreFile(path.join(rootDirectory, ".gitignore")),
8609
- collectIgnorePatterns(rootDirectory),
8610
- userConfig?.ignore?.files ?? []
8611
- ];
8612
- for (const source of sources) for (const pattern of source) seen.add(pattern);
8613
- return [...seen].filter((pattern) => pattern.length > 0);
8614
- };
8615
8687
  const toRelativeFilePath = (rootDirectory, filePath) => {
8616
8688
  const relative = toRelativePath(filePath, rootDirectory);
8617
8689
  return relative.length > 0 ? relative : filePath.replace(/\\/g, "/");
8618
8690
  };
8619
- const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8620
8691
  const parseArray = (value, label) => {
8621
8692
  if (!Array.isArray(value)) throw new Error(`Dead-code worker returned invalid ${label}.`);
8622
8693
  return value;
@@ -8640,7 +8711,7 @@ const parseUnusedFiles = (value) => {
8640
8711
  const values = parseArray(value, "unusedFiles");
8641
8712
  const unusedFiles = [];
8642
8713
  for (const [index, entry] of values.entries()) {
8643
- 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}].`);
8644
8715
  unusedFiles.push({ path: parseString(entry.path, `unusedFiles[${index}].path`) });
8645
8716
  }
8646
8717
  return unusedFiles;
@@ -8649,7 +8720,7 @@ const parseUnusedExports = (value) => {
8649
8720
  const values = parseArray(value, "unusedExports");
8650
8721
  const unusedExports = [];
8651
8722
  for (const [index, entry] of values.entries()) {
8652
- 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}].`);
8653
8724
  unusedExports.push({
8654
8725
  path: parseString(entry.path, `unusedExports[${index}].path`),
8655
8726
  name: parseString(entry.name, `unusedExports[${index}].name`),
@@ -8664,7 +8735,7 @@ const parseUnusedDependencies = (value) => {
8664
8735
  const values = parseArray(value, "unusedDependencies");
8665
8736
  const unusedDependencies = [];
8666
8737
  for (const [index, entry] of values.entries()) {
8667
- 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}].`);
8668
8739
  unusedDependencies.push({
8669
8740
  name: parseString(entry.name, `unusedDependencies[${index}].name`),
8670
8741
  isDevDependency: parseBoolean(entry.isDevDependency, `unusedDependencies[${index}].isDevDependency`)
@@ -8676,13 +8747,13 @@ const parseCircularDependencies = (value) => {
8676
8747
  const values = parseArray(value, "circularDependencies");
8677
8748
  const circularDependencies = [];
8678
8749
  for (const [index, entry] of values.entries()) {
8679
- 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}].`);
8680
8751
  circularDependencies.push({ files: parseStringArray(entry.files, `circularDependencies[${index}].files`) });
8681
8752
  }
8682
8753
  return circularDependencies;
8683
8754
  };
8684
8755
  const parseDeadCodeWorkerResult = (value) => {
8685
- 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.");
8686
8757
  return {
8687
8758
  unusedFiles: parseUnusedFiles(value.unusedFiles),
8688
8759
  unusedExports: parseUnusedExports(value.unusedExports),
@@ -8691,7 +8762,7 @@ const parseDeadCodeWorkerResult = (value) => {
8691
8762
  };
8692
8763
  };
8693
8764
  const parseDeadCodeWorkerError = (value) => {
8694
- 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." };
8695
8766
  return {
8696
8767
  ...typeof value.name === "string" ? { name: value.name } : {},
8697
8768
  message: value.message,
@@ -8699,7 +8770,7 @@ const parseDeadCodeWorkerError = (value) => {
8699
8770
  };
8700
8771
  };
8701
8772
  const parseDeadCodeWorkerMessage = (value) => {
8702
- 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.");
8703
8774
  if (value.ok === true) return {
8704
8775
  ok: true,
8705
8776
  result: value.result
@@ -8799,9 +8870,11 @@ const checkDeadCode = async (options) => {
8799
8870
  const { userConfig } = options;
8800
8871
  const rootDirectory = toCanonicalPath(options.rootDirectory);
8801
8872
  if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
8873
+ const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
8802
8874
  const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
8803
8875
  const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
8804
8876
  rootDirectory,
8877
+ entryPatterns,
8805
8878
  tsConfigPath: resolveTsConfigPath(rootDirectory),
8806
8879
  ignorePatterns,
8807
8880
  deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js")
@@ -9875,6 +9948,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
9875
9948
  settings: { "react-doctor": {
9876
9949
  framework: project.framework,
9877
9950
  rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
9951
+ ...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
9878
9952
  ...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
9879
9953
  } },
9880
9954
  rules: {
@@ -11096,6 +11170,7 @@ const calculateScore = async (diagnostics, options = {}) => {
11096
11170
  ...typeof options.metadata?.sourceFileCount === "number" ? { sourceFileCount: options.metadata.sourceFileCount } : {},
11097
11171
  ...options.metadata?.defaultBranch ? { defaultBranch: options.metadata.defaultBranch } : {},
11098
11172
  ...options.metadata?.doctorVersion ? { doctorVersion: options.metadata.doctorVersion } : {},
11173
+ ...options.metadata?.runId ? { runId: options.metadata.runId } : {},
11099
11174
  ...options.metadata?.githubEventName ? { githubEventName: options.metadata.githubEventName } : {},
11100
11175
  ...options.metadata?.githubActorAssociation ? { githubActorAssociation: options.metadata.githubActorAssociation } : {},
11101
11176
  ...options.metadata?.githubViewerPermission ? { githubViewerPermission: options.metadata.githubViewerPermission } : {}
@@ -11335,6 +11410,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
11335
11410
  sourceFileCount: project.sourceFileCount,
11336
11411
  ...defaultBranch !== null ? { defaultBranch } : {},
11337
11412
  ...input.doctorVersion !== void 0 ? { doctorVersion: input.doctorVersion } : {},
11413
+ ...input.runId !== void 0 ? { runId: input.runId } : {},
11338
11414
  ...githubActionsScoreMetadata,
11339
11415
  ...githubViewerPermission !== null ? { githubViewerPermission } : {}
11340
11416
  };
@@ -11791,6 +11867,14 @@ const CI_PROVIDER_BY_ENVIRONMENT_VARIABLE = [
11791
11867
  ["TRAVIS", "travis"],
11792
11868
  ["DRONE", "drone"]
11793
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
+ };
11794
11878
  const CODING_AGENT_BY_ENVIRONMENT_VARIABLE = [
11795
11879
  ["CLAUDECODE", "claude-code"],
11796
11880
  ["CLAUDE_CODE", "claude-code"],
@@ -11817,6 +11901,9 @@ const detectCiProvider = () => {
11817
11901
  for (const [environmentVariable, provider] of CI_PROVIDER_BY_ENVIRONMENT_VARIABLE) if (process.env[environmentVariable]) return provider;
11818
11902
  return isCiFlagSet(process.env.CI) ? "unknown" : null;
11819
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;
11820
11907
  const detectCodingAgentFromValue = () => {
11821
11908
  for (const environmentVariable of CODING_AGENT_ENVIRONMENT_VALUE_VARIABLES) {
11822
11909
  const value = process.env[environmentVariable]?.toLowerCase();
@@ -11931,7 +12018,7 @@ const makeNoopConsole = () => ({
11931
12018
  });
11932
12019
  //#endregion
11933
12020
  //#region src/cli/utils/version.ts
11934
- const VERSION = "0.2.18-dev.8d13ba3";
12021
+ const VERSION = "0.2.18-dev.8e7fb33";
11935
12022
  //#endregion
11936
12023
  //#region src/cli/utils/json-mode.ts
11937
12024
  let context = null;
@@ -12004,6 +12091,13 @@ const writeJsonErrorReport = (error) => {
12004
12091
  }
12005
12092
  };
12006
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
12007
12101
  //#region src/cli/utils/scrub-sensitive-text.ts
12008
12102
  const HOME_DIRECTORY = os.homedir();
12009
12103
  const USER_HOME_PATTERNS = [/[A-Za-z]:[\\/]Users[\\/][^\\/]+/gi, /(?:\/Users\/|\/home\/)[^/\\]+/gi];
@@ -12058,6 +12152,7 @@ const buildRunContext = () => {
12058
12152
  const userArguments = process.argv.slice(2);
12059
12153
  return {
12060
12154
  version: VERSION,
12155
+ runId: getRunId(),
12061
12156
  origin: detectOrigin(),
12062
12157
  command: detectCommand(userArguments),
12063
12158
  argv: scrubSensitivePaths(userArguments.join(" ")),
@@ -12068,6 +12163,8 @@ const buildRunContext = () => {
12068
12163
  arch: process.arch,
12069
12164
  ci: isCiEnvironment(),
12070
12165
  ciProvider: detectCiProvider(),
12166
+ eventName: detectCiEventName(),
12167
+ viaAction: isOfficialGithubAction(),
12071
12168
  codingAgent: detectCodingAgent(),
12072
12169
  interactive: !isNonInteractiveEnvironment(),
12073
12170
  jsonMode: isJsonModeActive(),
@@ -12136,6 +12233,8 @@ const buildSentryScope = (runContext = buildRunContext()) => {
12136
12233
  command: runContext.command,
12137
12234
  ci: runContext.ci,
12138
12235
  ciProvider: runContext.ciProvider,
12236
+ eventName: runContext.eventName,
12237
+ viaAction: runContext.viaAction,
12139
12238
  codingAgent: runContext.codingAgent,
12140
12239
  interactive: runContext.interactive,
12141
12240
  jsonMode: runContext.jsonMode,
@@ -12277,13 +12376,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12277
12376
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12278
12377
  * standard `SENTRY_RELEASE` override.
12279
12378
  */
12280
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.8d13ba3`;
12379
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.8e7fb33`;
12281
12380
  /**
12282
12381
  * Deployment environment shown in Sentry's environment filter. Defaults to
12283
12382
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12284
12383
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12285
12384
  */
12286
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.8d13ba3") ? "development" : "production");
12385
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.8e7fb33") ? "development" : "production");
12287
12386
  /**
12288
12387
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12289
12388
  * (set to `0` to disable tracing) and falls back to
@@ -15740,6 +15839,152 @@ const recordScanMetrics = (input) => {
15740
15839
  });
15741
15840
  };
15742
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
15743
15988
  //#region src/cli/utils/build-no-score-message.ts
15744
15989
  const ENTERPRISE_CONTACT_HINT = `Want something custom to your company? Contact us at ${ENTERPRISE_CONTACT_URL}.`;
15745
15990
  const buildNoScoreMessage = (isScoreDisabled) => {
@@ -16044,7 +16289,7 @@ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, rende
16044
16289
  const fixRecipeLine = formatFixRecipeLine(representative);
16045
16290
  if (fixRecipeLine) lines.push(highlighter.gray(`${TOP_ERROR_DETAIL_INDENT}${fixRecipeLine}`));
16046
16291
  }
16047
- const renderCodeFrame = severity === "error" || renderEverySite;
16292
+ const renderCodeFrame = severity === "error";
16048
16293
  const sites = renderEverySite ? ruleDiagnostics : [representative];
16049
16294
  for (const cluster of clusterNearbyDiagnostics(sites)) lines.push(...buildDiagnosticClusterLines(cluster, resolveSourceRoot, renderCodeFrame));
16050
16295
  return lines;
@@ -16670,6 +16915,19 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
16670
16915
  suppressRendering: inputOptions.suppressRendering ?? false,
16671
16916
  concurrency: inputOptions.concurrency
16672
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
+ });
16673
16931
  const inspect = async (directory, inputOptions = {}) => {
16674
16932
  const startTime = performance.now();
16675
16933
  resetSentryRunState();
@@ -16691,7 +16949,18 @@ const inspect = async (directory, inputOptions = {}) => {
16691
16949
  const wasSpinnerSilent = isSpinnerSilent();
16692
16950
  if (options.silent) setSpinnerSilent(true);
16693
16951
  try {
16694
- 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
+ });
16695
16964
  resetSentryRunState();
16696
16965
  return result;
16697
16966
  } finally {
@@ -16726,6 +16995,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
16726
16995
  runDeadCode: options.deadCode,
16727
16996
  isCi: options.isCi,
16728
16997
  doctorVersion: VERSION,
16998
+ runId: getRunId(),
16729
16999
  resolveLocalGithubViewerPermission: !options.noScore,
16730
17000
  suppressScanSummary: options.suppressRendering
16731
17001
  }, { beforeLint: (projectInfo, lintIncludePaths) => Effect.gen(function* () {
@@ -16789,6 +17059,15 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
16789
17059
  lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind,
16790
17060
  didDeadCodeFail: output.didDeadCodeFail
16791
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
+ });
16792
17071
  return result;
16793
17072
  };
16794
17073
  const finalizeAndRender = (input) => Effect.gen(function* () {
@@ -18611,7 +18890,13 @@ const isSafeRelativePath = (filePath) => {
18611
18890
  return normalized === filePath;
18612
18891
  };
18613
18892
  const readChangedFilesFrom = (filePath) => {
18614
- 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
+ }
18615
18900
  const uniqueFiles = /* @__PURE__ */ new Set();
18616
18901
  for (const line of raw.split(/\r?\n/)) {
18617
18902
  const candidate = toForwardSlashes(line.trim());
@@ -19034,13 +19319,6 @@ const runExplain = async (fileLineArgument, context) => {
19034
19319
  }
19035
19320
  };
19036
19321
  //#endregion
19037
- //#region src/cli/utils/should-fail-for-diagnostics.ts
19038
- const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
19039
- if (failOnLevel === "none") return false;
19040
- if (failOnLevel === "warning") return diagnostics.length > 0;
19041
- return diagnostics.some((diagnostic) => diagnostic.severity === "error");
19042
- };
19043
- //#endregion
19044
19322
  //#region src/cli/utils/validate-mode-flags.ts
19045
19323
  const validateModeFlags = (flags) => {
19046
19324
  const coercedDiff = coerceDiffValue(flags.diff);
@@ -19936,6 +20214,30 @@ const exitGracefully = () => {
19936
20214
  process.exit(130);
19937
20215
  };
19938
20216
  //#endregion
20217
+ //#region src/cli/utils/guard-stdin.ts
20218
+ const TERMINAL_HANGUP_CODES = new Set(["EIO", "ENXIO"]);
20219
+ /**
20220
+ * Handles a `process.stdin` `'error'` event. A terminal hangup mid-read
20221
+ * (`read EIO`) is environmental, not a bug, so exit like an interrupted run
20222
+ * instead of crashing. Re-throws anything else so genuine stdin failures keep
20223
+ * funneling to the crash reporter exactly as they did before this guard.
20224
+ */
20225
+ const handleStdinError = (error) => {
20226
+ if (error.code !== void 0 && TERMINAL_HANGUP_CODES.has(error.code)) process.exit(129);
20227
+ throw error;
20228
+ };
20229
+ /**
20230
+ * Arms a `process.stdin` error guard at startup. The only thing that reads
20231
+ * stdin is the interactive `prompts` UI, which opens the TTY in raw mode and
20232
+ * never attaches an `'error'` listener of its own. Without a listener Node
20233
+ * turns a `read EIO` from a vanished terminal into a fatal uncaught exception
20234
+ * (reported to Sentry as a crash); with one, {@link handleStdinError} exits
20235
+ * cleanly on a hangup. Mirrors the stdout EPIPE guard in `cli/index.ts`.
20236
+ */
20237
+ const guardStdin = () => {
20238
+ process.stdin.on("error", handleStdinError);
20239
+ };
20240
+ //#endregion
19939
20241
  //#region src/cli/utils/normalize-help-command.ts
19940
20242
  /**
19941
20243
  * 12-factor CLI Apps (#1, "Great help is essential"): `mycli help` and
@@ -20130,6 +20432,7 @@ initializeSentry();
20130
20432
  process.on("SIGINT", exitGracefully);
20131
20433
  process.on("SIGTERM", exitGracefully);
20132
20434
  unrefStdin();
20435
+ guardStdin();
20133
20436
  const formatExampleLines = (examples) => {
20134
20437
  const width = Math.max(...examples.map(([command]) => command.length));
20135
20438
  return examples.map(([command, description]) => ` $ ${command.padEnd(width)} ${highlighter.dim(`# ${description}`)}`).join("\n");
@@ -20210,4 +20513,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
20210
20513
  export {};
20211
20514
 
20212
20515
  //# sourceMappingURL=cli.js.map
20213
- //# debugId=07713237-df07-5858-b7a4-7b12c0e7b293
20516
+ //# debugId=abae260a-5485-52a6-9af5-5259ba942f1b
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
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]="9b91fa51-6642-5351-a848-af91945dec6f")}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";
@@ -2130,7 +2130,10 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
2130
2130
  "EACCES",
2131
2131
  "EPERM",
2132
2132
  "ENOENT",
2133
- "ENOTDIR"
2133
+ "ENOTDIR",
2134
+ "EINVAL",
2135
+ "ELOOP",
2136
+ "ENAMETOOLONG"
2134
2137
  ]);
2135
2138
  const isIgnorableReaddirError = (error) => {
2136
2139
  if (typeof error !== "object" || error === null) return false;
@@ -2916,6 +2919,23 @@ const getExpoDependencySpec = (packageJson) => {
2916
2919
  return typeof spec === "string" ? spec : null;
2917
2920
  };
2918
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
+ };
2919
2939
  const getPreactVersion = (packageJson) => {
2920
2940
  return {
2921
2941
  ...packageJson.peerDependencies,
@@ -3155,19 +3175,18 @@ const discoverProject = (directory) => {
3155
3175
  const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
3156
3176
  const sourceFileCount = countSourceFiles(directory);
3157
3177
  const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
3158
- let expoVersion = hasReactNativeWorkspace ? findExpoVersion(directory, packageJson) : null;
3159
- if (expoVersion !== null && isCatalogReference(expoVersion)) {
3160
- const catalogName = extractCatalogName(expoVersion);
3161
- let resolvedExpoVersion = resolveCatalogVersion(packageJson, "expo", directory, catalogName);
3162
- if (!resolvedExpoVersion) {
3163
- const monorepoRoot = findMonorepoRoot(directory);
3164
- if (monorepoRoot) {
3165
- const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
3166
- if (isFile(monorepoPackageJsonPath)) resolvedExpoVersion = resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), "expo", monorepoRoot, catalogName);
3167
- }
3168
- }
3169
- expoVersion = resolvedExpoVersion ?? expoVersion;
3170
- }
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;
3171
3190
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
3172
3191
  const preactVersion = getPreactVersion(packageJson);
3173
3192
  const projectInfo = {
@@ -3186,6 +3205,8 @@ const discoverProject = (directory) => {
3186
3205
  preactMajorVersion: parseReactMajor(preactVersion),
3187
3206
  hasReactNativeWorkspace,
3188
3207
  expoVersion,
3208
+ shopifyFlashListVersion,
3209
+ shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
3189
3210
  hasReanimated,
3190
3211
  sourceFileCount
3191
3212
  };
@@ -5451,6 +5472,63 @@ const collectIgnorePatterns = (rootDirectory) => {
5451
5472
  cachedPatternsByRoot.set(rootDirectory, patterns);
5452
5473
  return patterns;
5453
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);
5454
5532
  /**
5455
5533
  * Resolves a path to its canonical, symlink-free form, falling back to
5456
5534
  * the input when it cannot be realpath'd (broken symlink, permission
@@ -5476,6 +5554,7 @@ const toCanonicalPath = (filePath) => {
5476
5554
  const DEAD_CODE_PLUGIN = "deslop";
5477
5555
  const DEAD_CODE_CATEGORY = "Maintainability";
5478
5556
  const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
5557
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5479
5558
  const DEAD_CODE_WORKER_SCRIPT = `
5480
5559
  const inputChunks = [];
5481
5560
  process.stdin.on("data", (chunk) => inputChunks.push(chunk));
@@ -5516,6 +5595,9 @@ process.stdin.on("end", () => {
5516
5595
  const { analyze, defineConfig } = await import(workerInput.deslopJsModuleSpecifier);
5517
5596
  const config = {
5518
5597
  rootDir: workerInput.rootDirectory,
5598
+ ...(workerInput.entryPatterns.length > 0
5599
+ ? { entryPatterns: workerInput.entryPatterns }
5600
+ : {}),
5519
5601
  ...(workerInput.tsConfigPath ? { tsConfigPath: workerInput.tsConfigPath } : {}),
5520
5602
  ...(workerInput.ignorePatterns.length > 0
5521
5603
  ? { ignorePatterns: workerInput.ignorePatterns }
@@ -5535,21 +5617,10 @@ const resolveTsConfigPath = (rootDirectory) => {
5535
5617
  if (fs.existsSync(candidate)) return candidate;
5536
5618
  }
5537
5619
  };
5538
- const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
5539
- const seen = /* @__PURE__ */ new Set();
5540
- const sources = [
5541
- readIgnoreFile(path.join(rootDirectory, ".gitignore")),
5542
- collectIgnorePatterns(rootDirectory),
5543
- userConfig?.ignore?.files ?? []
5544
- ];
5545
- for (const source of sources) for (const pattern of source) seen.add(pattern);
5546
- return [...seen].filter((pattern) => pattern.length > 0);
5547
- };
5548
5620
  const toRelativeFilePath = (rootDirectory, filePath) => {
5549
5621
  const relative = toRelativePath(filePath, rootDirectory);
5550
5622
  return relative.length > 0 ? relative : filePath.replace(/\\/g, "/");
5551
5623
  };
5552
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5553
5624
  const parseArray = (value, label) => {
5554
5625
  if (!Array.isArray(value)) throw new Error(`Dead-code worker returned invalid ${label}.`);
5555
5626
  return value;
@@ -5732,9 +5803,11 @@ const checkDeadCode = async (options) => {
5732
5803
  const { userConfig } = options;
5733
5804
  const rootDirectory = toCanonicalPath(options.rootDirectory);
5734
5805
  if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
5806
+ const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
5735
5807
  const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
5736
5808
  const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
5737
5809
  rootDirectory,
5810
+ entryPatterns,
5738
5811
  tsConfigPath: resolveTsConfigPath(rootDirectory),
5739
5812
  ignorePatterns,
5740
5813
  deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js")
@@ -6808,6 +6881,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
6808
6881
  settings: { "react-doctor": {
6809
6882
  framework: project.framework,
6810
6883
  rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
6884
+ ...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
6811
6885
  ...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
6812
6886
  } },
6813
6887
  rules: {
@@ -8029,6 +8103,7 @@ const calculateScore = async (diagnostics, options = {}) => {
8029
8103
  ...typeof options.metadata?.sourceFileCount === "number" ? { sourceFileCount: options.metadata.sourceFileCount } : {},
8030
8104
  ...options.metadata?.defaultBranch ? { defaultBranch: options.metadata.defaultBranch } : {},
8031
8105
  ...options.metadata?.doctorVersion ? { doctorVersion: options.metadata.doctorVersion } : {},
8106
+ ...options.metadata?.runId ? { runId: options.metadata.runId } : {},
8032
8107
  ...options.metadata?.githubEventName ? { githubEventName: options.metadata.githubEventName } : {},
8033
8108
  ...options.metadata?.githubActorAssociation ? { githubActorAssociation: options.metadata.githubActorAssociation } : {},
8034
8109
  ...options.metadata?.githubViewerPermission ? { githubViewerPermission: options.metadata.githubViewerPermission } : {}
@@ -8268,6 +8343,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
8268
8343
  sourceFileCount: project.sourceFileCount,
8269
8344
  ...defaultBranch !== null ? { defaultBranch } : {},
8270
8345
  ...input.doctorVersion !== void 0 ? { doctorVersion: input.doctorVersion } : {},
8346
+ ...input.runId !== void 0 ? { runId: input.runId } : {},
8271
8347
  ...githubActionsScoreMetadata,
8272
8348
  ...githubViewerPermission !== null ? { githubViewerPermission } : {}
8273
8349
  };
@@ -8724,4 +8800,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8724
8800
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8725
8801
 
8726
8802
  //# sourceMappingURL=index.js.map
8727
- //# debugId=9b91fa51-6642-5351-a848-af91945dec6f
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.18-dev.8d13ba3",
3
+ "version": "0.2.18-dev.8e7fb33",
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.16",
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.18-dev.8d13ba3"
66
+ "oxlint-plugin-react-doctor": "0.2.18-dev.8e7fb33"
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.18",
75
- "@react-doctor/core": "0.2.18"
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"