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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eb93b210-c190-581c-8fe2-f1e1c70e0bab")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="afe9afbe-4d17-5f2a-8b4f-9b49703c42be")}catch(e){}}();
3
3
  import { i as __toESM$1, r as __require, t as __commonJSMin$1 } from "./chunk-ChKA3wi6.js";
4
4
  import { createRequire } from "node:module";
5
5
  import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
@@ -11,6 +11,7 @@ import * as Path from "node:path";
11
11
  import path from "node:path";
12
12
  import * as NodeChildProcess from "node:child_process";
13
13
  import { execFileSync, spawn, spawnSync } from "node:child_process";
14
+ import { ResolverFactory } from "oxc-resolver";
14
15
  import ts from "typescript";
15
16
  import * as OS from "node:os";
16
17
  import os from "node:os";
@@ -61448,7 +61449,8 @@ var AmbiguousProjectError = class extends Error {
61448
61449
  }
61449
61450
  };
61450
61451
  const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
61451
- const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
61452
+ const HTML_FILE_PATTERN = /\.html$/i;
61453
+ const SOURCE_FILE_PATTERN = /\.(?:tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
61452
61454
  const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
61453
61455
  const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
61454
61456
  const MINIFIED_SNIFF_BYTES = 65536;
@@ -62042,7 +62044,7 @@ const findMonorepoRoot = (startDirectory) => {
62042
62044
  */
62043
62045
  const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
62044
62046
  const TSCONFIG_FILENAME = "tsconfig.json";
62045
- const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || Path.isAbsolute(extendsValue);
62047
+ const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
62046
62048
  const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
62047
62049
  const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62048
62050
  const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
@@ -62059,7 +62061,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62059
62061
  return null;
62060
62062
  };
62061
62063
  const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
62062
- if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(Path.resolve(fromConfigDirectory, extendsValue));
62064
+ if (isLocalModuleSpecifier(extendsValue)) {
62065
+ const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
62066
+ if (isFile(resolvedPath)) return resolvedPath;
62067
+ const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
62068
+ return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
62069
+ }
62063
62070
  return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
62064
62071
  };
62065
62072
  const normalizeCompilerOptions = (compilerOptions) => {
@@ -62253,6 +62260,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
62253
62260
  ".cts",
62254
62261
  ".json"
62255
62262
  ];
62263
+ const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
62264
+ conditionNames: [
62265
+ "import",
62266
+ "require",
62267
+ "node",
62268
+ "default"
62269
+ ],
62270
+ extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
62271
+ });
62256
62272
  const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
62257
62273
  const hasCompilerPackage = (packageJson, compilerPackages) => {
62258
62274
  const allDependencies = {
@@ -62276,6 +62292,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
62276
62292
  return false;
62277
62293
  };
62278
62294
  const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
62295
+ if (!isLocalModuleSpecifier(moduleSpecifier)) {
62296
+ try {
62297
+ const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
62298
+ if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
62299
+ } catch {}
62300
+ try {
62301
+ const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
62302
+ return isFile(resolvedPath) ? resolvedPath : null;
62303
+ } catch {
62304
+ return null;
62305
+ }
62306
+ }
62279
62307
  const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
62280
62308
  const extension = Path.extname(unresolvedPath);
62281
62309
  return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
@@ -62285,10 +62313,10 @@ const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
62285
62313
  ]).find(isFile) ?? null;
62286
62314
  };
62287
62315
  const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json") || Path.basename(filePath) === ".babelrc" ? ts.parseJsonText(filePath, content) : ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
62288
- const getStaticPropertyName$1 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
62316
+ const getStaticPropertyName$2 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
62289
62317
  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");
62290
62318
  const hasExportModifier = (node) => ts.canHaveModifiers(node) && Boolean(ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
62291
- const getRequireModuleSpecifier = (expression) => {
62319
+ const getRequireModuleSpecifier$1 = (expression) => {
62292
62320
  if (!ts.isCallExpression(expression) || !ts.isIdentifier(expression.expression) || expression.expression.text !== "require" || expression.arguments.length !== 1) return null;
62293
62321
  const moduleSpecifier = expression.arguments[0];
62294
62322
  return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
@@ -62301,7 +62329,7 @@ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statemen
62301
62329
  const namedBindings = importClause?.namedBindings;
62302
62330
  return namedBindings ? ts.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
62303
62331
  }
62304
- if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === bindingName);
62332
+ if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
62305
62333
  return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === bindingName;
62306
62334
  });
62307
62335
  const getImportBinding = (sourceFile, bindingName) => {
@@ -62332,24 +62360,24 @@ const getImportBinding = (sourceFile, bindingName) => {
62332
62360
  for (const declaration of statement.declarationList.declarations) {
62333
62361
  if (!declaration.initializer) continue;
62334
62362
  if (ts.isIdentifier(declaration.name) && declaration.name.text === bindingName) {
62335
- const directModuleSpecifier = getRequireModuleSpecifier(declaration.initializer);
62363
+ const directModuleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
62336
62364
  if (directModuleSpecifier) return {
62337
62365
  moduleSpecifier: directModuleSpecifier,
62338
62366
  exportName: "default",
62339
62367
  isNamespace: true
62340
62368
  };
62341
- if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier(declaration.initializer.expression) !== null) return {
62342
- moduleSpecifier: getRequireModuleSpecifier(declaration.initializer.expression) ?? "",
62369
+ if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier$1(declaration.initializer.expression) !== null) return {
62370
+ moduleSpecifier: getRequireModuleSpecifier$1(declaration.initializer.expression) ?? "",
62343
62371
  exportName: declaration.initializer.name.text,
62344
62372
  isNamespace: false
62345
62373
  };
62346
62374
  }
62347
62375
  if (!ts.isObjectBindingPattern(declaration.name)) continue;
62348
62376
  const bindingElement = declaration.name.elements.find((element) => ts.isIdentifier(element.name) && element.name.text === bindingName);
62349
- const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
62377
+ const moduleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
62350
62378
  if (bindingElement && moduleSpecifier) return {
62351
62379
  moduleSpecifier,
62352
- exportName: bindingElement.propertyName ? getStaticPropertyName$1(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
62380
+ exportName: bindingElement.propertyName ? getStaticPropertyName$2(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
62353
62381
  isNamespace: false
62354
62382
  };
62355
62383
  }
@@ -62402,6 +62430,48 @@ const getScopedConfigBinding = (identifier) => {
62402
62430
  };
62403
62431
  };
62404
62432
  const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
62433
+ const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
62434
+ const isConstantVariableInitializer = (node) => ts.isExpression(node) && ts.isVariableDeclaration(node.parent) && ts.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & ts.NodeFlags.Const);
62435
+ const isNodeCreateRequireCall = (node, analysis) => {
62436
+ if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
62437
+ if (!ts.isCallExpression(node)) return false;
62438
+ const target = node.expression;
62439
+ if (ts.isIdentifier(target)) {
62440
+ if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
62441
+ const importBinding = getImportBinding(analysis.sourceFile, target.text);
62442
+ return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
62443
+ }
62444
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return false;
62445
+ if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "createRequire") return false;
62446
+ const createRequireReceiver = target.expression;
62447
+ if (ts.isCallExpression(createRequireReceiver)) {
62448
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(createRequireReceiver);
62449
+ if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !ts.isIdentifier(createRequireReceiver.expression)) return false;
62450
+ const requireIdentifier = createRequireReceiver.expression;
62451
+ return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
62452
+ }
62453
+ if (!ts.isIdentifier(createRequireReceiver)) return false;
62454
+ if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
62455
+ const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
62456
+ return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
62457
+ };
62458
+ const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
62459
+ const [moduleSpecifierNode] = callExpression.arguments;
62460
+ if (!moduleSpecifierNode || !ts.isStringLiteralLike(moduleSpecifierNode)) return null;
62461
+ const target = callExpression.expression;
62462
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
62463
+ if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "resolve") return null;
62464
+ if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
62465
+ if (!ts.isIdentifier(target.expression)) return null;
62466
+ const resolverIdentifier = target.expression;
62467
+ if (analysis.localBindings.has(resolverIdentifier.text)) return null;
62468
+ const scopedBinding = getScopedConfigBinding(resolverIdentifier);
62469
+ const topLevelBinding = scopedBinding.wasFound ? null : getTopLevelBinding(analysis.sourceFile, resolverIdentifier.text);
62470
+ const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : topLevelBinding;
62471
+ if (resolverInitializer === null && !scopedBinding.wasFound && resolverIdentifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, resolverIdentifier.text) && getImportBinding(analysis.sourceFile, resolverIdentifier.text) === null) return moduleSpecifierNode.text;
62472
+ if (!resolverInitializer || !isConstantVariableInitializer(resolverInitializer) || !isNodeCreateRequireCall(resolverInitializer, analysis)) return null;
62473
+ return moduleSpecifierNode.text;
62474
+ };
62405
62475
  const getAssignedPropertyInitializer = (identifier, propertyName) => {
62406
62476
  let bindingScope = null;
62407
62477
  let currentNode = identifier;
@@ -62510,7 +62580,7 @@ const getReactCompilerFlagState = (expression, analysis) => {
62510
62580
  }
62511
62581
  if (!ts.isObjectLiteralExpression(unwrappedExpression)) return null;
62512
62582
  for (const property of [...unwrappedExpression.properties].reverse()) {
62513
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
62583
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
62514
62584
  if (ts.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
62515
62585
  if (ts.isSpreadAssignment(property)) {
62516
62586
  const spreadState = getReactCompilerFlagState(property.expression, analysis);
@@ -62536,8 +62606,8 @@ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedEx
62536
62606
  }
62537
62607
  if (!ts.isObjectLiteralExpression(resolvedExpression)) return null;
62538
62608
  for (const property of [...resolvedExpression.properties].reverse()) {
62539
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === propertyName) return property.initializer;
62540
- if (ts.isMethodDeclaration(property) && getStaticPropertyName$1(property.name) === propertyName) return property;
62609
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === propertyName) return property.initializer;
62610
+ if (ts.isMethodDeclaration(property) && getStaticPropertyName$2(property.name) === propertyName) return property;
62541
62611
  if (ts.isShorthandPropertyAssignment(property) && property.name.text === propertyName) return property.name;
62542
62612
  if (ts.isSpreadAssignment(property)) {
62543
62613
  const spreadProperty = getSelectedObjectProperty(property.expression, propertyName, analysis, visitedExpressions);
@@ -62568,7 +62638,7 @@ const configExpressionMayDefineProperty = (expression, propertyName, analysis) =
62568
62638
  return resolvedExpression.properties.some((property) => {
62569
62639
  if (ts.isSpreadAssignment(property)) return configExpressionMayDefineProperty(property.expression, propertyName, analysis);
62570
62640
  if (ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property) || ts.isMethodDeclaration(property) || ts.isGetAccessorDeclaration(property) || ts.isSetAccessorDeclaration(property)) {
62571
- const staticPropertyName = getStaticPropertyName$1(property.name);
62641
+ const staticPropertyName = getStaticPropertyName$2(property.name);
62572
62642
  return staticPropertyName === null || staticPropertyName === propertyName;
62573
62643
  }
62574
62644
  return false;
@@ -62587,7 +62657,7 @@ const getExportedConfigNodes = (sourceFile, exportName) => {
62587
62657
  continue;
62588
62658
  }
62589
62659
  if (ts.isExpressionStatement(statement) && isCommonJsConfigExportAssignment(statement.expression, sourceFile) && exportName !== "default" && ts.isObjectLiteralExpression(statement.expression.right)) for (const property of [...statement.expression.right.properties].reverse()) {
62590
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === exportName) {
62660
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === exportName) {
62591
62661
  exportedNodes.push(property.initializer);
62592
62662
  break;
62593
62663
  }
@@ -62685,6 +62755,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
62685
62755
  visitReturns(functionNode.body);
62686
62756
  return hasCompiler;
62687
62757
  };
62758
+ const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
62759
+ const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
62760
+ if (!importedFilePath) return null;
62761
+ return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList);
62762
+ };
62688
62763
  const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
62689
62764
  const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
62690
62765
  if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
@@ -62705,30 +62780,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
62705
62780
  const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
62706
62781
  if (importBinding) {
62707
62782
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62708
- if (!importBinding.moduleSpecifier.startsWith(".")) return false;
62709
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62710
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62783
+ return Boolean(analyzeImportedConfig({
62784
+ analysis,
62785
+ moduleSpecifier: importBinding.moduleSpecifier,
62786
+ exportName: importBinding.exportName,
62787
+ allowCompilerTransform
62788
+ }));
62711
62789
  }
62712
62790
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
62713
62791
  return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
62714
62792
  };
62715
62793
  const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
62716
62794
  const target = callExpression.expression;
62795
+ const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
62796
+ if (callableRequiredModuleSpecifier !== null) {
62797
+ if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62798
+ if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
62799
+ const hasCompilerTransform = analyzeImportedConfig({
62800
+ analysis,
62801
+ moduleSpecifier: callableRequiredModuleSpecifier,
62802
+ exportName: "default",
62803
+ allowCompilerTransform,
62804
+ argumentsList: callExpression.arguments
62805
+ });
62806
+ if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62807
+ return null;
62808
+ }
62717
62809
  if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
62718
62810
  const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
62719
62811
  if (propertyName === null) return null;
62720
- const requiredModuleSpecifier = getRequireModuleSpecifier(target.expression);
62812
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
62721
62813
  if (requiredModuleSpecifier !== null) {
62722
- if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62723
- if (!requiredModuleSpecifier.startsWith(".")) return null;
62724
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62725
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62814
+ 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;
62815
+ if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
62816
+ const hasCompilerTransform = analyzeImportedConfig({
62817
+ analysis,
62818
+ moduleSpecifier: requiredModuleSpecifier,
62819
+ exportName: propertyName,
62820
+ allowCompilerTransform,
62821
+ argumentsList: callExpression.arguments
62822
+ });
62823
+ if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62824
+ return null;
62726
62825
  }
62727
62826
  if (!ts.isIdentifier(target.expression)) return null;
62728
- const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
62729
- if (importBinding?.isNamespace && importBinding.moduleSpecifier.startsWith(".")) {
62730
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62731
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62827
+ const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
62828
+ if (importBinding?.isNamespace) {
62829
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
62830
+ const hasCompilerTransform = analyzeImportedConfig({
62831
+ analysis,
62832
+ moduleSpecifier: importBinding.moduleSpecifier,
62833
+ exportName: propertyName,
62834
+ allowCompilerTransform,
62835
+ argumentsList: callExpression.arguments
62836
+ });
62837
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62838
+ return null;
62732
62839
  }
62733
62840
  const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
62734
62841
  if (selectedProperty === null) return null;
@@ -62746,25 +62853,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62746
62853
  const reactCompilerFlagState = excludedPropertyNames?.has("reactCompiler") ? null : getReactCompilerFlagState(node, analysis);
62747
62854
  if (reactCompilerFlagState?.isEnabled) return true;
62748
62855
  for (const [propertyIndex, property] of node.properties.entries()) if (ts.isPropertyAssignment(property)) {
62749
- const propertyName = getStaticPropertyName$1(property.name);
62856
+ const propertyName = getStaticPropertyName$2(property.name);
62750
62857
  if (propertyName && excludedPropertyNames?.has(propertyName)) continue;
62751
62858
  if (propertyName === "reactCompiler") continue;
62752
- 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;
62859
+ 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;
62753
62860
  const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
62754
- if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer) && property.initializer.text.startsWith(".")) {
62755
- const extendedFilePath = resolveImportedConfigFile(analysis.filePath, property.initializer.text);
62756
- if (extendedFilePath && analyzeConfigModuleExport(extendedFilePath, "default", false, analysis.importDepth + 1, analysis.visitedModules)) return true;
62861
+ if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
62862
+ if (analyzeImportedConfig({
62863
+ analysis,
62864
+ moduleSpecifier: property.initializer.text,
62865
+ exportName: "default",
62866
+ allowCompilerTransform: false
62867
+ })) return true;
62757
62868
  }
62758
62869
  if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
62759
62870
  } else if (ts.isShorthandPropertyAssignment(property)) {
62760
62871
  if (excludedPropertyNames?.has(property.name.text)) continue;
62761
62872
  if (property.name.text === "reactCompiler") continue;
62762
- 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;
62873
+ 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;
62763
62874
  const propertyAllowsCompilerTransform = property.name.text === "plugins" || property.name.text === "presets";
62764
62875
  if (analyzeConfigNode(property.name, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
62765
62876
  } else if (ts.isSpreadAssignment(property)) {
62766
62877
  if (reactCompilerFlagState && getReactCompilerFlagState(property.expression, analysis) !== null) continue;
62767
- 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;
62878
+ 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;
62768
62879
  if (analyzeConfigNode(property.expression, analysis, allowCompilerTransform, false, excludedPropertyNames)) return true;
62769
62880
  }
62770
62881
  return false;
@@ -62777,23 +62888,36 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62777
62888
  });
62778
62889
  }
62779
62890
  if (ts.isCallExpression(node)) {
62891
+ const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
62892
+ if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
62780
62893
  const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
62781
62894
  if (callTargetResult !== null) return callTargetResult;
62782
- const directModuleSpecifier = getRequireModuleSpecifier(node);
62895
+ const directModuleSpecifier = getRequireModuleSpecifier$1(node);
62783
62896
  const isRequireShadowed = analysis.localBindings.has("require") || ts.isIdentifier(node.expression) && getScopedConfigBinding(node.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require");
62784
62897
  if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
62785
62898
  if (directModuleSpecifier && !isRequireShadowed) {
62786
62899
  if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
62787
- if (directModuleSpecifier.startsWith(".")) {
62788
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, directModuleSpecifier);
62789
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, "default", allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62790
- }
62900
+ if (analyzeImportedConfig({
62901
+ analysis,
62902
+ moduleSpecifier: directModuleSpecifier,
62903
+ exportName: "default",
62904
+ allowCompilerTransform
62905
+ })) return true;
62791
62906
  }
62792
62907
  if (ts.isIdentifier(node.expression)) {
62793
- const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62794
- if (importBinding?.moduleSpecifier.startsWith(".")) {
62795
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62796
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, node.arguments));
62908
+ if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
62909
+ const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62910
+ if (importBinding) {
62911
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62912
+ const hasCompilerTransform = analyzeImportedConfig({
62913
+ analysis,
62914
+ moduleSpecifier: importBinding.moduleSpecifier,
62915
+ exportName: importBinding.exportName,
62916
+ allowCompilerTransform,
62917
+ argumentsList: node.arguments
62918
+ });
62919
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62920
+ }
62797
62921
  }
62798
62922
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
62799
62923
  if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
@@ -62801,27 +62925,31 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62801
62925
  return analyzeConfigNode(node.expression, analysis, allowCompilerTransform) || node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false));
62802
62926
  }
62803
62927
  if (ts.isPropertyAccessExpression(node)) {
62804
- const requiredModuleSpecifier = getRequireModuleSpecifier(node.expression);
62928
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
62805
62929
  if (requiredModuleSpecifier) {
62806
- if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62807
- if (requiredModuleSpecifier.startsWith(".")) {
62808
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62809
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62810
- }
62930
+ 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;
62931
+ if (analyzeImportedConfig({
62932
+ analysis,
62933
+ moduleSpecifier: requiredModuleSpecifier,
62934
+ exportName: node.name.text,
62935
+ allowCompilerTransform
62936
+ })) return true;
62811
62937
  return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
62812
62938
  }
62813
62939
  if (ts.isIdentifier(node.expression)) {
62814
- if (analysis.localBindings.has(node.expression.text)) {
62815
- const localInitializer = analysis.localBindings.get(node.expression.text);
62816
- return Boolean(localInitializer && analyzeConfigNode(localInitializer, analysis, allowCompilerTransform));
62940
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
62941
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
62942
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
62817
62943
  }
62818
62944
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62819
62945
  if (importBinding?.isNamespace) {
62820
62946
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
62821
- if (importBinding.moduleSpecifier.startsWith(".")) {
62822
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62823
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62824
- }
62947
+ if (analyzeImportedConfig({
62948
+ analysis,
62949
+ moduleSpecifier: importBinding.moduleSpecifier,
62950
+ exportName: node.name.text,
62951
+ allowCompilerTransform
62952
+ })) return true;
62825
62953
  return false;
62826
62954
  }
62827
62955
  const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
@@ -62832,13 +62960,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62832
62960
  }
62833
62961
  if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
62834
62962
  if (ts.isIdentifier(node.expression)) {
62963
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
62964
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
62965
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
62966
+ }
62835
62967
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62836
62968
  if (importBinding?.isNamespace) {
62837
62969
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
62838
- if (importBinding.moduleSpecifier.startsWith(".")) {
62839
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62840
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.argumentExpression.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62841
- }
62970
+ return Boolean(analyzeImportedConfig({
62971
+ analysis,
62972
+ moduleSpecifier: importBinding.moduleSpecifier,
62973
+ exportName: node.argumentExpression.text,
62974
+ allowCompilerTransform
62975
+ }));
62842
62976
  }
62843
62977
  const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
62844
62978
  if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
@@ -62876,14 +63010,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62876
63010
  };
62877
63011
  const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
62878
63012
  const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
62879
- const hasCompilerInPackageJsonConfig = (packageJson) => isPlainObject(packageJson.babel) && analyzeConfigSourceFileExport(ts.parseJsonText("package.json", JSON.stringify(packageJson.babel)), "package.json#babel", "default", false, 0, /* @__PURE__ */ new Set());
62880
- const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
63013
+ const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
63014
+ if (!isPlainObject(packageJson.babel)) return false;
63015
+ const packageJsonPath = Path.join(directory, "package.json");
63016
+ return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
63017
+ };
63018
+ const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
62881
63019
  const hasCompilerConfigurationInAncestors = (directory) => {
62882
63020
  if (isProjectBoundary(directory)) return false;
62883
63021
  let ancestorDirectory = Path.dirname(directory);
62884
63022
  while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
62885
63023
  const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
62886
- if (hasCompilerInPackageJsonConfig(isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {}) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
63024
+ const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
63025
+ if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
62887
63026
  if (isProjectBoundary(ancestorDirectory)) return false;
62888
63027
  ancestorDirectory = Path.dirname(ancestorDirectory);
62889
63028
  }
@@ -66138,7 +66277,7 @@ const warn = (message) => {
66138
66277
  runSync(warn$1(message));
66139
66278
  };
66140
66279
  const CONFIG_BASENAME = "doctor.config";
66141
- const CONFIG_EXTENSIONS = [
66280
+ const CONFIG_EXTENSIONS$1 = [
66142
66281
  "ts",
66143
66282
  "mts",
66144
66283
  "cts",
@@ -66242,7 +66381,7 @@ const loadLegacyConfig = (directory) => {
66242
66381
  };
66243
66382
  const loadConfigFromDirectory = async (directory) => {
66244
66383
  let sawBrokenConfigFile = false;
66245
- for (const extension of CONFIG_EXTENSIONS) {
66384
+ for (const extension of CONFIG_EXTENSIONS$1) {
66246
66385
  const filePath = Path.join(directory, `${CONFIG_BASENAME}.${extension}`);
66247
66386
  if (!isFile(filePath)) continue;
66248
66387
  const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
@@ -66977,6 +67116,321 @@ const buildReactNativeDiagnostic = (input) => ({
66977
67116
  column: input.column ?? 0,
66978
67117
  category: input.category ?? "Correctness"
66979
67118
  });
67119
+ const ANDROID_APP_BUILD_FILE_NAMES = ["build.gradle", "build.gradle.kts"];
67120
+ const BUILD_TYPES_BLOCK_PATTERN = /\bbuildTypes\s*\{/g;
67121
+ const RELEASE_STRING_MARKER = "__RD_RELEASE__";
67122
+ const RELEASE_BLOCK_PATTERNS = [/\brelease\s*\{/g, /\b(?:getByName|named)\s*\(\s*(?:["']release["']|__RD_RELEASE__)\s*\)\s*\{/g];
67123
+ const MINIFY_ASSIGNMENT_PATTERN = /\b(?:isMinifyEnabled|minifyEnabled)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
67124
+ const SHRINK_RESOURCES_ASSIGNMENT_PATTERN = /\b(?:isShrinkResources|shrinkResources)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
67125
+ const stripGradleComments = (contents) => {
67126
+ let result = "";
67127
+ let index = 0;
67128
+ let quote = null;
67129
+ while (index < contents.length) {
67130
+ const character = contents[index];
67131
+ const nextCharacter = contents[index + 1];
67132
+ if (quote !== null) {
67133
+ result += character;
67134
+ if (character === "\\") {
67135
+ result += nextCharacter ?? "";
67136
+ index += 2;
67137
+ continue;
67138
+ }
67139
+ if (character === quote) quote = null;
67140
+ index += 1;
67141
+ continue;
67142
+ }
67143
+ if (character === "\"" || character === "'") {
67144
+ quote = character;
67145
+ result += character;
67146
+ index += 1;
67147
+ continue;
67148
+ }
67149
+ if (character === "/" && nextCharacter === "/") {
67150
+ while (index < contents.length && contents[index] !== "\n") {
67151
+ result += " ";
67152
+ index += 1;
67153
+ }
67154
+ continue;
67155
+ }
67156
+ if (character === "/" && nextCharacter === "*") {
67157
+ result += " ";
67158
+ index += 2;
67159
+ while (index < contents.length && !(contents[index] === "*" && contents[index + 1] === "/")) {
67160
+ result += contents[index] === "\n" ? "\n" : " ";
67161
+ index += 1;
67162
+ }
67163
+ if (index < contents.length) {
67164
+ result += " ";
67165
+ index += 2;
67166
+ }
67167
+ continue;
67168
+ }
67169
+ result += character;
67170
+ index += 1;
67171
+ }
67172
+ return result;
67173
+ };
67174
+ const maskGradleStrings = (contents) => {
67175
+ let result = "";
67176
+ let index = 0;
67177
+ let quote = null;
67178
+ while (index < contents.length) {
67179
+ const character = contents[index];
67180
+ if (quote === null) {
67181
+ if (character === "\"" || character === "'") {
67182
+ quote = character;
67183
+ result += " ";
67184
+ } else result += character;
67185
+ index += 1;
67186
+ continue;
67187
+ }
67188
+ if (character === "\\") {
67189
+ result += " ";
67190
+ index += 2;
67191
+ continue;
67192
+ }
67193
+ if (character === quote) quote = null;
67194
+ result += character === "\n" ? "\n" : " ";
67195
+ index += 1;
67196
+ }
67197
+ return result;
67198
+ };
67199
+ const findBlockContents = (contents, pattern) => {
67200
+ const blocks = [];
67201
+ pattern.lastIndex = 0;
67202
+ let match = pattern.exec(contents);
67203
+ while (match !== null) {
67204
+ const openingBraceIndex = pattern.lastIndex - 1;
67205
+ let depth = 1;
67206
+ let index = openingBraceIndex + 1;
67207
+ let quote = null;
67208
+ while (index < contents.length && depth > 0) {
67209
+ const character = contents[index];
67210
+ if (quote !== null) {
67211
+ if (character === "\\") {
67212
+ index += 2;
67213
+ continue;
67214
+ }
67215
+ if (character === quote) quote = null;
67216
+ } else if (character === "\"" || character === "'") quote = character;
67217
+ else if (character === "{") depth += 1;
67218
+ else if (character === "}") depth -= 1;
67219
+ index += 1;
67220
+ }
67221
+ if (depth === 0) blocks.push(contents.slice(openingBraceIndex + 1, index - 1));
67222
+ match = pattern.exec(contents);
67223
+ }
67224
+ return blocks;
67225
+ };
67226
+ const getFinalStaticBoolean = (contents, pattern) => {
67227
+ pattern.lastIndex = 0;
67228
+ let finalValue = null;
67229
+ let match = pattern.exec(contents);
67230
+ while (match !== null) {
67231
+ const staticValue = match[1]?.trim().replace(/\)$/, "").trim();
67232
+ if (staticValue === "true") finalValue = true;
67233
+ else if (staticValue === "false") finalValue = false;
67234
+ else finalValue = null;
67235
+ match = pattern.exec(contents);
67236
+ }
67237
+ return finalValue;
67238
+ };
67239
+ const getReleaseBlocks = (contents) => findBlockContents(contents, BUILD_TYPES_BLOCK_PATTERN).flatMap((buildTypesBlock) => RELEASE_BLOCK_PATTERNS.flatMap((pattern) => findBlockContents(buildTypesBlock, pattern)));
67240
+ const readAndroidReleaseShrinking = (rootDirectory) => {
67241
+ for (const buildFileName of ANDROID_APP_BUILD_FILE_NAMES) {
67242
+ const filePath = Path.posix.join("android", "app", buildFileName);
67243
+ const absoluteFilePath = Path.join(rootDirectory, filePath);
67244
+ if (!isFile(absoluteFilePath)) continue;
67245
+ let contents;
67246
+ try {
67247
+ contents = stripGradleComments(NFS.readFileSync(absoluteFilePath, "utf-8"));
67248
+ } catch {
67249
+ return null;
67250
+ }
67251
+ const releaseBlocks = getReleaseBlocks(maskGradleStrings(contents.replace(/(["'])release\1/g, RELEASE_STRING_MARKER)));
67252
+ const [releaseBlock] = releaseBlocks;
67253
+ if (releaseBlock === void 0 || releaseBlocks.length !== 1) return null;
67254
+ const hasDisabledMinification = getFinalStaticBoolean(releaseBlock, MINIFY_ASSIGNMENT_PATTERN) === false;
67255
+ const hasDisabledResourceShrinking = getFinalStaticBoolean(releaseBlock, SHRINK_RESOURCES_ASSIGNMENT_PATTERN) === false;
67256
+ if (!hasDisabledMinification && !hasDisabledResourceShrinking) return null;
67257
+ return {
67258
+ filePath,
67259
+ hasDisabledMinification,
67260
+ hasDisabledResourceShrinking
67261
+ };
67262
+ }
67263
+ return null;
67264
+ };
67265
+ const checkReactNativeAndroidReleaseShrinking = (rootDirectory) => {
67266
+ const releaseShrinking = readAndroidReleaseShrinking(rootDirectory);
67267
+ if (releaseShrinking === null) return [];
67268
+ const disabledFeatures = [releaseShrinking.hasDisabledMinification ? "code minification" : null, releaseShrinking.hasDisabledResourceShrinking ? "resource shrinking" : null].filter((feature) => feature !== null);
67269
+ return [buildReactNativeDiagnostic({
67270
+ filePath: releaseShrinking.filePath,
67271
+ rule: "rn-android-release-shrinking-disabled",
67272
+ category: "Performance",
67273
+ message: `The Android release build explicitly disables ${disabledFeatures.join(" and ")}, leaving unreachable code or resources in the shipped app.`,
67274
+ help: "Enable release code minification and resource shrinking, then test the optimized build and add keep rules for libraries that require them."
67275
+ })];
67276
+ };
67277
+ const getTypescriptScriptKind = (fileName) => {
67278
+ if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
67279
+ if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
67280
+ if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
67281
+ return ts.ScriptKind.JS;
67282
+ };
67283
+ const unwrapTypescriptExpression = (expression) => {
67284
+ let currentExpression = expression;
67285
+ while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
67286
+ return currentExpression;
67287
+ };
67288
+ const BABEL_CONFIG_FILE_NAMES$1 = [
67289
+ "babel.config.js",
67290
+ "babel.config.cjs",
67291
+ "babel.config.mjs",
67292
+ "babel.config.ts",
67293
+ "babel.config.cts",
67294
+ "babel.config.json",
67295
+ ".babelrc",
67296
+ ".babelrc.js",
67297
+ ".babelrc.cjs",
67298
+ ".babelrc.mjs",
67299
+ ".babelrc.cts",
67300
+ ".babelrc.json"
67301
+ ];
67302
+ const readUnknownPluginNames = (value) => {
67303
+ if (!Array.isArray(value)) return null;
67304
+ const pluginNames = [];
67305
+ for (const entry of value) {
67306
+ if (typeof entry === "string") {
67307
+ pluginNames.push(entry);
67308
+ continue;
67309
+ }
67310
+ if (Array.isArray(entry) && typeof entry[0] === "string") {
67311
+ pluginNames.push(entry[0]);
67312
+ continue;
67313
+ }
67314
+ return null;
67315
+ }
67316
+ return pluginNames;
67317
+ };
67318
+ const getStaticPropertyName$1 = (propertyName) => {
67319
+ if (ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName)) return propertyName.text;
67320
+ return null;
67321
+ };
67322
+ const getStaticPluginName = (expression) => {
67323
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
67324
+ if (ts.isStringLiteralLike(unwrappedExpression)) return unwrappedExpression.text;
67325
+ if (!ts.isArrayLiteralExpression(unwrappedExpression)) return null;
67326
+ const pluginExpression = unwrappedExpression.elements[0];
67327
+ return pluginExpression && ts.isStringLiteralLike(pluginExpression) ? pluginExpression.text : null;
67328
+ };
67329
+ const getPluginNamesFromObject = (objectExpression) => {
67330
+ if (objectExpression.properties.some((property) => ts.isSpreadAssignment(property))) return null;
67331
+ const pluginProperties = objectExpression.properties.filter((property) => ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === "plugins");
67332
+ if (pluginProperties.length !== 1) return pluginProperties.length === 0 ? [] : null;
67333
+ const pluginListExpression = unwrapTypescriptExpression(pluginProperties[0].initializer);
67334
+ if (!ts.isArrayLiteralExpression(pluginListExpression)) return null;
67335
+ const pluginNames = [];
67336
+ for (const element of pluginListExpression.elements) {
67337
+ if (ts.isSpreadElement(element)) return null;
67338
+ const pluginName = getStaticPluginName(element);
67339
+ if (pluginName === null) return null;
67340
+ pluginNames.push(pluginName);
67341
+ }
67342
+ return pluginNames;
67343
+ };
67344
+ 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";
67345
+ const getDirectExportedObject = (sourceFile) => {
67346
+ const exportedExpressions = [];
67347
+ for (const statement of sourceFile.statements) {
67348
+ if (ts.isExportAssignment(statement)) {
67349
+ exportedExpressions.push(statement.expression);
67350
+ continue;
67351
+ }
67352
+ if (ts.isExpressionStatement(statement) && ts.isBinaryExpression(statement.expression) && statement.expression.operatorToken.kind === ts.SyntaxKind.EqualsToken && isModuleExports(statement.expression.left)) exportedExpressions.push(statement.expression.right);
67353
+ }
67354
+ if (exportedExpressions.length !== 1) return null;
67355
+ const exportedExpression = unwrapTypescriptExpression(exportedExpressions[0]);
67356
+ return ts.isObjectLiteralExpression(exportedExpression) ? exportedExpression : null;
67357
+ };
67358
+ const parseConfigPluginNames = (filePath, contents) => {
67359
+ try {
67360
+ const parsedJson = JSON.parse(contents);
67361
+ return isPlainObject(parsedJson) ? readUnknownPluginNames(parsedJson.plugins) : null;
67362
+ } catch {
67363
+ if (ts.transpileModule(contents, {
67364
+ fileName: filePath,
67365
+ reportDiagnostics: true,
67366
+ compilerOptions: { allowJs: true }
67367
+ }).diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) return null;
67368
+ const exportedObject = getDirectExportedObject(ts.createSourceFile(filePath, contents, ts.ScriptTarget.Latest, true, getTypescriptScriptKind(filePath)));
67369
+ return exportedObject === null ? null : getPluginNamesFromObject(exportedObject);
67370
+ }
67371
+ };
67372
+ const readStaticBabelPluginNames = (rootDirectory) => {
67373
+ for (const fileName of BABEL_CONFIG_FILE_NAMES$1) {
67374
+ const absoluteFilePath = Path.join(rootDirectory, fileName);
67375
+ if (!isFile(absoluteFilePath)) continue;
67376
+ try {
67377
+ return {
67378
+ filePath: fileName,
67379
+ pluginNames: parseConfigPluginNames(fileName, NFS.readFileSync(absoluteFilePath, "utf-8"))
67380
+ };
67381
+ } catch {
67382
+ return {
67383
+ filePath: fileName,
67384
+ pluginNames: null
67385
+ };
67386
+ }
67387
+ }
67388
+ const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
67389
+ if (!isPlainObject(packageJson.babel)) return null;
67390
+ return {
67391
+ filePath: "package.json",
67392
+ pluginNames: readUnknownPluginNames(packageJson.babel.plugins)
67393
+ };
67394
+ };
67395
+ const REACT_COMPILER_PLUGIN_NAMES = new Set(["babel-plugin-react-compiler", "react-compiler"]);
67396
+ const REANIMATED_PLUGIN_NAME = "react-native-reanimated/plugin";
67397
+ const WORKLETS_PLUGIN_NAME = "react-native-worklets/plugin";
67398
+ const checkReactCompilerPluginOrder = (filePath, pluginNames) => {
67399
+ if (pluginNames.findIndex((pluginName) => REACT_COMPILER_PLUGIN_NAMES.has(pluginName)) <= 0) return [];
67400
+ return [buildReactNativeDiagnostic({
67401
+ filePath,
67402
+ rule: "rn-react-compiler-plugin-first",
67403
+ category: "Performance",
67404
+ message: "The React Compiler Babel plugin is not first, so an earlier transform can change component or hook code before the compiler analyzes it.",
67405
+ help: "Move `babel-plugin-react-compiler` to the first entry in the Babel `plugins` array."
67406
+ })];
67407
+ };
67408
+ const checkReanimatedPluginOrder = (project, filePath, pluginNames) => {
67409
+ const reanimatedMajorVersion = project.reanimatedVersion === null || project.reanimatedVersion === void 0 ? null : getLowestDependencyMajor(project.reanimatedVersion);
67410
+ if (reanimatedMajorVersion === null || reanimatedMajorVersion < 4) return [];
67411
+ const diagnostics = [];
67412
+ if (pluginNames.includes(REANIMATED_PLUGIN_NAME)) diagnostics.push(buildReactNativeDiagnostic({
67413
+ filePath,
67414
+ rule: "rn-reanimated-worklets-plugin-last",
67415
+ category: "Performance",
67416
+ message: "This Reanimated 4 project still uses `react-native-reanimated/plugin`, which was renamed to the Worklets Babel plugin.",
67417
+ help: "Replace it with `react-native-worklets/plugin` and keep that plugin last in the Babel `plugins` array."
67418
+ }));
67419
+ const workletsPluginIndex = pluginNames.lastIndexOf(WORKLETS_PLUGIN_NAME);
67420
+ if (workletsPluginIndex !== -1 && workletsPluginIndex !== pluginNames.length - 1) diagnostics.push(buildReactNativeDiagnostic({
67421
+ filePath,
67422
+ rule: "rn-reanimated-worklets-plugin-last",
67423
+ category: "Performance",
67424
+ message: "`react-native-worklets/plugin` is not last in the Babel `plugins` array, so later transforms can prevent worklets from being compiled correctly.",
67425
+ help: "Move `react-native-worklets/plugin` to the final entry in the Babel `plugins` array."
67426
+ }));
67427
+ return diagnostics;
67428
+ };
67429
+ const checkReactNativeBabelPluginOrder = (rootDirectory, project) => {
67430
+ const babelPlugins = readStaticBabelPluginNames(rootDirectory);
67431
+ if (babelPlugins === null || babelPlugins.pluginNames === null) return [];
67432
+ return [...checkReactCompilerPluginOrder(babelPlugins.filePath, babelPlugins.pluginNames), ...checkReanimatedPluginOrder(project, babelPlugins.filePath, babelPlugins.pluginNames)];
67433
+ };
66980
67434
  const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
66981
67435
  const isBuilderBobLibrary = (packageJson) => {
66982
67436
  const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
@@ -67053,7 +67507,12 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
67053
67507
  const isReactNativeProject = (project) => project.framework === "react-native" || project.framework === "expo" || project.hasReactNativeWorkspace || project.expoVersion !== null;
67054
67508
  const checkReactNativeProject = (rootDirectory, project) => {
67055
67509
  if (!isReactNativeProject(project)) return [];
67056
- return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
67510
+ return [
67511
+ ...checkReactNativeMetroBabelPreset(rootDirectory),
67512
+ ...checkReactNativeBabelPluginOrder(rootDirectory, project),
67513
+ ...checkReactNativeAndroidReleaseShrinking(rootDirectory),
67514
+ ...checkReactNativeLibraryDependencies(rootDirectory)
67515
+ ];
67057
67516
  };
67058
67517
  const RULE_KEY = "no-vulnerable-react-server-components";
67059
67518
  const REACT_RSC_ADVISORIES_BY_MINOR = {
@@ -67204,17 +67663,6 @@ const checkReactServerComponentsAdvisory = (scanDirectory, project) => {
67204
67663
  }
67205
67664
  return diagnostics;
67206
67665
  };
67207
- const getTypescriptScriptKind = (fileName) => {
67208
- if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
67209
- if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
67210
- if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
67211
- return ts.ScriptKind.JS;
67212
- };
67213
- const unwrapTypescriptExpression = (expression) => {
67214
- let currentExpression = expression;
67215
- while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
67216
- return currentExpression;
67217
- };
67218
67666
  const EMPTY_MOTION_EXPRESSION_EVIDENCE = {
67219
67667
  isAnimationFunction: false,
67220
67668
  isMotionComponent: false,
@@ -67770,7 +68218,11 @@ const buildCapabilities = (project) => {
67770
68218
  capabilities.add(project.framework);
67771
68219
  if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
67772
68220
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
67773
- if (project.expoVersion !== null) capabilities.add("expo");
68221
+ if (project.expoVersion !== null) {
68222
+ capabilities.add("expo");
68223
+ const expoSdkMajorVersion = getLowestDependencyMajor(project.expoVersion);
68224
+ if (expoSdkMajorVersion !== null && expoSdkMajorVersion >= 54) capabilities.add("expo:54");
68225
+ }
67774
68226
  if ((project.framework === "nextjs" || project.framework === "tanstack-start" || project.framework === "remix") && !project.isStaticExport) capabilities.add("server-actions");
67775
68227
  if (SSR_FRAMEWORKS.has(project.framework) || project.hasSsrDependency) capabilities.add("ssr");
67776
68228
  if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
@@ -67834,6 +68286,11 @@ const buildCapabilities = (project) => {
67834
68286
  if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
67835
68287
  if (project.isPreES2023Target) capabilities.add("pre-es2023");
67836
68288
  if (project.hasReactCompiler) capabilities.add("react-compiler");
68289
+ if (project.reanimatedVersion !== void 0 && project.reanimatedVersion !== null) {
68290
+ capabilities.add("reanimated");
68291
+ const reanimatedMajorVersion = getLowestDependencyMajor(project.reanimatedVersion);
68292
+ if (reanimatedMajorVersion !== null && reanimatedMajorVersion >= 4) capabilities.add("reanimated:4");
68293
+ }
67837
68294
  if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
67838
68295
  if (project.styledComponentsVersion) {
67839
68296
  capabilities.add("styled-components");
@@ -69731,7 +70188,11 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
69731
70188
  const ROOT_DIRECTORY_PLACEHOLDER = "<root>";
69732
70189
  const normalizeConfigForHash = (config) => {
69733
70190
  const clone = JSON.parse(JSON.stringify(config));
69734
- if (clone?.settings?.["react-doctor"]) clone.settings["react-doctor"].rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
70191
+ if (clone?.settings?.["react-doctor"]) {
70192
+ const reactDoctorSettings = clone.settings["react-doctor"];
70193
+ reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
70194
+ if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
70195
+ }
69735
70196
  if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
69736
70197
  return clone;
69737
70198
  };
@@ -69890,13 +70351,14 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
69890
70351
  }
69891
70352
  return enabled;
69892
70353
  };
69893
- const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
70354
+ 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 }) => {
69894
70355
  const hasIncludedTags = includedTags.size > 0;
69895
70356
  const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
69896
70357
  const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
69897
70358
  const jsPlugins = [];
69898
70359
  if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
69899
70360
  const capabilities = getCapabilities(project);
70361
+ const settingsRootDirectory = resolveSettingsRootDirectory(project.rootDirectory);
69900
70362
  const enabledReactDoctorRules = {};
69901
70363
  for (const registryEntry of REACT_DOCTOR_RULES) {
69902
70364
  const rule = reactDoctorPlugin.rules[registryEntry.id];
@@ -69942,8 +70404,16 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
69942
70404
  jsPlugins: [...jsPlugins, pluginPath],
69943
70405
  settings: { "react-doctor": {
69944
70406
  framework: project.framework,
69945
- rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
70407
+ rootDirectory: settingsRootDirectory,
69946
70408
  capabilities: [...capabilities].sort(),
70409
+ ...runtimeGlobals && runtimeGlobals.length > 0 ? { runtimeGlobals: [...runtimeGlobals] } : {},
70410
+ ...unpluginAutoImportGlobalScopes && unpluginAutoImportGlobalScopes.length > 0 ? {
70411
+ unpluginAutoImportRootDirectories: [...new Set([settingsRootDirectory, project.rootDirectory])],
70412
+ unpluginAutoImportGlobalScopes: unpluginAutoImportGlobalScopes.map((scope) => ({
70413
+ directory: scope.directory,
70414
+ names: [...scope.names]
70415
+ }))
70416
+ } : {},
69947
70417
  ...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
69948
70418
  ...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
69949
70419
  } },
@@ -69954,6 +70424,245 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
69954
70424
  }
69955
70425
  };
69956
70426
  };
70427
+ const AUTO_IMPORT_ADAPTER_PATTERN = /^unplugin-auto-import\/(?:astro|esbuild|rollup|rolldown|rspack|vite|webpack)$/;
70428
+ const CONFIG_BASENAMES = [
70429
+ "astro.config",
70430
+ "esbuild.config",
70431
+ "rollup.config",
70432
+ "rolldown.config",
70433
+ "rspack.config",
70434
+ "vite.config",
70435
+ "webpack.config"
70436
+ ];
70437
+ const CONFIG_EXTENSIONS = [
70438
+ ".cjs",
70439
+ ".cts",
70440
+ ".js",
70441
+ ".mjs",
70442
+ ".mts",
70443
+ ".ts"
70444
+ ];
70445
+ const CONFIG_FILENAMES = new Set(CONFIG_BASENAMES.flatMap((basename) => CONFIG_EXTENSIONS.map((extension) => `${basename}${extension}`)));
70446
+ const DEFAULT_ESLINT_GLOBALS_PATH = ".eslintrc-auto-import.json";
70447
+ const SUPPORTED_GLOBAL_VALUES = new Set([
70448
+ true,
70449
+ false,
70450
+ "readable",
70451
+ "readonly",
70452
+ "writable",
70453
+ "writeable"
70454
+ ]);
70455
+ const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
70456
+ if (ts.isSpreadAssignment(property)) return false;
70457
+ const name = ts.isComputedPropertyName(property.name) ? unwrapTypescriptExpression(property.name.expression) : property.name;
70458
+ return (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) && name.text === propertyName;
70459
+ }) ?? null;
70460
+ const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !ts.isSpreadAssignment(property) && ts.isComputedPropertyName(property.name) && !ts.isStringLiteralLike(unwrapTypescriptExpression(property.name.expression)));
70461
+ const getStaticPropertyAssignment = (objectExpression, propertyName) => {
70462
+ const property = getStaticProperty(objectExpression, propertyName);
70463
+ return property && ts.isPropertyAssignment(property) ? property : null;
70464
+ };
70465
+ const getRequireModuleSpecifier = (expression) => {
70466
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
70467
+ if (ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "default") return getRequireModuleSpecifier(unwrappedExpression.expression);
70468
+ if (!ts.isCallExpression(unwrappedExpression) || !ts.isIdentifier(unwrappedExpression.expression) || unwrappedExpression.expression.text !== "require" || unwrappedExpression.arguments.length !== 1) return null;
70469
+ const moduleSpecifier = unwrappedExpression.arguments[0];
70470
+ return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
70471
+ };
70472
+ const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
70473
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
70474
+ return ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
70475
+ };
70476
+ 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");
70477
+ const isTopLevelExpression = (node) => {
70478
+ let ancestor = node.parent;
70479
+ while (ancestor && !ts.isSourceFile(ancestor)) {
70480
+ if (ts.isExpressionStatement(ancestor)) return ts.isSourceFile(ancestor.parent);
70481
+ if (!ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isAwaitExpression(ancestor)) return false;
70482
+ ancestor = ancestor.parent;
70483
+ }
70484
+ return false;
70485
+ };
70486
+ const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
70487
+ let ancestor = node.parent;
70488
+ let didFindConfigProperty = false;
70489
+ while (ancestor && !ts.isSourceFile(ancestor)) {
70490
+ 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;
70491
+ if (ts.isPropertyAssignment(ancestor)) {
70492
+ const isConfigProperty = (ts.isIdentifier(ancestor.name) || ts.isStringLiteralLike(ancestor.name)) && ancestor.name.text === propertyName;
70493
+ if (didFindConfigProperty || !isConfigProperty) return false;
70494
+ if (!ts.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(ts.isSpreadAssignment)) return false;
70495
+ didFindConfigProperty = true;
70496
+ ancestor = ancestor.parent;
70497
+ continue;
70498
+ }
70499
+ if (didFindConfigProperty) {
70500
+ if (ts.isExportAssignment(ancestor)) return true;
70501
+ if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
70502
+ 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);
70503
+ 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;
70504
+ }
70505
+ ancestor = ancestor.parent;
70506
+ }
70507
+ return false;
70508
+ };
70509
+ const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory) => {
70510
+ const optionsExpression = callExpression.arguments[0];
70511
+ if (!optionsExpression) return null;
70512
+ const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
70513
+ if (!ts.isObjectLiteralExpression(unwrappedOptions)) return null;
70514
+ if (unwrappedOptions.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
70515
+ if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
70516
+ const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
70517
+ if (!eslintrcProperty) return null;
70518
+ const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
70519
+ if (!ts.isObjectLiteralExpression(eslintrcExpression)) return null;
70520
+ if (eslintrcExpression.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
70521
+ const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
70522
+ if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== ts.SyntaxKind.TrueKeyword) return null;
70523
+ const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
70524
+ if (!filepathProperty) return Path.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
70525
+ if (!ts.isPropertyAssignment(filepathProperty)) return null;
70526
+ const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
70527
+ return ts.isStringLiteralLike(filepathExpression) ? Path.resolve(packageDirectory, filepathExpression.text) : null;
70528
+ };
70529
+ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
70530
+ let sourceText;
70531
+ try {
70532
+ sourceText = NFS.readFileSync(configPath, "utf8");
70533
+ } catch {
70534
+ return {
70535
+ didFindActiveAutoImport: false,
70536
+ globalsPaths: []
70537
+ };
70538
+ }
70539
+ const sourceFile = ts.createSourceFile(configPath, sourceText, ts.ScriptTarget.Latest, true);
70540
+ const autoImportBindings = /* @__PURE__ */ new Map();
70541
+ const esbuildBindings = /* @__PURE__ */ new Set();
70542
+ const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
70543
+ for (const statement of sourceFile.statements) {
70544
+ if (ts.isImportDeclaration(statement) && ts.isStringLiteralLike(statement.moduleSpecifier)) {
70545
+ const moduleSpecifier = statement.moduleSpecifier.text;
70546
+ if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
70547
+ const defaultBinding = statement.importClause?.name;
70548
+ if (defaultBinding) autoImportBindings.set(defaultBinding.text, moduleSpecifier);
70549
+ }
70550
+ if (moduleSpecifier === "esbuild") {
70551
+ const defaultBinding = statement.importClause?.name;
70552
+ if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
70553
+ const namedBindings = statement.importClause?.namedBindings;
70554
+ if (namedBindings && ts.isNamedImports(namedBindings)) {
70555
+ for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
70556
+ }
70557
+ if (namedBindings && ts.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
70558
+ }
70559
+ }
70560
+ if (!ts.isVariableStatement(statement)) continue;
70561
+ for (const declaration of statement.declarationList.declarations) {
70562
+ if (!declaration.initializer) continue;
70563
+ const declarationName = ts.isIdentifier(declaration.name) ? declaration.name.text : null;
70564
+ const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
70565
+ if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
70566
+ if (moduleSpecifier === "esbuild") {
70567
+ if (declarationName) esbuildNamespaceBindings.add(declarationName);
70568
+ if (ts.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
70569
+ const importedName = bindingElement.propertyName ?? bindingElement.name;
70570
+ if (ts.isIdentifier(importedName) && importedName.text === "build" && ts.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
70571
+ }
70572
+ }
70573
+ if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
70574
+ }
70575
+ }
70576
+ const globalsPaths = /* @__PURE__ */ new Set();
70577
+ let didFindActiveAutoImport = false;
70578
+ let didFindUnsafeActiveAutoImport = false;
70579
+ const visit = (node) => {
70580
+ if (ts.isCallExpression(node)) {
70581
+ const moduleSpecifier = ts.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
70582
+ if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
70583
+ if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
70584
+ didFindActiveAutoImport = true;
70585
+ const globalsPath = getGlobalsPathFromActiveAutoImportCall(node, packageDirectory);
70586
+ if (globalsPath) globalsPaths.add(globalsPath);
70587
+ else didFindUnsafeActiveAutoImport = true;
70588
+ }
70589
+ }
70590
+ }
70591
+ ts.forEachChild(node, visit);
70592
+ };
70593
+ visit(sourceFile);
70594
+ return {
70595
+ didFindActiveAutoImport,
70596
+ globalsPaths: didFindUnsafeActiveAutoImport ? [] : [...globalsPaths]
70597
+ };
70598
+ };
70599
+ const collectGeneratedGlobalNames = (globalsPath, rootDirectory) => {
70600
+ const relativePath = Path.relative(rootDirectory, globalsPath);
70601
+ if (relativePath.startsWith("..") || Path.isAbsolute(relativePath)) return [];
70602
+ const parsed = failOpenReadJson(globalsPath, null);
70603
+ if (!isPlainObject(parsed) || !isPlainObject(parsed.globals)) return [];
70604
+ 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();
70605
+ };
70606
+ const findOwningPackageDirectory = (absoluteFilePath, rootDirectory, cache) => {
70607
+ let currentDirectory = Path.dirname(absoluteFilePath);
70608
+ const visitedDirectories = [];
70609
+ while (true) {
70610
+ const cachedDirectory = cache.get(currentDirectory);
70611
+ if (cachedDirectory !== void 0) {
70612
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, cachedDirectory);
70613
+ return cachedDirectory;
70614
+ }
70615
+ const relativeDirectory = Path.relative(rootDirectory, currentDirectory);
70616
+ if (relativeDirectory.startsWith("..") || Path.isAbsolute(relativeDirectory)) {
70617
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
70618
+ return null;
70619
+ }
70620
+ visitedDirectories.push(currentDirectory);
70621
+ if (NFS.existsSync(Path.join(currentDirectory, "package.json"))) {
70622
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, currentDirectory);
70623
+ return currentDirectory;
70624
+ }
70625
+ if (currentDirectory === rootDirectory) {
70626
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
70627
+ return null;
70628
+ }
70629
+ currentDirectory = Path.dirname(currentDirectory);
70630
+ }
70631
+ };
70632
+ const collectPackageGlobalNames = (packageDirectory, rootDirectory) => {
70633
+ let directoryEntries;
70634
+ try {
70635
+ directoryEntries = NFS.readdirSync(packageDirectory, { withFileTypes: true });
70636
+ } catch {
70637
+ return [];
70638
+ }
70639
+ const configuredGlobalsPaths = [];
70640
+ for (const entry of directoryEntries) {
70641
+ if (!entry.isFile() && !entry.isSymbolicLink() || !CONFIG_FILENAMES.has(entry.name)) continue;
70642
+ const configGlobalsPaths = collectGlobalsPathsFromConfig(Path.join(packageDirectory, entry.name), packageDirectory);
70643
+ if (configGlobalsPaths.didFindActiveAutoImport) configuredGlobalsPaths.push(configGlobalsPaths.globalsPaths.toSorted());
70644
+ }
70645
+ if (configuredGlobalsPaths.length === 0) return [];
70646
+ const globalsPaths = configuredGlobalsPaths[0];
70647
+ if (configuredGlobalsPaths.some((candidatePaths) => candidatePaths.length !== globalsPaths.length || candidatePaths.some((candidatePath, index) => candidatePath !== globalsPaths[index]))) return [];
70648
+ const names = /* @__PURE__ */ new Set();
70649
+ for (const globalsPath of globalsPaths) for (const name of collectGeneratedGlobalNames(globalsPath, rootDirectory)) names.add(name);
70650
+ return [...names].sort();
70651
+ };
70652
+ const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }) => {
70653
+ const absoluteRootDirectory = Path.resolve(rootDirectory);
70654
+ const packageDirectoryCache = /* @__PURE__ */ new Map();
70655
+ const packageDirectories = /* @__PURE__ */ new Set();
70656
+ for (const candidateFile of candidateFiles) {
70657
+ const packageDirectory = findOwningPackageDirectory(Path.resolve(absoluteRootDirectory, candidateFile), absoluteRootDirectory, packageDirectoryCache);
70658
+ if (packageDirectory) packageDirectories.add(packageDirectory);
70659
+ }
70660
+ const scopes = [...packageDirectories].map((packageDirectory) => ({
70661
+ directory: Path.relative(absoluteRootDirectory, packageDirectory).replaceAll("\\", "/"),
70662
+ names: collectPackageGlobalNames(packageDirectory, absoluteRootDirectory)
70663
+ })).sort((firstScope, secondScope) => firstScope.directory.localeCompare(secondScope.directory));
70664
+ return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
70665
+ };
69957
70666
  const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
69958
70667
  const decodeFileDiagnostics = (raw) => {
69959
70668
  if (!Array.isArray(raw)) return null;
@@ -70276,6 +70985,12 @@ const appendReanimatedSharedValueHint = (help, rule, project) => {
70276
70985
  if (!help) return REANIMATED_SHARED_VALUE_HINT;
70277
70986
  return `${help}\n\n${REANIMATED_SHARED_VALUE_HINT}`;
70278
70987
  };
70988
+ const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
70989
+ const boundedOffset = Math.min(Math.max(utf8Offset, 0), sourceBuffer.length);
70990
+ let lineStartOffset = boundedOffset;
70991
+ while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
70992
+ return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
70993
+ };
70279
70994
  const REDACTED_PLACEHOLDER = "<redacted>";
70280
70995
  const KEEP_PREFIX = `$1${REDACTED_PLACEHOLDER}`;
70281
70996
  const KNOWN_SECRET_RULES = [
@@ -70991,7 +71706,7 @@ const resolveMatchByOccurrence = (rule, category) => OCCURRENCE_MATCHED_CATEGORI
70991
71706
  * with empty text still carry a useful jump target, so they're kept
70992
71707
  * with a neutral message.
70993
71708
  */
70994
- const buildRelatedLocations = (labels, filePath) => {
71709
+ const buildRelatedLocations = (labels, filePath, sourceBuffer) => {
70995
71710
  if (labels.length <= 1) return [];
70996
71711
  const related = [];
70997
71712
  for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
@@ -70999,8 +71714,8 @@ const buildRelatedLocations = (labels, filePath) => {
70999
71714
  if (!label?.span) continue;
71000
71715
  related.push({
71001
71716
  filePath,
71002
- line: label.span.line ?? 0,
71003
- column: label.span.column ?? 0,
71717
+ line: sourceBuffer === null ? label.span.line ?? 0 : lineOfUtf8Offset(sourceBuffer, label.span.offset),
71718
+ column: sourceBuffer === null ? label.span.column ?? 0 : columnOfUtf8Offset(sourceBuffer, label.span.offset),
71004
71719
  offset: label.span.offset,
71005
71720
  length: label.span.length,
71006
71721
  message: label.label ?? ""
@@ -71020,7 +71735,7 @@ const isOxlintOutput = (value) => isRecord(value) && Array.isArray(value.diagnos
71020
71735
  * to the first `{`. Raises `OxlintOutputUnparseable` when the
71021
71736
  * stdout isn't valid JSON or doesn't carry a `diagnostics` array.
71022
71737
  */
71023
- const parseOxlintOutput = (stdout, project, rootDirectory) => {
71738
+ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath) => {
71024
71739
  if (!stdout) return [];
71025
71740
  const jsonStart = stdout.indexOf("{");
71026
71741
  const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
@@ -71037,8 +71752,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71037
71752
  const sourceBufferCache = /* @__PURE__ */ new Map();
71038
71753
  const sourceLinesCache = /* @__PURE__ */ new Map();
71039
71754
  const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
71755
+ const resolveMappedSourceFilename = (filename) => sourcePathByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
71756
+ const resolveSourceFilename = (filename) => resolveMappedSourceFilename(filename) ?? filename;
71040
71757
  const readSourceBuffer = (filename) => {
71041
- const absolutePath = resolveAbsolutePath(filename);
71758
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71042
71759
  const cached = sourceBufferCache.get(absolutePath);
71043
71760
  if (cached !== void 0) return cached;
71044
71761
  let sourceBuffer;
@@ -71051,7 +71768,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71051
71768
  return sourceBuffer;
71052
71769
  };
71053
71770
  const readSourceLines = (filename) => {
71054
- const absolutePath = resolveAbsolutePath(filename);
71771
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71055
71772
  const cached = sourceLinesCache.get(absolutePath);
71056
71773
  if (cached !== void 0) return cached;
71057
71774
  const sourceBuffer = readSourceBuffer(filename);
@@ -71060,27 +71777,30 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71060
71777
  return sourceLines;
71061
71778
  };
71062
71779
  const isMinifiedDiagnosticFile = (filename) => {
71063
- const absolutePath = resolveAbsolutePath(filename);
71780
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
71064
71781
  const cached = minifiedFileCache.get(absolutePath);
71065
71782
  if (cached !== void 0) return cached;
71066
71783
  const minified = isMinifiedSource(absolutePath);
71067
71784
  minifiedFileCache.set(absolutePath, minified);
71068
71785
  return minified;
71069
71786
  };
71070
- 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) => {
71787
+ 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) => {
71071
71788
  const { plugin, rule } = parseRuleCode(diagnostic.code);
71072
71789
  const primaryLabel = diagnostic.labels[0];
71073
71790
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
71074
- const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
71791
+ const mappedSourceFilename = resolveMappedSourceFilename(diagnostic.filename);
71792
+ const normalizedFilePath = (mappedSourceFilename ?? diagnostic.filename).replaceAll("\\", "/");
71075
71793
  const primarySpan = primaryLabel?.span;
71076
71794
  const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
71077
- const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
71795
+ const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath, mappedSourceFilename === void 0 ? null : sourceBuffer);
71078
71796
  const category = resolveDiagnosticCategory(plugin, rule);
71079
71797
  const matchByOccurrence = resolveMatchByOccurrence(rule, category);
71080
71798
  const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
71081
- const primaryLineIndex = primarySpan ? primarySpan.line - 1 : -1;
71799
+ const primaryLineNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.line ?? 0;
71800
+ const primaryColumnNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? columnOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.column ?? 0;
71801
+ const primaryLineIndex = primarySpan ? primaryLineNumber - 1 : -1;
71082
71802
  const primaryLine = sourceLines?.[primaryLineIndex];
71083
- const primaryColumnIndex = primarySpan ? primarySpan.column - 1 : -1;
71803
+ const primaryColumnIndex = primarySpan ? primaryColumnNumber - 1 : -1;
71084
71804
  const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
71085
71805
  const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
71086
71806
  const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
@@ -71093,8 +71813,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
71093
71813
  message: cleaned.message,
71094
71814
  help: cleaned.help,
71095
71815
  url: diagnostic.url,
71096
- line: primarySpan?.line ?? 0,
71097
- column: primarySpan?.column ?? 0,
71816
+ line: primaryLineNumber,
71817
+ column: primaryColumnNumber,
71098
71818
  ...primarySpan ? {
71099
71819
  offset: primarySpan.offset,
71100
71820
  length: primarySpan.length,
@@ -71282,7 +72002,11 @@ const isParallelismRelatedSpawnError = (error) => {
71282
72002
  * loop with a slimmer config in that case.
71283
72003
  */
71284
72004
  const spawnLintBatches = async (input) => {
71285
- const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
72005
+ const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, sourcePathByLintPath, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
72006
+ const resolveSourcePath = (filePath) => {
72007
+ const absoluteFilePath = Path.isAbsolute(filePath) ? filePath : Path.resolve(rootDirectory, filePath);
72008
+ return sourcePathByLintPath?.get(Path.normalize(absoluteFilePath)) ?? filePath;
72009
+ };
71286
72010
  const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
71287
72011
  let rescueDeadlineEpochMs;
71288
72012
  const isPastDeadline = () => deadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(deadlineEpochMs) === 0 || rescueDeadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(rescueDeadlineEpochMs) === 0;
@@ -71302,7 +72026,7 @@ const spawnLintBatches = async (input) => {
71302
72026
  }
71303
72027
  const batchArgs = [...baseArgs, ...batch];
71304
72028
  try {
71305
- return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory);
72029
+ return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory, sourcePathByLintPath);
71306
72030
  } catch (error) {
71307
72031
  if (!isSplittableReactDoctorError(error)) throw error;
71308
72032
  if (isPastDeadline()) {
@@ -71408,10 +72132,12 @@ const spawnLintBatches = async (input) => {
71408
72132
  onPartialFailure(buildMessage(`${skippedFiles.slice(0, 3).join(", ")}${skippedFiles.length > 3 ? `, +${skippedFiles.length - 3} more` : ""}`));
71409
72133
  };
71410
72134
  const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
71411
- reportSkippedFiles(droppedFiles, (fileListPreview) => `${droppedFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
71412
- reportSkippedFiles(outcome.deadlineSkippedFiles, (fileListPreview) => `${outcome.deadlineSkippedFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
72135
+ const droppedSourceFiles = [...new Set(droppedFiles.map(resolveSourcePath))];
72136
+ const deadlineSkippedSourceFiles = [...new Set(outcome.deadlineSkippedFiles.map(resolveSourcePath))];
72137
+ reportSkippedFiles(droppedSourceFiles, (fileListPreview) => `${droppedSourceFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
72138
+ reportSkippedFiles(deadlineSkippedSourceFiles, (fileListPreview) => `${deadlineSkippedSourceFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
71413
72139
  const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
71414
- input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)))].sort());
72140
+ input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)).map(resolveSourcePath))].sort());
71415
72141
  return dedupeDiagnostics(diagnostics);
71416
72142
  };
71417
72143
  let didValidate = false;
@@ -71510,6 +72236,266 @@ const planLintBatches = ({ baseArgs, files, sizeByFile }) => {
71510
72236
  }
71511
72237
  return batches.filter((batch) => batch.fileIndexes.length > 0).map((batch) => batch.fileIndexes.sort((leftIndex, rightIndex) => leftIndex - rightIndex).map((fileIndex) => files[fileIndex]));
71512
72238
  };
72239
+ const THREE_MODULE_IMPORT_PATTERN = /\b(?:from\s*|import\s*(?:\(\s*)?|require\s*\(\s*)["']three(?:\/[^"']*)?["']/;
72240
+ const containsThreeModuleImport = (sourceText) => THREE_MODULE_IMPORT_PATTERN.test(sourceText);
72241
+ const COMMENT_OPEN = "<!--";
72242
+ const COMMENT_CLOSE = "-->";
72243
+ const FRONTMATTER_FENCE = "---";
72244
+ const SCRIPT_TAG_NAME = "script";
72245
+ const SCRIPT_OPEN = `<${SCRIPT_TAG_NAME}`;
72246
+ const SCRIPT_CLOSE = `</${SCRIPT_TAG_NAME}`;
72247
+ const TEMPLATE_TAG_NAME = "template";
72248
+ const TEMPLATE_CLOSE = `</${TEMPLATE_TAG_NAME}`;
72249
+ const JAVASCRIPT_MIME_TYPES = new Set([
72250
+ "application/ecmascript",
72251
+ "application/javascript",
72252
+ "application/x-ecmascript",
72253
+ "application/x-javascript",
72254
+ "text/ecmascript",
72255
+ "text/javascript",
72256
+ "text/javascript1.0",
72257
+ "text/javascript1.1",
72258
+ "text/javascript1.2",
72259
+ "text/javascript1.3",
72260
+ "text/javascript1.4",
72261
+ "text/javascript1.5",
72262
+ "text/jscript",
72263
+ "text/livescript",
72264
+ "text/x-ecmascript",
72265
+ "text/x-javascript"
72266
+ ]);
72267
+ const RAW_TEXT_TAG_NAMES = new Set([
72268
+ "iframe",
72269
+ "noembed",
72270
+ "noframes",
72271
+ "noscript",
72272
+ "style",
72273
+ "textarea",
72274
+ "title",
72275
+ "xmp"
72276
+ ]);
72277
+ const PLAINTEXT_TAG_NAME = "plaintext";
72278
+ const TAG_OPEN_UTF8_BYTE = "<".charCodeAt(0);
72279
+ const TAG_CLOSE_UTF8_BYTE = ">".charCodeAt(0);
72280
+ const SINGLE_QUOTE_UTF8_BYTE = "'".charCodeAt(0);
72281
+ const DOUBLE_QUOTE_UTF8_BYTE = "\"".charCodeAt(0);
72282
+ const ATTRIBUTE_ASSIGNMENT_UTF8_BYTE = "=".charCodeAt(0);
72283
+ const TAG_SELF_CLOSE_UTF8_BYTE = "/".charCodeAt(0);
72284
+ const TAB_UTF8_BYTE = " ".charCodeAt(0);
72285
+ const FORM_FEED_UTF8_BYTE = "\f".charCodeAt(0);
72286
+ const isHtmlWhitespace = (byte) => byte === TAB_UTF8_BYTE || byte === 10 || byte === FORM_FEED_UTF8_BYTE || byte === 13 || byte === 32;
72287
+ const matchesAsciiCaseInsensitive = (sourceBuffer, startByte, expected) => {
72288
+ if (startByte + expected.length > sourceBuffer.length) return false;
72289
+ for (let expectedIndex = 0; expectedIndex < expected.length; expectedIndex++) {
72290
+ const sourceByte = sourceBuffer[startByte + expectedIndex];
72291
+ if (sourceByte === void 0 || String.fromCharCode(sourceByte).toLowerCase() !== expected[expectedIndex]) return false;
72292
+ }
72293
+ return true;
72294
+ };
72295
+ const isTagBoundary = (byte) => byte === TAG_CLOSE_UTF8_BYTE || byte === TAG_SELF_CLOSE_UTF8_BYTE || isHtmlWhitespace(byte);
72296
+ const isPotentialTagStart = (byte) => {
72297
+ if (byte === void 0) return false;
72298
+ return /[A-Za-z!/?]/.test(String.fromCharCode(byte));
72299
+ };
72300
+ const findLineEnd = (sourceBuffer, lineStartByte) => {
72301
+ let byteIndex = lineStartByte;
72302
+ while (byteIndex < sourceBuffer.length && sourceBuffer[byteIndex] !== 10 && sourceBuffer[byteIndex] !== 13) byteIndex++;
72303
+ return byteIndex;
72304
+ };
72305
+ const findNextLineStart = (sourceBuffer, lineStartByte) => {
72306
+ const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
72307
+ if (sourceBuffer[lineEndByte] === 13 && sourceBuffer[lineEndByte + 1] === 10) return lineEndByte + 2;
72308
+ return Math.min(lineEndByte + 1, sourceBuffer.length);
72309
+ };
72310
+ const isFrontmatterFenceLine = (sourceBuffer, lineStartByte) => {
72311
+ if (!matchesAsciiCaseInsensitive(sourceBuffer, lineStartByte, FRONTMATTER_FENCE)) return false;
72312
+ const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
72313
+ for (let byteIndex = lineStartByte + 3; byteIndex < lineEndByte; byteIndex++) if (!isHtmlWhitespace(sourceBuffer[byteIndex])) return false;
72314
+ return true;
72315
+ };
72316
+ const findFrontmatterEnd = (sourceBuffer) => {
72317
+ if (!isFrontmatterFenceLine(sourceBuffer, 0)) return 0;
72318
+ const openingFenceEndByte = findLineEnd(sourceBuffer, 0);
72319
+ let lineStartByte = findNextLineStart(sourceBuffer, 0);
72320
+ while (lineStartByte < sourceBuffer.length) {
72321
+ if (isFrontmatterFenceLine(sourceBuffer, lineStartByte)) return findLineEnd(sourceBuffer, lineStartByte);
72322
+ lineStartByte = findNextLineStart(sourceBuffer, lineStartByte);
72323
+ }
72324
+ return openingFenceEndByte;
72325
+ };
72326
+ const maskByteRange = (maskedBuffer, startByte, endByte) => {
72327
+ for (let byteIndex = startByte; byteIndex < endByte; byteIndex++) {
72328
+ const byte = maskedBuffer[byteIndex];
72329
+ if (byte !== 10 && byte !== 13) maskedBuffer[byteIndex] = 32;
72330
+ }
72331
+ };
72332
+ const readStartTagName = (sourceBuffer, tagStartByte) => {
72333
+ const firstNameByte = sourceBuffer[tagStartByte + 1];
72334
+ if (firstNameByte === void 0 || !/[A-Za-z]/.test(String.fromCharCode(firstNameByte))) return null;
72335
+ let nameEndByte = tagStartByte + 2;
72336
+ while (nameEndByte < sourceBuffer.length && /[A-Za-z0-9:-]/.test(String.fromCharCode(sourceBuffer[nameEndByte] ?? 32))) nameEndByte++;
72337
+ return sourceBuffer.subarray(tagStartByte + 1, nameEndByte).toString("ascii").toLowerCase();
72338
+ };
72339
+ const findTagEnd = (sourceBuffer, startByte) => {
72340
+ let quoteByte = null;
72341
+ for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) {
72342
+ const byte = sourceBuffer[byteIndex];
72343
+ if (quoteByte !== null) {
72344
+ if (byte === quoteByte) quoteByte = null;
72345
+ continue;
72346
+ }
72347
+ if (byte === SINGLE_QUOTE_UTF8_BYTE || byte === DOUBLE_QUOTE_UTF8_BYTE) {
72348
+ quoteByte = byte;
72349
+ continue;
72350
+ }
72351
+ if (byte === TAG_CLOSE_UTF8_BYTE) return byteIndex;
72352
+ }
72353
+ return sourceBuffer.length;
72354
+ };
72355
+ const parseScriptAttributes = (sourceBuffer, attributesStartByte, tagEndByte) => {
72356
+ let byteIndex = attributesStartByte;
72357
+ let hasSource = false;
72358
+ let language = null;
72359
+ let scriptType = null;
72360
+ while (byteIndex < tagEndByte) {
72361
+ while (byteIndex < tagEndByte && (isHtmlWhitespace(sourceBuffer[byteIndex]) || sourceBuffer[byteIndex] === TAG_SELF_CLOSE_UTF8_BYTE)) byteIndex++;
72362
+ const attributeNameStartByte = byteIndex;
72363
+ while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== ATTRIBUTE_ASSIGNMENT_UTF8_BYTE && sourceBuffer[byteIndex] !== TAG_SELF_CLOSE_UTF8_BYTE) byteIndex++;
72364
+ const attributeName = sourceBuffer.subarray(attributeNameStartByte, byteIndex).toString("ascii").toLowerCase();
72365
+ while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
72366
+ let attributeValue = "";
72367
+ if (sourceBuffer[byteIndex] === ATTRIBUTE_ASSIGNMENT_UTF8_BYTE) {
72368
+ byteIndex++;
72369
+ while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
72370
+ const quoteByte = sourceBuffer[byteIndex];
72371
+ if (quoteByte === SINGLE_QUOTE_UTF8_BYTE || quoteByte === DOUBLE_QUOTE_UTF8_BYTE) {
72372
+ const valueStartByte = byteIndex + 1;
72373
+ byteIndex = valueStartByte;
72374
+ while (byteIndex < tagEndByte && sourceBuffer[byteIndex] !== quoteByte) byteIndex++;
72375
+ attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
72376
+ if (byteIndex < tagEndByte) byteIndex++;
72377
+ } else {
72378
+ const valueStartByte = byteIndex;
72379
+ while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== TAG_CLOSE_UTF8_BYTE) byteIndex++;
72380
+ attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
72381
+ }
72382
+ }
72383
+ if (attributeName === "src") hasSource = true;
72384
+ else if (attributeName === "type" && scriptType === null) scriptType = attributeValue;
72385
+ else if (attributeName === "language" && language === null) language = attributeValue;
72386
+ }
72387
+ return {
72388
+ hasSource,
72389
+ language,
72390
+ type: scriptType
72391
+ };
72392
+ };
72393
+ const isExecutableScript = (attributes) => {
72394
+ if (attributes.hasSource) return false;
72395
+ const type = attributes.type?.trim().toLowerCase() ?? "";
72396
+ if (type !== "") {
72397
+ const mimeType = type.split(";")[0]?.trim() ?? "";
72398
+ return mimeType === "module" || JAVASCRIPT_MIME_TYPES.has(mimeType);
72399
+ }
72400
+ const language = attributes.language?.trim().toLowerCase() ?? "";
72401
+ return language === "" || JAVASCRIPT_MIME_TYPES.has(`text/${language}`);
72402
+ };
72403
+ const findElementClose = (sourceBuffer, startByte, tagName) => {
72404
+ const closeTagStart = `</${tagName}`;
72405
+ 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;
72406
+ return sourceBuffer.length;
72407
+ };
72408
+ const prepareHtmlScriptSource = (sourceBuffer) => {
72409
+ const frontmatterEndByte = findFrontmatterEnd(sourceBuffer);
72410
+ let maskedBuffer = frontmatterEndByte > 0 ? Buffer.from(sourceBuffer) : null;
72411
+ if (maskedBuffer !== null) maskByteRange(maskedBuffer, 0, frontmatterEndByte);
72412
+ const executableScriptBodies = [];
72413
+ let byteIndex = frontmatterEndByte;
72414
+ let templateDepth = 0;
72415
+ while (byteIndex < sourceBuffer.length) {
72416
+ if (sourceBuffer[byteIndex] !== TAG_OPEN_UTF8_BYTE) {
72417
+ byteIndex++;
72418
+ continue;
72419
+ }
72420
+ if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, COMMENT_OPEN)) {
72421
+ const commentEndByte = sourceBuffer.indexOf(COMMENT_CLOSE, byteIndex + 4);
72422
+ byteIndex = commentEndByte === -1 ? sourceBuffer.length : commentEndByte + 3;
72423
+ continue;
72424
+ }
72425
+ if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, TEMPLATE_CLOSE) && isTagBoundary(sourceBuffer[byteIndex + TEMPLATE_CLOSE.length])) {
72426
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + TEMPLATE_CLOSE.length);
72427
+ if (templateDepth > 0) templateDepth--;
72428
+ byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
72429
+ continue;
72430
+ }
72431
+ if (!matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, SCRIPT_OPEN) || !isTagBoundary(sourceBuffer[byteIndex + SCRIPT_OPEN.length])) {
72432
+ if (!isPotentialTagStart(sourceBuffer[byteIndex + 1])) {
72433
+ byteIndex++;
72434
+ continue;
72435
+ }
72436
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + 1);
72437
+ const tagName = readStartTagName(sourceBuffer, byteIndex);
72438
+ if (tagName === PLAINTEXT_TAG_NAME) break;
72439
+ if (tagName === TEMPLATE_TAG_NAME) templateDepth++;
72440
+ if (tagName !== null && RAW_TEXT_TAG_NAMES.has(tagName)) {
72441
+ const closeTagStartByte = findElementClose(sourceBuffer, tagEndByte + 1, tagName);
72442
+ if (closeTagStartByte === sourceBuffer.length) break;
72443
+ const closeTagEndByte = findTagEnd(sourceBuffer, closeTagStartByte + tagName.length + 2);
72444
+ byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
72445
+ continue;
72446
+ }
72447
+ byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
72448
+ continue;
72449
+ }
72450
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + SCRIPT_OPEN.length);
72451
+ if (tagEndByte === sourceBuffer.length) break;
72452
+ const bodyStartByte = tagEndByte + 1;
72453
+ const bodyEndByte = findElementClose(sourceBuffer, bodyStartByte, SCRIPT_TAG_NAME);
72454
+ const attributes = parseScriptAttributes(sourceBuffer, byteIndex + SCRIPT_OPEN.length, tagEndByte);
72455
+ if (attributes.hasSource || templateDepth > 0) {
72456
+ maskedBuffer ??= Buffer.from(sourceBuffer);
72457
+ maskByteRange(maskedBuffer, bodyStartByte, bodyEndByte);
72458
+ } else if (isExecutableScript(attributes)) executableScriptBodies.push(sourceBuffer.subarray(bodyStartByte, bodyEndByte));
72459
+ if (bodyEndByte === sourceBuffer.length) break;
72460
+ const closeTagEndByte = findTagEnd(sourceBuffer, bodyEndByte + SCRIPT_CLOSE.length);
72461
+ byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
72462
+ }
72463
+ return {
72464
+ executableScriptBodies,
72465
+ lintBuffer: maskedBuffer ?? sourceBuffer
72466
+ };
72467
+ };
72468
+ const prepareHtmlLintSources = (rootDirectory, temporaryDirectory, candidateFiles) => {
72469
+ const lintFiles = [];
72470
+ const sourcePathByLintPath = /* @__PURE__ */ new Map();
72471
+ const sizeByLintPath = /* @__PURE__ */ new Map();
72472
+ const htmlSourcesDirectory = Path.join(temporaryDirectory, "html-sources");
72473
+ let htmlFileIndex = 0;
72474
+ let hasThreeModuleImport = false;
72475
+ for (const candidateFile of candidateFiles) {
72476
+ if (!HTML_FILE_PATTERN.test(candidateFile)) {
72477
+ lintFiles.push(candidateFile);
72478
+ continue;
72479
+ }
72480
+ const absoluteSourcePath = Path.isAbsolute(candidateFile) ? candidateFile : Path.resolve(rootDirectory, candidateFile);
72481
+ const sourceBuffer = NFS.readFileSync(absoluteSourcePath);
72482
+ const { executableScriptBodies, lintBuffer } = prepareHtmlScriptSource(sourceBuffer);
72483
+ if (htmlFileIndex === 0) NFS.mkdirSync(htmlSourcesDirectory, { recursive: true });
72484
+ const lintPath = Path.join(htmlSourcesDirectory, `${htmlFileIndex}.astro`);
72485
+ NFS.writeFileSync(lintPath, lintBuffer);
72486
+ lintFiles.push(lintPath);
72487
+ sourcePathByLintPath.set(Path.resolve(lintPath), candidateFile);
72488
+ sizeByLintPath.set(lintPath, sourceBuffer.length);
72489
+ hasThreeModuleImport ||= executableScriptBodies.some((scriptBody) => containsThreeModuleImport(scriptBody.toString("utf8")));
72490
+ htmlFileIndex++;
72491
+ }
72492
+ return {
72493
+ lintFiles,
72494
+ sourcePathByLintPath,
72495
+ sizeByLintPath,
72496
+ hasThreeModuleImport
72497
+ };
72498
+ };
71513
72499
  /**
71514
72500
  * Atomically (re)writes the generated oxlintrc.json. Used twice in
71515
72501
  * the runner: once for the primary scan, once for the
@@ -71670,6 +72656,8 @@ const reactHooksJsPluginDropNote = (error) => {
71670
72656
  const runOxlint = async (options) => {
71671
72657
  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;
71672
72658
  const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
72659
+ const runtimeGlobals = Array.isArray(userConfig?.runtimeGlobals) ? userConfig.runtimeGlobals.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
72660
+ let unpluginAutoImportGlobalScopes = [];
71673
72661
  const severityControls = buildRuleSeverityControls(userConfig);
71674
72662
  validateRuleRegistration();
71675
72663
  resetManifestCaches();
@@ -71683,21 +72671,6 @@ const runOxlint = async (options) => {
71683
72671
  const pluginPath = resolvePluginPath();
71684
72672
  const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
71685
72673
  const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
71686
- const buildConfig = (overrides) => createOxlintConfig({
71687
- pluginPath,
71688
- project,
71689
- customRulesOnly,
71690
- extendsPaths: overrides.extendsPaths,
71691
- ignoredTags,
71692
- includedTags,
71693
- includeTagDefaults,
71694
- serverAuthFunctionNames,
71695
- severityControls,
71696
- userPlugins,
71697
- disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
71698
- ruleSelection: overrides.ruleSelection,
71699
- sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
71700
- });
71701
72674
  const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
71702
72675
  const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
71703
72676
  const configPath = Path.join(configDirectory, "oxlintrc.json");
@@ -71733,7 +72706,36 @@ const runOxlint = async (options) => {
71733
72706
  await yieldToEventLoop();
71734
72707
  const sizedScanFiles = includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null;
71735
72708
  const candidateFiles = includePaths !== void 0 ? includePaths : (sizedScanFiles ?? []).map((entry) => entry.path);
72709
+ unpluginAutoImportGlobalScopes = collectUnpluginAutoImportGlobalScopes({
72710
+ rootDirectory,
72711
+ candidateFiles
72712
+ });
72713
+ const preparedHtmlSources = prepareHtmlLintSources(rootDirectory, configDirectory, candidateFiles);
72714
+ const lintFiles = preparedHtmlSources.lintFiles;
72715
+ const hasHtmlFiles = preparedHtmlSources.sourcePathByLintPath.size > 0;
72716
+ const lintProject = !project.hasThree && preparedHtmlSources.hasThreeModuleImport ? {
72717
+ ...project,
72718
+ hasThree: true
72719
+ } : project;
72720
+ const buildConfig = (overrides) => createOxlintConfig({
72721
+ pluginPath,
72722
+ project: lintProject,
72723
+ customRulesOnly,
72724
+ extendsPaths: overrides.extendsPaths,
72725
+ ignoredTags,
72726
+ includedTags,
72727
+ includeTagDefaults,
72728
+ runtimeGlobals,
72729
+ unpluginAutoImportGlobalScopes,
72730
+ serverAuthFunctionNames,
72731
+ severityControls,
72732
+ userPlugins,
72733
+ disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
72734
+ ruleSelection: overrides.ruleSelection,
72735
+ sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
72736
+ });
71736
72737
  const sizeByFile = sizedScanFiles !== null && lintBatchOrdering === "cost" ? new Map(sizedScanFiles.map((entry) => [entry.path, entry.sizeBytes])) : null;
72738
+ if (sizeByFile !== null) for (const [lintPath, sizeBytes] of preparedHtmlSources.sizeByLintPath) sizeByFile.set(lintPath, sizeBytes);
71737
72739
  const buildFileBatches = (passBaseArgs, passFiles) => sizeByFile !== null ? planLintBatches({
71738
72740
  baseArgs: passBaseArgs,
71739
72741
  files: passFiles,
@@ -71762,7 +72764,8 @@ const runOxlint = async (options) => {
71762
72764
  fileBatches: passFileBatches,
71763
72765
  rootDirectory,
71764
72766
  nodeBinaryPath,
71765
- project,
72767
+ project: lintProject,
72768
+ sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
71766
72769
  onPartialFailure: reportPartialFailure,
71767
72770
  onAnalyzedFiles: (filePaths) => {
71768
72771
  analyzedFiles = filePaths;
@@ -71797,7 +72800,7 @@ const runOxlint = async (options) => {
71797
72800
  };
71798
72801
  }
71799
72802
  };
71800
- if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0) {
72803
+ if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0 && !hasHtmlFiles) {
71801
72804
  const rulesetHash = computeRulesetHash({
71802
72805
  config: buildConfig({
71803
72806
  extendsPaths: [],
@@ -71955,14 +72958,15 @@ const runOxlint = async (options) => {
71955
72958
  ]);
71956
72959
  }
71957
72960
  const baseArgs = makeBaseArgs(configPath);
71958
- const fileBatches = buildFileBatches(baseArgs, candidateFiles);
72961
+ const fileBatches = buildFileBatches(baseArgs, lintFiles);
71959
72962
  let analyzedFiles = [];
71960
72963
  const runBatches = () => spawnLintBatches({
71961
72964
  baseArgs,
71962
72965
  fileBatches,
71963
72966
  rootDirectory,
71964
72967
  nodeBinaryPath,
71965
- project,
72968
+ project: lintProject,
72969
+ sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
71966
72970
  onPartialFailure,
71967
72971
  onAnalyzedFiles: (filePaths) => {
71968
72972
  analyzedFiles = filePaths;
@@ -73884,4 +74888,4 @@ const toJsonReport = (result, options) => buildJsonReport({
73884
74888
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
73885
74889
 
73886
74890
  //# sourceMappingURL=index.js.map
73887
- //# debugId=eb93b210-c190-581c-8fe2-f1e1c70e0bab
74891
+ //# debugId=afe9afbe-4d17-5f2a-8b4f-9b49703c42be