react-doctor 0.5.1-dev.486c68f → 0.5.1-dev.7c88165
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 +582 -195
- package/dist/index.d.ts +125 -48
- package/dist/index.js +187 -21
- package/dist/lsp.js +89 -16
- package/dist/skills/react-doctor/SKILL.md +10 -9
- package/package.json +6 -6
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).
|
|
@@ -9205,6 +9237,22 @@ interface ReactDoctorConfig {
|
|
|
9205
9237
|
* requested directory).
|
|
9206
9238
|
*/
|
|
9207
9239
|
rootDir?: string;
|
|
9240
|
+
/**
|
|
9241
|
+
* Projects to scan and score separately — the config-file equivalent of
|
|
9242
|
+
* the CLI `--project` flag, for repos that always want per-module scoring
|
|
9243
|
+
* (e.g. a monorepo dashboard tracking each module's score daily) without
|
|
9244
|
+
* passing the flag on every run.
|
|
9245
|
+
*
|
|
9246
|
+
* Entries resolve exactly like `--project` values: workspace package
|
|
9247
|
+
* names (or directory basenames) first, then directory paths relative to
|
|
9248
|
+
* the scanned root. `"*"` selects every discovered workspace project.
|
|
9249
|
+
* Invalid entries fail the run with the same error as the flag.
|
|
9250
|
+
*
|
|
9251
|
+
* Precedence: an explicit `--project` flag overrides this list. Only the
|
|
9252
|
+
* config at the invocation root is consulted — `projects` inside a
|
|
9253
|
+
* module's own config is ignored (modules can't redirect the scan).
|
|
9254
|
+
*/
|
|
9255
|
+
projects?: string[];
|
|
9208
9256
|
textComponents?: string[];
|
|
9209
9257
|
/**
|
|
9210
9258
|
* Names of components that safely route string-only children through a
|
|
@@ -9569,12 +9617,55 @@ interface DiagnoseResult {
|
|
|
9569
9617
|
elapsedMilliseconds: number;
|
|
9570
9618
|
}
|
|
9571
9619
|
/**
|
|
9572
|
-
* A single project to scan as part of a `
|
|
9620
|
+
* A single project to scan as part of a `diagnose({ projects })` batch.
|
|
9573
9621
|
* Scan options (`deadCode`, `lint`, etc.) are flat on the entry and
|
|
9574
9622
|
* layer on top of the global defaults — omitted fields fall through.
|
|
9575
|
-
* `config` is a full `ReactDoctorConfig` override that replaces the
|
|
9576
|
-
* on-disk `doctor.config.*` for this project's scan.
|
|
9577
9623
|
*/
|
|
9624
|
+
interface ProjectDefinition extends DiagnoseOptions {
|
|
9625
|
+
directory: string;
|
|
9626
|
+
/**
|
|
9627
|
+
* Per-project config overrides, layered additively (see
|
|
9628
|
+
* `mergeReactDoctorConfigs`) on top of the project's on-disk
|
|
9629
|
+
* `doctor.config.*` and the batch-level `DiagnoseProjectsInput.config`
|
|
9630
|
+
* — so disabling one rule here keeps every base rule intact.
|
|
9631
|
+
*/
|
|
9632
|
+
config?: ReactDoctorConfig;
|
|
9633
|
+
}
|
|
9634
|
+
interface ProjectResultOk extends DiagnoseResult {
|
|
9635
|
+
ok: true;
|
|
9636
|
+
directory: string;
|
|
9637
|
+
}
|
|
9638
|
+
interface ProjectResultError {
|
|
9639
|
+
ok: false;
|
|
9640
|
+
directory: string;
|
|
9641
|
+
error: Error;
|
|
9642
|
+
}
|
|
9643
|
+
type ProjectResult = ProjectResultOk | ProjectResultError;
|
|
9644
|
+
interface DiagnoseProjectsInput extends DiagnoseOptions {
|
|
9645
|
+
projects: ProjectDefinition[];
|
|
9646
|
+
/**
|
|
9647
|
+
* Config overrides applied to every project in the batch, layered
|
|
9648
|
+
* additively (see `mergeReactDoctorConfigs`) between each project's
|
|
9649
|
+
* on-disk `doctor.config.*` and its `ProjectDefinition.config` — one
|
|
9650
|
+
* base rule set for the batch, overridden per project only where needed.
|
|
9651
|
+
*/
|
|
9652
|
+
config?: ReactDoctorConfig;
|
|
9653
|
+
/**
|
|
9654
|
+
* Maximum number of projects to scan concurrently. Defaults to
|
|
9655
|
+
* `DEFAULT_PROJECT_SCAN_CONCURRENCY` (4) — each project scan fans out
|
|
9656
|
+
* its own lint workers, so the batch is bounded rather than fully
|
|
9657
|
+
* parallel. Set to `1` for sequential execution. Values below 1 are
|
|
9658
|
+
* clamped to 1.
|
|
9659
|
+
*/
|
|
9660
|
+
concurrency?: number;
|
|
9661
|
+
}
|
|
9662
|
+
interface DiagnoseProjectsResult {
|
|
9663
|
+
projects: ProjectResult[];
|
|
9664
|
+
diagnostics: Diagnostic[];
|
|
9665
|
+
score: ScoreResult | null;
|
|
9666
|
+
elapsedMilliseconds: number;
|
|
9667
|
+
} //#endregion
|
|
9668
|
+
//#region src/types/handle-error.d.ts
|
|
9578
9669
|
//#endregion
|
|
9579
9670
|
//#region src/types/inspect.d.ts
|
|
9580
9671
|
interface InspectResult {
|
|
@@ -9969,8 +10060,15 @@ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#e
|
|
|
9969
10060
|
* `GitBaseBranchMissing`) as clean user errors instead of crashes.
|
|
9970
10061
|
*/
|
|
9971
10062
|
declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => Promise<DiffInfo | null>;
|
|
9972
|
-
declare const filterSourceFiles: (filePaths: string[]) => string[];
|
|
9973
|
-
|
|
10063
|
+
declare const filterSourceFiles: (filePaths: string[]) => string[];
|
|
10064
|
+
/**
|
|
10065
|
+
* Programmatic façade over `Git.changedLineRanges` (the `lines` scope). Diffs
|
|
10066
|
+
* `files` with `--unified=0` against `baseRef` (or the index when `cached`),
|
|
10067
|
+
* returning per-file changed line ranges relative to `directory`. Returns
|
|
10068
|
+
* `null` when the ranges can't be computed (git unavailable / unsafe ref /
|
|
10069
|
+
* non-zero exit) so the caller degrades to file-level scope; an empty array
|
|
10070
|
+
* means git succeeded but the files added no lines.
|
|
10071
|
+
*/
|
|
9974
10072
|
//#endregion
|
|
9975
10073
|
//#region src/summarize-diagnostics.d.ts
|
|
9976
10074
|
declare const summarizeDiagnostics: (diagnostics: Diagnostic[], worstScore?: number | null, worstScoreLabel?: string | null) => JsonReportSummary; //#endregion
|
|
@@ -9988,41 +10086,20 @@ declare const defineConfig: (config: ReactDoctorConfig) => ReactDoctorConfig; //
|
|
|
9988
10086
|
//#endregion
|
|
9989
10087
|
//#region ../api/dist/index.d.ts
|
|
9990
10088
|
//#region src/diagnose.d.ts
|
|
9991
|
-
|
|
9992
|
-
/**
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
* ```ts
|
|
10006
|
-
* const result = await diagnoseProjects({
|
|
10007
|
-
* projects: [
|
|
10008
|
-
* { directory: "packages/app" },
|
|
10009
|
-
* { directory: "packages/shared", deadCode: false },
|
|
10010
|
-
* { directory: "packages/admin", config: {
|
|
10011
|
-
* rules: { "react-doctor/no-array-index-as-key": "off" },
|
|
10012
|
-
* }},
|
|
10013
|
-
* ],
|
|
10014
|
-
* concurrency: 4,
|
|
10015
|
-
* });
|
|
10016
|
-
*
|
|
10017
|
-
* for (const project of result.projects) {
|
|
10018
|
-
* if (project.ok) {
|
|
10019
|
-
* console.log(project.directory, project.score);
|
|
10020
|
-
* } else {
|
|
10021
|
-
* console.error(project.directory, project.error);
|
|
10022
|
-
* }
|
|
10023
|
-
* }
|
|
10024
|
-
* ```
|
|
10025
|
-
*/
|
|
10089
|
+
interface Diagnose {
|
|
10090
|
+
/** Scan a single project directory and return diagnostics + score. */
|
|
10091
|
+
(directory: string, options?: DiagnoseOptions): Promise<DiagnoseResult>;
|
|
10092
|
+
/**
|
|
10093
|
+
* Scan multiple projects in parallel — each through the same pipeline as
|
|
10094
|
+
* the single-directory form — and return per-project results plus an
|
|
10095
|
+
* aggregate worst-of score. A failing project (e.g. no `package.json`)
|
|
10096
|
+
* comes back with `ok: false` instead of aborting the batch. Per-project
|
|
10097
|
+
* `config` layers on the batch `config`, which layers on each project's
|
|
10098
|
+
* on-disk config (see `mergeReactDoctorConfigs`).
|
|
10099
|
+
*/
|
|
10100
|
+
(input: DiagnoseProjectsInput): Promise<DiagnoseProjectsResult>;
|
|
10101
|
+
}
|
|
10102
|
+
declare const diagnose: Diagnose; //#endregion
|
|
10026
10103
|
//#endregion
|
|
10027
10104
|
//#region src/index.d.ts
|
|
10028
10105
|
declare const clearCaches: () => void;
|
|
@@ -10033,5 +10110,5 @@ interface ToJsonReportOptions {
|
|
|
10033
10110
|
}
|
|
10034
10111
|
declare const toJsonReport: (result: DiagnoseResult, options: ToJsonReportOptions) => JsonReport;
|
|
10035
10112
|
//#endregion
|
|
10036
|
-
export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
10113
|
+
export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseProjectsInput, type DiagnoseProjectsResult, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectDefinition, type ProjectInfo, ProjectNotFoundError, type ProjectResult, type ProjectResultError, type ProjectResultOk, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
10037
10114
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d789108a-ddf2-5b61-a479-4c797dba74cb")}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);
|
|
@@ -38422,6 +38475,7 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
|
|
|
38422
38475
|
};
|
|
38423
38476
|
const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
|
|
38424
38477
|
const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
38478
|
+
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
38425
38479
|
const REACT_COMPILER_MESSAGE = "This component misses React Compiler's automatic memoization & re-renders more than it should. Rewrite the flagged code so the compiler can optimize it.";
|
|
38426
38480
|
const PLUGIN_CATEGORY_MAP = {
|
|
38427
38481
|
react: "Bugs",
|
|
@@ -38449,7 +38503,10 @@ const getRuleRecommendation = (ruleName, project) => {
|
|
|
38449
38503
|
};
|
|
38450
38504
|
const getRuleCategory = (ruleName) => reactDoctorPlugin.rules[ruleName]?.category;
|
|
38451
38505
|
const getRuleTitle = (ruleName) => reactDoctorPlugin.rules[ruleName]?.title;
|
|
38452
|
-
const resolveDiagnosticTitle = (plugin, rule) =>
|
|
38506
|
+
const resolveDiagnosticTitle = (plugin, rule) => {
|
|
38507
|
+
if (plugin !== "react-hooks-js") return getRuleTitle(rule);
|
|
38508
|
+
return rule === "todo" ? REACT_COMPILER_TODO_TITLE : REACT_COMPILER_TITLE;
|
|
38509
|
+
};
|
|
38453
38510
|
const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
|
|
38454
38511
|
const cleaned = resolveCleanedDiagnostic(typeof message === "string" ? message : "", typeof help === "string" ? help : "", plugin, rule, project);
|
|
38455
38512
|
return {
|
|
@@ -39208,25 +39265,36 @@ const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
|
|
|
39208
39265
|
const SCORE_AXES = [
|
|
39209
39266
|
{
|
|
39210
39267
|
key: "supplyChain",
|
|
39211
|
-
label: "supply chain"
|
|
39268
|
+
label: "supply chain",
|
|
39269
|
+
gates: true
|
|
39212
39270
|
},
|
|
39213
39271
|
{
|
|
39214
39272
|
key: "vulnerability",
|
|
39215
|
-
label: "vulnerability"
|
|
39273
|
+
label: "vulnerability",
|
|
39274
|
+
gates: true
|
|
39216
39275
|
},
|
|
39217
39276
|
{
|
|
39218
39277
|
key: "maintenance",
|
|
39219
|
-
label: "maintenance"
|
|
39278
|
+
label: "maintenance",
|
|
39279
|
+
gates: false
|
|
39220
39280
|
},
|
|
39221
39281
|
{
|
|
39222
39282
|
key: "quality",
|
|
39223
|
-
label: "quality"
|
|
39283
|
+
label: "quality",
|
|
39284
|
+
gates: false
|
|
39224
39285
|
},
|
|
39225
39286
|
{
|
|
39226
39287
|
key: "license",
|
|
39227
|
-
label: "license"
|
|
39288
|
+
label: "license",
|
|
39289
|
+
gates: false
|
|
39228
39290
|
}
|
|
39229
39291
|
];
|
|
39292
|
+
const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
|
|
39293
|
+
const worstGatedAxis = (score) => {
|
|
39294
|
+
let worst = GATED_AXES[0];
|
|
39295
|
+
for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
|
|
39296
|
+
return worst;
|
|
39297
|
+
};
|
|
39230
39298
|
const clampScore = (value) => {
|
|
39231
39299
|
if (!Number.isFinite(value)) return 50;
|
|
39232
39300
|
return Math.min(Math.max(value, 0), 100);
|
|
@@ -39342,15 +39410,14 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
|
|
|
39342
39410
|
"socket.purl": toPurl(dependency)
|
|
39343
39411
|
} }));
|
|
39344
39412
|
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);
|
|
39413
|
+
const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
|
|
39347
39414
|
const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
|
|
39348
39415
|
return {
|
|
39349
39416
|
filePath: "package.json",
|
|
39350
39417
|
plugin: SUPPLY_CHAIN_PLUGIN,
|
|
39351
39418
|
rule: SUPPLY_CHAIN_RULE,
|
|
39352
39419
|
severity: options.severity,
|
|
39353
|
-
message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket
|
|
39420
|
+
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
39421
|
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
39422
|
url: packagePageUrl,
|
|
39356
39423
|
line: dependency.line,
|
|
@@ -39362,7 +39429,9 @@ const buildLowScoreDiagnostic = (dependency, score, options) => {
|
|
|
39362
39429
|
* Scores every direct dependency in the project's `package.json` against
|
|
39363
39430
|
* Socket.dev's free PURL endpoint (the same one Socket Firewall's free tier
|
|
39364
39431
|
* uses — no API key) and returns a diagnostic for each dependency whose
|
|
39365
|
-
* Socket
|
|
39432
|
+
* worst Socket *security* axis — supply chain or vulnerability — is below
|
|
39433
|
+
* the configured `minScore`. The quality / maintenance / license axes are
|
|
39434
|
+
* reported as context but never gate (see GATED_AXES).
|
|
39366
39435
|
*
|
|
39367
39436
|
* Lookups run with bounded concurrency via `Effect.forEach`. The check is
|
|
39368
39437
|
* total/fail-open: each per-package lookup already recovers to `null`
|
|
@@ -39380,8 +39449,9 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
39380
39449
|
for (let index = 0; index < dependencies.length; index += 1) {
|
|
39381
39450
|
const score = scores[index];
|
|
39382
39451
|
if (!score) continue;
|
|
39383
|
-
|
|
39384
|
-
|
|
39452
|
+
const worstAxis = worstGatedAxis(score);
|
|
39453
|
+
if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
|
|
39454
|
+
diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
|
|
39385
39455
|
}
|
|
39386
39456
|
return diagnostics;
|
|
39387
39457
|
});
|
|
@@ -39389,7 +39459,8 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
39389
39459
|
* `SupplyChain` scores the project's direct dependencies against Socket.dev's
|
|
39390
39460
|
* free, keyless PURL endpoint — the same lookup Socket Firewall's free tier
|
|
39391
39461
|
* (`sfw`) performs — and streams a diagnostic for each dependency whose
|
|
39392
|
-
* Socket
|
|
39462
|
+
* worst Socket security axis (supply chain or vulnerability) falls below
|
|
39463
|
+
* the configured `supplyChain.minScore`.
|
|
39393
39464
|
*
|
|
39394
39465
|
* Runs by default (one network request per dependency); the orchestrator
|
|
39395
39466
|
* provides `layerOf([])` only when the user opts out via
|
|
@@ -40032,13 +40103,55 @@ const clearAutoSuppressionCaches = () => {};
|
|
|
40032
40103
|
* untouched so the loader sees the same plain object either way.
|
|
40033
40104
|
*/
|
|
40034
40105
|
const defineConfig = (config) => config;
|
|
40106
|
+
const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
|
|
40107
|
+
const mergeIgnores = (baseIgnore, overrideIgnore) => {
|
|
40108
|
+
const mergedIgnore = {
|
|
40109
|
+
...baseIgnore,
|
|
40110
|
+
...overrideIgnore
|
|
40111
|
+
};
|
|
40112
|
+
if (baseIgnore.rules && overrideIgnore.rules) mergedIgnore.rules = unionValues(baseIgnore.rules, overrideIgnore.rules);
|
|
40113
|
+
if (baseIgnore.files && overrideIgnore.files) mergedIgnore.files = unionValues(baseIgnore.files, overrideIgnore.files);
|
|
40114
|
+
if (baseIgnore.tags && overrideIgnore.tags) mergedIgnore.tags = unionValues(baseIgnore.tags, overrideIgnore.tags);
|
|
40115
|
+
if (baseIgnore.overrides && overrideIgnore.overrides) mergedIgnore.overrides = [...baseIgnore.overrides, ...overrideIgnore.overrides];
|
|
40116
|
+
return mergedIgnore;
|
|
40117
|
+
};
|
|
40118
|
+
/**
|
|
40119
|
+
* Layer one `ReactDoctorConfig` on top of another, additively: `rules` /
|
|
40120
|
+
* `categories` / `supplyChain` merge per key, `ignore` lists union
|
|
40121
|
+
* (`ignore.overrides` concatenate), and every other field is a scalar the
|
|
40122
|
+
* override simply wins on when set. Returns the base unchanged when there
|
|
40123
|
+
* is no override, and vice versa — so callers can thread `null` /
|
|
40124
|
+
* `undefined` through without special-casing.
|
|
40125
|
+
*/
|
|
40126
|
+
const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
|
|
40127
|
+
if (overrideConfig === void 0) return baseConfig;
|
|
40128
|
+
if (baseConfig === null) return overrideConfig;
|
|
40129
|
+
const mergedConfig = {
|
|
40130
|
+
...baseConfig,
|
|
40131
|
+
...overrideConfig
|
|
40132
|
+
};
|
|
40133
|
+
if (baseConfig.rules && overrideConfig.rules) mergedConfig.rules = {
|
|
40134
|
+
...baseConfig.rules,
|
|
40135
|
+
...overrideConfig.rules
|
|
40136
|
+
};
|
|
40137
|
+
if (baseConfig.categories && overrideConfig.categories) mergedConfig.categories = {
|
|
40138
|
+
...baseConfig.categories,
|
|
40139
|
+
...overrideConfig.categories
|
|
40140
|
+
};
|
|
40141
|
+
if (baseConfig.supplyChain && overrideConfig.supplyChain) mergedConfig.supplyChain = {
|
|
40142
|
+
...baseConfig.supplyChain,
|
|
40143
|
+
...overrideConfig.supplyChain
|
|
40144
|
+
};
|
|
40145
|
+
if (baseConfig.ignore && overrideConfig.ignore) mergedConfig.ignore = mergeIgnores(baseConfig.ignore, overrideConfig.ignore);
|
|
40146
|
+
return mergedConfig;
|
|
40147
|
+
};
|
|
40035
40148
|
//#endregion
|
|
40036
40149
|
//#region ../api/dist/index.js
|
|
40037
|
-
const buildDiagnoseLayer = (config,
|
|
40038
|
-
const configLayer =
|
|
40150
|
+
const buildDiagnoseLayer = (config, configOverrideTarget) => {
|
|
40151
|
+
const configLayer = configOverrideTarget === void 0 ? Config.layerNode : Config.layerOf({
|
|
40039
40152
|
config,
|
|
40040
|
-
resolvedDirectory:
|
|
40041
|
-
configSourceDirectory:
|
|
40153
|
+
resolvedDirectory: configOverrideTarget.resolvedDirectory,
|
|
40154
|
+
configSourceDirectory: configOverrideTarget.configSourceDirectory
|
|
40042
40155
|
});
|
|
40043
40156
|
return mergeAll$1(Project.layerNode, configLayer, DeadCode.layerNode, Files.layerNode, Git.layerNode, Linter.layerOxlint, LintPartialFailures.layerLive, Progress.layerNoop, Reporter.layerNoop, Score.layerHttp, config?.supplyChain?.enabled !== false ? SupplyChain.layerNode : SupplyChain.layerOf([]));
|
|
40044
40157
|
};
|
|
@@ -40070,11 +40183,64 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
|
|
|
40070
40183
|
elapsedMilliseconds
|
|
40071
40184
|
};
|
|
40072
40185
|
};
|
|
40073
|
-
const
|
|
40186
|
+
const diagnoseDirectory = async (directory, options) => {
|
|
40074
40187
|
const startTime = globalThis.performance.now();
|
|
40075
40188
|
const scanTarget = await resolveScanTarget(directory);
|
|
40076
40189
|
return outputToDiagnoseResult(await runPromise(restoreLegacyThrow(buildInspectProgram(scanTarget, options).pipe(provide(buildDiagnoseLayer(scanTarget.userConfig)), provide(layerOtlp)))), globalThis.performance.now() - startTime);
|
|
40077
40190
|
};
|
|
40191
|
+
const findWorstScore = (projectResults) => {
|
|
40192
|
+
let worstResult = null;
|
|
40193
|
+
let worstScore = Number.POSITIVE_INFINITY;
|
|
40194
|
+
for (const projectResult of projectResults) {
|
|
40195
|
+
if (!projectResult.ok || projectResult.score === null) continue;
|
|
40196
|
+
if (projectResult.score.score < worstScore) {
|
|
40197
|
+
worstScore = projectResult.score.score;
|
|
40198
|
+
worstResult = projectResult.score;
|
|
40199
|
+
}
|
|
40200
|
+
}
|
|
40201
|
+
return worstResult;
|
|
40202
|
+
};
|
|
40203
|
+
const diagnoseProject = async (projectDefinition, baseOptions, batchConfig) => {
|
|
40204
|
+
const startTime = globalThis.performance.now();
|
|
40205
|
+
try {
|
|
40206
|
+
const scanTarget = await resolveScanTarget(projectDefinition.directory);
|
|
40207
|
+
const { directory: _, config: projectConfig, ...perProjectOptions } = projectDefinition;
|
|
40208
|
+
const didOverrideConfig = batchConfig !== void 0 || projectConfig !== void 0;
|
|
40209
|
+
const effectiveConfig = mergeReactDoctorConfigs(mergeReactDoctorConfigs(scanTarget.userConfig, batchConfig), projectConfig);
|
|
40210
|
+
const program = buildInspectProgram(scanTarget, {
|
|
40211
|
+
...baseOptions,
|
|
40212
|
+
...perProjectOptions
|
|
40213
|
+
}, effectiveConfig ?? void 0);
|
|
40214
|
+
const didOverridePlugins = batchConfig?.plugins !== void 0 || projectConfig?.plugins !== void 0;
|
|
40215
|
+
const layer = buildDiagnoseLayer(effectiveConfig, didOverrideConfig ? {
|
|
40216
|
+
resolvedDirectory: scanTarget.resolvedDirectory,
|
|
40217
|
+
configSourceDirectory: didOverridePlugins ? null : scanTarget.configSourceDirectory
|
|
40218
|
+
} : void 0);
|
|
40219
|
+
return {
|
|
40220
|
+
ok: true,
|
|
40221
|
+
...outputToDiagnoseResult(await runPromise(restoreLegacyThrow(program.pipe(provide(layer), provide(layerOtlp)))), globalThis.performance.now() - startTime),
|
|
40222
|
+
directory: scanTarget.resolvedDirectory
|
|
40223
|
+
};
|
|
40224
|
+
} catch (error) {
|
|
40225
|
+
return {
|
|
40226
|
+
ok: false,
|
|
40227
|
+
directory: projectDefinition.directory,
|
|
40228
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
40229
|
+
};
|
|
40230
|
+
}
|
|
40231
|
+
};
|
|
40232
|
+
const diagnoseProjectBatch = async (input) => {
|
|
40233
|
+
const startTime = globalThis.performance.now();
|
|
40234
|
+
const { projects, concurrency, config: batchConfig, ...baseOptions } = input;
|
|
40235
|
+
const projectResults = await mapWithConcurrency(projects, concurrency ?? 4, (projectDefinition) => diagnoseProject(projectDefinition, baseOptions, batchConfig));
|
|
40236
|
+
return {
|
|
40237
|
+
projects: projectResults,
|
|
40238
|
+
diagnostics: projectResults.flatMap((projectResult) => projectResult.ok ? projectResult.diagnostics : []),
|
|
40239
|
+
score: findWorstScore(projectResults),
|
|
40240
|
+
elapsedMilliseconds: globalThis.performance.now() - startTime
|
|
40241
|
+
};
|
|
40242
|
+
};
|
|
40243
|
+
const diagnose = (async (directoryOrInput, options = {}) => typeof directoryOrInput === "string" ? diagnoseDirectory(directoryOrInput, options) : diagnoseProjectBatch(directoryOrInput));
|
|
40078
40244
|
//#endregion
|
|
40079
40245
|
//#region src/index.ts
|
|
40080
40246
|
const clearCaches = () => {
|
|
@@ -40107,4 +40273,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
40107
40273
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
40108
40274
|
|
|
40109
40275
|
//# sourceMappingURL=index.js.map
|
|
40110
|
-
//# debugId=
|
|
40276
|
+
//# debugId=d789108a-ddf2-5b61-a479-4c797dba74cb
|