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/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="082c13c1-ba8f-56d5-9944-c005ab0edc0e")}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]="f34e66dd-4b16-53f5-a3af-9844fbc71772")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as NodeChildProcess from "node:child_process";
5
5
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
@@ -11,6 +11,7 @@ import process$1 from "node:process";
11
11
  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";
12
12
  import * as Crypto from "node:crypto";
13
13
  import crypto, { createHash, randomUUID } from "node:crypto";
14
+ import { ResolverFactory } from "oxc-resolver";
14
15
  import ts from "typescript";
15
16
  import * as OS from "node:os";
16
17
  import os, { tmpdir } from "node:os";
@@ -64616,7 +64617,8 @@ var AmbiguousProjectError = class extends Error {
64616
64617
  }
64617
64618
  };
64618
64619
  const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
64619
- const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
64620
+ const HTML_FILE_PATTERN = /\.html$/i;
64621
+ const SOURCE_FILE_PATTERN = /\.(?:tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
64620
64622
  const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
64621
64623
  const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
64622
64624
  const MINIFIED_SNIFF_BYTES = 65536;
@@ -65239,7 +65241,7 @@ const findMonorepoRoot = (startDirectory) => {
65239
65241
  */
65240
65242
  const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
65241
65243
  const TSCONFIG_FILENAME = "tsconfig.json";
65242
- const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || Path.isAbsolute(extendsValue);
65244
+ const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
65243
65245
  const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
65244
65246
  const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
65245
65247
  const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
@@ -65256,7 +65258,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
65256
65258
  return null;
65257
65259
  };
65258
65260
  const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
65259
- if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(Path.resolve(fromConfigDirectory, extendsValue));
65261
+ if (isLocalModuleSpecifier(extendsValue)) {
65262
+ const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
65263
+ if (isFile(resolvedPath)) return resolvedPath;
65264
+ const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
65265
+ return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
65266
+ }
65260
65267
  return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
65261
65268
  };
65262
65269
  const normalizeCompilerOptions = (compilerOptions) => {
@@ -65450,6 +65457,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
65450
65457
  ".cts",
65451
65458
  ".json"
65452
65459
  ];
65460
+ const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
65461
+ conditionNames: [
65462
+ "import",
65463
+ "require",
65464
+ "node",
65465
+ "default"
65466
+ ],
65467
+ extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
65468
+ });
65453
65469
  const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
65454
65470
  const hasCompilerPackage = (packageJson, compilerPackages) => {
65455
65471
  const allDependencies = {
@@ -65473,6 +65489,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
65473
65489
  return false;
65474
65490
  };
65475
65491
  const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
65492
+ if (!isLocalModuleSpecifier(moduleSpecifier)) {
65493
+ try {
65494
+ const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
65495
+ if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
65496
+ } catch {}
65497
+ try {
65498
+ const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
65499
+ return isFile(resolvedPath) ? resolvedPath : null;
65500
+ } catch {
65501
+ return null;
65502
+ }
65503
+ }
65476
65504
  const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
65477
65505
  const extension = Path.extname(unresolvedPath);
65478
65506
  return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
@@ -65482,10 +65510,10 @@ const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
65482
65510
  ]).find(isFile) ?? null;
65483
65511
  };
65484
65512
  const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json") || Path.basename(filePath) === ".babelrc" ? ts.parseJsonText(filePath, content) : ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
65485
- const getStaticPropertyName$1 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
65513
+ const getStaticPropertyName$2 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
65486
65514
  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");
65487
65515
  const hasExportModifier = (node) => ts.canHaveModifiers(node) && Boolean(ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
65488
- const getRequireModuleSpecifier = (expression) => {
65516
+ const getRequireModuleSpecifier$1 = (expression) => {
65489
65517
  if (!ts.isCallExpression(expression) || !ts.isIdentifier(expression.expression) || expression.expression.text !== "require" || expression.arguments.length !== 1) return null;
65490
65518
  const moduleSpecifier = expression.arguments[0];
65491
65519
  return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
@@ -65498,7 +65526,7 @@ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statemen
65498
65526
  const namedBindings = importClause?.namedBindings;
65499
65527
  return namedBindings ? ts.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
65500
65528
  }
65501
- if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === bindingName);
65529
+ if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
65502
65530
  return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === bindingName;
65503
65531
  });
65504
65532
  const getImportBinding = (sourceFile, bindingName) => {
@@ -65529,24 +65557,24 @@ const getImportBinding = (sourceFile, bindingName) => {
65529
65557
  for (const declaration of statement.declarationList.declarations) {
65530
65558
  if (!declaration.initializer) continue;
65531
65559
  if (ts.isIdentifier(declaration.name) && declaration.name.text === bindingName) {
65532
- const directModuleSpecifier = getRequireModuleSpecifier(declaration.initializer);
65560
+ const directModuleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
65533
65561
  if (directModuleSpecifier) return {
65534
65562
  moduleSpecifier: directModuleSpecifier,
65535
65563
  exportName: "default",
65536
65564
  isNamespace: true
65537
65565
  };
65538
- if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier(declaration.initializer.expression) !== null) return {
65539
- moduleSpecifier: getRequireModuleSpecifier(declaration.initializer.expression) ?? "",
65566
+ if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier$1(declaration.initializer.expression) !== null) return {
65567
+ moduleSpecifier: getRequireModuleSpecifier$1(declaration.initializer.expression) ?? "",
65540
65568
  exportName: declaration.initializer.name.text,
65541
65569
  isNamespace: false
65542
65570
  };
65543
65571
  }
65544
65572
  if (!ts.isObjectBindingPattern(declaration.name)) continue;
65545
65573
  const bindingElement = declaration.name.elements.find((element) => ts.isIdentifier(element.name) && element.name.text === bindingName);
65546
- const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
65574
+ const moduleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
65547
65575
  if (bindingElement && moduleSpecifier) return {
65548
65576
  moduleSpecifier,
65549
- exportName: bindingElement.propertyName ? getStaticPropertyName$1(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
65577
+ exportName: bindingElement.propertyName ? getStaticPropertyName$2(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
65550
65578
  isNamespace: false
65551
65579
  };
65552
65580
  }
@@ -65599,6 +65627,48 @@ const getScopedConfigBinding = (identifier) => {
65599
65627
  };
65600
65628
  };
65601
65629
  const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
65630
+ const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
65631
+ const isConstantVariableInitializer = (node) => ts.isExpression(node) && ts.isVariableDeclaration(node.parent) && ts.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & ts.NodeFlags.Const);
65632
+ const isNodeCreateRequireCall = (node, analysis) => {
65633
+ if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
65634
+ if (!ts.isCallExpression(node)) return false;
65635
+ const target = node.expression;
65636
+ if (ts.isIdentifier(target)) {
65637
+ if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
65638
+ const importBinding = getImportBinding(analysis.sourceFile, target.text);
65639
+ return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
65640
+ }
65641
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return false;
65642
+ if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "createRequire") return false;
65643
+ const createRequireReceiver = target.expression;
65644
+ if (ts.isCallExpression(createRequireReceiver)) {
65645
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(createRequireReceiver);
65646
+ if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !ts.isIdentifier(createRequireReceiver.expression)) return false;
65647
+ const requireIdentifier = createRequireReceiver.expression;
65648
+ return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
65649
+ }
65650
+ if (!ts.isIdentifier(createRequireReceiver)) return false;
65651
+ if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
65652
+ const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
65653
+ return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
65654
+ };
65655
+ const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
65656
+ const [moduleSpecifierNode] = callExpression.arguments;
65657
+ if (!moduleSpecifierNode || !ts.isStringLiteralLike(moduleSpecifierNode)) return null;
65658
+ const target = callExpression.expression;
65659
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
65660
+ if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "resolve") return null;
65661
+ if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
65662
+ if (!ts.isIdentifier(target.expression)) return null;
65663
+ const resolverIdentifier = target.expression;
65664
+ if (analysis.localBindings.has(resolverIdentifier.text)) return null;
65665
+ const scopedBinding = getScopedConfigBinding(resolverIdentifier);
65666
+ const topLevelBinding = scopedBinding.wasFound ? null : getTopLevelBinding(analysis.sourceFile, resolverIdentifier.text);
65667
+ const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : topLevelBinding;
65668
+ if (resolverInitializer === null && !scopedBinding.wasFound && resolverIdentifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, resolverIdentifier.text) && getImportBinding(analysis.sourceFile, resolverIdentifier.text) === null) return moduleSpecifierNode.text;
65669
+ if (!resolverInitializer || !isConstantVariableInitializer(resolverInitializer) || !isNodeCreateRequireCall(resolverInitializer, analysis)) return null;
65670
+ return moduleSpecifierNode.text;
65671
+ };
65602
65672
  const getAssignedPropertyInitializer = (identifier, propertyName) => {
65603
65673
  let bindingScope = null;
65604
65674
  let currentNode = identifier;
@@ -65707,7 +65777,7 @@ const getReactCompilerFlagState = (expression, analysis) => {
65707
65777
  }
65708
65778
  if (!ts.isObjectLiteralExpression(unwrappedExpression)) return null;
65709
65779
  for (const property of [...unwrappedExpression.properties].reverse()) {
65710
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
65780
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
65711
65781
  if (ts.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
65712
65782
  if (ts.isSpreadAssignment(property)) {
65713
65783
  const spreadState = getReactCompilerFlagState(property.expression, analysis);
@@ -65733,8 +65803,8 @@ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedEx
65733
65803
  }
65734
65804
  if (!ts.isObjectLiteralExpression(resolvedExpression)) return null;
65735
65805
  for (const property of [...resolvedExpression.properties].reverse()) {
65736
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === propertyName) return property.initializer;
65737
- if (ts.isMethodDeclaration(property) && getStaticPropertyName$1(property.name) === propertyName) return property;
65806
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === propertyName) return property.initializer;
65807
+ if (ts.isMethodDeclaration(property) && getStaticPropertyName$2(property.name) === propertyName) return property;
65738
65808
  if (ts.isShorthandPropertyAssignment(property) && property.name.text === propertyName) return property.name;
65739
65809
  if (ts.isSpreadAssignment(property)) {
65740
65810
  const spreadProperty = getSelectedObjectProperty(property.expression, propertyName, analysis, visitedExpressions);
@@ -65765,7 +65835,7 @@ const configExpressionMayDefineProperty = (expression, propertyName, analysis) =
65765
65835
  return resolvedExpression.properties.some((property) => {
65766
65836
  if (ts.isSpreadAssignment(property)) return configExpressionMayDefineProperty(property.expression, propertyName, analysis);
65767
65837
  if (ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property) || ts.isMethodDeclaration(property) || ts.isGetAccessorDeclaration(property) || ts.isSetAccessorDeclaration(property)) {
65768
- const staticPropertyName = getStaticPropertyName$1(property.name);
65838
+ const staticPropertyName = getStaticPropertyName$2(property.name);
65769
65839
  return staticPropertyName === null || staticPropertyName === propertyName;
65770
65840
  }
65771
65841
  return false;
@@ -65784,7 +65854,7 @@ const getExportedConfigNodes = (sourceFile, exportName) => {
65784
65854
  continue;
65785
65855
  }
65786
65856
  if (ts.isExpressionStatement(statement) && isCommonJsConfigExportAssignment(statement.expression, sourceFile) && exportName !== "default" && ts.isObjectLiteralExpression(statement.expression.right)) for (const property of [...statement.expression.right.properties].reverse()) {
65787
- if (ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === exportName) {
65857
+ if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === exportName) {
65788
65858
  exportedNodes.push(property.initializer);
65789
65859
  break;
65790
65860
  }
@@ -65882,6 +65952,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
65882
65952
  visitReturns(functionNode.body);
65883
65953
  return hasCompiler;
65884
65954
  };
65955
+ const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
65956
+ const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
65957
+ if (!importedFilePath) return null;
65958
+ return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList);
65959
+ };
65885
65960
  const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
65886
65961
  const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
65887
65962
  if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
@@ -65902,30 +65977,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
65902
65977
  const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
65903
65978
  if (importBinding) {
65904
65979
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
65905
- if (!importBinding.moduleSpecifier.startsWith(".")) return false;
65906
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
65907
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
65980
+ return Boolean(analyzeImportedConfig({
65981
+ analysis,
65982
+ moduleSpecifier: importBinding.moduleSpecifier,
65983
+ exportName: importBinding.exportName,
65984
+ allowCompilerTransform
65985
+ }));
65908
65986
  }
65909
65987
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
65910
65988
  return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
65911
65989
  };
65912
65990
  const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
65913
65991
  const target = callExpression.expression;
65992
+ const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
65993
+ if (callableRequiredModuleSpecifier !== null) {
65994
+ if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
65995
+ if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
65996
+ const hasCompilerTransform = analyzeImportedConfig({
65997
+ analysis,
65998
+ moduleSpecifier: callableRequiredModuleSpecifier,
65999
+ exportName: "default",
66000
+ allowCompilerTransform,
66001
+ argumentsList: callExpression.arguments
66002
+ });
66003
+ if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
66004
+ return null;
66005
+ }
65914
66006
  if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
65915
66007
  const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
65916
66008
  if (propertyName === null) return null;
65917
- const requiredModuleSpecifier = getRequireModuleSpecifier(target.expression);
66009
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
65918
66010
  if (requiredModuleSpecifier !== null) {
65919
- if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
65920
- if (!requiredModuleSpecifier.startsWith(".")) return null;
65921
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
65922
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
66011
+ 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;
66012
+ if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
66013
+ const hasCompilerTransform = analyzeImportedConfig({
66014
+ analysis,
66015
+ moduleSpecifier: requiredModuleSpecifier,
66016
+ exportName: propertyName,
66017
+ allowCompilerTransform,
66018
+ argumentsList: callExpression.arguments
66019
+ });
66020
+ if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
66021
+ return null;
65923
66022
  }
65924
66023
  if (!ts.isIdentifier(target.expression)) return null;
65925
- const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
65926
- if (importBinding?.isNamespace && importBinding.moduleSpecifier.startsWith(".")) {
65927
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
65928
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
66024
+ const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
66025
+ if (importBinding?.isNamespace) {
66026
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
66027
+ const hasCompilerTransform = analyzeImportedConfig({
66028
+ analysis,
66029
+ moduleSpecifier: importBinding.moduleSpecifier,
66030
+ exportName: propertyName,
66031
+ allowCompilerTransform,
66032
+ argumentsList: callExpression.arguments
66033
+ });
66034
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
66035
+ return null;
65929
66036
  }
65930
66037
  const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
65931
66038
  if (selectedProperty === null) return null;
@@ -65943,25 +66050,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
65943
66050
  const reactCompilerFlagState = excludedPropertyNames?.has("reactCompiler") ? null : getReactCompilerFlagState(node, analysis);
65944
66051
  if (reactCompilerFlagState?.isEnabled) return true;
65945
66052
  for (const [propertyIndex, property] of node.properties.entries()) if (ts.isPropertyAssignment(property)) {
65946
- const propertyName = getStaticPropertyName$1(property.name);
66053
+ const propertyName = getStaticPropertyName$2(property.name);
65947
66054
  if (propertyName && excludedPropertyNames?.has(propertyName)) continue;
65948
66055
  if (propertyName === "reactCompiler") continue;
65949
- 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;
66056
+ 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;
65950
66057
  const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
65951
- if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer) && property.initializer.text.startsWith(".")) {
65952
- const extendedFilePath = resolveImportedConfigFile(analysis.filePath, property.initializer.text);
65953
- if (extendedFilePath && analyzeConfigModuleExport(extendedFilePath, "default", false, analysis.importDepth + 1, analysis.visitedModules)) return true;
66058
+ if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
66059
+ if (analyzeImportedConfig({
66060
+ analysis,
66061
+ moduleSpecifier: property.initializer.text,
66062
+ exportName: "default",
66063
+ allowCompilerTransform: false
66064
+ })) return true;
65954
66065
  }
65955
66066
  if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
65956
66067
  } else if (ts.isShorthandPropertyAssignment(property)) {
65957
66068
  if (excludedPropertyNames?.has(property.name.text)) continue;
65958
66069
  if (property.name.text === "reactCompiler") continue;
65959
- 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;
66070
+ 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;
65960
66071
  const propertyAllowsCompilerTransform = property.name.text === "plugins" || property.name.text === "presets";
65961
66072
  if (analyzeConfigNode(property.name, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
65962
66073
  } else if (ts.isSpreadAssignment(property)) {
65963
66074
  if (reactCompilerFlagState && getReactCompilerFlagState(property.expression, analysis) !== null) continue;
65964
- 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;
66075
+ 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;
65965
66076
  if (analyzeConfigNode(property.expression, analysis, allowCompilerTransform, false, excludedPropertyNames)) return true;
65966
66077
  }
65967
66078
  return false;
@@ -65974,23 +66085,36 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
65974
66085
  });
65975
66086
  }
65976
66087
  if (ts.isCallExpression(node)) {
66088
+ const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
66089
+ if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
65977
66090
  const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
65978
66091
  if (callTargetResult !== null) return callTargetResult;
65979
- const directModuleSpecifier = getRequireModuleSpecifier(node);
66092
+ const directModuleSpecifier = getRequireModuleSpecifier$1(node);
65980
66093
  const isRequireShadowed = analysis.localBindings.has("require") || ts.isIdentifier(node.expression) && getScopedConfigBinding(node.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require");
65981
66094
  if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
65982
66095
  if (directModuleSpecifier && !isRequireShadowed) {
65983
66096
  if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
65984
- if (directModuleSpecifier.startsWith(".")) {
65985
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, directModuleSpecifier);
65986
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, "default", allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
65987
- }
66097
+ if (analyzeImportedConfig({
66098
+ analysis,
66099
+ moduleSpecifier: directModuleSpecifier,
66100
+ exportName: "default",
66101
+ allowCompilerTransform
66102
+ })) return true;
65988
66103
  }
65989
66104
  if (ts.isIdentifier(node.expression)) {
65990
- const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
65991
- if (importBinding?.moduleSpecifier.startsWith(".")) {
65992
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
65993
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, node.arguments));
66105
+ if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
66106
+ const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
66107
+ if (importBinding) {
66108
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
66109
+ const hasCompilerTransform = analyzeImportedConfig({
66110
+ analysis,
66111
+ moduleSpecifier: importBinding.moduleSpecifier,
66112
+ exportName: importBinding.exportName,
66113
+ allowCompilerTransform,
66114
+ argumentsList: node.arguments
66115
+ });
66116
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
66117
+ }
65994
66118
  }
65995
66119
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
65996
66120
  if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
@@ -65998,27 +66122,31 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
65998
66122
  return analyzeConfigNode(node.expression, analysis, allowCompilerTransform) || node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false));
65999
66123
  }
66000
66124
  if (ts.isPropertyAccessExpression(node)) {
66001
- const requiredModuleSpecifier = getRequireModuleSpecifier(node.expression);
66125
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
66002
66126
  if (requiredModuleSpecifier) {
66003
- if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
66004
- if (requiredModuleSpecifier.startsWith(".")) {
66005
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
66006
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
66007
- }
66127
+ 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;
66128
+ if (analyzeImportedConfig({
66129
+ analysis,
66130
+ moduleSpecifier: requiredModuleSpecifier,
66131
+ exportName: node.name.text,
66132
+ allowCompilerTransform
66133
+ })) return true;
66008
66134
  return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
66009
66135
  }
66010
66136
  if (ts.isIdentifier(node.expression)) {
66011
- if (analysis.localBindings.has(node.expression.text)) {
66012
- const localInitializer = analysis.localBindings.get(node.expression.text);
66013
- return Boolean(localInitializer && analyzeConfigNode(localInitializer, analysis, allowCompilerTransform));
66137
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
66138
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
66139
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
66014
66140
  }
66015
66141
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
66016
66142
  if (importBinding?.isNamespace) {
66017
66143
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
66018
- if (importBinding.moduleSpecifier.startsWith(".")) {
66019
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
66020
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
66021
- }
66144
+ if (analyzeImportedConfig({
66145
+ analysis,
66146
+ moduleSpecifier: importBinding.moduleSpecifier,
66147
+ exportName: node.name.text,
66148
+ allowCompilerTransform
66149
+ })) return true;
66022
66150
  return false;
66023
66151
  }
66024
66152
  const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
@@ -66029,13 +66157,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
66029
66157
  }
66030
66158
  if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
66031
66159
  if (ts.isIdentifier(node.expression)) {
66160
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
66161
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
66162
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
66163
+ }
66032
66164
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
66033
66165
  if (importBinding?.isNamespace) {
66034
66166
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
66035
- if (importBinding.moduleSpecifier.startsWith(".")) {
66036
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
66037
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.argumentExpression.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
66038
- }
66167
+ return Boolean(analyzeImportedConfig({
66168
+ analysis,
66169
+ moduleSpecifier: importBinding.moduleSpecifier,
66170
+ exportName: node.argumentExpression.text,
66171
+ allowCompilerTransform
66172
+ }));
66039
66173
  }
66040
66174
  const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
66041
66175
  if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
@@ -66073,14 +66207,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
66073
66207
  };
66074
66208
  const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
66075
66209
  const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
66076
- const hasCompilerInPackageJsonConfig = (packageJson) => isPlainObject(packageJson.babel) && analyzeConfigSourceFileExport(ts.parseJsonText("package.json", JSON.stringify(packageJson.babel)), "package.json#babel", "default", false, 0, /* @__PURE__ */ new Set());
66077
- const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
66210
+ const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
66211
+ if (!isPlainObject(packageJson.babel)) return false;
66212
+ const packageJsonPath = Path.join(directory, "package.json");
66213
+ return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
66214
+ };
66215
+ const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
66078
66216
  const hasCompilerConfigurationInAncestors = (directory) => {
66079
66217
  if (isProjectBoundary(directory)) return false;
66080
66218
  let ancestorDirectory = Path.dirname(directory);
66081
66219
  while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
66082
66220
  const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
66083
- if (hasCompilerInPackageJsonConfig(isFile(ancestorPackagePath) ? readPackageJson$1(ancestorPackagePath) : {}) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
66221
+ const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson$1(ancestorPackagePath) : {};
66222
+ if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
66084
66223
  if (isProjectBoundary(ancestorDirectory)) return false;
66085
66224
  ancestorDirectory = Path.dirname(ancestorDirectory);
66086
66225
  }
@@ -69335,7 +69474,7 @@ const warn = (message) => {
69335
69474
  runSync(warn$1(message));
69336
69475
  };
69337
69476
  const CONFIG_BASENAME = "doctor.config";
69338
- const CONFIG_EXTENSIONS = [
69477
+ const CONFIG_EXTENSIONS$1 = [
69339
69478
  "ts",
69340
69479
  "mts",
69341
69480
  "cts",
@@ -69439,7 +69578,7 @@ const loadLegacyConfig = (directory) => {
69439
69578
  };
69440
69579
  const loadConfigFromDirectory = async (directory) => {
69441
69580
  let sawBrokenConfigFile = false;
69442
- for (const extension of CONFIG_EXTENSIONS) {
69581
+ for (const extension of CONFIG_EXTENSIONS$1) {
69443
69582
  const filePath = Path.join(directory, `${CONFIG_BASENAME}.${extension}`);
69444
69583
  if (!isFile(filePath)) continue;
69445
69584
  const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
@@ -69498,7 +69637,7 @@ const loadConfigWithSource = (rootDirectory) => {
69498
69637
  return loadPromise;
69499
69638
  };
69500
69639
  const directoryHasCurrentConfig = (directory) => {
69501
- for (const extension of CONFIG_EXTENSIONS) if (isFile(Path.join(directory, `${CONFIG_BASENAME}.${extension}`))) return true;
69640
+ for (const extension of CONFIG_EXTENSIONS$1) if (isFile(Path.join(directory, `${CONFIG_BASENAME}.${extension}`))) return true;
69502
69641
  return readEmbeddedPackageJsonConfig(directory) !== null;
69503
69642
  };
69504
69643
  /**
@@ -70202,6 +70341,321 @@ const buildReactNativeDiagnostic = (input) => ({
70202
70341
  column: input.column ?? 0,
70203
70342
  category: input.category ?? "Correctness"
70204
70343
  });
70344
+ const ANDROID_APP_BUILD_FILE_NAMES = ["build.gradle", "build.gradle.kts"];
70345
+ const BUILD_TYPES_BLOCK_PATTERN = /\bbuildTypes\s*\{/g;
70346
+ const RELEASE_STRING_MARKER = "__RD_RELEASE__";
70347
+ const RELEASE_BLOCK_PATTERNS = [/\brelease\s*\{/g, /\b(?:getByName|named)\s*\(\s*(?:["']release["']|__RD_RELEASE__)\s*\)\s*\{/g];
70348
+ const MINIFY_ASSIGNMENT_PATTERN = /\b(?:isMinifyEnabled|minifyEnabled)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
70349
+ const SHRINK_RESOURCES_ASSIGNMENT_PATTERN = /\b(?:isShrinkResources|shrinkResources)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
70350
+ const stripGradleComments = (contents) => {
70351
+ let result = "";
70352
+ let index = 0;
70353
+ let quote = null;
70354
+ while (index < contents.length) {
70355
+ const character = contents[index];
70356
+ const nextCharacter = contents[index + 1];
70357
+ if (quote !== null) {
70358
+ result += character;
70359
+ if (character === "\\") {
70360
+ result += nextCharacter ?? "";
70361
+ index += 2;
70362
+ continue;
70363
+ }
70364
+ if (character === quote) quote = null;
70365
+ index += 1;
70366
+ continue;
70367
+ }
70368
+ if (character === "\"" || character === "'") {
70369
+ quote = character;
70370
+ result += character;
70371
+ index += 1;
70372
+ continue;
70373
+ }
70374
+ if (character === "/" && nextCharacter === "/") {
70375
+ while (index < contents.length && contents[index] !== "\n") {
70376
+ result += " ";
70377
+ index += 1;
70378
+ }
70379
+ continue;
70380
+ }
70381
+ if (character === "/" && nextCharacter === "*") {
70382
+ result += " ";
70383
+ index += 2;
70384
+ while (index < contents.length && !(contents[index] === "*" && contents[index + 1] === "/")) {
70385
+ result += contents[index] === "\n" ? "\n" : " ";
70386
+ index += 1;
70387
+ }
70388
+ if (index < contents.length) {
70389
+ result += " ";
70390
+ index += 2;
70391
+ }
70392
+ continue;
70393
+ }
70394
+ result += character;
70395
+ index += 1;
70396
+ }
70397
+ return result;
70398
+ };
70399
+ const maskGradleStrings = (contents) => {
70400
+ let result = "";
70401
+ let index = 0;
70402
+ let quote = null;
70403
+ while (index < contents.length) {
70404
+ const character = contents[index];
70405
+ if (quote === null) {
70406
+ if (character === "\"" || character === "'") {
70407
+ quote = character;
70408
+ result += " ";
70409
+ } else result += character;
70410
+ index += 1;
70411
+ continue;
70412
+ }
70413
+ if (character === "\\") {
70414
+ result += " ";
70415
+ index += 2;
70416
+ continue;
70417
+ }
70418
+ if (character === quote) quote = null;
70419
+ result += character === "\n" ? "\n" : " ";
70420
+ index += 1;
70421
+ }
70422
+ return result;
70423
+ };
70424
+ const findBlockContents = (contents, pattern) => {
70425
+ const blocks = [];
70426
+ pattern.lastIndex = 0;
70427
+ let match = pattern.exec(contents);
70428
+ while (match !== null) {
70429
+ const openingBraceIndex = pattern.lastIndex - 1;
70430
+ let depth = 1;
70431
+ let index = openingBraceIndex + 1;
70432
+ let quote = null;
70433
+ while (index < contents.length && depth > 0) {
70434
+ const character = contents[index];
70435
+ if (quote !== null) {
70436
+ if (character === "\\") {
70437
+ index += 2;
70438
+ continue;
70439
+ }
70440
+ if (character === quote) quote = null;
70441
+ } else if (character === "\"" || character === "'") quote = character;
70442
+ else if (character === "{") depth += 1;
70443
+ else if (character === "}") depth -= 1;
70444
+ index += 1;
70445
+ }
70446
+ if (depth === 0) blocks.push(contents.slice(openingBraceIndex + 1, index - 1));
70447
+ match = pattern.exec(contents);
70448
+ }
70449
+ return blocks;
70450
+ };
70451
+ const getFinalStaticBoolean = (contents, pattern) => {
70452
+ pattern.lastIndex = 0;
70453
+ let finalValue = null;
70454
+ let match = pattern.exec(contents);
70455
+ while (match !== null) {
70456
+ const staticValue = match[1]?.trim().replace(/\)$/, "").trim();
70457
+ if (staticValue === "true") finalValue = true;
70458
+ else if (staticValue === "false") finalValue = false;
70459
+ else finalValue = null;
70460
+ match = pattern.exec(contents);
70461
+ }
70462
+ return finalValue;
70463
+ };
70464
+ const getReleaseBlocks = (contents) => findBlockContents(contents, BUILD_TYPES_BLOCK_PATTERN).flatMap((buildTypesBlock) => RELEASE_BLOCK_PATTERNS.flatMap((pattern) => findBlockContents(buildTypesBlock, pattern)));
70465
+ const readAndroidReleaseShrinking = (rootDirectory) => {
70466
+ for (const buildFileName of ANDROID_APP_BUILD_FILE_NAMES) {
70467
+ const filePath = Path.posix.join("android", "app", buildFileName);
70468
+ const absoluteFilePath = Path.join(rootDirectory, filePath);
70469
+ if (!isFile(absoluteFilePath)) continue;
70470
+ let contents;
70471
+ try {
70472
+ contents = stripGradleComments(NFS.readFileSync(absoluteFilePath, "utf-8"));
70473
+ } catch {
70474
+ return null;
70475
+ }
70476
+ const releaseBlocks = getReleaseBlocks(maskGradleStrings(contents.replace(/(["'])release\1/g, RELEASE_STRING_MARKER)));
70477
+ const [releaseBlock] = releaseBlocks;
70478
+ if (releaseBlock === void 0 || releaseBlocks.length !== 1) return null;
70479
+ const hasDisabledMinification = getFinalStaticBoolean(releaseBlock, MINIFY_ASSIGNMENT_PATTERN) === false;
70480
+ const hasDisabledResourceShrinking = getFinalStaticBoolean(releaseBlock, SHRINK_RESOURCES_ASSIGNMENT_PATTERN) === false;
70481
+ if (!hasDisabledMinification && !hasDisabledResourceShrinking) return null;
70482
+ return {
70483
+ filePath,
70484
+ hasDisabledMinification,
70485
+ hasDisabledResourceShrinking
70486
+ };
70487
+ }
70488
+ return null;
70489
+ };
70490
+ const checkReactNativeAndroidReleaseShrinking = (rootDirectory) => {
70491
+ const releaseShrinking = readAndroidReleaseShrinking(rootDirectory);
70492
+ if (releaseShrinking === null) return [];
70493
+ const disabledFeatures = [releaseShrinking.hasDisabledMinification ? "code minification" : null, releaseShrinking.hasDisabledResourceShrinking ? "resource shrinking" : null].filter((feature) => feature !== null);
70494
+ return [buildReactNativeDiagnostic({
70495
+ filePath: releaseShrinking.filePath,
70496
+ rule: "rn-android-release-shrinking-disabled",
70497
+ category: "Performance",
70498
+ message: `The Android release build explicitly disables ${disabledFeatures.join(" and ")}, leaving unreachable code or resources in the shipped app.`,
70499
+ help: "Enable release code minification and resource shrinking, then test the optimized build and add keep rules for libraries that require them."
70500
+ })];
70501
+ };
70502
+ const getTypescriptScriptKind = (fileName) => {
70503
+ if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
70504
+ if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
70505
+ if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
70506
+ return ts.ScriptKind.JS;
70507
+ };
70508
+ const unwrapTypescriptExpression = (expression) => {
70509
+ let currentExpression = expression;
70510
+ while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
70511
+ return currentExpression;
70512
+ };
70513
+ const BABEL_CONFIG_FILE_NAMES$1 = [
70514
+ "babel.config.js",
70515
+ "babel.config.cjs",
70516
+ "babel.config.mjs",
70517
+ "babel.config.ts",
70518
+ "babel.config.cts",
70519
+ "babel.config.json",
70520
+ ".babelrc",
70521
+ ".babelrc.js",
70522
+ ".babelrc.cjs",
70523
+ ".babelrc.mjs",
70524
+ ".babelrc.cts",
70525
+ ".babelrc.json"
70526
+ ];
70527
+ const readUnknownPluginNames = (value) => {
70528
+ if (!Array.isArray(value)) return null;
70529
+ const pluginNames = [];
70530
+ for (const entry of value) {
70531
+ if (typeof entry === "string") {
70532
+ pluginNames.push(entry);
70533
+ continue;
70534
+ }
70535
+ if (Array.isArray(entry) && typeof entry[0] === "string") {
70536
+ pluginNames.push(entry[0]);
70537
+ continue;
70538
+ }
70539
+ return null;
70540
+ }
70541
+ return pluginNames;
70542
+ };
70543
+ const getStaticPropertyName$1 = (propertyName) => {
70544
+ if (ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName)) return propertyName.text;
70545
+ return null;
70546
+ };
70547
+ const getStaticPluginName = (expression) => {
70548
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
70549
+ if (ts.isStringLiteralLike(unwrappedExpression)) return unwrappedExpression.text;
70550
+ if (!ts.isArrayLiteralExpression(unwrappedExpression)) return null;
70551
+ const pluginExpression = unwrappedExpression.elements[0];
70552
+ return pluginExpression && ts.isStringLiteralLike(pluginExpression) ? pluginExpression.text : null;
70553
+ };
70554
+ const getPluginNamesFromObject = (objectExpression) => {
70555
+ if (objectExpression.properties.some((property) => ts.isSpreadAssignment(property))) return null;
70556
+ const pluginProperties = objectExpression.properties.filter((property) => ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === "plugins");
70557
+ if (pluginProperties.length !== 1) return pluginProperties.length === 0 ? [] : null;
70558
+ const pluginListExpression = unwrapTypescriptExpression(pluginProperties[0].initializer);
70559
+ if (!ts.isArrayLiteralExpression(pluginListExpression)) return null;
70560
+ const pluginNames = [];
70561
+ for (const element of pluginListExpression.elements) {
70562
+ if (ts.isSpreadElement(element)) return null;
70563
+ const pluginName = getStaticPluginName(element);
70564
+ if (pluginName === null) return null;
70565
+ pluginNames.push(pluginName);
70566
+ }
70567
+ return pluginNames;
70568
+ };
70569
+ 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";
70570
+ const getDirectExportedObject = (sourceFile) => {
70571
+ const exportedExpressions = [];
70572
+ for (const statement of sourceFile.statements) {
70573
+ if (ts.isExportAssignment(statement)) {
70574
+ exportedExpressions.push(statement.expression);
70575
+ continue;
70576
+ }
70577
+ if (ts.isExpressionStatement(statement) && ts.isBinaryExpression(statement.expression) && statement.expression.operatorToken.kind === ts.SyntaxKind.EqualsToken && isModuleExports(statement.expression.left)) exportedExpressions.push(statement.expression.right);
70578
+ }
70579
+ if (exportedExpressions.length !== 1) return null;
70580
+ const exportedExpression = unwrapTypescriptExpression(exportedExpressions[0]);
70581
+ return ts.isObjectLiteralExpression(exportedExpression) ? exportedExpression : null;
70582
+ };
70583
+ const parseConfigPluginNames = (filePath, contents) => {
70584
+ try {
70585
+ const parsedJson = JSON.parse(contents);
70586
+ return isPlainObject(parsedJson) ? readUnknownPluginNames(parsedJson.plugins) : null;
70587
+ } catch {
70588
+ if (ts.transpileModule(contents, {
70589
+ fileName: filePath,
70590
+ reportDiagnostics: true,
70591
+ compilerOptions: { allowJs: true }
70592
+ }).diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) return null;
70593
+ const exportedObject = getDirectExportedObject(ts.createSourceFile(filePath, contents, ts.ScriptTarget.Latest, true, getTypescriptScriptKind(filePath)));
70594
+ return exportedObject === null ? null : getPluginNamesFromObject(exportedObject);
70595
+ }
70596
+ };
70597
+ const readStaticBabelPluginNames = (rootDirectory) => {
70598
+ for (const fileName of BABEL_CONFIG_FILE_NAMES$1) {
70599
+ const absoluteFilePath = Path.join(rootDirectory, fileName);
70600
+ if (!isFile(absoluteFilePath)) continue;
70601
+ try {
70602
+ return {
70603
+ filePath: fileName,
70604
+ pluginNames: parseConfigPluginNames(fileName, NFS.readFileSync(absoluteFilePath, "utf-8"))
70605
+ };
70606
+ } catch {
70607
+ return {
70608
+ filePath: fileName,
70609
+ pluginNames: null
70610
+ };
70611
+ }
70612
+ }
70613
+ const packageJson = readPackageJson$1(Path.join(rootDirectory, "package.json"));
70614
+ if (!isPlainObject(packageJson.babel)) return null;
70615
+ return {
70616
+ filePath: "package.json",
70617
+ pluginNames: readUnknownPluginNames(packageJson.babel.plugins)
70618
+ };
70619
+ };
70620
+ const REACT_COMPILER_PLUGIN_NAMES = new Set(["babel-plugin-react-compiler", "react-compiler"]);
70621
+ const REANIMATED_PLUGIN_NAME = "react-native-reanimated/plugin";
70622
+ const WORKLETS_PLUGIN_NAME = "react-native-worklets/plugin";
70623
+ const checkReactCompilerPluginOrder = (filePath, pluginNames) => {
70624
+ if (pluginNames.findIndex((pluginName) => REACT_COMPILER_PLUGIN_NAMES.has(pluginName)) <= 0) return [];
70625
+ return [buildReactNativeDiagnostic({
70626
+ filePath,
70627
+ rule: "rn-react-compiler-plugin-first",
70628
+ category: "Performance",
70629
+ message: "The React Compiler Babel plugin is not first, so an earlier transform can change component or hook code before the compiler analyzes it.",
70630
+ help: "Move `babel-plugin-react-compiler` to the first entry in the Babel `plugins` array."
70631
+ })];
70632
+ };
70633
+ const checkReanimatedPluginOrder = (project, filePath, pluginNames) => {
70634
+ const reanimatedMajorVersion = project.reanimatedVersion === null || project.reanimatedVersion === void 0 ? null : getLowestDependencyMajor(project.reanimatedVersion);
70635
+ if (reanimatedMajorVersion === null || reanimatedMajorVersion < 4) return [];
70636
+ const diagnostics = [];
70637
+ if (pluginNames.includes(REANIMATED_PLUGIN_NAME)) diagnostics.push(buildReactNativeDiagnostic({
70638
+ filePath,
70639
+ rule: "rn-reanimated-worklets-plugin-last",
70640
+ category: "Performance",
70641
+ message: "This Reanimated 4 project still uses `react-native-reanimated/plugin`, which was renamed to the Worklets Babel plugin.",
70642
+ help: "Replace it with `react-native-worklets/plugin` and keep that plugin last in the Babel `plugins` array."
70643
+ }));
70644
+ const workletsPluginIndex = pluginNames.lastIndexOf(WORKLETS_PLUGIN_NAME);
70645
+ if (workletsPluginIndex !== -1 && workletsPluginIndex !== pluginNames.length - 1) diagnostics.push(buildReactNativeDiagnostic({
70646
+ filePath,
70647
+ rule: "rn-reanimated-worklets-plugin-last",
70648
+ category: "Performance",
70649
+ message: "`react-native-worklets/plugin` is not last in the Babel `plugins` array, so later transforms can prevent worklets from being compiled correctly.",
70650
+ help: "Move `react-native-worklets/plugin` to the final entry in the Babel `plugins` array."
70651
+ }));
70652
+ return diagnostics;
70653
+ };
70654
+ const checkReactNativeBabelPluginOrder = (rootDirectory, project) => {
70655
+ const babelPlugins = readStaticBabelPluginNames(rootDirectory);
70656
+ if (babelPlugins === null || babelPlugins.pluginNames === null) return [];
70657
+ return [...checkReactCompilerPluginOrder(babelPlugins.filePath, babelPlugins.pluginNames), ...checkReanimatedPluginOrder(project, babelPlugins.filePath, babelPlugins.pluginNames)];
70658
+ };
70205
70659
  const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
70206
70660
  const isBuilderBobLibrary = (packageJson) => {
70207
70661
  const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
@@ -70278,7 +70732,12 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
70278
70732
  const isReactNativeProject = (project) => project.framework === "react-native" || project.framework === "expo" || project.hasReactNativeWorkspace || project.expoVersion !== null;
70279
70733
  const checkReactNativeProject = (rootDirectory, project) => {
70280
70734
  if (!isReactNativeProject(project)) return [];
70281
- return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
70735
+ return [
70736
+ ...checkReactNativeMetroBabelPreset(rootDirectory),
70737
+ ...checkReactNativeBabelPluginOrder(rootDirectory, project),
70738
+ ...checkReactNativeAndroidReleaseShrinking(rootDirectory),
70739
+ ...checkReactNativeLibraryDependencies(rootDirectory)
70740
+ ];
70282
70741
  };
70283
70742
  const RULE_KEY = "no-vulnerable-react-server-components";
70284
70743
  const REACT_RSC_ADVISORIES_BY_MINOR = {
@@ -70429,17 +70888,6 @@ const checkReactServerComponentsAdvisory = (scanDirectory, project) => {
70429
70888
  }
70430
70889
  return diagnostics;
70431
70890
  };
70432
- const getTypescriptScriptKind = (fileName) => {
70433
- if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
70434
- if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
70435
- if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
70436
- return ts.ScriptKind.JS;
70437
- };
70438
- const unwrapTypescriptExpression = (expression) => {
70439
- let currentExpression = expression;
70440
- while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
70441
- return currentExpression;
70442
- };
70443
70891
  const EMPTY_MOTION_EXPRESSION_EVIDENCE = {
70444
70892
  isAnimationFunction: false,
70445
70893
  isMotionComponent: false,
@@ -70995,7 +71443,11 @@ const buildCapabilities = (project) => {
70995
71443
  capabilities.add(project.framework);
70996
71444
  if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
70997
71445
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
70998
- if (project.expoVersion !== null) capabilities.add("expo");
71446
+ if (project.expoVersion !== null) {
71447
+ capabilities.add("expo");
71448
+ const expoSdkMajorVersion = getLowestDependencyMajor(project.expoVersion);
71449
+ if (expoSdkMajorVersion !== null && expoSdkMajorVersion >= 54) capabilities.add("expo:54");
71450
+ }
70999
71451
  if ((project.framework === "nextjs" || project.framework === "tanstack-start" || project.framework === "remix") && !project.isStaticExport) capabilities.add("server-actions");
71000
71452
  if (SSR_FRAMEWORKS.has(project.framework) || project.hasSsrDependency) capabilities.add("ssr");
71001
71453
  if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
@@ -71059,6 +71511,11 @@ const buildCapabilities = (project) => {
71059
71511
  if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
71060
71512
  if (project.isPreES2023Target) capabilities.add("pre-es2023");
71061
71513
  if (project.hasReactCompiler) capabilities.add("react-compiler");
71514
+ if (project.reanimatedVersion !== void 0 && project.reanimatedVersion !== null) {
71515
+ capabilities.add("reanimated");
71516
+ const reanimatedMajorVersion = getLowestDependencyMajor(project.reanimatedVersion);
71517
+ if (reanimatedMajorVersion !== null && reanimatedMajorVersion >= 4) capabilities.add("reanimated:4");
71518
+ }
71062
71519
  if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
71063
71520
  if (project.styledComponentsVersion) {
71064
71521
  capabilities.add("styled-components");
@@ -72972,7 +73429,11 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
72972
73429
  const ROOT_DIRECTORY_PLACEHOLDER = "<root>";
72973
73430
  const normalizeConfigForHash = (config) => {
72974
73431
  const clone = JSON.parse(JSON.stringify(config));
72975
- if (clone?.settings?.["react-doctor"]) clone.settings["react-doctor"].rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
73432
+ if (clone?.settings?.["react-doctor"]) {
73433
+ const reactDoctorSettings = clone.settings["react-doctor"];
73434
+ reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
73435
+ if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
73436
+ }
72976
73437
  if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
72977
73438
  return clone;
72978
73439
  };
@@ -73131,13 +73592,14 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
73131
73592
  }
73132
73593
  return enabled;
73133
73594
  };
73134
- const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
73595
+ 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 }) => {
73135
73596
  const hasIncludedTags = includedTags.size > 0;
73136
73597
  const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
73137
73598
  const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
73138
73599
  const jsPlugins = [];
73139
73600
  if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
73140
73601
  const capabilities = getCapabilities(project);
73602
+ const settingsRootDirectory = resolveSettingsRootDirectory(project.rootDirectory);
73141
73603
  const enabledReactDoctorRules = {};
73142
73604
  for (const registryEntry of REACT_DOCTOR_RULES) {
73143
73605
  const rule = reactDoctorPlugin.rules[registryEntry.id];
@@ -73183,8 +73645,16 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
73183
73645
  jsPlugins: [...jsPlugins, pluginPath],
73184
73646
  settings: { "react-doctor": {
73185
73647
  framework: project.framework,
73186
- rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
73648
+ rootDirectory: settingsRootDirectory,
73187
73649
  capabilities: [...capabilities].sort(),
73650
+ ...runtimeGlobals && runtimeGlobals.length > 0 ? { runtimeGlobals: [...runtimeGlobals] } : {},
73651
+ ...unpluginAutoImportGlobalScopes && unpluginAutoImportGlobalScopes.length > 0 ? {
73652
+ unpluginAutoImportRootDirectories: [...new Set([settingsRootDirectory, project.rootDirectory])],
73653
+ unpluginAutoImportGlobalScopes: unpluginAutoImportGlobalScopes.map((scope) => ({
73654
+ directory: scope.directory,
73655
+ names: [...scope.names]
73656
+ }))
73657
+ } : {},
73188
73658
  ...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
73189
73659
  ...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
73190
73660
  } },
@@ -73195,6 +73665,245 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
73195
73665
  }
73196
73666
  };
73197
73667
  };
73668
+ const AUTO_IMPORT_ADAPTER_PATTERN = /^unplugin-auto-import\/(?:astro|esbuild|rollup|rolldown|rspack|vite|webpack)$/;
73669
+ const CONFIG_BASENAMES = [
73670
+ "astro.config",
73671
+ "esbuild.config",
73672
+ "rollup.config",
73673
+ "rolldown.config",
73674
+ "rspack.config",
73675
+ "vite.config",
73676
+ "webpack.config"
73677
+ ];
73678
+ const CONFIG_EXTENSIONS = [
73679
+ ".cjs",
73680
+ ".cts",
73681
+ ".js",
73682
+ ".mjs",
73683
+ ".mts",
73684
+ ".ts"
73685
+ ];
73686
+ const CONFIG_FILENAMES = new Set(CONFIG_BASENAMES.flatMap((basename) => CONFIG_EXTENSIONS.map((extension) => `${basename}${extension}`)));
73687
+ const DEFAULT_ESLINT_GLOBALS_PATH = ".eslintrc-auto-import.json";
73688
+ const SUPPORTED_GLOBAL_VALUES = new Set([
73689
+ true,
73690
+ false,
73691
+ "readable",
73692
+ "readonly",
73693
+ "writable",
73694
+ "writeable"
73695
+ ]);
73696
+ const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
73697
+ if (ts.isSpreadAssignment(property)) return false;
73698
+ const name = ts.isComputedPropertyName(property.name) ? unwrapTypescriptExpression(property.name.expression) : property.name;
73699
+ return (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) && name.text === propertyName;
73700
+ }) ?? null;
73701
+ const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !ts.isSpreadAssignment(property) && ts.isComputedPropertyName(property.name) && !ts.isStringLiteralLike(unwrapTypescriptExpression(property.name.expression)));
73702
+ const getStaticPropertyAssignment = (objectExpression, propertyName) => {
73703
+ const property = getStaticProperty(objectExpression, propertyName);
73704
+ return property && ts.isPropertyAssignment(property) ? property : null;
73705
+ };
73706
+ const getRequireModuleSpecifier = (expression) => {
73707
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
73708
+ if (ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "default") return getRequireModuleSpecifier(unwrappedExpression.expression);
73709
+ if (!ts.isCallExpression(unwrappedExpression) || !ts.isIdentifier(unwrappedExpression.expression) || unwrappedExpression.expression.text !== "require" || unwrappedExpression.arguments.length !== 1) return null;
73710
+ const moduleSpecifier = unwrappedExpression.arguments[0];
73711
+ return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
73712
+ };
73713
+ const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
73714
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
73715
+ return ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
73716
+ };
73717
+ 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");
73718
+ const isTopLevelExpression = (node) => {
73719
+ let ancestor = node.parent;
73720
+ while (ancestor && !ts.isSourceFile(ancestor)) {
73721
+ if (ts.isExpressionStatement(ancestor)) return ts.isSourceFile(ancestor.parent);
73722
+ if (!ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isAwaitExpression(ancestor)) return false;
73723
+ ancestor = ancestor.parent;
73724
+ }
73725
+ return false;
73726
+ };
73727
+ const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
73728
+ let ancestor = node.parent;
73729
+ let didFindConfigProperty = false;
73730
+ while (ancestor && !ts.isSourceFile(ancestor)) {
73731
+ 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;
73732
+ if (ts.isPropertyAssignment(ancestor)) {
73733
+ const isConfigProperty = (ts.isIdentifier(ancestor.name) || ts.isStringLiteralLike(ancestor.name)) && ancestor.name.text === propertyName;
73734
+ if (didFindConfigProperty || !isConfigProperty) return false;
73735
+ if (!ts.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(ts.isSpreadAssignment)) return false;
73736
+ didFindConfigProperty = true;
73737
+ ancestor = ancestor.parent;
73738
+ continue;
73739
+ }
73740
+ if (didFindConfigProperty) {
73741
+ if (ts.isExportAssignment(ancestor)) return true;
73742
+ if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
73743
+ 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);
73744
+ 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;
73745
+ }
73746
+ ancestor = ancestor.parent;
73747
+ }
73748
+ return false;
73749
+ };
73750
+ const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory) => {
73751
+ const optionsExpression = callExpression.arguments[0];
73752
+ if (!optionsExpression) return null;
73753
+ const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
73754
+ if (!ts.isObjectLiteralExpression(unwrappedOptions)) return null;
73755
+ if (unwrappedOptions.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
73756
+ if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
73757
+ const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
73758
+ if (!eslintrcProperty) return null;
73759
+ const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
73760
+ if (!ts.isObjectLiteralExpression(eslintrcExpression)) return null;
73761
+ if (eslintrcExpression.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
73762
+ const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
73763
+ if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== ts.SyntaxKind.TrueKeyword) return null;
73764
+ const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
73765
+ if (!filepathProperty) return Path.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
73766
+ if (!ts.isPropertyAssignment(filepathProperty)) return null;
73767
+ const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
73768
+ return ts.isStringLiteralLike(filepathExpression) ? Path.resolve(packageDirectory, filepathExpression.text) : null;
73769
+ };
73770
+ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
73771
+ let sourceText;
73772
+ try {
73773
+ sourceText = NFS.readFileSync(configPath, "utf8");
73774
+ } catch {
73775
+ return {
73776
+ didFindActiveAutoImport: false,
73777
+ globalsPaths: []
73778
+ };
73779
+ }
73780
+ const sourceFile = ts.createSourceFile(configPath, sourceText, ts.ScriptTarget.Latest, true);
73781
+ const autoImportBindings = /* @__PURE__ */ new Map();
73782
+ const esbuildBindings = /* @__PURE__ */ new Set();
73783
+ const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
73784
+ for (const statement of sourceFile.statements) {
73785
+ if (ts.isImportDeclaration(statement) && ts.isStringLiteralLike(statement.moduleSpecifier)) {
73786
+ const moduleSpecifier = statement.moduleSpecifier.text;
73787
+ if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
73788
+ const defaultBinding = statement.importClause?.name;
73789
+ if (defaultBinding) autoImportBindings.set(defaultBinding.text, moduleSpecifier);
73790
+ }
73791
+ if (moduleSpecifier === "esbuild") {
73792
+ const defaultBinding = statement.importClause?.name;
73793
+ if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
73794
+ const namedBindings = statement.importClause?.namedBindings;
73795
+ if (namedBindings && ts.isNamedImports(namedBindings)) {
73796
+ for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
73797
+ }
73798
+ if (namedBindings && ts.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
73799
+ }
73800
+ }
73801
+ if (!ts.isVariableStatement(statement)) continue;
73802
+ for (const declaration of statement.declarationList.declarations) {
73803
+ if (!declaration.initializer) continue;
73804
+ const declarationName = ts.isIdentifier(declaration.name) ? declaration.name.text : null;
73805
+ const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
73806
+ if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
73807
+ if (moduleSpecifier === "esbuild") {
73808
+ if (declarationName) esbuildNamespaceBindings.add(declarationName);
73809
+ if (ts.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
73810
+ const importedName = bindingElement.propertyName ?? bindingElement.name;
73811
+ if (ts.isIdentifier(importedName) && importedName.text === "build" && ts.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
73812
+ }
73813
+ }
73814
+ if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
73815
+ }
73816
+ }
73817
+ const globalsPaths = /* @__PURE__ */ new Set();
73818
+ let didFindActiveAutoImport = false;
73819
+ let didFindUnsafeActiveAutoImport = false;
73820
+ const visit = (node) => {
73821
+ if (ts.isCallExpression(node)) {
73822
+ const moduleSpecifier = ts.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
73823
+ if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
73824
+ if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
73825
+ didFindActiveAutoImport = true;
73826
+ const globalsPath = getGlobalsPathFromActiveAutoImportCall(node, packageDirectory);
73827
+ if (globalsPath) globalsPaths.add(globalsPath);
73828
+ else didFindUnsafeActiveAutoImport = true;
73829
+ }
73830
+ }
73831
+ }
73832
+ ts.forEachChild(node, visit);
73833
+ };
73834
+ visit(sourceFile);
73835
+ return {
73836
+ didFindActiveAutoImport,
73837
+ globalsPaths: didFindUnsafeActiveAutoImport ? [] : [...globalsPaths]
73838
+ };
73839
+ };
73840
+ const collectGeneratedGlobalNames = (globalsPath, rootDirectory) => {
73841
+ const relativePath = Path.relative(rootDirectory, globalsPath);
73842
+ if (relativePath.startsWith("..") || Path.isAbsolute(relativePath)) return [];
73843
+ const parsed = failOpenReadJson(globalsPath, null);
73844
+ if (!isPlainObject(parsed) || !isPlainObject(parsed.globals)) return [];
73845
+ 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();
73846
+ };
73847
+ const findOwningPackageDirectory = (absoluteFilePath, rootDirectory, cache) => {
73848
+ let currentDirectory = Path.dirname(absoluteFilePath);
73849
+ const visitedDirectories = [];
73850
+ while (true) {
73851
+ const cachedDirectory = cache.get(currentDirectory);
73852
+ if (cachedDirectory !== void 0) {
73853
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, cachedDirectory);
73854
+ return cachedDirectory;
73855
+ }
73856
+ const relativeDirectory = Path.relative(rootDirectory, currentDirectory);
73857
+ if (relativeDirectory.startsWith("..") || Path.isAbsolute(relativeDirectory)) {
73858
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
73859
+ return null;
73860
+ }
73861
+ visitedDirectories.push(currentDirectory);
73862
+ if (NFS.existsSync(Path.join(currentDirectory, "package.json"))) {
73863
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, currentDirectory);
73864
+ return currentDirectory;
73865
+ }
73866
+ if (currentDirectory === rootDirectory) {
73867
+ for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
73868
+ return null;
73869
+ }
73870
+ currentDirectory = Path.dirname(currentDirectory);
73871
+ }
73872
+ };
73873
+ const collectPackageGlobalNames = (packageDirectory, rootDirectory) => {
73874
+ let directoryEntries;
73875
+ try {
73876
+ directoryEntries = NFS.readdirSync(packageDirectory, { withFileTypes: true });
73877
+ } catch {
73878
+ return [];
73879
+ }
73880
+ const configuredGlobalsPaths = [];
73881
+ for (const entry of directoryEntries) {
73882
+ if (!entry.isFile() && !entry.isSymbolicLink() || !CONFIG_FILENAMES.has(entry.name)) continue;
73883
+ const configGlobalsPaths = collectGlobalsPathsFromConfig(Path.join(packageDirectory, entry.name), packageDirectory);
73884
+ if (configGlobalsPaths.didFindActiveAutoImport) configuredGlobalsPaths.push(configGlobalsPaths.globalsPaths.toSorted());
73885
+ }
73886
+ if (configuredGlobalsPaths.length === 0) return [];
73887
+ const globalsPaths = configuredGlobalsPaths[0];
73888
+ if (configuredGlobalsPaths.some((candidatePaths) => candidatePaths.length !== globalsPaths.length || candidatePaths.some((candidatePath, index) => candidatePath !== globalsPaths[index]))) return [];
73889
+ const names = /* @__PURE__ */ new Set();
73890
+ for (const globalsPath of globalsPaths) for (const name of collectGeneratedGlobalNames(globalsPath, rootDirectory)) names.add(name);
73891
+ return [...names].sort();
73892
+ };
73893
+ const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }) => {
73894
+ const absoluteRootDirectory = Path.resolve(rootDirectory);
73895
+ const packageDirectoryCache = /* @__PURE__ */ new Map();
73896
+ const packageDirectories = /* @__PURE__ */ new Set();
73897
+ for (const candidateFile of candidateFiles) {
73898
+ const packageDirectory = findOwningPackageDirectory(Path.resolve(absoluteRootDirectory, candidateFile), absoluteRootDirectory, packageDirectoryCache);
73899
+ if (packageDirectory) packageDirectories.add(packageDirectory);
73900
+ }
73901
+ const scopes = [...packageDirectories].map((packageDirectory) => ({
73902
+ directory: Path.relative(absoluteRootDirectory, packageDirectory).replaceAll("\\", "/"),
73903
+ names: collectPackageGlobalNames(packageDirectory, absoluteRootDirectory)
73904
+ })).sort((firstScope, secondScope) => firstScope.directory.localeCompare(secondScope.directory));
73905
+ return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
73906
+ };
73198
73907
  const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
73199
73908
  const decodeFileDiagnostics = (raw) => {
73200
73909
  if (!Array.isArray(raw)) return null;
@@ -73517,6 +74226,12 @@ const appendReanimatedSharedValueHint = (help, rule, project) => {
73517
74226
  if (!help) return REANIMATED_SHARED_VALUE_HINT;
73518
74227
  return `${help}\n\n${REANIMATED_SHARED_VALUE_HINT}`;
73519
74228
  };
74229
+ const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
74230
+ const boundedOffset = Math.min(Math.max(utf8Offset, 0), sourceBuffer.length);
74231
+ let lineStartOffset = boundedOffset;
74232
+ while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
74233
+ return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
74234
+ };
73520
74235
  const REDACTED_PLACEHOLDER = "<redacted>";
73521
74236
  const KEEP_PREFIX = `$1${REDACTED_PLACEHOLDER}`;
73522
74237
  const KNOWN_SECRET_RULES = [
@@ -74232,7 +74947,7 @@ const resolveMatchByOccurrence = (rule, category) => OCCURRENCE_MATCHED_CATEGORI
74232
74947
  * with empty text still carry a useful jump target, so they're kept
74233
74948
  * with a neutral message.
74234
74949
  */
74235
- const buildRelatedLocations = (labels, filePath) => {
74950
+ const buildRelatedLocations = (labels, filePath, sourceBuffer) => {
74236
74951
  if (labels.length <= 1) return [];
74237
74952
  const related = [];
74238
74953
  for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
@@ -74240,8 +74955,8 @@ const buildRelatedLocations = (labels, filePath) => {
74240
74955
  if (!label?.span) continue;
74241
74956
  related.push({
74242
74957
  filePath,
74243
- line: label.span.line ?? 0,
74244
- column: label.span.column ?? 0,
74958
+ line: sourceBuffer === null ? label.span.line ?? 0 : lineOfUtf8Offset(sourceBuffer, label.span.offset),
74959
+ column: sourceBuffer === null ? label.span.column ?? 0 : columnOfUtf8Offset(sourceBuffer, label.span.offset),
74245
74960
  offset: label.span.offset,
74246
74961
  length: label.span.length,
74247
74962
  message: label.label ?? ""
@@ -74261,7 +74976,7 @@ const isOxlintOutput = (value) => isRecord$1(value) && Array.isArray(value.diagn
74261
74976
  * to the first `{`. Raises `OxlintOutputUnparseable` when the
74262
74977
  * stdout isn't valid JSON or doesn't carry a `diagnostics` array.
74263
74978
  */
74264
- const parseOxlintOutput = (stdout, project, rootDirectory) => {
74979
+ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath) => {
74265
74980
  if (!stdout) return [];
74266
74981
  const jsonStart = stdout.indexOf("{");
74267
74982
  const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
@@ -74278,8 +74993,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
74278
74993
  const sourceBufferCache = /* @__PURE__ */ new Map();
74279
74994
  const sourceLinesCache = /* @__PURE__ */ new Map();
74280
74995
  const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
74996
+ const resolveMappedSourceFilename = (filename) => sourcePathByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
74997
+ const resolveSourceFilename = (filename) => resolveMappedSourceFilename(filename) ?? filename;
74281
74998
  const readSourceBuffer = (filename) => {
74282
- const absolutePath = resolveAbsolutePath(filename);
74999
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
74283
75000
  const cached = sourceBufferCache.get(absolutePath);
74284
75001
  if (cached !== void 0) return cached;
74285
75002
  let sourceBuffer;
@@ -74292,7 +75009,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
74292
75009
  return sourceBuffer;
74293
75010
  };
74294
75011
  const readSourceLines = (filename) => {
74295
- const absolutePath = resolveAbsolutePath(filename);
75012
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
74296
75013
  const cached = sourceLinesCache.get(absolutePath);
74297
75014
  if (cached !== void 0) return cached;
74298
75015
  const sourceBuffer = readSourceBuffer(filename);
@@ -74301,27 +75018,30 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
74301
75018
  return sourceLines;
74302
75019
  };
74303
75020
  const isMinifiedDiagnosticFile = (filename) => {
74304
- const absolutePath = resolveAbsolutePath(filename);
75021
+ const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
74305
75022
  const cached = minifiedFileCache.get(absolutePath);
74306
75023
  if (cached !== void 0) return cached;
74307
75024
  const minified = isMinifiedSource(absolutePath);
74308
75025
  minifiedFileCache.set(absolutePath, minified);
74309
75026
  return minified;
74310
75027
  };
74311
- 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) => {
75028
+ 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) => {
74312
75029
  const { plugin, rule } = parseRuleCode(diagnostic.code);
74313
75030
  const primaryLabel = diagnostic.labels[0];
74314
75031
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
74315
- const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
75032
+ const mappedSourceFilename = resolveMappedSourceFilename(diagnostic.filename);
75033
+ const normalizedFilePath = (mappedSourceFilename ?? diagnostic.filename).replaceAll("\\", "/");
74316
75034
  const primarySpan = primaryLabel?.span;
74317
75035
  const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
74318
- const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
75036
+ const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath, mappedSourceFilename === void 0 ? null : sourceBuffer);
74319
75037
  const category = resolveDiagnosticCategory(plugin, rule);
74320
75038
  const matchByOccurrence = resolveMatchByOccurrence(rule, category);
74321
75039
  const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
74322
- const primaryLineIndex = primarySpan ? primarySpan.line - 1 : -1;
75040
+ const primaryLineNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.line ?? 0;
75041
+ const primaryColumnNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? columnOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.column ?? 0;
75042
+ const primaryLineIndex = primarySpan ? primaryLineNumber - 1 : -1;
74323
75043
  const primaryLine = sourceLines?.[primaryLineIndex];
74324
- const primaryColumnIndex = primarySpan ? primarySpan.column - 1 : -1;
75044
+ const primaryColumnIndex = primarySpan ? primaryColumnNumber - 1 : -1;
74325
75045
  const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
74326
75046
  const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
74327
75047
  const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
@@ -74334,8 +75054,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
74334
75054
  message: cleaned.message,
74335
75055
  help: cleaned.help,
74336
75056
  url: diagnostic.url,
74337
- line: primarySpan?.line ?? 0,
74338
- column: primarySpan?.column ?? 0,
75057
+ line: primaryLineNumber,
75058
+ column: primaryColumnNumber,
74339
75059
  ...primarySpan ? {
74340
75060
  offset: primarySpan.offset,
74341
75061
  length: primarySpan.length,
@@ -74523,7 +75243,11 @@ const isParallelismRelatedSpawnError = (error) => {
74523
75243
  * loop with a slimmer config in that case.
74524
75244
  */
74525
75245
  const spawnLintBatches = async (input) => {
74526
- const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
75246
+ const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, sourcePathByLintPath, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
75247
+ const resolveSourcePath = (filePath) => {
75248
+ const absoluteFilePath = Path.isAbsolute(filePath) ? filePath : Path.resolve(rootDirectory, filePath);
75249
+ return sourcePathByLintPath?.get(Path.normalize(absoluteFilePath)) ?? filePath;
75250
+ };
74527
75251
  const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
74528
75252
  let rescueDeadlineEpochMs;
74529
75253
  const isPastDeadline = () => deadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(deadlineEpochMs) === 0 || rescueDeadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(rescueDeadlineEpochMs) === 0;
@@ -74543,7 +75267,7 @@ const spawnLintBatches = async (input) => {
74543
75267
  }
74544
75268
  const batchArgs = [...baseArgs, ...batch];
74545
75269
  try {
74546
- return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory);
75270
+ return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory, sourcePathByLintPath);
74547
75271
  } catch (error) {
74548
75272
  if (!isSplittableReactDoctorError(error)) throw error;
74549
75273
  if (isPastDeadline()) {
@@ -74649,10 +75373,12 @@ const spawnLintBatches = async (input) => {
74649
75373
  onPartialFailure(buildMessage(`${skippedFiles.slice(0, 3).join(", ")}${skippedFiles.length > 3 ? `, +${skippedFiles.length - 3} more` : ""}`));
74650
75374
  };
74651
75375
  const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
74652
- reportSkippedFiles(droppedFiles, (fileListPreview) => `${droppedFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
74653
- reportSkippedFiles(outcome.deadlineSkippedFiles, (fileListPreview) => `${outcome.deadlineSkippedFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
75376
+ const droppedSourceFiles = [...new Set(droppedFiles.map(resolveSourcePath))];
75377
+ const deadlineSkippedSourceFiles = [...new Set(outcome.deadlineSkippedFiles.map(resolveSourcePath))];
75378
+ reportSkippedFiles(droppedSourceFiles, (fileListPreview) => `${droppedSourceFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
75379
+ reportSkippedFiles(deadlineSkippedSourceFiles, (fileListPreview) => `${deadlineSkippedSourceFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
74654
75380
  const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
74655
- input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)))].sort());
75381
+ input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)).map(resolveSourcePath))].sort());
74656
75382
  return dedupeDiagnostics(diagnostics);
74657
75383
  };
74658
75384
  let didValidate = false;
@@ -74751,6 +75477,266 @@ const planLintBatches = ({ baseArgs, files, sizeByFile }) => {
74751
75477
  }
74752
75478
  return batches.filter((batch) => batch.fileIndexes.length > 0).map((batch) => batch.fileIndexes.sort((leftIndex, rightIndex) => leftIndex - rightIndex).map((fileIndex) => files[fileIndex]));
74753
75479
  };
75480
+ const THREE_MODULE_IMPORT_PATTERN = /\b(?:from\s*|import\s*(?:\(\s*)?|require\s*\(\s*)["']three(?:\/[^"']*)?["']/;
75481
+ const containsThreeModuleImport = (sourceText) => THREE_MODULE_IMPORT_PATTERN.test(sourceText);
75482
+ const COMMENT_OPEN = "<!--";
75483
+ const COMMENT_CLOSE = "-->";
75484
+ const FRONTMATTER_FENCE = "---";
75485
+ const SCRIPT_TAG_NAME = "script";
75486
+ const SCRIPT_OPEN = `<${SCRIPT_TAG_NAME}`;
75487
+ const SCRIPT_CLOSE = `</${SCRIPT_TAG_NAME}`;
75488
+ const TEMPLATE_TAG_NAME = "template";
75489
+ const TEMPLATE_CLOSE = `</${TEMPLATE_TAG_NAME}`;
75490
+ const JAVASCRIPT_MIME_TYPES = new Set([
75491
+ "application/ecmascript",
75492
+ "application/javascript",
75493
+ "application/x-ecmascript",
75494
+ "application/x-javascript",
75495
+ "text/ecmascript",
75496
+ "text/javascript",
75497
+ "text/javascript1.0",
75498
+ "text/javascript1.1",
75499
+ "text/javascript1.2",
75500
+ "text/javascript1.3",
75501
+ "text/javascript1.4",
75502
+ "text/javascript1.5",
75503
+ "text/jscript",
75504
+ "text/livescript",
75505
+ "text/x-ecmascript",
75506
+ "text/x-javascript"
75507
+ ]);
75508
+ const RAW_TEXT_TAG_NAMES = new Set([
75509
+ "iframe",
75510
+ "noembed",
75511
+ "noframes",
75512
+ "noscript",
75513
+ "style",
75514
+ "textarea",
75515
+ "title",
75516
+ "xmp"
75517
+ ]);
75518
+ const PLAINTEXT_TAG_NAME = "plaintext";
75519
+ const TAG_OPEN_UTF8_BYTE = "<".charCodeAt(0);
75520
+ const TAG_CLOSE_UTF8_BYTE = ">".charCodeAt(0);
75521
+ const SINGLE_QUOTE_UTF8_BYTE = "'".charCodeAt(0);
75522
+ const DOUBLE_QUOTE_UTF8_BYTE = "\"".charCodeAt(0);
75523
+ const ATTRIBUTE_ASSIGNMENT_UTF8_BYTE = "=".charCodeAt(0);
75524
+ const TAG_SELF_CLOSE_UTF8_BYTE = "/".charCodeAt(0);
75525
+ const TAB_UTF8_BYTE = " ".charCodeAt(0);
75526
+ const FORM_FEED_UTF8_BYTE = "\f".charCodeAt(0);
75527
+ const isHtmlWhitespace = (byte) => byte === TAB_UTF8_BYTE || byte === 10 || byte === FORM_FEED_UTF8_BYTE || byte === 13 || byte === 32;
75528
+ const matchesAsciiCaseInsensitive = (sourceBuffer, startByte, expected) => {
75529
+ if (startByte + expected.length > sourceBuffer.length) return false;
75530
+ for (let expectedIndex = 0; expectedIndex < expected.length; expectedIndex++) {
75531
+ const sourceByte = sourceBuffer[startByte + expectedIndex];
75532
+ if (sourceByte === void 0 || String.fromCharCode(sourceByte).toLowerCase() !== expected[expectedIndex]) return false;
75533
+ }
75534
+ return true;
75535
+ };
75536
+ const isTagBoundary = (byte) => byte === TAG_CLOSE_UTF8_BYTE || byte === TAG_SELF_CLOSE_UTF8_BYTE || isHtmlWhitespace(byte);
75537
+ const isPotentialTagStart = (byte) => {
75538
+ if (byte === void 0) return false;
75539
+ return /[A-Za-z!/?]/.test(String.fromCharCode(byte));
75540
+ };
75541
+ const findLineEnd = (sourceBuffer, lineStartByte) => {
75542
+ let byteIndex = lineStartByte;
75543
+ while (byteIndex < sourceBuffer.length && sourceBuffer[byteIndex] !== 10 && sourceBuffer[byteIndex] !== 13) byteIndex++;
75544
+ return byteIndex;
75545
+ };
75546
+ const findNextLineStart = (sourceBuffer, lineStartByte) => {
75547
+ const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
75548
+ if (sourceBuffer[lineEndByte] === 13 && sourceBuffer[lineEndByte + 1] === 10) return lineEndByte + 2;
75549
+ return Math.min(lineEndByte + 1, sourceBuffer.length);
75550
+ };
75551
+ const isFrontmatterFenceLine = (sourceBuffer, lineStartByte) => {
75552
+ if (!matchesAsciiCaseInsensitive(sourceBuffer, lineStartByte, FRONTMATTER_FENCE)) return false;
75553
+ const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
75554
+ for (let byteIndex = lineStartByte + 3; byteIndex < lineEndByte; byteIndex++) if (!isHtmlWhitespace(sourceBuffer[byteIndex])) return false;
75555
+ return true;
75556
+ };
75557
+ const findFrontmatterEnd = (sourceBuffer) => {
75558
+ if (!isFrontmatterFenceLine(sourceBuffer, 0)) return 0;
75559
+ const openingFenceEndByte = findLineEnd(sourceBuffer, 0);
75560
+ let lineStartByte = findNextLineStart(sourceBuffer, 0);
75561
+ while (lineStartByte < sourceBuffer.length) {
75562
+ if (isFrontmatterFenceLine(sourceBuffer, lineStartByte)) return findLineEnd(sourceBuffer, lineStartByte);
75563
+ lineStartByte = findNextLineStart(sourceBuffer, lineStartByte);
75564
+ }
75565
+ return openingFenceEndByte;
75566
+ };
75567
+ const maskByteRange = (maskedBuffer, startByte, endByte) => {
75568
+ for (let byteIndex = startByte; byteIndex < endByte; byteIndex++) {
75569
+ const byte = maskedBuffer[byteIndex];
75570
+ if (byte !== 10 && byte !== 13) maskedBuffer[byteIndex] = 32;
75571
+ }
75572
+ };
75573
+ const readStartTagName = (sourceBuffer, tagStartByte) => {
75574
+ const firstNameByte = sourceBuffer[tagStartByte + 1];
75575
+ if (firstNameByte === void 0 || !/[A-Za-z]/.test(String.fromCharCode(firstNameByte))) return null;
75576
+ let nameEndByte = tagStartByte + 2;
75577
+ while (nameEndByte < sourceBuffer.length && /[A-Za-z0-9:-]/.test(String.fromCharCode(sourceBuffer[nameEndByte] ?? 32))) nameEndByte++;
75578
+ return sourceBuffer.subarray(tagStartByte + 1, nameEndByte).toString("ascii").toLowerCase();
75579
+ };
75580
+ const findTagEnd = (sourceBuffer, startByte) => {
75581
+ let quoteByte = null;
75582
+ for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) {
75583
+ const byte = sourceBuffer[byteIndex];
75584
+ if (quoteByte !== null) {
75585
+ if (byte === quoteByte) quoteByte = null;
75586
+ continue;
75587
+ }
75588
+ if (byte === SINGLE_QUOTE_UTF8_BYTE || byte === DOUBLE_QUOTE_UTF8_BYTE) {
75589
+ quoteByte = byte;
75590
+ continue;
75591
+ }
75592
+ if (byte === TAG_CLOSE_UTF8_BYTE) return byteIndex;
75593
+ }
75594
+ return sourceBuffer.length;
75595
+ };
75596
+ const parseScriptAttributes = (sourceBuffer, attributesStartByte, tagEndByte) => {
75597
+ let byteIndex = attributesStartByte;
75598
+ let hasSource = false;
75599
+ let language = null;
75600
+ let scriptType = null;
75601
+ while (byteIndex < tagEndByte) {
75602
+ while (byteIndex < tagEndByte && (isHtmlWhitespace(sourceBuffer[byteIndex]) || sourceBuffer[byteIndex] === TAG_SELF_CLOSE_UTF8_BYTE)) byteIndex++;
75603
+ const attributeNameStartByte = byteIndex;
75604
+ while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== ATTRIBUTE_ASSIGNMENT_UTF8_BYTE && sourceBuffer[byteIndex] !== TAG_SELF_CLOSE_UTF8_BYTE) byteIndex++;
75605
+ const attributeName = sourceBuffer.subarray(attributeNameStartByte, byteIndex).toString("ascii").toLowerCase();
75606
+ while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
75607
+ let attributeValue = "";
75608
+ if (sourceBuffer[byteIndex] === ATTRIBUTE_ASSIGNMENT_UTF8_BYTE) {
75609
+ byteIndex++;
75610
+ while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
75611
+ const quoteByte = sourceBuffer[byteIndex];
75612
+ if (quoteByte === SINGLE_QUOTE_UTF8_BYTE || quoteByte === DOUBLE_QUOTE_UTF8_BYTE) {
75613
+ const valueStartByte = byteIndex + 1;
75614
+ byteIndex = valueStartByte;
75615
+ while (byteIndex < tagEndByte && sourceBuffer[byteIndex] !== quoteByte) byteIndex++;
75616
+ attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
75617
+ if (byteIndex < tagEndByte) byteIndex++;
75618
+ } else {
75619
+ const valueStartByte = byteIndex;
75620
+ while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== TAG_CLOSE_UTF8_BYTE) byteIndex++;
75621
+ attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
75622
+ }
75623
+ }
75624
+ if (attributeName === "src") hasSource = true;
75625
+ else if (attributeName === "type" && scriptType === null) scriptType = attributeValue;
75626
+ else if (attributeName === "language" && language === null) language = attributeValue;
75627
+ }
75628
+ return {
75629
+ hasSource,
75630
+ language,
75631
+ type: scriptType
75632
+ };
75633
+ };
75634
+ const isExecutableScript = (attributes) => {
75635
+ if (attributes.hasSource) return false;
75636
+ const type = attributes.type?.trim().toLowerCase() ?? "";
75637
+ if (type !== "") {
75638
+ const mimeType = type.split(";")[0]?.trim() ?? "";
75639
+ return mimeType === "module" || JAVASCRIPT_MIME_TYPES.has(mimeType);
75640
+ }
75641
+ const language = attributes.language?.trim().toLowerCase() ?? "";
75642
+ return language === "" || JAVASCRIPT_MIME_TYPES.has(`text/${language}`);
75643
+ };
75644
+ const findElementClose = (sourceBuffer, startByte, tagName) => {
75645
+ const closeTagStart = `</${tagName}`;
75646
+ 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;
75647
+ return sourceBuffer.length;
75648
+ };
75649
+ const prepareHtmlScriptSource = (sourceBuffer) => {
75650
+ const frontmatterEndByte = findFrontmatterEnd(sourceBuffer);
75651
+ let maskedBuffer = frontmatterEndByte > 0 ? Buffer.from(sourceBuffer) : null;
75652
+ if (maskedBuffer !== null) maskByteRange(maskedBuffer, 0, frontmatterEndByte);
75653
+ const executableScriptBodies = [];
75654
+ let byteIndex = frontmatterEndByte;
75655
+ let templateDepth = 0;
75656
+ while (byteIndex < sourceBuffer.length) {
75657
+ if (sourceBuffer[byteIndex] !== TAG_OPEN_UTF8_BYTE) {
75658
+ byteIndex++;
75659
+ continue;
75660
+ }
75661
+ if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, COMMENT_OPEN)) {
75662
+ const commentEndByte = sourceBuffer.indexOf(COMMENT_CLOSE, byteIndex + 4);
75663
+ byteIndex = commentEndByte === -1 ? sourceBuffer.length : commentEndByte + 3;
75664
+ continue;
75665
+ }
75666
+ if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, TEMPLATE_CLOSE) && isTagBoundary(sourceBuffer[byteIndex + TEMPLATE_CLOSE.length])) {
75667
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + TEMPLATE_CLOSE.length);
75668
+ if (templateDepth > 0) templateDepth--;
75669
+ byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
75670
+ continue;
75671
+ }
75672
+ if (!matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, SCRIPT_OPEN) || !isTagBoundary(sourceBuffer[byteIndex + SCRIPT_OPEN.length])) {
75673
+ if (!isPotentialTagStart(sourceBuffer[byteIndex + 1])) {
75674
+ byteIndex++;
75675
+ continue;
75676
+ }
75677
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + 1);
75678
+ const tagName = readStartTagName(sourceBuffer, byteIndex);
75679
+ if (tagName === PLAINTEXT_TAG_NAME) break;
75680
+ if (tagName === TEMPLATE_TAG_NAME) templateDepth++;
75681
+ if (tagName !== null && RAW_TEXT_TAG_NAMES.has(tagName)) {
75682
+ const closeTagStartByte = findElementClose(sourceBuffer, tagEndByte + 1, tagName);
75683
+ if (closeTagStartByte === sourceBuffer.length) break;
75684
+ const closeTagEndByte = findTagEnd(sourceBuffer, closeTagStartByte + tagName.length + 2);
75685
+ byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
75686
+ continue;
75687
+ }
75688
+ byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
75689
+ continue;
75690
+ }
75691
+ const tagEndByte = findTagEnd(sourceBuffer, byteIndex + SCRIPT_OPEN.length);
75692
+ if (tagEndByte === sourceBuffer.length) break;
75693
+ const bodyStartByte = tagEndByte + 1;
75694
+ const bodyEndByte = findElementClose(sourceBuffer, bodyStartByte, SCRIPT_TAG_NAME);
75695
+ const attributes = parseScriptAttributes(sourceBuffer, byteIndex + SCRIPT_OPEN.length, tagEndByte);
75696
+ if (attributes.hasSource || templateDepth > 0) {
75697
+ maskedBuffer ??= Buffer.from(sourceBuffer);
75698
+ maskByteRange(maskedBuffer, bodyStartByte, bodyEndByte);
75699
+ } else if (isExecutableScript(attributes)) executableScriptBodies.push(sourceBuffer.subarray(bodyStartByte, bodyEndByte));
75700
+ if (bodyEndByte === sourceBuffer.length) break;
75701
+ const closeTagEndByte = findTagEnd(sourceBuffer, bodyEndByte + SCRIPT_CLOSE.length);
75702
+ byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
75703
+ }
75704
+ return {
75705
+ executableScriptBodies,
75706
+ lintBuffer: maskedBuffer ?? sourceBuffer
75707
+ };
75708
+ };
75709
+ const prepareHtmlLintSources = (rootDirectory, temporaryDirectory, candidateFiles) => {
75710
+ const lintFiles = [];
75711
+ const sourcePathByLintPath = /* @__PURE__ */ new Map();
75712
+ const sizeByLintPath = /* @__PURE__ */ new Map();
75713
+ const htmlSourcesDirectory = Path.join(temporaryDirectory, "html-sources");
75714
+ let htmlFileIndex = 0;
75715
+ let hasThreeModuleImport = false;
75716
+ for (const candidateFile of candidateFiles) {
75717
+ if (!HTML_FILE_PATTERN.test(candidateFile)) {
75718
+ lintFiles.push(candidateFile);
75719
+ continue;
75720
+ }
75721
+ const absoluteSourcePath = Path.isAbsolute(candidateFile) ? candidateFile : Path.resolve(rootDirectory, candidateFile);
75722
+ const sourceBuffer = NFS.readFileSync(absoluteSourcePath);
75723
+ const { executableScriptBodies, lintBuffer } = prepareHtmlScriptSource(sourceBuffer);
75724
+ if (htmlFileIndex === 0) NFS.mkdirSync(htmlSourcesDirectory, { recursive: true });
75725
+ const lintPath = Path.join(htmlSourcesDirectory, `${htmlFileIndex}.astro`);
75726
+ NFS.writeFileSync(lintPath, lintBuffer);
75727
+ lintFiles.push(lintPath);
75728
+ sourcePathByLintPath.set(Path.resolve(lintPath), candidateFile);
75729
+ sizeByLintPath.set(lintPath, sourceBuffer.length);
75730
+ hasThreeModuleImport ||= executableScriptBodies.some((scriptBody) => containsThreeModuleImport(scriptBody.toString("utf8")));
75731
+ htmlFileIndex++;
75732
+ }
75733
+ return {
75734
+ lintFiles,
75735
+ sourcePathByLintPath,
75736
+ sizeByLintPath,
75737
+ hasThreeModuleImport
75738
+ };
75739
+ };
74754
75740
  /**
74755
75741
  * Atomically (re)writes the generated oxlintrc.json. Used twice in
74756
75742
  * the runner: once for the primary scan, once for the
@@ -74911,6 +75897,8 @@ const reactHooksJsPluginDropNote = (error) => {
74911
75897
  const runOxlint = async (options) => {
74912
75898
  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;
74913
75899
  const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
75900
+ const runtimeGlobals = Array.isArray(userConfig?.runtimeGlobals) ? userConfig.runtimeGlobals.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
75901
+ let unpluginAutoImportGlobalScopes = [];
74914
75902
  const severityControls = buildRuleSeverityControls(userConfig);
74915
75903
  validateRuleRegistration();
74916
75904
  resetManifestCaches();
@@ -74924,21 +75912,6 @@ const runOxlint = async (options) => {
74924
75912
  const pluginPath = resolvePluginPath();
74925
75913
  const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
74926
75914
  const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
74927
- const buildConfig = (overrides) => createOxlintConfig({
74928
- pluginPath,
74929
- project,
74930
- customRulesOnly,
74931
- extendsPaths: overrides.extendsPaths,
74932
- ignoredTags,
74933
- includedTags,
74934
- includeTagDefaults,
74935
- serverAuthFunctionNames,
74936
- severityControls,
74937
- userPlugins,
74938
- disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
74939
- ruleSelection: overrides.ruleSelection,
74940
- sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
74941
- });
74942
75915
  const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
74943
75916
  const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
74944
75917
  const configPath = Path.join(configDirectory, "oxlintrc.json");
@@ -74974,7 +75947,36 @@ const runOxlint = async (options) => {
74974
75947
  await yieldToEventLoop();
74975
75948
  const sizedScanFiles = includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null;
74976
75949
  const candidateFiles = includePaths !== void 0 ? includePaths : (sizedScanFiles ?? []).map((entry) => entry.path);
75950
+ unpluginAutoImportGlobalScopes = collectUnpluginAutoImportGlobalScopes({
75951
+ rootDirectory,
75952
+ candidateFiles
75953
+ });
75954
+ const preparedHtmlSources = prepareHtmlLintSources(rootDirectory, configDirectory, candidateFiles);
75955
+ const lintFiles = preparedHtmlSources.lintFiles;
75956
+ const hasHtmlFiles = preparedHtmlSources.sourcePathByLintPath.size > 0;
75957
+ const lintProject = !project.hasThree && preparedHtmlSources.hasThreeModuleImport ? {
75958
+ ...project,
75959
+ hasThree: true
75960
+ } : project;
75961
+ const buildConfig = (overrides) => createOxlintConfig({
75962
+ pluginPath,
75963
+ project: lintProject,
75964
+ customRulesOnly,
75965
+ extendsPaths: overrides.extendsPaths,
75966
+ ignoredTags,
75967
+ includedTags,
75968
+ includeTagDefaults,
75969
+ runtimeGlobals,
75970
+ unpluginAutoImportGlobalScopes,
75971
+ serverAuthFunctionNames,
75972
+ severityControls,
75973
+ userPlugins,
75974
+ disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
75975
+ ruleSelection: overrides.ruleSelection,
75976
+ sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
75977
+ });
74977
75978
  const sizeByFile = sizedScanFiles !== null && lintBatchOrdering === "cost" ? new Map(sizedScanFiles.map((entry) => [entry.path, entry.sizeBytes])) : null;
75979
+ if (sizeByFile !== null) for (const [lintPath, sizeBytes] of preparedHtmlSources.sizeByLintPath) sizeByFile.set(lintPath, sizeBytes);
74978
75980
  const buildFileBatches = (passBaseArgs, passFiles) => sizeByFile !== null ? planLintBatches({
74979
75981
  baseArgs: passBaseArgs,
74980
75982
  files: passFiles,
@@ -75003,7 +76005,8 @@ const runOxlint = async (options) => {
75003
76005
  fileBatches: passFileBatches,
75004
76006
  rootDirectory,
75005
76007
  nodeBinaryPath,
75006
- project,
76008
+ project: lintProject,
76009
+ sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
75007
76010
  onPartialFailure: reportPartialFailure,
75008
76011
  onAnalyzedFiles: (filePaths) => {
75009
76012
  analyzedFiles = filePaths;
@@ -75038,7 +76041,7 @@ const runOxlint = async (options) => {
75038
76041
  };
75039
76042
  }
75040
76043
  };
75041
- if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0) {
76044
+ if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0 && !hasHtmlFiles) {
75042
76045
  const rulesetHash = computeRulesetHash({
75043
76046
  config: buildConfig({
75044
76047
  extendsPaths: [],
@@ -75196,14 +76199,15 @@ const runOxlint = async (options) => {
75196
76199
  ]);
75197
76200
  }
75198
76201
  const baseArgs = makeBaseArgs(configPath);
75199
- const fileBatches = buildFileBatches(baseArgs, candidateFiles);
76202
+ const fileBatches = buildFileBatches(baseArgs, lintFiles);
75200
76203
  let analyzedFiles = [];
75201
76204
  const runBatches = () => spawnLintBatches({
75202
76205
  baseArgs,
75203
76206
  fileBatches,
75204
76207
  rootDirectory,
75205
76208
  nodeBinaryPath,
75206
- project,
76209
+ project: lintProject,
76210
+ sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
75207
76211
  onPartialFailure,
75208
76212
  onAnalyzedFiles: (filePaths) => {
75209
76213
  analyzedFiles = filePaths;
@@ -77410,7 +78414,7 @@ const makeNoopConsole = () => ({
77410
78414
  });
77411
78415
  //#endregion
77412
78416
  //#region src/cli/utils/version.ts
77413
- const VERSION = "0.9.1-dev.54ba416";
78417
+ const VERSION = "0.9.1-dev.6904ff1";
77414
78418
  //#endregion
77415
78419
  //#region src/cli/utils/json-mode.ts
77416
78420
  let context = null;
@@ -77768,13 +78772,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
77768
78772
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
77769
78773
  * standard `SENTRY_RELEASE` override.
77770
78774
  */
77771
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.9.1-dev.54ba416`;
78775
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.9.1-dev.6904ff1`;
77772
78776
  /**
77773
78777
  * Deployment environment shown in Sentry's environment filter. Defaults to
77774
78778
  * `production` for tagged releases and `development` for dev/unbuilt versions,
77775
78779
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
77776
78780
  */
77777
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.9.1-dev.54ba416") ? "development" : "production");
78781
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.9.1-dev.6904ff1") ? "development" : "production");
77778
78782
  /**
77779
78783
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
77780
78784
  * (set to `0` to disable tracing) and falls back to
@@ -90439,6 +91443,7 @@ const buildScanAttributes = (input) => {
90439
91443
  rulesDisabled: ruleKeys.filter((key) => ruleOverrides[key] === "off").length,
90440
91444
  fileCount: input.result?.scannedFileCount ?? null,
90441
91445
  nonJsxFileCount: input.result?.analyzedFiles?.filter((filePath) => !JSX_FILE_PATTERN.test(filePath)).length ?? null,
91446
+ htmlFileCount: input.result?.analyzedFiles?.filter((filePath) => HTML_FILE_PATTERN.test(filePath)).length ?? null,
90442
91447
  multilineDiagnosticCount: input.result?.diagnostics.filter((diagnostic) => (diagnostic.endLine ?? diagnostic.line) > diagnostic.line).length ?? null
90443
91448
  });
90444
91449
  };
@@ -96492,7 +97497,7 @@ ${highlighter.dim("Learn more:")}
96492
97497
  ${highlighter.info(CI_URL)}
96493
97498
  `;
96494
97499
  const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
96495
- const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--supply-chain", "enable the dependency supply-chain scan (default)").option("--no-supply-chain", "skip the dependency supply-chain scan (Socket.dev dependency health checks)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--debug", "force a Sentry trace and print its id at the end (paste it into a bug report)").option("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("--json-out <path>", "with --json, write the report to a file instead of stdout").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple); overrides the `projects` config field").option("--scope <value>", "how much supported JS/TS source to scan/report: full (default), files, changed (only new issues vs base), or lines (issues whose source spans touch changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").option("--include-untracked", "with --scope files/changed/lines, also scan ordinary untracked files (respects .gitignore)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--max-duration <seconds>", "scan time budget for the whole run, shared across workspace projects: past it, remaining lint batches and dead-code are skipped and partial results are reported (skipped files are listed in the JSON report)").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
97500
+ const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--supply-chain", "enable the dependency supply-chain scan (default)").option("--no-supply-chain", "skip the dependency supply-chain scan (Socket.dev dependency health checks)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--debug", "force a Sentry trace and print its id at the end (paste it into a bug report)").option("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("--json-out <path>", "with --json, write the report to a file instead of stdout").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple); overrides the `projects` config field").option("--scope <value>", "how much supported JS/TS and inline HTML script source to scan/report: full (default), files, changed (only new issues vs base), or lines (issues whose source spans touch changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").option("--include-untracked", "with --scope files/changed/lines, also scan ordinary untracked files (respects .gitignore)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--max-duration <seconds>", "scan time budget for the whole run, shared across workspace projects: past it, remaining lint batches and dead-code are skipped and partial results are reported (skipped files are listed in the JSON report)").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
96496
97501
  program.action(inspectAction);
96497
97502
  program.command("design [directory]").description("Run only the focused UI design diagnostics").addHelpText("after", renderDesignHelpEpilog).action((directory, _options, command) => designAction(directory ?? ".", command.optsWithGlobals()));
96498
97503
  program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
@@ -96572,4 +97577,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
96572
97577
  export { toForwardSlashes as A, highlighter as B, buildRulePriorityMap as C, resolveBlockingLevel as D, formatLearnMoreLine as E, isCiEnvironment as F, sync as G, mergeReactDoctorConfigs as H, DIAGNOSTIC_CATEGORY_BUCKETS as I, void_ as K, Progress as L, isUnicodeSupported as M, METRIC as N, isReactDoctorWorkflowInstalled as O, TUI_REPORT_DETAIL_WIDTH_FRACTION as P, Reporter as R, hasLintHardFailure as S, formatFixRecipeLine as T, resolveScanTarget as U, mapWithConcurrency as V, runPromise as W, canAnimateOnboarding as _, resolveCliInspectOptions as a, buildCodeFrame as b, detectLaunchableAgents as c, launchCliAgent as d, isShareOptedOut as f, doctorFace as g, easeOutCubic as h, selectProjects as i, findNearestPackageDirectory as j, recordCount as k, CLI_AGENT_BINARIES as l, printFooter as m, shouldFailScanGate as n, countUniqueScannedFiles as o, inspect as p, succeed$3 as q, discoverWorkspacePackages as r, setUpGitHubActions as s, exitGracefully as t, copyToClipboard as u, computeProjectedScore as v, buildSortedRuleGroups as w, buildNoScoreMessage as x, formatElapsedTime as y, getCategoryImpact as z };
96573
97578
 
96574
97579
  //# sourceMappingURL=cli.js.map
96575
- //# debugId=082c13c1-ba8f-56d5-9944-c005ab0edc0e
97580
+ //# debugId=f34e66dd-4b16-53f5-a3af-9844fbc71772