react-doctor 0.9.1-dev.7ee59d3 → 0.9.1-dev.846c2df

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 +142 -48
  2. package/dist/index.js +139 -45
  3. package/dist/lsp.js +139 -45
  4. package/package.json +5 -4
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]="7f26fa62-fe0c-5ae0-bc9c-97a0deb50b43")}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";
@@ -65240,7 +65241,7 @@ const findMonorepoRoot = (startDirectory) => {
65240
65241
  */
65241
65242
  const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
65242
65243
  const TSCONFIG_FILENAME = "tsconfig.json";
65243
- const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || Path.isAbsolute(extendsValue);
65244
+ const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
65244
65245
  const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
65245
65246
  const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
65246
65247
  const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
@@ -65257,7 +65258,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
65257
65258
  return null;
65258
65259
  };
65259
65260
  const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
65260
- 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
+ }
65261
65267
  return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
65262
65268
  };
65263
65269
  const normalizeCompilerOptions = (compilerOptions) => {
@@ -65451,6 +65457,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
65451
65457
  ".cts",
65452
65458
  ".json"
65453
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
+ });
65454
65469
  const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
65455
65470
  const hasCompilerPackage = (packageJson, compilerPackages) => {
65456
65471
  const allDependencies = {
@@ -65474,6 +65489,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
65474
65489
  return false;
65475
65490
  };
65476
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
+ }
65477
65504
  const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
65478
65505
  const extension = Path.extname(unresolvedPath);
65479
65506
  return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
@@ -65925,6 +65952,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
65925
65952
  visitReturns(functionNode.body);
65926
65953
  return hasCompiler;
65927
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
+ };
65928
65960
  const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
65929
65961
  const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
65930
65962
  if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
@@ -65945,30 +65977,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
65945
65977
  const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
65946
65978
  if (importBinding) {
65947
65979
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
65948
- if (!importBinding.moduleSpecifier.startsWith(".")) return false;
65949
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
65950
- 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
+ }));
65951
65986
  }
65952
65987
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
65953
65988
  return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
65954
65989
  };
65955
65990
  const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
65956
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
+ }
65957
66006
  if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
65958
66007
  const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
65959
66008
  if (propertyName === null) return null;
65960
66009
  const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
65961
66010
  if (requiredModuleSpecifier !== null) {
65962
- if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
65963
- if (!requiredModuleSpecifier.startsWith(".")) return null;
65964
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
65965
- 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;
65966
66022
  }
65967
66023
  if (!ts.isIdentifier(target.expression)) return null;
65968
- const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
65969
- if (importBinding?.isNamespace && importBinding.moduleSpecifier.startsWith(".")) {
65970
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
65971
- 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;
65972
66036
  }
65973
66037
  const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
65974
66038
  if (selectedProperty === null) return null;
@@ -65991,9 +66055,13 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
65991
66055
  if (propertyName === "reactCompiler") continue;
65992
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;
65993
66057
  const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
65994
- if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer) && property.initializer.text.startsWith(".")) {
65995
- const extendedFilePath = resolveImportedConfigFile(analysis.filePath, property.initializer.text);
65996
- 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;
65997
66065
  }
65998
66066
  if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
65999
66067
  } else if (ts.isShorthandPropertyAssignment(property)) {
@@ -66026,16 +66094,27 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
66026
66094
  if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
66027
66095
  if (directModuleSpecifier && !isRequireShadowed) {
66028
66096
  if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
66029
- if (directModuleSpecifier.startsWith(".")) {
66030
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, directModuleSpecifier);
66031
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, "default", allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
66032
- }
66097
+ if (analyzeImportedConfig({
66098
+ analysis,
66099
+ moduleSpecifier: directModuleSpecifier,
66100
+ exportName: "default",
66101
+ allowCompilerTransform
66102
+ })) return true;
66033
66103
  }
66034
66104
  if (ts.isIdentifier(node.expression)) {
66035
- const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
66036
- if (importBinding?.moduleSpecifier.startsWith(".")) {
66037
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
66038
- 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
+ }
66039
66118
  }
66040
66119
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
66041
66120
  if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
@@ -66045,25 +66124,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
66045
66124
  if (ts.isPropertyAccessExpression(node)) {
66046
66125
  const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
66047
66126
  if (requiredModuleSpecifier) {
66048
- if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
66049
- if (requiredModuleSpecifier.startsWith(".")) {
66050
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
66051
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
66052
- }
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;
66053
66134
  return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
66054
66135
  }
66055
66136
  if (ts.isIdentifier(node.expression)) {
66056
- if (analysis.localBindings.has(node.expression.text)) {
66057
- const localInitializer = analysis.localBindings.get(node.expression.text);
66058
- 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));
66059
66140
  }
66060
66141
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
66061
66142
  if (importBinding?.isNamespace) {
66062
66143
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
66063
- if (importBinding.moduleSpecifier.startsWith(".")) {
66064
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
66065
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
66066
- }
66144
+ if (analyzeImportedConfig({
66145
+ analysis,
66146
+ moduleSpecifier: importBinding.moduleSpecifier,
66147
+ exportName: node.name.text,
66148
+ allowCompilerTransform
66149
+ })) return true;
66067
66150
  return false;
66068
66151
  }
66069
66152
  const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
@@ -66074,13 +66157,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
66074
66157
  }
66075
66158
  if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
66076
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
+ }
66077
66164
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
66078
66165
  if (importBinding?.isNamespace) {
66079
66166
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
66080
- if (importBinding.moduleSpecifier.startsWith(".")) {
66081
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
66082
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.argumentExpression.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
66083
- }
66167
+ return Boolean(analyzeImportedConfig({
66168
+ analysis,
66169
+ moduleSpecifier: importBinding.moduleSpecifier,
66170
+ exportName: node.argumentExpression.text,
66171
+ allowCompilerTransform
66172
+ }));
66084
66173
  }
66085
66174
  const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
66086
66175
  if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
@@ -66118,14 +66207,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
66118
66207
  };
66119
66208
  const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
66120
66209
  const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
66121
- const hasCompilerInPackageJsonConfig = (packageJson) => isPlainObject(packageJson.babel) && analyzeConfigSourceFileExport(ts.parseJsonText("package.json", JSON.stringify(packageJson.babel)), "package.json#babel", "default", false, 0, /* @__PURE__ */ new Set());
66122
- 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);
66123
66216
  const hasCompilerConfigurationInAncestors = (directory) => {
66124
66217
  if (isProjectBoundary(directory)) return false;
66125
66218
  let ancestorDirectory = Path.dirname(directory);
66126
66219
  while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
66127
66220
  const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
66128
- 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;
66129
66223
  if (isProjectBoundary(ancestorDirectory)) return false;
66130
66224
  ancestorDirectory = Path.dirname(ancestorDirectory);
66131
66225
  }
@@ -78320,7 +78414,7 @@ const makeNoopConsole = () => ({
78320
78414
  });
78321
78415
  //#endregion
78322
78416
  //#region src/cli/utils/version.ts
78323
- const VERSION = "0.9.1-dev.7ee59d3";
78417
+ const VERSION = "0.9.1-dev.846c2df";
78324
78418
  //#endregion
78325
78419
  //#region src/cli/utils/json-mode.ts
78326
78420
  let context = null;
@@ -78678,13 +78772,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
78678
78772
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
78679
78773
  * standard `SENTRY_RELEASE` override.
78680
78774
  */
78681
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.9.1-dev.7ee59d3`;
78775
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.9.1-dev.846c2df`;
78682
78776
  /**
78683
78777
  * Deployment environment shown in Sentry's environment filter. Defaults to
78684
78778
  * `production` for tagged releases and `development` for dev/unbuilt versions,
78685
78779
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
78686
78780
  */
78687
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.9.1-dev.7ee59d3") ? "development" : "production");
78781
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.9.1-dev.846c2df") ? "development" : "production");
78688
78782
  /**
78689
78783
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
78690
78784
  * (set to `0` to disable tracing) and falls back to
@@ -97483,4 +97577,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
97483
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 };
97484
97578
 
97485
97579
  //# sourceMappingURL=cli.js.map
97486
- //# debugId=7f26fa62-fe0c-5ae0-bc9c-97a0deb50b43
97580
+ //# debugId=f34e66dd-4b16-53f5-a3af-9844fbc71772
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]="5ad39650-1163-5117-aad5-472963ee3867")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="afe9afbe-4d17-5f2a-8b4f-9b49703c42be")}catch(e){}}();
3
3
  import { i as __toESM$1, r as __require, t as __commonJSMin$1 } from "./chunk-ChKA3wi6.js";
4
4
  import { createRequire } from "node:module";
5
5
  import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
@@ -11,6 +11,7 @@ import * as Path from "node:path";
11
11
  import path from "node:path";
12
12
  import * as NodeChildProcess from "node:child_process";
13
13
  import { execFileSync, spawn, spawnSync } from "node:child_process";
14
+ import { ResolverFactory } from "oxc-resolver";
14
15
  import ts from "typescript";
15
16
  import * as OS from "node:os";
16
17
  import os from "node:os";
@@ -62043,7 +62044,7 @@ const findMonorepoRoot = (startDirectory) => {
62043
62044
  */
62044
62045
  const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
62045
62046
  const TSCONFIG_FILENAME = "tsconfig.json";
62046
- const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || Path.isAbsolute(extendsValue);
62047
+ const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
62047
62048
  const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
62048
62049
  const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62049
62050
  const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
@@ -62060,7 +62061,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62060
62061
  return null;
62061
62062
  };
62062
62063
  const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
62063
- if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(Path.resolve(fromConfigDirectory, extendsValue));
62064
+ if (isLocalModuleSpecifier(extendsValue)) {
62065
+ const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
62066
+ if (isFile(resolvedPath)) return resolvedPath;
62067
+ const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
62068
+ return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
62069
+ }
62064
62070
  return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
62065
62071
  };
62066
62072
  const normalizeCompilerOptions = (compilerOptions) => {
@@ -62254,6 +62260,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
62254
62260
  ".cts",
62255
62261
  ".json"
62256
62262
  ];
62263
+ const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
62264
+ conditionNames: [
62265
+ "import",
62266
+ "require",
62267
+ "node",
62268
+ "default"
62269
+ ],
62270
+ extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
62271
+ });
62257
62272
  const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
62258
62273
  const hasCompilerPackage = (packageJson, compilerPackages) => {
62259
62274
  const allDependencies = {
@@ -62277,6 +62292,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
62277
62292
  return false;
62278
62293
  };
62279
62294
  const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
62295
+ if (!isLocalModuleSpecifier(moduleSpecifier)) {
62296
+ try {
62297
+ const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
62298
+ if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
62299
+ } catch {}
62300
+ try {
62301
+ const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
62302
+ return isFile(resolvedPath) ? resolvedPath : null;
62303
+ } catch {
62304
+ return null;
62305
+ }
62306
+ }
62280
62307
  const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
62281
62308
  const extension = Path.extname(unresolvedPath);
62282
62309
  return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
@@ -62728,6 +62755,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
62728
62755
  visitReturns(functionNode.body);
62729
62756
  return hasCompiler;
62730
62757
  };
62758
+ const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
62759
+ const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
62760
+ if (!importedFilePath) return null;
62761
+ return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList);
62762
+ };
62731
62763
  const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
62732
62764
  const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
62733
62765
  if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
@@ -62748,30 +62780,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
62748
62780
  const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
62749
62781
  if (importBinding) {
62750
62782
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62751
- if (!importBinding.moduleSpecifier.startsWith(".")) return false;
62752
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62753
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62783
+ return Boolean(analyzeImportedConfig({
62784
+ analysis,
62785
+ moduleSpecifier: importBinding.moduleSpecifier,
62786
+ exportName: importBinding.exportName,
62787
+ allowCompilerTransform
62788
+ }));
62754
62789
  }
62755
62790
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
62756
62791
  return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
62757
62792
  };
62758
62793
  const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
62759
62794
  const target = callExpression.expression;
62795
+ const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
62796
+ if (callableRequiredModuleSpecifier !== null) {
62797
+ if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62798
+ if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
62799
+ const hasCompilerTransform = analyzeImportedConfig({
62800
+ analysis,
62801
+ moduleSpecifier: callableRequiredModuleSpecifier,
62802
+ exportName: "default",
62803
+ allowCompilerTransform,
62804
+ argumentsList: callExpression.arguments
62805
+ });
62806
+ if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62807
+ return null;
62808
+ }
62760
62809
  if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
62761
62810
  const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
62762
62811
  if (propertyName === null) return null;
62763
62812
  const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
62764
62813
  if (requiredModuleSpecifier !== null) {
62765
- if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62766
- if (!requiredModuleSpecifier.startsWith(".")) return null;
62767
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62768
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62814
+ if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (analysis.localBindings.has(target.expression.expression.text) || getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62815
+ if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
62816
+ const hasCompilerTransform = analyzeImportedConfig({
62817
+ analysis,
62818
+ moduleSpecifier: requiredModuleSpecifier,
62819
+ exportName: propertyName,
62820
+ allowCompilerTransform,
62821
+ argumentsList: callExpression.arguments
62822
+ });
62823
+ if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62824
+ return null;
62769
62825
  }
62770
62826
  if (!ts.isIdentifier(target.expression)) return null;
62771
- const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
62772
- if (importBinding?.isNamespace && importBinding.moduleSpecifier.startsWith(".")) {
62773
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62774
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62827
+ const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
62828
+ if (importBinding?.isNamespace) {
62829
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
62830
+ const hasCompilerTransform = analyzeImportedConfig({
62831
+ analysis,
62832
+ moduleSpecifier: importBinding.moduleSpecifier,
62833
+ exportName: propertyName,
62834
+ allowCompilerTransform,
62835
+ argumentsList: callExpression.arguments
62836
+ });
62837
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62838
+ return null;
62775
62839
  }
62776
62840
  const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
62777
62841
  if (selectedProperty === null) return null;
@@ -62794,9 +62858,13 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62794
62858
  if (propertyName === "reactCompiler") continue;
62795
62859
  if ((propertyName === "plugins" || propertyName === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, propertyName, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === propertyName)) continue;
62796
62860
  const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
62797
- if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer) && property.initializer.text.startsWith(".")) {
62798
- const extendedFilePath = resolveImportedConfigFile(analysis.filePath, property.initializer.text);
62799
- if (extendedFilePath && analyzeConfigModuleExport(extendedFilePath, "default", false, analysis.importDepth + 1, analysis.visitedModules)) return true;
62861
+ if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
62862
+ if (analyzeImportedConfig({
62863
+ analysis,
62864
+ moduleSpecifier: property.initializer.text,
62865
+ exportName: "default",
62866
+ allowCompilerTransform: false
62867
+ })) return true;
62800
62868
  }
62801
62869
  if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
62802
62870
  } else if (ts.isShorthandPropertyAssignment(property)) {
@@ -62829,16 +62897,27 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62829
62897
  if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
62830
62898
  if (directModuleSpecifier && !isRequireShadowed) {
62831
62899
  if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
62832
- if (directModuleSpecifier.startsWith(".")) {
62833
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, directModuleSpecifier);
62834
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, "default", allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62835
- }
62900
+ if (analyzeImportedConfig({
62901
+ analysis,
62902
+ moduleSpecifier: directModuleSpecifier,
62903
+ exportName: "default",
62904
+ allowCompilerTransform
62905
+ })) return true;
62836
62906
  }
62837
62907
  if (ts.isIdentifier(node.expression)) {
62838
- const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62839
- if (importBinding?.moduleSpecifier.startsWith(".")) {
62840
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62841
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, node.arguments));
62908
+ if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
62909
+ const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62910
+ if (importBinding) {
62911
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62912
+ const hasCompilerTransform = analyzeImportedConfig({
62913
+ analysis,
62914
+ moduleSpecifier: importBinding.moduleSpecifier,
62915
+ exportName: importBinding.exportName,
62916
+ allowCompilerTransform,
62917
+ argumentsList: node.arguments
62918
+ });
62919
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62920
+ }
62842
62921
  }
62843
62922
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
62844
62923
  if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
@@ -62848,25 +62927,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62848
62927
  if (ts.isPropertyAccessExpression(node)) {
62849
62928
  const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
62850
62929
  if (requiredModuleSpecifier) {
62851
- if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62852
- if (requiredModuleSpecifier.startsWith(".")) {
62853
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62854
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62855
- }
62930
+ if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (analysis.localBindings.has(node.expression.expression.text) || getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62931
+ if (analyzeImportedConfig({
62932
+ analysis,
62933
+ moduleSpecifier: requiredModuleSpecifier,
62934
+ exportName: node.name.text,
62935
+ allowCompilerTransform
62936
+ })) return true;
62856
62937
  return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
62857
62938
  }
62858
62939
  if (ts.isIdentifier(node.expression)) {
62859
- if (analysis.localBindings.has(node.expression.text)) {
62860
- const localInitializer = analysis.localBindings.get(node.expression.text);
62861
- return Boolean(localInitializer && analyzeConfigNode(localInitializer, analysis, allowCompilerTransform));
62940
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
62941
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
62942
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
62862
62943
  }
62863
62944
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62864
62945
  if (importBinding?.isNamespace) {
62865
62946
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
62866
- if (importBinding.moduleSpecifier.startsWith(".")) {
62867
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62868
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62869
- }
62947
+ if (analyzeImportedConfig({
62948
+ analysis,
62949
+ moduleSpecifier: importBinding.moduleSpecifier,
62950
+ exportName: node.name.text,
62951
+ allowCompilerTransform
62952
+ })) return true;
62870
62953
  return false;
62871
62954
  }
62872
62955
  const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
@@ -62877,13 +62960,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62877
62960
  }
62878
62961
  if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
62879
62962
  if (ts.isIdentifier(node.expression)) {
62963
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
62964
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
62965
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
62966
+ }
62880
62967
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62881
62968
  if (importBinding?.isNamespace) {
62882
62969
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
62883
- if (importBinding.moduleSpecifier.startsWith(".")) {
62884
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62885
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.argumentExpression.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62886
- }
62970
+ return Boolean(analyzeImportedConfig({
62971
+ analysis,
62972
+ moduleSpecifier: importBinding.moduleSpecifier,
62973
+ exportName: node.argumentExpression.text,
62974
+ allowCompilerTransform
62975
+ }));
62887
62976
  }
62888
62977
  const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
62889
62978
  if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
@@ -62921,14 +63010,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62921
63010
  };
62922
63011
  const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
62923
63012
  const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
62924
- const hasCompilerInPackageJsonConfig = (packageJson) => isPlainObject(packageJson.babel) && analyzeConfigSourceFileExport(ts.parseJsonText("package.json", JSON.stringify(packageJson.babel)), "package.json#babel", "default", false, 0, /* @__PURE__ */ new Set());
62925
- const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
63013
+ const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
63014
+ if (!isPlainObject(packageJson.babel)) return false;
63015
+ const packageJsonPath = Path.join(directory, "package.json");
63016
+ return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
63017
+ };
63018
+ const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
62926
63019
  const hasCompilerConfigurationInAncestors = (directory) => {
62927
63020
  if (isProjectBoundary(directory)) return false;
62928
63021
  let ancestorDirectory = Path.dirname(directory);
62929
63022
  while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
62930
63023
  const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
62931
- if (hasCompilerInPackageJsonConfig(isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {}) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
63024
+ const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
63025
+ if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
62932
63026
  if (isProjectBoundary(ancestorDirectory)) return false;
62933
63027
  ancestorDirectory = Path.dirname(ancestorDirectory);
62934
63028
  }
@@ -74794,4 +74888,4 @@ const toJsonReport = (result, options) => buildJsonReport({
74794
74888
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
74795
74889
 
74796
74890
  //# sourceMappingURL=index.js.map
74797
- //# debugId=5ad39650-1163-5117-aad5-472963ee3867
74891
+ //# debugId=afe9afbe-4d17-5f2a-8b4f-9b49703c42be
package/dist/lsp.js CHANGED
@@ -10,6 +10,7 @@ import * as Crypto from "node:crypto";
10
10
  import crypto, { createHash } from "node:crypto";
11
11
  import * as NodeChildProcess from "node:child_process";
12
12
  import { execFileSync, spawn, spawnSync } from "node:child_process";
13
+ import { ResolverFactory } from "oxc-resolver";
13
14
  import ts from "typescript";
14
15
  import { parseJSON5 } from "confbox";
15
16
  import * as NodeUrl from "node:url";
@@ -62096,7 +62097,7 @@ const findMonorepoRoot = (startDirectory) => {
62096
62097
  */
62097
62098
  const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
62098
62099
  const TSCONFIG_FILENAME = "tsconfig.json";
62099
- const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || Path.isAbsolute(extendsValue);
62100
+ const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
62100
62101
  const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
62101
62102
  const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62102
62103
  const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
@@ -62113,7 +62114,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
62113
62114
  return null;
62114
62115
  };
62115
62116
  const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
62116
- if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(Path.resolve(fromConfigDirectory, extendsValue));
62117
+ if (isLocalModuleSpecifier(extendsValue)) {
62118
+ const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
62119
+ if (isFile(resolvedPath)) return resolvedPath;
62120
+ const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
62121
+ return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
62122
+ }
62117
62123
  return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
62118
62124
  };
62119
62125
  const normalizeCompilerOptions = (compilerOptions) => {
@@ -62307,6 +62313,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
62307
62313
  ".cts",
62308
62314
  ".json"
62309
62315
  ];
62316
+ const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
62317
+ conditionNames: [
62318
+ "import",
62319
+ "require",
62320
+ "node",
62321
+ "default"
62322
+ ],
62323
+ extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
62324
+ });
62310
62325
  const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
62311
62326
  const hasCompilerPackage = (packageJson, compilerPackages) => {
62312
62327
  const allDependencies = {
@@ -62330,6 +62345,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
62330
62345
  return false;
62331
62346
  };
62332
62347
  const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
62348
+ if (!isLocalModuleSpecifier(moduleSpecifier)) {
62349
+ try {
62350
+ const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
62351
+ if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
62352
+ } catch {}
62353
+ try {
62354
+ const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
62355
+ return isFile(resolvedPath) ? resolvedPath : null;
62356
+ } catch {
62357
+ return null;
62358
+ }
62359
+ }
62333
62360
  const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
62334
62361
  const extension = Path.extname(unresolvedPath);
62335
62362
  return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
@@ -62781,6 +62808,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
62781
62808
  visitReturns(functionNode.body);
62782
62809
  return hasCompiler;
62783
62810
  };
62811
+ const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
62812
+ const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
62813
+ if (!importedFilePath) return null;
62814
+ return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList);
62815
+ };
62784
62816
  const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
62785
62817
  const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
62786
62818
  if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
@@ -62801,30 +62833,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
62801
62833
  const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
62802
62834
  if (importBinding) {
62803
62835
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62804
- if (!importBinding.moduleSpecifier.startsWith(".")) return false;
62805
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62806
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62836
+ return Boolean(analyzeImportedConfig({
62837
+ analysis,
62838
+ moduleSpecifier: importBinding.moduleSpecifier,
62839
+ exportName: importBinding.exportName,
62840
+ allowCompilerTransform
62841
+ }));
62807
62842
  }
62808
62843
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
62809
62844
  return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
62810
62845
  };
62811
62846
  const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
62812
62847
  const target = callExpression.expression;
62848
+ const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
62849
+ if (callableRequiredModuleSpecifier !== null) {
62850
+ if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62851
+ if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
62852
+ const hasCompilerTransform = analyzeImportedConfig({
62853
+ analysis,
62854
+ moduleSpecifier: callableRequiredModuleSpecifier,
62855
+ exportName: "default",
62856
+ allowCompilerTransform,
62857
+ argumentsList: callExpression.arguments
62858
+ });
62859
+ if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62860
+ return null;
62861
+ }
62813
62862
  if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
62814
62863
  const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
62815
62864
  if (propertyName === null) return null;
62816
62865
  const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
62817
62866
  if (requiredModuleSpecifier !== null) {
62818
- if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62819
- if (!requiredModuleSpecifier.startsWith(".")) return null;
62820
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62821
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62867
+ if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (analysis.localBindings.has(target.expression.expression.text) || getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62868
+ if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
62869
+ const hasCompilerTransform = analyzeImportedConfig({
62870
+ analysis,
62871
+ moduleSpecifier: requiredModuleSpecifier,
62872
+ exportName: propertyName,
62873
+ allowCompilerTransform,
62874
+ argumentsList: callExpression.arguments
62875
+ });
62876
+ if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62877
+ return null;
62822
62878
  }
62823
62879
  if (!ts.isIdentifier(target.expression)) return null;
62824
- const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
62825
- if (importBinding?.isNamespace && importBinding.moduleSpecifier.startsWith(".")) {
62826
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62827
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, propertyName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, callExpression.arguments));
62880
+ const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
62881
+ if (importBinding?.isNamespace) {
62882
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
62883
+ const hasCompilerTransform = analyzeImportedConfig({
62884
+ analysis,
62885
+ moduleSpecifier: importBinding.moduleSpecifier,
62886
+ exportName: propertyName,
62887
+ allowCompilerTransform,
62888
+ argumentsList: callExpression.arguments
62889
+ });
62890
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62891
+ return null;
62828
62892
  }
62829
62893
  const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
62830
62894
  if (selectedProperty === null) return null;
@@ -62847,9 +62911,13 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62847
62911
  if (propertyName === "reactCompiler") continue;
62848
62912
  if ((propertyName === "plugins" || propertyName === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, propertyName, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === propertyName)) continue;
62849
62913
  const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
62850
- if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer) && property.initializer.text.startsWith(".")) {
62851
- const extendedFilePath = resolveImportedConfigFile(analysis.filePath, property.initializer.text);
62852
- if (extendedFilePath && analyzeConfigModuleExport(extendedFilePath, "default", false, analysis.importDepth + 1, analysis.visitedModules)) return true;
62914
+ if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
62915
+ if (analyzeImportedConfig({
62916
+ analysis,
62917
+ moduleSpecifier: property.initializer.text,
62918
+ exportName: "default",
62919
+ allowCompilerTransform: false
62920
+ })) return true;
62853
62921
  }
62854
62922
  if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
62855
62923
  } else if (ts.isShorthandPropertyAssignment(property)) {
@@ -62882,16 +62950,27 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62882
62950
  if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
62883
62951
  if (directModuleSpecifier && !isRequireShadowed) {
62884
62952
  if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
62885
- if (directModuleSpecifier.startsWith(".")) {
62886
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, directModuleSpecifier);
62887
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, "default", allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62888
- }
62953
+ if (analyzeImportedConfig({
62954
+ analysis,
62955
+ moduleSpecifier: directModuleSpecifier,
62956
+ exportName: "default",
62957
+ allowCompilerTransform
62958
+ })) return true;
62889
62959
  }
62890
62960
  if (ts.isIdentifier(node.expression)) {
62891
- const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62892
- if (importBinding?.moduleSpecifier.startsWith(".")) {
62893
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62894
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, node.arguments));
62961
+ if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
62962
+ const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62963
+ if (importBinding) {
62964
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
62965
+ const hasCompilerTransform = analyzeImportedConfig({
62966
+ analysis,
62967
+ moduleSpecifier: importBinding.moduleSpecifier,
62968
+ exportName: importBinding.exportName,
62969
+ allowCompilerTransform,
62970
+ argumentsList: node.arguments
62971
+ });
62972
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
62973
+ }
62895
62974
  }
62896
62975
  const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
62897
62976
  if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
@@ -62901,25 +62980,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62901
62980
  if (ts.isPropertyAccessExpression(node)) {
62902
62981
  const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
62903
62982
  if (requiredModuleSpecifier) {
62904
- if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62905
- if (requiredModuleSpecifier.startsWith(".")) {
62906
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, requiredModuleSpecifier);
62907
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62908
- }
62983
+ if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (analysis.localBindings.has(node.expression.expression.text) || getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
62984
+ if (analyzeImportedConfig({
62985
+ analysis,
62986
+ moduleSpecifier: requiredModuleSpecifier,
62987
+ exportName: node.name.text,
62988
+ allowCompilerTransform
62989
+ })) return true;
62909
62990
  return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
62910
62991
  }
62911
62992
  if (ts.isIdentifier(node.expression)) {
62912
- if (analysis.localBindings.has(node.expression.text)) {
62913
- const localInitializer = analysis.localBindings.get(node.expression.text);
62914
- return Boolean(localInitializer && analyzeConfigNode(localInitializer, analysis, allowCompilerTransform));
62993
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
62994
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
62995
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
62915
62996
  }
62916
62997
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62917
62998
  if (importBinding?.isNamespace) {
62918
62999
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
62919
- if (importBinding.moduleSpecifier.startsWith(".")) {
62920
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62921
- if (importedFilePath && analyzeConfigModuleExport(importedFilePath, node.name.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules)) return true;
62922
- }
63000
+ if (analyzeImportedConfig({
63001
+ analysis,
63002
+ moduleSpecifier: importBinding.moduleSpecifier,
63003
+ exportName: node.name.text,
63004
+ allowCompilerTransform
63005
+ })) return true;
62923
63006
  return false;
62924
63007
  }
62925
63008
  const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
@@ -62930,13 +63013,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62930
63013
  }
62931
63014
  if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
62932
63015
  if (ts.isIdentifier(node.expression)) {
63016
+ if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
63017
+ const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
63018
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
63019
+ }
62933
63020
  const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
62934
63021
  if (importBinding?.isNamespace) {
62935
63022
  if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
62936
- if (importBinding.moduleSpecifier.startsWith(".")) {
62937
- const importedFilePath = resolveImportedConfigFile(analysis.filePath, importBinding.moduleSpecifier);
62938
- return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, node.argumentExpression.text, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules));
62939
- }
63023
+ return Boolean(analyzeImportedConfig({
63024
+ analysis,
63025
+ moduleSpecifier: importBinding.moduleSpecifier,
63026
+ exportName: node.argumentExpression.text,
63027
+ allowCompilerTransform
63028
+ }));
62940
63029
  }
62941
63030
  const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
62942
63031
  if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
@@ -62974,14 +63063,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
62974
63063
  };
62975
63064
  const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
62976
63065
  const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
62977
- const hasCompilerInPackageJsonConfig = (packageJson) => isPlainObject(packageJson.babel) && analyzeConfigSourceFileExport(ts.parseJsonText("package.json", JSON.stringify(packageJson.babel)), "package.json#babel", "default", false, 0, /* @__PURE__ */ new Set());
62978
- const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
63066
+ const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
63067
+ if (!isPlainObject(packageJson.babel)) return false;
63068
+ const packageJsonPath = Path.join(directory, "package.json");
63069
+ return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
63070
+ };
63071
+ const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
62979
63072
  const hasCompilerConfigurationInAncestors = (directory) => {
62980
63073
  if (isProjectBoundary(directory)) return false;
62981
63074
  let ancestorDirectory = Path.dirname(directory);
62982
63075
  while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
62983
63076
  const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
62984
- if (hasCompilerInPackageJsonConfig(isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {}) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
63077
+ const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
63078
+ if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
62985
63079
  if (isProjectBoundary(ancestorDirectory)) return false;
62986
63080
  ancestorDirectory = Path.dirname(ancestorDirectory);
62987
63081
  }
@@ -76416,5 +76510,5 @@ const startLanguageServer = () => {
76416
76510
  };
76417
76511
  //#endregion
76418
76512
  export { startLanguageServer };
76419
- !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]="6a2a246a-da30-59c5-aa97-af8188206b96")}catch(e){}}();
76420
- //# debugId=6a2a246a-da30-59c5-aa97-af8188206b96
76513
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c9dabb64-11c9-5783-a682-d985b8bc43fe")}catch(e){}}();
76514
+ //# debugId=c9dabb64-11c9-5783-a682-d985b8bc43fe
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.9.1-dev.7ee59d3",
3
+ "version": "0.9.1-dev.846c2df",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -61,6 +61,7 @@
61
61
  "ink-spinner": "^5.0.0",
62
62
  "jiti": "^2.7.0",
63
63
  "magicast": "^0.5.3",
64
+ "oxc-resolver": "^11.24.2",
64
65
  "oxlint": ">=1.74.0 <1.75.0",
65
66
  "prompts": "^2.4.2",
66
67
  "react": "19.2.5",
@@ -70,7 +71,7 @@
70
71
  "vscode-uri": "^3.1.0",
71
72
  "yaml": "^2.9.0",
72
73
  "deslop-js": "0.9.1",
73
- "oxlint-plugin-react-doctor": "0.9.1-dev.7ee59d3"
74
+ "oxlint-plugin-react-doctor": "0.9.1-dev.846c2df"
74
75
  },
75
76
  "devDependencies": {
76
77
  "@types/babel__code-frame": "^7.27.0",
@@ -81,8 +82,8 @@
81
82
  "ink-testing-library": "^4.0.0",
82
83
  "ora": "^9.4.0",
83
84
  "@react-doctor/api": "0.9.1",
84
- "@react-doctor/core": "0.9.1",
85
- "@react-doctor/language-server": "0.9.1"
85
+ "@react-doctor/language-server": "0.9.1",
86
+ "@react-doctor/core": "0.9.1"
86
87
  },
87
88
  "engines": {
88
89
  "node": "^20.19.0 || >=22.13.0"