react-doctor 0.9.1-dev.54ba416 → 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}`)] : [
@@ -62338,10 +62366,10 @@ const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
62338
62366
  ]).find(isFile) ?? null;
62339
62367
  };
62340
62368
  const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json") || Path.basename(filePath) === ".babelrc" ? ts.parseJsonText(filePath, content) : ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
62341
- const getStaticPropertyName$1 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
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,24 +62413,24 @@ 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
- exportName: bindingElement.propertyName ? getStaticPropertyName$1(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
62433
+ exportName: bindingElement.propertyName ? getStaticPropertyName$2(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
62406
62434
  isNamespace: false
62407
62435
  };
62408
62436
  }
@@ -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;
@@ -62563,7 +62633,7 @@ const getReactCompilerFlagState = (expression, analysis) => {
62563
62633
  }
62564
62634
  if (!ts.isObjectLiteralExpression(unwrappedExpression)) return null;
62565
62635
  for (const property of [...unwrappedExpression.properties].reverse()) {
62566
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
62636
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
62567
62637
  if (ts.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
62568
62638
  if (ts.isSpreadAssignment(property)) {
62569
62639
  const spreadState = getReactCompilerFlagState(property.expression, analysis);
@@ -62589,8 +62659,8 @@ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedEx
62589
62659
  }
62590
62660
  if (!ts.isObjectLiteralExpression(resolvedExpression)) return null;
62591
62661
  for (const property of [...resolvedExpression.properties].reverse()) {
62592
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === propertyName) return property.initializer;
62593
- if (ts.isMethodDeclaration(property) && getStaticPropertyName$1(property.name) === propertyName) return property;
62662
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === propertyName) return property.initializer;
62663
+ if (ts.isMethodDeclaration(property) && getStaticPropertyName$2(property.name) === propertyName) return property;
62594
62664
  if (ts.isShorthandPropertyAssignment(property) && property.name.text === propertyName) return property.name;
62595
62665
  if (ts.isSpreadAssignment(property)) {
62596
62666
  const spreadProperty = getSelectedObjectProperty(property.expression, propertyName, analysis, visitedExpressions);
@@ -62621,7 +62691,7 @@ const configExpressionMayDefineProperty = (expression, propertyName, analysis) =
62621
62691
  return resolvedExpression.properties.some((property) => {
62622
62692
  if (ts.isSpreadAssignment(property)) return configExpressionMayDefineProperty(property.expression, propertyName, analysis);
62623
62693
  if (ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property) || ts.isMethodDeclaration(property) || ts.isGetAccessorDeclaration(property) || ts.isSetAccessorDeclaration(property)) {
62624
- const staticPropertyName = getStaticPropertyName$1(property.name);
62694
+ const staticPropertyName = getStaticPropertyName$2(property.name);
62625
62695
  return staticPropertyName === null || staticPropertyName === propertyName;
62626
62696
  }
62627
62697
  return false;
@@ -62640,7 +62710,7 @@ const getExportedConfigNodes = (sourceFile, exportName) => {
62640
62710
  continue;
62641
62711
  }
62642
62712
  if (ts.isExpressionStatement(statement) && isCommonJsConfigExportAssignment(statement.expression, sourceFile) && exportName !== "default" && ts.isObjectLiteralExpression(statement.expression.right)) for (const property of [...statement.expression.right.properties].reverse()) {
62643
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === exportName) {
62713
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === exportName) {
62644
62714
  exportedNodes.push(property.initializer);
62645
62715
  break;
62646
62716
  }
@@ -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;
@@ -62799,25 +62906,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62799
62906
  const reactCompilerFlagState = excludedPropertyNames?.has("reactCompiler") ? null : getReactCompilerFlagState(node, analysis);
62800
62907
  if (reactCompilerFlagState?.isEnabled) return true;
62801
62908
  for (const [propertyIndex, property] of node.properties.entries()) if (ts.isPropertyAssignment(property)) {
62802
- const propertyName = getStaticPropertyName$1(property.name);
62909
+ const propertyName = getStaticPropertyName$2(property.name);
62803
62910
  if (propertyName && excludedPropertyNames?.has(propertyName)) continue;
62804
62911
  if (propertyName === "reactCompiler") continue;
62805
- 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$1(laterProperty.name) === propertyName)) continue;
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)) {
62813
62924
  if (excludedPropertyNames?.has(property.name.text)) continue;
62814
62925
  if (property.name.text === "reactCompiler") continue;
62815
- if ((property.name.text === "plugins" || property.name.text === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, property.name.text, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$1(laterProperty.name) === property.name.text)) continue;
62926
+ if ((property.name.text === "plugins" || property.name.text === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, property.name.text, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === property.name.text)) continue;
62816
62927
  const propertyAllowsCompilerTransform = property.name.text === "plugins" || property.name.text === "presets";
62817
62928
  if (analyzeConfigNode(property.name, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
62818
62929
  } else if (ts.isSpreadAssignment(property)) {
62819
62930
  if (reactCompilerFlagState && getReactCompilerFlagState(property.expression, analysis) !== null) continue;
62820
- if (node.properties.slice(propertyIndex + 1).some((laterProperty) => (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && (getStaticPropertyName$1(laterProperty.name) === "plugins" || getStaticPropertyName$1(laterProperty.name) === "presets"))) continue;
62931
+ if (node.properties.slice(propertyIndex + 1).some((laterProperty) => (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && (getStaticPropertyName$2(laterProperty.name) === "plugins" || getStaticPropertyName$2(laterProperty.name) === "presets"))) continue;
62821
62932
  if (analyzeConfigNode(property.expression, analysis, allowCompilerTransform, false, excludedPropertyNames)) return true;
62822
62933
  }
62823
62934
  return false;
@@ -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);
@@ -66956,6 +67095,321 @@ const buildReactNativeDiagnostic = (input) => ({
66956
67095
  column: input.column ?? 0,
66957
67096
  category: input.category ?? "Correctness"
66958
67097
  });
67098
+ const ANDROID_APP_BUILD_FILE_NAMES = ["build.gradle", "build.gradle.kts"];
67099
+ const BUILD_TYPES_BLOCK_PATTERN = /\bbuildTypes\s*\{/g;
67100
+ const RELEASE_STRING_MARKER = "__RD_RELEASE__";
67101
+ const RELEASE_BLOCK_PATTERNS = [/\brelease\s*\{/g, /\b(?:getByName|named)\s*\(\s*(?:["']release["']|__RD_RELEASE__)\s*\)\s*\{/g];
67102
+ const MINIFY_ASSIGNMENT_PATTERN = /\b(?:isMinifyEnabled|minifyEnabled)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
67103
+ const SHRINK_RESOURCES_ASSIGNMENT_PATTERN = /\b(?:isShrinkResources|shrinkResources)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
67104
+ const stripGradleComments = (contents) => {
67105
+ let result = "";
67106
+ let index = 0;
67107
+ let quote = null;
67108
+ while (index < contents.length) {
67109
+ const character = contents[index];
67110
+ const nextCharacter = contents[index + 1];
67111
+ if (quote !== null) {
67112
+ result += character;
67113
+ if (character === "\\") {
67114
+ result += nextCharacter ?? "";
67115
+ index += 2;
67116
+ continue;
67117
+ }
67118
+ if (character === quote) quote = null;
67119
+ index += 1;
67120
+ continue;
67121
+ }
67122
+ if (character === "\"" || character === "'") {
67123
+ quote = character;
67124
+ result += character;
67125
+ index += 1;
67126
+ continue;
67127
+ }
67128
+ if (character === "/" && nextCharacter === "/") {
67129
+ while (index < contents.length && contents[index] !== "\n") {
67130
+ result += " ";
67131
+ index += 1;
67132
+ }
67133
+ continue;
67134
+ }
67135
+ if (character === "/" && nextCharacter === "*") {
67136
+ result += " ";
67137
+ index += 2;
67138
+ while (index < contents.length && !(contents[index] === "*" && contents[index + 1] === "/")) {
67139
+ result += contents[index] === "\n" ? "\n" : " ";
67140
+ index += 1;
67141
+ }
67142
+ if (index < contents.length) {
67143
+ result += " ";
67144
+ index += 2;
67145
+ }
67146
+ continue;
67147
+ }
67148
+ result += character;
67149
+ index += 1;
67150
+ }
67151
+ return result;
67152
+ };
67153
+ const maskGradleStrings = (contents) => {
67154
+ let result = "";
67155
+ let index = 0;
67156
+ let quote = null;
67157
+ while (index < contents.length) {
67158
+ const character = contents[index];
67159
+ if (quote === null) {
67160
+ if (character === "\"" || character === "'") {
67161
+ quote = character;
67162
+ result += " ";
67163
+ } else result += character;
67164
+ index += 1;
67165
+ continue;
67166
+ }
67167
+ if (character === "\\") {
67168
+ result += " ";
67169
+ index += 2;
67170
+ continue;
67171
+ }
67172
+ if (character === quote) quote = null;
67173
+ result += character === "\n" ? "\n" : " ";
67174
+ index += 1;
67175
+ }
67176
+ return result;
67177
+ };
67178
+ const findBlockContents = (contents, pattern) => {
67179
+ const blocks = [];
67180
+ pattern.lastIndex = 0;
67181
+ let match = pattern.exec(contents);
67182
+ while (match !== null) {
67183
+ const openingBraceIndex = pattern.lastIndex - 1;
67184
+ let depth = 1;
67185
+ let index = openingBraceIndex + 1;
67186
+ let quote = null;
67187
+ while (index < contents.length && depth > 0) {
67188
+ const character = contents[index];
67189
+ if (quote !== null) {
67190
+ if (character === "\\") {
67191
+ index += 2;
67192
+ continue;
67193
+ }
67194
+ if (character === quote) quote = null;
67195
+ } else if (character === "\"" || character === "'") quote = character;
67196
+ else if (character === "{") depth += 1;
67197
+ else if (character === "}") depth -= 1;
67198
+ index += 1;
67199
+ }
67200
+ if (depth === 0) blocks.push(contents.slice(openingBraceIndex + 1, index - 1));
67201
+ match = pattern.exec(contents);
67202
+ }
67203
+ return blocks;
67204
+ };
67205
+ const getFinalStaticBoolean = (contents, pattern) => {
67206
+ pattern.lastIndex = 0;
67207
+ let finalValue = null;
67208
+ let match = pattern.exec(contents);
67209
+ while (match !== null) {
67210
+ const staticValue = match[1]?.trim().replace(/\)$/, "").trim();
67211
+ if (staticValue === "true") finalValue = true;
67212
+ else if (staticValue === "false") finalValue = false;
67213
+ else finalValue = null;
67214
+ match = pattern.exec(contents);
67215
+ }
67216
+ return finalValue;
67217
+ };
67218
+ const getReleaseBlocks = (contents) => findBlockContents(contents, BUILD_TYPES_BLOCK_PATTERN).flatMap((buildTypesBlock) => RELEASE_BLOCK_PATTERNS.flatMap((pattern) => findBlockContents(buildTypesBlock, pattern)));
67219
+ const readAndroidReleaseShrinking = (rootDirectory) => {
67220
+ for (const buildFileName of ANDROID_APP_BUILD_FILE_NAMES) {
67221
+ const filePath = Path.posix.join("android", "app", buildFileName);
67222
+ const absoluteFilePath = Path.join(rootDirectory, filePath);
67223
+ if (!isFile(absoluteFilePath)) continue;
67224
+ let contents;
67225
+ try {
67226
+ contents = stripGradleComments(NFS.readFileSync(absoluteFilePath, "utf-8"));
67227
+ } catch {
67228
+ return null;
67229
+ }
67230
+ const releaseBlocks = getReleaseBlocks(maskGradleStrings(contents.replace(/(["'])release\1/g, RELEASE_STRING_MARKER)));
67231
+ const [releaseBlock] = releaseBlocks;
67232
+ if (releaseBlock === void 0 || releaseBlocks.length !== 1) return null;
67233
+ const hasDisabledMinification = getFinalStaticBoolean(releaseBlock, MINIFY_ASSIGNMENT_PATTERN) === false;
67234
+ const hasDisabledResourceShrinking = getFinalStaticBoolean(releaseBlock, SHRINK_RESOURCES_ASSIGNMENT_PATTERN) === false;
67235
+ if (!hasDisabledMinification && !hasDisabledResourceShrinking) return null;
67236
+ return {
67237
+ filePath,
67238
+ hasDisabledMinification,
67239
+ hasDisabledResourceShrinking
67240
+ };
67241
+ }
67242
+ return null;
67243
+ };
67244
+ const checkReactNativeAndroidReleaseShrinking = (rootDirectory) => {
67245
+ const releaseShrinking = readAndroidReleaseShrinking(rootDirectory);
67246
+ if (releaseShrinking === null) return [];
67247
+ const disabledFeatures = [releaseShrinking.hasDisabledMinification ? "code minification" : null, releaseShrinking.hasDisabledResourceShrinking ? "resource shrinking" : null].filter((feature) => feature !== null);
67248
+ return [buildReactNativeDiagnostic({
67249
+ filePath: releaseShrinking.filePath,
67250
+ rule: "rn-android-release-shrinking-disabled",
67251
+ category: "Performance",
67252
+ message: `The Android release build explicitly disables ${disabledFeatures.join(" and ")}, leaving unreachable code or resources in the shipped app.`,
67253
+ help: "Enable release code minification and resource shrinking, then test the optimized build and add keep rules for libraries that require them."
67254
+ })];
67255
+ };
67256
+ const getTypescriptScriptKind = (fileName) => {
67257
+ if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
67258
+ if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
67259
+ if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
67260
+ return ts.ScriptKind.JS;
67261
+ };
67262
+ const unwrapTypescriptExpression = (expression) => {
67263
+ let currentExpression = expression;
67264
+ while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
67265
+ return currentExpression;
67266
+ };
67267
+ const BABEL_CONFIG_FILE_NAMES$1 = [
67268
+ "babel.config.js",
67269
+ "babel.config.cjs",
67270
+ "babel.config.mjs",
67271
+ "babel.config.ts",
67272
+ "babel.config.cts",
67273
+ "babel.config.json",
67274
+ ".babelrc",
67275
+ ".babelrc.js",
67276
+ ".babelrc.cjs",
67277
+ ".babelrc.mjs",
67278
+ ".babelrc.cts",
67279
+ ".babelrc.json"
67280
+ ];
67281
+ const readUnknownPluginNames = (value) => {
67282
+ if (!Array.isArray(value)) return null;
67283
+ const pluginNames = [];
67284
+ for (const entry of value) {
67285
+ if (typeof entry === "string") {
67286
+ pluginNames.push(entry);
67287
+ continue;
67288
+ }
67289
+ if (Array.isArray(entry) && typeof entry[0] === "string") {
67290
+ pluginNames.push(entry[0]);
67291
+ continue;
67292
+ }
67293
+ return null;
67294
+ }
67295
+ return pluginNames;
67296
+ };
67297
+ const getStaticPropertyName$1 = (propertyName) => {
67298
+ if (ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName)) return propertyName.text;
67299
+ return null;
67300
+ };
67301
+ const getStaticPluginName = (expression) => {
67302
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
67303
+ if (ts.isStringLiteralLike(unwrappedExpression)) return unwrappedExpression.text;
67304
+ if (!ts.isArrayLiteralExpression(unwrappedExpression)) return null;
67305
+ const pluginExpression = unwrappedExpression.elements[0];
67306
+ return pluginExpression && ts.isStringLiteralLike(pluginExpression) ? pluginExpression.text : null;
67307
+ };
67308
+ const getPluginNamesFromObject = (objectExpression) => {
67309
+ if (objectExpression.properties.some((property) => ts.isSpreadAssignment(property))) return null;
67310
+ const pluginProperties = objectExpression.properties.filter((property) => ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === "plugins");
67311
+ if (pluginProperties.length !== 1) return pluginProperties.length === 0 ? [] : null;
67312
+ const pluginListExpression = unwrapTypescriptExpression(pluginProperties[0].initializer);
67313
+ if (!ts.isArrayLiteralExpression(pluginListExpression)) return null;
67314
+ const pluginNames = [];
67315
+ for (const element of pluginListExpression.elements) {
67316
+ if (ts.isSpreadElement(element)) return null;
67317
+ const pluginName = getStaticPluginName(element);
67318
+ if (pluginName === null) return null;
67319
+ pluginNames.push(pluginName);
67320
+ }
67321
+ return pluginNames;
67322
+ };
67323
+ const isModuleExports = (expression) => ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === "module" && expression.name.text === "exports" || ts.isElementAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === "module" && expression.argumentExpression !== void 0 && ts.isStringLiteralLike(expression.argumentExpression) && expression.argumentExpression.text === "exports";
67324
+ const getDirectExportedObject = (sourceFile) => {
67325
+ const exportedExpressions = [];
67326
+ for (const statement of sourceFile.statements) {
67327
+ if (ts.isExportAssignment(statement)) {
67328
+ exportedExpressions.push(statement.expression);
67329
+ continue;
67330
+ }
67331
+ if (ts.isExpressionStatement(statement) && ts.isBinaryExpression(statement.expression) && statement.expression.operatorToken.kind === ts.SyntaxKind.EqualsToken && isModuleExports(statement.expression.left)) exportedExpressions.push(statement.expression.right);
67332
+ }
67333
+ if (exportedExpressions.length !== 1) return null;
67334
+ const exportedExpression = unwrapTypescriptExpression(exportedExpressions[0]);
67335
+ return ts.isObjectLiteralExpression(exportedExpression) ? exportedExpression : null;
67336
+ };
67337
+ const parseConfigPluginNames = (filePath, contents) => {
67338
+ try {
67339
+ const parsedJson = JSON.parse(contents);
67340
+ return isPlainObject(parsedJson) ? readUnknownPluginNames(parsedJson.plugins) : null;
67341
+ } catch {
67342
+ if (ts.transpileModule(contents, {
67343
+ fileName: filePath,
67344
+ reportDiagnostics: true,
67345
+ compilerOptions: { allowJs: true }
67346
+ }).diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) return null;
67347
+ const exportedObject = getDirectExportedObject(ts.createSourceFile(filePath, contents, ts.ScriptTarget.Latest, true, getTypescriptScriptKind(filePath)));
67348
+ return exportedObject === null ? null : getPluginNamesFromObject(exportedObject);
67349
+ }
67350
+ };
67351
+ const readStaticBabelPluginNames = (rootDirectory) => {
67352
+ for (const fileName of BABEL_CONFIG_FILE_NAMES$1) {
67353
+ const absoluteFilePath = Path.join(rootDirectory, fileName);
67354
+ if (!isFile(absoluteFilePath)) continue;
67355
+ try {
67356
+ return {
67357
+ filePath: fileName,
67358
+ pluginNames: parseConfigPluginNames(fileName, NFS.readFileSync(absoluteFilePath, "utf-8"))
67359
+ };
67360
+ } catch {
67361
+ return {
67362
+ filePath: fileName,
67363
+ pluginNames: null
67364
+ };
67365
+ }
67366
+ }
67367
+ const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
67368
+ if (!isPlainObject(packageJson.babel)) return null;
67369
+ return {
67370
+ filePath: "package.json",
67371
+ pluginNames: readUnknownPluginNames(packageJson.babel.plugins)
67372
+ };
67373
+ };
67374
+ const REACT_COMPILER_PLUGIN_NAMES = new Set(["babel-plugin-react-compiler", "react-compiler"]);
67375
+ const REANIMATED_PLUGIN_NAME = "react-native-reanimated/plugin";
67376
+ const WORKLETS_PLUGIN_NAME = "react-native-worklets/plugin";
67377
+ const checkReactCompilerPluginOrder = (filePath, pluginNames) => {
67378
+ if (pluginNames.findIndex((pluginName) => REACT_COMPILER_PLUGIN_NAMES.has(pluginName)) <= 0) return [];
67379
+ return [buildReactNativeDiagnostic({
67380
+ filePath,
67381
+ rule: "rn-react-compiler-plugin-first",
67382
+ category: "Performance",
67383
+ message: "The React Compiler Babel plugin is not first, so an earlier transform can change component or hook code before the compiler analyzes it.",
67384
+ help: "Move `babel-plugin-react-compiler` to the first entry in the Babel `plugins` array."
67385
+ })];
67386
+ };
67387
+ const checkReanimatedPluginOrder = (project, filePath, pluginNames) => {
67388
+ const reanimatedMajorVersion = project.reanimatedVersion === null || project.reanimatedVersion === void 0 ? null : getLowestDependencyMajor(project.reanimatedVersion);
67389
+ if (reanimatedMajorVersion === null || reanimatedMajorVersion < 4) return [];
67390
+ const diagnostics = [];
67391
+ if (pluginNames.includes(REANIMATED_PLUGIN_NAME)) diagnostics.push(buildReactNativeDiagnostic({
67392
+ filePath,
67393
+ rule: "rn-reanimated-worklets-plugin-last",
67394
+ category: "Performance",
67395
+ message: "This Reanimated 4 project still uses `react-native-reanimated/plugin`, which was renamed to the Worklets Babel plugin.",
67396
+ help: "Replace it with `react-native-worklets/plugin` and keep that plugin last in the Babel `plugins` array."
67397
+ }));
67398
+ const workletsPluginIndex = pluginNames.lastIndexOf(WORKLETS_PLUGIN_NAME);
67399
+ if (workletsPluginIndex !== -1 && workletsPluginIndex !== pluginNames.length - 1) diagnostics.push(buildReactNativeDiagnostic({
67400
+ filePath,
67401
+ rule: "rn-reanimated-worklets-plugin-last",
67402
+ category: "Performance",
67403
+ message: "`react-native-worklets/plugin` is not last in the Babel `plugins` array, so later transforms can prevent worklets from being compiled correctly.",
67404
+ help: "Move `react-native-worklets/plugin` to the final entry in the Babel `plugins` array."
67405
+ }));
67406
+ return diagnostics;
67407
+ };
67408
+ const checkReactNativeBabelPluginOrder = (rootDirectory, project) => {
67409
+ const babelPlugins = readStaticBabelPluginNames(rootDirectory);
67410
+ if (babelPlugins === null || babelPlugins.pluginNames === null) return [];
67411
+ return [...checkReactCompilerPluginOrder(babelPlugins.filePath, babelPlugins.pluginNames), ...checkReanimatedPluginOrder(project, babelPlugins.filePath, babelPlugins.pluginNames)];
67412
+ };
66959
67413
  const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
66960
67414
  const isBuilderBobLibrary = (packageJson) => {
66961
67415
  const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
@@ -67032,7 +67486,12 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
67032
67486
  const isReactNativeProject = (project) => project.framework === "react-native" || project.framework === "expo" || project.hasReactNativeWorkspace || project.expoVersion !== null;
67033
67487
  const checkReactNativeProject = (rootDirectory, project) => {
67034
67488
  if (!isReactNativeProject(project)) return [];
67035
- return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
67489
+ return [
67490
+ ...checkReactNativeMetroBabelPreset(rootDirectory),
67491
+ ...checkReactNativeBabelPluginOrder(rootDirectory, project),
67492
+ ...checkReactNativeAndroidReleaseShrinking(rootDirectory),
67493
+ ...checkReactNativeLibraryDependencies(rootDirectory)
67494
+ ];
67036
67495
  };
67037
67496
  const RULE_KEY = "no-vulnerable-react-server-components";
67038
67497
  const REACT_RSC_ADVISORIES_BY_MINOR = {
@@ -67183,17 +67642,6 @@ const checkReactServerComponentsAdvisory = (scanDirectory, project) => {
67183
67642
  }
67184
67643
  return diagnostics;
67185
67644
  };
67186
- const getTypescriptScriptKind = (fileName) => {
67187
- if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
67188
- if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
67189
- if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
67190
- return ts.ScriptKind.JS;
67191
- };
67192
- const unwrapTypescriptExpression = (expression) => {
67193
- let currentExpression = expression;
67194
- while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
67195
- return currentExpression;
67196
- };
67197
67645
  const EMPTY_MOTION_EXPRESSION_EVIDENCE = {
67198
67646
  isAnimationFunction: false,
67199
67647
  isMotionComponent: false,
@@ -67749,7 +68197,11 @@ const buildCapabilities = (project) => {
67749
68197
  capabilities.add(project.framework);
67750
68198
  if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
67751
68199
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
67752
- if (project.expoVersion !== null) capabilities.add("expo");
68200
+ if (project.expoVersion !== null) {
68201
+ capabilities.add("expo");
68202
+ const expoSdkMajorVersion = getLowestDependencyMajor(project.expoVersion);
68203
+ if (expoSdkMajorVersion !== null && expoSdkMajorVersion >= 54) capabilities.add("expo:54");
68204
+ }
67753
68205
  if ((project.framework === "nextjs" || project.framework === "tanstack-start" || project.framework === "remix") && !project.isStaticExport) capabilities.add("server-actions");
67754
68206
  if (SSR_FRAMEWORKS.has(project.framework) || project.hasSsrDependency) capabilities.add("ssr");
67755
68207
  if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
@@ -67813,6 +68265,11 @@ const buildCapabilities = (project) => {
67813
68265
  if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
67814
68266
  if (project.isPreES2023Target) capabilities.add("pre-es2023");
67815
68267
  if (project.hasReactCompiler) capabilities.add("react-compiler");
68268
+ if (project.reanimatedVersion !== void 0 && project.reanimatedVersion !== null) {
68269
+ capabilities.add("reanimated");
68270
+ const reanimatedMajorVersion = getLowestDependencyMajor(project.reanimatedVersion);
68271
+ if (reanimatedMajorVersion !== null && reanimatedMajorVersion >= 4) capabilities.add("reanimated:4");
68272
+ }
67816
68273
  if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
67817
68274
  if (project.styledComponentsVersion) {
67818
68275
  capabilities.add("styled-components");
@@ -69710,7 +70167,11 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
69710
70167
  const ROOT_DIRECTORY_PLACEHOLDER = "<root>";
69711
70168
  const normalizeConfigForHash = (config) => {
69712
70169
  const clone = JSON.parse(JSON.stringify(config));
69713
- 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
+ }
69714
70175
  if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
69715
70176
  return clone;
69716
70177
  };
@@ -69869,13 +70330,14 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
69869
70330
  }
69870
70331
  return enabled;
69871
70332
  };
69872
- 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 }) => {
69873
70334
  const hasIncludedTags = includedTags.size > 0;
69874
70335
  const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
69875
70336
  const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
69876
70337
  const jsPlugins = [];
69877
70338
  if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
69878
70339
  const capabilities = getCapabilities(project);
70340
+ const settingsRootDirectory = resolveSettingsRootDirectory(project.rootDirectory);
69879
70341
  const enabledReactDoctorRules = {};
69880
70342
  for (const registryEntry of REACT_DOCTOR_RULES) {
69881
70343
  const rule = reactDoctorPlugin.rules[registryEntry.id];
@@ -69921,8 +70383,16 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
69921
70383
  jsPlugins: [...jsPlugins, pluginPath],
69922
70384
  settings: { "react-doctor": {
69923
70385
  framework: project.framework,
69924
- rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
70386
+ rootDirectory: settingsRootDirectory,
69925
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
+ } : {},
69926
70396
  ...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
69927
70397
  ...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
69928
70398
  } },
@@ -69933,6 +70403,245 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
69933
70403
  }
69934
70404
  };
69935
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
+ };
69936
70645
  const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
69937
70646
  const decodeFileDiagnostics = (raw) => {
69938
70647
  if (!Array.isArray(raw)) return null;
@@ -70255,6 +70964,12 @@ const appendReanimatedSharedValueHint = (help, rule, project) => {
70255
70964
  if (!help) return REANIMATED_SHARED_VALUE_HINT;
70256
70965
  return `${help}\n\n${REANIMATED_SHARED_VALUE_HINT}`;
70257
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
+ };
70258
70973
  const REDACTED_PLACEHOLDER = "<redacted>";
70259
70974
  const KEEP_PREFIX = `$1${REDACTED_PLACEHOLDER}`;
70260
70975
  const KNOWN_SECRET_RULES = [
@@ -70970,7 +71685,7 @@ const resolveMatchByOccurrence = (rule, category) => OCCURRENCE_MATCHED_CATEGORI
70970
71685
  * with empty text still carry a useful jump target, so they're kept
70971
71686
  * with a neutral message.
70972
71687
  */
70973
- const buildRelatedLocations = (labels, filePath) => {
71688
+ const buildRelatedLocations = (labels, filePath, sourceBuffer) => {
70974
71689
  if (labels.length <= 1) return [];
70975
71690
  const related = [];
70976
71691
  for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
@@ -70978,8 +71693,8 @@ const buildRelatedLocations = (labels, filePath) => {
70978
71693
  if (!label?.span) continue;
70979
71694
  related.push({
70980
71695
  filePath,
70981
- line: label.span.line ?? 0,
70982
- 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),
70983
71698
  offset: label.span.offset,
70984
71699
  length: label.span.length,
70985
71700
  message: label.label ?? ""
@@ -70999,7 +71714,7 @@ const isOxlintOutput = (value) => isRecord(value) && Array.isArray(value.diagnos
70999
71714
  * to the first `{`. Raises `OxlintOutputUnparseable` when the
71000
71715
  * stdout isn't valid JSON or doesn't carry a `diagnostics` array.
71001
71716
  */
71002
- const parseOxlintOutput = (stdout, project, rootDirectory) => {
71717
+ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath) => {
71003
71718
  if (!stdout) return [];
71004
71719
  const jsonStart = stdout.indexOf("{");
71005
71720
  const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
@@ -71016,8 +71731,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71016
71731
  const sourceBufferCache = /* @__PURE__ */ new Map();
71017
71732
  const sourceLinesCache = /* @__PURE__ */ new Map();
71018
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;
71019
71736
  const readSourceBuffer = (filename) => {
71020
- const absolutePath = resolveAbsolutePath(filename);
71737
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71021
71738
  const cached = sourceBufferCache.get(absolutePath);
71022
71739
  if (cached !== void 0) return cached;
71023
71740
  let sourceBuffer;
@@ -71030,7 +71747,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71030
71747
  return sourceBuffer;
71031
71748
  };
71032
71749
  const readSourceLines = (filename) => {
71033
- const absolutePath = resolveAbsolutePath(filename);
71750
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71034
71751
  const cached = sourceLinesCache.get(absolutePath);
71035
71752
  if (cached !== void 0) return cached;
71036
71753
  const sourceBuffer = readSourceBuffer(filename);
@@ -71039,27 +71756,30 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71039
71756
  return sourceLines;
71040
71757
  };
71041
71758
  const isMinifiedDiagnosticFile = (filename) => {
71042
- const absolutePath = resolveAbsolutePath(filename);
71759
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71043
71760
  const cached = minifiedFileCache.get(absolutePath);
71044
71761
  if (cached !== void 0) return cached;
71045
71762
  const minified = isMinifiedSource(absolutePath);
71046
71763
  minifiedFileCache.set(absolutePath, minified);
71047
71764
  return minified;
71048
71765
  };
71049
- 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) => {
71050
71767
  const { plugin, rule } = parseRuleCode(diagnostic.code);
71051
71768
  const primaryLabel = diagnostic.labels[0];
71052
71769
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
71053
- const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
71770
+ const mappedSourceFilename = resolveMappedSourceFilename(diagnostic.filename);
71771
+ const normalizedFilePath = (mappedSourceFilename ?? diagnostic.filename).replaceAll("\\", "/");
71054
71772
  const primarySpan = primaryLabel?.span;
71055
71773
  const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
71056
- const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
71774
+ const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath, mappedSourceFilename === void 0 ? null : sourceBuffer);
71057
71775
  const category = resolveDiagnosticCategory(plugin, rule);
71058
71776
  const matchByOccurrence = resolveMatchByOccurrence(rule, category);
71059
71777
  const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
71060
- 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;
71061
71781
  const primaryLine = sourceLines?.[primaryLineIndex];
71062
- const primaryColumnIndex = primarySpan ? primarySpan.column - 1 : -1;
71782
+ const primaryColumnIndex = primarySpan ? primaryColumnNumber - 1 : -1;
71063
71783
  const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
71064
71784
  const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
71065
71785
  const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
@@ -71072,8 +71792,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71072
71792
  message: cleaned.message,
71073
71793
  help: cleaned.help,
71074
71794
  url: diagnostic.url,
71075
- line: primarySpan?.line ?? 0,
71076
- column: primarySpan?.column ?? 0,
71795
+ line: primaryLineNumber,
71796
+ column: primaryColumnNumber,
71077
71797
  ...primarySpan ? {
71078
71798
  offset: primarySpan.offset,
71079
71799
  length: primarySpan.length,
@@ -71261,7 +71981,11 @@ const isParallelismRelatedSpawnError = (error) => {
71261
71981
  * loop with a slimmer config in that case.
71262
71982
  */
71263
71983
  const spawnLintBatches = async (input) => {
71264
- 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
+ };
71265
71989
  const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
71266
71990
  let rescueDeadlineEpochMs;
71267
71991
  const isPastDeadline = () => deadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(deadlineEpochMs) === 0 || rescueDeadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(rescueDeadlineEpochMs) === 0;
@@ -71281,7 +72005,7 @@ const spawnLintBatches = async (input) => {
71281
72005
  }
71282
72006
  const batchArgs = [...baseArgs, ...batch];
71283
72007
  try {
71284
- 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);
71285
72009
  } catch (error) {
71286
72010
  if (!isSplittableReactDoctorError(error)) throw error;
71287
72011
  if (isPastDeadline()) {
@@ -71387,10 +72111,12 @@ const spawnLintBatches = async (input) => {
71387
72111
  onPartialFailure(buildMessage(`${skippedFiles.slice(0, 3).join(", ")}${skippedFiles.length > 3 ? `, +${skippedFiles.length - 3} more` : ""}`));
71388
72112
  };
71389
72113
  const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
71390
- reportSkippedFiles(droppedFiles, (fileListPreview) => `${droppedFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
71391
- 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})`);
71392
72118
  const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
71393
- 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());
71394
72120
  return dedupeDiagnostics(diagnostics);
71395
72121
  };
71396
72122
  let didValidate = false;
@@ -71489,6 +72215,266 @@ const planLintBatches = ({ baseArgs, files, sizeByFile }) => {
71489
72215
  }
71490
72216
  return batches.filter((batch) => batch.fileIndexes.length > 0).map((batch) => batch.fileIndexes.sort((leftIndex, rightIndex) => leftIndex - rightIndex).map((fileIndex) => files[fileIndex]));
71491
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
+ };
71492
72478
  /**
71493
72479
  * Atomically (re)writes the generated oxlintrc.json. Used twice in
71494
72480
  * the runner: once for the primary scan, once for the
@@ -71649,6 +72635,8 @@ const reactHooksJsPluginDropNote = (error) => {
71649
72635
  const runOxlint = async (options) => {
71650
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;
71651
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 = [];
71652
72640
  const severityControls = buildRuleSeverityControls(userConfig);
71653
72641
  validateRuleRegistration();
71654
72642
  resetManifestCaches();
@@ -71662,21 +72650,6 @@ const runOxlint = async (options) => {
71662
72650
  const pluginPath = resolvePluginPath();
71663
72651
  const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
71664
72652
  const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
71665
- const buildConfig = (overrides) => createOxlintConfig({
71666
- pluginPath,
71667
- project,
71668
- customRulesOnly,
71669
- extendsPaths: overrides.extendsPaths,
71670
- ignoredTags,
71671
- includedTags,
71672
- includeTagDefaults,
71673
- serverAuthFunctionNames,
71674
- severityControls,
71675
- userPlugins,
71676
- disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
71677
- ruleSelection: overrides.ruleSelection,
71678
- sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
71679
- });
71680
72653
  const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
71681
72654
  const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
71682
72655
  const configPath = Path.join(configDirectory, "oxlintrc.json");
@@ -71712,7 +72685,36 @@ const runOxlint = async (options) => {
71712
72685
  await yieldToEventLoop();
71713
72686
  const sizedScanFiles = includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null;
71714
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
+ });
71715
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);
71716
72718
  const buildFileBatches = (passBaseArgs, passFiles) => sizeByFile !== null ? planLintBatches({
71717
72719
  baseArgs: passBaseArgs,
71718
72720
  files: passFiles,
@@ -71741,7 +72743,8 @@ const runOxlint = async (options) => {
71741
72743
  fileBatches: passFileBatches,
71742
72744
  rootDirectory,
71743
72745
  nodeBinaryPath,
71744
- project,
72746
+ project: lintProject,
72747
+ sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
71745
72748
  onPartialFailure: reportPartialFailure,
71746
72749
  onAnalyzedFiles: (filePaths) => {
71747
72750
  analyzedFiles = filePaths;
@@ -71776,7 +72779,7 @@ const runOxlint = async (options) => {
71776
72779
  };
71777
72780
  }
71778
72781
  };
71779
- 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) {
71780
72783
  const rulesetHash = computeRulesetHash({
71781
72784
  config: buildConfig({
71782
72785
  extendsPaths: [],
@@ -71934,14 +72937,15 @@ const runOxlint = async (options) => {
71934
72937
  ]);
71935
72938
  }
71936
72939
  const baseArgs = makeBaseArgs(configPath);
71937
- const fileBatches = buildFileBatches(baseArgs, candidateFiles);
72940
+ const fileBatches = buildFileBatches(baseArgs, lintFiles);
71938
72941
  let analyzedFiles = [];
71939
72942
  const runBatches = () => spawnLintBatches({
71940
72943
  baseArgs,
71941
72944
  fileBatches,
71942
72945
  rootDirectory,
71943
72946
  nodeBinaryPath,
71944
- project,
72947
+ project: lintProject,
72948
+ sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
71945
72949
  onPartialFailure,
71946
72950
  onAnalyzedFiles: (filePaths) => {
71947
72951
  analyzedFiles = filePaths;
@@ -73517,7 +74521,8 @@ const SCANNABLE_EXTENSIONS = [
73517
74521
  ".js",
73518
74522
  ".jsx",
73519
74523
  ".mts",
73520
- ".mjs"
74524
+ ".mjs",
74525
+ ".html"
73521
74526
  ];
73522
74527
  const SILENT_LOGGER = {
73523
74528
  info: () => {},
@@ -75505,5 +76510,5 @@ const startLanguageServer = () => {
75505
76510
  };
75506
76511
  //#endregion
75507
76512
  export { startLanguageServer };
75508
- !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]="aeb8bc8c-7094-5b26-bb18-e269e2d4318a")}catch(e){}}();
75509
- //# debugId=aeb8bc8c-7094-5b26-bb18-e269e2d4318a
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