react-doctor 0.2.14-dev.daef23c → 0.2.14-dev.f1913f2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import * as Redacted from "effect/Redacted";
14
14
  import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
15
15
  import * as Otlp from "effect/unstable/observability/Otlp";
16
16
  import * as Context from "effect/Context";
17
+ import os from "node:os";
17
18
  import * as Console from "effect/Console";
18
19
  import * as Fiber from "effect/Fiber";
19
20
  import * as Filter from "effect/Filter";
@@ -26,7 +27,6 @@ import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
26
27
  import * as NodePath from "@effect/platform-node-shared/NodePath";
27
28
  import * as ChildProcess from "effect/unstable/process/ChildProcess";
28
29
  import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
29
- import os from "node:os";
30
30
  import * as ts from "typescript";
31
31
  import { gzipSync } from "node:zlib";
32
32
  //#region \0rolldown/runtime.js
@@ -2874,29 +2874,34 @@ const findDependencyInfoFromMonorepoRoot = (directory) => {
2874
2874
  framework: rootInfo.framework !== "unknown" ? rootInfo.framework : workspaceInfo.framework
2875
2875
  };
2876
2876
  };
2877
- const someWorkspacePackageJson = (rootDirectory, rootPackageJson, predicate) => {
2878
- if (predicate(rootPackageJson)) return true;
2877
+ const findInWorkspacePackageJsons = (rootDirectory, rootPackageJson, select) => {
2878
+ const rootValue = select(rootPackageJson);
2879
+ if (rootValue !== null) return rootValue;
2879
2880
  const patterns = getWorkspacePatterns(rootDirectory, rootPackageJson);
2880
- if (patterns.length === 0) return false;
2881
+ if (patterns.length === 0) return null;
2881
2882
  const visitedDirectories = /* @__PURE__ */ new Set();
2882
2883
  for (const pattern of patterns) {
2883
- const directories = resolveWorkspaceDirectories(rootDirectory, pattern);
2884
+ const directories = [...resolveWorkspaceDirectories(rootDirectory, pattern)].sort();
2884
2885
  for (const workspaceDirectory of directories) {
2885
2886
  if (visitedDirectories.has(workspaceDirectory)) continue;
2886
2887
  visitedDirectories.add(workspaceDirectory);
2887
- if (predicate(readPackageJson(path.join(workspaceDirectory, "package.json")))) return true;
2888
+ const value = select(readPackageJson(path.join(workspaceDirectory, "package.json")));
2889
+ if (value !== null) return value;
2888
2890
  }
2889
2891
  }
2890
- return false;
2892
+ return null;
2891
2893
  };
2894
+ const someWorkspacePackageJson = (rootDirectory, rootPackageJson, predicate) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, (packageJson) => predicate(packageJson) ? true : null) !== null;
2892
2895
  const NAMES = new Set([
2893
2896
  "react-native",
2894
2897
  "react-native-tvos",
2895
- "expo",
2896
- "expo-router",
2897
- "@expo/cli",
2898
- "@expo/metro-config",
2899
- "@expo/metro-runtime",
2898
+ ...new Set([
2899
+ "expo",
2900
+ "expo-router",
2901
+ "@expo/cli",
2902
+ "@expo/metro-config",
2903
+ "@expo/metro-runtime"
2904
+ ]),
2900
2905
  "react-native-windows",
2901
2906
  "react-native-macos"
2902
2907
  ]);
@@ -2920,6 +2925,11 @@ const isPackageJsonReactNativeAware = (packageJson) => {
2920
2925
  return false;
2921
2926
  };
2922
2927
  const hasReactNativeWorkspaceAnywhere = (rootDirectory, rootPackageJson) => someWorkspacePackageJson(rootDirectory, rootPackageJson, isPackageJsonReactNativeAware);
2928
+ const getExpoDependencySpec = (packageJson) => {
2929
+ const spec = packageJson.dependencies?.expo ?? packageJson.devDependencies?.expo ?? packageJson.peerDependencies?.expo ?? packageJson.optionalDependencies?.expo;
2930
+ return typeof spec === "string" ? spec : null;
2931
+ };
2932
+ const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
2923
2933
  const getPreactVersion = (packageJson) => {
2924
2934
  return {
2925
2935
  ...packageJson.peerDependencies,
@@ -3159,6 +3169,19 @@ const discoverProject = (directory) => {
3159
3169
  const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
3160
3170
  const sourceFileCount = countSourceFiles(directory);
3161
3171
  const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
3172
+ let expoVersion = hasReactNativeWorkspace ? findExpoVersion(directory, packageJson) : null;
3173
+ if (expoVersion !== null && isCatalogReference(expoVersion)) {
3174
+ const catalogName = extractCatalogName(expoVersion);
3175
+ let resolvedExpoVersion = resolveCatalogVersion(packageJson, "expo", directory, catalogName);
3176
+ if (!resolvedExpoVersion) {
3177
+ const monorepoRoot = findMonorepoRoot(directory);
3178
+ if (monorepoRoot) {
3179
+ const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
3180
+ if (isFile(monorepoPackageJsonPath)) resolvedExpoVersion = resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), "expo", monorepoRoot, catalogName);
3181
+ }
3182
+ }
3183
+ expoVersion = resolvedExpoVersion ?? expoVersion;
3184
+ }
3162
3185
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
3163
3186
  const preactVersion = getPreactVersion(packageJson);
3164
3187
  const projectInfo = {
@@ -3176,6 +3199,7 @@ const discoverProject = (directory) => {
3176
3199
  preactVersion,
3177
3200
  preactMajorVersion: parseReactMajor(preactVersion),
3178
3201
  hasReactNativeWorkspace,
3202
+ expoVersion,
3179
3203
  hasReanimated,
3180
3204
  sourceFileCount
3181
3205
  };
@@ -4247,6 +4271,17 @@ const layerOtlp = Layer.unwrap(Effect.gen(function* () {
4247
4271
  }).pipe(Layer.provide(FetchHttpClient.layer));
4248
4272
  }).pipe(Effect.orDie));
4249
4273
  /**
4274
+ * Resolves a requested lint worker count to a clamped integer within
4275
+ * `[MIN_SCAN_CONCURRENCY, MAX_SCAN_CONCURRENCY]`. `"auto"` uses the
4276
+ * machine's CPU cores; out-of-range or non-finite requests degrade to
4277
+ * `MIN_SCAN_CONCURRENCY` rather than oversubscribing or running zero workers.
4278
+ */
4279
+ const resolveScanConcurrency = (requested) => {
4280
+ const desired = requested === "auto" ? os.availableParallelism() : requested;
4281
+ if (!Number.isFinite(desired) || desired < 1) return 1;
4282
+ return Math.max(1, Math.min(Math.floor(desired), 16));
4283
+ };
4284
+ /**
4250
4285
  * Per-batch oxlint wall-clock budget. Reads from the env var on
4251
4286
  * startup so the eval harness can raise the budget under sandbox
4252
4287
  * microVMs without recompiling react-doctor. Tests override via
@@ -4266,6 +4301,30 @@ var OxlintSpawnTimeoutMs = class extends Context.Reference("react-doctor/OxlintS
4266
4301
  * tests that exercise the cap behavior.
4267
4302
  */
4268
4303
  var OxlintOutputMaxBytes = class extends Context.Reference("react-doctor/OxlintOutputMaxBytes", { defaultValue: () => OXLINT_OUTPUT_MAX_BYTES }) {};
4304
+ /**
4305
+ * Number of oxlint subprocesses the lint pass runs in parallel. Defaults
4306
+ * to `1` (serial — the historical behavior) so resource usage is opt-in.
4307
+ * The CLI's `--experimental-parallel` flag overrides this via `Layer.succeed`; the
4308
+ * `REACT_DOCTOR_PARALLEL` env var seeds the default for programmatic /
4309
+ * CI callers that never touch the flag:
4310
+ *
4311
+ * - unset / `0` / `false` / `off` → `1` (serial)
4312
+ * - `auto` / `true` / `on` → available CPU cores (clamped)
4313
+ * - a positive integer → that many workers (clamped)
4314
+ *
4315
+ * The resolved value is always within
4316
+ * `[MIN_SCAN_CONCURRENCY, MAX_SCAN_CONCURRENCY]`.
4317
+ */
4318
+ var OxlintConcurrency = class extends Context.Reference("react-doctor/OxlintConcurrency", { defaultValue: () => {
4319
+ const raw = process.env["REACT_DOCTOR_PARALLEL"];
4320
+ if (raw === void 0) return 1;
4321
+ const normalized = raw.trim().toLowerCase();
4322
+ if (normalized === "" || normalized === "0" || normalized === "false" || normalized === "off") return 1;
4323
+ if (normalized === "auto" || normalized === "true" || normalized === "on") return resolveScanConcurrency("auto");
4324
+ const parsed = Number.parseInt(normalized, 10);
4325
+ if (!Number.isInteger(parsed) || parsed <= 0) return 1;
4326
+ return resolveScanConcurrency(parsed);
4327
+ } }) {};
4269
4328
  const DIAGNOSTIC_SURFACES = [
4270
4329
  "cli",
4271
4330
  "prComment",
@@ -4548,6 +4607,359 @@ const resolveScanTarget = (requestedDirectory, options = {}) => {
4548
4607
  didRedirectViaRootDir: redirectedDirectory !== null
4549
4608
  };
4550
4609
  };
4610
+ const getDirectDependencyNames = (packageJson) => new Set([...Object.keys(packageJson.dependencies ?? {}), ...Object.keys(packageJson.devDependencies ?? {})]);
4611
+ const buildExpoCheckContext = (rootDirectory, expoVersion) => {
4612
+ const packageJson = readPackageJson(path.join(rootDirectory, "package.json"));
4613
+ return {
4614
+ rootDirectory,
4615
+ packageJson,
4616
+ directDependencyNames: getDirectDependencyNames(packageJson),
4617
+ expoSdkMajor: getLowestDependencyMajor(expoVersion)
4618
+ };
4619
+ };
4620
+ const buildExpoDiagnostic = (input) => ({
4621
+ filePath: input.filePath ?? "package.json",
4622
+ plugin: "react-doctor",
4623
+ rule: input.rule,
4624
+ severity: input.severity ?? "warning",
4625
+ message: input.message,
4626
+ help: input.help,
4627
+ line: input.line ?? 0,
4628
+ column: input.column ?? 0,
4629
+ category: input.category ?? "Correctness"
4630
+ });
4631
+ const CRITICAL_OVERRIDE_NAMES = new Set([
4632
+ "@expo/cli",
4633
+ "@expo/config",
4634
+ "@expo/metro-config",
4635
+ "@expo/metro-runtime",
4636
+ "@expo/metro",
4637
+ "metro"
4638
+ ]);
4639
+ const isCriticalOverrideName = (packageName) => CRITICAL_OVERRIDE_NAMES.has(packageName) || packageName.startsWith("metro-");
4640
+ const collectOverrideNames = (packageJson) => new Set([
4641
+ ...Object.keys(packageJson.overrides ?? {}),
4642
+ ...Object.keys(packageJson.resolutions ?? {}),
4643
+ ...Object.keys(packageJson.pnpm?.overrides ?? {})
4644
+ ]);
4645
+ const checkExpoDependencyOverrides = (context) => {
4646
+ const overriddenCriticalNames = [...collectOverrideNames(context.packageJson)].filter(isCriticalOverrideName).sort();
4647
+ if (overriddenCriticalNames.length === 0) return [];
4648
+ const quotedNames = overriddenCriticalNames.map((name) => `"${name}"`).join(", ");
4649
+ return [buildExpoDiagnostic({
4650
+ rule: "expo-no-conflicting-dependency-override",
4651
+ message: `package.json pins SDK-critical ${overriddenCriticalNames.length === 1 ? "package" : "packages"} via overrides/resolutions (${quotedNames}) — these versions are tied to the Expo SDK release and overriding them is unsupported and may break Metro or native builds`,
4652
+ help: `Remove the override/resolution for ${quotedNames} and reinstall so the Expo-pinned versions are used`
4653
+ })];
4654
+ };
4655
+ const isPathGitIgnored = (rootDirectory, absolutePath) => {
4656
+ const result = spawnSync("git", [
4657
+ "check-ignore",
4658
+ "-q",
4659
+ absolutePath
4660
+ ], {
4661
+ cwd: rootDirectory,
4662
+ stdio: [
4663
+ "ignore",
4664
+ "ignore",
4665
+ "ignore"
4666
+ ]
4667
+ });
4668
+ if (result.error) return null;
4669
+ if (result.status === 0) return true;
4670
+ if (result.status === 1) return false;
4671
+ return null;
4672
+ };
4673
+ const LOCAL_ENV_FILE_NAMES = [
4674
+ ".env.local",
4675
+ ".env.development.local",
4676
+ ".env.production.local",
4677
+ ".env.test.local"
4678
+ ];
4679
+ const checkExpoEnvLocalFiles = (context) => {
4680
+ const { rootDirectory } = context;
4681
+ const committedEnvFiles = LOCAL_ENV_FILE_NAMES.filter((fileName) => {
4682
+ const filePath = path.join(rootDirectory, fileName);
4683
+ if (!isFile(filePath)) return false;
4684
+ return isPathGitIgnored(rootDirectory, filePath) === false;
4685
+ });
4686
+ if (committedEnvFiles.length === 0) return [];
4687
+ return [buildExpoDiagnostic({
4688
+ rule: "expo-env-local-not-gitignored",
4689
+ category: "Security",
4690
+ message: `Local environment ${committedEnvFiles.length === 1 ? "file" : "files"} (${committedEnvFiles.join(", ")}) ${committedEnvFiles.length === 1 ? "is" : "are"} not ignored by Git — committing \`.env*.local\` risks leaking secrets and overriding committed defaults for everyone who clones the project`,
4691
+ help: `Add \`.env*.local\` to your .gitignore. If already committed, untrack with \`git rm --cached ${committedEnvFiles.join(" ")}\``
4692
+ })];
4693
+ };
4694
+ const isExpoSdkAtLeast = (expoSdkMajor, minMajor) => expoSdkMajor !== null && expoSdkMajor >= minMajor;
4695
+ const UNIMODULES_HELP = "Remove every `@unimodules/*` and `react-native-unimodules` package — their functionality now lives in `expo-modules-core`. See https://expo.fyi/r/sdk-44-remove-unimodules";
4696
+ const FIREBASE_HELP = "Use the Firebase JS SDK or React Native Firebase directly. See https://expo.fyi/firebase-migration-guide";
4697
+ const unimodulesEntry = (packageName) => ({
4698
+ packageName,
4699
+ rule: "expo-no-unimodules-packages",
4700
+ message: `"${packageName}" is a legacy unimodules package that is incompatible with Expo SDK 44+ and will break native builds`,
4701
+ help: UNIMODULES_HELP
4702
+ });
4703
+ const FLAGGED_DEPENDENCIES = [
4704
+ unimodulesEntry("@unimodules/core"),
4705
+ unimodulesEntry("@unimodules/react-native-adapter"),
4706
+ unimodulesEntry("react-native-unimodules"),
4707
+ {
4708
+ packageName: "expo-cli",
4709
+ rule: "expo-no-cli-dependencies",
4710
+ message: "`expo-cli` (the legacy global CLI) is a project dependency — the CLI now ships inside the `expo` package, and keeping `expo-cli` causes failures such as `unknown option --fix` when running `npx expo install --fix`",
4711
+ help: "Remove `expo-cli` from your dependencies and use the bundled CLI via `npx expo`"
4712
+ },
4713
+ {
4714
+ packageName: "eas-cli",
4715
+ rule: "expo-no-cli-dependencies",
4716
+ message: "`eas-cli` is a project dependency — pinning it in package.json drifts from the latest EAS CLI and bloats installs",
4717
+ help: "Remove `eas-cli` from your dependencies and run it on demand with `npx eas-cli` (or install it globally)"
4718
+ },
4719
+ {
4720
+ packageName: "expo-modules-autolinking",
4721
+ rule: "expo-no-redundant-dependency",
4722
+ message: "\"expo-modules-autolinking\" should not be a direct dependency — Expo installs it transitively as needed",
4723
+ help: "Remove `expo-modules-autolinking` from your package.json"
4724
+ },
4725
+ {
4726
+ packageName: "expo-dev-launcher",
4727
+ rule: "expo-no-redundant-dependency",
4728
+ message: "\"expo-dev-launcher\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
4729
+ help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
4730
+ },
4731
+ {
4732
+ packageName: "expo-dev-menu",
4733
+ rule: "expo-no-redundant-dependency",
4734
+ message: "\"expo-dev-menu\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
4735
+ help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
4736
+ },
4737
+ {
4738
+ packageName: "expo-modules-core",
4739
+ rule: "expo-no-redundant-dependency",
4740
+ message: "\"expo-modules-core\" should not be a direct dependency — use the API re-exported from the `expo` package",
4741
+ help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
4742
+ },
4743
+ {
4744
+ packageName: "@expo/metro-config",
4745
+ rule: "expo-no-redundant-dependency",
4746
+ message: "\"@expo/metro-config\" should not be a direct dependency — use the `expo/metro-config` sub-export of the `expo` package",
4747
+ help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
4748
+ },
4749
+ {
4750
+ packageName: "@types/react-native",
4751
+ rule: "expo-no-redundant-dependency",
4752
+ message: "\"@types/react-native\" should not be installed — React Native ships its own types since SDK 48",
4753
+ help: "Remove `@types/react-native` from your package.json",
4754
+ minSdkMajor: 48
4755
+ },
4756
+ {
4757
+ packageName: "@expo/config-plugins",
4758
+ rule: "expo-no-redundant-dependency",
4759
+ message: "\"@expo/config-plugins\" should not be a direct dependency — use the `expo/config-plugins` sub-export of the `expo` package",
4760
+ help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
4761
+ minSdkMajor: 48
4762
+ },
4763
+ {
4764
+ packageName: "@expo/prebuild-config",
4765
+ rule: "expo-no-redundant-dependency",
4766
+ message: "\"@expo/prebuild-config\" should not be a direct dependency — Expo installs it transitively",
4767
+ help: "Remove `@expo/prebuild-config` from your package.json",
4768
+ minSdkMajor: 53
4769
+ },
4770
+ {
4771
+ packageName: "expo-permissions",
4772
+ rule: "expo-no-redundant-dependency",
4773
+ message: "\"expo-permissions\" was deprecated in SDK 41 and may no longer compile — permissions moved onto each module (e.g. `MediaLibrary.requestPermissionsAsync()`)",
4774
+ help: "Remove `expo-permissions` and request permissions from the relevant module instead",
4775
+ minSdkMajor: 50
4776
+ },
4777
+ {
4778
+ packageName: "expo-app-loading",
4779
+ rule: "expo-no-redundant-dependency",
4780
+ message: "\"expo-app-loading\" was removed in SDK 49",
4781
+ help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
4782
+ minSdkMajor: 49
4783
+ },
4784
+ {
4785
+ packageName: "expo-firebase-analytics",
4786
+ rule: "expo-no-redundant-dependency",
4787
+ message: "\"expo-firebase-analytics\" was removed in SDK 48",
4788
+ help: FIREBASE_HELP,
4789
+ minSdkMajor: 48
4790
+ },
4791
+ {
4792
+ packageName: "expo-firebase-recaptcha",
4793
+ rule: "expo-no-redundant-dependency",
4794
+ message: "\"expo-firebase-recaptcha\" was removed in SDK 48",
4795
+ help: FIREBASE_HELP,
4796
+ minSdkMajor: 48
4797
+ },
4798
+ {
4799
+ packageName: "expo-firebase-core",
4800
+ rule: "expo-no-redundant-dependency",
4801
+ message: "\"expo-firebase-core\" was removed in SDK 48",
4802
+ help: FIREBASE_HELP,
4803
+ minSdkMajor: 48
4804
+ }
4805
+ ];
4806
+ const checkExpoFlaggedDependencies = (context) => FLAGGED_DEPENDENCIES.filter((flaggedDependency) => {
4807
+ if (!context.directDependencyNames.has(flaggedDependency.packageName)) return false;
4808
+ if (flaggedDependency.minSdkMajor === void 0) return true;
4809
+ return isExpoSdkAtLeast(context.expoSdkMajor, flaggedDependency.minSdkMajor);
4810
+ }).map((flaggedDependency) => buildExpoDiagnostic({
4811
+ rule: flaggedDependency.rule,
4812
+ message: flaggedDependency.message,
4813
+ help: flaggedDependency.help
4814
+ }));
4815
+ const findLocalModuleNativeFiles = (rootDirectory) => {
4816
+ const modulesDirectory = path.join(rootDirectory, "modules");
4817
+ if (!isDirectory(modulesDirectory)) return [];
4818
+ const nativeFilePaths = [];
4819
+ for (const moduleEntry of readDirectoryEntries(modulesDirectory)) {
4820
+ if (!moduleEntry.isDirectory()) continue;
4821
+ const moduleDirectory = path.join(modulesDirectory, moduleEntry.name);
4822
+ const gradlePath = path.join(moduleDirectory, "android", "build.gradle");
4823
+ if (isFile(gradlePath)) nativeFilePaths.push(gradlePath);
4824
+ const iosDirectory = path.join(moduleDirectory, "ios");
4825
+ if (isDirectory(iosDirectory)) {
4826
+ for (const iosEntry of readDirectoryEntries(iosDirectory)) if (iosEntry.isFile() && iosEntry.name.endsWith(".podspec")) nativeFilePaths.push(path.join(iosDirectory, iosEntry.name));
4827
+ }
4828
+ }
4829
+ return nativeFilePaths;
4830
+ };
4831
+ const checkExpoGitignore = (context) => {
4832
+ const { rootDirectory } = context;
4833
+ const diagnostics = [];
4834
+ const expoStateDirectory = path.join(rootDirectory, ".expo");
4835
+ if (isDirectory(expoStateDirectory) && isPathGitIgnored(rootDirectory, expoStateDirectory) === false) diagnostics.push(buildExpoDiagnostic({
4836
+ rule: "expo-gitignore",
4837
+ message: "The `.expo` directory is not ignored by Git — it holds machine-specific device history and dev-server settings that should not be committed",
4838
+ help: "Add `.expo/` to your .gitignore"
4839
+ }));
4840
+ if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
4841
+ rule: "expo-gitignore",
4842
+ message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored — usually caused by an overly broad `ios`/`android` ignore rule",
4843
+ help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
4844
+ }));
4845
+ return diagnostics;
4846
+ };
4847
+ const LOCKFILE_NAMES = [
4848
+ "pnpm-lock.yaml",
4849
+ "yarn.lock",
4850
+ "package-lock.json",
4851
+ "bun.lockb",
4852
+ "bun.lock"
4853
+ ];
4854
+ const checkExpoLockfile = (context) => {
4855
+ const workspaceRoot = isMonorepoRoot(context.rootDirectory) ? context.rootDirectory : findMonorepoRoot(context.rootDirectory) ?? context.rootDirectory;
4856
+ const presentLockfiles = LOCKFILE_NAMES.filter((lockfileName) => isFile(path.join(workspaceRoot, lockfileName)));
4857
+ if (presentLockfiles.length === 0) return [buildExpoDiagnostic({
4858
+ rule: "expo-lockfile",
4859
+ message: "No lock file detected at the project root — installs are not reproducible, and EAS Build cannot infer your package manager",
4860
+ help: "Install dependencies with your package manager to generate a lock file, then commit it"
4861
+ })];
4862
+ if (presentLockfiles.length > 1) return [buildExpoDiagnostic({
4863
+ rule: "expo-lockfile",
4864
+ message: `Multiple lock files detected (${presentLockfiles.join(", ")}) — CI environments such as EAS Build infer the package manager from the lock file, so this is ambiguous`,
4865
+ help: "Delete the lock files for the package managers you are not using and keep only one"
4866
+ })];
4867
+ return [];
4868
+ };
4869
+ const METRO_CONFIG_FILE_NAMES = [
4870
+ "metro.config.js",
4871
+ "metro.config.cjs",
4872
+ "metro.config.mjs",
4873
+ "metro.config.ts"
4874
+ ];
4875
+ const EXPO_METRO_CONFIG_EXTEND_SIGNALS = [
4876
+ "expo/metro-config",
4877
+ "@sentry/react-native/metro",
4878
+ "getSentryExpoConfig"
4879
+ ];
4880
+ const checkExpoMetroConfig = (context) => {
4881
+ const metroConfigPath = METRO_CONFIG_FILE_NAMES.map((fileName) => path.join(context.rootDirectory, fileName)).find((candidatePath) => isFile(candidatePath));
4882
+ if (metroConfigPath === void 0) return [];
4883
+ let contents;
4884
+ try {
4885
+ contents = fs.readFileSync(metroConfigPath, "utf-8");
4886
+ } catch {
4887
+ return [];
4888
+ }
4889
+ if (EXPO_METRO_CONFIG_EXTEND_SIGNALS.some((signal) => contents.includes(signal))) return [];
4890
+ return [buildExpoDiagnostic({
4891
+ rule: "expo-metro-config",
4892
+ filePath: path.basename(metroConfigPath),
4893
+ message: "Your metro.config does not extend `expo/metro-config` — a custom Metro config that doesn't extend Expo's leads to unexpected, hard-to-debug bundling issues",
4894
+ help: "Update your metro config to extend `expo/metro-config`. See https://docs.expo.dev/guides/customizing-metro/"
4895
+ })];
4896
+ };
4897
+ const CONFLICTING_SCRIPT_NAMES = ["expo", "react-native"];
4898
+ const checkExpoPackageJsonConflicts = (context) => {
4899
+ const { packageJson } = context;
4900
+ const diagnostics = [];
4901
+ const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
4902
+ if (conflictingScriptNames.length > 0) {
4903
+ const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
4904
+ const shadowsExpoCli = conflictingScriptNames.includes("expo");
4905
+ diagnostics.push(buildExpoDiagnostic({
4906
+ rule: "expo-package-json-conflict",
4907
+ message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that conflicts" : "as scripts that conflict"} with binaries in node_modules/.bin${shadowsExpoCli ? " — a `expo` script shadows the Expo CLI and will likely cause build failures" : ""}`,
4908
+ help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
4909
+ }));
4910
+ }
4911
+ const packageName = packageJson.name;
4912
+ if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
4913
+ rule: "expo-package-json-conflict",
4914
+ message: `package.json "name" is "${packageName}", which collides with a dependency of the same name`,
4915
+ help: "Rename your package so it no longer matches one of its dependencies"
4916
+ }));
4917
+ return diagnostics;
4918
+ };
4919
+ const EXPO_ROUTER_REACT_NAVIGATION_MIN_SDK_MAJOR = 56;
4920
+ const EXPO_ROUTER_REACT_NAVIGATION_MAX_SDK_MAJOR_EXCLUSIVE = 57;
4921
+ const checkExpoRouterReactNavigation = (context) => {
4922
+ const { expoSdkMajor } = context;
4923
+ if (!isExpoSdkAtLeast(expoSdkMajor, EXPO_ROUTER_REACT_NAVIGATION_MIN_SDK_MAJOR)) return [];
4924
+ if (expoSdkMajor !== null && expoSdkMajor >= EXPO_ROUTER_REACT_NAVIGATION_MAX_SDK_MAJOR_EXCLUSIVE) return [];
4925
+ if (!context.directDependencyNames.has("expo-router")) return [];
4926
+ const reactNavigationNames = [...context.directDependencyNames].filter((packageName) => packageName.startsWith("@react-navigation/")).sort();
4927
+ if (reactNavigationNames.length === 0) return [];
4928
+ return [buildExpoDiagnostic({
4929
+ rule: "expo-router-no-react-navigation",
4930
+ message: `As of SDK 56, expo-router is no longer compatible with react-navigation, but ${reactNavigationNames.map((name) => `"${name}"`).join(", ")} ${reactNavigationNames.length === 1 ? "is" : "are"} installed as direct ${reactNavigationNames.length === 1 ? "dependency" : "dependencies"}`,
4931
+ help: "Remove these `@react-navigation/*` packages and replace direct imports with their expo-router equivalents. See https://docs.expo.dev/router/migrate/sdk-55-to-56/"
4932
+ })];
4933
+ };
4934
+ const VECTOR_ICONS_MIN_SDK_MAJOR = 56;
4935
+ const SCOPED_VECTOR_ICONS_NAMESPACE = "@react-native-vector-icons/";
4936
+ const CONFLICTING_VECTOR_ICONS_PACKAGES = ["@expo/vector-icons", "react-native-vector-icons"];
4937
+ const checkExpoVectorIcons = (context) => {
4938
+ if (!isExpoSdkAtLeast(context.expoSdkMajor, VECTOR_ICONS_MIN_SDK_MAJOR)) return [];
4939
+ const hasScopedPackage = [...context.directDependencyNames].some((packageName) => packageName.startsWith(SCOPED_VECTOR_ICONS_NAMESPACE));
4940
+ const hasConflictingPackage = CONFLICTING_VECTOR_ICONS_PACKAGES.some((packageName) => context.directDependencyNames.has(packageName));
4941
+ if (!hasScopedPackage || !hasConflictingPackage) return [];
4942
+ return [buildExpoDiagnostic({
4943
+ rule: "expo-vector-icons-conflict",
4944
+ message: "This project installs both the scoped `@react-native-vector-icons/*` packages and `@expo/vector-icons` (or the deprecated `react-native-vector-icons`) — mixing them causes icon-rendering conflicts",
4945
+ help: "Migrate to the scoped packages by running `npx @react-native-vector-icons/codemod`, then remove the conflicting package"
4946
+ })];
4947
+ };
4948
+ const checkExpoProject = (rootDirectory, project) => {
4949
+ if (project.expoVersion === null) return [];
4950
+ const context = buildExpoCheckContext(rootDirectory, project.expoVersion);
4951
+ return [
4952
+ ...checkExpoFlaggedDependencies(context),
4953
+ ...checkExpoDependencyOverrides(context),
4954
+ ...checkExpoRouterReactNavigation(context),
4955
+ ...checkExpoVectorIcons(context),
4956
+ ...checkExpoPackageJsonConflicts(context),
4957
+ ...checkExpoLockfile(context),
4958
+ ...checkExpoGitignore(context),
4959
+ ...checkExpoEnvLocalFiles(context),
4960
+ ...checkExpoMetroConfig(context)
4961
+ ];
4962
+ };
4551
4963
  const PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
4552
4964
  const PNPM_LOCKFILE = "pnpm-lock.yaml";
4553
4965
  const PACKAGE_JSON_FILE = "package.json";
@@ -5828,6 +6240,7 @@ const buildCapabilities = (project) => {
5828
6240
  const capabilities = /* @__PURE__ */ new Set();
5829
6241
  capabilities.add(project.framework);
5830
6242
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6243
+ if (project.expoVersion !== null) capabilities.add("expo");
5831
6244
  const reactMajor = project.reactMajorVersion;
5832
6245
  if (reactMajor !== null) {
5833
6246
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -6105,6 +6518,44 @@ const dedupeDiagnostics = (diagnostics) => {
6105
6518
  }
6106
6519
  return uniqueDiagnostics;
6107
6520
  };
6521
+ /**
6522
+ * Runs `task` over `items` with at most `concurrency` tasks in flight at
6523
+ * once, returning results in input order. A pool of workers each pulls the
6524
+ * next not-yet-started index until the list drains — so a worker that
6525
+ * finishes a fast task immediately picks up the next one (greedy load
6526
+ * balancing), which matters when tasks have uneven durations (oxlint
6527
+ * batches do).
6528
+ *
6529
+ * Failure semantics mirror a bounded `Promise.all`: on the first rejection
6530
+ * no further tasks are started, the already-in-flight tasks are awaited to
6531
+ * settle (so no subprocess is orphaned mid-write), and the returned promise
6532
+ * rejects with that first error. This keeps the caller's fail-fast retry
6533
+ * path (e.g. oxlint's retry-without-extends) from spawning a second wave on
6534
+ * top of a still-running first one.
6535
+ */
6536
+ const mapWithConcurrency = async (items, concurrency, task) => {
6537
+ const results = new Array(items.length);
6538
+ if (items.length === 0) return results;
6539
+ const workerCount = Math.min(Math.max(1, Math.floor(concurrency) || 1), items.length);
6540
+ let nextIndex = 0;
6541
+ const errors = [];
6542
+ const runWorker = async () => {
6543
+ while (errors.length === 0) {
6544
+ const index = nextIndex;
6545
+ nextIndex += 1;
6546
+ if (index >= items.length) return;
6547
+ try {
6548
+ results[index] = await task(items[index], index);
6549
+ } catch (error) {
6550
+ errors.push(error);
6551
+ return;
6552
+ }
6553
+ }
6554
+ };
6555
+ await Promise.all(Array.from({ length: workerCount }, runWorker));
6556
+ if (errors.length > 0) throw errors[0];
6557
+ return results;
6558
+ };
6108
6559
  const getPublicEnvPrefix = (framework) => {
6109
6560
  switch (framework) {
6110
6561
  case "nextjs": return "NEXT_PUBLIC_*";
@@ -6787,6 +7238,7 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
6787
7238
  */
6788
7239
  const spawnLintBatches = async (input) => {
6789
7240
  const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes } = input;
7241
+ const concurrency = resolveScanConcurrency(input.concurrency ?? 1);
6790
7242
  const totalFileCount = fileBatches.reduce((sum, batch) => sum + batch.length, 0);
6791
7243
  const allDiagnostics = [];
6792
7244
  const droppedFiles = [];
@@ -6806,23 +7258,31 @@ const spawnLintBatches = async (input) => {
6806
7258
  return [...await spawnLintBatch(batch.slice(0, splitIndex)), ...await spawnLintBatch(batch.slice(splitIndex))];
6807
7259
  }
6808
7260
  };
7261
+ let startedFileCount = 0;
6809
7262
  let scannedFileCount = 0;
6810
- for (const batch of fileBatches) {
6811
- let batchFileIndex = 0;
6812
- const progressInterval = onFileProgress && batch.length > 1 ? setInterval(() => {
6813
- if (batchFileIndex < batch.length) {
6814
- batchFileIndex += 1;
6815
- onFileProgress(scannedFileCount + batchFileIndex, totalFileCount);
6816
- }
6817
- }, 50) : null;
6818
- try {
7263
+ let displayedFileCount = 0;
7264
+ const progressTimer = onFileProgress && totalFileCount > 1 ? setInterval(() => {
7265
+ const ceiling = Math.min(startedFileCount, totalFileCount - 1);
7266
+ if (displayedFileCount < ceiling) {
7267
+ displayedFileCount += 1;
7268
+ onFileProgress(displayedFileCount, totalFileCount);
7269
+ }
7270
+ }, 50) : null;
7271
+ progressTimer?.unref?.();
7272
+ try {
7273
+ const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
7274
+ startedFileCount += batch.length;
6819
7275
  const batchDiagnostics = await spawnLintBatch(batch);
6820
- allDiagnostics.push(...batchDiagnostics);
6821
7276
  scannedFileCount += batch.length;
6822
- onFileProgress?.(scannedFileCount, totalFileCount);
6823
- } finally {
6824
- if (progressInterval !== null) clearInterval(progressInterval);
6825
- }
7277
+ if (onFileProgress) {
7278
+ displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
7279
+ onFileProgress(displayedFileCount, totalFileCount);
7280
+ }
7281
+ return batchDiagnostics;
7282
+ });
7283
+ for (const batchDiagnostics of batchResults) allDiagnostics.push(...batchDiagnostics);
7284
+ } finally {
7285
+ if (progressTimer !== null) clearInterval(progressTimer);
6826
7286
  }
6827
7287
  if (droppedFiles.length > 0 && onPartialFailure) {
6828
7288
  const previewFiles = droppedFiles.slice(0, 3).join(", ");
@@ -6949,7 +7409,8 @@ const runOxlint = async (options) => {
6949
7409
  onPartialFailure,
6950
7410
  onFileProgress: options.onFileProgress,
6951
7411
  spawnTimeoutMs,
6952
- outputMaxBytes
7412
+ outputMaxBytes,
7413
+ concurrency: options.concurrency
6953
7414
  });
6954
7415
  writeOxlintConfig(configPath, buildConfig(extendsPaths));
6955
7416
  try {
@@ -7017,6 +7478,7 @@ var Linter = class Linter extends Context.Service()("react-doctor/Linter") {
7017
7478
  const partialFailures = yield* LintPartialFailures;
7018
7479
  const spawnTimeoutMs = yield* OxlintSpawnTimeoutMs;
7019
7480
  const outputMaxBytes = yield* OxlintOutputMaxBytes;
7481
+ const concurrency = yield* OxlintConcurrency;
7020
7482
  const collectedFailures = [];
7021
7483
  const diagnostics = yield* Effect.tryPromise({
7022
7484
  try: () => runOxlint({
@@ -7035,7 +7497,8 @@ var Linter = class Linter extends Context.Service()("react-doctor/Linter") {
7035
7497
  },
7036
7498
  onFileProgress: input.onFileProgress,
7037
7499
  spawnTimeoutMs,
7038
- outputMaxBytes
7500
+ outputMaxBytes,
7501
+ concurrency
7039
7502
  }),
7040
7503
  catch: ensureReactDoctorError
7041
7504
  });
@@ -7368,7 +7831,11 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
7368
7831
  showWarnings
7369
7832
  });
7370
7833
  const applyPerElementPipeline = (rawStream) => rawStream.pipe(Stream.filterMap(filterMapNullable(transform.apply)), Stream.tap((diagnostic) => reporterService.emit(diagnostic)));
7371
- const environmentDiagnostics = isDiffMode ? [] : [...checkReducedMotion(scanDirectory), ...checkPnpmHardening(scanDirectory)];
7834
+ const environmentDiagnostics = isDiffMode ? [] : [
7835
+ ...checkReducedMotion(scanDirectory),
7836
+ ...checkPnpmHardening(scanDirectory),
7837
+ ...checkExpoProject(scanDirectory, project)
7838
+ ];
7372
7839
  const envCollected = yield* Stream.runCollect(applyPerElementPipeline(Stream.fromIterable(environmentDiagnostics)));
7373
7840
  const lintFailure = yield* Ref.make({
7374
7841
  didFail: false,
@@ -7380,6 +7847,8 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
7380
7847
  didFail: false,
7381
7848
  reason: null
7382
7849
  });
7850
+ const scanConcurrency = yield* OxlintConcurrency;
7851
+ const workerCountSuffix = scanConcurrency > 1 ? ` · ${scanConcurrency} workers` : "";
7383
7852
  const scanProgress = yield* progressService.start("Scanning...");
7384
7853
  const scanStartTime = Date.now();
7385
7854
  let lastReportedTotalFileCount = 0;
@@ -7396,7 +7865,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
7396
7865
  configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
7397
7866
  onFileProgress: (scannedFileCount, totalFileCount) => {
7398
7867
  lastReportedTotalFileCount = totalFileCount;
7399
- Effect.runSync(scanProgress.update(`Scanning files (${scannedFileCount}/${totalFileCount})...`));
7868
+ Effect.runSync(scanProgress.update(`Scanning files (${scannedFileCount}/${totalFileCount})${workerCountSuffix}...`));
7400
7869
  }
7401
7870
  }).pipe(Stream.catchTag("ReactDoctorError", (error) => Stream.unwrap(Effect.gen(function* () {
7402
7871
  yield* Ref.set(lintFailure, {
@@ -7428,7 +7897,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
7428
7897
  const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
7429
7898
  if (!lintFailureState.didFail) if (deadCodeFailureState.didFail) yield* scanProgress.fail(DEAD_CODE_FAIL_TEXT);
7430
7899
  else if (input.suppressScanSummary) yield* scanProgress.stop();
7431
- else yield* scanProgress.succeed(`Scanned ${totalFileCount} ${totalFileCount === 1 ? "file" : "files"} in ${scanElapsedSeconds}s`);
7900
+ else yield* scanProgress.succeed(`Scanned ${totalFileCount} ${totalFileCount === 1 ? "file" : "files"} in ${scanElapsedSeconds}s${workerCountSuffix}`);
7432
7901
  yield* reporterService.finalize;
7433
7902
  const finalDiagnostics = [
7434
7903
  ...envCollected,