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/README.md +8 -0
- package/dist/cli.js +539 -38
- package/dist/index.d.ts +16 -0
- package/dist/index.js +500 -31
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -15,6 +15,7 @@ import * as Redacted from "effect/Redacted";
|
|
|
15
15
|
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
16
16
|
import * as Otlp from "effect/unstable/observability/Otlp";
|
|
17
17
|
import * as Context from "effect/Context";
|
|
18
|
+
import os, { tmpdir } from "node:os";
|
|
18
19
|
import * as Console from "effect/Console";
|
|
19
20
|
import * as Fiber from "effect/Fiber";
|
|
20
21
|
import * as Filter from "effect/Filter";
|
|
@@ -27,7 +28,6 @@ import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
|
|
|
27
28
|
import * as NodePath from "@effect/platform-node-shared/NodePath";
|
|
28
29
|
import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
29
30
|
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
30
|
-
import os, { tmpdir } from "node:os";
|
|
31
31
|
import * as ts from "typescript";
|
|
32
32
|
import { gzipSync } from "node:zlib";
|
|
33
33
|
import { performance } from "node:perf_hooks";
|
|
@@ -5892,29 +5892,34 @@ const findDependencyInfoFromMonorepoRoot = (directory) => {
|
|
|
5892
5892
|
framework: rootInfo.framework !== "unknown" ? rootInfo.framework : workspaceInfo.framework
|
|
5893
5893
|
};
|
|
5894
5894
|
};
|
|
5895
|
-
const
|
|
5896
|
-
|
|
5895
|
+
const findInWorkspacePackageJsons = (rootDirectory, rootPackageJson, select) => {
|
|
5896
|
+
const rootValue = select(rootPackageJson);
|
|
5897
|
+
if (rootValue !== null) return rootValue;
|
|
5897
5898
|
const patterns = getWorkspacePatterns(rootDirectory, rootPackageJson);
|
|
5898
|
-
if (patterns.length === 0) return
|
|
5899
|
+
if (patterns.length === 0) return null;
|
|
5899
5900
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
5900
5901
|
for (const pattern of patterns) {
|
|
5901
|
-
const directories = resolveWorkspaceDirectories(rootDirectory, pattern);
|
|
5902
|
+
const directories = [...resolveWorkspaceDirectories(rootDirectory, pattern)].sort();
|
|
5902
5903
|
for (const workspaceDirectory of directories) {
|
|
5903
5904
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
5904
5905
|
visitedDirectories.add(workspaceDirectory);
|
|
5905
|
-
|
|
5906
|
+
const value = select(readPackageJson$1(path.join(workspaceDirectory, "package.json")));
|
|
5907
|
+
if (value !== null) return value;
|
|
5906
5908
|
}
|
|
5907
5909
|
}
|
|
5908
|
-
return
|
|
5910
|
+
return null;
|
|
5909
5911
|
};
|
|
5912
|
+
const someWorkspacePackageJson = (rootDirectory, rootPackageJson, predicate) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, (packageJson) => predicate(packageJson) ? true : null) !== null;
|
|
5910
5913
|
const NAMES = new Set([
|
|
5911
5914
|
"react-native",
|
|
5912
5915
|
"react-native-tvos",
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5916
|
+
...new Set([
|
|
5917
|
+
"expo",
|
|
5918
|
+
"expo-router",
|
|
5919
|
+
"@expo/cli",
|
|
5920
|
+
"@expo/metro-config",
|
|
5921
|
+
"@expo/metro-runtime"
|
|
5922
|
+
]),
|
|
5918
5923
|
"react-native-windows",
|
|
5919
5924
|
"react-native-macos"
|
|
5920
5925
|
]);
|
|
@@ -5938,6 +5943,11 @@ const isPackageJsonReactNativeAware = (packageJson) => {
|
|
|
5938
5943
|
return false;
|
|
5939
5944
|
};
|
|
5940
5945
|
const hasReactNativeWorkspaceAnywhere = (rootDirectory, rootPackageJson) => someWorkspacePackageJson(rootDirectory, rootPackageJson, isPackageJsonReactNativeAware);
|
|
5946
|
+
const getExpoDependencySpec = (packageJson) => {
|
|
5947
|
+
const spec = packageJson.dependencies?.expo ?? packageJson.devDependencies?.expo ?? packageJson.peerDependencies?.expo ?? packageJson.optionalDependencies?.expo;
|
|
5948
|
+
return typeof spec === "string" ? spec : null;
|
|
5949
|
+
};
|
|
5950
|
+
const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
|
|
5941
5951
|
const getPreactVersion = (packageJson) => {
|
|
5942
5952
|
return {
|
|
5943
5953
|
...packageJson.peerDependencies,
|
|
@@ -6174,6 +6184,19 @@ const discoverProject = (directory) => {
|
|
|
6174
6184
|
const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
|
|
6175
6185
|
const sourceFileCount = countSourceFiles(directory);
|
|
6176
6186
|
const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
|
|
6187
|
+
let expoVersion = hasReactNativeWorkspace ? findExpoVersion(directory, packageJson) : null;
|
|
6188
|
+
if (expoVersion !== null && isCatalogReference(expoVersion)) {
|
|
6189
|
+
const catalogName = extractCatalogName(expoVersion);
|
|
6190
|
+
let resolvedExpoVersion = resolveCatalogVersion(packageJson, "expo", directory, catalogName);
|
|
6191
|
+
if (!resolvedExpoVersion) {
|
|
6192
|
+
const monorepoRoot = findMonorepoRoot(directory);
|
|
6193
|
+
if (monorepoRoot) {
|
|
6194
|
+
const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
|
|
6195
|
+
if (isFile(monorepoPackageJsonPath)) resolvedExpoVersion = resolveCatalogVersion(readPackageJson$1(monorepoPackageJsonPath), "expo", monorepoRoot, catalogName);
|
|
6196
|
+
}
|
|
6197
|
+
}
|
|
6198
|
+
expoVersion = resolvedExpoVersion ?? expoVersion;
|
|
6199
|
+
}
|
|
6177
6200
|
const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
|
|
6178
6201
|
const preactVersion = getPreactVersion(packageJson);
|
|
6179
6202
|
const projectInfo = {
|
|
@@ -6191,6 +6214,7 @@ const discoverProject = (directory) => {
|
|
|
6191
6214
|
preactVersion,
|
|
6192
6215
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
6193
6216
|
hasReactNativeWorkspace,
|
|
6217
|
+
expoVersion,
|
|
6194
6218
|
hasReanimated,
|
|
6195
6219
|
sourceFileCount
|
|
6196
6220
|
};
|
|
@@ -7264,6 +7288,17 @@ const layerOtlp = Layer.unwrap(Effect.gen(function* () {
|
|
|
7264
7288
|
}).pipe(Layer.provide(FetchHttpClient.layer));
|
|
7265
7289
|
}).pipe(Effect.orDie));
|
|
7266
7290
|
/**
|
|
7291
|
+
* Resolves a requested lint worker count to a clamped integer within
|
|
7292
|
+
* `[MIN_SCAN_CONCURRENCY, MAX_SCAN_CONCURRENCY]`. `"auto"` uses the
|
|
7293
|
+
* machine's CPU cores; out-of-range or non-finite requests degrade to
|
|
7294
|
+
* `MIN_SCAN_CONCURRENCY` rather than oversubscribing or running zero workers.
|
|
7295
|
+
*/
|
|
7296
|
+
const resolveScanConcurrency = (requested) => {
|
|
7297
|
+
const desired = requested === "auto" ? os.availableParallelism() : requested;
|
|
7298
|
+
if (!Number.isFinite(desired) || desired < 1) return 1;
|
|
7299
|
+
return Math.max(1, Math.min(Math.floor(desired), 16));
|
|
7300
|
+
};
|
|
7301
|
+
/**
|
|
7267
7302
|
* Per-batch oxlint wall-clock budget. Reads from the env var on
|
|
7268
7303
|
* startup so the eval harness can raise the budget under sandbox
|
|
7269
7304
|
* microVMs without recompiling react-doctor. Tests override via
|
|
@@ -7283,6 +7318,30 @@ var OxlintSpawnTimeoutMs = class extends Context.Reference("react-doctor/OxlintS
|
|
|
7283
7318
|
* tests that exercise the cap behavior.
|
|
7284
7319
|
*/
|
|
7285
7320
|
var OxlintOutputMaxBytes = class extends Context.Reference("react-doctor/OxlintOutputMaxBytes", { defaultValue: () => OXLINT_OUTPUT_MAX_BYTES }) {};
|
|
7321
|
+
/**
|
|
7322
|
+
* Number of oxlint subprocesses the lint pass runs in parallel. Defaults
|
|
7323
|
+
* to `1` (serial — the historical behavior) so resource usage is opt-in.
|
|
7324
|
+
* The CLI's `--experimental-parallel` flag overrides this via `Layer.succeed`; the
|
|
7325
|
+
* `REACT_DOCTOR_PARALLEL` env var seeds the default for programmatic /
|
|
7326
|
+
* CI callers that never touch the flag:
|
|
7327
|
+
*
|
|
7328
|
+
* - unset / `0` / `false` / `off` → `1` (serial)
|
|
7329
|
+
* - `auto` / `true` / `on` → available CPU cores (clamped)
|
|
7330
|
+
* - a positive integer → that many workers (clamped)
|
|
7331
|
+
*
|
|
7332
|
+
* The resolved value is always within
|
|
7333
|
+
* `[MIN_SCAN_CONCURRENCY, MAX_SCAN_CONCURRENCY]`.
|
|
7334
|
+
*/
|
|
7335
|
+
var OxlintConcurrency = class extends Context.Reference("react-doctor/OxlintConcurrency", { defaultValue: () => {
|
|
7336
|
+
const raw = process.env["REACT_DOCTOR_PARALLEL"];
|
|
7337
|
+
if (raw === void 0) return 1;
|
|
7338
|
+
const normalized = raw.trim().toLowerCase();
|
|
7339
|
+
if (normalized === "" || normalized === "0" || normalized === "false" || normalized === "off") return 1;
|
|
7340
|
+
if (normalized === "auto" || normalized === "true" || normalized === "on") return resolveScanConcurrency("auto");
|
|
7341
|
+
const parsed = Number.parseInt(normalized, 10);
|
|
7342
|
+
if (!Number.isInteger(parsed) || parsed <= 0) return 1;
|
|
7343
|
+
return resolveScanConcurrency(parsed);
|
|
7344
|
+
} }) {};
|
|
7286
7345
|
const DIAGNOSTIC_SURFACES = [
|
|
7287
7346
|
"cli",
|
|
7288
7347
|
"prComment",
|
|
@@ -7562,6 +7621,359 @@ const resolveScanTarget = (requestedDirectory, options = {}) => {
|
|
|
7562
7621
|
didRedirectViaRootDir: redirectedDirectory !== null
|
|
7563
7622
|
};
|
|
7564
7623
|
};
|
|
7624
|
+
const getDirectDependencyNames = (packageJson) => new Set([...Object.keys(packageJson.dependencies ?? {}), ...Object.keys(packageJson.devDependencies ?? {})]);
|
|
7625
|
+
const buildExpoCheckContext = (rootDirectory, expoVersion) => {
|
|
7626
|
+
const packageJson = readPackageJson$1(path.join(rootDirectory, "package.json"));
|
|
7627
|
+
return {
|
|
7628
|
+
rootDirectory,
|
|
7629
|
+
packageJson,
|
|
7630
|
+
directDependencyNames: getDirectDependencyNames(packageJson),
|
|
7631
|
+
expoSdkMajor: getLowestDependencyMajor(expoVersion)
|
|
7632
|
+
};
|
|
7633
|
+
};
|
|
7634
|
+
const buildExpoDiagnostic = (input) => ({
|
|
7635
|
+
filePath: input.filePath ?? "package.json",
|
|
7636
|
+
plugin: "react-doctor",
|
|
7637
|
+
rule: input.rule,
|
|
7638
|
+
severity: input.severity ?? "warning",
|
|
7639
|
+
message: input.message,
|
|
7640
|
+
help: input.help,
|
|
7641
|
+
line: input.line ?? 0,
|
|
7642
|
+
column: input.column ?? 0,
|
|
7643
|
+
category: input.category ?? "Correctness"
|
|
7644
|
+
});
|
|
7645
|
+
const CRITICAL_OVERRIDE_NAMES = new Set([
|
|
7646
|
+
"@expo/cli",
|
|
7647
|
+
"@expo/config",
|
|
7648
|
+
"@expo/metro-config",
|
|
7649
|
+
"@expo/metro-runtime",
|
|
7650
|
+
"@expo/metro",
|
|
7651
|
+
"metro"
|
|
7652
|
+
]);
|
|
7653
|
+
const isCriticalOverrideName = (packageName) => CRITICAL_OVERRIDE_NAMES.has(packageName) || packageName.startsWith("metro-");
|
|
7654
|
+
const collectOverrideNames = (packageJson) => new Set([
|
|
7655
|
+
...Object.keys(packageJson.overrides ?? {}),
|
|
7656
|
+
...Object.keys(packageJson.resolutions ?? {}),
|
|
7657
|
+
...Object.keys(packageJson.pnpm?.overrides ?? {})
|
|
7658
|
+
]);
|
|
7659
|
+
const checkExpoDependencyOverrides = (context) => {
|
|
7660
|
+
const overriddenCriticalNames = [...collectOverrideNames(context.packageJson)].filter(isCriticalOverrideName).sort();
|
|
7661
|
+
if (overriddenCriticalNames.length === 0) return [];
|
|
7662
|
+
const quotedNames = overriddenCriticalNames.map((name) => `"${name}"`).join(", ");
|
|
7663
|
+
return [buildExpoDiagnostic({
|
|
7664
|
+
rule: "expo-no-conflicting-dependency-override",
|
|
7665
|
+
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`,
|
|
7666
|
+
help: `Remove the override/resolution for ${quotedNames} and reinstall so the Expo-pinned versions are used`
|
|
7667
|
+
})];
|
|
7668
|
+
};
|
|
7669
|
+
const isPathGitIgnored = (rootDirectory, absolutePath) => {
|
|
7670
|
+
const result = spawnSync("git", [
|
|
7671
|
+
"check-ignore",
|
|
7672
|
+
"-q",
|
|
7673
|
+
absolutePath
|
|
7674
|
+
], {
|
|
7675
|
+
cwd: rootDirectory,
|
|
7676
|
+
stdio: [
|
|
7677
|
+
"ignore",
|
|
7678
|
+
"ignore",
|
|
7679
|
+
"ignore"
|
|
7680
|
+
]
|
|
7681
|
+
});
|
|
7682
|
+
if (result.error) return null;
|
|
7683
|
+
if (result.status === 0) return true;
|
|
7684
|
+
if (result.status === 1) return false;
|
|
7685
|
+
return null;
|
|
7686
|
+
};
|
|
7687
|
+
const LOCAL_ENV_FILE_NAMES = [
|
|
7688
|
+
".env.local",
|
|
7689
|
+
".env.development.local",
|
|
7690
|
+
".env.production.local",
|
|
7691
|
+
".env.test.local"
|
|
7692
|
+
];
|
|
7693
|
+
const checkExpoEnvLocalFiles = (context) => {
|
|
7694
|
+
const { rootDirectory } = context;
|
|
7695
|
+
const committedEnvFiles = LOCAL_ENV_FILE_NAMES.filter((fileName) => {
|
|
7696
|
+
const filePath = path.join(rootDirectory, fileName);
|
|
7697
|
+
if (!isFile(filePath)) return false;
|
|
7698
|
+
return isPathGitIgnored(rootDirectory, filePath) === false;
|
|
7699
|
+
});
|
|
7700
|
+
if (committedEnvFiles.length === 0) return [];
|
|
7701
|
+
return [buildExpoDiagnostic({
|
|
7702
|
+
rule: "expo-env-local-not-gitignored",
|
|
7703
|
+
category: "Security",
|
|
7704
|
+
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`,
|
|
7705
|
+
help: `Add \`.env*.local\` to your .gitignore. If already committed, untrack with \`git rm --cached ${committedEnvFiles.join(" ")}\``
|
|
7706
|
+
})];
|
|
7707
|
+
};
|
|
7708
|
+
const isExpoSdkAtLeast = (expoSdkMajor, minMajor) => expoSdkMajor !== null && expoSdkMajor >= minMajor;
|
|
7709
|
+
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";
|
|
7710
|
+
const FIREBASE_HELP = "Use the Firebase JS SDK or React Native Firebase directly. See https://expo.fyi/firebase-migration-guide";
|
|
7711
|
+
const unimodulesEntry = (packageName) => ({
|
|
7712
|
+
packageName,
|
|
7713
|
+
rule: "expo-no-unimodules-packages",
|
|
7714
|
+
message: `"${packageName}" is a legacy unimodules package that is incompatible with Expo SDK 44+ and will break native builds`,
|
|
7715
|
+
help: UNIMODULES_HELP
|
|
7716
|
+
});
|
|
7717
|
+
const FLAGGED_DEPENDENCIES = [
|
|
7718
|
+
unimodulesEntry("@unimodules/core"),
|
|
7719
|
+
unimodulesEntry("@unimodules/react-native-adapter"),
|
|
7720
|
+
unimodulesEntry("react-native-unimodules"),
|
|
7721
|
+
{
|
|
7722
|
+
packageName: "expo-cli",
|
|
7723
|
+
rule: "expo-no-cli-dependencies",
|
|
7724
|
+
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`",
|
|
7725
|
+
help: "Remove `expo-cli` from your dependencies and use the bundled CLI via `npx expo`"
|
|
7726
|
+
},
|
|
7727
|
+
{
|
|
7728
|
+
packageName: "eas-cli",
|
|
7729
|
+
rule: "expo-no-cli-dependencies",
|
|
7730
|
+
message: "`eas-cli` is a project dependency — pinning it in package.json drifts from the latest EAS CLI and bloats installs",
|
|
7731
|
+
help: "Remove `eas-cli` from your dependencies and run it on demand with `npx eas-cli` (or install it globally)"
|
|
7732
|
+
},
|
|
7733
|
+
{
|
|
7734
|
+
packageName: "expo-modules-autolinking",
|
|
7735
|
+
rule: "expo-no-redundant-dependency",
|
|
7736
|
+
message: "\"expo-modules-autolinking\" should not be a direct dependency — Expo installs it transitively as needed",
|
|
7737
|
+
help: "Remove `expo-modules-autolinking` from your package.json"
|
|
7738
|
+
},
|
|
7739
|
+
{
|
|
7740
|
+
packageName: "expo-dev-launcher",
|
|
7741
|
+
rule: "expo-no-redundant-dependency",
|
|
7742
|
+
message: "\"expo-dev-launcher\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
|
|
7743
|
+
help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
|
|
7744
|
+
},
|
|
7745
|
+
{
|
|
7746
|
+
packageName: "expo-dev-menu",
|
|
7747
|
+
rule: "expo-no-redundant-dependency",
|
|
7748
|
+
message: "\"expo-dev-menu\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
|
|
7749
|
+
help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
|
|
7750
|
+
},
|
|
7751
|
+
{
|
|
7752
|
+
packageName: "expo-modules-core",
|
|
7753
|
+
rule: "expo-no-redundant-dependency",
|
|
7754
|
+
message: "\"expo-modules-core\" should not be a direct dependency — use the API re-exported from the `expo` package",
|
|
7755
|
+
help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
|
|
7756
|
+
},
|
|
7757
|
+
{
|
|
7758
|
+
packageName: "@expo/metro-config",
|
|
7759
|
+
rule: "expo-no-redundant-dependency",
|
|
7760
|
+
message: "\"@expo/metro-config\" should not be a direct dependency — use the `expo/metro-config` sub-export of the `expo` package",
|
|
7761
|
+
help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
|
|
7762
|
+
},
|
|
7763
|
+
{
|
|
7764
|
+
packageName: "@types/react-native",
|
|
7765
|
+
rule: "expo-no-redundant-dependency",
|
|
7766
|
+
message: "\"@types/react-native\" should not be installed — React Native ships its own types since SDK 48",
|
|
7767
|
+
help: "Remove `@types/react-native` from your package.json",
|
|
7768
|
+
minSdkMajor: 48
|
|
7769
|
+
},
|
|
7770
|
+
{
|
|
7771
|
+
packageName: "@expo/config-plugins",
|
|
7772
|
+
rule: "expo-no-redundant-dependency",
|
|
7773
|
+
message: "\"@expo/config-plugins\" should not be a direct dependency — use the `expo/config-plugins` sub-export of the `expo` package",
|
|
7774
|
+
help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
|
|
7775
|
+
minSdkMajor: 48
|
|
7776
|
+
},
|
|
7777
|
+
{
|
|
7778
|
+
packageName: "@expo/prebuild-config",
|
|
7779
|
+
rule: "expo-no-redundant-dependency",
|
|
7780
|
+
message: "\"@expo/prebuild-config\" should not be a direct dependency — Expo installs it transitively",
|
|
7781
|
+
help: "Remove `@expo/prebuild-config` from your package.json",
|
|
7782
|
+
minSdkMajor: 53
|
|
7783
|
+
},
|
|
7784
|
+
{
|
|
7785
|
+
packageName: "expo-permissions",
|
|
7786
|
+
rule: "expo-no-redundant-dependency",
|
|
7787
|
+
message: "\"expo-permissions\" was deprecated in SDK 41 and may no longer compile — permissions moved onto each module (e.g. `MediaLibrary.requestPermissionsAsync()`)",
|
|
7788
|
+
help: "Remove `expo-permissions` and request permissions from the relevant module instead",
|
|
7789
|
+
minSdkMajor: 50
|
|
7790
|
+
},
|
|
7791
|
+
{
|
|
7792
|
+
packageName: "expo-app-loading",
|
|
7793
|
+
rule: "expo-no-redundant-dependency",
|
|
7794
|
+
message: "\"expo-app-loading\" was removed in SDK 49",
|
|
7795
|
+
help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
|
|
7796
|
+
minSdkMajor: 49
|
|
7797
|
+
},
|
|
7798
|
+
{
|
|
7799
|
+
packageName: "expo-firebase-analytics",
|
|
7800
|
+
rule: "expo-no-redundant-dependency",
|
|
7801
|
+
message: "\"expo-firebase-analytics\" was removed in SDK 48",
|
|
7802
|
+
help: FIREBASE_HELP,
|
|
7803
|
+
minSdkMajor: 48
|
|
7804
|
+
},
|
|
7805
|
+
{
|
|
7806
|
+
packageName: "expo-firebase-recaptcha",
|
|
7807
|
+
rule: "expo-no-redundant-dependency",
|
|
7808
|
+
message: "\"expo-firebase-recaptcha\" was removed in SDK 48",
|
|
7809
|
+
help: FIREBASE_HELP,
|
|
7810
|
+
minSdkMajor: 48
|
|
7811
|
+
},
|
|
7812
|
+
{
|
|
7813
|
+
packageName: "expo-firebase-core",
|
|
7814
|
+
rule: "expo-no-redundant-dependency",
|
|
7815
|
+
message: "\"expo-firebase-core\" was removed in SDK 48",
|
|
7816
|
+
help: FIREBASE_HELP,
|
|
7817
|
+
minSdkMajor: 48
|
|
7818
|
+
}
|
|
7819
|
+
];
|
|
7820
|
+
const checkExpoFlaggedDependencies = (context) => FLAGGED_DEPENDENCIES.filter((flaggedDependency) => {
|
|
7821
|
+
if (!context.directDependencyNames.has(flaggedDependency.packageName)) return false;
|
|
7822
|
+
if (flaggedDependency.minSdkMajor === void 0) return true;
|
|
7823
|
+
return isExpoSdkAtLeast(context.expoSdkMajor, flaggedDependency.minSdkMajor);
|
|
7824
|
+
}).map((flaggedDependency) => buildExpoDiagnostic({
|
|
7825
|
+
rule: flaggedDependency.rule,
|
|
7826
|
+
message: flaggedDependency.message,
|
|
7827
|
+
help: flaggedDependency.help
|
|
7828
|
+
}));
|
|
7829
|
+
const findLocalModuleNativeFiles = (rootDirectory) => {
|
|
7830
|
+
const modulesDirectory = path.join(rootDirectory, "modules");
|
|
7831
|
+
if (!isDirectory(modulesDirectory)) return [];
|
|
7832
|
+
const nativeFilePaths = [];
|
|
7833
|
+
for (const moduleEntry of readDirectoryEntries(modulesDirectory)) {
|
|
7834
|
+
if (!moduleEntry.isDirectory()) continue;
|
|
7835
|
+
const moduleDirectory = path.join(modulesDirectory, moduleEntry.name);
|
|
7836
|
+
const gradlePath = path.join(moduleDirectory, "android", "build.gradle");
|
|
7837
|
+
if (isFile(gradlePath)) nativeFilePaths.push(gradlePath);
|
|
7838
|
+
const iosDirectory = path.join(moduleDirectory, "ios");
|
|
7839
|
+
if (isDirectory(iosDirectory)) {
|
|
7840
|
+
for (const iosEntry of readDirectoryEntries(iosDirectory)) if (iosEntry.isFile() && iosEntry.name.endsWith(".podspec")) nativeFilePaths.push(path.join(iosDirectory, iosEntry.name));
|
|
7841
|
+
}
|
|
7842
|
+
}
|
|
7843
|
+
return nativeFilePaths;
|
|
7844
|
+
};
|
|
7845
|
+
const checkExpoGitignore = (context) => {
|
|
7846
|
+
const { rootDirectory } = context;
|
|
7847
|
+
const diagnostics = [];
|
|
7848
|
+
const expoStateDirectory = path.join(rootDirectory, ".expo");
|
|
7849
|
+
if (isDirectory(expoStateDirectory) && isPathGitIgnored(rootDirectory, expoStateDirectory) === false) diagnostics.push(buildExpoDiagnostic({
|
|
7850
|
+
rule: "expo-gitignore",
|
|
7851
|
+
message: "The `.expo` directory is not ignored by Git — it holds machine-specific device history and dev-server settings that should not be committed",
|
|
7852
|
+
help: "Add `.expo/` to your .gitignore"
|
|
7853
|
+
}));
|
|
7854
|
+
if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
|
|
7855
|
+
rule: "expo-gitignore",
|
|
7856
|
+
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",
|
|
7857
|
+
help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
|
|
7858
|
+
}));
|
|
7859
|
+
return diagnostics;
|
|
7860
|
+
};
|
|
7861
|
+
const LOCKFILE_NAMES = [
|
|
7862
|
+
"pnpm-lock.yaml",
|
|
7863
|
+
"yarn.lock",
|
|
7864
|
+
"package-lock.json",
|
|
7865
|
+
"bun.lockb",
|
|
7866
|
+
"bun.lock"
|
|
7867
|
+
];
|
|
7868
|
+
const checkExpoLockfile = (context) => {
|
|
7869
|
+
const workspaceRoot = isMonorepoRoot(context.rootDirectory) ? context.rootDirectory : findMonorepoRoot(context.rootDirectory) ?? context.rootDirectory;
|
|
7870
|
+
const presentLockfiles = LOCKFILE_NAMES.filter((lockfileName) => isFile(path.join(workspaceRoot, lockfileName)));
|
|
7871
|
+
if (presentLockfiles.length === 0) return [buildExpoDiagnostic({
|
|
7872
|
+
rule: "expo-lockfile",
|
|
7873
|
+
message: "No lock file detected at the project root — installs are not reproducible, and EAS Build cannot infer your package manager",
|
|
7874
|
+
help: "Install dependencies with your package manager to generate a lock file, then commit it"
|
|
7875
|
+
})];
|
|
7876
|
+
if (presentLockfiles.length > 1) return [buildExpoDiagnostic({
|
|
7877
|
+
rule: "expo-lockfile",
|
|
7878
|
+
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`,
|
|
7879
|
+
help: "Delete the lock files for the package managers you are not using and keep only one"
|
|
7880
|
+
})];
|
|
7881
|
+
return [];
|
|
7882
|
+
};
|
|
7883
|
+
const METRO_CONFIG_FILE_NAMES = [
|
|
7884
|
+
"metro.config.js",
|
|
7885
|
+
"metro.config.cjs",
|
|
7886
|
+
"metro.config.mjs",
|
|
7887
|
+
"metro.config.ts"
|
|
7888
|
+
];
|
|
7889
|
+
const EXPO_METRO_CONFIG_EXTEND_SIGNALS = [
|
|
7890
|
+
"expo/metro-config",
|
|
7891
|
+
"@sentry/react-native/metro",
|
|
7892
|
+
"getSentryExpoConfig"
|
|
7893
|
+
];
|
|
7894
|
+
const checkExpoMetroConfig = (context) => {
|
|
7895
|
+
const metroConfigPath = METRO_CONFIG_FILE_NAMES.map((fileName) => path.join(context.rootDirectory, fileName)).find((candidatePath) => isFile(candidatePath));
|
|
7896
|
+
if (metroConfigPath === void 0) return [];
|
|
7897
|
+
let contents;
|
|
7898
|
+
try {
|
|
7899
|
+
contents = fs.readFileSync(metroConfigPath, "utf-8");
|
|
7900
|
+
} catch {
|
|
7901
|
+
return [];
|
|
7902
|
+
}
|
|
7903
|
+
if (EXPO_METRO_CONFIG_EXTEND_SIGNALS.some((signal) => contents.includes(signal))) return [];
|
|
7904
|
+
return [buildExpoDiagnostic({
|
|
7905
|
+
rule: "expo-metro-config",
|
|
7906
|
+
filePath: path.basename(metroConfigPath),
|
|
7907
|
+
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",
|
|
7908
|
+
help: "Update your metro config to extend `expo/metro-config`. See https://docs.expo.dev/guides/customizing-metro/"
|
|
7909
|
+
})];
|
|
7910
|
+
};
|
|
7911
|
+
const CONFLICTING_SCRIPT_NAMES = ["expo", "react-native"];
|
|
7912
|
+
const checkExpoPackageJsonConflicts = (context) => {
|
|
7913
|
+
const { packageJson } = context;
|
|
7914
|
+
const diagnostics = [];
|
|
7915
|
+
const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
|
|
7916
|
+
if (conflictingScriptNames.length > 0) {
|
|
7917
|
+
const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
|
|
7918
|
+
const shadowsExpoCli = conflictingScriptNames.includes("expo");
|
|
7919
|
+
diagnostics.push(buildExpoDiagnostic({
|
|
7920
|
+
rule: "expo-package-json-conflict",
|
|
7921
|
+
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" : ""}`,
|
|
7922
|
+
help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
|
|
7923
|
+
}));
|
|
7924
|
+
}
|
|
7925
|
+
const packageName = packageJson.name;
|
|
7926
|
+
if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
|
|
7927
|
+
rule: "expo-package-json-conflict",
|
|
7928
|
+
message: `package.json "name" is "${packageName}", which collides with a dependency of the same name`,
|
|
7929
|
+
help: "Rename your package so it no longer matches one of its dependencies"
|
|
7930
|
+
}));
|
|
7931
|
+
return diagnostics;
|
|
7932
|
+
};
|
|
7933
|
+
const EXPO_ROUTER_REACT_NAVIGATION_MIN_SDK_MAJOR = 56;
|
|
7934
|
+
const EXPO_ROUTER_REACT_NAVIGATION_MAX_SDK_MAJOR_EXCLUSIVE = 57;
|
|
7935
|
+
const checkExpoRouterReactNavigation = (context) => {
|
|
7936
|
+
const { expoSdkMajor } = context;
|
|
7937
|
+
if (!isExpoSdkAtLeast(expoSdkMajor, EXPO_ROUTER_REACT_NAVIGATION_MIN_SDK_MAJOR)) return [];
|
|
7938
|
+
if (expoSdkMajor !== null && expoSdkMajor >= EXPO_ROUTER_REACT_NAVIGATION_MAX_SDK_MAJOR_EXCLUSIVE) return [];
|
|
7939
|
+
if (!context.directDependencyNames.has("expo-router")) return [];
|
|
7940
|
+
const reactNavigationNames = [...context.directDependencyNames].filter((packageName) => packageName.startsWith("@react-navigation/")).sort();
|
|
7941
|
+
if (reactNavigationNames.length === 0) return [];
|
|
7942
|
+
return [buildExpoDiagnostic({
|
|
7943
|
+
rule: "expo-router-no-react-navigation",
|
|
7944
|
+
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"}`,
|
|
7945
|
+
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/"
|
|
7946
|
+
})];
|
|
7947
|
+
};
|
|
7948
|
+
const VECTOR_ICONS_MIN_SDK_MAJOR = 56;
|
|
7949
|
+
const SCOPED_VECTOR_ICONS_NAMESPACE = "@react-native-vector-icons/";
|
|
7950
|
+
const CONFLICTING_VECTOR_ICONS_PACKAGES = ["@expo/vector-icons", "react-native-vector-icons"];
|
|
7951
|
+
const checkExpoVectorIcons = (context) => {
|
|
7952
|
+
if (!isExpoSdkAtLeast(context.expoSdkMajor, VECTOR_ICONS_MIN_SDK_MAJOR)) return [];
|
|
7953
|
+
const hasScopedPackage = [...context.directDependencyNames].some((packageName) => packageName.startsWith(SCOPED_VECTOR_ICONS_NAMESPACE));
|
|
7954
|
+
const hasConflictingPackage = CONFLICTING_VECTOR_ICONS_PACKAGES.some((packageName) => context.directDependencyNames.has(packageName));
|
|
7955
|
+
if (!hasScopedPackage || !hasConflictingPackage) return [];
|
|
7956
|
+
return [buildExpoDiagnostic({
|
|
7957
|
+
rule: "expo-vector-icons-conflict",
|
|
7958
|
+
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",
|
|
7959
|
+
help: "Migrate to the scoped packages by running `npx @react-native-vector-icons/codemod`, then remove the conflicting package"
|
|
7960
|
+
})];
|
|
7961
|
+
};
|
|
7962
|
+
const checkExpoProject = (rootDirectory, project) => {
|
|
7963
|
+
if (project.expoVersion === null) return [];
|
|
7964
|
+
const context = buildExpoCheckContext(rootDirectory, project.expoVersion);
|
|
7965
|
+
return [
|
|
7966
|
+
...checkExpoFlaggedDependencies(context),
|
|
7967
|
+
...checkExpoDependencyOverrides(context),
|
|
7968
|
+
...checkExpoRouterReactNavigation(context),
|
|
7969
|
+
...checkExpoVectorIcons(context),
|
|
7970
|
+
...checkExpoPackageJsonConflicts(context),
|
|
7971
|
+
...checkExpoLockfile(context),
|
|
7972
|
+
...checkExpoGitignore(context),
|
|
7973
|
+
...checkExpoEnvLocalFiles(context),
|
|
7974
|
+
...checkExpoMetroConfig(context)
|
|
7975
|
+
];
|
|
7976
|
+
};
|
|
7565
7977
|
const PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
|
|
7566
7978
|
const PNPM_LOCKFILE = "pnpm-lock.yaml";
|
|
7567
7979
|
const PACKAGE_JSON_FILE = "package.json";
|
|
@@ -8839,6 +9251,7 @@ const buildCapabilities = (project) => {
|
|
|
8839
9251
|
const capabilities = /* @__PURE__ */ new Set();
|
|
8840
9252
|
capabilities.add(project.framework);
|
|
8841
9253
|
if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
|
|
9254
|
+
if (project.expoVersion !== null) capabilities.add("expo");
|
|
8842
9255
|
const reactMajor = project.reactMajorVersion;
|
|
8843
9256
|
if (reactMajor !== null) {
|
|
8844
9257
|
const cappedReactMajor = Math.min(reactMajor, 30);
|
|
@@ -9116,6 +9529,44 @@ const dedupeDiagnostics = (diagnostics) => {
|
|
|
9116
9529
|
}
|
|
9117
9530
|
return uniqueDiagnostics;
|
|
9118
9531
|
};
|
|
9532
|
+
/**
|
|
9533
|
+
* Runs `task` over `items` with at most `concurrency` tasks in flight at
|
|
9534
|
+
* once, returning results in input order. A pool of workers each pulls the
|
|
9535
|
+
* next not-yet-started index until the list drains — so a worker that
|
|
9536
|
+
* finishes a fast task immediately picks up the next one (greedy load
|
|
9537
|
+
* balancing), which matters when tasks have uneven durations (oxlint
|
|
9538
|
+
* batches do).
|
|
9539
|
+
*
|
|
9540
|
+
* Failure semantics mirror a bounded `Promise.all`: on the first rejection
|
|
9541
|
+
* no further tasks are started, the already-in-flight tasks are awaited to
|
|
9542
|
+
* settle (so no subprocess is orphaned mid-write), and the returned promise
|
|
9543
|
+
* rejects with that first error. This keeps the caller's fail-fast retry
|
|
9544
|
+
* path (e.g. oxlint's retry-without-extends) from spawning a second wave on
|
|
9545
|
+
* top of a still-running first one.
|
|
9546
|
+
*/
|
|
9547
|
+
const mapWithConcurrency = async (items, concurrency, task) => {
|
|
9548
|
+
const results = new Array(items.length);
|
|
9549
|
+
if (items.length === 0) return results;
|
|
9550
|
+
const workerCount = Math.min(Math.max(1, Math.floor(concurrency) || 1), items.length);
|
|
9551
|
+
let nextIndex = 0;
|
|
9552
|
+
const errors = [];
|
|
9553
|
+
const runWorker = async () => {
|
|
9554
|
+
while (errors.length === 0) {
|
|
9555
|
+
const index = nextIndex;
|
|
9556
|
+
nextIndex += 1;
|
|
9557
|
+
if (index >= items.length) return;
|
|
9558
|
+
try {
|
|
9559
|
+
results[index] = await task(items[index], index);
|
|
9560
|
+
} catch (error) {
|
|
9561
|
+
errors.push(error);
|
|
9562
|
+
return;
|
|
9563
|
+
}
|
|
9564
|
+
}
|
|
9565
|
+
};
|
|
9566
|
+
await Promise.all(Array.from({ length: workerCount }, runWorker));
|
|
9567
|
+
if (errors.length > 0) throw errors[0];
|
|
9568
|
+
return results;
|
|
9569
|
+
};
|
|
9119
9570
|
const getPublicEnvPrefix = (framework) => {
|
|
9120
9571
|
switch (framework) {
|
|
9121
9572
|
case "nextjs": return "NEXT_PUBLIC_*";
|
|
@@ -9798,6 +10249,7 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
|
|
|
9798
10249
|
*/
|
|
9799
10250
|
const spawnLintBatches = async (input) => {
|
|
9800
10251
|
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes } = input;
|
|
10252
|
+
const concurrency = resolveScanConcurrency(input.concurrency ?? 1);
|
|
9801
10253
|
const totalFileCount = fileBatches.reduce((sum, batch) => sum + batch.length, 0);
|
|
9802
10254
|
const allDiagnostics = [];
|
|
9803
10255
|
const droppedFiles = [];
|
|
@@ -9817,23 +10269,31 @@ const spawnLintBatches = async (input) => {
|
|
|
9817
10269
|
return [...await spawnLintBatch(batch.slice(0, splitIndex)), ...await spawnLintBatch(batch.slice(splitIndex))];
|
|
9818
10270
|
}
|
|
9819
10271
|
};
|
|
10272
|
+
let startedFileCount = 0;
|
|
9820
10273
|
let scannedFileCount = 0;
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
const
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
10274
|
+
let displayedFileCount = 0;
|
|
10275
|
+
const progressTimer = onFileProgress && totalFileCount > 1 ? setInterval(() => {
|
|
10276
|
+
const ceiling = Math.min(startedFileCount, totalFileCount - 1);
|
|
10277
|
+
if (displayedFileCount < ceiling) {
|
|
10278
|
+
displayedFileCount += 1;
|
|
10279
|
+
onFileProgress(displayedFileCount, totalFileCount);
|
|
10280
|
+
}
|
|
10281
|
+
}, 50) : null;
|
|
10282
|
+
progressTimer?.unref?.();
|
|
10283
|
+
try {
|
|
10284
|
+
const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
|
|
10285
|
+
startedFileCount += batch.length;
|
|
9830
10286
|
const batchDiagnostics = await spawnLintBatch(batch);
|
|
9831
|
-
allDiagnostics.push(...batchDiagnostics);
|
|
9832
10287
|
scannedFileCount += batch.length;
|
|
9833
|
-
onFileProgress
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
10288
|
+
if (onFileProgress) {
|
|
10289
|
+
displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
|
|
10290
|
+
onFileProgress(displayedFileCount, totalFileCount);
|
|
10291
|
+
}
|
|
10292
|
+
return batchDiagnostics;
|
|
10293
|
+
});
|
|
10294
|
+
for (const batchDiagnostics of batchResults) allDiagnostics.push(...batchDiagnostics);
|
|
10295
|
+
} finally {
|
|
10296
|
+
if (progressTimer !== null) clearInterval(progressTimer);
|
|
9837
10297
|
}
|
|
9838
10298
|
if (droppedFiles.length > 0 && onPartialFailure) {
|
|
9839
10299
|
const previewFiles = droppedFiles.slice(0, 3).join(", ");
|
|
@@ -9960,7 +10420,8 @@ const runOxlint = async (options) => {
|
|
|
9960
10420
|
onPartialFailure,
|
|
9961
10421
|
onFileProgress: options.onFileProgress,
|
|
9962
10422
|
spawnTimeoutMs,
|
|
9963
|
-
outputMaxBytes
|
|
10423
|
+
outputMaxBytes,
|
|
10424
|
+
concurrency: options.concurrency
|
|
9964
10425
|
});
|
|
9965
10426
|
writeOxlintConfig(configPath, buildConfig(extendsPaths));
|
|
9966
10427
|
try {
|
|
@@ -10028,6 +10489,7 @@ var Linter = class Linter extends Context.Service()("react-doctor/Linter") {
|
|
|
10028
10489
|
const partialFailures = yield* LintPartialFailures;
|
|
10029
10490
|
const spawnTimeoutMs = yield* OxlintSpawnTimeoutMs;
|
|
10030
10491
|
const outputMaxBytes = yield* OxlintOutputMaxBytes;
|
|
10492
|
+
const concurrency = yield* OxlintConcurrency;
|
|
10031
10493
|
const collectedFailures = [];
|
|
10032
10494
|
const diagnostics = yield* Effect.tryPromise({
|
|
10033
10495
|
try: () => runOxlint({
|
|
@@ -10046,7 +10508,8 @@ var Linter = class Linter extends Context.Service()("react-doctor/Linter") {
|
|
|
10046
10508
|
},
|
|
10047
10509
|
onFileProgress: input.onFileProgress,
|
|
10048
10510
|
spawnTimeoutMs,
|
|
10049
|
-
outputMaxBytes
|
|
10511
|
+
outputMaxBytes,
|
|
10512
|
+
concurrency
|
|
10050
10513
|
}),
|
|
10051
10514
|
catch: ensureReactDoctorError
|
|
10052
10515
|
});
|
|
@@ -10379,7 +10842,11 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
10379
10842
|
showWarnings
|
|
10380
10843
|
});
|
|
10381
10844
|
const applyPerElementPipeline = (rawStream) => rawStream.pipe(Stream.filterMap(filterMapNullable(transform.apply)), Stream.tap((diagnostic) => reporterService.emit(diagnostic)));
|
|
10382
|
-
const environmentDiagnostics = isDiffMode ? [] : [
|
|
10845
|
+
const environmentDiagnostics = isDiffMode ? [] : [
|
|
10846
|
+
...checkReducedMotion(scanDirectory),
|
|
10847
|
+
...checkPnpmHardening(scanDirectory),
|
|
10848
|
+
...checkExpoProject(scanDirectory, project)
|
|
10849
|
+
];
|
|
10383
10850
|
const envCollected = yield* Stream.runCollect(applyPerElementPipeline(Stream.fromIterable(environmentDiagnostics)));
|
|
10384
10851
|
const lintFailure = yield* Ref.make({
|
|
10385
10852
|
didFail: false,
|
|
@@ -10391,6 +10858,8 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
10391
10858
|
didFail: false,
|
|
10392
10859
|
reason: null
|
|
10393
10860
|
});
|
|
10861
|
+
const scanConcurrency = yield* OxlintConcurrency;
|
|
10862
|
+
const workerCountSuffix = scanConcurrency > 1 ? ` · ${scanConcurrency} workers` : "";
|
|
10394
10863
|
const scanProgress = yield* progressService.start("Scanning...");
|
|
10395
10864
|
const scanStartTime = Date.now();
|
|
10396
10865
|
let lastReportedTotalFileCount = 0;
|
|
@@ -10407,7 +10876,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
10407
10876
|
configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
|
|
10408
10877
|
onFileProgress: (scannedFileCount, totalFileCount) => {
|
|
10409
10878
|
lastReportedTotalFileCount = totalFileCount;
|
|
10410
|
-
Effect.runSync(scanProgress.update(`Scanning files (${scannedFileCount}/${totalFileCount})...`));
|
|
10879
|
+
Effect.runSync(scanProgress.update(`Scanning files (${scannedFileCount}/${totalFileCount})${workerCountSuffix}...`));
|
|
10411
10880
|
}
|
|
10412
10881
|
}).pipe(Stream.catchTag("ReactDoctorError", (error) => Stream.unwrap(Effect.gen(function* () {
|
|
10413
10882
|
yield* Ref.set(lintFailure, {
|
|
@@ -10439,7 +10908,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
10439
10908
|
const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
10440
10909
|
if (!lintFailureState.didFail) if (deadCodeFailureState.didFail) yield* scanProgress.fail(DEAD_CODE_FAIL_TEXT);
|
|
10441
10910
|
else if (input.suppressScanSummary) yield* scanProgress.stop();
|
|
10442
|
-
else yield* scanProgress.succeed(`Scanned ${totalFileCount} ${totalFileCount === 1 ? "file" : "files"} in ${scanElapsedSeconds}s`);
|
|
10911
|
+
else yield* scanProgress.succeed(`Scanned ${totalFileCount} ${totalFileCount === 1 ? "file" : "files"} in ${scanElapsedSeconds}s${workerCountSuffix}`);
|
|
10443
10912
|
yield* reporterService.finalize;
|
|
10444
10913
|
const finalDiagnostics = [
|
|
10445
10914
|
...envCollected,
|
|
@@ -14048,7 +14517,8 @@ const buildRuntimeLayers = (input) => {
|
|
|
14048
14517
|
resolvedDirectory: input.directory,
|
|
14049
14518
|
configSourceDirectory: input.configSourceDirectory
|
|
14050
14519
|
}) : Config.layerNode;
|
|
14051
|
-
|
|
14520
|
+
const baseLayers = Layer.mergeAll(Project.layerNode, configLayer, Files.layerNode, Git.layerNode, linterLayer, LintPartialFailures.layerLive, deadCodeLayer, progressLayer, Reporter.layerNoop, scoreLayer);
|
|
14521
|
+
return input.oxlintConcurrency === void 0 ? baseLayers : Layer.mergeAll(baseLayers, Layer.succeed(OxlintConcurrency, input.oxlintConcurrency));
|
|
14052
14522
|
};
|
|
14053
14523
|
//#endregion
|
|
14054
14524
|
//#region src/cli/utils/noop-console.ts
|
|
@@ -14840,7 +15310,7 @@ const resolveOxlintNodeEffect = (isLintEnabled, isQuiet) => Effect.gen(function*
|
|
|
14840
15310
|
const resolveOxlintNode = (isLintEnabled, isQuiet) => Effect.runPromise(resolveOxlintNodeEffect(isLintEnabled, isQuiet).pipe(Effect.provide(NodeResolver.layerNode)));
|
|
14841
15311
|
//#endregion
|
|
14842
15312
|
//#region src/cli/utils/version.ts
|
|
14843
|
-
const VERSION = "0.2.14-dev.
|
|
15313
|
+
const VERSION = "0.2.14-dev.f1913f2";
|
|
14844
15314
|
//#endregion
|
|
14845
15315
|
//#region src/inspect.ts
|
|
14846
15316
|
const silentConsole = makeNoopConsole();
|
|
@@ -14870,7 +15340,8 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
14870
15340
|
adoptExistingLintConfig: userConfig?.adoptExistingLintConfig ?? true,
|
|
14871
15341
|
ignoredTags: buildIgnoredTags(userConfig),
|
|
14872
15342
|
outputSurface: inputOptions.outputSurface ?? "cli",
|
|
14873
|
-
suppressRendering: inputOptions.suppressRendering ?? false
|
|
15343
|
+
suppressRendering: inputOptions.suppressRendering ?? false,
|
|
15344
|
+
concurrency: inputOptions.concurrency
|
|
14874
15345
|
});
|
|
14875
15346
|
const inspect = async (directory, inputOptions = {}) => {
|
|
14876
15347
|
const startTime = performance.now();
|
|
@@ -14910,7 +15381,8 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
14910
15381
|
shouldSkipLint: !options.lint || lintBindingMissing,
|
|
14911
15382
|
shouldRunDeadCode: options.deadCode,
|
|
14912
15383
|
shouldComputeScore: !options.noScore,
|
|
14913
|
-
shouldShowProgressSpinners
|
|
15384
|
+
shouldShowProgressSpinners,
|
|
15385
|
+
oxlintConcurrency: options.concurrency
|
|
14914
15386
|
});
|
|
14915
15387
|
const program = runInspect({
|
|
14916
15388
|
directory,
|
|
@@ -16721,6 +17193,34 @@ const printAgentInstallHint = (writeLine = defaultWriteLine) => {
|
|
|
16721
17193
|
for (const line of AGENT_INSTALL_HINT_LINES) writeLine(line);
|
|
16722
17194
|
};
|
|
16723
17195
|
//#endregion
|
|
17196
|
+
//#region src/cli/utils/resolve-parallel-flag.ts
|
|
17197
|
+
/**
|
|
17198
|
+
* Translates the `--experimental-parallel [workers]` flag into a concrete
|
|
17199
|
+
* worker count for `InspectOptions.concurrency`:
|
|
17200
|
+
*
|
|
17201
|
+
* - flag absent (`undefined`) → `undefined` (defer to the ambient
|
|
17202
|
+
* default: serial unless `REACT_DOCTOR_PARALLEL` is set)
|
|
17203
|
+
* - bare flag / `auto` → auto-detect CPU cores
|
|
17204
|
+
* - `--experimental-parallel <n>` → `n` workers (clamped)
|
|
17205
|
+
* - `false` / `off` / `0` → serial (an explicit opt-out, so
|
|
17206
|
+
* it overrides an env-enabled default rather than deferring to it)
|
|
17207
|
+
* - an unparseable value → auto-detect cores
|
|
17208
|
+
*
|
|
17209
|
+
* Commander yields `true` for a bare flag, the raw string for an explicit
|
|
17210
|
+
* value, and `undefined` when the flag is omitted.
|
|
17211
|
+
*/
|
|
17212
|
+
const resolveParallelFlag = (parallel) => {
|
|
17213
|
+
if (parallel === void 0) return void 0;
|
|
17214
|
+
if (parallel === true) return resolveScanConcurrency("auto");
|
|
17215
|
+
if (parallel === false) return 1;
|
|
17216
|
+
const normalized = parallel.trim().toLowerCase();
|
|
17217
|
+
if (normalized === "" || normalized === "auto" || normalized === "true") return resolveScanConcurrency("auto");
|
|
17218
|
+
if (normalized === "false" || normalized === "off" || normalized === "0") return 1;
|
|
17219
|
+
const parsed = Number.parseInt(normalized, 10);
|
|
17220
|
+
if (!Number.isInteger(parsed) || parsed <= 0) return resolveScanConcurrency("auto");
|
|
17221
|
+
return resolveScanConcurrency(parsed);
|
|
17222
|
+
};
|
|
17223
|
+
//#endregion
|
|
16724
17224
|
//#region src/cli/utils/resolve-cli-inspect-options.ts
|
|
16725
17225
|
/**
|
|
16726
17226
|
* Translates CLI flags into the `InspectOptions` contract `inspect()`
|
|
@@ -16746,7 +17246,8 @@ const resolveCliInspectOptions = (flags, userConfig) => {
|
|
|
16746
17246
|
noScore: flags.score === false || (userConfig?.noScore ?? false),
|
|
16747
17247
|
isCi: isCiEnvironment(),
|
|
16748
17248
|
silent: Boolean(flags.json),
|
|
16749
|
-
outputSurface: flags.prComment ? "prComment" : "cli"
|
|
17249
|
+
outputSurface: flags.prComment ? "prComment" : "cli",
|
|
17250
|
+
concurrency: resolveParallelFlag(flags.experimentalParallel)
|
|
16750
17251
|
};
|
|
16751
17252
|
};
|
|
16752
17253
|
//#endregion
|
|
@@ -17296,7 +17797,7 @@ const ROOT_FLAG_SPEC = {
|
|
|
17296
17797
|
"--project",
|
|
17297
17798
|
"--why"
|
|
17298
17799
|
]),
|
|
17299
|
-
longOptionsWithOptionalValues: new Set(["--diff"]),
|
|
17800
|
+
longOptionsWithOptionalValues: new Set(["--diff", "--experimental-parallel"]),
|
|
17300
17801
|
shortOptionsWithoutValues: new Set([
|
|
17301
17802
|
"-h",
|
|
17302
17803
|
"-v",
|
|
@@ -17388,7 +17889,7 @@ const stripUnknownCliFlags = (argv) => {
|
|
|
17388
17889
|
process.on("SIGINT", exitGracefully);
|
|
17389
17890
|
process.on("SIGTERM", exitGracefully);
|
|
17390
17891
|
unrefStdin();
|
|
17391
|
-
const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--full", "force a full scan (overrides any `diff` value in config or `--diff`)").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--diff [base]", "scan only files changed vs base branch (pass `false` to disable; overridden by --full)").option("--changed-files-from <file>", "internal: scan source files listed in a newline-delimited changed-files file").option("--no-score", "skip the score API and the share URL").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--fail-on <level>", "exit with error code on diagnostics: error, warning, none (default: none)").option("--annotations", "output diagnostics as GitHub Actions annotations").option("--pr-comment", "tune CLI output for sticky PR comments (drops weak-signal rule families like `design` from the printed list and the fail-on gate; configure via config.surfaces)").option("--explain <file:line>", "diagnose why a rule fired or why a suppression didn't apply at a specific location").option("--why <file:line>", "alias for --explain").option("--respect-inline-disables", "respect inline `// eslint-disable*` / `// oxlint-disable*` comments (default)").option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (errors always show)").option("--no-warnings", "hide warning-severity diagnostics (default)").addHelpText("after", `
|
|
17892
|
+
const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--full", "force a full scan (overrides any `diff` value in config or `--diff`)").option("--experimental-parallel [workers]", "experimental: lint with N parallel workers (default: auto-detect CPU cores) — speeds up large repos").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--diff [base]", "scan only files changed vs base branch (pass `false` to disable; overridden by --full)").option("--changed-files-from <file>", "internal: scan source files listed in a newline-delimited changed-files file").option("--no-score", "skip the score API and the share URL").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--fail-on <level>", "exit with error code on diagnostics: error, warning, none (default: none)").option("--annotations", "output diagnostics as GitHub Actions annotations").option("--pr-comment", "tune CLI output for sticky PR comments (drops weak-signal rule families like `design` from the printed list and the fail-on gate; configure via config.surfaces)").option("--explain <file:line>", "diagnose why a rule fired or why a suppression didn't apply at a specific location").option("--why <file:line>", "alias for --explain").option("--respect-inline-disables", "respect inline `// eslint-disable*` / `// oxlint-disable*` comments (default)").option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (errors always show)").option("--no-warnings", "hide warning-severity diagnostics (default)").addHelpText("after", `
|
|
17392
17893
|
${highlighter.dim("Configuration:")}
|
|
17393
17894
|
Place a ${highlighter.info("react-doctor.config.json")} (or ${highlighter.info("\"reactDoctor\"")} key in your package.json) in the project root.
|
|
17394
17895
|
CLI flags always override config values. See the README for the full schema.
|