react-doctor 0.3.0-dev.915745e → 0.3.0-dev.9a8ad6e
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/README.md +5 -1
- package/dist/cli.js +540 -217
- package/dist/index.d.ts +106 -12
- package/dist/index.js +135 -54
- package/dist/lsp.js +112 -49
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,16 @@ import * as Schema from "effect/Schema";
|
|
|
2
2
|
import * as Cause from "effect/Cause";
|
|
3
3
|
//#region ../core/dist/index.d.ts
|
|
4
4
|
//#region src/types/config.d.ts
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Severity threshold at which a scan blocks CI (exits non-zero). Controlled
|
|
7
|
+
* by `blocking` / `--blocking` (default `"error"`):
|
|
8
|
+
*
|
|
9
|
+
* - `"error"` — block when an `"error"`-severity diagnostic reaches the
|
|
10
|
+
* `ciFailure` surface. The default.
|
|
11
|
+
* - `"warning"` — block on any diagnostic (warnings included).
|
|
12
|
+
* - `"none"` — never block; the scan is advisory (still reports + scores).
|
|
13
|
+
*/
|
|
14
|
+
type BlockingLevel = "error" | "warning" | "none";
|
|
6
15
|
interface ReactDoctorIgnoreOverride {
|
|
7
16
|
/** Glob patterns the override applies to (e.g. `["src/legacy/**"]`). */
|
|
8
17
|
files: string[];
|
|
@@ -46,9 +55,11 @@ interface ReactDoctorIgnoreConfig {
|
|
|
46
55
|
* (sets `outputSurface: "prComment"`).
|
|
47
56
|
* - `score` — diagnostics shipped to the React Doctor score API
|
|
48
57
|
* (or counted toward local score calculations).
|
|
49
|
-
* - `ciFailure` — diagnostics that count toward the
|
|
50
|
-
*
|
|
51
|
-
*
|
|
58
|
+
* - `ciFailure` — diagnostics that count toward the CI exit-code gate.
|
|
59
|
+
* react-doctor blocks (exits non-zero) when a diagnostic at or above the
|
|
60
|
+
* `blocking` threshold reaches this surface (default: `"error"`). A
|
|
61
|
+
* diagnostic excluded from this surface never fails the build,
|
|
62
|
+
* regardless of severity.
|
|
52
63
|
*
|
|
53
64
|
* Defaults: design rules (tag `"design"`) are excluded from `prComment`,
|
|
54
65
|
* `score`, and `ciFailure` so style cleanup doesn't dilute meaningful
|
|
@@ -122,8 +133,9 @@ interface ReactDoctorConfig {
|
|
|
122
133
|
verbose?: boolean;
|
|
123
134
|
/**
|
|
124
135
|
* Whether to surface `"warning"`-severity diagnostics. Default: `true`
|
|
125
|
-
* — every warning reaches every surface (CLI, PR comment, score,
|
|
126
|
-
*
|
|
136
|
+
* — every warning reaches every surface (CLI, PR comment, score, the
|
|
137
|
+
* CI gate). Warnings only flip the exit code when `blocking` is set to
|
|
138
|
+
* `"warning"`; at the default `"error"` threshold they stay advisory.
|
|
127
139
|
*
|
|
128
140
|
* Set to `false` to surface only `"error"`-severity findings. This is the
|
|
129
141
|
* master toggle and runs after per-rule / per-category severity
|
|
@@ -132,7 +144,23 @@ interface ReactDoctorConfig {
|
|
|
132
144
|
*/
|
|
133
145
|
warnings?: boolean;
|
|
134
146
|
diff?: boolean | string;
|
|
135
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Severity threshold at which the scan blocks CI (exits non-zero).
|
|
149
|
+
* Default: `"error"` — only `"error"`-severity diagnostics on the
|
|
150
|
+
* `ciFailure` surface fail the build. Set to `"warning"` to also block
|
|
151
|
+
* on warnings, or `"none"` to keep the scan advisory (it still reports
|
|
152
|
+
* findings and a score, but always exits `0`).
|
|
153
|
+
*
|
|
154
|
+
* The GitHub Action exposes the same control as its `blocking`
|
|
155
|
+
* input, and the CLI as `--blocking <level>`. Flags win over config.
|
|
156
|
+
*/
|
|
157
|
+
blocking?: BlockingLevel;
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated Renamed to `blocking` (same values + default). Still
|
|
160
|
+
* honored as an alias when `blocking` is unset, but using it emits a
|
|
161
|
+
* one-time deprecation warning. Prefer `blocking`.
|
|
162
|
+
*/
|
|
163
|
+
failOn?: BlockingLevel;
|
|
136
164
|
customRulesOnly?: boolean;
|
|
137
165
|
share?: boolean;
|
|
138
166
|
noScore?: boolean;
|
|
@@ -230,7 +258,7 @@ interface ReactDoctorConfig {
|
|
|
230
258
|
* Per-surface include/exclude controls. Each `DiagnosticSurface` is
|
|
231
259
|
* resolved independently against rule tags, category, and id so a
|
|
232
260
|
* single rule can be visible locally yet hidden from PR comments,
|
|
233
|
-
* neutralized from the score, and excluded from
|
|
261
|
+
* neutralized from the score, and excluded from the CI gate — all
|
|
234
262
|
* without touching the rule's severity or activation.
|
|
235
263
|
*
|
|
236
264
|
* Defaults (applied before user overrides):
|
|
@@ -255,7 +283,7 @@ interface ReactDoctorConfig {
|
|
|
255
283
|
* `"off"` skips registration in the generated lint config so the
|
|
256
284
|
* rule never runs; `"error"` / `"warn"` re-stamp the registered
|
|
257
285
|
* severity and the post-lint diagnostic, so downstream consumers
|
|
258
|
-
* (
|
|
286
|
+
* (the CI gate, the score, the printed list) all see the
|
|
259
287
|
* user-chosen severity.
|
|
260
288
|
*
|
|
261
289
|
* For visibility-only changes (silence on PR comments but keep on
|
|
@@ -550,6 +578,16 @@ interface InspectResult {
|
|
|
550
578
|
* summary to report combined scan time.
|
|
551
579
|
*/
|
|
552
580
|
scanElapsedMilliseconds?: number;
|
|
581
|
+
/**
|
|
582
|
+
* Present only for a baseline run (`InspectOptions.baseline` set). The
|
|
583
|
+
* `diagnostics` above are then the *introduced* findings only; this
|
|
584
|
+
* carries the comparison totals for Codecov-style delta reporting.
|
|
585
|
+
*/
|
|
586
|
+
baselineDelta?: {
|
|
587
|
+
/** The commit the base content was read from (resolved merge-base). */baseRef: string; /** Findings present at base but gone at head — resolved by the change. */
|
|
588
|
+
fixedCount: number; /** Total findings at base (over the same files), for context. */
|
|
589
|
+
baseTotalCount: number;
|
|
590
|
+
};
|
|
553
591
|
}
|
|
554
592
|
/**
|
|
555
593
|
* Options accepted by `inspect()`. Mixes two concern groups; ordered
|
|
@@ -578,10 +616,34 @@ interface DiffInfo {
|
|
|
578
616
|
*/
|
|
579
617
|
currentBranch: string | null;
|
|
580
618
|
baseBranch: string;
|
|
619
|
+
/**
|
|
620
|
+
* Resolved base commit SHA, when known (the GitHub Action forwards
|
|
621
|
+
* `pull_request.base.sha`). Preferred over `baseBranch` for baseline
|
|
622
|
+
* merge-base resolution because a branch name often doesn't resolve in a
|
|
623
|
+
* shallow PR checkout, whereas the fetched SHA always does.
|
|
624
|
+
*/
|
|
625
|
+
baseSha?: string;
|
|
626
|
+
/**
|
|
627
|
+
* The commit the changed-file diff was computed against (see
|
|
628
|
+
* `GitDiffSelection.diffBaseRef`). Baseline mode reads base content from
|
|
629
|
+
* here so a two-dot `A..B` range reads from `A` directly instead of being
|
|
630
|
+
* incorrectly merge-based with HEAD.
|
|
631
|
+
*/
|
|
632
|
+
diffBaseRef?: string;
|
|
581
633
|
changedFiles: string[];
|
|
582
634
|
isCurrentChanges?: boolean;
|
|
583
635
|
}
|
|
584
|
-
type JsonReportMode = "full" | "diff" | "staged";
|
|
636
|
+
type JsonReportMode = "full" | "diff" | "staged" | "baseline";
|
|
637
|
+
interface JsonReportBaselineInfo {
|
|
638
|
+
/** Resolved base commit (merge-base) the head was compared against. */
|
|
639
|
+
baseRef: string;
|
|
640
|
+
/** Count of introduced findings (equals `summary.totalDiagnosticCount`). */
|
|
641
|
+
newCount: number;
|
|
642
|
+
/** Count of findings the change resolved (present at base, gone at head). */
|
|
643
|
+
fixedCount: number;
|
|
644
|
+
/** Total findings at base over the same files, for context. */
|
|
645
|
+
baseTotalCount: number;
|
|
646
|
+
}
|
|
585
647
|
interface JsonReportDiffInfo {
|
|
586
648
|
baseBranch: string;
|
|
587
649
|
/** `null` when `HEAD` is detached — see `DiffInfo.currentBranch`. */
|
|
@@ -611,8 +673,15 @@ interface JsonReportError {
|
|
|
611
673
|
message: string;
|
|
612
674
|
name: string;
|
|
613
675
|
chain: string[];
|
|
676
|
+
/**
|
|
677
|
+
* Sentry event id for the crash, when the run reported one (CLI crash
|
|
678
|
+
* path in CI). Lets the GitHub Action surface a quotable reference so a
|
|
679
|
+
* failed scan can be traced back to its Sentry event. `null` for expected
|
|
680
|
+
* user errors and synthetic fallbacks that never hit Sentry.
|
|
681
|
+
*/
|
|
682
|
+
sentryEventId?: string | null;
|
|
614
683
|
}
|
|
615
|
-
interface
|
|
684
|
+
interface JsonReportV1$1 {
|
|
616
685
|
schemaVersion: 1;
|
|
617
686
|
version: string;
|
|
618
687
|
ok: boolean;
|
|
@@ -628,7 +697,20 @@ interface JsonReport {
|
|
|
628
697
|
summary: JsonReportSummary;
|
|
629
698
|
elapsedMilliseconds: number;
|
|
630
699
|
error: JsonReportError | null;
|
|
631
|
-
}
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Baseline (PR-introduced-issues-only) report. Structurally a superset of v1
|
|
703
|
+
* — every v1 field is present with identical meaning, so consumers that only
|
|
704
|
+
* read `summary` / `diagnostics` / `ok` work unchanged — plus a `baseline`
|
|
705
|
+
* block and `mode: "baseline"`. Here `diagnostics` (and `summary`'s counts)
|
|
706
|
+
* are the *introduced* findings only; `summary.score` is still the head
|
|
707
|
+
* scan's project-health score. New consumers branch on `schemaVersion === 2`.
|
|
708
|
+
*/
|
|
709
|
+
interface JsonReportV2 extends Omit<JsonReportV1$1, "schemaVersion"> {
|
|
710
|
+
schemaVersion: 2;
|
|
711
|
+
baseline: JsonReportBaselineInfo;
|
|
712
|
+
}
|
|
713
|
+
type JsonReport = JsonReportV1$1 | JsonReportV2; //#endregion
|
|
632
714
|
//#region src/types/prompts.d.ts
|
|
633
715
|
//#endregion
|
|
634
716
|
//#region src/project-info/errors.d.ts
|
|
@@ -807,6 +889,8 @@ interface BuildJsonReportErrorInput {
|
|
|
807
889
|
error: unknown;
|
|
808
890
|
elapsedMilliseconds: number;
|
|
809
891
|
mode?: JsonReportMode;
|
|
892
|
+
/** Sentry event id for the crash, when the run reported one. */
|
|
893
|
+
sentryEventId?: string | null;
|
|
810
894
|
}
|
|
811
895
|
declare const buildJsonReportError: (input: BuildJsonReportErrorInput) => JsonReport; //#endregion
|
|
812
896
|
//#region src/build-json-report.d.ts
|
|
@@ -820,6 +904,16 @@ interface BuildJsonReportInput {
|
|
|
820
904
|
result: InspectResult;
|
|
821
905
|
}>;
|
|
822
906
|
totalElapsedMilliseconds: number;
|
|
907
|
+
/**
|
|
908
|
+
* Present for a baseline run — `scans[].result.diagnostics` are then the
|
|
909
|
+
* introduced findings only. Emits a `schemaVersion: 2` report with the
|
|
910
|
+
* delta totals and `mode: "baseline"`.
|
|
911
|
+
*/
|
|
912
|
+
baseline?: {
|
|
913
|
+
baseRef: string;
|
|
914
|
+
fixedCount: number;
|
|
915
|
+
baseTotalCount: number;
|
|
916
|
+
};
|
|
823
917
|
}
|
|
824
918
|
declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#endregion
|
|
825
919
|
//#region src/build-skipped-checks.d.ts
|
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]="44e73f8d-b81f-599b-a04e-22497cd72bb2")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as fs$1 from "node:fs";
|
|
@@ -91,7 +91,8 @@ var Diagnostic = class extends Schema.Class("Diagnostic")({
|
|
|
91
91
|
const JsonReportMode = Schema.Literals([
|
|
92
92
|
"full",
|
|
93
93
|
"diff",
|
|
94
|
-
"staged"
|
|
94
|
+
"staged",
|
|
95
|
+
"baseline"
|
|
95
96
|
]);
|
|
96
97
|
var JsonReportSummary = class extends Schema.Class("JsonReportSummary")({
|
|
97
98
|
errorCount: Schema.Number,
|
|
@@ -110,7 +111,9 @@ var JsonReportDiffInfo = class extends Schema.Class("JsonReportDiffInfo")({
|
|
|
110
111
|
var JsonReportError = class extends Schema.Class("JsonReportError")({
|
|
111
112
|
message: Schema.String,
|
|
112
113
|
name: Schema.String,
|
|
113
|
-
chain: Schema.Array(Schema.String)
|
|
114
|
+
chain: Schema.Array(Schema.String),
|
|
115
|
+
/** Sentry event id for the crash, when one was reported. */
|
|
116
|
+
sentryEventId: Schema.optional(Schema.NullOr(Schema.String))
|
|
114
117
|
}) {};
|
|
115
118
|
/**
|
|
116
119
|
* Schema for a single project entry within a JsonReport. `project` is
|
|
@@ -147,7 +150,33 @@ var JsonReportV1 = class extends Schema.Class("JsonReportV1")({
|
|
|
147
150
|
elapsedMilliseconds: Schema.Number,
|
|
148
151
|
error: Schema.NullOr(JsonReportError)
|
|
149
152
|
}) {};
|
|
150
|
-
Schema.
|
|
153
|
+
var JsonReportBaseline = class extends Schema.Class("JsonReportBaseline")({
|
|
154
|
+
baseRef: Schema.String,
|
|
155
|
+
newCount: Schema.Number,
|
|
156
|
+
fixedCount: Schema.Number,
|
|
157
|
+
baseTotalCount: Schema.Number
|
|
158
|
+
}) {};
|
|
159
|
+
/**
|
|
160
|
+
* Baseline (PR-introduced-issues-only) report — `schemaVersion: 2`. A
|
|
161
|
+
* superset of v1: same fields, plus a `baseline` block. `diagnostics` /
|
|
162
|
+
* `summary` counts are the introduced findings only; `summary.score` stays
|
|
163
|
+
* the head project-health score. Consumers branch on `schemaVersion`.
|
|
164
|
+
*/
|
|
165
|
+
var JsonReportV2 = class extends Schema.Class("JsonReportV2")({
|
|
166
|
+
schemaVersion: Schema.Literal(2),
|
|
167
|
+
version: Schema.String,
|
|
168
|
+
ok: Schema.Boolean,
|
|
169
|
+
directory: Schema.String,
|
|
170
|
+
mode: JsonReportMode,
|
|
171
|
+
diff: Schema.NullOr(JsonReportDiffInfo),
|
|
172
|
+
baseline: JsonReportBaseline,
|
|
173
|
+
projects: Schema.Array(JsonReportProjectEntry),
|
|
174
|
+
diagnostics: Schema.Array(Diagnostic),
|
|
175
|
+
summary: JsonReportSummary,
|
|
176
|
+
elapsedMilliseconds: Schema.Number,
|
|
177
|
+
error: Schema.NullOr(JsonReportError)
|
|
178
|
+
}) {};
|
|
179
|
+
Schema.Union([JsonReportV1, JsonReportV2]);
|
|
151
180
|
//#endregion
|
|
152
181
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js
|
|
153
182
|
var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
@@ -6229,6 +6258,11 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6229
6258
|
branch
|
|
6230
6259
|
]).pipe(Effect.map((result) => result.status === 0));
|
|
6231
6260
|
const headSha = (directory) => runGit(directory, ["rev-parse", "HEAD"]).pipe(Effect.map((result) => result.status === 0 ? trimOrNull(result.stdout) : null));
|
|
6261
|
+
const mergeBase = (input) => isSafeGitRevision(input.ref) ? runGit(input.directory, [
|
|
6262
|
+
"merge-base",
|
|
6263
|
+
input.ref,
|
|
6264
|
+
"HEAD"
|
|
6265
|
+
]).pipe(Effect.map((result) => result.status === 0 ? trimOrNull(result.stdout) : null)) : Effect.succeed(null);
|
|
6232
6266
|
const githubRepo = (directory) => runGit(directory, [
|
|
6233
6267
|
"config",
|
|
6234
6268
|
"--get",
|
|
@@ -6304,6 +6338,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6304
6338
|
return {
|
|
6305
6339
|
currentBranch: yield* currentBranch(input.directory),
|
|
6306
6340
|
baseBranch: baseRef,
|
|
6341
|
+
diffBaseRef,
|
|
6307
6342
|
changedFiles: splitNullSeparated(diff.stdout),
|
|
6308
6343
|
isCurrentChanges: false
|
|
6309
6344
|
};
|
|
@@ -6315,6 +6350,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6315
6350
|
githubRepo,
|
|
6316
6351
|
githubViewerPermission,
|
|
6317
6352
|
branchExists,
|
|
6353
|
+
mergeBase,
|
|
6318
6354
|
diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
|
|
6319
6355
|
if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
|
|
6320
6356
|
if (explicitBaseBranch !== void 0) {
|
|
@@ -6372,6 +6408,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6372
6408
|
return {
|
|
6373
6409
|
currentBranch: resolvedCurrentBranch,
|
|
6374
6410
|
baseBranch,
|
|
6411
|
+
diffBaseRef: mergeBaseRef,
|
|
6375
6412
|
changedFiles: splitNullSeparated(diff.stdout),
|
|
6376
6413
|
isCurrentChanges: false
|
|
6377
6414
|
};
|
|
@@ -6393,6 +6430,12 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6393
6430
|
directory,
|
|
6394
6431
|
maxStdoutBytes: options?.maxBufferBytes
|
|
6395
6432
|
}).pipe(Effect.map((result) => result.status === 0 ? result.stdout : null)),
|
|
6433
|
+
showRefContent: ({ directory, ref, relativePath, options }) => isSafeGitRevision(ref) ? runCommand({
|
|
6434
|
+
command: "git",
|
|
6435
|
+
args: ["show", `${ref}:./${relativePath}`],
|
|
6436
|
+
directory,
|
|
6437
|
+
maxStdoutBytes: options?.maxBufferBytes
|
|
6438
|
+
}).pipe(Effect.map((result) => result.status === 0 ? result.stdout : null)) : Effect.succeed(null),
|
|
6396
6439
|
grep: (input) => Effect.gen(function* () {
|
|
6397
6440
|
const args = ["grep"];
|
|
6398
6441
|
if (input.listMatchingFiles ?? true) args.push("-l");
|
|
@@ -6428,9 +6471,11 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6428
6471
|
githubRepo: () => Effect.succeed(snapshot.githubRepo ?? null),
|
|
6429
6472
|
githubViewerPermission: () => Effect.succeed(snapshot.githubViewerPermission ?? null),
|
|
6430
6473
|
branchExists: (_directory, branch) => Effect.succeed(snapshot.branchExists?.get(branch) ?? false),
|
|
6474
|
+
mergeBase: ({ ref }) => Effect.succeed(snapshot.mergeBase?.get(ref) ?? null),
|
|
6431
6475
|
diffSelection: () => Effect.succeed(snapshot.diffSelection ?? null),
|
|
6432
6476
|
stagedFilePaths: () => Effect.succeed(snapshot.stagedFiles ?? []),
|
|
6433
6477
|
showStagedContent: (_directory, relativePath) => Effect.succeed(snapshot.stagedContent?.get(relativePath) ?? null),
|
|
6478
|
+
showRefContent: ({ ref, relativePath }) => Effect.succeed(snapshot.refContent?.get(`${ref}:${relativePath}`) ?? null),
|
|
6434
6479
|
grep: () => Effect.sync(() => {
|
|
6435
6480
|
const matches = snapshot.grepMatches;
|
|
6436
6481
|
if (matches === null || matches === void 0) return null;
|
|
@@ -8528,57 +8573,74 @@ const resolveNodeForOxlint = () => {
|
|
|
8528
8573
|
});
|
|
8529
8574
|
});
|
|
8530
8575
|
/**
|
|
8531
|
-
* Zip-Slip defense:
|
|
8532
|
-
*
|
|
8533
|
-
*
|
|
8534
|
-
*
|
|
8535
|
-
* working tree) can include `..` segments that escape the temp
|
|
8536
|
-
* tree. Resolve the candidate against the temp dir and reject any
|
|
8537
|
-
* result that lands outside it before `writeFileSync` runs.
|
|
8576
|
+
* Zip-Slip defense: relative paths come from git (`diff --name-only`), which
|
|
8577
|
+
* normalizes during ordinary adds, but a crafted index/pack/symlinked tree can
|
|
8578
|
+
* smuggle `..` segments that escape the temp root. Resolve against the temp dir
|
|
8579
|
+
* and reject anything that lands outside before writing.
|
|
8538
8580
|
*/
|
|
8539
8581
|
const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
|
|
8540
|
-
const relative = path
|
|
8541
|
-
return Boolean(relative) && !relative.startsWith("..") && !path
|
|
8582
|
+
const relative = path.relative(parentAbsolutePath, childAbsolutePath);
|
|
8583
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
8542
8584
|
};
|
|
8585
|
+
/**
|
|
8586
|
+
* Writes a set of source files (supplied by `readContent` — e.g.
|
|
8587
|
+
* `git show <ref>:<path>` for a baseline tree, or `git show :<path>` for the
|
|
8588
|
+
* index) into a temp tree that mirrors the project layout, copying the
|
|
8589
|
+
* well-known project-config files from `directory` so oxlint resolves
|
|
8590
|
+
* tsconfig / lint config identically to the working tree. Shared by the staged
|
|
8591
|
+
* and baseline scan paths so the zip-slip guard lives in one audited place.
|
|
8592
|
+
* Per-file read failures skip that file (the scan proceeds with whatever read
|
|
8593
|
+
* cleanly) rather than sinking the whole snapshot.
|
|
8594
|
+
*/
|
|
8595
|
+
const materializeSourceTree = (input) => Effect.gen(function* () {
|
|
8596
|
+
const materializedFiles = [];
|
|
8597
|
+
const resolvedTempDirectory = path.resolve(input.tempDirectory);
|
|
8598
|
+
for (const relativePath of input.files) {
|
|
8599
|
+
const content = yield* input.readContent(relativePath).pipe(Effect.orElseSucceed(() => null));
|
|
8600
|
+
if (content === null) continue;
|
|
8601
|
+
const candidateTargetPath = path.resolve(resolvedTempDirectory, relativePath);
|
|
8602
|
+
if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
|
|
8603
|
+
yield* Effect.sync(() => {
|
|
8604
|
+
fs.mkdirSync(path.dirname(candidateTargetPath), { recursive: true });
|
|
8605
|
+
fs.writeFileSync(candidateTargetPath, content);
|
|
8606
|
+
});
|
|
8607
|
+
materializedFiles.push(relativePath);
|
|
8608
|
+
}
|
|
8609
|
+
yield* Effect.sync(() => {
|
|
8610
|
+
for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
|
|
8611
|
+
const sourcePath = path.join(input.directory, configFilename);
|
|
8612
|
+
const targetPath = path.join(resolvedTempDirectory, configFilename);
|
|
8613
|
+
if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) fs.cpSync(sourcePath, targetPath);
|
|
8614
|
+
}
|
|
8615
|
+
});
|
|
8616
|
+
return {
|
|
8617
|
+
tempDirectory: input.tempDirectory,
|
|
8618
|
+
materializedFiles,
|
|
8619
|
+
cleanup: () => {
|
|
8620
|
+
try {
|
|
8621
|
+
fs.rmSync(input.tempDirectory, {
|
|
8622
|
+
recursive: true,
|
|
8623
|
+
force: true
|
|
8624
|
+
});
|
|
8625
|
+
} catch {}
|
|
8626
|
+
}
|
|
8627
|
+
};
|
|
8628
|
+
});
|
|
8543
8629
|
(class StagedFiles extends Context.Service()("react-doctor/StagedFiles") {
|
|
8544
8630
|
static layerNode = Layer.effect(StagedFiles, Effect.gen(function* () {
|
|
8545
8631
|
const git = yield* Git;
|
|
8546
8632
|
return StagedFiles.of({
|
|
8547
8633
|
discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(Effect.map((entries) => entries.filter(isLintableSourceFile))),
|
|
8548
|
-
materialize: ({ directory, stagedFiles, tempDirectory }) =>
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
fs$1.writeFileSync(candidateTargetPath, content);
|
|
8559
|
-
});
|
|
8560
|
-
materializedFiles.push(relativePath);
|
|
8561
|
-
}
|
|
8562
|
-
yield* Effect.sync(() => {
|
|
8563
|
-
for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
|
|
8564
|
-
const sourcePath = path$1.join(directory, configFilename);
|
|
8565
|
-
const targetPath = path$1.join(resolvedTempDirectory, configFilename);
|
|
8566
|
-
if (fs$1.existsSync(sourcePath) && !fs$1.existsSync(targetPath)) fs$1.cpSync(sourcePath, targetPath);
|
|
8567
|
-
}
|
|
8568
|
-
});
|
|
8569
|
-
return {
|
|
8570
|
-
tempDirectory,
|
|
8571
|
-
stagedFiles: materializedFiles,
|
|
8572
|
-
cleanup: () => {
|
|
8573
|
-
try {
|
|
8574
|
-
fs$1.rmSync(tempDirectory, {
|
|
8575
|
-
recursive: true,
|
|
8576
|
-
force: true
|
|
8577
|
-
});
|
|
8578
|
-
} catch {}
|
|
8579
|
-
}
|
|
8580
|
-
};
|
|
8581
|
-
})
|
|
8634
|
+
materialize: ({ directory, stagedFiles, tempDirectory }) => materializeSourceTree({
|
|
8635
|
+
directory,
|
|
8636
|
+
files: stagedFiles,
|
|
8637
|
+
tempDirectory,
|
|
8638
|
+
readContent: (relativePath) => git.showStagedContent(directory, relativePath, { maxBufferBytes: GIT_SHOW_MAX_BUFFER_BYTES })
|
|
8639
|
+
}).pipe(Effect.map((tree) => ({
|
|
8640
|
+
tempDirectory: tree.tempDirectory,
|
|
8641
|
+
stagedFiles: tree.materializedFiles,
|
|
8642
|
+
cleanup: tree.cleanup
|
|
8643
|
+
})))
|
|
8582
8644
|
});
|
|
8583
8645
|
}));
|
|
8584
8646
|
/**
|
|
@@ -8624,18 +8686,22 @@ const safeGetErrorChain = (error) => {
|
|
|
8624
8686
|
};
|
|
8625
8687
|
const buildJsonReportError = (input) => {
|
|
8626
8688
|
const chain = safeGetErrorChain(input.error);
|
|
8689
|
+
const sentryEventId = input.sentryEventId ?? null;
|
|
8627
8690
|
const errorPayload = isReactDoctorError(input.error) ? {
|
|
8628
8691
|
message: formatReactDoctorError(input.error),
|
|
8629
8692
|
name: `ReactDoctorError(${input.error.reason._tag})`,
|
|
8630
|
-
chain
|
|
8693
|
+
chain,
|
|
8694
|
+
sentryEventId
|
|
8631
8695
|
} : input.error instanceof Error ? {
|
|
8632
8696
|
message: input.error.message || input.error.name || "Error",
|
|
8633
8697
|
name: input.error.name || "Error",
|
|
8634
|
-
chain
|
|
8698
|
+
chain,
|
|
8699
|
+
sentryEventId
|
|
8635
8700
|
} : {
|
|
8636
8701
|
message: safeStringify(input.error),
|
|
8637
8702
|
name: "Error",
|
|
8638
|
-
chain
|
|
8703
|
+
chain,
|
|
8704
|
+
sentryEventId
|
|
8639
8705
|
};
|
|
8640
8706
|
return {
|
|
8641
8707
|
schemaVersion: 1,
|
|
@@ -8711,12 +8777,10 @@ const buildJsonReport = (input) => {
|
|
|
8711
8777
|
const flattenedDiagnostics = projects.flatMap((entry) => entry.diagnostics);
|
|
8712
8778
|
const worstScoredProject = findWorstScoredProject(projects);
|
|
8713
8779
|
const summary = summarizeDiagnostics(flattenedDiagnostics, worstScoredProject?.score?.score ?? null, worstScoredProject?.score?.label ?? null);
|
|
8714
|
-
|
|
8715
|
-
schemaVersion: 1,
|
|
8780
|
+
const shared = {
|
|
8716
8781
|
version: input.version,
|
|
8717
8782
|
ok: true,
|
|
8718
8783
|
directory: input.directory,
|
|
8719
|
-
mode: input.mode,
|
|
8720
8784
|
diff: toJsonDiff(input.diff),
|
|
8721
8785
|
projects,
|
|
8722
8786
|
diagnostics: flattenedDiagnostics,
|
|
@@ -8724,6 +8788,22 @@ const buildJsonReport = (input) => {
|
|
|
8724
8788
|
elapsedMilliseconds: input.totalElapsedMilliseconds,
|
|
8725
8789
|
error: null
|
|
8726
8790
|
};
|
|
8791
|
+
if (input.baseline) return {
|
|
8792
|
+
schemaVersion: 2,
|
|
8793
|
+
mode: "baseline",
|
|
8794
|
+
baseline: {
|
|
8795
|
+
baseRef: input.baseline.baseRef,
|
|
8796
|
+
newCount: summary.totalDiagnosticCount,
|
|
8797
|
+
fixedCount: input.baseline.fixedCount,
|
|
8798
|
+
baseTotalCount: input.baseline.baseTotalCount
|
|
8799
|
+
},
|
|
8800
|
+
...shared
|
|
8801
|
+
};
|
|
8802
|
+
return {
|
|
8803
|
+
schemaVersion: 1,
|
|
8804
|
+
mode: input.mode,
|
|
8805
|
+
...shared
|
|
8806
|
+
};
|
|
8727
8807
|
};
|
|
8728
8808
|
/**
|
|
8729
8809
|
* Single source of truth for the skipped-check accounting shared by the
|
|
@@ -8767,6 +8847,7 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
|
|
|
8767
8847
|
return {
|
|
8768
8848
|
currentBranch: selection.currentBranch,
|
|
8769
8849
|
baseBranch: selection.baseBranch,
|
|
8850
|
+
...selection.diffBaseRef !== void 0 ? { diffBaseRef: selection.diffBaseRef } : {},
|
|
8770
8851
|
changedFiles: [...selection.changedFiles],
|
|
8771
8852
|
...selection.isCurrentChanges ? { isCurrentChanges: true } : {}
|
|
8772
8853
|
};
|
|
@@ -8848,4 +8929,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8848
8929
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8849
8930
|
|
|
8850
8931
|
//# sourceMappingURL=index.js.map
|
|
8851
|
-
//# debugId=
|
|
8932
|
+
//# debugId=44e73f8d-b81f-599b-a04e-22497cd72bb2
|