react-doctor 0.9.1-dev.5d2f66d → 0.9.1-dev.6904ff1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cli.js +790 -103
- package/dist/index.d.ts +2 -2
- package/dist/index.js +784 -98
- package/dist/lsp.js +786 -99
- package/package.json +5 -4
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f34e66dd-4b16-53f5-a3af-9844fbc71772")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as NodeChildProcess from "node:child_process";
|
|
5
5
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -11,6 +11,7 @@ import process$1 from "node:process";
|
|
|
11
11
|
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
|
|
12
12
|
import * as Crypto from "node:crypto";
|
|
13
13
|
import crypto, { createHash, randomUUID } from "node:crypto";
|
|
14
|
+
import { ResolverFactory } from "oxc-resolver";
|
|
14
15
|
import ts from "typescript";
|
|
15
16
|
import * as OS from "node:os";
|
|
16
17
|
import os, { tmpdir } from "node:os";
|
|
@@ -64616,7 +64617,8 @@ var AmbiguousProjectError = class extends Error {
|
|
|
64616
64617
|
}
|
|
64617
64618
|
};
|
|
64618
64619
|
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
64619
|
-
const
|
|
64620
|
+
const HTML_FILE_PATTERN = /\.html$/i;
|
|
64621
|
+
const SOURCE_FILE_PATTERN = /\.(?:tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
|
|
64620
64622
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
64621
64623
|
const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
|
|
64622
64624
|
const MINIFIED_SNIFF_BYTES = 65536;
|
|
@@ -65239,7 +65241,7 @@ const findMonorepoRoot = (startDirectory) => {
|
|
|
65239
65241
|
*/
|
|
65240
65242
|
const isProjectBoundary = (directory) => NFS.existsSync(Path.join(directory, ".git")) || isMonorepoRoot(directory);
|
|
65241
65243
|
const TSCONFIG_FILENAME = "tsconfig.json";
|
|
65242
|
-
const
|
|
65244
|
+
const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || Path.isAbsolute(moduleSpecifier);
|
|
65243
65245
|
const ensureJsonExtension = (filePath) => Path.extname(filePath) === "" ? `${filePath}.json` : filePath;
|
|
65244
65246
|
const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
65245
65247
|
const requireFromConfig = createRequire(Path.join(fromConfigDirectory, "tsconfig.json"));
|
|
@@ -65256,7 +65258,12 @@ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
|
65256
65258
|
return null;
|
|
65257
65259
|
};
|
|
65258
65260
|
const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
|
|
65259
|
-
if (
|
|
65261
|
+
if (isLocalModuleSpecifier(extendsValue)) {
|
|
65262
|
+
const resolvedPath = Path.resolve(fromConfigDirectory, extendsValue);
|
|
65263
|
+
if (isFile(resolvedPath)) return resolvedPath;
|
|
65264
|
+
const directoryConfigPath = Path.join(resolvedPath, TSCONFIG_FILENAME);
|
|
65265
|
+
return isFile(directoryConfigPath) ? directoryConfigPath : ensureJsonExtension(resolvedPath);
|
|
65266
|
+
}
|
|
65260
65267
|
return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
|
|
65261
65268
|
};
|
|
65262
65269
|
const normalizeCompilerOptions = (compilerOptions) => {
|
|
@@ -65450,6 +65457,15 @@ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
|
|
|
65450
65457
|
".cts",
|
|
65451
65458
|
".json"
|
|
65452
65459
|
];
|
|
65460
|
+
const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
|
|
65461
|
+
conditionNames: [
|
|
65462
|
+
"import",
|
|
65463
|
+
"require",
|
|
65464
|
+
"node",
|
|
65465
|
+
"default"
|
|
65466
|
+
],
|
|
65467
|
+
extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
|
|
65468
|
+
});
|
|
65453
65469
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
65454
65470
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
65455
65471
|
const allDependencies = {
|
|
@@ -65473,6 +65489,18 @@ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
|
|
|
65473
65489
|
return false;
|
|
65474
65490
|
};
|
|
65475
65491
|
const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
|
|
65492
|
+
if (!isLocalModuleSpecifier(moduleSpecifier)) {
|
|
65493
|
+
try {
|
|
65494
|
+
const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
|
|
65495
|
+
if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
|
|
65496
|
+
} catch {}
|
|
65497
|
+
try {
|
|
65498
|
+
const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
|
|
65499
|
+
return isFile(resolvedPath) ? resolvedPath : null;
|
|
65500
|
+
} catch {
|
|
65501
|
+
return null;
|
|
65502
|
+
}
|
|
65503
|
+
}
|
|
65476
65504
|
const unresolvedPath = Path.resolve(Path.dirname(fromFilePath), moduleSpecifier);
|
|
65477
65505
|
const extension = Path.extname(unresolvedPath);
|
|
65478
65506
|
return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
|
|
@@ -65485,7 +65513,7 @@ const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json")
|
|
|
65485
65513
|
const getStaticPropertyName$2 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
|
|
65486
65514
|
const isCommonJsConfigExportAssignment = (node, sourceFile) => ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
|
|
65487
65515
|
const hasExportModifier = (node) => ts.canHaveModifiers(node) && Boolean(ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
|
|
65488
|
-
const getRequireModuleSpecifier = (expression) => {
|
|
65516
|
+
const getRequireModuleSpecifier$1 = (expression) => {
|
|
65489
65517
|
if (!ts.isCallExpression(expression) || !ts.isIdentifier(expression.expression) || expression.expression.text !== "require" || expression.arguments.length !== 1) return null;
|
|
65490
65518
|
const moduleSpecifier = expression.arguments[0];
|
|
65491
65519
|
return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
@@ -65498,7 +65526,7 @@ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statemen
|
|
|
65498
65526
|
const namedBindings = importClause?.namedBindings;
|
|
65499
65527
|
return namedBindings ? ts.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
|
|
65500
65528
|
}
|
|
65501
|
-
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) =>
|
|
65529
|
+
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
|
|
65502
65530
|
return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === bindingName;
|
|
65503
65531
|
});
|
|
65504
65532
|
const getImportBinding = (sourceFile, bindingName) => {
|
|
@@ -65529,21 +65557,21 @@ const getImportBinding = (sourceFile, bindingName) => {
|
|
|
65529
65557
|
for (const declaration of statement.declarationList.declarations) {
|
|
65530
65558
|
if (!declaration.initializer) continue;
|
|
65531
65559
|
if (ts.isIdentifier(declaration.name) && declaration.name.text === bindingName) {
|
|
65532
|
-
const directModuleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
65560
|
+
const directModuleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
|
|
65533
65561
|
if (directModuleSpecifier) return {
|
|
65534
65562
|
moduleSpecifier: directModuleSpecifier,
|
|
65535
65563
|
exportName: "default",
|
|
65536
65564
|
isNamespace: true
|
|
65537
65565
|
};
|
|
65538
|
-
if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier(declaration.initializer.expression) !== null) return {
|
|
65539
|
-
moduleSpecifier: getRequireModuleSpecifier(declaration.initializer.expression) ?? "",
|
|
65566
|
+
if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier$1(declaration.initializer.expression) !== null) return {
|
|
65567
|
+
moduleSpecifier: getRequireModuleSpecifier$1(declaration.initializer.expression) ?? "",
|
|
65540
65568
|
exportName: declaration.initializer.name.text,
|
|
65541
65569
|
isNamespace: false
|
|
65542
65570
|
};
|
|
65543
65571
|
}
|
|
65544
65572
|
if (!ts.isObjectBindingPattern(declaration.name)) continue;
|
|
65545
65573
|
const bindingElement = declaration.name.elements.find((element) => ts.isIdentifier(element.name) && element.name.text === bindingName);
|
|
65546
|
-
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
65574
|
+
const moduleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
|
|
65547
65575
|
if (bindingElement && moduleSpecifier) return {
|
|
65548
65576
|
moduleSpecifier,
|
|
65549
65577
|
exportName: bindingElement.propertyName ? getStaticPropertyName$2(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
|
|
@@ -65599,6 +65627,48 @@ const getScopedConfigBinding = (identifier) => {
|
|
|
65599
65627
|
};
|
|
65600
65628
|
};
|
|
65601
65629
|
const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
|
|
65630
|
+
const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
|
|
65631
|
+
const isConstantVariableInitializer = (node) => ts.isExpression(node) && ts.isVariableDeclaration(node.parent) && ts.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & ts.NodeFlags.Const);
|
|
65632
|
+
const isNodeCreateRequireCall = (node, analysis) => {
|
|
65633
|
+
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node) || ts.isAwaitExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
|
|
65634
|
+
if (!ts.isCallExpression(node)) return false;
|
|
65635
|
+
const target = node.expression;
|
|
65636
|
+
if (ts.isIdentifier(target)) {
|
|
65637
|
+
if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
|
|
65638
|
+
const importBinding = getImportBinding(analysis.sourceFile, target.text);
|
|
65639
|
+
return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
|
|
65640
|
+
}
|
|
65641
|
+
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return false;
|
|
65642
|
+
if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "createRequire") return false;
|
|
65643
|
+
const createRequireReceiver = target.expression;
|
|
65644
|
+
if (ts.isCallExpression(createRequireReceiver)) {
|
|
65645
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(createRequireReceiver);
|
|
65646
|
+
if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !ts.isIdentifier(createRequireReceiver.expression)) return false;
|
|
65647
|
+
const requireIdentifier = createRequireReceiver.expression;
|
|
65648
|
+
return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
|
|
65649
|
+
}
|
|
65650
|
+
if (!ts.isIdentifier(createRequireReceiver)) return false;
|
|
65651
|
+
if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
|
|
65652
|
+
const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
|
|
65653
|
+
return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
|
|
65654
|
+
};
|
|
65655
|
+
const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
|
|
65656
|
+
const [moduleSpecifierNode] = callExpression.arguments;
|
|
65657
|
+
if (!moduleSpecifierNode || !ts.isStringLiteralLike(moduleSpecifierNode)) return null;
|
|
65658
|
+
const target = callExpression.expression;
|
|
65659
|
+
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
65660
|
+
if ((ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null) !== "resolve") return null;
|
|
65661
|
+
if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
|
|
65662
|
+
if (!ts.isIdentifier(target.expression)) return null;
|
|
65663
|
+
const resolverIdentifier = target.expression;
|
|
65664
|
+
if (analysis.localBindings.has(resolverIdentifier.text)) return null;
|
|
65665
|
+
const scopedBinding = getScopedConfigBinding(resolverIdentifier);
|
|
65666
|
+
const topLevelBinding = scopedBinding.wasFound ? null : getTopLevelBinding(analysis.sourceFile, resolverIdentifier.text);
|
|
65667
|
+
const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : topLevelBinding;
|
|
65668
|
+
if (resolverInitializer === null && !scopedBinding.wasFound && resolverIdentifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, resolverIdentifier.text) && getImportBinding(analysis.sourceFile, resolverIdentifier.text) === null) return moduleSpecifierNode.text;
|
|
65669
|
+
if (!resolverInitializer || !isConstantVariableInitializer(resolverInitializer) || !isNodeCreateRequireCall(resolverInitializer, analysis)) return null;
|
|
65670
|
+
return moduleSpecifierNode.text;
|
|
65671
|
+
};
|
|
65602
65672
|
const getAssignedPropertyInitializer = (identifier, propertyName) => {
|
|
65603
65673
|
let bindingScope = null;
|
|
65604
65674
|
let currentNode = identifier;
|
|
@@ -65882,6 +65952,11 @@ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, a
|
|
|
65882
65952
|
visitReturns(functionNode.body);
|
|
65883
65953
|
return hasCompiler;
|
|
65884
65954
|
};
|
|
65955
|
+
const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
|
|
65956
|
+
const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
|
|
65957
|
+
if (!importedFilePath) return null;
|
|
65958
|
+
return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList);
|
|
65959
|
+
};
|
|
65885
65960
|
const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
|
|
65886
65961
|
const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
|
|
65887
65962
|
if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
|
|
@@ -65902,30 +65977,62 @@ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, i
|
|
|
65902
65977
|
const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
|
|
65903
65978
|
if (importBinding) {
|
|
65904
65979
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
65905
|
-
|
|
65906
|
-
|
|
65907
|
-
|
|
65980
|
+
return Boolean(analyzeImportedConfig({
|
|
65981
|
+
analysis,
|
|
65982
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
65983
|
+
exportName: importBinding.exportName,
|
|
65984
|
+
allowCompilerTransform
|
|
65985
|
+
}));
|
|
65908
65986
|
}
|
|
65909
65987
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
|
|
65910
65988
|
return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
|
|
65911
65989
|
};
|
|
65912
65990
|
const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
|
|
65913
65991
|
const target = callExpression.expression;
|
|
65992
|
+
const callableRequiredModuleSpecifier = getRequireModuleSpecifier$1(target);
|
|
65993
|
+
if (callableRequiredModuleSpecifier !== null) {
|
|
65994
|
+
if (ts.isCallExpression(target) && ts.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
65995
|
+
if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
|
|
65996
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
65997
|
+
analysis,
|
|
65998
|
+
moduleSpecifier: callableRequiredModuleSpecifier,
|
|
65999
|
+
exportName: "default",
|
|
66000
|
+
allowCompilerTransform,
|
|
66001
|
+
argumentsList: callExpression.arguments
|
|
66002
|
+
});
|
|
66003
|
+
if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
66004
|
+
return null;
|
|
66005
|
+
}
|
|
65914
66006
|
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
65915
66007
|
const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
|
|
65916
66008
|
if (propertyName === null) return null;
|
|
65917
|
-
const requiredModuleSpecifier = getRequireModuleSpecifier(target.expression);
|
|
66009
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
|
|
65918
66010
|
if (requiredModuleSpecifier !== null) {
|
|
65919
|
-
if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
65920
|
-
if (
|
|
65921
|
-
const
|
|
65922
|
-
|
|
66011
|
+
if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (analysis.localBindings.has(target.expression.expression.text) || getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
66012
|
+
if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
|
|
66013
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
66014
|
+
analysis,
|
|
66015
|
+
moduleSpecifier: requiredModuleSpecifier,
|
|
66016
|
+
exportName: propertyName,
|
|
66017
|
+
allowCompilerTransform,
|
|
66018
|
+
argumentsList: callExpression.arguments
|
|
66019
|
+
});
|
|
66020
|
+
if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
66021
|
+
return null;
|
|
65923
66022
|
}
|
|
65924
66023
|
if (!ts.isIdentifier(target.expression)) return null;
|
|
65925
|
-
const importBinding = getImportBinding(analysis.sourceFile, target.expression.text);
|
|
65926
|
-
if (importBinding?.isNamespace
|
|
65927
|
-
|
|
65928
|
-
|
|
66024
|
+
const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
|
|
66025
|
+
if (importBinding?.isNamespace) {
|
|
66026
|
+
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
|
|
66027
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
66028
|
+
analysis,
|
|
66029
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
66030
|
+
exportName: propertyName,
|
|
66031
|
+
allowCompilerTransform,
|
|
66032
|
+
argumentsList: callExpression.arguments
|
|
66033
|
+
});
|
|
66034
|
+
if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
66035
|
+
return null;
|
|
65929
66036
|
}
|
|
65930
66037
|
const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
|
|
65931
66038
|
if (selectedProperty === null) return null;
|
|
@@ -65948,9 +66055,13 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
65948
66055
|
if (propertyName === "reactCompiler") continue;
|
|
65949
66056
|
if ((propertyName === "plugins" || propertyName === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => ts.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, propertyName, analysis) || (ts.isPropertyAssignment(laterProperty) || ts.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName$2(laterProperty.name) === propertyName)) continue;
|
|
65950
66057
|
const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
|
|
65951
|
-
if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)
|
|
65952
|
-
|
|
65953
|
-
|
|
66058
|
+
if (propertyName === "extends" && ts.isStringLiteralLike(property.initializer)) {
|
|
66059
|
+
if (analyzeImportedConfig({
|
|
66060
|
+
analysis,
|
|
66061
|
+
moduleSpecifier: property.initializer.text,
|
|
66062
|
+
exportName: "default",
|
|
66063
|
+
allowCompilerTransform: false
|
|
66064
|
+
})) return true;
|
|
65954
66065
|
}
|
|
65955
66066
|
if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
|
|
65956
66067
|
} else if (ts.isShorthandPropertyAssignment(property)) {
|
|
@@ -65974,23 +66085,36 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
65974
66085
|
});
|
|
65975
66086
|
}
|
|
65976
66087
|
if (ts.isCallExpression(node)) {
|
|
66088
|
+
const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
|
|
66089
|
+
if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
|
|
65977
66090
|
const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
|
|
65978
66091
|
if (callTargetResult !== null) return callTargetResult;
|
|
65979
|
-
const directModuleSpecifier = getRequireModuleSpecifier(node);
|
|
66092
|
+
const directModuleSpecifier = getRequireModuleSpecifier$1(node);
|
|
65980
66093
|
const isRequireShadowed = analysis.localBindings.has("require") || ts.isIdentifier(node.expression) && getScopedConfigBinding(node.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require");
|
|
65981
66094
|
if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
65982
66095
|
if (directModuleSpecifier && !isRequireShadowed) {
|
|
65983
66096
|
if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
|
|
65984
|
-
if (
|
|
65985
|
-
|
|
65986
|
-
|
|
65987
|
-
|
|
66097
|
+
if (analyzeImportedConfig({
|
|
66098
|
+
analysis,
|
|
66099
|
+
moduleSpecifier: directModuleSpecifier,
|
|
66100
|
+
exportName: "default",
|
|
66101
|
+
allowCompilerTransform
|
|
66102
|
+
})) return true;
|
|
65988
66103
|
}
|
|
65989
66104
|
if (ts.isIdentifier(node.expression)) {
|
|
65990
|
-
|
|
65991
|
-
|
|
65992
|
-
|
|
65993
|
-
|
|
66105
|
+
if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
|
|
66106
|
+
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
66107
|
+
if (importBinding) {
|
|
66108
|
+
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
66109
|
+
const hasCompilerTransform = analyzeImportedConfig({
|
|
66110
|
+
analysis,
|
|
66111
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
66112
|
+
exportName: importBinding.exportName,
|
|
66113
|
+
allowCompilerTransform,
|
|
66114
|
+
argumentsList: node.arguments
|
|
66115
|
+
});
|
|
66116
|
+
if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
|
|
66117
|
+
}
|
|
65994
66118
|
}
|
|
65995
66119
|
const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
|
|
65996
66120
|
if (topLevelBinding && ts.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
|
|
@@ -65998,27 +66122,31 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
65998
66122
|
return analyzeConfigNode(node.expression, analysis, allowCompilerTransform) || node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false));
|
|
65999
66123
|
}
|
|
66000
66124
|
if (ts.isPropertyAccessExpression(node)) {
|
|
66001
|
-
const requiredModuleSpecifier = getRequireModuleSpecifier(node.expression);
|
|
66125
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
|
|
66002
66126
|
if (requiredModuleSpecifier) {
|
|
66003
|
-
if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
66004
|
-
if (
|
|
66005
|
-
|
|
66006
|
-
|
|
66007
|
-
|
|
66127
|
+
if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (analysis.localBindings.has(node.expression.expression.text) || getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
66128
|
+
if (analyzeImportedConfig({
|
|
66129
|
+
analysis,
|
|
66130
|
+
moduleSpecifier: requiredModuleSpecifier,
|
|
66131
|
+
exportName: node.name.text,
|
|
66132
|
+
allowCompilerTransform
|
|
66133
|
+
})) return true;
|
|
66008
66134
|
return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
|
|
66009
66135
|
}
|
|
66010
66136
|
if (ts.isIdentifier(node.expression)) {
|
|
66011
|
-
if (analysis.localBindings.has(node.expression.text)) {
|
|
66012
|
-
const
|
|
66013
|
-
return Boolean(
|
|
66137
|
+
if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
|
|
66138
|
+
const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
|
|
66139
|
+
return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
|
|
66014
66140
|
}
|
|
66015
66141
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
66016
66142
|
if (importBinding?.isNamespace) {
|
|
66017
66143
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.name.text)) return true;
|
|
66018
|
-
if (
|
|
66019
|
-
|
|
66020
|
-
|
|
66021
|
-
|
|
66144
|
+
if (analyzeImportedConfig({
|
|
66145
|
+
analysis,
|
|
66146
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
66147
|
+
exportName: node.name.text,
|
|
66148
|
+
allowCompilerTransform
|
|
66149
|
+
})) return true;
|
|
66022
66150
|
return false;
|
|
66023
66151
|
}
|
|
66024
66152
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.name.text, analysis);
|
|
@@ -66029,13 +66157,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
66029
66157
|
}
|
|
66030
66158
|
if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteralLike(node.argumentExpression)) {
|
|
66031
66159
|
if (ts.isIdentifier(node.expression)) {
|
|
66160
|
+
if (analysis.localBindings.has(node.expression.text) || getScopedConfigBinding(node.expression).wasFound) {
|
|
66161
|
+
const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
|
|
66162
|
+
return Boolean(selectedProperty && analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform));
|
|
66163
|
+
}
|
|
66032
66164
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
66033
66165
|
if (importBinding?.isNamespace) {
|
|
66034
66166
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, node.argumentExpression.text)) return true;
|
|
66035
|
-
|
|
66036
|
-
|
|
66037
|
-
|
|
66038
|
-
|
|
66167
|
+
return Boolean(analyzeImportedConfig({
|
|
66168
|
+
analysis,
|
|
66169
|
+
moduleSpecifier: importBinding.moduleSpecifier,
|
|
66170
|
+
exportName: node.argumentExpression.text,
|
|
66171
|
+
allowCompilerTransform
|
|
66172
|
+
}));
|
|
66039
66173
|
}
|
|
66040
66174
|
const selectedProperty = getSelectedObjectProperty(node.expression, node.argumentExpression.text, analysis);
|
|
66041
66175
|
if (selectedProperty) return analyzeConfigNode(selectedProperty, analysis, allowCompilerTransform);
|
|
@@ -66073,14 +66207,19 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
66073
66207
|
};
|
|
66074
66208
|
const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
|
|
66075
66209
|
const hasCompilerInConfigFiles = (directory, filenames) => filenames.some((filename) => hasCompilerInConfigFile(Path.join(directory, filename)));
|
|
66076
|
-
const hasCompilerInPackageJsonConfig = (
|
|
66077
|
-
|
|
66210
|
+
const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
|
|
66211
|
+
if (!isPlainObject(packageJson.babel)) return false;
|
|
66212
|
+
const packageJsonPath = Path.join(directory, "package.json");
|
|
66213
|
+
return analyzeConfigSourceFileExport(ts.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
|
|
66214
|
+
};
|
|
66215
|
+
const hasCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
|
|
66078
66216
|
const hasCompilerConfigurationInAncestors = (directory) => {
|
|
66079
66217
|
if (isProjectBoundary(directory)) return false;
|
|
66080
66218
|
let ancestorDirectory = Path.dirname(directory);
|
|
66081
66219
|
while (ancestorDirectory !== Path.dirname(ancestorDirectory)) {
|
|
66082
66220
|
const ancestorPackagePath = Path.join(ancestorDirectory, "package.json");
|
|
66083
|
-
|
|
66221
|
+
const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson$1(ancestorPackagePath) : {};
|
|
66222
|
+
if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
|
|
66084
66223
|
if (isProjectBoundary(ancestorDirectory)) return false;
|
|
66085
66224
|
ancestorDirectory = Path.dirname(ancestorDirectory);
|
|
66086
66225
|
}
|
|
@@ -69335,7 +69474,7 @@ const warn = (message) => {
|
|
|
69335
69474
|
runSync(warn$1(message));
|
|
69336
69475
|
};
|
|
69337
69476
|
const CONFIG_BASENAME = "doctor.config";
|
|
69338
|
-
const CONFIG_EXTENSIONS = [
|
|
69477
|
+
const CONFIG_EXTENSIONS$1 = [
|
|
69339
69478
|
"ts",
|
|
69340
69479
|
"mts",
|
|
69341
69480
|
"cts",
|
|
@@ -69439,7 +69578,7 @@ const loadLegacyConfig = (directory) => {
|
|
|
69439
69578
|
};
|
|
69440
69579
|
const loadConfigFromDirectory = async (directory) => {
|
|
69441
69580
|
let sawBrokenConfigFile = false;
|
|
69442
|
-
for (const extension of CONFIG_EXTENSIONS) {
|
|
69581
|
+
for (const extension of CONFIG_EXTENSIONS$1) {
|
|
69443
69582
|
const filePath = Path.join(directory, `${CONFIG_BASENAME}.${extension}`);
|
|
69444
69583
|
if (!isFile(filePath)) continue;
|
|
69445
69584
|
const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
|
|
@@ -69498,7 +69637,7 @@ const loadConfigWithSource = (rootDirectory) => {
|
|
|
69498
69637
|
return loadPromise;
|
|
69499
69638
|
};
|
|
69500
69639
|
const directoryHasCurrentConfig = (directory) => {
|
|
69501
|
-
for (const extension of CONFIG_EXTENSIONS) if (isFile(Path.join(directory, `${CONFIG_BASENAME}.${extension}`))) return true;
|
|
69640
|
+
for (const extension of CONFIG_EXTENSIONS$1) if (isFile(Path.join(directory, `${CONFIG_BASENAME}.${extension}`))) return true;
|
|
69502
69641
|
return readEmbeddedPackageJsonConfig(directory) !== null;
|
|
69503
69642
|
};
|
|
69504
69643
|
/**
|
|
@@ -73290,7 +73429,11 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
73290
73429
|
const ROOT_DIRECTORY_PLACEHOLDER = "<root>";
|
|
73291
73430
|
const normalizeConfigForHash = (config) => {
|
|
73292
73431
|
const clone = JSON.parse(JSON.stringify(config));
|
|
73293
|
-
if (clone?.settings?.["react-doctor"])
|
|
73432
|
+
if (clone?.settings?.["react-doctor"]) {
|
|
73433
|
+
const reactDoctorSettings = clone.settings["react-doctor"];
|
|
73434
|
+
reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
|
|
73435
|
+
if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
|
|
73436
|
+
}
|
|
73294
73437
|
if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
|
|
73295
73438
|
return clone;
|
|
73296
73439
|
};
|
|
@@ -73449,13 +73592,14 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
73449
73592
|
}
|
|
73450
73593
|
return enabled;
|
|
73451
73594
|
};
|
|
73452
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
73595
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, runtimeGlobals, unpluginAutoImportGlobalScopes, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
73453
73596
|
const hasIncludedTags = includedTags.size > 0;
|
|
73454
73597
|
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
73455
73598
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
73456
73599
|
const jsPlugins = [];
|
|
73457
73600
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
73458
73601
|
const capabilities = getCapabilities(project);
|
|
73602
|
+
const settingsRootDirectory = resolveSettingsRootDirectory(project.rootDirectory);
|
|
73459
73603
|
const enabledReactDoctorRules = {};
|
|
73460
73604
|
for (const registryEntry of REACT_DOCTOR_RULES) {
|
|
73461
73605
|
const rule = reactDoctorPlugin.rules[registryEntry.id];
|
|
@@ -73501,8 +73645,16 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
73501
73645
|
jsPlugins: [...jsPlugins, pluginPath],
|
|
73502
73646
|
settings: { "react-doctor": {
|
|
73503
73647
|
framework: project.framework,
|
|
73504
|
-
rootDirectory:
|
|
73648
|
+
rootDirectory: settingsRootDirectory,
|
|
73505
73649
|
capabilities: [...capabilities].sort(),
|
|
73650
|
+
...runtimeGlobals && runtimeGlobals.length > 0 ? { runtimeGlobals: [...runtimeGlobals] } : {},
|
|
73651
|
+
...unpluginAutoImportGlobalScopes && unpluginAutoImportGlobalScopes.length > 0 ? {
|
|
73652
|
+
unpluginAutoImportRootDirectories: [...new Set([settingsRootDirectory, project.rootDirectory])],
|
|
73653
|
+
unpluginAutoImportGlobalScopes: unpluginAutoImportGlobalScopes.map((scope) => ({
|
|
73654
|
+
directory: scope.directory,
|
|
73655
|
+
names: [...scope.names]
|
|
73656
|
+
}))
|
|
73657
|
+
} : {},
|
|
73506
73658
|
...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
|
|
73507
73659
|
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
73508
73660
|
} },
|
|
@@ -73513,6 +73665,245 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
73513
73665
|
}
|
|
73514
73666
|
};
|
|
73515
73667
|
};
|
|
73668
|
+
const AUTO_IMPORT_ADAPTER_PATTERN = /^unplugin-auto-import\/(?:astro|esbuild|rollup|rolldown|rspack|vite|webpack)$/;
|
|
73669
|
+
const CONFIG_BASENAMES = [
|
|
73670
|
+
"astro.config",
|
|
73671
|
+
"esbuild.config",
|
|
73672
|
+
"rollup.config",
|
|
73673
|
+
"rolldown.config",
|
|
73674
|
+
"rspack.config",
|
|
73675
|
+
"vite.config",
|
|
73676
|
+
"webpack.config"
|
|
73677
|
+
];
|
|
73678
|
+
const CONFIG_EXTENSIONS = [
|
|
73679
|
+
".cjs",
|
|
73680
|
+
".cts",
|
|
73681
|
+
".js",
|
|
73682
|
+
".mjs",
|
|
73683
|
+
".mts",
|
|
73684
|
+
".ts"
|
|
73685
|
+
];
|
|
73686
|
+
const CONFIG_FILENAMES = new Set(CONFIG_BASENAMES.flatMap((basename) => CONFIG_EXTENSIONS.map((extension) => `${basename}${extension}`)));
|
|
73687
|
+
const DEFAULT_ESLINT_GLOBALS_PATH = ".eslintrc-auto-import.json";
|
|
73688
|
+
const SUPPORTED_GLOBAL_VALUES = new Set([
|
|
73689
|
+
true,
|
|
73690
|
+
false,
|
|
73691
|
+
"readable",
|
|
73692
|
+
"readonly",
|
|
73693
|
+
"writable",
|
|
73694
|
+
"writeable"
|
|
73695
|
+
]);
|
|
73696
|
+
const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
|
|
73697
|
+
if (ts.isSpreadAssignment(property)) return false;
|
|
73698
|
+
const name = ts.isComputedPropertyName(property.name) ? unwrapTypescriptExpression(property.name.expression) : property.name;
|
|
73699
|
+
return (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) && name.text === propertyName;
|
|
73700
|
+
}) ?? null;
|
|
73701
|
+
const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !ts.isSpreadAssignment(property) && ts.isComputedPropertyName(property.name) && !ts.isStringLiteralLike(unwrapTypescriptExpression(property.name.expression)));
|
|
73702
|
+
const getStaticPropertyAssignment = (objectExpression, propertyName) => {
|
|
73703
|
+
const property = getStaticProperty(objectExpression, propertyName);
|
|
73704
|
+
return property && ts.isPropertyAssignment(property) ? property : null;
|
|
73705
|
+
};
|
|
73706
|
+
const getRequireModuleSpecifier = (expression) => {
|
|
73707
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
73708
|
+
if (ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "default") return getRequireModuleSpecifier(unwrappedExpression.expression);
|
|
73709
|
+
if (!ts.isCallExpression(unwrappedExpression) || !ts.isIdentifier(unwrappedExpression.expression) || unwrappedExpression.expression.text !== "require" || unwrappedExpression.arguments.length !== 1) return null;
|
|
73710
|
+
const moduleSpecifier = unwrappedExpression.arguments[0];
|
|
73711
|
+
return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
73712
|
+
};
|
|
73713
|
+
const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
|
|
73714
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
73715
|
+
return ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
|
|
73716
|
+
};
|
|
73717
|
+
const isCommonJsExportAssignment = (node, sourceFile) => ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
|
|
73718
|
+
const isTopLevelExpression = (node) => {
|
|
73719
|
+
let ancestor = node.parent;
|
|
73720
|
+
while (ancestor && !ts.isSourceFile(ancestor)) {
|
|
73721
|
+
if (ts.isExpressionStatement(ancestor)) return ts.isSourceFile(ancestor.parent);
|
|
73722
|
+
if (!ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isAwaitExpression(ancestor)) return false;
|
|
73723
|
+
ancestor = ancestor.parent;
|
|
73724
|
+
}
|
|
73725
|
+
return false;
|
|
73726
|
+
};
|
|
73727
|
+
const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
|
|
73728
|
+
let ancestor = node.parent;
|
|
73729
|
+
let didFindConfigProperty = false;
|
|
73730
|
+
while (ancestor && !ts.isSourceFile(ancestor)) {
|
|
73731
|
+
if (!didFindConfigProperty && !ts.isArrayLiteralExpression(ancestor) && !ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isPropertyAssignment(ancestor)) return false;
|
|
73732
|
+
if (ts.isPropertyAssignment(ancestor)) {
|
|
73733
|
+
const isConfigProperty = (ts.isIdentifier(ancestor.name) || ts.isStringLiteralLike(ancestor.name)) && ancestor.name.text === propertyName;
|
|
73734
|
+
if (didFindConfigProperty || !isConfigProperty) return false;
|
|
73735
|
+
if (!ts.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(ts.isSpreadAssignment)) return false;
|
|
73736
|
+
didFindConfigProperty = true;
|
|
73737
|
+
ancestor = ancestor.parent;
|
|
73738
|
+
continue;
|
|
73739
|
+
}
|
|
73740
|
+
if (didFindConfigProperty) {
|
|
73741
|
+
if (ts.isExportAssignment(ancestor)) return true;
|
|
73742
|
+
if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
|
|
73743
|
+
if (propertyName === "plugins" && ts.isCallExpression(ancestor) && (ts.isIdentifier(ancestor.expression) ? esbuildBindings.has(ancestor.expression.text) : ts.isPropertyAccessExpression(ancestor.expression) && ancestor.expression.name.text === "build" && (ts.isIdentifier(ancestor.expression.expression) && esbuildNamespaceBindings.has(ancestor.expression.expression.text) || getRequireModuleSpecifier(ancestor.expression.expression) === "esbuild"))) return isTopLevelExpression(ancestor);
|
|
73744
|
+
if (!(ts.isObjectLiteralExpression(ancestor) || ts.isParenthesizedExpression(ancestor) || ts.isAsExpression(ancestor) || ts.isSatisfiesExpression(ancestor) || ts.isNonNullExpression(ancestor) || ts.isTypeAssertionExpression(ancestor) || ts.isCallExpression(ancestor) && ts.isIdentifier(ancestor.expression) && ancestor.expression.text === "defineConfig")) return false;
|
|
73745
|
+
}
|
|
73746
|
+
ancestor = ancestor.parent;
|
|
73747
|
+
}
|
|
73748
|
+
return false;
|
|
73749
|
+
};
|
|
73750
|
+
const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory) => {
|
|
73751
|
+
const optionsExpression = callExpression.arguments[0];
|
|
73752
|
+
if (!optionsExpression) return null;
|
|
73753
|
+
const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
|
|
73754
|
+
if (!ts.isObjectLiteralExpression(unwrappedOptions)) return null;
|
|
73755
|
+
if (unwrappedOptions.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
|
|
73756
|
+
if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
|
|
73757
|
+
const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
|
|
73758
|
+
if (!eslintrcProperty) return null;
|
|
73759
|
+
const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
|
|
73760
|
+
if (!ts.isObjectLiteralExpression(eslintrcExpression)) return null;
|
|
73761
|
+
if (eslintrcExpression.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
|
|
73762
|
+
const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
|
|
73763
|
+
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== ts.SyntaxKind.TrueKeyword) return null;
|
|
73764
|
+
const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
|
|
73765
|
+
if (!filepathProperty) return Path.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
|
|
73766
|
+
if (!ts.isPropertyAssignment(filepathProperty)) return null;
|
|
73767
|
+
const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
|
|
73768
|
+
return ts.isStringLiteralLike(filepathExpression) ? Path.resolve(packageDirectory, filepathExpression.text) : null;
|
|
73769
|
+
};
|
|
73770
|
+
const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
73771
|
+
let sourceText;
|
|
73772
|
+
try {
|
|
73773
|
+
sourceText = NFS.readFileSync(configPath, "utf8");
|
|
73774
|
+
} catch {
|
|
73775
|
+
return {
|
|
73776
|
+
didFindActiveAutoImport: false,
|
|
73777
|
+
globalsPaths: []
|
|
73778
|
+
};
|
|
73779
|
+
}
|
|
73780
|
+
const sourceFile = ts.createSourceFile(configPath, sourceText, ts.ScriptTarget.Latest, true);
|
|
73781
|
+
const autoImportBindings = /* @__PURE__ */ new Map();
|
|
73782
|
+
const esbuildBindings = /* @__PURE__ */ new Set();
|
|
73783
|
+
const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
|
|
73784
|
+
for (const statement of sourceFile.statements) {
|
|
73785
|
+
if (ts.isImportDeclaration(statement) && ts.isStringLiteralLike(statement.moduleSpecifier)) {
|
|
73786
|
+
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
73787
|
+
if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
73788
|
+
const defaultBinding = statement.importClause?.name;
|
|
73789
|
+
if (defaultBinding) autoImportBindings.set(defaultBinding.text, moduleSpecifier);
|
|
73790
|
+
}
|
|
73791
|
+
if (moduleSpecifier === "esbuild") {
|
|
73792
|
+
const defaultBinding = statement.importClause?.name;
|
|
73793
|
+
if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
|
|
73794
|
+
const namedBindings = statement.importClause?.namedBindings;
|
|
73795
|
+
if (namedBindings && ts.isNamedImports(namedBindings)) {
|
|
73796
|
+
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
|
|
73797
|
+
}
|
|
73798
|
+
if (namedBindings && ts.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
|
|
73799
|
+
}
|
|
73800
|
+
}
|
|
73801
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
73802
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
73803
|
+
if (!declaration.initializer) continue;
|
|
73804
|
+
const declarationName = ts.isIdentifier(declaration.name) ? declaration.name.text : null;
|
|
73805
|
+
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
73806
|
+
if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
|
|
73807
|
+
if (moduleSpecifier === "esbuild") {
|
|
73808
|
+
if (declarationName) esbuildNamespaceBindings.add(declarationName);
|
|
73809
|
+
if (ts.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
|
|
73810
|
+
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
73811
|
+
if (ts.isIdentifier(importedName) && importedName.text === "build" && ts.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
|
|
73812
|
+
}
|
|
73813
|
+
}
|
|
73814
|
+
if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
|
|
73815
|
+
}
|
|
73816
|
+
}
|
|
73817
|
+
const globalsPaths = /* @__PURE__ */ new Set();
|
|
73818
|
+
let didFindActiveAutoImport = false;
|
|
73819
|
+
let didFindUnsafeActiveAutoImport = false;
|
|
73820
|
+
const visit = (node) => {
|
|
73821
|
+
if (ts.isCallExpression(node)) {
|
|
73822
|
+
const moduleSpecifier = ts.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
|
|
73823
|
+
if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
73824
|
+
if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
|
|
73825
|
+
didFindActiveAutoImport = true;
|
|
73826
|
+
const globalsPath = getGlobalsPathFromActiveAutoImportCall(node, packageDirectory);
|
|
73827
|
+
if (globalsPath) globalsPaths.add(globalsPath);
|
|
73828
|
+
else didFindUnsafeActiveAutoImport = true;
|
|
73829
|
+
}
|
|
73830
|
+
}
|
|
73831
|
+
}
|
|
73832
|
+
ts.forEachChild(node, visit);
|
|
73833
|
+
};
|
|
73834
|
+
visit(sourceFile);
|
|
73835
|
+
return {
|
|
73836
|
+
didFindActiveAutoImport,
|
|
73837
|
+
globalsPaths: didFindUnsafeActiveAutoImport ? [] : [...globalsPaths]
|
|
73838
|
+
};
|
|
73839
|
+
};
|
|
73840
|
+
const collectGeneratedGlobalNames = (globalsPath, rootDirectory) => {
|
|
73841
|
+
const relativePath = Path.relative(rootDirectory, globalsPath);
|
|
73842
|
+
if (relativePath.startsWith("..") || Path.isAbsolute(relativePath)) return [];
|
|
73843
|
+
const parsed = failOpenReadJson(globalsPath, null);
|
|
73844
|
+
if (!isPlainObject(parsed) || !isPlainObject(parsed.globals)) return [];
|
|
73845
|
+
return Object.entries(parsed.globals).filter((entry) => entry[0].length > 0 && (typeof entry[1] === "boolean" || typeof entry[1] === "string") && SUPPORTED_GLOBAL_VALUES.has(entry[1])).map(([name]) => name).sort();
|
|
73846
|
+
};
|
|
73847
|
+
const findOwningPackageDirectory = (absoluteFilePath, rootDirectory, cache) => {
|
|
73848
|
+
let currentDirectory = Path.dirname(absoluteFilePath);
|
|
73849
|
+
const visitedDirectories = [];
|
|
73850
|
+
while (true) {
|
|
73851
|
+
const cachedDirectory = cache.get(currentDirectory);
|
|
73852
|
+
if (cachedDirectory !== void 0) {
|
|
73853
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, cachedDirectory);
|
|
73854
|
+
return cachedDirectory;
|
|
73855
|
+
}
|
|
73856
|
+
const relativeDirectory = Path.relative(rootDirectory, currentDirectory);
|
|
73857
|
+
if (relativeDirectory.startsWith("..") || Path.isAbsolute(relativeDirectory)) {
|
|
73858
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
|
|
73859
|
+
return null;
|
|
73860
|
+
}
|
|
73861
|
+
visitedDirectories.push(currentDirectory);
|
|
73862
|
+
if (NFS.existsSync(Path.join(currentDirectory, "package.json"))) {
|
|
73863
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, currentDirectory);
|
|
73864
|
+
return currentDirectory;
|
|
73865
|
+
}
|
|
73866
|
+
if (currentDirectory === rootDirectory) {
|
|
73867
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
|
|
73868
|
+
return null;
|
|
73869
|
+
}
|
|
73870
|
+
currentDirectory = Path.dirname(currentDirectory);
|
|
73871
|
+
}
|
|
73872
|
+
};
|
|
73873
|
+
const collectPackageGlobalNames = (packageDirectory, rootDirectory) => {
|
|
73874
|
+
let directoryEntries;
|
|
73875
|
+
try {
|
|
73876
|
+
directoryEntries = NFS.readdirSync(packageDirectory, { withFileTypes: true });
|
|
73877
|
+
} catch {
|
|
73878
|
+
return [];
|
|
73879
|
+
}
|
|
73880
|
+
const configuredGlobalsPaths = [];
|
|
73881
|
+
for (const entry of directoryEntries) {
|
|
73882
|
+
if (!entry.isFile() && !entry.isSymbolicLink() || !CONFIG_FILENAMES.has(entry.name)) continue;
|
|
73883
|
+
const configGlobalsPaths = collectGlobalsPathsFromConfig(Path.join(packageDirectory, entry.name), packageDirectory);
|
|
73884
|
+
if (configGlobalsPaths.didFindActiveAutoImport) configuredGlobalsPaths.push(configGlobalsPaths.globalsPaths.toSorted());
|
|
73885
|
+
}
|
|
73886
|
+
if (configuredGlobalsPaths.length === 0) return [];
|
|
73887
|
+
const globalsPaths = configuredGlobalsPaths[0];
|
|
73888
|
+
if (configuredGlobalsPaths.some((candidatePaths) => candidatePaths.length !== globalsPaths.length || candidatePaths.some((candidatePath, index) => candidatePath !== globalsPaths[index]))) return [];
|
|
73889
|
+
const names = /* @__PURE__ */ new Set();
|
|
73890
|
+
for (const globalsPath of globalsPaths) for (const name of collectGeneratedGlobalNames(globalsPath, rootDirectory)) names.add(name);
|
|
73891
|
+
return [...names].sort();
|
|
73892
|
+
};
|
|
73893
|
+
const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }) => {
|
|
73894
|
+
const absoluteRootDirectory = Path.resolve(rootDirectory);
|
|
73895
|
+
const packageDirectoryCache = /* @__PURE__ */ new Map();
|
|
73896
|
+
const packageDirectories = /* @__PURE__ */ new Set();
|
|
73897
|
+
for (const candidateFile of candidateFiles) {
|
|
73898
|
+
const packageDirectory = findOwningPackageDirectory(Path.resolve(absoluteRootDirectory, candidateFile), absoluteRootDirectory, packageDirectoryCache);
|
|
73899
|
+
if (packageDirectory) packageDirectories.add(packageDirectory);
|
|
73900
|
+
}
|
|
73901
|
+
const scopes = [...packageDirectories].map((packageDirectory) => ({
|
|
73902
|
+
directory: Path.relative(absoluteRootDirectory, packageDirectory).replaceAll("\\", "/"),
|
|
73903
|
+
names: collectPackageGlobalNames(packageDirectory, absoluteRootDirectory)
|
|
73904
|
+
})).sort((firstScope, secondScope) => firstScope.directory.localeCompare(secondScope.directory));
|
|
73905
|
+
return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
|
|
73906
|
+
};
|
|
73516
73907
|
const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
|
|
73517
73908
|
const decodeFileDiagnostics = (raw) => {
|
|
73518
73909
|
if (!Array.isArray(raw)) return null;
|
|
@@ -73835,6 +74226,12 @@ const appendReanimatedSharedValueHint = (help, rule, project) => {
|
|
|
73835
74226
|
if (!help) return REANIMATED_SHARED_VALUE_HINT;
|
|
73836
74227
|
return `${help}\n\n${REANIMATED_SHARED_VALUE_HINT}`;
|
|
73837
74228
|
};
|
|
74229
|
+
const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
|
|
74230
|
+
const boundedOffset = Math.min(Math.max(utf8Offset, 0), sourceBuffer.length);
|
|
74231
|
+
let lineStartOffset = boundedOffset;
|
|
74232
|
+
while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
|
|
74233
|
+
return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
|
|
74234
|
+
};
|
|
73838
74235
|
const REDACTED_PLACEHOLDER = "<redacted>";
|
|
73839
74236
|
const KEEP_PREFIX = `$1${REDACTED_PLACEHOLDER}`;
|
|
73840
74237
|
const KNOWN_SECRET_RULES = [
|
|
@@ -74550,7 +74947,7 @@ const resolveMatchByOccurrence = (rule, category) => OCCURRENCE_MATCHED_CATEGORI
|
|
|
74550
74947
|
* with empty text still carry a useful jump target, so they're kept
|
|
74551
74948
|
* with a neutral message.
|
|
74552
74949
|
*/
|
|
74553
|
-
const buildRelatedLocations = (labels, filePath) => {
|
|
74950
|
+
const buildRelatedLocations = (labels, filePath, sourceBuffer) => {
|
|
74554
74951
|
if (labels.length <= 1) return [];
|
|
74555
74952
|
const related = [];
|
|
74556
74953
|
for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
|
|
@@ -74558,8 +74955,8 @@ const buildRelatedLocations = (labels, filePath) => {
|
|
|
74558
74955
|
if (!label?.span) continue;
|
|
74559
74956
|
related.push({
|
|
74560
74957
|
filePath,
|
|
74561
|
-
line: label.span.line ?? 0,
|
|
74562
|
-
column: label.span.column ?? 0,
|
|
74958
|
+
line: sourceBuffer === null ? label.span.line ?? 0 : lineOfUtf8Offset(sourceBuffer, label.span.offset),
|
|
74959
|
+
column: sourceBuffer === null ? label.span.column ?? 0 : columnOfUtf8Offset(sourceBuffer, label.span.offset),
|
|
74563
74960
|
offset: label.span.offset,
|
|
74564
74961
|
length: label.span.length,
|
|
74565
74962
|
message: label.label ?? ""
|
|
@@ -74579,7 +74976,7 @@ const isOxlintOutput = (value) => isRecord$1(value) && Array.isArray(value.diagn
|
|
|
74579
74976
|
* to the first `{`. Raises `OxlintOutputUnparseable` when the
|
|
74580
74977
|
* stdout isn't valid JSON or doesn't carry a `diagnostics` array.
|
|
74581
74978
|
*/
|
|
74582
|
-
const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
74979
|
+
const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath) => {
|
|
74583
74980
|
if (!stdout) return [];
|
|
74584
74981
|
const jsonStart = stdout.indexOf("{");
|
|
74585
74982
|
const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
|
|
@@ -74596,8 +74993,10 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
74596
74993
|
const sourceBufferCache = /* @__PURE__ */ new Map();
|
|
74597
74994
|
const sourceLinesCache = /* @__PURE__ */ new Map();
|
|
74598
74995
|
const resolveAbsolutePath = (filename) => Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
|
|
74996
|
+
const resolveMappedSourceFilename = (filename) => sourcePathByLintPath?.get(Path.normalize(resolveAbsolutePath(filename)));
|
|
74997
|
+
const resolveSourceFilename = (filename) => resolveMappedSourceFilename(filename) ?? filename;
|
|
74599
74998
|
const readSourceBuffer = (filename) => {
|
|
74600
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
74999
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
74601
75000
|
const cached = sourceBufferCache.get(absolutePath);
|
|
74602
75001
|
if (cached !== void 0) return cached;
|
|
74603
75002
|
let sourceBuffer;
|
|
@@ -74610,7 +75009,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
74610
75009
|
return sourceBuffer;
|
|
74611
75010
|
};
|
|
74612
75011
|
const readSourceLines = (filename) => {
|
|
74613
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
75012
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
74614
75013
|
const cached = sourceLinesCache.get(absolutePath);
|
|
74615
75014
|
if (cached !== void 0) return cached;
|
|
74616
75015
|
const sourceBuffer = readSourceBuffer(filename);
|
|
@@ -74619,27 +75018,30 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
74619
75018
|
return sourceLines;
|
|
74620
75019
|
};
|
|
74621
75020
|
const isMinifiedDiagnosticFile = (filename) => {
|
|
74622
|
-
const absolutePath = resolveAbsolutePath(filename);
|
|
75021
|
+
const absolutePath = resolveAbsolutePath(resolveSourceFilename(filename));
|
|
74623
75022
|
const cached = minifiedFileCache.get(absolutePath);
|
|
74624
75023
|
if (cached !== void 0) return cached;
|
|
74625
75024
|
const minified = isMinifiedSource(absolutePath);
|
|
74626
75025
|
minifiedFileCache.set(absolutePath, minified);
|
|
74627
75026
|
return minified;
|
|
74628
75027
|
};
|
|
74629
|
-
return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.filter((diagnostic) => isMappableOxlintDiagnostic(diagnostic) && isLintableSourceFile(diagnostic.filename) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
|
|
75028
|
+
return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.filter((diagnostic) => isMappableOxlintDiagnostic(diagnostic) && isLintableSourceFile(resolveSourceFilename(diagnostic.filename)) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
|
|
74630
75029
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
74631
75030
|
const primaryLabel = diagnostic.labels[0];
|
|
74632
75031
|
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
74633
|
-
const
|
|
75032
|
+
const mappedSourceFilename = resolveMappedSourceFilename(diagnostic.filename);
|
|
75033
|
+
const normalizedFilePath = (mappedSourceFilename ?? diagnostic.filename).replaceAll("\\", "/");
|
|
74634
75034
|
const primarySpan = primaryLabel?.span;
|
|
74635
75035
|
const sourceBuffer = primarySpan ? readSourceBuffer(diagnostic.filename) : null;
|
|
74636
|
-
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
|
|
75036
|
+
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath, mappedSourceFilename === void 0 ? null : sourceBuffer);
|
|
74637
75037
|
const category = resolveDiagnosticCategory(plugin, rule);
|
|
74638
75038
|
const matchByOccurrence = resolveMatchByOccurrence(rule, category);
|
|
74639
75039
|
const sourceLines = primarySpan ? readSourceLines(diagnostic.filename) : null;
|
|
74640
|
-
const
|
|
75040
|
+
const primaryLineNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.line ?? 0;
|
|
75041
|
+
const primaryColumnNumber = primarySpan && mappedSourceFilename !== void 0 && sourceBuffer !== null ? columnOfUtf8Offset(sourceBuffer, primarySpan.offset) : primarySpan?.column ?? 0;
|
|
75042
|
+
const primaryLineIndex = primarySpan ? primaryLineNumber - 1 : -1;
|
|
74641
75043
|
const primaryLine = sourceLines?.[primaryLineIndex];
|
|
74642
|
-
const primaryColumnIndex = primarySpan ?
|
|
75044
|
+
const primaryColumnIndex = primarySpan ? primaryColumnNumber - 1 : -1;
|
|
74643
75045
|
const isJsxTagLabel = primaryLine !== void 0 && primaryColumnIndex >= 0 && (primaryLine[primaryColumnIndex] === "<" || primaryLine[primaryColumnIndex - 1] === "<");
|
|
74644
75046
|
const jsxOpenerEndLineIndex = sourceLines && isJsxTagLabel ? findJsxOpenerSpan(sourceLines, primaryLineIndex) : null;
|
|
74645
75047
|
const primarySpanEndLine = jsxOpenerEndLineIndex !== null ? jsxOpenerEndLineIndex + 1 : primarySpan && sourceBuffer ? lineOfUtf8Offset(sourceBuffer, primarySpan.offset + Math.max(primarySpan.length - 1, 0)) : void 0;
|
|
@@ -74652,8 +75054,8 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
74652
75054
|
message: cleaned.message,
|
|
74653
75055
|
help: cleaned.help,
|
|
74654
75056
|
url: diagnostic.url,
|
|
74655
|
-
line:
|
|
74656
|
-
column:
|
|
75057
|
+
line: primaryLineNumber,
|
|
75058
|
+
column: primaryColumnNumber,
|
|
74657
75059
|
...primarySpan ? {
|
|
74658
75060
|
offset: primarySpan.offset,
|
|
74659
75061
|
length: primarySpan.length,
|
|
@@ -74841,7 +75243,11 @@ const isParallelismRelatedSpawnError = (error) => {
|
|
|
74841
75243
|
* loop with a slimmer config in that case.
|
|
74842
75244
|
*/
|
|
74843
75245
|
const spawnLintBatches = async (input) => {
|
|
74844
|
-
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
|
|
75246
|
+
const { baseArgs, fileBatches, rootDirectory, nodeBinaryPath, project, sourcePathByLintPath, onPartialFailure, onFileProgress, spawnTimeoutMs, outputMaxBytes, splitTotalBudgetMs = OXLINT_SPLIT_TOTAL_BUDGET_MS, splitMaxDepth = 8, signal, deadlineEpochMs } = input;
|
|
75247
|
+
const resolveSourcePath = (filePath) => {
|
|
75248
|
+
const absoluteFilePath = Path.isAbsolute(filePath) ? filePath : Path.resolve(rootDirectory, filePath);
|
|
75249
|
+
return sourcePathByLintPath?.get(Path.normalize(absoluteFilePath)) ?? filePath;
|
|
75250
|
+
};
|
|
74845
75251
|
const requestedConcurrency = resolveScanConcurrency(input.concurrency ?? 1);
|
|
74846
75252
|
let rescueDeadlineEpochMs;
|
|
74847
75253
|
const isPastDeadline = () => deadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(deadlineEpochMs) === 0 || rescueDeadlineEpochMs !== void 0 && remainingDeadlineBudgetMs(rescueDeadlineEpochMs) === 0;
|
|
@@ -74861,7 +75267,7 @@ const spawnLintBatches = async (input) => {
|
|
|
74861
75267
|
}
|
|
74862
75268
|
const batchArgs = [...baseArgs, ...batch];
|
|
74863
75269
|
try {
|
|
74864
|
-
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory);
|
|
75270
|
+
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory, sourcePathByLintPath);
|
|
74865
75271
|
} catch (error) {
|
|
74866
75272
|
if (!isSplittableReactDoctorError(error)) throw error;
|
|
74867
75273
|
if (isPastDeadline()) {
|
|
@@ -74967,10 +75373,12 @@ const spawnLintBatches = async (input) => {
|
|
|
74967
75373
|
onPartialFailure(buildMessage(`${skippedFiles.slice(0, 3).join(", ")}${skippedFiles.length > 3 ? `, +${skippedFiles.length - 3} more` : ""}`));
|
|
74968
75374
|
};
|
|
74969
75375
|
const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
|
|
74970
|
-
|
|
74971
|
-
|
|
75376
|
+
const droppedSourceFiles = [...new Set(droppedFiles.map(resolveSourcePath))];
|
|
75377
|
+
const deadlineSkippedSourceFiles = [...new Set(outcome.deadlineSkippedFiles.map(resolveSourcePath))];
|
|
75378
|
+
reportSkippedFiles(droppedSourceFiles, (fileListPreview) => `${droppedSourceFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
|
|
75379
|
+
reportSkippedFiles(deadlineSkippedSourceFiles, (fileListPreview) => `${deadlineSkippedSourceFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
|
|
74972
75380
|
const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
|
|
74973
|
-
input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)))].sort());
|
|
75381
|
+
input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)).map(resolveSourcePath))].sort());
|
|
74974
75382
|
return dedupeDiagnostics(diagnostics);
|
|
74975
75383
|
};
|
|
74976
75384
|
let didValidate = false;
|
|
@@ -75069,6 +75477,266 @@ const planLintBatches = ({ baseArgs, files, sizeByFile }) => {
|
|
|
75069
75477
|
}
|
|
75070
75478
|
return batches.filter((batch) => batch.fileIndexes.length > 0).map((batch) => batch.fileIndexes.sort((leftIndex, rightIndex) => leftIndex - rightIndex).map((fileIndex) => files[fileIndex]));
|
|
75071
75479
|
};
|
|
75480
|
+
const THREE_MODULE_IMPORT_PATTERN = /\b(?:from\s*|import\s*(?:\(\s*)?|require\s*\(\s*)["']three(?:\/[^"']*)?["']/;
|
|
75481
|
+
const containsThreeModuleImport = (sourceText) => THREE_MODULE_IMPORT_PATTERN.test(sourceText);
|
|
75482
|
+
const COMMENT_OPEN = "<!--";
|
|
75483
|
+
const COMMENT_CLOSE = "-->";
|
|
75484
|
+
const FRONTMATTER_FENCE = "---";
|
|
75485
|
+
const SCRIPT_TAG_NAME = "script";
|
|
75486
|
+
const SCRIPT_OPEN = `<${SCRIPT_TAG_NAME}`;
|
|
75487
|
+
const SCRIPT_CLOSE = `</${SCRIPT_TAG_NAME}`;
|
|
75488
|
+
const TEMPLATE_TAG_NAME = "template";
|
|
75489
|
+
const TEMPLATE_CLOSE = `</${TEMPLATE_TAG_NAME}`;
|
|
75490
|
+
const JAVASCRIPT_MIME_TYPES = new Set([
|
|
75491
|
+
"application/ecmascript",
|
|
75492
|
+
"application/javascript",
|
|
75493
|
+
"application/x-ecmascript",
|
|
75494
|
+
"application/x-javascript",
|
|
75495
|
+
"text/ecmascript",
|
|
75496
|
+
"text/javascript",
|
|
75497
|
+
"text/javascript1.0",
|
|
75498
|
+
"text/javascript1.1",
|
|
75499
|
+
"text/javascript1.2",
|
|
75500
|
+
"text/javascript1.3",
|
|
75501
|
+
"text/javascript1.4",
|
|
75502
|
+
"text/javascript1.5",
|
|
75503
|
+
"text/jscript",
|
|
75504
|
+
"text/livescript",
|
|
75505
|
+
"text/x-ecmascript",
|
|
75506
|
+
"text/x-javascript"
|
|
75507
|
+
]);
|
|
75508
|
+
const RAW_TEXT_TAG_NAMES = new Set([
|
|
75509
|
+
"iframe",
|
|
75510
|
+
"noembed",
|
|
75511
|
+
"noframes",
|
|
75512
|
+
"noscript",
|
|
75513
|
+
"style",
|
|
75514
|
+
"textarea",
|
|
75515
|
+
"title",
|
|
75516
|
+
"xmp"
|
|
75517
|
+
]);
|
|
75518
|
+
const PLAINTEXT_TAG_NAME = "plaintext";
|
|
75519
|
+
const TAG_OPEN_UTF8_BYTE = "<".charCodeAt(0);
|
|
75520
|
+
const TAG_CLOSE_UTF8_BYTE = ">".charCodeAt(0);
|
|
75521
|
+
const SINGLE_QUOTE_UTF8_BYTE = "'".charCodeAt(0);
|
|
75522
|
+
const DOUBLE_QUOTE_UTF8_BYTE = "\"".charCodeAt(0);
|
|
75523
|
+
const ATTRIBUTE_ASSIGNMENT_UTF8_BYTE = "=".charCodeAt(0);
|
|
75524
|
+
const TAG_SELF_CLOSE_UTF8_BYTE = "/".charCodeAt(0);
|
|
75525
|
+
const TAB_UTF8_BYTE = " ".charCodeAt(0);
|
|
75526
|
+
const FORM_FEED_UTF8_BYTE = "\f".charCodeAt(0);
|
|
75527
|
+
const isHtmlWhitespace = (byte) => byte === TAB_UTF8_BYTE || byte === 10 || byte === FORM_FEED_UTF8_BYTE || byte === 13 || byte === 32;
|
|
75528
|
+
const matchesAsciiCaseInsensitive = (sourceBuffer, startByte, expected) => {
|
|
75529
|
+
if (startByte + expected.length > sourceBuffer.length) return false;
|
|
75530
|
+
for (let expectedIndex = 0; expectedIndex < expected.length; expectedIndex++) {
|
|
75531
|
+
const sourceByte = sourceBuffer[startByte + expectedIndex];
|
|
75532
|
+
if (sourceByte === void 0 || String.fromCharCode(sourceByte).toLowerCase() !== expected[expectedIndex]) return false;
|
|
75533
|
+
}
|
|
75534
|
+
return true;
|
|
75535
|
+
};
|
|
75536
|
+
const isTagBoundary = (byte) => byte === TAG_CLOSE_UTF8_BYTE || byte === TAG_SELF_CLOSE_UTF8_BYTE || isHtmlWhitespace(byte);
|
|
75537
|
+
const isPotentialTagStart = (byte) => {
|
|
75538
|
+
if (byte === void 0) return false;
|
|
75539
|
+
return /[A-Za-z!/?]/.test(String.fromCharCode(byte));
|
|
75540
|
+
};
|
|
75541
|
+
const findLineEnd = (sourceBuffer, lineStartByte) => {
|
|
75542
|
+
let byteIndex = lineStartByte;
|
|
75543
|
+
while (byteIndex < sourceBuffer.length && sourceBuffer[byteIndex] !== 10 && sourceBuffer[byteIndex] !== 13) byteIndex++;
|
|
75544
|
+
return byteIndex;
|
|
75545
|
+
};
|
|
75546
|
+
const findNextLineStart = (sourceBuffer, lineStartByte) => {
|
|
75547
|
+
const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
|
|
75548
|
+
if (sourceBuffer[lineEndByte] === 13 && sourceBuffer[lineEndByte + 1] === 10) return lineEndByte + 2;
|
|
75549
|
+
return Math.min(lineEndByte + 1, sourceBuffer.length);
|
|
75550
|
+
};
|
|
75551
|
+
const isFrontmatterFenceLine = (sourceBuffer, lineStartByte) => {
|
|
75552
|
+
if (!matchesAsciiCaseInsensitive(sourceBuffer, lineStartByte, FRONTMATTER_FENCE)) return false;
|
|
75553
|
+
const lineEndByte = findLineEnd(sourceBuffer, lineStartByte);
|
|
75554
|
+
for (let byteIndex = lineStartByte + 3; byteIndex < lineEndByte; byteIndex++) if (!isHtmlWhitespace(sourceBuffer[byteIndex])) return false;
|
|
75555
|
+
return true;
|
|
75556
|
+
};
|
|
75557
|
+
const findFrontmatterEnd = (sourceBuffer) => {
|
|
75558
|
+
if (!isFrontmatterFenceLine(sourceBuffer, 0)) return 0;
|
|
75559
|
+
const openingFenceEndByte = findLineEnd(sourceBuffer, 0);
|
|
75560
|
+
let lineStartByte = findNextLineStart(sourceBuffer, 0);
|
|
75561
|
+
while (lineStartByte < sourceBuffer.length) {
|
|
75562
|
+
if (isFrontmatterFenceLine(sourceBuffer, lineStartByte)) return findLineEnd(sourceBuffer, lineStartByte);
|
|
75563
|
+
lineStartByte = findNextLineStart(sourceBuffer, lineStartByte);
|
|
75564
|
+
}
|
|
75565
|
+
return openingFenceEndByte;
|
|
75566
|
+
};
|
|
75567
|
+
const maskByteRange = (maskedBuffer, startByte, endByte) => {
|
|
75568
|
+
for (let byteIndex = startByte; byteIndex < endByte; byteIndex++) {
|
|
75569
|
+
const byte = maskedBuffer[byteIndex];
|
|
75570
|
+
if (byte !== 10 && byte !== 13) maskedBuffer[byteIndex] = 32;
|
|
75571
|
+
}
|
|
75572
|
+
};
|
|
75573
|
+
const readStartTagName = (sourceBuffer, tagStartByte) => {
|
|
75574
|
+
const firstNameByte = sourceBuffer[tagStartByte + 1];
|
|
75575
|
+
if (firstNameByte === void 0 || !/[A-Za-z]/.test(String.fromCharCode(firstNameByte))) return null;
|
|
75576
|
+
let nameEndByte = tagStartByte + 2;
|
|
75577
|
+
while (nameEndByte < sourceBuffer.length && /[A-Za-z0-9:-]/.test(String.fromCharCode(sourceBuffer[nameEndByte] ?? 32))) nameEndByte++;
|
|
75578
|
+
return sourceBuffer.subarray(tagStartByte + 1, nameEndByte).toString("ascii").toLowerCase();
|
|
75579
|
+
};
|
|
75580
|
+
const findTagEnd = (sourceBuffer, startByte) => {
|
|
75581
|
+
let quoteByte = null;
|
|
75582
|
+
for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) {
|
|
75583
|
+
const byte = sourceBuffer[byteIndex];
|
|
75584
|
+
if (quoteByte !== null) {
|
|
75585
|
+
if (byte === quoteByte) quoteByte = null;
|
|
75586
|
+
continue;
|
|
75587
|
+
}
|
|
75588
|
+
if (byte === SINGLE_QUOTE_UTF8_BYTE || byte === DOUBLE_QUOTE_UTF8_BYTE) {
|
|
75589
|
+
quoteByte = byte;
|
|
75590
|
+
continue;
|
|
75591
|
+
}
|
|
75592
|
+
if (byte === TAG_CLOSE_UTF8_BYTE) return byteIndex;
|
|
75593
|
+
}
|
|
75594
|
+
return sourceBuffer.length;
|
|
75595
|
+
};
|
|
75596
|
+
const parseScriptAttributes = (sourceBuffer, attributesStartByte, tagEndByte) => {
|
|
75597
|
+
let byteIndex = attributesStartByte;
|
|
75598
|
+
let hasSource = false;
|
|
75599
|
+
let language = null;
|
|
75600
|
+
let scriptType = null;
|
|
75601
|
+
while (byteIndex < tagEndByte) {
|
|
75602
|
+
while (byteIndex < tagEndByte && (isHtmlWhitespace(sourceBuffer[byteIndex]) || sourceBuffer[byteIndex] === TAG_SELF_CLOSE_UTF8_BYTE)) byteIndex++;
|
|
75603
|
+
const attributeNameStartByte = byteIndex;
|
|
75604
|
+
while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== ATTRIBUTE_ASSIGNMENT_UTF8_BYTE && sourceBuffer[byteIndex] !== TAG_SELF_CLOSE_UTF8_BYTE) byteIndex++;
|
|
75605
|
+
const attributeName = sourceBuffer.subarray(attributeNameStartByte, byteIndex).toString("ascii").toLowerCase();
|
|
75606
|
+
while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
|
|
75607
|
+
let attributeValue = "";
|
|
75608
|
+
if (sourceBuffer[byteIndex] === ATTRIBUTE_ASSIGNMENT_UTF8_BYTE) {
|
|
75609
|
+
byteIndex++;
|
|
75610
|
+
while (byteIndex < tagEndByte && isHtmlWhitespace(sourceBuffer[byteIndex])) byteIndex++;
|
|
75611
|
+
const quoteByte = sourceBuffer[byteIndex];
|
|
75612
|
+
if (quoteByte === SINGLE_QUOTE_UTF8_BYTE || quoteByte === DOUBLE_QUOTE_UTF8_BYTE) {
|
|
75613
|
+
const valueStartByte = byteIndex + 1;
|
|
75614
|
+
byteIndex = valueStartByte;
|
|
75615
|
+
while (byteIndex < tagEndByte && sourceBuffer[byteIndex] !== quoteByte) byteIndex++;
|
|
75616
|
+
attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
|
|
75617
|
+
if (byteIndex < tagEndByte) byteIndex++;
|
|
75618
|
+
} else {
|
|
75619
|
+
const valueStartByte = byteIndex;
|
|
75620
|
+
while (byteIndex < tagEndByte && !isHtmlWhitespace(sourceBuffer[byteIndex]) && sourceBuffer[byteIndex] !== TAG_CLOSE_UTF8_BYTE) byteIndex++;
|
|
75621
|
+
attributeValue = sourceBuffer.subarray(valueStartByte, byteIndex).toString("utf8");
|
|
75622
|
+
}
|
|
75623
|
+
}
|
|
75624
|
+
if (attributeName === "src") hasSource = true;
|
|
75625
|
+
else if (attributeName === "type" && scriptType === null) scriptType = attributeValue;
|
|
75626
|
+
else if (attributeName === "language" && language === null) language = attributeValue;
|
|
75627
|
+
}
|
|
75628
|
+
return {
|
|
75629
|
+
hasSource,
|
|
75630
|
+
language,
|
|
75631
|
+
type: scriptType
|
|
75632
|
+
};
|
|
75633
|
+
};
|
|
75634
|
+
const isExecutableScript = (attributes) => {
|
|
75635
|
+
if (attributes.hasSource) return false;
|
|
75636
|
+
const type = attributes.type?.trim().toLowerCase() ?? "";
|
|
75637
|
+
if (type !== "") {
|
|
75638
|
+
const mimeType = type.split(";")[0]?.trim() ?? "";
|
|
75639
|
+
return mimeType === "module" || JAVASCRIPT_MIME_TYPES.has(mimeType);
|
|
75640
|
+
}
|
|
75641
|
+
const language = attributes.language?.trim().toLowerCase() ?? "";
|
|
75642
|
+
return language === "" || JAVASCRIPT_MIME_TYPES.has(`text/${language}`);
|
|
75643
|
+
};
|
|
75644
|
+
const findElementClose = (sourceBuffer, startByte, tagName) => {
|
|
75645
|
+
const closeTagStart = `</${tagName}`;
|
|
75646
|
+
for (let byteIndex = startByte; byteIndex < sourceBuffer.length; byteIndex++) if (sourceBuffer[byteIndex] === TAG_OPEN_UTF8_BYTE && matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, closeTagStart) && isTagBoundary(sourceBuffer[byteIndex + closeTagStart.length])) return byteIndex;
|
|
75647
|
+
return sourceBuffer.length;
|
|
75648
|
+
};
|
|
75649
|
+
const prepareHtmlScriptSource = (sourceBuffer) => {
|
|
75650
|
+
const frontmatterEndByte = findFrontmatterEnd(sourceBuffer);
|
|
75651
|
+
let maskedBuffer = frontmatterEndByte > 0 ? Buffer.from(sourceBuffer) : null;
|
|
75652
|
+
if (maskedBuffer !== null) maskByteRange(maskedBuffer, 0, frontmatterEndByte);
|
|
75653
|
+
const executableScriptBodies = [];
|
|
75654
|
+
let byteIndex = frontmatterEndByte;
|
|
75655
|
+
let templateDepth = 0;
|
|
75656
|
+
while (byteIndex < sourceBuffer.length) {
|
|
75657
|
+
if (sourceBuffer[byteIndex] !== TAG_OPEN_UTF8_BYTE) {
|
|
75658
|
+
byteIndex++;
|
|
75659
|
+
continue;
|
|
75660
|
+
}
|
|
75661
|
+
if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, COMMENT_OPEN)) {
|
|
75662
|
+
const commentEndByte = sourceBuffer.indexOf(COMMENT_CLOSE, byteIndex + 4);
|
|
75663
|
+
byteIndex = commentEndByte === -1 ? sourceBuffer.length : commentEndByte + 3;
|
|
75664
|
+
continue;
|
|
75665
|
+
}
|
|
75666
|
+
if (matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, TEMPLATE_CLOSE) && isTagBoundary(sourceBuffer[byteIndex + TEMPLATE_CLOSE.length])) {
|
|
75667
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + TEMPLATE_CLOSE.length);
|
|
75668
|
+
if (templateDepth > 0) templateDepth--;
|
|
75669
|
+
byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
|
|
75670
|
+
continue;
|
|
75671
|
+
}
|
|
75672
|
+
if (!matchesAsciiCaseInsensitive(sourceBuffer, byteIndex, SCRIPT_OPEN) || !isTagBoundary(sourceBuffer[byteIndex + SCRIPT_OPEN.length])) {
|
|
75673
|
+
if (!isPotentialTagStart(sourceBuffer[byteIndex + 1])) {
|
|
75674
|
+
byteIndex++;
|
|
75675
|
+
continue;
|
|
75676
|
+
}
|
|
75677
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + 1);
|
|
75678
|
+
const tagName = readStartTagName(sourceBuffer, byteIndex);
|
|
75679
|
+
if (tagName === PLAINTEXT_TAG_NAME) break;
|
|
75680
|
+
if (tagName === TEMPLATE_TAG_NAME) templateDepth++;
|
|
75681
|
+
if (tagName !== null && RAW_TEXT_TAG_NAMES.has(tagName)) {
|
|
75682
|
+
const closeTagStartByte = findElementClose(sourceBuffer, tagEndByte + 1, tagName);
|
|
75683
|
+
if (closeTagStartByte === sourceBuffer.length) break;
|
|
75684
|
+
const closeTagEndByte = findTagEnd(sourceBuffer, closeTagStartByte + tagName.length + 2);
|
|
75685
|
+
byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
|
|
75686
|
+
continue;
|
|
75687
|
+
}
|
|
75688
|
+
byteIndex = Math.min(tagEndByte + 1, sourceBuffer.length);
|
|
75689
|
+
continue;
|
|
75690
|
+
}
|
|
75691
|
+
const tagEndByte = findTagEnd(sourceBuffer, byteIndex + SCRIPT_OPEN.length);
|
|
75692
|
+
if (tagEndByte === sourceBuffer.length) break;
|
|
75693
|
+
const bodyStartByte = tagEndByte + 1;
|
|
75694
|
+
const bodyEndByte = findElementClose(sourceBuffer, bodyStartByte, SCRIPT_TAG_NAME);
|
|
75695
|
+
const attributes = parseScriptAttributes(sourceBuffer, byteIndex + SCRIPT_OPEN.length, tagEndByte);
|
|
75696
|
+
if (attributes.hasSource || templateDepth > 0) {
|
|
75697
|
+
maskedBuffer ??= Buffer.from(sourceBuffer);
|
|
75698
|
+
maskByteRange(maskedBuffer, bodyStartByte, bodyEndByte);
|
|
75699
|
+
} else if (isExecutableScript(attributes)) executableScriptBodies.push(sourceBuffer.subarray(bodyStartByte, bodyEndByte));
|
|
75700
|
+
if (bodyEndByte === sourceBuffer.length) break;
|
|
75701
|
+
const closeTagEndByte = findTagEnd(sourceBuffer, bodyEndByte + SCRIPT_CLOSE.length);
|
|
75702
|
+
byteIndex = Math.min(closeTagEndByte + 1, sourceBuffer.length);
|
|
75703
|
+
}
|
|
75704
|
+
return {
|
|
75705
|
+
executableScriptBodies,
|
|
75706
|
+
lintBuffer: maskedBuffer ?? sourceBuffer
|
|
75707
|
+
};
|
|
75708
|
+
};
|
|
75709
|
+
const prepareHtmlLintSources = (rootDirectory, temporaryDirectory, candidateFiles) => {
|
|
75710
|
+
const lintFiles = [];
|
|
75711
|
+
const sourcePathByLintPath = /* @__PURE__ */ new Map();
|
|
75712
|
+
const sizeByLintPath = /* @__PURE__ */ new Map();
|
|
75713
|
+
const htmlSourcesDirectory = Path.join(temporaryDirectory, "html-sources");
|
|
75714
|
+
let htmlFileIndex = 0;
|
|
75715
|
+
let hasThreeModuleImport = false;
|
|
75716
|
+
for (const candidateFile of candidateFiles) {
|
|
75717
|
+
if (!HTML_FILE_PATTERN.test(candidateFile)) {
|
|
75718
|
+
lintFiles.push(candidateFile);
|
|
75719
|
+
continue;
|
|
75720
|
+
}
|
|
75721
|
+
const absoluteSourcePath = Path.isAbsolute(candidateFile) ? candidateFile : Path.resolve(rootDirectory, candidateFile);
|
|
75722
|
+
const sourceBuffer = NFS.readFileSync(absoluteSourcePath);
|
|
75723
|
+
const { executableScriptBodies, lintBuffer } = prepareHtmlScriptSource(sourceBuffer);
|
|
75724
|
+
if (htmlFileIndex === 0) NFS.mkdirSync(htmlSourcesDirectory, { recursive: true });
|
|
75725
|
+
const lintPath = Path.join(htmlSourcesDirectory, `${htmlFileIndex}.astro`);
|
|
75726
|
+
NFS.writeFileSync(lintPath, lintBuffer);
|
|
75727
|
+
lintFiles.push(lintPath);
|
|
75728
|
+
sourcePathByLintPath.set(Path.resolve(lintPath), candidateFile);
|
|
75729
|
+
sizeByLintPath.set(lintPath, sourceBuffer.length);
|
|
75730
|
+
hasThreeModuleImport ||= executableScriptBodies.some((scriptBody) => containsThreeModuleImport(scriptBody.toString("utf8")));
|
|
75731
|
+
htmlFileIndex++;
|
|
75732
|
+
}
|
|
75733
|
+
return {
|
|
75734
|
+
lintFiles,
|
|
75735
|
+
sourcePathByLintPath,
|
|
75736
|
+
sizeByLintPath,
|
|
75737
|
+
hasThreeModuleImport
|
|
75738
|
+
};
|
|
75739
|
+
};
|
|
75072
75740
|
/**
|
|
75073
75741
|
* Atomically (re)writes the generated oxlintrc.json. Used twice in
|
|
75074
75742
|
* the runner: once for the primary scan, once for the
|
|
@@ -75229,6 +75897,8 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
75229
75897
|
const runOxlint = async (options) => {
|
|
75230
75898
|
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
|
|
75231
75899
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
75900
|
+
const runtimeGlobals = Array.isArray(userConfig?.runtimeGlobals) ? userConfig.runtimeGlobals.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
75901
|
+
let unpluginAutoImportGlobalScopes = [];
|
|
75232
75902
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
75233
75903
|
validateRuleRegistration();
|
|
75234
75904
|
resetManifestCaches();
|
|
@@ -75242,21 +75912,6 @@ const runOxlint = async (options) => {
|
|
|
75242
75912
|
const pluginPath = resolvePluginPath();
|
|
75243
75913
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
75244
75914
|
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
75245
|
-
const buildConfig = (overrides) => createOxlintConfig({
|
|
75246
|
-
pluginPath,
|
|
75247
|
-
project,
|
|
75248
|
-
customRulesOnly,
|
|
75249
|
-
extendsPaths: overrides.extendsPaths,
|
|
75250
|
-
ignoredTags,
|
|
75251
|
-
includedTags,
|
|
75252
|
-
includeTagDefaults,
|
|
75253
|
-
serverAuthFunctionNames,
|
|
75254
|
-
severityControls,
|
|
75255
|
-
userPlugins,
|
|
75256
|
-
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
|
|
75257
|
-
ruleSelection: overrides.ruleSelection,
|
|
75258
|
-
sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
|
|
75259
|
-
});
|
|
75260
75915
|
const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
|
|
75261
75916
|
const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
75262
75917
|
const configPath = Path.join(configDirectory, "oxlintrc.json");
|
|
@@ -75292,7 +75947,36 @@ const runOxlint = async (options) => {
|
|
|
75292
75947
|
await yieldToEventLoop();
|
|
75293
75948
|
const sizedScanFiles = includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null;
|
|
75294
75949
|
const candidateFiles = includePaths !== void 0 ? includePaths : (sizedScanFiles ?? []).map((entry) => entry.path);
|
|
75950
|
+
unpluginAutoImportGlobalScopes = collectUnpluginAutoImportGlobalScopes({
|
|
75951
|
+
rootDirectory,
|
|
75952
|
+
candidateFiles
|
|
75953
|
+
});
|
|
75954
|
+
const preparedHtmlSources = prepareHtmlLintSources(rootDirectory, configDirectory, candidateFiles);
|
|
75955
|
+
const lintFiles = preparedHtmlSources.lintFiles;
|
|
75956
|
+
const hasHtmlFiles = preparedHtmlSources.sourcePathByLintPath.size > 0;
|
|
75957
|
+
const lintProject = !project.hasThree && preparedHtmlSources.hasThreeModuleImport ? {
|
|
75958
|
+
...project,
|
|
75959
|
+
hasThree: true
|
|
75960
|
+
} : project;
|
|
75961
|
+
const buildConfig = (overrides) => createOxlintConfig({
|
|
75962
|
+
pluginPath,
|
|
75963
|
+
project: lintProject,
|
|
75964
|
+
customRulesOnly,
|
|
75965
|
+
extendsPaths: overrides.extendsPaths,
|
|
75966
|
+
ignoredTags,
|
|
75967
|
+
includedTags,
|
|
75968
|
+
includeTagDefaults,
|
|
75969
|
+
runtimeGlobals,
|
|
75970
|
+
unpluginAutoImportGlobalScopes,
|
|
75971
|
+
serverAuthFunctionNames,
|
|
75972
|
+
severityControls,
|
|
75973
|
+
userPlugins,
|
|
75974
|
+
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin,
|
|
75975
|
+
ruleSelection: overrides.ruleSelection,
|
|
75976
|
+
sidecarRuleIdFilter: overrides.sidecarRuleIdFilter
|
|
75977
|
+
});
|
|
75295
75978
|
const sizeByFile = sizedScanFiles !== null && lintBatchOrdering === "cost" ? new Map(sizedScanFiles.map((entry) => [entry.path, entry.sizeBytes])) : null;
|
|
75979
|
+
if (sizeByFile !== null) for (const [lintPath, sizeBytes] of preparedHtmlSources.sizeByLintPath) sizeByFile.set(lintPath, sizeBytes);
|
|
75296
75980
|
const buildFileBatches = (passBaseArgs, passFiles) => sizeByFile !== null ? planLintBatches({
|
|
75297
75981
|
baseArgs: passBaseArgs,
|
|
75298
75982
|
files: passFiles,
|
|
@@ -75321,7 +76005,8 @@ const runOxlint = async (options) => {
|
|
|
75321
76005
|
fileBatches: passFileBatches,
|
|
75322
76006
|
rootDirectory,
|
|
75323
76007
|
nodeBinaryPath,
|
|
75324
|
-
project,
|
|
76008
|
+
project: lintProject,
|
|
76009
|
+
sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
|
|
75325
76010
|
onPartialFailure: reportPartialFailure,
|
|
75326
76011
|
onAnalyzedFiles: (filePaths) => {
|
|
75327
76012
|
analyzedFiles = filePaths;
|
|
@@ -75356,7 +76041,7 @@ const runOxlint = async (options) => {
|
|
|
75356
76041
|
};
|
|
75357
76042
|
}
|
|
75358
76043
|
};
|
|
75359
|
-
if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0) {
|
|
76044
|
+
if (perFileLintCacheEnabled && !project.hasReactCompiler && project.hasReactCompilerLintPlugin !== true && extendsPaths.length === 0 && userPlugins.length === 0 && !hasHtmlFiles) {
|
|
75360
76045
|
const rulesetHash = computeRulesetHash({
|
|
75361
76046
|
config: buildConfig({
|
|
75362
76047
|
extendsPaths: [],
|
|
@@ -75514,14 +76199,15 @@ const runOxlint = async (options) => {
|
|
|
75514
76199
|
]);
|
|
75515
76200
|
}
|
|
75516
76201
|
const baseArgs = makeBaseArgs(configPath);
|
|
75517
|
-
const fileBatches = buildFileBatches(baseArgs,
|
|
76202
|
+
const fileBatches = buildFileBatches(baseArgs, lintFiles);
|
|
75518
76203
|
let analyzedFiles = [];
|
|
75519
76204
|
const runBatches = () => spawnLintBatches({
|
|
75520
76205
|
baseArgs,
|
|
75521
76206
|
fileBatches,
|
|
75522
76207
|
rootDirectory,
|
|
75523
76208
|
nodeBinaryPath,
|
|
75524
|
-
project,
|
|
76209
|
+
project: lintProject,
|
|
76210
|
+
sourcePathByLintPath: preparedHtmlSources.sourcePathByLintPath,
|
|
75525
76211
|
onPartialFailure,
|
|
75526
76212
|
onAnalyzedFiles: (filePaths) => {
|
|
75527
76213
|
analyzedFiles = filePaths;
|
|
@@ -77728,7 +78414,7 @@ const makeNoopConsole = () => ({
|
|
|
77728
78414
|
});
|
|
77729
78415
|
//#endregion
|
|
77730
78416
|
//#region src/cli/utils/version.ts
|
|
77731
|
-
const VERSION = "0.9.1-dev.
|
|
78417
|
+
const VERSION = "0.9.1-dev.6904ff1";
|
|
77732
78418
|
//#endregion
|
|
77733
78419
|
//#region src/cli/utils/json-mode.ts
|
|
77734
78420
|
let context = null;
|
|
@@ -78086,13 +78772,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
78086
78772
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
78087
78773
|
* standard `SENTRY_RELEASE` override.
|
|
78088
78774
|
*/
|
|
78089
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.9.1-dev.
|
|
78775
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.9.1-dev.6904ff1`;
|
|
78090
78776
|
/**
|
|
78091
78777
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
78092
78778
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
78093
78779
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
78094
78780
|
*/
|
|
78095
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.9.1-dev.
|
|
78781
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.9.1-dev.6904ff1") ? "development" : "production");
|
|
78096
78782
|
/**
|
|
78097
78783
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
78098
78784
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -90757,6 +91443,7 @@ const buildScanAttributes = (input) => {
|
|
|
90757
91443
|
rulesDisabled: ruleKeys.filter((key) => ruleOverrides[key] === "off").length,
|
|
90758
91444
|
fileCount: input.result?.scannedFileCount ?? null,
|
|
90759
91445
|
nonJsxFileCount: input.result?.analyzedFiles?.filter((filePath) => !JSX_FILE_PATTERN.test(filePath)).length ?? null,
|
|
91446
|
+
htmlFileCount: input.result?.analyzedFiles?.filter((filePath) => HTML_FILE_PATTERN.test(filePath)).length ?? null,
|
|
90760
91447
|
multilineDiagnosticCount: input.result?.diagnostics.filter((diagnostic) => (diagnostic.endLine ?? diagnostic.line) > diagnostic.line).length ?? null
|
|
90761
91448
|
});
|
|
90762
91449
|
};
|
|
@@ -96810,7 +97497,7 @@ ${highlighter.dim("Learn more:")}
|
|
|
96810
97497
|
${highlighter.info(CI_URL)}
|
|
96811
97498
|
`;
|
|
96812
97499
|
const collectCategoryOption = (value, previousValues) => [...previousValues ?? [], value];
|
|
96813
|
-
const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--supply-chain", "enable the dependency supply-chain scan (default)").option("--no-supply-chain", "skip the dependency supply-chain scan (Socket.dev dependency health checks)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--debug", "force a Sentry trace and print its id at the end (paste it into a bug report)").option("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("--json-out <path>", "with --json, write the report to a file instead of stdout").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple); overrides the `projects` config field").option("--scope <value>", "how much supported JS/TS source to scan/report: full (default), files, changed (only new issues vs base), or lines (issues whose source spans touch changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").option("--include-untracked", "with --scope files/changed/lines, also scan ordinary untracked files (respects .gitignore)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--max-duration <seconds>", "scan time budget for the whole run, shared across workspace projects: past it, remaining lint batches and dead-code are skipped and partial results are reported (skipped files are listed in the JSON report)").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
|
|
97500
|
+
const program = new Command().name("react-doctor").description("Diagnose React codebase health").version(VERSION, "-v, --version", "display the version number").argument("[directory]", "project directory to scan", ".").option("--lint", "enable linting").option("--no-lint", "skip linting").option("--dead-code", "enable dead-code analysis (default)").option("--no-dead-code", "skip dead-code analysis (unused files / exports / dependencies, circular imports)").option("--supply-chain", "enable the dependency supply-chain scan (default)").option("--no-supply-chain", "skip the dependency supply-chain scan (Socket.dev dependency health checks)").option("--verbose", "show every rule and per-file details (default shows top 3 rules)").option("--debug", "force a Sentry trace and print its id at the end (paste it into a bug report)").option("--output-dir <dir>", "directory for the full diagnostics dump (default: a temp folder)").option("--score", "output only the score").option("--json", "output a single structured JSON report (suppresses other output)").option("--json-compact", "with --json, emit compact JSON (no indentation)").option("--json-out <path>", "with --json, write the report to a file instead of stdout").option("-y, --yes", "skip prompts, scan all workspace projects").option("--no-parallel", "lint serially with one worker (default: parallel across CPU cores; set the worker count with REACT_DOCTOR_PARALLEL)").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple); overrides the `projects` config field").option("--scope <value>", "how much supported JS/TS and inline HTML script source to scan/report: full (default), files, changed (only new issues vs base), or lines (issues whose source spans touch changed lines)").option("--base <ref>", "base git ref for files/changed/lines scope (auto-detected when omitted)").option("--include-untracked", "with --scope files/changed/lines, also scan ordinary untracked files (respects .gitignore)").addOption(new Option("--diff [base]", "[deprecated] alias for --scope changed (pass `false` to force a full scan)").hideHelp()).addOption(new Option("--changed-files-from <file>", "scan source files listed in a newline-delimited changed-files file").hideHelp()).option("--no-score", "skip the score API, the share URL, and crash reporting").addOption(new Option("--category <category>", "only show diagnostics in a category (repeatable; e.g. Security)").argParser(collectCategoryOption)).option("--no-telemetry", "alias for --no-score (skip the score API, share URL, and crash reporting)").option("--staged", "scan only staged (git index) files for pre-commit hooks").option("--max-duration <seconds>", "scan time budget for the whole run, shared across workspace projects: past it, remaining lint batches and dead-code are skipped and partial results are reported (skipped files are listed in the JSON report)").option("--blocking <level>", "severity that fails CI: error (default), warning, or none (advisory)").addOption(new Option("--fail-on <level>", "[deprecated] alias for --blocking <level>").hideHelp()).option("--no-respect-inline-disables", "audit mode: neutralize inline lint suppressions before scanning").option("--warnings", "show warning-severity diagnostics (default)").option("--no-warnings", "hide warning-severity diagnostics (errors only)").option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").addHelpText("after", renderRootHelpEpilog);
|
|
96814
97501
|
program.action(inspectAction);
|
|
96815
97502
|
program.command("design [directory]").description("Run only the focused UI design diagnostics").addHelpText("after", renderDesignHelpEpilog).action((directory, _options, command) => designAction(directory ?? ".", command.optsWithGlobals()));
|
|
96816
97503
|
program.command("why <location>").description("Explain why a rule fired (or why a suppression didn't apply) at a file:line").option("--project <name>", "select projects: workspace names or directory paths (comma-separated for multiple)").option("-c, --cwd <cwd>", "working directory", process.cwd()).option("--color", "force colored output").option("--no-color", "disable colored output (also honors NO_COLOR)").action((location, options) => whyAction(location, options));
|
|
@@ -96890,4 +97577,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
96890
97577
|
export { toForwardSlashes as A, highlighter as B, buildRulePriorityMap as C, resolveBlockingLevel as D, formatLearnMoreLine as E, isCiEnvironment as F, sync as G, mergeReactDoctorConfigs as H, DIAGNOSTIC_CATEGORY_BUCKETS as I, void_ as K, Progress as L, isUnicodeSupported as M, METRIC as N, isReactDoctorWorkflowInstalled as O, TUI_REPORT_DETAIL_WIDTH_FRACTION as P, Reporter as R, hasLintHardFailure as S, formatFixRecipeLine as T, resolveScanTarget as U, mapWithConcurrency as V, runPromise as W, canAnimateOnboarding as _, resolveCliInspectOptions as a, buildCodeFrame as b, detectLaunchableAgents as c, launchCliAgent as d, isShareOptedOut as f, doctorFace as g, easeOutCubic as h, selectProjects as i, findNearestPackageDirectory as j, recordCount as k, CLI_AGENT_BINARIES as l, printFooter as m, shouldFailScanGate as n, countUniqueScannedFiles as o, inspect as p, succeed$3 as q, discoverWorkspacePackages as r, setUpGitHubActions as s, exitGracefully as t, copyToClipboard as u, computeProjectedScore as v, buildSortedRuleGroups as w, buildNoScoreMessage as x, formatElapsedTime as y, getCategoryImpact as z };
|
|
96891
97578
|
|
|
96892
97579
|
//# sourceMappingURL=cli.js.map
|
|
96893
|
-
//# debugId=
|
|
97580
|
+
//# debugId=f34e66dd-4b16-53f5-a3af-9844fbc71772
|