react-doctor 0.9.0-dev.db9d300 → 0.9.1-dev.1aa6b12
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/README.md +2 -0
- package/dist/cli.js +1135 -129
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1129 -124
- package/dist/lsp.js +1132 -126
- package/package.json +7 -6
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";
|
|
@@ -61478,7 +61479,8 @@ var AmbiguousProjectError = class extends Error {
|
|
|
61478
61479
|
}
|
|
61479
61480
|
};
|
|
61480
61481
|
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
61481
|
-
const
|
|
61482
|
+
const HTML_FILE_PATTERN = /\.html$/i;
|
|
61483
|
+
const SOURCE_FILE_PATTERN = /\.(?:tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
|
|
61482
61484
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
61483
61485
|
const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
|
|
61484
61486
|
const MINIFIED_SNIFF_BYTES = 65536;
|
|
@@ -61844,7 +61846,7 @@ const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
|
|
|
61844
61846
|
const FILE_LINT_CACHE_FILENAME = "file-lint-cache.json";
|
|
61845
61847
|
const FILE_LINT_CACHE_MAX_FILE_COUNT = 5e4;
|
|
61846
61848
|
const SIDECAR_LINT_CACHE_FILENAME = "sidecar-lint-cache.json";
|
|
61847
|
-
const CORE_PACKAGE_VERSION = "0.9.
|
|
61849
|
+
const CORE_PACKAGE_VERSION = "0.9.1";
|
|
61848
61850
|
const DEAD_CODE_CACHE_FILENAME = "dead-code-cache.json";
|
|
61849
61851
|
const DEAD_CODE_SUMMARY_CACHE_FILENAME = "dead-code-summaries.json";
|
|
61850
61852
|
const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
@@ -62095,7 +62097,7 @@ const findMonorepoRoot = (startDirectory) => {
|
|
|
62095
62097
|
*/
|
|
62096
62098
|
const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
|
|
62097
62099
|
const TSCONFIG_FILENAME = "tsconfig.json";
|
|
62098
|
-
const
|
|
62100
|
+
const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
|
|
62099
62101
|
const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
|
|
62100
62102
|
const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
62101
62103
|
const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
|
|
@@ -62112,7 +62114,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
|
62112
62114
|
return null;
|
|
62113
62115
|
};
|
|
62114
62116
|
const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
62115
|
-
if (
|
|
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
|
+
}
|
|
62116
62123
|
return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
|
|
62117
62124
|
};
|
|
62118
62125
|
const normalizeCompilerOptions = (compilerOptions) => {
|
|
@@ -62235,6 +62242,7 @@ const frameworkMergeRank = (framework) => {
|
|
|
62235
62242
|
return MOBILE_FRAMEWORKS.has(framework) ? 2 : 1;
|
|
62236
62243
|
};
|
|
62237
62244
|
const REACT_COMPILER_LINT_PACKAGES = new Set(["eslint-plugin-react-compiler"]);
|
|
62245
|
+
const REACT_COMPILER_RUNTIME_PACKAGES = new Set(["react-compiler-runtime"]);
|
|
62238
62246
|
const NEXT_CONFIG_FILENAMES = [
|
|
62239
62247
|
"next.config.js",
|
|
62240
62248
|
"next.config.mjs",
|
|
@@ -62305,6 +62313,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
|
|
|
62305
62313
|
".cts",
|
|
62306
62314
|
".json"
|
|
62307
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
|
+
});
|
|
62308
62325
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
62309
62326
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
62310
62327
|
const allDependencies = {
|
|
@@ -62328,6 +62345,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
|
|
|
62328
62345
|
return false;
|
|
62329
62346
|
};
|
|
62330
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
|
+
}
|
|
62331
62360
|
const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
|
|
62332
62361
|
const extension = Path.extname(unresolvedPath);
|
|
62333
62362
|
return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
|
|
@@ -62337,10 +62366,10 @@ const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
|
|
|
62337
62366
|
]).find(isFile) ?? null;
|
|
62338
62367
|
};
|
|
62339
62368
|
const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json") || Path.basename(filePath) === ".babelrc" ? ts.parseJsonText(filePath, content) : ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
62340
|
-
const getStaticPropertyName$
|
|
62369
|
+
const getStaticPropertyName$2 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
|
|
62341
62370
|
const isCommonJsConfigExportAssignment = (node, sourceFile) => ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
|
|
62342
62371
|
const hasExportModifier = (node) => ts.canHaveModifiers(node) && Boolean(ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
|
|
62343
|
-
const getRequireModuleSpecifier = (expression) => {
|
|
62372
|
+
const getRequireModuleSpecifier$1 = (expression) => {
|
|
62344
62373
|
if (!ts.isCallExpression(expression) || !ts.isIdentifier(expression.expression) || expression.expression.text !== "require" || expression.arguments.length !== 1) return null;
|
|
62345
62374
|
const moduleSpecifier = expression.arguments[0];
|
|
62346
62375
|
return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
@@ -62353,7 +62382,7 @@ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statemen
|
|
|
62353
62382
|
const namedBindings = importClause?.namedBindings;
|
|
62354
62383
|
return namedBindings ? ts.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
|
|
62355
62384
|
}
|
|
62356
|
-
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) =>
|
|
62385
|
+
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
|
|
62357
62386
|
return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === bindingName;
|
|
62358
62387
|
});
|
|
62359
62388
|
const getImportBinding = (sourceFile, bindingName) => {
|
|
@@ -62384,24 +62413,24 @@ const getImportBinding = (sourceFile, bindingName) => {
|
|
|
62384
62413
|
for (const declaration of statement.declarationList.declarations) {
|
|
62385
62414
|
if (!declaration.initializer) continue;
|
|
62386
62415
|
if (ts.isIdentifier(declaration.name) && declaration.name.text === bindingName) {
|
|
62387
|
-
const directModuleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
62416
|
+
const directModuleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
|
|
62388
62417
|
if (directModuleSpecifier) return {
|
|
62389
62418
|
moduleSpecifier: directModuleSpecifier,
|
|
62390
62419
|
exportName: "default",
|
|
62391
62420
|
isNamespace: true
|
|
62392
62421
|
};
|
|
62393
|
-
if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier(declaration.initializer.expression) !== null) return {
|
|
62394
|
-
moduleSpecifier: getRequireModuleSpecifier(declaration.initializer.expression) ?? "",
|
|
62422
|
+
if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier$1(declaration.initializer.expression) !== null) return {
|
|
62423
|
+
moduleSpecifier: getRequireModuleSpecifier$1(declaration.initializer.expression) ?? "",
|
|
62395
62424
|
exportName: declaration.initializer.name.text,
|
|
62396
62425
|
isNamespace: false
|
|
62397
62426
|
};
|
|
62398
62427
|
}
|
|
62399
62428
|
if (!ts.isObjectBindingPattern(declaration.name)) continue;
|
|
62400
62429
|
const bindingElement = declaration.name.elements.find((element) => ts.isIdentifier(element.name) && element.name.text === bindingName);
|
|
62401
|
-
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
62430
|
+
const moduleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
|
|
62402
62431
|
if (bindingElement && moduleSpecifier) return {
|
|
62403
62432
|
moduleSpecifier,
|
|
62404
|
-
exportName: bindingElement.propertyName ? getStaticPropertyName$
|
|
62433
|
+
exportName: bindingElement.propertyName ? getStaticPropertyName$2(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
|
|
62405
62434
|
isNamespace: false
|
|
62406
62435
|
};
|
|
62407
62436
|
}
|
|
@@ -62454,6 +62483,48 @@ const getScopedConfigBinding = (identifier) => {
|
|
|
62454
62483
|
};
|
|
62455
62484
|
};
|
|
62456
62485
|
const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
|
|
62486
|
+
const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
|
|
62487
|
+
const isConstantVariableInitializer = (node) => ts.isExpression(node) && ts.isVariableDeclaration(node.parent) && ts.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & ts.NodeFlags.Const);
|
|
62488
|
+
const isNodeCreateRequireCall = (node, analysis) => {
|
|
62489
|
+
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
|
|
62490
|
+
if (!ts.isCallExpression(node)) return false;
|
|
62491
|
+
const target = node.expression;
|
|
62492
|
+
if (ts.isIdentifier(target)) {
|
|
62493
|
+
if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
|
|
62494
|
+
const importBinding = getImportBinding(analysis.sourceFile, target.text);
|
|
62495
|
+
return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
|
|
62496
|
+
}
|
|
62497
|
+
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return false;
|
|
62498
|
+
if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "createRequire") return false;
|
|
62499
|
+
const createRequireReceiver = target.expression;
|
|
62500
|
+
if (ts.isCallExpression(createRequireReceiver)) {
|
|
62501
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(createRequireReceiver);
|
|
62502
|
+
if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !ts.isIdentifier(createRequireReceiver.expression)) return false;
|
|
62503
|
+
const requireIdentifier = createRequireReceiver.expression;
|
|
62504
|
+
return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
|
|
62505
|
+
}
|
|
62506
|
+
if (!ts.isIdentifier(createRequireReceiver)) return false;
|
|
62507
|
+
if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
|
|
62508
|
+
const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
|
|
62509
|
+
return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
|
|
62510
|
+
};
|
|
62511
|
+
const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
|
|
62512
|
+
const [moduleSpecifierNode] = callExpression.arguments;
|
|
62513
|
+
if (!moduleSpecifierNode || !ts.isStringLiteralLike(moduleSpecifierNode)) return null;
|
|
62514
|
+
const target = callExpression.expression;
|
|
62515
|
+
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
62516
|
+
if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "resolve") return null;
|
|
62517
|
+
if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
|
|
62518
|
+
if (!ts.isIdentifier(target.expression)) return null;
|
|
62519
|
+
const resolverIdentifier = target.expression;
|
|
62520
|
+
if (analysis.localBindings.has(resolverIdentifier.text)) return null;
|
|
62521
|
+
const scopedBinding = getScopedConfigBinding(resolverIdentifier);
|
|
62522
|
+
const topLevelBinding = scopedBinding.wasFound ? null : getTopLevelBinding(analysis.sourceFile, resolverIdentifier.text);
|
|
62523
|
+
const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : topLevelBinding;
|
|
62524
|
+
if (resolverInitializer === null && !scopedBinding.wasFound && resolverIdentifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, resolverIdentifier.text) && getImportBinding(analysis.sourceFile, resolverIdentifier.text) === null) return moduleSpecifierNode.text;
|
|
62525
|
+
if (!resolverInitializer || !isConstantVariableInitializer(resolverInitializer) || !isNodeCreateRequireCall(resolverInitializer, analysis)) return null;
|
|
62526
|
+
return moduleSpecifierNode.text;
|
|
62527
|
+
};
|
|
62457
62528
|
const getAssignedPropertyInitializer = (identifier, propertyName) => {
|
|
62458
62529
|
let bindingScope = null;
|
|
62459
62530
|
let currentNode = identifier;
|
|
@@ -62562,7 +62633,7 @@ const getReactCompilerFlagState = (expression, analysis) => {
|
|
|
62562
62633
|
}
|
|
62563
62634
|
if (!ts.isObjectLiteralExpression(unwrappedExpression)) return null;
|
|
62564
62635
|
for (const property of [...unwrappedExpression.properties].reverse()) {
|
|
62565
|
-
if (ts.isPropertyAssignment(property) && getStaticPropertyName$
|
|
62636
|
+
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
|
|
62566
62637
|
if (ts.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
|
|
62567
62638
|
if (ts.isSpreadAssignment(property)) {
|
|
62568
62639
|
const spreadState = getReactCompilerFlagState(property.expression, analysis);
|
|
@@ -62588,8 +62659,8 @@ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedEx
|
|
|
62588
62659
|
}
|
|
62589
62660
|
if (!ts.isObjectLiteralExpression(resolvedExpression)) return null;
|
|
62590
62661
|
for (const property of [...resolvedExpression.properties].reverse()) {
|
|
62591
|
-
if (ts.isPropertyAssignment(property) && getStaticPropertyName$
|
|
62592
|
-
if (ts.isMethodDeclaration(property) && getStaticPropertyName$
|
|
62662
|
+
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === propertyName) return property.initializer;
|
|
62663
|
+
if (ts.isMethodDeclaration(property) && getStaticPropertyName$2(property.name) === propertyName) return property;
|
|
62593
62664
|
if (ts.isShorthandPropertyAssignment(property) && property.name.text === propertyName) return property.name;
|
|
62594
62665
|
if (ts.isSpreadAssignment(property)) {
|
|
62595
62666
|
const spreadProperty = getSelectedObjectProperty(property.expression, propertyName, analysis, visitedExpressions);
|
|
@@ -62620,7 +62691,7 @@ const configExpressionMayDefineProperty = (expression, propertyName, analysis) =
|
|
|
62620
62691
|
return resolvedExpression.properties.some((property) => {
|
|
62621
62692
|
if (ts.isSpreadAssignment(property)) return configExpressionMayDefineProperty(property.expression, propertyName, analysis);
|
|
62622
62693
|
if (ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property) || ts.isMethodDeclaration(property) || ts.isGetAccessorDeclaration(property) || ts.isSetAccessorDeclaration(property)) {
|
|
62623
|
-
const staticPropertyName = getStaticPropertyName$
|
|
62694
|
+
const staticPropertyName = getStaticPropertyName$2(property.name);
|
|
62624
62695
|
return staticPropertyName === null || staticPropertyName === propertyName;
|
|
62625
62696
|
}
|
|
62626
62697
|
return false;
|
|
@@ -62639,7 +62710,7 @@ const getExportedConfigNodes = (sourceFile, exportName) => {
|
|
|
62639
62710
|
continue;
|
|
62640
62711
|
}
|
|
62641
62712
|
if (ts.isExpressionStatement(statement) && isCommonJsConfigExportAssignment(statement.expression, sourceFile) && exportName !== "default" && ts.isObjectLiteralExpression(statement.expression.right)) for (const property of [...statement.expression.right.properties].reverse()) {
|
|
62642
|
-
if (ts.isPropertyAssignment(property) && getStaticPropertyName$
|
|
62713
|
+
if (ts.isPropertyAssignment(property) && getStaticPropertyName$2(property.name) === exportName) {
|
|
62643
62714
|
exportedNodes.push(property.initializer);
|
|
62644
62715
|
break;
|
|
62645
62716
|
}
|
|
@@ -62737,6 +62808,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
|
|
|
62737
62808
|
visitReturns(functionNode.body);
|
|
62738
62809
|
return hasCompiler;
|
|
62739
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
|
+
};
|
|
62740
62816
|
const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
|
|
62741
62817
|
const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
|
|
62742
62818
|
if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
|
|
@@ -62757,30 +62833,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
|
|
|
62757
62833
|
const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
|
|
62758
62834
|
if (importBinding) {
|
|
62759
62835
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
62760
|
-
|
|
62761
|
-
|
|
62762
|
-
|
|
62836
|
+
return Boolean(analyzeImportedConfig({
|
|
62837
|
+
analysis,
|
|
62838
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
62839
|
+
exportName: importBinding.exportName,
|
|
62840
|
+
allowCompilerTransform
|
|
62841
|
+
}));
|
|
62763
62842
|
}
|
|
62764
62843
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
|
|
62765
62844
|
return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
62766
62845
|
};
|
|
62767
62846
|
const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
|
|
62768
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
|
+
}
|
|
62769
62862
|
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
62770
62863
|
const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
|
|
62771
62864
|
if (propertyName === null) return null;
|
|
62772
|
-
const requiredModuleSpecifier = getRequireModuleSpecifier(target.expression);
|
|
62865
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
|
|
62773
62866
|
if (requiredModuleSpecifier !== null) {
|
|
62774
|
-
if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
62775
|
-
if (
|
|
62776
|
-
const
|
|
62777
|
-
|
|
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;
|
|
62778
62878
|
}
|
|
62779
62879
|
if (!ts.isIdentifier(target.expression)) return null;
|
|
62780
|
-
const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
|
|
62781
|
-
if (importBinding?.isNamespace
|
|
62782
|
-
|
|
62783
|
-
|
|
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;
|
|
62784
62892
|
}
|
|
62785
62893
|
const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
|
|
62786
62894
|
if (selectedProperty === null) return null;
|
|
@@ -62798,25 +62906,29 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62798
62906
|
const reactCompilerFlagState = excludedPropertyNames?.has("reactCompiler") ? null : getReactCompilerFlagState(node, analysis);
|
|
62799
62907
|
if (reactCompilerFlagState?.isEnabled) return true;
|
|
62800
62908
|
for (const [propertyIndex, property] of node.properties.entries()) if (ts.isPropertyAssignment(property)) {
|
|
62801
|
-
const propertyName = getStaticPropertyName$
|
|
62909
|
+
const propertyName = getStaticPropertyName$2(property.name);
|
|
62802
62910
|
if (propertyName && excludedPropertyNames?.has(propertyName)) continue;
|
|
62803
62911
|
if (propertyName === "reactCompiler") continue;
|
|
62804
|
-
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$
|
|
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;
|
|
62805
62913
|
const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
|
|
62806
|
-
if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)
|
|
62807
|
-
|
|
62808
|
-
|
|
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;
|
|
62809
62921
|
}
|
|
62810
62922
|
if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
|
|
62811
62923
|
} else if (ts.isShorthandPropertyAssignment(property)) {
|
|
62812
62924
|
if (excludedPropertyNames?.has(property.name.text)) continue;
|
|
62813
62925
|
if (property.name.text === "reactCompiler") continue;
|
|
62814
|
-
if ((property.name.text === "plugins" || property.name.text === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, property.name.text, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$
|
|
62926
|
+
if ((property.name.text === "plugins" || property.name.text === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, property.name.text, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === property.name.text)) continue;
|
|
62815
62927
|
const propertyAllowsCompilerTransform = property.name.text === "plugins" || property.name.text === "presets";
|
|
62816
62928
|
if (analyzeConfigNode(property.name, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
|
|
62817
62929
|
} else if (ts.isSpreadAssignment(property)) {
|
|
62818
62930
|
if (reactCompilerFlagState && getReactCompilerFlagState(property.expression, analysis) !== null) continue;
|
|
62819
|
-
if (node.properties.slice(propertyIndex + 1).some((laterProperty) => (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && (getStaticPropertyName$
|
|
62931
|
+
if (node.properties.slice(propertyIndex + 1).some((laterProperty) => (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && (getStaticPropertyName$2(laterProperty.name) === "plugins" || getStaticPropertyName$2(laterProperty.name) === "presets"))) continue;
|
|
62820
62932
|
if (analyzeConfigNode(property.expression, analysis, allowCompilerTransform, false, excludedPropertyNames)) return true;
|
|
62821
62933
|
}
|
|
62822
62934
|
return false;
|
|
@@ -62829,23 +62941,36 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62829
62941
|
});
|
|
62830
62942
|
}
|
|
62831
62943
|
if (ts.isCallExpression(node)) {
|
|
62944
|
+
const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
|
|
62945
|
+
if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
|
|
62832
62946
|
const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
|
|
62833
62947
|
if (callTargetResult !== null) return callTargetResult;
|
|
62834
|
-
const directModuleSpecifier = getRequireModuleSpecifier(node);
|
|
62948
|
+
const directModuleSpecifier = getRequireModuleSpecifier$1(node);
|
|
62835
62949
|
const isRequireShadowed = analysis.localBindings.has("require") || ts.isIdentifier(node.expression) && getScopedConfigBinding(node.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require");
|
|
62836
62950
|
if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
62837
62951
|
if (directModuleSpecifier && !isRequireShadowed) {
|
|
62838
62952
|
if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
|
|
62839
|
-
if (
|
|
62840
|
-
|
|
62841
|
-
|
|
62842
|
-
|
|
62953
|
+
if (analyzeImportedConfig({
|
|
62954
|
+
analysis,
|
|
62955
|
+
moduleSpecifier: directModuleSpecifier,
|
|
62956
|
+
exportName: "default",
|
|
62957
|
+
allowCompilerTransform
|
|
62958
|
+
})) return true;
|
|
62843
62959
|
}
|
|
62844
62960
|
if (ts.isIdentifier(node.expression)) {
|
|
62845
|
-
|
|
62846
|
-
|
|
62847
|
-
|
|
62848
|
-
|
|
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
|
+
}
|
|
62849
62974
|
}
|
|
62850
62975
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
|
|
62851
62976
|
if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
|
|
@@ -62853,27 +62978,31 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62853
62978
|
return analyzeConfigNode(node.expression, analysis, allowCompilerTransform) || node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false));
|
|
62854
62979
|
}
|
|
62855
62980
|
if (ts.isPropertyAccessExpression(node)) {
|
|
62856
|
-
const requiredModuleSpecifier = getRequireModuleSpecifier(node.expression);
|
|
62981
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
|
|
62857
62982
|
if (requiredModuleSpecifier) {
|
|
62858
|
-
if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
62859
|
-
if (
|
|
62860
|
-
|
|
62861
|
-
|
|
62862
|
-
|
|
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;
|
|
62863
62990
|
return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
|
|
62864
62991
|
}
|
|
62865
62992
|
if (ts.isIdentifier(node.expression)) {
|
|
62866
|
-
if (analysis.localBindings.has(node.expression.text)) {
|
|
62867
|
-
const
|
|
62868
|
-
return Boolean(
|
|
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));
|
|
62869
62996
|
}
|
|
62870
62997
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
62871
62998
|
if (importBinding?.isNamespace) {
|
|
62872
62999
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
|
|
62873
|
-
if (
|
|
62874
|
-
|
|
62875
|
-
|
|
62876
|
-
|
|
63000
|
+
if (analyzeImportedConfig({
|
|
63001
|
+
analysis,
|
|
63002
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63003
|
+
exportName: node.name.text,
|
|
63004
|
+
allowCompilerTransform
|
|
63005
|
+
})) return true;
|
|
62877
63006
|
return false;
|
|
62878
63007
|
}
|
|
62879
63008
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
|
|
@@ -62884,13 +63013,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62884
63013
|
}
|
|
62885
63014
|
if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
|
|
62886
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
|
+
}
|
|
62887
63020
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
62888
63021
|
if (importBinding?.isNamespace) {
|
|
62889
63022
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
|
|
62890
|
-
|
|
62891
|
-
|
|
62892
|
-
|
|
62893
|
-
|
|
63023
|
+
return Boolean(analyzeImportedConfig({
|
|
63024
|
+
analysis,
|
|
63025
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
63026
|
+
exportName: node.argumentExpression.text,
|
|
63027
|
+
allowCompilerTransform
|
|
63028
|
+
}));
|
|
62894
63029
|
}
|
|
62895
63030
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
|
|
62896
63031
|
if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
@@ -62928,20 +63063,25 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62928
63063
|
};
|
|
62929
63064
|
const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
|
|
62930
63065
|
const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
|
|
62931
|
-
const hasCompilerInPackageJsonConfig = (
|
|
62932
|
-
|
|
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);
|
|
62933
63072
|
const hasCompilerConfigurationInAncestors = (directory) => {
|
|
62934
63073
|
if (isProjectBoundary(directory)) return false;
|
|
62935
63074
|
let ancestorDirectory = Path.dirname(directory);
|
|
62936
63075
|
while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
|
|
62937
63076
|
const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
|
|
62938
|
-
|
|
63077
|
+
const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
|
|
63078
|
+
if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
|
|
62939
63079
|
if (isProjectBoundary(ancestorDirectory)) return false;
|
|
62940
63080
|
ancestorDirectory = Path.dirname(ancestorDirectory);
|
|
62941
63081
|
}
|
|
62942
63082
|
return false;
|
|
62943
63083
|
};
|
|
62944
|
-
const detectReactCompiler = (directory, packageJson) => hasCompilerConfiguration(directory, packageJson) || hasCompilerConfigurationInAncestors(directory);
|
|
63084
|
+
const detectReactCompiler = (directory, packageJson) => hasCompilerPackage(packageJson, REACT_COMPILER_RUNTIME_PACKAGES) || hasCompilerPackageInAncestors(directory, REACT_COMPILER_RUNTIME_PACKAGES) || hasCompilerConfiguration(directory, packageJson) || hasCompilerConfigurationInAncestors(directory);
|
|
62945
63085
|
const detectReactCompilerLintPlugin = (directory, packageJson) => hasCompilerPackage(packageJson, REACT_COMPILER_LINT_PACKAGES) || hasCompilerPackageInAncestors(directory, REACT_COMPILER_LINT_PACKAGES);
|
|
62946
63086
|
const detectNextjsStaticExport = (directory) => NEXT_CONFIG_FILENAMES.some((filename) => {
|
|
62947
63087
|
const filePath = Path.join(directory, filename);
|
|
@@ -66164,7 +66304,7 @@ const warn = (message) => {
|
|
|
66164
66304
|
runSync(warn$1(message));
|
|
66165
66305
|
};
|
|
66166
66306
|
const CONFIG_BASENAME = "doctor.config";
|
|
66167
|
-
const CONFIG_EXTENSIONS = [
|
|
66307
|
+
const CONFIG_EXTENSIONS$1 = [
|
|
66168
66308
|
"ts",
|
|
66169
66309
|
"mts",
|
|
66170
66310
|
"cts",
|
|
@@ -66268,7 +66408,7 @@ const loadLegacyConfig = (directory) => {
|
|
|
66268
66408
|
};
|
|
66269
66409
|
const loadConfigFromDirectory = async (directory) => {
|
|
66270
66410
|
let sawBrokenConfigFile = false;
|
|
66271
|
-
for (const extension of CONFIG_EXTENSIONS) {
|
|
66411
|
+
for (const extension of CONFIG_EXTENSIONS$1) {
|
|
66272
66412
|
const filePath = Path.join(directory, `${CONFIG_BASENAME}.${extension}`);
|
|
66273
66413
|
if (!isFile(filePath)) continue;
|
|
66274
66414
|
const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
|
|
@@ -66955,6 +67095,321 @@ const buildReactNativeDiagnostic = (input) => ({
|
|
|
66955
67095
|
column: input.column ?? 0,
|
|
66956
67096
|
category: input.category ?? "Correctness"
|
|
66957
67097
|
});
|
|
67098
|
+
const ANDROID_APP_BUILD_FILE_NAMES = ["build.gradle", "build.gradle.kts"];
|
|
67099
|
+
const BUILD_TYPES_BLOCK_PATTERN = /\bbuildTypes\s*\{/g;
|
|
67100
|
+
const RELEASE_STRING_MARKER = "__RD_RELEASE__";
|
|
67101
|
+
const RELEASE_BLOCK_PATTERNS = [/\brelease\s*\{/g, /\b(?:getByName|named)\s*\(\s*(?:["']release["']|__RD_RELEASE__)\s*\)\s*\{/g];
|
|
67102
|
+
const MINIFY_ASSIGNMENT_PATTERN = /\b(?:isMinifyEnabled|minifyEnabled)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
|
|
67103
|
+
const SHRINK_RESOURCES_ASSIGNMENT_PATTERN = /\b(?:isShrinkResources|shrinkResources)\b\s*(?:\(\s*|=\s*|\s+)([^;}\r\n]+)/g;
|
|
67104
|
+
const stripGradleComments = (contents) => {
|
|
67105
|
+
let result = "";
|
|
67106
|
+
let index = 0;
|
|
67107
|
+
let quote = null;
|
|
67108
|
+
while (index < contents.length) {
|
|
67109
|
+
const character = contents[index];
|
|
67110
|
+
const nextCharacter = contents[index + 1];
|
|
67111
|
+
if (quote !== null) {
|
|
67112
|
+
result += character;
|
|
67113
|
+
if (character === "\\") {
|
|
67114
|
+
result += nextCharacter ?? "";
|
|
67115
|
+
index += 2;
|
|
67116
|
+
continue;
|
|
67117
|
+
}
|
|
67118
|
+
if (character === quote) quote = null;
|
|
67119
|
+
index += 1;
|
|
67120
|
+
continue;
|
|
67121
|
+
}
|
|
67122
|
+
if (character === "\"" || character === "'") {
|
|
67123
|
+
quote = character;
|
|
67124
|
+
result += character;
|
|
67125
|
+
index += 1;
|
|
67126
|
+
continue;
|
|
67127
|
+
}
|
|
67128
|
+
if (character === "/" && nextCharacter === "/") {
|
|
67129
|
+
while (index < contents.length && contents[index] !== "\n") {
|
|
67130
|
+
result += " ";
|
|
67131
|
+
index += 1;
|
|
67132
|
+
}
|
|
67133
|
+
continue;
|
|
67134
|
+
}
|
|
67135
|
+
if (character === "/" && nextCharacter === "*") {
|
|
67136
|
+
result += " ";
|
|
67137
|
+
index += 2;
|
|
67138
|
+
while (index < contents.length && !(contents[index] === "*" && contents[index + 1] === "/")) {
|
|
67139
|
+
result += contents[index] === "\n" ? "\n" : " ";
|
|
67140
|
+
index += 1;
|
|
67141
|
+
}
|
|
67142
|
+
if (index < contents.length) {
|
|
67143
|
+
result += " ";
|
|
67144
|
+
index += 2;
|
|
67145
|
+
}
|
|
67146
|
+
continue;
|
|
67147
|
+
}
|
|
67148
|
+
result += character;
|
|
67149
|
+
index += 1;
|
|
67150
|
+
}
|
|
67151
|
+
return result;
|
|
67152
|
+
};
|
|
67153
|
+
const maskGradleStrings = (contents) => {
|
|
67154
|
+
let result = "";
|
|
67155
|
+
let index = 0;
|
|
67156
|
+
let quote = null;
|
|
67157
|
+
while (index < contents.length) {
|
|
67158
|
+
const character = contents[index];
|
|
67159
|
+
if (quote === null) {
|
|
67160
|
+
if (character === "\"" || character === "'") {
|
|
67161
|
+
quote = character;
|
|
67162
|
+
result += " ";
|
|
67163
|
+
} else result += character;
|
|
67164
|
+
index += 1;
|
|
67165
|
+
continue;
|
|
67166
|
+
}
|
|
67167
|
+
if (character === "\\") {
|
|
67168
|
+
result += " ";
|
|
67169
|
+
index += 2;
|
|
67170
|
+
continue;
|
|
67171
|
+
}
|
|
67172
|
+
if (character === quote) quote = null;
|
|
67173
|
+
result += character === "\n" ? "\n" : " ";
|
|
67174
|
+
index += 1;
|
|
67175
|
+
}
|
|
67176
|
+
return result;
|
|
67177
|
+
};
|
|
67178
|
+
const findBlockContents = (contents, pattern) => {
|
|
67179
|
+
const blocks = [];
|
|
67180
|
+
pattern.lastIndex = 0;
|
|
67181
|
+
let match = pattern.exec(contents);
|
|
67182
|
+
while (match !== null) {
|
|
67183
|
+
const openingBraceIndex = pattern.lastIndex - 1;
|
|
67184
|
+
let depth = 1;
|
|
67185
|
+
let index = openingBraceIndex + 1;
|
|
67186
|
+
let quote = null;
|
|
67187
|
+
while (index < contents.length && depth > 0) {
|
|
67188
|
+
const character = contents[index];
|
|
67189
|
+
if (quote !== null) {
|
|
67190
|
+
if (character === "\\") {
|
|
67191
|
+
index += 2;
|
|
67192
|
+
continue;
|
|
67193
|
+
}
|
|
67194
|
+
if (character === quote) quote = null;
|
|
67195
|
+
} else if (character === "\"" || character === "'") quote = character;
|
|
67196
|
+
else if (character === "{") depth += 1;
|
|
67197
|
+
else if (character === "}") depth -= 1;
|
|
67198
|
+
index += 1;
|
|
67199
|
+
}
|
|
67200
|
+
if (depth === 0) blocks.push(contents.slice(openingBraceIndex + 1, index - 1));
|
|
67201
|
+
match = pattern.exec(contents);
|
|
67202
|
+
}
|
|
67203
|
+
return blocks;
|
|
67204
|
+
};
|
|
67205
|
+
const getFinalStaticBoolean = (contents, pattern) => {
|
|
67206
|
+
pattern.lastIndex = 0;
|
|
67207
|
+
let finalValue = null;
|
|
67208
|
+
let match = pattern.exec(contents);
|
|
67209
|
+
while (match !== null) {
|
|
67210
|
+
const staticValue = match[1]?.trim().replace(/\)$/, "").trim();
|
|
67211
|
+
if (staticValue === "true") finalValue = true;
|
|
67212
|
+
else if (staticValue === "false") finalValue = false;
|
|
67213
|
+
else finalValue = null;
|
|
67214
|
+
match = pattern.exec(contents);
|
|
67215
|
+
}
|
|
67216
|
+
return finalValue;
|
|
67217
|
+
};
|
|
67218
|
+
const getReleaseBlocks = (contents) => findBlockContents(contents, BUILD_TYPES_BLOCK_PATTERN).flatMap((buildTypesBlock) => RELEASE_BLOCK_PATTERNS.flatMap((pattern) => findBlockContents(buildTypesBlock, pattern)));
|
|
67219
|
+
const readAndroidReleaseShrinking = (rootDirectory) => {
|
|
67220
|
+
for (const buildFileName of ANDROID_APP_BUILD_FILE_NAMES) {
|
|
67221
|
+
const filePath = Path.posix.join("android", "app", buildFileName);
|
|
67222
|
+
const absoluteFilePath = Path.join(rootDirectory, filePath);
|
|
67223
|
+
if (!isFile(absoluteFilePath)) continue;
|
|
67224
|
+
let contents;
|
|
67225
|
+
try {
|
|
67226
|
+
contents = stripGradleComments(NFS.readFileSync(absoluteFilePath, "utf-8"));
|
|
67227
|
+
} catch {
|
|
67228
|
+
return null;
|
|
67229
|
+
}
|
|
67230
|
+
const releaseBlocks = getReleaseBlocks(maskGradleStrings(contents.replace(/(["'])release\1/g, RELEASE_STRING_MARKER)));
|
|
67231
|
+
const [releaseBlock] = releaseBlocks;
|
|
67232
|
+
if (releaseBlock === void 0 || releaseBlocks.length !== 1) return null;
|
|
67233
|
+
const hasDisabledMinification = getFinalStaticBoolean(releaseBlock, MINIFY_ASSIGNMENT_PATTERN) === false;
|
|
67234
|
+
const hasDisabledResourceShrinking = getFinalStaticBoolean(releaseBlock, SHRINK_RESOURCES_ASSIGNMENT_PATTERN) === false;
|
|
67235
|
+
if (!hasDisabledMinification && !hasDisabledResourceShrinking) return null;
|
|
67236
|
+
return {
|
|
67237
|
+
filePath,
|
|
67238
|
+
hasDisabledMinification,
|
|
67239
|
+
hasDisabledResourceShrinking
|
|
67240
|
+
};
|
|
67241
|
+
}
|
|
67242
|
+
return null;
|
|
67243
|
+
};
|
|
67244
|
+
const checkReactNativeAndroidReleaseShrinking = (rootDirectory) => {
|
|
67245
|
+
const releaseShrinking = readAndroidReleaseShrinking(rootDirectory);
|
|
67246
|
+
if (releaseShrinking === null) return [];
|
|
67247
|
+
const disabledFeatures = [releaseShrinking.hasDisabledMinification ? "code minification" : null, releaseShrinking.hasDisabledResourceShrinking ? "resource shrinking" : null].filter((feature) => feature !== null);
|
|
67248
|
+
return [buildReactNativeDiagnostic({
|
|
67249
|
+
filePath: releaseShrinking.filePath,
|
|
67250
|
+
rule: "rn-android-release-shrinking-disabled",
|
|
67251
|
+
category: "Performance",
|
|
67252
|
+
message: `The Android release build explicitly disables ${disabledFeatures.join(" and ")}, leaving unreachable code or resources in the shipped app.`,
|
|
67253
|
+
help: "Enable release code minification and resource shrinking, then test the optimized build and add keep rules for libraries that require them."
|
|
67254
|
+
})];
|
|
67255
|
+
};
|
|
67256
|
+
const getTypescriptScriptKind = (fileName) => {
|
|
67257
|
+
if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
67258
|
+
if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
67259
|
+
if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
|
|
67260
|
+
return ts.ScriptKind.JS;
|
|
67261
|
+
};
|
|
67262
|
+
const unwrapTypescriptExpression = (expression) => {
|
|
67263
|
+
let currentExpression = expression;
|
|
67264
|
+
while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
|
|
67265
|
+
return currentExpression;
|
|
67266
|
+
};
|
|
67267
|
+
const BABEL_CONFIG_FILE_NAMES$1 = [
|
|
67268
|
+
"babel.config.js",
|
|
67269
|
+
"babel.config.cjs",
|
|
67270
|
+
"babel.config.mjs",
|
|
67271
|
+
"babel.config.ts",
|
|
67272
|
+
"babel.config.cts",
|
|
67273
|
+
"babel.config.json",
|
|
67274
|
+
".babelrc",
|
|
67275
|
+
".babelrc.js",
|
|
67276
|
+
".babelrc.cjs",
|
|
67277
|
+
".babelrc.mjs",
|
|
67278
|
+
".babelrc.cts",
|
|
67279
|
+
".babelrc.json"
|
|
67280
|
+
];
|
|
67281
|
+
const readUnknownPluginNames = (value) => {
|
|
67282
|
+
if (!Array.isArray(value)) return null;
|
|
67283
|
+
const pluginNames = [];
|
|
67284
|
+
for (const entry of value) {
|
|
67285
|
+
if (typeof entry === "string") {
|
|
67286
|
+
pluginNames.push(entry);
|
|
67287
|
+
continue;
|
|
67288
|
+
}
|
|
67289
|
+
if (Array.isArray(entry) && typeof entry[0] === "string") {
|
|
67290
|
+
pluginNames.push(entry[0]);
|
|
67291
|
+
continue;
|
|
67292
|
+
}
|
|
67293
|
+
return null;
|
|
67294
|
+
}
|
|
67295
|
+
return pluginNames;
|
|
67296
|
+
};
|
|
67297
|
+
const getStaticPropertyName$1 = (propertyName) => {
|
|
67298
|
+
if (ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName)) return propertyName.text;
|
|
67299
|
+
return null;
|
|
67300
|
+
};
|
|
67301
|
+
const getStaticPluginName = (expression) => {
|
|
67302
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
67303
|
+
if (ts.isStringLiteralLike(unwrappedExpression)) return unwrappedExpression.text;
|
|
67304
|
+
if (!ts.isArrayLiteralExpression(unwrappedExpression)) return null;
|
|
67305
|
+
const pluginExpression = unwrappedExpression.elements[0];
|
|
67306
|
+
return pluginExpression && ts.isStringLiteralLike(pluginExpression) ? pluginExpression.text : null;
|
|
67307
|
+
};
|
|
67308
|
+
const getPluginNamesFromObject = (objectExpression) => {
|
|
67309
|
+
if (objectExpression.properties.some((property) => ts.isSpreadAssignment(property))) return null;
|
|
67310
|
+
const pluginProperties = objectExpression.properties.filter((property) => ts.isPropertyAssignment(property) && getStaticPropertyName$1(property.name) === "plugins");
|
|
67311
|
+
if (pluginProperties.length !== 1) return pluginProperties.length === 0 ? [] : null;
|
|
67312
|
+
const pluginListExpression = unwrapTypescriptExpression(pluginProperties[0].initializer);
|
|
67313
|
+
if (!ts.isArrayLiteralExpression(pluginListExpression)) return null;
|
|
67314
|
+
const pluginNames = [];
|
|
67315
|
+
for (const element of pluginListExpression.elements) {
|
|
67316
|
+
if (ts.isSpreadElement(element)) return null;
|
|
67317
|
+
const pluginName = getStaticPluginName(element);
|
|
67318
|
+
if (pluginName === null) return null;
|
|
67319
|
+
pluginNames.push(pluginName);
|
|
67320
|
+
}
|
|
67321
|
+
return pluginNames;
|
|
67322
|
+
};
|
|
67323
|
+
const isModuleExports = (expression) => ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === "module" && expression.name.text === "exports" || ts.isElementAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === "module" && expression.argumentExpression !== void 0 && ts.isStringLiteralLike(expression.argumentExpression) && expression.argumentExpression.text === "exports";
|
|
67324
|
+
const getDirectExportedObject = (sourceFile) => {
|
|
67325
|
+
const exportedExpressions = [];
|
|
67326
|
+
for (const statement of sourceFile.statements) {
|
|
67327
|
+
if (ts.isExportAssignment(statement)) {
|
|
67328
|
+
exportedExpressions.push(statement.expression);
|
|
67329
|
+
continue;
|
|
67330
|
+
}
|
|
67331
|
+
if (ts.isExpressionStatement(statement) && ts.isBinaryExpression(statement.expression) && statement.expression.operatorToken.kind === ts.SyntaxKind.EqualsToken && isModuleExports(statement.expression.left)) exportedExpressions.push(statement.expression.right);
|
|
67332
|
+
}
|
|
67333
|
+
if (exportedExpressions.length !== 1) return null;
|
|
67334
|
+
const exportedExpression = unwrapTypescriptExpression(exportedExpressions[0]);
|
|
67335
|
+
return ts.isObjectLiteralExpression(exportedExpression) ? exportedExpression : null;
|
|
67336
|
+
};
|
|
67337
|
+
const parseConfigPluginNames = (filePath, contents) => {
|
|
67338
|
+
try {
|
|
67339
|
+
const parsedJson = JSON.parse(contents);
|
|
67340
|
+
return isPlainObject(parsedJson) ? readUnknownPluginNames(parsedJson.plugins) : null;
|
|
67341
|
+
} catch {
|
|
67342
|
+
if (ts.transpileModule(contents, {
|
|
67343
|
+
fileName: filePath,
|
|
67344
|
+
reportDiagnostics: true,
|
|
67345
|
+
compilerOptions: { allowJs: true }
|
|
67346
|
+
}).diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) return null;
|
|
67347
|
+
const exportedObject = getDirectExportedObject(ts.createSourceFile(filePath, contents, ts.ScriptTarget.Latest, true, getTypescriptScriptKind(filePath)));
|
|
67348
|
+
return exportedObject === null ? null : getPluginNamesFromObject(exportedObject);
|
|
67349
|
+
}
|
|
67350
|
+
};
|
|
67351
|
+
const readStaticBabelPluginNames = (rootDirectory) => {
|
|
67352
|
+
for (const fileName of BABEL_CONFIG_FILE_NAMES$1) {
|
|
67353
|
+
const absoluteFilePath = Path.join(rootDirectory, fileName);
|
|
67354
|
+
if (!isFile(absoluteFilePath)) continue;
|
|
67355
|
+
try {
|
|
67356
|
+
return {
|
|
67357
|
+
filePath: fileName,
|
|
67358
|
+
pluginNames: parseConfigPluginNames(fileName, NFS.readFileSync(absoluteFilePath, "utf-8"))
|
|
67359
|
+
};
|
|
67360
|
+
} catch {
|
|
67361
|
+
return {
|
|
67362
|
+
filePath: fileName,
|
|
67363
|
+
pluginNames: null
|
|
67364
|
+
};
|
|
67365
|
+
}
|
|
67366
|
+
}
|
|
67367
|
+
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
67368
|
+
if (!isPlainObject(packageJson.babel)) return null;
|
|
67369
|
+
return {
|
|
67370
|
+
filePath: "package.json",
|
|
67371
|
+
pluginNames: readUnknownPluginNames(packageJson.babel.plugins)
|
|
67372
|
+
};
|
|
67373
|
+
};
|
|
67374
|
+
const REACT_COMPILER_PLUGIN_NAMES = new Set(["babel-plugin-react-compiler", "react-compiler"]);
|
|
67375
|
+
const REANIMATED_PLUGIN_NAME = "react-native-reanimated/plugin";
|
|
67376
|
+
const WORKLETS_PLUGIN_NAME = "react-native-worklets/plugin";
|
|
67377
|
+
const checkReactCompilerPluginOrder = (filePath, pluginNames) => {
|
|
67378
|
+
if (pluginNames.findIndex((pluginName) => REACT_COMPILER_PLUGIN_NAMES.has(pluginName)) <= 0) return [];
|
|
67379
|
+
return [buildReactNativeDiagnostic({
|
|
67380
|
+
filePath,
|
|
67381
|
+
rule: "rn-react-compiler-plugin-first",
|
|
67382
|
+
category: "Performance",
|
|
67383
|
+
message: "The React Compiler Babel plugin is not first, so an earlier transform can change component or hook code before the compiler analyzes it.",
|
|
67384
|
+
help: "Move `babel-plugin-react-compiler` to the first entry in the Babel `plugins` array."
|
|
67385
|
+
})];
|
|
67386
|
+
};
|
|
67387
|
+
const checkReanimatedPluginOrder = (project, filePath, pluginNames) => {
|
|
67388
|
+
const reanimatedMajorVersion = project.reanimatedVersion === null || project.reanimatedVersion === void 0 ? null : getLowestDependencyMajor(project.reanimatedVersion);
|
|
67389
|
+
if (reanimatedMajorVersion === null || reanimatedMajorVersion < 4) return [];
|
|
67390
|
+
const diagnostics = [];
|
|
67391
|
+
if (pluginNames.includes(REANIMATED_PLUGIN_NAME)) diagnostics.push(buildReactNativeDiagnostic({
|
|
67392
|
+
filePath,
|
|
67393
|
+
rule: "rn-reanimated-worklets-plugin-last",
|
|
67394
|
+
category: "Performance",
|
|
67395
|
+
message: "This Reanimated 4 project still uses `react-native-reanimated/plugin`, which was renamed to the Worklets Babel plugin.",
|
|
67396
|
+
help: "Replace it with `react-native-worklets/plugin` and keep that plugin last in the Babel `plugins` array."
|
|
67397
|
+
}));
|
|
67398
|
+
const workletsPluginIndex = pluginNames.lastIndexOf(WORKLETS_PLUGIN_NAME);
|
|
67399
|
+
if (workletsPluginIndex !== -1 && workletsPluginIndex !== pluginNames.length - 1) diagnostics.push(buildReactNativeDiagnostic({
|
|
67400
|
+
filePath,
|
|
67401
|
+
rule: "rn-reanimated-worklets-plugin-last",
|
|
67402
|
+
category: "Performance",
|
|
67403
|
+
message: "`react-native-worklets/plugin` is not last in the Babel `plugins` array, so later transforms can prevent worklets from being compiled correctly.",
|
|
67404
|
+
help: "Move `react-native-worklets/plugin` to the final entry in the Babel `plugins` array."
|
|
67405
|
+
}));
|
|
67406
|
+
return diagnostics;
|
|
67407
|
+
};
|
|
67408
|
+
const checkReactNativeBabelPluginOrder = (rootDirectory, project) => {
|
|
67409
|
+
const babelPlugins = readStaticBabelPluginNames(rootDirectory);
|
|
67410
|
+
if (babelPlugins === null || babelPlugins.pluginNames === null) return [];
|
|
67411
|
+
return [...checkReactCompilerPluginOrder(babelPlugins.filePath, babelPlugins.pluginNames), ...checkReanimatedPluginOrder(project, babelPlugins.filePath, babelPlugins.pluginNames)];
|
|
67412
|
+
};
|
|
66958
67413
|
const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
|
|
66959
67414
|
const isBuilderBobLibrary = (packageJson) => {
|
|
66960
67415
|
const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
|
|
@@ -67031,7 +67486,12 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
67031
67486
|
const isReactNativeProject = (project) => project.framework === "react-native" || project.framework === "expo" || project.hasReactNativeWorkspace || project.expoVersion !== null;
|
|
67032
67487
|
const checkReactNativeProject = (rootDirectory, project) => {
|
|
67033
67488
|
if (!isReactNativeProject(project)) return [];
|
|
67034
|
-
return [
|
|
67489
|
+
return [
|
|
67490
|
+
...checkReactNativeMetroBabelPreset(rootDirectory),
|
|
67491
|
+
...checkReactNativeBabelPluginOrder(rootDirectory, project),
|
|
67492
|
+
...checkReactNativeAndroidReleaseShrinking(rootDirectory),
|
|
67493
|
+
...checkReactNativeLibraryDependencies(rootDirectory)
|
|
67494
|
+
];
|
|
67035
67495
|
};
|
|
67036
67496
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
67037
67497
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
@@ -67182,17 +67642,6 @@ const checkReactServerComponentsAdvisory = (scanDirectory, project) => {
|
|
|
67182
67642
|
}
|
|
67183
67643
|
return diagnostics;
|
|
67184
67644
|
};
|
|
67185
|
-
const getTypescriptScriptKind = (fileName) => {
|
|
67186
|
-
if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
67187
|
-
if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
67188
|
-
if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
|
|
67189
|
-
return ts.ScriptKind.JS;
|
|
67190
|
-
};
|
|
67191
|
-
const unwrapTypescriptExpression = (expression) => {
|
|
67192
|
-
let currentExpression = expression;
|
|
67193
|
-
while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
|
|
67194
|
-
return currentExpression;
|
|
67195
|
-
};
|
|
67196
67645
|
const EMPTY_MOTION_EXPRESSION_EVIDENCE = {
|
|
67197
67646
|
isAnimationFunction: false,
|
|
67198
67647
|
isMotionComponent: false,
|
|
@@ -67748,7 +68197,11 @@ const buildCapabilities = (project) => {
|
|
|
67748
68197
|
capabilities.add(project.framework);
|
|
67749
68198
|
if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
|
|
67750
68199
|
if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
|
|
67751
|
-
if (project.expoVersion !== null)
|
|
68200
|
+
if (project.expoVersion !== null) {
|
|
68201
|
+
capabilities.add("expo");
|
|
68202
|
+
const expoSdkMajorVersion = getLowestDependencyMajor(project.expoVersion);
|
|
68203
|
+
if (expoSdkMajorVersion !== null && expoSdkMajorVersion >= 54) capabilities.add("expo:54");
|
|
68204
|
+
}
|
|
67752
68205
|
if ((project.framework === "nextjs" || project.framework === "tanstack-start" || project.framework === "remix") && !project.isStaticExport) capabilities.add("server-actions");
|
|
67753
68206
|
if (SSR_FRAMEWORKS.has(project.framework) || project.hasSsrDependency) capabilities.add("ssr");
|
|
67754
68207
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
@@ -67812,6 +68265,11 @@ const buildCapabilities = (project) => {
|
|
|
67812
68265
|
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
67813
68266
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
67814
68267
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
68268
|
+
if (project.reanimatedVersion !== void 0 && project.reanimatedVersion !== null) {
|
|
68269
|
+
capabilities.add("reanimated");
|
|
68270
|
+
const reanimatedMajorVersion = getLowestDependencyMajor(project.reanimatedVersion);
|
|
68271
|
+
if (reanimatedMajorVersion !== null && reanimatedMajorVersion >= 4) capabilities.add("reanimated:4");
|
|
68272
|
+
}
|
|
67815
68273
|
if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
|
|
67816
68274
|
if (project.styledComponentsVersion) {
|
|
67817
68275
|
capabilities.add("styled-components");
|
|
@@ -69709,7 +70167,11 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
69709
70167
|
const ROOT_DIRECTORY_PLACEHOLDER = "<root>";
|
|
69710
70168
|
const normalizeConfigForHash = (config) => {
|
|
69711
70169
|
const clone = JSON.parse(JSON.stringify(config));
|
|
69712
|
-
if (clone?.settings?.["react-doctor"])
|
|
70170
|
+
if (clone?.settings?.["react-doctor"]) {
|
|
70171
|
+
const reactDoctorSettings = clone.settings["react-doctor"];
|
|
70172
|
+
reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
|
|
70173
|
+
if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
|
|
70174
|
+
}
|
|
69713
70175
|
if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
|
|
69714
70176
|
return clone;
|
|
69715
70177
|
};
|
|
@@ -69868,13 +70330,14 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
69868
70330
|
}
|
|
69869
70331
|
return enabled;
|
|
69870
70332
|
};
|
|
69871
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
70333
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, runtimeGlobals, unpluginAutoImportGlobalScopes, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
69872
70334
|
const hasIncludedTags = includedTags.size > 0;
|
|
69873
70335
|
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
69874
70336
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
69875
70337
|
const jsPlugins = [];
|
|
69876
70338
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
69877
70339
|
const capabilities = getCapabilities(project);
|
|
70340
|
+
const settingsRootDirectory = resolveSettingsRootDirectory(project.rootDirectory);
|
|
69878
70341
|
const enabledReactDoctorRules = {};
|
|
69879
70342
|
for (const registryEntry of REACT_DOCTOR_RULES) {
|
|
69880
70343
|
const rule = reactDoctorPlugin.rules[registryEntry.id];
|
|
@@ -69920,8 +70383,16 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
69920
70383
|
jsPlugins: [...jsPlugins, pluginPath],
|
|
69921
70384
|
settings: { "react-doctor": {
|
|
69922
70385
|
framework: project.framework,
|
|
69923
|
-
rootDirectory:
|
|
70386
|
+
rootDirectory: settingsRootDirectory,
|
|
69924
70387
|
capabilities: [...capabilities].sort(),
|
|
70388
|
+
...runtimeGlobals && runtimeGlobals.length > 0 ? { runtimeGlobals: [...runtimeGlobals] } : {},
|
|
70389
|
+
...unpluginAutoImportGlobalScopes && unpluginAutoImportGlobalScopes.length > 0 ? {
|
|
70390
|
+
unpluginAutoImportRootDirectories: [...new Set([settingsRootDirectory, project.rootDirectory])],
|
|
70391
|
+
unpluginAutoImportGlobalScopes: unpluginAutoImportGlobalScopes.map((scope) => ({
|
|
70392
|
+
directory: scope.directory,
|
|
70393
|
+
names: [...scope.names]
|
|
70394
|
+
}))
|
|
70395
|
+
} : {},
|
|
69925
70396
|
...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
|
|
69926
70397
|
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
69927
70398
|
} },
|
|
@@ -69932,6 +70403,245 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
69932
70403
|
}
|
|
69933
70404
|
};
|
|
69934
70405
|
};
|
|
70406
|
+
const AUTO_IMPORT_ADAPTER_PATTERN = /^unplugin-auto-import\/(?:astro|esbuild|rollup|rolldown|rspack|vite|webpack)$/;
|
|
70407
|
+
const CONFIG_BASENAMES = [
|
|
70408
|
+
"astro.config",
|
|
70409
|
+
"esbuild.config",
|
|
70410
|
+
"rollup.config",
|
|
70411
|
+
"rolldown.config",
|
|
70412
|
+
"rspack.config",
|
|
70413
|
+
"vite.config",
|
|
70414
|
+
"webpack.config"
|
|
70415
|
+
];
|
|
70416
|
+
const CONFIG_EXTENSIONS = [
|
|
70417
|
+
".cjs",
|
|
70418
|
+
".cts",
|
|
70419
|
+
".js",
|
|
70420
|
+
".mjs",
|
|
70421
|
+
".mts",
|
|
70422
|
+
".ts"
|
|
70423
|
+
];
|
|
70424
|
+
const CONFIG_FILENAMES = new Set(CONFIG_BASENAMES.flatMap((basename) => CONFIG_EXTENSIONS.map((extension) => `${basename}${extension}`)));
|
|
70425
|
+
const DEFAULT_ESLINT_GLOBALS_PATH = ".eslintrc-auto-import.json";
|
|
70426
|
+
const SUPPORTED_GLOBAL_VALUES = new Set([
|
|
70427
|
+
true,
|
|
70428
|
+
false,
|
|
70429
|
+
"readable",
|
|
70430
|
+
"readonly",
|
|
70431
|
+
"writable",
|
|
70432
|
+
"writeable"
|
|
70433
|
+
]);
|
|
70434
|
+
const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
|
|
70435
|
+
if (ts.isSpreadAssignment(property)) return false;
|
|
70436
|
+
const name = ts.isComputedPropertyName(property.name) ? unwrapTypescriptExpression(property.name.expression) : property.name;
|
|
70437
|
+
return (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) && name.text === propertyName;
|
|
70438
|
+
}) ?? null;
|
|
70439
|
+
const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !ts.isSpreadAssignment(property) && ts.isComputedPropertyName(property.name) && !ts.isStringLiteralLike(unwrapTypescriptExpression(property.name.expression)));
|
|
70440
|
+
const getStaticPropertyAssignment = (objectExpression, propertyName) => {
|
|
70441
|
+
const property = getStaticProperty(objectExpression, propertyName);
|
|
70442
|
+
return property && ts.isPropertyAssignment(property) ? property : null;
|
|
70443
|
+
};
|
|
70444
|
+
const getRequireModuleSpecifier = (expression) => {
|
|
70445
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
70446
|
+
if (ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "default") return getRequireModuleSpecifier(unwrappedExpression.expression);
|
|
70447
|
+
if (!ts.isCallExpression(unwrappedExpression) || !ts.isIdentifier(unwrappedExpression.expression) || unwrappedExpression.expression.text !== "require" || unwrappedExpression.arguments.length !== 1) return null;
|
|
70448
|
+
const moduleSpecifier = unwrappedExpression.arguments[0];
|
|
70449
|
+
return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
70450
|
+
};
|
|
70451
|
+
const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
|
|
70452
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
70453
|
+
return ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
|
|
70454
|
+
};
|
|
70455
|
+
const isCommonJsExportAssignment = (node, sourceFile) => ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
|
|
70456
|
+
const isTopLevelExpression = (node) => {
|
|
70457
|
+
let ancestor = node.parent;
|
|
70458
|
+
while (ancestor && !ts.isSourceFile(ancestor)) {
|
|
70459
|
+
if (ts.isExpressionStatement(ancestor)) return ts.isSourceFile(ancestor.parent);
|
|
70460
|
+
if (!ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isAwaitExpression(ancestor)) return false;
|
|
70461
|
+
ancestor = ancestor.parent;
|
|
70462
|
+
}
|
|
70463
|
+
return false;
|
|
70464
|
+
};
|
|
70465
|
+
const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
|
|
70466
|
+
let ancestor = node.parent;
|
|
70467
|
+
let didFindConfigProperty = false;
|
|
70468
|
+
while (ancestor && !ts.isSourceFile(ancestor)) {
|
|
70469
|
+
if (!didFindConfigProperty && !ts.isArrayLiteralExpression(ancestor) && !ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isPropertyAssignment(ancestor)) return false;
|
|
70470
|
+
if (ts.isPropertyAssignment(ancestor)) {
|
|
70471
|
+
const isConfigProperty = (ts.isIdentifier(ancestor.name) || ts.isStringLiteralLike(ancestor.name)) && ancestor.name.text === propertyName;
|
|
70472
|
+
if (didFindConfigProperty || !isConfigProperty) return false;
|
|
70473
|
+
if (!ts.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(ts.isSpreadAssignment)) return false;
|
|
70474
|
+
didFindConfigProperty = true;
|
|
70475
|
+
ancestor = ancestor.parent;
|
|
70476
|
+
continue;
|
|
70477
|
+
}
|
|
70478
|
+
if (didFindConfigProperty) {
|
|
70479
|
+
if (ts.isExportAssignment(ancestor)) return true;
|
|
70480
|
+
if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
|
|
70481
|
+
if (propertyName === "plugins" && ts.isCallExpression(ancestor) && (ts.isIdentifier(ancestor.expression) ? esbuildBindings.has(ancestor.expression.text) : ts.isPropertyAccessExpression(ancestor.expression) && ancestor.expression.name.text === "build" && (ts.isIdentifier(ancestor.expression.expression) && esbuildNamespaceBindings.has(ancestor.expression.expression.text) || getRequireModuleSpecifier(ancestor.expression.expression) === "esbuild"))) return isTopLevelExpression(ancestor);
|
|
70482
|
+
if (!(ts.isObjectLiteralExpression(ancestor) || ts.isParenthesizedExpression(ancestor) || ts.isAsExpression(ancestor) || ts.isSatisfiesExpression(ancestor) || ts.isNonNullExpression(ancestor) || ts.isTypeAssertionExpression(ancestor) || ts.isCallExpression(ancestor) && ts.isIdentifier(ancestor.expression) && ancestor.expression.text === "defineConfig")) return false;
|
|
70483
|
+
}
|
|
70484
|
+
ancestor = ancestor.parent;
|
|
70485
|
+
}
|
|
70486
|
+
return false;
|
|
70487
|
+
};
|
|
70488
|
+
const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory) => {
|
|
70489
|
+
const optionsExpression = callExpression.arguments[0];
|
|
70490
|
+
if (!optionsExpression) return null;
|
|
70491
|
+
const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
|
|
70492
|
+
if (!ts.isObjectLiteralExpression(unwrappedOptions)) return null;
|
|
70493
|
+
if (unwrappedOptions.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
|
|
70494
|
+
if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
|
|
70495
|
+
const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
|
|
70496
|
+
if (!eslintrcProperty) return null;
|
|
70497
|
+
const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
|
|
70498
|
+
if (!ts.isObjectLiteralExpression(eslintrcExpression)) return null;
|
|
70499
|
+
if (eslintrcExpression.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
|
|
70500
|
+
const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
|
|
70501
|
+
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== ts.SyntaxKind.TrueKeyword) return null;
|
|
70502
|
+
const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
|
|
70503
|
+
if (!filepathProperty) return Path.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
|
|
70504
|
+
if (!ts.isPropertyAssignment(filepathProperty)) return null;
|
|
70505
|
+
const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
|
|
70506
|
+
return ts.isStringLiteralLike(filepathExpression) ? Path.resolve(packageDirectory, filepathExpression.text) : null;
|
|
70507
|
+
};
|
|
70508
|
+
const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
70509
|
+
let sourceText;
|
|
70510
|
+
try {
|
|
70511
|
+
sourceText = NFS.readFileSync(configPath, "utf8");
|
|
70512
|
+
} catch {
|
|
70513
|
+
return {
|
|
70514
|
+
didFindActiveAutoImport: false,
|
|
70515
|
+
globalsPaths: []
|
|
70516
|
+
};
|
|
70517
|
+
}
|
|
70518
|
+
const sourceFile = ts.createSourceFile(configPath, sourceText, ts.ScriptTarget.Latest, true);
|
|
70519
|
+
const autoImportBindings = /* @__PURE__ */ new Map();
|
|
70520
|
+
const esbuildBindings = /* @__PURE__ */ new Set();
|
|
70521
|
+
const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
|
|
70522
|
+
for (const statement of sourceFile.statements) {
|
|
70523
|
+
if (ts.isImportDeclaration(statement) && ts.isStringLiteralLike(statement.moduleSpecifier)) {
|
|
70524
|
+
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
70525
|
+
if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
70526
|
+
const defaultBinding = statement.importClause?.name;
|
|
70527
|
+
if (defaultBinding) autoImportBindings.set(defaultBinding.text, moduleSpecifier);
|
|
70528
|
+
}
|
|
70529
|
+
if (moduleSpecifier === "esbuild") {
|
|
70530
|
+
const defaultBinding = statement.importClause?.name;
|
|
70531
|
+
if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
|
|
70532
|
+
const namedBindings = statement.importClause?.namedBindings;
|
|
70533
|
+
if (namedBindings && ts.isNamedImports(namedBindings)) {
|
|
70534
|
+
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
|
|
70535
|
+
}
|
|
70536
|
+
if (namedBindings && ts.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
|
|
70537
|
+
}
|
|
70538
|
+
}
|
|
70539
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
70540
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
70541
|
+
if (!declaration.initializer) continue;
|
|
70542
|
+
const declarationName = ts.isIdentifier(declaration.name) ? declaration.name.text : null;
|
|
70543
|
+
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
70544
|
+
if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
|
|
70545
|
+
if (moduleSpecifier === "esbuild") {
|
|
70546
|
+
if (declarationName) esbuildNamespaceBindings.add(declarationName);
|
|
70547
|
+
if (ts.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
|
|
70548
|
+
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
70549
|
+
if (ts.isIdentifier(importedName) && importedName.text === "build" && ts.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
|
|
70550
|
+
}
|
|
70551
|
+
}
|
|
70552
|
+
if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
|
|
70553
|
+
}
|
|
70554
|
+
}
|
|
70555
|
+
const globalsPaths = /* @__PURE__ */ new Set();
|
|
70556
|
+
let didFindActiveAutoImport = false;
|
|
70557
|
+
let didFindUnsafeActiveAutoImport = false;
|
|
70558
|
+
const visit = (node) => {
|
|
70559
|
+
if (ts.isCallExpression(node)) {
|
|
70560
|
+
const moduleSpecifier = ts.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
|
|
70561
|
+
if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
70562
|
+
if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
|
|
70563
|
+
didFindActiveAutoImport = true;
|
|
70564
|
+
const globalsPath = getGlobalsPathFromActiveAutoImportCall(node, packageDirectory);
|
|
70565
|
+
if (globalsPath) globalsPaths.add(globalsPath);
|
|
70566
|
+
else didFindUnsafeActiveAutoImport = true;
|
|
70567
|
+
}
|
|
70568
|
+
}
|
|
70569
|
+
}
|
|
70570
|
+
ts.forEachChild(node, visit);
|
|
70571
|
+
};
|
|
70572
|
+
visit(sourceFile);
|
|
70573
|
+
return {
|
|
70574
|
+
didFindActiveAutoImport,
|
|
70575
|
+
globalsPaths: didFindUnsafeActiveAutoImport ? [] : [...globalsPaths]
|
|
70576
|
+
};
|
|
70577
|
+
};
|
|
70578
|
+
const collectGeneratedGlobalNames = (globalsPath, rootDirectory) => {
|
|
70579
|
+
const relativePath = Path.relative(rootDirectory, globalsPath);
|
|
70580
|
+
if (relativePath.startsWith("..") || Path.isAbsolute(relativePath)) return [];
|
|
70581
|
+
const parsed = failOpenReadJson(globalsPath, null);
|
|
70582
|
+
if (!isPlainObject(parsed) || !isPlainObject(parsed.globals)) return [];
|
|
70583
|
+
return Object.entries(parsed.globals).filter((entry) => entry[0].length > 0 && (typeof entry[1] === "boolean" || typeof entry[1] === "string") && SUPPORTED_GLOBAL_VALUES.has(entry[1])).map(([name]) => name).sort();
|
|
70584
|
+
};
|
|
70585
|
+
const findOwningPackageDirectory = (absoluteFilePath, rootDirectory, cache) => {
|
|
70586
|
+
let currentDirectory = Path.dirname(absoluteFilePath);
|
|
70587
|
+
const visitedDirectories = [];
|
|
70588
|
+
while (true) {
|
|
70589
|
+
const cachedDirectory = cache.get(currentDirectory);
|
|
70590
|
+
if (cachedDirectory !== void 0) {
|
|
70591
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, cachedDirectory);
|
|
70592
|
+
return cachedDirectory;
|
|
70593
|
+
}
|
|
70594
|
+
const relativeDirectory = Path.relative(rootDirectory, currentDirectory);
|
|
70595
|
+
if (relativeDirectory.startsWith("..") || Path.isAbsolute(relativeDirectory)) {
|
|
70596
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
|
|
70597
|
+
return null;
|
|
70598
|
+
}
|
|
70599
|
+
visitedDirectories.push(currentDirectory);
|
|
70600
|
+
if (NFS.existsSync(Path.join(currentDirectory, "package.json"))) {
|
|
70601
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, currentDirectory);
|
|
70602
|
+
return currentDirectory;
|
|
70603
|
+
}
|
|
70604
|
+
if (currentDirectory === rootDirectory) {
|
|
70605
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
|
|
70606
|
+
return null;
|
|
70607
|
+
}
|
|
70608
|
+
currentDirectory = Path.dirname(currentDirectory);
|
|
70609
|
+
}
|
|
70610
|
+
};
|
|
70611
|
+
const collectPackageGlobalNames = (packageDirectory, rootDirectory) => {
|
|
70612
|
+
let directoryEntries;
|
|
70613
|
+
try {
|
|
70614
|
+
directoryEntries = NFS.readdirSync(packageDirectory, { withFileTypes: true });
|
|
70615
|
+
} catch {
|
|
70616
|
+
return [];
|
|
70617
|
+
}
|
|
70618
|
+
const configuredGlobalsPaths = [];
|
|
70619
|
+
for (const entry of directoryEntries) {
|
|
70620
|
+
if (!entry.isFile() && !entry.isSymbolicLink() || !CONFIG_FILENAMES.has(entry.name)) continue;
|
|
70621
|
+
const configGlobalsPaths = collectGlobalsPathsFromConfig(Path.join(packageDirectory, entry.name), packageDirectory);
|
|
70622
|
+
if (configGlobalsPaths.didFindActiveAutoImport) configuredGlobalsPaths.push(configGlobalsPaths.globalsPaths.toSorted());
|
|
70623
|
+
}
|
|
70624
|
+
if (configuredGlobalsPaths.length === 0) return [];
|
|
70625
|
+
const globalsPaths = configuredGlobalsPaths[0];
|
|
70626
|
+
if (configuredGlobalsPaths.some((candidatePaths) => candidatePaths.length !== globalsPaths.length || candidatePaths.some((candidatePath, index) => candidatePath !== globalsPaths[index]))) return [];
|
|
70627
|
+
const names = /* @__PURE__ */ new Set();
|
|
70628
|
+
for (const globalsPath of globalsPaths) for (const name of collectGeneratedGlobalNames(globalsPath, rootDirectory)) names.add(name);
|
|
70629
|
+
return [...names].sort();
|
|
70630
|
+
};
|
|
70631
|
+
const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }) => {
|
|
70632
|
+
const absoluteRootDirectory = Path.resolve(rootDirectory);
|
|
70633
|
+
const packageDirectoryCache = /* @__PURE__ */ new Map();
|
|
70634
|
+
const packageDirectories = /* @__PURE__ */ new Set();
|
|
70635
|
+
for (const candidateFile of candidateFiles) {
|
|
70636
|
+
const packageDirectory = findOwningPackageDirectory(Path.resolve(absoluteRootDirectory, candidateFile), absoluteRootDirectory, packageDirectoryCache);
|
|
70637
|
+
if (packageDirectory) packageDirectories.add(packageDirectory);
|
|
70638
|
+
}
|
|
70639
|
+
const scopes = [...packageDirectories].map((packageDirectory) => ({
|
|
70640
|
+
directory: Path.relative(absoluteRootDirectory, packageDirectory).replaceAll("\\", "/"),
|
|
70641
|
+
names: collectPackageGlobalNames(packageDirectory, absoluteRootDirectory)
|
|
70642
|
+
})).sort((firstScope, secondScope) => firstScope.directory.localeCompare(secondScope.directory));
|
|
70643
|
+
return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
|
|
70644
|
+
};
|
|
69935
70645
|
const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
|
|
69936
70646
|
const decodeFileDiagnostics = (raw) => {
|
|
69937
70647
|
if (!Array.isArray(raw)) return null;
|
|
@@ -70254,6 +70964,12 @@ const appendReanimatedSharedValueHint = (help, rule, project) => {
|
|
|
70254
70964
|
if (!help) return REANIMATED_SHARED_VALUE_HINT;
|
|
70255
70965
|
return `${help}\n\n${REANIMATED_SHARED_VALUE_HINT}`;
|
|
70256
70966
|
};
|
|
70967
|
+
const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
|
|
70968
|
+
const boundedOffset = Math.min(Math.max(utf8Offset, 0), sourceBuffer.length);
|
|
70969
|
+
let lineStartOffset = boundedOffset;
|
|
70970
|
+
while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
|
|
70971
|
+
return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
|
|
70972
|
+
};
|
|
70257
70973
|
const REDACTED_PLACEHOLDER = "<redacted>";
|
|
70258
70974
|
const KEEP_PREFIX = `$1${REDACTED_PLACEHOLDER}`;
|
|
70259
70975
|
const KNOWN_SECRET_RULES = [
|
|
@@ -70969,7 +71685,7 @@ const resolveMatchByOccurrence = (rule, category) => OCCURRENCE_MATCHED_CATEGORI
|
|
|
70969
71685
|
* with empty text still carry a useful jump target, so they're kept
|
|
70970
71686
|
* with a neutral message.
|
|
70971
71687
|
*/
|
|
70972
|
-
const buildRelatedLocations = (labels, filePath) => {
|
|
71688
|
+
const buildRelatedLocations = (labels, filePath, sourceBuffer) => {
|
|
70973
71689
|
if (labels.length <= 1) return [];
|
|
70974
71690
|
const related = [];
|
|
70975
71691
|
for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
|
|
@@ -70977,8 +71693,8 @@ const buildRelatedLocations = (labels, filePath) => {
|
|
|
70977
71693
|
if (!label?.span) continue;
|
|
70978
71694
|
related.push({
|
|
70979
71695
|
filePath,
|
|
70980
|
-
line: label.span.line ?? 0,
|
|
70981
|
-
column: label.span.column ?? 0,
|
|
71696
|
+
line: sourceBuffer === null ? label.span.line ?? 0 : lineOfUtf8Offset(sourceBuffer, label.span.offset),
|
|
71697
|
+
column: sourceBuffer === null ? label.span.column ?? 0 : columnOfUtf8Offset(sourceBuffer, label.span.offset),
|
|
70982
71698
|
offset: label.span.offset,
|
|
70983
71699
|
length: label.span.length,
|
|
70984
71700
|
message: label.label ?? ""
|
|
@@ -70998,7 +71714,7 @@ const isOxlintOutput = (value) => isRecord(value) && Array.isArray(value.diagnos
|
|
|
70998
71714
|
* to the first `{`. Raises `OxlintOutputUnparseable` when the
|
|
70999
71715
|
* stdout isn't valid JSON or doesn't carry a `diagnostics` array.
|
|
71000
71716
|
*/
|
|
71001
|
-
const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
71717
|
+
const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath) => {
|
|
71002
71718
|
if (!stdout) return [];
|
|
71003
71719
|
const jsonStart = stdout.indexOf("{");
|
|
71004
71720
|
const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
|
|
@@ -71015,8 +71731,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
71015
71731
|
const sourceBufferCache = /* @__PURE__ */ new Map();
|
|
71016
71732
|
const sourceLinesCache = /* @__PURE__ */ new Map();
|
|
71017
71733
|
const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
|
|
71734
|
+
const resolveMappedSourceFilename = (filename) => sourcePathByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
|
|
71735
|
+
const resolveSourceFilename = (filename) => resolveMappedSourceFilename(filename) ?? filename;
|
|
71018
71736
|
const readSourceBuffer = (filename) => {
|
|
71019
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
71737
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
71020
71738
|
const cached = sourceBufferCache.get(absolutePath);
|
|
71021
71739
|
if (cached !== void 0) return cached;
|
|
71022
71740
|
let sourceBuffer;
|
|
@@ -71029,7 +71747,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
71029
71747
|
return sourceBuffer;
|
|
71030
71748
|
};
|
|
71031
71749
|
const readSourceLines = (filename) => {
|
|
71032
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
71750
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
71033
71751
|
const cached = sourceLinesCache.get(absolutePath);
|
|
71034
71752
|
if (cached !== void 0) return cached;
|
|
71035
71753
|
const sourceBuffer = readSourceBuffer(filename);
|
|
@@ -71038,27 +71756,30 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
71038
71756
|
return sourceLines;
|
|
71039
71757
|
};
|
|
71040
71758
|
const isMinifiedDiagnosticFile = (filename) => {
|
|
71041
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
71759
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
71042
71760
|
const cached = minifiedFileCache.get(absolutePath);
|
|
71043
71761
|
if (cached !== void 0) return cached;
|
|
71044
71762
|
const minified = isMinifiedSource(absolutePath);
|
|
71045
71763
|
minifiedFileCache.set(absolutePath, minified);
|
|
71046
71764
|
return minified;
|
|
71047
71765
|
};
|
|
71048
|
-
return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.filter((diagnostic) => isMappableOxlintDiagnostic(diagnostic) && isLintableSourceFile(diagnostic.filename) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
|
|
71766
|
+
return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.filter((diagnostic) => isMappableOxlintDiagnostic(diagnostic) && isLintableSourceFile(resolveSourceFilename(diagnostic.filename)) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
|
|
71049
71767
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
71050
71768
|
const primaryLabel = diagnostic.labels[0];
|
|
71051
71769
|
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
71052
|
-
const
|
|
71770
|
+
const mappedSourceFilename = resolveMappedSourceFilename(diagnostic.filename);
|
|
71771
|
+
const normalizedFilePath = (mappedSourceFilename ?? diagnostic.filename).replaceAll("\\", "/");
|
|
71053
71772
|
const primarySpan = primaryLabel?.span;
|
|
71054
71773
|
const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
|
|
71055
|
-
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
|
|
71774
|
+
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath, mappedSourceFilename === void 0 ? null : sourceBuffer);
|
|
71056
71775
|
const category = resolveDiagnosticCategory(plugin, rule);
|
|
71057
71776
|
const matchByOccurrence = resolveMatchByOccurrence(rule, category);
|
|
71058
71777
|
const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
|
|
71059
|
-
const
|
|
71778
|
+
const primaryLineNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.line ?? 0;
|
|
71779
|
+
const primaryColumnNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? columnOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.column ?? 0;
|
|
71780
|
+
const primaryLineIndex = primarySpan ? primaryLineNumber - 1 : -1;
|
|
71060
71781
|
const primaryLine = sourceLines?.[primaryLineIndex];
|
|
71061
|
-
const primaryColumnIndex = primarySpan ?
|
|
71782
|
+
const primaryColumnIndex = primarySpan ? primaryColumnNumber - 1 : -1;
|
|
71062
71783
|
const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
|
|
71063
71784
|
const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
|
|
71064
71785
|
const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
|
|
@@ -71071,8 +71792,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
71071
71792
|
message: cleaned.message,
|
|
71072
71793
|
help: cleaned.help,
|
|
71073
71794
|
url: diagnostic.url,
|
|
71074
|
-
line:
|
|
71075
|
-
column:
|
|
71795
|
+
line: primaryLineNumber,
|
|
71796
|
+
column: primaryColumnNumber,
|
|
71076
71797
|
...primarySpan ? {
|
|
71077
71798
|
offset: primarySpan.offset,
|
|
71078
71799
|
length: primarySpan.length,
|
|
@@ -71260,7 +71981,11 @@ const isParallelismRelatedSpawnError = (error) => {
|
|
|
71260
71981
|
* loop with a slimmer config in that case.
|
|
71261
71982
|
*/
|
|
71262
71983
|
const spawnLintBatches = async (input) => {
|
|
71263
|
-
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
|
|
71984
|
+
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, sourcePathByLintPath, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
|
|
71985
|
+
const resolveSourcePath = (filePath) => {
|
|
71986
|
+
const absoluteFilePath = Path.isAbsolute(filePath) ? filePath : Path.resolve(rootDirectory, filePath);
|
|
71987
|
+
return sourcePathByLintPath?.get(Path.normalize(absoluteFilePath)) ?? filePath;
|
|
71988
|
+
};
|
|
71264
71989
|
const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
|
|
71265
71990
|
let rescueDeadlineEpochMs;
|
|
71266
71991
|
const isPastDeadline = () => deadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(deadlineEpochMs) === 0 || rescueDeadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(rescueDeadlineEpochMs) === 0;
|
|
@@ -71280,7 +72005,7 @@ const spawnLintBatches = async (input) => {
|
|
|
71280
72005
|
}
|
|
71281
72006
|
const batchArgs = [...baseArgs, ...batch];
|
|
71282
72007
|
try {
|
|
71283
|
-
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory);
|
|
72008
|
+
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory, sourcePathByLintPath);
|
|
71284
72009
|
} catch (error) {
|
|
71285
72010
|
if (!isSplittableReactDoctorError(error)) throw error;
|
|
71286
72011
|
if (isPastDeadline()) {
|
|
@@ -71386,10 +72111,12 @@ const spawnLintBatches = async (input) => {
|
|
|
71386
72111
|
onPartialFailure(buildMessage(`${skippedFiles.slice(0, 3).join(", ")}${skippedFiles.length > 3 ? `, +${skippedFiles.length - 3} more` : ""}`));
|
|
71387
72112
|
};
|
|
71388
72113
|
const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
|
|
71389
|
-
|
|
71390
|
-
|
|
72114
|
+
const droppedSourceFiles = [...new Set(droppedFiles.map(resolveSourcePath))];
|
|
72115
|
+
const deadlineSkippedSourceFiles = [...new Set(outcome.deadlineSkippedFiles.map(resolveSourcePath))];
|
|
72116
|
+
reportSkippedFiles(droppedSourceFiles, (fileListPreview) => `${droppedSourceFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
|
|
72117
|
+
reportSkippedFiles(deadlineSkippedSourceFiles, (fileListPreview) => `${deadlineSkippedSourceFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
|
|
71391
72118
|
const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
|
|
71392
|
-
input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)))].sort());
|
|
72119
|
+
input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)).map(resolveSourcePath))].sort());
|
|
71393
72120
|
return dedupeDiagnostics(diagnostics);
|
|
71394
72121
|
};
|
|
71395
72122
|
let didValidate = false;
|
|
@@ -71488,6 +72215,266 @@ const planLintBatches = ({ baseArgs, files, sizeByFile }) => {
|
|
|
71488
72215
|
}
|
|
71489
72216
|
return batches.filter((batch) => batch.fileIndexes.length > 0).map((batch) => batch.fileIndexes.sort((leftIndex, rightIndex) => leftIndex - rightIndex).map((fileIndex) => files[fileIndex]));
|
|
71490
72217
|
};
|
|
72218
|
+
const THREE_MODULE_IMPORT_PATTERN = /\b(?:from\s*|import\s*(?:\(\s*)?|require\s*\(\s*)["']three(?:\/[^"']*)?["']/;
|
|
72219
|
+
const containsThreeModuleImport = (sourceText) => THREE_MODULE_IMPORT_PATTERN.test(sourceText);
|
|
72220
|
+
const COMMENT_OPEN = "<!--";
|
|
72221
|
+
const COMMENT_CLOSE = "-->";
|
|
72222
|
+
const FRONTMATTER_FENCE = "---";
|
|
72223
|
+
const SCRIPT_TAG_NAME = "script";
|
|
72224
|
+
const SCRIPT_OPEN = `<${SCRIPT_TAG_NAME}`;
|
|
72225
|
+
const SCRIPT_CLOSE = `</${SCRIPT_TAG_NAME}`;
|
|
72226
|
+
const TEMPLATE_TAG_NAME = "template";
|
|
72227
|
+
const TEMPLATE_CLOSE = `</${TEMPLATE_TAG_NAME}`;
|
|
72228
|
+
const JAVASCRIPT_MIME_TYPES = new Set([
|
|
72229
|
+
"application/ecmascript",
|
|
72230
|
+
"application/javascript",
|
|
72231
|
+
"application/x-ecmascript",
|
|
72232
|
+
"application/x-javascript",
|
|
72233
|
+
"text/ecmascript",
|
|
72234
|
+
"text/javascript",
|
|
72235
|
+
"text/javascript1.0",
|
|
72236
|
+
"text/javascript1.1",
|
|
72237
|
+
"text/javascript1.2",
|
|
72238
|
+
"text/javascript1.3",
|
|
72239
|
+
"text/javascript1.4",
|
|
72240
|
+
"text/javascript1.5",
|
|
72241
|
+
"text/jscript",
|
|
72242
|
+
"text/livescript",
|
|
72243
|
+
"text/x-ecmascript",
|
|
72244
|
+
"text/x-javascript"
|
|
72245
|
+
]);
|
|
72246
|
+
const RAW_TEXT_TAG_NAMES = new Set([
|
|
72247
|
+
"iframe",
|
|
72248
|
+
"noembed",
|
|
72249
|
+
"noframes",
|
|
72250
|
+
"noscript",
|
|
72251
|
+
"style",
|
|
72252
|
+
"textarea",
|
|
72253
|
+
"title",
|
|
72254
|
+
"xmp"
|
|
72255
|
+
]);
|
|
72256
|
+
const PLAINTEXT_TAG_NAME = "plaintext";
|
|
72257
|
+
const TAG_OPEN_UTF8_BYTE = "<".charCodeAt(0);
|
|
72258
|
+
const TAG_CLOSE_UTF8_BYTE = ">".charCodeAt(0);
|
|
72259
|
+
const SINGLE_QUOTE_UTF8_BYTE = "'".charCodeAt(0);
|
|
72260
|
+
const DOUBLE_QUOTE_UTF8_BYTE = "\"".charCodeAt(0);
|
|
72261
|
+
const ATTRIBUTE_ASSIGNMENT_UTF8_BYTE = "=".charCodeAt(0);
|
|
72262
|
+
const TAG_SELF_CLOSE_UTF8_BYTE = "/".charCodeAt(0);
|
|
72263
|
+
const TAB_UTF8_BYTE = " ".charCodeAt(0);
|
|
72264
|
+
const FORM_FEED_UTF8_BYTE = "\f".charCodeAt(0);
|
|
72265
|
+
const isHtmlWhitespace = (byte) => byte === TAB_UTF8_BYTE || byte === 10 || byte === FORM_FEED_UTF8_BYTE || byte === 13 || byte === 32;
|
|
72266
|
+
const matchesAsciiCaseInsensitive = (sourceBuffer, startByte, expected) => {
|
|
72267
|
+
if (startByte + expected.length > sourceBuffer.length) return false;
|
|
72268
|
+
for (let expectedIndex = 0; expectedIndex < expected.length; expectedIndex++) {
|
|
72269
|
+
const sourceByte = sourceBuffer[startByte + expectedIndex];
|
|
72270
|
+
if (sourceByte === void 0 || String.fromCharCode(sourceByte).toLowerCase() !== expected[expectedIndex]) return false;
|
|
72271
|
+
}
|
|
72272
|
+
return true;
|
|
72273
|
+
};
|
|
72274
|
+
const isTagBoundary = (byte) => byte === TAG_CLOSE_UTF8_BYTE || byte === TAG_SELF_CLOSE_UTF8_BYTE || isHtmlWhitespace(byte);
|
|
72275
|
+
const isPotentialTagStart = (byte) => {
|
|
72276
|
+
if (byte === void 0) return false;
|
|
72277
|
+
return /[A-Za-z!/?]/.test(String.fromCharCode(byte));
|
|
72278
|
+
};
|
|
72279
|
+
const findLineEnd = (sourceBuffer, lineStartByte) => {
|
|
72280
|
+
let byteIndex = lineStartByte;
|
|
72281
|
+
while (byteIndex < sourceBuffer.length && sourceBuffer[byteIndex] !== 10 && sourceBuffer[byteIndex] !== 13) byteIndex++;
|
|
72282
|
+
return byteIndex;
|
|
72283
|
+
};
|
|
72284
|
+
const findNextLineStart = (sourceBuffer, lineStartByte) => {
|
|
72285
|
+
const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
|
|
72286
|
+
if (sourceBuffer[lineEndByte] === 13 && sourceBuffer[lineEndByte + 1] === 10) return lineEndByte + 2;
|
|
72287
|
+
return Math.min(lineEndByte + 1, sourceBuffer.length);
|
|
72288
|
+
};
|
|
72289
|
+
const isFrontmatterFenceLine = (sourceBuffer, lineStartByte) => {
|
|
72290
|
+
if (!matchesAsciiCaseInsensitive(sourceBuffer, lineStartByte, FRONTMATTER_FENCE)) return false;
|
|
72291
|
+
const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
|
|
72292
|
+
for (let byteIndex = lineStartByte + 3; byteIndex < lineEndByte; byteIndex++) if (!isHtmlWhitespace(sourceBuffer[byteIndex])) return false;
|
|
72293
|
+
return true;
|
|
72294
|
+
};
|
|
72295
|
+
const findFrontmatterEnd = (sourceBuffer) => {
|
|
72296
|
+
if (!isFrontmatterFenceLine(sourceBuffer, 0)) return 0;
|
|
72297
|
+
const openingFenceEndByte = findLineEnd(sourceBuffer, 0);
|
|
72298
|
+
let lineStartByte = findNextLineStart(sourceBuffer, 0);
|
|
72299
|
+
while (lineStartByte < sourceBuffer.length) {
|
|
72300
|
+
if (isFrontmatterFenceLine(sourceBuffer, lineStartByte)) return findLineEnd(sourceBuffer, lineStartByte);
|
|
72301
|
+
lineStartByte = findNextLineStart(sourceBuffer, lineStartByte);
|
|
72302
|
+
}
|
|
72303
|
+
return openingFenceEndByte;
|
|
72304
|
+
};
|
|
72305
|
+
const maskByteRange = (maskedBuffer, startByte, endByte) => {
|
|
72306
|
+
for (let byteIndex = startByte; byteIndex < endByte; byteIndex++) {
|
|
72307
|
+
const byte = maskedBuffer[byteIndex];
|
|
72308
|
+
if (byte !== 10 && byte !== 13) maskedBuffer[byteIndex] = 32;
|
|
72309
|
+
}
|
|
72310
|
+
};
|
|
72311
|
+
const readStartTagName = (sourceBuffer, tagStartByte) => {
|
|
72312
|
+
const firstNameByte = sourceBuffer[tagStartByte + 1];
|
|
72313
|
+
if (firstNameByte === void 0 || !/[A-Za-z]/.test(String.fromCharCode(firstNameByte))) return null;
|
|
72314
|
+
let nameEndByte = tagStartByte + 2;
|
|
72315
|
+
while (nameEndByte < sourceBuffer.length && /[A-Za-z0-9:-]/.test(String.fromCharCode(sourceBuffer[nameEndByte] ?? 32))) nameEndByte++;
|
|
72316
|
+
return sourceBuffer.subarray(tagStartByte + 1, nameEndByte).toString("ascii").toLowerCase();
|
|
72317
|
+
};
|
|
72318
|
+
const findTagEnd = (sourceBuffer, startByte) => {
|
|
72319
|
+
let quoteByte = null;
|
|
72320
|
+
for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) {
|
|
72321
|
+
const byte = sourceBuffer[byteIndex];
|
|
72322
|
+
if (quoteByte !== null) {
|
|
72323
|
+
if (byte === quoteByte) quoteByte = null;
|
|
72324
|
+
continue;
|
|
72325
|
+
}
|
|
72326
|
+
if (byte === SINGLE_QUOTE_UTF8_BYTE || byte === DOUBLE_QUOTE_UTF8_BYTE) {
|
|
72327
|
+
quoteByte = byte;
|
|
72328
|
+
continue;
|
|
72329
|
+
}
|
|
72330
|
+
if (byte === TAG_CLOSE_UTF8_BYTE) return byteIndex;
|
|
72331
|
+
}
|
|
72332
|
+
return sourceBuffer.length;
|
|
72333
|
+
};
|
|
72334
|
+
const parseScriptAttributes = (sourceBuffer, attributesStartByte, tagEndByte) => {
|
|
72335
|
+
let byteIndex = attributesStartByte;
|
|
72336
|
+
let hasSource = false;
|
|
72337
|
+
let language = null;
|
|
72338
|
+
let scriptType = null;
|
|
72339
|
+
while (byteIndex < tagEndByte) {
|
|
72340
|
+
while (byteIndex < tagEndByte && (isHtmlWhitespace(sourceBuffer[byteIndex]) || sourceBuffer[byteIndex] === TAG_SELF_CLOSE_UTF8_BYTE)) byteIndex++;
|
|
72341
|
+
const attributeNameStartByte = byteIndex;
|
|
72342
|
+
while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== ATTRIBUTE_ASSIGNMENT_UTF8_BYTE && sourceBuffer[byteIndex] !== TAG_SELF_CLOSE_UTF8_BYTE) byteIndex++;
|
|
72343
|
+
const attributeName = sourceBuffer.subarray(attributeNameStartByte, byteIndex).toString("ascii").toLowerCase();
|
|
72344
|
+
while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
|
|
72345
|
+
let attributeValue = "";
|
|
72346
|
+
if (sourceBuffer[byteIndex] === ATTRIBUTE_ASSIGNMENT_UTF8_BYTE) {
|
|
72347
|
+
byteIndex++;
|
|
72348
|
+
while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
|
|
72349
|
+
const quoteByte = sourceBuffer[byteIndex];
|
|
72350
|
+
if (quoteByte === SINGLE_QUOTE_UTF8_BYTE || quoteByte === DOUBLE_QUOTE_UTF8_BYTE) {
|
|
72351
|
+
const valueStartByte = byteIndex + 1;
|
|
72352
|
+
byteIndex = valueStartByte;
|
|
72353
|
+
while (byteIndex < tagEndByte && sourceBuffer[byteIndex] !== quoteByte) byteIndex++;
|
|
72354
|
+
attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
|
|
72355
|
+
if (byteIndex < tagEndByte) byteIndex++;
|
|
72356
|
+
} else {
|
|
72357
|
+
const valueStartByte = byteIndex;
|
|
72358
|
+
while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== TAG_CLOSE_UTF8_BYTE) byteIndex++;
|
|
72359
|
+
attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
|
|
72360
|
+
}
|
|
72361
|
+
}
|
|
72362
|
+
if (attributeName === "src") hasSource = true;
|
|
72363
|
+
else if (attributeName === "type" && scriptType === null) scriptType = attributeValue;
|
|
72364
|
+
else if (attributeName === "language" && language === null) language = attributeValue;
|
|
72365
|
+
}
|
|
72366
|
+
return {
|
|
72367
|
+
hasSource,
|
|
72368
|
+
language,
|
|
72369
|
+
type: scriptType
|
|
72370
|
+
};
|
|
72371
|
+
};
|
|
72372
|
+
const isExecutableScript = (attributes) => {
|
|
72373
|
+
if (attributes.hasSource) return false;
|
|
72374
|
+
const type = attributes.type?.trim().toLowerCase() ?? "";
|
|
72375
|
+
if (type !== "") {
|
|
72376
|
+
const mimeType = type.split(";")[0]?.trim() ?? "";
|
|
72377
|
+
return mimeType === "module" || JAVASCRIPT_MIME_TYPES.has(mimeType);
|
|
72378
|
+
}
|
|
72379
|
+
const language = attributes.language?.trim().toLowerCase() ?? "";
|
|
72380
|
+
return language === "" || JAVASCRIPT_MIME_TYPES.has(`text/${language}`);
|
|
72381
|
+
};
|
|
72382
|
+
const findElementClose = (sourceBuffer, startByte, tagName) => {
|
|
72383
|
+
const closeTagStart = `</${tagName}`;
|
|
72384
|
+
for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) if (sourceBuffer[byteIndex] === TAG_OPEN_UTF8_BYTE && matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, closeTagStart) && isTagBoundary(sourceBuffer[byteIndex + closeTagStart.length])) return byteIndex;
|
|
72385
|
+
return sourceBuffer.length;
|
|
72386
|
+
};
|
|
72387
|
+
const prepareHtmlScriptSource = (sourceBuffer) => {
|
|
72388
|
+
const frontmatterEndByte = findFrontmatterEnd(sourceBuffer);
|
|
72389
|
+
let maskedBuffer = frontmatterEndByte > 0 ? Buffer.from(sourceBuffer) : null;
|
|
72390
|
+
if (maskedBuffer !== null) maskByteRange(maskedBuffer, 0, frontmatterEndByte);
|
|
72391
|
+
const executableScriptBodies = [];
|
|
72392
|
+
let byteIndex = frontmatterEndByte;
|
|
72393
|
+
let templateDepth = 0;
|
|
72394
|
+
while (byteIndex < sourceBuffer.length) {
|
|
72395
|
+
if (sourceBuffer[byteIndex] !== TAG_OPEN_UTF8_BYTE) {
|
|
72396
|
+
byteIndex++;
|
|
72397
|
+
continue;
|
|
72398
|
+
}
|
|
72399
|
+
if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, COMMENT_OPEN)) {
|
|
72400
|
+
const commentEndByte = sourceBuffer.indexOf(COMMENT_CLOSE, byteIndex + 4);
|
|
72401
|
+
byteIndex = commentEndByte === -1 ? sourceBuffer.length : commentEndByte + 3;
|
|
72402
|
+
continue;
|
|
72403
|
+
}
|
|
72404
|
+
if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, TEMPLATE_CLOSE) && isTagBoundary(sourceBuffer[byteIndex + TEMPLATE_CLOSE.length])) {
|
|
72405
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + TEMPLATE_CLOSE.length);
|
|
72406
|
+
if (templateDepth > 0) templateDepth--;
|
|
72407
|
+
byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
|
|
72408
|
+
continue;
|
|
72409
|
+
}
|
|
72410
|
+
if (!matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, SCRIPT_OPEN) || !isTagBoundary(sourceBuffer[byteIndex + SCRIPT_OPEN.length])) {
|
|
72411
|
+
if (!isPotentialTagStart(sourceBuffer[byteIndex + 1])) {
|
|
72412
|
+
byteIndex++;
|
|
72413
|
+
continue;
|
|
72414
|
+
}
|
|
72415
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + 1);
|
|
72416
|
+
const tagName = readStartTagName(sourceBuffer, byteIndex);
|
|
72417
|
+
if (tagName === PLAINTEXT_TAG_NAME) break;
|
|
72418
|
+
if (tagName === TEMPLATE_TAG_NAME) templateDepth++;
|
|
72419
|
+
if (tagName !== null && RAW_TEXT_TAG_NAMES.has(tagName)) {
|
|
72420
|
+
const closeTagStartByte = findElementClose(sourceBuffer, tagEndByte + 1, tagName);
|
|
72421
|
+
if (closeTagStartByte === sourceBuffer.length) break;
|
|
72422
|
+
const closeTagEndByte = findTagEnd(sourceBuffer, closeTagStartByte + tagName.length + 2);
|
|
72423
|
+
byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
|
|
72424
|
+
continue;
|
|
72425
|
+
}
|
|
72426
|
+
byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
|
|
72427
|
+
continue;
|
|
72428
|
+
}
|
|
72429
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + SCRIPT_OPEN.length);
|
|
72430
|
+
if (tagEndByte === sourceBuffer.length) break;
|
|
72431
|
+
const bodyStartByte = tagEndByte + 1;
|
|
72432
|
+
const bodyEndByte = findElementClose(sourceBuffer, bodyStartByte, SCRIPT_TAG_NAME);
|
|
72433
|
+
const attributes = parseScriptAttributes(sourceBuffer, byteIndex + SCRIPT_OPEN.length, tagEndByte);
|
|
72434
|
+
if (attributes.hasSource || templateDepth > 0) {
|
|
72435
|
+
maskedBuffer ??= Buffer.from(sourceBuffer);
|
|
72436
|
+
maskByteRange(maskedBuffer, bodyStartByte, bodyEndByte);
|
|
72437
|
+
} else if (isExecutableScript(attributes)) executableScriptBodies.push(sourceBuffer.subarray(bodyStartByte, bodyEndByte));
|
|
72438
|
+
if (bodyEndByte === sourceBuffer.length) break;
|
|
72439
|
+
const closeTagEndByte = findTagEnd(sourceBuffer, bodyEndByte + SCRIPT_CLOSE.length);
|
|
72440
|
+
byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
|
|
72441
|
+
}
|
|
72442
|
+
return {
|
|
72443
|
+
executableScriptBodies,
|
|
72444
|
+
lintBuffer: maskedBuffer ?? sourceBuffer
|
|
72445
|
+
};
|
|
72446
|
+
};
|
|
72447
|
+
const prepareHtmlLintSources = (rootDirectory, temporaryDirectory, candidateFiles) => {
|
|
72448
|
+
const lintFiles = [];
|
|
72449
|
+
const sourcePathByLintPath = /* @__PURE__ */ new Map();
|
|
72450
|
+
const sizeByLintPath = /* @__PURE__ */ new Map();
|
|
72451
|
+
const htmlSourcesDirectory = Path.join(temporaryDirectory, "html-sources");
|
|
72452
|
+
let htmlFileIndex = 0;
|
|
72453
|
+
let hasThreeModuleImport = false;
|
|
72454
|
+
for (const candidateFile of candidateFiles) {
|
|
72455
|
+
if (!HTML_FILE_PATTERN.test(candidateFile)) {
|
|
72456
|
+
lintFiles.push(candidateFile);
|
|
72457
|
+
continue;
|
|
72458
|
+
}
|
|
72459
|
+
const absoluteSourcePath = Path.isAbsolute(candidateFile) ? candidateFile : Path.resolve(rootDirectory, candidateFile);
|
|
72460
|
+
const sourceBuffer = NFS.readFileSync(absoluteSourcePath);
|
|
72461
|
+
const { executableScriptBodies, lintBuffer } = prepareHtmlScriptSource(sourceBuffer);
|
|
72462
|
+
if (htmlFileIndex === 0) NFS.mkdirSync(htmlSourcesDirectory, { recursive: true });
|
|
72463
|
+
const lintPath = Path.join(htmlSourcesDirectory, `${htmlFileIndex}.astro`);
|
|
72464
|
+
NFS.writeFileSync(lintPath, lintBuffer);
|
|
72465
|
+
lintFiles.push(lintPath);
|
|
72466
|
+
sourcePathByLintPath.set(Path.resolve(lintPath), candidateFile);
|
|
72467
|
+
sizeByLintPath.set(lintPath, sourceBuffer.length);
|
|
72468
|
+
hasThreeModuleImport ||= executableScriptBodies.some((scriptBody) => containsThreeModuleImport(scriptBody.toString("utf8")));
|
|
72469
|
+
htmlFileIndex++;
|
|
72470
|
+
}
|
|
72471
|
+
return {
|
|
72472
|
+
lintFiles,
|
|
72473
|
+
sourcePathByLintPath,
|
|
72474
|
+
sizeByLintPath,
|
|
72475
|
+
hasThreeModuleImport
|
|
72476
|
+
};
|
|
72477
|
+
};
|
|
71491
72478
|
/**
|
|
71492
72479
|
* Atomically (re)writes the generated oxlintrc.json. Used twice in
|
|
71493
72480
|
* the runner: once for the primary scan, once for the
|
|
@@ -71648,6 +72635,8 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
71648
72635
|
const runOxlint = async (options) => {
|
|
71649
72636
|
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
|
|
71650
72637
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
72638
|
+
const runtimeGlobals = Array.isArray(userConfig?.runtimeGlobals) ? userConfig.runtimeGlobals.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
72639
|
+
let unpluginAutoImportGlobalScopes = [];
|
|
71651
72640
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
71652
72641
|
validateRuleRegistration();
|
|
71653
72642
|
resetManifestCaches();
|
|
@@ -71661,21 +72650,6 @@ const runOxlint = async (options) => {
|
|
|
71661
72650
|
const pluginPath = resolvePluginPath();
|
|
71662
72651
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
71663
72652
|
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
71664
|
-
const buildConfig = (overrides) => createOxlintConfig({
|
|
71665
|
-
pluginPath,
|
|
71666
|
-
project,
|
|
71667
|
-
customRulesOnly,
|
|
71668
|
-
extendsPaths: overrides.extendsPaths,
|
|
71669
|
-
ignoredTags,
|
|
71670
|
-
includedTags,
|
|
71671
|
-
includeTagDefaults,
|
|
71672
|
-
serverAuthFunctionNames,
|
|
71673
|
-
severityControls,
|
|
71674
|
-
userPlugins,
|
|
71675
|
-
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
|
|
71676
|
-
ruleSelection: overrides.ruleSelection,
|
|
71677
|
-
sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
|
|
71678
|
-
});
|
|
71679
72653
|
const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
|
|
71680
72654
|
const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
71681
72655
|
const configPath = Path.join(configDirectory, "oxlintrc.json");
|
|
@@ -71711,7 +72685,36 @@ const runOxlint = async (options) => {
|
|
|
71711
72685
|
await yieldToEventLoop();
|
|
71712
72686
|
const sizedScanFiles = includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null;
|
|
71713
72687
|
const candidateFiles = includePaths !== void 0 ? includePaths : (sizedScanFiles ?? []).map((entry) => entry.path);
|
|
72688
|
+
unpluginAutoImportGlobalScopes = collectUnpluginAutoImportGlobalScopes({
|
|
72689
|
+
rootDirectory,
|
|
72690
|
+
candidateFiles
|
|
72691
|
+
});
|
|
72692
|
+
const preparedHtmlSources = prepareHtmlLintSources(rootDirectory, configDirectory, candidateFiles);
|
|
72693
|
+
const lintFiles = preparedHtmlSources.lintFiles;
|
|
72694
|
+
const hasHtmlFiles = preparedHtmlSources.sourcePathByLintPath.size > 0;
|
|
72695
|
+
const lintProject = !project.hasThree && preparedHtmlSources.hasThreeModuleImport ? {
|
|
72696
|
+
...project,
|
|
72697
|
+
hasThree: true
|
|
72698
|
+
} : project;
|
|
72699
|
+
const buildConfig = (overrides) => createOxlintConfig({
|
|
72700
|
+
pluginPath,
|
|
72701
|
+
project: lintProject,
|
|
72702
|
+
customRulesOnly,
|
|
72703
|
+
extendsPaths: overrides.extendsPaths,
|
|
72704
|
+
ignoredTags,
|
|
72705
|
+
includedTags,
|
|
72706
|
+
includeTagDefaults,
|
|
72707
|
+
runtimeGlobals,
|
|
72708
|
+
unpluginAutoImportGlobalScopes,
|
|
72709
|
+
serverAuthFunctionNames,
|
|
72710
|
+
severityControls,
|
|
72711
|
+
userPlugins,
|
|
72712
|
+
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
|
|
72713
|
+
ruleSelection: overrides.ruleSelection,
|
|
72714
|
+
sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
|
|
72715
|
+
});
|
|
71714
72716
|
const sizeByFile = sizedScanFiles !== null && lintBatchOrdering === "cost" ? new Map(sizedScanFiles.map((entry) => [entry.path, entry.sizeBytes])) : null;
|
|
72717
|
+
if (sizeByFile !== null) for (const [lintPath, sizeBytes] of preparedHtmlSources.sizeByLintPath) sizeByFile.set(lintPath, sizeBytes);
|
|
71715
72718
|
const buildFileBatches = (passBaseArgs, passFiles) => sizeByFile !== null ? planLintBatches({
|
|
71716
72719
|
baseArgs: passBaseArgs,
|
|
71717
72720
|
files: passFiles,
|
|
@@ -71740,7 +72743,8 @@ const runOxlint = async (options) => {
|
|
|
71740
72743
|
fileBatches: passFileBatches,
|
|
71741
72744
|
rootDirectory,
|
|
71742
72745
|
nodeBinaryPath,
|
|
71743
|
-
project,
|
|
72746
|
+
project: lintProject,
|
|
72747
|
+
sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
|
|
71744
72748
|
onPartialFailure: reportPartialFailure,
|
|
71745
72749
|
onAnalyzedFiles: (filePaths) => {
|
|
71746
72750
|
analyzedFiles = filePaths;
|
|
@@ -71775,7 +72779,7 @@ const runOxlint = async (options) => {
|
|
|
71775
72779
|
};
|
|
71776
72780
|
}
|
|
71777
72781
|
};
|
|
71778
|
-
if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0) {
|
|
72782
|
+
if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0 && !hasHtmlFiles) {
|
|
71779
72783
|
const rulesetHash = computeRulesetHash({
|
|
71780
72784
|
config: buildConfig({
|
|
71781
72785
|
extendsPaths: [],
|
|
@@ -71933,14 +72937,15 @@ const runOxlint = async (options) => {
|
|
|
71933
72937
|
]);
|
|
71934
72938
|
}
|
|
71935
72939
|
const baseArgs = makeBaseArgs(configPath);
|
|
71936
|
-
const fileBatches = buildFileBatches(baseArgs,
|
|
72940
|
+
const fileBatches = buildFileBatches(baseArgs, lintFiles);
|
|
71937
72941
|
let analyzedFiles = [];
|
|
71938
72942
|
const runBatches = () => spawnLintBatches({
|
|
71939
72943
|
baseArgs,
|
|
71940
72944
|
fileBatches,
|
|
71941
72945
|
rootDirectory,
|
|
71942
72946
|
nodeBinaryPath,
|
|
71943
|
-
project,
|
|
72947
|
+
project: lintProject,
|
|
72948
|
+
sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
|
|
71944
72949
|
onPartialFailure,
|
|
71945
72950
|
onAnalyzedFiles: (filePaths) => {
|
|
71946
72951
|
analyzedFiles = filePaths;
|
|
@@ -73474,7 +74479,7 @@ const computeConfigFingerprint = (projectDirectory, version) => {
|
|
|
73474
74479
|
/** Display name used in client-facing messages and progress titles. */
|
|
73475
74480
|
const SERVER_DISPLAY_NAME = "React Doctor";
|
|
73476
74481
|
/** Server version reported in `serverInfo`; injected at build, `dev` from source. */
|
|
73477
|
-
const SERVER_VERSION = "0.9.
|
|
74482
|
+
const SERVER_VERSION = "0.9.1";
|
|
73478
74483
|
/** `Diagnostic.source` shown next to every published diagnostic. */
|
|
73479
74484
|
const DIAGNOSTIC_SOURCE = "react-doctor";
|
|
73480
74485
|
/**
|
|
@@ -73516,7 +74521,8 @@ const SCANNABLE_EXTENSIONS = [
|
|
|
73516
74521
|
".js",
|
|
73517
74522
|
".jsx",
|
|
73518
74523
|
".mts",
|
|
73519
|
-
".mjs"
|
|
74524
|
+
".mjs",
|
|
74525
|
+
".html"
|
|
73520
74526
|
];
|
|
73521
74527
|
const SILENT_LOGGER = {
|
|
73522
74528
|
info: () => {},
|
|
@@ -75504,5 +76510,5 @@ const startLanguageServer = () => {
|
|
|
75504
76510
|
};
|
|
75505
76511
|
//#endregion
|
|
75506
76512
|
export { startLanguageServer };
|
|
75507
|
-
!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]="
|
|
75508
|
-
//# debugId=
|
|
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
|