react-doctor 0.9.1-dev.b1b62db → 0.9.2

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.
Files changed (4) hide show
  1. package/dist/cli.js +216 -74
  2. package/dist/index.js +213 -71
  3. package/dist/lsp.js +214 -72
  4. package/package.json +7 -6
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e6d636d4-ff95-5229-92f8-47807b2a44c4")}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]="41e39010-e2d7-5e6b-9bba-626bf64affe5")}catch(e){}}();
3
3
  import { i as __toESM$1, r as __require, t as __commonJSMin$1 } from "./chunk-ChKA3wi6.js";
4
4
  import { createRequire } from "node:module";
5
5
  import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
@@ -11,6 +11,7 @@ import * as Path from "node:path";
11
11
  import path from "node:path";
12
12
  import * as NodeChildProcess from "node:child_process";
13
13
  import { execFileSync, spawn, spawnSync } from "node:child_process";
14
+ import { ResolverFactory } from "oxc-resolver";
14
15
  import ts from "typescript";
15
16
  import * as OS from "node:os";
16
17
  import os from "node:os";
@@ -61792,7 +61793,7 @@ const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
61792
61793
  const FILE_LINT_CACHE_FILENAME = "file-lint-cache.json";
61793
61794
  const FILE_LINT_CACHE_MAX_FILE_COUNT = 5e4;
61794
61795
  const SIDECAR_LINT_CACHE_FILENAME = "sidecar-lint-cache.json";
61795
- const CORE_PACKAGE_VERSION = "0.9.1";
61796
+ const CORE_PACKAGE_VERSION = "0.9.2";
61796
61797
  const DEAD_CODE_CACHE_FILENAME = "dead-code-cache.json";
61797
61798
  const DEAD_CODE_SUMMARY_CACHE_FILENAME = "dead-code-summaries.json";
61798
61799
  const SUPPLY_CHAIN_PLUGIN = "socket";
@@ -62042,8 +62043,13 @@ const findMonorepoRoot = (startDirectory) => {
62042
62043
  * byte-equivalent copy.
62043
62044
  */
62044
62045
  const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
62046
+ const unwrapTypescriptExpression = (expression) => {
62047
+ let currentExpression = expression;
62048
+ while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
62049
+ return currentExpression;
62050
+ };
62045
62051
  const TSCONFIG_FILENAME = "tsconfig.json";
62046
- const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || Path.isAbsolute(extendsValue);
62052
+ const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
62047
62053
  const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
62048
62054
  const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62049
62055
  const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
@@ -62060,7 +62066,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62060
62066
  return null;
62061
62067
  };
62062
62068
  const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
62063
- if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(Path.resolve(fromConfigDirectory, extendsValue));
62069
+ if (isLocalModuleSpecifier(extendsValue)) {
62070
+ const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
62071
+ if (isFile(resolvedPath)) return resolvedPath;
62072
+ const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
62073
+ return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
62074
+ }
62064
62075
  return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
62065
62076
  };
62066
62077
  const normalizeCompilerOptions = (compilerOptions) => {
@@ -62254,6 +62265,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
62254
62265
  ".cts",
62255
62266
  ".json"
62256
62267
  ];
62268
+ const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
62269
+ conditionNames: [
62270
+ "import",
62271
+ "require",
62272
+ "node",
62273
+ "default"
62274
+ ],
62275
+ extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
62276
+ });
62257
62277
  const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
62258
62278
  const hasCompilerPackage = (packageJson, compilerPackages) => {
62259
62279
  const allDependencies = {
@@ -62277,6 +62297,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
62277
62297
  return false;
62278
62298
  };
62279
62299
  const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
62300
+ if (!isLocalModuleSpecifier(moduleSpecifier)) {
62301
+ try {
62302
+ const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
62303
+ if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
62304
+ } catch {}
62305
+ try {
62306
+ const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
62307
+ return isFile(resolvedPath) ? resolvedPath : null;
62308
+ } catch {
62309
+ return null;
62310
+ }
62311
+ }
62280
62312
  const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
62281
62313
  const extension = Path.extname(unresolvedPath);
62282
62314
  return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
@@ -62302,7 +62334,7 @@ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statemen
62302
62334
  const namedBindings = importClause?.namedBindings;
62303
62335
  return namedBindings ? ts.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
62304
62336
  }
62305
- if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === bindingName);
62337
+ if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
62306
62338
  return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === bindingName;
62307
62339
  });
62308
62340
  const getImportBinding = (sourceFile, bindingName) => {
@@ -62403,6 +62435,48 @@ const getScopedConfigBinding = (identifier) => {
62403
62435
  };
62404
62436
  };
62405
62437
  const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
62438
+ const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
62439
+ const isConstantVariableInitializer = (node) => ts.isExpression(node) && ts.isVariableDeclaration(node.parent) && ts.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & ts.NodeFlags.Const);
62440
+ const isNodeCreateRequireCall = (node, analysis) => {
62441
+ if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
62442
+ if (!ts.isCallExpression(node)) return false;
62443
+ const target = node.expression;
62444
+ if (ts.isIdentifier(target)) {
62445
+ if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
62446
+ const importBinding = getImportBinding(analysis.sourceFile, target.text);
62447
+ return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
62448
+ }
62449
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return false;
62450
+ if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "createRequire") return false;
62451
+ const createRequireReceiver = target.expression;
62452
+ if (ts.isCallExpression(createRequireReceiver)) {
62453
+ const requiredModuleSpecifier = getRequireModuleSpecifier$1(createRequireReceiver);
62454
+ if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !ts.isIdentifier(createRequireReceiver.expression)) return false;
62455
+ const requireIdentifier = createRequireReceiver.expression;
62456
+ return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
62457
+ }
62458
+ if (!ts.isIdentifier(createRequireReceiver)) return false;
62459
+ if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
62460
+ const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
62461
+ return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
62462
+ };
62463
+ const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
62464
+ const [moduleSpecifierNode] = callExpression.arguments;
62465
+ if (!moduleSpecifierNode || !ts.isStringLiteralLike(moduleSpecifierNode)) return null;
62466
+ const target = callExpression.expression;
62467
+ if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
62468
+ if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "resolve") return null;
62469
+ if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
62470
+ if (!ts.isIdentifier(target.expression)) return null;
62471
+ const resolverIdentifier = target.expression;
62472
+ if (analysis.localBindings.has(resolverIdentifier.text)) return null;
62473
+ const scopedBinding = getScopedConfigBinding(resolverIdentifier);
62474
+ const topLevelBinding = scopedBinding.wasFound ? null : getTopLevelBinding(analysis.sourceFile, resolverIdentifier.text);
62475
+ const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : topLevelBinding;
62476
+ if (resolverInitializer === null && !scopedBinding.wasFound && resolverIdentifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, resolverIdentifier.text) && getImportBinding(analysis.sourceFile, resolverIdentifier.text) === null) return moduleSpecifierNode.text;
62477
+ if (!resolverInitializer || !isConstantVariableInitializer(resolverInitializer) || !isNodeCreateRequireCall(resolverInitializer, analysis)) return null;
62478
+ return moduleSpecifierNode.text;
62479
+ };
62406
62480
  const getAssignedPropertyInitializer = (identifier, propertyName) => {
62407
62481
  let bindingScope = null;
62408
62482
  let currentNode = identifier;
@@ -62445,9 +62519,11 @@ const getAssignedPropertyInitializer = (identifier, propertyName) => {
62445
62519
  initializer: assignedInitializer
62446
62520
  };
62447
62521
  };
62448
- const getStaticConfigValueState = (expression, analysis) => {
62449
- let unwrappedExpression = expression;
62450
- while (ts.isParenthesizedExpression(unwrappedExpression) || ts.isAsExpression(unwrappedExpression) || ts.isTypeAssertionExpression(unwrappedExpression) || ts.isSatisfiesExpression(unwrappedExpression) || ts.isNonNullExpression(unwrappedExpression)) unwrappedExpression = unwrappedExpression.expression;
62522
+ const getStaticConfigValueState = (expression, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
62523
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
62524
+ if (visitedExpressions.has(unwrappedExpression)) return null;
62525
+ const nextVisitedExpressions = new Set(visitedExpressions);
62526
+ nextVisitedExpressions.add(unwrappedExpression);
62451
62527
  if (unwrappedExpression.kind === ts.SyntaxKind.NullKeyword || ts.isIdentifier(unwrappedExpression) && unwrappedExpression.text === "undefined") return {
62452
62528
  isNullish: true,
62453
62529
  isTruthy: false
@@ -62463,31 +62539,31 @@ const getStaticConfigValueState = (expression, analysis) => {
62463
62539
  if (ts.isIdentifier(unwrappedExpression)) {
62464
62540
  if (analysis.localBindings.has(unwrappedExpression.text)) {
62465
62541
  const localInitializer = analysis.localBindings.get(unwrappedExpression.text);
62466
- return localInitializer ? getStaticConfigValueState(localInitializer, analysis) : null;
62542
+ return localInitializer ? getStaticConfigValueState(localInitializer, analysis, nextVisitedExpressions) : null;
62467
62543
  }
62468
62544
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
62469
- return topLevelBinding && ts.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis) : null;
62545
+ return topLevelBinding && ts.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis, nextVisitedExpressions) : null;
62470
62546
  }
62471
62547
  if (ts.isConditionalExpression(unwrappedExpression)) {
62472
- const conditionState = getStaticConfigValueState(unwrappedExpression.condition, analysis);
62473
- if (conditionState !== null) return getStaticConfigValueState(conditionState.isTruthy ? unwrappedExpression.whenTrue : unwrappedExpression.whenFalse, analysis);
62474
- const whenTrueState = getStaticConfigValueState(unwrappedExpression.whenTrue, analysis);
62475
- const whenFalseState = getStaticConfigValueState(unwrappedExpression.whenFalse, analysis);
62548
+ const conditionState = getStaticConfigValueState(unwrappedExpression.condition, analysis, nextVisitedExpressions);
62549
+ if (conditionState !== null) return getStaticConfigValueState(conditionState.isTruthy ? unwrappedExpression.whenTrue : unwrappedExpression.whenFalse, analysis, nextVisitedExpressions);
62550
+ const whenTrueState = getStaticConfigValueState(unwrappedExpression.whenTrue, analysis, nextVisitedExpressions);
62551
+ const whenFalseState = getStaticConfigValueState(unwrappedExpression.whenFalse, analysis, nextVisitedExpressions);
62476
62552
  return whenTrueState !== null && whenFalseState !== null && whenTrueState.isNullish === whenFalseState.isNullish && whenTrueState.isTruthy === whenFalseState.isTruthy ? whenTrueState : null;
62477
62553
  }
62478
62554
  if (ts.isBinaryExpression(unwrappedExpression)) {
62479
- const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis);
62555
+ const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis, nextVisitedExpressions);
62480
62556
  if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
62481
62557
  if (leftState === null) return null;
62482
- return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis) : leftState;
62558
+ return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
62483
62559
  }
62484
62560
  if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.BarBarToken) {
62485
62561
  if (leftState === null) return null;
62486
- return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis);
62562
+ return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions);
62487
62563
  }
62488
62564
  if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken) {
62489
62565
  if (leftState === null) return null;
62490
- return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis) : leftState;
62566
+ return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
62491
62567
  }
62492
62568
  }
62493
62569
  return null;
@@ -62496,25 +62572,27 @@ const isStaticallyDisabledConfigExpression = (expression, analysis) => getStatic
62496
62572
  const isStaticallyTruthyConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isTruthy === true;
62497
62573
  const isStaticallyNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === true;
62498
62574
  const isStaticallyNonNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === false;
62499
- const getReactCompilerFlagState = (expression, analysis) => {
62500
- let unwrappedExpression = expression;
62501
- while (ts.isParenthesizedExpression(unwrappedExpression) || ts.isAsExpression(unwrappedExpression) || ts.isTypeAssertionExpression(unwrappedExpression) || ts.isSatisfiesExpression(unwrappedExpression) || ts.isNonNullExpression(unwrappedExpression)) unwrappedExpression = unwrappedExpression.expression;
62575
+ const getReactCompilerFlagState = (expression, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
62576
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
62577
+ if (visitedExpressions.has(unwrappedExpression)) return null;
62578
+ const nextVisitedExpressions = new Set(visitedExpressions);
62579
+ nextVisitedExpressions.add(unwrappedExpression);
62502
62580
  if (ts.isIdentifier(unwrappedExpression)) {
62503
62581
  const assignedBinding = getAssignedPropertyInitializer(unwrappedExpression, "reactCompiler");
62504
62582
  if (assignedBinding.wasFound && assignedBinding.initializer) return { isEnabled: !isStaticallyDisabledConfigExpression(assignedBinding.initializer, analysis) };
62505
62583
  if (analysis.localBindings.has(unwrappedExpression.text)) {
62506
62584
  const localInitializer = analysis.localBindings.get(unwrappedExpression.text);
62507
- return localInitializer ? getReactCompilerFlagState(localInitializer, analysis) : null;
62585
+ return localInitializer ? getReactCompilerFlagState(localInitializer, analysis, nextVisitedExpressions) : null;
62508
62586
  }
62509
62587
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
62510
- return topLevelBinding && ts.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis) : null;
62588
+ return topLevelBinding && ts.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis, nextVisitedExpressions) : null;
62511
62589
  }
62512
62590
  if (!ts.isObjectLiteralExpression(unwrappedExpression)) return null;
62513
62591
  for (const property of [...unwrappedExpression.properties].reverse()) {
62514
62592
  if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
62515
62593
  if (ts.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
62516
62594
  if (ts.isSpreadAssignment(property)) {
62517
- const spreadState = getReactCompilerFlagState(property.expression, analysis);
62595
+ const spreadState = getReactCompilerFlagState(property.expression, analysis, nextVisitedExpressions);
62518
62596
  if (spreadState) return spreadState;
62519
62597
  }
62520
62598
  }
@@ -62686,6 +62764,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
62686
62764
  visitReturns(functionNode.body);
62687
62765
  return hasCompiler;
62688
62766
  };
62767
+ const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
62768
+ const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
62769
+ if (!importedFilePath) return null;
62770
+ return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList);
62771
+ };
62689
62772
  const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
62690
62773
  const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
62691
62774
  if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
@@ -62706,30 +62789,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
62706
62789
  const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
62707
62790
  if (importBinding) {
62708
62791
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62709
- if (!importBinding.moduleSpecifier.startsWith(".")) return false;
62710
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62711
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62792
+ return Boolean(analyzeImportedConfig({
62793
+ analysis,
62794
+ moduleSpecifier: importBinding.moduleSpecifier,
62795
+ exportName: importBinding.exportName,
62796
+ allowCompilerTransform
62797
+ }));
62712
62798
  }
62713
62799
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
62714
62800
  return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
62715
62801
  };
62716
62802
  const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
62717
62803
  const target = callExpression.expression;
62804
+ const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
62805
+ if (callableRequiredModuleSpecifier !== null) {
62806
+ if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62807
+ if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
62808
+ const hasCompilerTransform = analyzeImportedConfig({
62809
+ analysis,
62810
+ moduleSpecifier: callableRequiredModuleSpecifier,
62811
+ exportName: "default",
62812
+ allowCompilerTransform,
62813
+ argumentsList: callExpression.arguments
62814
+ });
62815
+ if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62816
+ return null;
62817
+ }
62718
62818
  if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
62719
62819
  const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
62720
62820
  if (propertyName === null) return null;
62721
62821
  const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
62722
62822
  if (requiredModuleSpecifier !== null) {
62723
- if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62724
- if (!requiredModuleSpecifier.startsWith(".")) return null;
62725
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62726
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62823
+ 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;
62824
+ if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
62825
+ const hasCompilerTransform = analyzeImportedConfig({
62826
+ analysis,
62827
+ moduleSpecifier: requiredModuleSpecifier,
62828
+ exportName: propertyName,
62829
+ allowCompilerTransform,
62830
+ argumentsList: callExpression.arguments
62831
+ });
62832
+ if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62833
+ return null;
62727
62834
  }
62728
62835
  if (!ts.isIdentifier(target.expression)) return null;
62729
- const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
62730
- if (importBinding?.isNamespace && importBinding.moduleSpecifier.startsWith(".")) {
62731
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62732
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62836
+ const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
62837
+ if (importBinding?.isNamespace) {
62838
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
62839
+ const hasCompilerTransform = analyzeImportedConfig({
62840
+ analysis,
62841
+ moduleSpecifier: importBinding.moduleSpecifier,
62842
+ exportName: propertyName,
62843
+ allowCompilerTransform,
62844
+ argumentsList: callExpression.arguments
62845
+ });
62846
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62847
+ return null;
62733
62848
  }
62734
62849
  const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
62735
62850
  if (selectedProperty === null) return null;
@@ -62752,9 +62867,13 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62752
62867
  if (propertyName === "reactCompiler") continue;
62753
62868
  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;
62754
62869
  const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
62755
- if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer) && property.initializer.text.startsWith(".")) {
62756
- const extendedFilePath = resolveImportedConfigFile(analysis.filePath, property.initializer.text);
62757
- if (extendedFilePath && analyzeConfigModuleExport(extendedFilePath, "default", false, analysis.importDepth + 1, analysis.visitedModules)) return true;
62870
+ if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
62871
+ if (analyzeImportedConfig({
62872
+ analysis,
62873
+ moduleSpecifier: property.initializer.text,
62874
+ exportName: "default",
62875
+ allowCompilerTransform: false
62876
+ })) return true;
62758
62877
  }
62759
62878
  if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
62760
62879
  } else if (ts.isShorthandPropertyAssignment(property)) {
@@ -62778,6 +62897,8 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62778
62897
  });
62779
62898
  }
62780
62899
  if (ts.isCallExpression(node)) {
62900
+ const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
62901
+ if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
62781
62902
  const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
62782
62903
  if (callTargetResult !== null) return callTargetResult;
62783
62904
  const directModuleSpecifier = getRequireModuleSpecifier$1(node);
@@ -62785,16 +62906,27 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62785
62906
  if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
62786
62907
  if (directModuleSpecifier && !isRequireShadowed) {
62787
62908
  if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
62788
- if (directModuleSpecifier.startsWith(".")) {
62789
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, directModuleSpecifier);
62790
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, "default", allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62791
- }
62909
+ if (analyzeImportedConfig({
62910
+ analysis,
62911
+ moduleSpecifier: directModuleSpecifier,
62912
+ exportName: "default",
62913
+ allowCompilerTransform
62914
+ })) return true;
62792
62915
  }
62793
62916
  if (ts.isIdentifier(node.expression)) {
62794
- const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62795
- if (importBinding?.moduleSpecifier.startsWith(".")) {
62796
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62797
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, node.arguments));
62917
+ if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
62918
+ const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62919
+ if (importBinding) {
62920
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62921
+ const hasCompilerTransform = analyzeImportedConfig({
62922
+ analysis,
62923
+ moduleSpecifier: importBinding.moduleSpecifier,
62924
+ exportName: importBinding.exportName,
62925
+ allowCompilerTransform,
62926
+ argumentsList: node.arguments
62927
+ });
62928
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62929
+ }
62798
62930
  }
62799
62931
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
62800
62932
  if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
@@ -62804,25 +62936,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62804
62936
  if (ts.isPropertyAccessExpression(node)) {
62805
62937
  const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
62806
62938
  if (requiredModuleSpecifier) {
62807
- if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62808
- if (requiredModuleSpecifier.startsWith(".")) {
62809
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62810
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62811
- }
62939
+ 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;
62940
+ if (analyzeImportedConfig({
62941
+ analysis,
62942
+ moduleSpecifier: requiredModuleSpecifier,
62943
+ exportName: node.name.text,
62944
+ allowCompilerTransform
62945
+ })) return true;
62812
62946
  return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
62813
62947
  }
62814
62948
  if (ts.isIdentifier(node.expression)) {
62815
- if (analysis.localBindings.has(node.expression.text)) {
62816
- const localInitializer = analysis.localBindings.get(node.expression.text);
62817
- return Boolean(localInitializer && analyzeConfigNode(localInitializer, analysis, allowCompilerTransform));
62949
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
62950
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
62951
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
62818
62952
  }
62819
62953
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62820
62954
  if (importBinding?.isNamespace) {
62821
62955
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
62822
- if (importBinding.moduleSpecifier.startsWith(".")) {
62823
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62824
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62825
- }
62956
+ if (analyzeImportedConfig({
62957
+ analysis,
62958
+ moduleSpecifier: importBinding.moduleSpecifier,
62959
+ exportName: node.name.text,
62960
+ allowCompilerTransform
62961
+ })) return true;
62826
62962
  return false;
62827
62963
  }
62828
62964
  const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
@@ -62833,13 +62969,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62833
62969
  }
62834
62970
  if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
62835
62971
  if (ts.isIdentifier(node.expression)) {
62972
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
62973
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
62974
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
62975
+ }
62836
62976
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62837
62977
  if (importBinding?.isNamespace) {
62838
62978
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
62839
- if (importBinding.moduleSpecifier.startsWith(".")) {
62840
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62841
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.argumentExpression.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62842
- }
62979
+ return Boolean(analyzeImportedConfig({
62980
+ analysis,
62981
+ moduleSpecifier: importBinding.moduleSpecifier,
62982
+ exportName: node.argumentExpression.text,
62983
+ allowCompilerTransform
62984
+ }));
62843
62985
  }
62844
62986
  const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
62845
62987
  if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
@@ -62877,14 +63019,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62877
63019
  };
62878
63020
  const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
62879
63021
  const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
62880
- const hasCompilerInPackageJsonConfig = (packageJson) => isPlainObject(packageJson.babel) && analyzeConfigSourceFileExport(ts.parseJsonText("package.json", JSON.stringify(packageJson.babel)), "package.json#babel", "default", false, 0, /* @__PURE__ */ new Set());
62881
- const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
63022
+ const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
63023
+ if (!isPlainObject(packageJson.babel)) return false;
63024
+ const packageJsonPath = Path.join(directory, "package.json");
63025
+ return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
63026
+ };
63027
+ const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
62882
63028
  const hasCompilerConfigurationInAncestors = (directory) => {
62883
63029
  if (isProjectBoundary(directory)) return false;
62884
63030
  let ancestorDirectory = Path.dirname(directory);
62885
63031
  while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
62886
63032
  const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
62887
- if (hasCompilerInPackageJsonConfig(isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {}) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
63033
+ const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
63034
+ if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
62888
63035
  if (isProjectBoundary(ancestorDirectory)) return false;
62889
63036
  ancestorDirectory = Path.dirname(ancestorDirectory);
62890
63037
  }
@@ -67142,11 +67289,6 @@ const getTypescriptScriptKind = (fileName) => {
67142
67289
  if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
67143
67290
  return ts.ScriptKind.JS;
67144
67291
  };
67145
- const unwrapTypescriptExpression = (expression) => {
67146
- let currentExpression = expression;
67147
- while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
67148
- return currentExpression;
67149
- };
67150
67292
  const BABEL_CONFIG_FILE_NAMES$1 = [
67151
67293
  "babel.config.js",
67152
67294
  "babel.config.cjs",
@@ -74750,4 +74892,4 @@ const toJsonReport = (result, options) => buildJsonReport({
74750
74892
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
74751
74893
 
74752
74894
  //# sourceMappingURL=index.js.map
74753
- //# debugId=e6d636d4-ff95-5229-92f8-47807b2a44c4
74895
+ //# debugId=41e39010-e2d7-5e6b-9bba-626bf64affe5