react-doctor 0.5.1-dev.22268f7 → 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 +332 -126
- package/dist/index.d.ts +84 -39
- package/dist/index.js +225 -45
- package/dist/lsp.js +127 -40
- 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 } : {},
|
|
@@ -43496,6 +43580,48 @@ const groupBy = (items, keyFn) => {
|
|
|
43496
43580
|
* a 404. Gate the directive on this predicate.
|
|
43497
43581
|
*/
|
|
43498
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
|
+
};
|
|
43499
43625
|
//#endregion
|
|
43500
43626
|
//#region src/cli/utils/is-ci-environment.ts
|
|
43501
43627
|
const CI_ENVIRONMENT_VARIABLES = [
|
|
@@ -43604,6 +43730,8 @@ const METRIC = {
|
|
|
43604
43730
|
cliInvoked: "cli.invoked",
|
|
43605
43731
|
cliError: "cli.error",
|
|
43606
43732
|
projectDetected: "project.detected",
|
|
43733
|
+
projectPathSelected: "project.path_selected",
|
|
43734
|
+
projectConfigSelected: "project.config_selected",
|
|
43607
43735
|
scanCompleted: "scan.completed",
|
|
43608
43736
|
scanDuration: "scan.duration",
|
|
43609
43737
|
scanPhaseDuration: "scan.phase_duration",
|
|
@@ -43673,7 +43801,7 @@ const makeNoopConsole = () => ({
|
|
|
43673
43801
|
});
|
|
43674
43802
|
//#endregion
|
|
43675
43803
|
//#region src/cli/utils/version.ts
|
|
43676
|
-
const VERSION = "0.5.1-dev.
|
|
43804
|
+
const VERSION = "0.5.1-dev.3de9106";
|
|
43677
43805
|
//#endregion
|
|
43678
43806
|
//#region src/cli/utils/json-mode.ts
|
|
43679
43807
|
let context = null;
|
|
@@ -44031,13 +44159,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
44031
44159
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
44032
44160
|
* standard `SENTRY_RELEASE` override.
|
|
44033
44161
|
*/
|
|
44034
|
-
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`;
|
|
44035
44163
|
/**
|
|
44036
44164
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
44037
44165
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
44038
44166
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
44039
44167
|
*/
|
|
44040
|
-
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");
|
|
44041
44169
|
/**
|
|
44042
44170
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
44043
44171
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -47335,12 +47463,13 @@ const toSpanAttributes = (tags) => {
|
|
|
47335
47463
|
/**
|
|
47336
47464
|
* Clears the module-level run-scoped Sentry state — the current scanned project
|
|
47337
47465
|
* and the active run trace. `inspect()` calls this at the start of every run and
|
|
47338
|
-
* again after a clean one
|
|
47339
|
-
*
|
|
47340
|
-
*
|
|
47341
|
-
*
|
|
47342
|
-
*
|
|
47343
|
-
*
|
|
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).
|
|
47344
47473
|
*/
|
|
47345
47474
|
const resetSentryRunState = () => {
|
|
47346
47475
|
setSentryProjectInfo(null);
|
|
@@ -47363,8 +47492,13 @@ const resetSentryRunState = () => {
|
|
|
47363
47492
|
* state right after a clean run and at the start of the next one, so the trace
|
|
47364
47493
|
* is never attached to a non-scan error; on a thrown error the state is left in
|
|
47365
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.
|
|
47366
47500
|
*/
|
|
47367
|
-
const withSentryRunSpan = (run) => {
|
|
47501
|
+
const withSentryRunSpan = (run, options = {}) => {
|
|
47368
47502
|
if (!isSentryTracingEnabled()) return run(void 0);
|
|
47369
47503
|
const { tags } = buildSentryScope();
|
|
47370
47504
|
const command = typeof tags.command === "string" ? tags.command : "inspect";
|
|
@@ -47373,12 +47507,14 @@ const withSentryRunSpan = (run) => {
|
|
|
47373
47507
|
op: "cli.inspect",
|
|
47374
47508
|
attributes: toSpanAttributes(tags)
|
|
47375
47509
|
}, (rootSpan) => {
|
|
47376
|
-
|
|
47377
|
-
|
|
47378
|
-
|
|
47379
|
-
|
|
47380
|
-
|
|
47381
|
-
|
|
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
|
+
}
|
|
47382
47518
|
return run(rootSpan);
|
|
47383
47519
|
});
|
|
47384
47520
|
};
|
|
@@ -47389,9 +47525,15 @@ const withSentryRunSpan = (run) => {
|
|
|
47389
47525
|
* run's root span so the transaction/trace carries the project shape too.
|
|
47390
47526
|
* Always cheap — the span attribute set is skipped when `rootSpan` is absent
|
|
47391
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).
|
|
47392
47534
|
*/
|
|
47393
|
-
const recordSentryProjectContext = (projectInfo, rootSpan) => {
|
|
47394
|
-
setSentryProjectInfo(projectInfo);
|
|
47535
|
+
const recordSentryProjectContext = (projectInfo, rootSpan, options = {}) => {
|
|
47536
|
+
if (options.concurrentScan !== true) setSentryProjectInfo(projectInfo);
|
|
47395
47537
|
rootSpan?.setAttributes(toSpanAttributes(buildSentryProjectContext(projectInfo).tags));
|
|
47396
47538
|
};
|
|
47397
47539
|
//#endregion
|
|
@@ -47628,6 +47770,12 @@ const buildOutcomeAttributes = (input) => {
|
|
|
47628
47770
|
topRule = rule;
|
|
47629
47771
|
topRuleCount = count;
|
|
47630
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
|
+
}
|
|
47631
47779
|
const attributes = {
|
|
47632
47780
|
outcome,
|
|
47633
47781
|
exitCode: wouldBlock ? 1 : 0,
|
|
@@ -47638,6 +47786,8 @@ const buildOutcomeAttributes = (input) => {
|
|
|
47638
47786
|
errorCount: summary.errorCount,
|
|
47639
47787
|
warningCount: summary.warningCount,
|
|
47640
47788
|
affectedFiles: summary.affectedFileCount,
|
|
47789
|
+
diagnosticsInTestFiles,
|
|
47790
|
+
diagnosticsInStoryFiles,
|
|
47641
47791
|
distinctRulesFired: countByRule.size,
|
|
47642
47792
|
topRule,
|
|
47643
47793
|
scannedFileCount: result.scannedFileCount ?? null,
|
|
@@ -47970,17 +48120,24 @@ const writeStdout = (text) => sync(() => {
|
|
|
47970
48120
|
const POINTER = isUnicodeSupported() ? "›" : ">";
|
|
47971
48121
|
const colorizeBySeverity = (text, severity) => severity === "error" ? highlighter.error(text) : highlighter.warn(text);
|
|
47972
48122
|
const collectAffectedFiles = (diagnostics) => new Set(diagnostics.map((diagnostic) => diagnostic.filePath));
|
|
47973
|
-
const
|
|
47974
|
-
|
|
48123
|
+
const formatFileContextTag = (diagnostic) => diagnostic.fileContext ? ` (${diagnostic.fileContext} file)` : "";
|
|
48124
|
+
const buildVerboseFileEntries = (diagnostics) => {
|
|
48125
|
+
const fileEntries = /* @__PURE__ */ new Map();
|
|
47975
48126
|
for (const diagnostic of diagnostics) {
|
|
47976
|
-
|
|
47977
|
-
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({
|
|
47978
48136
|
line: diagnostic.line,
|
|
47979
48137
|
suppressionHint: diagnostic.suppressionHint
|
|
47980
48138
|
});
|
|
47981
|
-
fileSites.set(diagnostic.filePath, sites);
|
|
47982
48139
|
}
|
|
47983
|
-
return
|
|
48140
|
+
return fileEntries;
|
|
47984
48141
|
};
|
|
47985
48142
|
const formatSiteCountBadge = (count) => count > 1 ? `×${count}` : "";
|
|
47986
48143
|
const formatTrailingSiteBadge = (count) => {
|
|
@@ -48069,10 +48226,11 @@ const clusterNearbyDiagnostics = (diagnostics) => {
|
|
|
48069
48226
|
return clusters;
|
|
48070
48227
|
};
|
|
48071
48228
|
const formatClusterLocation = (cluster) => {
|
|
48072
|
-
const
|
|
48073
|
-
|
|
48074
|
-
if (cluster.
|
|
48075
|
-
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}`;
|
|
48076
48234
|
};
|
|
48077
48235
|
const buildDiagnosticClusterLines = (cluster, resolveSourceRoot, renderCodeFrame) => {
|
|
48078
48236
|
const lead = cluster.diagnostics[0];
|
|
@@ -48215,25 +48373,26 @@ const formatElapsedTime = (elapsedMilliseconds) => {
|
|
|
48215
48373
|
};
|
|
48216
48374
|
const formatRuleSummary = (ruleKey, ruleDiagnostics) => {
|
|
48217
48375
|
const firstDiagnostic = ruleDiagnostics[0];
|
|
48376
|
+
const distinctMessages = [...new Set(ruleDiagnostics.map((diagnostic) => diagnostic.message))];
|
|
48218
48377
|
const sections = [
|
|
48219
48378
|
`Rule: ${ruleKey}`,
|
|
48220
48379
|
`Severity: ${firstDiagnostic.severity}`,
|
|
48221
48380
|
`Category: ${firstDiagnostic.category}`,
|
|
48222
48381
|
`Count: ${ruleDiagnostics.length}`,
|
|
48223
48382
|
"",
|
|
48224
|
-
|
|
48383
|
+
distinctMessages.join("\n\n")
|
|
48225
48384
|
];
|
|
48226
48385
|
if (firstDiagnostic.help) sections.push("", `Suggestion: ${firstDiagnostic.help}`);
|
|
48227
48386
|
if (firstDiagnostic.url) sections.push("", `Docs: ${firstDiagnostic.url}`);
|
|
48228
48387
|
const fixRecipeLine = formatFixRecipeLine(firstDiagnostic);
|
|
48229
48388
|
if (fixRecipeLine) sections.push("", fixRecipeLine);
|
|
48230
48389
|
sections.push("", "Files:");
|
|
48231
|
-
const
|
|
48232
|
-
for (const [filePath, sites] of
|
|
48233
|
-
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}`);
|
|
48234
48393
|
if (site.suppressionHint) sections.push(` ${site.suppressionHint}`);
|
|
48235
48394
|
}
|
|
48236
|
-
else sections.push(` ${filePath}`);
|
|
48395
|
+
else sections.push(` ${filePath}${contextTag}`);
|
|
48237
48396
|
return sections.join("\n") + "\n";
|
|
48238
48397
|
};
|
|
48239
48398
|
//#endregion
|
|
@@ -48982,6 +49141,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
48982
49141
|
ignoredTags: buildIgnoredTags(userConfig),
|
|
48983
49142
|
outputSurface: inputOptions.outputSurface ?? "cli",
|
|
48984
49143
|
suppressRendering: inputOptions.suppressRendering ?? false,
|
|
49144
|
+
concurrentScan: inputOptions.concurrentScan ?? false,
|
|
48985
49145
|
concurrency: inputOptions.concurrency,
|
|
48986
49146
|
baseline: inputOptions.baseline ?? null,
|
|
48987
49147
|
changedLineRanges: inputOptions.changedLineRanges ?? null,
|
|
@@ -49009,7 +49169,8 @@ const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
|
|
|
49009
49169
|
});
|
|
49010
49170
|
const inspect = async (directory, inputOptions = {}) => {
|
|
49011
49171
|
const startTime = performance$1.now();
|
|
49012
|
-
|
|
49172
|
+
const isConcurrentScan = inputOptions.concurrentScan === true;
|
|
49173
|
+
if (!isConcurrentScan) resetSentryRunState();
|
|
49013
49174
|
const hasConfigOverride = inputOptions.configOverride !== void 0;
|
|
49014
49175
|
let scanDirectory;
|
|
49015
49176
|
let userConfig;
|
|
@@ -49017,7 +49178,7 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49017
49178
|
if (hasConfigOverride) {
|
|
49018
49179
|
scanDirectory = directory;
|
|
49019
49180
|
userConfig = inputOptions.configOverride ?? null;
|
|
49020
|
-
configSourceDirectory = null;
|
|
49181
|
+
configSourceDirectory = inputOptions.configSourceDirectory ?? null;
|
|
49021
49182
|
} else {
|
|
49022
49183
|
const scanTarget = await resolveScanTarget(directory);
|
|
49023
49184
|
scanDirectory = scanTarget.resolvedDirectory;
|
|
@@ -49025,8 +49186,9 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49025
49186
|
configSourceDirectory = scanTarget.configSourceDirectory;
|
|
49026
49187
|
}
|
|
49027
49188
|
const options = mergeInspectOptions(inputOptions, userConfig);
|
|
49189
|
+
const ownsSpinnerSilence = options.silent && !isConcurrentScan;
|
|
49028
49190
|
const wasSpinnerSilent = isSpinnerSilent();
|
|
49029
|
-
if (
|
|
49191
|
+
if (ownsSpinnerSilence) setSpinnerSilent(true);
|
|
49030
49192
|
try {
|
|
49031
49193
|
const result = await withSentryRunSpan(async (rootSentrySpan) => {
|
|
49032
49194
|
try {
|
|
@@ -49039,11 +49201,11 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49039
49201
|
});
|
|
49040
49202
|
throw error;
|
|
49041
49203
|
}
|
|
49042
|
-
});
|
|
49043
|
-
resetSentryRunState();
|
|
49204
|
+
}, { concurrentScan: isConcurrentScan });
|
|
49205
|
+
if (!isConcurrentScan) resetSentryRunState();
|
|
49044
49206
|
return result;
|
|
49045
49207
|
} finally {
|
|
49046
|
-
if (
|
|
49208
|
+
if (ownsSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
|
|
49047
49209
|
}
|
|
49048
49210
|
};
|
|
49049
49211
|
/**
|
|
@@ -49132,7 +49294,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49132
49294
|
const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
|
|
49133
49295
|
const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
|
|
49134
49296
|
if (cachedPayload) {
|
|
49135
|
-
recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
|
|
49297
|
+
recordSentryProjectContext(cachedPayload.project, rootSentrySpan, { concurrentScan: options.concurrentScan });
|
|
49136
49298
|
recordCount(METRIC.projectDetected, 1);
|
|
49137
49299
|
await renderCachedProjectDetection({
|
|
49138
49300
|
payload: cachedPayload,
|
|
@@ -49154,7 +49316,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49154
49316
|
recordOnboardingCompletion(options);
|
|
49155
49317
|
return result;
|
|
49156
49318
|
}
|
|
49157
|
-
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);
|
|
49158
49320
|
const layers = buildRuntimeLayers({
|
|
49159
49321
|
directory,
|
|
49160
49322
|
hasConfigOverride,
|
|
@@ -49183,7 +49345,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49183
49345
|
suppressScanSummary: options.suppressRendering,
|
|
49184
49346
|
supplyChainManifestChanged: options.supplyChainManifestChanged
|
|
49185
49347
|
}, { beforeLint: (projectInfo, lintIncludePaths) => gen(function* () {
|
|
49186
|
-
recordSentryProjectContext(projectInfo, rootSentrySpan);
|
|
49348
|
+
recordSentryProjectContext(projectInfo, rootSentrySpan, { concurrentScan: options.concurrentScan });
|
|
49187
49349
|
recordCount(METRIC.projectDetected, 1);
|
|
49188
49350
|
if (options.scoreOnly || options.suppressRendering) return;
|
|
49189
49351
|
const lintSourceFileCount = lintIncludePaths?.length ?? projectInfo.sourceFileCount;
|
|
@@ -49338,7 +49500,7 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49338
49500
|
if (options.scoreOnly) {
|
|
49339
49501
|
if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory, false, "stderr");
|
|
49340
49502
|
if (score) yield* log(`${score.score}`);
|
|
49341
|
-
else yield*
|
|
49503
|
+
else yield* error$1(highlighter.gray(noScoreMessage));
|
|
49342
49504
|
return buildResult();
|
|
49343
49505
|
}
|
|
49344
49506
|
const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
|
|
@@ -51707,6 +51869,9 @@ const readChangedFilesFrom = (filePath) => {
|
|
|
51707
51869
|
return [...uniqueFiles];
|
|
51708
51870
|
};
|
|
51709
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
|
|
51710
51875
|
//#region src/cli/utils/render-multi-project-summary.ts
|
|
51711
51876
|
const getScoreLabel = (score) => {
|
|
51712
51877
|
if (score >= 75) return "Great";
|
|
@@ -51734,10 +51899,10 @@ const findLowestScoredScan = (completedScans) => {
|
|
|
51734
51899
|
return scoredScans.reduce((worst, scan) => scan.result.score.score < worst.result.score.score ? scan : worst);
|
|
51735
51900
|
};
|
|
51736
51901
|
const printMultiProjectSummary = (input) => gen(function* () {
|
|
51737
|
-
const { completedScans,
|
|
51902
|
+
const { completedScans, verbose, isOffline, projectName, totalElapsedMilliseconds } = input;
|
|
51738
51903
|
const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
|
|
51739
51904
|
const animateRender = !verbose && canAnimateOnboarding(process.stdout);
|
|
51740
|
-
const displayDiagnostics = filterDiagnosticsByCategories(
|
|
51905
|
+
const displayDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, "cli"), categoryFilters);
|
|
51741
51906
|
const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
|
|
51742
51907
|
for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
|
|
51743
51908
|
const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
|
|
@@ -51749,8 +51914,7 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51749
51914
|
else fileCountFromScansWithoutPaths += scan.result.scannedFileCount ?? scan.result.project.sourceFileCount;
|
|
51750
51915
|
}
|
|
51751
51916
|
const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
|
|
51752
|
-
|
|
51753
|
-
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)}`);
|
|
51754
51918
|
if (displayDiagnostics.length > 0) {
|
|
51755
51919
|
yield* log("");
|
|
51756
51920
|
yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
|
|
@@ -51760,9 +51924,9 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51760
51924
|
const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
|
|
51761
51925
|
yield* printSummary({
|
|
51762
51926
|
diagnostics: displayDiagnostics,
|
|
51763
|
-
elapsedMilliseconds:
|
|
51927
|
+
elapsedMilliseconds: totalElapsedMilliseconds,
|
|
51764
51928
|
scoreResult: aggregateScore,
|
|
51765
|
-
potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics,
|
|
51929
|
+
potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics, filterScansForSurface([lowestScoredScan], "cli"), lowestScoredScan.result.score)) : null,
|
|
51766
51930
|
totalSourceFileCount,
|
|
51767
51931
|
noScoreMessage: "Score unavailable.",
|
|
51768
51932
|
verbose,
|
|
@@ -51770,7 +51934,7 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51770
51934
|
animateProjection: animateRender
|
|
51771
51935
|
});
|
|
51772
51936
|
const entries = completedScans.map((scan) => {
|
|
51773
|
-
const projectDiagnostics = filterDiagnosticsByCategories(
|
|
51937
|
+
const projectDiagnostics = filterDiagnosticsByCategories(filterScansForSurface([scan], "cli"), categoryFilters);
|
|
51774
51938
|
const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
51775
51939
|
return {
|
|
51776
51940
|
projectName: scan.result.project.projectName,
|
|
@@ -52117,16 +52281,22 @@ const parseFileLineArgument = (rawArgument) => {
|
|
|
52117
52281
|
};
|
|
52118
52282
|
//#endregion
|
|
52119
52283
|
//#region src/cli/utils/select-projects.ts
|
|
52120
|
-
const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
|
|
52284
|
+
const selectProjects = async (rootDirectory, projectFlag, skipPrompts, configProjects) => {
|
|
52121
52285
|
const hasRootPackageJson = isFile(Path.join(rootDirectory, "package.json"));
|
|
52122
52286
|
let packages = listWorkspacePackages(rootDirectory);
|
|
52123
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
|
+
}
|
|
52124
52295
|
if (packages.length === 0) return [rootDirectory];
|
|
52125
52296
|
if (packages.length === 1) {
|
|
52126
52297
|
cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages[0].name}`);
|
|
52127
52298
|
return [packages[0].directory];
|
|
52128
52299
|
}
|
|
52129
|
-
if (projectFlag) return resolveProjectFlag(projectFlag, packages);
|
|
52130
52300
|
if (skipPrompts) {
|
|
52131
52301
|
printDiscoveredProjects(packages);
|
|
52132
52302
|
return packages.map((workspacePackage) => workspacePackage.directory);
|
|
@@ -52134,17 +52304,25 @@ const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
|
|
|
52134
52304
|
return promptProjectSelection(packages, rootDirectory);
|
|
52135
52305
|
};
|
|
52136
52306
|
const ALL_PROJECTS_SENTINEL = "*";
|
|
52137
|
-
const resolveProjectFlag = (projectFlag, workspacePackages) => {
|
|
52307
|
+
const resolveProjectFlag = (projectFlag, workspacePackages, rootDirectory) => {
|
|
52138
52308
|
const requestedNames = projectFlag.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
52139
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.`);
|
|
52140
|
-
|
|
52141
|
-
|
|
52142
|
-
|
|
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) => {
|
|
52143
52316
|
const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || Path.basename(workspacePackage.directory) === requestedName);
|
|
52144
|
-
if (
|
|
52145
|
-
|
|
52146
|
-
|
|
52147
|
-
|
|
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
|
+
});
|
|
52148
52326
|
};
|
|
52149
52327
|
const printDiscoveredProjects = (packages) => {
|
|
52150
52328
|
cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
|
|
@@ -52339,7 +52517,7 @@ const finalizeScans = (input) => {
|
|
|
52339
52517
|
}));
|
|
52340
52518
|
}
|
|
52341
52519
|
if (input.isScoreOnly || baselineDegraded) return;
|
|
52342
|
-
if (shouldBlockCi(
|
|
52520
|
+
if (shouldBlockCi(filterScansForSurface(input.completedScans, "ciFailure"), resolveBlockingLevel(input.flags, input.userConfig))) process.exitCode = 1;
|
|
52343
52521
|
};
|
|
52344
52522
|
const buildChangedFilesDiffInfo = (changedFiles) => ({
|
|
52345
52523
|
currentBranch: process.env.GITHUB_HEAD_REF?.trim() || null,
|
|
@@ -52472,7 +52650,6 @@ const inspectAction = async (directory, flags) => {
|
|
|
52472
52650
|
filePath: Path.isAbsolute(diagnostic.filePath) ? diagnostic.filePath.replaceAll(snapshot.tempDirectory, () => resolvedDirectory) : diagnostic.filePath
|
|
52473
52651
|
}));
|
|
52474
52652
|
finalizeScans({
|
|
52475
|
-
diagnostics: remappedDiagnostics,
|
|
52476
52653
|
completedScans: [{
|
|
52477
52654
|
directory: resolvedDirectory,
|
|
52478
52655
|
result: {
|
|
@@ -52482,7 +52659,8 @@ const inspectAction = async (directory, flags) => {
|
|
|
52482
52659
|
...scanResult.project,
|
|
52483
52660
|
rootDirectory: resolvedDirectory
|
|
52484
52661
|
}
|
|
52485
|
-
}
|
|
52662
|
+
},
|
|
52663
|
+
config: userConfig
|
|
52486
52664
|
}],
|
|
52487
52665
|
mode: "staged",
|
|
52488
52666
|
diff: null,
|
|
@@ -52500,7 +52678,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
52500
52678
|
}
|
|
52501
52679
|
return;
|
|
52502
52680
|
}
|
|
52503
|
-
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
|
|
52681
|
+
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts, userConfig?.projects);
|
|
52504
52682
|
const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
|
|
52505
52683
|
const requestedScope = resolveScope(flags, userConfig);
|
|
52506
52684
|
const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
|
|
@@ -52538,60 +52716,87 @@ const inspectAction = async (directory, flags) => {
|
|
|
52538
52716
|
}
|
|
52539
52717
|
cliLogger.break();
|
|
52540
52718
|
}
|
|
52541
|
-
const allDiagnostics = [];
|
|
52542
52719
|
const completedScans = [];
|
|
52543
52720
|
const isMultiProject = projectDirectories.length > 1;
|
|
52544
|
-
const
|
|
52545
|
-
|
|
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;
|
|
52546
52727
|
let includePaths;
|
|
52547
52728
|
let supplyChainManifestChanged = false;
|
|
52548
52729
|
if (isDiffMode) {
|
|
52549
|
-
const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory,
|
|
52550
|
-
supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory,
|
|
52730
|
+
const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory, scanDirectory, diffInfo);
|
|
52731
|
+
supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory, scanDirectory, diffInfo);
|
|
52551
52732
|
if (changedSourceFiles.length === 0 && !supplyChainManifestChanged) {
|
|
52552
52733
|
if (!isQuiet) {
|
|
52553
|
-
cliLogger.dim(`No changed source files in ${
|
|
52734
|
+
cliLogger.dim(`No changed source files in ${scanDirectory}, skipping.`);
|
|
52554
52735
|
cliLogger.break();
|
|
52555
52736
|
}
|
|
52556
|
-
|
|
52737
|
+
return null;
|
|
52557
52738
|
}
|
|
52558
52739
|
includePaths = [...changedSourceFiles];
|
|
52559
52740
|
if (supplyChainManifestChanged) includePaths.push("package.json");
|
|
52560
52741
|
}
|
|
52561
52742
|
if (!isQuiet && !isMultiProject) cliLogger.dim(" ");
|
|
52562
|
-
const scanResult = await inspect(
|
|
52743
|
+
const scanResult = await inspect(scanDirectory, {
|
|
52563
52744
|
...scanOptions,
|
|
52564
52745
|
includePaths,
|
|
52565
|
-
configOverride:
|
|
52746
|
+
configOverride: projectConfig,
|
|
52747
|
+
configSourceDirectory: projectConfigSourceDirectory ?? void 0,
|
|
52566
52748
|
suppressRendering: isMultiProject,
|
|
52749
|
+
concurrentScan: isMultiProject,
|
|
52567
52750
|
baseline: baselineRef ? { ref: baselineRef } : void 0,
|
|
52568
|
-
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory,
|
|
52751
|
+
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, scanDirectory, changedLineRanges) : void 0,
|
|
52569
52752
|
supplyChainManifestChanged
|
|
52570
52753
|
});
|
|
52571
|
-
allDiagnostics.push(...scanResult.diagnostics);
|
|
52572
|
-
completedScans.push({
|
|
52573
|
-
directory: projectDirectory,
|
|
52574
|
-
result: scanResult
|
|
52575
|
-
});
|
|
52576
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);
|
|
52577
52783
|
}
|
|
52578
52784
|
if (!isQuiet && isMultiProject && completedScans.length > 0) {
|
|
52579
52785
|
const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
|
|
52580
52786
|
await runPromise(printMultiProjectSummary({
|
|
52581
52787
|
completedScans,
|
|
52582
52788
|
categoryFilters,
|
|
52583
|
-
userConfig,
|
|
52584
52789
|
verbose: Boolean(flags.verbose),
|
|
52585
52790
|
outputDirectory: flags.outputDir,
|
|
52586
52791
|
isOffline: !shouldShowShareLink,
|
|
52587
|
-
projectName: Path.basename(resolvedDirectory)
|
|
52792
|
+
projectName: Path.basename(resolvedDirectory),
|
|
52793
|
+
totalElapsedMilliseconds: performance$1.now() - scanLoopStartTime
|
|
52588
52794
|
}));
|
|
52589
52795
|
}
|
|
52590
|
-
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(
|
|
52796
|
+
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, scanOptions.outputSurface ?? "cli"), categoryFilters);
|
|
52591
52797
|
const didScansWriteDump = isMultiProject ? !isQuiet && completedScans.length > 0 : completedScans.length > 0;
|
|
52592
52798
|
if (flags.outputDir && !didScansWriteDump) await runPromise(printDiagnosticsDump(selectedSurfaceDiagnostics, flags.outputDir, false, isQuiet ? "stderr" : "stdout"));
|
|
52593
52799
|
finalizeScans({
|
|
52594
|
-
diagnostics: allDiagnostics,
|
|
52595
52800
|
completedScans,
|
|
52596
52801
|
mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
|
|
52597
52802
|
diff: isDiffMode ? diffInfo : null,
|
|
@@ -53561,6 +53766,7 @@ ${formatExampleLines([
|
|
|
53561
53766
|
["react-doctor", "scan the current project"],
|
|
53562
53767
|
["react-doctor ./apps/web", "scan a specific directory"],
|
|
53563
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)"],
|
|
53564
53770
|
["react-doctor --staged", "scan staged files (pre-commit hook)"],
|
|
53565
53771
|
["react-doctor --category Security", "show only one diagnostic category"],
|
|
53566
53772
|
["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
|
|
@@ -53592,9 +53798,9 @@ ${highlighter.dim("Learn more:")}
|
|
|
53592
53798
|
${highlighter.info(CANONICAL_GITHUB_URL)}
|
|
53593
53799
|
`;
|
|
53594
53800
|
const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
|
|
53595
|
-
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 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);
|
|
53596
53802
|
program.action(inspectAction);
|
|
53597
|
-
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));
|
|
53598
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);
|
|
53599
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);
|
|
53600
53806
|
const rules = program.command("rules").description("List, explain, and configure which React Doctor rules run");
|
|
@@ -53635,4 +53841,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
53635
53841
|
export {};
|
|
53636
53842
|
|
|
53637
53843
|
//# sourceMappingURL=cli.js.map
|
|
53638
|
-
//# debugId=
|
|
53844
|
+
//# debugId=74796c64-5e08-5b67-b3ec-6294b1811a26
|