react-doctor 0.5.6-dev.6b8e756 → 0.5.6-dev.740211c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lsp.js CHANGED
@@ -19335,6 +19335,7 @@ var JsonReportProjectEntry = class extends Class("JsonReportProjectEntry")({
19335
19335
  score: Unknown,
19336
19336
  skippedChecks: ArraySchema(String$1),
19337
19337
  skippedCheckReasons: optional(Record$1(String$1, String$1)),
19338
+ scannedFileCount: optional(Number$1),
19338
19339
  elapsedMilliseconds: Number$1
19339
19340
  }) {};
19340
19341
  /**
@@ -32761,6 +32762,7 @@ const isLargeMinifiedFile = (absolutePath) => {
32761
32762
  if (sizeBytes < 2e4) return false;
32762
32763
  return isMinifiedSource(absolutePath);
32763
32764
  };
32765
+ const isErrnoException = (error) => error instanceof Error && "code" in error;
32764
32766
  const IGNORABLE_READDIR_ERROR_CODES = new Set([
32765
32767
  "EACCES",
32766
32768
  "EPERM",
@@ -32770,11 +32772,7 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
32770
32772
  "ELOOP",
32771
32773
  "ENAMETOOLONG"
32772
32774
  ]);
32773
- const isIgnorableReaddirError = (error) => {
32774
- if (typeof error !== "object" || error === null) return false;
32775
- const errorCode = error.code;
32776
- return typeof errorCode === "string" && IGNORABLE_READDIR_ERROR_CODES.has(errorCode);
32777
- };
32775
+ const isIgnorableReaddirError = (error) => isErrnoException(error) && typeof error.code === "string" && IGNORABLE_READDIR_ERROR_CODES.has(error.code);
32778
32776
  const readDirectoryEntries = (directoryPath) => {
32779
32777
  try {
32780
32778
  return NFS.readdirSync(directoryPath, { withFileTypes: true });
@@ -32824,7 +32822,7 @@ const readPackageJsonUncached = (packageJsonPath) => {
32824
32822
  return JSON.parse(NFS.readFileSync(packageJsonPath, "utf-8"));
32825
32823
  } catch (error) {
32826
32824
  if (error instanceof SyntaxError) return {};
32827
- if (error instanceof Error && "code" in error) {
32825
+ if (isErrnoException(error)) {
32828
32826
  const { code } = error;
32829
32827
  if (code === "EISDIR" || code === "EACCES" || code === "EPERM" || code === "ENOENT") return {};
32830
32828
  }
@@ -33549,17 +33547,13 @@ const isPackageJsonReactNativeAware = (packageJson) => {
33549
33547
  return false;
33550
33548
  };
33551
33549
  const hasReactNativeWorkspaceAnywhere = (rootDirectory, rootPackageJson) => someWorkspacePackageJson(rootDirectory, rootPackageJson, isPackageJsonReactNativeAware);
33552
- const getExpoDependencySpec = (packageJson) => {
33553
- const spec = packageJson.dependencies?.expo ?? packageJson.devDependencies?.expo ?? packageJson.peerDependencies?.expo ?? packageJson.optionalDependencies?.expo;
33550
+ const getDependencySpec = (packageJson, packageName) => {
33551
+ const spec = packageJson.dependencies?.[packageName] ?? packageJson.devDependencies?.[packageName] ?? packageJson.peerDependencies?.[packageName] ?? packageJson.optionalDependencies?.[packageName];
33554
33552
  return typeof spec === "string" ? spec : null;
33555
33553
  };
33556
- const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
33554
+ const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, (packageJson) => getDependencySpec(packageJson, "expo"));
33557
33555
  const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
33558
- const getShopifyFlashListDependencySpec = (packageJson) => {
33559
- const spec = packageJson.dependencies?.["@shopify/flash-list"] ?? packageJson.devDependencies?.["@shopify/flash-list"] ?? packageJson.peerDependencies?.["@shopify/flash-list"] ?? packageJson.optionalDependencies?.["@shopify/flash-list"];
33560
- return typeof spec === "string" ? spec : null;
33561
- };
33562
- const findShopifyFlashListVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getShopifyFlashListDependencySpec);
33556
+ const findShopifyFlashListVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, (packageJson) => getDependencySpec(packageJson, SHOPIFY_FLASH_LIST_PACKAGE_NAME));
33563
33557
  const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
33564
33558
  if (version === null || !isCatalogReference(version)) return version;
33565
33559
  const catalogName = extractCatalogName(version);
@@ -33571,11 +33565,7 @@ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson,
33571
33565
  if (!isFile(monorepoPackageJsonPath)) return version;
33572
33566
  return resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
33573
33567
  };
33574
- const getNextjsDependencySpec = (packageJson) => {
33575
- const spec = packageJson.dependencies?.next ?? packageJson.devDependencies?.next ?? packageJson.peerDependencies?.next ?? packageJson.optionalDependencies?.next;
33576
- return typeof spec === "string" ? spec : null;
33577
- };
33578
- const findNextjsVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getNextjsDependencySpec);
33568
+ const findNextjsVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, (packageJson) => getDependencySpec(packageJson, "next"));
33579
33569
  const getPreactVersion = (packageJson) => {
33580
33570
  return {
33581
33571
  ...packageJson.peerDependencies,
@@ -33657,6 +33647,11 @@ const ES_TARGET_YEAR_BY_NAME = {
33657
33647
  esnext: 9999
33658
33648
  };
33659
33649
  /**
33650
+ * tsconfig filenames probed when resolving a project's TypeScript
33651
+ * compiler options — the root config first, then a monorepo base config.
33652
+ */
33653
+ const TSCONFIG_FILENAMES = ["tsconfig.json", "tsconfig.base.json"];
33654
+ /**
33660
33655
  * Project-config files that `StagedFiles.materialize` copies into
33661
33656
  * the temp directory alongside staged sources so oxlint resolves
33662
33657
  * `tsconfig` / `package.json` / lint configs the same way it would
@@ -34178,6 +34173,7 @@ const isTailwindAtLeast = (detected, required) => {
34178
34173
  if (detected.major !== required.major) return detected.major > required.major;
34179
34174
  return detected.minor >= required.minor;
34180
34175
  };
34176
+ const messageFromUnknown = (error) => error instanceof Error ? error.message : String(error);
34181
34177
  var InvalidGlobPatternError = class extends Error {
34182
34178
  pattern;
34183
34179
  reason;
@@ -34206,7 +34202,7 @@ const compileGlobPattern = (rawPattern) => {
34206
34202
  try {
34207
34203
  return import_picomatch.default.makeRe(normalizeGlobPattern(rawPattern), PICOMATCH_OPTIONS);
34208
34204
  } catch (caughtError) {
34209
- throw new InvalidGlobPatternError(rawPattern, caughtError instanceof Error ? caughtError.message : String(caughtError));
34205
+ throw new InvalidGlobPatternError(rawPattern, messageFromUnknown(caughtError));
34210
34206
  }
34211
34207
  };
34212
34208
  const compileGlobPatternsLenient = (patterns, onInvalid) => {
@@ -35362,7 +35358,6 @@ const PACKAGE_JSON_FILENAME = "package.json";
35362
35358
  const PACKAGE_JSON_CONFIG_KEY = "reactDoctor";
35363
35359
  const LEGACY_CONFIG_FILENAME = "react-doctor.config.json";
35364
35360
  const jiti = createJiti(import.meta.url);
35365
- const formatError = (error) => error instanceof Error ? error.message : String(error);
35366
35361
  const importDefaultExport = async (jitiInstance, filePath) => {
35367
35362
  const imported = await jitiInstance.import(filePath);
35368
35363
  return imported?.default ?? imported;
@@ -35394,7 +35389,7 @@ const loadModuleConfig = async (filePath) => {
35394
35389
  try {
35395
35390
  return await importDefaultExport(aliasJiti, filePath);
35396
35391
  } catch (retryError) {
35397
- throw new Error(`${formatError(error)} (retry with ${SELF_PACKAGE_IMPORT_SPECIFIER} aliased to the running react-doctor package also failed: ${formatError(retryError)})`, { cause: retryError });
35392
+ throw new Error(`${messageFromUnknown(error)} (retry with ${SELF_PACKAGE_IMPORT_SPECIFIER} aliased to the running react-doctor package also failed: ${messageFromUnknown(retryError)})`, { cause: retryError });
35398
35393
  }
35399
35394
  }
35400
35395
  };
@@ -35443,7 +35438,7 @@ const loadLegacyConfig = (directory) => {
35443
35438
  }
35444
35439
  warn(`${LEGACY_CONFIG_FILENAME} must contain an object, ignoring.`);
35445
35440
  } catch (error) {
35446
- warn(`Failed to load ${LEGACY_CONFIG_FILENAME}: ${formatError(error)}`);
35441
+ warn(`Failed to load ${LEGACY_CONFIG_FILENAME}: ${messageFromUnknown(error)}`);
35447
35442
  }
35448
35443
  return {
35449
35444
  status: "invalid",
@@ -35470,7 +35465,7 @@ const loadConfigFromDirectory = async (directory) => {
35470
35465
  warn(`${CONFIG_BASENAME}.${extension} must export an object, ignoring.`);
35471
35466
  sawBrokenConfigFile = true;
35472
35467
  } catch (error) {
35473
- warn(`Failed to load ${CONFIG_BASENAME}.${extension}: ${formatError(error)}`);
35468
+ warn(`Failed to load ${CONFIG_BASENAME}.${extension}: ${messageFromUnknown(error)}`);
35474
35469
  sawBrokenConfigFile = true;
35475
35470
  }
35476
35471
  }
@@ -36458,15 +36453,10 @@ const buildCapabilities = (project) => {
36458
36453
  }
36459
36454
  if (project.tailwindVersion !== null) {
36460
36455
  capabilities.add("tailwind");
36461
- const tailwind = parseTailwindMajorMinor(project.tailwindVersion);
36462
- if (isTailwindAtLeast(tailwind, {
36456
+ if (isTailwindAtLeast(parseTailwindMajorMinor(project.tailwindVersion), {
36463
36457
  major: 3,
36464
36458
  minor: 4
36465
36459
  })) capabilities.add("tailwind:3.4");
36466
- if (tailwind !== null && isTailwindAtLeast(tailwind, {
36467
- major: 4,
36468
- minor: 0
36469
- })) capabilities.add("tailwind:4");
36470
36460
  }
36471
36461
  if (project.zodVersion !== null) {
36472
36462
  capabilities.add("zod");
@@ -36655,7 +36645,7 @@ const readIgnoreFile = (filePath) => {
36655
36645
  try {
36656
36646
  content = NFS.readFileSync(filePath, "utf-8");
36657
36647
  } catch (error) {
36658
- const errnoCode = error?.code;
36648
+ const errnoCode = isErrnoException(error) ? error.code : void 0;
36659
36649
  if (errnoCode && errnoCode !== "ENOENT") runSync(warn$1(`Could not read ignore file ${filePath}: ${errnoCode}`));
36660
36650
  return [];
36661
36651
  }
@@ -36696,8 +36686,8 @@ const collectIgnorePatterns = (rootDirectory) => {
36696
36686
  cachedPatternsByRoot.set(rootDirectory, patterns);
36697
36687
  return patterns;
36698
36688
  };
36689
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
36699
36690
  const KNIP_JSON_FILENAME = "knip.json";
36700
- const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
36701
36691
  const readJsonFileSafe = (filePath) => {
36702
36692
  let rawContents;
36703
36693
  try {
@@ -36713,10 +36703,10 @@ const readJsonFileSafe = (filePath) => {
36713
36703
  };
36714
36704
  const readKnipConfig = (rootDirectory) => {
36715
36705
  const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
36716
- if (isRecord$1(knipJson)) return knipJson;
36706
+ if (isRecord(knipJson)) return knipJson;
36717
36707
  const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
36718
- const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
36719
- return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
36708
+ const packageKnipConfig = isRecord(packageJson) ? packageJson.knip : null;
36709
+ return isRecord(packageKnipConfig) ? packageKnipConfig : null;
36720
36710
  };
36721
36711
  const normalizePatternList = (value) => {
36722
36712
  if (typeof value === "string" && value.length > 0) return [value];
@@ -36728,10 +36718,10 @@ const prefixWorkspacePatterns = (workspacePattern, patterns) => {
36728
36718
  return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
36729
36719
  };
36730
36720
  const collectKnipWorkspacePatterns = (workspaces, settingName) => {
36731
- if (!isRecord$1(workspaces)) return [];
36721
+ if (!isRecord(workspaces)) return [];
36732
36722
  const patterns = [];
36733
36723
  for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
36734
- if (!isRecord$1(workspaceConfig)) continue;
36724
+ if (!isRecord(workspaceConfig)) continue;
36735
36725
  patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
36736
36726
  }
36737
36727
  return patterns;
@@ -36776,8 +36766,6 @@ const toCanonicalPath = (filePath) => {
36776
36766
  };
36777
36767
  const DEAD_CODE_PLUGIN = "deslop";
36778
36768
  const DEAD_CODE_CATEGORY = "Maintainability";
36779
- const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
36780
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
36781
36769
  const DEAD_CODE_WORKER_SCRIPT = `
36782
36770
  const inputChunks = [];
36783
36771
  process.stdin.on("data", (chunk) => inputChunks.push(chunk));
@@ -36835,7 +36823,7 @@ process.stdin.on("end", () => {
36835
36823
  });
36836
36824
  `;
36837
36825
  const resolveTsConfigPath = (rootDirectory) => {
36838
- for (const filename of TSCONFIG_FILENAMES$1) {
36826
+ for (const filename of TSCONFIG_FILENAMES) {
36839
36827
  const candidate = Path.join(rootDirectory, filename);
36840
36828
  if (NFS.existsSync(candidate)) return candidate;
36841
36829
  }
@@ -37216,15 +37204,13 @@ var DeadCode = class DeadCode extends Service()("react-doctor/DeadCode") {
37216
37204
  })()) }));
37217
37205
  static layerOf = (diagnostics) => succeed$3(DeadCode, DeadCode.of({ run: () => fromIterable$1(diagnostics) }));
37218
37206
  };
37219
- const createNodeReadFileLinesSync = (rootDirectory) => {
37220
- return (filePath) => {
37221
- const absolutePath = Path.isAbsolute(filePath) ? filePath : Path.join(rootDirectory, filePath);
37222
- try {
37223
- return NFS.readFileSync(absolutePath, "utf-8").split("\n");
37224
- } catch {
37225
- return null;
37226
- }
37227
- };
37207
+ const createNodeReadFileLinesSync = (rootDirectory) => (filePath) => {
37208
+ const absolutePath = Path.isAbsolute(filePath) ? filePath : Path.join(rootDirectory, filePath);
37209
+ try {
37210
+ return NFS.readFileSync(absolutePath, "utf-8").split("\n");
37211
+ } catch {
37212
+ return null;
37213
+ }
37228
37214
  };
37229
37215
  var Files = class Files extends Service()("react-doctor/Files") {
37230
37216
  static layerNode = succeed$3(Files, Files.of({
@@ -37435,7 +37421,10 @@ var Git = class Git extends Service()("react-doctor/Git") {
37435
37421
  directory: input.directory,
37436
37422
  cause
37437
37423
  }) });
37438
- }));
37424
+ }), withSpan("git.exec", { attributes: {
37425
+ "git.command": input.command,
37426
+ "git.subcommand": input.args[0] ?? ""
37427
+ } }));
37439
37428
  const runGit = (directory, args) => runCommand({
37440
37429
  command: "git",
37441
37430
  args,
@@ -37463,7 +37452,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
37463
37452
  ]);
37464
37453
  if (candidates.status !== 0) return null;
37465
37454
  return trimOrNull(candidates.stdout.split("\n")[0] ?? "");
37466
- });
37455
+ }).pipe(withSpan("Git.defaultBranch"));
37467
37456
  const branchExists = (directory, branch) => runGit(directory, [
37468
37457
  "rev-parse",
37469
37458
  "--verify",
@@ -37510,7 +37499,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
37510
37499
  const result = resultOption.value;
37511
37500
  if (result.status !== 0) return null;
37512
37501
  return parseGithubViewerPermission(result.stdout);
37513
- }).pipe(catch_$1(() => succeed$2(null)));
37502
+ }).pipe(catch_$1(() => succeed$2(null)), withSpan("Git.githubViewerPermission"));
37514
37503
  /**
37515
37504
  * Resolves a `--diff A..B` / `A...B` commit range into a changed-file
37516
37505
  * selection. Each endpoint is validated with `isSafeGitRevision`
@@ -37624,7 +37613,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
37624
37613
  changedFiles: splitNullSeparated(diff.stdout),
37625
37614
  isCurrentChanges: false
37626
37615
  };
37627
- }),
37616
+ }).pipe(withSpan("Git.diffSelection")),
37628
37617
  stagedFilePaths: (directory) => runGit(directory, [
37629
37618
  "diff",
37630
37619
  "--cached",
@@ -37666,7 +37655,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
37666
37655
  status: result.status,
37667
37656
  stdout: result.stdout
37668
37657
  };
37669
- }),
37658
+ }).pipe(withSpan("Git.grep")),
37670
37659
  changedLineRanges: ({ directory, baseRef, cached, files }) => gen(function* () {
37671
37660
  if (files.length === 0) return [];
37672
37661
  if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
@@ -37682,7 +37671,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
37682
37671
  ]);
37683
37672
  if (result.status !== 0) return null;
37684
37673
  return parseChangedLineRanges(result.stdout);
37685
- })
37674
+ }).pipe(withSpan("Git.changedLineRanges"))
37686
37675
  });
37687
37676
  })).pipe(provide$2(layer$2.pipe(provide$2(mergeAll$1(layer$1, layer)))));
37688
37677
  /**
@@ -37897,7 +37886,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
37897
37886
  for (const [absolutePath, originalContent] of originalContents) try {
37898
37887
  NFS.writeFileSync(absolutePath, originalContent);
37899
37888
  } catch (error) {
37900
- process.stderr.write(`[react-doctor] Failed to restore inline disable directives in ${absolutePath}: ${error instanceof Error ? error.message : String(error)}\n[react-doctor] Run: git checkout -- ${absolutePath}\n`);
37889
+ process.stderr.write(`[react-doctor] Failed to restore inline disable directives in ${absolutePath}: ${messageFromUnknown(error)}\n[react-doctor] Run: git checkout -- ${absolutePath}\n`);
37901
37890
  }
37902
37891
  };
37903
37892
  const onExit = () => restore();
@@ -38003,7 +37992,7 @@ const resolveUserPlugin = (spec, configSourceDirectory) => {
38003
37992
  try {
38004
37993
  resolvedSpecifier = isRelative ? Path.resolve(configSourceDirectory, spec) : candidateRequire.resolve(spec);
38005
37994
  } catch (error) {
38006
- warnConfigIssue(`config.plugins entry "${spec}" could not be resolved from ${configSourceDirectory}: ${error instanceof Error ? error.message : String(error)}`);
37995
+ warnConfigIssue(`config.plugins entry "${spec}" could not be resolved from ${configSourceDirectory}: ${messageFromUnknown(error)}`);
38007
37996
  return null;
38008
37997
  }
38009
37998
  const { name, ruleNames } = readPluginShape(resolvedSpecifier, (target) => candidateRequire(target));
@@ -38075,8 +38064,8 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
38075
38064
  }
38076
38065
  return enabled;
38077
38066
  };
38078
- const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [] }) => {
38079
- const reactHooksJsPlugin = resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
38067
+ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false }) => {
38068
+ const reactHooksJsPlugin = disableReactHooksJsPlugin ? null : resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
38080
38069
  const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
38081
38070
  const jsPlugins = [];
38082
38071
  if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
@@ -38136,7 +38125,6 @@ const resolveOxlintBinary = () => {
38136
38125
  return Path.join(oxlintPackageDirectory, "bin", "oxlint");
38137
38126
  };
38138
38127
  const resolvePluginPath = () => esmRequire.resolve("oxlint-plugin-react-doctor");
38139
- const TSCONFIG_FILENAMES = ["tsconfig.json", "tsconfig.base.json"];
38140
38128
  const resolveTsConfigRelativePath = (rootDirectory) => {
38141
38129
  for (const filename of TSCONFIG_FILENAMES) if (NFS.existsSync(Path.join(rootDirectory, filename))) return `./${filename}`;
38142
38130
  return null;
@@ -38508,7 +38496,7 @@ const scopeContainsNonImportBinding = (node, scopeNode, identifierName) => {
38508
38496
  const isIdentifierShadowedByLocalBinding = (identifier, sourceFile) => {
38509
38497
  let currentNode = identifier.parent;
38510
38498
  while (currentNode) {
38511
- if (isScopeNode(currentNode)) {
38499
+ if (isScopeBoundary(currentNode)) {
38512
38500
  if (scopeContainsNonImportBinding(currentNode, currentNode, identifier.text)) return true;
38513
38501
  }
38514
38502
  if (currentNode === sourceFile) return false;
@@ -38599,11 +38587,10 @@ const findResolutionInScope = (scopeNode, identifierName, reactImportBindings, s
38599
38587
  });
38600
38588
  return resolution;
38601
38589
  };
38602
- const isScopeNode = isScopeBoundary;
38603
38590
  const resolveIdentifierBinding = (identifier, reactImportBindings, sourceFile, visitedDeclarations = /* @__PURE__ */ new Set()) => {
38604
38591
  let currentNode = identifier.parent;
38605
38592
  while (currentNode) {
38606
- if (isScopeNode(currentNode)) {
38593
+ if (isScopeBoundary(currentNode)) {
38607
38594
  const resolution = findResolutionInScope(currentNode, identifier.text, reactImportBindings, sourceFile, visitedDeclarations);
38608
38595
  if (resolution) return resolution;
38609
38596
  }
@@ -38773,9 +38760,9 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
38773
38760
  try {
38774
38761
  parsed = JSON.parse(sanitizedStdout);
38775
38762
  } catch {
38776
- throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 200) }) });
38763
+ throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
38777
38764
  }
38778
- if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 200) }) });
38765
+ if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
38779
38766
  const minifiedFileCache = /* @__PURE__ */ new Map();
38780
38767
  const isMinifiedDiagnosticFile = (filename) => {
38781
38768
  const absolutePath = Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
@@ -38851,7 +38838,7 @@ const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLIN
38851
38838
  child.kill("SIGKILL");
38852
38839
  reject(new ReactDoctorError({ reason: new OxlintBatchExceeded({
38853
38840
  kind: "timeout",
38854
- detail: `${spawnTimeoutMs / 1e3}s budget exceeded`
38841
+ detail: `${spawnTimeoutMs / MILLISECONDS_PER_SECOND}s budget exceeded`
38855
38842
  }) }));
38856
38843
  }, spawnTimeoutMs);
38857
38844
  timeoutHandle.unref?.();
@@ -39066,6 +39053,28 @@ const writeOxlintConfig = (configPath, configToWrite) => {
39066
39053
  NFS.closeSync(fileHandle);
39067
39054
  }
39068
39055
  };
39056
+ const REACT_HOOKS_JS_DROP_PREFIX = "React Compiler rules (react-hooks-js/*) skipped — eslint-plugin-react-hooks failed to load in this environment";
39057
+ /**
39058
+ * Detects an oxlint config-load crash caused by the optional
39059
+ * `react-hooks-js` (eslint-plugin-react-hooks) React Compiler plugin and
39060
+ * builds the partial-failure note for it; returns `null` when the failure
39061
+ * was anything else.
39062
+ *
39063
+ * oxlint prints a framed error to stdout (not stderr) and exits non-zero
39064
+ * when a `jsPlugins` entry can't be imported; that non-JSON stdout
39065
+ * surfaces as `OxlintOutputUnparseable`. Because oxlint fails the WHOLE
39066
+ * config load on it, leaving the plugin in would drop every curated
39067
+ * react-doctor diagnostic too — so the caller retries with the plugin
39068
+ * stripped (issue #833). Both markers sit at the start of oxlint's
39069
+ * message, so they survive the `preview` slice even for deep pnpm paths.
39070
+ */
39071
+ const reactHooksJsPluginDropNote = (error) => {
39072
+ if (!(error instanceof ReactDoctorError) || error.reason._tag !== "OxlintOutputUnparseable") return null;
39073
+ const { preview } = error.reason;
39074
+ if (!preview.includes("Failed to load JS plugin") || !preview.includes("eslint-plugin-react-hooks")) return null;
39075
+ const underlyingReason = preview.match(/Error:[^\n]*/)?.[0]?.trim();
39076
+ return `${REACT_HOOKS_JS_DROP_PREFIX}${underlyingReason ? `: ${underlyingReason}` : ""}. Other rules ran normally.`;
39077
+ };
39069
39078
  /**
39070
39079
  * The oxlint runner. Composed of three pieces in `runners/oxlint/`:
39071
39080
  *
@@ -39093,15 +39102,16 @@ const runOxlint = async (options) => {
39093
39102
  const pluginPath = resolvePluginPath();
39094
39103
  const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
39095
39104
  const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
39096
- const buildConfig = (extendsForThisAttempt) => createOxlintConfig({
39105
+ const buildConfig = (overrides) => createOxlintConfig({
39097
39106
  pluginPath,
39098
39107
  project,
39099
39108
  customRulesOnly,
39100
- extendsPaths: extendsForThisAttempt,
39109
+ extendsPaths: overrides.extendsPaths,
39101
39110
  ignoredTags,
39102
39111
  serverAuthFunctionNames,
39103
39112
  severityControls,
39104
- userPlugins
39113
+ userPlugins,
39114
+ disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin
39105
39115
  });
39106
39116
  const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
39107
39117
  const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
@@ -39137,12 +39147,22 @@ const runOxlint = async (options) => {
39137
39147
  outputMaxBytes,
39138
39148
  concurrency: options.concurrency
39139
39149
  });
39140
- writeOxlintConfig(configPath, buildConfig(extendsPaths));
39150
+ writeOxlintConfig(configPath, buildConfig({ extendsPaths }));
39141
39151
  try {
39142
39152
  return await runBatches();
39143
39153
  } catch (error) {
39154
+ const reactHooksJsDropNote = reactHooksJsPluginDropNote(error);
39155
+ if (reactHooksJsDropNote !== null) {
39156
+ writeOxlintConfig(configPath, buildConfig({
39157
+ extendsPaths,
39158
+ disableReactHooksJsPlugin: true
39159
+ }));
39160
+ const diagnostics = await runBatches();
39161
+ onPartialFailure?.(reactHooksJsDropNote);
39162
+ return diagnostics;
39163
+ }
39144
39164
  if (extendsPaths.length === 0) throw error;
39145
- writeOxlintConfig(configPath, buildConfig([]));
39165
+ writeOxlintConfig(configPath, buildConfig({ extendsPaths: [] }));
39146
39166
  return await runBatches();
39147
39167
  }
39148
39168
  } finally {
@@ -39940,7 +39960,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
39940
39960
  }))))))));
39941
39961
  const deadCodeFailureState = yield* get$2(deadCodeFailure);
39942
39962
  const scanElapsedMilliseconds = Date.now() - scanStartTime;
39943
- const scanElapsedSeconds = (scanElapsedMilliseconds / 1e3).toFixed(1);
39963
+ const scanElapsedSeconds = (scanElapsedMilliseconds / MILLISECONDS_PER_SECOND).toFixed(1);
39944
39964
  if (!lintFailureState.didFail) if (deadCodeFailureState.didFail) yield* scanProgress.fail(DEAD_CODE_FAIL_TEXT);
39945
39965
  else if (input.suppressScanSummary) yield* scanProgress.stop();
39946
39966
  else yield* scanProgress.succeed(`Scanned ${scannedFilesLabel} in ${scanElapsedSeconds}s${workerCountSuffix}`);
@@ -40154,7 +40174,7 @@ const materializeSourceTree = (input) => gen(function* () {
40154
40174
  static layerNode = effect(StagedFiles, gen(function* () {
40155
40175
  const git = yield* Git;
40156
40176
  return StagedFiles.of({
40157
- discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(map$3((entries) => entries.filter(isLintableSourceFile))),
40177
+ discoverSourceFiles: (directory) => git.stagedFilePaths(directory).pipe(map$3((entries) => entries.filter(isLintableSourceFile)), withSpan("StagedFiles.discoverSourceFiles")),
40158
40178
  materialize: ({ directory, stagedFiles, tempDirectory }) => materializeSourceTree({
40159
40179
  directory,
40160
40180
  files: stagedFiles,
@@ -40164,7 +40184,7 @@ const materializeSourceTree = (input) => gen(function* () {
40164
40184
  tempDirectory: tree.tempDirectory,
40165
40185
  stagedFiles: tree.materializedFiles,
40166
40186
  cleanup: tree.cleanup
40167
- })))
40187
+ })), withSpan("StagedFiles.materialize"))
40168
40188
  });
40169
40189
  }));
40170
40190
  /**
@@ -40232,7 +40252,10 @@ const runEditorScan = async (input) => {
40232
40252
  isCi: false,
40233
40253
  resolveLocalGithubViewerPermission: false,
40234
40254
  skipJsxIncludeFilter: true
40235
- }).pipe(provide(layers), provide(layerOtlp)));
40255
+ }).pipe(withSpan("runEditorScan", { attributes: {
40256
+ "editor.lint": lint,
40257
+ "editor.runDeadCode": runDeadCode
40258
+ } }), provide(layers), provide(layerOtlp)));
40236
40259
  if (isSuccess(exit)) {
40237
40260
  const output = exit.value;
40238
40261
  return {
@@ -40262,7 +40285,7 @@ const runEditorScan = async (input) => {
40262
40285
  didDeadCodeFail: false,
40263
40286
  deadCodeFailureReason: null,
40264
40287
  lintPartialFailures: [],
40265
- error: error instanceof Error ? error.message : String(error)
40288
+ error: messageFromUnknown(error)
40266
40289
  };
40267
40290
  };
40268
40291
  /**
@@ -40544,7 +40567,6 @@ const toLspDiagnostic = (input) => {
40544
40567
  data
40545
40568
  };
40546
40569
  };
40547
- const toUri = (absoluteFilePath) => fsPathToUri(absoluteFilePath);
40548
40570
  /**
40549
40571
  * Owns the published-diagnostic state. Maps scan outcomes to LSP
40550
40572
  * diagnostics, publishes complete per-URI replacement sets (so the
@@ -40574,7 +40596,7 @@ var DiagnosticsManager = class {
40574
40596
  const isProtectedPath = (fsPath) => protectOpen && this.isOpen(fsPath);
40575
40597
  for (const [fsPath, coreDiagnostics] of outcome.byFile) {
40576
40598
  if (isProtectedPath(fsPath)) continue;
40577
- const uri = toUri(fsPath);
40599
+ const uri = fsPathToUri(fsPath);
40578
40600
  const text = this.textProvider(fsPath);
40579
40601
  const lspDiagnostics = coreDiagnostics.map((diagnostic) => toLspDiagnostic({
40580
40602
  diagnostic,
@@ -40596,7 +40618,7 @@ var DiagnosticsManager = class {
40596
40618
  for (const fsPath of outcome.requestedPaths) {
40597
40619
  if (isProtectedPath(fsPath)) continue;
40598
40620
  if (outcome.byFile.has(fsPath)) continue;
40599
- const uri = toUri(fsPath);
40621
+ const uri = fsPathToUri(fsPath);
40600
40622
  if (this.byUri.has(uri)) this.byUri.delete(uri);
40601
40623
  this.publish(uri, []);
40602
40624
  }
@@ -40621,7 +40643,7 @@ var DiagnosticsManager = class {
40621
40643
  const set = this.projectUris.get(project) ?? /* @__PURE__ */ new Set();
40622
40644
  for (const uri of liveUris) set.add(uri);
40623
40645
  for (const fsPath of outcome.requestedPaths) {
40624
- const uri = toUri(fsPath);
40646
+ const uri = fsPathToUri(fsPath);
40625
40647
  if (!liveUris.has(uri)) set.delete(uri);
40626
40648
  }
40627
40649
  this.projectUris.set(project, set);
@@ -40649,7 +40671,7 @@ var DiagnosticsManager = class {
40649
40671
  const tracked = this.projectUris.get(project);
40650
40672
  if (!tracked) return;
40651
40673
  const liveUris = /* @__PURE__ */ new Set();
40652
- for (const fsPath of liveFsPaths) liveUris.add(toUri(fsPath));
40674
+ for (const fsPath of liveFsPaths) liveUris.add(fsPathToUri(fsPath));
40653
40675
  for (const uri of [...tracked]) {
40654
40676
  if (liveUris.has(uri)) continue;
40655
40677
  this.byUri.delete(uri);
@@ -40946,7 +40968,7 @@ const createProjectGraph = (options) => {
40946
40968
  });
40947
40969
  }
40948
40970
  } catch (error) {
40949
- logger.warn(`Project discovery failed for ${root}: ${error instanceof Error ? error.message : String(error)}`);
40971
+ logger.warn(`Project discovery failed for ${root}: ${messageFromUnknown(error)}`);
40950
40972
  }
40951
40973
  return [...seen.values()].sort((first, second) => second.directory.length - first.directory.length);
40952
40974
  };
@@ -40974,6 +40996,11 @@ const createProjectGraph = (options) => {
40974
40996
  }
40975
40997
  };
40976
40998
  };
40999
+ const toProjectRelative = (projectDirectory, filePath) => {
41000
+ const relative = Path.relative(projectDirectory, filePath).replace(/\\/g, "/");
41001
+ if (relative.length === 0 || relative.startsWith("../") || Path.isAbsolute(relative)) return null;
41002
+ return relative;
41003
+ };
40977
41004
  const resolveCacheFilePath = (projectDirectory) => {
40978
41005
  const nodeModules = path.join(projectDirectory, "node_modules");
40979
41006
  if (fs.existsSync(nodeModules)) return path.join(nodeModules, ".cache", "react-doctor", "lint-cache.json");
@@ -41008,7 +41035,7 @@ const createLintCache = (input) => {
41008
41035
  fs.writeFileSync(tempPath, JSON.stringify(payload));
41009
41036
  fs.renameSync(tempPath, cacheFilePath);
41010
41037
  } catch (error) {
41011
- logger.warn(`Failed to persist lint cache: ${error instanceof Error ? error.message : String(error)}`);
41038
+ logger.warn(`Failed to persist lint cache: ${messageFromUnknown(error)}`);
41012
41039
  }
41013
41040
  };
41014
41041
  return {
@@ -41034,11 +41061,6 @@ const createLintCache = (input) => {
41034
41061
  };
41035
41062
  const OVERLAY_TEMP_PREFIX = "react-doctor-lsp-";
41036
41063
  const OVERLAY_CONFIG_FILENAMES = [...new Set([...STAGED_FILES_PROJECT_CONFIG_FILENAMES, ...ADOPTABLE_LINT_CONFIG_FILENAMES])];
41037
- const toProjectRelative$1 = (projectDirectory, filePath) => {
41038
- const relative = path.relative(projectDirectory, filePath).replace(/\\/g, "/");
41039
- if (relative.length === 0 || relative.startsWith("../") || path.isAbsolute(relative)) return null;
41040
- return relative;
41041
- };
41042
41064
  /**
41043
41065
  * Writes the live (possibly unsaved) content of the target files into a
41044
41066
  * throwaway temp tree that mirrors the project, alongside the well-known
@@ -41052,7 +41074,7 @@ const materializeOverlay = (input) => {
41052
41074
  const relativePaths = [];
41053
41075
  try {
41054
41076
  for (const filePath of input.files) {
41055
- const relative = toProjectRelative$1(input.projectDirectory, filePath);
41077
+ const relative = toProjectRelative(input.projectDirectory, filePath);
41056
41078
  if (relative === null) continue;
41057
41079
  const content = input.readText(filePath);
41058
41080
  if (content === null) continue;
@@ -41100,11 +41122,6 @@ const materializeOverlay = (input) => {
41100
41122
  throw error;
41101
41123
  }
41102
41124
  };
41103
- const toProjectRelative = (projectDirectory, filePath) => {
41104
- const relative = path.relative(projectDirectory, filePath).replace(/\\/g, "/");
41105
- if (relative.length === 0 || relative.startsWith("../") || path.isAbsolute(relative)) return null;
41106
- return relative;
41107
- };
41108
41125
  /**
41109
41126
  * Resolves a diagnostic's (possibly relative, possibly overlay-temp)
41110
41127
  * file path back to the canonical absolute path inside the real project.
@@ -41326,7 +41343,7 @@ const createScheduler = (options) => {
41326
41343
  if (outcome && !token.isCancelled) options.onResult(outcome);
41327
41344
  }).catch((error) => {
41328
41345
  if (options.onError) options.onError(error, request);
41329
- else logger.error(`Scan failed: ${error instanceof Error ? error.message : String(error)}`);
41346
+ else logger.error(`Scan failed: ${messageFromUnknown(error)}`);
41330
41347
  }).finally(() => {
41331
41348
  running -= 1;
41332
41349
  if (isBackground) runningBackground -= 1;
@@ -41713,7 +41730,7 @@ const createServer = (connection, options = {}) => {
41713
41730
  maybeWarnLintUnavailable(outcome);
41714
41731
  if (outcome.request.priority === "background") scanTelemetry.accumulate(outcome);
41715
41732
  },
41716
- onError: (error, request) => logger.error(`Scan of ${request.projectDirectory} threw: ${error instanceof Error ? error.message : String(error)}`),
41733
+ onError: (error, request) => logger.error(`Scan of ${request.projectDirectory} threw: ${messageFromUnknown(error)}`),
41717
41734
  onIdleChange: (idle) => {
41718
41735
  setBusy(!idle);
41719
41736
  if (idle) scanTelemetry.finish();
@@ -42361,5 +42378,5 @@ const startLanguageServer = () => {
42361
42378
  };
42362
42379
  //#endregion
42363
42380
  export { startLanguageServer };
42364
- !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]="9421149c-0ed9-5e00-81da-4f7dd8faf332")}catch(e){}}();
42365
- //# debugId=9421149c-0ed9-5e00-81da-4f7dd8faf332
42381
+ !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]="657a7bbf-22e5-505b-a956-410727faec39")}catch(e){}}();
42382
+ //# debugId=657a7bbf-22e5-505b-a956-410727faec39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.5.6-dev.6b8e756",
3
+ "version": "0.5.6-dev.740211c",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -64,7 +64,7 @@
64
64
  "vscode-languageserver": "^9.0.1",
65
65
  "vscode-languageserver-textdocument": "^1.0.12",
66
66
  "vscode-uri": "^3.1.0",
67
- "oxlint-plugin-react-doctor": "0.5.6-dev.6b8e756"
67
+ "oxlint-plugin-react-doctor": "0.5.6-dev.740211c"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/babel__code-frame": "^7.27.0",