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/dist/lsp.js CHANGED
@@ -31,12 +31,12 @@ import * as ChildProcess from "effect/unstable/process/ChildProcess";
31
31
  import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
32
32
  import * as ts from "typescript";
33
33
  import { gzipSync } from "node:zlib";
34
+ import crypto from "node:crypto";
34
35
  import * as Exit from "effect/Exit";
35
36
  import { CodeActionKind, CodeActionTriggerKind, DidChangeWatchedFilesNotification, DocumentDiagnosticReportKind, FileChangeType, TextDocumentSyncKind, TextDocuments, createConnection } from "vscode-languageserver/node.js";
36
37
  import { TextDocument } from "vscode-languageserver-textdocument";
37
38
  import { URI } from "vscode-uri";
38
39
  import { CodeActionKind as CodeActionKind$1, DiagnosticSeverity, DiagnosticTag, MarkupKind } from "vscode-languageserver";
39
- import crypto from "node:crypto";
40
40
  import * as Sentry from "@sentry/node";
41
41
  //#region \0rolldown/runtime.js
42
42
  var __create$1 = Object.create;
@@ -102,7 +102,8 @@ const buildDiagnosticIdentity = (input) => `${input.filePath}::${input.line}:${i
102
102
  const JsonReportMode = Schema.Literals([
103
103
  "full",
104
104
  "diff",
105
- "staged"
105
+ "staged",
106
+ "baseline"
106
107
  ]);
107
108
  var JsonReportSummary = class extends Schema.Class("JsonReportSummary")({
108
109
  errorCount: Schema.Number,
@@ -121,7 +122,9 @@ var JsonReportDiffInfo = class extends Schema.Class("JsonReportDiffInfo")({
121
122
  var JsonReportError = class extends Schema.Class("JsonReportError")({
122
123
  message: Schema.String,
123
124
  name: Schema.String,
124
- chain: Schema.Array(Schema.String)
125
+ chain: Schema.Array(Schema.String),
126
+ /** Sentry event id for the crash, when one was reported. */
127
+ sentryEventId: Schema.optional(Schema.NullOr(Schema.String))
125
128
  }) {};
126
129
  /**
127
130
  * Schema for a single project entry within a JsonReport. `project` is
@@ -158,7 +161,33 @@ var JsonReportV1 = class extends Schema.Class("JsonReportV1")({
158
161
  elapsedMilliseconds: Schema.Number,
159
162
  error: Schema.NullOr(JsonReportError)
160
163
  }) {};
161
- Schema.Union([JsonReportV1]);
164
+ var JsonReportBaseline = class extends Schema.Class("JsonReportBaseline")({
165
+ baseRef: Schema.String,
166
+ newCount: Schema.Number,
167
+ fixedCount: Schema.Number,
168
+ baseTotalCount: Schema.Number
169
+ }) {};
170
+ /**
171
+ * Baseline (PR-introduced-issues-only) report — `schemaVersion: 2`. A
172
+ * superset of v1: same fields, plus a `baseline` block. `diagnostics` /
173
+ * `summary` counts are the introduced findings only; `summary.score` stays
174
+ * the head project-health score. Consumers branch on `schemaVersion`.
175
+ */
176
+ var JsonReportV2 = class extends Schema.Class("JsonReportV2")({
177
+ schemaVersion: Schema.Literal(2),
178
+ version: Schema.String,
179
+ ok: Schema.Boolean,
180
+ directory: Schema.String,
181
+ mode: JsonReportMode,
182
+ diff: Schema.NullOr(JsonReportDiffInfo),
183
+ baseline: JsonReportBaseline,
184
+ projects: Schema.Array(JsonReportProjectEntry),
185
+ diagnostics: Schema.Array(Diagnostic),
186
+ summary: JsonReportSummary,
187
+ elapsedMilliseconds: Schema.Number,
188
+ error: Schema.NullOr(JsonReportError)
189
+ }) {};
190
+ Schema.Union([JsonReportV1, JsonReportV2]);
162
191
  //#endregion
163
192
  //#region ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js
164
193
  var require_constants = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
@@ -6166,6 +6195,11 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6166
6195
  branch
6167
6196
  ]).pipe(Effect.map((result) => result.status === 0));
6168
6197
  const headSha = (directory) => runGit(directory, ["rev-parse", "HEAD"]).pipe(Effect.map((result) => result.status === 0 ? trimOrNull(result.stdout) : null));
6198
+ const mergeBase = (input) => isSafeGitRevision(input.ref) ? runGit(input.directory, [
6199
+ "merge-base",
6200
+ input.ref,
6201
+ "HEAD"
6202
+ ]).pipe(Effect.map((result) => result.status === 0 ? trimOrNull(result.stdout) : null)) : Effect.succeed(null);
6169
6203
  const githubRepo = (directory) => runGit(directory, [
6170
6204
  "config",
6171
6205
  "--get",
@@ -6241,6 +6275,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6241
6275
  return {
6242
6276
  currentBranch: yield* currentBranch(input.directory),
6243
6277
  baseBranch: baseRef,
6278
+ diffBaseRef,
6244
6279
  changedFiles: splitNullSeparated(diff.stdout),
6245
6280
  isCurrentChanges: false
6246
6281
  };
@@ -6252,6 +6287,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6252
6287
  githubRepo,
6253
6288
  githubViewerPermission,
6254
6289
  branchExists,
6290
+ mergeBase,
6255
6291
  diffSelection: ({ directory, explicitBaseBranch }) => Effect.gen(function* () {
6256
6292
  if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* Effect.fail(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
6257
6293
  if (explicitBaseBranch !== void 0) {
@@ -6309,6 +6345,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6309
6345
  return {
6310
6346
  currentBranch: resolvedCurrentBranch,
6311
6347
  baseBranch,
6348
+ diffBaseRef: mergeBaseRef,
6312
6349
  changedFiles: splitNullSeparated(diff.stdout),
6313
6350
  isCurrentChanges: false
6314
6351
  };
@@ -6330,6 +6367,12 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6330
6367
  directory,
6331
6368
  maxStdoutBytes: options?.maxBufferBytes
6332
6369
  }).pipe(Effect.map((result) => result.status === 0 ? result.stdout : null)),
6370
+ showRefContent: ({ directory, ref, relativePath, options }) => isSafeGitRevision(ref) ? runCommand({
6371
+ command: "git",
6372
+ args: ["show", `${ref}:./${relativePath}`],
6373
+ directory,
6374
+ maxStdoutBytes: options?.maxBufferBytes
6375
+ }).pipe(Effect.map((result) => result.status === 0 ? result.stdout : null)) : Effect.succeed(null),
6333
6376
  grep: (input) => Effect.gen(function* () {
6334
6377
  const args = ["grep"];
6335
6378
  if (input.listMatchingFiles ?? true) args.push("-l");
@@ -6365,9 +6408,11 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6365
6408
  githubRepo: () => Effect.succeed(snapshot.githubRepo ?? null),
6366
6409
  githubViewerPermission: () => Effect.succeed(snapshot.githubViewerPermission ?? null),
6367
6410
  branchExists: (_directory, branch) => Effect.succeed(snapshot.branchExists?.get(branch) ?? false),
6411
+ mergeBase: ({ ref }) => Effect.succeed(snapshot.mergeBase?.get(ref) ?? null),
6368
6412
  diffSelection: () => Effect.succeed(snapshot.diffSelection ?? null),
6369
6413
  stagedFilePaths: () => Effect.succeed(snapshot.stagedFiles ?? []),
6370
6414
  showStagedContent: (_directory, relativePath) => Effect.succeed(snapshot.stagedContent?.get(relativePath) ?? null),
6415
+ showRefContent: ({ ref, relativePath }) => Effect.succeed(snapshot.refContent?.get(`${ref}:${relativePath}`) ?? null),
6371
6416
  grep: () => Effect.sync(() => {
6372
6417
  const matches = snapshot.grepMatches;
6373
6418
  if (matches === null || matches === void 0) return null;
@@ -8465,57 +8510,74 @@ const resolveNodeForOxlint = () => {
8465
8510
  });
8466
8511
  });
8467
8512
  /**
8468
- * Zip-Slip defense: `git diff --cached --name-only` is the source
8469
- * of `relativePath`, and git normalizes paths during ordinary
8470
- * `git add`. But a deliberately crafted index entry (via
8471
- * `git update-index --add`, a malicious pack, or a symlinked
8472
- * working tree) can include `..` segments that escape the temp
8473
- * tree. Resolve the candidate against the temp dir and reject any
8474
- * result that lands outside it before `writeFileSync` runs.
8513
+ * Zip-Slip defense: relative paths come from git (`diff --name-only`), which
8514
+ * normalizes during ordinary adds, but a crafted index/pack/symlinked tree can
8515
+ * smuggle `..` segments that escape the temp root. Resolve against the temp dir
8516
+ * and reject anything that lands outside before writing.
8475
8517
  */
8476
8518
  const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
8477
- const relative = path$1.relative(parentAbsolutePath, childAbsolutePath);
8478
- return Boolean(relative) && !relative.startsWith("..") && !path$1.isAbsolute(relative);
8519
+ const relative = path.relative(parentAbsolutePath, childAbsolutePath);
8520
+ return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
8479
8521
  };
8522
+ /**
8523
+ * Writes a set of source files (supplied by `readContent` — e.g.
8524
+ * `git show <ref>:<path>` for a baseline tree, or `git show :<path>` for the
8525
+ * index) into a temp tree that mirrors the project layout, copying the
8526
+ * well-known project-config files from `directory` so oxlint resolves
8527
+ * tsconfig / lint config identically to the working tree. Shared by the staged
8528
+ * and baseline scan paths so the zip-slip guard lives in one audited place.
8529
+ * Per-file read failures skip that file (the scan proceeds with whatever read
8530
+ * cleanly) rather than sinking the whole snapshot.
8531
+ */
8532
+ const materializeSourceTree = (input) => Effect.gen(function* () {
8533
+ const materializedFiles = [];
8534
+ const resolvedTempDirectory = path.resolve(input.tempDirectory);
8535
+ for (const relativePath of input.files) {
8536
+ const content = yield* input.readContent(relativePath).pipe(Effect.orElseSucceed(() => null));
8537
+ if (content === null) continue;
8538
+ const candidateTargetPath = path.resolve(resolvedTempDirectory, relativePath);
8539
+ if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
8540
+ yield* Effect.sync(() => {
8541
+ fs.mkdirSync(path.dirname(candidateTargetPath), { recursive: true });
8542
+ fs.writeFileSync(candidateTargetPath, content);
8543
+ });
8544
+ materializedFiles.push(relativePath);
8545
+ }
8546
+ yield* Effect.sync(() => {
8547
+ for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
8548
+ const sourcePath = path.join(input.directory, configFilename);
8549
+ const targetPath = path.join(resolvedTempDirectory, configFilename);
8550
+ if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) fs.cpSync(sourcePath, targetPath);
8551
+ }
8552
+ });
8553
+ return {
8554
+ tempDirectory: input.tempDirectory,
8555
+ materializedFiles,
8556
+ cleanup: () => {
8557
+ try {
8558
+ fs.rmSync(input.tempDirectory, {
8559
+ recursive: true,
8560
+ force: true
8561
+ });
8562
+ } catch {}
8563
+ }
8564
+ };
8565
+ });
8480
8566
  (class StagedFiles extends Context.Service()("react-doctor/StagedFiles") {
8481
8567
  static layerNode = Layer.effect(StagedFiles, Effect.gen(function* () {
8482
8568
  const git = yield* Git;
8483
8569
  return StagedFiles.of({
8484
8570
  discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(Effect.map((entries) => entries.filter(isLintableSourceFile))),
8485
- materialize: ({ directory, stagedFiles, tempDirectory }) => Effect.gen(function* () {
8486
- const materializedFiles = [];
8487
- const resolvedTempDirectory = path$1.resolve(tempDirectory);
8488
- for (const relativePath of stagedFiles) {
8489
- const content = yield* git.showStagedContent(directory, relativePath, { maxBufferBytes: GIT_SHOW_MAX_BUFFER_BYTES }).pipe(Effect.orElseSucceed(() => null));
8490
- if (content === null) continue;
8491
- const candidateTargetPath = path$1.resolve(resolvedTempDirectory, relativePath);
8492
- if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
8493
- yield* Effect.sync(() => {
8494
- fs$1.mkdirSync(path$1.dirname(candidateTargetPath), { recursive: true });
8495
- fs$1.writeFileSync(candidateTargetPath, content);
8496
- });
8497
- materializedFiles.push(relativePath);
8498
- }
8499
- yield* Effect.sync(() => {
8500
- for (const configFilename of STAGED_FILES_PROJECT_CONFIG_FILENAMES) {
8501
- const sourcePath = path$1.join(directory, configFilename);
8502
- const targetPath = path$1.join(resolvedTempDirectory, configFilename);
8503
- if (fs$1.existsSync(sourcePath) && !fs$1.existsSync(targetPath)) fs$1.cpSync(sourcePath, targetPath);
8504
- }
8505
- });
8506
- return {
8507
- tempDirectory,
8508
- stagedFiles: materializedFiles,
8509
- cleanup: () => {
8510
- try {
8511
- fs$1.rmSync(tempDirectory, {
8512
- recursive: true,
8513
- force: true
8514
- });
8515
- } catch {}
8516
- }
8517
- };
8518
- })
8571
+ materialize: ({ directory, stagedFiles, tempDirectory }) => materializeSourceTree({
8572
+ directory,
8573
+ files: stagedFiles,
8574
+ tempDirectory,
8575
+ readContent: (relativePath) => git.showStagedContent(directory, relativePath, { maxBufferBytes: GIT_SHOW_MAX_BUFFER_BYTES })
8576
+ }).pipe(Effect.map((tree) => ({
8577
+ tempDirectory: tree.tempDirectory,
8578
+ stagedFiles: tree.materializedFiles,
8579
+ cleanup: tree.cleanup
8580
+ })))
8519
8581
  });
8520
8582
  }));
8521
8583
  /**
@@ -10402,6 +10464,7 @@ const METRIC = {
10402
10464
  scanScore: "scan.score",
10403
10465
  scanClean: "scan.clean",
10404
10466
  scanCheckSkipped: "scan.check_skipped",
10467
+ baselineDegraded: "baseline.degraded",
10405
10468
  ruleFired: "rule.fired",
10406
10469
  lintFailed: "lint.failed",
10407
10470
  deadCodeFailed: "deadcode.failed",
@@ -10737,5 +10800,5 @@ const startLanguageServer = () => {
10737
10800
  };
10738
10801
  //#endregion
10739
10802
  export { startLanguageServer };
10740
- !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]="b511e523-1a41-564e-9005-d6a8133fcd38")}catch(e){}}();
10741
- //# debugId=b511e523-1a41-564e-9005-d6a8133fcd38
10803
+ !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]="e614bb84-5901-5a70-99a0-7f973d27a6b7")}catch(e){}}();
10804
+ //# debugId=e614bb84-5901-5a70-99a0-7f973d27a6b7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.3.0-dev.915745e",
3
+ "version": "0.3.0-dev.9a8ad6e",
4
4
  "description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -66,7 +66,7 @@
66
66
  "vscode-languageserver": "^9.0.1",
67
67
  "vscode-languageserver-textdocument": "^1.0.12",
68
68
  "vscode-uri": "^3.1.0",
69
- "oxlint-plugin-react-doctor": "0.3.0-dev.915745e"
69
+ "oxlint-plugin-react-doctor": "0.3.0-dev.9a8ad6e"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/babel__code-frame": "^7.27.0",