react-doctor 0.5.1-dev.038aaf7 → 0.5.1-dev.04e72a4
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 +293 -120
- package/dist/index.d.ts +84 -39
- package/dist/index.js +141 -21
- package/dist/lsp.js +43 -16
- package/package.json +6 -6
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]="0d78b267-b420-5397-a36a-5fed74a7f95f")}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";
|
|
@@ -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
|
};
|
|
@@ -41712,6 +41733,7 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
41712
41733
|
};
|
|
41713
41734
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
41714
41735
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
41736
|
+
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
41715
41737
|
const REACT_COMPILER_MESSAGE = "This component misses React Compiler's automatic memoization & re-renders more than it should. Rewrite the flagged code so the compiler can optimize it.";
|
|
41716
41738
|
const PLUGIN_CATEGORY_MAP = {
|
|
41717
41739
|
react: "Bugs",
|
|
@@ -41739,7 +41761,10 @@ const getRuleRecommendation = (ruleName, project) => {
|
|
|
41739
41761
|
};
|
|
41740
41762
|
const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
|
|
41741
41763
|
const getRuleTitle = (ruleName) => reactDoctorPlugin.rules[ruleName]?.title;
|
|
41742
|
-
const resolveDiagnosticTitle = (plugin, rule) =>
|
|
41764
|
+
const resolveDiagnosticTitle = (plugin, rule) => {
|
|
41765
|
+
if (plugin !== "react-hooks-js") return getRuleTitle(rule);
|
|
41766
|
+
return rule === "todo" ? REACT_COMPILER_TODO_TITLE : REACT_COMPILER_TITLE;
|
|
41767
|
+
};
|
|
41743
41768
|
const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
41744
41769
|
const cleaned = resolveCleanedDiagnostic(typeof message === "string" ? message : "", typeof help === "string" ? help : "", plugin, rule, project);
|
|
41745
41770
|
return {
|
|
@@ -42418,7 +42443,7 @@ const ScoreApiResponseSchema = Struct({
|
|
|
42418
42443
|
})))
|
|
42419
42444
|
});
|
|
42420
42445
|
const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
|
|
42421
|
-
const
|
|
42446
|
+
const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
|
|
42422
42447
|
const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
42423
42448
|
const describeFailure = (error) => {
|
|
42424
42449
|
if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
|
|
@@ -42431,7 +42456,7 @@ const calculateScore = async (diagnostics, options = {}) => {
|
|
|
42431
42456
|
const requestUrl = options.isCi ? `${SCORE_API_URL}?ci=1` : SCORE_API_URL;
|
|
42432
42457
|
try {
|
|
42433
42458
|
const compressedBody = gzipSync(JSON.stringify({
|
|
42434
|
-
diagnostics:
|
|
42459
|
+
diagnostics: stripLocalFileFields(diagnostics),
|
|
42435
42460
|
...options.metadata?.repo ? { repo: options.metadata.repo } : {},
|
|
42436
42461
|
...options.metadata?.sha ? { sha: options.metadata.sha } : {},
|
|
42437
42462
|
...options.metadata?.framework ? { framework: options.metadata.framework } : {},
|
|
@@ -43496,6 +43521,48 @@ const groupBy = (items, keyFn) => {
|
|
|
43496
43521
|
* a 404. Gate the directive on this predicate.
|
|
43497
43522
|
*/
|
|
43498
43523
|
const hasPublishedFixRecipe = (diagnostic) => diagnostic.plugin === "react-doctor" && Object.hasOwn(reactDoctorPlugin.rules, diagnostic.rule);
|
|
43524
|
+
const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
|
|
43525
|
+
const mergeIgnores = (baseIgnore, overrideIgnore) => {
|
|
43526
|
+
const mergedIgnore = {
|
|
43527
|
+
...baseIgnore,
|
|
43528
|
+
...overrideIgnore
|
|
43529
|
+
};
|
|
43530
|
+
if (baseIgnore.rules && overrideIgnore.rules) mergedIgnore.rules = unionValues(baseIgnore.rules, overrideIgnore.rules);
|
|
43531
|
+
if (baseIgnore.files && overrideIgnore.files) mergedIgnore.files = unionValues(baseIgnore.files, overrideIgnore.files);
|
|
43532
|
+
if (baseIgnore.tags && overrideIgnore.tags) mergedIgnore.tags = unionValues(baseIgnore.tags, overrideIgnore.tags);
|
|
43533
|
+
if (baseIgnore.overrides && overrideIgnore.overrides) mergedIgnore.overrides = [...baseIgnore.overrides, ...overrideIgnore.overrides];
|
|
43534
|
+
return mergedIgnore;
|
|
43535
|
+
};
|
|
43536
|
+
/**
|
|
43537
|
+
* Layer one `ReactDoctorConfig` on top of another, additively: `rules` /
|
|
43538
|
+
* `categories` / `supplyChain` merge per key, `ignore` lists union
|
|
43539
|
+
* (`ignore.overrides` concatenate), and every other field is a scalar the
|
|
43540
|
+
* override simply wins on when set. Returns the base unchanged when there
|
|
43541
|
+
* is no override, and vice versa — so callers can thread `null` /
|
|
43542
|
+
* `undefined` through without special-casing.
|
|
43543
|
+
*/
|
|
43544
|
+
const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
|
|
43545
|
+
if (overrideConfig === void 0) return baseConfig;
|
|
43546
|
+
if (baseConfig === null) return overrideConfig;
|
|
43547
|
+
const mergedConfig = {
|
|
43548
|
+
...baseConfig,
|
|
43549
|
+
...overrideConfig
|
|
43550
|
+
};
|
|
43551
|
+
if (baseConfig.rules && overrideConfig.rules) mergedConfig.rules = {
|
|
43552
|
+
...baseConfig.rules,
|
|
43553
|
+
...overrideConfig.rules
|
|
43554
|
+
};
|
|
43555
|
+
if (baseConfig.categories && overrideConfig.categories) mergedConfig.categories = {
|
|
43556
|
+
...baseConfig.categories,
|
|
43557
|
+
...overrideConfig.categories
|
|
43558
|
+
};
|
|
43559
|
+
if (baseConfig.supplyChain && overrideConfig.supplyChain) mergedConfig.supplyChain = {
|
|
43560
|
+
...baseConfig.supplyChain,
|
|
43561
|
+
...overrideConfig.supplyChain
|
|
43562
|
+
};
|
|
43563
|
+
if (baseConfig.ignore && overrideConfig.ignore) mergedConfig.ignore = mergeIgnores(baseConfig.ignore, overrideConfig.ignore);
|
|
43564
|
+
return mergedConfig;
|
|
43565
|
+
};
|
|
43499
43566
|
//#endregion
|
|
43500
43567
|
//#region src/cli/utils/is-ci-environment.ts
|
|
43501
43568
|
const CI_ENVIRONMENT_VARIABLES = [
|
|
@@ -43604,6 +43671,8 @@ const METRIC = {
|
|
|
43604
43671
|
cliInvoked: "cli.invoked",
|
|
43605
43672
|
cliError: "cli.error",
|
|
43606
43673
|
projectDetected: "project.detected",
|
|
43674
|
+
projectPathSelected: "project.path_selected",
|
|
43675
|
+
projectConfigSelected: "project.config_selected",
|
|
43607
43676
|
scanCompleted: "scan.completed",
|
|
43608
43677
|
scanDuration: "scan.duration",
|
|
43609
43678
|
scanPhaseDuration: "scan.phase_duration",
|
|
@@ -43673,7 +43742,7 @@ const makeNoopConsole = () => ({
|
|
|
43673
43742
|
});
|
|
43674
43743
|
//#endregion
|
|
43675
43744
|
//#region src/cli/utils/version.ts
|
|
43676
|
-
const VERSION = "0.5.1-dev.
|
|
43745
|
+
const VERSION = "0.5.1-dev.04e72a4";
|
|
43677
43746
|
//#endregion
|
|
43678
43747
|
//#region src/cli/utils/json-mode.ts
|
|
43679
43748
|
let context = null;
|
|
@@ -44031,13 +44100,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
44031
44100
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
44032
44101
|
* standard `SENTRY_RELEASE` override.
|
|
44033
44102
|
*/
|
|
44034
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.
|
|
44103
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.04e72a4`;
|
|
44035
44104
|
/**
|
|
44036
44105
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
44037
44106
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
44038
44107
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
44039
44108
|
*/
|
|
44040
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.
|
|
44109
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.04e72a4") ? "development" : "production");
|
|
44041
44110
|
/**
|
|
44042
44111
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
44043
44112
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -47335,12 +47404,13 @@ const toSpanAttributes = (tags) => {
|
|
|
47335
47404
|
/**
|
|
47336
47405
|
* Clears the module-level run-scoped Sentry state — the current scanned project
|
|
47337
47406
|
* 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
|
-
*
|
|
47407
|
+
* again after a clean one, so a prior or just-finished scan can't attach its
|
|
47408
|
+
* project tags / trace to a later run or to a non-scan error (e.g.
|
|
47409
|
+
* inspectAction's post-loop finalize/handoff steps). A thrown scan error skips
|
|
47410
|
+
* the post-run reset, leaving the state for the command catch to attribute and
|
|
47411
|
+
* link the crash. Concurrent batch members (`concurrentScan`) never touch this
|
|
47412
|
+
* state — they neither write nor reset it. Safe to call when Sentry is off (the
|
|
47413
|
+
* refs are read only when an event is built).
|
|
47344
47414
|
*/
|
|
47345
47415
|
const resetSentryRunState = () => {
|
|
47346
47416
|
setSentryProjectInfo(null);
|
|
@@ -47363,8 +47433,13 @@ const resetSentryRunState = () => {
|
|
|
47363
47433
|
* state right after a clean run and at the start of the next one, so the trace
|
|
47364
47434
|
* is never attached to a non-scan error; on a thrown error the state is left in
|
|
47365
47435
|
* place for the command catch, then the process exits.
|
|
47436
|
+
*
|
|
47437
|
+
* A `concurrentScan` (one member of the CLI's multi-project pool) still gets
|
|
47438
|
+
* its own root span, but skips recording the active run trace — the module-
|
|
47439
|
+
* level handle has single-scan semantics, and overlapping writers would link a
|
|
47440
|
+
* crash to an arbitrary sibling's trace.
|
|
47366
47441
|
*/
|
|
47367
|
-
const withSentryRunSpan = (run) => {
|
|
47442
|
+
const withSentryRunSpan = (run, options = {}) => {
|
|
47368
47443
|
if (!isSentryTracingEnabled()) return run(void 0);
|
|
47369
47444
|
const { tags } = buildSentryScope();
|
|
47370
47445
|
const command = typeof tags.command === "string" ? tags.command : "inspect";
|
|
@@ -47373,12 +47448,14 @@ const withSentryRunSpan = (run) => {
|
|
|
47373
47448
|
op: "cli.inspect",
|
|
47374
47449
|
attributes: toSpanAttributes(tags)
|
|
47375
47450
|
}, (rootSpan) => {
|
|
47376
|
-
|
|
47377
|
-
|
|
47378
|
-
|
|
47379
|
-
|
|
47380
|
-
|
|
47381
|
-
|
|
47451
|
+
if (options.concurrentScan !== true) {
|
|
47452
|
+
const spanContext = rootSpan.spanContext();
|
|
47453
|
+
setActiveRunTrace({
|
|
47454
|
+
traceId: spanContext.traceId,
|
|
47455
|
+
spanId: spanContext.spanId,
|
|
47456
|
+
sampled: (spanContext.traceFlags & 1) === 1
|
|
47457
|
+
});
|
|
47458
|
+
}
|
|
47382
47459
|
return run(rootSpan);
|
|
47383
47460
|
});
|
|
47384
47461
|
};
|
|
@@ -47389,9 +47466,15 @@ const withSentryRunSpan = (run) => {
|
|
|
47389
47466
|
* run's root span so the transaction/trace carries the project shape too.
|
|
47390
47467
|
* Always cheap — the span attribute set is skipped when `rootSpan` is absent
|
|
47391
47468
|
* (tracing off), and storing the info is a plain assignment.
|
|
47469
|
+
*
|
|
47470
|
+
* A `concurrentScan` only sets the span attributes: the module-level project
|
|
47471
|
+
* ref has single-scan semantics, and overlapping writers would stamp events
|
|
47472
|
+
* and metrics with an arbitrary sibling's project. Wide events keep full
|
|
47473
|
+
* attribution (they ride the span); per-emit metrics simply omit the project
|
|
47474
|
+
* shape during a concurrent batch (absent, never wrong).
|
|
47392
47475
|
*/
|
|
47393
|
-
const recordSentryProjectContext = (projectInfo, rootSpan) => {
|
|
47394
|
-
setSentryProjectInfo(projectInfo);
|
|
47476
|
+
const recordSentryProjectContext = (projectInfo, rootSpan, options = {}) => {
|
|
47477
|
+
if (options.concurrentScan !== true) setSentryProjectInfo(projectInfo);
|
|
47395
47478
|
rootSpan?.setAttributes(toSpanAttributes(buildSentryProjectContext(projectInfo).tags));
|
|
47396
47479
|
};
|
|
47397
47480
|
//#endregion
|
|
@@ -47628,6 +47711,12 @@ const buildOutcomeAttributes = (input) => {
|
|
|
47628
47711
|
topRule = rule;
|
|
47629
47712
|
topRuleCount = count;
|
|
47630
47713
|
}
|
|
47714
|
+
let diagnosticsInTestFiles = 0;
|
|
47715
|
+
let diagnosticsInStoryFiles = 0;
|
|
47716
|
+
for (const diagnostic of result.diagnostics) {
|
|
47717
|
+
if (diagnostic.fileContext === "test") diagnosticsInTestFiles += 1;
|
|
47718
|
+
if (diagnostic.fileContext === "story") diagnosticsInStoryFiles += 1;
|
|
47719
|
+
}
|
|
47631
47720
|
const attributes = {
|
|
47632
47721
|
outcome,
|
|
47633
47722
|
exitCode: wouldBlock ? 1 : 0,
|
|
@@ -47638,6 +47727,8 @@ const buildOutcomeAttributes = (input) => {
|
|
|
47638
47727
|
errorCount: summary.errorCount,
|
|
47639
47728
|
warningCount: summary.warningCount,
|
|
47640
47729
|
affectedFiles: summary.affectedFileCount,
|
|
47730
|
+
diagnosticsInTestFiles,
|
|
47731
|
+
diagnosticsInStoryFiles,
|
|
47641
47732
|
distinctRulesFired: countByRule.size,
|
|
47642
47733
|
topRule,
|
|
47643
47734
|
scannedFileCount: result.scannedFileCount ?? null,
|
|
@@ -47685,6 +47776,7 @@ const buildConfigAttributes = (input) => {
|
|
|
47685
47776
|
noScore: input.noScore,
|
|
47686
47777
|
respectInlineDisables: input.respectInlineDisables,
|
|
47687
47778
|
showWarnings: input.showWarnings,
|
|
47779
|
+
usedOutputDir: input.usedOutputDir,
|
|
47688
47780
|
ignoredTagCount: input.ignoredTagCount,
|
|
47689
47781
|
hasCustomConfig: input.hasCustomConfig,
|
|
47690
47782
|
rulesConfigured: ruleKeys.length,
|
|
@@ -47969,17 +48061,24 @@ const writeStdout = (text) => sync(() => {
|
|
|
47969
48061
|
const POINTER = isUnicodeSupported() ? "›" : ">";
|
|
47970
48062
|
const colorizeBySeverity = (text, severity) => severity === "error" ? highlighter.error(text) : highlighter.warn(text);
|
|
47971
48063
|
const collectAffectedFiles = (diagnostics) => new Set(diagnostics.map((diagnostic) => diagnostic.filePath));
|
|
47972
|
-
const
|
|
47973
|
-
|
|
48064
|
+
const formatFileContextTag = (diagnostic) => diagnostic.fileContext ? ` (${diagnostic.fileContext} file)` : "";
|
|
48065
|
+
const buildVerboseFileEntries = (diagnostics) => {
|
|
48066
|
+
const fileEntries = /* @__PURE__ */ new Map();
|
|
47974
48067
|
for (const diagnostic of diagnostics) {
|
|
47975
|
-
|
|
47976
|
-
if (
|
|
48068
|
+
let entry = fileEntries.get(diagnostic.filePath);
|
|
48069
|
+
if (entry === void 0) {
|
|
48070
|
+
entry = {
|
|
48071
|
+
contextTag: formatFileContextTag(diagnostic),
|
|
48072
|
+
sites: []
|
|
48073
|
+
};
|
|
48074
|
+
fileEntries.set(diagnostic.filePath, entry);
|
|
48075
|
+
}
|
|
48076
|
+
if (diagnostic.line > 0) entry.sites.push({
|
|
47977
48077
|
line: diagnostic.line,
|
|
47978
48078
|
suppressionHint: diagnostic.suppressionHint
|
|
47979
48079
|
});
|
|
47980
|
-
fileSites.set(diagnostic.filePath, sites);
|
|
47981
48080
|
}
|
|
47982
|
-
return
|
|
48081
|
+
return fileEntries;
|
|
47983
48082
|
};
|
|
47984
48083
|
const formatSiteCountBadge = (count) => count > 1 ? `×${count}` : "";
|
|
47985
48084
|
const formatTrailingSiteBadge = (count) => {
|
|
@@ -48068,10 +48167,11 @@ const clusterNearbyDiagnostics = (diagnostics) => {
|
|
|
48068
48167
|
return clusters;
|
|
48069
48168
|
};
|
|
48070
48169
|
const formatClusterLocation = (cluster) => {
|
|
48071
|
-
const
|
|
48072
|
-
|
|
48073
|
-
if (cluster.
|
|
48074
|
-
return `${filePath}:${cluster.startLine}`;
|
|
48170
|
+
const lead = cluster.diagnostics[0];
|
|
48171
|
+
const contextTag = formatFileContextTag(lead);
|
|
48172
|
+
if (cluster.startLine <= 0) return `${lead.filePath}${contextTag}`;
|
|
48173
|
+
if (cluster.endLine > cluster.startLine) return `${lead.filePath}:${cluster.startLine}-${cluster.endLine}${contextTag}`;
|
|
48174
|
+
return `${lead.filePath}:${cluster.startLine}${contextTag}`;
|
|
48075
48175
|
};
|
|
48076
48176
|
const buildDiagnosticClusterLines = (cluster, resolveSourceRoot, renderCodeFrame) => {
|
|
48077
48177
|
const lead = cluster.diagnostics[0];
|
|
@@ -48227,12 +48327,12 @@ const formatRuleSummary = (ruleKey, ruleDiagnostics) => {
|
|
|
48227
48327
|
const fixRecipeLine = formatFixRecipeLine(firstDiagnostic);
|
|
48228
48328
|
if (fixRecipeLine) sections.push("", fixRecipeLine);
|
|
48229
48329
|
sections.push("", "Files:");
|
|
48230
|
-
const
|
|
48231
|
-
for (const [filePath, sites] of
|
|
48232
|
-
sections.push(` ${filePath}:${site.line}`);
|
|
48330
|
+
const fileEntries = buildVerboseFileEntries(ruleDiagnostics);
|
|
48331
|
+
for (const [filePath, { contextTag, sites }] of fileEntries) if (sites.length > 0) for (const site of sites) {
|
|
48332
|
+
sections.push(` ${filePath}:${site.line}${contextTag}`);
|
|
48233
48333
|
if (site.suppressionHint) sections.push(` ${site.suppressionHint}`);
|
|
48234
48334
|
}
|
|
48235
|
-
else sections.push(` ${filePath}`);
|
|
48335
|
+
else sections.push(` ${filePath}${contextTag}`);
|
|
48236
48336
|
return sections.join("\n") + "\n";
|
|
48237
48337
|
};
|
|
48238
48338
|
//#endregion
|
|
@@ -48502,15 +48602,22 @@ const printNoScoreHeader = (noScoreMessage) => gen(function* () {
|
|
|
48502
48602
|
});
|
|
48503
48603
|
//#endregion
|
|
48504
48604
|
//#region src/cli/utils/write-diagnostics-directory.ts
|
|
48505
|
-
const
|
|
48506
|
-
|
|
48507
|
-
|
|
48508
|
-
|
|
48509
|
-
|
|
48510
|
-
|
|
48605
|
+
const ruleDumpFileName = (ruleKey) => ruleKey.replace(/\//g, "--") + ".txt";
|
|
48606
|
+
const readPreviousRuleDumpFileNames = (directory) => {
|
|
48607
|
+
try {
|
|
48608
|
+
const previous = JSON.parse(NFS.readFileSync(Path.join(directory, "diagnostics.json"), "utf8"));
|
|
48609
|
+
return new Set(previous.filter((d) => typeof d?.plugin === "string" && typeof d?.rule === "string").map((d) => ruleDumpFileName(`${d.plugin}/${d.rule}`)));
|
|
48610
|
+
} catch {
|
|
48611
|
+
return /* @__PURE__ */ new Set();
|
|
48511
48612
|
}
|
|
48512
|
-
|
|
48513
|
-
|
|
48613
|
+
};
|
|
48614
|
+
const writeDiagnosticsDirectory = (diagnostics, outputDirectory) => {
|
|
48615
|
+
const directory = outputDirectory ? Path.resolve(outputDirectory) : Path.join(tmpdir(), `react-doctor-${randomUUID()}`);
|
|
48616
|
+
if (outputDirectory) for (const fileName of readPreviousRuleDumpFileNames(directory)) NFS.rmSync(Path.join(directory, fileName), { force: true });
|
|
48617
|
+
NFS.mkdirSync(directory, { recursive: true });
|
|
48618
|
+
for (const [ruleKey, ruleDiagnostics] of buildSortedRuleGroups(diagnostics)) NFS.writeFileSync(Path.join(directory, ruleDumpFileName(ruleKey)), formatRuleSummary(ruleKey, ruleDiagnostics));
|
|
48619
|
+
NFS.writeFileSync(Path.join(directory, "diagnostics.json"), JSON.stringify(diagnostics));
|
|
48620
|
+
return directory;
|
|
48514
48621
|
};
|
|
48515
48622
|
//#endregion
|
|
48516
48623
|
//#region src/cli/utils/render-summary.ts
|
|
@@ -48547,6 +48654,16 @@ const printFooter = (input) => gen(function* () {
|
|
|
48547
48654
|
yield* log(` ${highlighter.bold("GitHub:")} ${highlighter.info(CANONICAL_GITHUB_URL)}`);
|
|
48548
48655
|
yield* printFooterDescription("Report issues and star the repository!");
|
|
48549
48656
|
});
|
|
48657
|
+
const printDiagnosticsDump = (diagnostics, outputDirectory, verbose, stream = "stdout") => gen(function* () {
|
|
48658
|
+
const writtenDirectory = yield* try_({
|
|
48659
|
+
try: () => writeDiagnosticsDirectory(diagnostics, outputDirectory),
|
|
48660
|
+
catch: (cause) => cause
|
|
48661
|
+
}).pipe(orElseSucceed(() => null));
|
|
48662
|
+
if (writtenDirectory !== null && (verbose || outputDirectory)) {
|
|
48663
|
+
const pathLine = highlighter.gray(` Full diagnostics written to ${writtenDirectory}`);
|
|
48664
|
+
yield* stream === "stderr" || Boolean(outputDirectory) && isJsonModeActive() ? sync(() => process.stderr.write(`${pathLine}\n`)) : log(pathLine);
|
|
48665
|
+
}
|
|
48666
|
+
});
|
|
48550
48667
|
const printSummary = (input) => gen(function* () {
|
|
48551
48668
|
if (input.scoreResult) {
|
|
48552
48669
|
const animateProjection = Boolean(input.animateProjection) && input.potentialScore != null && !input.verbose;
|
|
@@ -48557,11 +48674,7 @@ const printSummary = (input) => gen(function* () {
|
|
|
48557
48674
|
if (animateProjection) yield* animateScoreProjection(input.scoreResult, input.potentialScore, 5);
|
|
48558
48675
|
}
|
|
48559
48676
|
} else yield* printNoScoreHeader(input.noScoreMessage);
|
|
48560
|
-
|
|
48561
|
-
try: () => writeDiagnosticsDirectory(input.diagnostics),
|
|
48562
|
-
catch: (cause) => cause
|
|
48563
|
-
}).pipe(orElseSucceed(() => null));
|
|
48564
|
-
if (diagnosticsDirectory !== null && input.verbose) yield* log(highlighter.gray(` Full diagnostics written to ${diagnosticsDirectory}`));
|
|
48677
|
+
yield* printDiagnosticsDump(input.diagnostics, input.outputDirectory, input.verbose);
|
|
48565
48678
|
});
|
|
48566
48679
|
//#endregion
|
|
48567
48680
|
//#region src/cli/utils/should-auto-select-current-choice.ts
|
|
@@ -48951,6 +49064,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
48951
49064
|
lint: inputOptions.lint ?? userConfig?.lint ?? true,
|
|
48952
49065
|
deadCode: inputOptions.deadCode ?? userConfig?.deadCode ?? true,
|
|
48953
49066
|
verbose: inputOptions.verbose ?? userConfig?.verbose ?? false,
|
|
49067
|
+
outputDirectory: inputOptions.outputDirectory || null,
|
|
48954
49068
|
scoreOnly: inputOptions.scoreOnly ?? false,
|
|
48955
49069
|
noScore: inputOptions.noScore ?? userConfig?.noScore ?? false,
|
|
48956
49070
|
isCi: inputOptions.isCi ?? false,
|
|
@@ -48967,6 +49081,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
48967
49081
|
ignoredTags: buildIgnoredTags(userConfig),
|
|
48968
49082
|
outputSurface: inputOptions.outputSurface ?? "cli",
|
|
48969
49083
|
suppressRendering: inputOptions.suppressRendering ?? false,
|
|
49084
|
+
concurrentScan: inputOptions.concurrentScan ?? false,
|
|
48970
49085
|
concurrency: inputOptions.concurrency,
|
|
48971
49086
|
baseline: inputOptions.baseline ?? null,
|
|
48972
49087
|
changedLineRanges: inputOptions.changedLineRanges ?? null,
|
|
@@ -48987,13 +49102,15 @@ const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
|
|
|
48987
49102
|
noScore: options.noScore,
|
|
48988
49103
|
respectInlineDisables: options.respectInlineDisables,
|
|
48989
49104
|
showWarnings: options.warnings,
|
|
49105
|
+
usedOutputDir: options.outputDirectory !== null,
|
|
48990
49106
|
ignoredTagCount: options.ignoredTags.size,
|
|
48991
49107
|
hasCustomConfig,
|
|
48992
49108
|
userConfig
|
|
48993
49109
|
});
|
|
48994
49110
|
const inspect = async (directory, inputOptions = {}) => {
|
|
48995
49111
|
const startTime = performance$1.now();
|
|
48996
|
-
|
|
49112
|
+
const isConcurrentScan = inputOptions.concurrentScan === true;
|
|
49113
|
+
if (!isConcurrentScan) resetSentryRunState();
|
|
48997
49114
|
const hasConfigOverride = inputOptions.configOverride !== void 0;
|
|
48998
49115
|
let scanDirectory;
|
|
48999
49116
|
let userConfig;
|
|
@@ -49001,7 +49118,7 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49001
49118
|
if (hasConfigOverride) {
|
|
49002
49119
|
scanDirectory = directory;
|
|
49003
49120
|
userConfig = inputOptions.configOverride ?? null;
|
|
49004
|
-
configSourceDirectory = null;
|
|
49121
|
+
configSourceDirectory = inputOptions.configSourceDirectory ?? null;
|
|
49005
49122
|
} else {
|
|
49006
49123
|
const scanTarget = await resolveScanTarget(directory);
|
|
49007
49124
|
scanDirectory = scanTarget.resolvedDirectory;
|
|
@@ -49009,8 +49126,9 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49009
49126
|
configSourceDirectory = scanTarget.configSourceDirectory;
|
|
49010
49127
|
}
|
|
49011
49128
|
const options = mergeInspectOptions(inputOptions, userConfig);
|
|
49129
|
+
const ownsSpinnerSilence = options.silent && !isConcurrentScan;
|
|
49012
49130
|
const wasSpinnerSilent = isSpinnerSilent();
|
|
49013
|
-
if (
|
|
49131
|
+
if (ownsSpinnerSilence) setSpinnerSilent(true);
|
|
49014
49132
|
try {
|
|
49015
49133
|
const result = await withSentryRunSpan(async (rootSentrySpan) => {
|
|
49016
49134
|
try {
|
|
@@ -49023,11 +49141,11 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49023
49141
|
});
|
|
49024
49142
|
throw error;
|
|
49025
49143
|
}
|
|
49026
|
-
});
|
|
49027
|
-
resetSentryRunState();
|
|
49144
|
+
}, { concurrentScan: isConcurrentScan });
|
|
49145
|
+
if (!isConcurrentScan) resetSentryRunState();
|
|
49028
49146
|
return result;
|
|
49029
49147
|
} finally {
|
|
49030
|
-
if (
|
|
49148
|
+
if (ownsSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
|
|
49031
49149
|
}
|
|
49032
49150
|
};
|
|
49033
49151
|
/**
|
|
@@ -49116,7 +49234,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49116
49234
|
const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
|
|
49117
49235
|
const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
|
|
49118
49236
|
if (cachedPayload) {
|
|
49119
|
-
recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
|
|
49237
|
+
recordSentryProjectContext(cachedPayload.project, rootSentrySpan, { concurrentScan: options.concurrentScan });
|
|
49120
49238
|
recordCount(METRIC.projectDetected, 1);
|
|
49121
49239
|
await renderCachedProjectDetection({
|
|
49122
49240
|
payload: cachedPayload,
|
|
@@ -49138,7 +49256,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49138
49256
|
recordOnboardingCompletion(options);
|
|
49139
49257
|
return result;
|
|
49140
49258
|
}
|
|
49141
|
-
const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && options.lint && Boolean(resolvedNodeBinaryPath);
|
|
49259
|
+
const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && !options.suppressRendering && options.lint && Boolean(resolvedNodeBinaryPath);
|
|
49142
49260
|
const layers = buildRuntimeLayers({
|
|
49143
49261
|
directory,
|
|
49144
49262
|
hasConfigOverride,
|
|
@@ -49167,7 +49285,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49167
49285
|
suppressScanSummary: options.suppressRendering,
|
|
49168
49286
|
supplyChainManifestChanged: options.supplyChainManifestChanged
|
|
49169
49287
|
}, { beforeLint: (projectInfo, lintIncludePaths) => gen(function* () {
|
|
49170
|
-
recordSentryProjectContext(projectInfo, rootSentrySpan);
|
|
49288
|
+
recordSentryProjectContext(projectInfo, rootSentrySpan, { concurrentScan: options.concurrentScan });
|
|
49171
49289
|
recordCount(METRIC.projectDetected, 1);
|
|
49172
49290
|
if (options.scoreOnly || options.suppressRendering) return;
|
|
49173
49291
|
const lintSourceFileCount = lintIncludePaths?.length ?? projectInfo.sourceFileCount;
|
|
@@ -49317,15 +49435,16 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49317
49435
|
...baselineDelta ? { baselineDelta } : {}
|
|
49318
49436
|
});
|
|
49319
49437
|
if (options.suppressRendering) return buildResult();
|
|
49438
|
+
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
49439
|
+
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
49320
49440
|
if (options.scoreOnly) {
|
|
49441
|
+
if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory, false, "stderr");
|
|
49321
49442
|
if (score) yield* log(`${score.score}`);
|
|
49322
|
-
else yield*
|
|
49443
|
+
else yield* error$1(highlighter.gray(noScoreMessage));
|
|
49323
49444
|
return buildResult();
|
|
49324
49445
|
}
|
|
49325
49446
|
const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
|
|
49326
49447
|
const pause = onboardingSectionPause(animateRender);
|
|
49327
|
-
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
49328
|
-
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
49329
49448
|
const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
|
|
49330
49449
|
const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
|
|
49331
49450
|
if (printedDiagnostics.length === 0) {
|
|
@@ -49343,6 +49462,7 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49343
49462
|
yield* log(highlighter.gray(" Score not shown — some checks could not complete."));
|
|
49344
49463
|
} else if (score) yield* printScoreHeader(score);
|
|
49345
49464
|
else yield* printNoScoreHeader(noScoreMessage);
|
|
49465
|
+
if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory);
|
|
49346
49466
|
return buildResult();
|
|
49347
49467
|
}
|
|
49348
49468
|
yield* pause;
|
|
@@ -49367,6 +49487,7 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49367
49487
|
totalSourceFileCount: lintSourceFileCount,
|
|
49368
49488
|
noScoreMessage,
|
|
49369
49489
|
verbose: options.verbose,
|
|
49490
|
+
outputDirectory: options.outputDirectory,
|
|
49370
49491
|
animateProjection: animateRender
|
|
49371
49492
|
});
|
|
49372
49493
|
if (hasSkippedChecks) {
|
|
@@ -49538,9 +49659,9 @@ const isExpectedUserError = (error) => error instanceof CliInputError || isProje
|
|
|
49538
49659
|
//#region src/cli/utils/build-handoff-payload.ts
|
|
49539
49660
|
const buildHandoffPayload = (input) => {
|
|
49540
49661
|
const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
|
|
49541
|
-
let
|
|
49662
|
+
let outputDirectory = null;
|
|
49542
49663
|
try {
|
|
49543
|
-
|
|
49664
|
+
outputDirectory = writeDiagnosticsDirectory([...input.diagnostics], input.outputDirectory);
|
|
49544
49665
|
} catch {}
|
|
49545
49666
|
const lines = [
|
|
49546
49667
|
"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:",
|
|
@@ -49567,7 +49688,7 @@ const buildHandoffPayload = (input) => {
|
|
|
49567
49688
|
if (remainingFiles > 0) lines.push(` - +${remainingFiles} more files`);
|
|
49568
49689
|
});
|
|
49569
49690
|
lines.push("");
|
|
49570
|
-
if (
|
|
49691
|
+
if (outputDirectory) lines.push(`Full results for all ${input.diagnostics.length} issues (diagnostics.json + a .txt per rule): ${outputDirectory}`, "");
|
|
49571
49692
|
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.");
|
|
49572
49693
|
return lines.join("\n");
|
|
49573
49694
|
};
|
|
@@ -51466,7 +51587,8 @@ const handoffToAgent = async (input) => {
|
|
|
51466
51587
|
if (handoffTarget === void 0 || handoffTarget === SKIP_CHOICE) return;
|
|
51467
51588
|
const payload = buildHandoffPayload({
|
|
51468
51589
|
diagnostics: input.diagnostics,
|
|
51469
|
-
projectName: input.projectName
|
|
51590
|
+
projectName: input.projectName,
|
|
51591
|
+
outputDirectory: input.outputDirectory
|
|
51470
51592
|
});
|
|
51471
51593
|
if (handoffTarget === CLIPBOARD_CHOICE) {
|
|
51472
51594
|
if (await copyToClipboard(payload)) cliLogger.log("Copied the prompt to your clipboard.");
|
|
@@ -51687,6 +51809,9 @@ const readChangedFilesFrom = (filePath) => {
|
|
|
51687
51809
|
return [...uniqueFiles];
|
|
51688
51810
|
};
|
|
51689
51811
|
//#endregion
|
|
51812
|
+
//#region src/cli/utils/filter-scans-for-surface.ts
|
|
51813
|
+
const filterScansForSurface = (completedScans, surface) => completedScans.flatMap((scan) => filterDiagnosticsForSurface([...scan.result.diagnostics], surface, scan.config));
|
|
51814
|
+
//#endregion
|
|
51690
51815
|
//#region src/cli/utils/render-multi-project-summary.ts
|
|
51691
51816
|
const getScoreLabel = (score) => {
|
|
51692
51817
|
if (score >= 75) return "Great";
|
|
@@ -51714,10 +51839,10 @@ const findLowestScoredScan = (completedScans) => {
|
|
|
51714
51839
|
return scoredScans.reduce((worst, scan) => scan.result.score.score < worst.result.score.score ? scan : worst);
|
|
51715
51840
|
};
|
|
51716
51841
|
const printMultiProjectSummary = (input) => gen(function* () {
|
|
51717
|
-
const { completedScans,
|
|
51842
|
+
const { completedScans, verbose, isOffline, projectName, totalElapsedMilliseconds } = input;
|
|
51718
51843
|
const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
|
|
51719
51844
|
const animateRender = !verbose && canAnimateOnboarding(process.stdout);
|
|
51720
|
-
const displayDiagnostics = filterDiagnosticsByCategories(
|
|
51845
|
+
const displayDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, "cli"), categoryFilters);
|
|
51721
51846
|
const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
|
|
51722
51847
|
for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
|
|
51723
51848
|
const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
|
|
@@ -51729,8 +51854,7 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51729
51854
|
else fileCountFromScansWithoutPaths += scan.result.scannedFileCount ?? scan.result.project.sourceFileCount;
|
|
51730
51855
|
}
|
|
51731
51856
|
const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
|
|
51732
|
-
|
|
51733
|
-
yield* log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalScanElapsedMilliseconds)}`);
|
|
51857
|
+
yield* log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalElapsedMilliseconds)}`);
|
|
51734
51858
|
if (displayDiagnostics.length > 0) {
|
|
51735
51859
|
yield* log("");
|
|
51736
51860
|
yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
|
|
@@ -51740,16 +51864,17 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51740
51864
|
const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
|
|
51741
51865
|
yield* printSummary({
|
|
51742
51866
|
diagnostics: displayDiagnostics,
|
|
51743
|
-
elapsedMilliseconds:
|
|
51867
|
+
elapsedMilliseconds: totalElapsedMilliseconds,
|
|
51744
51868
|
scoreResult: aggregateScore,
|
|
51745
|
-
potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics,
|
|
51869
|
+
potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics, filterScansForSurface([lowestScoredScan], "cli"), lowestScoredScan.result.score)) : null,
|
|
51746
51870
|
totalSourceFileCount,
|
|
51747
51871
|
noScoreMessage: "Score unavailable.",
|
|
51748
51872
|
verbose,
|
|
51873
|
+
outputDirectory: input.outputDirectory,
|
|
51749
51874
|
animateProjection: animateRender
|
|
51750
51875
|
});
|
|
51751
51876
|
const entries = completedScans.map((scan) => {
|
|
51752
|
-
const projectDiagnostics = filterDiagnosticsByCategories(
|
|
51877
|
+
const projectDiagnostics = filterDiagnosticsByCategories(filterScansForSurface([scan], "cli"), categoryFilters);
|
|
51753
51878
|
const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
51754
51879
|
return {
|
|
51755
51880
|
projectName: scan.result.project.projectName,
|
|
@@ -51846,6 +51971,7 @@ const resolveCliInspectOptions = (flags, userConfig) => {
|
|
|
51846
51971
|
lint: flags.lint,
|
|
51847
51972
|
deadCode: flags.deadCode,
|
|
51848
51973
|
verbose: flags.verbose,
|
|
51974
|
+
outputDirectory: flags.outputDir,
|
|
51849
51975
|
respectInlineDisables: flags.respectInlineDisables === false ? false : void 0,
|
|
51850
51976
|
warnings: wantsWarningGate ? true : flags.warnings,
|
|
51851
51977
|
scoreOnly: flags.score === true,
|
|
@@ -52095,16 +52221,22 @@ const parseFileLineArgument = (rawArgument) => {
|
|
|
52095
52221
|
};
|
|
52096
52222
|
//#endregion
|
|
52097
52223
|
//#region src/cli/utils/select-projects.ts
|
|
52098
|
-
const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
|
|
52224
|
+
const selectProjects = async (rootDirectory, projectFlag, skipPrompts, configProjects) => {
|
|
52099
52225
|
const hasRootPackageJson = isFile(Path.join(rootDirectory, "package.json"));
|
|
52100
52226
|
let packages = listWorkspacePackages(rootDirectory);
|
|
52101
52227
|
if (packages.length === 0 && (!hasRootPackageJson || isMonorepoRoot(rootDirectory))) packages = discoverReactSubprojects(rootDirectory);
|
|
52228
|
+
if (projectFlag) return resolveProjectFlag(projectFlag, packages, rootDirectory);
|
|
52229
|
+
const configRequestedNames = (configProjects ?? []).map((requestedName) => requestedName.trim()).filter((requestedName) => requestedName.length > 0);
|
|
52230
|
+
if (configRequestedNames.length > 0) {
|
|
52231
|
+
const resolvedDirectories = resolveRequestedProjects(configRequestedNames, packages, rootDirectory, "config");
|
|
52232
|
+
recordCount(METRIC.projectConfigSelected, resolvedDirectories.length);
|
|
52233
|
+
return resolvedDirectories;
|
|
52234
|
+
}
|
|
52102
52235
|
if (packages.length === 0) return [rootDirectory];
|
|
52103
52236
|
if (packages.length === 1) {
|
|
52104
52237
|
cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages[0].name}`);
|
|
52105
52238
|
return [packages[0].directory];
|
|
52106
52239
|
}
|
|
52107
|
-
if (projectFlag) return resolveProjectFlag(projectFlag, packages);
|
|
52108
52240
|
if (skipPrompts) {
|
|
52109
52241
|
printDiscoveredProjects(packages);
|
|
52110
52242
|
return packages.map((workspacePackage) => workspacePackage.directory);
|
|
@@ -52112,17 +52244,25 @@ const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
|
|
|
52112
52244
|
return promptProjectSelection(packages, rootDirectory);
|
|
52113
52245
|
};
|
|
52114
52246
|
const ALL_PROJECTS_SENTINEL = "*";
|
|
52115
|
-
const resolveProjectFlag = (projectFlag, workspacePackages) => {
|
|
52247
|
+
const resolveProjectFlag = (projectFlag, workspacePackages, rootDirectory) => {
|
|
52116
52248
|
const requestedNames = projectFlag.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
52117
52249
|
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.`);
|
|
52118
|
-
|
|
52119
|
-
|
|
52120
|
-
|
|
52250
|
+
return resolveRequestedProjects(requestedNames, workspacePackages, rootDirectory, "flag");
|
|
52251
|
+
};
|
|
52252
|
+
const resolveRequestedProjects = (requestedNames, workspacePackages, rootDirectory, source) => {
|
|
52253
|
+
if (requestedNames.includes(ALL_PROJECTS_SENTINEL)) return workspacePackages.length > 0 ? workspacePackages.map((workspacePackage) => workspacePackage.directory) : [rootDirectory];
|
|
52254
|
+
const sourceLabel = source === "flag" ? "Project" : "Config \"projects\" entry";
|
|
52255
|
+
return requestedNames.map((requestedName) => {
|
|
52121
52256
|
const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || Path.basename(workspacePackage.directory) === requestedName);
|
|
52122
|
-
if (
|
|
52123
|
-
|
|
52124
|
-
|
|
52125
|
-
|
|
52257
|
+
if (matched) return matched.directory;
|
|
52258
|
+
const candidateDirectory = Path.resolve(rootDirectory, requestedName);
|
|
52259
|
+
if (isDirectory(candidateDirectory)) {
|
|
52260
|
+
recordCount(METRIC.projectPathSelected);
|
|
52261
|
+
return candidateDirectory;
|
|
52262
|
+
}
|
|
52263
|
+
const availableNames = workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ");
|
|
52264
|
+
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}.`);
|
|
52265
|
+
});
|
|
52126
52266
|
};
|
|
52127
52267
|
const printDiscoveredProjects = (packages) => {
|
|
52128
52268
|
cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
|
|
@@ -52317,7 +52457,7 @@ const finalizeScans = (input) => {
|
|
|
52317
52457
|
}));
|
|
52318
52458
|
}
|
|
52319
52459
|
if (input.isScoreOnly || baselineDegraded) return;
|
|
52320
|
-
if (shouldBlockCi(
|
|
52460
|
+
if (shouldBlockCi(filterScansForSurface(input.completedScans, "ciFailure"), resolveBlockingLevel(input.flags, input.userConfig))) process.exitCode = 1;
|
|
52321
52461
|
};
|
|
52322
52462
|
const buildChangedFilesDiffInfo = (changedFiles) => ({
|
|
52323
52463
|
currentBranch: process.env.GITHUB_HEAD_REF?.trim() || null,
|
|
@@ -52450,7 +52590,6 @@ const inspectAction = async (directory, flags) => {
|
|
|
52450
52590
|
filePath: Path.isAbsolute(diagnostic.filePath) ? diagnostic.filePath.replaceAll(snapshot.tempDirectory, () => resolvedDirectory) : diagnostic.filePath
|
|
52451
52591
|
}));
|
|
52452
52592
|
finalizeScans({
|
|
52453
|
-
diagnostics: remappedDiagnostics,
|
|
52454
52593
|
completedScans: [{
|
|
52455
52594
|
directory: resolvedDirectory,
|
|
52456
52595
|
result: {
|
|
@@ -52460,7 +52599,8 @@ const inspectAction = async (directory, flags) => {
|
|
|
52460
52599
|
...scanResult.project,
|
|
52461
52600
|
rootDirectory: resolvedDirectory
|
|
52462
52601
|
}
|
|
52463
|
-
}
|
|
52602
|
+
},
|
|
52603
|
+
config: userConfig
|
|
52464
52604
|
}],
|
|
52465
52605
|
mode: "staged",
|
|
52466
52606
|
diff: null,
|
|
@@ -52478,7 +52618,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
52478
52618
|
}
|
|
52479
52619
|
return;
|
|
52480
52620
|
}
|
|
52481
|
-
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
|
|
52621
|
+
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts, userConfig?.projects);
|
|
52482
52622
|
const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
|
|
52483
52623
|
const requestedScope = resolveScope(flags, userConfig);
|
|
52484
52624
|
const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
|
|
@@ -52516,56 +52656,87 @@ const inspectAction = async (directory, flags) => {
|
|
|
52516
52656
|
}
|
|
52517
52657
|
cliLogger.break();
|
|
52518
52658
|
}
|
|
52519
|
-
const allDiagnostics = [];
|
|
52520
52659
|
const completedScans = [];
|
|
52521
52660
|
const isMultiProject = projectDirectories.length > 1;
|
|
52522
|
-
const
|
|
52523
|
-
|
|
52661
|
+
const scanProject = async (projectDirectory) => {
|
|
52662
|
+
const projectScanTarget = projectDirectory === resolvedDirectory ? scanTarget : await resolveScanTarget(projectDirectory, { allowAmbiguous: true });
|
|
52663
|
+
const scanDirectory = projectScanTarget.resolvedDirectory;
|
|
52664
|
+
const projectConfig = projectDirectory === resolvedDirectory ? userConfig : mergeReactDoctorConfigs(userConfig, projectScanTarget.userConfig ?? void 0);
|
|
52665
|
+
const projectConfigSourceDirectory = projectScanTarget.userConfig?.plugins === void 0 ? scanTarget.configSourceDirectory : projectScanTarget.configSourceDirectory;
|
|
52666
|
+
const supplyChainEnabled = projectConfig?.supplyChain?.enabled !== false;
|
|
52524
52667
|
let includePaths;
|
|
52525
52668
|
let supplyChainManifestChanged = false;
|
|
52526
52669
|
if (isDiffMode) {
|
|
52527
|
-
const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory,
|
|
52528
|
-
supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory,
|
|
52670
|
+
const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory, scanDirectory, diffInfo);
|
|
52671
|
+
supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory, scanDirectory, diffInfo);
|
|
52529
52672
|
if (changedSourceFiles.length === 0 && !supplyChainManifestChanged) {
|
|
52530
52673
|
if (!isQuiet) {
|
|
52531
|
-
cliLogger.dim(`No changed source files in ${
|
|
52674
|
+
cliLogger.dim(`No changed source files in ${scanDirectory}, skipping.`);
|
|
52532
52675
|
cliLogger.break();
|
|
52533
52676
|
}
|
|
52534
|
-
|
|
52677
|
+
return null;
|
|
52535
52678
|
}
|
|
52536
52679
|
includePaths = [...changedSourceFiles];
|
|
52537
52680
|
if (supplyChainManifestChanged) includePaths.push("package.json");
|
|
52538
52681
|
}
|
|
52539
52682
|
if (!isQuiet && !isMultiProject) cliLogger.dim(" ");
|
|
52540
|
-
const scanResult = await inspect(
|
|
52683
|
+
const scanResult = await inspect(scanDirectory, {
|
|
52541
52684
|
...scanOptions,
|
|
52542
52685
|
includePaths,
|
|
52543
|
-
configOverride:
|
|
52686
|
+
configOverride: projectConfig,
|
|
52687
|
+
configSourceDirectory: projectConfigSourceDirectory ?? void 0,
|
|
52544
52688
|
suppressRendering: isMultiProject,
|
|
52689
|
+
concurrentScan: isMultiProject,
|
|
52545
52690
|
baseline: baselineRef ? { ref: baselineRef } : void 0,
|
|
52546
|
-
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory,
|
|
52691
|
+
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, scanDirectory, changedLineRanges) : void 0,
|
|
52547
52692
|
supplyChainManifestChanged
|
|
52548
52693
|
});
|
|
52549
|
-
allDiagnostics.push(...scanResult.diagnostics);
|
|
52550
|
-
completedScans.push({
|
|
52551
|
-
directory: projectDirectory,
|
|
52552
|
-
result: scanResult
|
|
52553
|
-
});
|
|
52554
52694
|
if (!isQuiet && !isMultiProject) cliLogger.break();
|
|
52695
|
+
return {
|
|
52696
|
+
directory: scanDirectory,
|
|
52697
|
+
result: scanResult,
|
|
52698
|
+
config: projectConfig
|
|
52699
|
+
};
|
|
52700
|
+
};
|
|
52701
|
+
const scanLoopStartTime = performance$1.now();
|
|
52702
|
+
const projectCount = projectDirectories.length;
|
|
52703
|
+
const batchSpinner = isMultiProject && !isQuiet ? spinner(`Scanning ${projectCount} projects…`).start() : null;
|
|
52704
|
+
const ownsBatchSpinnerSilence = isMultiProject && scanOptions.silent === true;
|
|
52705
|
+
const wasSpinnerSilent = isSpinnerSilent();
|
|
52706
|
+
if (ownsBatchSpinnerSilence) setSpinnerSilent(true);
|
|
52707
|
+
let finishedProjectCount = 0;
|
|
52708
|
+
let scanOutcomes;
|
|
52709
|
+
try {
|
|
52710
|
+
scanOutcomes = await mapWithConcurrency(projectDirectories, isMultiProject ? 4 : 1, async (projectDirectory) => {
|
|
52711
|
+
const scanOutcome = await scanProject(projectDirectory);
|
|
52712
|
+
finishedProjectCount += 1;
|
|
52713
|
+
batchSpinner?.update(`Scanning ${projectCount} projects… (${finishedProjectCount}/${projectCount})`);
|
|
52714
|
+
return scanOutcome;
|
|
52715
|
+
});
|
|
52716
|
+
} finally {
|
|
52717
|
+
if (ownsBatchSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
|
|
52718
|
+
batchSpinner?.stop();
|
|
52719
|
+
}
|
|
52720
|
+
for (const scanOutcome of scanOutcomes) {
|
|
52721
|
+
if (scanOutcome === null) continue;
|
|
52722
|
+
completedScans.push(scanOutcome);
|
|
52555
52723
|
}
|
|
52556
52724
|
if (!isQuiet && isMultiProject && completedScans.length > 0) {
|
|
52557
52725
|
const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
|
|
52558
52726
|
await runPromise(printMultiProjectSummary({
|
|
52559
52727
|
completedScans,
|
|
52560
52728
|
categoryFilters,
|
|
52561
|
-
userConfig,
|
|
52562
52729
|
verbose: Boolean(flags.verbose),
|
|
52730
|
+
outputDirectory: flags.outputDir,
|
|
52563
52731
|
isOffline: !shouldShowShareLink,
|
|
52564
|
-
projectName: Path.basename(resolvedDirectory)
|
|
52732
|
+
projectName: Path.basename(resolvedDirectory),
|
|
52733
|
+
totalElapsedMilliseconds: performance$1.now() - scanLoopStartTime
|
|
52565
52734
|
}));
|
|
52566
52735
|
}
|
|
52736
|
+
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, scanOptions.outputSurface ?? "cli"), categoryFilters);
|
|
52737
|
+
const didScansWriteDump = isMultiProject ? !isQuiet && completedScans.length > 0 : completedScans.length > 0;
|
|
52738
|
+
if (flags.outputDir && !didScansWriteDump) await runPromise(printDiagnosticsDump(selectedSurfaceDiagnostics, flags.outputDir, false, isQuiet ? "stderr" : "stdout"));
|
|
52567
52739
|
finalizeScans({
|
|
52568
|
-
diagnostics: allDiagnostics,
|
|
52569
52740
|
completedScans,
|
|
52570
52741
|
mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
|
|
52571
52742
|
diff: isDiffMode ? diffInfo : null,
|
|
@@ -52578,13 +52749,13 @@ const inspectAction = async (directory, flags) => {
|
|
|
52578
52749
|
resolvedDirectory,
|
|
52579
52750
|
startTime
|
|
52580
52751
|
});
|
|
52581
|
-
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
|
|
52582
52752
|
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
|
|
52583
52753
|
await handoffToAgent({
|
|
52584
52754
|
diagnostics: selectedSurfaceDiagnostics,
|
|
52585
52755
|
projectName: Path.basename(resolvedDirectory),
|
|
52586
52756
|
rootDirectory: resolvedDirectory,
|
|
52587
|
-
interactive: true
|
|
52757
|
+
interactive: true,
|
|
52758
|
+
outputDirectory: flags.outputDir
|
|
52588
52759
|
});
|
|
52589
52760
|
return;
|
|
52590
52761
|
}
|
|
@@ -53380,6 +53551,7 @@ const ROOT_FLAG_SPEC = {
|
|
|
53380
53551
|
"--category",
|
|
53381
53552
|
"--changed-files-from",
|
|
53382
53553
|
"--blocking",
|
|
53554
|
+
"--output-dir",
|
|
53383
53555
|
"--fail-on",
|
|
53384
53556
|
"--project",
|
|
53385
53557
|
"--scope"
|
|
@@ -53534,6 +53706,7 @@ ${formatExampleLines([
|
|
|
53534
53706
|
["react-doctor", "scan the current project"],
|
|
53535
53707
|
["react-doctor ./apps/web", "scan a specific directory"],
|
|
53536
53708
|
["react-doctor --diff main", "scan only files changed vs. main"],
|
|
53709
|
+
["react-doctor --project modules/a,modules/b", "score each module separately (names or paths)"],
|
|
53537
53710
|
["react-doctor --staged", "scan staged files (pre-commit hook)"],
|
|
53538
53711
|
["react-doctor --category Security", "show only one diagnostic category"],
|
|
53539
53712
|
["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
|
|
@@ -53565,9 +53738,9 @@ ${highlighter.dim("Learn more:")}
|
|
|
53565
53738
|
${highlighter.info(CANONICAL_GITHUB_URL)}
|
|
53566
53739
|
`;
|
|
53567
53740
|
const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
|
|
53568
|
-
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
|
|
53741
|
+
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);
|
|
53569
53742
|
program.action(inspectAction);
|
|
53570
|
-
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
|
|
53743
|
+
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));
|
|
53571
53744
|
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);
|
|
53572
53745
|
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);
|
|
53573
53746
|
const rules = program.command("rules").description("List, explain, and configure which React Doctor rules run");
|
|
@@ -53608,4 +53781,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
53608
53781
|
export {};
|
|
53609
53782
|
|
|
53610
53783
|
//# sourceMappingURL=cli.js.map
|
|
53611
|
-
//# debugId=
|
|
53784
|
+
//# debugId=0d78b267-b420-5397-a36a-5fed74a7f95f
|