react-doctor 0.7.6-dev.0a8d30b → 0.7.6-dev.17418

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/cli.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]="5dcb5b0b-ca1e-5655-8f52-3c22b421256d")}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]="63b8a227-543e-5501-a998-58c03a1fb10e")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as NodeChildProcess from "node:child_process";
5
5
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
@@ -36341,12 +36341,10 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
36341
36341
  const listSourceFilesWithSize = (rootDirectory) => collectSizedSourceFiles(rootDirectory, (listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory)).sort());
36342
36342
  const listSourceFiles = (rootDirectory) => listSourceFilesWithSize(rootDirectory).map((entry) => entry.path);
36343
36343
  const countSourceFiles = (rootDirectory) => listSourceFilesWithSize(rootDirectory).length;
36344
- const UTF8_BOM_CHARACTER = "";
36345
- const stripUtf8Bom = (content) => content.startsWith(UTF8_BOM_CHARACTER) ? content.slice(1) : content;
36346
36344
  const cachedPackageJsons = /* @__PURE__ */ new Map();
36347
36345
  const readPackageJsonUncached = (packageJsonPath) => {
36348
36346
  try {
36349
- return JSON.parse(stripUtf8Bom(NFS.readFileSync(packageJsonPath, "utf-8")));
36347
+ return JSON.parse(NFS.readFileSync(packageJsonPath, "utf-8"));
36350
36348
  } catch (error) {
36351
36349
  if (error instanceof SyntaxError) return {};
36352
36350
  if (isErrnoException(error)) {
@@ -40019,6 +40017,7 @@ const PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
40019
40017
  const PNPM_LOCKFILE = "pnpm-lock.yaml";
40020
40018
  const PACKAGE_JSON_FILE = "package.json";
40021
40019
  const PNPM_HARDENING_RULE_KEY = "require-pnpm-hardening";
40020
+ const UTF8_BOM_CHAR = "";
40022
40021
  const HARDENING_SETTING_KEYS = new Set([
40023
40022
  "minimumReleaseAge",
40024
40023
  "blockExoticSubdeps",
@@ -40043,11 +40042,12 @@ const stripInlineComment = (rawValue) => {
40043
40042
  return rawValue;
40044
40043
  };
40045
40044
  const unquote = (rawValue) => rawValue.replace(/^["']|["']$/g, "");
40045
+ const stripBom = (rawContent) => rawContent.startsWith(UTF8_BOM_CHAR) ? rawContent.slice(1) : rawContent;
40046
40046
  const parseHardeningSettings = (content) => {
40047
40047
  let minimumReleaseAge = null;
40048
40048
  let blockExoticSubdeps = null;
40049
40049
  let trustPolicy = null;
40050
- const lines = stripUtf8Bom(content).split(/\r?\n/);
40050
+ const lines = stripBom(content).split(/\r?\n/);
40051
40051
  for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
40052
40052
  const lineText = lines[lineIndex];
40053
40053
  if (lineText === void 0) continue;
@@ -40081,7 +40081,7 @@ const isPnpmManagedProject = (rootDirectory) => {
40081
40081
  const packageJsonPath = Path.join(rootDirectory, PACKAGE_JSON_FILE);
40082
40082
  if (!isFile(packageJsonPath)) return false;
40083
40083
  try {
40084
- const packageJsonRaw = stripUtf8Bom(NFS.readFileSync(packageJsonPath, "utf-8"));
40084
+ const packageJsonRaw = NFS.readFileSync(packageJsonPath, "utf-8");
40085
40085
  const packageJson = JSON.parse(packageJsonRaw);
40086
40086
  if (packageJson !== null && typeof packageJson === "object" && "packageManager" in packageJson && typeof packageJson.packageManager === "string" && packageJson.packageManager.startsWith("pnpm@")) return true;
40087
40087
  } catch {
@@ -40762,7 +40762,9 @@ const setColorEnabled = (enabled) => {
40762
40762
  highlighter.gray = colors.gray;
40763
40763
  highlighter.bold = colors.bold;
40764
40764
  };
40765
- const computeExplicitLintIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter(isLintableSourceFile) : void 0;
40765
+ const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
40766
+ const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
40767
+ const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
40766
40768
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
40767
40769
  const FALSY_VALUES = new Set([
40768
40770
  "false",
@@ -41601,11 +41603,11 @@ const resolveDeadCodeTimeout = (input) => {
41601
41603
  phaseTimeoutMs: workerTimeoutMs + DEAD_CODE_PHASE_TIMEOUT_OVER_WORKER_MS
41602
41604
  };
41603
41605
  };
41604
- const resolveLintIncludePaths = (rootDirectory, userConfig) => {
41606
+ const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
41605
41607
  if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
41606
41608
  const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
41607
41609
  return listSourceFiles(rootDirectory).filter((filePath) => {
41608
- if (!isLintableSourceFile(filePath)) return false;
41610
+ if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
41609
41611
  return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
41610
41612
  });
41611
41613
  };
@@ -41823,7 +41825,6 @@ const parseGithubViewerPermission = (stdout) => {
41823
41825
  return /^[A-Z_]+$/.test(value) ? value.toLowerCase() : null;
41824
41826
  };
41825
41827
  const splitNullSeparated = (value) => value.split("\0").filter((entry) => entry.length > 0);
41826
- const UNTRACKED_FILE_LAST_LINE = Number.MAX_SAFE_INTEGER;
41827
41828
  /**
41828
41829
  * `Git` wraps every `git`-via-subprocess call react-doctor makes
41829
41830
  * behind a `Context.Service`. The production layer (`layerNode`)
@@ -41894,14 +41895,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
41894
41895
  args,
41895
41896
  directory
41896
41897
  });
41897
- const listUntrackedFilePaths = (directory, includePaths = []) => runGit(directory, [
41898
- "ls-files",
41899
- "-z",
41900
- "--others",
41901
- "--exclude-standard",
41902
- ...includePaths.length > 0 ? ["--", ...includePaths] : []
41903
- ]).pipe(map$3((result) => result.status === 0 ? splitNullSeparated(result.stdout) : null));
41904
- const mergeUntracked = (directory, trackedFilePaths, includeUntracked) => includeUntracked ? listUntrackedFilePaths(directory).pipe(map$3((untracked) => untracked === null ? trackedFilePaths : [...new Set([...trackedFilePaths, ...untracked])])) : succeed$2(trackedFilePaths);
41905
41898
  const currentBranch = (directory) => runGit(directory, [
41906
41899
  "rev-parse",
41907
41900
  "--abbrev-ref",
@@ -42024,7 +42017,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
42024
42017
  githubViewerPermission,
42025
42018
  branchExists,
42026
42019
  mergeBase,
42027
- diffSelection: ({ directory, explicitBaseBranch, includeUntracked = false }) => gen(function* () {
42020
+ diffSelection: ({ directory, explicitBaseBranch }) => gen(function* () {
42028
42021
  if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* fail$4(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
42029
42022
  if (explicitBaseBranch !== void 0) {
42030
42023
  const range = parseGitDiffRange(explicitBaseBranch);
@@ -42053,7 +42046,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
42053
42046
  "HEAD"
42054
42047
  ]);
42055
42048
  if (uncommitted.status !== 0) return null;
42056
- const files = yield* mergeUntracked(directory, splitNullSeparated(uncommitted.stdout), includeUntracked);
42049
+ const files = splitNullSeparated(uncommitted.stdout);
42057
42050
  if (files.length === 0) return null;
42058
42051
  return {
42059
42052
  currentBranch: resolvedCurrentBranch,
@@ -42083,7 +42076,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
42083
42076
  currentBranch: resolvedCurrentBranch,
42084
42077
  baseBranch,
42085
42078
  diffBaseRef: mergeBaseRef,
42086
- changedFiles: yield* mergeUntracked(directory, splitNullSeparated(diff.stdout), includeUntracked),
42079
+ changedFiles: splitNullSeparated(diff.stdout),
42087
42080
  isCurrentChanges: false
42088
42081
  };
42089
42082
  }).pipe(withSpan("Git.diffSelection")),
@@ -42129,7 +42122,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
42129
42122
  stdout: result.stdout
42130
42123
  };
42131
42124
  }).pipe(withSpan("Git.grep")),
42132
- changedLineRanges: ({ directory, baseRef, cached, files, includeUntracked = false }) => gen(function* () {
42125
+ changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
42133
42126
  if (files.length === 0) return [];
42134
42127
  if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
42135
42128
  const result = yield* runGit(directory, [
@@ -42143,14 +42136,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
42143
42136
  ...files
42144
42137
  ]);
42145
42138
  if (result.status !== 0) return null;
42146
- const changedLineRanges = parseChangedLineRanges(result.stdout);
42147
- if (cached || !includeUntracked) return changedLineRanges;
42148
- const untrackedFilePaths = yield* listUntrackedFilePaths(directory, files);
42149
- if (untrackedFilePaths === null) return changedLineRanges;
42150
- return [...changedLineRanges, ...untrackedFilePaths.map((file) => ({
42151
- file,
42152
- ranges: [[1, UNTRACKED_FILE_LAST_LINE]]
42153
- }))];
42139
+ return parseChangedLineRanges(result.stdout);
42154
42140
  }).pipe(catch_$1((error) => error.reason._tag === "GitInvocationFailed" ? succeed$2(null) : fail$4(error)), withSpan("Git.changedLineRanges"))
42155
42141
  });
42156
42142
  })).pipe(provide$2(layer$3.pipe(provide$2(mergeAll$1(layer$2, layer$1)))));
@@ -42902,12 +42888,6 @@ const mapWithConcurrency = async (items, concurrency, task) => {
42902
42888
  if (errors.length > 0) throw errors[0];
42903
42889
  return results;
42904
42890
  };
42905
- const lineOfUtf8Offset = (sourceBuffer, utf8Offset) => {
42906
- let lineNumber = 1;
42907
- const scanEnd = Math.min(utf8Offset, sourceBuffer.length);
42908
- for (let byteIndex = 0; byteIndex < scanEnd; byteIndex++) if (sourceBuffer[byteIndex] === 10) lineNumber++;
42909
- return lineNumber;
42910
- };
42911
42891
  const REANIMATED_SHARED_VALUE_HINT = "If this is a Reanimated shared value, prefer its React Compiler-compatible `.get()` / `.set()` accessors over `.value` — https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue/#react-compiler-support";
42912
42892
  const ACCESSORS_MIN_VERSION = "3.15.0";
42913
42893
  const supportsAccessors = (reanimatedVersion) => {
@@ -43479,6 +43459,13 @@ const findOutermostEnclosingFunctionRange = (sourceFile, targetLine) => {
43479
43459
  visit(sourceFile);
43480
43460
  return foundRange;
43481
43461
  };
43462
+ const NEWLINE_BYTE = 10;
43463
+ const lineOfUtf8Offset = (sourceBuffer, utf8Offset) => {
43464
+ let lineNumber = 1;
43465
+ const scanEnd = Math.min(utf8Offset, sourceBuffer.length);
43466
+ for (let byteIndex = 0; byteIndex < scanEnd; byteIndex++) if (sourceBuffer[byteIndex] === NEWLINE_BYTE) lineNumber++;
43467
+ return lineNumber;
43468
+ };
43482
43469
  /**
43483
43470
  * Drops `react-doctor/react-compiler-no-manual-memoization` diagnostics
43484
43471
  * whose enclosing function also carries a `react-hooks-js` (React
@@ -43683,33 +43670,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
43683
43670
  }
43684
43671
  if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
43685
43672
  const minifiedFileCache = /* @__PURE__ */ new Map();
43686
- const sourceBufferCache = /* @__PURE__ */ new Map();
43687
- const sourceLinesCache = /* @__PURE__ */ new Map();
43688
- const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
43689
- const readSourceBuffer = (filename) => {
43690
- const absolutePath = resolveAbsolutePath(filename);
43691
- const cached = sourceBufferCache.get(absolutePath);
43692
- if (cached !== void 0) return cached;
43693
- let sourceBuffer;
43694
- try {
43695
- sourceBuffer = NFS.readFileSync(absolutePath);
43696
- } catch {
43697
- sourceBuffer = null;
43698
- }
43699
- sourceBufferCache.set(absolutePath, sourceBuffer);
43700
- return sourceBuffer;
43701
- };
43702
- const readSourceLines = (filename) => {
43703
- const absolutePath = resolveAbsolutePath(filename);
43704
- const cached = sourceLinesCache.get(absolutePath);
43705
- if (cached !== void 0) return cached;
43706
- const sourceBuffer = readSourceBuffer(filename);
43707
- const sourceLines = sourceBuffer ? sourceBuffer.toString("utf8").split("\n") : null;
43708
- sourceLinesCache.set(absolutePath, sourceLines);
43709
- return sourceLines;
43710
- };
43711
43673
  const isMinifiedDiagnosticFile = (filename) => {
43712
- const absolutePath = resolveAbsolutePath(filename);
43674
+ const absolutePath = Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
43713
43675
  const cached = minifiedFileCache.get(absolutePath);
43714
43676
  if (cached !== void 0) return cached;
43715
43677
  const minified = isMinifiedSource(absolutePath);
@@ -43722,17 +43684,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
43722
43684
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
43723
43685
  const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
43724
43686
  const primarySpan = primaryLabel?.span;
43725
- const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
43726
43687
  const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
43727
43688
  const category = resolveDiagnosticCategory(plugin, rule);
43728
- const matchByOccurrence = resolveMatchByOccurrence(rule, category);
43729
- const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
43730
- const primaryLineIndex = primarySpan ? primarySpan.line - 1 : -1;
43731
- const primaryLine = sourceLines?.[primaryLineIndex];
43732
- const primaryColumnIndex = primarySpan ? primarySpan.column - 1 : -1;
43733
- const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
43734
- const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
43735
- const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
43736
43689
  return {
43737
43690
  filePath: normalizedFilePath,
43738
43691
  plugin,
@@ -43746,11 +43699,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
43746
43699
  column: primarySpan?.column ?? 0,
43747
43700
  ...primarySpan ? {
43748
43701
  offset: primarySpan.offset,
43749
- length: primarySpan.length,
43750
- ...primarySpanEndLine !== void 0 ? { endLine: primarySpanEndLine } : {}
43702
+ length: primarySpan.length
43751
43703
  } : {},
43752
43704
  category,
43753
- ...matchByOccurrence ? { matchByOccurrence: true } : {},
43705
+ ...resolveMatchByOccurrence(rule, category) ? { matchByOccurrence: true } : {},
43754
43706
  ...relatedLocations.length > 0 ? { relatedLocations } : {}
43755
43707
  };
43756
43708
  }), rootDirectory);
@@ -45537,7 +45489,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
45537
45489
  directory: scanDirectory,
45538
45490
  repo
45539
45491
  }).pipe(orElseSucceed(() => null)) : succeed$2(null));
45540
- const lintIncludePaths = (input.skipExplicitIncludePathFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
45492
+ const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
45541
45493
  const fallbackScannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => Path.resolve(scanDirectory, relativePath)) : [];
45542
45494
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
45543
45495
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
@@ -46282,11 +46234,10 @@ const computeDiagnosticDelta = (input) => {
46282
46234
  * render diff-base mistakes (`GitBaseBranchInvalid` /
46283
46235
  * `GitBaseBranchMissing`) as clean user errors instead of crashes.
46284
46236
  */
46285
- const getDiffInfo = (directory, explicitBaseBranch, includeUntracked) => runPromise(gen(function* () {
46237
+ const getDiffInfo = (directory, explicitBaseBranch) => runPromise(gen(function* () {
46286
46238
  const selection = yield* (yield* Git).diffSelection({
46287
46239
  directory,
46288
- explicitBaseBranch,
46289
- includeUntracked
46240
+ explicitBaseBranch
46290
46241
  });
46291
46242
  if (selection === null) return null;
46292
46243
  return {
@@ -46716,7 +46667,7 @@ const makeNoopConsole = () => ({
46716
46667
  });
46717
46668
  //#endregion
46718
46669
  //#region src/cli/utils/version.ts
46719
- const VERSION = "0.7.6-dev.0a8d30b";
46670
+ const VERSION = "0.7.6-dev.0017418";
46720
46671
  //#endregion
46721
46672
  //#region src/cli/utils/json-mode.ts
46722
46673
  let context = null;
@@ -47085,13 +47036,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
47085
47036
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
47086
47037
  * standard `SENTRY_RELEASE` override.
47087
47038
  */
47088
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.7.6-dev.0a8d30b`;
47039
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.7.6-dev.0017418`;
47089
47040
  /**
47090
47041
  * Deployment environment shown in Sentry's environment filter. Defaults to
47091
47042
  * `production` for tagged releases and `development` for dev/unbuilt versions,
47092
47043
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
47093
47044
  */
47094
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.7.6-dev.0a8d30b") ? "development" : "production");
47045
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.7.6-dev.0017418") ? "development" : "production");
47095
47046
  /**
47096
47047
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
47097
47048
  * (set to `0` to disable tracing) and falls back to
@@ -50856,7 +50807,7 @@ const BLOCKING_SUMMARY = {
50856
50807
  const SCOPE_SUMMARY = {
50857
50808
  full: "Scan the whole project on every run",
50858
50809
  files: "Report every issue in changed files",
50859
- lines: "Report issues whose source spans touch changed lines",
50810
+ lines: "Report issues on changed lines",
50860
50811
  changed: "Report only the issues a change introduces"
50861
50812
  };
50862
50813
  const gatesEqual = (left, right) => left.blocking === right.blocking && left.scope === right.scope && left.comment === right.comment && left.reviewComments === right.reviewComments && left.commitStatus === right.commitStatus;
@@ -59251,7 +59202,7 @@ const buildDirtyPathContentFingerprint = (absolutePath, statusCode) => {
59251
59202
  return null;
59252
59203
  }
59253
59204
  if (!stats.isFile()) return null;
59254
- if (stats.size > 10485760) return null;
59205
+ if (stats.size > 10485760) return `stat:${stats.mtimeMs}:${stats.size}`;
59255
59206
  return hashFileContents(absolutePath);
59256
59207
  };
59257
59208
  const buildWorktreeFingerprint = (projectDirectory) => {
@@ -59725,9 +59676,7 @@ const buildScanAttributes = (input) => {
59725
59676
  hasCustomConfig: input.hasCustomConfig,
59726
59677
  rulesConfigured: ruleKeys.length,
59727
59678
  rulesDisabled: ruleKeys.filter((key) => ruleOverrides[key] === "off").length,
59728
- fileCount: input.result?.scannedFileCount ?? null,
59729
- nonJsxFileCount: input.result?.analyzedFiles?.filter((filePath) => !JSX_FILE_PATTERN.test(filePath)).length ?? null,
59730
- multilineDiagnosticCount: input.result?.diagnostics.filter((diagnostic) => (diagnostic.endLine ?? diagnostic.line) > diagnostic.line).length ?? null
59679
+ fileCount: input.result?.scannedFileCount ?? null
59731
59680
  });
59732
59681
  };
59733
59682
  /**
@@ -59796,12 +59745,6 @@ const countDeadlineSkippedFiles = (lintPartialFailures) => sumFileCountsMatching
59796
59745
  const DROPPED_FILES_MESSAGE_PATTERN = /^(\d+) file\(s\) failed to lint and were skipped/;
59797
59746
  const countDroppedLintFiles = (lintPartialFailures) => sumFileCountsMatching(lintPartialFailures, DROPPED_FILES_MESSAGE_PATTERN);
59798
59747
  //#endregion
59799
- //#region src/cli/utils/diagnostic-intersects-line-ranges.ts
59800
- const diagnosticIntersectsLineRanges = (diagnostic, lineRanges) => {
59801
- const diagnosticEndLine = Math.max(diagnostic.line, diagnostic.endLine ?? diagnostic.line);
59802
- return lineRanges.some(([rangeStartLine, rangeEndLine]) => diagnostic.line <= rangeEndLine && diagnosticEndLine >= rangeStartLine);
59803
- };
59804
- //#endregion
59805
59748
  //#region src/cli/utils/materialize-baseline-files.ts
59806
59749
  /**
59807
59750
  * Materializes the `ref` version of `files` into `tempDirectory` (via
@@ -60987,7 +60930,7 @@ const buildChangedLineMatcher = (directory, changedLineRanges) => {
60987
60930
  const relativePath = toForwardSlashes(path.isAbsolute(diagnostic.filePath) ? path.relative(directory, diagnostic.filePath) : diagnostic.filePath);
60988
60931
  const ranges = rangesByFile.get(relativePath);
60989
60932
  if (ranges === void 0) return false;
60990
- return diagnosticIntersectsLineRanges(diagnostic, ranges);
60933
+ return ranges.some(([start, end]) => diagnostic.line >= start && diagnostic.line <= end);
60991
60934
  };
60992
60935
  };
60993
60936
  const buildIgnoredTags = (userConfig) => {
@@ -63809,15 +63752,10 @@ const warnIfAiTrainingEnvironment = () => {
63809
63752
  //#region src/cli/utils/validate-mode-flags.ts
63810
63753
  const usedDiffAlias = (flags) => flags.diff !== void 0 && flags.diff !== false && flags.diff !== "false" && flags.diff !== "";
63811
63754
  const usedScope = (flags) => typeof flags.scope === "string" && flags.scope.length > 0;
63812
- const validateIncludeUntrackedScope = (includeUntracked, scope) => {
63813
- if (!includeUntracked || scope !== void 0 && scope !== "full") return;
63814
- throw new CliInputError("--include-untracked requires the files, changed, or lines scope (via --scope, --diff, or config).");
63815
- };
63816
63755
  const validateModeFlags = (flags) => {
63817
63756
  if (usedScope(flags) && usedDiffAlias(flags)) throw new CliInputError("Cannot combine --scope and --diff; --diff is the deprecated alias.");
63818
63757
  if (flags.staged && usedDiffAlias(flags)) throw new CliInputError("Cannot combine --staged and --diff; pick one mode.");
63819
63758
  if (flags.staged && (flags.scope === "full" || flags.scope === "changed")) throw new CliInputError(`Cannot combine --staged with --scope ${flags.scope}; use --scope files or --scope lines, or drop --scope.`);
63820
- if (flags.includeUntracked && flags.staged) throw new CliInputError("Cannot combine --include-untracked with --staged; the git index never holds untracked files.");
63821
63759
  if (flags.score && flags.json) throw new CliInputError("Cannot combine --score and --json; pick one output mode.");
63822
63760
  if (flags.score && flags.telemetry === false) throw new CliInputError("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
63823
63761
  if (flags.debug && (flags.score === false || flags.telemetry === false)) {
@@ -64027,15 +63965,13 @@ const inspectAction = async (directory, flags) => {
64027
63965
  const projectDirectories = await selectProjects(resolvedDirectory, flags.project, skipPrompts, userConfig?.projects);
64028
63966
  const changedFilesDiffInfo = flags.changedFilesFrom ? buildChangedFilesDiffInfo(readChangedFilesFrom(Path.resolve(flags.changedFilesFrom))) : null;
64029
63967
  const requestedScope = resolveScope(flags, userConfig);
64030
- const includeUntracked = flags.includeUntracked ?? false;
64031
63968
  const scopeRequest = requestedScope.scope === void 0 && changedFilesDiffInfo !== null ? {
64032
63969
  ...requestedScope,
64033
63970
  scope: "changed"
64034
63971
  } : requestedScope;
64035
- validateIncludeUntrackedScope(includeUntracked, scopeRequest.scope);
64036
63972
  const wantsDiffMode = scopeRequest.scope !== void 0 && scopeRequest.scope !== "full";
64037
63973
  const shouldDetectDiff = changedFilesDiffInfo === null && (wantsDiffMode || scopeRequest.scope === void 0 && !skipPrompts && !isQuiet);
64038
- const diffInfo = changedFilesDiffInfo ?? (shouldDetectDiff ? await getDiffInfo(resolvedDirectory, scopeRequest.base, includeUntracked) : null);
63974
+ const diffInfo = changedFilesDiffInfo ?? (shouldDetectDiff ? await getDiffInfo(resolvedDirectory, scopeRequest.base) : null);
64039
63975
  const scope = await finalizeScope({
64040
63976
  requested: scopeRequest,
64041
63977
  diffInfo,
@@ -64049,8 +63985,7 @@ const inspectAction = async (directory, flags) => {
64049
63985
  const changedLineRanges = scope === "lines" && diffInfo !== null && (diffInfo.isCurrentChanges || linesBaseRef !== null) && diffInfo !== null ? await getChangedLineRanges({
64050
63986
  directory: resolvedDirectory,
64051
63987
  baseRef: linesBaseRef ?? void 0,
64052
- files: [...diffInfo.changedFiles],
64053
- includeUntracked
63988
+ files: [...diffInfo.changedFiles]
64054
63989
  }) : null;
64055
63990
  if (scope === "lines" && changedLineRanges === null && !isQuiet) {
64056
63991
  cliLogger.warn("Could not determine changed lines (no base ref or git diff failed); reporting all issues in changed files.");
@@ -64983,7 +64918,6 @@ const ROOT_FLAG_SPEC = {
64983
64918
  "--dead-code",
64984
64919
  "--debug",
64985
64920
  "--help",
64986
- "--include-untracked",
64987
64921
  "--json",
64988
64922
  "--json-compact",
64989
64923
  "--lint",
@@ -65247,7 +65181,7 @@ ${highlighter.dim("Learn more:")}
65247
65181
  ${highlighter.info(CI_URL)}
65248
65182
  `;
65249
65183
  const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
65250
- const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--supply-chain", "enable the dependency supply-chain scan (default)").option("--no-supply-chain", "skip the dependency supply-chain scan (Socket.dev dependency health checks)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--debug", "force a Sentry trace and print its id at the end (paste it into a bug report)").option("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("--json-out <path>", "with --json, write the report to a file instead of stdout").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple); overrides the `projects` config field").option("--scope <value>", "how much supported JS/TS source to scan/report: full (default), files, changed (only new issues vs base), or lines (issues whose source spans touch changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").option("--include-untracked", "with --scope files/changed/lines, also scan ordinary untracked files (respects .gitignore)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--max-duration <seconds>", "scan time budget for the whole run, shared across workspace projects: past it, remaining lint batches and dead-code are skipped and partial results are reported (skipped files are listed in the JSON report)").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
65184
+ const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--supply-chain", "enable the dependency supply-chain scan (default)").option("--no-supply-chain", "skip the dependency supply-chain scan (Socket.dev dependency health checks)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--debug", "force a Sentry trace and print its id at the end (paste it into a bug report)").option("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("--json-out <path>", "with --json, write the report to a file instead of stdout").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple); overrides the `projects` config field").option("--scope <value>", "how much to scan/report: full (default), files, changed (only new issues vs base), or lines (only changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--max-duration <seconds>", "scan time budget for the whole run, shared across workspace projects: past it, remaining lint batches and dead-code are skipped and partial results are reported (skipped files are listed in the JSON report)").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
65251
65185
  program.action(inspectAction);
65252
65186
  program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
65253
65187
  program.command("install").alias("setup").description("Install the react-doctor skill into your coding agents and optional git hook").option("-y, --yes", "skip prompts, install for all detected agents").option("--dry-run", "show what would be installed without writing files").option("--agent-hooks", "install native non-blocking agent hooks for Claude Code and Cursor").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderInstallHelpEpilog).action(installAction);
@@ -65297,4 +65231,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
65297
65231
  export {};
65298
65232
 
65299
65233
  //# sourceMappingURL=cli.js.map
65300
- //# debugId=5dcb5b0b-ca1e-5655-8f52-3c22b421256d
65234
+ //# debugId=63b8a227-543e-5501-a998-58c03a1fb10e
package/dist/index.d.ts CHANGED
@@ -9654,7 +9654,6 @@ interface DiagnoseOptions {
9654
9654
  /** See `ReactDoctorConfig.deadCode`. Ignored in diff mode. */
9655
9655
  deadCode?: boolean;
9656
9656
  verbose?: boolean;
9657
- /** Restrict linting to these supported JS/TS source files. */
9658
9657
  includePaths?: string[];
9659
9658
  /**
9660
9659
  * Per-call override for `ReactDoctorConfig.respectInlineDisables`.
@@ -9916,9 +9915,9 @@ interface JsonReportProjectEntry {
9916
9915
  skippedCheckReasons?: Record<string, string>;
9917
9916
  /**
9918
9917
  * Number of source files this scan's linter examined. In diff / changed
9919
- * mode it's the count of changed supported JS/TS source files; in a full
9920
- * scan it's the whole source tree. `0` in a diff scan means the changed
9921
- * files held nothing React Doctor lints —
9918
+ * mode it's the count of changed React-eligible files (`.tsx`/`.jsx` plus
9919
+ * framework entry files); in a full scan it's the whole source tree. `0`
9920
+ * in a diff scan means the changed files held nothing React Doctor lints —
9922
9921
  * the GitHub Action reads that as "nothing to report" (skips the PR comment;
9923
9922
  * the commit status says "skipped"). Optional: absent on reports from
9924
9923
  * constructors that don't track it (e.g. `toJsonReport`).
@@ -10256,7 +10255,7 @@ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReportV3$1;
10256
10255
  * render diff-base mistakes (`GitBaseBranchInvalid` /
10257
10256
  * `GitBaseBranchMissing`) as clean user errors instead of crashes.
10258
10257
  */
10259
- declare const getDiffInfo: (directory: string, explicitBaseBranch?: string, includeUntracked?: boolean) => Promise<DiffInfo | null>;
10258
+ declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => Promise<DiffInfo | null>;
10260
10259
  declare const filterSourceFiles: (filePaths: string[]) => string[];
10261
10260
  /**
10262
10261
  * Programmatic façade over `Git.changedLineRanges` (the `lines` scope). Diffs
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]="80f981d4-ebf0-5bc0-9643-8a68d27626a5")}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]="7a10d23c-04fd-53e1-a623-a3dc5d6d0830")}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
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";
@@ -32930,6 +32930,7 @@ const IGNORED_DIRECTORIES = new Set([
32930
32930
  "out",
32931
32931
  "storybook-static"
32932
32932
  ]);
32933
+ const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
32933
32934
  const MILLISECONDS_PER_SECOND = 1e3;
32934
32935
  const SCORE_API_URL = "https://www.react.doctor/api/score";
32935
32936
  const FETCH_TIMEOUT_MS = 1e4;
@@ -33142,15 +33143,13 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
33142
33143
  const listSourceFilesWithSize = (rootDirectory) => collectSizedSourceFiles(rootDirectory, (listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory)).sort());
33143
33144
  const listSourceFiles = (rootDirectory) => listSourceFilesWithSize(rootDirectory).map((entry) => entry.path);
33144
33145
  const countSourceFiles = (rootDirectory) => listSourceFilesWithSize(rootDirectory).length;
33145
- const UTF8_BOM_CHARACTER = "";
33146
- const stripUtf8Bom = (content) => content.startsWith(UTF8_BOM_CHARACTER) ? content.slice(1) : content;
33147
33146
  const cachedPackageJsons = /* @__PURE__ */ new Map();
33148
33147
  const clearPackageJsonCache = () => {
33149
33148
  cachedPackageJsons.clear();
33150
33149
  };
33151
33150
  const readPackageJsonUncached = (packageJsonPath) => {
33152
33151
  try {
33153
- return JSON.parse(stripUtf8Bom(NFS.readFileSync(packageJsonPath, "utf-8")));
33152
+ return JSON.parse(NFS.readFileSync(packageJsonPath, "utf-8"));
33154
33153
  } catch (error) {
33155
33154
  if (error instanceof SyntaxError) return {};
33156
33155
  if (isErrnoException(error)) {
@@ -36791,6 +36790,7 @@ const PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
36791
36790
  const PNPM_LOCKFILE = "pnpm-lock.yaml";
36792
36791
  const PACKAGE_JSON_FILE = "package.json";
36793
36792
  const PNPM_HARDENING_RULE_KEY = "require-pnpm-hardening";
36793
+ const UTF8_BOM_CHAR = "";
36794
36794
  const HARDENING_SETTING_KEYS = new Set([
36795
36795
  "minimumReleaseAge",
36796
36796
  "blockExoticSubdeps",
@@ -36815,11 +36815,12 @@ const stripInlineComment = (rawValue) => {
36815
36815
  return rawValue;
36816
36816
  };
36817
36817
  const unquote = (rawValue) => rawValue.replace(/^["']|["']$/g, "");
36818
+ const stripBom = (rawContent) => rawContent.startsWith(UTF8_BOM_CHAR) ? rawContent.slice(1) : rawContent;
36818
36819
  const parseHardeningSettings = (content) => {
36819
36820
  let minimumReleaseAge = null;
36820
36821
  let blockExoticSubdeps = null;
36821
36822
  let trustPolicy = null;
36822
- const lines = stripUtf8Bom(content).split(/\r?\n/);
36823
+ const lines = stripBom(content).split(/\r?\n/);
36823
36824
  for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
36824
36825
  const lineText = lines[lineIndex];
36825
36826
  if (lineText === void 0) continue;
@@ -36853,7 +36854,7 @@ const isPnpmManagedProject = (rootDirectory) => {
36853
36854
  const packageJsonPath = Path.join(rootDirectory, PACKAGE_JSON_FILE);
36854
36855
  if (!isFile(packageJsonPath)) return false;
36855
36856
  try {
36856
- const packageJsonRaw = stripUtf8Bom(NFS.readFileSync(packageJsonPath, "utf-8"));
36857
+ const packageJsonRaw = NFS.readFileSync(packageJsonPath, "utf-8");
36857
36858
  const packageJson = JSON.parse(packageJsonRaw);
36858
36859
  if (packageJson !== null && typeof packageJson === "object" && "packageManager" in packageJson && typeof packageJson.packageManager === "string" && packageJson.packageManager.startsWith("pnpm@")) return true;
36859
36860
  } catch {
@@ -37515,7 +37516,9 @@ const highlighter = {
37515
37516
  gray: import_picocolors.default.gray,
37516
37517
  bold: import_picocolors.default.bold
37517
37518
  };
37518
- const computeExplicitLintIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter(isLintableSourceFile) : void 0;
37519
+ const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
37520
+ const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
37521
+ const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
37519
37522
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
37520
37523
  const FALSY_VALUES = new Set([
37521
37524
  "false",
@@ -38357,11 +38360,11 @@ const resolveDeadCodeTimeout = (input) => {
38357
38360
  phaseTimeoutMs: workerTimeoutMs + DEAD_CODE_PHASE_TIMEOUT_OVER_WORKER_MS
38358
38361
  };
38359
38362
  };
38360
- const resolveLintIncludePaths = (rootDirectory, userConfig) => {
38363
+ const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
38361
38364
  if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
38362
38365
  const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
38363
38366
  return listSourceFiles(rootDirectory).filter((filePath) => {
38364
- if (!isLintableSourceFile(filePath)) return false;
38367
+ if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
38365
38368
  return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
38366
38369
  });
38367
38370
  };
@@ -38579,7 +38582,6 @@ const parseGithubViewerPermission = (stdout) => {
38579
38582
  return /^[A-Z_]+$/.test(value) ? value.toLowerCase() : null;
38580
38583
  };
38581
38584
  const splitNullSeparated = (value) => value.split("\0").filter((entry) => entry.length > 0);
38582
- const UNTRACKED_FILE_LAST_LINE = Number.MAX_SAFE_INTEGER;
38583
38585
  /**
38584
38586
  * `Git` wraps every `git`-via-subprocess call react-doctor makes
38585
38587
  * behind a `Context.Service`. The production layer (`layerNode`)
@@ -38650,14 +38652,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
38650
38652
  args,
38651
38653
  directory
38652
38654
  });
38653
- const listUntrackedFilePaths = (directory, includePaths = []) => runGit(directory, [
38654
- "ls-files",
38655
- "-z",
38656
- "--others",
38657
- "--exclude-standard",
38658
- ...includePaths.length > 0 ? ["--", ...includePaths] : []
38659
- ]).pipe(map$3((result) => result.status === 0 ? splitNullSeparated(result.stdout) : null));
38660
- const mergeUntracked = (directory, trackedFilePaths, includeUntracked) => includeUntracked ? listUntrackedFilePaths(directory).pipe(map$3((untracked) => untracked === null ? trackedFilePaths : [...new Set([...trackedFilePaths, ...untracked])])) : succeed$2(trackedFilePaths);
38661
38655
  const currentBranch = (directory) => runGit(directory, [
38662
38656
  "rev-parse",
38663
38657
  "--abbrev-ref",
@@ -38780,7 +38774,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38780
38774
  githubViewerPermission,
38781
38775
  branchExists,
38782
38776
  mergeBase,
38783
- diffSelection: ({ directory, explicitBaseBranch, includeUntracked = false }) => gen(function* () {
38777
+ diffSelection: ({ directory, explicitBaseBranch }) => gen(function* () {
38784
38778
  if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* fail$4(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
38785
38779
  if (explicitBaseBranch !== void 0) {
38786
38780
  const range = parseGitDiffRange(explicitBaseBranch);
@@ -38809,7 +38803,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38809
38803
  "HEAD"
38810
38804
  ]);
38811
38805
  if (uncommitted.status !== 0) return null;
38812
- const files = yield* mergeUntracked(directory, splitNullSeparated(uncommitted.stdout), includeUntracked);
38806
+ const files = splitNullSeparated(uncommitted.stdout);
38813
38807
  if (files.length === 0) return null;
38814
38808
  return {
38815
38809
  currentBranch: resolvedCurrentBranch,
@@ -38839,7 +38833,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38839
38833
  currentBranch: resolvedCurrentBranch,
38840
38834
  baseBranch,
38841
38835
  diffBaseRef: mergeBaseRef,
38842
- changedFiles: yield* mergeUntracked(directory, splitNullSeparated(diff.stdout), includeUntracked),
38836
+ changedFiles: splitNullSeparated(diff.stdout),
38843
38837
  isCurrentChanges: false
38844
38838
  };
38845
38839
  }).pipe(withSpan("Git.diffSelection")),
@@ -38885,7 +38879,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38885
38879
  stdout: result.stdout
38886
38880
  };
38887
38881
  }).pipe(withSpan("Git.grep")),
38888
- changedLineRanges: ({ directory, baseRef, cached, files, includeUntracked = false }) => gen(function* () {
38882
+ changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
38889
38883
  if (files.length === 0) return [];
38890
38884
  if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
38891
38885
  const result = yield* runGit(directory, [
@@ -38899,14 +38893,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38899
38893
  ...files
38900
38894
  ]);
38901
38895
  if (result.status !== 0) return null;
38902
- const changedLineRanges = parseChangedLineRanges(result.stdout);
38903
- if (cached || !includeUntracked) return changedLineRanges;
38904
- const untrackedFilePaths = yield* listUntrackedFilePaths(directory, files);
38905
- if (untrackedFilePaths === null) return changedLineRanges;
38906
- return [...changedLineRanges, ...untrackedFilePaths.map((file) => ({
38907
- file,
38908
- ranges: [[1, UNTRACKED_FILE_LAST_LINE]]
38909
- }))];
38896
+ return parseChangedLineRanges(result.stdout);
38910
38897
  }).pipe(catch_$1((error) => error.reason._tag === "GitInvocationFailed" ? succeed$2(null) : fail$4(error)), withSpan("Git.changedLineRanges"))
38911
38898
  });
38912
38899
  })).pipe(provide$2(layer$2.pipe(provide$2(mergeAll$1(layer$1, layer)))));
@@ -39658,12 +39645,6 @@ const mapWithConcurrency = async (items, concurrency, task) => {
39658
39645
  if (errors.length > 0) throw errors[0];
39659
39646
  return results;
39660
39647
  };
39661
- const lineOfUtf8Offset = (sourceBuffer, utf8Offset) => {
39662
- let lineNumber = 1;
39663
- const scanEnd = Math.min(utf8Offset, sourceBuffer.length);
39664
- for (let byteIndex = 0; byteIndex < scanEnd; byteIndex++) if (sourceBuffer[byteIndex] === 10) lineNumber++;
39665
- return lineNumber;
39666
- };
39667
39648
  const REANIMATED_SHARED_VALUE_HINT = "If this is a Reanimated shared value, prefer its React Compiler-compatible `.get()` / `.set()` accessors over `.value` — https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue/#react-compiler-support";
39668
39649
  const ACCESSORS_MIN_VERSION = "3.15.0";
39669
39650
  const supportsAccessors = (reanimatedVersion) => {
@@ -40235,6 +40216,13 @@ const findOutermostEnclosingFunctionRange = (sourceFile, targetLine) => {
40235
40216
  visit(sourceFile);
40236
40217
  return foundRange;
40237
40218
  };
40219
+ const NEWLINE_BYTE = 10;
40220
+ const lineOfUtf8Offset = (sourceBuffer, utf8Offset) => {
40221
+ let lineNumber = 1;
40222
+ const scanEnd = Math.min(utf8Offset, sourceBuffer.length);
40223
+ for (let byteIndex = 0; byteIndex < scanEnd; byteIndex++) if (sourceBuffer[byteIndex] === NEWLINE_BYTE) lineNumber++;
40224
+ return lineNumber;
40225
+ };
40238
40226
  /**
40239
40227
  * Drops `react-doctor/react-compiler-no-manual-memoization` diagnostics
40240
40228
  * whose enclosing function also carries a `react-hooks-js` (React
@@ -40439,33 +40427,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
40439
40427
  }
40440
40428
  if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
40441
40429
  const minifiedFileCache = /* @__PURE__ */ new Map();
40442
- const sourceBufferCache = /* @__PURE__ */ new Map();
40443
- const sourceLinesCache = /* @__PURE__ */ new Map();
40444
- const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
40445
- const readSourceBuffer = (filename) => {
40446
- const absolutePath = resolveAbsolutePath(filename);
40447
- const cached = sourceBufferCache.get(absolutePath);
40448
- if (cached !== void 0) return cached;
40449
- let sourceBuffer;
40450
- try {
40451
- sourceBuffer = NFS.readFileSync(absolutePath);
40452
- } catch {
40453
- sourceBuffer = null;
40454
- }
40455
- sourceBufferCache.set(absolutePath, sourceBuffer);
40456
- return sourceBuffer;
40457
- };
40458
- const readSourceLines = (filename) => {
40459
- const absolutePath = resolveAbsolutePath(filename);
40460
- const cached = sourceLinesCache.get(absolutePath);
40461
- if (cached !== void 0) return cached;
40462
- const sourceBuffer = readSourceBuffer(filename);
40463
- const sourceLines = sourceBuffer ? sourceBuffer.toString("utf8").split("\n") : null;
40464
- sourceLinesCache.set(absolutePath, sourceLines);
40465
- return sourceLines;
40466
- };
40467
40430
  const isMinifiedDiagnosticFile = (filename) => {
40468
- const absolutePath = resolveAbsolutePath(filename);
40431
+ const absolutePath = Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
40469
40432
  const cached = minifiedFileCache.get(absolutePath);
40470
40433
  if (cached !== void 0) return cached;
40471
40434
  const minified = isMinifiedSource(absolutePath);
@@ -40478,17 +40441,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
40478
40441
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
40479
40442
  const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
40480
40443
  const primarySpan = primaryLabel?.span;
40481
- const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
40482
40444
  const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
40483
40445
  const category = resolveDiagnosticCategory(plugin, rule);
40484
- const matchByOccurrence = resolveMatchByOccurrence(rule, category);
40485
- const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
40486
- const primaryLineIndex = primarySpan ? primarySpan.line - 1 : -1;
40487
- const primaryLine = sourceLines?.[primaryLineIndex];
40488
- const primaryColumnIndex = primarySpan ? primarySpan.column - 1 : -1;
40489
- const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
40490
- const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
40491
- const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
40492
40446
  return {
40493
40447
  filePath: normalizedFilePath,
40494
40448
  plugin,
@@ -40502,11 +40456,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
40502
40456
  column: primarySpan?.column ?? 0,
40503
40457
  ...primarySpan ? {
40504
40458
  offset: primarySpan.offset,
40505
- length: primarySpan.length,
40506
- ...primarySpanEndLine !== void 0 ? { endLine: primarySpanEndLine } : {}
40459
+ length: primarySpan.length
40507
40460
  } : {},
40508
40461
  category,
40509
- ...matchByOccurrence ? { matchByOccurrence: true } : {},
40462
+ ...resolveMatchByOccurrence(rule, category) ? { matchByOccurrence: true } : {},
40510
40463
  ...relatedLocations.length > 0 ? { relatedLocations } : {}
40511
40464
  };
40512
40465
  }), rootDirectory);
@@ -42293,7 +42246,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
42293
42246
  directory: scanDirectory,
42294
42247
  repo
42295
42248
  }).pipe(orElseSucceed(() => null)) : succeed$2(null));
42296
- const lintIncludePaths = (input.skipExplicitIncludePathFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
42249
+ const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
42297
42250
  const fallbackScannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => Path.resolve(scanDirectory, relativePath)) : [];
42298
42251
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
42299
42252
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
@@ -42964,11 +42917,10 @@ const buildSkippedChecks = (input) => {
42964
42917
  * render diff-base mistakes (`GitBaseBranchInvalid` /
42965
42918
  * `GitBaseBranchMissing`) as clean user errors instead of crashes.
42966
42919
  */
42967
- const getDiffInfo = (directory, explicitBaseBranch, includeUntracked) => runPromise(gen(function* () {
42920
+ const getDiffInfo = (directory, explicitBaseBranch) => runPromise(gen(function* () {
42968
42921
  const selection = yield* (yield* Git).diffSelection({
42969
42922
  directory,
42970
- explicitBaseBranch,
42971
- includeUntracked
42923
+ explicitBaseBranch
42972
42924
  });
42973
42925
  if (selection === null) return null;
42974
42926
  return {
@@ -43258,4 +43210,4 @@ const toJsonReport = (result, options) => buildJsonReport({
43258
43210
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
43259
43211
 
43260
43212
  //# sourceMappingURL=index.js.map
43261
- //# debugId=80f981d4-ebf0-5bc0-9643-8a68d27626a5
43213
+ //# debugId=7a10d23c-04fd-53e1-a623-a3dc5d6d0830
package/dist/lsp.js CHANGED
@@ -32959,6 +32959,7 @@ const IGNORED_DIRECTORIES = new Set([
32959
32959
  "out",
32960
32960
  "storybook-static"
32961
32961
  ]);
32962
+ const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
32962
32963
  const MILLISECONDS_PER_SECOND = 1e3;
32963
32964
  const SCORE_API_URL = "https://www.react.doctor/api/score";
32964
32965
  const FETCH_TIMEOUT_MS = 1e4;
@@ -33194,15 +33195,13 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
33194
33195
  const listSourceFilesWithSize = (rootDirectory) => collectSizedSourceFiles(rootDirectory, (listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory)).sort());
33195
33196
  const listSourceFiles = (rootDirectory) => listSourceFilesWithSize(rootDirectory).map((entry) => entry.path);
33196
33197
  const countSourceFiles = (rootDirectory) => listSourceFilesWithSize(rootDirectory).length;
33197
- const UTF8_BOM_CHARACTER = "";
33198
- const stripUtf8Bom = (content) => content.startsWith(UTF8_BOM_CHARACTER) ? content.slice(1) : content;
33199
33198
  const cachedPackageJsons = /* @__PURE__ */ new Map();
33200
33199
  const clearPackageJsonCache = () => {
33201
33200
  cachedPackageJsons.clear();
33202
33201
  };
33203
33202
  const readPackageJsonUncached = (packageJsonPath) => {
33204
33203
  try {
33205
- return JSON.parse(stripUtf8Bom(NFS.readFileSync(packageJsonPath, "utf-8")));
33204
+ return JSON.parse(NFS.readFileSync(packageJsonPath, "utf-8"));
33206
33205
  } catch (error) {
33207
33206
  if (error instanceof SyntaxError) return {};
33208
33207
  if (isErrnoException(error)) {
@@ -36769,6 +36768,7 @@ const PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
36769
36768
  const PNPM_LOCKFILE = "pnpm-lock.yaml";
36770
36769
  const PACKAGE_JSON_FILE = "package.json";
36771
36770
  const PNPM_HARDENING_RULE_KEY = "require-pnpm-hardening";
36771
+ const UTF8_BOM_CHAR = "";
36772
36772
  const HARDENING_SETTING_KEYS = new Set([
36773
36773
  "minimumReleaseAge",
36774
36774
  "blockExoticSubdeps",
@@ -36793,11 +36793,12 @@ const stripInlineComment = (rawValue) => {
36793
36793
  return rawValue;
36794
36794
  };
36795
36795
  const unquote = (rawValue) => rawValue.replace(/^["']|["']$/g, "");
36796
+ const stripBom = (rawContent) => rawContent.startsWith(UTF8_BOM_CHAR) ? rawContent.slice(1) : rawContent;
36796
36797
  const parseHardeningSettings = (content) => {
36797
36798
  let minimumReleaseAge = null;
36798
36799
  let blockExoticSubdeps = null;
36799
36800
  let trustPolicy = null;
36800
- const lines = stripUtf8Bom(content).split(/\r?\n/);
36801
+ const lines = stripBom(content).split(/\r?\n/);
36801
36802
  for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
36802
36803
  const lineText = lines[lineIndex];
36803
36804
  if (lineText === void 0) continue;
@@ -36831,7 +36832,7 @@ const isPnpmManagedProject = (rootDirectory) => {
36831
36832
  const packageJsonPath = Path.join(rootDirectory, PACKAGE_JSON_FILE);
36832
36833
  if (!isFile(packageJsonPath)) return false;
36833
36834
  try {
36834
- const packageJsonRaw = stripUtf8Bom(NFS.readFileSync(packageJsonPath, "utf-8"));
36835
+ const packageJsonRaw = NFS.readFileSync(packageJsonPath, "utf-8");
36835
36836
  const packageJson = JSON.parse(packageJsonRaw);
36836
36837
  if (packageJson !== null && typeof packageJson === "object" && "packageManager" in packageJson && typeof packageJson.packageManager === "string" && packageJson.packageManager.startsWith("pnpm@")) return true;
36837
36838
  } catch {
@@ -37493,7 +37494,9 @@ const highlighter = {
37493
37494
  gray: import_picocolors.default.gray,
37494
37495
  bold: import_picocolors.default.bold
37495
37496
  };
37496
- const computeExplicitLintIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter(isLintableSourceFile) : void 0;
37497
+ const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
37498
+ const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
37499
+ const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
37497
37500
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
37498
37501
  const FALSY_VALUES = new Set([
37499
37502
  "false",
@@ -38335,11 +38338,11 @@ const resolveDeadCodeTimeout = (input) => {
38335
38338
  phaseTimeoutMs: workerTimeoutMs + DEAD_CODE_PHASE_TIMEOUT_OVER_WORKER_MS
38336
38339
  };
38337
38340
  };
38338
- const resolveLintIncludePaths = (rootDirectory, userConfig) => {
38341
+ const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
38339
38342
  if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
38340
38343
  const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
38341
38344
  return listSourceFiles(rootDirectory).filter((filePath) => {
38342
- if (!isLintableSourceFile(filePath)) return false;
38345
+ if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
38343
38346
  return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
38344
38347
  });
38345
38348
  };
@@ -38557,7 +38560,6 @@ const parseGithubViewerPermission = (stdout) => {
38557
38560
  return /^[A-Z_]+$/.test(value) ? value.toLowerCase() : null;
38558
38561
  };
38559
38562
  const splitNullSeparated = (value) => value.split("\0").filter((entry) => entry.length > 0);
38560
- const UNTRACKED_FILE_LAST_LINE = Number.MAX_SAFE_INTEGER;
38561
38563
  /**
38562
38564
  * `Git` wraps every `git`-via-subprocess call react-doctor makes
38563
38565
  * behind a `Context.Service`. The production layer (`layerNode`)
@@ -38628,14 +38630,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
38628
38630
  args,
38629
38631
  directory
38630
38632
  });
38631
- const listUntrackedFilePaths = (directory, includePaths = []) => runGit(directory, [
38632
- "ls-files",
38633
- "-z",
38634
- "--others",
38635
- "--exclude-standard",
38636
- ...includePaths.length > 0 ? ["--", ...includePaths] : []
38637
- ]).pipe(map$3((result) => result.status === 0 ? splitNullSeparated(result.stdout) : null));
38638
- const mergeUntracked = (directory, trackedFilePaths, includeUntracked) => includeUntracked ? listUntrackedFilePaths(directory).pipe(map$3((untracked) => untracked === null ? trackedFilePaths : [...new Set([...trackedFilePaths, ...untracked])])) : succeed$2(trackedFilePaths);
38639
38633
  const currentBranch = (directory) => runGit(directory, [
38640
38634
  "rev-parse",
38641
38635
  "--abbrev-ref",
@@ -38758,7 +38752,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38758
38752
  githubViewerPermission,
38759
38753
  branchExists,
38760
38754
  mergeBase,
38761
- diffSelection: ({ directory, explicitBaseBranch, includeUntracked = false }) => gen(function* () {
38755
+ diffSelection: ({ directory, explicitBaseBranch }) => gen(function* () {
38762
38756
  if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* fail$4(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
38763
38757
  if (explicitBaseBranch !== void 0) {
38764
38758
  const range = parseGitDiffRange(explicitBaseBranch);
@@ -38787,7 +38781,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38787
38781
  "HEAD"
38788
38782
  ]);
38789
38783
  if (uncommitted.status !== 0) return null;
38790
- const files = yield* mergeUntracked(directory, splitNullSeparated(uncommitted.stdout), includeUntracked);
38784
+ const files = splitNullSeparated(uncommitted.stdout);
38791
38785
  if (files.length === 0) return null;
38792
38786
  return {
38793
38787
  currentBranch: resolvedCurrentBranch,
@@ -38817,7 +38811,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38817
38811
  currentBranch: resolvedCurrentBranch,
38818
38812
  baseBranch,
38819
38813
  diffBaseRef: mergeBaseRef,
38820
- changedFiles: yield* mergeUntracked(directory, splitNullSeparated(diff.stdout), includeUntracked),
38814
+ changedFiles: splitNullSeparated(diff.stdout),
38821
38815
  isCurrentChanges: false
38822
38816
  };
38823
38817
  }).pipe(withSpan("Git.diffSelection")),
@@ -38863,7 +38857,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38863
38857
  stdout: result.stdout
38864
38858
  };
38865
38859
  }).pipe(withSpan("Git.grep")),
38866
- changedLineRanges: ({ directory, baseRef, cached, files, includeUntracked = false }) => gen(function* () {
38860
+ changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
38867
38861
  if (files.length === 0) return [];
38868
38862
  if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
38869
38863
  const result = yield* runGit(directory, [
@@ -38877,14 +38871,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38877
38871
  ...files
38878
38872
  ]);
38879
38873
  if (result.status !== 0) return null;
38880
- const changedLineRanges = parseChangedLineRanges(result.stdout);
38881
- if (cached || !includeUntracked) return changedLineRanges;
38882
- const untrackedFilePaths = yield* listUntrackedFilePaths(directory, files);
38883
- if (untrackedFilePaths === null) return changedLineRanges;
38884
- return [...changedLineRanges, ...untrackedFilePaths.map((file) => ({
38885
- file,
38886
- ranges: [[1, UNTRACKED_FILE_LAST_LINE]]
38887
- }))];
38874
+ return parseChangedLineRanges(result.stdout);
38888
38875
  }).pipe(catch_$1((error) => error.reason._tag === "GitInvocationFailed" ? succeed$2(null) : fail$4(error)), withSpan("Git.changedLineRanges"))
38889
38876
  });
38890
38877
  })).pipe(provide$2(layer$2.pipe(provide$2(mergeAll$1(layer$1, layer)))));
@@ -39636,12 +39623,6 @@ const mapWithConcurrency = async (items, concurrency, task) => {
39636
39623
  if (errors.length > 0) throw errors[0];
39637
39624
  return results;
39638
39625
  };
39639
- const lineOfUtf8Offset = (sourceBuffer, utf8Offset) => {
39640
- let lineNumber = 1;
39641
- const scanEnd = Math.min(utf8Offset, sourceBuffer.length);
39642
- for (let byteIndex = 0; byteIndex < scanEnd; byteIndex++) if (sourceBuffer[byteIndex] === 10) lineNumber++;
39643
- return lineNumber;
39644
- };
39645
39626
  const REANIMATED_SHARED_VALUE_HINT = "If this is a Reanimated shared value, prefer its React Compiler-compatible `.get()` / `.set()` accessors over `.value` — https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue/#react-compiler-support";
39646
39627
  const ACCESSORS_MIN_VERSION = "3.15.0";
39647
39628
  const supportsAccessors = (reanimatedVersion) => {
@@ -40213,6 +40194,13 @@ const findOutermostEnclosingFunctionRange = (sourceFile, targetLine) => {
40213
40194
  visit(sourceFile);
40214
40195
  return foundRange;
40215
40196
  };
40197
+ const NEWLINE_BYTE = 10;
40198
+ const lineOfUtf8Offset = (sourceBuffer, utf8Offset) => {
40199
+ let lineNumber = 1;
40200
+ const scanEnd = Math.min(utf8Offset, sourceBuffer.length);
40201
+ for (let byteIndex = 0; byteIndex < scanEnd; byteIndex++) if (sourceBuffer[byteIndex] === NEWLINE_BYTE) lineNumber++;
40202
+ return lineNumber;
40203
+ };
40216
40204
  /**
40217
40205
  * Drops `react-doctor/react-compiler-no-manual-memoization` diagnostics
40218
40206
  * whose enclosing function also carries a `react-hooks-js` (React
@@ -40417,33 +40405,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
40417
40405
  }
40418
40406
  if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
40419
40407
  const minifiedFileCache = /* @__PURE__ */ new Map();
40420
- const sourceBufferCache = /* @__PURE__ */ new Map();
40421
- const sourceLinesCache = /* @__PURE__ */ new Map();
40422
- const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
40423
- const readSourceBuffer = (filename) => {
40424
- const absolutePath = resolveAbsolutePath(filename);
40425
- const cached = sourceBufferCache.get(absolutePath);
40426
- if (cached !== void 0) return cached;
40427
- let sourceBuffer;
40428
- try {
40429
- sourceBuffer = NFS.readFileSync(absolutePath);
40430
- } catch {
40431
- sourceBuffer = null;
40432
- }
40433
- sourceBufferCache.set(absolutePath, sourceBuffer);
40434
- return sourceBuffer;
40435
- };
40436
- const readSourceLines = (filename) => {
40437
- const absolutePath = resolveAbsolutePath(filename);
40438
- const cached = sourceLinesCache.get(absolutePath);
40439
- if (cached !== void 0) return cached;
40440
- const sourceBuffer = readSourceBuffer(filename);
40441
- const sourceLines = sourceBuffer ? sourceBuffer.toString("utf8").split("\n") : null;
40442
- sourceLinesCache.set(absolutePath, sourceLines);
40443
- return sourceLines;
40444
- };
40445
40408
  const isMinifiedDiagnosticFile = (filename) => {
40446
- const absolutePath = resolveAbsolutePath(filename);
40409
+ const absolutePath = Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
40447
40410
  const cached = minifiedFileCache.get(absolutePath);
40448
40411
  if (cached !== void 0) return cached;
40449
40412
  const minified = isMinifiedSource(absolutePath);
@@ -40456,17 +40419,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
40456
40419
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
40457
40420
  const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
40458
40421
  const primarySpan = primaryLabel?.span;
40459
- const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
40460
40422
  const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
40461
40423
  const category = resolveDiagnosticCategory(plugin, rule);
40462
- const matchByOccurrence = resolveMatchByOccurrence(rule, category);
40463
- const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
40464
- const primaryLineIndex = primarySpan ? primarySpan.line - 1 : -1;
40465
- const primaryLine = sourceLines?.[primaryLineIndex];
40466
- const primaryColumnIndex = primarySpan ? primarySpan.column - 1 : -1;
40467
- const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
40468
- const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
40469
- const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
40470
40424
  return {
40471
40425
  filePath: normalizedFilePath,
40472
40426
  plugin,
@@ -40480,11 +40434,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
40480
40434
  column: primarySpan?.column ?? 0,
40481
40435
  ...primarySpan ? {
40482
40436
  offset: primarySpan.offset,
40483
- length: primarySpan.length,
40484
- ...primarySpanEndLine !== void 0 ? { endLine: primarySpanEndLine } : {}
40437
+ length: primarySpan.length
40485
40438
  } : {},
40486
40439
  category,
40487
- ...matchByOccurrence ? { matchByOccurrence: true } : {},
40440
+ ...resolveMatchByOccurrence(rule, category) ? { matchByOccurrence: true } : {},
40488
40441
  ...relatedLocations.length > 0 ? { relatedLocations } : {}
40489
40442
  };
40490
40443
  }), rootDirectory);
@@ -42271,7 +42224,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
42271
42224
  directory: scanDirectory,
42272
42225
  repo
42273
42226
  }).pipe(orElseSucceed(() => null)) : succeed$2(null));
42274
- const lintIncludePaths = (input.skipExplicitIncludePathFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
42227
+ const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
42275
42228
  const fallbackScannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => Path.resolve(scanDirectory, relativePath)) : [];
42276
42229
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
42277
42230
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
@@ -42766,7 +42719,7 @@ const runEditorScan = async (input) => {
42766
42719
  warnings,
42767
42720
  isCi: false,
42768
42721
  resolveLocalGithubViewerPermission: false,
42769
- skipExplicitIncludePathFilter: true
42722
+ skipJsxIncludeFilter: true
42770
42723
  }).pipe(withSpan("runEditorScan", { attributes: {
42771
42724
  "editor.lint": lint,
42772
42725
  "editor.runDeadCode": runDeadCode
@@ -43529,7 +43482,7 @@ const createLintCache = (input) => {
43529
43482
  let persistTimer = null;
43530
43483
  try {
43531
43484
  const parsed = JSON.parse(fs.readFileSync(cacheFilePath, "utf8"));
43532
- if (parsed.version === 2 && parsed.fingerprint === input.fingerprint) for (const [fsPath, entry] of Object.entries(parsed.entries)) entries.set(fsPath, entry);
43485
+ if (parsed.version === 1 && parsed.fingerprint === input.fingerprint) for (const [fsPath, entry] of Object.entries(parsed.entries)) entries.set(fsPath, entry);
43533
43486
  } catch {}
43534
43487
  const persist = () => {
43535
43488
  if (persistTimer) {
@@ -43540,7 +43493,7 @@ const createLintCache = (input) => {
43540
43493
  dirty = false;
43541
43494
  try {
43542
43495
  const payload = {
43543
- version: 2,
43496
+ version: 1,
43544
43497
  fingerprint: input.fingerprint,
43545
43498
  entries: Object.fromEntries(entries)
43546
43499
  };
@@ -43553,14 +43506,14 @@ const createLintCache = (input) => {
43553
43506
  }
43554
43507
  };
43555
43508
  return {
43556
- lookup: (fsPath, identity) => {
43509
+ lookup: (fsPath, stat) => {
43557
43510
  const entry = entries.get(fsPath);
43558
- if (entry !== void 0 && entry.contentHash === identity.contentHash) return entry.diagnostics;
43511
+ if (entry !== void 0 && entry.mtimeMs === stat.mtimeMs && entry.size === stat.size) return entry.diagnostics;
43559
43512
  return null;
43560
43513
  },
43561
- store: (fsPath, identity, diagnostics) => {
43514
+ store: (fsPath, stat, diagnostics) => {
43562
43515
  entries.set(fsPath, {
43563
- ...identity,
43516
+ ...stat,
43564
43517
  diagnostics
43565
43518
  });
43566
43519
  dirty = true;
@@ -43649,9 +43602,16 @@ const resolveDiagnosticFsPath = (rawFilePath, scanDirectory, projectDirectory, o
43649
43602
  }
43650
43603
  return normalizeFsPath(absolute);
43651
43604
  };
43652
- const readFileIdentity = (fsPath) => {
43653
- const contentHash = hashFileContents(fsPath);
43654
- return contentHash === null ? null : { contentHash };
43605
+ const statSafe = (fsPath) => {
43606
+ try {
43607
+ const stat = fs.statSync(fsPath);
43608
+ return {
43609
+ mtimeMs: stat.mtimeMs,
43610
+ size: stat.size
43611
+ };
43612
+ } catch {
43613
+ return null;
43614
+ }
43655
43615
  };
43656
43616
  /**
43657
43617
  * Outcome for a per-file request served without running oxlint (every
@@ -43677,7 +43637,7 @@ const outcomeWithoutScan = (request, byFile, requestedPaths) => ({
43677
43637
  * overlay tree (unsaved buffers) or disk, groups diagnostics by canonical
43678
43638
  * absolute path, and reports stale-detection metadata.
43679
43639
  *
43680
- * A persistent per-file lint cache (keyed by content, namespaced by a
43640
+ * A persistent per-file lint cache (keyed by mtime + size, namespaced by a
43681
43641
  * config fingerprint) short-circuits unchanged files so a re-opened editor
43682
43642
  * or repeated workspace scan skips the oxlint subprocess for everything it
43683
43643
  * hasn't edited. The cache applies only to disk-based, lint-only, per-file
@@ -43707,15 +43667,15 @@ const createScanRunner = (options) => {
43707
43667
  const requestedPaths = request.priority === "background" && !request.useOverlay && options.isOpen ? allRequested.filter((fsPath) => !options.isOpen?.(fsPath)) : allRequested;
43708
43668
  const cache = cacheEnabled && !isWholeProject && !request.useOverlay && !request.runDeadCode ? getCache(projectDirectory) : null;
43709
43669
  const byFile = /* @__PURE__ */ new Map();
43710
- const identityByPath = /* @__PURE__ */ new Map();
43670
+ const statByPath = /* @__PURE__ */ new Map();
43711
43671
  let filesToScan = requestedPaths;
43712
43672
  if (cache) {
43713
43673
  const uncached = [];
43714
43674
  for (const fsPath of requestedPaths) {
43715
- const identity = readFileIdentity(fsPath);
43716
- if (identity) {
43717
- identityByPath.set(fsPath, identity);
43718
- const hit = cache.lookup(fsPath, identity);
43675
+ const stat = statSafe(fsPath);
43676
+ if (stat) {
43677
+ statByPath.set(fsPath, stat);
43678
+ const hit = cache.lookup(fsPath, stat);
43719
43679
  if (hit !== null) {
43720
43680
  if (hit.length > 0) byFile.set(fsPath, hit);
43721
43681
  continue;
@@ -43758,9 +43718,9 @@ const createScanRunner = (options) => {
43758
43718
  }
43759
43719
  if (cache && result.ok && !result.skipped && !result.didLintFail && result.lintPartialFailures.length === 0) {
43760
43720
  for (const fsPath of filesToScan) {
43761
- const identity = identityByPath.get(fsPath);
43762
- if (!identity) continue;
43763
- cache.store(fsPath, identity, byFile.get(fsPath) ?? []);
43721
+ const stat = statByPath.get(fsPath);
43722
+ if (!stat) continue;
43723
+ cache.store(fsPath, stat, byFile.get(fsPath) ?? []);
43764
43724
  }
43765
43725
  cache.schedulePersist();
43766
43726
  }
@@ -44894,5 +44854,5 @@ const startLanguageServer = () => {
44894
44854
  };
44895
44855
  //#endregion
44896
44856
  export { startLanguageServer };
44897
- !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]="288f7240-2ee1-5bcb-a56e-bca2b972818c")}catch(e){}}();
44898
- //# debugId=288f7240-2ee1-5bcb-a56e-bca2b972818c
44857
+ !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]="b77898db-d8e8-531a-a32b-9de2d1a63635")}catch(e){}}();
44858
+ //# debugId=b77898db-d8e8-531a-a32b-9de2d1a63635
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.7.6-dev.0a8d30b",
3
+ "version": "0.7.6-dev.0017418",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -66,7 +66,7 @@
66
66
  "vscode-uri": "^3.1.0",
67
67
  "yaml": "^2.9.0",
68
68
  "deslop-js": "0.7.6",
69
- "oxlint-plugin-react-doctor": "0.7.6-dev.0a8d30b"
69
+ "oxlint-plugin-react-doctor": "0.7.6-dev.0017418"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/babel__code-frame": "^7.27.0",
@@ -75,8 +75,8 @@
75
75
  "commander": "^14.0.3",
76
76
  "ora": "^9.4.0",
77
77
  "@react-doctor/api": "0.7.6",
78
- "@react-doctor/language-server": "0.7.6",
79
- "@react-doctor/core": "0.7.6"
78
+ "@react-doctor/core": "0.7.6",
79
+ "@react-doctor/language-server": "0.7.6"
80
80
  },
81
81
  "engines": {
82
82
  "node": "^20.19.0 || >=22.13.0"