react-doctor 0.5.1-dev.2f26228 → 0.5.1-dev.3de9106
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 +405 -158
- package/dist/index.d.ts +92 -46
- package/dist/index.js +251 -57
- package/dist/lsp.js +153 -52
- 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]="74796c64-5e08-5b67-b3ec-6294b1811a26")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as NodeChildProcess from "node:child_process";
|
|
5
5
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -13,11 +13,11 @@ import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, FRAMEWORK_SPECIFIC_RULE_
|
|
|
13
13
|
import * as OS from "node:os";
|
|
14
14
|
import os, { tmpdir } from "node:os";
|
|
15
15
|
import { parseJSON5 } from "confbox";
|
|
16
|
+
import * as NodeUrl from "node:url";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
16
18
|
import { createJiti } from "jiti";
|
|
17
19
|
import * as Crypto from "node:crypto";
|
|
18
20
|
import crypto, { createHash, randomUUID } from "node:crypto";
|
|
19
|
-
import * as NodeUrl from "node:url";
|
|
20
|
-
import { fileURLToPath } from "node:url";
|
|
21
21
|
import { gzipSync } from "node:zlib";
|
|
22
22
|
import * as Sentry from "@sentry/node";
|
|
23
23
|
import { performance as performance$1 } from "node:perf_hooks";
|
|
@@ -22356,6 +22356,7 @@ var Diagnostic = class extends Class("Diagnostic")({
|
|
|
22356
22356
|
endLine: optional(Number$1),
|
|
22357
22357
|
endColumn: optional(Number$1),
|
|
22358
22358
|
category: String$1,
|
|
22359
|
+
fileContext: optional(Literals(["test", "story"])),
|
|
22359
22360
|
suppressionHint: optional(String$1),
|
|
22360
22361
|
relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation))
|
|
22361
22362
|
}) {};
|
|
@@ -37767,8 +37768,10 @@ const isFileIgnoredByPatterns = (filePath, rootDirectory, patterns) => {
|
|
|
37767
37768
|
const relativePath = toRelativePath(filePath, rootDirectory);
|
|
37768
37769
|
return patterns.some((pattern) => pattern.test(relativePath));
|
|
37769
37770
|
};
|
|
37771
|
+
const SCRIPT_EXTENSION_FRAGMENT = "[cm]?[jt]sx?";
|
|
37772
|
+
const STORY_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:stories|story)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
|
|
37773
|
+
const TEST_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:test|spec|fixture|fixtures)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
|
|
37770
37774
|
const TEST_FILE_DIRECTORY_PATTERN = /(?:^|\/)(?:__tests__|__test__|tests|test|__mocks__|cypress|e2e|playwright)\//;
|
|
37771
|
-
const TEST_FILE_SUFFIX_PATTERN = /\.(?:test|spec|stories|story|fixture|fixtures)\.(?:[cm]?[jt]sx?)$/;
|
|
37772
37775
|
const FIXTURE_PROJECT_PATTERN = /\/(?:fixtures|__fixtures__)\//;
|
|
37773
37776
|
const SOURCE_ROOT_PATTERN = /\/(?:src|app|lib|components|pages|features|modules|packages|apps|frontend|client)\//g;
|
|
37774
37777
|
const stripAboveSourceRoot = (relativePath) => {
|
|
@@ -37779,12 +37782,23 @@ const stripAboveSourceRoot = (relativePath) => {
|
|
|
37779
37782
|
if (lastIdx >= 0) return relativePath.slice(lastIdx);
|
|
37780
37783
|
return relativePath.slice(fixtureMatch.index + fixtureMatch[0].length - 1);
|
|
37781
37784
|
};
|
|
37782
|
-
|
|
37783
|
-
|
|
37785
|
+
/**
|
|
37786
|
+
* Classifies where a file sits relative to shipped code. A finding in a
|
|
37787
|
+
* `.stories.tsx` or `.spec.ts` file never runs in front of users, so
|
|
37788
|
+
* renderers label those sites instead of framing them as production
|
|
37789
|
+
* impact (`rn-no-raw-text` in a spec doesn't say users crash).
|
|
37790
|
+
*
|
|
37791
|
+
* `"story"` is the `.stories.*` / `.story.*` suffix; `"test"` is the
|
|
37792
|
+
* test/spec/fixture suffixes and test directories; `"production"` is
|
|
37793
|
+
* the default.
|
|
37794
|
+
*/
|
|
37795
|
+
const classifyFileContext = (relativePath) => {
|
|
37796
|
+
if (relativePath.length === 0) return "production";
|
|
37784
37797
|
const forwardSlashed = relativePath.replaceAll("\\", "/");
|
|
37785
|
-
if (
|
|
37798
|
+
if (STORY_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "story";
|
|
37799
|
+
if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "test";
|
|
37786
37800
|
const scoped = stripAboveSourceRoot(forwardSlashed);
|
|
37787
|
-
return TEST_FILE_DIRECTORY_PATTERN.test(scoped);
|
|
37801
|
+
return TEST_FILE_DIRECTORY_PATTERN.test(scoped) ? "test" : "production";
|
|
37788
37802
|
};
|
|
37789
37803
|
/**
|
|
37790
37804
|
* Resolves the user-configured severity override for a rule.
|
|
@@ -38004,6 +38018,8 @@ const collectStringSet = (values) => {
|
|
|
38004
38018
|
* 5. `rn-no-raw-text` suppression via configured `textComponents` and
|
|
38005
38019
|
* `rawTextWrapperComponents` (config-driven JSX enclosure checks)
|
|
38006
38020
|
* 6. inline suppressions (`// react-doctor-disable-next-line ...`)
|
|
38021
|
+
* 7. file-context stamping (`fileContext: "test" | "story"` on
|
|
38022
|
+
* survivors in non-production files, so renderers can label them)
|
|
38007
38023
|
*
|
|
38008
38024
|
* Returns `null` when the diagnostic is dropped, the (possibly
|
|
38009
38025
|
* severity-restamped) diagnostic otherwise.
|
|
@@ -38023,7 +38039,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
38023
38039
|
const hasTextComponents = textComponentNames.size > 0;
|
|
38024
38040
|
const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
|
|
38025
38041
|
const fileLinesCache = /* @__PURE__ */ new Map();
|
|
38026
|
-
const
|
|
38042
|
+
const fileContextCache = /* @__PURE__ */ new Map();
|
|
38027
38043
|
const libraryFileCache = /* @__PURE__ */ new Map();
|
|
38028
38044
|
const isLibraryFile = (filePath) => {
|
|
38029
38045
|
let cached = libraryFileCache.get(filePath);
|
|
@@ -38040,11 +38056,11 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
38040
38056
|
fileLinesCache.set(filePath, lines);
|
|
38041
38057
|
return lines;
|
|
38042
38058
|
};
|
|
38043
|
-
const
|
|
38044
|
-
let cached =
|
|
38059
|
+
const getFileContext = (filePath) => {
|
|
38060
|
+
let cached = fileContextCache.get(filePath);
|
|
38045
38061
|
if (cached === void 0) {
|
|
38046
|
-
cached =
|
|
38047
|
-
|
|
38062
|
+
cached = classifyFileContext(filePath);
|
|
38063
|
+
fileContextCache.set(filePath, cached);
|
|
38048
38064
|
}
|
|
38049
38065
|
return cached;
|
|
38050
38066
|
};
|
|
@@ -38053,7 +38069,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
38053
38069
|
const rule = reactDoctorPlugin.rules[diagnostic.rule];
|
|
38054
38070
|
if (!rule?.tags?.includes("test-noise")) return false;
|
|
38055
38071
|
if (rule.tags.includes("migration-hint")) return false;
|
|
38056
|
-
return
|
|
38072
|
+
return getFileContext(diagnostic.filePath) !== "production";
|
|
38057
38073
|
};
|
|
38058
38074
|
const isRuleIgnored = (ruleIdentifier) => {
|
|
38059
38075
|
for (const ignored of ignoredRules) if (isSameRuleKey(ignored, ruleIdentifier)) return true;
|
|
@@ -38110,6 +38126,11 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
38110
38126
|
};
|
|
38111
38127
|
}
|
|
38112
38128
|
}
|
|
38129
|
+
const fileContext = getFileContext(current.filePath);
|
|
38130
|
+
if (fileContext !== "production") current = {
|
|
38131
|
+
...current,
|
|
38132
|
+
fileContext
|
|
38133
|
+
};
|
|
38113
38134
|
return current;
|
|
38114
38135
|
} };
|
|
38115
38136
|
};
|
|
@@ -38506,10 +38527,41 @@ const PACKAGE_JSON_CONFIG_KEY$1 = "reactDoctor";
|
|
|
38506
38527
|
const LEGACY_CONFIG_FILENAME = "react-doctor.config.json";
|
|
38507
38528
|
const jiti = createJiti(import.meta.url);
|
|
38508
38529
|
const formatError = (error) => error instanceof Error ? error.message : String(error);
|
|
38509
|
-
const
|
|
38510
|
-
const imported = await
|
|
38530
|
+
const importDefaultExport = async (jitiInstance, filePath) => {
|
|
38531
|
+
const imported = await jitiInstance.import(filePath);
|
|
38511
38532
|
return imported?.default ?? imported;
|
|
38512
38533
|
};
|
|
38534
|
+
const SELF_PACKAGE_IMPORT_SPECIFIER = "react-doctor/api";
|
|
38535
|
+
const SELF_PACKAGE_RESOLVE_TARGETS = ["react-doctor/api", "@react-doctor/core"];
|
|
38536
|
+
const MODULE_NOT_FOUND_ERROR_CODES = new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
|
|
38537
|
+
let selfAliasJiti;
|
|
38538
|
+
const getSelfAliasJiti = () => {
|
|
38539
|
+
if (selfAliasJiti !== void 0) return selfAliasJiti;
|
|
38540
|
+
for (const resolveTarget of SELF_PACKAGE_RESOLVE_TARGETS) try {
|
|
38541
|
+
const aliasTargetPath = fileURLToPath(jiti.esmResolve(resolveTarget));
|
|
38542
|
+
selfAliasJiti = createJiti(import.meta.url, { alias: { [SELF_PACKAGE_IMPORT_SPECIFIER]: aliasTargetPath } });
|
|
38543
|
+
return selfAliasJiti;
|
|
38544
|
+
} catch {
|
|
38545
|
+
continue;
|
|
38546
|
+
}
|
|
38547
|
+
selfAliasJiti = null;
|
|
38548
|
+
return selfAliasJiti;
|
|
38549
|
+
};
|
|
38550
|
+
const isSelfPackageResolutionError = (error) => error instanceof Error && "code" in error && typeof error.code === "string" && MODULE_NOT_FOUND_ERROR_CODES.has(error.code) && error.message.includes(SELF_PACKAGE_IMPORT_SPECIFIER);
|
|
38551
|
+
const loadModuleConfig = async (filePath) => {
|
|
38552
|
+
try {
|
|
38553
|
+
return await importDefaultExport(jiti, filePath);
|
|
38554
|
+
} catch (error) {
|
|
38555
|
+
if (!isSelfPackageResolutionError(error)) throw error;
|
|
38556
|
+
const aliasJiti = getSelfAliasJiti();
|
|
38557
|
+
if (!aliasJiti) throw error;
|
|
38558
|
+
try {
|
|
38559
|
+
return await importDefaultExport(aliasJiti, filePath);
|
|
38560
|
+
} catch (retryError) {
|
|
38561
|
+
throw new Error(`${formatError(error)} (retry with ${SELF_PACKAGE_IMPORT_SPECIFIER} aliased to the running react-doctor package also failed: ${formatError(retryError)})`, { cause: retryError });
|
|
38562
|
+
}
|
|
38563
|
+
}
|
|
38564
|
+
};
|
|
38513
38565
|
const readDataConfig = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
|
|
38514
38566
|
const readEmbeddedPackageJsonConfig = (directory) => {
|
|
38515
38567
|
const packageJsonPath = Path.join(directory, PACKAGE_JSON_FILENAME);
|
|
@@ -39245,6 +39297,17 @@ const checkPnpmHardening = (rootDirectory) => {
|
|
|
39245
39297
|
}));
|
|
39246
39298
|
return diagnostics;
|
|
39247
39299
|
};
|
|
39300
|
+
const buildReactNativeDiagnostic = (input) => ({
|
|
39301
|
+
filePath: input.filePath,
|
|
39302
|
+
plugin: "react-doctor",
|
|
39303
|
+
rule: input.rule,
|
|
39304
|
+
severity: input.severity ?? "warning",
|
|
39305
|
+
message: input.message,
|
|
39306
|
+
help: input.help,
|
|
39307
|
+
line: input.line ?? 0,
|
|
39308
|
+
column: input.column ?? 0,
|
|
39309
|
+
category: input.category ?? "Correctness"
|
|
39310
|
+
});
|
|
39248
39311
|
const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
|
|
39249
39312
|
const isBuilderBobLibrary = (packageJson) => {
|
|
39250
39313
|
const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
|
|
@@ -39256,17 +39319,12 @@ const checkReactNativeLibraryDependencies = (rootDirectory) => {
|
|
|
39256
39319
|
const misplaced = ["react", "react-native"].filter((name) => packageJson.dependencies?.[name] !== void 0);
|
|
39257
39320
|
if (misplaced.length === 0) return [];
|
|
39258
39321
|
const quoted = misplaced.map((name) => `"${name}"`).join(" and ");
|
|
39259
|
-
return [{
|
|
39322
|
+
return [buildReactNativeDiagnostic({
|
|
39260
39323
|
filePath: "package.json",
|
|
39261
|
-
plugin: "react-doctor",
|
|
39262
39324
|
rule: "rn-library-react-in-dependencies",
|
|
39263
|
-
severity: "warning",
|
|
39264
39325
|
message: `This react-native-builder-bob library lists ${quoted} in \`dependencies\` — that ships a second copy into consumer apps, causing "Invalid hook call" (duplicate React) and duplicate-native-module crashes.`,
|
|
39265
|
-
help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development)
|
|
39266
|
-
|
|
39267
|
-
column: 0,
|
|
39268
|
-
category: "Correctness"
|
|
39269
|
-
}];
|
|
39326
|
+
help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`
|
|
39327
|
+
})];
|
|
39270
39328
|
};
|
|
39271
39329
|
const BABEL_CONFIG_FILE_NAMES = [
|
|
39272
39330
|
"babel.config.js",
|
|
@@ -39278,6 +39336,8 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
39278
39336
|
".babelrc.json"
|
|
39279
39337
|
];
|
|
39280
39338
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
39339
|
+
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
39340
|
+
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
39281
39341
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
39282
39342
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
39283
39343
|
const filePath = Path.join(rootDirectory, fileName);
|
|
@@ -39288,18 +39348,20 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
39288
39348
|
} catch {
|
|
39289
39349
|
continue;
|
|
39290
39350
|
}
|
|
39291
|
-
if (
|
|
39292
|
-
return [{
|
|
39351
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
39293
39352
|
filePath: fileName,
|
|
39294
|
-
plugin: "react-doctor",
|
|
39295
39353
|
rule: "rn-no-metro-babel-preset",
|
|
39296
39354
|
severity: "error",
|
|
39297
39355
|
message: "`module:metro-react-native-babel-preset` was renamed to `@react-native/babel-preset` and is no longer installed by React Native 0.73+ — this preset reference fails to resolve and breaks the Metro/Babel transform.",
|
|
39298
|
-
help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
|
|
39299
|
-
|
|
39300
|
-
|
|
39301
|
-
|
|
39302
|
-
|
|
39356
|
+
help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
|
|
39357
|
+
})];
|
|
39358
|
+
if (MODERN_PRESET_REFERENCE.test(contents) && !ENABLE_BABEL_RUNTIME_VERSION.test(contents)) return [buildReactNativeDiagnostic({
|
|
39359
|
+
filePath: fileName,
|
|
39360
|
+
rule: "rn-no-metro-babel-runtime-version",
|
|
39361
|
+
severity: "warning",
|
|
39362
|
+
message: "`module:@react-native/babel-preset` has no `enableBabelRuntime` version, so Babel runtime helpers can be duplicated across files instead of imported once from @babel/runtime, increasing the JS bundle size.",
|
|
39363
|
+
help: "Set `enableBabelRuntime` to the @babel/runtime version from package.json, e.g. `['module:@react-native/babel-preset', { enableBabelRuntime: '^7.26.0' }]`."
|
|
39364
|
+
})];
|
|
39303
39365
|
}
|
|
39304
39366
|
return [];
|
|
39305
39367
|
};
|
|
@@ -41711,8 +41773,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
41711
41773
|
return bindingResolution !== null && !bindingResolution.isReactUseBinding;
|
|
41712
41774
|
};
|
|
41713
41775
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
41776
|
+
const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
|
|
41777
|
+
const TRAILING_PERIOD_PATTERN = /\.$/;
|
|
41714
41778
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
41715
|
-
const
|
|
41779
|
+
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
41780
|
+
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
41781
|
+
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
41782
|
+
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
41783
|
+
const buildReactCompilerMessage = (reasonSummary) => {
|
|
41784
|
+
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
41785
|
+
if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
|
|
41786
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
|
|
41787
|
+
};
|
|
41716
41788
|
const PLUGIN_CATEGORY_MAP = {
|
|
41717
41789
|
react: "Bugs",
|
|
41718
41790
|
"react-hooks": "Bugs",
|
|
@@ -41739,7 +41811,10 @@ const getRuleRecommendation = (ruleName, project) => {
|
|
|
41739
41811
|
};
|
|
41740
41812
|
const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
|
|
41741
41813
|
const getRuleTitle = (ruleName) => reactDoctorPlugin.rules[ruleName]?.title;
|
|
41742
|
-
const resolveDiagnosticTitle = (plugin, rule) =>
|
|
41814
|
+
const resolveDiagnosticTitle = (plugin, rule) => {
|
|
41815
|
+
if (plugin !== "react-hooks-js") return getRuleTitle(rule);
|
|
41816
|
+
return rule === "todo" ? REACT_COMPILER_TODO_TITLE : REACT_COMPILER_TITLE;
|
|
41817
|
+
};
|
|
41743
41818
|
const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
41744
41819
|
const cleaned = resolveCleanedDiagnostic(typeof message === "string" ? message : "", typeof help === "string" ? help : "", plugin, rule, project);
|
|
41745
41820
|
return {
|
|
@@ -41748,10 +41823,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
|
41748
41823
|
};
|
|
41749
41824
|
};
|
|
41750
41825
|
const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
41751
|
-
if (plugin === "react-hooks-js")
|
|
41752
|
-
message
|
|
41753
|
-
|
|
41754
|
-
|
|
41826
|
+
if (plugin === "react-hooks-js") {
|
|
41827
|
+
const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
|
|
41828
|
+
if (rule === "todo") return {
|
|
41829
|
+
message: REACT_COMPILER_GENERIC_MESSAGE,
|
|
41830
|
+
help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
|
|
41831
|
+
};
|
|
41832
|
+
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
41833
|
+
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
41834
|
+
return {
|
|
41835
|
+
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
41836
|
+
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
41837
|
+
};
|
|
41838
|
+
}
|
|
41755
41839
|
return {
|
|
41756
41840
|
message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
|
|
41757
41841
|
help: help || getRuleRecommendation(rule, project) || ""
|
|
@@ -42418,7 +42502,7 @@ const ScoreApiResponseSchema = Struct({
|
|
|
42418
42502
|
})))
|
|
42419
42503
|
});
|
|
42420
42504
|
const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
|
|
42421
|
-
const
|
|
42505
|
+
const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
|
|
42422
42506
|
const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
42423
42507
|
const describeFailure = (error) => {
|
|
42424
42508
|
if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
|
|
@@ -42431,7 +42515,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
42431
42515
|
const requestUrl = options.isCi ? `${SCORE_API_URL}?ci=1` : SCORE_API_URL;
|
|
42432
42516
|
try {
|
|
42433
42517
|
const compressedBody = gzipSync(JSON.stringify({
|
|
42434
|
-
diagnostics:
|
|
42518
|
+
diagnostics: stripLocalFileFields(diagnostics),
|
|
42435
42519
|
...options.metadata?.repo ? { repo: options.metadata.repo } : {},
|
|
42436
42520
|
...options.metadata?.sha ? { sha: options.metadata.sha } : {},
|
|
42437
42521
|
...options.metadata?.framework ? { framework: options.metadata.framework } : {},
|
|
@@ -42498,25 +42582,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
|
|
|
42498
42582
|
const SCORE_AXES = [
|
|
42499
42583
|
{
|
|
42500
42584
|
key: "supplyChain",
|
|
42501
|
-
label: "supply chain"
|
|
42585
|
+
label: "supply chain",
|
|
42586
|
+
gates: true
|
|
42502
42587
|
},
|
|
42503
42588
|
{
|
|
42504
42589
|
key: "vulnerability",
|
|
42505
|
-
label: "vulnerability"
|
|
42590
|
+
label: "vulnerability",
|
|
42591
|
+
gates: true
|
|
42506
42592
|
},
|
|
42507
42593
|
{
|
|
42508
42594
|
key: "maintenance",
|
|
42509
|
-
label: "maintenance"
|
|
42595
|
+
label: "maintenance",
|
|
42596
|
+
gates: false
|
|
42510
42597
|
},
|
|
42511
42598
|
{
|
|
42512
42599
|
key: "quality",
|
|
42513
|
-
label: "quality"
|
|
42600
|
+
label: "quality",
|
|
42601
|
+
gates: false
|
|
42514
42602
|
},
|
|
42515
42603
|
{
|
|
42516
42604
|
key: "license",
|
|
42517
|
-
label: "license"
|
|
42605
|
+
label: "license",
|
|
42606
|
+
gates: false
|
|
42518
42607
|
}
|
|
42519
42608
|
];
|
|
42609
|
+
const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
|
|
42610
|
+
const worstGatedAxis = (score) => {
|
|
42611
|
+
let worst = GATED_AXES[0];
|
|
42612
|
+
for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
|
|
42613
|
+
return worst;
|
|
42614
|
+
};
|
|
42520
42615
|
const clampScore = (value) => {
|
|
42521
42616
|
if (!Number.isFinite(value)) return 50;
|
|
42522
42617
|
return Math.min(Math.max(value, 0), 100);
|
|
@@ -42657,15 +42752,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
|
|
|
42657
42752
|
"socket.purl": toPurl(dependency)
|
|
42658
42753
|
} }));
|
|
42659
42754
|
const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
|
|
42660
|
-
const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
42661
|
-
const overall = toHundred(score.overall);
|
|
42755
|
+
const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
|
|
42662
42756
|
const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
|
|
42663
42757
|
return {
|
|
42664
42758
|
filePath: "package.json",
|
|
42665
42759
|
plugin: SUPPLY_CHAIN_PLUGIN,
|
|
42666
42760
|
rule: SUPPLY_CHAIN_RULE,
|
|
42667
42761
|
severity: options.severity,
|
|
42668
|
-
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket
|
|
42762
|
+
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
|
|
42669
42763
|
help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
|
|
42670
42764
|
url: packagePageUrl,
|
|
42671
42765
|
line: dependency.line,
|
|
@@ -42700,7 +42794,9 @@ const collectSupplyChainScores = (input) => gen(function* () {
|
|
|
42700
42794
|
* Scores every direct dependency in the project's `package.json` against
|
|
42701
42795
|
* Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
|
|
42702
42796
|
* uses — no API key) and returns a diagnostic for each dependency whose
|
|
42703
|
-
* Socket
|
|
42797
|
+
* worst Socket *security* axis — supply chain or vulnerability — is below
|
|
42798
|
+
* the configured `minScore`. The quality / maintenance / license axes are
|
|
42799
|
+
* reported as context but never gate (see GATED_AXES).
|
|
42704
42800
|
*
|
|
42705
42801
|
* Lookups run with bounded concurrency via `Effect.forEach`. The check is
|
|
42706
42802
|
* total/fail-open: each per-package lookup already recovers to `null`
|
|
@@ -42718,8 +42814,9 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
42718
42814
|
for (let index = 0; index < dependencies.length; index += 1) {
|
|
42719
42815
|
const score = scores[index];
|
|
42720
42816
|
if (!score) continue;
|
|
42721
|
-
|
|
42722
|
-
|
|
42817
|
+
const worstAxis = worstGatedAxis(score);
|
|
42818
|
+
if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
|
|
42819
|
+
diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
|
|
42723
42820
|
}
|
|
42724
42821
|
return diagnostics;
|
|
42725
42822
|
});
|
|
@@ -42727,7 +42824,8 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
42727
42824
|
* `SupplyChain` scores the project's direct dependencies against Socket.dev's
|
|
42728
42825
|
* free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
|
|
42729
42826
|
* (`sfw`) performs — and streams a diagnostic for each dependency whose
|
|
42730
|
-
* Socket
|
|
42827
|
+
* worst Socket security axis (supply chain or vulnerability) falls below
|
|
42828
|
+
* the configured `supplyChain.minScore`.
|
|
42731
42829
|
*
|
|
42732
42830
|
* Runs by default (one network request per dependency); the orchestrator
|
|
42733
42831
|
* provides `layerOf([])` only when the user opts out via
|
|
@@ -43482,6 +43580,48 @@ const groupBy = (items, keyFn) => {
|
|
|
43482
43580
|
* a 404. Gate the directive on this predicate.
|
|
43483
43581
|
*/
|
|
43484
43582
|
const hasPublishedFixRecipe = (diagnostic) => diagnostic.plugin === "react-doctor" && Object.hasOwn(reactDoctorPlugin.rules, diagnostic.rule);
|
|
43583
|
+
const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
|
|
43584
|
+
const mergeIgnores = (baseIgnore, overrideIgnore) => {
|
|
43585
|
+
const mergedIgnore = {
|
|
43586
|
+
...baseIgnore,
|
|
43587
|
+
...overrideIgnore
|
|
43588
|
+
};
|
|
43589
|
+
if (baseIgnore.rules && overrideIgnore.rules) mergedIgnore.rules = unionValues(baseIgnore.rules, overrideIgnore.rules);
|
|
43590
|
+
if (baseIgnore.files && overrideIgnore.files) mergedIgnore.files = unionValues(baseIgnore.files, overrideIgnore.files);
|
|
43591
|
+
if (baseIgnore.tags && overrideIgnore.tags) mergedIgnore.tags = unionValues(baseIgnore.tags, overrideIgnore.tags);
|
|
43592
|
+
if (baseIgnore.overrides && overrideIgnore.overrides) mergedIgnore.overrides = [...baseIgnore.overrides, ...overrideIgnore.overrides];
|
|
43593
|
+
return mergedIgnore;
|
|
43594
|
+
};
|
|
43595
|
+
/**
|
|
43596
|
+
* Layer one `ReactDoctorConfig` on top of another, additively: `rules` /
|
|
43597
|
+
* `categories` / `supplyChain` merge per key, `ignore` lists union
|
|
43598
|
+
* (`ignore.overrides` concatenate), and every other field is a scalar the
|
|
43599
|
+
* override simply wins on when set. Returns the base unchanged when there
|
|
43600
|
+
* is no override, and vice versa — so callers can thread `null` /
|
|
43601
|
+
* `undefined` through without special-casing.
|
|
43602
|
+
*/
|
|
43603
|
+
const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
|
|
43604
|
+
if (overrideConfig === void 0) return baseConfig;
|
|
43605
|
+
if (baseConfig === null) return overrideConfig;
|
|
43606
|
+
const mergedConfig = {
|
|
43607
|
+
...baseConfig,
|
|
43608
|
+
...overrideConfig
|
|
43609
|
+
};
|
|
43610
|
+
if (baseConfig.rules && overrideConfig.rules) mergedConfig.rules = {
|
|
43611
|
+
...baseConfig.rules,
|
|
43612
|
+
...overrideConfig.rules
|
|
43613
|
+
};
|
|
43614
|
+
if (baseConfig.categories && overrideConfig.categories) mergedConfig.categories = {
|
|
43615
|
+
...baseConfig.categories,
|
|
43616
|
+
...overrideConfig.categories
|
|
43617
|
+
};
|
|
43618
|
+
if (baseConfig.supplyChain && overrideConfig.supplyChain) mergedConfig.supplyChain = {
|
|
43619
|
+
...baseConfig.supplyChain,
|
|
43620
|
+
...overrideConfig.supplyChain
|
|
43621
|
+
};
|
|
43622
|
+
if (baseConfig.ignore && overrideConfig.ignore) mergedConfig.ignore = mergeIgnores(baseConfig.ignore, overrideConfig.ignore);
|
|
43623
|
+
return mergedConfig;
|
|
43624
|
+
};
|
|
43485
43625
|
//#endregion
|
|
43486
43626
|
//#region src/cli/utils/is-ci-environment.ts
|
|
43487
43627
|
const CI_ENVIRONMENT_VARIABLES = [
|
|
@@ -43590,6 +43730,8 @@ const METRIC = {
|
|
|
43590
43730
|
cliInvoked: "cli.invoked",
|
|
43591
43731
|
cliError: "cli.error",
|
|
43592
43732
|
projectDetected: "project.detected",
|
|
43733
|
+
projectPathSelected: "project.path_selected",
|
|
43734
|
+
projectConfigSelected: "project.config_selected",
|
|
43593
43735
|
scanCompleted: "scan.completed",
|
|
43594
43736
|
scanDuration: "scan.duration",
|
|
43595
43737
|
scanPhaseDuration: "scan.phase_duration",
|
|
@@ -43659,7 +43801,7 @@ const makeNoopConsole = () => ({
|
|
|
43659
43801
|
});
|
|
43660
43802
|
//#endregion
|
|
43661
43803
|
//#region src/cli/utils/version.ts
|
|
43662
|
-
const VERSION = "0.5.1-dev.
|
|
43804
|
+
const VERSION = "0.5.1-dev.3de9106";
|
|
43663
43805
|
//#endregion
|
|
43664
43806
|
//#region src/cli/utils/json-mode.ts
|
|
43665
43807
|
let context = null;
|
|
@@ -44017,13 +44159,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
44017
44159
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
44018
44160
|
* standard `SENTRY_RELEASE` override.
|
|
44019
44161
|
*/
|
|
44020
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.
|
|
44162
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.3de9106`;
|
|
44021
44163
|
/**
|
|
44022
44164
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
44023
44165
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
44024
44166
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
44025
44167
|
*/
|
|
44026
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.
|
|
44168
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.3de9106") ? "development" : "production");
|
|
44027
44169
|
/**
|
|
44028
44170
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
44029
44171
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -47321,12 +47463,13 @@ const toSpanAttributes = (tags) => {
|
|
|
47321
47463
|
/**
|
|
47322
47464
|
* Clears the module-level run-scoped Sentry state — the current scanned project
|
|
47323
47465
|
* and the active run trace. `inspect()` calls this at the start of every run and
|
|
47324
|
-
* again after a clean one
|
|
47325
|
-
*
|
|
47326
|
-
*
|
|
47327
|
-
*
|
|
47328
|
-
*
|
|
47329
|
-
*
|
|
47466
|
+
* again after a clean one, so a prior or just-finished scan can't attach its
|
|
47467
|
+
* project tags / trace to a later run or to a non-scan error (e.g.
|
|
47468
|
+
* inspectAction's post-loop finalize/handoff steps). A thrown scan error skips
|
|
47469
|
+
* the post-run reset, leaving the state for the command catch to attribute and
|
|
47470
|
+
* link the crash. Concurrent batch members (`concurrentScan`) never touch this
|
|
47471
|
+
* state — they neither write nor reset it. Safe to call when Sentry is off (the
|
|
47472
|
+
* refs are read only when an event is built).
|
|
47330
47473
|
*/
|
|
47331
47474
|
const resetSentryRunState = () => {
|
|
47332
47475
|
setSentryProjectInfo(null);
|
|
@@ -47349,8 +47492,13 @@ const resetSentryRunState = () => {
|
|
|
47349
47492
|
* state right after a clean run and at the start of the next one, so the trace
|
|
47350
47493
|
* is never attached to a non-scan error; on a thrown error the state is left in
|
|
47351
47494
|
* place for the command catch, then the process exits.
|
|
47495
|
+
*
|
|
47496
|
+
* A `concurrentScan` (one member of the CLI's multi-project pool) still gets
|
|
47497
|
+
* its own root span, but skips recording the active run trace — the module-
|
|
47498
|
+
* level handle has single-scan semantics, and overlapping writers would link a
|
|
47499
|
+
* crash to an arbitrary sibling's trace.
|
|
47352
47500
|
*/
|
|
47353
|
-
const withSentryRunSpan = (run) => {
|
|
47501
|
+
const withSentryRunSpan = (run, options = {}) => {
|
|
47354
47502
|
if (!isSentryTracingEnabled()) return run(void 0);
|
|
47355
47503
|
const { tags } = buildSentryScope();
|
|
47356
47504
|
const command = typeof tags.command === "string" ? tags.command : "inspect";
|
|
@@ -47359,12 +47507,14 @@ const withSentryRunSpan = (run) => {
|
|
|
47359
47507
|
op: "cli.inspect",
|
|
47360
47508
|
attributes: toSpanAttributes(tags)
|
|
47361
47509
|
}, (rootSpan) => {
|
|
47362
|
-
|
|
47363
|
-
|
|
47364
|
-
|
|
47365
|
-
|
|
47366
|
-
|
|
47367
|
-
|
|
47510
|
+
if (options.concurrentScan !== true) {
|
|
47511
|
+
const spanContext = rootSpan.spanContext();
|
|
47512
|
+
setActiveRunTrace({
|
|
47513
|
+
traceId: spanContext.traceId,
|
|
47514
|
+
spanId: spanContext.spanId,
|
|
47515
|
+
sampled: (spanContext.traceFlags & 1) === 1
|
|
47516
|
+
});
|
|
47517
|
+
}
|
|
47368
47518
|
return run(rootSpan);
|
|
47369
47519
|
});
|
|
47370
47520
|
};
|
|
@@ -47375,9 +47525,15 @@ const withSentryRunSpan = (run) => {
|
|
|
47375
47525
|
* run's root span so the transaction/trace carries the project shape too.
|
|
47376
47526
|
* Always cheap — the span attribute set is skipped when `rootSpan` is absent
|
|
47377
47527
|
* (tracing off), and storing the info is a plain assignment.
|
|
47528
|
+
*
|
|
47529
|
+
* A `concurrentScan` only sets the span attributes: the module-level project
|
|
47530
|
+
* ref has single-scan semantics, and overlapping writers would stamp events
|
|
47531
|
+
* and metrics with an arbitrary sibling's project. Wide events keep full
|
|
47532
|
+
* attribution (they ride the span); per-emit metrics simply omit the project
|
|
47533
|
+
* shape during a concurrent batch (absent, never wrong).
|
|
47378
47534
|
*/
|
|
47379
|
-
const recordSentryProjectContext = (projectInfo, rootSpan) => {
|
|
47380
|
-
setSentryProjectInfo(projectInfo);
|
|
47535
|
+
const recordSentryProjectContext = (projectInfo, rootSpan, options = {}) => {
|
|
47536
|
+
if (options.concurrentScan !== true) setSentryProjectInfo(projectInfo);
|
|
47381
47537
|
rootSpan?.setAttributes(toSpanAttributes(buildSentryProjectContext(projectInfo).tags));
|
|
47382
47538
|
};
|
|
47383
47539
|
//#endregion
|
|
@@ -47614,6 +47770,12 @@ const buildOutcomeAttributes = (input) => {
|
|
|
47614
47770
|
topRule = rule;
|
|
47615
47771
|
topRuleCount = count;
|
|
47616
47772
|
}
|
|
47773
|
+
let diagnosticsInTestFiles = 0;
|
|
47774
|
+
let diagnosticsInStoryFiles = 0;
|
|
47775
|
+
for (const diagnostic of result.diagnostics) {
|
|
47776
|
+
if (diagnostic.fileContext === "test") diagnosticsInTestFiles += 1;
|
|
47777
|
+
if (diagnostic.fileContext === "story") diagnosticsInStoryFiles += 1;
|
|
47778
|
+
}
|
|
47617
47779
|
const attributes = {
|
|
47618
47780
|
outcome,
|
|
47619
47781
|
exitCode: wouldBlock ? 1 : 0,
|
|
@@ -47624,6 +47786,8 @@ const buildOutcomeAttributes = (input) => {
|
|
|
47624
47786
|
errorCount: summary.errorCount,
|
|
47625
47787
|
warningCount: summary.warningCount,
|
|
47626
47788
|
affectedFiles: summary.affectedFileCount,
|
|
47789
|
+
diagnosticsInTestFiles,
|
|
47790
|
+
diagnosticsInStoryFiles,
|
|
47627
47791
|
distinctRulesFired: countByRule.size,
|
|
47628
47792
|
topRule,
|
|
47629
47793
|
scannedFileCount: result.scannedFileCount ?? null,
|
|
@@ -47671,6 +47835,7 @@ const buildConfigAttributes = (input) => {
|
|
|
47671
47835
|
noScore: input.noScore,
|
|
47672
47836
|
respectInlineDisables: input.respectInlineDisables,
|
|
47673
47837
|
showWarnings: input.showWarnings,
|
|
47838
|
+
usedOutputDir: input.usedOutputDir,
|
|
47674
47839
|
ignoredTagCount: input.ignoredTagCount,
|
|
47675
47840
|
hasCustomConfig: input.hasCustomConfig,
|
|
47676
47841
|
rulesConfigured: ruleKeys.length,
|
|
@@ -47955,17 +48120,24 @@ const writeStdout = (text) => sync(() => {
|
|
|
47955
48120
|
const POINTER = isUnicodeSupported() ? "›" : ">";
|
|
47956
48121
|
const colorizeBySeverity = (text, severity) => severity === "error" ? highlighter.error(text) : highlighter.warn(text);
|
|
47957
48122
|
const collectAffectedFiles = (diagnostics) => new Set(diagnostics.map((diagnostic) => diagnostic.filePath));
|
|
47958
|
-
const
|
|
47959
|
-
|
|
48123
|
+
const formatFileContextTag = (diagnostic) => diagnostic.fileContext ? ` (${diagnostic.fileContext} file)` : "";
|
|
48124
|
+
const buildVerboseFileEntries = (diagnostics) => {
|
|
48125
|
+
const fileEntries = /* @__PURE__ */ new Map();
|
|
47960
48126
|
for (const diagnostic of diagnostics) {
|
|
47961
|
-
|
|
47962
|
-
if (
|
|
48127
|
+
let entry = fileEntries.get(diagnostic.filePath);
|
|
48128
|
+
if (entry === void 0) {
|
|
48129
|
+
entry = {
|
|
48130
|
+
contextTag: formatFileContextTag(diagnostic),
|
|
48131
|
+
sites: []
|
|
48132
|
+
};
|
|
48133
|
+
fileEntries.set(diagnostic.filePath, entry);
|
|
48134
|
+
}
|
|
48135
|
+
if (diagnostic.line > 0) entry.sites.push({
|
|
47963
48136
|
line: diagnostic.line,
|
|
47964
48137
|
suppressionHint: diagnostic.suppressionHint
|
|
47965
48138
|
});
|
|
47966
|
-
fileSites.set(diagnostic.filePath, sites);
|
|
47967
48139
|
}
|
|
47968
|
-
return
|
|
48140
|
+
return fileEntries;
|
|
47969
48141
|
};
|
|
47970
48142
|
const formatSiteCountBadge = (count) => count > 1 ? `×${count}` : "";
|
|
47971
48143
|
const formatTrailingSiteBadge = (count) => {
|
|
@@ -48054,10 +48226,11 @@ const clusterNearbyDiagnostics = (diagnostics) => {
|
|
|
48054
48226
|
return clusters;
|
|
48055
48227
|
};
|
|
48056
48228
|
const formatClusterLocation = (cluster) => {
|
|
48057
|
-
const
|
|
48058
|
-
|
|
48059
|
-
if (cluster.
|
|
48060
|
-
return `${filePath}:${cluster.startLine}`;
|
|
48229
|
+
const lead = cluster.diagnostics[0];
|
|
48230
|
+
const contextTag = formatFileContextTag(lead);
|
|
48231
|
+
if (cluster.startLine <= 0) return `${lead.filePath}${contextTag}`;
|
|
48232
|
+
if (cluster.endLine > cluster.startLine) return `${lead.filePath}:${cluster.startLine}-${cluster.endLine}${contextTag}`;
|
|
48233
|
+
return `${lead.filePath}:${cluster.startLine}${contextTag}`;
|
|
48061
48234
|
};
|
|
48062
48235
|
const buildDiagnosticClusterLines = (cluster, resolveSourceRoot, renderCodeFrame) => {
|
|
48063
48236
|
const lead = cluster.diagnostics[0];
|
|
@@ -48200,25 +48373,26 @@ const formatElapsedTime = (elapsedMilliseconds) => {
|
|
|
48200
48373
|
};
|
|
48201
48374
|
const formatRuleSummary = (ruleKey, ruleDiagnostics) => {
|
|
48202
48375
|
const firstDiagnostic = ruleDiagnostics[0];
|
|
48376
|
+
const distinctMessages = [...new Set(ruleDiagnostics.map((diagnostic) => diagnostic.message))];
|
|
48203
48377
|
const sections = [
|
|
48204
48378
|
`Rule: ${ruleKey}`,
|
|
48205
48379
|
`Severity: ${firstDiagnostic.severity}`,
|
|
48206
48380
|
`Category: ${firstDiagnostic.category}`,
|
|
48207
48381
|
`Count: ${ruleDiagnostics.length}`,
|
|
48208
48382
|
"",
|
|
48209
|
-
|
|
48383
|
+
distinctMessages.join("\n\n")
|
|
48210
48384
|
];
|
|
48211
48385
|
if (firstDiagnostic.help) sections.push("", `Suggestion: ${firstDiagnostic.help}`);
|
|
48212
48386
|
if (firstDiagnostic.url) sections.push("", `Docs: ${firstDiagnostic.url}`);
|
|
48213
48387
|
const fixRecipeLine = formatFixRecipeLine(firstDiagnostic);
|
|
48214
48388
|
if (fixRecipeLine) sections.push("", fixRecipeLine);
|
|
48215
48389
|
sections.push("", "Files:");
|
|
48216
|
-
const
|
|
48217
|
-
for (const [filePath, sites] of
|
|
48218
|
-
sections.push(` ${filePath}:${site.line}`);
|
|
48390
|
+
const fileEntries = buildVerboseFileEntries(ruleDiagnostics);
|
|
48391
|
+
for (const [filePath, { contextTag, sites }] of fileEntries) if (sites.length > 0) for (const site of sites) {
|
|
48392
|
+
sections.push(` ${filePath}:${site.line}${contextTag}`);
|
|
48219
48393
|
if (site.suppressionHint) sections.push(` ${site.suppressionHint}`);
|
|
48220
48394
|
}
|
|
48221
|
-
else sections.push(` ${filePath}`);
|
|
48395
|
+
else sections.push(` ${filePath}${contextTag}`);
|
|
48222
48396
|
return sections.join("\n") + "\n";
|
|
48223
48397
|
};
|
|
48224
48398
|
//#endregion
|
|
@@ -48488,15 +48662,22 @@ const printNoScoreHeader = (noScoreMessage) => gen(function* () {
|
|
|
48488
48662
|
});
|
|
48489
48663
|
//#endregion
|
|
48490
48664
|
//#region src/cli/utils/write-diagnostics-directory.ts
|
|
48491
|
-
const
|
|
48492
|
-
|
|
48493
|
-
|
|
48494
|
-
|
|
48495
|
-
|
|
48496
|
-
|
|
48665
|
+
const ruleDumpFileName = (ruleKey) => ruleKey.replace(/\//g, "--") + ".txt";
|
|
48666
|
+
const readPreviousRuleDumpFileNames = (directory) => {
|
|
48667
|
+
try {
|
|
48668
|
+
const previous = JSON.parse(NFS.readFileSync(Path.join(directory, "diagnostics.json"), "utf8"));
|
|
48669
|
+
return new Set(previous.filter((d) => typeof d?.plugin === "string" && typeof d?.rule === "string").map((d) => ruleDumpFileName(`${d.plugin}/${d.rule}`)));
|
|
48670
|
+
} catch {
|
|
48671
|
+
return /* @__PURE__ */ new Set();
|
|
48497
48672
|
}
|
|
48498
|
-
|
|
48499
|
-
|
|
48673
|
+
};
|
|
48674
|
+
const writeDiagnosticsDirectory = (diagnostics, outputDirectory) => {
|
|
48675
|
+
const directory = outputDirectory ? Path.resolve(outputDirectory) : Path.join(tmpdir(), `react-doctor-${randomUUID()}`);
|
|
48676
|
+
if (outputDirectory) for (const fileName of readPreviousRuleDumpFileNames(directory)) NFS.rmSync(Path.join(directory, fileName), { force: true });
|
|
48677
|
+
NFS.mkdirSync(directory, { recursive: true });
|
|
48678
|
+
for (const [ruleKey, ruleDiagnostics] of buildSortedRuleGroups(diagnostics)) NFS.writeFileSync(Path.join(directory, ruleDumpFileName(ruleKey)), formatRuleSummary(ruleKey, ruleDiagnostics));
|
|
48679
|
+
NFS.writeFileSync(Path.join(directory, "diagnostics.json"), JSON.stringify(diagnostics));
|
|
48680
|
+
return directory;
|
|
48500
48681
|
};
|
|
48501
48682
|
//#endregion
|
|
48502
48683
|
//#region src/cli/utils/render-summary.ts
|
|
@@ -48533,6 +48714,16 @@ const printFooter = (input) => gen(function* () {
|
|
|
48533
48714
|
yield* log(` ${highlighter.bold("GitHub:")} ${highlighter.info(CANONICAL_GITHUB_URL)}`);
|
|
48534
48715
|
yield* printFooterDescription("Report issues and star the repository!");
|
|
48535
48716
|
});
|
|
48717
|
+
const printDiagnosticsDump = (diagnostics, outputDirectory, verbose, stream = "stdout") => gen(function* () {
|
|
48718
|
+
const writtenDirectory = yield* try_({
|
|
48719
|
+
try: () => writeDiagnosticsDirectory(diagnostics, outputDirectory),
|
|
48720
|
+
catch: (cause) => cause
|
|
48721
|
+
}).pipe(orElseSucceed(() => null));
|
|
48722
|
+
if (writtenDirectory !== null && (verbose || outputDirectory)) {
|
|
48723
|
+
const pathLine = highlighter.gray(` Full diagnostics written to ${writtenDirectory}`);
|
|
48724
|
+
yield* stream === "stderr" || Boolean(outputDirectory) && isJsonModeActive() ? sync(() => process.stderr.write(`${pathLine}\n`)) : log(pathLine);
|
|
48725
|
+
}
|
|
48726
|
+
});
|
|
48536
48727
|
const printSummary = (input) => gen(function* () {
|
|
48537
48728
|
if (input.scoreResult) {
|
|
48538
48729
|
const animateProjection = Boolean(input.animateProjection) && input.potentialScore != null && !input.verbose;
|
|
@@ -48543,11 +48734,7 @@ const printSummary = (input) => gen(function* () {
|
|
|
48543
48734
|
if (animateProjection) yield* animateScoreProjection(input.scoreResult, input.potentialScore, 5);
|
|
48544
48735
|
}
|
|
48545
48736
|
} else yield* printNoScoreHeader(input.noScoreMessage);
|
|
48546
|
-
|
|
48547
|
-
try: () => writeDiagnosticsDirectory(input.diagnostics),
|
|
48548
|
-
catch: (cause) => cause
|
|
48549
|
-
}).pipe(orElseSucceed(() => null));
|
|
48550
|
-
if (diagnosticsDirectory !== null && input.verbose) yield* log(highlighter.gray(` Full diagnostics written to ${diagnosticsDirectory}`));
|
|
48737
|
+
yield* printDiagnosticsDump(input.diagnostics, input.outputDirectory, input.verbose);
|
|
48551
48738
|
});
|
|
48552
48739
|
//#endregion
|
|
48553
48740
|
//#region src/cli/utils/should-auto-select-current-choice.ts
|
|
@@ -48937,6 +49124,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
48937
49124
|
lint: inputOptions.lint ?? userConfig?.lint ?? true,
|
|
48938
49125
|
deadCode: inputOptions.deadCode ?? userConfig?.deadCode ?? true,
|
|
48939
49126
|
verbose: inputOptions.verbose ?? userConfig?.verbose ?? false,
|
|
49127
|
+
outputDirectory: inputOptions.outputDirectory || null,
|
|
48940
49128
|
scoreOnly: inputOptions.scoreOnly ?? false,
|
|
48941
49129
|
noScore: inputOptions.noScore ?? userConfig?.noScore ?? false,
|
|
48942
49130
|
isCi: inputOptions.isCi ?? false,
|
|
@@ -48953,6 +49141,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
48953
49141
|
ignoredTags: buildIgnoredTags(userConfig),
|
|
48954
49142
|
outputSurface: inputOptions.outputSurface ?? "cli",
|
|
48955
49143
|
suppressRendering: inputOptions.suppressRendering ?? false,
|
|
49144
|
+
concurrentScan: inputOptions.concurrentScan ?? false,
|
|
48956
49145
|
concurrency: inputOptions.concurrency,
|
|
48957
49146
|
baseline: inputOptions.baseline ?? null,
|
|
48958
49147
|
changedLineRanges: inputOptions.changedLineRanges ?? null,
|
|
@@ -48973,13 +49162,15 @@ const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
|
|
|
48973
49162
|
noScore: options.noScore,
|
|
48974
49163
|
respectInlineDisables: options.respectInlineDisables,
|
|
48975
49164
|
showWarnings: options.warnings,
|
|
49165
|
+
usedOutputDir: options.outputDirectory !== null,
|
|
48976
49166
|
ignoredTagCount: options.ignoredTags.size,
|
|
48977
49167
|
hasCustomConfig,
|
|
48978
49168
|
userConfig
|
|
48979
49169
|
});
|
|
48980
49170
|
const inspect = async (directory, inputOptions = {}) => {
|
|
48981
49171
|
const startTime = performance$1.now();
|
|
48982
|
-
|
|
49172
|
+
const isConcurrentScan = inputOptions.concurrentScan === true;
|
|
49173
|
+
if (!isConcurrentScan) resetSentryRunState();
|
|
48983
49174
|
const hasConfigOverride = inputOptions.configOverride !== void 0;
|
|
48984
49175
|
let scanDirectory;
|
|
48985
49176
|
let userConfig;
|
|
@@ -48987,7 +49178,7 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
48987
49178
|
if (hasConfigOverride) {
|
|
48988
49179
|
scanDirectory = directory;
|
|
48989
49180
|
userConfig = inputOptions.configOverride ?? null;
|
|
48990
|
-
configSourceDirectory = null;
|
|
49181
|
+
configSourceDirectory = inputOptions.configSourceDirectory ?? null;
|
|
48991
49182
|
} else {
|
|
48992
49183
|
const scanTarget = await resolveScanTarget(directory);
|
|
48993
49184
|
scanDirectory = scanTarget.resolvedDirectory;
|
|
@@ -48995,8 +49186,9 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
48995
49186
|
configSourceDirectory = scanTarget.configSourceDirectory;
|
|
48996
49187
|
}
|
|
48997
49188
|
const options = mergeInspectOptions(inputOptions, userConfig);
|
|
49189
|
+
const ownsSpinnerSilence = options.silent && !isConcurrentScan;
|
|
48998
49190
|
const wasSpinnerSilent = isSpinnerSilent();
|
|
48999
|
-
if (
|
|
49191
|
+
if (ownsSpinnerSilence) setSpinnerSilent(true);
|
|
49000
49192
|
try {
|
|
49001
49193
|
const result = await withSentryRunSpan(async (rootSentrySpan) => {
|
|
49002
49194
|
try {
|
|
@@ -49009,11 +49201,11 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49009
49201
|
});
|
|
49010
49202
|
throw error;
|
|
49011
49203
|
}
|
|
49012
|
-
});
|
|
49013
|
-
resetSentryRunState();
|
|
49204
|
+
}, { concurrentScan: isConcurrentScan });
|
|
49205
|
+
if (!isConcurrentScan) resetSentryRunState();
|
|
49014
49206
|
return result;
|
|
49015
49207
|
} finally {
|
|
49016
|
-
if (
|
|
49208
|
+
if (ownsSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
|
|
49017
49209
|
}
|
|
49018
49210
|
};
|
|
49019
49211
|
/**
|
|
@@ -49102,7 +49294,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49102
49294
|
const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
|
|
49103
49295
|
const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
|
|
49104
49296
|
if (cachedPayload) {
|
|
49105
|
-
recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
|
|
49297
|
+
recordSentryProjectContext(cachedPayload.project, rootSentrySpan, { concurrentScan: options.concurrentScan });
|
|
49106
49298
|
recordCount(METRIC.projectDetected, 1);
|
|
49107
49299
|
await renderCachedProjectDetection({
|
|
49108
49300
|
payload: cachedPayload,
|
|
@@ -49124,7 +49316,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49124
49316
|
recordOnboardingCompletion(options);
|
|
49125
49317
|
return result;
|
|
49126
49318
|
}
|
|
49127
|
-
const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && options.lint && Boolean(resolvedNodeBinaryPath);
|
|
49319
|
+
const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && !options.suppressRendering && options.lint && Boolean(resolvedNodeBinaryPath);
|
|
49128
49320
|
const layers = buildRuntimeLayers({
|
|
49129
49321
|
directory,
|
|
49130
49322
|
hasConfigOverride,
|
|
@@ -49153,7 +49345,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49153
49345
|
suppressScanSummary: options.suppressRendering,
|
|
49154
49346
|
supplyChainManifestChanged: options.supplyChainManifestChanged
|
|
49155
49347
|
}, { beforeLint: (projectInfo, lintIncludePaths) => gen(function* () {
|
|
49156
|
-
recordSentryProjectContext(projectInfo, rootSentrySpan);
|
|
49348
|
+
recordSentryProjectContext(projectInfo, rootSentrySpan, { concurrentScan: options.concurrentScan });
|
|
49157
49349
|
recordCount(METRIC.projectDetected, 1);
|
|
49158
49350
|
if (options.scoreOnly || options.suppressRendering) return;
|
|
49159
49351
|
const lintSourceFileCount = lintIncludePaths?.length ?? projectInfo.sourceFileCount;
|
|
@@ -49303,15 +49495,16 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49303
49495
|
...baselineDelta ? { baselineDelta } : {}
|
|
49304
49496
|
});
|
|
49305
49497
|
if (options.suppressRendering) return buildResult();
|
|
49498
|
+
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
49499
|
+
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
49306
49500
|
if (options.scoreOnly) {
|
|
49501
|
+
if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory, false, "stderr");
|
|
49307
49502
|
if (score) yield* log(`${score.score}`);
|
|
49308
|
-
else yield*
|
|
49503
|
+
else yield* error$1(highlighter.gray(noScoreMessage));
|
|
49309
49504
|
return buildResult();
|
|
49310
49505
|
}
|
|
49311
49506
|
const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
|
|
49312
49507
|
const pause = onboardingSectionPause(animateRender);
|
|
49313
|
-
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
49314
|
-
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
49315
49508
|
const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
|
|
49316
49509
|
const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
|
|
49317
49510
|
if (printedDiagnostics.length === 0) {
|
|
@@ -49329,6 +49522,7 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49329
49522
|
yield* log(highlighter.gray(" Score not shown — some checks could not complete."));
|
|
49330
49523
|
} else if (score) yield* printScoreHeader(score);
|
|
49331
49524
|
else yield* printNoScoreHeader(noScoreMessage);
|
|
49525
|
+
if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory);
|
|
49332
49526
|
return buildResult();
|
|
49333
49527
|
}
|
|
49334
49528
|
yield* pause;
|
|
@@ -49353,6 +49547,7 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49353
49547
|
totalSourceFileCount: lintSourceFileCount,
|
|
49354
49548
|
noScoreMessage,
|
|
49355
49549
|
verbose: options.verbose,
|
|
49550
|
+
outputDirectory: options.outputDirectory,
|
|
49356
49551
|
animateProjection: animateRender
|
|
49357
49552
|
});
|
|
49358
49553
|
if (hasSkippedChecks) {
|
|
@@ -49524,9 +49719,9 @@ const isExpectedUserError = (error) => error instanceof CliInputError || isProje
|
|
|
49524
49719
|
//#region src/cli/utils/build-handoff-payload.ts
|
|
49525
49720
|
const buildHandoffPayload = (input) => {
|
|
49526
49721
|
const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
|
|
49527
|
-
let
|
|
49722
|
+
let outputDirectory = null;
|
|
49528
49723
|
try {
|
|
49529
|
-
|
|
49724
|
+
outputDirectory = writeDiagnosticsDirectory([...input.diagnostics], input.outputDirectory);
|
|
49530
49725
|
} catch {}
|
|
49531
49726
|
const lines = [
|
|
49532
49727
|
"Before fixing anything, first ask me whether I'd like to add React Doctor to CI so every pull request is scanned automatically. Explain that:",
|
|
@@ -49553,7 +49748,7 @@ const buildHandoffPayload = (input) => {
|
|
|
49553
49748
|
if (remainingFiles > 0) lines.push(` - +${remainingFiles} more files`);
|
|
49554
49749
|
});
|
|
49555
49750
|
lines.push("");
|
|
49556
|
-
if (
|
|
49751
|
+
if (outputDirectory) lines.push(`Full results for all ${input.diagnostics.length} issues (diagnostics.json + a .txt per rule): ${outputDirectory}`, "");
|
|
49557
49752
|
lines.push("Read each file and fix the root cause — don't suppress or silence the rule.", "", "Verify against the real thing, don't assume: confirm each change matches the canonical fix recipe you fetched for that rule, then re-run `npx react-doctor@latest --verbose` and check the issue is actually gone against the real tool before moving on.", "", "Teach me as you go: for every issue you touch, explain it in plain language (no jargon) — what the problem is, why it's a problem, and how serious it is in human terms. Describe the real-world impact and severity concretely (e.g. \"this crashes the page for users on Safari\" vs. \"this is a minor cleanup with no user impact\") so I understand why it matters, not just what changed.", "", "Then work through the rest from the full results above.");
|
|
49558
49753
|
return lines.join("\n");
|
|
49559
49754
|
};
|
|
@@ -51452,7 +51647,8 @@ const handoffToAgent = async (input) => {
|
|
|
51452
51647
|
if (handoffTarget === void 0 || handoffTarget === SKIP_CHOICE) return;
|
|
51453
51648
|
const payload = buildHandoffPayload({
|
|
51454
51649
|
diagnostics: input.diagnostics,
|
|
51455
|
-
projectName: input.projectName
|
|
51650
|
+
projectName: input.projectName,
|
|
51651
|
+
outputDirectory: input.outputDirectory
|
|
51456
51652
|
});
|
|
51457
51653
|
if (handoffTarget === CLIPBOARD_CHOICE) {
|
|
51458
51654
|
if (await copyToClipboard(payload)) cliLogger.log("Copied the prompt to your clipboard.");
|
|
@@ -51673,6 +51869,9 @@ const readChangedFilesFrom = (filePath) => {
|
|
|
51673
51869
|
return [...uniqueFiles];
|
|
51674
51870
|
};
|
|
51675
51871
|
//#endregion
|
|
51872
|
+
//#region src/cli/utils/filter-scans-for-surface.ts
|
|
51873
|
+
const filterScansForSurface = (completedScans, surface) => completedScans.flatMap((scan) => filterDiagnosticsForSurface([...scan.result.diagnostics], surface, scan.config));
|
|
51874
|
+
//#endregion
|
|
51676
51875
|
//#region src/cli/utils/render-multi-project-summary.ts
|
|
51677
51876
|
const getScoreLabel = (score) => {
|
|
51678
51877
|
if (score >= 75) return "Great";
|
|
@@ -51700,10 +51899,10 @@ const findLowestScoredScan = (completedScans) => {
|
|
|
51700
51899
|
return scoredScans.reduce((worst, scan) => scan.result.score.score < worst.result.score.score ? scan : worst);
|
|
51701
51900
|
};
|
|
51702
51901
|
const printMultiProjectSummary = (input) => gen(function* () {
|
|
51703
|
-
const { completedScans,
|
|
51902
|
+
const { completedScans, verbose, isOffline, projectName, totalElapsedMilliseconds } = input;
|
|
51704
51903
|
const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
|
|
51705
51904
|
const animateRender = !verbose && canAnimateOnboarding(process.stdout);
|
|
51706
|
-
const displayDiagnostics = filterDiagnosticsByCategories(
|
|
51905
|
+
const displayDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, "cli"), categoryFilters);
|
|
51707
51906
|
const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
|
|
51708
51907
|
for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
|
|
51709
51908
|
const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
|
|
@@ -51715,8 +51914,7 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51715
51914
|
else fileCountFromScansWithoutPaths += scan.result.scannedFileCount ?? scan.result.project.sourceFileCount;
|
|
51716
51915
|
}
|
|
51717
51916
|
const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
|
|
51718
|
-
|
|
51719
|
-
yield* log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalScanElapsedMilliseconds)}`);
|
|
51917
|
+
yield* log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalElapsedMilliseconds)}`);
|
|
51720
51918
|
if (displayDiagnostics.length > 0) {
|
|
51721
51919
|
yield* log("");
|
|
51722
51920
|
yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
|
|
@@ -51726,16 +51924,17 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51726
51924
|
const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
|
|
51727
51925
|
yield* printSummary({
|
|
51728
51926
|
diagnostics: displayDiagnostics,
|
|
51729
|
-
elapsedMilliseconds:
|
|
51927
|
+
elapsedMilliseconds: totalElapsedMilliseconds,
|
|
51730
51928
|
scoreResult: aggregateScore,
|
|
51731
|
-
potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics,
|
|
51929
|
+
potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics, filterScansForSurface([lowestScoredScan], "cli"), lowestScoredScan.result.score)) : null,
|
|
51732
51930
|
totalSourceFileCount,
|
|
51733
51931
|
noScoreMessage: "Score unavailable.",
|
|
51734
51932
|
verbose,
|
|
51933
|
+
outputDirectory: input.outputDirectory,
|
|
51735
51934
|
animateProjection: animateRender
|
|
51736
51935
|
});
|
|
51737
51936
|
const entries = completedScans.map((scan) => {
|
|
51738
|
-
const projectDiagnostics = filterDiagnosticsByCategories(
|
|
51937
|
+
const projectDiagnostics = filterDiagnosticsByCategories(filterScansForSurface([scan], "cli"), categoryFilters);
|
|
51739
51938
|
const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
51740
51939
|
return {
|
|
51741
51940
|
projectName: scan.result.project.projectName,
|
|
@@ -51832,6 +52031,7 @@ const resolveCliInspectOptions = (flags, userConfig) => {
|
|
|
51832
52031
|
lint: flags.lint,
|
|
51833
52032
|
deadCode: flags.deadCode,
|
|
51834
52033
|
verbose: flags.verbose,
|
|
52034
|
+
outputDirectory: flags.outputDir,
|
|
51835
52035
|
respectInlineDisables: flags.respectInlineDisables === false ? false : void 0,
|
|
51836
52036
|
warnings: wantsWarningGate ? true : flags.warnings,
|
|
51837
52037
|
scoreOnly: flags.score === true,
|
|
@@ -52081,16 +52281,22 @@ const parseFileLineArgument = (rawArgument) => {
|
|
|
52081
52281
|
};
|
|
52082
52282
|
//#endregion
|
|
52083
52283
|
//#region src/cli/utils/select-projects.ts
|
|
52084
|
-
const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
|
|
52284
|
+
const selectProjects = async (rootDirectory, projectFlag, skipPrompts, configProjects) => {
|
|
52085
52285
|
const hasRootPackageJson = isFile(Path.join(rootDirectory, "package.json"));
|
|
52086
52286
|
let packages = listWorkspacePackages(rootDirectory);
|
|
52087
52287
|
if (packages.length === 0 && (!hasRootPackageJson || isMonorepoRoot(rootDirectory))) packages = discoverReactSubprojects(rootDirectory);
|
|
52288
|
+
if (projectFlag) return resolveProjectFlag(projectFlag, packages, rootDirectory);
|
|
52289
|
+
const configRequestedNames = (configProjects ?? []).map((requestedName) => requestedName.trim()).filter((requestedName) => requestedName.length > 0);
|
|
52290
|
+
if (configRequestedNames.length > 0) {
|
|
52291
|
+
const resolvedDirectories = resolveRequestedProjects(configRequestedNames, packages, rootDirectory, "config");
|
|
52292
|
+
recordCount(METRIC.projectConfigSelected, resolvedDirectories.length);
|
|
52293
|
+
return resolvedDirectories;
|
|
52294
|
+
}
|
|
52088
52295
|
if (packages.length === 0) return [rootDirectory];
|
|
52089
52296
|
if (packages.length === 1) {
|
|
52090
52297
|
cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages[0].name}`);
|
|
52091
52298
|
return [packages[0].directory];
|
|
52092
52299
|
}
|
|
52093
|
-
if (projectFlag) return resolveProjectFlag(projectFlag, packages);
|
|
52094
52300
|
if (skipPrompts) {
|
|
52095
52301
|
printDiscoveredProjects(packages);
|
|
52096
52302
|
return packages.map((workspacePackage) => workspacePackage.directory);
|
|
@@ -52098,17 +52304,25 @@ const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
|
|
|
52098
52304
|
return promptProjectSelection(packages, rootDirectory);
|
|
52099
52305
|
};
|
|
52100
52306
|
const ALL_PROJECTS_SENTINEL = "*";
|
|
52101
|
-
const resolveProjectFlag = (projectFlag, workspacePackages) => {
|
|
52307
|
+
const resolveProjectFlag = (projectFlag, workspacePackages, rootDirectory) => {
|
|
52102
52308
|
const requestedNames = projectFlag.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
52103
52309
|
if (requestedNames.length === 0) throw new CliInputError(`--project "${projectFlag}" did not name any project. Pass a project name, a comma-separated list, or "*" for all.`);
|
|
52104
|
-
|
|
52105
|
-
|
|
52106
|
-
|
|
52310
|
+
return resolveRequestedProjects(requestedNames, workspacePackages, rootDirectory, "flag");
|
|
52311
|
+
};
|
|
52312
|
+
const resolveRequestedProjects = (requestedNames, workspacePackages, rootDirectory, source) => {
|
|
52313
|
+
if (requestedNames.includes(ALL_PROJECTS_SENTINEL)) return workspacePackages.length > 0 ? workspacePackages.map((workspacePackage) => workspacePackage.directory) : [rootDirectory];
|
|
52314
|
+
const sourceLabel = source === "flag" ? "Project" : "Config \"projects\" entry";
|
|
52315
|
+
return requestedNames.map((requestedName) => {
|
|
52107
52316
|
const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || Path.basename(workspacePackage.directory) === requestedName);
|
|
52108
|
-
if (
|
|
52109
|
-
|
|
52110
|
-
|
|
52111
|
-
|
|
52317
|
+
if (matched) return matched.directory;
|
|
52318
|
+
const candidateDirectory = Path.resolve(rootDirectory, requestedName);
|
|
52319
|
+
if (isDirectory(candidateDirectory)) {
|
|
52320
|
+
recordCount(METRIC.projectPathSelected);
|
|
52321
|
+
return candidateDirectory;
|
|
52322
|
+
}
|
|
52323
|
+
const availableNames = workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ");
|
|
52324
|
+
throw new CliInputError(workspacePackages.length > 0 ? `${sourceLabel} "${requestedName}" is not a workspace project or a directory. Available projects: ${availableNames}` : `${sourceLabel} "${requestedName}" is not a directory under ${rootDirectory}.`);
|
|
52325
|
+
});
|
|
52112
52326
|
};
|
|
52113
52327
|
const printDiscoveredProjects = (packages) => {
|
|
52114
52328
|
cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
|
|
@@ -52303,7 +52517,7 @@ const finalizeScans = (input) => {
|
|
|
52303
52517
|
}));
|
|
52304
52518
|
}
|
|
52305
52519
|
if (input.isScoreOnly || baselineDegraded) return;
|
|
52306
|
-
if (shouldBlockCi(
|
|
52520
|
+
if (shouldBlockCi(filterScansForSurface(input.completedScans, "ciFailure"), resolveBlockingLevel(input.flags, input.userConfig))) process.exitCode = 1;
|
|
52307
52521
|
};
|
|
52308
52522
|
const buildChangedFilesDiffInfo = (changedFiles) => ({
|
|
52309
52523
|
currentBranch: process.env.GITHUB_HEAD_REF?.trim() || null,
|
|
@@ -52436,7 +52650,6 @@ const inspectAction = async (directory, flags) => {
|
|
|
52436
52650
|
filePath: Path.isAbsolute(diagnostic.filePath) ? diagnostic.filePath.replaceAll(snapshot.tempDirectory, () => resolvedDirectory) : diagnostic.filePath
|
|
52437
52651
|
}));
|
|
52438
52652
|
finalizeScans({
|
|
52439
|
-
diagnostics: remappedDiagnostics,
|
|
52440
52653
|
completedScans: [{
|
|
52441
52654
|
directory: resolvedDirectory,
|
|
52442
52655
|
result: {
|
|
@@ -52446,7 +52659,8 @@ const inspectAction = async (directory, flags) => {
|
|
|
52446
52659
|
...scanResult.project,
|
|
52447
52660
|
rootDirectory: resolvedDirectory
|
|
52448
52661
|
}
|
|
52449
|
-
}
|
|
52662
|
+
},
|
|
52663
|
+
config: userConfig
|
|
52450
52664
|
}],
|
|
52451
52665
|
mode: "staged",
|
|
52452
52666
|
diff: null,
|
|
@@ -52464,7 +52678,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
52464
52678
|
}
|
|
52465
52679
|
return;
|
|
52466
52680
|
}
|
|
52467
|
-
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
|
|
52681
|
+
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts, userConfig?.projects);
|
|
52468
52682
|
const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
|
|
52469
52683
|
const requestedScope = resolveScope(flags, userConfig);
|
|
52470
52684
|
const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
|
|
@@ -52502,56 +52716,87 @@ const inspectAction = async (directory, flags) => {
|
|
|
52502
52716
|
}
|
|
52503
52717
|
cliLogger.break();
|
|
52504
52718
|
}
|
|
52505
|
-
const allDiagnostics = [];
|
|
52506
52719
|
const completedScans = [];
|
|
52507
52720
|
const isMultiProject = projectDirectories.length > 1;
|
|
52508
|
-
const
|
|
52509
|
-
|
|
52721
|
+
const scanProject = async (projectDirectory) => {
|
|
52722
|
+
const projectScanTarget = projectDirectory === resolvedDirectory ? scanTarget : await resolveScanTarget(projectDirectory, { allowAmbiguous: true });
|
|
52723
|
+
const scanDirectory = projectScanTarget.resolvedDirectory;
|
|
52724
|
+
const projectConfig = projectDirectory === resolvedDirectory ? userConfig : mergeReactDoctorConfigs(userConfig, projectScanTarget.userConfig ?? void 0);
|
|
52725
|
+
const projectConfigSourceDirectory = projectScanTarget.userConfig?.plugins === void 0 ? scanTarget.configSourceDirectory : projectScanTarget.configSourceDirectory;
|
|
52726
|
+
const supplyChainEnabled = projectConfig?.supplyChain?.enabled !== false;
|
|
52510
52727
|
let includePaths;
|
|
52511
52728
|
let supplyChainManifestChanged = false;
|
|
52512
52729
|
if (isDiffMode) {
|
|
52513
|
-
const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory,
|
|
52514
|
-
supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory,
|
|
52730
|
+
const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory, scanDirectory, diffInfo);
|
|
52731
|
+
supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory, scanDirectory, diffInfo);
|
|
52515
52732
|
if (changedSourceFiles.length === 0 && !supplyChainManifestChanged) {
|
|
52516
52733
|
if (!isQuiet) {
|
|
52517
|
-
cliLogger.dim(`No changed source files in ${
|
|
52734
|
+
cliLogger.dim(`No changed source files in ${scanDirectory}, skipping.`);
|
|
52518
52735
|
cliLogger.break();
|
|
52519
52736
|
}
|
|
52520
|
-
|
|
52737
|
+
return null;
|
|
52521
52738
|
}
|
|
52522
52739
|
includePaths = [...changedSourceFiles];
|
|
52523
52740
|
if (supplyChainManifestChanged) includePaths.push("package.json");
|
|
52524
52741
|
}
|
|
52525
52742
|
if (!isQuiet && !isMultiProject) cliLogger.dim(" ");
|
|
52526
|
-
const scanResult = await inspect(
|
|
52743
|
+
const scanResult = await inspect(scanDirectory, {
|
|
52527
52744
|
...scanOptions,
|
|
52528
52745
|
includePaths,
|
|
52529
|
-
configOverride:
|
|
52746
|
+
configOverride: projectConfig,
|
|
52747
|
+
configSourceDirectory: projectConfigSourceDirectory ?? void 0,
|
|
52530
52748
|
suppressRendering: isMultiProject,
|
|
52749
|
+
concurrentScan: isMultiProject,
|
|
52531
52750
|
baseline: baselineRef ? { ref: baselineRef } : void 0,
|
|
52532
|
-
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory,
|
|
52751
|
+
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, scanDirectory, changedLineRanges) : void 0,
|
|
52533
52752
|
supplyChainManifestChanged
|
|
52534
52753
|
});
|
|
52535
|
-
allDiagnostics.push(...scanResult.diagnostics);
|
|
52536
|
-
completedScans.push({
|
|
52537
|
-
directory: projectDirectory,
|
|
52538
|
-
result: scanResult
|
|
52539
|
-
});
|
|
52540
52754
|
if (!isQuiet && !isMultiProject) cliLogger.break();
|
|
52755
|
+
return {
|
|
52756
|
+
directory: scanDirectory,
|
|
52757
|
+
result: scanResult,
|
|
52758
|
+
config: projectConfig
|
|
52759
|
+
};
|
|
52760
|
+
};
|
|
52761
|
+
const scanLoopStartTime = performance$1.now();
|
|
52762
|
+
const projectCount = projectDirectories.length;
|
|
52763
|
+
const batchSpinner = isMultiProject && !isQuiet ? spinner(`Scanning ${projectCount} projects…`).start() : null;
|
|
52764
|
+
const ownsBatchSpinnerSilence = isMultiProject && scanOptions.silent === true;
|
|
52765
|
+
const wasSpinnerSilent = isSpinnerSilent();
|
|
52766
|
+
if (ownsBatchSpinnerSilence) setSpinnerSilent(true);
|
|
52767
|
+
let finishedProjectCount = 0;
|
|
52768
|
+
let scanOutcomes;
|
|
52769
|
+
try {
|
|
52770
|
+
scanOutcomes = await mapWithConcurrency(projectDirectories, isMultiProject ? 4 : 1, async (projectDirectory) => {
|
|
52771
|
+
const scanOutcome = await scanProject(projectDirectory);
|
|
52772
|
+
finishedProjectCount += 1;
|
|
52773
|
+
batchSpinner?.update(`Scanning ${projectCount} projects… (${finishedProjectCount}/${projectCount})`);
|
|
52774
|
+
return scanOutcome;
|
|
52775
|
+
});
|
|
52776
|
+
} finally {
|
|
52777
|
+
if (ownsBatchSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
|
|
52778
|
+
batchSpinner?.stop();
|
|
52779
|
+
}
|
|
52780
|
+
for (const scanOutcome of scanOutcomes) {
|
|
52781
|
+
if (scanOutcome === null) continue;
|
|
52782
|
+
completedScans.push(scanOutcome);
|
|
52541
52783
|
}
|
|
52542
52784
|
if (!isQuiet && isMultiProject && completedScans.length > 0) {
|
|
52543
52785
|
const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
|
|
52544
52786
|
await runPromise(printMultiProjectSummary({
|
|
52545
52787
|
completedScans,
|
|
52546
52788
|
categoryFilters,
|
|
52547
|
-
userConfig,
|
|
52548
52789
|
verbose: Boolean(flags.verbose),
|
|
52790
|
+
outputDirectory: flags.outputDir,
|
|
52549
52791
|
isOffline: !shouldShowShareLink,
|
|
52550
|
-
projectName: Path.basename(resolvedDirectory)
|
|
52792
|
+
projectName: Path.basename(resolvedDirectory),
|
|
52793
|
+
totalElapsedMilliseconds: performance$1.now() - scanLoopStartTime
|
|
52551
52794
|
}));
|
|
52552
52795
|
}
|
|
52796
|
+
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, scanOptions.outputSurface ?? "cli"), categoryFilters);
|
|
52797
|
+
const didScansWriteDump = isMultiProject ? !isQuiet && completedScans.length > 0 : completedScans.length > 0;
|
|
52798
|
+
if (flags.outputDir && !didScansWriteDump) await runPromise(printDiagnosticsDump(selectedSurfaceDiagnostics, flags.outputDir, false, isQuiet ? "stderr" : "stdout"));
|
|
52553
52799
|
finalizeScans({
|
|
52554
|
-
diagnostics: allDiagnostics,
|
|
52555
52800
|
completedScans,
|
|
52556
52801
|
mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
|
|
52557
52802
|
diff: isDiffMode ? diffInfo : null,
|
|
@@ -52564,13 +52809,13 @@ const inspectAction = async (directory, flags) => {
|
|
|
52564
52809
|
resolvedDirectory,
|
|
52565
52810
|
startTime
|
|
52566
52811
|
});
|
|
52567
|
-
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
|
|
52568
52812
|
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
|
|
52569
52813
|
await handoffToAgent({
|
|
52570
52814
|
diagnostics: selectedSurfaceDiagnostics,
|
|
52571
52815
|
projectName: Path.basename(resolvedDirectory),
|
|
52572
52816
|
rootDirectory: resolvedDirectory,
|
|
52573
|
-
interactive: true
|
|
52817
|
+
interactive: true,
|
|
52818
|
+
outputDirectory: flags.outputDir
|
|
52574
52819
|
});
|
|
52575
52820
|
return;
|
|
52576
52821
|
}
|
|
@@ -53366,6 +53611,7 @@ const ROOT_FLAG_SPEC = {
|
|
|
53366
53611
|
"--category",
|
|
53367
53612
|
"--changed-files-from",
|
|
53368
53613
|
"--blocking",
|
|
53614
|
+
"--output-dir",
|
|
53369
53615
|
"--fail-on",
|
|
53370
53616
|
"--project",
|
|
53371
53617
|
"--scope"
|
|
@@ -53520,6 +53766,7 @@ ${formatExampleLines([
|
|
|
53520
53766
|
["react-doctor", "scan the current project"],
|
|
53521
53767
|
["react-doctor ./apps/web", "scan a specific directory"],
|
|
53522
53768
|
["react-doctor --diff main", "scan only files changed vs. main"],
|
|
53769
|
+
["react-doctor --project modules/a,modules/b", "score each module separately (names or paths)"],
|
|
53523
53770
|
["react-doctor --staged", "scan staged files (pre-commit hook)"],
|
|
53524
53771
|
["react-doctor --category Security", "show only one diagnostic category"],
|
|
53525
53772
|
["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
|
|
@@ -53551,9 +53798,9 @@ ${highlighter.dim("Learn more:")}
|
|
|
53551
53798
|
${highlighter.info(CANONICAL_GITHUB_URL)}
|
|
53552
53799
|
`;
|
|
53553
53800
|
const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
|
|
53554
|
-
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
|
|
53801
|
+
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("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").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 projects: workspace names or directory paths (comma-separated for multiple); overrides the `projects` config field").option("--scope <value>", "how much to scan/report: full (default), files, changed (only new issues vs base), or lines (only changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--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("--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("--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("--sfw", "demo: print the Socket.dev supply-chain score of every direct dependency, then exit").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
|
|
53555
53802
|
program.action(inspectAction);
|
|
53556
|
-
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
|
|
53803
|
+
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 projects: workspace names or directory paths (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));
|
|
53557
53804
|
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);
|
|
53558
53805
|
program.command("version").description("show the version with Node and platform info").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action(versionAction);
|
|
53559
53806
|
const rules = program.command("rules").description("List, explain, and configure which React Doctor rules run");
|
|
@@ -53594,4 +53841,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
53594
53841
|
export {};
|
|
53595
53842
|
|
|
53596
53843
|
//# sourceMappingURL=cli.js.map
|
|
53597
|
-
//# debugId=
|
|
53844
|
+
//# debugId=74796c64-5e08-5b67-b3ec-6294b1811a26
|