react-doctor 0.4.2-dev.98066c2 → 0.4.2-dev.a59499b
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 +90 -42
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e5cd8a39-286b-53d3-8951-268670de9a6a")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
5
5
|
import * as path$1 from "node:path";
|
|
@@ -12249,7 +12249,7 @@ const makeNoopConsole = () => ({
|
|
|
12249
12249
|
});
|
|
12250
12250
|
//#endregion
|
|
12251
12251
|
//#region src/cli/utils/version.ts
|
|
12252
|
-
const VERSION = "0.4.2-dev.
|
|
12252
|
+
const VERSION = "0.4.2-dev.a59499b";
|
|
12253
12253
|
//#endregion
|
|
12254
12254
|
//#region src/cli/utils/json-mode.ts
|
|
12255
12255
|
let context = null;
|
|
@@ -12607,13 +12607,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12607
12607
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12608
12608
|
* standard `SENTRY_RELEASE` override.
|
|
12609
12609
|
*/
|
|
12610
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.2-dev.
|
|
12610
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.2-dev.a59499b`;
|
|
12611
12611
|
/**
|
|
12612
12612
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12613
12613
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12614
12614
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12615
12615
|
*/
|
|
12616
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.2-dev.
|
|
12616
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.2-dev.a59499b") ? "development" : "production");
|
|
12617
12617
|
/**
|
|
12618
12618
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12619
12619
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -16809,6 +16809,9 @@ const computeProjectedScore = async (topErrorSource, rescoreSource, currentScore
|
|
|
16809
16809
|
if (!potentialScore || potentialScore.score <= currentScore.score) return null;
|
|
16810
16810
|
return potentialScore.score;
|
|
16811
16811
|
};
|
|
16812
|
+
//#endregion
|
|
16813
|
+
//#region src/cli/utils/filter-diagnostics-by-categories.ts
|
|
16814
|
+
const filterDiagnosticsByCategories = (diagnostics, categories) => categories.size === 0 ? [...diagnostics] : diagnostics.filter((diagnostic) => categories.has(diagnostic.category));
|
|
16812
16815
|
const FORCE_ONBOARDING_ENV_VAR = "REACT_DOCTOR_FORCE_ONBOARDING";
|
|
16813
16816
|
const FALSY_FLAG_VALUES = new Set([
|
|
16814
16817
|
"",
|
|
@@ -17239,11 +17242,47 @@ const resolveOxlintNodeEffect = (isLintEnabled, isQuiet) => Effect.gen(function*
|
|
|
17239
17242
|
});
|
|
17240
17243
|
const resolveOxlintNode = (isLintEnabled, isQuiet) => Effect.runPromise(resolveOxlintNodeEffect(isLintEnabled, isQuiet).pipe(Effect.provide(NodeResolver.layerNode)));
|
|
17241
17244
|
//#endregion
|
|
17245
|
+
//#region src/cli/utils/cli-input-error.ts
|
|
17246
|
+
/**
|
|
17247
|
+
* A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
|
|
17248
|
+
* argument, mutually exclusive flags, or an unknown `--project` name. This is
|
|
17249
|
+
* user input, not a react-doctor bug, so `isExpectedUserError` routes it
|
|
17250
|
+
* through `handleUserError`: a clean, single-line message with no Sentry
|
|
17251
|
+
* report and no "Something went wrong, open a prefilled issue" block.
|
|
17252
|
+
*
|
|
17253
|
+
* The `message` is rendered verbatim, so it must read as a complete,
|
|
17254
|
+
* human-readable sentence that tells the user how to fix their invocation.
|
|
17255
|
+
*/
|
|
17256
|
+
var CliInputError = class extends Error {
|
|
17257
|
+
name = "CliInputError";
|
|
17258
|
+
};
|
|
17259
|
+
//#endregion
|
|
17260
|
+
//#region src/cli/utils/resolve-cli-categories.ts
|
|
17261
|
+
const categoryByLowercase = new Map(DIAGNOSTIC_CATEGORY_BUCKETS.map((category) => [category.toLowerCase(), category]));
|
|
17262
|
+
const knownCategoryList = DIAGNOSTIC_CATEGORY_BUCKETS.join(", ");
|
|
17263
|
+
const splitCategoryFlagValue = (value) => value.split(",").map((category) => category.trim()).filter((category) => category.length > 0);
|
|
17264
|
+
const resolveCliCategories = (categoryFlag) => {
|
|
17265
|
+
const rawCategoryValues = categoryFlag === void 0 ? [] : Array.isArray(categoryFlag) ? categoryFlag : [categoryFlag];
|
|
17266
|
+
const resolvedCategories = [];
|
|
17267
|
+
const seenCategories = /* @__PURE__ */ new Set();
|
|
17268
|
+
for (const rawCategoryValue of rawCategoryValues) for (const categoryQuery of splitCategoryFlagValue(rawCategoryValue)) {
|
|
17269
|
+
const matchedCategory = categoryByLowercase.get(categoryQuery.toLowerCase());
|
|
17270
|
+
if (matchedCategory === void 0) throw new CliInputError(`Unknown category "${categoryQuery}". Expected one of: ${knownCategoryList}.`);
|
|
17271
|
+
if (!seenCategories.has(matchedCategory)) {
|
|
17272
|
+
seenCategories.add(matchedCategory);
|
|
17273
|
+
resolvedCategories.push(matchedCategory);
|
|
17274
|
+
}
|
|
17275
|
+
}
|
|
17276
|
+
if (rawCategoryValues.length > 0 && resolvedCategories.length === 0) throw new CliInputError(`--category requires one of: ${knownCategoryList}.`);
|
|
17277
|
+
return resolvedCategories.length > 0 ? resolvedCategories : void 0;
|
|
17278
|
+
};
|
|
17279
|
+
//#endregion
|
|
17242
17280
|
//#region src/inspect.ts
|
|
17243
17281
|
const silentConsole = makeNoopConsole();
|
|
17244
17282
|
const runConsole = (effect) => {
|
|
17245
17283
|
Effect.runSync(effect);
|
|
17246
17284
|
};
|
|
17285
|
+
const formatCategorySelection = (categoryFilters) => [...categoryFilters].join(", ");
|
|
17247
17286
|
const buildIgnoredTags = (userConfig) => {
|
|
17248
17287
|
const tags = /* @__PURE__ */ new Set();
|
|
17249
17288
|
if (userConfig?.ignore?.tags) for (const tag of userConfig.ignore.tags) tags.add(tag);
|
|
@@ -17264,6 +17303,7 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
17264
17303
|
share: userConfig?.share ?? true,
|
|
17265
17304
|
respectInlineDisables: inputOptions.respectInlineDisables ?? userConfig?.respectInlineDisables ?? true,
|
|
17266
17305
|
warnings: inputOptions.warnings ?? userConfig?.warnings ?? true,
|
|
17306
|
+
categoryFilters: new Set(resolveCliCategories(inputOptions.categoryFilters) ?? []),
|
|
17267
17307
|
adoptExistingLintConfig: userConfig?.adoptExistingLintConfig ?? true,
|
|
17268
17308
|
ignoredTags: buildIgnoredTags(userConfig),
|
|
17269
17309
|
outputSurface: inputOptions.outputSurface ?? "cli",
|
|
@@ -17549,14 +17589,16 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17549
17589
|
const animateRender = !options.silent && !options.verbose && canAnimateOnboarding(process.stdout);
|
|
17550
17590
|
const pause = onboardingSectionPause(animateRender);
|
|
17551
17591
|
const surfaceDiagnostics = filterDiagnosticsForSurface([...diagnostics], options.outputSurface, userConfig);
|
|
17592
|
+
const printedDiagnostics = filterDiagnosticsByCategories(surfaceDiagnostics, options.categoryFilters);
|
|
17552
17593
|
const demotedDiagnosticCount = diagnostics.length - surfaceDiagnostics.length;
|
|
17553
17594
|
const lintSourceFileCount = options.includePaths.length > 0 ? options.includePaths.length : project.sourceFileCount;
|
|
17554
|
-
if (
|
|
17595
|
+
if (printedDiagnostics.length === 0) {
|
|
17555
17596
|
yield* pause;
|
|
17556
17597
|
if (hasSkippedChecks) {
|
|
17557
17598
|
const skippedLabel = skippedChecks.join(" and ");
|
|
17558
17599
|
yield* Console.warn(highlighter.warn(`No issues detected, but ${skippedLabel} checks failed — results are incomplete.`));
|
|
17559
|
-
} else if (
|
|
17600
|
+
} else if (options.categoryFilters.size > 0) yield* Console.log(highlighter.success(`No issues found in category ${formatCategorySelection(options.categoryFilters)}!`));
|
|
17601
|
+
else if (demotedDiagnosticCount > 0) yield* Console.log(highlighter.success(`No issues found! (${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface — see config.surfaces.)`));
|
|
17560
17602
|
else yield* Console.log(highlighter.success("No issues found!"));
|
|
17561
17603
|
yield* Console.log("");
|
|
17562
17604
|
yield* pause;
|
|
@@ -17569,20 +17611,20 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17569
17611
|
}
|
|
17570
17612
|
yield* pause;
|
|
17571
17613
|
yield* Console.log("");
|
|
17572
|
-
yield* printDiagnostics([...
|
|
17614
|
+
yield* printDiagnostics([...printedDiagnostics], options.verbose, directory, buildRulePriorityMap([score]), isCodingAgentEnvironment(), {
|
|
17573
17615
|
sectionPause: pause,
|
|
17574
17616
|
animateCountUp: animateRender
|
|
17575
17617
|
});
|
|
17576
17618
|
if (options.isNonInteractiveEnvironment && options.outputSurface !== "prComment") yield* printAgentGuidance();
|
|
17577
|
-
if (demotedDiagnosticCount > 0) {
|
|
17619
|
+
if (options.categoryFilters.size === 0 && demotedDiagnosticCount > 0) {
|
|
17578
17620
|
yield* Console.log(highlighter.gray(` ${demotedDiagnosticCount} demoted from the ${options.outputSurface} surface (e.g. design cleanup) — run \`npx react-doctor@latest .\` locally for the full list.`));
|
|
17579
17621
|
yield* Console.log("");
|
|
17580
17622
|
}
|
|
17581
|
-
const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...
|
|
17623
|
+
const potentialScore = score ? yield* Effect.promise(() => computeProjectedScore([...printedDiagnostics], [...surfaceDiagnostics], score)) : null;
|
|
17582
17624
|
const shouldShowShareLink = !options.noScore && options.share && !options.isCi;
|
|
17583
17625
|
yield* pause;
|
|
17584
17626
|
yield* printSummary({
|
|
17585
|
-
diagnostics: [...
|
|
17627
|
+
diagnostics: [...printedDiagnostics],
|
|
17586
17628
|
elapsedMilliseconds,
|
|
17587
17629
|
scoreResult: score,
|
|
17588
17630
|
potentialScore,
|
|
@@ -17598,7 +17640,7 @@ const finalizeAndRender = (input) => Effect.gen(function* () {
|
|
|
17598
17640
|
}
|
|
17599
17641
|
yield* pause;
|
|
17600
17642
|
yield* printFooter({
|
|
17601
|
-
diagnostics: [...
|
|
17643
|
+
diagnostics: [...printedDiagnostics],
|
|
17602
17644
|
scoreResult: score,
|
|
17603
17645
|
projectName: project.projectName,
|
|
17604
17646
|
isOffline: !shouldShowShareLink
|
|
@@ -17729,21 +17771,6 @@ const handleUserError = (error, options = {}) => {
|
|
|
17729
17771
|
process.exitCode = 1;
|
|
17730
17772
|
};
|
|
17731
17773
|
//#endregion
|
|
17732
|
-
//#region src/cli/utils/cli-input-error.ts
|
|
17733
|
-
/**
|
|
17734
|
-
* A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
|
|
17735
|
-
* argument, mutually exclusive flags, or an unknown `--project` name. This is
|
|
17736
|
-
* user input, not a react-doctor bug, so `isExpectedUserError` routes it
|
|
17737
|
-
* through `handleUserError`: a clean, single-line message with no Sentry
|
|
17738
|
-
* report and no "Something went wrong, open a prefilled issue" block.
|
|
17739
|
-
*
|
|
17740
|
-
* The `message` is rendered verbatim, so it must read as a complete,
|
|
17741
|
-
* human-readable sentence that tells the user how to fix their invocation.
|
|
17742
|
-
*/
|
|
17743
|
-
var CliInputError = class extends Error {
|
|
17744
|
-
name = "CliInputError";
|
|
17745
|
-
};
|
|
17746
|
-
//#endregion
|
|
17747
17774
|
//#region src/cli/utils/is-expected-user-error.ts
|
|
17748
17775
|
/**
|
|
17749
17776
|
* Whether `error` is an expected, user-actionable failure — the user's project
|
|
@@ -19932,8 +19959,9 @@ const findLowestScoredScan = (completedScans) => {
|
|
|
19932
19959
|
};
|
|
19933
19960
|
const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
19934
19961
|
const { completedScans, userConfig, verbose, isOffline, projectName } = input;
|
|
19962
|
+
const categoryFilters = input.categoryFilters ?? /* @__PURE__ */ new Set();
|
|
19935
19963
|
const animateRender = !verbose && canAnimateOnboarding(process.stdout);
|
|
19936
|
-
const
|
|
19964
|
+
const displayDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(completedScans.flatMap((scan) => scan.result.diagnostics), "cli", userConfig), categoryFilters);
|
|
19937
19965
|
const projectRootByDiagnostic = /* @__PURE__ */ new WeakMap();
|
|
19938
19966
|
for (const scan of completedScans) for (const diagnostic of scan.result.diagnostics) projectRootByDiagnostic.set(diagnostic, scan.result.project.rootDirectory);
|
|
19939
19967
|
const resolveDiagnosticSourceRoot = (diagnostic) => projectRootByDiagnostic.get(diagnostic) ?? "";
|
|
@@ -19947,29 +19975,30 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
|
19947
19975
|
const totalScannedFileCount = uniqueScannedFilePaths.size + fileCountFromScansWithoutPaths;
|
|
19948
19976
|
const totalScanElapsedMilliseconds = completedScans.reduce((sum, scan) => sum + (scan.result.scanElapsedMilliseconds ?? scan.result.elapsedMilliseconds), 0);
|
|
19949
19977
|
yield* Console.log(`${highlighter.success("✔")} Scanned ${totalScannedFileCount} ${totalScannedFileCount === 1 ? "file" : "files"} in ${formatElapsedTime(totalScanElapsedMilliseconds)}`);
|
|
19950
|
-
if (
|
|
19978
|
+
if (displayDiagnostics.length > 0) {
|
|
19951
19979
|
yield* Console.log("");
|
|
19952
|
-
yield* printDiagnostics(
|
|
19980
|
+
yield* printDiagnostics(displayDiagnostics, verbose, resolveDiagnosticSourceRoot, buildRulePriorityMap(completedScans.map((scan) => scan.result.score)), isCodingAgentEnvironment(), { animateCountUp: animateRender });
|
|
19953
19981
|
}
|
|
19954
19982
|
const lowestScoredScan = findLowestScoredScan(completedScans);
|
|
19955
19983
|
const aggregateScore = lowestScoredScan?.result.score ?? null;
|
|
19956
19984
|
const totalSourceFileCount = completedScans.reduce((sum, scan) => sum + scan.result.project.sourceFileCount, 0);
|
|
19957
19985
|
yield* printSummary({
|
|
19958
|
-
diagnostics:
|
|
19986
|
+
diagnostics: displayDiagnostics,
|
|
19959
19987
|
elapsedMilliseconds: completedScans.reduce((sum, scan) => sum + scan.result.elapsedMilliseconds, 0),
|
|
19960
19988
|
scoreResult: aggregateScore,
|
|
19961
|
-
potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(
|
|
19989
|
+
potentialScore: lowestScoredScan ? yield* Effect.promise(() => computeProjectedScore(displayDiagnostics, filterDiagnosticsForSurface(lowestScoredScan.result.diagnostics, "cli", userConfig), lowestScoredScan.result.score)) : null,
|
|
19962
19990
|
totalSourceFileCount,
|
|
19963
19991
|
noScoreMessage: "Score unavailable.",
|
|
19964
19992
|
verbose,
|
|
19965
19993
|
animateProjection: animateRender
|
|
19966
19994
|
});
|
|
19967
19995
|
const entries = completedScans.map((scan) => {
|
|
19968
|
-
const
|
|
19996
|
+
const projectDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface([...scan.result.diagnostics], "cli", userConfig), categoryFilters);
|
|
19997
|
+
const errorCount = projectDiagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
19969
19998
|
return {
|
|
19970
19999
|
projectName: scan.result.project.projectName,
|
|
19971
20000
|
score: scan.result.score?.score ?? null,
|
|
19972
|
-
issueCount:
|
|
20001
|
+
issueCount: projectDiagnostics.length,
|
|
19973
20002
|
errorCount
|
|
19974
20003
|
};
|
|
19975
20004
|
});
|
|
@@ -19977,7 +20006,7 @@ const printMultiProjectSummary = (input) => Effect.gen(function* () {
|
|
|
19977
20006
|
yield* Console.log("");
|
|
19978
20007
|
for (const entry of entries) yield* Console.log(buildSummaryLine(entry, longestProjectNameLength));
|
|
19979
20008
|
yield* printFooter({
|
|
19980
|
-
diagnostics:
|
|
20009
|
+
diagnostics: displayDiagnostics,
|
|
19981
20010
|
scoreResult: aggregateScore,
|
|
19982
20011
|
projectName,
|
|
19983
20012
|
isOffline
|
|
@@ -20067,7 +20096,8 @@ const resolveCliInspectOptions = (flags, userConfig) => {
|
|
|
20067
20096
|
noScore: flags.score === false || flags.telemetry === false || (userConfig?.noScore ?? false),
|
|
20068
20097
|
isCi: isCiEnvironment(),
|
|
20069
20098
|
silent: Boolean(flags.json),
|
|
20070
|
-
concurrency: resolveParallelFlag(flags.parallel)
|
|
20099
|
+
concurrency: resolveParallelFlag(flags.parallel),
|
|
20100
|
+
categoryFilters: resolveCliCategories(flags.category)
|
|
20071
20101
|
};
|
|
20072
20102
|
};
|
|
20073
20103
|
//#endregion
|
|
@@ -20320,6 +20350,16 @@ const validateModeFlags = (flags) => {
|
|
|
20320
20350
|
};
|
|
20321
20351
|
//#endregion
|
|
20322
20352
|
//#region src/cli/commands/inspect.ts
|
|
20353
|
+
const filterCompletedScansByCategories = (completedScans, categoryFilters) => {
|
|
20354
|
+
if (categoryFilters.size === 0) return [...completedScans];
|
|
20355
|
+
return completedScans.map((scan) => ({
|
|
20356
|
+
...scan,
|
|
20357
|
+
result: {
|
|
20358
|
+
...scan.result,
|
|
20359
|
+
diagnostics: filterDiagnosticsByCategories(scan.result.diagnostics, categoryFilters)
|
|
20360
|
+
}
|
|
20361
|
+
}));
|
|
20362
|
+
};
|
|
20323
20363
|
/**
|
|
20324
20364
|
* Post-scan finalization shared by the staged-arm and project-loop
|
|
20325
20365
|
* paths of `inspectAction`: emit the JSON report (when in JSON mode)
|
|
@@ -20332,6 +20372,7 @@ const finalizeScans = (input) => {
|
|
|
20332
20372
|
const baselineComputed = input.completedScans.length > 0 && input.completedScans.every((scan) => scan.result.baselineDelta !== void 0);
|
|
20333
20373
|
const baselineDegraded = input.baselineIntended && !baselineComputed;
|
|
20334
20374
|
const mode = baselineDegraded ? "diff" : input.mode;
|
|
20375
|
+
const jsonCompletedScans = filterCompletedScansByCategories(input.completedScans, input.categoryFilters);
|
|
20335
20376
|
if (input.isJsonMode) {
|
|
20336
20377
|
const baseline = baselineComputed && baselineDeltas.length > 0 ? {
|
|
20337
20378
|
baseRef: baselineDeltas[0].baseRef,
|
|
@@ -20343,7 +20384,7 @@ const finalizeScans = (input) => {
|
|
|
20343
20384
|
directory: input.resolvedDirectory,
|
|
20344
20385
|
mode,
|
|
20345
20386
|
diff: input.diff,
|
|
20346
|
-
scans:
|
|
20387
|
+
scans: jsonCompletedScans,
|
|
20347
20388
|
totalElapsedMilliseconds: performance.now() - input.startTime,
|
|
20348
20389
|
baseline
|
|
20349
20390
|
}));
|
|
@@ -20417,6 +20458,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20417
20458
|
await Effect.runPromise(playWelcomeScene({ speedMultiplier: isReturningUser ? 2 : 1 }));
|
|
20418
20459
|
} else Effect.runSync(printBrandedHeader);
|
|
20419
20460
|
const scanOptions = resolveCliInspectOptions(flags, userConfig);
|
|
20461
|
+
const categoryFilters = new Set(scanOptions.categoryFilters ?? []);
|
|
20420
20462
|
const skipPrompts = shouldSkipPrompts({
|
|
20421
20463
|
yes: flags.yes,
|
|
20422
20464
|
json: flags.json
|
|
@@ -20477,6 +20519,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20477
20519
|
isJsonMode,
|
|
20478
20520
|
isScoreOnly,
|
|
20479
20521
|
flags,
|
|
20522
|
+
categoryFilters,
|
|
20480
20523
|
userConfig,
|
|
20481
20524
|
resolvedDirectory,
|
|
20482
20525
|
startTime
|
|
@@ -20536,6 +20579,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
20536
20579
|
const shouldShowShareLink = !scanOptions.noScore && (userConfig?.share ?? true) && !scanOptions.isCi;
|
|
20537
20580
|
await Effect.runPromise(printMultiProjectSummary({
|
|
20538
20581
|
completedScans,
|
|
20582
|
+
categoryFilters,
|
|
20539
20583
|
userConfig,
|
|
20540
20584
|
verbose: Boolean(flags.verbose),
|
|
20541
20585
|
isOffline: !shouldShowShareLink,
|
|
@@ -20551,14 +20595,15 @@ const inspectAction = async (directory, flags) => {
|
|
|
20551
20595
|
isJsonMode,
|
|
20552
20596
|
isScoreOnly,
|
|
20553
20597
|
flags,
|
|
20598
|
+
categoryFilters,
|
|
20554
20599
|
userConfig,
|
|
20555
20600
|
resolvedDirectory,
|
|
20556
20601
|
startTime
|
|
20557
20602
|
});
|
|
20558
|
-
const
|
|
20559
|
-
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() &&
|
|
20603
|
+
const selectedSurfaceDiagnostics = filterDiagnosticsByCategories(filterDiagnosticsForSurface(allDiagnostics, scanOptions.outputSurface ?? "cli", userConfig), categoryFilters);
|
|
20604
|
+
if (!isQuiet && !skipPrompts && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment() && selectedSurfaceDiagnostics.length > 0) {
|
|
20560
20605
|
await handoffToAgent({
|
|
20561
|
-
diagnostics:
|
|
20606
|
+
diagnostics: selectedSurfaceDiagnostics,
|
|
20562
20607
|
projectName: path$1.basename(resolvedDirectory),
|
|
20563
20608
|
rootDirectory: resolvedDirectory,
|
|
20564
20609
|
interactive: true
|
|
@@ -20989,7 +21034,7 @@ const rulesListAction = async (options) => {
|
|
|
20989
21034
|
});
|
|
20990
21035
|
const catalog = buildRuleCatalog();
|
|
20991
21036
|
const config = validateConfigTypes((await resolveRuleConfigTarget(resolveProjectRoot(options))).config);
|
|
20992
|
-
const categoryFilter = options.category
|
|
21037
|
+
const categoryFilter = typeof options.category === "string" ? options.category.toLowerCase() : void 0;
|
|
20993
21038
|
const frameworkFilter = options.framework?.toLowerCase();
|
|
20994
21039
|
const rows = catalog.filter((entry) => {
|
|
20995
21040
|
if (categoryFilter && entry.category.toLowerCase() !== categoryFilter) return false;
|
|
@@ -21352,6 +21397,7 @@ const ROOT_FLAG_SPEC = {
|
|
|
21352
21397
|
"--yes"
|
|
21353
21398
|
]),
|
|
21354
21399
|
longOptionsWithRequiredValues: new Set([
|
|
21400
|
+
"--category",
|
|
21355
21401
|
"--changed-files-from",
|
|
21356
21402
|
"--blocking",
|
|
21357
21403
|
"--fail-on",
|
|
@@ -21508,6 +21554,7 @@ ${formatExampleLines([
|
|
|
21508
21554
|
["react-doctor ./apps/web", "scan a specific directory"],
|
|
21509
21555
|
["react-doctor --diff main", "scan only files changed vs. main"],
|
|
21510
21556
|
["react-doctor --staged", "scan staged files (pre-commit hook)"],
|
|
21557
|
+
["react-doctor --category Security", "show only one diagnostic category"],
|
|
21511
21558
|
["react-doctor --blocking warning", "fail CI on warnings too (default: error)"],
|
|
21512
21559
|
["react-doctor --json > report.json", "write a machine-readable report"],
|
|
21513
21560
|
["react-doctor why src/App.tsx:42", "explain why a rule fired there"],
|
|
@@ -21536,7 +21583,8 @@ ${formatExampleLines([
|
|
|
21536
21583
|
${highlighter.dim("Learn more:")}
|
|
21537
21584
|
${highlighter.info(CANONICAL_GITHUB_URL)}
|
|
21538
21585
|
`;
|
|
21539
|
-
const
|
|
21586
|
+
const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
|
|
21587
|
+
const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select workspace project (comma-separated for multiple)").option("--diff [base]", "scan only files changed vs base branch (pass `false` to force a full scan, overriding config)").addOption(new Option$1("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option$1("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option$1("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
|
|
21540
21588
|
program.action(inspectAction);
|
|
21541
21589
|
program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select workspace project (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
|
|
21542
21590
|
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);
|
|
@@ -21579,4 +21627,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
21579
21627
|
export {};
|
|
21580
21628
|
|
|
21581
21629
|
//# sourceMappingURL=cli.js.map
|
|
21582
|
-
//# debugId=
|
|
21630
|
+
//# debugId=e5cd8a39-286b-53d3-8951-268670de9a6a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.4.2-dev.
|
|
3
|
+
"version": "0.4.2-dev.a59499b",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"vscode-languageserver": "^9.0.1",
|
|
67
67
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
68
68
|
"vscode-uri": "^3.1.0",
|
|
69
|
-
"oxlint-plugin-react-doctor": "0.4.2-dev.
|
|
69
|
+
"oxlint-plugin-react-doctor": "0.4.2-dev.a59499b"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"commander": "^14.0.3",
|
|
76
76
|
"ora": "^9.4.0",
|
|
77
77
|
"@react-doctor/api": "0.4.2",
|
|
78
|
-
"@react-doctor/
|
|
79
|
-
"@react-doctor/
|
|
78
|
+
"@react-doctor/core": "0.4.2",
|
|
79
|
+
"@react-doctor/language-server": "0.4.2"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": "^20.19.0 || >=22.12.0"
|