react-doctor 0.5.1-dev.a64093c → 0.5.1-dev.c4f0e60
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 +298 -66
- package/dist/index.d.ts +48 -9
- package/dist/index.js +82 -15
- package/dist/lsp.js +82 -15
- package/dist/skills/react-doctor/SKILL.md +10 -9
- package/package.json +3 -3
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]="60598d2a-66c7-5091-a013-028926866fbd")}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";
|
|
@@ -40271,6 +40271,42 @@ var Files = class Files extends Service()("react-doctor/Files") {
|
|
|
40271
40271
|
}));
|
|
40272
40272
|
};
|
|
40273
40273
|
};
|
|
40274
|
+
const HUNK_HEADER_PATTERN = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
|
|
40275
|
+
/**
|
|
40276
|
+
* Parses a `git diff --unified=0` patch into the inclusive 1-based line ranges
|
|
40277
|
+
* each file added or modified on the new side. Files are keyed by the path in
|
|
40278
|
+
* the `+++ b/<path>` header (with `--relative`, relative to the diff's cwd).
|
|
40279
|
+
* Added/renamed/modified files appear; pure deletions (`+++ /dev/null`) are
|
|
40280
|
+
* skipped because they have no new-side line to report on.
|
|
40281
|
+
*/
|
|
40282
|
+
const parseChangedLineRanges = (patch) => {
|
|
40283
|
+
const rangesByFile = /* @__PURE__ */ new Map();
|
|
40284
|
+
let currentRanges = null;
|
|
40285
|
+
for (const line of patch.split("\n")) {
|
|
40286
|
+
if (line.startsWith("+++ ")) {
|
|
40287
|
+
const target = line.slice(4).trim();
|
|
40288
|
+
if (target === "/dev/null") {
|
|
40289
|
+
currentRanges = null;
|
|
40290
|
+
continue;
|
|
40291
|
+
}
|
|
40292
|
+
const file = target.startsWith("b/") ? target.slice(2) : target;
|
|
40293
|
+
currentRanges = rangesByFile.get(file) ?? [];
|
|
40294
|
+
rangesByFile.set(file, currentRanges);
|
|
40295
|
+
continue;
|
|
40296
|
+
}
|
|
40297
|
+
if (currentRanges === null) continue;
|
|
40298
|
+
const hunk = HUNK_HEADER_PATTERN.exec(line);
|
|
40299
|
+
if (hunk === null) continue;
|
|
40300
|
+
const start = Number(hunk[1]);
|
|
40301
|
+
const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
|
|
40302
|
+
if (lineCount <= 0) continue;
|
|
40303
|
+
currentRanges.push([start, start + lineCount - 1]);
|
|
40304
|
+
}
|
|
40305
|
+
return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
|
|
40306
|
+
file,
|
|
40307
|
+
ranges
|
|
40308
|
+
}));
|
|
40309
|
+
};
|
|
40274
40310
|
const trimOrNull = (value) => {
|
|
40275
40311
|
const trimmed = value.trim();
|
|
40276
40312
|
return trimmed.length === 0 ? null : trimmed;
|
|
@@ -40636,6 +40672,22 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
40636
40672
|
status: result.status,
|
|
40637
40673
|
stdout: result.stdout
|
|
40638
40674
|
};
|
|
40675
|
+
}),
|
|
40676
|
+
changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
|
|
40677
|
+
if (files.length === 0) return [];
|
|
40678
|
+
if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
|
|
40679
|
+
const result = yield* runGit(directory, [
|
|
40680
|
+
"diff",
|
|
40681
|
+
"--unified=0",
|
|
40682
|
+
"--diff-filter=ACMR",
|
|
40683
|
+
"--relative",
|
|
40684
|
+
...cached ? ["--cached"] : [],
|
|
40685
|
+
...baseRef !== void 0 ? [baseRef] : [],
|
|
40686
|
+
"--",
|
|
40687
|
+
...files
|
|
40688
|
+
]);
|
|
40689
|
+
if (result.status !== 0) return null;
|
|
40690
|
+
return parseChangedLineRanges(result.stdout);
|
|
40639
40691
|
})
|
|
40640
40692
|
});
|
|
40641
40693
|
})).pipe(provide$2(layer$3.pipe(provide$2(mergeAll$1(layer$2, layer$1)))));
|
|
@@ -40666,7 +40718,8 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
40666
40718
|
status: matches.length === 0 ? 1 : 0,
|
|
40667
40719
|
stdout
|
|
40668
40720
|
};
|
|
40669
|
-
})
|
|
40721
|
+
}),
|
|
40722
|
+
changedLineRanges: () => succeed$2(snapshot.changedLineRanges ?? [])
|
|
40670
40723
|
}));
|
|
40671
40724
|
};
|
|
40672
40725
|
const estimateArgsLength = (args) => args.reduce((total, argument) => total + argument.length + 1, 0);
|
|
@@ -42445,25 +42498,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
|
|
|
42445
42498
|
const SCORE_AXES = [
|
|
42446
42499
|
{
|
|
42447
42500
|
key: "supplyChain",
|
|
42448
|
-
label: "supply chain"
|
|
42501
|
+
label: "supply chain",
|
|
42502
|
+
gates: true
|
|
42449
42503
|
},
|
|
42450
42504
|
{
|
|
42451
42505
|
key: "vulnerability",
|
|
42452
|
-
label: "vulnerability"
|
|
42506
|
+
label: "vulnerability",
|
|
42507
|
+
gates: true
|
|
42453
42508
|
},
|
|
42454
42509
|
{
|
|
42455
42510
|
key: "maintenance",
|
|
42456
|
-
label: "maintenance"
|
|
42511
|
+
label: "maintenance",
|
|
42512
|
+
gates: false
|
|
42457
42513
|
},
|
|
42458
42514
|
{
|
|
42459
42515
|
key: "quality",
|
|
42460
|
-
label: "quality"
|
|
42516
|
+
label: "quality",
|
|
42517
|
+
gates: false
|
|
42461
42518
|
},
|
|
42462
42519
|
{
|
|
42463
42520
|
key: "license",
|
|
42464
|
-
label: "license"
|
|
42521
|
+
label: "license",
|
|
42522
|
+
gates: false
|
|
42465
42523
|
}
|
|
42466
42524
|
];
|
|
42525
|
+
const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
|
|
42526
|
+
const worstGatedAxis = (score) => {
|
|
42527
|
+
let worst = GATED_AXES[0];
|
|
42528
|
+
for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
|
|
42529
|
+
return worst;
|
|
42530
|
+
};
|
|
42467
42531
|
const clampScore = (value) => {
|
|
42468
42532
|
if (!Number.isFinite(value)) return 50;
|
|
42469
42533
|
return Math.min(Math.max(value, 0), 100);
|
|
@@ -42604,15 +42668,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
|
|
|
42604
42668
|
"socket.purl": toPurl(dependency)
|
|
42605
42669
|
} }));
|
|
42606
42670
|
const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
|
|
42607
|
-
const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
42608
|
-
const overall = toHundred(score.overall);
|
|
42671
|
+
const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
|
|
42609
42672
|
const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
|
|
42610
42673
|
return {
|
|
42611
42674
|
filePath: "package.json",
|
|
42612
42675
|
plugin: SUPPLY_CHAIN_PLUGIN,
|
|
42613
42676
|
rule: SUPPLY_CHAIN_RULE,
|
|
42614
42677
|
severity: options.severity,
|
|
42615
|
-
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket
|
|
42678
|
+
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
|
|
42616
42679
|
help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
|
|
42617
42680
|
url: packagePageUrl,
|
|
42618
42681
|
line: dependency.line,
|
|
@@ -42647,7 +42710,9 @@ const collectSupplyChainScores = (input) => gen(function* () {
|
|
|
42647
42710
|
* Scores every direct dependency in the project's `package.json` against
|
|
42648
42711
|
* Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
|
|
42649
42712
|
* uses — no API key) and returns a diagnostic for each dependency whose
|
|
42650
|
-
* Socket
|
|
42713
|
+
* worst Socket *security* axis — supply chain or vulnerability — is below
|
|
42714
|
+
* the configured `minScore`. The quality / maintenance / license axes are
|
|
42715
|
+
* reported as context but never gate (see GATED_AXES).
|
|
42651
42716
|
*
|
|
42652
42717
|
* Lookups run with bounded concurrency via `Effect.forEach`. The check is
|
|
42653
42718
|
* total/fail-open: each per-package lookup already recovers to `null`
|
|
@@ -42665,8 +42730,9 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
42665
42730
|
for (let index = 0; index < dependencies.length; index += 1) {
|
|
42666
42731
|
const score = scores[index];
|
|
42667
42732
|
if (!score) continue;
|
|
42668
|
-
|
|
42669
|
-
|
|
42733
|
+
const worstAxis = worstGatedAxis(score);
|
|
42734
|
+
if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
|
|
42735
|
+
diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
|
|
42670
42736
|
}
|
|
42671
42737
|
return diagnostics;
|
|
42672
42738
|
});
|
|
@@ -42674,7 +42740,8 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
42674
42740
|
* `SupplyChain` scores the project's direct dependencies against Socket.dev's
|
|
42675
42741
|
* free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
|
|
42676
42742
|
* (`sfw`) performs — and streams a diagnostic for each dependency whose
|
|
42677
|
-
* Socket
|
|
42743
|
+
* worst Socket security axis (supply chain or vulnerability) falls below
|
|
42744
|
+
* the configured `supplyChain.minScore`.
|
|
42678
42745
|
*
|
|
42679
42746
|
* Runs by default (one network request per dependency); the orchestrator
|
|
42680
42747
|
* provides `layerOf([])` only when the user opts out via
|
|
@@ -43366,6 +43433,21 @@ const getDiffInfo = (directory, explicitBaseBranch) => runPromise(gen(function*
|
|
|
43366
43433
|
}).pipe(provide(Git.layerNode)));
|
|
43367
43434
|
const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
|
|
43368
43435
|
/**
|
|
43436
|
+
* Programmatic façade over `Git.changedLineRanges` (the `lines` scope). Diffs
|
|
43437
|
+
* `files` with `--unified=0` against `baseRef` (or the index when `cached`),
|
|
43438
|
+
* returning per-file changed line ranges relative to `directory`. Returns
|
|
43439
|
+
* `null` when the ranges can't be computed (git unavailable / unsafe ref /
|
|
43440
|
+
* non-zero exit) so the caller degrades to file-level scope; an empty array
|
|
43441
|
+
* means git succeeded but the files added no lines.
|
|
43442
|
+
*/
|
|
43443
|
+
const getChangedLineRanges = (input) => runPromise(gen(function* () {
|
|
43444
|
+
const ranges = yield* (yield* Git).changedLineRanges(input);
|
|
43445
|
+
return ranges === null ? null : ranges.map((entry) => ({
|
|
43446
|
+
file: entry.file,
|
|
43447
|
+
ranges: entry.ranges
|
|
43448
|
+
}));
|
|
43449
|
+
}).pipe(provide(Git.layerNode)));
|
|
43450
|
+
/**
|
|
43369
43451
|
* Canonical URL for a rule's documentation page — its reviewer-tested fix
|
|
43370
43452
|
* recipe rendered for humans — served at
|
|
43371
43453
|
* `https://react.doctor/docs/rules/<plugin>/<rule>`. The CLI links here
|
|
@@ -43591,7 +43673,7 @@ const makeNoopConsole = () => ({
|
|
|
43591
43673
|
});
|
|
43592
43674
|
//#endregion
|
|
43593
43675
|
//#region src/cli/utils/version.ts
|
|
43594
|
-
const VERSION = "0.5.1-dev.
|
|
43676
|
+
const VERSION = "0.5.1-dev.c4f0e60";
|
|
43595
43677
|
//#endregion
|
|
43596
43678
|
//#region src/cli/utils/json-mode.ts
|
|
43597
43679
|
let context = null;
|
|
@@ -43949,13 +44031,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
43949
44031
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
43950
44032
|
* standard `SENTRY_RELEASE` override.
|
|
43951
44033
|
*/
|
|
43952
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.
|
|
44034
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.c4f0e60`;
|
|
43953
44035
|
/**
|
|
43954
44036
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
43955
44037
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
43956
44038
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
43957
44039
|
*/
|
|
43958
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.
|
|
44040
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.c4f0e60") ? "development" : "production");
|
|
43959
44041
|
/**
|
|
43960
44042
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
43961
44043
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -47594,6 +47676,7 @@ const buildConfigAttributes = (input) => {
|
|
|
47594
47676
|
const ruleKeys = Object.keys(ruleOverrides);
|
|
47595
47677
|
return {
|
|
47596
47678
|
mode: input.mode,
|
|
47679
|
+
scope: input.scope,
|
|
47597
47680
|
parallel: input.parallel,
|
|
47598
47681
|
workerCount: input.workerCount ?? null,
|
|
47599
47682
|
lint: input.lint,
|
|
@@ -47635,6 +47718,9 @@ const recordRunEvent = (rootSpan, input) => {
|
|
|
47635
47718
|
} catch {}
|
|
47636
47719
|
};
|
|
47637
47720
|
//#endregion
|
|
47721
|
+
//#region src/cli/utils/path-format.ts
|
|
47722
|
+
const toForwardSlashes = (filePath) => filePath.replaceAll("\\", "/");
|
|
47723
|
+
//#endregion
|
|
47638
47724
|
//#region src/cli/utils/materialize-baseline-files.ts
|
|
47639
47725
|
/**
|
|
47640
47726
|
* Materializes the `ref` version of `files` into `tempDirectory` (via
|
|
@@ -48797,6 +48883,7 @@ const buildScanResultCacheKey = (input) => {
|
|
|
48797
48883
|
ignoredTags: [...input.options.ignoredTags].sort(),
|
|
48798
48884
|
concurrency: input.options.concurrency,
|
|
48799
48885
|
baselineRef: input.options.baseline?.ref,
|
|
48886
|
+
changedLineRanges: input.options.changedLineRanges ?? void 0,
|
|
48800
48887
|
noScore: input.options.noScore,
|
|
48801
48888
|
isCi: input.options.isCi,
|
|
48802
48889
|
suppressRendering: input.options.suppressRendering,
|
|
@@ -48845,6 +48932,16 @@ const recordOnboardingCompletion = (options) => {
|
|
|
48845
48932
|
})) markOnboardingComplete();
|
|
48846
48933
|
};
|
|
48847
48934
|
const formatCategorySelection = (categoryFilters) => [...categoryFilters].join(", ");
|
|
48935
|
+
const buildChangedLineMatcher = (directory, changedLineRanges) => {
|
|
48936
|
+
const rangesByFile = /* @__PURE__ */ new Map();
|
|
48937
|
+
for (const entry of changedLineRanges) rangesByFile.set(toForwardSlashes(entry.file), entry.ranges);
|
|
48938
|
+
return (diagnostic) => {
|
|
48939
|
+
const relativePath = toForwardSlashes(path.isAbsolute(diagnostic.filePath) ? path.relative(directory, diagnostic.filePath) : diagnostic.filePath);
|
|
48940
|
+
const ranges = rangesByFile.get(relativePath);
|
|
48941
|
+
if (ranges === void 0) return false;
|
|
48942
|
+
return ranges.some(([start, end]) => diagnostic.line >= start && diagnostic.line <= end);
|
|
48943
|
+
};
|
|
48944
|
+
};
|
|
48848
48945
|
const buildIgnoredTags = (userConfig) => {
|
|
48849
48946
|
const tags = /* @__PURE__ */ new Set();
|
|
48850
48947
|
if (userConfig?.ignore?.tags) for (const tag of userConfig.ignore.tags) tags.add(tag);
|
|
@@ -48872,9 +48969,16 @@ const mergeInspectOptions = (inputOptions, userConfig) => ({
|
|
|
48872
48969
|
suppressRendering: inputOptions.suppressRendering ?? false,
|
|
48873
48970
|
concurrency: inputOptions.concurrency,
|
|
48874
48971
|
baseline: inputOptions.baseline ?? null,
|
|
48972
|
+
changedLineRanges: inputOptions.changedLineRanges ?? null,
|
|
48875
48973
|
supplyChainManifestChanged: inputOptions.supplyChainManifestChanged ?? false
|
|
48876
48974
|
});
|
|
48975
|
+
const deriveScope = (options) => {
|
|
48976
|
+
if (options.baseline) return "changed";
|
|
48977
|
+
if (options.changedLineRanges !== null) return "lines";
|
|
48978
|
+
return options.includePaths.length > 0 ? "files" : "full";
|
|
48979
|
+
};
|
|
48877
48980
|
const buildRunEventConfig = (options, userConfig, hasCustomConfig) => ({
|
|
48981
|
+
scope: deriveScope(options),
|
|
48878
48982
|
parallel: options.concurrency !== void 0,
|
|
48879
48983
|
workerCount: options.concurrency,
|
|
48880
48984
|
lint: options.lint,
|
|
@@ -49096,6 +49200,9 @@ const runInspectWithRuntime = async (directory, options, userConfig, hasConfigOv
|
|
|
49096
49200
|
inspectDiagnostics = comparison.displayDiagnostics;
|
|
49097
49201
|
baselineDelta = comparison.baselineDelta;
|
|
49098
49202
|
}
|
|
49203
|
+
} else if (options.changedLineRanges !== null && isDiffMode) {
|
|
49204
|
+
const isOnChangedLine = buildChangedLineMatcher(directory, options.changedLineRanges);
|
|
49205
|
+
inspectDiagnostics = output.diagnostics.filter(isOnChangedLine);
|
|
49099
49206
|
}
|
|
49100
49207
|
const baselineDegraded = Boolean(options.baseline) && isDiffMode && baselineDelta === void 0;
|
|
49101
49208
|
const score = didLintFail ? null : output.score;
|
|
@@ -51554,9 +51661,6 @@ const reportErrorToSentry = async (error) => {
|
|
|
51554
51661
|
}
|
|
51555
51662
|
};
|
|
51556
51663
|
//#endregion
|
|
51557
|
-
//#region src/cli/utils/path-format.ts
|
|
51558
|
-
const toForwardSlashes = (filePath) => filePath.replaceAll("\\", "/");
|
|
51559
|
-
//#endregion
|
|
51560
51664
|
//#region src/cli/utils/read-changed-files-from.ts
|
|
51561
51665
|
const isSafeRelativePath = (filePath) => {
|
|
51562
51666
|
if (filePath.length === 0) return false;
|
|
@@ -51753,22 +51857,101 @@ const resolveCliInspectOptions = (flags, userConfig) => {
|
|
|
51753
51857
|
};
|
|
51754
51858
|
};
|
|
51755
51859
|
//#endregion
|
|
51756
|
-
//#region src/cli/utils/resolve-
|
|
51757
|
-
const
|
|
51758
|
-
|
|
51759
|
-
|
|
51760
|
-
|
|
51761
|
-
|
|
51762
|
-
|
|
51763
|
-
|
|
51764
|
-
|
|
51765
|
-
|
|
51860
|
+
//#region src/cli/utils/resolve-scope.ts
|
|
51861
|
+
const SCOPE_VALUES = new Set([
|
|
51862
|
+
"full",
|
|
51863
|
+
"files",
|
|
51864
|
+
"changed",
|
|
51865
|
+
"lines"
|
|
51866
|
+
]);
|
|
51867
|
+
const isScopeValue = (value) => SCOPE_VALUES.has(value);
|
|
51868
|
+
const coerceDeprecatedDiff = (value) => {
|
|
51869
|
+
if (value === void 0) return void 0;
|
|
51870
|
+
if (value === false || value === "false") return { scope: "full" };
|
|
51871
|
+
if (value === true || value === "true") return { scope: "changed" };
|
|
51872
|
+
if (value === "") return void 0;
|
|
51873
|
+
return {
|
|
51874
|
+
scope: "changed",
|
|
51875
|
+
base: value
|
|
51876
|
+
};
|
|
51877
|
+
};
|
|
51878
|
+
/**
|
|
51879
|
+
* Resolves the *requested* scope from flags + config without touching git.
|
|
51880
|
+
* Precedence mirrors `pickBlockingLevel`: flags win over config, and the new
|
|
51881
|
+
* `--scope` wins over the deprecated `--diff` alias on each side
|
|
51882
|
+
* (`flags.scope` > `flags.diff` > `config.scope` > `config.diff`). Returns
|
|
51883
|
+
* `scope: undefined` when nothing is set so the caller can default to `full`
|
|
51884
|
+
* or offer the interactive prompt.
|
|
51885
|
+
*/
|
|
51886
|
+
const resolveScope = (flags, userConfig) => {
|
|
51887
|
+
const base = flags.base ?? userConfig?.base;
|
|
51888
|
+
if (typeof flags.scope === "string" && flags.scope.length > 0) {
|
|
51889
|
+
if (isScopeValue(flags.scope)) return {
|
|
51890
|
+
scope: flags.scope,
|
|
51891
|
+
base,
|
|
51892
|
+
usedDeprecatedDiff: false
|
|
51893
|
+
};
|
|
51894
|
+
cliLogger.warn(`Invalid --scope "${flags.scope}". Expected one of: full, files, changed, lines. Ignoring.`);
|
|
51766
51895
|
}
|
|
51767
|
-
|
|
51768
|
-
|
|
51769
|
-
|
|
51770
|
-
|
|
51771
|
-
|
|
51896
|
+
const flagDiff = coerceDeprecatedDiff(flags.diff);
|
|
51897
|
+
if (flagDiff !== void 0) return {
|
|
51898
|
+
scope: flagDiff.scope,
|
|
51899
|
+
base: base ?? flagDiff.base,
|
|
51900
|
+
usedDeprecatedDiff: true
|
|
51901
|
+
};
|
|
51902
|
+
if (userConfig?.scope !== void 0) {
|
|
51903
|
+
if (isScopeValue(userConfig.scope)) return {
|
|
51904
|
+
scope: userConfig.scope,
|
|
51905
|
+
base,
|
|
51906
|
+
usedDeprecatedDiff: false
|
|
51907
|
+
};
|
|
51908
|
+
cliLogger.warn(`Invalid scope "${userConfig.scope}" in config. Expected one of: full, files, changed, lines. Ignoring.`);
|
|
51909
|
+
}
|
|
51910
|
+
const configDiff = coerceDeprecatedDiff(userConfig?.diff);
|
|
51911
|
+
if (configDiff !== void 0) return {
|
|
51912
|
+
scope: configDiff.scope,
|
|
51913
|
+
base: base ?? configDiff.base,
|
|
51914
|
+
usedDeprecatedDiff: true
|
|
51915
|
+
};
|
|
51916
|
+
return {
|
|
51917
|
+
scope: void 0,
|
|
51918
|
+
base,
|
|
51919
|
+
usedDeprecatedDiff: false
|
|
51920
|
+
};
|
|
51921
|
+
};
|
|
51922
|
+
const warnDeprecatedDiff = (flags, userConfig) => {
|
|
51923
|
+
const usedFlag = flags.diff !== void 0;
|
|
51924
|
+
if (!usedFlag && userConfig?.diff === void 0) return;
|
|
51925
|
+
const targetScope = coerceDeprecatedDiff(usedFlag ? flags.diff : userConfig?.diff)?.scope ?? "changed";
|
|
51926
|
+
if (usedFlag) {
|
|
51927
|
+
const baseHint = targetScope === "changed" ? " (add `--base <ref>` to pin the base)" : "";
|
|
51928
|
+
cliLogger.warn(`The \`--diff\` flag is deprecated; use \`--scope ${targetScope}\`${baseHint} instead.`);
|
|
51929
|
+
return;
|
|
51930
|
+
}
|
|
51931
|
+
cliLogger.warn(`The \`diff\` config option is deprecated; use \`scope: "${targetScope}"\` instead.`);
|
|
51932
|
+
};
|
|
51933
|
+
const warnDiffUnavailable = (requested, isQuiet) => {
|
|
51934
|
+
if (isQuiet) return;
|
|
51935
|
+
if (typeof requested.base === "string") cliLogger.warn(`Could not compute diff against "${requested.base}" (merge-base failed or HEAD has no history). Running full scan.`);
|
|
51936
|
+
else cliLogger.warn("No feature branch or uncommitted changes detected. Running full scan.");
|
|
51937
|
+
cliLogger.break();
|
|
51938
|
+
};
|
|
51939
|
+
/**
|
|
51940
|
+
* Resolves the requested scope against the detected diff into the final scope.
|
|
51941
|
+
* An explicit non-`full` scope needs a usable `diffInfo`; without one it warns
|
|
51942
|
+
* and falls back to `full`. When nothing was requested, an interactive run on a
|
|
51943
|
+
* branch with changed source files is offered the "full vs changed" prompt.
|
|
51944
|
+
*/
|
|
51945
|
+
const finalizeScope = async ({ requested, diffInfo, skipPrompts, isQuiet }) => {
|
|
51946
|
+
if (requested.scope !== void 0) {
|
|
51947
|
+
if (requested.scope === "full") return "full";
|
|
51948
|
+
if (diffInfo !== null) return requested.scope;
|
|
51949
|
+
warnDiffUnavailable(requested, isQuiet);
|
|
51950
|
+
return "full";
|
|
51951
|
+
}
|
|
51952
|
+
if (diffInfo === null || skipPrompts || isQuiet) return "full";
|
|
51953
|
+
const changedSourceFiles = filterSourceFiles([...diffInfo.changedFiles]);
|
|
51954
|
+
if (changedSourceFiles.length === 0) return "full";
|
|
51772
51955
|
const { scanScope } = await prompts({
|
|
51773
51956
|
type: "select",
|
|
51774
51957
|
name: "scanScope",
|
|
@@ -51780,29 +51963,13 @@ const resolveDiffMode = async (diffInfo, effectiveDiff, shouldSkipPrompts, isQui
|
|
|
51780
51963
|
}, {
|
|
51781
51964
|
title: diffInfo.isCurrentChanges ? `Uncommitted changes (${changedSourceFiles.length})` : `Changed files on ${diffInfo.currentBranch ?? "this branch"} (${changedSourceFiles.length})`,
|
|
51782
51965
|
description: diffInfo.isCurrentChanges ? "Compare working tree changes against HEAD" : `Compare against ${diffInfo.baseBranch} from the branch merge-base`,
|
|
51783
|
-
value: "
|
|
51966
|
+
value: "changed"
|
|
51784
51967
|
}],
|
|
51785
51968
|
initial: diffInfo.isCurrentChanges ? 0 : 1
|
|
51786
51969
|
});
|
|
51787
|
-
return scanScope === "
|
|
51788
|
-
};
|
|
51789
|
-
//#endregion
|
|
51790
|
-
//#region src/cli/utils/coerce-diff-value.ts
|
|
51791
|
-
const coerceDiffValue = (value) => {
|
|
51792
|
-
if (value === void 0) return void 0;
|
|
51793
|
-
if (typeof value === "boolean") return value;
|
|
51794
|
-
if (typeof value === "string") {
|
|
51795
|
-
if (value.length === 0) return void 0;
|
|
51796
|
-
if (value === "false") return false;
|
|
51797
|
-
if (value === "true") return true;
|
|
51798
|
-
return value;
|
|
51799
|
-
}
|
|
51800
|
-
process.stderr.write(`[react-doctor] invalid diff value (expected boolean or string): ${typeof value}. Falling back to no diff.\n`);
|
|
51970
|
+
return scanScope === "changed" ? "changed" : "full";
|
|
51801
51971
|
};
|
|
51802
51972
|
//#endregion
|
|
51803
|
-
//#region src/cli/utils/resolve-effective-diff.ts
|
|
51804
|
-
const resolveEffectiveDiff = (flags, userConfig) => coerceDiffValue(flags.diff ?? userConfig?.diff);
|
|
51805
|
-
//#endregion
|
|
51806
51973
|
//#region src/cli/utils/resolve-project-relative-directory.ts
|
|
51807
51974
|
/**
|
|
51808
51975
|
* The scanned project's directory relative to the diff root, forward-slashed —
|
|
@@ -51833,6 +52000,30 @@ const resolveProjectDiffIncludePaths = (rootDirectory, projectDirectory, diffInf
|
|
|
51833
52000
|
return projectRelativePath.length > 0 ? [projectRelativePath] : [];
|
|
51834
52001
|
});
|
|
51835
52002
|
};
|
|
52003
|
+
/**
|
|
52004
|
+
* Re-keys repo-relative changed line ranges (from `getChangedLineRanges`) to
|
|
52005
|
+
* the scanned project, mirroring `resolveProjectDiffIncludePaths`'s boundary
|
|
52006
|
+
* rule so the `lines` scope filter inside `inspect()` matches the project-
|
|
52007
|
+
* relative diagnostic paths. Files outside the project are dropped.
|
|
52008
|
+
*/
|
|
52009
|
+
const resolveProjectChangedLineRanges = (rootDirectory, projectDirectory, ranges) => {
|
|
52010
|
+
const relativeProjectDirectory = resolveProjectRelativeDirectory(rootDirectory, projectDirectory);
|
|
52011
|
+
if (relativeProjectDirectory === null) return [];
|
|
52012
|
+
if (relativeProjectDirectory.length === 0) return ranges.map((entry) => ({
|
|
52013
|
+
file: toForwardSlashes(entry.file),
|
|
52014
|
+
ranges: entry.ranges
|
|
52015
|
+
}));
|
|
52016
|
+
const projectPrefix = `${relativeProjectDirectory}/`;
|
|
52017
|
+
return ranges.flatMap((entry) => {
|
|
52018
|
+
const normalizedFilePath = toForwardSlashes(entry.file);
|
|
52019
|
+
if (!normalizedFilePath.startsWith(projectPrefix)) return [];
|
|
52020
|
+
const projectRelativePath = normalizedFilePath.slice(projectPrefix.length);
|
|
52021
|
+
return projectRelativePath.length > 0 ? [{
|
|
52022
|
+
file: projectRelativePath,
|
|
52023
|
+
ranges: entry.ranges
|
|
52024
|
+
}] : [];
|
|
52025
|
+
});
|
|
52026
|
+
};
|
|
51836
52027
|
//#endregion
|
|
51837
52028
|
//#region src/cli/utils/build-diagnostic-issue-url.ts
|
|
51838
52029
|
const formatRuleIdentifier = (diagnostic) => `${diagnostic.plugin}/${diagnostic.rule}`;
|
|
@@ -52065,10 +52256,12 @@ const warnDeprecatedFailOn = (flags, userConfig) => {
|
|
|
52065
52256
|
};
|
|
52066
52257
|
//#endregion
|
|
52067
52258
|
//#region src/cli/utils/validate-mode-flags.ts
|
|
52259
|
+
const usedDiffAlias = (flags) => flags.diff !== void 0 && flags.diff !== false && flags.diff !== "false" && flags.diff !== "";
|
|
52260
|
+
const usedScope = (flags) => typeof flags.scope === "string" && flags.scope.length > 0;
|
|
52068
52261
|
const validateModeFlags = (flags) => {
|
|
52069
|
-
|
|
52070
|
-
|
|
52071
|
-
if (
|
|
52262
|
+
if (usedScope(flags) && usedDiffAlias(flags)) throw new CliInputError("Cannot combine --scope and --diff; --diff is the deprecated alias.");
|
|
52263
|
+
if (flags.staged && usedDiffAlias(flags)) throw new CliInputError("Cannot combine --staged and --diff; pick one mode.");
|
|
52264
|
+
if (flags.staged && (flags.scope === "full" || flags.scope === "changed")) throw new CliInputError(`Cannot combine --staged with --scope ${flags.scope}; use --scope files or --scope lines, or drop --scope.`);
|
|
52072
52265
|
if (flags.score && flags.json) throw new CliInputError("Cannot combine --score and --json; pick one output mode.");
|
|
52073
52266
|
if (flags.score && flags.telemetry === false) throw new CliInputError("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
|
|
52074
52267
|
if (flags.sfw) {
|
|
@@ -52076,7 +52269,8 @@ const validateModeFlags = (flags) => {
|
|
|
52076
52269
|
flags.json ? "--json" : null,
|
|
52077
52270
|
flags.score ? "--score" : null,
|
|
52078
52271
|
flags.staged ? "--staged" : null,
|
|
52079
|
-
|
|
52272
|
+
usedScope(flags) ? "--scope" : null,
|
|
52273
|
+
usedDiffAlias(flags) ? "--diff" : null
|
|
52080
52274
|
].find((name) => name !== null);
|
|
52081
52275
|
if (conflictingFlag) throw new CliInputError(`Cannot combine --sfw with ${conflictingFlag}; --sfw is a standalone demo listing.`);
|
|
52082
52276
|
}
|
|
@@ -52172,6 +52366,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
52172
52366
|
const resolvedDirectory = scanTarget.resolvedDirectory;
|
|
52173
52367
|
setJsonReportDirectory(resolvedDirectory);
|
|
52174
52368
|
warnDeprecatedFailOn(flags, userConfig);
|
|
52369
|
+
warnDeprecatedDiff(flags, userConfig);
|
|
52175
52370
|
if (scanTarget.didRedirectViaRootDir && !isQuiet) {
|
|
52176
52371
|
cliLogger.dim(`Redirected to ${highlighter.info(toRelativePath(resolvedDirectory, requestedDirectory))} via react-doctor config "rootDir".`);
|
|
52177
52372
|
cliLogger.break();
|
|
@@ -52233,11 +52428,22 @@ const inspectAction = async (directory, flags) => {
|
|
|
52233
52428
|
});
|
|
52234
52429
|
throw error;
|
|
52235
52430
|
});
|
|
52431
|
+
const stagedWantsLines = resolveScope(flags, userConfig).scope === "lines";
|
|
52432
|
+
const stagedLineRanges = stagedWantsLines ? await getChangedLineRanges({
|
|
52433
|
+
directory: resolvedDirectory,
|
|
52434
|
+
cached: true,
|
|
52435
|
+
files: snapshot.stagedFiles
|
|
52436
|
+
}) : null;
|
|
52437
|
+
if (stagedWantsLines && stagedLineRanges === null && !isQuiet) {
|
|
52438
|
+
cliLogger.warn("Could not determine staged changed lines; reporting all issues in staged files.");
|
|
52439
|
+
cliLogger.break();
|
|
52440
|
+
}
|
|
52236
52441
|
try {
|
|
52237
52442
|
const scanResult = await inspect(snapshot.tempDirectory, {
|
|
52238
52443
|
...scanOptions,
|
|
52239
52444
|
includePaths: snapshot.stagedFiles,
|
|
52240
|
-
configOverride: userConfig
|
|
52445
|
+
configOverride: userConfig,
|
|
52446
|
+
changedLineRanges: stagedLineRanges ?? void 0
|
|
52241
52447
|
});
|
|
52242
52448
|
const remappedDiagnostics = scanResult.diagnostics.map((diagnostic) => ({
|
|
52243
52449
|
...diagnostic,
|
|
@@ -52274,10 +52480,33 @@ const inspectAction = async (directory, flags) => {
|
|
|
52274
52480
|
}
|
|
52275
52481
|
const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts);
|
|
52276
52482
|
const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
|
|
52277
|
-
const
|
|
52278
|
-
const
|
|
52279
|
-
|
|
52280
|
-
|
|
52483
|
+
const requestedScope = resolveScope(flags, userConfig);
|
|
52484
|
+
const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
|
|
52485
|
+
...requestedScope,
|
|
52486
|
+
scope: "changed"
|
|
52487
|
+
} : requestedScope;
|
|
52488
|
+
const wantsDiffMode = scopeRequest.scope !== void 0 && scopeRequest.scope !== "full";
|
|
52489
|
+
const shouldDetectDiff = changedFilesDiffInfo === null && (wantsDiffMode || scopeRequest.scope === void 0 && !skipPrompts && !isQuiet);
|
|
52490
|
+
const diffInfo = changedFilesDiffInfo ?? (shouldDetectDiff ? await getDiffInfo(resolvedDirectory, scopeRequest.base) : null);
|
|
52491
|
+
const scope = await finalizeScope({
|
|
52492
|
+
requested: scopeRequest,
|
|
52493
|
+
diffInfo,
|
|
52494
|
+
skipPrompts,
|
|
52495
|
+
isQuiet
|
|
52496
|
+
});
|
|
52497
|
+
const isDiffMode = scope !== "full";
|
|
52498
|
+
const comparisonBaseRef = isDiffMode && diffInfo && !diffInfo.isCurrentChanges ? diffInfo.baseSha ? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseSha) : diffInfo.diffBaseRef ?? await resolveMergeBaseRef(resolvedDirectory, diffInfo.baseBranch) : null;
|
|
52499
|
+
const baselineRef = scope === "changed" ? comparisonBaseRef : null;
|
|
52500
|
+
const linesBaseRef = diffInfo?.isCurrentChanges ? "HEAD" : comparisonBaseRef;
|
|
52501
|
+
const changedLineRanges = scope === "lines" && diffInfo !== null && (diffInfo.isCurrentChanges || linesBaseRef !== null) && diffInfo !== null ? await getChangedLineRanges({
|
|
52502
|
+
directory: resolvedDirectory,
|
|
52503
|
+
baseRef: linesBaseRef ?? void 0,
|
|
52504
|
+
files: [...diffInfo.changedFiles]
|
|
52505
|
+
}) : null;
|
|
52506
|
+
if (scope === "lines" && changedLineRanges === null && !isQuiet) {
|
|
52507
|
+
cliLogger.warn("Could not determine changed lines (no base ref or git diff failed); reporting all issues in changed files.");
|
|
52508
|
+
cliLogger.break();
|
|
52509
|
+
}
|
|
52281
52510
|
setJsonReportMode(baselineRef ? "baseline" : isDiffMode ? "diff" : "full");
|
|
52282
52511
|
if (isDiffMode && diffInfo && !isQuiet) {
|
|
52283
52512
|
if (diffInfo.isCurrentChanges) cliLogger.log("Scanning uncommitted changes");
|
|
@@ -52314,6 +52543,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
52314
52543
|
configOverride: userConfig,
|
|
52315
52544
|
suppressRendering: isMultiProject,
|
|
52316
52545
|
baseline: baselineRef ? { ref: baselineRef } : void 0,
|
|
52546
|
+
changedLineRanges: scope === "lines" && changedLineRanges !== null ? resolveProjectChangedLineRanges(resolvedDirectory, projectDirectory, changedLineRanges) : void 0,
|
|
52317
52547
|
supplyChainManifestChanged
|
|
52318
52548
|
});
|
|
52319
52549
|
allDiagnostics.push(...scanResult.diagnostics);
|
|
@@ -52339,7 +52569,7 @@ const inspectAction = async (directory, flags) => {
|
|
|
52339
52569
|
completedScans,
|
|
52340
52570
|
mode: baselineRef ? "baseline" : isDiffMode ? "diff" : "full",
|
|
52341
52571
|
diff: isDiffMode ? diffInfo : null,
|
|
52342
|
-
baselineIntended:
|
|
52572
|
+
baselineIntended: scope === "changed" && diffInfo !== null && !diffInfo.isCurrentChanges,
|
|
52343
52573
|
isJsonMode,
|
|
52344
52574
|
isScoreOnly,
|
|
52345
52575
|
flags,
|
|
@@ -53146,11 +53376,13 @@ const ROOT_FLAG_SPEC = {
|
|
|
53146
53376
|
"--yes"
|
|
53147
53377
|
]),
|
|
53148
53378
|
longOptionsWithRequiredValues: new Set([
|
|
53379
|
+
"--base",
|
|
53149
53380
|
"--category",
|
|
53150
53381
|
"--changed-files-from",
|
|
53151
53382
|
"--blocking",
|
|
53152
53383
|
"--fail-on",
|
|
53153
|
-
"--project"
|
|
53384
|
+
"--project",
|
|
53385
|
+
"--scope"
|
|
53154
53386
|
]),
|
|
53155
53387
|
longOptionsWithOptionalValues: new Set(["--diff"]),
|
|
53156
53388
|
shortOptionsWithoutValues: new Set([
|
|
@@ -53333,7 +53565,7 @@ ${highlighter.dim("Learn more:")}
|
|
|
53333
53565
|
${highlighter.info(CANONICAL_GITHUB_URL)}
|
|
53334
53566
|
`;
|
|
53335
53567
|
const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
|
|
53336
|
-
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("--
|
|
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 project (comma-separated for multiple)").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);
|
|
53337
53569
|
program.action(inspectAction);
|
|
53338
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 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));
|
|
53339
53571
|
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);
|
|
@@ -53376,4 +53608,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
53376
53608
|
export {};
|
|
53377
53609
|
|
|
53378
53610
|
//# sourceMappingURL=cli.js.map
|
|
53379
|
-
//# debugId=
|
|
53611
|
+
//# debugId=60598d2a-66c7-5091-a013-028926866fbd
|
package/dist/index.d.ts
CHANGED
|
@@ -8989,6 +8989,20 @@ declare namespace Annotations {
|
|
|
8989
8989
|
* - `"none"` — never block; the scan is advisory (still reports + scores).
|
|
8990
8990
|
*/
|
|
8991
8991
|
type BlockingLevel = "error" | "warning" | "none";
|
|
8992
|
+
/**
|
|
8993
|
+
* How much of the project a scan looks at and reports on — the single knob the
|
|
8994
|
+
* CLI `--scope` flag, the GitHub Action `scope` input, and this config field
|
|
8995
|
+
* all share. Ordered widest to narrowest:
|
|
8996
|
+
*
|
|
8997
|
+
* - `"full"` — whole project, every issue (the default). Whole-project checks
|
|
8998
|
+
* (dead-code, environment, supply-chain) run only at this scope.
|
|
8999
|
+
* - `"files"` — only the files changed vs the base, with ALL issues in them
|
|
9000
|
+
* (no compare-to-main). What `--staged` and an uncommitted `--diff` do today.
|
|
9001
|
+
* - `"changed"` — only issues the change INTRODUCED vs the base (the baseline
|
|
9002
|
+
* delta). What `--diff <base>` and the action's `scope: changed` do today.
|
|
9003
|
+
* - `"lines"` — only issues on the lines the change actually touched.
|
|
9004
|
+
*/
|
|
9005
|
+
type ScopeValue = "full" | "files" | "changed" | "lines";
|
|
8992
9006
|
interface ReactDoctorIgnoreOverride {
|
|
8993
9007
|
/** Glob patterns the override applies to (e.g. `["src/legacy/**"]`). */
|
|
8994
9008
|
files: string[];
|
|
@@ -9102,11 +9116,11 @@ interface SurfaceControls {
|
|
|
9102
9116
|
*
|
|
9103
9117
|
* Mirrors how Socket Firewall's free tier (`sfw`) works: each direct
|
|
9104
9118
|
* dependency's PURL is looked up against Socket's keyless
|
|
9105
|
-
* `firewall-api.socket.dev/purl/<purl>` endpoint, which returns
|
|
9106
|
-
*
|
|
9107
|
-
*
|
|
9108
|
-
*
|
|
9109
|
-
* finding does.
|
|
9119
|
+
* `firewall-api.socket.dev/purl/<purl>` endpoint, which returns per-axis
|
|
9120
|
+
* scores (0–100 once normalized). A dependency whose worst security axis
|
|
9121
|
+
* (supply chain or vulnerability) scores below `minScore` produces a
|
|
9122
|
+
* diagnostic; at the default `severity: "error"` it fails the scan
|
|
9123
|
+
* (non-zero CI exit), the same way an error-severity lint finding does.
|
|
9110
9124
|
*/
|
|
9111
9125
|
interface SupplyChainConfig {
|
|
9112
9126
|
/**
|
|
@@ -9118,8 +9132,9 @@ interface SupplyChainConfig {
|
|
|
9118
9132
|
enabled?: boolean;
|
|
9119
9133
|
/**
|
|
9120
9134
|
* Minimum acceptable Socket score on a 0–100 scale. A direct dependency
|
|
9121
|
-
* whose Socket
|
|
9122
|
-
*
|
|
9135
|
+
* whose worst Socket *security* axis — supply chain or vulnerability — is
|
|
9136
|
+
* below this is flagged; the quality / maintenance / license axes never
|
|
9137
|
+
* gate. Default: `50`. Values outside `0..100` are clamped.
|
|
9123
9138
|
*/
|
|
9124
9139
|
minScore?: number;
|
|
9125
9140
|
/**
|
|
@@ -9166,6 +9181,23 @@ interface ReactDoctorConfig {
|
|
|
9166
9181
|
* `rules` / `categories`) still shows even when `warnings` is `false`.
|
|
9167
9182
|
*/
|
|
9168
9183
|
warnings?: boolean;
|
|
9184
|
+
/**
|
|
9185
|
+
* Scan scope. Defaults to `"full"`. See `ScopeValue` for the four values.
|
|
9186
|
+
* The CLI `--scope` flag and the GitHub Action `scope` input set the same
|
|
9187
|
+
* thing; flags win over config.
|
|
9188
|
+
*/
|
|
9189
|
+
scope?: ScopeValue;
|
|
9190
|
+
/**
|
|
9191
|
+
* Base git ref the `"files"` / `"changed"` / `"lines"` scopes compare
|
|
9192
|
+
* against. Auto-detected from the default branch / merge-base when unset.
|
|
9193
|
+
*/
|
|
9194
|
+
base?: string;
|
|
9195
|
+
/**
|
|
9196
|
+
* @deprecated Use `scope` instead. Still honored as an alias when `scope`
|
|
9197
|
+
* is unset: `diff: "<base>"` / `diff: true` → `scope: "changed"`,
|
|
9198
|
+
* `diff: false` → `scope: "full"`. Using it emits a one-time deprecation
|
|
9199
|
+
* warning. Prefer `scope` (+ `base`).
|
|
9200
|
+
*/
|
|
9169
9201
|
diff?: boolean | string;
|
|
9170
9202
|
/**
|
|
9171
9203
|
* Severity threshold at which the scan blocks CI (exits non-zero).
|
|
@@ -9969,8 +10001,15 @@ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#e
|
|
|
9969
10001
|
* `GitBaseBranchMissing`) as clean user errors instead of crashes.
|
|
9970
10002
|
*/
|
|
9971
10003
|
declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => Promise<DiffInfo | null>;
|
|
9972
|
-
declare const filterSourceFiles: (filePaths: string[]) => string[];
|
|
9973
|
-
|
|
10004
|
+
declare const filterSourceFiles: (filePaths: string[]) => string[];
|
|
10005
|
+
/**
|
|
10006
|
+
* Programmatic façade over `Git.changedLineRanges` (the `lines` scope). Diffs
|
|
10007
|
+
* `files` with `--unified=0` against `baseRef` (or the index when `cached`),
|
|
10008
|
+
* returning per-file changed line ranges relative to `directory`. Returns
|
|
10009
|
+
* `null` when the ranges can't be computed (git unavailable / unsafe ref /
|
|
10010
|
+
* non-zero exit) so the caller degrades to file-level scope; an empty array
|
|
10011
|
+
* means git succeeded but the files added no lines.
|
|
10012
|
+
*/
|
|
9974
10013
|
//#endregion
|
|
9975
10014
|
//#region src/summarize-diagnostics.d.ts
|
|
9976
10015
|
declare const summarizeDiagnostics: (diagnostics: Diagnostic[], worstScore?: number | null, worstScoreLabel?: string | null) => JsonReportSummary; //#endregion
|
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]="0090e471-3c19-51d5-8774-cc4c6a98e591")}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";
|
|
@@ -37034,6 +37034,42 @@ var Files = class Files extends Service()("react-doctor/Files") {
|
|
|
37034
37034
|
}));
|
|
37035
37035
|
};
|
|
37036
37036
|
};
|
|
37037
|
+
const HUNK_HEADER_PATTERN = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
|
|
37038
|
+
/**
|
|
37039
|
+
* Parses a `git diff --unified=0` patch into the inclusive 1-based line ranges
|
|
37040
|
+
* each file added or modified on the new side. Files are keyed by the path in
|
|
37041
|
+
* the `+++ b/<path>` header (with `--relative`, relative to the diff's cwd).
|
|
37042
|
+
* Added/renamed/modified files appear; pure deletions (`+++ /dev/null`) are
|
|
37043
|
+
* skipped because they have no new-side line to report on.
|
|
37044
|
+
*/
|
|
37045
|
+
const parseChangedLineRanges = (patch) => {
|
|
37046
|
+
const rangesByFile = /* @__PURE__ */ new Map();
|
|
37047
|
+
let currentRanges = null;
|
|
37048
|
+
for (const line of patch.split("\n")) {
|
|
37049
|
+
if (line.startsWith("+++ ")) {
|
|
37050
|
+
const target = line.slice(4).trim();
|
|
37051
|
+
if (target === "/dev/null") {
|
|
37052
|
+
currentRanges = null;
|
|
37053
|
+
continue;
|
|
37054
|
+
}
|
|
37055
|
+
const file = target.startsWith("b/") ? target.slice(2) : target;
|
|
37056
|
+
currentRanges = rangesByFile.get(file) ?? [];
|
|
37057
|
+
rangesByFile.set(file, currentRanges);
|
|
37058
|
+
continue;
|
|
37059
|
+
}
|
|
37060
|
+
if (currentRanges === null) continue;
|
|
37061
|
+
const hunk = HUNK_HEADER_PATTERN.exec(line);
|
|
37062
|
+
if (hunk === null) continue;
|
|
37063
|
+
const start = Number(hunk[1]);
|
|
37064
|
+
const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
|
|
37065
|
+
if (lineCount <= 0) continue;
|
|
37066
|
+
currentRanges.push([start, start + lineCount - 1]);
|
|
37067
|
+
}
|
|
37068
|
+
return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
|
|
37069
|
+
file,
|
|
37070
|
+
ranges
|
|
37071
|
+
}));
|
|
37072
|
+
};
|
|
37037
37073
|
const trimOrNull = (value) => {
|
|
37038
37074
|
const trimmed = value.trim();
|
|
37039
37075
|
return trimmed.length === 0 ? null : trimmed;
|
|
@@ -37399,6 +37435,22 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
37399
37435
|
status: result.status,
|
|
37400
37436
|
stdout: result.stdout
|
|
37401
37437
|
};
|
|
37438
|
+
}),
|
|
37439
|
+
changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
|
|
37440
|
+
if (files.length === 0) return [];
|
|
37441
|
+
if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
|
|
37442
|
+
const result = yield* runGit(directory, [
|
|
37443
|
+
"diff",
|
|
37444
|
+
"--unified=0",
|
|
37445
|
+
"--diff-filter=ACMR",
|
|
37446
|
+
"--relative",
|
|
37447
|
+
...cached ? ["--cached"] : [],
|
|
37448
|
+
...baseRef !== void 0 ? [baseRef] : [],
|
|
37449
|
+
"--",
|
|
37450
|
+
...files
|
|
37451
|
+
]);
|
|
37452
|
+
if (result.status !== 0) return null;
|
|
37453
|
+
return parseChangedLineRanges(result.stdout);
|
|
37402
37454
|
})
|
|
37403
37455
|
});
|
|
37404
37456
|
})).pipe(provide$2(layer$2.pipe(provide$2(mergeAll$1(layer$1, layer)))));
|
|
@@ -37429,7 +37481,8 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
37429
37481
|
status: matches.length === 0 ? 1 : 0,
|
|
37430
37482
|
stdout
|
|
37431
37483
|
};
|
|
37432
|
-
})
|
|
37484
|
+
}),
|
|
37485
|
+
changedLineRanges: () => succeed$2(snapshot.changedLineRanges ?? [])
|
|
37433
37486
|
}));
|
|
37434
37487
|
};
|
|
37435
37488
|
const estimateArgsLength = (args) => args.reduce((total, argument) => total + argument.length + 1, 0);
|
|
@@ -39208,25 +39261,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
|
|
|
39208
39261
|
const SCORE_AXES = [
|
|
39209
39262
|
{
|
|
39210
39263
|
key: "supplyChain",
|
|
39211
|
-
label: "supply chain"
|
|
39264
|
+
label: "supply chain",
|
|
39265
|
+
gates: true
|
|
39212
39266
|
},
|
|
39213
39267
|
{
|
|
39214
39268
|
key: "vulnerability",
|
|
39215
|
-
label: "vulnerability"
|
|
39269
|
+
label: "vulnerability",
|
|
39270
|
+
gates: true
|
|
39216
39271
|
},
|
|
39217
39272
|
{
|
|
39218
39273
|
key: "maintenance",
|
|
39219
|
-
label: "maintenance"
|
|
39274
|
+
label: "maintenance",
|
|
39275
|
+
gates: false
|
|
39220
39276
|
},
|
|
39221
39277
|
{
|
|
39222
39278
|
key: "quality",
|
|
39223
|
-
label: "quality"
|
|
39279
|
+
label: "quality",
|
|
39280
|
+
gates: false
|
|
39224
39281
|
},
|
|
39225
39282
|
{
|
|
39226
39283
|
key: "license",
|
|
39227
|
-
label: "license"
|
|
39284
|
+
label: "license",
|
|
39285
|
+
gates: false
|
|
39228
39286
|
}
|
|
39229
39287
|
];
|
|
39288
|
+
const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
|
|
39289
|
+
const worstGatedAxis = (score) => {
|
|
39290
|
+
let worst = GATED_AXES[0];
|
|
39291
|
+
for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
|
|
39292
|
+
return worst;
|
|
39293
|
+
};
|
|
39230
39294
|
const clampScore = (value) => {
|
|
39231
39295
|
if (!Number.isFinite(value)) return 50;
|
|
39232
39296
|
return Math.min(Math.max(value, 0), 100);
|
|
@@ -39342,15 +39406,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
|
|
|
39342
39406
|
"socket.purl": toPurl(dependency)
|
|
39343
39407
|
} }));
|
|
39344
39408
|
const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
|
|
39345
|
-
const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
39346
|
-
const overall = toHundred(score.overall);
|
|
39409
|
+
const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
|
|
39347
39410
|
const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
|
|
39348
39411
|
return {
|
|
39349
39412
|
filePath: "package.json",
|
|
39350
39413
|
plugin: SUPPLY_CHAIN_PLUGIN,
|
|
39351
39414
|
rule: SUPPLY_CHAIN_RULE,
|
|
39352
39415
|
severity: options.severity,
|
|
39353
|
-
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket
|
|
39416
|
+
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
|
|
39354
39417
|
help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
|
|
39355
39418
|
url: packagePageUrl,
|
|
39356
39419
|
line: dependency.line,
|
|
@@ -39362,7 +39425,9 @@ const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
|
39362
39425
|
* Scores every direct dependency in the project's `package.json` against
|
|
39363
39426
|
* Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
|
|
39364
39427
|
* uses — no API key) and returns a diagnostic for each dependency whose
|
|
39365
|
-
* Socket
|
|
39428
|
+
* worst Socket *security* axis — supply chain or vulnerability — is below
|
|
39429
|
+
* the configured `minScore`. The quality / maintenance / license axes are
|
|
39430
|
+
* reported as context but never gate (see GATED_AXES).
|
|
39366
39431
|
*
|
|
39367
39432
|
* Lookups run with bounded concurrency via `Effect.forEach`. The check is
|
|
39368
39433
|
* total/fail-open: each per-package lookup already recovers to `null`
|
|
@@ -39380,8 +39445,9 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
39380
39445
|
for (let index = 0; index < dependencies.length; index += 1) {
|
|
39381
39446
|
const score = scores[index];
|
|
39382
39447
|
if (!score) continue;
|
|
39383
|
-
|
|
39384
|
-
|
|
39448
|
+
const worstAxis = worstGatedAxis(score);
|
|
39449
|
+
if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
|
|
39450
|
+
diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
|
|
39385
39451
|
}
|
|
39386
39452
|
return diagnostics;
|
|
39387
39453
|
});
|
|
@@ -39389,7 +39455,8 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
39389
39455
|
* `SupplyChain` scores the project's direct dependencies against Socket.dev's
|
|
39390
39456
|
* free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
|
|
39391
39457
|
* (`sfw`) performs — and streams a diagnostic for each dependency whose
|
|
39392
|
-
* Socket
|
|
39458
|
+
* worst Socket security axis (supply chain or vulnerability) falls below
|
|
39459
|
+
* the configured `supplyChain.minScore`.
|
|
39393
39460
|
*
|
|
39394
39461
|
* Runs by default (one network request per dependency); the orchestrator
|
|
39395
39462
|
* provides `layerOf([])` only when the user opts out via
|
|
@@ -40107,4 +40174,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
40107
40174
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
40108
40175
|
|
|
40109
40176
|
//# sourceMappingURL=index.js.map
|
|
40110
|
-
//# debugId=
|
|
40177
|
+
//# debugId=0090e471-3c19-51d5-8774-cc4c6a98e591
|
package/dist/lsp.js
CHANGED
|
@@ -37020,6 +37020,42 @@ var Files = class Files extends Service()("react-doctor/Files") {
|
|
|
37020
37020
|
}));
|
|
37021
37021
|
};
|
|
37022
37022
|
};
|
|
37023
|
+
const HUNK_HEADER_PATTERN = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
|
|
37024
|
+
/**
|
|
37025
|
+
* Parses a `git diff --unified=0` patch into the inclusive 1-based line ranges
|
|
37026
|
+
* each file added or modified on the new side. Files are keyed by the path in
|
|
37027
|
+
* the `+++ b/<path>` header (with `--relative`, relative to the diff's cwd).
|
|
37028
|
+
* Added/renamed/modified files appear; pure deletions (`+++ /dev/null`) are
|
|
37029
|
+
* skipped because they have no new-side line to report on.
|
|
37030
|
+
*/
|
|
37031
|
+
const parseChangedLineRanges = (patch) => {
|
|
37032
|
+
const rangesByFile = /* @__PURE__ */ new Map();
|
|
37033
|
+
let currentRanges = null;
|
|
37034
|
+
for (const line of patch.split("\n")) {
|
|
37035
|
+
if (line.startsWith("+++ ")) {
|
|
37036
|
+
const target = line.slice(4).trim();
|
|
37037
|
+
if (target === "/dev/null") {
|
|
37038
|
+
currentRanges = null;
|
|
37039
|
+
continue;
|
|
37040
|
+
}
|
|
37041
|
+
const file = target.startsWith("b/") ? target.slice(2) : target;
|
|
37042
|
+
currentRanges = rangesByFile.get(file) ?? [];
|
|
37043
|
+
rangesByFile.set(file, currentRanges);
|
|
37044
|
+
continue;
|
|
37045
|
+
}
|
|
37046
|
+
if (currentRanges === null) continue;
|
|
37047
|
+
const hunk = HUNK_HEADER_PATTERN.exec(line);
|
|
37048
|
+
if (hunk === null) continue;
|
|
37049
|
+
const start = Number(hunk[1]);
|
|
37050
|
+
const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
|
|
37051
|
+
if (lineCount <= 0) continue;
|
|
37052
|
+
currentRanges.push([start, start + lineCount - 1]);
|
|
37053
|
+
}
|
|
37054
|
+
return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
|
|
37055
|
+
file,
|
|
37056
|
+
ranges
|
|
37057
|
+
}));
|
|
37058
|
+
};
|
|
37023
37059
|
const trimOrNull = (value) => {
|
|
37024
37060
|
const trimmed = value.trim();
|
|
37025
37061
|
return trimmed.length === 0 ? null : trimmed;
|
|
@@ -37385,6 +37421,22 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
37385
37421
|
status: result.status,
|
|
37386
37422
|
stdout: result.stdout
|
|
37387
37423
|
};
|
|
37424
|
+
}),
|
|
37425
|
+
changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
|
|
37426
|
+
if (files.length === 0) return [];
|
|
37427
|
+
if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
|
|
37428
|
+
const result = yield* runGit(directory, [
|
|
37429
|
+
"diff",
|
|
37430
|
+
"--unified=0",
|
|
37431
|
+
"--diff-filter=ACMR",
|
|
37432
|
+
"--relative",
|
|
37433
|
+
...cached ? ["--cached"] : [],
|
|
37434
|
+
...baseRef !== void 0 ? [baseRef] : [],
|
|
37435
|
+
"--",
|
|
37436
|
+
...files
|
|
37437
|
+
]);
|
|
37438
|
+
if (result.status !== 0) return null;
|
|
37439
|
+
return parseChangedLineRanges(result.stdout);
|
|
37388
37440
|
})
|
|
37389
37441
|
});
|
|
37390
37442
|
})).pipe(provide$2(layer$2.pipe(provide$2(mergeAll$1(layer$1, layer)))));
|
|
@@ -37415,7 +37467,8 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
37415
37467
|
status: matches.length === 0 ? 1 : 0,
|
|
37416
37468
|
stdout
|
|
37417
37469
|
};
|
|
37418
|
-
})
|
|
37470
|
+
}),
|
|
37471
|
+
changedLineRanges: () => succeed$2(snapshot.changedLineRanges ?? [])
|
|
37419
37472
|
}));
|
|
37420
37473
|
};
|
|
37421
37474
|
const estimateArgsLength = (args) => args.reduce((total, argument) => total + argument.length + 1, 0);
|
|
@@ -39194,25 +39247,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
|
|
|
39194
39247
|
const SCORE_AXES = [
|
|
39195
39248
|
{
|
|
39196
39249
|
key: "supplyChain",
|
|
39197
|
-
label: "supply chain"
|
|
39250
|
+
label: "supply chain",
|
|
39251
|
+
gates: true
|
|
39198
39252
|
},
|
|
39199
39253
|
{
|
|
39200
39254
|
key: "vulnerability",
|
|
39201
|
-
label: "vulnerability"
|
|
39255
|
+
label: "vulnerability",
|
|
39256
|
+
gates: true
|
|
39202
39257
|
},
|
|
39203
39258
|
{
|
|
39204
39259
|
key: "maintenance",
|
|
39205
|
-
label: "maintenance"
|
|
39260
|
+
label: "maintenance",
|
|
39261
|
+
gates: false
|
|
39206
39262
|
},
|
|
39207
39263
|
{
|
|
39208
39264
|
key: "quality",
|
|
39209
|
-
label: "quality"
|
|
39265
|
+
label: "quality",
|
|
39266
|
+
gates: false
|
|
39210
39267
|
},
|
|
39211
39268
|
{
|
|
39212
39269
|
key: "license",
|
|
39213
|
-
label: "license"
|
|
39270
|
+
label: "license",
|
|
39271
|
+
gates: false
|
|
39214
39272
|
}
|
|
39215
39273
|
];
|
|
39274
|
+
const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
|
|
39275
|
+
const worstGatedAxis = (score) => {
|
|
39276
|
+
let worst = GATED_AXES[0];
|
|
39277
|
+
for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
|
|
39278
|
+
return worst;
|
|
39279
|
+
};
|
|
39216
39280
|
const clampScore = (value) => {
|
|
39217
39281
|
if (!Number.isFinite(value)) return 50;
|
|
39218
39282
|
return Math.min(Math.max(value, 0), 100);
|
|
@@ -39328,15 +39392,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
|
|
|
39328
39392
|
"socket.purl": toPurl(dependency)
|
|
39329
39393
|
} }));
|
|
39330
39394
|
const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
|
|
39331
|
-
const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
39332
|
-
const overall = toHundred(score.overall);
|
|
39395
|
+
const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
|
|
39333
39396
|
const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
|
|
39334
39397
|
return {
|
|
39335
39398
|
filePath: "package.json",
|
|
39336
39399
|
plugin: SUPPLY_CHAIN_PLUGIN,
|
|
39337
39400
|
rule: SUPPLY_CHAIN_RULE,
|
|
39338
39401
|
severity: options.severity,
|
|
39339
|
-
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket
|
|
39402
|
+
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
|
|
39340
39403
|
help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
|
|
39341
39404
|
url: packagePageUrl,
|
|
39342
39405
|
line: dependency.line,
|
|
@@ -39348,7 +39411,9 @@ const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
|
39348
39411
|
* Scores every direct dependency in the project's `package.json` against
|
|
39349
39412
|
* Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
|
|
39350
39413
|
* uses — no API key) and returns a diagnostic for each dependency whose
|
|
39351
|
-
* Socket
|
|
39414
|
+
* worst Socket *security* axis — supply chain or vulnerability — is below
|
|
39415
|
+
* the configured `minScore`. The quality / maintenance / license axes are
|
|
39416
|
+
* reported as context but never gate (see GATED_AXES).
|
|
39352
39417
|
*
|
|
39353
39418
|
* Lookups run with bounded concurrency via `Effect.forEach`. The check is
|
|
39354
39419
|
* total/fail-open: each per-package lookup already recovers to `null`
|
|
@@ -39366,8 +39431,9 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
39366
39431
|
for (let index = 0; index < dependencies.length; index += 1) {
|
|
39367
39432
|
const score = scores[index];
|
|
39368
39433
|
if (!score) continue;
|
|
39369
|
-
|
|
39370
|
-
|
|
39434
|
+
const worstAxis = worstGatedAxis(score);
|
|
39435
|
+
if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
|
|
39436
|
+
diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
|
|
39371
39437
|
}
|
|
39372
39438
|
return diagnostics;
|
|
39373
39439
|
});
|
|
@@ -39375,7 +39441,8 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
39375
39441
|
* `SupplyChain` scores the project's direct dependencies against Socket.dev's
|
|
39376
39442
|
* free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
|
|
39377
39443
|
* (`sfw`) performs — and streams a diagnostic for each dependency whose
|
|
39378
|
-
* Socket
|
|
39444
|
+
* worst Socket security axis (supply chain or vulnerability) falls below
|
|
39445
|
+
* the configured `supplyChain.minScore`.
|
|
39379
39446
|
*
|
|
39380
39447
|
* Runs by default (one network request per dependency); the orchestrator
|
|
39381
39448
|
* provides `layerOf([])` only when the user opts out via
|
|
@@ -41985,5 +42052,5 @@ const startLanguageServer = () => {
|
|
|
41985
42052
|
};
|
|
41986
42053
|
//#endregion
|
|
41987
42054
|
export { startLanguageServer };
|
|
41988
|
-
!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]="
|
|
41989
|
-
//# debugId=
|
|
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]="3f2681f1-5caf-5b77-a639-8334ae51b66f")}catch(e){}}();
|
|
42056
|
+
//# debugId=3f2681f1-5caf-5b77-a639-8334ae51b66f
|
|
@@ -10,13 +10,13 @@ Scans React codebases for security, performance, correctness, and architecture i
|
|
|
10
10
|
|
|
11
11
|
## After making React code changes:
|
|
12
12
|
|
|
13
|
-
Run `npx react-doctor@latest --verbose --
|
|
13
|
+
Run `npx react-doctor@latest --verbose --scope changed` and check the score did not regress.
|
|
14
14
|
|
|
15
15
|
If the score dropped, fix the regressions before committing.
|
|
16
16
|
|
|
17
17
|
## For general cleanup or code improvement:
|
|
18
18
|
|
|
19
|
-
Run `npx react-doctor@latest --verbose` (
|
|
19
|
+
Run `npx react-doctor@latest --verbose` (the default `--scope full`) to scan the full codebase. Fix issues by severity — errors first, then warnings.
|
|
20
20
|
|
|
21
21
|
## /doctor — full local triage workflow
|
|
22
22
|
|
|
@@ -39,12 +39,13 @@ When the user wants to understand a rule, disagrees with one, or wants to disabl
|
|
|
39
39
|
## Command
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
npx react-doctor@latest --verbose --
|
|
42
|
+
npx react-doctor@latest --verbose --scope changed
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
| Flag
|
|
46
|
-
|
|
|
47
|
-
| `.`
|
|
48
|
-
| `--verbose`
|
|
49
|
-
| `--
|
|
50
|
-
| `--
|
|
45
|
+
| Flag | Purpose |
|
|
46
|
+
| ----------------- | ---------------------------------------------------------------- |
|
|
47
|
+
| `.` | Scan current directory |
|
|
48
|
+
| `--verbose` | Show affected files and line numbers per rule |
|
|
49
|
+
| `--scope changed` | Only report issues introduced vs the base branch (default: full) |
|
|
50
|
+
| `--scope lines` | Only report issues on the changed lines |
|
|
51
|
+
| `--score` | Output only the numeric score |
|
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.c4f0e60",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -64,7 +64,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.c4f0e60"
|
|
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/api": "0.5.1",
|
|
76
75
|
"@react-doctor/core": "0.5.1",
|
|
76
|
+
"@react-doctor/api": "0.5.1",
|
|
77
77
|
"@react-doctor/language-server": "0.5.1"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|