react-doctor 0.9.1-dev.7ee59d3 → 0.9.1-dev.80e89c5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +170 -72
- package/dist/index.js +167 -69
- package/dist/lsp.js +167 -69
- package/package.json +5 -4
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]="
|
|
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]="ac29de69-5480-5f78-bf24-603b28879241")}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";
|
|
@@ -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
|
|
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 (
|
|
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}`)] : [
|
|
@@ -62487,9 +62519,11 @@ const getAssignedPropertyInitializer = (identifier, propertyName) => {
|
|
|
62487
62519
|
initializer: assignedInitializer
|
|
62488
62520
|
};
|
|
62489
62521
|
};
|
|
62490
|
-
const getStaticConfigValueState = (expression, analysis) => {
|
|
62491
|
-
|
|
62492
|
-
|
|
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);
|
|
62493
62527
|
if (unwrappedExpression.kind === ts.SyntaxKind.NullKeyword || ts.isIdentifier(unwrappedExpression) && unwrappedExpression.text === "undefined") return {
|
|
62494
62528
|
isNullish: true,
|
|
62495
62529
|
isTruthy: false
|
|
@@ -62505,31 +62539,31 @@ const getStaticConfigValueState = (expression, analysis) => {
|
|
|
62505
62539
|
if (ts.isIdentifier(unwrappedExpression)) {
|
|
62506
62540
|
if (analysis.localBindings.has(unwrappedExpression.text)) {
|
|
62507
62541
|
const localInitializer = analysis.localBindings.get(unwrappedExpression.text);
|
|
62508
|
-
return localInitializer ? getStaticConfigValueState(localInitializer, analysis) : null;
|
|
62542
|
+
return localInitializer ? getStaticConfigValueState(localInitializer, analysis, nextVisitedExpressions) : null;
|
|
62509
62543
|
}
|
|
62510
62544
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
|
|
62511
|
-
return topLevelBinding && ts.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis) : null;
|
|
62545
|
+
return topLevelBinding && ts.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis, nextVisitedExpressions) : null;
|
|
62512
62546
|
}
|
|
62513
62547
|
if (ts.isConditionalExpression(unwrappedExpression)) {
|
|
62514
|
-
const conditionState = getStaticConfigValueState(unwrappedExpression.condition, analysis);
|
|
62515
|
-
if (conditionState !== null) return getStaticConfigValueState(conditionState.isTruthy ? unwrappedExpression.whenTrue : unwrappedExpression.whenFalse, analysis);
|
|
62516
|
-
const whenTrueState = getStaticConfigValueState(unwrappedExpression.whenTrue, analysis);
|
|
62517
|
-
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);
|
|
62518
62552
|
return whenTrueState !== null && whenFalseState !== null && whenTrueState.isNullish === whenFalseState.isNullish && whenTrueState.isTruthy === whenFalseState.isTruthy ? whenTrueState : null;
|
|
62519
62553
|
}
|
|
62520
62554
|
if (ts.isBinaryExpression(unwrappedExpression)) {
|
|
62521
|
-
const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis);
|
|
62555
|
+
const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis, nextVisitedExpressions);
|
|
62522
62556
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
|
|
62523
62557
|
if (leftState === null) return null;
|
|
62524
|
-
return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis) : leftState;
|
|
62558
|
+
return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
|
|
62525
62559
|
}
|
|
62526
62560
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.BarBarToken) {
|
|
62527
62561
|
if (leftState === null) return null;
|
|
62528
|
-
return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis);
|
|
62562
|
+
return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions);
|
|
62529
62563
|
}
|
|
62530
62564
|
if (unwrappedExpression.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken) {
|
|
62531
62565
|
if (leftState === null) return null;
|
|
62532
|
-
return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis) : leftState;
|
|
62566
|
+
return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
|
|
62533
62567
|
}
|
|
62534
62568
|
}
|
|
62535
62569
|
return null;
|
|
@@ -62538,25 +62572,27 @@ const isStaticallyDisabledConfigExpression = (expression, analysis) => getStatic
|
|
|
62538
62572
|
const isStaticallyTruthyConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isTruthy === true;
|
|
62539
62573
|
const isStaticallyNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === true;
|
|
62540
62574
|
const isStaticallyNonNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === false;
|
|
62541
|
-
const getReactCompilerFlagState = (expression, analysis) => {
|
|
62542
|
-
|
|
62543
|
-
|
|
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);
|
|
62544
62580
|
if (ts.isIdentifier(unwrappedExpression)) {
|
|
62545
62581
|
const assignedBinding = getAssignedPropertyInitializer(unwrappedExpression, "reactCompiler");
|
|
62546
62582
|
if (assignedBinding.wasFound && assignedBinding.initializer) return { isEnabled: !isStaticallyDisabledConfigExpression(assignedBinding.initializer, analysis) };
|
|
62547
62583
|
if (analysis.localBindings.has(unwrappedExpression.text)) {
|
|
62548
62584
|
const localInitializer = analysis.localBindings.get(unwrappedExpression.text);
|
|
62549
|
-
return localInitializer ? getReactCompilerFlagState(localInitializer, analysis) : null;
|
|
62585
|
+
return localInitializer ? getReactCompilerFlagState(localInitializer, analysis, nextVisitedExpressions) : null;
|
|
62550
62586
|
}
|
|
62551
62587
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
|
|
62552
|
-
return topLevelBinding && ts.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis) : null;
|
|
62588
|
+
return topLevelBinding && ts.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis, nextVisitedExpressions) : null;
|
|
62553
62589
|
}
|
|
62554
62590
|
if (!ts.isObjectLiteralExpression(unwrappedExpression)) return null;
|
|
62555
62591
|
for (const property of [...unwrappedExpression.properties].reverse()) {
|
|
62556
62592
|
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
|
|
62557
62593
|
if (ts.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
|
|
62558
62594
|
if (ts.isSpreadAssignment(property)) {
|
|
62559
|
-
const spreadState = getReactCompilerFlagState(property.expression, analysis);
|
|
62595
|
+
const spreadState = getReactCompilerFlagState(property.expression, analysis, nextVisitedExpressions);
|
|
62560
62596
|
if (spreadState) return spreadState;
|
|
62561
62597
|
}
|
|
62562
62598
|
}
|
|
@@ -62728,6 +62764,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
|
|
|
62728
62764
|
visitReturns(functionNode.body);
|
|
62729
62765
|
return hasCompiler;
|
|
62730
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
|
+
};
|
|
62731
62772
|
const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
|
|
62732
62773
|
const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
|
|
62733
62774
|
if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
|
|
@@ -62748,30 +62789,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
|
|
|
62748
62789
|
const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
|
|
62749
62790
|
if (importBinding) {
|
|
62750
62791
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
62751
|
-
|
|
62752
|
-
|
|
62753
|
-
|
|
62792
|
+
return Boolean(analyzeImportedConfig({
|
|
62793
|
+
analysis,
|
|
62794
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
62795
|
+
exportName: importBinding.exportName,
|
|
62796
|
+
allowCompilerTransform
|
|
62797
|
+
}));
|
|
62754
62798
|
}
|
|
62755
62799
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
|
|
62756
62800
|
return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
62757
62801
|
};
|
|
62758
62802
|
const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
|
|
62759
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
|
+
}
|
|
62760
62818
|
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
62761
62819
|
const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
|
|
62762
62820
|
if (propertyName === null) return null;
|
|
62763
62821
|
const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
|
|
62764
62822
|
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 (
|
|
62767
|
-
const
|
|
62768
|
-
|
|
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;
|
|
62769
62834
|
}
|
|
62770
62835
|
if (!ts.isIdentifier(target.expression)) return null;
|
|
62771
|
-
const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
|
|
62772
|
-
if (importBinding?.isNamespace
|
|
62773
|
-
|
|
62774
|
-
|
|
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;
|
|
62775
62848
|
}
|
|
62776
62849
|
const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
|
|
62777
62850
|
if (selectedProperty === null) return null;
|
|
@@ -62794,9 +62867,13 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62794
62867
|
if (propertyName === "reactCompiler") continue;
|
|
62795
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;
|
|
62796
62869
|
const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
|
|
62797
|
-
if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)
|
|
62798
|
-
|
|
62799
|
-
|
|
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;
|
|
62800
62877
|
}
|
|
62801
62878
|
if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
|
|
62802
62879
|
} else if (ts.isShorthandPropertyAssignment(property)) {
|
|
@@ -62829,16 +62906,27 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62829
62906
|
if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
62830
62907
|
if (directModuleSpecifier && !isRequireShadowed) {
|
|
62831
62908
|
if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
|
|
62832
|
-
if (
|
|
62833
|
-
|
|
62834
|
-
|
|
62835
|
-
|
|
62909
|
+
if (analyzeImportedConfig({
|
|
62910
|
+
analysis,
|
|
62911
|
+
moduleSpecifier: directModuleSpecifier,
|
|
62912
|
+
exportName: "default",
|
|
62913
|
+
allowCompilerTransform
|
|
62914
|
+
})) return true;
|
|
62836
62915
|
}
|
|
62837
62916
|
if (ts.isIdentifier(node.expression)) {
|
|
62838
|
-
|
|
62839
|
-
|
|
62840
|
-
|
|
62841
|
-
|
|
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
|
+
}
|
|
62842
62930
|
}
|
|
62843
62931
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
|
|
62844
62932
|
if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
|
|
@@ -62848,25 +62936,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62848
62936
|
if (ts.isPropertyAccessExpression(node)) {
|
|
62849
62937
|
const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
|
|
62850
62938
|
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 (
|
|
62853
|
-
|
|
62854
|
-
|
|
62855
|
-
|
|
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;
|
|
62856
62946
|
return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
|
|
62857
62947
|
}
|
|
62858
62948
|
if (ts.isIdentifier(node.expression)) {
|
|
62859
|
-
if (analysis.localBindings.has(node.expression.text)) {
|
|
62860
|
-
const
|
|
62861
|
-
return Boolean(
|
|
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));
|
|
62862
62952
|
}
|
|
62863
62953
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
62864
62954
|
if (importBinding?.isNamespace) {
|
|
62865
62955
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
|
|
62866
|
-
if (
|
|
62867
|
-
|
|
62868
|
-
|
|
62869
|
-
|
|
62956
|
+
if (analyzeImportedConfig({
|
|
62957
|
+
analysis,
|
|
62958
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
62959
|
+
exportName: node.name.text,
|
|
62960
|
+
allowCompilerTransform
|
|
62961
|
+
})) return true;
|
|
62870
62962
|
return false;
|
|
62871
62963
|
}
|
|
62872
62964
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
|
|
@@ -62877,13 +62969,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62877
62969
|
}
|
|
62878
62970
|
if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
|
|
62879
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
|
+
}
|
|
62880
62976
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
62881
62977
|
if (importBinding?.isNamespace) {
|
|
62882
62978
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
|
|
62883
|
-
|
|
62884
|
-
|
|
62885
|
-
|
|
62886
|
-
|
|
62979
|
+
return Boolean(analyzeImportedConfig({
|
|
62980
|
+
analysis,
|
|
62981
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
62982
|
+
exportName: node.argumentExpression.text,
|
|
62983
|
+
allowCompilerTransform
|
|
62984
|
+
}));
|
|
62887
62985
|
}
|
|
62888
62986
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
|
|
62889
62987
|
if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
@@ -62921,14 +63019,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62921
63019
|
};
|
|
62922
63020
|
const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
|
|
62923
63021
|
const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
|
|
62924
|
-
const hasCompilerInPackageJsonConfig = (
|
|
62925
|
-
|
|
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);
|
|
62926
63028
|
const hasCompilerConfigurationInAncestors = (directory) => {
|
|
62927
63029
|
if (isProjectBoundary(directory)) return false;
|
|
62928
63030
|
let ancestorDirectory = Path.dirname(directory);
|
|
62929
63031
|
while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
|
|
62930
63032
|
const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
|
|
62931
|
-
|
|
63033
|
+
const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
|
|
63034
|
+
if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
|
|
62932
63035
|
if (isProjectBoundary(ancestorDirectory)) return false;
|
|
62933
63036
|
ancestorDirectory = Path.dirname(ancestorDirectory);
|
|
62934
63037
|
}
|
|
@@ -67186,11 +67289,6 @@ const getTypescriptScriptKind = (fileName) => {
|
|
|
67186
67289
|
if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
|
|
67187
67290
|
return ts.ScriptKind.JS;
|
|
67188
67291
|
};
|
|
67189
|
-
const unwrapTypescriptExpression = (expression) => {
|
|
67190
|
-
let currentExpression = expression;
|
|
67191
|
-
while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
|
|
67192
|
-
return currentExpression;
|
|
67193
|
-
};
|
|
67194
67292
|
const BABEL_CONFIG_FILE_NAMES$1 = [
|
|
67195
67293
|
"babel.config.js",
|
|
67196
67294
|
"babel.config.cjs",
|
|
@@ -74794,4 +74892,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
74794
74892
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
74795
74893
|
|
|
74796
74894
|
//# sourceMappingURL=index.js.map
|
|
74797
|
-
//# debugId=
|
|
74895
|
+
//# debugId=ac29de69-5480-5f78-bf24-603b28879241
|