react-doctor 0.3.0 → 0.4.0-dev.36ecd05

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/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
- type FailOnLevel = "error" | "warning" | "none";
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 `--fail-on` exit
50
- * code gate. A diagnostic excluded from this surface never fails the
51
- * build, regardless of severity.
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
- * `--fail-on`).
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
- failOn?: FailOnLevel;
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 `--fail-on` — all
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
- * (`--fail-on`, the score, the printed list) all see the
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 JsonReport {
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
- } //#endregion
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]="78466bb6-1333-5899-a21b-ca9ce49351a3")}catch(e){}}();
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]="122e86e2-7fd2-5262-b325-14cf4d9fee78")}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.Union([JsonReportV1]);
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) => {
@@ -5298,6 +5343,7 @@ const checkReducedMotion = (rootDirectory) => {
5298
5343
  if (!hasMotionLibrary) return [];
5299
5344
  const result = spawnSync("git", [
5300
5345
  "grep",
5346
+ "--untracked",
5301
5347
  "-ql",
5302
5348
  "-E",
5303
5349
  REDUCED_MOTION_GREP_PATTERN,
@@ -6213,6 +6259,11 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6213
6259
  branch
6214
6260
  ]).pipe(Effect.map((result) => result.status === 0));
6215
6261
  const headSha = (directory) => runGit(directory, ["rev-parse", "HEAD"]).pipe(Effect.map((result) => result.status === 0 ? trimOrNull(result.stdout) : null));
6262
+ const mergeBase = (input) => isSafeGitRevision(input.ref) ? runGit(input.directory, [
6263
+ "merge-base",
6264
+ input.ref,
6265
+ "HEAD"
6266
+ ]).pipe(Effect.map((result) => result.status === 0 ? trimOrNull(result.stdout) : null)) : Effect.succeed(null);
6216
6267
  const githubRepo = (directory) => runGit(directory, [
6217
6268
  "config",
6218
6269
  "--get",
@@ -6288,6 +6339,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6288
6339
  return {
6289
6340
  currentBranch: yield* currentBranch(input.directory),
6290
6341
  baseBranch: baseRef,
6342
+ diffBaseRef,
6291
6343
  changedFiles: splitNullSeparated(diff.stdout),
6292
6344
  isCurrentChanges: false
6293
6345
  };
@@ -6299,6 +6351,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6299
6351
  githubRepo,
6300
6352
  githubViewerPermission,
6301
6353
  branchExists,
6354
+ mergeBase,
6302
6355
  diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
6303
6356
  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
6357
  if (explicitBaseBranch !== void 0) {
@@ -6356,6 +6409,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6356
6409
  return {
6357
6410
  currentBranch: resolvedCurrentBranch,
6358
6411
  baseBranch,
6412
+ diffBaseRef: mergeBaseRef,
6359
6413
  changedFiles: splitNullSeparated(diff.stdout),
6360
6414
  isCurrentChanges: false
6361
6415
  };
@@ -6377,6 +6431,12 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6377
6431
  directory,
6378
6432
  maxStdoutBytes: options?.maxBufferBytes
6379
6433
  }).pipe(Effect.map((result) => result.status === 0 ? result.stdout : null)),
6434
+ showRefContent: ({ directory, ref, relativePath, options }) => isSafeGitRevision(ref) ? runCommand({
6435
+ command: "git",
6436
+ args: ["show", `${ref}:./${relativePath}`],
6437
+ directory,
6438
+ maxStdoutBytes: options?.maxBufferBytes
6439
+ }).pipe(Effect.map((result) => result.status === 0 ? result.stdout : null)) : Effect.succeed(null),
6380
6440
  grep: (input) => Effect.gen(function* () {
6381
6441
  const args = ["grep"];
6382
6442
  if (input.listMatchingFiles ?? true) args.push("-l");
@@ -6412,9 +6472,11 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6412
6472
  githubRepo: () => Effect.succeed(snapshot.githubRepo ?? null),
6413
6473
  githubViewerPermission: () => Effect.succeed(snapshot.githubViewerPermission ?? null),
6414
6474
  branchExists: (_directory, branch) => Effect.succeed(snapshot.branchExists?.get(branch) ?? false),
6475
+ mergeBase: ({ ref }) => Effect.succeed(snapshot.mergeBase?.get(ref) ?? null),
6415
6476
  diffSelection: () => Effect.succeed(snapshot.diffSelection ?? null),
6416
6477
  stagedFilePaths: () => Effect.succeed(snapshot.stagedFiles ?? []),
6417
6478
  showStagedContent: (_directory, relativePath) => Effect.succeed(snapshot.stagedContent?.get(relativePath) ?? null),
6479
+ showRefContent: ({ ref, relativePath }) => Effect.succeed(snapshot.refContent?.get(`${ref}:${relativePath}`) ?? null),
6418
6480
  grep: () => Effect.sync(() => {
6419
6481
  const matches = snapshot.grepMatches;
6420
6482
  if (matches === null || matches === void 0) return null;
@@ -7469,6 +7531,30 @@ const parseRuleCode = (code) => {
7469
7531
  };
7470
7532
  };
7471
7533
  const resolveDiagnosticCategory = (plugin, rule) => getRuleCategory(rule) ?? lookupOwnString(PLUGIN_CATEGORY_MAP, plugin) ?? "Bugs";
7534
+ /**
7535
+ * Maps oxlint's non-primary labels (`labels[1..]`) into related source
7536
+ * locations. Editors surface these as a diagnostic's
7537
+ * `relatedInformation`; non-editor consumers ignore the field. Labels
7538
+ * with empty text still carry a useful jump target, so they're kept
7539
+ * with a neutral message.
7540
+ */
7541
+ const buildRelatedLocations = (labels, filePath) => {
7542
+ if (labels.length <= 1) return [];
7543
+ const related = [];
7544
+ for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
7545
+ const label = labels[labelIndex];
7546
+ if (!label?.span) continue;
7547
+ related.push({
7548
+ filePath,
7549
+ line: label.span.line ?? 0,
7550
+ column: label.span.column ?? 0,
7551
+ offset: label.span.offset,
7552
+ length: label.span.length,
7553
+ message: label.label ?? ""
7554
+ });
7555
+ }
7556
+ return related;
7557
+ };
7472
7558
  const isOxlintOutput = (value) => {
7473
7559
  if (typeof value !== "object" || value === null) return false;
7474
7560
  const candidate = value;
@@ -7505,8 +7591,11 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
7505
7591
  const { plugin, rule } = parseRuleCode(diagnostic.code);
7506
7592
  const primaryLabel = diagnostic.labels[0];
7507
7593
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
7594
+ const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
7595
+ const primarySpan = primaryLabel?.span;
7596
+ const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
7508
7597
  return {
7509
- filePath: diagnostic.filename.replaceAll("\\", "/"),
7598
+ filePath: normalizedFilePath,
7510
7599
  plugin,
7511
7600
  rule,
7512
7601
  severity: diagnostic.severity,
@@ -7514,9 +7603,14 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
7514
7603
  message: cleaned.message,
7515
7604
  help: cleaned.help,
7516
7605
  url: diagnostic.url,
7517
- line: primaryLabel?.span.line ?? 0,
7518
- column: primaryLabel?.span.column ?? 0,
7519
- category: resolveDiagnosticCategory(plugin, rule)
7606
+ line: primarySpan?.line ?? 0,
7607
+ column: primarySpan?.column ?? 0,
7608
+ ...primarySpan ? {
7609
+ offset: primarySpan.offset,
7610
+ length: primarySpan.length
7611
+ } : {},
7612
+ category: resolveDiagnosticCategory(plugin, rule),
7613
+ ...relatedLocations.length > 0 ? { relatedLocations } : {}
7520
7614
  };
7521
7615
  });
7522
7616
  };
@@ -8245,7 +8339,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
8245
8339
  directory: scanDirectory,
8246
8340
  repo
8247
8341
  }).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
8248
- const lintIncludePaths = computeJsxIncludePaths([...input.includePaths]) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
8342
+ const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeJsxIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
8249
8343
  const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
8250
8344
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
8251
8345
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
@@ -8480,57 +8574,74 @@ const resolveNodeForOxlint = () => {
8480
8574
  });
8481
8575
  });
8482
8576
  /**
8483
- * Zip-Slip defense: `git diff --cached --name-only` is the source
8484
- * of `relativePath`, and git normalizes paths during ordinary
8485
- * `git add`. But a deliberately crafted index entry (via
8486
- * `git update-index --add`, a malicious pack, or a symlinked
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.
8577
+ * Zip-Slip defense: relative paths come from git (`diff --name-only`), which
8578
+ * normalizes during ordinary adds, but a crafted index/pack/symlinked tree can
8579
+ * smuggle `..` segments that escape the temp root. Resolve against the temp dir
8580
+ * and reject anything that lands outside before writing.
8490
8581
  */
8491
8582
  const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
8492
- const relative = path$1.relative(parentAbsolutePath, childAbsolutePath);
8493
- return Boolean(relative) && !relative.startsWith("..") && !path$1.isAbsolute(relative);
8583
+ const relative = path.relative(parentAbsolutePath, childAbsolutePath);
8584
+ return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
8494
8585
  };
8586
+ /**
8587
+ * Writes a set of source files (supplied by `readContent` — e.g.
8588
+ * `git show <ref>:<path>` for a baseline tree, or `git show :<path>` for the
8589
+ * index) into a temp tree that mirrors the project layout, copying the
8590
+ * well-known project-config files from `directory` so oxlint resolves
8591
+ * tsconfig / lint config identically to the working tree. Shared by the staged
8592
+ * and baseline scan paths so the zip-slip guard lives in one audited place.
8593
+ * Per-file read failures skip that file (the scan proceeds with whatever read
8594
+ * cleanly) rather than sinking the whole snapshot.
8595
+ */
8596
+ const materializeSourceTree = (input) => Effect.gen(function* () {
8597
+ const materializedFiles = [];
8598
+ const resolvedTempDirectory = path.resolve(input.tempDirectory);
8599
+ for (const relativePath of input.files) {
8600
+ const content = yield* input.readContent(relativePath).pipe(Effect.orElseSucceed(() => null));
8601
+ if (content === null) continue;
8602
+ const candidateTargetPath = path.resolve(resolvedTempDirectory, relativePath);
8603
+ if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
8604
+ yield* Effect.sync(() => {
8605
+ fs.mkdirSync(path.dirname(candidateTargetPath), { recursive: true });
8606
+ fs.writeFileSync(candidateTargetPath, content);
8607
+ });
8608
+ materializedFiles.push(relativePath);
8609
+ }
8610
+ yield* Effect.sync(() => {
8611
+ for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
8612
+ const sourcePath = path.join(input.directory, configFilename);
8613
+ const targetPath = path.join(resolvedTempDirectory, configFilename);
8614
+ if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) fs.cpSync(sourcePath, targetPath);
8615
+ }
8616
+ });
8617
+ return {
8618
+ tempDirectory: input.tempDirectory,
8619
+ materializedFiles,
8620
+ cleanup: () => {
8621
+ try {
8622
+ fs.rmSync(input.tempDirectory, {
8623
+ recursive: true,
8624
+ force: true
8625
+ });
8626
+ } catch {}
8627
+ }
8628
+ };
8629
+ });
8495
8630
  (class StagedFiles extends Context.Service()("react-doctor/StagedFiles") {
8496
8631
  static layerNode = Layer.effect(StagedFiles, Effect.gen(function* () {
8497
8632
  const git = yield* Git;
8498
8633
  return StagedFiles.of({
8499
8634
  discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(Effect.map((entries) => entries.filter(isLintableSourceFile))),
8500
- materialize: ({ directory, stagedFiles, tempDirectory }) => Effect.gen(function* () {
8501
- const materializedFiles = [];
8502
- const resolvedTempDirectory = path$1.resolve(tempDirectory);
8503
- for (const relativePath of stagedFiles) {
8504
- const content = yield* git.showStagedContent(directory, relativePath, { maxBufferBytes: GIT_SHOW_MAX_BUFFER_BYTES }).pipe(Effect.orElseSucceed(() => null));
8505
- if (content === null) continue;
8506
- const candidateTargetPath = path$1.resolve(resolvedTempDirectory, relativePath);
8507
- if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
8508
- yield* Effect.sync(() => {
8509
- fs$1.mkdirSync(path$1.dirname(candidateTargetPath), { recursive: true });
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
- })
8635
+ materialize: ({ directory, stagedFiles, tempDirectory }) => materializeSourceTree({
8636
+ directory,
8637
+ files: stagedFiles,
8638
+ tempDirectory,
8639
+ readContent: (relativePath) => git.showStagedContent(directory, relativePath, { maxBufferBytes: GIT_SHOW_MAX_BUFFER_BYTES })
8640
+ }).pipe(Effect.map((tree) => ({
8641
+ tempDirectory: tree.tempDirectory,
8642
+ stagedFiles: tree.materializedFiles,
8643
+ cleanup: tree.cleanup
8644
+ })))
8534
8645
  });
8535
8646
  }));
8536
8647
  /**
@@ -8576,18 +8687,22 @@ const safeGetErrorChain = (error) => {
8576
8687
  };
8577
8688
  const buildJsonReportError = (input) => {
8578
8689
  const chain = safeGetErrorChain(input.error);
8690
+ const sentryEventId = input.sentryEventId ?? null;
8579
8691
  const errorPayload = isReactDoctorError(input.error) ? {
8580
8692
  message: formatReactDoctorError(input.error),
8581
8693
  name: `ReactDoctorError(${input.error.reason._tag})`,
8582
- chain
8694
+ chain,
8695
+ sentryEventId
8583
8696
  } : input.error instanceof Error ? {
8584
8697
  message: input.error.message || input.error.name || "Error",
8585
8698
  name: input.error.name || "Error",
8586
- chain
8699
+ chain,
8700
+ sentryEventId
8587
8701
  } : {
8588
8702
  message: safeStringify(input.error),
8589
8703
  name: "Error",
8590
- chain
8704
+ chain,
8705
+ sentryEventId
8591
8706
  };
8592
8707
  return {
8593
8708
  schemaVersion: 1,
@@ -8663,12 +8778,10 @@ const buildJsonReport = (input) => {
8663
8778
  const flattenedDiagnostics = projects.flatMap((entry) => entry.diagnostics);
8664
8779
  const worstScoredProject = findWorstScoredProject(projects);
8665
8780
  const summary = summarizeDiagnostics(flattenedDiagnostics, worstScoredProject?.score?.score ?? null, worstScoredProject?.score?.label ?? null);
8666
- return {
8667
- schemaVersion: 1,
8781
+ const shared = {
8668
8782
  version: input.version,
8669
8783
  ok: true,
8670
8784
  directory: input.directory,
8671
- mode: input.mode,
8672
8785
  diff: toJsonDiff(input.diff),
8673
8786
  projects,
8674
8787
  diagnostics: flattenedDiagnostics,
@@ -8676,6 +8789,22 @@ const buildJsonReport = (input) => {
8676
8789
  elapsedMilliseconds: input.totalElapsedMilliseconds,
8677
8790
  error: null
8678
8791
  };
8792
+ if (input.baseline) return {
8793
+ schemaVersion: 2,
8794
+ mode: "baseline",
8795
+ baseline: {
8796
+ baseRef: input.baseline.baseRef,
8797
+ newCount: summary.totalDiagnosticCount,
8798
+ fixedCount: input.baseline.fixedCount,
8799
+ baseTotalCount: input.baseline.baseTotalCount
8800
+ },
8801
+ ...shared
8802
+ };
8803
+ return {
8804
+ schemaVersion: 1,
8805
+ mode: input.mode,
8806
+ ...shared
8807
+ };
8679
8808
  };
8680
8809
  /**
8681
8810
  * Single source of truth for the skipped-check accounting shared by the
@@ -8719,6 +8848,7 @@ const getDiffInfo = (directory, explicitBaseBranch) => Effect.runPromise(Effect.
8719
8848
  return {
8720
8849
  currentBranch: selection.currentBranch,
8721
8850
  baseBranch: selection.baseBranch,
8851
+ ...selection.diffBaseRef !== void 0 ? { diffBaseRef: selection.diffBaseRef } : {},
8722
8852
  changedFiles: [...selection.changedFiles],
8723
8853
  ...selection.isCurrentChanges ? { isCurrentChanges: true } : {}
8724
8854
  };
@@ -8800,4 +8930,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8800
8930
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8801
8931
 
8802
8932
  //# sourceMappingURL=index.js.map
8803
- //# debugId=78466bb6-1333-5899-a21b-ca9ce49351a3
8933
+ //# debugId=122e86e2-7fd2-5262-b325-14cf4d9fee78