react-doctor 0.9.1-dev.5d2f66d → 0.9.1-dev.6904ff1

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
@@ -10,6 +10,7 @@ import * as Crypto from "node:crypto";
10
10
  import crypto, { createHash } from "node:crypto";
11
11
  import * as NodeChildProcess from "node:child_process";
12
12
  import { execFileSync, spawn, spawnSync } from "node:child_process";
13
+ import { ResolverFactory } from "oxc-resolver";
13
14
  import ts from "typescript";
14
15
  import { parseJSON5 } from "confbox";
15
16
  import * as NodeUrl from "node:url";
@@ -61478,7 +61479,8 @@ var AmbiguousProjectError = class extends Error {
61478
61479
  }
61479
61480
  };
61480
61481
  const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
61481
- const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
61482
+ const HTML_FILE_PATTERN = /\.html$/i;
61483
+ const SOURCE_FILE_PATTERN = /\.(?:tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
61482
61484
  const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
61483
61485
  const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
61484
61486
  const MINIFIED_SNIFF_BYTES = 65536;
@@ -62095,7 +62097,7 @@ const findMonorepoRoot = (startDirectory) => {
62095
62097
  */
62096
62098
  const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
62097
62099
  const TSCONFIG_FILENAME = "tsconfig.json";
62098
- const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || Path.isAbsolute(extendsValue);
62100
+ const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
62099
62101
  const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
62100
62102
  const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62101
62103
  const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
@@ -62112,7 +62114,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62112
62114
  return null;
62113
62115
  };
62114
62116
  const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
62115
- if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(Path.resolve(fromConfigDirectory, extendsValue));
62117
+ if (isLocalModuleSpecifier(extendsValue)) {
62118
+ const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
62119
+ if (isFile(resolvedPath)) return resolvedPath;
62120
+ const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
62121
+ return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
62122
+ }
62116
62123
  return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
62117
62124
  };
62118
62125
  const normalizeCompilerOptions = (compilerOptions) => {
@@ -62306,6 +62313,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
62306
62313
  ".cts",
62307
62314
  ".json"
62308
62315
  ];
62316
+ const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
62317
+ conditionNames: [
62318
+ "import",
62319
+ "require",
62320
+ "node",
62321
+ "default"
62322
+ ],
62323
+ extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
62324
+ });
62309
62325
  const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
62310
62326
  const hasCompilerPackage = (packageJson, compilerPackages) => {
62311
62327
  const allDependencies = {
@@ -62329,6 +62345,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
62329
62345
  return false;
62330
62346
  };
62331
62347
  const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
62348
+ if (!isLocalModuleSpecifier(moduleSpecifier)) {
62349
+ try {
62350
+ const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
62351
+ if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
62352
+ } catch {}
62353
+ try {
62354
+ const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
62355
+ return isFile(resolvedPath) ? resolvedPath : null;
62356
+ } catch {
62357
+ return null;
62358
+ }
62359
+ }
62332
62360
  const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
62333
62361
  const extension = Path.extname(unresolvedPath);
62334
62362
  return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
@@ -62341,7 +62369,7 @@ const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json")
62341
62369
  const getStaticPropertyName$2 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
62342
62370
  const isCommonJsConfigExportAssignment = (node, sourceFile) => ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
62343
62371
  const hasExportModifier = (node) => ts.canHaveModifiers(node) && Boolean(ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
62344
- const getRequireModuleSpecifier = (expression) => {
62372
+ const getRequireModuleSpecifier$1 = (expression) => {
62345
62373
  if (!ts.isCallExpression(expression) || !ts.isIdentifier(expression.expression) || expression.expression.text !== "require" || expression.arguments.length !== 1) return null;
62346
62374
  const moduleSpecifier = expression.arguments[0];
62347
62375
  return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
@@ -62354,7 +62382,7 @@ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statemen
62354
62382
  const namedBindings = importClause?.namedBindings;
62355
62383
  return namedBindings ? ts.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
62356
62384
  }
62357
- if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === bindingName);
62385
+ if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
62358
62386
  return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === bindingName;
62359
62387
  });
62360
62388
  const getImportBinding = (sourceFile, bindingName) => {
@@ -62385,21 +62413,21 @@ const getImportBinding = (sourceFile, bindingName) => {
62385
62413
  for (const declaration of statement.declarationList.declarations) {
62386
62414
  if (!declaration.initializer) continue;
62387
62415
  if (ts.isIdentifier(declaration.name) && declaration.name.text === bindingName) {
62388
- const directModuleSpecifier = getRequireModuleSpecifier(declaration.initializer);
62416
+ const directModuleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
62389
62417
  if (directModuleSpecifier) return {
62390
62418
  moduleSpecifier: directModuleSpecifier,
62391
62419
  exportName: "default",
62392
62420
  isNamespace: true
62393
62421
  };
62394
- if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier(declaration.initializer.expression) !== null) return {
62395
- moduleSpecifier: getRequireModuleSpecifier(declaration.initializer.expression) ?? "",
62422
+ if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier$1(declaration.initializer.expression) !== null) return {
62423
+ moduleSpecifier: getRequireModuleSpecifier$1(declaration.initializer.expression) ?? "",
62396
62424
  exportName: declaration.initializer.name.text,
62397
62425
  isNamespace: false
62398
62426
  };
62399
62427
  }
62400
62428
  if (!ts.isObjectBindingPattern(declaration.name)) continue;
62401
62429
  const bindingElement = declaration.name.elements.find((element) => ts.isIdentifier(element.name) && element.name.text === bindingName);
62402
- const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
62430
+ const moduleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
62403
62431
  if (bindingElement && moduleSpecifier) return {
62404
62432
  moduleSpecifier,
62405
62433
  exportName: bindingElement.propertyName ? getStaticPropertyName$2(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
@@ -62455,6 +62483,48 @@ const getScopedConfigBinding = (identifier) => {
62455
62483
  };
62456
62484
  };
62457
62485
  const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
62486
+ const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
62487
+ const isConstantVariableInitializer = (node) => ts.isExpression(node) && ts.isVariableDeclaration(node.parent) && ts.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & ts.NodeFlags.Const);
62488
+ const isNodeCreateRequireCall = (node, analysis) => {
62489
+ if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
62490
+ if (!ts.isCallExpression(node)) return false;
62491
+ const target = node.expression;
62492
+ if (ts.isIdentifier(target)) {
62493
+ if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
62494
+ const importBinding = getImportBinding(analysis.sourceFile, target.text);
62495
+ return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
62496
+ }
62497
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return false;
62498
+ if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "createRequire") return false;
62499
+ const createRequireReceiver = target.expression;
62500
+ if (ts.isCallExpression(createRequireReceiver)) {
62501
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(createRequireReceiver);
62502
+ if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !ts.isIdentifier(createRequireReceiver.expression)) return false;
62503
+ const requireIdentifier = createRequireReceiver.expression;
62504
+ return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
62505
+ }
62506
+ if (!ts.isIdentifier(createRequireReceiver)) return false;
62507
+ if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
62508
+ const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
62509
+ return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
62510
+ };
62511
+ const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
62512
+ const [moduleSpecifierNode] = callExpression.arguments;
62513
+ if (!moduleSpecifierNode || !ts.isStringLiteralLike(moduleSpecifierNode)) return null;
62514
+ const target = callExpression.expression;
62515
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
62516
+ if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "resolve") return null;
62517
+ if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
62518
+ if (!ts.isIdentifier(target.expression)) return null;
62519
+ const resolverIdentifier = target.expression;
62520
+ if (analysis.localBindings.has(resolverIdentifier.text)) return null;
62521
+ const scopedBinding = getScopedConfigBinding(resolverIdentifier);
62522
+ const topLevelBinding = scopedBinding.wasFound ? null : getTopLevelBinding(analysis.sourceFile, resolverIdentifier.text);
62523
+ const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : topLevelBinding;
62524
+ if (resolverInitializer === null && !scopedBinding.wasFound && resolverIdentifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, resolverIdentifier.text) && getImportBinding(analysis.sourceFile, resolverIdentifier.text) === null) return moduleSpecifierNode.text;
62525
+ if (!resolverInitializer || !isConstantVariableInitializer(resolverInitializer) || !isNodeCreateRequireCall(resolverInitializer, analysis)) return null;
62526
+ return moduleSpecifierNode.text;
62527
+ };
62458
62528
  const getAssignedPropertyInitializer = (identifier, propertyName) => {
62459
62529
  let bindingScope = null;
62460
62530
  let currentNode = identifier;
@@ -62738,6 +62808,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
62738
62808
  visitReturns(functionNode.body);
62739
62809
  return hasCompiler;
62740
62810
  };
62811
+ const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
62812
+ const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
62813
+ if (!importedFilePath) return null;
62814
+ return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList);
62815
+ };
62741
62816
  const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
62742
62817
  const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
62743
62818
  if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
@@ -62758,30 +62833,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
62758
62833
  const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
62759
62834
  if (importBinding) {
62760
62835
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62761
- if (!importBinding.moduleSpecifier.startsWith(".")) return false;
62762
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62763
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62836
+ return Boolean(analyzeImportedConfig({
62837
+ analysis,
62838
+ moduleSpecifier: importBinding.moduleSpecifier,
62839
+ exportName: importBinding.exportName,
62840
+ allowCompilerTransform
62841
+ }));
62764
62842
  }
62765
62843
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
62766
62844
  return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
62767
62845
  };
62768
62846
  const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
62769
62847
  const target = callExpression.expression;
62848
+ const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
62849
+ if (callableRequiredModuleSpecifier !== null) {
62850
+ if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62851
+ if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
62852
+ const hasCompilerTransform = analyzeImportedConfig({
62853
+ analysis,
62854
+ moduleSpecifier: callableRequiredModuleSpecifier,
62855
+ exportName: "default",
62856
+ allowCompilerTransform,
62857
+ argumentsList: callExpression.arguments
62858
+ });
62859
+ if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62860
+ return null;
62861
+ }
62770
62862
  if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
62771
62863
  const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
62772
62864
  if (propertyName === null) return null;
62773
- const requiredModuleSpecifier = getRequireModuleSpecifier(target.expression);
62865
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
62774
62866
  if (requiredModuleSpecifier !== null) {
62775
- if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62776
- if (!requiredModuleSpecifier.startsWith(".")) return null;
62777
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62778
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62867
+ if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (analysis.localBindings.has(target.expression.expression.text) || getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62868
+ if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
62869
+ const hasCompilerTransform = analyzeImportedConfig({
62870
+ analysis,
62871
+ moduleSpecifier: requiredModuleSpecifier,
62872
+ exportName: propertyName,
62873
+ allowCompilerTransform,
62874
+ argumentsList: callExpression.arguments
62875
+ });
62876
+ if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62877
+ return null;
62779
62878
  }
62780
62879
  if (!ts.isIdentifier(target.expression)) return null;
62781
- const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
62782
- if (importBinding?.isNamespace && importBinding.moduleSpecifier.startsWith(".")) {
62783
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62784
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62880
+ const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
62881
+ if (importBinding?.isNamespace) {
62882
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
62883
+ const hasCompilerTransform = analyzeImportedConfig({
62884
+ analysis,
62885
+ moduleSpecifier: importBinding.moduleSpecifier,
62886
+ exportName: propertyName,
62887
+ allowCompilerTransform,
62888
+ argumentsList: callExpression.arguments
62889
+ });
62890
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62891
+ return null;
62785
62892
  }
62786
62893
  const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
62787
62894
  if (selectedProperty === null) return null;
@@ -62804,9 +62911,13 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62804
62911
  if (propertyName === "reactCompiler") continue;
62805
62912
  if ((propertyName === "plugins" || propertyName === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, propertyName, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === propertyName)) continue;
62806
62913
  const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
62807
- if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer) && property.initializer.text.startsWith(".")) {
62808
- const extendedFilePath = resolveImportedConfigFile(analysis.filePath, property.initializer.text);
62809
- if (extendedFilePath && analyzeConfigModuleExport(extendedFilePath, "default", false, analysis.importDepth + 1, analysis.visitedModules)) return true;
62914
+ if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
62915
+ if (analyzeImportedConfig({
62916
+ analysis,
62917
+ moduleSpecifier: property.initializer.text,
62918
+ exportName: "default",
62919
+ allowCompilerTransform: false
62920
+ })) return true;
62810
62921
  }
62811
62922
  if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
62812
62923
  } else if (ts.isShorthandPropertyAssignment(property)) {
@@ -62830,23 +62941,36 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62830
62941
  });
62831
62942
  }
62832
62943
  if (ts.isCallExpression(node)) {
62944
+ const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
62945
+ if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
62833
62946
  const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
62834
62947
  if (callTargetResult !== null) return callTargetResult;
62835
- const directModuleSpecifier = getRequireModuleSpecifier(node);
62948
+ const directModuleSpecifier = getRequireModuleSpecifier$1(node);
62836
62949
  const isRequireShadowed = analysis.localBindings.has("require") || ts.isIdentifier(node.expression) && getScopedConfigBinding(node.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require");
62837
62950
  if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
62838
62951
  if (directModuleSpecifier && !isRequireShadowed) {
62839
62952
  if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
62840
- if (directModuleSpecifier.startsWith(".")) {
62841
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, directModuleSpecifier);
62842
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, "default", allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62843
- }
62953
+ if (analyzeImportedConfig({
62954
+ analysis,
62955
+ moduleSpecifier: directModuleSpecifier,
62956
+ exportName: "default",
62957
+ allowCompilerTransform
62958
+ })) return true;
62844
62959
  }
62845
62960
  if (ts.isIdentifier(node.expression)) {
62846
- const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62847
- if (importBinding?.moduleSpecifier.startsWith(".")) {
62848
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62849
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, node.arguments));
62961
+ if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
62962
+ const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62963
+ if (importBinding) {
62964
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62965
+ const hasCompilerTransform = analyzeImportedConfig({
62966
+ analysis,
62967
+ moduleSpecifier: importBinding.moduleSpecifier,
62968
+ exportName: importBinding.exportName,
62969
+ allowCompilerTransform,
62970
+ argumentsList: node.arguments
62971
+ });
62972
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62973
+ }
62850
62974
  }
62851
62975
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
62852
62976
  if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
@@ -62854,27 +62978,31 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62854
62978
  return analyzeConfigNode(node.expression, analysis, allowCompilerTransform) || node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false));
62855
62979
  }
62856
62980
  if (ts.isPropertyAccessExpression(node)) {
62857
- const requiredModuleSpecifier = getRequireModuleSpecifier(node.expression);
62981
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
62858
62982
  if (requiredModuleSpecifier) {
62859
- if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62860
- if (requiredModuleSpecifier.startsWith(".")) {
62861
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62862
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62863
- }
62983
+ if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (analysis.localBindings.has(node.expression.expression.text) || getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62984
+ if (analyzeImportedConfig({
62985
+ analysis,
62986
+ moduleSpecifier: requiredModuleSpecifier,
62987
+ exportName: node.name.text,
62988
+ allowCompilerTransform
62989
+ })) return true;
62864
62990
  return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
62865
62991
  }
62866
62992
  if (ts.isIdentifier(node.expression)) {
62867
- if (analysis.localBindings.has(node.expression.text)) {
62868
- const localInitializer = analysis.localBindings.get(node.expression.text);
62869
- return Boolean(localInitializer && analyzeConfigNode(localInitializer, analysis, allowCompilerTransform));
62993
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
62994
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
62995
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
62870
62996
  }
62871
62997
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62872
62998
  if (importBinding?.isNamespace) {
62873
62999
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
62874
- if (importBinding.moduleSpecifier.startsWith(".")) {
62875
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62876
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62877
- }
63000
+ if (analyzeImportedConfig({
63001
+ analysis,
63002
+ moduleSpecifier: importBinding.moduleSpecifier,
63003
+ exportName: node.name.text,
63004
+ allowCompilerTransform
63005
+ })) return true;
62878
63006
  return false;
62879
63007
  }
62880
63008
  const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
@@ -62885,13 +63013,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62885
63013
  }
62886
63014
  if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
62887
63015
  if (ts.isIdentifier(node.expression)) {
63016
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
63017
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
63018
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
63019
+ }
62888
63020
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62889
63021
  if (importBinding?.isNamespace) {
62890
63022
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
62891
- if (importBinding.moduleSpecifier.startsWith(".")) {
62892
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62893
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.argumentExpression.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62894
- }
63023
+ return Boolean(analyzeImportedConfig({
63024
+ analysis,
63025
+ moduleSpecifier: importBinding.moduleSpecifier,
63026
+ exportName: node.argumentExpression.text,
63027
+ allowCompilerTransform
63028
+ }));
62895
63029
  }
62896
63030
  const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
62897
63031
  if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
@@ -62929,14 +63063,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62929
63063
  };
62930
63064
  const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
62931
63065
  const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
62932
- const hasCompilerInPackageJsonConfig = (packageJson) => isPlainObject(packageJson.babel) && analyzeConfigSourceFileExport(ts.parseJsonText("package.json", JSON.stringify(packageJson.babel)), "package.json#babel", "default", false, 0, /* @__PURE__ */ new Set());
62933
- const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
63066
+ const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
63067
+ if (!isPlainObject(packageJson.babel)) return false;
63068
+ const packageJsonPath = Path.join(directory, "package.json");
63069
+ return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
63070
+ };
63071
+ const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
62934
63072
  const hasCompilerConfigurationInAncestors = (directory) => {
62935
63073
  if (isProjectBoundary(directory)) return false;
62936
63074
  let ancestorDirectory = Path.dirname(directory);
62937
63075
  while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
62938
63076
  const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
62939
- if (hasCompilerInPackageJsonConfig(isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {}) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
63077
+ const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
63078
+ if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
62940
63079
  if (isProjectBoundary(ancestorDirectory)) return false;
62941
63080
  ancestorDirectory = Path.dirname(ancestorDirectory);
62942
63081
  }
@@ -66165,7 +66304,7 @@ const warn = (message) => {
66165
66304
  runSync(warn$1(message));
66166
66305
  };
66167
66306
  const CONFIG_BASENAME = "doctor.config";
66168
- const CONFIG_EXTENSIONS = [
66307
+ const CONFIG_EXTENSIONS$1 = [
66169
66308
  "ts",
66170
66309
  "mts",
66171
66310
  "cts",
@@ -66269,7 +66408,7 @@ const loadLegacyConfig = (directory) => {
66269
66408
  };
66270
66409
  const loadConfigFromDirectory = async (directory) => {
66271
66410
  let sawBrokenConfigFile = false;
66272
- for (const extension of CONFIG_EXTENSIONS) {
66411
+ for (const extension of CONFIG_EXTENSIONS$1) {
66273
66412
  const filePath = Path.join(directory, `${CONFIG_BASENAME}.${extension}`);
66274
66413
  if (!isFile(filePath)) continue;
66275
66414
  const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
@@ -70028,7 +70167,11 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
70028
70167
  const ROOT_DIRECTORY_PLACEHOLDER = "<root>";
70029
70168
  const normalizeConfigForHash = (config) => {
70030
70169
  const clone = JSON.parse(JSON.stringify(config));
70031
- if (clone?.settings?.["react-doctor"]) clone.settings["react-doctor"].rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
70170
+ if (clone?.settings?.["react-doctor"]) {
70171
+ const reactDoctorSettings = clone.settings["react-doctor"];
70172
+ reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
70173
+ if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
70174
+ }
70032
70175
  if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
70033
70176
  return clone;
70034
70177
  };
@@ -70187,13 +70330,14 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
70187
70330
  }
70188
70331
  return enabled;
70189
70332
  };
70190
- const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
70333
+ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, runtimeGlobals, unpluginAutoImportGlobalScopes, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
70191
70334
  const hasIncludedTags = includedTags.size > 0;
70192
70335
  const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
70193
70336
  const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
70194
70337
  const jsPlugins = [];
70195
70338
  if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
70196
70339
  const capabilities = getCapabilities(project);
70340
+ const settingsRootDirectory = resolveSettingsRootDirectory(project.rootDirectory);
70197
70341
  const enabledReactDoctorRules = {};
70198
70342
  for (const registryEntry of REACT_DOCTOR_RULES) {
70199
70343
  const rule = reactDoctorPlugin.rules[registryEntry.id];
@@ -70239,8 +70383,16 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
70239
70383
  jsPlugins: [...jsPlugins, pluginPath],
70240
70384
  settings: { "react-doctor": {
70241
70385
  framework: project.framework,
70242
- rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
70386
+ rootDirectory: settingsRootDirectory,
70243
70387
  capabilities: [...capabilities].sort(),
70388
+ ...runtimeGlobals && runtimeGlobals.length > 0 ? { runtimeGlobals: [...runtimeGlobals] } : {},
70389
+ ...unpluginAutoImportGlobalScopes && unpluginAutoImportGlobalScopes.length > 0 ? {
70390
+ unpluginAutoImportRootDirectories: [...new Set([settingsRootDirectory, project.rootDirectory])],
70391
+ unpluginAutoImportGlobalScopes: unpluginAutoImportGlobalScopes.map((scope) => ({
70392
+ directory: scope.directory,
70393
+ names: [...scope.names]
70394
+ }))
70395
+ } : {},
70244
70396
  ...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
70245
70397
  ...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
70246
70398
  } },
@@ -70251,6 +70403,245 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
70251
70403
  }
70252
70404
  };
70253
70405
  };
70406
+ const AUTO_IMPORT_ADAPTER_PATTERN = /^unplugin-auto-import\/(?:astro|esbuild|rollup|rolldown|rspack|vite|webpack)$/;
70407
+ const CONFIG_BASENAMES = [
70408
+ "astro.config",
70409
+ "esbuild.config",
70410
+ "rollup.config",
70411
+ "rolldown.config",
70412
+ "rspack.config",
70413
+ "vite.config",
70414
+ "webpack.config"
70415
+ ];
70416
+ const CONFIG_EXTENSIONS = [
70417
+ ".cjs",
70418
+ ".cts",
70419
+ ".js",
70420
+ ".mjs",
70421
+ ".mts",
70422
+ ".ts"
70423
+ ];
70424
+ const CONFIG_FILENAMES = new Set(CONFIG_BASENAMES.flatMap((basename) => CONFIG_EXTENSIONS.map((extension) => `${basename}${extension}`)));
70425
+ const DEFAULT_ESLINT_GLOBALS_PATH = ".eslintrc-auto-import.json";
70426
+ const SUPPORTED_GLOBAL_VALUES = new Set([
70427
+ true,
70428
+ false,
70429
+ "readable",
70430
+ "readonly",
70431
+ "writable",
70432
+ "writeable"
70433
+ ]);
70434
+ const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
70435
+ if (ts.isSpreadAssignment(property)) return false;
70436
+ const name = ts.isComputedPropertyName(property.name) ? unwrapTypescriptExpression(property.name.expression) : property.name;
70437
+ return (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) && name.text === propertyName;
70438
+ }) ?? null;
70439
+ const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !ts.isSpreadAssignment(property) && ts.isComputedPropertyName(property.name) && !ts.isStringLiteralLike(unwrapTypescriptExpression(property.name.expression)));
70440
+ const getStaticPropertyAssignment = (objectExpression, propertyName) => {
70441
+ const property = getStaticProperty(objectExpression, propertyName);
70442
+ return property && ts.isPropertyAssignment(property) ? property : null;
70443
+ };
70444
+ const getRequireModuleSpecifier = (expression) => {
70445
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
70446
+ if (ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "default") return getRequireModuleSpecifier(unwrappedExpression.expression);
70447
+ if (!ts.isCallExpression(unwrappedExpression) || !ts.isIdentifier(unwrappedExpression.expression) || unwrappedExpression.expression.text !== "require" || unwrappedExpression.arguments.length !== 1) return null;
70448
+ const moduleSpecifier = unwrappedExpression.arguments[0];
70449
+ return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
70450
+ };
70451
+ const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
70452
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
70453
+ return ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
70454
+ };
70455
+ const isCommonJsExportAssignment = (node, sourceFile) => ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
70456
+ const isTopLevelExpression = (node) => {
70457
+ let ancestor = node.parent;
70458
+ while (ancestor && !ts.isSourceFile(ancestor)) {
70459
+ if (ts.isExpressionStatement(ancestor)) return ts.isSourceFile(ancestor.parent);
70460
+ if (!ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isAwaitExpression(ancestor)) return false;
70461
+ ancestor = ancestor.parent;
70462
+ }
70463
+ return false;
70464
+ };
70465
+ const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
70466
+ let ancestor = node.parent;
70467
+ let didFindConfigProperty = false;
70468
+ while (ancestor && !ts.isSourceFile(ancestor)) {
70469
+ if (!didFindConfigProperty && !ts.isArrayLiteralExpression(ancestor) && !ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isPropertyAssignment(ancestor)) return false;
70470
+ if (ts.isPropertyAssignment(ancestor)) {
70471
+ const isConfigProperty = (ts.isIdentifier(ancestor.name) || ts.isStringLiteralLike(ancestor.name)) && ancestor.name.text === propertyName;
70472
+ if (didFindConfigProperty || !isConfigProperty) return false;
70473
+ if (!ts.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(ts.isSpreadAssignment)) return false;
70474
+ didFindConfigProperty = true;
70475
+ ancestor = ancestor.parent;
70476
+ continue;
70477
+ }
70478
+ if (didFindConfigProperty) {
70479
+ if (ts.isExportAssignment(ancestor)) return true;
70480
+ if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
70481
+ if (propertyName === "plugins" && ts.isCallExpression(ancestor) && (ts.isIdentifier(ancestor.expression) ? esbuildBindings.has(ancestor.expression.text) : ts.isPropertyAccessExpression(ancestor.expression) && ancestor.expression.name.text === "build" && (ts.isIdentifier(ancestor.expression.expression) && esbuildNamespaceBindings.has(ancestor.expression.expression.text) || getRequireModuleSpecifier(ancestor.expression.expression) === "esbuild"))) return isTopLevelExpression(ancestor);
70482
+ if (!(ts.isObjectLiteralExpression(ancestor) || ts.isParenthesizedExpression(ancestor) || ts.isAsExpression(ancestor) || ts.isSatisfiesExpression(ancestor) || ts.isNonNullExpression(ancestor) || ts.isTypeAssertionExpression(ancestor) || ts.isCallExpression(ancestor) && ts.isIdentifier(ancestor.expression) && ancestor.expression.text === "defineConfig")) return false;
70483
+ }
70484
+ ancestor = ancestor.parent;
70485
+ }
70486
+ return false;
70487
+ };
70488
+ const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory) => {
70489
+ const optionsExpression = callExpression.arguments[0];
70490
+ if (!optionsExpression) return null;
70491
+ const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
70492
+ if (!ts.isObjectLiteralExpression(unwrappedOptions)) return null;
70493
+ if (unwrappedOptions.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
70494
+ if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
70495
+ const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
70496
+ if (!eslintrcProperty) return null;
70497
+ const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
70498
+ if (!ts.isObjectLiteralExpression(eslintrcExpression)) return null;
70499
+ if (eslintrcExpression.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
70500
+ const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
70501
+ if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== ts.SyntaxKind.TrueKeyword) return null;
70502
+ const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
70503
+ if (!filepathProperty) return Path.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
70504
+ if (!ts.isPropertyAssignment(filepathProperty)) return null;
70505
+ const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
70506
+ return ts.isStringLiteralLike(filepathExpression) ? Path.resolve(packageDirectory, filepathExpression.text) : null;
70507
+ };
70508
+ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
70509
+ let sourceText;
70510
+ try {
70511
+ sourceText = NFS.readFileSync(configPath, "utf8");
70512
+ } catch {
70513
+ return {
70514
+ didFindActiveAutoImport: false,
70515
+ globalsPaths: []
70516
+ };
70517
+ }
70518
+ const sourceFile = ts.createSourceFile(configPath, sourceText, ts.ScriptTarget.Latest, true);
70519
+ const autoImportBindings = /* @__PURE__ */ new Map();
70520
+ const esbuildBindings = /* @__PURE__ */ new Set();
70521
+ const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
70522
+ for (const statement of sourceFile.statements) {
70523
+ if (ts.isImportDeclaration(statement) && ts.isStringLiteralLike(statement.moduleSpecifier)) {
70524
+ const moduleSpecifier = statement.moduleSpecifier.text;
70525
+ if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
70526
+ const defaultBinding = statement.importClause?.name;
70527
+ if (defaultBinding) autoImportBindings.set(defaultBinding.text, moduleSpecifier);
70528
+ }
70529
+ if (moduleSpecifier === "esbuild") {
70530
+ const defaultBinding = statement.importClause?.name;
70531
+ if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
70532
+ const namedBindings = statement.importClause?.namedBindings;
70533
+ if (namedBindings && ts.isNamedImports(namedBindings)) {
70534
+ for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
70535
+ }
70536
+ if (namedBindings && ts.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
70537
+ }
70538
+ }
70539
+ if (!ts.isVariableStatement(statement)) continue;
70540
+ for (const declaration of statement.declarationList.declarations) {
70541
+ if (!declaration.initializer) continue;
70542
+ const declarationName = ts.isIdentifier(declaration.name) ? declaration.name.text : null;
70543
+ const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
70544
+ if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
70545
+ if (moduleSpecifier === "esbuild") {
70546
+ if (declarationName) esbuildNamespaceBindings.add(declarationName);
70547
+ if (ts.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
70548
+ const importedName = bindingElement.propertyName ?? bindingElement.name;
70549
+ if (ts.isIdentifier(importedName) && importedName.text === "build" && ts.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
70550
+ }
70551
+ }
70552
+ if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
70553
+ }
70554
+ }
70555
+ const globalsPaths = /* @__PURE__ */ new Set();
70556
+ let didFindActiveAutoImport = false;
70557
+ let didFindUnsafeActiveAutoImport = false;
70558
+ const visit = (node) => {
70559
+ if (ts.isCallExpression(node)) {
70560
+ const moduleSpecifier = ts.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
70561
+ if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
70562
+ if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
70563
+ didFindActiveAutoImport = true;
70564
+ const globalsPath = getGlobalsPathFromActiveAutoImportCall(node, packageDirectory);
70565
+ if (globalsPath) globalsPaths.add(globalsPath);
70566
+ else didFindUnsafeActiveAutoImport = true;
70567
+ }
70568
+ }
70569
+ }
70570
+ ts.forEachChild(node, visit);
70571
+ };
70572
+ visit(sourceFile);
70573
+ return {
70574
+ didFindActiveAutoImport,
70575
+ globalsPaths: didFindUnsafeActiveAutoImport ? [] : [...globalsPaths]
70576
+ };
70577
+ };
70578
+ const collectGeneratedGlobalNames = (globalsPath, rootDirectory) => {
70579
+ const relativePath = Path.relative(rootDirectory, globalsPath);
70580
+ if (relativePath.startsWith("..") || Path.isAbsolute(relativePath)) return [];
70581
+ const parsed = failOpenReadJson(globalsPath, null);
70582
+ if (!isPlainObject(parsed) || !isPlainObject(parsed.globals)) return [];
70583
+ return Object.entries(parsed.globals).filter((entry) => entry[0].length > 0 && (typeof entry[1] === "boolean" || typeof entry[1] === "string") && SUPPORTED_GLOBAL_VALUES.has(entry[1])).map(([name]) => name).sort();
70584
+ };
70585
+ const findOwningPackageDirectory = (absoluteFilePath, rootDirectory, cache) => {
70586
+ let currentDirectory = Path.dirname(absoluteFilePath);
70587
+ const visitedDirectories = [];
70588
+ while (true) {
70589
+ const cachedDirectory = cache.get(currentDirectory);
70590
+ if (cachedDirectory !== void 0) {
70591
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, cachedDirectory);
70592
+ return cachedDirectory;
70593
+ }
70594
+ const relativeDirectory = Path.relative(rootDirectory, currentDirectory);
70595
+ if (relativeDirectory.startsWith("..") || Path.isAbsolute(relativeDirectory)) {
70596
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
70597
+ return null;
70598
+ }
70599
+ visitedDirectories.push(currentDirectory);
70600
+ if (NFS.existsSync(Path.join(currentDirectory, "package.json"))) {
70601
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, currentDirectory);
70602
+ return currentDirectory;
70603
+ }
70604
+ if (currentDirectory === rootDirectory) {
70605
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
70606
+ return null;
70607
+ }
70608
+ currentDirectory = Path.dirname(currentDirectory);
70609
+ }
70610
+ };
70611
+ const collectPackageGlobalNames = (packageDirectory, rootDirectory) => {
70612
+ let directoryEntries;
70613
+ try {
70614
+ directoryEntries = NFS.readdirSync(packageDirectory, { withFileTypes: true });
70615
+ } catch {
70616
+ return [];
70617
+ }
70618
+ const configuredGlobalsPaths = [];
70619
+ for (const entry of directoryEntries) {
70620
+ if (!entry.isFile() && !entry.isSymbolicLink() || !CONFIG_FILENAMES.has(entry.name)) continue;
70621
+ const configGlobalsPaths = collectGlobalsPathsFromConfig(Path.join(packageDirectory, entry.name), packageDirectory);
70622
+ if (configGlobalsPaths.didFindActiveAutoImport) configuredGlobalsPaths.push(configGlobalsPaths.globalsPaths.toSorted());
70623
+ }
70624
+ if (configuredGlobalsPaths.length === 0) return [];
70625
+ const globalsPaths = configuredGlobalsPaths[0];
70626
+ if (configuredGlobalsPaths.some((candidatePaths) => candidatePaths.length !== globalsPaths.length || candidatePaths.some((candidatePath, index) => candidatePath !== globalsPaths[index]))) return [];
70627
+ const names = /* @__PURE__ */ new Set();
70628
+ for (const globalsPath of globalsPaths) for (const name of collectGeneratedGlobalNames(globalsPath, rootDirectory)) names.add(name);
70629
+ return [...names].sort();
70630
+ };
70631
+ const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }) => {
70632
+ const absoluteRootDirectory = Path.resolve(rootDirectory);
70633
+ const packageDirectoryCache = /* @__PURE__ */ new Map();
70634
+ const packageDirectories = /* @__PURE__ */ new Set();
70635
+ for (const candidateFile of candidateFiles) {
70636
+ const packageDirectory = findOwningPackageDirectory(Path.resolve(absoluteRootDirectory, candidateFile), absoluteRootDirectory, packageDirectoryCache);
70637
+ if (packageDirectory) packageDirectories.add(packageDirectory);
70638
+ }
70639
+ const scopes = [...packageDirectories].map((packageDirectory) => ({
70640
+ directory: Path.relative(absoluteRootDirectory, packageDirectory).replaceAll("\\", "/"),
70641
+ names: collectPackageGlobalNames(packageDirectory, absoluteRootDirectory)
70642
+ })).sort((firstScope, secondScope) => firstScope.directory.localeCompare(secondScope.directory));
70643
+ return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
70644
+ };
70254
70645
  const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
70255
70646
  const decodeFileDiagnostics = (raw) => {
70256
70647
  if (!Array.isArray(raw)) return null;
@@ -70573,6 +70964,12 @@ const appendReanimatedSharedValueHint = (help, rule, project) => {
70573
70964
  if (!help) return REANIMATED_SHARED_VALUE_HINT;
70574
70965
  return `${help}\n\n${REANIMATED_SHARED_VALUE_HINT}`;
70575
70966
  };
70967
+ const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
70968
+ const boundedOffset = Math.min(Math.max(utf8Offset, 0), sourceBuffer.length);
70969
+ let lineStartOffset = boundedOffset;
70970
+ while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
70971
+ return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
70972
+ };
70576
70973
  const REDACTED_PLACEHOLDER = "<redacted>";
70577
70974
  const KEEP_PREFIX = `$1${REDACTED_PLACEHOLDER}`;
70578
70975
  const KNOWN_SECRET_RULES = [
@@ -71288,7 +71685,7 @@ const resolveMatchByOccurrence = (rule, category) => OCCURRENCE_MATCHED_CATEGORI
71288
71685
  * with empty text still carry a useful jump target, so they're kept
71289
71686
  * with a neutral message.
71290
71687
  */
71291
- const buildRelatedLocations = (labels, filePath) => {
71688
+ const buildRelatedLocations = (labels, filePath, sourceBuffer) => {
71292
71689
  if (labels.length <= 1) return [];
71293
71690
  const related = [];
71294
71691
  for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
@@ -71296,8 +71693,8 @@ const buildRelatedLocations = (labels, filePath) => {
71296
71693
  if (!label?.span) continue;
71297
71694
  related.push({
71298
71695
  filePath,
71299
- line: label.span.line ?? 0,
71300
- column: label.span.column ?? 0,
71696
+ line: sourceBuffer === null ? label.span.line ?? 0 : lineOfUtf8Offset(sourceBuffer, label.span.offset),
71697
+ column: sourceBuffer === null ? label.span.column ?? 0 : columnOfUtf8Offset(sourceBuffer, label.span.offset),
71301
71698
  offset: label.span.offset,
71302
71699
  length: label.span.length,
71303
71700
  message: label.label ?? ""
@@ -71317,7 +71714,7 @@ const isOxlintOutput = (value) => isRecord(value) && Array.isArray(value.diagnos
71317
71714
  * to the first `{`. Raises `OxlintOutputUnparseable` when the
71318
71715
  * stdout isn't valid JSON or doesn't carry a `diagnostics` array.
71319
71716
  */
71320
- const parseOxlintOutput = (stdout, project, rootDirectory) => {
71717
+ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath) => {
71321
71718
  if (!stdout) return [];
71322
71719
  const jsonStart = stdout.indexOf("{");
71323
71720
  const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
@@ -71334,8 +71731,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71334
71731
  const sourceBufferCache = /* @__PURE__ */ new Map();
71335
71732
  const sourceLinesCache = /* @__PURE__ */ new Map();
71336
71733
  const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
71734
+ const resolveMappedSourceFilename = (filename) => sourcePathByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
71735
+ const resolveSourceFilename = (filename) => resolveMappedSourceFilename(filename) ?? filename;
71337
71736
  const readSourceBuffer = (filename) => {
71338
- const absolutePath = resolveAbsolutePath(filename);
71737
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71339
71738
  const cached = sourceBufferCache.get(absolutePath);
71340
71739
  if (cached !== void 0) return cached;
71341
71740
  let sourceBuffer;
@@ -71348,7 +71747,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71348
71747
  return sourceBuffer;
71349
71748
  };
71350
71749
  const readSourceLines = (filename) => {
71351
- const absolutePath = resolveAbsolutePath(filename);
71750
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71352
71751
  const cached = sourceLinesCache.get(absolutePath);
71353
71752
  if (cached !== void 0) return cached;
71354
71753
  const sourceBuffer = readSourceBuffer(filename);
@@ -71357,27 +71756,30 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71357
71756
  return sourceLines;
71358
71757
  };
71359
71758
  const isMinifiedDiagnosticFile = (filename) => {
71360
- const absolutePath = resolveAbsolutePath(filename);
71759
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71361
71760
  const cached = minifiedFileCache.get(absolutePath);
71362
71761
  if (cached !== void 0) return cached;
71363
71762
  const minified = isMinifiedSource(absolutePath);
71364
71763
  minifiedFileCache.set(absolutePath, minified);
71365
71764
  return minified;
71366
71765
  };
71367
- return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.filter((diagnostic) => isMappableOxlintDiagnostic(diagnostic) && isLintableSourceFile(diagnostic.filename) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
71766
+ return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.filter((diagnostic) => isMappableOxlintDiagnostic(diagnostic) && isLintableSourceFile(resolveSourceFilename(diagnostic.filename)) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
71368
71767
  const { plugin, rule } = parseRuleCode(diagnostic.code);
71369
71768
  const primaryLabel = diagnostic.labels[0];
71370
71769
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
71371
- const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
71770
+ const mappedSourceFilename = resolveMappedSourceFilename(diagnostic.filename);
71771
+ const normalizedFilePath = (mappedSourceFilename ?? diagnostic.filename).replaceAll("\\", "/");
71372
71772
  const primarySpan = primaryLabel?.span;
71373
71773
  const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
71374
- const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
71774
+ const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath, mappedSourceFilename === void 0 ? null : sourceBuffer);
71375
71775
  const category = resolveDiagnosticCategory(plugin, rule);
71376
71776
  const matchByOccurrence = resolveMatchByOccurrence(rule, category);
71377
71777
  const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
71378
- const primaryLineIndex = primarySpan ? primarySpan.line - 1 : -1;
71778
+ const primaryLineNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.line ?? 0;
71779
+ const primaryColumnNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? columnOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.column ?? 0;
71780
+ const primaryLineIndex = primarySpan ? primaryLineNumber - 1 : -1;
71379
71781
  const primaryLine = sourceLines?.[primaryLineIndex];
71380
- const primaryColumnIndex = primarySpan ? primarySpan.column - 1 : -1;
71782
+ const primaryColumnIndex = primarySpan ? primaryColumnNumber - 1 : -1;
71381
71783
  const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
71382
71784
  const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
71383
71785
  const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
@@ -71390,8 +71792,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71390
71792
  message: cleaned.message,
71391
71793
  help: cleaned.help,
71392
71794
  url: diagnostic.url,
71393
- line: primarySpan?.line ?? 0,
71394
- column: primarySpan?.column ?? 0,
71795
+ line: primaryLineNumber,
71796
+ column: primaryColumnNumber,
71395
71797
  ...primarySpan ? {
71396
71798
  offset: primarySpan.offset,
71397
71799
  length: primarySpan.length,
@@ -71579,7 +71981,11 @@ const isParallelismRelatedSpawnError = (error) => {
71579
71981
  * loop with a slimmer config in that case.
71580
71982
  */
71581
71983
  const spawnLintBatches = async (input) => {
71582
- const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
71984
+ const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, sourcePathByLintPath, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
71985
+ const resolveSourcePath = (filePath) => {
71986
+ const absoluteFilePath = Path.isAbsolute(filePath) ? filePath : Path.resolve(rootDirectory, filePath);
71987
+ return sourcePathByLintPath?.get(Path.normalize(absoluteFilePath)) ?? filePath;
71988
+ };
71583
71989
  const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
71584
71990
  let rescueDeadlineEpochMs;
71585
71991
  const isPastDeadline = () => deadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(deadlineEpochMs) === 0 || rescueDeadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(rescueDeadlineEpochMs) === 0;
@@ -71599,7 +72005,7 @@ const spawnLintBatches = async (input) => {
71599
72005
  }
71600
72006
  const batchArgs = [...baseArgs, ...batch];
71601
72007
  try {
71602
- return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory);
72008
+ return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory, sourcePathByLintPath);
71603
72009
  } catch (error) {
71604
72010
  if (!isSplittableReactDoctorError(error)) throw error;
71605
72011
  if (isPastDeadline()) {
@@ -71705,10 +72111,12 @@ const spawnLintBatches = async (input) => {
71705
72111
  onPartialFailure(buildMessage(`${skippedFiles.slice(0, 3).join(", ")}${skippedFiles.length > 3 ? `, +${skippedFiles.length - 3} more` : ""}`));
71706
72112
  };
71707
72113
  const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
71708
- reportSkippedFiles(droppedFiles, (fileListPreview) => `${droppedFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
71709
- reportSkippedFiles(outcome.deadlineSkippedFiles, (fileListPreview) => `${outcome.deadlineSkippedFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
72114
+ const droppedSourceFiles = [...new Set(droppedFiles.map(resolveSourcePath))];
72115
+ const deadlineSkippedSourceFiles = [...new Set(outcome.deadlineSkippedFiles.map(resolveSourcePath))];
72116
+ reportSkippedFiles(droppedSourceFiles, (fileListPreview) => `${droppedSourceFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
72117
+ reportSkippedFiles(deadlineSkippedSourceFiles, (fileListPreview) => `${deadlineSkippedSourceFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
71710
72118
  const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
71711
- input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)))].sort());
72119
+ input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)).map(resolveSourcePath))].sort());
71712
72120
  return dedupeDiagnostics(diagnostics);
71713
72121
  };
71714
72122
  let didValidate = false;
@@ -71807,6 +72215,266 @@ const planLintBatches = ({ baseArgs, files, sizeByFile }) => {
71807
72215
  }
71808
72216
  return batches.filter((batch) => batch.fileIndexes.length > 0).map((batch) => batch.fileIndexes.sort((leftIndex, rightIndex) => leftIndex - rightIndex).map((fileIndex) => files[fileIndex]));
71809
72217
  };
72218
+ const THREE_MODULE_IMPORT_PATTERN = /\b(?:from\s*|import\s*(?:\(\s*)?|require\s*\(\s*)["']three(?:\/[^"']*)?["']/;
72219
+ const containsThreeModuleImport = (sourceText) => THREE_MODULE_IMPORT_PATTERN.test(sourceText);
72220
+ const COMMENT_OPEN = "<!--";
72221
+ const COMMENT_CLOSE = "-->";
72222
+ const FRONTMATTER_FENCE = "---";
72223
+ const SCRIPT_TAG_NAME = "script";
72224
+ const SCRIPT_OPEN = `<${SCRIPT_TAG_NAME}`;
72225
+ const SCRIPT_CLOSE = `</${SCRIPT_TAG_NAME}`;
72226
+ const TEMPLATE_TAG_NAME = "template";
72227
+ const TEMPLATE_CLOSE = `</${TEMPLATE_TAG_NAME}`;
72228
+ const JAVASCRIPT_MIME_TYPES = new Set([
72229
+ "application/ecmascript",
72230
+ "application/javascript",
72231
+ "application/x-ecmascript",
72232
+ "application/x-javascript",
72233
+ "text/ecmascript",
72234
+ "text/javascript",
72235
+ "text/javascript1.0",
72236
+ "text/javascript1.1",
72237
+ "text/javascript1.2",
72238
+ "text/javascript1.3",
72239
+ "text/javascript1.4",
72240
+ "text/javascript1.5",
72241
+ "text/jscript",
72242
+ "text/livescript",
72243
+ "text/x-ecmascript",
72244
+ "text/x-javascript"
72245
+ ]);
72246
+ const RAW_TEXT_TAG_NAMES = new Set([
72247
+ "iframe",
72248
+ "noembed",
72249
+ "noframes",
72250
+ "noscript",
72251
+ "style",
72252
+ "textarea",
72253
+ "title",
72254
+ "xmp"
72255
+ ]);
72256
+ const PLAINTEXT_TAG_NAME = "plaintext";
72257
+ const TAG_OPEN_UTF8_BYTE = "<".charCodeAt(0);
72258
+ const TAG_CLOSE_UTF8_BYTE = ">".charCodeAt(0);
72259
+ const SINGLE_QUOTE_UTF8_BYTE = "'".charCodeAt(0);
72260
+ const DOUBLE_QUOTE_UTF8_BYTE = "\"".charCodeAt(0);
72261
+ const ATTRIBUTE_ASSIGNMENT_UTF8_BYTE = "=".charCodeAt(0);
72262
+ const TAG_SELF_CLOSE_UTF8_BYTE = "/".charCodeAt(0);
72263
+ const TAB_UTF8_BYTE = " ".charCodeAt(0);
72264
+ const FORM_FEED_UTF8_BYTE = "\f".charCodeAt(0);
72265
+ const isHtmlWhitespace = (byte) => byte === TAB_UTF8_BYTE || byte === 10 || byte === FORM_FEED_UTF8_BYTE || byte === 13 || byte === 32;
72266
+ const matchesAsciiCaseInsensitive = (sourceBuffer, startByte, expected) => {
72267
+ if (startByte + expected.length > sourceBuffer.length) return false;
72268
+ for (let expectedIndex = 0; expectedIndex < expected.length; expectedIndex++) {
72269
+ const sourceByte = sourceBuffer[startByte + expectedIndex];
72270
+ if (sourceByte === void 0 || String.fromCharCode(sourceByte).toLowerCase() !== expected[expectedIndex]) return false;
72271
+ }
72272
+ return true;
72273
+ };
72274
+ const isTagBoundary = (byte) => byte === TAG_CLOSE_UTF8_BYTE || byte === TAG_SELF_CLOSE_UTF8_BYTE || isHtmlWhitespace(byte);
72275
+ const isPotentialTagStart = (byte) => {
72276
+ if (byte === void 0) return false;
72277
+ return /[A-Za-z!/?]/.test(String.fromCharCode(byte));
72278
+ };
72279
+ const findLineEnd = (sourceBuffer, lineStartByte) => {
72280
+ let byteIndex = lineStartByte;
72281
+ while (byteIndex < sourceBuffer.length && sourceBuffer[byteIndex] !== 10 && sourceBuffer[byteIndex] !== 13) byteIndex++;
72282
+ return byteIndex;
72283
+ };
72284
+ const findNextLineStart = (sourceBuffer, lineStartByte) => {
72285
+ const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
72286
+ if (sourceBuffer[lineEndByte] === 13 && sourceBuffer[lineEndByte + 1] === 10) return lineEndByte + 2;
72287
+ return Math.min(lineEndByte + 1, sourceBuffer.length);
72288
+ };
72289
+ const isFrontmatterFenceLine = (sourceBuffer, lineStartByte) => {
72290
+ if (!matchesAsciiCaseInsensitive(sourceBuffer, lineStartByte, FRONTMATTER_FENCE)) return false;
72291
+ const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
72292
+ for (let byteIndex = lineStartByte + 3; byteIndex < lineEndByte; byteIndex++) if (!isHtmlWhitespace(sourceBuffer[byteIndex])) return false;
72293
+ return true;
72294
+ };
72295
+ const findFrontmatterEnd = (sourceBuffer) => {
72296
+ if (!isFrontmatterFenceLine(sourceBuffer, 0)) return 0;
72297
+ const openingFenceEndByte = findLineEnd(sourceBuffer, 0);
72298
+ let lineStartByte = findNextLineStart(sourceBuffer, 0);
72299
+ while (lineStartByte < sourceBuffer.length) {
72300
+ if (isFrontmatterFenceLine(sourceBuffer, lineStartByte)) return findLineEnd(sourceBuffer, lineStartByte);
72301
+ lineStartByte = findNextLineStart(sourceBuffer, lineStartByte);
72302
+ }
72303
+ return openingFenceEndByte;
72304
+ };
72305
+ const maskByteRange = (maskedBuffer, startByte, endByte) => {
72306
+ for (let byteIndex = startByte; byteIndex < endByte; byteIndex++) {
72307
+ const byte = maskedBuffer[byteIndex];
72308
+ if (byte !== 10 && byte !== 13) maskedBuffer[byteIndex] = 32;
72309
+ }
72310
+ };
72311
+ const readStartTagName = (sourceBuffer, tagStartByte) => {
72312
+ const firstNameByte = sourceBuffer[tagStartByte + 1];
72313
+ if (firstNameByte === void 0 || !/[A-Za-z]/.test(String.fromCharCode(firstNameByte))) return null;
72314
+ let nameEndByte = tagStartByte + 2;
72315
+ while (nameEndByte < sourceBuffer.length && /[A-Za-z0-9:-]/.test(String.fromCharCode(sourceBuffer[nameEndByte] ?? 32))) nameEndByte++;
72316
+ return sourceBuffer.subarray(tagStartByte + 1, nameEndByte).toString("ascii").toLowerCase();
72317
+ };
72318
+ const findTagEnd = (sourceBuffer, startByte) => {
72319
+ let quoteByte = null;
72320
+ for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) {
72321
+ const byte = sourceBuffer[byteIndex];
72322
+ if (quoteByte !== null) {
72323
+ if (byte === quoteByte) quoteByte = null;
72324
+ continue;
72325
+ }
72326
+ if (byte === SINGLE_QUOTE_UTF8_BYTE || byte === DOUBLE_QUOTE_UTF8_BYTE) {
72327
+ quoteByte = byte;
72328
+ continue;
72329
+ }
72330
+ if (byte === TAG_CLOSE_UTF8_BYTE) return byteIndex;
72331
+ }
72332
+ return sourceBuffer.length;
72333
+ };
72334
+ const parseScriptAttributes = (sourceBuffer, attributesStartByte, tagEndByte) => {
72335
+ let byteIndex = attributesStartByte;
72336
+ let hasSource = false;
72337
+ let language = null;
72338
+ let scriptType = null;
72339
+ while (byteIndex < tagEndByte) {
72340
+ while (byteIndex < tagEndByte && (isHtmlWhitespace(sourceBuffer[byteIndex]) || sourceBuffer[byteIndex] === TAG_SELF_CLOSE_UTF8_BYTE)) byteIndex++;
72341
+ const attributeNameStartByte = byteIndex;
72342
+ while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== ATTRIBUTE_ASSIGNMENT_UTF8_BYTE && sourceBuffer[byteIndex] !== TAG_SELF_CLOSE_UTF8_BYTE) byteIndex++;
72343
+ const attributeName = sourceBuffer.subarray(attributeNameStartByte, byteIndex).toString("ascii").toLowerCase();
72344
+ while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
72345
+ let attributeValue = "";
72346
+ if (sourceBuffer[byteIndex] === ATTRIBUTE_ASSIGNMENT_UTF8_BYTE) {
72347
+ byteIndex++;
72348
+ while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
72349
+ const quoteByte = sourceBuffer[byteIndex];
72350
+ if (quoteByte === SINGLE_QUOTE_UTF8_BYTE || quoteByte === DOUBLE_QUOTE_UTF8_BYTE) {
72351
+ const valueStartByte = byteIndex + 1;
72352
+ byteIndex = valueStartByte;
72353
+ while (byteIndex < tagEndByte && sourceBuffer[byteIndex] !== quoteByte) byteIndex++;
72354
+ attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
72355
+ if (byteIndex < tagEndByte) byteIndex++;
72356
+ } else {
72357
+ const valueStartByte = byteIndex;
72358
+ while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== TAG_CLOSE_UTF8_BYTE) byteIndex++;
72359
+ attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
72360
+ }
72361
+ }
72362
+ if (attributeName === "src") hasSource = true;
72363
+ else if (attributeName === "type" && scriptType === null) scriptType = attributeValue;
72364
+ else if (attributeName === "language" && language === null) language = attributeValue;
72365
+ }
72366
+ return {
72367
+ hasSource,
72368
+ language,
72369
+ type: scriptType
72370
+ };
72371
+ };
72372
+ const isExecutableScript = (attributes) => {
72373
+ if (attributes.hasSource) return false;
72374
+ const type = attributes.type?.trim().toLowerCase() ?? "";
72375
+ if (type !== "") {
72376
+ const mimeType = type.split(";")[0]?.trim() ?? "";
72377
+ return mimeType === "module" || JAVASCRIPT_MIME_TYPES.has(mimeType);
72378
+ }
72379
+ const language = attributes.language?.trim().toLowerCase() ?? "";
72380
+ return language === "" || JAVASCRIPT_MIME_TYPES.has(`text/${language}`);
72381
+ };
72382
+ const findElementClose = (sourceBuffer, startByte, tagName) => {
72383
+ const closeTagStart = `</${tagName}`;
72384
+ for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) if (sourceBuffer[byteIndex] === TAG_OPEN_UTF8_BYTE && matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, closeTagStart) && isTagBoundary(sourceBuffer[byteIndex + closeTagStart.length])) return byteIndex;
72385
+ return sourceBuffer.length;
72386
+ };
72387
+ const prepareHtmlScriptSource = (sourceBuffer) => {
72388
+ const frontmatterEndByte = findFrontmatterEnd(sourceBuffer);
72389
+ let maskedBuffer = frontmatterEndByte > 0 ? Buffer.from(sourceBuffer) : null;
72390
+ if (maskedBuffer !== null) maskByteRange(maskedBuffer, 0, frontmatterEndByte);
72391
+ const executableScriptBodies = [];
72392
+ let byteIndex = frontmatterEndByte;
72393
+ let templateDepth = 0;
72394
+ while (byteIndex < sourceBuffer.length) {
72395
+ if (sourceBuffer[byteIndex] !== TAG_OPEN_UTF8_BYTE) {
72396
+ byteIndex++;
72397
+ continue;
72398
+ }
72399
+ if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, COMMENT_OPEN)) {
72400
+ const commentEndByte = sourceBuffer.indexOf(COMMENT_CLOSE, byteIndex + 4);
72401
+ byteIndex = commentEndByte === -1 ? sourceBuffer.length : commentEndByte + 3;
72402
+ continue;
72403
+ }
72404
+ if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, TEMPLATE_CLOSE) && isTagBoundary(sourceBuffer[byteIndex + TEMPLATE_CLOSE.length])) {
72405
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + TEMPLATE_CLOSE.length);
72406
+ if (templateDepth > 0) templateDepth--;
72407
+ byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
72408
+ continue;
72409
+ }
72410
+ if (!matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, SCRIPT_OPEN) || !isTagBoundary(sourceBuffer[byteIndex + SCRIPT_OPEN.length])) {
72411
+ if (!isPotentialTagStart(sourceBuffer[byteIndex + 1])) {
72412
+ byteIndex++;
72413
+ continue;
72414
+ }
72415
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + 1);
72416
+ const tagName = readStartTagName(sourceBuffer, byteIndex);
72417
+ if (tagName === PLAINTEXT_TAG_NAME) break;
72418
+ if (tagName === TEMPLATE_TAG_NAME) templateDepth++;
72419
+ if (tagName !== null && RAW_TEXT_TAG_NAMES.has(tagName)) {
72420
+ const closeTagStartByte = findElementClose(sourceBuffer, tagEndByte + 1, tagName);
72421
+ if (closeTagStartByte === sourceBuffer.length) break;
72422
+ const closeTagEndByte = findTagEnd(sourceBuffer, closeTagStartByte + tagName.length + 2);
72423
+ byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
72424
+ continue;
72425
+ }
72426
+ byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
72427
+ continue;
72428
+ }
72429
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + SCRIPT_OPEN.length);
72430
+ if (tagEndByte === sourceBuffer.length) break;
72431
+ const bodyStartByte = tagEndByte + 1;
72432
+ const bodyEndByte = findElementClose(sourceBuffer, bodyStartByte, SCRIPT_TAG_NAME);
72433
+ const attributes = parseScriptAttributes(sourceBuffer, byteIndex + SCRIPT_OPEN.length, tagEndByte);
72434
+ if (attributes.hasSource || templateDepth > 0) {
72435
+ maskedBuffer ??= Buffer.from(sourceBuffer);
72436
+ maskByteRange(maskedBuffer, bodyStartByte, bodyEndByte);
72437
+ } else if (isExecutableScript(attributes)) executableScriptBodies.push(sourceBuffer.subarray(bodyStartByte, bodyEndByte));
72438
+ if (bodyEndByte === sourceBuffer.length) break;
72439
+ const closeTagEndByte = findTagEnd(sourceBuffer, bodyEndByte + SCRIPT_CLOSE.length);
72440
+ byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
72441
+ }
72442
+ return {
72443
+ executableScriptBodies,
72444
+ lintBuffer: maskedBuffer ?? sourceBuffer
72445
+ };
72446
+ };
72447
+ const prepareHtmlLintSources = (rootDirectory, temporaryDirectory, candidateFiles) => {
72448
+ const lintFiles = [];
72449
+ const sourcePathByLintPath = /* @__PURE__ */ new Map();
72450
+ const sizeByLintPath = /* @__PURE__ */ new Map();
72451
+ const htmlSourcesDirectory = Path.join(temporaryDirectory, "html-sources");
72452
+ let htmlFileIndex = 0;
72453
+ let hasThreeModuleImport = false;
72454
+ for (const candidateFile of candidateFiles) {
72455
+ if (!HTML_FILE_PATTERN.test(candidateFile)) {
72456
+ lintFiles.push(candidateFile);
72457
+ continue;
72458
+ }
72459
+ const absoluteSourcePath = Path.isAbsolute(candidateFile) ? candidateFile : Path.resolve(rootDirectory, candidateFile);
72460
+ const sourceBuffer = NFS.readFileSync(absoluteSourcePath);
72461
+ const { executableScriptBodies, lintBuffer } = prepareHtmlScriptSource(sourceBuffer);
72462
+ if (htmlFileIndex === 0) NFS.mkdirSync(htmlSourcesDirectory, { recursive: true });
72463
+ const lintPath = Path.join(htmlSourcesDirectory, `${htmlFileIndex}.astro`);
72464
+ NFS.writeFileSync(lintPath, lintBuffer);
72465
+ lintFiles.push(lintPath);
72466
+ sourcePathByLintPath.set(Path.resolve(lintPath), candidateFile);
72467
+ sizeByLintPath.set(lintPath, sourceBuffer.length);
72468
+ hasThreeModuleImport ||= executableScriptBodies.some((scriptBody) => containsThreeModuleImport(scriptBody.toString("utf8")));
72469
+ htmlFileIndex++;
72470
+ }
72471
+ return {
72472
+ lintFiles,
72473
+ sourcePathByLintPath,
72474
+ sizeByLintPath,
72475
+ hasThreeModuleImport
72476
+ };
72477
+ };
71810
72478
  /**
71811
72479
  * Atomically (re)writes the generated oxlintrc.json. Used twice in
71812
72480
  * the runner: once for the primary scan, once for the
@@ -71967,6 +72635,8 @@ const reactHooksJsPluginDropNote = (error) => {
71967
72635
  const runOxlint = async (options) => {
71968
72636
  const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
71969
72637
  const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
72638
+ const runtimeGlobals = Array.isArray(userConfig?.runtimeGlobals) ? userConfig.runtimeGlobals.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
72639
+ let unpluginAutoImportGlobalScopes = [];
71970
72640
  const severityControls = buildRuleSeverityControls(userConfig);
71971
72641
  validateRuleRegistration();
71972
72642
  resetManifestCaches();
@@ -71980,21 +72650,6 @@ const runOxlint = async (options) => {
71980
72650
  const pluginPath = resolvePluginPath();
71981
72651
  const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
71982
72652
  const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
71983
- const buildConfig = (overrides) => createOxlintConfig({
71984
- pluginPath,
71985
- project,
71986
- customRulesOnly,
71987
- extendsPaths: overrides.extendsPaths,
71988
- ignoredTags,
71989
- includedTags,
71990
- includeTagDefaults,
71991
- serverAuthFunctionNames,
71992
- severityControls,
71993
- userPlugins,
71994
- disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
71995
- ruleSelection: overrides.ruleSelection,
71996
- sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
71997
- });
71998
72653
  const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
71999
72654
  const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
72000
72655
  const configPath = Path.join(configDirectory, "oxlintrc.json");
@@ -72030,7 +72685,36 @@ const runOxlint = async (options) => {
72030
72685
  await yieldToEventLoop();
72031
72686
  const sizedScanFiles = includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null;
72032
72687
  const candidateFiles = includePaths !== void 0 ? includePaths : (sizedScanFiles ?? []).map((entry) => entry.path);
72688
+ unpluginAutoImportGlobalScopes = collectUnpluginAutoImportGlobalScopes({
72689
+ rootDirectory,
72690
+ candidateFiles
72691
+ });
72692
+ const preparedHtmlSources = prepareHtmlLintSources(rootDirectory, configDirectory, candidateFiles);
72693
+ const lintFiles = preparedHtmlSources.lintFiles;
72694
+ const hasHtmlFiles = preparedHtmlSources.sourcePathByLintPath.size > 0;
72695
+ const lintProject = !project.hasThree && preparedHtmlSources.hasThreeModuleImport ? {
72696
+ ...project,
72697
+ hasThree: true
72698
+ } : project;
72699
+ const buildConfig = (overrides) => createOxlintConfig({
72700
+ pluginPath,
72701
+ project: lintProject,
72702
+ customRulesOnly,
72703
+ extendsPaths: overrides.extendsPaths,
72704
+ ignoredTags,
72705
+ includedTags,
72706
+ includeTagDefaults,
72707
+ runtimeGlobals,
72708
+ unpluginAutoImportGlobalScopes,
72709
+ serverAuthFunctionNames,
72710
+ severityControls,
72711
+ userPlugins,
72712
+ disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
72713
+ ruleSelection: overrides.ruleSelection,
72714
+ sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
72715
+ });
72033
72716
  const sizeByFile = sizedScanFiles !== null && lintBatchOrdering === "cost" ? new Map(sizedScanFiles.map((entry) => [entry.path, entry.sizeBytes])) : null;
72717
+ if (sizeByFile !== null) for (const [lintPath, sizeBytes] of preparedHtmlSources.sizeByLintPath) sizeByFile.set(lintPath, sizeBytes);
72034
72718
  const buildFileBatches = (passBaseArgs, passFiles) => sizeByFile !== null ? planLintBatches({
72035
72719
  baseArgs: passBaseArgs,
72036
72720
  files: passFiles,
@@ -72059,7 +72743,8 @@ const runOxlint = async (options) => {
72059
72743
  fileBatches: passFileBatches,
72060
72744
  rootDirectory,
72061
72745
  nodeBinaryPath,
72062
- project,
72746
+ project: lintProject,
72747
+ sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
72063
72748
  onPartialFailure: reportPartialFailure,
72064
72749
  onAnalyzedFiles: (filePaths) => {
72065
72750
  analyzedFiles = filePaths;
@@ -72094,7 +72779,7 @@ const runOxlint = async (options) => {
72094
72779
  };
72095
72780
  }
72096
72781
  };
72097
- if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0) {
72782
+ if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0 && !hasHtmlFiles) {
72098
72783
  const rulesetHash = computeRulesetHash({
72099
72784
  config: buildConfig({
72100
72785
  extendsPaths: [],
@@ -72252,14 +72937,15 @@ const runOxlint = async (options) => {
72252
72937
  ]);
72253
72938
  }
72254
72939
  const baseArgs = makeBaseArgs(configPath);
72255
- const fileBatches = buildFileBatches(baseArgs, candidateFiles);
72940
+ const fileBatches = buildFileBatches(baseArgs, lintFiles);
72256
72941
  let analyzedFiles = [];
72257
72942
  const runBatches = () => spawnLintBatches({
72258
72943
  baseArgs,
72259
72944
  fileBatches,
72260
72945
  rootDirectory,
72261
72946
  nodeBinaryPath,
72262
- project,
72947
+ project: lintProject,
72948
+ sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
72263
72949
  onPartialFailure,
72264
72950
  onAnalyzedFiles: (filePaths) => {
72265
72951
  analyzedFiles = filePaths;
@@ -73835,7 +74521,8 @@ const SCANNABLE_EXTENSIONS = [
73835
74521
  ".js",
73836
74522
  ".jsx",
73837
74523
  ".mts",
73838
- ".mjs"
74524
+ ".mjs",
74525
+ ".html"
73839
74526
  ];
73840
74527
  const SILENT_LOGGER = {
73841
74528
  info: () => {},
@@ -75823,5 +76510,5 @@ const startLanguageServer = () => {
75823
76510
  };
75824
76511
  //#endregion
75825
76512
  export { startLanguageServer };
75826
- !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]="3e0d8192-41dd-5226-8de2-b76eaf077e6c")}catch(e){}}();
75827
- //# debugId=3e0d8192-41dd-5226-8de2-b76eaf077e6c
76513
+ !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]="c9dabb64-11c9-5783-a682-d985b8bc43fe")}catch(e){}}();
76514
+ //# debugId=c9dabb64-11c9-5783-a682-d985b8bc43fe