react-doctor 0.3.0-dev.6130583 → 0.3.0-dev.7593271
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 +18 -2
- package/bin/react-doctor.js +9 -1
- package/dist/cli.js +625 -233
- package/dist/index.d.ts +141 -12
- package/dist/index.js +189 -60
- package/dist/lsp.js +10804 -0
- package/package.json +8 -4
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
|
|
@@ -334,6 +362,25 @@ interface ReactDoctorConfig {
|
|
|
334
362
|
plugins?: string[];
|
|
335
363
|
} //#endregion
|
|
336
364
|
//#region src/types/diagnostic.d.ts
|
|
365
|
+
/**
|
|
366
|
+
* A secondary source location attached to a diagnostic (oxlint's
|
|
367
|
+
* non-primary labels). Editors render these as
|
|
368
|
+
* `Diagnostic.relatedInformation` so a user can jump from, say, a
|
|
369
|
+
* `no-derived-state` finding to the originating prop declaration.
|
|
370
|
+
* Positions mirror `Diagnostic` semantics: `line` / `column` are
|
|
371
|
+
* 1-indexed, and `offset` / `length` are UTF-8 byte spans from oxlint
|
|
372
|
+
* when available (preferred for precise ranges).
|
|
373
|
+
*/
|
|
374
|
+
interface DiagnosticRelatedLocation {
|
|
375
|
+
filePath: string;
|
|
376
|
+
line: number;
|
|
377
|
+
column: number;
|
|
378
|
+
offset?: number;
|
|
379
|
+
length?: number;
|
|
380
|
+
endLine?: number;
|
|
381
|
+
endColumn?: number;
|
|
382
|
+
message: string;
|
|
383
|
+
}
|
|
337
384
|
interface Diagnostic {
|
|
338
385
|
filePath: string;
|
|
339
386
|
plugin: string;
|
|
@@ -345,8 +392,24 @@ interface Diagnostic {
|
|
|
345
392
|
url?: string;
|
|
346
393
|
line: number;
|
|
347
394
|
column: number;
|
|
395
|
+
/**
|
|
396
|
+
* UTF-8 byte offset of the diagnostic's primary span start, straight
|
|
397
|
+
* from oxlint's label span. Optional because environment / dead-code
|
|
398
|
+
* diagnostics carry no source span. Editors (LSP) convert this into a
|
|
399
|
+
* precise range via the in-memory document; non-editor consumers can
|
|
400
|
+
* ignore it.
|
|
401
|
+
*/
|
|
402
|
+
offset?: number;
|
|
403
|
+
/** UTF-8 byte length of the primary span (pairs with `offset`). */
|
|
404
|
+
length?: number;
|
|
405
|
+
/** 1-indexed end line of the primary span, when derivable. */
|
|
406
|
+
endLine?: number;
|
|
407
|
+
/** 1-indexed end column of the primary span, when derivable. */
|
|
408
|
+
endColumn?: number;
|
|
348
409
|
category: string;
|
|
349
410
|
suppressionHint?: string;
|
|
411
|
+
/** Secondary source locations (oxlint's non-primary labels). */
|
|
412
|
+
relatedLocations?: DiagnosticRelatedLocation[];
|
|
350
413
|
}
|
|
351
414
|
//#endregion
|
|
352
415
|
//#region src/types/project-info.d.ts
|
|
@@ -515,6 +578,16 @@ interface InspectResult {
|
|
|
515
578
|
* summary to report combined scan time.
|
|
516
579
|
*/
|
|
517
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
|
+
};
|
|
518
591
|
}
|
|
519
592
|
/**
|
|
520
593
|
* Options accepted by `inspect()`. Mixes two concern groups; ordered
|
|
@@ -543,10 +616,34 @@ interface DiffInfo {
|
|
|
543
616
|
*/
|
|
544
617
|
currentBranch: string | null;
|
|
545
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;
|
|
546
633
|
changedFiles: string[];
|
|
547
634
|
isCurrentChanges?: boolean;
|
|
548
635
|
}
|
|
549
|
-
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
|
+
}
|
|
550
647
|
interface JsonReportDiffInfo {
|
|
551
648
|
baseBranch: string;
|
|
552
649
|
/** `null` when `HEAD` is detached — see `DiffInfo.currentBranch`. */
|
|
@@ -576,8 +673,15 @@ interface JsonReportError {
|
|
|
576
673
|
message: string;
|
|
577
674
|
name: string;
|
|
578
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;
|
|
579
683
|
}
|
|
580
|
-
interface
|
|
684
|
+
interface JsonReportV1$1 {
|
|
581
685
|
schemaVersion: 1;
|
|
582
686
|
version: string;
|
|
583
687
|
ok: boolean;
|
|
@@ -593,7 +697,20 @@ interface JsonReport {
|
|
|
593
697
|
summary: JsonReportSummary;
|
|
594
698
|
elapsedMilliseconds: number;
|
|
595
699
|
error: JsonReportError | null;
|
|
596
|
-
}
|
|
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
|
|
597
714
|
//#region src/types/prompts.d.ts
|
|
598
715
|
//#endregion
|
|
599
716
|
//#region src/project-info/errors.d.ts
|
|
@@ -772,6 +889,8 @@ interface BuildJsonReportErrorInput {
|
|
|
772
889
|
error: unknown;
|
|
773
890
|
elapsedMilliseconds: number;
|
|
774
891
|
mode?: JsonReportMode;
|
|
892
|
+
/** Sentry event id for the crash, when the run reported one. */
|
|
893
|
+
sentryEventId?: string | null;
|
|
775
894
|
}
|
|
776
895
|
declare const buildJsonReportError: (input: BuildJsonReportErrorInput) => JsonReport; //#endregion
|
|
777
896
|
//#region src/build-json-report.d.ts
|
|
@@ -785,6 +904,16 @@ interface BuildJsonReportInput {
|
|
|
785
904
|
result: InspectResult;
|
|
786
905
|
}>;
|
|
787
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
|
+
};
|
|
788
917
|
}
|
|
789
918
|
declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#endregion
|
|
790
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";
|
|
@@ -33,6 +33,7 @@ import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
|
33
33
|
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
34
34
|
import * as ts from "typescript";
|
|
35
35
|
import { gzipSync } from "node:zlib";
|
|
36
|
+
import "effect/Exit";
|
|
36
37
|
//#region \0rolldown/runtime.js
|
|
37
38
|
var __create$1 = Object.create;
|
|
38
39
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -58,6 +59,16 @@ var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(
|
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region ../core/dist/schemas.js
|
|
60
61
|
const Severity = Schema.Literals(["error", "warning"]);
|
|
62
|
+
var DiagnosticRelatedLocation = class extends Schema.Class("DiagnosticRelatedLocation")({
|
|
63
|
+
filePath: Schema.String,
|
|
64
|
+
line: Schema.Number,
|
|
65
|
+
column: Schema.Number,
|
|
66
|
+
offset: Schema.optional(Schema.Number),
|
|
67
|
+
length: Schema.optional(Schema.Number),
|
|
68
|
+
endLine: Schema.optional(Schema.Number),
|
|
69
|
+
endColumn: Schema.optional(Schema.Number),
|
|
70
|
+
message: Schema.String
|
|
71
|
+
}) {};
|
|
61
72
|
var Diagnostic = class extends Schema.Class("Diagnostic")({
|
|
62
73
|
filePath: Schema.String,
|
|
63
74
|
plugin: Schema.String,
|
|
@@ -69,13 +80,19 @@ var Diagnostic = class extends Schema.Class("Diagnostic")({
|
|
|
69
80
|
url: Schema.optional(Schema.String),
|
|
70
81
|
line: Schema.Number,
|
|
71
82
|
column: Schema.Number,
|
|
83
|
+
offset: Schema.optional(Schema.Number),
|
|
84
|
+
length: Schema.optional(Schema.Number),
|
|
85
|
+
endLine: Schema.optional(Schema.Number),
|
|
86
|
+
endColumn: Schema.optional(Schema.Number),
|
|
72
87
|
category: Schema.String,
|
|
73
|
-
suppressionHint: Schema.optional(Schema.String)
|
|
88
|
+
suppressionHint: Schema.optional(Schema.String),
|
|
89
|
+
relatedLocations: Schema.optional(Schema.Array(DiagnosticRelatedLocation))
|
|
74
90
|
}) {};
|
|
75
91
|
const JsonReportMode = Schema.Literals([
|
|
76
92
|
"full",
|
|
77
93
|
"diff",
|
|
78
|
-
"staged"
|
|
94
|
+
"staged",
|
|
95
|
+
"baseline"
|
|
79
96
|
]);
|
|
80
97
|
var JsonReportSummary = class extends Schema.Class("JsonReportSummary")({
|
|
81
98
|
errorCount: Schema.Number,
|
|
@@ -94,7 +111,9 @@ var JsonReportDiffInfo = class extends Schema.Class("JsonReportDiffInfo")({
|
|
|
94
111
|
var JsonReportError = class extends Schema.Class("JsonReportError")({
|
|
95
112
|
message: Schema.String,
|
|
96
113
|
name: Schema.String,
|
|
97
|
-
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))
|
|
98
117
|
}) {};
|
|
99
118
|
/**
|
|
100
119
|
* Schema for a single project entry within a JsonReport. `project` is
|
|
@@ -131,7 +150,33 @@ var JsonReportV1 = class extends Schema.Class("JsonReportV1")({
|
|
|
131
150
|
elapsedMilliseconds: Schema.Number,
|
|
132
151
|
error: Schema.NullOr(JsonReportError)
|
|
133
152
|
}) {};
|
|
134
|
-
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]);
|
|
135
180
|
//#endregion
|
|
136
181
|
//#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js
|
|
137
182
|
var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
@@ -6213,6 +6258,11 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6213
6258
|
branch
|
|
6214
6259
|
]).pipe(Effect.map((result) => result.status === 0));
|
|
6215
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);
|
|
6216
6266
|
const githubRepo = (directory) => runGit(directory, [
|
|
6217
6267
|
"config",
|
|
6218
6268
|
"--get",
|
|
@@ -6288,6 +6338,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6288
6338
|
return {
|
|
6289
6339
|
currentBranch: yield* currentBranch(input.directory),
|
|
6290
6340
|
baseBranch: baseRef,
|
|
6341
|
+
diffBaseRef,
|
|
6291
6342
|
changedFiles: splitNullSeparated(diff.stdout),
|
|
6292
6343
|
isCurrentChanges: false
|
|
6293
6344
|
};
|
|
@@ -6299,6 +6350,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6299
6350
|
githubRepo,
|
|
6300
6351
|
githubViewerPermission,
|
|
6301
6352
|
branchExists,
|
|
6353
|
+
mergeBase,
|
|
6302
6354
|
diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
|
|
6303
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." }) }));
|
|
6304
6356
|
if (explicitBaseBranch !== void 0) {
|
|
@@ -6356,6 +6408,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6356
6408
|
return {
|
|
6357
6409
|
currentBranch: resolvedCurrentBranch,
|
|
6358
6410
|
baseBranch,
|
|
6411
|
+
diffBaseRef: mergeBaseRef,
|
|
6359
6412
|
changedFiles: splitNullSeparated(diff.stdout),
|
|
6360
6413
|
isCurrentChanges: false
|
|
6361
6414
|
};
|
|
@@ -6377,6 +6430,12 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6377
6430
|
directory,
|
|
6378
6431
|
maxStdoutBytes: options?.maxBufferBytes
|
|
6379
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),
|
|
6380
6439
|
grep: (input) => Effect.gen(function* () {
|
|
6381
6440
|
const args = ["grep"];
|
|
6382
6441
|
if (input.listMatchingFiles ?? true) args.push("-l");
|
|
@@ -6412,9 +6471,11 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
|
|
|
6412
6471
|
githubRepo: () => Effect.succeed(snapshot.githubRepo ?? null),
|
|
6413
6472
|
githubViewerPermission: () => Effect.succeed(snapshot.githubViewerPermission ?? null),
|
|
6414
6473
|
branchExists: (_directory, branch) => Effect.succeed(snapshot.branchExists?.get(branch) ?? false),
|
|
6474
|
+
mergeBase: ({ ref }) => Effect.succeed(snapshot.mergeBase?.get(ref) ?? null),
|
|
6415
6475
|
diffSelection: () => Effect.succeed(snapshot.diffSelection ?? null),
|
|
6416
6476
|
stagedFilePaths: () => Effect.succeed(snapshot.stagedFiles ?? []),
|
|
6417
6477
|
showStagedContent: (_directory, relativePath) => Effect.succeed(snapshot.stagedContent?.get(relativePath) ?? null),
|
|
6478
|
+
showRefContent: ({ ref, relativePath }) => Effect.succeed(snapshot.refContent?.get(`${ref}:${relativePath}`) ?? null),
|
|
6418
6479
|
grep: () => Effect.sync(() => {
|
|
6419
6480
|
const matches = snapshot.grepMatches;
|
|
6420
6481
|
if (matches === null || matches === void 0) return null;
|
|
@@ -7469,6 +7530,30 @@ const parseRuleCode = (code) => {
|
|
|
7469
7530
|
};
|
|
7470
7531
|
};
|
|
7471
7532
|
const resolveDiagnosticCategory = (plugin, rule) => getRuleCategory(rule) ?? lookupOwnString(PLUGIN_CATEGORY_MAP, plugin) ?? "Bugs";
|
|
7533
|
+
/**
|
|
7534
|
+
* Maps oxlint's non-primary labels (`labels[1..]`) into related source
|
|
7535
|
+
* locations. Editors surface these as a diagnostic's
|
|
7536
|
+
* `relatedInformation`; non-editor consumers ignore the field. Labels
|
|
7537
|
+
* with empty text still carry a useful jump target, so they're kept
|
|
7538
|
+
* with a neutral message.
|
|
7539
|
+
*/
|
|
7540
|
+
const buildRelatedLocations = (labels, filePath) => {
|
|
7541
|
+
if (labels.length <= 1) return [];
|
|
7542
|
+
const related = [];
|
|
7543
|
+
for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
|
|
7544
|
+
const label = labels[labelIndex];
|
|
7545
|
+
if (!label?.span) continue;
|
|
7546
|
+
related.push({
|
|
7547
|
+
filePath,
|
|
7548
|
+
line: label.span.line ?? 0,
|
|
7549
|
+
column: label.span.column ?? 0,
|
|
7550
|
+
offset: label.span.offset,
|
|
7551
|
+
length: label.span.length,
|
|
7552
|
+
message: label.label ?? ""
|
|
7553
|
+
});
|
|
7554
|
+
}
|
|
7555
|
+
return related;
|
|
7556
|
+
};
|
|
7472
7557
|
const isOxlintOutput = (value) => {
|
|
7473
7558
|
if (typeof value !== "object" || value === null) return false;
|
|
7474
7559
|
const candidate = value;
|
|
@@ -7505,8 +7590,11 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
7505
7590
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
7506
7591
|
const primaryLabel = diagnostic.labels[0];
|
|
7507
7592
|
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
7593
|
+
const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
|
|
7594
|
+
const primarySpan = primaryLabel?.span;
|
|
7595
|
+
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
|
|
7508
7596
|
return {
|
|
7509
|
-
filePath:
|
|
7597
|
+
filePath: normalizedFilePath,
|
|
7510
7598
|
plugin,
|
|
7511
7599
|
rule,
|
|
7512
7600
|
severity: diagnostic.severity,
|
|
@@ -7514,9 +7602,14 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
7514
7602
|
message: cleaned.message,
|
|
7515
7603
|
help: cleaned.help,
|
|
7516
7604
|
url: diagnostic.url,
|
|
7517
|
-
line:
|
|
7518
|
-
column:
|
|
7519
|
-
|
|
7605
|
+
line: primarySpan?.line ?? 0,
|
|
7606
|
+
column: primarySpan?.column ?? 0,
|
|
7607
|
+
...primarySpan ? {
|
|
7608
|
+
offset: primarySpan.offset,
|
|
7609
|
+
length: primarySpan.length
|
|
7610
|
+
} : {},
|
|
7611
|
+
category: resolveDiagnosticCategory(plugin, rule),
|
|
7612
|
+
...relatedLocations.length > 0 ? { relatedLocations } : {}
|
|
7520
7613
|
};
|
|
7521
7614
|
});
|
|
7522
7615
|
};
|
|
@@ -8245,7 +8338,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8245
8338
|
directory: scanDirectory,
|
|
8246
8339
|
repo
|
|
8247
8340
|
}).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
|
|
8248
|
-
const lintIncludePaths = computeJsxIncludePaths([...input.includePaths]) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
|
|
8341
|
+
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeJsxIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
|
|
8249
8342
|
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
|
|
8250
8343
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
8251
8344
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
@@ -8480,57 +8573,74 @@ const resolveNodeForOxlint = () => {
|
|
|
8480
8573
|
});
|
|
8481
8574
|
});
|
|
8482
8575
|
/**
|
|
8483
|
-
* Zip-Slip defense:
|
|
8484
|
-
*
|
|
8485
|
-
*
|
|
8486
|
-
*
|
|
8487
|
-
* working tree) can include `..` segments that escape the temp
|
|
8488
|
-
* tree. Resolve the candidate against the temp dir and reject any
|
|
8489
|
-
* 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.
|
|
8490
8580
|
*/
|
|
8491
8581
|
const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
|
|
8492
|
-
const relative = path
|
|
8493
|
-
return Boolean(relative) && !relative.startsWith("..") && !path
|
|
8582
|
+
const relative = path.relative(parentAbsolutePath, childAbsolutePath);
|
|
8583
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
8494
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
|
+
});
|
|
8495
8629
|
(class StagedFiles extends Context.Service()("react-doctor/StagedFiles") {
|
|
8496
8630
|
static layerNode = Layer.effect(StagedFiles, Effect.gen(function* () {
|
|
8497
8631
|
const git = yield* Git;
|
|
8498
8632
|
return StagedFiles.of({
|
|
8499
8633
|
discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(Effect.map((entries) => entries.filter(isLintableSourceFile))),
|
|
8500
|
-
materialize: ({ directory, stagedFiles, tempDirectory }) =>
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
fs$1.writeFileSync(candidateTargetPath, content);
|
|
8511
|
-
});
|
|
8512
|
-
materializedFiles.push(relativePath);
|
|
8513
|
-
}
|
|
8514
|
-
yield* Effect.sync(() => {
|
|
8515
|
-
for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
|
|
8516
|
-
const sourcePath = path$1.join(directory, configFilename);
|
|
8517
|
-
const targetPath = path$1.join(resolvedTempDirectory, configFilename);
|
|
8518
|
-
if (fs$1.existsSync(sourcePath) && !fs$1.existsSync(targetPath)) fs$1.cpSync(sourcePath, targetPath);
|
|
8519
|
-
}
|
|
8520
|
-
});
|
|
8521
|
-
return {
|
|
8522
|
-
tempDirectory,
|
|
8523
|
-
stagedFiles: materializedFiles,
|
|
8524
|
-
cleanup: () => {
|
|
8525
|
-
try {
|
|
8526
|
-
fs$1.rmSync(tempDirectory, {
|
|
8527
|
-
recursive: true,
|
|
8528
|
-
force: true
|
|
8529
|
-
});
|
|
8530
|
-
} catch {}
|
|
8531
|
-
}
|
|
8532
|
-
};
|
|
8533
|
-
})
|
|
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
|
+
})))
|
|
8534
8644
|
});
|
|
8535
8645
|
}));
|
|
8536
8646
|
/**
|
|
@@ -8576,18 +8686,22 @@ const safeGetErrorChain = (error) => {
|
|
|
8576
8686
|
};
|
|
8577
8687
|
const buildJsonReportError = (input) => {
|
|
8578
8688
|
const chain = safeGetErrorChain(input.error);
|
|
8689
|
+
const sentryEventId = input.sentryEventId ?? null;
|
|
8579
8690
|
const errorPayload = isReactDoctorError(input.error) ? {
|
|
8580
8691
|
message: formatReactDoctorError(input.error),
|
|
8581
8692
|
name: `ReactDoctorError(${input.error.reason._tag})`,
|
|
8582
|
-
chain
|
|
8693
|
+
chain,
|
|
8694
|
+
sentryEventId
|
|
8583
8695
|
} : input.error instanceof Error ? {
|
|
8584
8696
|
message: input.error.message || input.error.name || "Error",
|
|
8585
8697
|
name: input.error.name || "Error",
|
|
8586
|
-
chain
|
|
8698
|
+
chain,
|
|
8699
|
+
sentryEventId
|
|
8587
8700
|
} : {
|
|
8588
8701
|
message: safeStringify(input.error),
|
|
8589
8702
|
name: "Error",
|
|
8590
|
-
chain
|
|
8703
|
+
chain,
|
|
8704
|
+
sentryEventId
|
|
8591
8705
|
};
|
|
8592
8706
|
return {
|
|
8593
8707
|
schemaVersion: 1,
|
|
@@ -8663,12 +8777,10 @@ const buildJsonReport = (input) => {
|
|
|
8663
8777
|
const flattenedDiagnostics = projects.flatMap((entry) => entry.diagnostics);
|
|
8664
8778
|
const worstScoredProject = findWorstScoredProject(projects);
|
|
8665
8779
|
const summary = summarizeDiagnostics(flattenedDiagnostics, worstScoredProject?.score?.score ?? null, worstScoredProject?.score?.label ?? null);
|
|
8666
|
-
|
|
8667
|
-
schemaVersion: 1,
|
|
8780
|
+
const shared = {
|
|
8668
8781
|
version: input.version,
|
|
8669
8782
|
ok: true,
|
|
8670
8783
|
directory: input.directory,
|
|
8671
|
-
mode: input.mode,
|
|
8672
8784
|
diff: toJsonDiff(input.diff),
|
|
8673
8785
|
projects,
|
|
8674
8786
|
diagnostics: flattenedDiagnostics,
|
|
@@ -8676,6 +8788,22 @@ const buildJsonReport = (input) => {
|
|
|
8676
8788
|
elapsedMilliseconds: input.totalElapsedMilliseconds,
|
|
8677
8789
|
error: null
|
|
8678
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
|
+
};
|
|
8679
8807
|
};
|
|
8680
8808
|
/**
|
|
8681
8809
|
* Single source of truth for the skipped-check accounting shared by the
|
|
@@ -8719,6 +8847,7 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
|
|
|
8719
8847
|
return {
|
|
8720
8848
|
currentBranch: selection.currentBranch,
|
|
8721
8849
|
baseBranch: selection.baseBranch,
|
|
8850
|
+
...selection.diffBaseRef !== void 0 ? { diffBaseRef: selection.diffBaseRef } : {},
|
|
8722
8851
|
changedFiles: [...selection.changedFiles],
|
|
8723
8852
|
...selection.isCurrentChanges ? { isCurrentChanges: true } : {}
|
|
8724
8853
|
};
|
|
@@ -8800,4 +8929,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8800
8929
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8801
8930
|
|
|
8802
8931
|
//# sourceMappingURL=index.js.map
|
|
8803
|
-
//# debugId=
|
|
8932
|
+
//# debugId=44e73f8d-b81f-599b-a04e-22497cd72bb2
|