react-doctor 0.5.1-dev.c4f0e60 → 0.5.1-dev.d48e7f1
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 +224 -92
- package/dist/index.d.ts +77 -39
- package/dist/index.js +102 -7
- package/dist/lsp.js +4 -2
- package/package.json +5 -5
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]="d9ff1bf2-c7e4-5f82-b78e-f40ab73a0483")}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";
|
|
@@ -43496,6 +43496,48 @@ const groupBy = (items, keyFn) => {
|
|
|
43496
43496
|
* a 404. Gate the directive on this predicate.
|
|
43497
43497
|
*/
|
|
43498
43498
|
const hasPublishedFixRecipe = (diagnostic) => diagnostic.plugin === "react-doctor" && Object.hasOwn(reactDoctorPlugin.rules, diagnostic.rule);
|
|
43499
|
+
const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
|
|
43500
|
+
const mergeIgnores = (baseIgnore, overrideIgnore) => {
|
|
43501
|
+
const mergedIgnore = {
|
|
43502
|
+
...baseIgnore,
|
|
43503
|
+
...overrideIgnore
|
|
43504
|
+
};
|
|
43505
|
+
if (baseIgnore.rules && overrideIgnore.rules) mergedIgnore.rules = unionValues(baseIgnore.rules, overrideIgnore.rules);
|
|
43506
|
+
if (baseIgnore.files && overrideIgnore.files) mergedIgnore.files = unionValues(baseIgnore.files, overrideIgnore.files);
|
|
43507
|
+
if (baseIgnore.tags && overrideIgnore.tags) mergedIgnore.tags = unionValues(baseIgnore.tags, overrideIgnore.tags);
|
|
43508
|
+
if (baseIgnore.overrides && overrideIgnore.overrides) mergedIgnore.overrides = [...baseIgnore.overrides, ...overrideIgnore.overrides];
|
|
43509
|
+
return mergedIgnore;
|
|
43510
|
+
};
|
|
43511
|
+
/**
|
|
43512
|
+
* Layer one `ReactDoctorConfig` on top of another, additively: `rules` /
|
|
43513
|
+
* `categories` / `supplyChain` merge per key, `ignore` lists union
|
|
43514
|
+
* (`ignore.overrides` concatenate), and every other field is a scalar the
|
|
43515
|
+
* override simply wins on when set. Returns the base unchanged when there
|
|
43516
|
+
* is no override, and vice versa — so callers can thread `null` /
|
|
43517
|
+
* `undefined` through without special-casing.
|
|
43518
|
+
*/
|
|
43519
|
+
const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
|
|
43520
|
+
if (overrideConfig === void 0) return baseConfig;
|
|
43521
|
+
if (baseConfig === null) return overrideConfig;
|
|
43522
|
+
const mergedConfig = {
|
|
43523
|
+
...baseConfig,
|
|
43524
|
+
...overrideConfig
|
|
43525
|
+
};
|
|
43526
|
+
if (baseConfig.rules && overrideConfig.rules) mergedConfig.rules = {
|
|
43527
|
+
...baseConfig.rules,
|
|
43528
|
+
...overrideConfig.rules
|
|
43529
|
+
};
|
|
43530
|
+
if (baseConfig.categories && overrideConfig.categories) mergedConfig.categories = {
|
|
43531
|
+
...baseConfig.categories,
|
|
43532
|
+
...overrideConfig.categories
|
|
43533
|
+
};
|
|
43534
|
+
if (baseConfig.supplyChain && overrideConfig.supplyChain) mergedConfig.supplyChain = {
|
|
43535
|
+
...baseConfig.supplyChain,
|
|
43536
|
+
...overrideConfig.supplyChain
|
|
43537
|
+
};
|
|
43538
|
+
if (baseConfig.ignore && overrideConfig.ignore) mergedConfig.ignore = mergeIgnores(baseConfig.ignore, overrideConfig.ignore);
|
|
43539
|
+
return mergedConfig;
|
|
43540
|
+
};
|
|
43499
43541
|
//#endregion
|
|
43500
43542
|
//#region src/cli/utils/is-ci-environment.ts
|
|
43501
43543
|
const CI_ENVIRONMENT_VARIABLES = [
|
|
@@ -43604,6 +43646,8 @@ const METRIC = {
|
|
|
43604
43646
|
cliInvoked: "cli.invoked",
|
|
43605
43647
|
cliError: "cli.error",
|
|
43606
43648
|
projectDetected: "project.detected",
|
|
43649
|
+
projectPathSelected: "project.path_selected",
|
|
43650
|
+
projectConfigSelected: "project.config_selected",
|
|
43607
43651
|
scanCompleted: "scan.completed",
|
|
43608
43652
|
scanDuration: "scan.duration",
|
|
43609
43653
|
scanPhaseDuration: "scan.phase_duration",
|
|
@@ -43673,7 +43717,7 @@ const makeNoopConsole = () => ({
|
|
|
43673
43717
|
});
|
|
43674
43718
|
//#endregion
|
|
43675
43719
|
//#region src/cli/utils/version.ts
|
|
43676
|
-
const VERSION = "0.5.1-dev.
|
|
43720
|
+
const VERSION = "0.5.1-dev.d48e7f1";
|
|
43677
43721
|
//#endregion
|
|
43678
43722
|
//#region src/cli/utils/json-mode.ts
|
|
43679
43723
|
let context = null;
|
|
@@ -44031,13 +44075,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
44031
44075
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
44032
44076
|
* standard `SENTRY_RELEASE` override.
|
|
44033
44077
|
*/
|
|
44034
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.
|
|
44078
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.d48e7f1`;
|
|
44035
44079
|
/**
|
|
44036
44080
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
44037
44081
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
44038
44082
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
44039
44083
|
*/
|
|
44040
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.
|
|
44084
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.d48e7f1") ? "development" : "production");
|
|
44041
44085
|
/**
|
|
44042
44086
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
44043
44087
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -47335,12 +47379,13 @@ const toSpanAttributes = (tags) => {
|
|
|
47335
47379
|
/**
|
|
47336
47380
|
* Clears the module-level run-scoped Sentry state — the current scanned project
|
|
47337
47381
|
* 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
|
-
*
|
|
47382
|
+
* again after a clean one, so a prior or just-finished scan can't attach its
|
|
47383
|
+
* project tags / trace to a later run or to a non-scan error (e.g.
|
|
47384
|
+
* inspectAction's post-loop finalize/handoff steps). A thrown scan error skips
|
|
47385
|
+
* the post-run reset, leaving the state for the command catch to attribute and
|
|
47386
|
+
* link the crash. Concurrent batch members (`concurrentScan`) never touch this
|
|
47387
|
+
* state — they neither write nor reset it. Safe to call when Sentry is off (the
|
|
47388
|
+
* refs are read only when an event is built).
|
|
47344
47389
|
*/
|
|
47345
47390
|
const resetSentryRunState = () => {
|
|
47346
47391
|
setSentryProjectInfo(null);
|
|
@@ -47363,8 +47408,13 @@ const resetSentryRunState = () => {
|
|
|
47363
47408
|
* state right after a clean run and at the start of the next one, so the trace
|
|
47364
47409
|
* is never attached to a non-scan error; on a thrown error the state is left in
|
|
47365
47410
|
* place for the command catch, then the process exits.
|
|
47411
|
+
*
|
|
47412
|
+
* A `concurrentScan` (one member of the CLI's multi-project pool) still gets
|
|
47413
|
+
* its own root span, but skips recording the active run trace — the module-
|
|
47414
|
+
* level handle has single-scan semantics, and overlapping writers would link a
|
|
47415
|
+
* crash to an arbitrary sibling's trace.
|
|
47366
47416
|
*/
|
|
47367
|
-
const withSentryRunSpan = (run) => {
|
|
47417
|
+
const withSentryRunSpan = (run, options = {}) => {
|
|
47368
47418
|
if (!isSentryTracingEnabled()) return run(void 0);
|
|
47369
47419
|
const { tags } = buildSentryScope();
|
|
47370
47420
|
const command = typeof tags.command === "string" ? tags.command : "inspect";
|
|
@@ -47373,12 +47423,14 @@ const withSentryRunSpan = (run) => {
|
|
|
47373
47423
|
op: "cli.inspect",
|
|
47374
47424
|
attributes: toSpanAttributes(tags)
|
|
47375
47425
|
}, (rootSpan) => {
|
|
47376
|
-
|
|
47377
|
-
|
|
47378
|
-
|
|
47379
|
-
|
|
47380
|
-
|
|
47381
|
-
|
|
47426
|
+
if (options.concurrentScan !== true) {
|
|
47427
|
+
const spanContext = rootSpan.spanContext();
|
|
47428
|
+
setActiveRunTrace({
|
|
47429
|
+
traceId: spanContext.traceId,
|
|
47430
|
+
spanId: spanContext.spanId,
|
|
47431
|
+
sampled: (spanContext.traceFlags & 1) === 1
|
|
47432
|
+
});
|
|
47433
|
+
}
|
|
47382
47434
|
return run(rootSpan);
|
|
47383
47435
|
});
|
|
47384
47436
|
};
|
|
@@ -47389,9 +47441,15 @@ const withSentryRunSpan = (run) => {
|
|
|
47389
47441
|
* run's root span so the transaction/trace carries the project shape too.
|
|
47390
47442
|
* Always cheap — the span attribute set is skipped when `rootSpan` is absent
|
|
47391
47443
|
* (tracing off), and storing the info is a plain assignment.
|
|
47444
|
+
*
|
|
47445
|
+
* A `concurrentScan` only sets the span attributes: the module-level project
|
|
47446
|
+
* ref has single-scan semantics, and overlapping writers would stamp events
|
|
47447
|
+
* and metrics with an arbitrary sibling's project. Wide events keep full
|
|
47448
|
+
* attribution (they ride the span); per-emit metrics simply omit the project
|
|
47449
|
+
* shape during a concurrent batch (absent, never wrong).
|
|
47392
47450
|
*/
|
|
47393
|
-
const recordSentryProjectContext = (projectInfo, rootSpan) => {
|
|
47394
|
-
setSentryProjectInfo(projectInfo);
|
|
47451
|
+
const recordSentryProjectContext = (projectInfo, rootSpan, options = {}) => {
|
|
47452
|
+
if (options.concurrentScan !== true) setSentryProjectInfo(projectInfo);
|
|
47395
47453
|
rootSpan?.setAttributes(toSpanAttributes(buildSentryProjectContext(projectInfo).tags));
|
|
47396
47454
|
};
|
|
47397
47455
|
//#endregion
|
|
@@ -47685,6 +47743,7 @@ const buildConfigAttributes = (input) => {
|
|
|
47685
47743
|
noScore: input.noScore,
|
|
47686
47744
|
respectInlineDisables: input.respectInlineDisables,
|
|
47687
47745
|
showWarnings: input.showWarnings,
|
|
47746
|
+
usedOutputDir: input.usedOutputDir,
|
|
47688
47747
|
ignoredTagCount: input.ignoredTagCount,
|
|
47689
47748
|
hasCustomConfig: input.hasCustomConfig,
|
|
47690
47749
|
rulesConfigured: ruleKeys.length,
|
|
@@ -48502,15 +48561,22 @@ const printNoScoreHeader = (noScoreMessage) => gen(function* () {
|
|
|
48502
48561
|
});
|
|
48503
48562
|
//#endregion
|
|
48504
48563
|
//#region src/cli/utils/write-diagnostics-directory.ts
|
|
48505
|
-
const
|
|
48506
|
-
|
|
48507
|
-
|
|
48508
|
-
|
|
48509
|
-
|
|
48510
|
-
|
|
48564
|
+
const ruleDumpFileName = (ruleKey) => ruleKey.replace(/\//g, "--") + ".txt";
|
|
48565
|
+
const readPreviousRuleDumpFileNames = (directory) => {
|
|
48566
|
+
try {
|
|
48567
|
+
const previous = JSON.parse(NFS.readFileSync(Path.join(directory, "diagnostics.json"), "utf8"));
|
|
48568
|
+
return new Set(previous.filter((d) => typeof d?.plugin === "string" && typeof d?.rule === "string").map((d) => ruleDumpFileName(`${d.plugin}/${d.rule}`)));
|
|
48569
|
+
} catch {
|
|
48570
|
+
return /* @__PURE__ */ new Set();
|
|
48511
48571
|
}
|
|
48512
|
-
|
|
48513
|
-
|
|
48572
|
+
};
|
|
48573
|
+
const writeDiagnosticsDirectory = (diagnostics, outputDirectory) => {
|
|
48574
|
+
const directory = outputDirectory ? Path.resolve(outputDirectory) : Path.join(tmpdir(), `react-doctor-${randomUUID()}`);
|
|
48575
|
+
if (outputDirectory) for (const fileName of readPreviousRuleDumpFileNames(directory)) NFS.rmSync(Path.join(directory, fileName), { force: true });
|
|
48576
|
+
NFS.mkdirSync(directory, { recursive: true });
|
|
48577
|
+
for (const [ruleKey, ruleDiagnostics] of buildSortedRuleGroups(diagnostics)) NFS.writeFileSync(Path.join(directory, ruleDumpFileName(ruleKey)), formatRuleSummary(ruleKey, ruleDiagnostics));
|
|
48578
|
+
NFS.writeFileSync(Path.join(directory, "diagnostics.json"), JSON.stringify(diagnostics));
|
|
48579
|
+
return directory;
|
|
48514
48580
|
};
|
|
48515
48581
|
//#endregion
|
|
48516
48582
|
//#region src/cli/utils/render-summary.ts
|
|
@@ -48547,6 +48613,16 @@ const printFooter = (input) => gen(function* () {
|
|
|
48547
48613
|
yield* log(` ${highlighter.bold("GitHub:")} ${highlighter.info(CANONICAL_GITHUB_URL)}`);
|
|
48548
48614
|
yield* printFooterDescription("Report issues and star the repository!");
|
|
48549
48615
|
});
|
|
48616
|
+
const printDiagnosticsDump = (diagnostics, outputDirectory, verbose, stream = "stdout") => gen(function* () {
|
|
48617
|
+
const writtenDirectory = yield* try_({
|
|
48618
|
+
try: () => writeDiagnosticsDirectory(diagnostics, outputDirectory),
|
|
48619
|
+
catch: (cause) => cause
|
|
48620
|
+
}).pipe(orElseSucceed(() => null));
|
|
48621
|
+
if (writtenDirectory !== null && (verbose || outputDirectory)) {
|
|
48622
|
+
const pathLine = highlighter.gray(` Full diagnostics written to ${writtenDirectory}`);
|
|
48623
|
+
yield* stream === "stderr" || Boolean(outputDirectory) && isJsonModeActive() ? sync(() => process.stderr.write(`${pathLine}\n`)) : log(pathLine);
|
|
48624
|
+
}
|
|
48625
|
+
});
|
|
48550
48626
|
const printSummary = (input) => gen(function* () {
|
|
48551
48627
|
if (input.scoreResult) {
|
|
48552
48628
|
const animateProjection = Boolean(input.animateProjection) && input.potentialScore != null && !input.verbose;
|
|
@@ -48557,11 +48633,7 @@ const printSummary = (input) => gen(function* () {
|
|
|
48557
48633
|
if (animateProjection) yield* animateScoreProjection(input.scoreResult, input.potentialScore, 5);
|
|
48558
48634
|
}
|
|
48559
48635
|
} 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}`));
|
|
48636
|
+
yield* printDiagnosticsDump(input.diagnostics, input.outputDirectory, input.verbose);
|
|
48565
48637
|
});
|
|
48566
48638
|
//#endregion
|
|
48567
48639
|
//#region src/cli/utils/should-auto-select-current-choice.ts
|
|
@@ -48951,6 +49023,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
48951
49023
|
lint: inputOptions.lint ?? userConfig?.lint ?? true,
|
|
48952
49024
|
deadCode: inputOptions.deadCode ?? userConfig?.deadCode ?? true,
|
|
48953
49025
|
verbose: inputOptions.verbose ?? userConfig?.verbose ?? false,
|
|
49026
|
+
outputDirectory: inputOptions.outputDirectory || null,
|
|
48954
49027
|
scoreOnly: inputOptions.scoreOnly ?? false,
|
|
48955
49028
|
noScore: inputOptions.noScore ?? userConfig?.noScore ?? false,
|
|
48956
49029
|
isCi: inputOptions.isCi ?? false,
|
|
@@ -48967,6 +49040,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
48967
49040
|
ignoredTags: buildIgnoredTags(userConfig),
|
|
48968
49041
|
outputSurface: inputOptions.outputSurface ?? "cli",
|
|
48969
49042
|
suppressRendering: inputOptions.suppressRendering ?? false,
|
|
49043
|
+
concurrentScan: inputOptions.concurrentScan ?? false,
|
|
48970
49044
|
concurrency: inputOptions.concurrency,
|
|
48971
49045
|
baseline: inputOptions.baseline ?? null,
|
|
48972
49046
|
changedLineRanges: inputOptions.changedLineRanges ?? null,
|
|
@@ -48987,13 +49061,15 @@ const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
|
|
|
48987
49061
|
noScore: options.noScore,
|
|
48988
49062
|
respectInlineDisables: options.respectInlineDisables,
|
|
48989
49063
|
showWarnings: options.warnings,
|
|
49064
|
+
usedOutputDir: options.outputDirectory !== null,
|
|
48990
49065
|
ignoredTagCount: options.ignoredTags.size,
|
|
48991
49066
|
hasCustomConfig,
|
|
48992
49067
|
userConfig
|
|
48993
49068
|
});
|
|
48994
49069
|
const inspect = async (directory, inputOptions = {}) => {
|
|
48995
49070
|
const startTime = performance$1.now();
|
|
48996
|
-
|
|
49071
|
+
const isConcurrentScan = inputOptions.concurrentScan === true;
|
|
49072
|
+
if (!isConcurrentScan) resetSentryRunState();
|
|
48997
49073
|
const hasConfigOverride = inputOptions.configOverride !== void 0;
|
|
48998
49074
|
let scanDirectory;
|
|
48999
49075
|
let userConfig;
|
|
@@ -49001,7 +49077,7 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49001
49077
|
if (hasConfigOverride) {
|
|
49002
49078
|
scanDirectory = directory;
|
|
49003
49079
|
userConfig = inputOptions.configOverride ?? null;
|
|
49004
|
-
configSourceDirectory = null;
|
|
49080
|
+
configSourceDirectory = inputOptions.configSourceDirectory ?? null;
|
|
49005
49081
|
} else {
|
|
49006
49082
|
const scanTarget = await resolveScanTarget(directory);
|
|
49007
49083
|
scanDirectory = scanTarget.resolvedDirectory;
|
|
@@ -49009,8 +49085,9 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49009
49085
|
configSourceDirectory = scanTarget.configSourceDirectory;
|
|
49010
49086
|
}
|
|
49011
49087
|
const options = mergeInspectOptions(inputOptions, userConfig);
|
|
49088
|
+
const ownsSpinnerSilence = options.silent && !isConcurrentScan;
|
|
49012
49089
|
const wasSpinnerSilent = isSpinnerSilent();
|
|
49013
|
-
if (
|
|
49090
|
+
if (ownsSpinnerSilence) setSpinnerSilent(true);
|
|
49014
49091
|
try {
|
|
49015
49092
|
const result = await withSentryRunSpan(async (rootSentrySpan) => {
|
|
49016
49093
|
try {
|
|
@@ -49023,11 +49100,11 @@ const inspect = async (directory, inputOptions = {}) => {
|
|
|
49023
49100
|
});
|
|
49024
49101
|
throw error;
|
|
49025
49102
|
}
|
|
49026
|
-
});
|
|
49027
|
-
resetSentryRunState();
|
|
49103
|
+
}, { concurrentScan: isConcurrentScan });
|
|
49104
|
+
if (!isConcurrentScan) resetSentryRunState();
|
|
49028
49105
|
return result;
|
|
49029
49106
|
} finally {
|
|
49030
|
-
if (
|
|
49107
|
+
if (ownsSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
|
|
49031
49108
|
}
|
|
49032
49109
|
};
|
|
49033
49110
|
/**
|
|
@@ -49116,7 +49193,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49116
49193
|
const scanResultCache = cacheKey === null ? null : createScanResultCache(directory);
|
|
49117
49194
|
const cachedPayload = cacheKey === null ? null : scanResultCache?.lookup(cacheKey) ?? null;
|
|
49118
49195
|
if (cachedPayload) {
|
|
49119
|
-
recordSentryProjectContext(cachedPayload.project, rootSentrySpan);
|
|
49196
|
+
recordSentryProjectContext(cachedPayload.project, rootSentrySpan, { concurrentScan: options.concurrentScan });
|
|
49120
49197
|
recordCount(METRIC.projectDetected, 1);
|
|
49121
49198
|
await renderCachedProjectDetection({
|
|
49122
49199
|
payload: cachedPayload,
|
|
@@ -49138,7 +49215,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49138
49215
|
recordOnboardingCompletion(options);
|
|
49139
49216
|
return result;
|
|
49140
49217
|
}
|
|
49141
|
-
const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && options.lint && Boolean(resolvedNodeBinaryPath);
|
|
49218
|
+
const shouldShowProgressSpinners = !options.isCiOrCodingAgentEnvironment && !options.silent && !options.scoreOnly && !options.suppressRendering && options.lint && Boolean(resolvedNodeBinaryPath);
|
|
49142
49219
|
const layers = buildRuntimeLayers({
|
|
49143
49220
|
directory,
|
|
49144
49221
|
hasConfigOverride,
|
|
@@ -49167,7 +49244,7 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49167
49244
|
suppressScanSummary: options.suppressRendering,
|
|
49168
49245
|
supplyChainManifestChanged: options.supplyChainManifestChanged
|
|
49169
49246
|
}, { beforeLint: (projectInfo, lintIncludePaths) => gen(function* () {
|
|
49170
|
-
recordSentryProjectContext(projectInfo, rootSentrySpan);
|
|
49247
|
+
recordSentryProjectContext(projectInfo, rootSentrySpan, { concurrentScan: options.concurrentScan });
|
|
49171
49248
|
recordCount(METRIC.projectDetected, 1);
|
|
49172
49249
|
if (options.scoreOnly || options.suppressRendering) return;
|
|
49173
49250
|
const lintSourceFileCount = lintIncludePaths?.length ?? projectInfo.sourceFileCount;
|
|
@@ -49317,15 +49394,16 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49317
49394
|
...baselineDelta ? { baselineDelta } : {}
|
|
49318
49395
|
});
|
|
49319
49396
|
if (options.suppressRendering) return buildResult();
|
|
49397
|
+
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
49398
|
+
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
49320
49399
|
if (options.scoreOnly) {
|
|
49400
|
+
if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory, false, "stderr");
|
|
49321
49401
|
if (score) yield* log(`${score.score}`);
|
|
49322
|
-
else yield*
|
|
49402
|
+
else yield* error$1(highlighter.gray(noScoreMessage));
|
|
49323
49403
|
return buildResult();
|
|
49324
49404
|
}
|
|
49325
49405
|
const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
|
|
49326
49406
|
const pause = onboardingSectionPause(animateRender);
|
|
49327
|
-
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
49328
|
-
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
49329
49407
|
const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
|
|
49330
49408
|
const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
|
|
49331
49409
|
if (printedDiagnostics.length === 0) {
|
|
@@ -49343,6 +49421,7 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49343
49421
|
yield* log(highlighter.gray(" Score not shown — some checks could not complete."));
|
|
49344
49422
|
} else if (score) yield* printScoreHeader(score);
|
|
49345
49423
|
else yield* printNoScoreHeader(noScoreMessage);
|
|
49424
|
+
if (options.outputDirectory !== null) yield* printDiagnosticsDump(printedDiagnostics, options.outputDirectory);
|
|
49346
49425
|
return buildResult();
|
|
49347
49426
|
}
|
|
49348
49427
|
yield* pause;
|
|
@@ -49367,6 +49446,7 @@ const finalizeAndRender = (input) => gen(function* () {
|
|
|
49367
49446
|
totalSourceFileCount: lintSourceFileCount,
|
|
49368
49447
|
noScoreMessage,
|
|
49369
49448
|
verbose: options.verbose,
|
|
49449
|
+
outputDirectory: options.outputDirectory,
|
|
49370
49450
|
animateProjection: animateRender
|
|
49371
49451
|
});
|
|
49372
49452
|
if (hasSkippedChecks) {
|
|
@@ -49538,9 +49618,9 @@ const isExpectedUserError = (error) => error instanceof CliInputError || isProje
|
|
|
49538
49618
|
//#region src/cli/utils/build-handoff-payload.ts
|
|
49539
49619
|
const buildHandoffPayload = (input) => {
|
|
49540
49620
|
const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
|
|
49541
|
-
let
|
|
49621
|
+
let outputDirectory = null;
|
|
49542
49622
|
try {
|
|
49543
|
-
|
|
49623
|
+
outputDirectory = writeDiagnosticsDirectory([...input.diagnostics], input.outputDirectory);
|
|
49544
49624
|
} catch {}
|
|
49545
49625
|
const lines = [
|
|
49546
49626
|
"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 +49647,7 @@ const buildHandoffPayload = (input) => {
|
|
|
49567
49647
|
if (remainingFiles > 0) lines.push(` - +${remainingFiles} more files`);
|
|
49568
49648
|
});
|
|
49569
49649
|
lines.push("");
|
|
49570
|
-
if (
|
|
49650
|
+
if (outputDirectory) lines.push(`Full results for all ${input.diagnostics.length} issues (diagnostics.json + a .txt per rule): ${outputDirectory}`, "");
|
|
49571
49651
|
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
49652
|
return lines.join("\n");
|
|
49573
49653
|
};
|
|
@@ -51466,7 +51546,8 @@ const handoffToAgent = async (input) => {
|
|
|
51466
51546
|
if (handoffTarget === void 0 || handoffTarget === SKIP_CHOICE) return;
|
|
51467
51547
|
const payload = buildHandoffPayload({
|
|
51468
51548
|
diagnostics: input.diagnostics,
|
|
51469
|
-
projectName: input.projectName
|
|
51549
|
+
projectName: input.projectName,
|
|
51550
|
+
outputDirectory: input.outputDirectory
|
|
51470
51551
|
});
|
|
51471
51552
|
if (handoffTarget === CLIPBOARD_CHOICE) {
|
|
51472
51553
|
if (await copyToClipboard(payload)) cliLogger.log("Copied the prompt to your clipboard.");
|
|
@@ -51687,6 +51768,9 @@ const readChangedFilesFrom = (filePath) => {
|
|
|
51687
51768
|
return [...uniqueFiles];
|
|
51688
51769
|
};
|
|
51689
51770
|
//#endregion
|
|
51771
|
+
//#region src/cli/utils/filter-scans-for-surface.ts
|
|
51772
|
+
const filterScansForSurface = (completedScans, surface) => completedScans.flatMap((scan) => filterDiagnosticsForSurface([...scan.result.diagnostics], surface, scan.config));
|
|
51773
|
+
//#endregion
|
|
51690
51774
|
//#region src/cli/utils/render-multi-project-summary.ts
|
|
51691
51775
|
const getScoreLabel = (score) => {
|
|
51692
51776
|
if (score >= 75) return "Great";
|
|
@@ -51714,10 +51798,10 @@ const findLowestScoredScan = (completedScans) => {
|
|
|
51714
51798
|
return scoredScans.reduce((worst, scan) => scan.result.score.score < worst.result.score.score ? scan : worst);
|
|
51715
51799
|
};
|
|
51716
51800
|
const printMultiProjectSummary = (input) => gen(function* () {
|
|
51717
|
-
const { completedScans,
|
|
51801
|
+
const { completedScans, verbose, isOffline, projectName, totalElapsedMilliseconds } = input;
|
|
51718
51802
|
const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
|
|
51719
51803
|
const animateRender = !verbose && canAnimateOnboarding(process.stdout);
|
|
51720
|
-
const displayDiagnostics = filterDiagnosticsByCategories(
|
|
51804
|
+
const displayDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, "cli"), categoryFilters);
|
|
51721
51805
|
const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
|
|
51722
51806
|
for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
|
|
51723
51807
|
const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
|
|
@@ -51729,8 +51813,7 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51729
51813
|
else fileCountFromScansWithoutPaths += scan.result.scannedFileCount ?? scan.result.project.sourceFileCount;
|
|
51730
51814
|
}
|
|
51731
51815
|
const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
|
|
51732
|
-
|
|
51733
|
-
yield* log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalScanElapsedMilliseconds)}`);
|
|
51816
|
+
yield* log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalElapsedMilliseconds)}`);
|
|
51734
51817
|
if (displayDiagnostics.length > 0) {
|
|
51735
51818
|
yield* log("");
|
|
51736
51819
|
yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
|
|
@@ -51740,16 +51823,17 @@ const printMultiProjectSummary = (input) => gen(function* () {
|
|
|
51740
51823
|
const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
|
|
51741
51824
|
yield* printSummary({
|
|
51742
51825
|
diagnostics: displayDiagnostics,
|
|
51743
|
-
elapsedMilliseconds:
|
|
51826
|
+
elapsedMilliseconds: totalElapsedMilliseconds,
|
|
51744
51827
|
scoreResult: aggregateScore,
|
|
51745
|
-
potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics,
|
|
51828
|
+
potentialScore: lowestScoredScan ? yield* promise(() => computeProjectedScore(displayDiagnostics, filterScansForSurface([lowestScoredScan], "cli"), lowestScoredScan.result.score)) : null,
|
|
51746
51829
|
totalSourceFileCount,
|
|
51747
51830
|
noScoreMessage: "Score unavailable.",
|
|
51748
51831
|
verbose,
|
|
51832
|
+
outputDirectory: input.outputDirectory,
|
|
51749
51833
|
animateProjection: animateRender
|
|
51750
51834
|
});
|
|
51751
51835
|
const entries = completedScans.map((scan) => {
|
|
51752
|
-
const projectDiagnostics = filterDiagnosticsByCategories(
|
|
51836
|
+
const projectDiagnostics = filterDiagnosticsByCategories(filterScansForSurface([scan], "cli"), categoryFilters);
|
|
51753
51837
|
const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
51754
51838
|
return {
|
|
51755
51839
|
projectName: scan.result.project.projectName,
|
|
@@ -51846,6 +51930,7 @@ const resolveCliInspectOptions = (flags, userConfig) => {
|
|
|
51846
51930
|
lint: flags.lint,
|
|
51847
51931
|
deadCode: flags.deadCode,
|
|
51848
51932
|
verbose: flags.verbose,
|
|
51933
|
+
outputDirectory: flags.outputDir,
|
|
51849
51934
|
respectInlineDisables: flags.respectInlineDisables === false ? false : void 0,
|
|
51850
51935
|
warnings: wantsWarningGate ? true : flags.warnings,
|
|
51851
51936
|
scoreOnly: flags.score === true,
|
|
@@ -52095,16 +52180,22 @@ const parseFileLineArgument = (rawArgument) => {
|
|
|
52095
52180
|
};
|
|
52096
52181
|
//#endregion
|
|
52097
52182
|
//#region src/cli/utils/select-projects.ts
|
|
52098
|
-
const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
|
|
52183
|
+
const selectProjects = async (rootDirectory, projectFlag, skipPrompts, configProjects) => {
|
|
52099
52184
|
const hasRootPackageJson = isFile(Path.join(rootDirectory, "package.json"));
|
|
52100
52185
|
let packages = listWorkspacePackages(rootDirectory);
|
|
52101
52186
|
if (packages.length === 0 && (!hasRootPackageJson || isMonorepoRoot(rootDirectory))) packages = discoverReactSubprojects(rootDirectory);
|
|
52187
|
+
if (projectFlag) return resolveProjectFlag(projectFlag, packages, rootDirectory);
|
|
52188
|
+
const configRequestedNames = (configProjects ?? []).map((requestedName) => requestedName.trim()).filter((requestedName) => requestedName.length > 0);
|
|
52189
|
+
if (configRequestedNames.length > 0) {
|
|
52190
|
+
const resolvedDirectories = resolveRequestedProjects(configRequestedNames, packages, rootDirectory, "config");
|
|
52191
|
+
recordCount(METRIC.projectConfigSelected, resolvedDirectories.length);
|
|
52192
|
+
return resolvedDirectories;
|
|
52193
|
+
}
|
|
52102
52194
|
if (packages.length === 0) return [rootDirectory];
|
|
52103
52195
|
if (packages.length === 1) {
|
|
52104
52196
|
cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages[0].name}`);
|
|
52105
52197
|
return [packages[0].directory];
|
|
52106
52198
|
}
|
|
52107
|
-
if (projectFlag) return resolveProjectFlag(projectFlag, packages);
|
|
52108
52199
|
if (skipPrompts) {
|
|
52109
52200
|
printDiscoveredProjects(packages);
|
|
52110
52201
|
return packages.map((workspacePackage) => workspacePackage.directory);
|
|
@@ -52112,17 +52203,25 @@ const selectProjects = async (rootDirectory, projectFlag, skipPrompts) => {
|
|
|
52112
52203
|
return promptProjectSelection(packages, rootDirectory);
|
|
52113
52204
|
};
|
|
52114
52205
|
const ALL_PROJECTS_SENTINEL = "*";
|
|
52115
|
-
const resolveProjectFlag = (projectFlag, workspacePackages) => {
|
|
52206
|
+
const resolveProjectFlag = (projectFlag, workspacePackages, rootDirectory) => {
|
|
52116
52207
|
const requestedNames = projectFlag.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
52117
52208
|
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
|
-
|
|
52209
|
+
return resolveRequestedProjects(requestedNames, workspacePackages, rootDirectory, "flag");
|
|
52210
|
+
};
|
|
52211
|
+
const resolveRequestedProjects = (requestedNames, workspacePackages, rootDirectory, source) => {
|
|
52212
|
+
if (requestedNames.includes(ALL_PROJECTS_SENTINEL)) return workspacePackages.length > 0 ? workspacePackages.map((workspacePackage) => workspacePackage.directory) : [rootDirectory];
|
|
52213
|
+
const sourceLabel = source === "flag" ? "Project" : "Config \"projects\" entry";
|
|
52214
|
+
return requestedNames.map((requestedName) => {
|
|
52121
52215
|
const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || Path.basename(workspacePackage.directory) === requestedName);
|
|
52122
|
-
if (
|
|
52123
|
-
|
|
52124
|
-
|
|
52125
|
-
|
|
52216
|
+
if (matched) return matched.directory;
|
|
52217
|
+
const candidateDirectory = Path.resolve(rootDirectory, requestedName);
|
|
52218
|
+
if (isDirectory(candidateDirectory)) {
|
|
52219
|
+
recordCount(METRIC.projectPathSelected);
|
|
52220
|
+
return candidateDirectory;
|
|
52221
|
+
}
|
|
52222
|
+
const availableNames = workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ");
|
|
52223
|
+
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}.`);
|
|
52224
|
+
});
|
|
52126
52225
|
};
|
|
52127
52226
|
const printDiscoveredProjects = (packages) => {
|
|
52128
52227
|
cliLogger.log(`${highlighter.success("✔")} Select projects ${highlighter.dim("›")} ${packages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
|
|
@@ -52317,7 +52416,7 @@ const finalizeScans = (input) => {
|
|
|
52317
52416
|
}));
|
|
52318
52417
|
}
|
|
52319
52418
|
if (input.isScoreOnly || baselineDegraded) return;
|
|
52320
|
-
if (shouldBlockCi(
|
|
52419
|
+
if (shouldBlockCi(filterScansForSurface(input.completedScans, "ciFailure"), resolveBlockingLevel(input.flags, input.userConfig))) process.exitCode = 1;
|
|
52321
52420
|
};
|
|
52322
52421
|
const buildChangedFilesDiffInfo = (changedFiles) => ({
|
|
52323
52422
|
currentBranch: process.env.GITHUB_HEAD_REF?.trim() || null,
|
|
@@ -52450,7 +52549,6 @@ const inspectAction = async (directory, flags) => {
|
|
|
52450
52549
|
filePath: Path.isAbsolute(diagnostic.filePath) ? diagnostic.filePath.replaceAll(snapshot.tempDirectory, () => resolvedDirectory) : diagnostic.filePath
|
|
52451
52550
|
}));
|
|
52452
52551
|
finalizeScans({
|
|
52453
|
-
diagnostics: remappedDiagnostics,
|
|
52454
52552
|
completedScans: [{
|
|
52455
52553
|
directory: resolvedDirectory,
|
|
52456
52554
|
result: {
|
|
@@ -52460,7 +52558,8 @@ const inspectAction = async (directory, flags) => {
|
|
|
52460
52558
|
...scanResult.project,
|
|
52461
52559
|
rootDirectory: resolvedDirectory
|
|
52462
52560
|
}
|
|
52463
|
-
}
|
|
52561
|
+
},
|
|
52562
|
+
config: userConfig
|
|
52464
52563
|
}],
|
|
52465
52564
|
mode: "staged",
|
|
52466
52565
|
diff: null,
|
|
@@ -52478,7 +52577,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
52478
52577
|
}
|
|
52479
52578
|
return;
|
|
52480
52579
|
}
|
|
52481
|
-
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
|
|
52580
|
+
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts, userConfig?.projects);
|
|
52482
52581
|
const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
|
|
52483
52582
|
const requestedScope = resolveScope(flags, userConfig);
|
|
52484
52583
|
const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
|
|
@@ -52516,56 +52615,87 @@ const inspectAction = async (directory, flags) => {
|
|
|
52516
52615
|
}
|
|
52517
52616
|
cliLogger.break();
|
|
52518
52617
|
}
|
|
52519
|
-
const allDiagnostics = [];
|
|
52520
52618
|
const completedScans = [];
|
|
52521
52619
|
const isMultiProject = projectDirectories.length > 1;
|
|
52522
|
-
const
|
|
52523
|
-
|
|
52620
|
+
const scanProject = async (projectDirectory) => {
|
|
52621
|
+
const projectScanTarget = projectDirectory === resolvedDirectory ? scanTarget : await resolveScanTarget(projectDirectory, { allowAmbiguous: true });
|
|
52622
|
+
const scanDirectory = projectScanTarget.resolvedDirectory;
|
|
52623
|
+
const projectConfig = projectDirectory === resolvedDirectory ? userConfig : mergeReactDoctorConfigs(userConfig, projectScanTarget.userConfig ?? void 0);
|
|
52624
|
+
const projectConfigSourceDirectory = projectScanTarget.userConfig?.plugins === void 0 ? scanTarget.configSourceDirectory : projectScanTarget.configSourceDirectory;
|
|
52625
|
+
const supplyChainEnabled = projectConfig?.supplyChain?.enabled !== false;
|
|
52524
52626
|
let includePaths;
|
|
52525
52627
|
let supplyChainManifestChanged = false;
|
|
52526
52628
|
if (isDiffMode) {
|
|
52527
|
-
const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory,
|
|
52528
|
-
supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory,
|
|
52629
|
+
const changedSourceFiles = diffInfo === null ? [] : resolveProjectDiffIncludePaths(resolvedDirectory, scanDirectory, diffInfo);
|
|
52630
|
+
supplyChainManifestChanged = supplyChainEnabled && diffInfo !== null && projectManifestChanged(resolvedDirectory, scanDirectory, diffInfo);
|
|
52529
52631
|
if (changedSourceFiles.length === 0 && !supplyChainManifestChanged) {
|
|
52530
52632
|
if (!isQuiet) {
|
|
52531
|
-
cliLogger.dim(`No changed source files in ${
|
|
52633
|
+
cliLogger.dim(`No changed source files in ${scanDirectory}, skipping.`);
|
|
52532
52634
|
cliLogger.break();
|
|
52533
52635
|
}
|
|
52534
|
-
|
|
52636
|
+
return null;
|
|
52535
52637
|
}
|
|
52536
52638
|
includePaths = [...changedSourceFiles];
|
|
52537
52639
|
if (supplyChainManifestChanged) includePaths.push("package.json");
|
|
52538
52640
|
}
|
|
52539
52641
|
if (!isQuiet && !isMultiProject) cliLogger.dim(" ");
|
|
52540
|
-
const scanResult = await inspect(
|
|
52642
|
+
const scanResult = await inspect(scanDirectory, {
|
|
52541
52643
|
...scanOptions,
|
|
52542
52644
|
includePaths,
|
|
52543
|
-
configOverride:
|
|
52645
|
+
configOverride: projectConfig,
|
|
52646
|
+
configSourceDirectory: projectConfigSourceDirectory ?? void 0,
|
|
52544
52647
|
suppressRendering: isMultiProject,
|
|
52648
|
+
concurrentScan: isMultiProject,
|
|
52545
52649
|
baseline: baselineRef ? { ref: baselineRef } : void 0,
|
|
52546
|
-
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory,
|
|
52650
|
+
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, scanDirectory, changedLineRanges) : void 0,
|
|
52547
52651
|
supplyChainManifestChanged
|
|
52548
52652
|
});
|
|
52549
|
-
allDiagnostics.push(...scanResult.diagnostics);
|
|
52550
|
-
completedScans.push({
|
|
52551
|
-
directory: projectDirectory,
|
|
52552
|
-
result: scanResult
|
|
52553
|
-
});
|
|
52554
52653
|
if (!isQuiet && !isMultiProject) cliLogger.break();
|
|
52654
|
+
return {
|
|
52655
|
+
directory: scanDirectory,
|
|
52656
|
+
result: scanResult,
|
|
52657
|
+
config: projectConfig
|
|
52658
|
+
};
|
|
52659
|
+
};
|
|
52660
|
+
const scanLoopStartTime = performance$1.now();
|
|
52661
|
+
const projectCount = projectDirectories.length;
|
|
52662
|
+
const batchSpinner = isMultiProject && !isQuiet ? spinner(`Scanning ${projectCount} projects…`).start() : null;
|
|
52663
|
+
const ownsBatchSpinnerSilence = isMultiProject && scanOptions.silent === true;
|
|
52664
|
+
const wasSpinnerSilent = isSpinnerSilent();
|
|
52665
|
+
if (ownsBatchSpinnerSilence) setSpinnerSilent(true);
|
|
52666
|
+
let finishedProjectCount = 0;
|
|
52667
|
+
let scanOutcomes;
|
|
52668
|
+
try {
|
|
52669
|
+
scanOutcomes = await mapWithConcurrency(projectDirectories, isMultiProject ? 4 : 1, async (projectDirectory) => {
|
|
52670
|
+
const scanOutcome = await scanProject(projectDirectory);
|
|
52671
|
+
finishedProjectCount += 1;
|
|
52672
|
+
batchSpinner?.update(`Scanning ${projectCount} projects… (${finishedProjectCount}/${projectCount})`);
|
|
52673
|
+
return scanOutcome;
|
|
52674
|
+
});
|
|
52675
|
+
} finally {
|
|
52676
|
+
if (ownsBatchSpinnerSilence) setSpinnerSilent(wasSpinnerSilent);
|
|
52677
|
+
batchSpinner?.stop();
|
|
52678
|
+
}
|
|
52679
|
+
for (const scanOutcome of scanOutcomes) {
|
|
52680
|
+
if (scanOutcome === null) continue;
|
|
52681
|
+
completedScans.push(scanOutcome);
|
|
52555
52682
|
}
|
|
52556
52683
|
if (!isQuiet && isMultiProject && completedScans.length > 0) {
|
|
52557
52684
|
const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
|
|
52558
52685
|
await runPromise(printMultiProjectSummary({
|
|
52559
52686
|
completedScans,
|
|
52560
52687
|
categoryFilters,
|
|
52561
|
-
userConfig,
|
|
52562
52688
|
verbose: Boolean(flags.verbose),
|
|
52689
|
+
outputDirectory: flags.outputDir,
|
|
52563
52690
|
isOffline: !shouldShowShareLink,
|
|
52564
|
-
projectName: Path.basename(resolvedDirectory)
|
|
52691
|
+
projectName: Path.basename(resolvedDirectory),
|
|
52692
|
+
totalElapsedMilliseconds: performance$1.now() - scanLoopStartTime
|
|
52565
52693
|
}));
|
|
52566
52694
|
}
|
|
52695
|
+
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterScansForSurface(completedScans, scanOptions.outputSurface ?? "cli"), categoryFilters);
|
|
52696
|
+
const didScansWriteDump = isMultiProject ? !isQuiet && completedScans.length > 0 : completedScans.length > 0;
|
|
52697
|
+
if (flags.outputDir && !didScansWriteDump) await runPromise(printDiagnosticsDump(selectedSurfaceDiagnostics, flags.outputDir, false, isQuiet ? "stderr" : "stdout"));
|
|
52567
52698
|
finalizeScans({
|
|
52568
|
-
diagnostics: allDiagnostics,
|
|
52569
52699
|
completedScans,
|
|
52570
52700
|
mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
|
|
52571
52701
|
diff: isDiffMode ? diffInfo : null,
|
|
@@ -52578,13 +52708,13 @@ const inspectAction = async (directory, flags) => {
|
|
|
52578
52708
|
resolvedDirectory,
|
|
52579
52709
|
startTime
|
|
52580
52710
|
});
|
|
52581
|
-
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
|
|
52582
52711
|
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
|
|
52583
52712
|
await handoffToAgent({
|
|
52584
52713
|
diagnostics: selectedSurfaceDiagnostics,
|
|
52585
52714
|
projectName: Path.basename(resolvedDirectory),
|
|
52586
52715
|
rootDirectory: resolvedDirectory,
|
|
52587
|
-
interactive: true
|
|
52716
|
+
interactive: true,
|
|
52717
|
+
outputDirectory: flags.outputDir
|
|
52588
52718
|
});
|
|
52589
52719
|
return;
|
|
52590
52720
|
}
|
|
@@ -53380,6 +53510,7 @@ const ROOT_FLAG_SPEC = {
|
|
|
53380
53510
|
"--category",
|
|
53381
53511
|
"--changed-files-from",
|
|
53382
53512
|
"--blocking",
|
|
53513
|
+
"--output-dir",
|
|
53383
53514
|
"--fail-on",
|
|
53384
53515
|
"--project",
|
|
53385
53516
|
"--scope"
|
|
@@ -53534,6 +53665,7 @@ ${formatExampleLines([
|
|
|
53534
53665
|
["react-doctor", "scan the current project"],
|
|
53535
53666
|
["react-doctor ./apps/web", "scan a specific directory"],
|
|
53536
53667
|
["react-doctor --diff main", "scan only files changed vs. main"],
|
|
53668
|
+
["react-doctor --project modules/a,modules/b", "score each module separately (names or paths)"],
|
|
53537
53669
|
["react-doctor --staged", "scan staged files (pre-commit hook)"],
|
|
53538
53670
|
["react-doctor --category Security", "show only one diagnostic category"],
|
|
53539
53671
|
["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
|
|
@@ -53565,9 +53697,9 @@ ${highlighter.dim("Learn more:")}
|
|
|
53565
53697
|
${highlighter.info(CANONICAL_GITHUB_URL)}
|
|
53566
53698
|
`;
|
|
53567
53699
|
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
|
|
53700
|
+
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
53701
|
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
|
|
53702
|
+
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
53703
|
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
53704
|
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
53705
|
const rules = program.command("rules").description("List, explain, and configure which React Doctor rules run");
|
|
@@ -53608,4 +53740,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
53608
53740
|
export {};
|
|
53609
53741
|
|
|
53610
53742
|
//# sourceMappingURL=cli.js.map
|
|
53611
|
-
//# debugId=
|
|
53743
|
+
//# debugId=d9ff1bf2-c7e4-5f82-b78e-f40ab73a0483
|
package/dist/index.d.ts
CHANGED
|
@@ -9237,6 +9237,22 @@ interface ReactDoctorConfig {
|
|
|
9237
9237
|
* requested directory).
|
|
9238
9238
|
*/
|
|
9239
9239
|
rootDir?: string;
|
|
9240
|
+
/**
|
|
9241
|
+
* Projects to scan and score separately — the config-file equivalent of
|
|
9242
|
+
* the CLI `--project` flag, for repos that always want per-module scoring
|
|
9243
|
+
* (e.g. a monorepo dashboard tracking each module's score daily) without
|
|
9244
|
+
* passing the flag on every run.
|
|
9245
|
+
*
|
|
9246
|
+
* Entries resolve exactly like `--project` values: workspace package
|
|
9247
|
+
* names (or directory basenames) first, then directory paths relative to
|
|
9248
|
+
* the scanned root. `"*"` selects every discovered workspace project.
|
|
9249
|
+
* Invalid entries fail the run with the same error as the flag.
|
|
9250
|
+
*
|
|
9251
|
+
* Precedence: an explicit `--project` flag overrides this list. Only the
|
|
9252
|
+
* config at the invocation root is consulted — `projects` inside a
|
|
9253
|
+
* module's own config is ignored (modules can't redirect the scan).
|
|
9254
|
+
*/
|
|
9255
|
+
projects?: string[];
|
|
9240
9256
|
textComponents?: string[];
|
|
9241
9257
|
/**
|
|
9242
9258
|
* Names of components that safely route string-only children through a
|
|
@@ -9601,12 +9617,55 @@ interface DiagnoseResult {
|
|
|
9601
9617
|
elapsedMilliseconds: number;
|
|
9602
9618
|
}
|
|
9603
9619
|
/**
|
|
9604
|
-
* A single project to scan as part of a `
|
|
9620
|
+
* A single project to scan as part of a `diagnose({ projects })` batch.
|
|
9605
9621
|
* Scan options (`deadCode`, `lint`, etc.) are flat on the entry and
|
|
9606
9622
|
* layer on top of the global defaults — omitted fields fall through.
|
|
9607
|
-
* `config` is a full `ReactDoctorConfig` override that replaces the
|
|
9608
|
-
* on-disk `doctor.config.*` for this project's scan.
|
|
9609
9623
|
*/
|
|
9624
|
+
interface ProjectDefinition extends DiagnoseOptions {
|
|
9625
|
+
directory: string;
|
|
9626
|
+
/**
|
|
9627
|
+
* Per-project config overrides, layered additively (see
|
|
9628
|
+
* `mergeReactDoctorConfigs`) on top of the project's on-disk
|
|
9629
|
+
* `doctor.config.*` and the batch-level `DiagnoseProjectsInput.config`
|
|
9630
|
+
* — so disabling one rule here keeps every base rule intact.
|
|
9631
|
+
*/
|
|
9632
|
+
config?: ReactDoctorConfig;
|
|
9633
|
+
}
|
|
9634
|
+
interface ProjectResultOk extends DiagnoseResult {
|
|
9635
|
+
ok: true;
|
|
9636
|
+
directory: string;
|
|
9637
|
+
}
|
|
9638
|
+
interface ProjectResultError {
|
|
9639
|
+
ok: false;
|
|
9640
|
+
directory: string;
|
|
9641
|
+
error: Error;
|
|
9642
|
+
}
|
|
9643
|
+
type ProjectResult = ProjectResultOk | ProjectResultError;
|
|
9644
|
+
interface DiagnoseProjectsInput extends DiagnoseOptions {
|
|
9645
|
+
projects: ProjectDefinition[];
|
|
9646
|
+
/**
|
|
9647
|
+
* Config overrides applied to every project in the batch, layered
|
|
9648
|
+
* additively (see `mergeReactDoctorConfigs`) between each project's
|
|
9649
|
+
* on-disk `doctor.config.*` and its `ProjectDefinition.config` — one
|
|
9650
|
+
* base rule set for the batch, overridden per project only where needed.
|
|
9651
|
+
*/
|
|
9652
|
+
config?: ReactDoctorConfig;
|
|
9653
|
+
/**
|
|
9654
|
+
* Maximum number of projects to scan concurrently. Defaults to
|
|
9655
|
+
* `DEFAULT_PROJECT_SCAN_CONCURRENCY` (4) — each project scan fans out
|
|
9656
|
+
* its own lint workers, so the batch is bounded rather than fully
|
|
9657
|
+
* parallel. Set to `1` for sequential execution. Values below 1 are
|
|
9658
|
+
* clamped to 1.
|
|
9659
|
+
*/
|
|
9660
|
+
concurrency?: number;
|
|
9661
|
+
}
|
|
9662
|
+
interface DiagnoseProjectsResult {
|
|
9663
|
+
projects: ProjectResult[];
|
|
9664
|
+
diagnostics: Diagnostic[];
|
|
9665
|
+
score: ScoreResult | null;
|
|
9666
|
+
elapsedMilliseconds: number;
|
|
9667
|
+
} //#endregion
|
|
9668
|
+
//#region src/types/handle-error.d.ts
|
|
9610
9669
|
//#endregion
|
|
9611
9670
|
//#region src/types/inspect.d.ts
|
|
9612
9671
|
interface InspectResult {
|
|
@@ -10027,41 +10086,20 @@ declare const defineConfig: (config: ReactDoctorConfig) => ReactDoctorConfig; //
|
|
|
10027
10086
|
//#endregion
|
|
10028
10087
|
//#region ../api/dist/index.d.ts
|
|
10029
10088
|
//#region src/diagnose.d.ts
|
|
10030
|
-
|
|
10031
|
-
/**
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
* ```ts
|
|
10045
|
-
* const result = await diagnoseProjects({
|
|
10046
|
-
* projects: [
|
|
10047
|
-
* { directory: "packages/app" },
|
|
10048
|
-
* { directory: "packages/shared", deadCode: false },
|
|
10049
|
-
* { directory: "packages/admin", config: {
|
|
10050
|
-
* rules: { "react-doctor/no-array-index-as-key": "off" },
|
|
10051
|
-
* }},
|
|
10052
|
-
* ],
|
|
10053
|
-
* concurrency: 4,
|
|
10054
|
-
* });
|
|
10055
|
-
*
|
|
10056
|
-
* for (const project of result.projects) {
|
|
10057
|
-
* if (project.ok) {
|
|
10058
|
-
* console.log(project.directory, project.score);
|
|
10059
|
-
* } else {
|
|
10060
|
-
* console.error(project.directory, project.error);
|
|
10061
|
-
* }
|
|
10062
|
-
* }
|
|
10063
|
-
* ```
|
|
10064
|
-
*/
|
|
10089
|
+
interface Diagnose {
|
|
10090
|
+
/** Scan a single project directory and return diagnostics + score. */
|
|
10091
|
+
(directory: string, options?: DiagnoseOptions): Promise<DiagnoseResult>;
|
|
10092
|
+
/**
|
|
10093
|
+
* Scan multiple projects in parallel — each through the same pipeline as
|
|
10094
|
+
* the single-directory form — and return per-project results plus an
|
|
10095
|
+
* aggregate worst-of score. A failing project (e.g. no `package.json`)
|
|
10096
|
+
* comes back with `ok: false` instead of aborting the batch. Per-project
|
|
10097
|
+
* `config` layers on the batch `config`, which layers on each project's
|
|
10098
|
+
* on-disk config (see `mergeReactDoctorConfigs`).
|
|
10099
|
+
*/
|
|
10100
|
+
(input: DiagnoseProjectsInput): Promise<DiagnoseProjectsResult>;
|
|
10101
|
+
}
|
|
10102
|
+
declare const diagnose: Diagnose; //#endregion
|
|
10065
10103
|
//#endregion
|
|
10066
10104
|
//#region src/index.d.ts
|
|
10067
10105
|
declare const clearCaches: () => void;
|
|
@@ -10072,5 +10110,5 @@ interface ToJsonReportOptions {
|
|
|
10072
10110
|
}
|
|
10073
10111
|
declare const toJsonReport: (result: DiagnoseResult, options: ToJsonReportOptions) => JsonReport;
|
|
10074
10112
|
//#endregion
|
|
10075
|
-
export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
10113
|
+
export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseProjectsInput, type DiagnoseProjectsResult, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectDefinition, type ProjectInfo, ProjectNotFoundError, type ProjectResult, type ProjectResultError, type ProjectResultOk, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
10076
10114
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.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]="36e8c556-ae72-5367-bba8-2516ba612eeb")}catch(e){}}();
|
|
3
3
|
import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as NFS from "node:fs";
|
|
@@ -40099,13 +40099,55 @@ const clearAutoSuppressionCaches = () => {};
|
|
|
40099
40099
|
* untouched so the loader sees the same plain object either way.
|
|
40100
40100
|
*/
|
|
40101
40101
|
const defineConfig = (config) => config;
|
|
40102
|
+
const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
|
|
40103
|
+
const mergeIgnores = (baseIgnore, overrideIgnore) => {
|
|
40104
|
+
const mergedIgnore = {
|
|
40105
|
+
...baseIgnore,
|
|
40106
|
+
...overrideIgnore
|
|
40107
|
+
};
|
|
40108
|
+
if (baseIgnore.rules && overrideIgnore.rules) mergedIgnore.rules = unionValues(baseIgnore.rules, overrideIgnore.rules);
|
|
40109
|
+
if (baseIgnore.files && overrideIgnore.files) mergedIgnore.files = unionValues(baseIgnore.files, overrideIgnore.files);
|
|
40110
|
+
if (baseIgnore.tags && overrideIgnore.tags) mergedIgnore.tags = unionValues(baseIgnore.tags, overrideIgnore.tags);
|
|
40111
|
+
if (baseIgnore.overrides && overrideIgnore.overrides) mergedIgnore.overrides = [...baseIgnore.overrides, ...overrideIgnore.overrides];
|
|
40112
|
+
return mergedIgnore;
|
|
40113
|
+
};
|
|
40114
|
+
/**
|
|
40115
|
+
* Layer one `ReactDoctorConfig` on top of another, additively: `rules` /
|
|
40116
|
+
* `categories` / `supplyChain` merge per key, `ignore` lists union
|
|
40117
|
+
* (`ignore.overrides` concatenate), and every other field is a scalar the
|
|
40118
|
+
* override simply wins on when set. Returns the base unchanged when there
|
|
40119
|
+
* is no override, and vice versa — so callers can thread `null` /
|
|
40120
|
+
* `undefined` through without special-casing.
|
|
40121
|
+
*/
|
|
40122
|
+
const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
|
|
40123
|
+
if (overrideConfig === void 0) return baseConfig;
|
|
40124
|
+
if (baseConfig === null) return overrideConfig;
|
|
40125
|
+
const mergedConfig = {
|
|
40126
|
+
...baseConfig,
|
|
40127
|
+
...overrideConfig
|
|
40128
|
+
};
|
|
40129
|
+
if (baseConfig.rules && overrideConfig.rules) mergedConfig.rules = {
|
|
40130
|
+
...baseConfig.rules,
|
|
40131
|
+
...overrideConfig.rules
|
|
40132
|
+
};
|
|
40133
|
+
if (baseConfig.categories && overrideConfig.categories) mergedConfig.categories = {
|
|
40134
|
+
...baseConfig.categories,
|
|
40135
|
+
...overrideConfig.categories
|
|
40136
|
+
};
|
|
40137
|
+
if (baseConfig.supplyChain && overrideConfig.supplyChain) mergedConfig.supplyChain = {
|
|
40138
|
+
...baseConfig.supplyChain,
|
|
40139
|
+
...overrideConfig.supplyChain
|
|
40140
|
+
};
|
|
40141
|
+
if (baseConfig.ignore && overrideConfig.ignore) mergedConfig.ignore = mergeIgnores(baseConfig.ignore, overrideConfig.ignore);
|
|
40142
|
+
return mergedConfig;
|
|
40143
|
+
};
|
|
40102
40144
|
//#endregion
|
|
40103
40145
|
//#region ../api/dist/index.js
|
|
40104
|
-
const buildDiagnoseLayer = (config,
|
|
40105
|
-
const configLayer =
|
|
40146
|
+
const buildDiagnoseLayer = (config, configOverrideTarget) => {
|
|
40147
|
+
const configLayer = configOverrideTarget === void 0 ? Config.layerNode : Config.layerOf({
|
|
40106
40148
|
config,
|
|
40107
|
-
resolvedDirectory:
|
|
40108
|
-
configSourceDirectory:
|
|
40149
|
+
resolvedDirectory: configOverrideTarget.resolvedDirectory,
|
|
40150
|
+
configSourceDirectory: configOverrideTarget.configSourceDirectory
|
|
40109
40151
|
});
|
|
40110
40152
|
return mergeAll$1(Project.layerNode, configLayer, DeadCode.layerNode, Files.layerNode, Git.layerNode, Linter.layerOxlint, LintPartialFailures.layerLive, Progress.layerNoop, Reporter.layerNoop, Score.layerHttp, config?.supplyChain?.enabled !== false ? SupplyChain.layerNode : SupplyChain.layerOf([]));
|
|
40111
40153
|
};
|
|
@@ -40137,11 +40179,64 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
|
|
|
40137
40179
|
elapsedMilliseconds
|
|
40138
40180
|
};
|
|
40139
40181
|
};
|
|
40140
|
-
const
|
|
40182
|
+
const diagnoseDirectory = async (directory, options) => {
|
|
40141
40183
|
const startTime = globalThis.performance.now();
|
|
40142
40184
|
const scanTarget = await resolveScanTarget(directory);
|
|
40143
40185
|
return outputToDiagnoseResult(await runPromise(restoreLegacyThrow(buildInspectProgram(scanTarget, options).pipe(provide(buildDiagnoseLayer(scanTarget.userConfig)), provide(layerOtlp)))), globalThis.performance.now() - startTime);
|
|
40144
40186
|
};
|
|
40187
|
+
const findWorstScore = (projectResults) => {
|
|
40188
|
+
let worstResult = null;
|
|
40189
|
+
let worstScore = Number.POSITIVE_INFINITY;
|
|
40190
|
+
for (const projectResult of projectResults) {
|
|
40191
|
+
if (!projectResult.ok || projectResult.score === null) continue;
|
|
40192
|
+
if (projectResult.score.score < worstScore) {
|
|
40193
|
+
worstScore = projectResult.score.score;
|
|
40194
|
+
worstResult = projectResult.score;
|
|
40195
|
+
}
|
|
40196
|
+
}
|
|
40197
|
+
return worstResult;
|
|
40198
|
+
};
|
|
40199
|
+
const diagnoseProject = async (projectDefinition, baseOptions, batchConfig) => {
|
|
40200
|
+
const startTime = globalThis.performance.now();
|
|
40201
|
+
try {
|
|
40202
|
+
const scanTarget = await resolveScanTarget(projectDefinition.directory);
|
|
40203
|
+
const { directory: _, config: projectConfig, ...perProjectOptions } = projectDefinition;
|
|
40204
|
+
const didOverrideConfig = batchConfig !== void 0 || projectConfig !== void 0;
|
|
40205
|
+
const effectiveConfig = mergeReactDoctorConfigs(mergeReactDoctorConfigs(scanTarget.userConfig, batchConfig), projectConfig);
|
|
40206
|
+
const program = buildInspectProgram(scanTarget, {
|
|
40207
|
+
...baseOptions,
|
|
40208
|
+
...perProjectOptions
|
|
40209
|
+
}, effectiveConfig ?? void 0);
|
|
40210
|
+
const didOverridePlugins = batchConfig?.plugins !== void 0 || projectConfig?.plugins !== void 0;
|
|
40211
|
+
const layer = buildDiagnoseLayer(effectiveConfig, didOverrideConfig ? {
|
|
40212
|
+
resolvedDirectory: scanTarget.resolvedDirectory,
|
|
40213
|
+
configSourceDirectory: didOverridePlugins ? null : scanTarget.configSourceDirectory
|
|
40214
|
+
} : void 0);
|
|
40215
|
+
return {
|
|
40216
|
+
ok: true,
|
|
40217
|
+
...outputToDiagnoseResult(await runPromise(restoreLegacyThrow(program.pipe(provide(layer), provide(layerOtlp)))), globalThis.performance.now() - startTime),
|
|
40218
|
+
directory: scanTarget.resolvedDirectory
|
|
40219
|
+
};
|
|
40220
|
+
} catch (error) {
|
|
40221
|
+
return {
|
|
40222
|
+
ok: false,
|
|
40223
|
+
directory: projectDefinition.directory,
|
|
40224
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
40225
|
+
};
|
|
40226
|
+
}
|
|
40227
|
+
};
|
|
40228
|
+
const diagnoseProjectBatch = async (input) => {
|
|
40229
|
+
const startTime = globalThis.performance.now();
|
|
40230
|
+
const { projects, concurrency, config: batchConfig, ...baseOptions } = input;
|
|
40231
|
+
const projectResults = await mapWithConcurrency(projects, concurrency ?? 4, (projectDefinition) => diagnoseProject(projectDefinition, baseOptions, batchConfig));
|
|
40232
|
+
return {
|
|
40233
|
+
projects: projectResults,
|
|
40234
|
+
diagnostics: projectResults.flatMap((projectResult) => projectResult.ok ? projectResult.diagnostics : []),
|
|
40235
|
+
score: findWorstScore(projectResults),
|
|
40236
|
+
elapsedMilliseconds: globalThis.performance.now() - startTime
|
|
40237
|
+
};
|
|
40238
|
+
};
|
|
40239
|
+
const diagnose = (async (directoryOrInput, options = {}) => typeof directoryOrInput === "string" ? diagnoseDirectory(directoryOrInput, options) : diagnoseProjectBatch(directoryOrInput));
|
|
40145
40240
|
//#endregion
|
|
40146
40241
|
//#region src/index.ts
|
|
40147
40242
|
const clearCaches = () => {
|
|
@@ -40174,4 +40269,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
40174
40269
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
40175
40270
|
|
|
40176
40271
|
//# sourceMappingURL=index.js.map
|
|
40177
|
-
//# debugId=
|
|
40272
|
+
//# debugId=36e8c556-ae72-5367-bba8-2516ba612eeb
|
package/dist/lsp.js
CHANGED
|
@@ -41709,6 +41709,8 @@ const METRIC = {
|
|
|
41709
41709
|
cliInvoked: "cli.invoked",
|
|
41710
41710
|
cliError: "cli.error",
|
|
41711
41711
|
projectDetected: "project.detected",
|
|
41712
|
+
projectPathSelected: "project.path_selected",
|
|
41713
|
+
projectConfigSelected: "project.config_selected",
|
|
41712
41714
|
scanCompleted: "scan.completed",
|
|
41713
41715
|
scanDuration: "scan.duration",
|
|
41714
41716
|
scanPhaseDuration: "scan.phase_duration",
|
|
@@ -42052,5 +42054,5 @@ const startLanguageServer = () => {
|
|
|
42052
42054
|
};
|
|
42053
42055
|
//#endregion
|
|
42054
42056
|
export { startLanguageServer };
|
|
42055
|
-
!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]="
|
|
42056
|
-
//# debugId=
|
|
42057
|
+
!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]="739323b3-967f-57c7-b44c-00115c2646bf")}catch(e){}}();
|
|
42058
|
+
//# debugId=739323b3-967f-57c7-b44c-00115c2646bf
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.5.1-dev.
|
|
3
|
+
"version": "0.5.1-dev.d48e7f1",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"agent-install": "0.0.5",
|
|
55
55
|
"conf": "^15.1.0",
|
|
56
56
|
"confbox": "^0.2.4",
|
|
57
|
-
"deslop-js": "^0.0.
|
|
57
|
+
"deslop-js": "^0.0.23",
|
|
58
58
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
59
59
|
"jiti": "^2.7.0",
|
|
60
60
|
"magicast": "^0.5.3",
|
|
61
|
-
"oxlint": "
|
|
61
|
+
"oxlint": ">=1.66.0 <1.67.0",
|
|
62
62
|
"prompts": "^2.4.2",
|
|
63
63
|
"typescript": ">=5.0.4 <7",
|
|
64
64
|
"vscode-languageserver": "^9.0.1",
|
|
65
65
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
66
66
|
"vscode-uri": "^3.1.0",
|
|
67
|
-
"oxlint-plugin-react-doctor": "0.5.1-dev.
|
|
67
|
+
"oxlint-plugin-react-doctor": "0.5.1-dev.d48e7f1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"@xterm/headless": "^6.0.0",
|
|
73
73
|
"commander": "^14.0.3",
|
|
74
74
|
"ora": "^9.4.0",
|
|
75
|
-
"@react-doctor/core": "0.5.1",
|
|
76
75
|
"@react-doctor/api": "0.5.1",
|
|
76
|
+
"@react-doctor/core": "0.5.1",
|
|
77
77
|
"@react-doctor/language-server": "0.5.1"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|