react-doctor 0.7.4-dev.d4f2209 → 0.7.4

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.js CHANGED
@@ -1,15 +1,15 @@
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]="95e70e55-12b7-5577-81f3-f5331db7ca53")}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]="e047abe8-ac42-570c-8465-e0f0dcb0715c")}catch(e){}}();
3
3
  import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
4
4
  import { createRequire } from "node:module";
5
- import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
6
5
  import * as NFS from "node:fs";
7
6
  import fs from "node:fs";
8
7
  import * as Path from "node:path";
9
8
  import path from "node:path";
10
9
  import * as NodeChildProcess from "node:child_process";
11
10
  import { execFileSync, spawn, spawnSync } from "node:child_process";
12
- import ts from "typescript";
11
+ import * as ts from "typescript";
12
+ import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
13
13
  import * as OS from "node:os";
14
14
  import os from "node:os";
15
15
  import { parseJSON5 } from "confbox";
@@ -19310,45 +19310,12 @@ var Diagnostic = class extends Class("Diagnostic")({
19310
19310
  relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation)),
19311
19311
  fixGroupId: optional(String$1)
19312
19312
  }) {};
19313
- var JsonReportDiagnosticV3 = class extends Class("JsonReportDiagnosticV3")({
19314
- id: String$1,
19315
- normalizedFilePath: String$1,
19316
- filePath: String$1,
19317
- plugin: String$1,
19318
- rule: String$1,
19319
- severity: Severity,
19320
- tags: ArraySchema(String$1),
19321
- title: optional(String$1),
19322
- message: String$1,
19323
- help: String$1,
19324
- url: optional(String$1),
19325
- line: Number$1,
19326
- column: Number$1,
19327
- offset: optional(Number$1),
19328
- length: optional(Number$1),
19329
- endLine: optional(Number$1),
19330
- endColumn: optional(Number$1),
19331
- category: String$1,
19332
- matchByOccurrence: optional(Boolean$1),
19333
- fileContext: optional(Literals(["test", "story"])),
19334
- suppressionHint: optional(String$1),
19335
- relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation)),
19336
- fixGroupId: optional(String$1)
19337
- }) {};
19338
- /**
19339
- * Deterministic identity string for a diagnostic. Same diagnostic
19340
- * across two scans yields the same identity; lets baselines,
19341
- * suppression files, content-hash caches, and IDE "ignore this"
19342
- * actions all key off one shared shape.
19343
- */
19344
- const buildDiagnosticIdentity = (input) => `${input.filePath}::${input.line}:${input.column}::${input.plugin}/${input.rule}`;
19345
19313
  const JsonReportMode = Literals([
19346
19314
  "full",
19347
19315
  "diff",
19348
19316
  "staged",
19349
19317
  "baseline"
19350
19318
  ]);
19351
- const Framework = Literals(FRAMEWORK_TOKENS);
19352
19319
  var JsonReportSummary = class extends Class("JsonReportSummary")({
19353
19320
  errorCount: Number$1,
19354
19321
  warningCount: Number$1,
@@ -19386,22 +19353,13 @@ var JsonReportProjectEntry = class extends Class("JsonReportProjectEntry")({
19386
19353
  scannedFileCount: optional(Number$1),
19387
19354
  elapsedMilliseconds: Number$1
19388
19355
  }) {};
19389
- var JsonReportProjectEntryV3 = class extends Class("JsonReportProjectEntryV3")({
19390
- directory: String$1,
19391
- packageRoot: String$1,
19392
- framework: Framework,
19393
- project: Unknown,
19394
- diagnostics: ArraySchema(JsonReportDiagnosticV3),
19395
- score: Unknown,
19396
- skippedChecks: ArraySchema(String$1),
19397
- skippedCheckReasons: optional(Record$1(String$1, String$1)),
19398
- analyzedFiles: ArraySchema(String$1),
19399
- analyzedFileCount: Number$1,
19400
- complete: Boolean$1,
19401
- scannedFileCount: optional(Number$1),
19402
- elapsedMilliseconds: Number$1
19403
- }) {};
19404
- /** Original full, diff, and staged report contract. */
19356
+ /**
19357
+ * Versioned JsonReport schema. `JsonReport` is a `Schema.Union` so we
19358
+ * can add `schemaVersion: 2` later as one new union member without
19359
+ * breaking existing v1 consumers (the GitHub Action keys off the
19360
+ * version literal). Today's union is single-arm; the shape is
19361
+ * intentional.
19362
+ */
19405
19363
  var JsonReportV1 = class extends Class("JsonReportV1")({
19406
19364
  schemaVersion: Literal(1),
19407
19365
  version: String$1,
@@ -19462,27 +19420,7 @@ var JsonReportV2 = class extends Class("JsonReportV2")({
19462
19420
  elapsedMilliseconds: Number$1,
19463
19421
  error: NullOr(JsonReportError)
19464
19422
  }) {};
19465
- var JsonReportV3 = class extends Class("JsonReportV3")({
19466
- schemaVersion: Literal(3),
19467
- version: String$1,
19468
- ok: Boolean$1,
19469
- directory: String$1,
19470
- mode: JsonReportMode,
19471
- baselineDegraded: optional(Boolean$1),
19472
- reactDetected: optional(Boolean$1),
19473
- diff: NullOr(JsonReportDiffInfo),
19474
- baseline: optional(JsonReportBaseline),
19475
- projects: ArraySchema(JsonReportProjectEntryV3),
19476
- diagnostics: ArraySchema(JsonReportDiagnosticV3),
19477
- summary: JsonReportSummary,
19478
- elapsedMilliseconds: Number$1,
19479
- error: NullOr(JsonReportError)
19480
- }) {};
19481
- Union([
19482
- JsonReportV1,
19483
- JsonReportV2,
19484
- JsonReportV3
19485
- ]);
19423
+ Union([JsonReportV1, JsonReportV2]);
19486
19424
  //#endregion
19487
19425
  //#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js
19488
19426
  var require_constants$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
@@ -33952,22 +33890,6 @@ const isPackageJsonReanimatedAware = (packageJson) => {
33952
33890
  };
33953
33891
  return Object.hasOwn(allDependencies, REANIMATED_DEPENDENCY_NAME$1);
33954
33892
  };
33955
- const SSR_DEPENDENCY_NAMES = new Set([
33956
- "@react-router/cloudflare",
33957
- "@react-router/node",
33958
- "@react-router/serve",
33959
- "vike",
33960
- "vite-plugin-ssr"
33961
- ]);
33962
- const isPackageJsonSsrAware = (packageJson) => {
33963
- const allDependencies = {
33964
- ...packageJson.peerDependencies,
33965
- ...packageJson.dependencies,
33966
- ...packageJson.devDependencies,
33967
- ...packageJson.optionalDependencies
33968
- };
33969
- return Object.keys(allDependencies).some((packageName) => SSR_DEPENDENCY_NAMES.has(packageName));
33970
- };
33971
33893
  const getWorkspacePatterns = (rootDirectory, packageJson) => {
33972
33894
  const pnpmPatterns = parsePnpmWorkspacePatterns(rootDirectory);
33973
33895
  if (pnpmPatterns.length > 0) return pnpmPatterns;
@@ -34108,7 +34030,6 @@ const evaluateManifestFacts = (facts, packageJson, directory) => {
34108
34030
  }
34109
34031
  facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
34110
34032
  facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
34111
- facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
34112
34033
  };
34113
34034
  const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
34114
34035
  const facts = {
@@ -34130,7 +34051,6 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
34130
34051
  },
34131
34052
  hasReactNativeAwarePackage: false,
34132
34053
  hasReanimatedAwarePackage: false,
34133
- hasSsrDependency: false,
34134
34054
  reanimatedVersion: null
34135
34055
  };
34136
34056
  evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
@@ -34370,7 +34290,6 @@ const discoverProjectWithoutPackageJson = (directory) => {
34370
34290
  hasTypeScript: hasOwnTsConfig,
34371
34291
  hasReactCompiler: false,
34372
34292
  hasTanStackQuery: false,
34373
- hasSsrDependency: false,
34374
34293
  preactVersion: null,
34375
34294
  preactMajorVersion: null,
34376
34295
  hasReactNativeWorkspace: false,
@@ -34490,7 +34409,6 @@ const discoverProject = (directory) => {
34490
34409
  hasTypeScript,
34491
34410
  hasReactCompiler: detectReactCompiler(directory, packageJson),
34492
34411
  hasTanStackQuery: hasTanStackQuery(packageJson),
34493
- hasSsrDependency: workspaceFacts.hasSsrDependency,
34494
34412
  preactVersion,
34495
34413
  preactMajorVersion: parseReactMajor(preactVersion),
34496
34414
  hasReactNativeWorkspace,
@@ -35570,14 +35488,6 @@ var AmbiguousProject = class extends TaggedErrorClass()("AmbiguousProject", {
35570
35488
  return `Ambiguous project at ${this.directory}: found ${this.candidates.length} candidates (${this.candidates.join(", ")})`;
35571
35489
  }
35572
35490
  };
35573
- var ProjectDiscoveryFailed = class extends TaggedErrorClass()("ProjectDiscoveryFailed", {
35574
- directory: String$1,
35575
- cause: Unknown
35576
- }) {
35577
- get message() {
35578
- return `Project discovery failed for ${this.directory}: ${pretty(fail$6(this.cause))}`;
35579
- }
35580
- };
35581
35491
  var DeadCodeAnalysisFailed = class extends TaggedErrorClass()("DeadCodeAnalysisFailed", { cause: Unknown }) {
35582
35492
  get message() {
35583
35493
  return `Dead-code analysis failed: ${pretty(fail$6(this.cause))}`;
@@ -35612,7 +35522,6 @@ const ReactDoctorErrorReason = Union([
35612
35522
  ProjectNotFound,
35613
35523
  NoReactDependency,
35614
35524
  AmbiguousProject,
35615
- ProjectDiscoveryFailed,
35616
35525
  DeadCodeAnalysisFailed,
35617
35526
  GitInvocationFailed,
35618
35527
  GitBaseBranchMissing,
@@ -37309,12 +37218,6 @@ const CLIENT_ONLY_FRAMEWORKS = new Set([
37309
37218
  "react-native",
37310
37219
  "expo"
37311
37220
  ]);
37312
- const SSR_FRAMEWORKS = new Set([
37313
- "nextjs",
37314
- "remix",
37315
- "gatsby",
37316
- "tanstack-start"
37317
- ]);
37318
37221
  const addMajorLadder = (capabilities, name, major, earliest, latest) => {
37319
37222
  if (major === null) return;
37320
37223
  const cappedMajor = Math.min(major, latest);
@@ -37327,7 +37230,6 @@ const buildCapabilities = (project) => {
37327
37230
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
37328
37231
  if (project.expoVersion !== null) capabilities.add("expo");
37329
37232
  if ((project.framework === "nextjs" || project.framework === "tanstack-start" || project.framework === "remix") && !project.isStaticExport) capabilities.add("server-actions");
37330
- if (SSR_FRAMEWORKS.has(project.framework) || project.hasSsrDependency) capabilities.add("ssr");
37331
37233
  if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
37332
37234
  if (project.isStaticExport) capabilities.add("nextjs:static-export");
37333
37235
  if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
@@ -40732,8 +40634,6 @@ const spawnLintBatches = async (input) => {
40732
40634
  const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
40733
40635
  reportSkippedFiles(droppedFiles, (fileListPreview) => `${droppedFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
40734
40636
  reportSkippedFiles(outcome.deadlineSkippedFiles, (fileListPreview) => `${outcome.deadlineSkippedFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
40735
- const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
40736
- input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)))].sort());
40737
40637
  return dedupeDiagnostics(diagnostics);
40738
40638
  };
40739
40639
  let didValidate = false;
@@ -40990,18 +40890,12 @@ const reactHooksJsPluginDropNote = (error) => {
40990
40890
  * 6. always restore disable directives + clean up the temp dir
40991
40891
  */
40992
40892
  const runOxlint = async (options) => {
40993
- const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
40893
+ const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), userConfig, configSourceDirectory = rootDirectory, onPartialFailure, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
40994
40894
  const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
40995
40895
  const severityControls = buildRuleSeverityControls(userConfig);
40996
40896
  validateRuleRegistration();
40997
40897
  resetManifestCaches();
40998
- if (includePaths !== void 0 && includePaths.length === 0) {
40999
- onFileCoverage?.({
41000
- candidateFiles: [],
41001
- analyzedFiles: []
41002
- });
41003
- return [];
41004
- }
40898
+ if (includePaths !== void 0 && includePaths.length === 0) return [];
41005
40899
  const pluginPath = resolvePluginPath();
41006
40900
  const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
41007
40901
  const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
@@ -41062,7 +40956,6 @@ const runOxlint = async (options) => {
41062
40956
  const runConfigOverFiles = async (buildConfigForPass, configFileName, files, fileProgress) => {
41063
40957
  if (files.length === 0) return {
41064
40958
  diagnostics: [],
41065
- analyzedFiles: [],
41066
40959
  didDropReactHooksJsPlugin: false,
41067
40960
  hadPartialFailure: false
41068
40961
  };
@@ -41074,32 +40967,24 @@ const runOxlint = async (options) => {
41074
40967
  const passConfigPath = Path.join(configDirectory, configFileName);
41075
40968
  const passBaseArgs = makeBaseArgs(passConfigPath);
41076
40969
  const passFileBatches = buildFileBatches(passBaseArgs, files);
41077
- let analyzedFiles = [];
41078
- const spawnPass = () => {
41079
- analyzedFiles = [];
41080
- return spawnLintBatches({
41081
- baseArgs: passBaseArgs,
41082
- fileBatches: passFileBatches,
41083
- rootDirectory,
41084
- nodeBinaryPath,
41085
- project,
41086
- onPartialFailure: reportPartialFailure,
41087
- onAnalyzedFiles: (filePaths) => {
41088
- analyzedFiles = filePaths;
41089
- },
41090
- onFileProgress: fileProgress,
41091
- spawnTimeoutMs,
41092
- outputMaxBytes,
41093
- concurrency: options.concurrency,
41094
- signal: options.signal,
41095
- deadlineEpochMs: options.deadlineEpochMs
41096
- });
41097
- };
40970
+ const spawnPass = () => spawnLintBatches({
40971
+ baseArgs: passBaseArgs,
40972
+ fileBatches: passFileBatches,
40973
+ rootDirectory,
40974
+ nodeBinaryPath,
40975
+ project,
40976
+ onPartialFailure: reportPartialFailure,
40977
+ onFileProgress: fileProgress,
40978
+ spawnTimeoutMs,
40979
+ outputMaxBytes,
40980
+ concurrency: options.concurrency,
40981
+ signal: options.signal,
40982
+ deadlineEpochMs: options.deadlineEpochMs
40983
+ });
41098
40984
  writeOxlintConfig(passConfigPath, buildConfigForPass({}));
41099
40985
  try {
41100
40986
  return {
41101
40987
  diagnostics: await spawnPass(),
41102
- analyzedFiles,
41103
40988
  didDropReactHooksJsPlugin: false,
41104
40989
  hadPartialFailure
41105
40990
  };
@@ -41111,7 +40996,6 @@ const runOxlint = async (options) => {
41111
40996
  reportPartialFailure(reactHooksJsDropNote);
41112
40997
  return {
41113
40998
  diagnostics,
41114
- analyzedFiles,
41115
40999
  didDropReactHooksJsPlugin: true,
41116
41000
  hadPartialFailure
41117
41001
  };
@@ -41187,7 +41071,6 @@ const runOxlint = async (options) => {
41187
41071
  const missFileSet = new Set(missFiles);
41188
41072
  const hitFiles = candidateFiles.filter((candidateFile) => !missFileSet.has(candidateFile));
41189
41073
  const sidecarReplayedDiagnostics = [];
41190
- const sidecarReplayedFiles = [];
41191
41074
  const sidecarLintFiles = [];
41192
41075
  if (sidecarCache === null) sidecarLintFiles.push(...hitFiles);
41193
41076
  else {
@@ -41195,10 +41078,8 @@ const runOxlint = async (options) => {
41195
41078
  for (const hitFile of hitFiles) {
41196
41079
  const cacheKey = cacheKeyByFile.get(hitFile);
41197
41080
  const entry = cacheKey === void 0 ? null : sidecarCache.lookup(cacheKey);
41198
- if (entry !== null && entry.probes.every((probe) => probeAnswers.answerFor(probe.kind, probe.path) === probe.answer)) {
41199
- sidecarReplayedFiles.push(hitFile);
41200
- sidecarReplayedDiagnostics.push(...entry.diagnostics);
41201
- } else sidecarLintFiles.push(hitFile);
41081
+ if (entry !== null && entry.probes.every((probe) => probeAnswers.answerFor(probe.kind, probe.path) === probe.answer)) sidecarReplayedDiagnostics.push(...entry.diagnostics);
41082
+ else sidecarLintFiles.push(hitFile);
41202
41083
  if (performance.now() - verifySliceStartedAt >= 12) {
41203
41084
  await yieldToEventLoop();
41204
41085
  verifySliceStartedAt = performance.now();
@@ -41224,7 +41105,6 @@ const runOxlint = async (options) => {
41224
41105
  sidecarRuleIdFilter: new Set(unboundedSidecarRuleIds)
41225
41106
  }), "oxlintrc.sidecar-unbounded.json", hitFiles, void 0) : {
41226
41107
  diagnostics: [],
41227
- analyzedFiles: [],
41228
41108
  didDropReactHooksJsPlugin: false,
41229
41109
  hadPartialFailure: false
41230
41110
  };
@@ -41255,15 +41135,6 @@ const runOxlint = async (options) => {
41255
41135
  probesByFile: await missProbesTask
41256
41136
  }]
41257
41137
  });
41258
- const analyzedFileSet = new Set(fullResult.analyzedFiles);
41259
- const boundedSidecarAnalyzedFileSet = new Set(boundedSidecarResult.analyzedFiles);
41260
- const unboundedSidecarAnalyzedFileSet = new Set(unboundedSidecarResult.analyzedFiles);
41261
- const sidecarReplayedFileSet = new Set(sidecarReplayedFiles);
41262
- for (const hitFile of hitFiles) if (useSidecarCache ? (sidecarReplayedFileSet.has(hitFile) || boundedSidecarAnalyzedFileSet.has(hitFile)) && (unboundedSidecarRuleIds.length === 0 || unboundedSidecarAnalyzedFileSet.has(hitFile)) : boundedSidecarAnalyzedFileSet.has(hitFile)) analyzedFileSet.add(hitFile);
41263
- onFileCoverage?.({
41264
- candidateFiles,
41265
- analyzedFiles: candidateFiles.filter((candidateFile) => analyzedFileSet.has(candidateFile))
41266
- });
41267
41138
  return dedupeDiagnostics([
41268
41139
  ...replayedDiagnostics,
41269
41140
  ...fullResult.diagnostics,
@@ -41274,7 +41145,6 @@ const runOxlint = async (options) => {
41274
41145
  }
41275
41146
  const baseArgs = makeBaseArgs(configPath);
41276
41147
  const fileBatches = buildFileBatches(baseArgs, candidateFiles);
41277
- let analyzedFiles = [];
41278
41148
  const runBatches = () => spawnLintBatches({
41279
41149
  baseArgs,
41280
41150
  fileBatches,
@@ -41282,9 +41152,6 @@ const runOxlint = async (options) => {
41282
41152
  nodeBinaryPath,
41283
41153
  project,
41284
41154
  onPartialFailure,
41285
- onAnalyzedFiles: (filePaths) => {
41286
- analyzedFiles = filePaths;
41287
- },
41288
41155
  onFileProgress: options.onFileProgress,
41289
41156
  spawnTimeoutMs,
41290
41157
  outputMaxBytes,
@@ -41294,12 +41161,7 @@ const runOxlint = async (options) => {
41294
41161
  });
41295
41162
  writeOxlintConfig(configPath, buildConfig({ extendsPaths }));
41296
41163
  try {
41297
- const diagnostics = await runBatches();
41298
- onFileCoverage?.({
41299
- candidateFiles,
41300
- analyzedFiles
41301
- });
41302
- return diagnostics;
41164
+ return await runBatches();
41303
41165
  } catch (error) {
41304
41166
  const reactHooksJsDropNote = reactHooksJsPluginDropNote(error);
41305
41167
  if (reactHooksJsDropNote !== null) {
@@ -41309,20 +41171,11 @@ const runOxlint = async (options) => {
41309
41171
  }));
41310
41172
  const diagnostics = await runBatches();
41311
41173
  onPartialFailure?.(reactHooksJsDropNote);
41312
- onFileCoverage?.({
41313
- candidateFiles,
41314
- analyzedFiles
41315
- });
41316
41174
  return diagnostics;
41317
41175
  }
41318
41176
  if (extendsPaths.length === 0) throw error;
41319
41177
  writeOxlintConfig(configPath, buildConfig({ extendsPaths: [] }));
41320
- const diagnostics = await runBatches();
41321
- onFileCoverage?.({
41322
- candidateFiles,
41323
- analyzedFiles
41324
- });
41325
- return diagnostics;
41178
+ return await runBatches();
41326
41179
  }
41327
41180
  } finally {
41328
41181
  restoreDisableDirectives();
@@ -41402,7 +41255,6 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
41402
41255
  onPartialFailure: (reason) => {
41403
41256
  collectedFailures.push(reason);
41404
41257
  },
41405
- onFileCoverage: input.onFileCoverage,
41406
41258
  onFileProgress: input.onFileProgress,
41407
41259
  perFileLintCacheEnabled,
41408
41260
  sidecarLintCacheEnabled,
@@ -41495,10 +41347,7 @@ const translateProjectInfoError = (cause, directory) => {
41495
41347
  directory: cause.directory,
41496
41348
  candidates: cause.candidates
41497
41349
  }) });
41498
- return new ReactDoctorError({ reason: new ProjectDiscoveryFailed({
41499
- directory,
41500
- cause
41501
- }) });
41350
+ return new ReactDoctorError({ reason: new ProjectNotFound({ directory }) });
41502
41351
  };
41503
41352
  var Project = class Project extends Service()("react-doctor/Project") {
41504
41353
  static layerNode = succeed$3(Project, Project.of({ discover: fn("Project.discover")(function* (directory) {
@@ -42110,7 +41959,6 @@ const resolveGithubActionsScoreMetadata = (environment = process.env) => {
42110
41959
  ...actorAssociation !== void 0 ? { githubActorAssociation: actorAssociation } : {}
42111
41960
  };
42112
41961
  };
42113
- const toNormalizedRelativePath = (filePath, rootDirectory) => Path.relative(Path.resolve(rootDirectory), Path.resolve(rootDirectory, filePath)).replaceAll("\\", "/") || ".";
42114
41962
  const NO_HOOKS = {
42115
41963
  beforeLint: () => void_,
42116
41964
  afterLint: () => void_
@@ -42209,7 +42057,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
42209
42057
  repo
42210
42058
  }).pipe(orElseSucceed(() => null)) : succeed$2(null));
42211
42059
  const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
42212
- const fallbackScannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => Path.resolve(scanDirectory, relativePath)) : [];
42060
+ const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => Path.resolve(scanDirectory, relativePath)) : [];
42213
42061
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
42214
42062
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
42215
42063
  yield* beforeLint(project, lintIncludePaths ?? void 0);
@@ -42314,7 +42162,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
42314
42162
  let deadCodeCacheHit = null;
42315
42163
  let deadCodeSummaryCacheHits = null;
42316
42164
  let deadCodeSummaryCacheMisses = null;
42317
- const lintFileCoverageState = { value: null };
42318
42165
  const baseLintStream = linterService.run({
42319
42166
  rootDirectory: scanDirectory,
42320
42167
  project,
@@ -42330,9 +42177,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
42330
42177
  lastReportedTotalFileCount = totalFileCount;
42331
42178
  runSync(scanProgress.update(`Scanning files (${scannedFileCount}/${totalFileCount})${workerCountSuffix}...`));
42332
42179
  },
42333
- onFileCoverage: (coverage) => {
42334
- lintFileCoverageState.value = coverage;
42335
- },
42336
42180
  onCacheStats: (cacheHitFileCount, totalConsideredFileCount) => {
42337
42181
  lintCacheHitFileCount = cacheHitFileCount;
42338
42182
  lintCacheTotalFileCount = totalConsideredFileCount;
@@ -42363,10 +42207,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
42363
42207
  const lintFailureState = yield* get$2(lintFailure);
42364
42208
  yield* afterLint(lintFailureState.didFail);
42365
42209
  if (lintFailureState.didFail) yield* scanProgress.fail(formatLintFailText(lintFailureState.reasonTag, process.version));
42366
- const candidateFiles = lintFileCoverageState.value === null ? [] : [...new Set(lintFileCoverageState.value.candidateFiles.map((filePath) => toNormalizedRelativePath(filePath, scanDirectory)))];
42367
- const analyzedFiles = lintFileCoverageState.value === null ? [] : [...new Set(lintFileCoverageState.value.analyzedFiles.map((filePath) => toNormalizedRelativePath(filePath, scanDirectory)))].sort();
42368
- const totalFileCount = candidateFiles.length || lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
42369
- const scannedFilePaths = input.suppressScanSummary ? candidateFiles.length > 0 ? candidateFiles.map((filePath) => Path.resolve(scanDirectory, filePath)) : fallbackScannedFilePaths : [];
42210
+ const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
42370
42211
  const scannedFilesLabel = `${totalFileCount} ${totalFileCount === 1 ? "file" : "files"}`;
42371
42212
  let deadCodeCollected = [];
42372
42213
  if (lintFailureState.didFail) {
@@ -42448,7 +42289,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
42448
42289
  deadCodeOverlapped: shouldOverlapDeadCode,
42449
42290
  scannedFileCount: totalFileCount,
42450
42291
  scannedFilePaths,
42451
- analyzedFiles,
42452
42292
  scanElapsedMilliseconds,
42453
42293
  scanConcurrency,
42454
42294
  supplyChainOverlapTimedOut: supplyChainResult.timedOut,
@@ -42700,7 +42540,7 @@ const buildJsonReportError = (input) => {
42700
42540
  sentryEventId
42701
42541
  };
42702
42542
  return {
42703
- schemaVersion: 3,
42543
+ schemaVersion: 1,
42704
42544
  version: input.version,
42705
42545
  ok: false,
42706
42546
  directory: input.directory,
@@ -42745,7 +42585,6 @@ const summarizeDiagnostics = (diagnostics, worstScore = null, worstScoreLabel =
42745
42585
  * React-runtime rule family was gated off for the project.
42746
42586
  */
42747
42587
  const hasReactRuntime = (project) => project.reactVersion !== null || project.preactVersion !== null;
42748
- const isScanComplete = (input) => input.analyzedFileCount !== void 0 && input.scannedFileCount !== void 0 && input.skippedCheckCount === 0 && input.skippedCheckReasonCount === 0 && input.analyzedFileCount === input.scannedFileCount;
42749
42588
  const toJsonDiff = (diff) => {
42750
42589
  if (!diff) return null;
42751
42590
  return {
@@ -42768,68 +42607,21 @@ const findWorstScoredProject = (projects) => {
42768
42607
  }
42769
42608
  return worst;
42770
42609
  };
42771
- const toJsonReportDiagnostic = (diagnostic, projectRoot, reportRoot) => {
42772
- const normalizedFilePath = toNormalizedRelativePath(diagnostic.filePath, projectRoot);
42773
- const reportRelativeFilePath = toNormalizedRelativePath(Path.resolve(projectRoot, diagnostic.filePath), reportRoot);
42774
- const ruleIdentity = getDiagnosticRuleIdentity(diagnostic);
42775
- return {
42776
- ...diagnostic,
42777
- id: buildDiagnosticIdentity({
42778
- filePath: reportRelativeFilePath,
42779
- line: diagnostic.line,
42780
- column: diagnostic.column,
42781
- plugin: diagnostic.plugin,
42782
- rule: diagnostic.rule
42783
- }),
42784
- normalizedFilePath,
42785
- category: ruleIdentity.category,
42786
- tags: [...new Set(ruleIdentity.tags)].sort()
42787
- };
42788
- };
42789
42610
  const buildJsonReport = (input) => {
42790
- const projects = input.scans.map(({ directory, result }) => {
42791
- const skippedChecks = result.skippedChecks ?? [];
42792
- const analyzedFiles = [...new Set((result.analyzedFiles ?? []).map((filePath) => toNormalizedRelativePath(filePath, result.project.rootDirectory)))].sort();
42793
- const scannedFileCount = result.scannedFileCount ?? result.project.sourceFileCount;
42794
- return {
42795
- directory,
42796
- packageRoot: result.project.rootDirectory,
42797
- framework: result.project.framework,
42798
- project: result.project,
42799
- diagnostics: result.diagnostics.map((diagnostic) => toJsonReportDiagnostic(diagnostic, result.project.rootDirectory, input.directory)),
42800
- score: result.score,
42801
- skippedChecks,
42802
- ...result.skippedCheckReasons ? { skippedCheckReasons: result.skippedCheckReasons } : {},
42803
- analyzedFiles,
42804
- analyzedFileCount: analyzedFiles.length,
42805
- complete: isScanComplete({
42806
- analyzedFileCount: result.analyzedFiles === void 0 ? void 0 : analyzedFiles.length,
42807
- scannedFileCount,
42808
- skippedCheckCount: skippedChecks.length,
42809
- skippedCheckReasonCount: Object.keys(result.skippedCheckReasons ?? {}).length
42810
- }),
42811
- ...typeof result.scannedFileCount === "number" ? { scannedFileCount } : {},
42812
- elapsedMilliseconds: result.elapsedMilliseconds
42813
- };
42814
- });
42611
+ const projects = input.scans.map(({ directory, result }) => ({
42612
+ directory,
42613
+ project: result.project,
42614
+ diagnostics: result.diagnostics,
42615
+ score: result.score,
42616
+ skippedChecks: result.skippedChecks,
42617
+ ...result.skippedCheckReasons ? { skippedCheckReasons: result.skippedCheckReasons } : {},
42618
+ ...typeof result.scannedFileCount === "number" ? { scannedFileCount: result.scannedFileCount } : {},
42619
+ elapsedMilliseconds: result.elapsedMilliseconds
42620
+ }));
42815
42621
  const flattenedDiagnostics = projects.flatMap((entry) => entry.diagnostics);
42816
42622
  const worstScoredProject = findWorstScoredProject(projects);
42817
- const diagnosticSummary = summarizeDiagnostics(flattenedDiagnostics, worstScoredProject?.score?.score ?? null, worstScoredProject?.score?.label ?? null);
42818
- const affectedFileCount = projects.reduce((totalAffectedFileCount, project) => totalAffectedFileCount + new Set(project.diagnostics.map((diagnostic) => diagnostic.normalizedFilePath)).size, 0);
42819
- const summary = {
42820
- ...diagnosticSummary,
42821
- affectedFileCount
42822
- };
42823
- return {
42824
- schemaVersion: 3,
42825
- mode: input.baseline !== void 0 ? "baseline" : input.baselineDegraded && input.mode === "baseline" ? "diff" : input.mode,
42826
- ...input.baseline ? { baseline: {
42827
- baseRef: input.baseline.baseRef,
42828
- newCount: summary.totalDiagnosticCount,
42829
- fixedCount: input.baseline.fixedCount,
42830
- baseTotalCount: input.baseline.baseTotalCount
42831
- } } : {},
42832
- ...input.baselineDegraded ? { baselineDegraded: true } : {},
42623
+ const summary = summarizeDiagnostics(flattenedDiagnostics, worstScoredProject?.score?.score ?? null, worstScoredProject?.score?.label ?? null);
42624
+ const shared = {
42833
42625
  ...input.scans.length > 0 ? { reactDetected: input.scans.some((scan) => hasReactRuntime(scan.result.project)) } : {},
42834
42626
  version: input.version,
42835
42627
  ok: true,
@@ -42841,26 +42633,39 @@ const buildJsonReport = (input) => {
42841
42633
  elapsedMilliseconds: input.totalElapsedMilliseconds,
42842
42634
  error: null
42843
42635
  };
42636
+ if (input.baseline) return {
42637
+ schemaVersion: 2,
42638
+ mode: "baseline",
42639
+ baseline: {
42640
+ baseRef: input.baseline.baseRef,
42641
+ newCount: summary.totalDiagnosticCount,
42642
+ fixedCount: input.baseline.fixedCount,
42643
+ baseTotalCount: input.baseline.baseTotalCount
42644
+ },
42645
+ ...shared
42646
+ };
42647
+ return {
42648
+ schemaVersion: 1,
42649
+ mode: input.mode,
42650
+ ...input.baselineDegraded ? { baselineDegraded: true } : {},
42651
+ ...shared
42652
+ };
42844
42653
  };
42845
42654
  /**
42846
42655
  * Single source of truth for the skipped-check accounting shared by the
42847
42656
  * CLI renderer (`react-doctor/src/inspect.ts → finalizeAndRender`) and the
42848
42657
  * programmatic shell (`@react-doctor/api → diagnose()`). Both surface a
42849
- * failed or partial analysis pass instead of a false "all clear", so the
42658
+ * failed lint / dead-code pass instead of a false "all clear", so the
42850
42659
  * branch logic lives here once.
42851
42660
  */
42852
42661
  const buildSkippedChecks = (input) => {
42853
42662
  const skippedChecks = [];
42854
42663
  if (input.didLintFail) skippedChecks.push("lint");
42855
42664
  if (input.didDeadCodeFail) skippedChecks.push("dead-code");
42856
- if (input.supplyChainOverlapTimedOut) skippedChecks.push("supply-chain");
42857
- if (input.securityScanFailed) skippedChecks.push("security-scan");
42858
42665
  const skippedCheckReasons = {};
42859
42666
  if (input.didLintFail && input.lintFailureReason !== null) skippedCheckReasons.lint = input.lintFailureReason;
42860
42667
  else if (input.lintPartialFailures.length > 0) skippedCheckReasons["lint:partial"] = input.lintPartialFailures.join("; ");
42861
42668
  if (input.didDeadCodeFail && input.deadCodeFailureReason !== null) skippedCheckReasons["dead-code"] = input.deadCodeFailureReason;
42862
- if (input.supplyChainOverlapTimedOut) skippedCheckReasons["supply-chain"] = "Supply-chain analysis timed out and was skipped.";
42863
- if (input.securityScanFailed) skippedCheckReasons["security-scan"] = "Security scan failed and was skipped.";
42864
42669
  return {
42865
42670
  skippedChecks,
42866
42671
  skippedCheckReasons
@@ -43049,8 +42854,6 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
43049
42854
  score: output.score,
43050
42855
  skippedChecks,
43051
42856
  ...Object.keys(skippedCheckReasons).length > 0 ? { skippedCheckReasons } : {},
43052
- analyzedFiles: output.analyzedFiles,
43053
- scannedFileCount: output.scannedFileCount,
43054
42857
  project: output.project,
43055
42858
  reactDetected: hasReactRuntime(output.project),
43056
42859
  elapsedMilliseconds
@@ -43160,8 +42963,6 @@ const toJsonReport = (result, options) => buildJsonReport({
43160
42963
  score: result.score,
43161
42964
  skippedChecks: result.skippedChecks,
43162
42965
  ...result.skippedCheckReasons ? { skippedCheckReasons: result.skippedCheckReasons } : {},
43163
- ...result.analyzedFiles ? { analyzedFiles: result.analyzedFiles } : {},
43164
- ...typeof result.scannedFileCount === "number" ? { scannedFileCount: result.scannedFileCount } : {},
43165
42966
  project: result.project,
43166
42967
  elapsedMilliseconds: result.elapsedMilliseconds
43167
42968
  }
@@ -43172,4 +42973,4 @@ const toJsonReport = (result, options) => buildJsonReport({
43172
42973
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
43173
42974
 
43174
42975
  //# sourceMappingURL=index.js.map
43175
- //# debugId=95e70e55-12b7-5577-81f3-f5331db7ca53
42976
+ //# debugId=e047abe8-ac42-570c-8465-e0f0dcb0715c