react-doctor 0.4.2-dev.772385f → 0.4.2-dev.773e235
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 +485 -115
- package/dist/index.js +30 -29
- package/dist/lsp.js +74 -77
- package/package.json +2 -2
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]="e5634721-88db-51c8-93e5-137793125d7a")}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,
|
|
@@ -9008,7 +9032,7 @@ const checkDeadCode = async (options) => {
|
|
|
9008
9032
|
plugin: DEAD_CODE_PLUGIN,
|
|
9009
9033
|
rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
|
|
9010
9034
|
severity: "warning",
|
|
9011
|
-
message: `Unused ${label}: \`${unusedDependency.name}
|
|
9035
|
+
message: `Unused ${label}: \`${unusedDependency.name}\` is not imported by the project, so it adds install time and supply-chain surface without being used.`,
|
|
9012
9036
|
help: "Remove the dependency from package.json if it is genuinely unused.",
|
|
9013
9037
|
line: 0,
|
|
9014
9038
|
column: 0,
|
|
@@ -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.773e235";
|
|
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.773e235`;
|
|
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.773e235") ? "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
|
|
@@ -16669,7 +16710,7 @@ const buildRuleDetailBlock = (ruleKey, ruleDiagnostics, resolveSourceRoot, rende
|
|
|
16669
16710
|
const learnMoreLine = formatLearnMoreLine(representative);
|
|
16670
16711
|
if (learnMoreLine) lines.push(`${TOP_ERROR_DETAIL_INDENT}${highlighter.info(learnMoreLine)}`);
|
|
16671
16712
|
}
|
|
16672
|
-
|
|
16713
|
+
for (const explanationLine of wrapTextToWidth(representative.message, resolveMeasureWidth(4), { breakLongWords: false })) lines.push(`${TOP_ERROR_DETAIL_INDENT}${explanationLine}`);
|
|
16673
16714
|
if (representative.help) for (const fixLine of wrapTextToWidth(`→ ${representative.help}`, resolveMeasureWidth(4), { breakLongWords: false })) lines.push(highlighter.dim(`${TOP_ERROR_DETAIL_INDENT}${fixLine}`));
|
|
16674
16715
|
if (renderEverySite && isAgentEnvironment) {
|
|
16675
16716
|
const fixRecipeLine = formatFixRecipeLine(representative);
|
|
@@ -16806,6 +16847,9 @@ const computeProjectedScore = async (topErrorSource, rescoreSource, currentScore
|
|
|
16806
16847
|
if (!potentialScore || potentialScore.score <= currentScore.score) return null;
|
|
16807
16848
|
return potentialScore.score;
|
|
16808
16849
|
};
|
|
16850
|
+
//#endregion
|
|
16851
|
+
//#region src/cli/utils/filter-diagnostics-by-categories.ts
|
|
16852
|
+
const filterDiagnosticsByCategories = (diagnostics, categories) => categories.size === 0 ? [...diagnostics] : diagnostics.filter((diagnostic) => categories.has(diagnostic.category));
|
|
16809
16853
|
const FORCE_ONBOARDING_ENV_VAR = "REACT_DOCTOR_FORCE_ONBOARDING";
|
|
16810
16854
|
const FALSY_FLAG_VALUES = new Set([
|
|
16811
16855
|
"",
|
|
@@ -17236,11 +17280,259 @@ const resolveOxlintNodeEffect = (isLintEnabled, isQuiet) => Effect.gen(function*
|
|
|
17236
17280
|
});
|
|
17237
17281
|
const resolveOxlintNode = (isLintEnabled, isQuiet) => Effect.runPromise(resolveOxlintNodeEffect(isLintEnabled, isQuiet).pipe(Effect.provide(NodeResolver.layerNode)));
|
|
17238
17282
|
//#endregion
|
|
17283
|
+
//#region src/cli/utils/cli-input-error.ts
|
|
17284
|
+
/**
|
|
17285
|
+
* A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
|
|
17286
|
+
* argument, mutually exclusive flags, or an unknown `--project` name. This is
|
|
17287
|
+
* user input, not a react-doctor bug, so `isExpectedUserError` routes it
|
|
17288
|
+
* through `handleUserError`: a clean, single-line message with no Sentry
|
|
17289
|
+
* report and no "Something went wrong, open a prefilled issue" block.
|
|
17290
|
+
*
|
|
17291
|
+
* The `message` is rendered verbatim, so it must read as a complete,
|
|
17292
|
+
* human-readable sentence that tells the user how to fix their invocation.
|
|
17293
|
+
*/
|
|
17294
|
+
var CliInputError = class extends Error {
|
|
17295
|
+
name = "CliInputError";
|
|
17296
|
+
};
|
|
17297
|
+
//#endregion
|
|
17298
|
+
//#region src/cli/utils/resolve-cli-categories.ts
|
|
17299
|
+
const categoryByLowercase = new Map(DIAGNOSTIC_CATEGORY_BUCKETS.map((category) => [category.toLowerCase(), category]));
|
|
17300
|
+
const knownCategoryList = DIAGNOSTIC_CATEGORY_BUCKETS.join(", ");
|
|
17301
|
+
const splitCategoryFlagValue = (value) => value.split(",").map((category) => category.trim()).filter((category) => category.length > 0);
|
|
17302
|
+
const resolveCliCategories = (categoryFlag) => {
|
|
17303
|
+
const rawCategoryValues = categoryFlag === void 0 ? [] : Array.isArray(categoryFlag) ? categoryFlag : [categoryFlag];
|
|
17304
|
+
const resolvedCategories = [];
|
|
17305
|
+
const seenCategories = /* @__PURE__ */ new Set();
|
|
17306
|
+
for (const rawCategoryValue of rawCategoryValues) for (const categoryQuery of splitCategoryFlagValue(rawCategoryValue)) {
|
|
17307
|
+
const matchedCategory = categoryByLowercase.get(categoryQuery.toLowerCase());
|
|
17308
|
+
if (matchedCategory === void 0) throw new CliInputError(`Unknown category "${categoryQuery}". Expected one of: ${knownCategoryList}.`);
|
|
17309
|
+
if (!seenCategories.has(matchedCategory)) {
|
|
17310
|
+
seenCategories.add(matchedCategory);
|
|
17311
|
+
resolvedCategories.push(matchedCategory);
|
|
17312
|
+
}
|
|
17313
|
+
}
|
|
17314
|
+
if (rawCategoryValues.length > 0 && resolvedCategories.length === 0) throw new CliInputError(`--category requires one of: ${knownCategoryList}.`);
|
|
17315
|
+
return resolvedCategories.length > 0 ? resolvedCategories : void 0;
|
|
17316
|
+
};
|
|
17317
|
+
//#endregion
|
|
17318
|
+
//#region src/cli/utils/scan-result-cache.ts
|
|
17319
|
+
const CACHE_DISABLED_VALUES = new Set(["1", "true"]);
|
|
17320
|
+
const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
17321
|
+
"oxlint",
|
|
17322
|
+
"oxlint/package.json",
|
|
17323
|
+
"oxlint-plugin-react-doctor",
|
|
17324
|
+
"deslop-js/package.json",
|
|
17325
|
+
"eslint-plugin-react-hooks/package.json"
|
|
17326
|
+
];
|
|
17327
|
+
const bundledRequire = createRequire(import.meta.url);
|
|
17328
|
+
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17329
|
+
const normalizeForStableJson = (value) => {
|
|
17330
|
+
if (value === null) return null;
|
|
17331
|
+
if (value === void 0) return void 0;
|
|
17332
|
+
const valueType = typeof value;
|
|
17333
|
+
if (valueType === "string" || valueType === "number" || valueType === "boolean") return value;
|
|
17334
|
+
if (valueType === "bigint" || valueType === "function" || valueType === "symbol") throw new Error("Unsupported cache key value");
|
|
17335
|
+
if (Array.isArray(value)) return value.map((item) => {
|
|
17336
|
+
const normalized = normalizeForStableJson(item);
|
|
17337
|
+
return normalized === void 0 ? null : normalized;
|
|
17338
|
+
});
|
|
17339
|
+
const prototype = Object.getPrototypeOf(value);
|
|
17340
|
+
if (prototype !== Object.prototype && prototype !== null) throw new Error("Unsupported cache key object");
|
|
17341
|
+
const record = value;
|
|
17342
|
+
const normalizedRecord = {};
|
|
17343
|
+
for (const key of Object.keys(record).sort()) {
|
|
17344
|
+
const normalized = normalizeForStableJson(record[key]);
|
|
17345
|
+
if (normalized !== void 0) normalizedRecord[key] = normalized;
|
|
17346
|
+
}
|
|
17347
|
+
return normalizedRecord;
|
|
17348
|
+
};
|
|
17349
|
+
const stringifyStableJson = (value) => {
|
|
17350
|
+
try {
|
|
17351
|
+
return JSON.stringify(normalizeForStableJson(value));
|
|
17352
|
+
} catch {
|
|
17353
|
+
return null;
|
|
17354
|
+
}
|
|
17355
|
+
};
|
|
17356
|
+
const hashString = (value) => crypto.createHash("sha1").update(value).digest("hex");
|
|
17357
|
+
const runGit$1 = (directory, args) => {
|
|
17358
|
+
try {
|
|
17359
|
+
return execFileSync("git", [...args], {
|
|
17360
|
+
cwd: directory,
|
|
17361
|
+
encoding: "utf8",
|
|
17362
|
+
stdio: [
|
|
17363
|
+
"ignore",
|
|
17364
|
+
"pipe",
|
|
17365
|
+
"ignore"
|
|
17366
|
+
]
|
|
17367
|
+
}).trim();
|
|
17368
|
+
} catch {
|
|
17369
|
+
return null;
|
|
17370
|
+
}
|
|
17371
|
+
};
|
|
17372
|
+
const readHeadSha = (projectDirectory) => runGit$1(projectDirectory, ["rev-parse", "HEAD"]);
|
|
17373
|
+
const isWorktreeClean = (projectDirectory) => {
|
|
17374
|
+
const status = runGit$1(projectDirectory, [
|
|
17375
|
+
"status",
|
|
17376
|
+
"--porcelain=v1",
|
|
17377
|
+
"--untracked-files=normal"
|
|
17378
|
+
]);
|
|
17379
|
+
return status !== null && status.length === 0;
|
|
17380
|
+
};
|
|
17381
|
+
const hasHiddenTrackedFileState = (projectDirectory) => {
|
|
17382
|
+
const output = runGit$1(projectDirectory, ["ls-files", "-v"]);
|
|
17383
|
+
if (output === null) return true;
|
|
17384
|
+
return output.split("\n").some((line) => line.length > 0 && line[0] !== "H");
|
|
17385
|
+
};
|
|
17386
|
+
const resolveCacheFilePath = (projectDirectory) => {
|
|
17387
|
+
const nodeModulesDirectory = path.join(projectDirectory, "node_modules");
|
|
17388
|
+
if (fs.existsSync(nodeModulesDirectory)) return path.join(nodeModulesDirectory, ".cache", "react-doctor", "scan-cache.json");
|
|
17389
|
+
const projectHash = hashString(projectDirectory).slice(0, 16);
|
|
17390
|
+
return path.join(os.tmpdir(), "react-doctor-cache", `scan-${projectHash}.json`);
|
|
17391
|
+
};
|
|
17392
|
+
const readPersistedCache = (cacheFilePath) => {
|
|
17393
|
+
try {
|
|
17394
|
+
const parsed = JSON.parse(fs.readFileSync(cacheFilePath, "utf8"));
|
|
17395
|
+
if (!isRecord$1(parsed) || parsed.version !== 1) return {
|
|
17396
|
+
version: 1,
|
|
17397
|
+
entries: []
|
|
17398
|
+
};
|
|
17399
|
+
if (!Array.isArray(parsed.entries)) return {
|
|
17400
|
+
version: 1,
|
|
17401
|
+
entries: []
|
|
17402
|
+
};
|
|
17403
|
+
const entries = [];
|
|
17404
|
+
for (const entry of parsed.entries) {
|
|
17405
|
+
if (!isRecord$1(entry) || typeof entry.key !== "string" || typeof entry.createdAtMs !== "number") continue;
|
|
17406
|
+
if (!isRecord$1(entry.payload) || !Array.isArray(entry.payload.diagnostics)) continue;
|
|
17407
|
+
entries.push(entry);
|
|
17408
|
+
}
|
|
17409
|
+
return {
|
|
17410
|
+
version: 1,
|
|
17411
|
+
entries
|
|
17412
|
+
};
|
|
17413
|
+
} catch {
|
|
17414
|
+
return {
|
|
17415
|
+
version: 1,
|
|
17416
|
+
entries: []
|
|
17417
|
+
};
|
|
17418
|
+
}
|
|
17419
|
+
};
|
|
17420
|
+
const writePersistedCache = (cacheFilePath, cache) => {
|
|
17421
|
+
try {
|
|
17422
|
+
fs.mkdirSync(path.dirname(cacheFilePath), { recursive: true });
|
|
17423
|
+
const tempPath = `${cacheFilePath}.${process.pid}.tmp`;
|
|
17424
|
+
fs.writeFileSync(tempPath, JSON.stringify(cache));
|
|
17425
|
+
fs.renameSync(tempPath, cacheFilePath);
|
|
17426
|
+
} catch {
|
|
17427
|
+
return;
|
|
17428
|
+
}
|
|
17429
|
+
};
|
|
17430
|
+
const isScanResultCacheDisabled = () => CACHE_DISABLED_VALUES.has(process.env.REACT_DOCTOR_NO_CACHE?.toLowerCase() ?? "");
|
|
17431
|
+
const resolveProjectIdentity = (projectDirectory) => {
|
|
17432
|
+
try {
|
|
17433
|
+
return fs.realpathSync.native(projectDirectory);
|
|
17434
|
+
} catch {
|
|
17435
|
+
return path.resolve(projectDirectory);
|
|
17436
|
+
}
|
|
17437
|
+
};
|
|
17438
|
+
const fileFingerprint = (filePath) => {
|
|
17439
|
+
try {
|
|
17440
|
+
const stat = fs.statSync(filePath);
|
|
17441
|
+
return `${filePath}:${stat.mtimeMs}:${stat.size}`;
|
|
17442
|
+
} catch {
|
|
17443
|
+
return null;
|
|
17444
|
+
}
|
|
17445
|
+
};
|
|
17446
|
+
const resolveToolchainFingerprint = (nodeBinaryPath) => {
|
|
17447
|
+
const fingerprints = [];
|
|
17448
|
+
if (nodeBinaryPath !== null) {
|
|
17449
|
+
const fingerprint = fileFingerprint(nodeBinaryPath);
|
|
17450
|
+
if (fingerprint !== null) fingerprints.push(`node=${fingerprint}`);
|
|
17451
|
+
}
|
|
17452
|
+
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
17453
|
+
const fingerprint = fileFingerprint(bundledRequire.resolve(specifier));
|
|
17454
|
+
if (fingerprint !== null) fingerprints.push(`${specifier}=${fingerprint}`);
|
|
17455
|
+
} catch {
|
|
17456
|
+
continue;
|
|
17457
|
+
}
|
|
17458
|
+
return fingerprints;
|
|
17459
|
+
};
|
|
17460
|
+
const buildScanResultCacheKey = (input) => {
|
|
17461
|
+
if (isScanResultCacheDisabled()) return null;
|
|
17462
|
+
if (!isWorktreeClean(input.projectDirectory)) return null;
|
|
17463
|
+
if (hasHiddenTrackedFileState(input.projectDirectory)) return null;
|
|
17464
|
+
const headSha = readHeadSha(input.projectDirectory);
|
|
17465
|
+
if (headSha === null) return null;
|
|
17466
|
+
if (stringifyStableJson(input.userConfig) === null) return null;
|
|
17467
|
+
const cacheKeyJson = stringifyStableJson({
|
|
17468
|
+
schemaVersion: 1,
|
|
17469
|
+
projectIdentity: resolveProjectIdentity(input.projectDirectory),
|
|
17470
|
+
headSha,
|
|
17471
|
+
reactDoctorVersion: input.version,
|
|
17472
|
+
nodeVersion: process.version,
|
|
17473
|
+
toolchainFingerprint: resolveToolchainFingerprint(input.nodeBinaryPath),
|
|
17474
|
+
configFingerprint: computeConfigFingerprint(input.projectDirectory, input.version),
|
|
17475
|
+
hasConfigOverride: input.hasConfigOverride,
|
|
17476
|
+
configSourceDirectory: input.configSourceDirectory,
|
|
17477
|
+
userConfig: input.userConfig,
|
|
17478
|
+
engineOptions: {
|
|
17479
|
+
lint: input.options.lint,
|
|
17480
|
+
deadCode: input.options.deadCode,
|
|
17481
|
+
includePaths: [...input.options.includePaths].sort(),
|
|
17482
|
+
customRulesOnly: input.options.customRulesOnly,
|
|
17483
|
+
respectInlineDisables: input.options.respectInlineDisables,
|
|
17484
|
+
warnings: input.options.warnings,
|
|
17485
|
+
adoptExistingLintConfig: input.options.adoptExistingLintConfig,
|
|
17486
|
+
ignoredTags: [...input.options.ignoredTags].sort(),
|
|
17487
|
+
concurrency: input.options.concurrency,
|
|
17488
|
+
baselineRef: input.options.baseline?.ref,
|
|
17489
|
+
noScore: input.options.noScore,
|
|
17490
|
+
isCi: input.options.isCi,
|
|
17491
|
+
suppressRendering: input.options.suppressRendering
|
|
17492
|
+
}
|
|
17493
|
+
});
|
|
17494
|
+
return cacheKeyJson === null ? null : hashString(cacheKeyJson);
|
|
17495
|
+
};
|
|
17496
|
+
const createScanResultCache = (projectDirectory) => {
|
|
17497
|
+
const cacheFilePath = resolveCacheFilePath(projectDirectory);
|
|
17498
|
+
const persistedCache = readPersistedCache(cacheFilePath);
|
|
17499
|
+
const entries = /* @__PURE__ */ new Map();
|
|
17500
|
+
for (const entry of persistedCache.entries) entries.set(entry.key, entry);
|
|
17501
|
+
const persist = () => {
|
|
17502
|
+
writePersistedCache(cacheFilePath, {
|
|
17503
|
+
version: 1,
|
|
17504
|
+
entries: [...entries.values()].sort((firstEntry, secondEntry) => secondEntry.createdAtMs - firstEntry.createdAtMs).slice(0, 20)
|
|
17505
|
+
});
|
|
17506
|
+
};
|
|
17507
|
+
return {
|
|
17508
|
+
lookup: (key) => entries.get(key)?.payload ?? null,
|
|
17509
|
+
store: (key, payload) => {
|
|
17510
|
+
entries.set(key, {
|
|
17511
|
+
key,
|
|
17512
|
+
createdAtMs: Date.now(),
|
|
17513
|
+
payload
|
|
17514
|
+
});
|
|
17515
|
+
persist();
|
|
17516
|
+
}
|
|
17517
|
+
};
|
|
17518
|
+
};
|
|
17519
|
+
const shouldStoreScanPayload = (payload) => !payload.didLintFail && !payload.didDeadCodeFail && payload.lintPartialFailures.length === 0;
|
|
17520
|
+
//#endregion
|
|
17239
17521
|
//#region src/inspect.ts
|
|
17240
17522
|
const silentConsole = makeNoopConsole();
|
|
17241
17523
|
const runConsole = (effect) => {
|
|
17242
17524
|
Effect.runSync(effect);
|
|
17243
17525
|
};
|
|
17526
|
+
const recordOnboardingCompletion = (options) => {
|
|
17527
|
+
const forceOnboarding = isOnboardingForced();
|
|
17528
|
+
if (shouldRecordOnboarding({
|
|
17529
|
+
paceOnboardingSections: !options.silent && !options.scoreOnly && !options.suppressRendering && !options.verbose && canAnimateOnboarding(process.stdout) && (forceOnboarding || !hasCompletedOnboarding()),
|
|
17530
|
+
forceOnboarding,
|
|
17531
|
+
verbose: options.verbose,
|
|
17532
|
+
isNonInteractiveEnvironment: options.isNonInteractiveEnvironment
|
|
17533
|
+
})) markOnboardingComplete();
|
|
17534
|
+
};
|
|
17535
|
+
const formatCategorySelection = (categoryFilters) => [...categoryFilters].join(", ");
|
|
17244
17536
|
const buildIgnoredTags = (userConfig) => {
|
|
17245
17537
|
const tags = /* @__PURE__ */ new Set();
|
|
17246
17538
|
if (userConfig?.ignore?.tags) for (const tag of userConfig.ignore.tags) tags.add(tag);
|
|
@@ -17261,6 +17553,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
17261
17553
|
share: userConfig?.share ?? true,
|
|
17262
17554
|
respectInlineDisables: inputOptions.respectInlineDisables ?? userConfig?.respectInlineDisables ?? true,
|
|
17263
17555
|
warnings: inputOptions.warnings ?? userConfig?.warnings ?? true,
|
|
17556
|
+
categoryFilters: new Set(resolveCliCategories(inputOptions.categoryFilters) ?? []),
|
|
17264
17557
|
adoptExistingLintConfig: userConfig?.adoptExistingLintConfig ?? true,
|
|
17265
17558
|
ignoredTags: buildIgnoredTags(userConfig),
|
|
17266
17559
|
outputSurface: inputOptions.outputSurface ?? "cli",
|
|
@@ -17347,6 +17640,7 @@ const runBaselineComparison = async (params) => {
|
|
|
17347
17640
|
hasConfigOverride: true,
|
|
17348
17641
|
userConfig: params.userConfig,
|
|
17349
17642
|
configSourceDirectory: null,
|
|
17643
|
+
projectInfoOverride: params.headProjectInfo,
|
|
17350
17644
|
shouldSkipLint: !params.options.lint || !params.resolvedNodeBinaryPath,
|
|
17351
17645
|
shouldRunDeadCode: false,
|
|
17352
17646
|
shouldComputeScore: false,
|
|
@@ -17393,6 +17687,40 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
17393
17687
|
const isDiffMode = options.includePaths.length > 0;
|
|
17394
17688
|
const resolvedNodeBinaryPath = await resolveOxlintNode(options.lint, options.scoreOnly || options.silent);
|
|
17395
17689
|
const lintBindingMissing = options.lint && !resolvedNodeBinaryPath;
|
|
17690
|
+
const cacheKey = buildScanResultCacheKey({
|
|
17691
|
+
projectDirectory: directory,
|
|
17692
|
+
version: VERSION,
|
|
17693
|
+
nodeBinaryPath: resolvedNodeBinaryPath,
|
|
17694
|
+
options,
|
|
17695
|
+
userConfig,
|
|
17696
|
+
hasConfigOverride,
|
|
17697
|
+
configSourceDirectory
|
|
17698
|
+
});
|
|
17699
|
+
const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
|
|
17700
|
+
const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
|
|
17701
|
+
if (cachedPayload) {
|
|
17702
|
+
recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
|
|
17703
|
+
recordCount(METRIC.projectDetected, 1);
|
|
17704
|
+
await renderCachedProjectDetection({
|
|
17705
|
+
payload: cachedPayload,
|
|
17706
|
+
options,
|
|
17707
|
+
userConfig,
|
|
17708
|
+
isDiffMode
|
|
17709
|
+
});
|
|
17710
|
+
const baselineDegraded = Boolean(options.baseline) && isDiffMode && cachedPayload.baselineDelta === void 0;
|
|
17711
|
+
const result = await renderAndRecordScan({
|
|
17712
|
+
payload: cachedPayload,
|
|
17713
|
+
options,
|
|
17714
|
+
userConfig,
|
|
17715
|
+
hasCustomConfig: userConfig !== null,
|
|
17716
|
+
startTime,
|
|
17717
|
+
rootSentrySpan,
|
|
17718
|
+
scanMode: cachedPayload.baselineDelta ? "baseline" : isDiffMode ? "diff" : "full",
|
|
17719
|
+
baselineDegraded
|
|
17720
|
+
});
|
|
17721
|
+
recordOnboardingCompletion(options);
|
|
17722
|
+
return result;
|
|
17723
|
+
}
|
|
17396
17724
|
const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && options.lint && Boolean(resolvedNodeBinaryPath);
|
|
17397
17725
|
const layers = buildRuntimeLayers({
|
|
17398
17726
|
directory,
|
|
@@ -17446,6 +17774,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
17446
17774
|
directory,
|
|
17447
17775
|
options,
|
|
17448
17776
|
userConfig,
|
|
17777
|
+
headProjectInfo: output.project,
|
|
17449
17778
|
headDiagnostics: output.diagnostics,
|
|
17450
17779
|
resolvedNodeBinaryPath,
|
|
17451
17780
|
baselineRef: options.baseline.ref
|
|
@@ -17457,12 +17786,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
17457
17786
|
}
|
|
17458
17787
|
const baselineDegraded = Boolean(options.baseline) && isDiffMode && baselineDelta === void 0;
|
|
17459
17788
|
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,
|
|
17789
|
+
const payload = {
|
|
17466
17790
|
diagnostics: inspectDiagnostics,
|
|
17467
17791
|
score,
|
|
17468
17792
|
project: output.project,
|
|
@@ -17476,39 +17800,77 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
17476
17800
|
scannedFileCount: output.scannedFileCount,
|
|
17477
17801
|
scannedFilePaths: output.scannedFilePaths,
|
|
17478
17802
|
scanElapsedMilliseconds: output.scanElapsedMilliseconds,
|
|
17479
|
-
baselineDelta
|
|
17803
|
+
baselineDelta,
|
|
17804
|
+
lintFailureReasonKind: lintBindingMissing ? "native-binding-missing" : output.lintFailureReasonKind
|
|
17480
17805
|
};
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17806
|
+
if (cacheKey !== null && scanResultCache !== null && shouldStoreScanPayload(payload)) scanResultCache.store(cacheKey, payload);
|
|
17807
|
+
const result = await renderAndRecordScan({
|
|
17808
|
+
payload,
|
|
17809
|
+
options,
|
|
17810
|
+
userConfig,
|
|
17811
|
+
hasCustomConfig: userConfig !== null,
|
|
17812
|
+
startTime,
|
|
17813
|
+
rootSentrySpan,
|
|
17814
|
+
scanMode: baselineDelta ? "baseline" : isDiffMode ? "diff" : "full",
|
|
17815
|
+
baselineDegraded
|
|
17816
|
+
});
|
|
17817
|
+
recordOnboardingCompletion(options);
|
|
17818
|
+
return result;
|
|
17819
|
+
};
|
|
17820
|
+
const runMaybeSilent = (effect, silent) => silent ? effect.pipe(Effect.provideService(Console.Console, silentConsole)) : effect;
|
|
17821
|
+
const renderCachedProjectDetection = async (input) => {
|
|
17822
|
+
if (input.options.scoreOnly || input.options.suppressRendering) return;
|
|
17823
|
+
await Effect.runPromise(runMaybeSilent(printProjectDetection({
|
|
17824
|
+
projectInfo: input.payload.project,
|
|
17825
|
+
userConfig: input.userConfig,
|
|
17826
|
+
isDiffMode: input.isDiffMode,
|
|
17827
|
+
includePaths: input.options.includePaths,
|
|
17828
|
+
lintSourceFileCount: input.payload.scannedFileCount
|
|
17829
|
+
}), input.options.silent));
|
|
17830
|
+
};
|
|
17831
|
+
const renderAndRecordScan = async (input) => {
|
|
17832
|
+
const finalizeInput = {
|
|
17833
|
+
options: input.options,
|
|
17834
|
+
elapsedMilliseconds: performance.now() - input.startTime,
|
|
17835
|
+
diagnostics: input.payload.diagnostics,
|
|
17836
|
+
score: input.payload.score,
|
|
17837
|
+
project: input.payload.project,
|
|
17838
|
+
userConfig: input.payload.userConfig,
|
|
17839
|
+
didLintFail: input.payload.didLintFail,
|
|
17840
|
+
lintFailureReason: input.payload.lintFailureReason,
|
|
17841
|
+
lintPartialFailures: input.payload.lintPartialFailures,
|
|
17842
|
+
didDeadCodeFail: input.payload.didDeadCodeFail,
|
|
17843
|
+
deadCodeFailureReason: input.payload.deadCodeFailureReason,
|
|
17844
|
+
directory: input.payload.directory,
|
|
17845
|
+
scannedFileCount: input.payload.scannedFileCount,
|
|
17846
|
+
scannedFilePaths: input.payload.scannedFilePaths,
|
|
17847
|
+
scanElapsedMilliseconds: input.payload.scanElapsedMilliseconds,
|
|
17848
|
+
baselineDelta: input.payload.baselineDelta
|
|
17849
|
+
};
|
|
17850
|
+
const result = await Effect.runPromise(runMaybeSilent(finalizeAndRender(finalizeInput), input.options.silent));
|
|
17489
17851
|
recordScanMetrics({
|
|
17490
17852
|
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:
|
|
17853
|
+
mode: input.scanMode,
|
|
17854
|
+
baselineDegraded: input.baselineDegraded,
|
|
17855
|
+
parallel: input.options.concurrency !== void 0,
|
|
17856
|
+
workerCount: input.options.concurrency,
|
|
17857
|
+
lint: input.options.lint,
|
|
17858
|
+
deadCode: input.options.deadCode,
|
|
17859
|
+
scoreOnly: input.options.scoreOnly,
|
|
17860
|
+
noScore: input.options.noScore,
|
|
17861
|
+
didLintFail: input.payload.didLintFail,
|
|
17862
|
+
lintFailureReasonKind: input.payload.lintFailureReasonKind,
|
|
17863
|
+
didDeadCodeFail: input.payload.didDeadCodeFail
|
|
17502
17864
|
});
|
|
17503
|
-
recordRunEvent(rootSentrySpan, {
|
|
17504
|
-
...buildRunEventConfig(options, userConfig,
|
|
17865
|
+
recordRunEvent(input.rootSentrySpan, {
|
|
17866
|
+
...buildRunEventConfig(input.options, input.userConfig, input.hasCustomConfig),
|
|
17505
17867
|
result,
|
|
17506
|
-
mode: scanMode,
|
|
17507
|
-
gateExempt: baselineDegraded,
|
|
17508
|
-
didLintFail,
|
|
17509
|
-
lintFailureReasonKind:
|
|
17510
|
-
lintPartialFailureCount:
|
|
17511
|
-
didDeadCodeFail:
|
|
17868
|
+
mode: input.scanMode,
|
|
17869
|
+
gateExempt: input.baselineDegraded,
|
|
17870
|
+
didLintFail: input.payload.didLintFail,
|
|
17871
|
+
lintFailureReasonKind: input.payload.lintFailureReasonKind,
|
|
17872
|
+
lintPartialFailureCount: input.payload.lintPartialFailures.length,
|
|
17873
|
+
didDeadCodeFail: input.payload.didDeadCodeFail
|
|
17512
17874
|
});
|
|
17513
17875
|
return result;
|
|
17514
17876
|
};
|
|
@@ -17544,14 +17906,16 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17544
17906
|
const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
|
|
17545
17907
|
const pause = onboardingSectionPause(animateRender);
|
|
17546
17908
|
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
17909
|
+
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
17547
17910
|
const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
|
|
17548
17911
|
const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
|
|
17549
|
-
if (
|
|
17912
|
+
if (printedDiagnostics.length === 0) {
|
|
17550
17913
|
yield* pause;
|
|
17551
17914
|
if (hasSkippedChecks) {
|
|
17552
17915
|
const skippedLabel = skippedChecks.join(" and ");
|
|
17553
17916
|
yield* Console.warn(highlighter.warn(`No issues detected, but ${skippedLabel} checks failed — results are incomplete.`));
|
|
17554
|
-
} else if (
|
|
17917
|
+
} else if (options.categoryFilters.size > 0) yield* Console.log(highlighter.success(`No issues found in category ${formatCategorySelection(options.categoryFilters)}!`));
|
|
17918
|
+
else if (demotedDiagnosticCount > 0) yield* Console.log(highlighter.success(`No issues found! (${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface — see config.surfaces.)`));
|
|
17555
17919
|
else yield* Console.log(highlighter.success("No issues found!"));
|
|
17556
17920
|
yield* Console.log("");
|
|
17557
17921
|
yield* pause;
|
|
@@ -17564,20 +17928,20 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17564
17928
|
}
|
|
17565
17929
|
yield* pause;
|
|
17566
17930
|
yield* Console.log("");
|
|
17567
|
-
yield* printDiagnostics([...
|
|
17931
|
+
yield* printDiagnostics([...printedDiagnostics], options.verbose, directory, buildRulePriorityMap([score]), isCodingAgentEnvironment(), {
|
|
17568
17932
|
sectionPause: pause,
|
|
17569
17933
|
animateCountUp: animateRender
|
|
17570
17934
|
});
|
|
17571
17935
|
if (options.isNonInteractiveEnvironment && options.outputSurface !== "prComment") yield* printAgentGuidance();
|
|
17572
|
-
if (demotedDiagnosticCount > 0) {
|
|
17936
|
+
if (options.categoryFilters.size === 0 && demotedDiagnosticCount > 0) {
|
|
17573
17937
|
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
17938
|
yield* Console.log("");
|
|
17575
17939
|
}
|
|
17576
|
-
const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...
|
|
17940
|
+
const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...printedDiagnostics], [...surfaceDiagnostics], score)) : null;
|
|
17577
17941
|
const shouldShowShareLink = !options.noScore && options.share && !options.isCi;
|
|
17578
17942
|
yield* pause;
|
|
17579
17943
|
yield* printSummary({
|
|
17580
|
-
diagnostics: [...
|
|
17944
|
+
diagnostics: [...printedDiagnostics],
|
|
17581
17945
|
elapsedMilliseconds,
|
|
17582
17946
|
scoreResult: score,
|
|
17583
17947
|
potentialScore,
|
|
@@ -17593,7 +17957,7 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17593
17957
|
}
|
|
17594
17958
|
yield* pause;
|
|
17595
17959
|
yield* printFooter({
|
|
17596
|
-
diagnostics: [...
|
|
17960
|
+
diagnostics: [...printedDiagnostics],
|
|
17597
17961
|
scoreResult: score,
|
|
17598
17962
|
projectName: project.projectName,
|
|
17599
17963
|
isOffline: !shouldShowShareLink
|
|
@@ -17724,21 +18088,6 @@ const handleUserError = (error, options = {}) => {
|
|
|
17724
18088
|
process.exitCode = 1;
|
|
17725
18089
|
};
|
|
17726
18090
|
//#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
18091
|
//#region src/cli/utils/is-expected-user-error.ts
|
|
17743
18092
|
/**
|
|
17744
18093
|
* Whether `error` is an expected, user-actionable failure — the user's project
|
|
@@ -19927,8 +20276,9 @@ const findLowestScoredScan = (completedScans) => {
|
|
|
19927
20276
|
};
|
|
19928
20277
|
const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
19929
20278
|
const { completedScans, userConfig, verbose, isOffline, projectName } = input;
|
|
20279
|
+
const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
|
|
19930
20280
|
const animateRender = !verbose && canAnimateOnboarding(process.stdout);
|
|
19931
|
-
const
|
|
20281
|
+
const displayDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(completedScans.flatMap((scan) => scan.result.diagnostics), "cli", userConfig), categoryFilters);
|
|
19932
20282
|
const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
|
|
19933
20283
|
for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
|
|
19934
20284
|
const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
|
|
@@ -19942,29 +20292,30 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
|
19942
20292
|
const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
|
|
19943
20293
|
const totalScanElapsedMilliseconds = completedScans.reduce((sum, scan) => sum + (scan.result.scanElapsedMilliseconds ?? scan.result.elapsedMilliseconds), 0);
|
|
19944
20294
|
yield* Console.log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalScanElapsedMilliseconds)}`);
|
|
19945
|
-
if (
|
|
20295
|
+
if (displayDiagnostics.length > 0) {
|
|
19946
20296
|
yield* Console.log("");
|
|
19947
|
-
yield* printDiagnostics(
|
|
20297
|
+
yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
|
|
19948
20298
|
}
|
|
19949
20299
|
const lowestScoredScan = findLowestScoredScan(completedScans);
|
|
19950
20300
|
const aggregateScore = lowestScoredScan?.result.score ?? null;
|
|
19951
20301
|
const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
|
|
19952
20302
|
yield* printSummary({
|
|
19953
|
-
diagnostics:
|
|
20303
|
+
diagnostics: displayDiagnostics,
|
|
19954
20304
|
elapsedMilliseconds: completedScans.reduce((sum, scan) => sum + scan.result.elapsedMilliseconds, 0),
|
|
19955
20305
|
scoreResult: aggregateScore,
|
|
19956
|
-
potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(
|
|
20306
|
+
potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(displayDiagnostics, filterDiagnosticsForSurface(lowestScoredScan.result.diagnostics, "cli", userConfig), lowestScoredScan.result.score)) : null,
|
|
19957
20307
|
totalSourceFileCount,
|
|
19958
20308
|
noScoreMessage: "Score unavailable.",
|
|
19959
20309
|
verbose,
|
|
19960
20310
|
animateProjection: animateRender
|
|
19961
20311
|
});
|
|
19962
20312
|
const entries = completedScans.map((scan) => {
|
|
19963
|
-
const
|
|
20313
|
+
const projectDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface([...scan.result.diagnostics], "cli", userConfig), categoryFilters);
|
|
20314
|
+
const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
19964
20315
|
return {
|
|
19965
20316
|
projectName: scan.result.project.projectName,
|
|
19966
20317
|
score: scan.result.score?.score ?? null,
|
|
19967
|
-
issueCount:
|
|
20318
|
+
issueCount: projectDiagnostics.length,
|
|
19968
20319
|
errorCount
|
|
19969
20320
|
};
|
|
19970
20321
|
});
|
|
@@ -19972,7 +20323,7 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
|
19972
20323
|
yield* Console.log("");
|
|
19973
20324
|
for (const entry of entries) yield* Console.log(buildSummaryLine(entry, longestProjectNameLength));
|
|
19974
20325
|
yield* printFooter({
|
|
19975
|
-
diagnostics:
|
|
20326
|
+
diagnostics: displayDiagnostics,
|
|
19976
20327
|
scoreResult: aggregateScore,
|
|
19977
20328
|
projectName,
|
|
19978
20329
|
isOffline
|
|
@@ -20062,7 +20413,8 @@ const resolveCliInspectOptions = (flags, userConfig) => {
|
|
|
20062
20413
|
noScore: flags.score === false || flags.telemetry === false || (userConfig?.noScore ?? false),
|
|
20063
20414
|
isCi: isCiEnvironment(),
|
|
20064
20415
|
silent: Boolean(flags.json),
|
|
20065
|
-
concurrency: resolveParallelFlag(flags.parallel)
|
|
20416
|
+
concurrency: resolveParallelFlag(flags.parallel),
|
|
20417
|
+
categoryFilters: resolveCliCategories(flags.category)
|
|
20066
20418
|
};
|
|
20067
20419
|
};
|
|
20068
20420
|
//#endregion
|
|
@@ -20315,6 +20667,16 @@ const validateModeFlags = (flags) => {
|
|
|
20315
20667
|
};
|
|
20316
20668
|
//#endregion
|
|
20317
20669
|
//#region src/cli/commands/inspect.ts
|
|
20670
|
+
const filterCompletedScansByCategories = (completedScans, categoryFilters) => {
|
|
20671
|
+
if (categoryFilters.size === 0) return [...completedScans];
|
|
20672
|
+
return completedScans.map((scan) => ({
|
|
20673
|
+
...scan,
|
|
20674
|
+
result: {
|
|
20675
|
+
...scan.result,
|
|
20676
|
+
diagnostics: filterDiagnosticsByCategories(scan.result.diagnostics, categoryFilters)
|
|
20677
|
+
}
|
|
20678
|
+
}));
|
|
20679
|
+
};
|
|
20318
20680
|
/**
|
|
20319
20681
|
* Post-scan finalization shared by the staged-arm and project-loop
|
|
20320
20682
|
* paths of `inspectAction`: emit the JSON report (when in JSON mode)
|
|
@@ -20327,6 +20689,7 @@ const finalizeScans = (input) => {
|
|
|
20327
20689
|
const baselineComputed = input.completedScans.length > 0 && input.completedScans.every((scan) => scan.result.baselineDelta !== void 0);
|
|
20328
20690
|
const baselineDegraded = input.baselineIntended && !baselineComputed;
|
|
20329
20691
|
const mode = baselineDegraded ? "diff" : input.mode;
|
|
20692
|
+
const jsonCompletedScans = filterCompletedScansByCategories(input.completedScans, input.categoryFilters);
|
|
20330
20693
|
if (input.isJsonMode) {
|
|
20331
20694
|
const baseline = baselineComputed && baselineDeltas.length > 0 ? {
|
|
20332
20695
|
baseRef: baselineDeltas[0].baseRef,
|
|
@@ -20338,7 +20701,7 @@ const finalizeScans = (input) => {
|
|
|
20338
20701
|
directory: input.resolvedDirectory,
|
|
20339
20702
|
mode,
|
|
20340
20703
|
diff: input.diff,
|
|
20341
|
-
scans:
|
|
20704
|
+
scans: jsonCompletedScans,
|
|
20342
20705
|
totalElapsedMilliseconds: performance.now() - input.startTime,
|
|
20343
20706
|
baseline
|
|
20344
20707
|
}));
|
|
@@ -20412,6 +20775,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20412
20775
|
await Effect.runPromise(playWelcomeScene({ speedMultiplier: isReturningUser ? 2 : 1 }));
|
|
20413
20776
|
} else Effect.runSync(printBrandedHeader);
|
|
20414
20777
|
const scanOptions = resolveCliInspectOptions(flags, userConfig);
|
|
20778
|
+
const categoryFilters = new Set(scanOptions.categoryFilters ?? []);
|
|
20415
20779
|
const skipPrompts = shouldSkipPrompts({
|
|
20416
20780
|
yes: flags.yes,
|
|
20417
20781
|
json: flags.json
|
|
@@ -20472,6 +20836,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20472
20836
|
isJsonMode,
|
|
20473
20837
|
isScoreOnly,
|
|
20474
20838
|
flags,
|
|
20839
|
+
categoryFilters,
|
|
20475
20840
|
userConfig,
|
|
20476
20841
|
resolvedDirectory,
|
|
20477
20842
|
startTime
|
|
@@ -20531,6 +20896,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20531
20896
|
const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
|
|
20532
20897
|
await Effect.runPromise(printMultiProjectSummary({
|
|
20533
20898
|
completedScans,
|
|
20899
|
+
categoryFilters,
|
|
20534
20900
|
userConfig,
|
|
20535
20901
|
verbose: Boolean(flags.verbose),
|
|
20536
20902
|
isOffline: !shouldShowShareLink,
|
|
@@ -20546,14 +20912,15 @@ const inspectAction = async (directory, flags) => {
|
|
|
20546
20912
|
isJsonMode,
|
|
20547
20913
|
isScoreOnly,
|
|
20548
20914
|
flags,
|
|
20915
|
+
categoryFilters,
|
|
20549
20916
|
userConfig,
|
|
20550
20917
|
resolvedDirectory,
|
|
20551
20918
|
startTime
|
|
20552
20919
|
});
|
|
20553
|
-
const
|
|
20554
|
-
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() &&
|
|
20920
|
+
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
|
|
20921
|
+
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
|
|
20555
20922
|
await handoffToAgent({
|
|
20556
|
-
diagnostics:
|
|
20923
|
+
diagnostics: selectedSurfaceDiagnostics,
|
|
20557
20924
|
projectName: path$1.basename(resolvedDirectory),
|
|
20558
20925
|
rootDirectory: resolvedDirectory,
|
|
20559
20926
|
interactive: true
|
|
@@ -20984,7 +21351,7 @@ const rulesListAction = async (options) => {
|
|
|
20984
21351
|
});
|
|
20985
21352
|
const catalog = buildRuleCatalog();
|
|
20986
21353
|
const config = validateConfigTypes((await resolveRuleConfigTarget(resolveProjectRoot(options))).config);
|
|
20987
|
-
const categoryFilter = options.category
|
|
21354
|
+
const categoryFilter = typeof options.category === "string" ? options.category.toLowerCase() : void 0;
|
|
20988
21355
|
const frameworkFilter = options.framework?.toLowerCase();
|
|
20989
21356
|
const rows = catalog.filter((entry) => {
|
|
20990
21357
|
if (categoryFilter && entry.category.toLowerCase() !== categoryFilter) return false;
|
|
@@ -21347,6 +21714,7 @@ const ROOT_FLAG_SPEC = {
|
|
|
21347
21714
|
"--yes"
|
|
21348
21715
|
]),
|
|
21349
21716
|
longOptionsWithRequiredValues: new Set([
|
|
21717
|
+
"--category",
|
|
21350
21718
|
"--changed-files-from",
|
|
21351
21719
|
"--blocking",
|
|
21352
21720
|
"--fail-on",
|
|
@@ -21503,6 +21871,7 @@ ${formatExampleLines([
|
|
|
21503
21871
|
["react-doctor ./apps/web", "scan a specific directory"],
|
|
21504
21872
|
["react-doctor --diff main", "scan only files changed vs. main"],
|
|
21505
21873
|
["react-doctor --staged", "scan staged files (pre-commit hook)"],
|
|
21874
|
+
["react-doctor --category Security", "show only one diagnostic category"],
|
|
21506
21875
|
["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
|
|
21507
21876
|
["react-doctor --json > report.json", "write a machine-readable report"],
|
|
21508
21877
|
["react-doctor why src/App.tsx:42", "explain why a rule fired there"],
|
|
@@ -21531,7 +21900,8 @@ ${formatExampleLines([
|
|
|
21531
21900
|
${highlighter.dim("Learn more:")}
|
|
21532
21901
|
${highlighter.info(CANONICAL_GITHUB_URL)}
|
|
21533
21902
|
`;
|
|
21534
|
-
const
|
|
21903
|
+
const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
|
|
21904
|
+
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
21905
|
program.action(inspectAction);
|
|
21536
21906
|
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
21907
|
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 +21944,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
21574
21944
|
export {};
|
|
21575
21945
|
|
|
21576
21946
|
//# sourceMappingURL=cli.js.map
|
|
21577
|
-
//# debugId=
|
|
21947
|
+
//# debugId=e5634721-88db-51c8-93e5-137793125d7a
|