react-doctor 0.5.1-dev.94f9f4f → 0.5.1-dev.a48fb06
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 +415 -132
- 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 +5 -5
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.a48fb06",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"agent-install": "0.0.5",
|
|
55
55
|
"conf": "^15.1.0",
|
|
56
56
|
"confbox": "^0.2.4",
|
|
57
|
-
"deslop-js": "^0.0.
|
|
57
|
+
"deslop-js": "^0.0.23",
|
|
58
58
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
59
59
|
"jiti": "^2.7.0",
|
|
60
60
|
"magicast": "^0.5.3",
|
|
@@ -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.a48fb06"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"@xterm/headless": "^6.0.0",
|
|
73
73
|
"commander": "^14.0.3",
|
|
74
74
|
"ora": "^9.4.0",
|
|
75
|
-
"@react-doctor/core": "0.5.1",
|
|
76
75
|
"@react-doctor/api": "0.5.1",
|
|
77
|
-
"@react-doctor/language-server": "0.5.1"
|
|
76
|
+
"@react-doctor/language-server": "0.5.1",
|
|
77
|
+
"@react-doctor/core": "0.5.1"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": "^20.19.0 || >=22.13.0"
|