react-doctor 0.4.2-dev.547e1e4 → 0.4.2-dev.5b06a86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +493 -116
- package/dist/index.js +30 -29
- package/dist/lsp.js +74 -77
- package/package.json +4 -4
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]="
|
|
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]="59fe9fce-f831-56a0-b6b2-b014bd09d533")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
5
5
|
import * as path$1 from "node:path";
|
|
@@ -34,7 +34,7 @@ import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
|
34
34
|
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
35
35
|
import * as ts from "typescript";
|
|
36
36
|
import { gzipSync } from "node:zlib";
|
|
37
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
37
|
+
import crypto, { createHash, randomUUID } from "node:crypto";
|
|
38
38
|
import * as Exit from "effect/Exit";
|
|
39
39
|
import * as Sentry from "@sentry/node";
|
|
40
40
|
import { performance } from "node:perf_hooks";
|
|
@@ -5151,8 +5151,8 @@ const isFile = (filePath) => {
|
|
|
5151
5151
|
return false;
|
|
5152
5152
|
}
|
|
5153
5153
|
};
|
|
5154
|
-
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx
|
|
5155
|
-
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.js$/i;
|
|
5154
|
+
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
|
|
5155
|
+
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
5156
5156
|
const MINIFIED_SNIFF_BYTES = 65536;
|
|
5157
5157
|
const GIT_LS_FILES_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
5158
5158
|
const IGNORED_DIRECTORIES = new Set([
|
|
@@ -6392,6 +6392,29 @@ const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
|
|
|
6392
6392
|
"oxlint.json",
|
|
6393
6393
|
".oxlintrc.json"
|
|
6394
6394
|
];
|
|
6395
|
+
const CONFIG_FINGERPRINT_FILENAMES = [
|
|
6396
|
+
"doctor.config.ts",
|
|
6397
|
+
"doctor.config.mts",
|
|
6398
|
+
"doctor.config.cts",
|
|
6399
|
+
"doctor.config.js",
|
|
6400
|
+
"doctor.config.mjs",
|
|
6401
|
+
"doctor.config.cjs",
|
|
6402
|
+
"doctor.config.json",
|
|
6403
|
+
"doctor.config.jsonc",
|
|
6404
|
+
"react-doctor.config.json",
|
|
6405
|
+
"package.json",
|
|
6406
|
+
"pnpm-workspace.yaml",
|
|
6407
|
+
"tsconfig.json",
|
|
6408
|
+
"tsconfig.base.json",
|
|
6409
|
+
".oxlintrc.json",
|
|
6410
|
+
".eslintrc.json",
|
|
6411
|
+
"pnpm-lock.yaml",
|
|
6412
|
+
"package-lock.json",
|
|
6413
|
+
"yarn.lock",
|
|
6414
|
+
"bun.lock",
|
|
6415
|
+
"bun.lockb",
|
|
6416
|
+
".gitignore"
|
|
6417
|
+
];
|
|
6395
6418
|
const CANONICAL_GITHUB_URL = "https://github.com/millionco/react-doctor";
|
|
6396
6419
|
const CANONICAL_DISCORD_URL = "https://react.doctor/discord";
|
|
6397
6420
|
const SKILL_NAME = "react-doctor";
|
|
@@ -7920,51 +7943,51 @@ const FLAGGED_DEPENDENCIES = [
|
|
|
7920
7943
|
{
|
|
7921
7944
|
packageName: "expo-modules-autolinking",
|
|
7922
7945
|
rule: "expo-no-redundant-dependency",
|
|
7923
|
-
message: "\"expo-modules-autolinking\" should not be a direct dependency
|
|
7946
|
+
message: "\"expo-modules-autolinking\" should not be a direct dependency. Expo pins the compatible version through the SDK, and a direct entry can drift to a version that breaks prebuild, Metro, or native builds",
|
|
7924
7947
|
help: "Remove `expo-modules-autolinking` from your package.json"
|
|
7925
7948
|
},
|
|
7926
7949
|
{
|
|
7927
7950
|
packageName: "expo-dev-launcher",
|
|
7928
7951
|
rule: "expo-no-redundant-dependency",
|
|
7929
|
-
message: "\"expo-dev-launcher\" should not be a direct dependency
|
|
7952
|
+
message: "\"expo-dev-launcher\" should not be a direct dependency. `expo-dev-client` pins the compatible launcher, and a direct entry can drift to a version that breaks native builds",
|
|
7930
7953
|
help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
|
|
7931
7954
|
},
|
|
7932
7955
|
{
|
|
7933
7956
|
packageName: "expo-dev-menu",
|
|
7934
7957
|
rule: "expo-no-redundant-dependency",
|
|
7935
|
-
message: "\"expo-dev-menu\" should not be a direct dependency
|
|
7958
|
+
message: "\"expo-dev-menu\" should not be a direct dependency. `expo-dev-client` pins the compatible dev menu, and a direct entry can drift to a version that breaks native builds",
|
|
7936
7959
|
help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
|
|
7937
7960
|
},
|
|
7938
7961
|
{
|
|
7939
7962
|
packageName: "expo-modules-core",
|
|
7940
7963
|
rule: "expo-no-redundant-dependency",
|
|
7941
|
-
message: "\"expo-modules-core\" should not be a direct dependency
|
|
7964
|
+
message: "\"expo-modules-core\" should not be a direct dependency. Expo pins the compatible native core, and a direct entry can drift to a version that breaks prebuild or native builds",
|
|
7942
7965
|
help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
|
|
7943
7966
|
},
|
|
7944
7967
|
{
|
|
7945
7968
|
packageName: "@expo/metro-config",
|
|
7946
7969
|
rule: "expo-no-redundant-dependency",
|
|
7947
|
-
message: "\"@expo/metro-config\" should not be a direct dependency
|
|
7970
|
+
message: "\"@expo/metro-config\" should not be a direct dependency. Expo pins the compatible Metro config, and a direct entry can drift to a version that breaks bundling",
|
|
7948
7971
|
help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
|
|
7949
7972
|
},
|
|
7950
7973
|
{
|
|
7951
7974
|
packageName: "@types/react-native",
|
|
7952
7975
|
rule: "expo-no-redundant-dependency",
|
|
7953
|
-
message: "\"@types/react-native\" should not be installed
|
|
7976
|
+
message: "\"@types/react-native\" should not be installed. React Native ships its own types since SDK 48, so the extra package can introduce duplicate or stale type definitions",
|
|
7954
7977
|
help: "Remove `@types/react-native` from your package.json",
|
|
7955
7978
|
minSdkMajor: 48
|
|
7956
7979
|
},
|
|
7957
7980
|
{
|
|
7958
7981
|
packageName: "@expo/config-plugins",
|
|
7959
7982
|
rule: "expo-no-redundant-dependency",
|
|
7960
|
-
message: "\"@expo/config-plugins\" should not be a direct dependency
|
|
7983
|
+
message: "\"@expo/config-plugins\" should not be a direct dependency. Expo pins the compatible config-plugin API, and a direct entry can drift to a version that breaks prebuild",
|
|
7961
7984
|
help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
|
|
7962
7985
|
minSdkMajor: 48
|
|
7963
7986
|
},
|
|
7964
7987
|
{
|
|
7965
7988
|
packageName: "@expo/prebuild-config",
|
|
7966
7989
|
rule: "expo-no-redundant-dependency",
|
|
7967
|
-
message: "\"@expo/prebuild-config\" should not be a direct dependency
|
|
7990
|
+
message: "\"@expo/prebuild-config\" should not be a direct dependency. Expo pins the compatible prebuild config, and a direct entry can drift to a version that breaks prebuild",
|
|
7968
7991
|
help: "Remove `@expo/prebuild-config` from your package.json",
|
|
7969
7992
|
minSdkMajor: 53
|
|
7970
7993
|
},
|
|
@@ -7978,28 +8001,28 @@ const FLAGGED_DEPENDENCIES = [
|
|
|
7978
8001
|
{
|
|
7979
8002
|
packageName: "expo-app-loading",
|
|
7980
8003
|
rule: "expo-no-redundant-dependency",
|
|
7981
|
-
message: "\"expo-app-loading\" was removed in SDK 49",
|
|
8004
|
+
message: "\"expo-app-loading\" was removed in SDK 49, so keeping it can leave imports unresolved after upgrading Expo",
|
|
7982
8005
|
help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
|
|
7983
8006
|
minSdkMajor: 49
|
|
7984
8007
|
},
|
|
7985
8008
|
{
|
|
7986
8009
|
packageName: "expo-firebase-analytics",
|
|
7987
8010
|
rule: "expo-no-redundant-dependency",
|
|
7988
|
-
message: "\"expo-firebase-analytics\" was removed in SDK 48",
|
|
8011
|
+
message: "\"expo-firebase-analytics\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
7989
8012
|
help: FIREBASE_HELP,
|
|
7990
8013
|
minSdkMajor: 48
|
|
7991
8014
|
},
|
|
7992
8015
|
{
|
|
7993
8016
|
packageName: "expo-firebase-recaptcha",
|
|
7994
8017
|
rule: "expo-no-redundant-dependency",
|
|
7995
|
-
message: "\"expo-firebase-recaptcha\" was removed in SDK 48",
|
|
8018
|
+
message: "\"expo-firebase-recaptcha\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
7996
8019
|
help: FIREBASE_HELP,
|
|
7997
8020
|
minSdkMajor: 48
|
|
7998
8021
|
},
|
|
7999
8022
|
{
|
|
8000
8023
|
packageName: "expo-firebase-core",
|
|
8001
8024
|
rule: "expo-no-redundant-dependency",
|
|
8002
|
-
message: "\"expo-firebase-core\" was removed in SDK 48",
|
|
8025
|
+
message: "\"expo-firebase-core\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
|
|
8003
8026
|
help: FIREBASE_HELP,
|
|
8004
8027
|
minSdkMajor: 48
|
|
8005
8028
|
}
|
|
@@ -8040,7 +8063,7 @@ const checkExpoGitignore = (context) => {
|
|
|
8040
8063
|
}));
|
|
8041
8064
|
if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
|
|
8042
8065
|
rule: "expo-gitignore",
|
|
8043
|
-
message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored
|
|
8066
|
+
message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored, so required native code can be missing from CI or teammate checkouts.",
|
|
8044
8067
|
help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
|
|
8045
8068
|
}));
|
|
8046
8069
|
return diagnostics;
|
|
@@ -8102,17 +8125,16 @@ const checkExpoPackageJsonConflicts = (context) => {
|
|
|
8102
8125
|
const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
|
|
8103
8126
|
if (conflictingScriptNames.length > 0) {
|
|
8104
8127
|
const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
|
|
8105
|
-
const shadowsExpoCli = conflictingScriptNames.includes("expo");
|
|
8106
8128
|
diagnostics.push(buildExpoDiagnostic({
|
|
8107
8129
|
rule: "expo-package-json-conflict",
|
|
8108
|
-
message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that
|
|
8130
|
+
message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that shadows" : "as scripts that shadow"} Expo/React Native binaries in node_modules/.bin, so tooling can run the local script instead of the expected CLI and fail builds.`,
|
|
8109
8131
|
help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
|
|
8110
8132
|
}));
|
|
8111
8133
|
}
|
|
8112
8134
|
const packageName = packageJson.name;
|
|
8113
8135
|
if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
|
|
8114
8136
|
rule: "expo-package-json-conflict",
|
|
8115
|
-
message: `package.json "name" is "${packageName}", which collides with a dependency of the same name
|
|
8137
|
+
message: `package.json "name" is "${packageName}", which collides with a dependency of the same name, so package self-resolution can shadow the dependency and break imports that expect the installed package.`,
|
|
8116
8138
|
help: "Rename your package so it no longer matches one of its dependencies"
|
|
8117
8139
|
}));
|
|
8118
8140
|
return diagnostics;
|
|
@@ -8183,7 +8205,7 @@ const checkExpoRouterReactNavigation = (context) => {
|
|
|
8183
8205
|
if (reactNavigationNames.length === 0) return [];
|
|
8184
8206
|
return [buildExpoDiagnostic({
|
|
8185
8207
|
rule: "expo-router-no-react-navigation",
|
|
8186
|
-
message: `As of SDK 56, expo-router is no longer compatible with react-navigation,
|
|
8208
|
+
message: `As of SDK 56, expo-router is no longer compatible with directly installed @react-navigation packages, so keeping ${reactNavigationNames.map((name) => `"${name}"`).join(", ")} can break routing or linking behavior after the SDK upgrade.`,
|
|
8187
8209
|
help: "Remove these `@react-navigation/*` packages and replace direct imports with their expo-router equivalents. See https://docs.expo.dev/router/migrate/sdk-55-to-56/"
|
|
8188
8210
|
})];
|
|
8189
8211
|
};
|
|
@@ -8555,7 +8577,9 @@ const setColorEnabled = (enabled) => {
|
|
|
8555
8577
|
highlighter.gray = colors.gray;
|
|
8556
8578
|
highlighter.bold = colors.bold;
|
|
8557
8579
|
};
|
|
8558
|
-
const
|
|
8580
|
+
const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
|
|
8581
|
+
const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
|
|
8582
|
+
const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
|
|
8559
8583
|
const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
|
|
8560
8584
|
const FALSY_VALUES = new Set([
|
|
8561
8585
|
"false",
|
|
@@ -8635,7 +8659,7 @@ const collectIgnorePatterns = (rootDirectory) => {
|
|
|
8635
8659
|
return patterns;
|
|
8636
8660
|
};
|
|
8637
8661
|
const KNIP_JSON_FILENAME = "knip.json";
|
|
8638
|
-
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8662
|
+
const isRecord$1$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8639
8663
|
const readJsonFileSafe = (filePath) => {
|
|
8640
8664
|
let rawContents;
|
|
8641
8665
|
try {
|
|
@@ -8651,10 +8675,10 @@ const readJsonFileSafe = (filePath) => {
|
|
|
8651
8675
|
};
|
|
8652
8676
|
const readKnipConfig = (rootDirectory) => {
|
|
8653
8677
|
const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
|
|
8654
|
-
if (isRecord$1(knipJson)) return knipJson;
|
|
8678
|
+
if (isRecord$1$1(knipJson)) return knipJson;
|
|
8655
8679
|
const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
|
|
8656
|
-
const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
|
|
8657
|
-
return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
|
|
8680
|
+
const packageKnipConfig = isRecord$1$1(packageJson) ? packageJson.knip : null;
|
|
8681
|
+
return isRecord$1$1(packageKnipConfig) ? packageKnipConfig : null;
|
|
8658
8682
|
};
|
|
8659
8683
|
const normalizePatternList = (value) => {
|
|
8660
8684
|
if (typeof value === "string" && value.length > 0) return [value];
|
|
@@ -8666,10 +8690,10 @@ const prefixWorkspacePatterns = (workspacePattern, patterns) => {
|
|
|
8666
8690
|
return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
|
|
8667
8691
|
};
|
|
8668
8692
|
const collectKnipWorkspacePatterns = (workspaces, settingName) => {
|
|
8669
|
-
if (!isRecord$1(workspaces)) return [];
|
|
8693
|
+
if (!isRecord$1$1(workspaces)) return [];
|
|
8670
8694
|
const patterns = [];
|
|
8671
8695
|
for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
|
|
8672
|
-
if (!isRecord$1(workspaceConfig)) continue;
|
|
8696
|
+
if (!isRecord$1$1(workspaceConfig)) continue;
|
|
8673
8697
|
patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
|
|
8674
8698
|
}
|
|
8675
8699
|
return patterns;
|
|
@@ -8981,7 +9005,7 @@ const checkDeadCode = async (options) => {
|
|
|
8981
9005
|
plugin: DEAD_CODE_PLUGIN,
|
|
8982
9006
|
rule: "unused-file",
|
|
8983
9007
|
severity: "warning",
|
|
8984
|
-
message: "Unused file
|
|
9008
|
+
message: "Unused file is not reachable from any entry point, so it adds maintenance surface without shipping any code.",
|
|
8985
9009
|
help: "Delete the file if it is truly unreachable, or import it from an entry point.",
|
|
8986
9010
|
line: 0,
|
|
8987
9011
|
column: 0,
|
|
@@ -8994,7 +9018,7 @@ const checkDeadCode = async (options) => {
|
|
|
8994
9018
|
plugin: DEAD_CODE_PLUGIN,
|
|
8995
9019
|
rule: unusedExport.isTypeOnly ? "unused-type" : "unused-export",
|
|
8996
9020
|
severity: "warning",
|
|
8997
|
-
message: `Unused ${label}: \`${unusedExport.name}
|
|
9021
|
+
message: `Unused ${label}: \`${unusedExport.name}\` is exported but no module imports it, so it expands the public surface and can mislead callers about supported API.`,
|
|
8998
9022
|
help: "Drop the `export` keyword (or remove the declaration) if no other module uses this symbol.",
|
|
8999
9023
|
line: unusedExport.line,
|
|
9000
9024
|
column: unusedExport.column,
|
|
@@ -9009,7 +9033,7 @@ const checkDeadCode = async (options) => {
|
|
|
9009
9033
|
rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
|
|
9010
9034
|
severity: "warning",
|
|
9011
9035
|
message: `Unused ${label}: \`${unusedDependency.name}\``,
|
|
9012
|
-
help:
|
|
9036
|
+
help: `An unused ${label} adds install time and supply-chain surface without being used; remove it from package.json if it is genuinely unused.`,
|
|
9013
9037
|
line: 0,
|
|
9014
9038
|
column: 0,
|
|
9015
9039
|
category: DEAD_CODE_CATEGORY
|
|
@@ -9022,7 +9046,7 @@ const checkDeadCode = async (options) => {
|
|
|
9022
9046
|
plugin: DEAD_CODE_PLUGIN,
|
|
9023
9047
|
rule: "circular-dependency",
|
|
9024
9048
|
severity: "warning",
|
|
9025
|
-
message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}
|
|
9049
|
+
message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}. Modules in the cycle can observe partially initialized exports, causing order-dependent bugs.`,
|
|
9026
9050
|
help: "Break the cycle by extracting the shared code into a third module that both files import.",
|
|
9027
9051
|
line: 0,
|
|
9028
9052
|
column: 0,
|
|
@@ -9105,11 +9129,11 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
|
|
|
9105
9129
|
return filePaths;
|
|
9106
9130
|
};
|
|
9107
9131
|
const listSourceFiles = (rootDirectory) => excludeMinifiedFiles(rootDirectory, listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory));
|
|
9108
|
-
const resolveLintIncludePaths = (rootDirectory, userConfig) => {
|
|
9132
|
+
const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
|
|
9109
9133
|
if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
|
|
9110
9134
|
const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
|
|
9111
9135
|
return listSourceFiles(rootDirectory).filter((filePath) => {
|
|
9112
|
-
if (!
|
|
9136
|
+
if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
|
|
9113
9137
|
return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
|
|
9114
9138
|
});
|
|
9115
9139
|
};
|
|
@@ -9889,16 +9913,16 @@ const readPluginShape = (pluginSpecifier, loadModule) => {
|
|
|
9889
9913
|
ruleNames: new Set(Object.keys(rules))
|
|
9890
9914
|
};
|
|
9891
9915
|
};
|
|
9892
|
-
const bundledRequire = createRequire(import.meta.url);
|
|
9916
|
+
const bundledRequire$1 = createRequire(import.meta.url);
|
|
9893
9917
|
const resolveReactHooksJsPlugin = (hasReactCompiler, customRulesOnly) => {
|
|
9894
9918
|
if (!hasReactCompiler || customRulesOnly) return null;
|
|
9895
9919
|
let pluginSpecifier;
|
|
9896
9920
|
try {
|
|
9897
|
-
pluginSpecifier = bundledRequire.resolve("eslint-plugin-react-hooks");
|
|
9921
|
+
pluginSpecifier = bundledRequire$1.resolve("eslint-plugin-react-hooks");
|
|
9898
9922
|
} catch {
|
|
9899
9923
|
return null;
|
|
9900
9924
|
}
|
|
9901
|
-
const { ruleNames } = readPluginShape(pluginSpecifier, (spec) => bundledRequire(spec));
|
|
9925
|
+
const { ruleNames } = readPluginShape(pluginSpecifier, (spec) => bundledRequire$1(spec));
|
|
9902
9926
|
return {
|
|
9903
9927
|
entry: {
|
|
9904
9928
|
name: "react-hooks-js",
|
|
@@ -11461,7 +11485,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
11461
11485
|
directory: scanDirectory,
|
|
11462
11486
|
repo
|
|
11463
11487
|
}).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
|
|
11464
|
-
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 :
|
|
11488
|
+
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
|
|
11465
11489
|
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
|
|
11466
11490
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
11467
11491
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
@@ -12047,6 +12071,22 @@ const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
|
|
|
12047
12071
|
* instead of being improvised per diagnostic.
|
|
12048
12072
|
*/
|
|
12049
12073
|
const buildRuleDocsUrl = (plugin, rule) => `${DOCS_RULES_BASE_URL}/${plugin}/${rule}`;
|
|
12074
|
+
const computeConfigFingerprint = (projectDirectory, version) => {
|
|
12075
|
+
const parts = [`v=${version}`];
|
|
12076
|
+
let directory = projectDirectory;
|
|
12077
|
+
for (;;) {
|
|
12078
|
+
for (const filename of CONFIG_FINGERPRINT_FILENAMES) try {
|
|
12079
|
+
const stat = fs.statSync(path.join(directory, filename));
|
|
12080
|
+
parts.push(`${directory}/${filename}=${stat.mtimeMs}:${stat.size}`);
|
|
12081
|
+
} catch {
|
|
12082
|
+
continue;
|
|
12083
|
+
}
|
|
12084
|
+
const parent = path.dirname(directory);
|
|
12085
|
+
if (parent === directory) break;
|
|
12086
|
+
directory = parent;
|
|
12087
|
+
}
|
|
12088
|
+
return crypto.createHash("sha1").update(parts.join("|")).digest("hex");
|
|
12089
|
+
};
|
|
12050
12090
|
const groupBy = (items, keyFn) => {
|
|
12051
12091
|
const groups = /* @__PURE__ */ new Map();
|
|
12052
12092
|
for (const item of items) {
|
|
@@ -12247,7 +12287,7 @@ const makeNoopConsole = () => ({
|
|
|
12247
12287
|
});
|
|
12248
12288
|
//#endregion
|
|
12249
12289
|
//#region src/cli/utils/version.ts
|
|
12250
|
-
const VERSION = "0.4.2-dev.
|
|
12290
|
+
const VERSION = "0.4.2-dev.5b06a86";
|
|
12251
12291
|
//#endregion
|
|
12252
12292
|
//#region src/cli/utils/json-mode.ts
|
|
12253
12293
|
let context = null;
|
|
@@ -12605,13 +12645,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12605
12645
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12606
12646
|
* standard `SENTRY_RELEASE` override.
|
|
12607
12647
|
*/
|
|
12608
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.2-dev.
|
|
12648
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.2-dev.5b06a86`;
|
|
12609
12649
|
/**
|
|
12610
12650
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12611
12651
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12612
12652
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12613
12653
|
*/
|
|
12614
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.2-dev.
|
|
12654
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.2-dev.5b06a86") ? "development" : "production");
|
|
12615
12655
|
/**
|
|
12616
12656
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12617
12657
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -15874,13 +15914,14 @@ const buildRuntimeLayers = (input) => {
|
|
|
15874
15914
|
const linterLayer = input.shouldSkipLint ? Linter.layerOf([]) : Linter.layerOxlint;
|
|
15875
15915
|
const deadCodeLayer = input.shouldRunDeadCode ? DeadCode.layerNode : DeadCode.layerOf([]);
|
|
15876
15916
|
const scoreLayer = input.shouldComputeScore ? Score.layerHttp : Score.layerOf(null);
|
|
15917
|
+
const projectLayer = input.projectInfoOverride === void 0 ? Project.layerNode : Project.layerOf(input.projectInfoOverride);
|
|
15877
15918
|
const progressLayer = input.shouldShowProgressSpinners ? Progress.layerOra(buildSpinnerProgressHandle) : Progress.layerNoop;
|
|
15878
15919
|
const configLayer = input.hasConfigOverride ? Config.layerOf({
|
|
15879
15920
|
config: input.userConfig,
|
|
15880
15921
|
resolvedDirectory: input.directory,
|
|
15881
15922
|
configSourceDirectory: input.configSourceDirectory
|
|
15882
15923
|
}) : Config.layerNode;
|
|
15883
|
-
const baseLayers = Layer.mergeAll(
|
|
15924
|
+
const baseLayers = Layer.mergeAll(projectLayer, configLayer, Files.layerNode, Git.layerNode, linterLayer, LintPartialFailures.layerLive, deadCodeLayer, progressLayer, Reporter.layerNoop, scoreLayer);
|
|
15884
15925
|
return input.oxlintConcurrency === void 0 ? baseLayers : Layer.mergeAll(baseLayers, Layer.succeed(OxlintConcurrency, input.oxlintConcurrency));
|
|
15885
15926
|
};
|
|
15886
15927
|
//#endregion
|
|
@@ -16606,6 +16647,11 @@ const printCategoryCountUp = (tallies) => Effect.gen(function* () {
|
|
|
16606
16647
|
});
|
|
16607
16648
|
const TOP_ERROR_DETAIL_INDENT = " ";
|
|
16608
16649
|
const pickRepresentativeDiagnostic = (ruleDiagnostics) => ruleDiagnostics.find((diagnostic) => diagnostic.line > 0) ?? ruleDiagnostics[0];
|
|
16650
|
+
const hasIndistinctSiteLocations = (ruleDiagnostics) => {
|
|
16651
|
+
const firstDiagnostic = ruleDiagnostics[0];
|
|
16652
|
+
if (firstDiagnostic === void 0) return false;
|
|
16653
|
+
return ruleDiagnostics.every((diagnostic) => diagnostic.line <= 0 && diagnostic.filePath === firstDiagnostic.filePath);
|
|
16654
|
+
};
|
|
16609
16655
|
const FRAME_CONTEXT_REACH_LINES = 3;
|
|
16610
16656
|
const clusterNearbyDiagnostics = (diagnostics) => {
|
|
16611
16657
|
const byFile = groupBy(diagnostics, (diagnostic) => diagnostic.filePath);
|
|
@@ -16669,7 +16715,9 @@ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, rende
|
|
|
16669
16715
|
const learnMoreLine = formatLearnMoreLine(representative);
|
|
16670
16716
|
if (learnMoreLine) lines.push(`${TOP_ERROR_DETAIL_INDENT}${highlighter.info(learnMoreLine)}`);
|
|
16671
16717
|
}
|
|
16672
|
-
|
|
16718
|
+
const isCollapsedWarningGroup = severity === "warning" && hasIndistinctSiteLocations(ruleDiagnostics);
|
|
16719
|
+
const impactMessages = isCollapsedWarningGroup ? [...new Set(ruleDiagnostics.map((diagnostic) => diagnostic.message))] : [representative.message];
|
|
16720
|
+
for (const impactMessage of impactMessages) for (const explanationLine of wrapTextToWidth(impactMessage, resolveMeasureWidth(4), { breakLongWords: false })) lines.push(`${TOP_ERROR_DETAIL_INDENT}${explanationLine}`);
|
|
16673
16721
|
if (representative.help) for (const fixLine of wrapTextToWidth(`→ ${representative.help}`, resolveMeasureWidth(4), { breakLongWords: false })) lines.push(highlighter.dim(`${TOP_ERROR_DETAIL_INDENT}${fixLine}`));
|
|
16674
16722
|
if (renderEverySite && isAgentEnvironment) {
|
|
16675
16723
|
const fixRecipeLine = formatFixRecipeLine(representative);
|
|
@@ -16677,7 +16725,7 @@ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, rende
|
|
|
16677
16725
|
}
|
|
16678
16726
|
const renderCodeFrame = severity === "error";
|
|
16679
16727
|
const sites = renderEverySite ? ruleDiagnostics : [representative];
|
|
16680
|
-
for (const cluster of clusterNearbyDiagnostics(sites)) lines.push(...buildDiagnosticClusterLines(cluster, resolveSourceRoot, renderCodeFrame));
|
|
16728
|
+
if (!(isCollapsedWarningGroup && representative.help.includes(representative.filePath))) for (const cluster of clusterNearbyDiagnostics(sites)) lines.push(...buildDiagnosticClusterLines(cluster, resolveSourceRoot, renderCodeFrame));
|
|
16681
16729
|
return lines;
|
|
16682
16730
|
};
|
|
16683
16731
|
const selectErrorRuleGroups = (diagnostics, rulePriority) => buildSortedRuleGroups(diagnostics.filter((diagnostic) => diagnostic.severity === "error"), rulePriority);
|
|
@@ -16806,6 +16854,9 @@ const computeProjectedScore = async (topErrorSource, rescoreSource, currentScore
|
|
|
16806
16854
|
if (!potentialScore || potentialScore.score <= currentScore.score) return null;
|
|
16807
16855
|
return potentialScore.score;
|
|
16808
16856
|
};
|
|
16857
|
+
//#endregion
|
|
16858
|
+
//#region src/cli/utils/filter-diagnostics-by-categories.ts
|
|
16859
|
+
const filterDiagnosticsByCategories = (diagnostics, categories) => categories.size === 0 ? [...diagnostics] : diagnostics.filter((diagnostic) => categories.has(diagnostic.category));
|
|
16809
16860
|
const FORCE_ONBOARDING_ENV_VAR = "REACT_DOCTOR_FORCE_ONBOARDING";
|
|
16810
16861
|
const FALSY_FLAG_VALUES = new Set([
|
|
16811
16862
|
"",
|
|
@@ -17236,11 +17287,259 @@ const resolveOxlintNodeEffect = (isLintEnabled, isQuiet) => Effect.gen(function*
|
|
|
17236
17287
|
});
|
|
17237
17288
|
const resolveOxlintNode = (isLintEnabled, isQuiet) => Effect.runPromise(resolveOxlintNodeEffect(isLintEnabled, isQuiet).pipe(Effect.provide(NodeResolver.layerNode)));
|
|
17238
17289
|
//#endregion
|
|
17290
|
+
//#region src/cli/utils/cli-input-error.ts
|
|
17291
|
+
/**
|
|
17292
|
+
* A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
|
|
17293
|
+
* argument, mutually exclusive flags, or an unknown `--project` name. This is
|
|
17294
|
+
* user input, not a react-doctor bug, so `isExpectedUserError` routes it
|
|
17295
|
+
* through `handleUserError`: a clean, single-line message with no Sentry
|
|
17296
|
+
* report and no "Something went wrong, open a prefilled issue" block.
|
|
17297
|
+
*
|
|
17298
|
+
* The `message` is rendered verbatim, so it must read as a complete,
|
|
17299
|
+
* human-readable sentence that tells the user how to fix their invocation.
|
|
17300
|
+
*/
|
|
17301
|
+
var CliInputError = class extends Error {
|
|
17302
|
+
name = "CliInputError";
|
|
17303
|
+
};
|
|
17304
|
+
//#endregion
|
|
17305
|
+
//#region src/cli/utils/resolve-cli-categories.ts
|
|
17306
|
+
const categoryByLowercase = new Map(DIAGNOSTIC_CATEGORY_BUCKETS.map((category) => [category.toLowerCase(), category]));
|
|
17307
|
+
const knownCategoryList = DIAGNOSTIC_CATEGORY_BUCKETS.join(", ");
|
|
17308
|
+
const splitCategoryFlagValue = (value) => value.split(",").map((category) => category.trim()).filter((category) => category.length > 0);
|
|
17309
|
+
const resolveCliCategories = (categoryFlag) => {
|
|
17310
|
+
const rawCategoryValues = categoryFlag === void 0 ? [] : Array.isArray(categoryFlag) ? categoryFlag : [categoryFlag];
|
|
17311
|
+
const resolvedCategories = [];
|
|
17312
|
+
const seenCategories = /* @__PURE__ */ new Set();
|
|
17313
|
+
for (const rawCategoryValue of rawCategoryValues) for (const categoryQuery of splitCategoryFlagValue(rawCategoryValue)) {
|
|
17314
|
+
const matchedCategory = categoryByLowercase.get(categoryQuery.toLowerCase());
|
|
17315
|
+
if (matchedCategory === void 0) throw new CliInputError(`Unknown category "${categoryQuery}". Expected one of: ${knownCategoryList}.`);
|
|
17316
|
+
if (!seenCategories.has(matchedCategory)) {
|
|
17317
|
+
seenCategories.add(matchedCategory);
|
|
17318
|
+
resolvedCategories.push(matchedCategory);
|
|
17319
|
+
}
|
|
17320
|
+
}
|
|
17321
|
+
if (rawCategoryValues.length > 0 && resolvedCategories.length === 0) throw new CliInputError(`--category requires one of: ${knownCategoryList}.`);
|
|
17322
|
+
return resolvedCategories.length > 0 ? resolvedCategories : void 0;
|
|
17323
|
+
};
|
|
17324
|
+
//#endregion
|
|
17325
|
+
//#region src/cli/utils/scan-result-cache.ts
|
|
17326
|
+
const CACHE_DISABLED_VALUES = new Set(["1", "true"]);
|
|
17327
|
+
const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
17328
|
+
"oxlint",
|
|
17329
|
+
"oxlint/package.json",
|
|
17330
|
+
"oxlint-plugin-react-doctor",
|
|
17331
|
+
"deslop-js/package.json",
|
|
17332
|
+
"eslint-plugin-react-hooks/package.json"
|
|
17333
|
+
];
|
|
17334
|
+
const bundledRequire = createRequire(import.meta.url);
|
|
17335
|
+
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17336
|
+
const normalizeForStableJson = (value) => {
|
|
17337
|
+
if (value === null) return null;
|
|
17338
|
+
if (value === void 0) return void 0;
|
|
17339
|
+
const valueType = typeof value;
|
|
17340
|
+
if (valueType === "string" || valueType === "number" || valueType === "boolean") return value;
|
|
17341
|
+
if (valueType === "bigint" || valueType === "function" || valueType === "symbol") throw new Error("Unsupported cache key value");
|
|
17342
|
+
if (Array.isArray(value)) return value.map((item) => {
|
|
17343
|
+
const normalized = normalizeForStableJson(item);
|
|
17344
|
+
return normalized === void 0 ? null : normalized;
|
|
17345
|
+
});
|
|
17346
|
+
const prototype = Object.getPrototypeOf(value);
|
|
17347
|
+
if (prototype !== Object.prototype && prototype !== null) throw new Error("Unsupported cache key object");
|
|
17348
|
+
const record = value;
|
|
17349
|
+
const normalizedRecord = {};
|
|
17350
|
+
for (const key of Object.keys(record).sort()) {
|
|
17351
|
+
const normalized = normalizeForStableJson(record[key]);
|
|
17352
|
+
if (normalized !== void 0) normalizedRecord[key] = normalized;
|
|
17353
|
+
}
|
|
17354
|
+
return normalizedRecord;
|
|
17355
|
+
};
|
|
17356
|
+
const stringifyStableJson = (value) => {
|
|
17357
|
+
try {
|
|
17358
|
+
return JSON.stringify(normalizeForStableJson(value));
|
|
17359
|
+
} catch {
|
|
17360
|
+
return null;
|
|
17361
|
+
}
|
|
17362
|
+
};
|
|
17363
|
+
const hashString = (value) => crypto.createHash("sha1").update(value).digest("hex");
|
|
17364
|
+
const runGit$1 = (directory, args) => {
|
|
17365
|
+
try {
|
|
17366
|
+
return execFileSync("git", [...args], {
|
|
17367
|
+
cwd: directory,
|
|
17368
|
+
encoding: "utf8",
|
|
17369
|
+
stdio: [
|
|
17370
|
+
"ignore",
|
|
17371
|
+
"pipe",
|
|
17372
|
+
"ignore"
|
|
17373
|
+
]
|
|
17374
|
+
}).trim();
|
|
17375
|
+
} catch {
|
|
17376
|
+
return null;
|
|
17377
|
+
}
|
|
17378
|
+
};
|
|
17379
|
+
const readHeadSha = (projectDirectory) => runGit$1(projectDirectory, ["rev-parse", "HEAD"]);
|
|
17380
|
+
const isWorktreeClean = (projectDirectory) => {
|
|
17381
|
+
const status = runGit$1(projectDirectory, [
|
|
17382
|
+
"status",
|
|
17383
|
+
"--porcelain=v1",
|
|
17384
|
+
"--untracked-files=normal"
|
|
17385
|
+
]);
|
|
17386
|
+
return status !== null && status.length === 0;
|
|
17387
|
+
};
|
|
17388
|
+
const hasHiddenTrackedFileState = (projectDirectory) => {
|
|
17389
|
+
const output = runGit$1(projectDirectory, ["ls-files", "-v"]);
|
|
17390
|
+
if (output === null) return true;
|
|
17391
|
+
return output.split("\n").some((line) => line.length > 0 && line[0] !== "H");
|
|
17392
|
+
};
|
|
17393
|
+
const resolveCacheFilePath = (projectDirectory) => {
|
|
17394
|
+
const nodeModulesDirectory = path.join(projectDirectory, "node_modules");
|
|
17395
|
+
if (fs.existsSync(nodeModulesDirectory)) return path.join(nodeModulesDirectory, ".cache", "react-doctor", "scan-cache.json");
|
|
17396
|
+
const projectHash = hashString(projectDirectory).slice(0, 16);
|
|
17397
|
+
return path.join(os.tmpdir(), "react-doctor-cache", `scan-${projectHash}.json`);
|
|
17398
|
+
};
|
|
17399
|
+
const readPersistedCache = (cacheFilePath) => {
|
|
17400
|
+
try {
|
|
17401
|
+
const parsed = JSON.parse(fs.readFileSync(cacheFilePath, "utf8"));
|
|
17402
|
+
if (!isRecord$1(parsed) || parsed.version !== 1) return {
|
|
17403
|
+
version: 1,
|
|
17404
|
+
entries: []
|
|
17405
|
+
};
|
|
17406
|
+
if (!Array.isArray(parsed.entries)) return {
|
|
17407
|
+
version: 1,
|
|
17408
|
+
entries: []
|
|
17409
|
+
};
|
|
17410
|
+
const entries = [];
|
|
17411
|
+
for (const entry of parsed.entries) {
|
|
17412
|
+
if (!isRecord$1(entry) || typeof entry.key !== "string" || typeof entry.createdAtMs !== "number") continue;
|
|
17413
|
+
if (!isRecord$1(entry.payload) || !Array.isArray(entry.payload.diagnostics)) continue;
|
|
17414
|
+
entries.push(entry);
|
|
17415
|
+
}
|
|
17416
|
+
return {
|
|
17417
|
+
version: 1,
|
|
17418
|
+
entries
|
|
17419
|
+
};
|
|
17420
|
+
} catch {
|
|
17421
|
+
return {
|
|
17422
|
+
version: 1,
|
|
17423
|
+
entries: []
|
|
17424
|
+
};
|
|
17425
|
+
}
|
|
17426
|
+
};
|
|
17427
|
+
const writePersistedCache = (cacheFilePath, cache) => {
|
|
17428
|
+
try {
|
|
17429
|
+
fs.mkdirSync(path.dirname(cacheFilePath), { recursive: true });
|
|
17430
|
+
const tempPath = `${cacheFilePath}.${process.pid}.tmp`;
|
|
17431
|
+
fs.writeFileSync(tempPath, JSON.stringify(cache));
|
|
17432
|
+
fs.renameSync(tempPath, cacheFilePath);
|
|
17433
|
+
} catch {
|
|
17434
|
+
return;
|
|
17435
|
+
}
|
|
17436
|
+
};
|
|
17437
|
+
const isScanResultCacheDisabled = () => CACHE_DISABLED_VALUES.has(process.env.REACT_DOCTOR_NO_CACHE?.toLowerCase() ?? "");
|
|
17438
|
+
const resolveProjectIdentity = (projectDirectory) => {
|
|
17439
|
+
try {
|
|
17440
|
+
return fs.realpathSync.native(projectDirectory);
|
|
17441
|
+
} catch {
|
|
17442
|
+
return path.resolve(projectDirectory);
|
|
17443
|
+
}
|
|
17444
|
+
};
|
|
17445
|
+
const fileFingerprint = (filePath) => {
|
|
17446
|
+
try {
|
|
17447
|
+
const stat = fs.statSync(filePath);
|
|
17448
|
+
return `${filePath}:${stat.mtimeMs}:${stat.size}`;
|
|
17449
|
+
} catch {
|
|
17450
|
+
return null;
|
|
17451
|
+
}
|
|
17452
|
+
};
|
|
17453
|
+
const resolveToolchainFingerprint = (nodeBinaryPath) => {
|
|
17454
|
+
const fingerprints = [];
|
|
17455
|
+
if (nodeBinaryPath !== null) {
|
|
17456
|
+
const fingerprint = fileFingerprint(nodeBinaryPath);
|
|
17457
|
+
if (fingerprint !== null) fingerprints.push(`node=${fingerprint}`);
|
|
17458
|
+
}
|
|
17459
|
+
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
17460
|
+
const fingerprint = fileFingerprint(bundledRequire.resolve(specifier));
|
|
17461
|
+
if (fingerprint !== null) fingerprints.push(`${specifier}=${fingerprint}`);
|
|
17462
|
+
} catch {
|
|
17463
|
+
continue;
|
|
17464
|
+
}
|
|
17465
|
+
return fingerprints;
|
|
17466
|
+
};
|
|
17467
|
+
const buildScanResultCacheKey = (input) => {
|
|
17468
|
+
if (isScanResultCacheDisabled()) return null;
|
|
17469
|
+
if (!isWorktreeClean(input.projectDirectory)) return null;
|
|
17470
|
+
if (hasHiddenTrackedFileState(input.projectDirectory)) return null;
|
|
17471
|
+
const headSha = readHeadSha(input.projectDirectory);
|
|
17472
|
+
if (headSha === null) return null;
|
|
17473
|
+
if (stringifyStableJson(input.userConfig) === null) return null;
|
|
17474
|
+
const cacheKeyJson = stringifyStableJson({
|
|
17475
|
+
schemaVersion: 1,
|
|
17476
|
+
projectIdentity: resolveProjectIdentity(input.projectDirectory),
|
|
17477
|
+
headSha,
|
|
17478
|
+
reactDoctorVersion: input.version,
|
|
17479
|
+
nodeVersion: process.version,
|
|
17480
|
+
toolchainFingerprint: resolveToolchainFingerprint(input.nodeBinaryPath),
|
|
17481
|
+
configFingerprint: computeConfigFingerprint(input.projectDirectory, input.version),
|
|
17482
|
+
hasConfigOverride: input.hasConfigOverride,
|
|
17483
|
+
configSourceDirectory: input.configSourceDirectory,
|
|
17484
|
+
userConfig: input.userConfig,
|
|
17485
|
+
engineOptions: {
|
|
17486
|
+
lint: input.options.lint,
|
|
17487
|
+
deadCode: input.options.deadCode,
|
|
17488
|
+
includePaths: [...input.options.includePaths].sort(),
|
|
17489
|
+
customRulesOnly: input.options.customRulesOnly,
|
|
17490
|
+
respectInlineDisables: input.options.respectInlineDisables,
|
|
17491
|
+
warnings: input.options.warnings,
|
|
17492
|
+
adoptExistingLintConfig: input.options.adoptExistingLintConfig,
|
|
17493
|
+
ignoredTags: [...input.options.ignoredTags].sort(),
|
|
17494
|
+
concurrency: input.options.concurrency,
|
|
17495
|
+
baselineRef: input.options.baseline?.ref,
|
|
17496
|
+
noScore: input.options.noScore,
|
|
17497
|
+
isCi: input.options.isCi,
|
|
17498
|
+
suppressRendering: input.options.suppressRendering
|
|
17499
|
+
}
|
|
17500
|
+
});
|
|
17501
|
+
return cacheKeyJson === null ? null : hashString(cacheKeyJson);
|
|
17502
|
+
};
|
|
17503
|
+
const createScanResultCache = (projectDirectory) => {
|
|
17504
|
+
const cacheFilePath = resolveCacheFilePath(projectDirectory);
|
|
17505
|
+
const persistedCache = readPersistedCache(cacheFilePath);
|
|
17506
|
+
const entries = /* @__PURE__ */ new Map();
|
|
17507
|
+
for (const entry of persistedCache.entries) entries.set(entry.key, entry);
|
|
17508
|
+
const persist = () => {
|
|
17509
|
+
writePersistedCache(cacheFilePath, {
|
|
17510
|
+
version: 1,
|
|
17511
|
+
entries: [...entries.values()].sort((firstEntry, secondEntry) => secondEntry.createdAtMs - firstEntry.createdAtMs).slice(0, 20)
|
|
17512
|
+
});
|
|
17513
|
+
};
|
|
17514
|
+
return {
|
|
17515
|
+
lookup: (key) => entries.get(key)?.payload ?? null,
|
|
17516
|
+
store: (key, payload) => {
|
|
17517
|
+
entries.set(key, {
|
|
17518
|
+
key,
|
|
17519
|
+
createdAtMs: Date.now(),
|
|
17520
|
+
payload
|
|
17521
|
+
});
|
|
17522
|
+
persist();
|
|
17523
|
+
}
|
|
17524
|
+
};
|
|
17525
|
+
};
|
|
17526
|
+
const shouldStoreScanPayload = (payload) => !payload.didLintFail && !payload.didDeadCodeFail && payload.lintPartialFailures.length === 0;
|
|
17527
|
+
//#endregion
|
|
17239
17528
|
//#region src/inspect.ts
|
|
17240
17529
|
const silentConsole = makeNoopConsole();
|
|
17241
17530
|
const runConsole = (effect) => {
|
|
17242
17531
|
Effect.runSync(effect);
|
|
17243
17532
|
};
|
|
17533
|
+
const recordOnboardingCompletion = (options) => {
|
|
17534
|
+
const forceOnboarding = isOnboardingForced();
|
|
17535
|
+
if (shouldRecordOnboarding({
|
|
17536
|
+
paceOnboardingSections: !options.silent && !options.scoreOnly && !options.suppressRendering && !options.verbose && canAnimateOnboarding(process.stdout) && (forceOnboarding || !hasCompletedOnboarding()),
|
|
17537
|
+
forceOnboarding,
|
|
17538
|
+
verbose: options.verbose,
|
|
17539
|
+
isNonInteractiveEnvironment: options.isNonInteractiveEnvironment
|
|
17540
|
+
})) markOnboardingComplete();
|
|
17541
|
+
};
|
|
17542
|
+
const formatCategorySelection = (categoryFilters) => [...categoryFilters].join(", ");
|
|
17244
17543
|
const buildIgnoredTags = (userConfig) => {
|
|
17245
17544
|
const tags = /* @__PURE__ */ new Set();
|
|
17246
17545
|
if (userConfig?.ignore?.tags) for (const tag of userConfig.ignore.tags) tags.add(tag);
|
|
@@ -17261,6 +17560,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
17261
17560
|
share: userConfig?.share ?? true,
|
|
17262
17561
|
respectInlineDisables: inputOptions.respectInlineDisables ?? userConfig?.respectInlineDisables ?? true,
|
|
17263
17562
|
warnings: inputOptions.warnings ?? userConfig?.warnings ?? true,
|
|
17563
|
+
categoryFilters: new Set(resolveCliCategories(inputOptions.categoryFilters) ?? []),
|
|
17264
17564
|
adoptExistingLintConfig: userConfig?.adoptExistingLintConfig ?? true,
|
|
17265
17565
|
ignoredTags: buildIgnoredTags(userConfig),
|
|
17266
17566
|
outputSurface: inputOptions.outputSurface ?? "cli",
|
|
@@ -17347,6 +17647,7 @@ const runBaselineComparison = async (params) => {
|
|
|
17347
17647
|
hasConfigOverride: true,
|
|
17348
17648
|
userConfig: params.userConfig,
|
|
17349
17649
|
configSourceDirectory: null,
|
|
17650
|
+
projectInfoOverride: params.headProjectInfo,
|
|
17350
17651
|
shouldSkipLint: !params.options.lint || !params.resolvedNodeBinaryPath,
|
|
17351
17652
|
shouldRunDeadCode: false,
|
|
17352
17653
|
shouldComputeScore: false,
|
|
@@ -17393,6 +17694,40 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
17393
17694
|
const isDiffMode = options.includePaths.length > 0;
|
|
17394
17695
|
const resolvedNodeBinaryPath = await resolveOxlintNode(options.lint, options.scoreOnly || options.silent);
|
|
17395
17696
|
const lintBindingMissing = options.lint && !resolvedNodeBinaryPath;
|
|
17697
|
+
const cacheKey = buildScanResultCacheKey({
|
|
17698
|
+
projectDirectory: directory,
|
|
17699
|
+
version: VERSION,
|
|
17700
|
+
nodeBinaryPath: resolvedNodeBinaryPath,
|
|
17701
|
+
options,
|
|
17702
|
+
userConfig,
|
|
17703
|
+
hasConfigOverride,
|
|
17704
|
+
configSourceDirectory
|
|
17705
|
+
});
|
|
17706
|
+
const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
|
|
17707
|
+
const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
|
|
17708
|
+
if (cachedPayload) {
|
|
17709
|
+
recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
|
|
17710
|
+
recordCount(METRIC.projectDetected, 1);
|
|
17711
|
+
await renderCachedProjectDetection({
|
|
17712
|
+
payload: cachedPayload,
|
|
17713
|
+
options,
|
|
17714
|
+
userConfig,
|
|
17715
|
+
isDiffMode
|
|
17716
|
+
});
|
|
17717
|
+
const baselineDegraded = Boolean(options.baseline) && isDiffMode && cachedPayload.baselineDelta === void 0;
|
|
17718
|
+
const result = await renderAndRecordScan({
|
|
17719
|
+
payload: cachedPayload,
|
|
17720
|
+
options,
|
|
17721
|
+
userConfig,
|
|
17722
|
+
hasCustomConfig: userConfig !== null,
|
|
17723
|
+
startTime,
|
|
17724
|
+
rootSentrySpan,
|
|
17725
|
+
scanMode: cachedPayload.baselineDelta ? "baseline" : isDiffMode ? "diff" : "full",
|
|
17726
|
+
baselineDegraded
|
|
17727
|
+
});
|
|
17728
|
+
recordOnboardingCompletion(options);
|
|
17729
|
+
return result;
|
|
17730
|
+
}
|
|
17396
17731
|
const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && options.lint && Boolean(resolvedNodeBinaryPath);
|
|
17397
17732
|
const layers = buildRuntimeLayers({
|
|
17398
17733
|
directory,
|
|
@@ -17446,6 +17781,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
17446
17781
|
directory,
|
|
17447
17782
|
options,
|
|
17448
17783
|
userConfig,
|
|
17784
|
+
headProjectInfo: output.project,
|
|
17449
17785
|
headDiagnostics: output.diagnostics,
|
|
17450
17786
|
resolvedNodeBinaryPath,
|
|
17451
17787
|
baselineRef: options.baseline.ref
|
|
@@ -17457,12 +17793,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
17457
17793
|
}
|
|
17458
17794
|
const baselineDegraded = Boolean(options.baseline) && isDiffMode && baselineDelta === void 0;
|
|
17459
17795
|
const score = didLintFail ? null : output.score;
|
|
17460
|
-
const
|
|
17461
|
-
const forceOnboarding = isOnboardingForced();
|
|
17462
|
-
const paceOnboardingSections = !options.silent && !options.scoreOnly && !options.suppressRendering && !options.verbose && canAnimateOnboarding(process.stdout) && (forceOnboarding || !hasCompletedOnboarding());
|
|
17463
|
-
const finalizeInput = {
|
|
17464
|
-
options,
|
|
17465
|
-
elapsedMilliseconds,
|
|
17796
|
+
const payload = {
|
|
17466
17797
|
diagnostics: inspectDiagnostics,
|
|
17467
17798
|
score,
|
|
17468
17799
|
project: output.project,
|
|
@@ -17476,39 +17807,77 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
17476
17807
|
scannedFileCount: output.scannedFileCount,
|
|
17477
17808
|
scannedFilePaths: output.scannedFilePaths,
|
|
17478
17809
|
scanElapsedMilliseconds: output.scanElapsedMilliseconds,
|
|
17479
|
-
baselineDelta
|
|
17810
|
+
baselineDelta,
|
|
17811
|
+
lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind
|
|
17480
17812
|
};
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17813
|
+
if (cacheKey !== null && scanResultCache !== null && shouldStoreScanPayload(payload)) scanResultCache.store(cacheKey, payload);
|
|
17814
|
+
const result = await renderAndRecordScan({
|
|
17815
|
+
payload,
|
|
17816
|
+
options,
|
|
17817
|
+
userConfig,
|
|
17818
|
+
hasCustomConfig: userConfig !== null,
|
|
17819
|
+
startTime,
|
|
17820
|
+
rootSentrySpan,
|
|
17821
|
+
scanMode: baselineDelta ? "baseline" : isDiffMode ? "diff" : "full",
|
|
17822
|
+
baselineDegraded
|
|
17823
|
+
});
|
|
17824
|
+
recordOnboardingCompletion(options);
|
|
17825
|
+
return result;
|
|
17826
|
+
};
|
|
17827
|
+
const runMaybeSilent = (effect, silent) => silent ? effect.pipe(Effect.provideService(Console.Console, silentConsole)) : effect;
|
|
17828
|
+
const renderCachedProjectDetection = async (input) => {
|
|
17829
|
+
if (input.options.scoreOnly || input.options.suppressRendering) return;
|
|
17830
|
+
await Effect.runPromise(runMaybeSilent(printProjectDetection({
|
|
17831
|
+
projectInfo: input.payload.project,
|
|
17832
|
+
userConfig: input.userConfig,
|
|
17833
|
+
isDiffMode: input.isDiffMode,
|
|
17834
|
+
includePaths: input.options.includePaths,
|
|
17835
|
+
lintSourceFileCount: input.payload.scannedFileCount
|
|
17836
|
+
}), input.options.silent));
|
|
17837
|
+
};
|
|
17838
|
+
const renderAndRecordScan = async (input) => {
|
|
17839
|
+
const finalizeInput = {
|
|
17840
|
+
options: input.options,
|
|
17841
|
+
elapsedMilliseconds: performance.now() - input.startTime,
|
|
17842
|
+
diagnostics: input.payload.diagnostics,
|
|
17843
|
+
score: input.payload.score,
|
|
17844
|
+
project: input.payload.project,
|
|
17845
|
+
userConfig: input.payload.userConfig,
|
|
17846
|
+
didLintFail: input.payload.didLintFail,
|
|
17847
|
+
lintFailureReason: input.payload.lintFailureReason,
|
|
17848
|
+
lintPartialFailures: input.payload.lintPartialFailures,
|
|
17849
|
+
didDeadCodeFail: input.payload.didDeadCodeFail,
|
|
17850
|
+
deadCodeFailureReason: input.payload.deadCodeFailureReason,
|
|
17851
|
+
directory: input.payload.directory,
|
|
17852
|
+
scannedFileCount: input.payload.scannedFileCount,
|
|
17853
|
+
scannedFilePaths: input.payload.scannedFilePaths,
|
|
17854
|
+
scanElapsedMilliseconds: input.payload.scanElapsedMilliseconds,
|
|
17855
|
+
baselineDelta: input.payload.baselineDelta
|
|
17856
|
+
};
|
|
17857
|
+
const result = await Effect.runPromise(runMaybeSilent(finalizeAndRender(finalizeInput), input.options.silent));
|
|
17489
17858
|
recordScanMetrics({
|
|
17490
17859
|
result,
|
|
17491
|
-
mode: scanMode,
|
|
17492
|
-
baselineDegraded,
|
|
17493
|
-
parallel: options.concurrency !== void 0,
|
|
17494
|
-
workerCount: options.concurrency,
|
|
17495
|
-
lint: options.lint,
|
|
17496
|
-
deadCode: options.deadCode,
|
|
17497
|
-
scoreOnly: options.scoreOnly,
|
|
17498
|
-
noScore: options.noScore,
|
|
17499
|
-
didLintFail,
|
|
17500
|
-
lintFailureReasonKind:
|
|
17501
|
-
didDeadCodeFail:
|
|
17860
|
+
mode: input.scanMode,
|
|
17861
|
+
baselineDegraded: input.baselineDegraded,
|
|
17862
|
+
parallel: input.options.concurrency !== void 0,
|
|
17863
|
+
workerCount: input.options.concurrency,
|
|
17864
|
+
lint: input.options.lint,
|
|
17865
|
+
deadCode: input.options.deadCode,
|
|
17866
|
+
scoreOnly: input.options.scoreOnly,
|
|
17867
|
+
noScore: input.options.noScore,
|
|
17868
|
+
didLintFail: input.payload.didLintFail,
|
|
17869
|
+
lintFailureReasonKind: input.payload.lintFailureReasonKind,
|
|
17870
|
+
didDeadCodeFail: input.payload.didDeadCodeFail
|
|
17502
17871
|
});
|
|
17503
|
-
recordRunEvent(rootSentrySpan, {
|
|
17504
|
-
...buildRunEventConfig(options, userConfig,
|
|
17872
|
+
recordRunEvent(input.rootSentrySpan, {
|
|
17873
|
+
...buildRunEventConfig(input.options, input.userConfig, input.hasCustomConfig),
|
|
17505
17874
|
result,
|
|
17506
|
-
mode: scanMode,
|
|
17507
|
-
gateExempt: baselineDegraded,
|
|
17508
|
-
didLintFail,
|
|
17509
|
-
lintFailureReasonKind:
|
|
17510
|
-
lintPartialFailureCount:
|
|
17511
|
-
didDeadCodeFail:
|
|
17875
|
+
mode: input.scanMode,
|
|
17876
|
+
gateExempt: input.baselineDegraded,
|
|
17877
|
+
didLintFail: input.payload.didLintFail,
|
|
17878
|
+
lintFailureReasonKind: input.payload.lintFailureReasonKind,
|
|
17879
|
+
lintPartialFailureCount: input.payload.lintPartialFailures.length,
|
|
17880
|
+
didDeadCodeFail: input.payload.didDeadCodeFail
|
|
17512
17881
|
});
|
|
17513
17882
|
return result;
|
|
17514
17883
|
};
|
|
@@ -17544,14 +17913,16 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17544
17913
|
const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
|
|
17545
17914
|
const pause = onboardingSectionPause(animateRender);
|
|
17546
17915
|
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
17916
|
+
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
17547
17917
|
const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
|
|
17548
17918
|
const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
|
|
17549
|
-
if (
|
|
17919
|
+
if (printedDiagnostics.length === 0) {
|
|
17550
17920
|
yield* pause;
|
|
17551
17921
|
if (hasSkippedChecks) {
|
|
17552
17922
|
const skippedLabel = skippedChecks.join(" and ");
|
|
17553
17923
|
yield* Console.warn(highlighter.warn(`No issues detected, but ${skippedLabel} checks failed — results are incomplete.`));
|
|
17554
|
-
} else if (
|
|
17924
|
+
} else if (options.categoryFilters.size > 0) yield* Console.log(highlighter.success(`No issues found in category ${formatCategorySelection(options.categoryFilters)}!`));
|
|
17925
|
+
else if (demotedDiagnosticCount > 0) yield* Console.log(highlighter.success(`No issues found! (${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface — see config.surfaces.)`));
|
|
17555
17926
|
else yield* Console.log(highlighter.success("No issues found!"));
|
|
17556
17927
|
yield* Console.log("");
|
|
17557
17928
|
yield* pause;
|
|
@@ -17564,20 +17935,20 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17564
17935
|
}
|
|
17565
17936
|
yield* pause;
|
|
17566
17937
|
yield* Console.log("");
|
|
17567
|
-
yield* printDiagnostics([...
|
|
17938
|
+
yield* printDiagnostics([...printedDiagnostics], options.verbose, directory, buildRulePriorityMap([score]), isCodingAgentEnvironment(), {
|
|
17568
17939
|
sectionPause: pause,
|
|
17569
17940
|
animateCountUp: animateRender
|
|
17570
17941
|
});
|
|
17571
17942
|
if (options.isNonInteractiveEnvironment && options.outputSurface !== "prComment") yield* printAgentGuidance();
|
|
17572
|
-
if (demotedDiagnosticCount > 0) {
|
|
17943
|
+
if (options.categoryFilters.size === 0 && demotedDiagnosticCount > 0) {
|
|
17573
17944
|
yield* Console.log(highlighter.gray(` ${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface (e.g. design cleanup) — run \`npx react-doctor@latest .\` locally for the full list.`));
|
|
17574
17945
|
yield* Console.log("");
|
|
17575
17946
|
}
|
|
17576
|
-
const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...
|
|
17947
|
+
const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...printedDiagnostics], [...surfaceDiagnostics], score)) : null;
|
|
17577
17948
|
const shouldShowShareLink = !options.noScore && options.share && !options.isCi;
|
|
17578
17949
|
yield* pause;
|
|
17579
17950
|
yield* printSummary({
|
|
17580
|
-
diagnostics: [...
|
|
17951
|
+
diagnostics: [...printedDiagnostics],
|
|
17581
17952
|
elapsedMilliseconds,
|
|
17582
17953
|
scoreResult: score,
|
|
17583
17954
|
potentialScore,
|
|
@@ -17593,7 +17964,7 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17593
17964
|
}
|
|
17594
17965
|
yield* pause;
|
|
17595
17966
|
yield* printFooter({
|
|
17596
|
-
diagnostics: [...
|
|
17967
|
+
diagnostics: [...printedDiagnostics],
|
|
17597
17968
|
scoreResult: score,
|
|
17598
17969
|
projectName: project.projectName,
|
|
17599
17970
|
isOffline: !shouldShowShareLink
|
|
@@ -17724,21 +18095,6 @@ const handleUserError = (error, options = {}) => {
|
|
|
17724
18095
|
process.exitCode = 1;
|
|
17725
18096
|
};
|
|
17726
18097
|
//#endregion
|
|
17727
|
-
//#region src/cli/utils/cli-input-error.ts
|
|
17728
|
-
/**
|
|
17729
|
-
* A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
|
|
17730
|
-
* argument, mutually exclusive flags, or an unknown `--project` name. This is
|
|
17731
|
-
* user input, not a react-doctor bug, so `isExpectedUserError` routes it
|
|
17732
|
-
* through `handleUserError`: a clean, single-line message with no Sentry
|
|
17733
|
-
* report and no "Something went wrong, open a prefilled issue" block.
|
|
17734
|
-
*
|
|
17735
|
-
* The `message` is rendered verbatim, so it must read as a complete,
|
|
17736
|
-
* human-readable sentence that tells the user how to fix their invocation.
|
|
17737
|
-
*/
|
|
17738
|
-
var CliInputError = class extends Error {
|
|
17739
|
-
name = "CliInputError";
|
|
17740
|
-
};
|
|
17741
|
-
//#endregion
|
|
17742
18098
|
//#region src/cli/utils/is-expected-user-error.ts
|
|
17743
18099
|
/**
|
|
17744
18100
|
* Whether `error` is an expected, user-actionable failure — the user's project
|
|
@@ -19927,8 +20283,9 @@ const findLowestScoredScan = (completedScans) => {
|
|
|
19927
20283
|
};
|
|
19928
20284
|
const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
19929
20285
|
const { completedScans, userConfig, verbose, isOffline, projectName } = input;
|
|
20286
|
+
const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
|
|
19930
20287
|
const animateRender = !verbose && canAnimateOnboarding(process.stdout);
|
|
19931
|
-
const
|
|
20288
|
+
const displayDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(completedScans.flatMap((scan) => scan.result.diagnostics), "cli", userConfig), categoryFilters);
|
|
19932
20289
|
const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
|
|
19933
20290
|
for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
|
|
19934
20291
|
const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
|
|
@@ -19942,29 +20299,30 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
|
19942
20299
|
const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
|
|
19943
20300
|
const totalScanElapsedMilliseconds = completedScans.reduce((sum, scan) => sum + (scan.result.scanElapsedMilliseconds ?? scan.result.elapsedMilliseconds), 0);
|
|
19944
20301
|
yield* Console.log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalScanElapsedMilliseconds)}`);
|
|
19945
|
-
if (
|
|
20302
|
+
if (displayDiagnostics.length > 0) {
|
|
19946
20303
|
yield* Console.log("");
|
|
19947
|
-
yield* printDiagnostics(
|
|
20304
|
+
yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
|
|
19948
20305
|
}
|
|
19949
20306
|
const lowestScoredScan = findLowestScoredScan(completedScans);
|
|
19950
20307
|
const aggregateScore = lowestScoredScan?.result.score ?? null;
|
|
19951
20308
|
const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
|
|
19952
20309
|
yield* printSummary({
|
|
19953
|
-
diagnostics:
|
|
20310
|
+
diagnostics: displayDiagnostics,
|
|
19954
20311
|
elapsedMilliseconds: completedScans.reduce((sum, scan) => sum + scan.result.elapsedMilliseconds, 0),
|
|
19955
20312
|
scoreResult: aggregateScore,
|
|
19956
|
-
potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(
|
|
20313
|
+
potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(displayDiagnostics, filterDiagnosticsForSurface(lowestScoredScan.result.diagnostics, "cli", userConfig), lowestScoredScan.result.score)) : null,
|
|
19957
20314
|
totalSourceFileCount,
|
|
19958
20315
|
noScoreMessage: "Score unavailable.",
|
|
19959
20316
|
verbose,
|
|
19960
20317
|
animateProjection: animateRender
|
|
19961
20318
|
});
|
|
19962
20319
|
const entries = completedScans.map((scan) => {
|
|
19963
|
-
const
|
|
20320
|
+
const projectDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface([...scan.result.diagnostics], "cli", userConfig), categoryFilters);
|
|
20321
|
+
const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
19964
20322
|
return {
|
|
19965
20323
|
projectName: scan.result.project.projectName,
|
|
19966
20324
|
score: scan.result.score?.score ?? null,
|
|
19967
|
-
issueCount:
|
|
20325
|
+
issueCount: projectDiagnostics.length,
|
|
19968
20326
|
errorCount
|
|
19969
20327
|
};
|
|
19970
20328
|
});
|
|
@@ -19972,7 +20330,7 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
|
19972
20330
|
yield* Console.log("");
|
|
19973
20331
|
for (const entry of entries) yield* Console.log(buildSummaryLine(entry, longestProjectNameLength));
|
|
19974
20332
|
yield* printFooter({
|
|
19975
|
-
diagnostics:
|
|
20333
|
+
diagnostics: displayDiagnostics,
|
|
19976
20334
|
scoreResult: aggregateScore,
|
|
19977
20335
|
projectName,
|
|
19978
20336
|
isOffline
|
|
@@ -20062,7 +20420,8 @@ const resolveCliInspectOptions = (flags, userConfig) => {
|
|
|
20062
20420
|
noScore: flags.score === false || flags.telemetry === false || (userConfig?.noScore ?? false),
|
|
20063
20421
|
isCi: isCiEnvironment(),
|
|
20064
20422
|
silent: Boolean(flags.json),
|
|
20065
|
-
concurrency: resolveParallelFlag(flags.parallel)
|
|
20423
|
+
concurrency: resolveParallelFlag(flags.parallel),
|
|
20424
|
+
categoryFilters: resolveCliCategories(flags.category)
|
|
20066
20425
|
};
|
|
20067
20426
|
};
|
|
20068
20427
|
//#endregion
|
|
@@ -20315,6 +20674,16 @@ const validateModeFlags = (flags) => {
|
|
|
20315
20674
|
};
|
|
20316
20675
|
//#endregion
|
|
20317
20676
|
//#region src/cli/commands/inspect.ts
|
|
20677
|
+
const filterCompletedScansByCategories = (completedScans, categoryFilters) => {
|
|
20678
|
+
if (categoryFilters.size === 0) return [...completedScans];
|
|
20679
|
+
return completedScans.map((scan) => ({
|
|
20680
|
+
...scan,
|
|
20681
|
+
result: {
|
|
20682
|
+
...scan.result,
|
|
20683
|
+
diagnostics: filterDiagnosticsByCategories(scan.result.diagnostics, categoryFilters)
|
|
20684
|
+
}
|
|
20685
|
+
}));
|
|
20686
|
+
};
|
|
20318
20687
|
/**
|
|
20319
20688
|
* Post-scan finalization shared by the staged-arm and project-loop
|
|
20320
20689
|
* paths of `inspectAction`: emit the JSON report (when in JSON mode)
|
|
@@ -20327,6 +20696,7 @@ const finalizeScans = (input) => {
|
|
|
20327
20696
|
const baselineComputed = input.completedScans.length > 0 && input.completedScans.every((scan) => scan.result.baselineDelta !== void 0);
|
|
20328
20697
|
const baselineDegraded = input.baselineIntended && !baselineComputed;
|
|
20329
20698
|
const mode = baselineDegraded ? "diff" : input.mode;
|
|
20699
|
+
const jsonCompletedScans = filterCompletedScansByCategories(input.completedScans, input.categoryFilters);
|
|
20330
20700
|
if (input.isJsonMode) {
|
|
20331
20701
|
const baseline = baselineComputed && baselineDeltas.length > 0 ? {
|
|
20332
20702
|
baseRef: baselineDeltas[0].baseRef,
|
|
@@ -20338,7 +20708,7 @@ const finalizeScans = (input) => {
|
|
|
20338
20708
|
directory: input.resolvedDirectory,
|
|
20339
20709
|
mode,
|
|
20340
20710
|
diff: input.diff,
|
|
20341
|
-
scans:
|
|
20711
|
+
scans: jsonCompletedScans,
|
|
20342
20712
|
totalElapsedMilliseconds: performance.now() - input.startTime,
|
|
20343
20713
|
baseline
|
|
20344
20714
|
}));
|
|
@@ -20412,6 +20782,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20412
20782
|
await Effect.runPromise(playWelcomeScene({ speedMultiplier: isReturningUser ? 2 : 1 }));
|
|
20413
20783
|
} else Effect.runSync(printBrandedHeader);
|
|
20414
20784
|
const scanOptions = resolveCliInspectOptions(flags, userConfig);
|
|
20785
|
+
const categoryFilters = new Set(scanOptions.categoryFilters ?? []);
|
|
20415
20786
|
const skipPrompts = shouldSkipPrompts({
|
|
20416
20787
|
yes: flags.yes,
|
|
20417
20788
|
json: flags.json
|
|
@@ -20472,6 +20843,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20472
20843
|
isJsonMode,
|
|
20473
20844
|
isScoreOnly,
|
|
20474
20845
|
flags,
|
|
20846
|
+
categoryFilters,
|
|
20475
20847
|
userConfig,
|
|
20476
20848
|
resolvedDirectory,
|
|
20477
20849
|
startTime
|
|
@@ -20531,6 +20903,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20531
20903
|
const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
|
|
20532
20904
|
await Effect.runPromise(printMultiProjectSummary({
|
|
20533
20905
|
completedScans,
|
|
20906
|
+
categoryFilters,
|
|
20534
20907
|
userConfig,
|
|
20535
20908
|
verbose: Boolean(flags.verbose),
|
|
20536
20909
|
isOffline: !shouldShowShareLink,
|
|
@@ -20546,14 +20919,15 @@ const inspectAction = async (directory, flags) => {
|
|
|
20546
20919
|
isJsonMode,
|
|
20547
20920
|
isScoreOnly,
|
|
20548
20921
|
flags,
|
|
20922
|
+
categoryFilters,
|
|
20549
20923
|
userConfig,
|
|
20550
20924
|
resolvedDirectory,
|
|
20551
20925
|
startTime
|
|
20552
20926
|
});
|
|
20553
|
-
const
|
|
20554
|
-
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() &&
|
|
20927
|
+
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
|
|
20928
|
+
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
|
|
20555
20929
|
await handoffToAgent({
|
|
20556
|
-
diagnostics:
|
|
20930
|
+
diagnostics: selectedSurfaceDiagnostics,
|
|
20557
20931
|
projectName: path$1.basename(resolvedDirectory),
|
|
20558
20932
|
rootDirectory: resolvedDirectory,
|
|
20559
20933
|
interactive: true
|
|
@@ -20984,7 +21358,7 @@ const rulesListAction = async (options) => {
|
|
|
20984
21358
|
});
|
|
20985
21359
|
const catalog = buildRuleCatalog();
|
|
20986
21360
|
const config = validateConfigTypes((await resolveRuleConfigTarget(resolveProjectRoot(options))).config);
|
|
20987
|
-
const categoryFilter = options.category
|
|
21361
|
+
const categoryFilter = typeof options.category === "string" ? options.category.toLowerCase() : void 0;
|
|
20988
21362
|
const frameworkFilter = options.framework?.toLowerCase();
|
|
20989
21363
|
const rows = catalog.filter((entry) => {
|
|
20990
21364
|
if (categoryFilter && entry.category.toLowerCase() !== categoryFilter) return false;
|
|
@@ -21347,6 +21721,7 @@ const ROOT_FLAG_SPEC = {
|
|
|
21347
21721
|
"--yes"
|
|
21348
21722
|
]),
|
|
21349
21723
|
longOptionsWithRequiredValues: new Set([
|
|
21724
|
+
"--category",
|
|
21350
21725
|
"--changed-files-from",
|
|
21351
21726
|
"--blocking",
|
|
21352
21727
|
"--fail-on",
|
|
@@ -21503,6 +21878,7 @@ ${formatExampleLines([
|
|
|
21503
21878
|
["react-doctor ./apps/web", "scan a specific directory"],
|
|
21504
21879
|
["react-doctor --diff main", "scan only files changed vs. main"],
|
|
21505
21880
|
["react-doctor --staged", "scan staged files (pre-commit hook)"],
|
|
21881
|
+
["react-doctor --category Security", "show only one diagnostic category"],
|
|
21506
21882
|
["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
|
|
21507
21883
|
["react-doctor --json > report.json", "write a machine-readable report"],
|
|
21508
21884
|
["react-doctor why src/App.tsx:42", "explain why a rule fired there"],
|
|
@@ -21531,7 +21907,8 @@ ${formatExampleLines([
|
|
|
21531
21907
|
${highlighter.dim("Learn more:")}
|
|
21532
21908
|
${highlighter.info(CANONICAL_GITHUB_URL)}
|
|
21533
21909
|
`;
|
|
21534
|
-
const
|
|
21910
|
+
const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
|
|
21911
|
+
const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--diff [base]", "scan only files changed vs base branch (pass `false` to force a full scan, overriding config)").addOption(new Option$1("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option$1("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option$1("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
|
|
21535
21912
|
program.action(inspectAction);
|
|
21536
21913
|
program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select workspace project (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
|
|
21537
21914
|
program.command("install").alias("setup").description("Install the react-doctor skill into your coding agents and optional git hook").option("-y, --yes", "skip prompts, install for all detected agents").option("--dry-run", "show what would be installed without writing files").option("--agent-hooks", "install native non-blocking agent hooks for Claude Code and Cursor").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderInstallHelpEpilog).action(installAction);
|
|
@@ -21574,4 +21951,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
21574
21951
|
export {};
|
|
21575
21952
|
|
|
21576
21953
|
//# sourceMappingURL=cli.js.map
|
|
21577
|
-
//# debugId=
|
|
21954
|
+
//# debugId=59fe9fce-f831-56a0-b6b2-b014bd09d533
|