react-doctor 0.9.1-dev.8534d86 → 0.9.1-dev.b1b62db
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +279 -19
- package/dist/index.js +275 -15
- package/dist/lsp.js +275 -15
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e6d636d4-ff95-5229-92f8-47807b2a44c4")}catch(e){}}();
|
|
3
3
|
import { i as __toESM$1, r as __require, t as __commonJSMin$1 } from "./chunk-ChKA3wi6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
|
|
@@ -62289,7 +62289,7 @@ const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json")
|
|
|
62289
62289
|
const getStaticPropertyName$2 = (propertyName) => ts.isIdentifier(propertyName) || ts.isStringLiteralLike(propertyName) ? propertyName.text : ts.isComputedPropertyName(propertyName) && ts.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
|
|
62290
62290
|
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");
|
|
62291
62291
|
const hasExportModifier = (node) => ts.canHaveModifiers(node) && Boolean(ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
|
|
62292
|
-
const getRequireModuleSpecifier = (expression) => {
|
|
62292
|
+
const getRequireModuleSpecifier$1 = (expression) => {
|
|
62293
62293
|
if (!ts.isCallExpression(expression) || !ts.isIdentifier(expression.expression) || expression.expression.text !== "require" || expression.arguments.length !== 1) return null;
|
|
62294
62294
|
const moduleSpecifier = expression.arguments[0];
|
|
62295
62295
|
return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
@@ -62333,21 +62333,21 @@ const getImportBinding = (sourceFile, bindingName) => {
|
|
|
62333
62333
|
for (const declaration of statement.declarationList.declarations) {
|
|
62334
62334
|
if (!declaration.initializer) continue;
|
|
62335
62335
|
if (ts.isIdentifier(declaration.name) && declaration.name.text === bindingName) {
|
|
62336
|
-
const directModuleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
62336
|
+
const directModuleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
|
|
62337
62337
|
if (directModuleSpecifier) return {
|
|
62338
62338
|
moduleSpecifier: directModuleSpecifier,
|
|
62339
62339
|
exportName: "default",
|
|
62340
62340
|
isNamespace: true
|
|
62341
62341
|
};
|
|
62342
|
-
if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier(declaration.initializer.expression) !== null) return {
|
|
62343
|
-
moduleSpecifier: getRequireModuleSpecifier(declaration.initializer.expression) ?? "",
|
|
62342
|
+
if (ts.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier$1(declaration.initializer.expression) !== null) return {
|
|
62343
|
+
moduleSpecifier: getRequireModuleSpecifier$1(declaration.initializer.expression) ?? "",
|
|
62344
62344
|
exportName: declaration.initializer.name.text,
|
|
62345
62345
|
isNamespace: false
|
|
62346
62346
|
};
|
|
62347
62347
|
}
|
|
62348
62348
|
if (!ts.isObjectBindingPattern(declaration.name)) continue;
|
|
62349
62349
|
const bindingElement = declaration.name.elements.find((element) => ts.isIdentifier(element.name) && element.name.text === bindingName);
|
|
62350
|
-
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
62350
|
+
const moduleSpecifier = getRequireModuleSpecifier$1(declaration.initializer);
|
|
62351
62351
|
if (bindingElement && moduleSpecifier) return {
|
|
62352
62352
|
moduleSpecifier,
|
|
62353
62353
|
exportName: bindingElement.propertyName ? getStaticPropertyName$2(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
|
|
@@ -62718,7 +62718,7 @@ const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransfor
|
|
|
62718
62718
|
if (!ts.isPropertyAccessExpression(target) && !ts.isElementAccessExpression(target)) return null;
|
|
62719
62719
|
const propertyName = ts.isPropertyAccessExpression(target) ? target.name.text : target.argumentExpression && ts.isStringLiteralLike(target.argumentExpression) ? target.argumentExpression.text : null;
|
|
62720
62720
|
if (propertyName === null) return null;
|
|
62721
|
-
const requiredModuleSpecifier = getRequireModuleSpecifier(target.expression);
|
|
62721
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(target.expression);
|
|
62722
62722
|
if (requiredModuleSpecifier !== null) {
|
|
62723
62723
|
if (ts.isCallExpression(target.expression) && ts.isIdentifier(target.expression.expression) && (getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
62724
62724
|
if (!requiredModuleSpecifier.startsWith(".")) return null;
|
|
@@ -62780,7 +62780,7 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62780
62780
|
if (ts.isCallExpression(node)) {
|
|
62781
62781
|
const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
|
|
62782
62782
|
if (callTargetResult !== null) return callTargetResult;
|
|
62783
|
-
const directModuleSpecifier = getRequireModuleSpecifier(node);
|
|
62783
|
+
const directModuleSpecifier = getRequireModuleSpecifier$1(node);
|
|
62784
62784
|
const isRequireShadowed = analysis.localBindings.has("require") || ts.isIdentifier(node.expression) && getScopedConfigBinding(node.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require");
|
|
62785
62785
|
if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
|
|
62786
62786
|
if (directModuleSpecifier && !isRequireShadowed) {
|
|
@@ -62802,7 +62802,7 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
62802
62802
|
return analyzeConfigNode(node.expression, analysis, allowCompilerTransform) || node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false));
|
|
62803
62803
|
}
|
|
62804
62804
|
if (ts.isPropertyAccessExpression(node)) {
|
|
62805
|
-
const requiredModuleSpecifier = getRequireModuleSpecifier(node.expression);
|
|
62805
|
+
const requiredModuleSpecifier = getRequireModuleSpecifier$1(node.expression);
|
|
62806
62806
|
if (requiredModuleSpecifier) {
|
|
62807
62807
|
if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression) && (getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
|
|
62808
62808
|
if (requiredModuleSpecifier.startsWith(".")) {
|
|
@@ -66139,7 +66139,7 @@ const warn = (message) => {
|
|
|
66139
66139
|
runSync(warn$1(message));
|
|
66140
66140
|
};
|
|
66141
66141
|
const CONFIG_BASENAME = "doctor.config";
|
|
66142
|
-
const CONFIG_EXTENSIONS = [
|
|
66142
|
+
const CONFIG_EXTENSIONS$1 = [
|
|
66143
66143
|
"ts",
|
|
66144
66144
|
"mts",
|
|
66145
66145
|
"cts",
|
|
@@ -66243,7 +66243,7 @@ const loadLegacyConfig = (directory) => {
|
|
|
66243
66243
|
};
|
|
66244
66244
|
const loadConfigFromDirectory = async (directory) => {
|
|
66245
66245
|
let sawBrokenConfigFile = false;
|
|
66246
|
-
for (const extension of CONFIG_EXTENSIONS) {
|
|
66246
|
+
for (const extension of CONFIG_EXTENSIONS$1) {
|
|
66247
66247
|
const filePath = Path.join(directory, `${CONFIG_BASENAME}.${extension}`);
|
|
66248
66248
|
if (!isFile(filePath)) continue;
|
|
66249
66249
|
const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
|
|
@@ -70050,7 +70050,11 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
70050
70050
|
const ROOT_DIRECTORY_PLACEHOLDER = "<root>";
|
|
70051
70051
|
const normalizeConfigForHash = (config) => {
|
|
70052
70052
|
const clone = JSON.parse(JSON.stringify(config));
|
|
70053
|
-
if (clone?.settings?.["react-doctor"])
|
|
70053
|
+
if (clone?.settings?.["react-doctor"]) {
|
|
70054
|
+
const reactDoctorSettings = clone.settings["react-doctor"];
|
|
70055
|
+
reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
|
|
70056
|
+
if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
|
|
70057
|
+
}
|
|
70054
70058
|
if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
|
|
70055
70059
|
return clone;
|
|
70056
70060
|
};
|
|
@@ -70209,13 +70213,14 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
70209
70213
|
}
|
|
70210
70214
|
return enabled;
|
|
70211
70215
|
};
|
|
70212
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
70216
|
+
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 }) => {
|
|
70213
70217
|
const hasIncludedTags = includedTags.size > 0;
|
|
70214
70218
|
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
70215
70219
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
70216
70220
|
const jsPlugins = [];
|
|
70217
70221
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
70218
70222
|
const capabilities = getCapabilities(project);
|
|
70223
|
+
const settingsRootDirectory = resolveSettingsRootDirectory(project.rootDirectory);
|
|
70219
70224
|
const enabledReactDoctorRules = {};
|
|
70220
70225
|
for (const registryEntry of REACT_DOCTOR_RULES) {
|
|
70221
70226
|
const rule = reactDoctorPlugin.rules[registryEntry.id];
|
|
@@ -70261,8 +70266,16 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
70261
70266
|
jsPlugins: [...jsPlugins, pluginPath],
|
|
70262
70267
|
settings: { "react-doctor": {
|
|
70263
70268
|
framework: project.framework,
|
|
70264
|
-
rootDirectory:
|
|
70269
|
+
rootDirectory: settingsRootDirectory,
|
|
70265
70270
|
capabilities: [...capabilities].sort(),
|
|
70271
|
+
...runtimeGlobals && runtimeGlobals.length > 0 ? { runtimeGlobals: [...runtimeGlobals] } : {},
|
|
70272
|
+
...unpluginAutoImportGlobalScopes && unpluginAutoImportGlobalScopes.length > 0 ? {
|
|
70273
|
+
unpluginAutoImportRootDirectories: [...new Set([settingsRootDirectory, project.rootDirectory])],
|
|
70274
|
+
unpluginAutoImportGlobalScopes: unpluginAutoImportGlobalScopes.map((scope) => ({
|
|
70275
|
+
directory: scope.directory,
|
|
70276
|
+
names: [...scope.names]
|
|
70277
|
+
}))
|
|
70278
|
+
} : {},
|
|
70266
70279
|
...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
|
|
70267
70280
|
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
70268
70281
|
} },
|
|
@@ -70273,6 +70286,245 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
70273
70286
|
}
|
|
70274
70287
|
};
|
|
70275
70288
|
};
|
|
70289
|
+
const AUTO_IMPORT_ADAPTER_PATTERN = /^unplugin-auto-import\/(?:astro|esbuild|rollup|rolldown|rspack|vite|webpack)$/;
|
|
70290
|
+
const CONFIG_BASENAMES = [
|
|
70291
|
+
"astro.config",
|
|
70292
|
+
"esbuild.config",
|
|
70293
|
+
"rollup.config",
|
|
70294
|
+
"rolldown.config",
|
|
70295
|
+
"rspack.config",
|
|
70296
|
+
"vite.config",
|
|
70297
|
+
"webpack.config"
|
|
70298
|
+
];
|
|
70299
|
+
const CONFIG_EXTENSIONS = [
|
|
70300
|
+
".cjs",
|
|
70301
|
+
".cts",
|
|
70302
|
+
".js",
|
|
70303
|
+
".mjs",
|
|
70304
|
+
".mts",
|
|
70305
|
+
".ts"
|
|
70306
|
+
];
|
|
70307
|
+
const CONFIG_FILENAMES = new Set(CONFIG_BASENAMES.flatMap((basename) => CONFIG_EXTENSIONS.map((extension) => `${basename}${extension}`)));
|
|
70308
|
+
const DEFAULT_ESLINT_GLOBALS_PATH = ".eslintrc-auto-import.json";
|
|
70309
|
+
const SUPPORTED_GLOBAL_VALUES = new Set([
|
|
70310
|
+
true,
|
|
70311
|
+
false,
|
|
70312
|
+
"readable",
|
|
70313
|
+
"readonly",
|
|
70314
|
+
"writable",
|
|
70315
|
+
"writeable"
|
|
70316
|
+
]);
|
|
70317
|
+
const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
|
|
70318
|
+
if (ts.isSpreadAssignment(property)) return false;
|
|
70319
|
+
const name = ts.isComputedPropertyName(property.name) ? unwrapTypescriptExpression(property.name.expression) : property.name;
|
|
70320
|
+
return (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) && name.text === propertyName;
|
|
70321
|
+
}) ?? null;
|
|
70322
|
+
const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !ts.isSpreadAssignment(property) && ts.isComputedPropertyName(property.name) && !ts.isStringLiteralLike(unwrapTypescriptExpression(property.name.expression)));
|
|
70323
|
+
const getStaticPropertyAssignment = (objectExpression, propertyName) => {
|
|
70324
|
+
const property = getStaticProperty(objectExpression, propertyName);
|
|
70325
|
+
return property && ts.isPropertyAssignment(property) ? property : null;
|
|
70326
|
+
};
|
|
70327
|
+
const getRequireModuleSpecifier = (expression) => {
|
|
70328
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
70329
|
+
if (ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "default") return getRequireModuleSpecifier(unwrappedExpression.expression);
|
|
70330
|
+
if (!ts.isCallExpression(unwrappedExpression) || !ts.isIdentifier(unwrappedExpression.expression) || unwrappedExpression.expression.text !== "require" || unwrappedExpression.arguments.length !== 1) return null;
|
|
70331
|
+
const moduleSpecifier = unwrappedExpression.arguments[0];
|
|
70332
|
+
return moduleSpecifier && ts.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
70333
|
+
};
|
|
70334
|
+
const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
|
|
70335
|
+
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
70336
|
+
return ts.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
|
|
70337
|
+
};
|
|
70338
|
+
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");
|
|
70339
|
+
const isTopLevelExpression = (node) => {
|
|
70340
|
+
let ancestor = node.parent;
|
|
70341
|
+
while (ancestor && !ts.isSourceFile(ancestor)) {
|
|
70342
|
+
if (ts.isExpressionStatement(ancestor)) return ts.isSourceFile(ancestor.parent);
|
|
70343
|
+
if (!ts.isParenthesizedExpression(ancestor) && !ts.isAsExpression(ancestor) && !ts.isSatisfiesExpression(ancestor) && !ts.isNonNullExpression(ancestor) && !ts.isTypeAssertionExpression(ancestor) && !ts.isAwaitExpression(ancestor)) return false;
|
|
70344
|
+
ancestor = ancestor.parent;
|
|
70345
|
+
}
|
|
70346
|
+
return false;
|
|
70347
|
+
};
|
|
70348
|
+
const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
|
|
70349
|
+
let ancestor = node.parent;
|
|
70350
|
+
let didFindConfigProperty = false;
|
|
70351
|
+
while (ancestor && !ts.isSourceFile(ancestor)) {
|
|
70352
|
+
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;
|
|
70353
|
+
if (ts.isPropertyAssignment(ancestor)) {
|
|
70354
|
+
const isConfigProperty = (ts.isIdentifier(ancestor.name) || ts.isStringLiteralLike(ancestor.name)) && ancestor.name.text === propertyName;
|
|
70355
|
+
if (didFindConfigProperty || !isConfigProperty) return false;
|
|
70356
|
+
if (!ts.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(ts.isSpreadAssignment)) return false;
|
|
70357
|
+
didFindConfigProperty = true;
|
|
70358
|
+
ancestor = ancestor.parent;
|
|
70359
|
+
continue;
|
|
70360
|
+
}
|
|
70361
|
+
if (didFindConfigProperty) {
|
|
70362
|
+
if (ts.isExportAssignment(ancestor)) return true;
|
|
70363
|
+
if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
|
|
70364
|
+
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);
|
|
70365
|
+
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;
|
|
70366
|
+
}
|
|
70367
|
+
ancestor = ancestor.parent;
|
|
70368
|
+
}
|
|
70369
|
+
return false;
|
|
70370
|
+
};
|
|
70371
|
+
const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory) => {
|
|
70372
|
+
const optionsExpression = callExpression.arguments[0];
|
|
70373
|
+
if (!optionsExpression) return null;
|
|
70374
|
+
const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
|
|
70375
|
+
if (!ts.isObjectLiteralExpression(unwrappedOptions)) return null;
|
|
70376
|
+
if (unwrappedOptions.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
|
|
70377
|
+
if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
|
|
70378
|
+
const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
|
|
70379
|
+
if (!eslintrcProperty) return null;
|
|
70380
|
+
const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
|
|
70381
|
+
if (!ts.isObjectLiteralExpression(eslintrcExpression)) return null;
|
|
70382
|
+
if (eslintrcExpression.properties.some(ts.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
|
|
70383
|
+
const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
|
|
70384
|
+
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== ts.SyntaxKind.TrueKeyword) return null;
|
|
70385
|
+
const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
|
|
70386
|
+
if (!filepathProperty) return Path.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
|
|
70387
|
+
if (!ts.isPropertyAssignment(filepathProperty)) return null;
|
|
70388
|
+
const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
|
|
70389
|
+
return ts.isStringLiteralLike(filepathExpression) ? Path.resolve(packageDirectory, filepathExpression.text) : null;
|
|
70390
|
+
};
|
|
70391
|
+
const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
70392
|
+
let sourceText;
|
|
70393
|
+
try {
|
|
70394
|
+
sourceText = NFS.readFileSync(configPath, "utf8");
|
|
70395
|
+
} catch {
|
|
70396
|
+
return {
|
|
70397
|
+
didFindActiveAutoImport: false,
|
|
70398
|
+
globalsPaths: []
|
|
70399
|
+
};
|
|
70400
|
+
}
|
|
70401
|
+
const sourceFile = ts.createSourceFile(configPath, sourceText, ts.ScriptTarget.Latest, true);
|
|
70402
|
+
const autoImportBindings = /* @__PURE__ */ new Map();
|
|
70403
|
+
const esbuildBindings = /* @__PURE__ */ new Set();
|
|
70404
|
+
const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
|
|
70405
|
+
for (const statement of sourceFile.statements) {
|
|
70406
|
+
if (ts.isImportDeclaration(statement) && ts.isStringLiteralLike(statement.moduleSpecifier)) {
|
|
70407
|
+
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
70408
|
+
if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
70409
|
+
const defaultBinding = statement.importClause?.name;
|
|
70410
|
+
if (defaultBinding) autoImportBindings.set(defaultBinding.text, moduleSpecifier);
|
|
70411
|
+
}
|
|
70412
|
+
if (moduleSpecifier === "esbuild") {
|
|
70413
|
+
const defaultBinding = statement.importClause?.name;
|
|
70414
|
+
if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
|
|
70415
|
+
const namedBindings = statement.importClause?.namedBindings;
|
|
70416
|
+
if (namedBindings && ts.isNamedImports(namedBindings)) {
|
|
70417
|
+
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
|
|
70418
|
+
}
|
|
70419
|
+
if (namedBindings && ts.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
|
|
70420
|
+
}
|
|
70421
|
+
}
|
|
70422
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
70423
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
70424
|
+
if (!declaration.initializer) continue;
|
|
70425
|
+
const declarationName = ts.isIdentifier(declaration.name) ? declaration.name.text : null;
|
|
70426
|
+
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
70427
|
+
if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
|
|
70428
|
+
if (moduleSpecifier === "esbuild") {
|
|
70429
|
+
if (declarationName) esbuildNamespaceBindings.add(declarationName);
|
|
70430
|
+
if (ts.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
|
|
70431
|
+
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
70432
|
+
if (ts.isIdentifier(importedName) && importedName.text === "build" && ts.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
|
|
70433
|
+
}
|
|
70434
|
+
}
|
|
70435
|
+
if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
|
|
70436
|
+
}
|
|
70437
|
+
}
|
|
70438
|
+
const globalsPaths = /* @__PURE__ */ new Set();
|
|
70439
|
+
let didFindActiveAutoImport = false;
|
|
70440
|
+
let didFindUnsafeActiveAutoImport = false;
|
|
70441
|
+
const visit = (node) => {
|
|
70442
|
+
if (ts.isCallExpression(node)) {
|
|
70443
|
+
const moduleSpecifier = ts.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
|
|
70444
|
+
if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
70445
|
+
if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
|
|
70446
|
+
didFindActiveAutoImport = true;
|
|
70447
|
+
const globalsPath = getGlobalsPathFromActiveAutoImportCall(node, packageDirectory);
|
|
70448
|
+
if (globalsPath) globalsPaths.add(globalsPath);
|
|
70449
|
+
else didFindUnsafeActiveAutoImport = true;
|
|
70450
|
+
}
|
|
70451
|
+
}
|
|
70452
|
+
}
|
|
70453
|
+
ts.forEachChild(node, visit);
|
|
70454
|
+
};
|
|
70455
|
+
visit(sourceFile);
|
|
70456
|
+
return {
|
|
70457
|
+
didFindActiveAutoImport,
|
|
70458
|
+
globalsPaths: didFindUnsafeActiveAutoImport ? [] : [...globalsPaths]
|
|
70459
|
+
};
|
|
70460
|
+
};
|
|
70461
|
+
const collectGeneratedGlobalNames = (globalsPath, rootDirectory) => {
|
|
70462
|
+
const relativePath = Path.relative(rootDirectory, globalsPath);
|
|
70463
|
+
if (relativePath.startsWith("..") || Path.isAbsolute(relativePath)) return [];
|
|
70464
|
+
const parsed = failOpenReadJson(globalsPath, null);
|
|
70465
|
+
if (!isPlainObject(parsed) || !isPlainObject(parsed.globals)) return [];
|
|
70466
|
+
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();
|
|
70467
|
+
};
|
|
70468
|
+
const findOwningPackageDirectory = (absoluteFilePath, rootDirectory, cache) => {
|
|
70469
|
+
let currentDirectory = Path.dirname(absoluteFilePath);
|
|
70470
|
+
const visitedDirectories = [];
|
|
70471
|
+
while (true) {
|
|
70472
|
+
const cachedDirectory = cache.get(currentDirectory);
|
|
70473
|
+
if (cachedDirectory !== void 0) {
|
|
70474
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, cachedDirectory);
|
|
70475
|
+
return cachedDirectory;
|
|
70476
|
+
}
|
|
70477
|
+
const relativeDirectory = Path.relative(rootDirectory, currentDirectory);
|
|
70478
|
+
if (relativeDirectory.startsWith("..") || Path.isAbsolute(relativeDirectory)) {
|
|
70479
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
|
|
70480
|
+
return null;
|
|
70481
|
+
}
|
|
70482
|
+
visitedDirectories.push(currentDirectory);
|
|
70483
|
+
if (NFS.existsSync(Path.join(currentDirectory, "package.json"))) {
|
|
70484
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, currentDirectory);
|
|
70485
|
+
return currentDirectory;
|
|
70486
|
+
}
|
|
70487
|
+
if (currentDirectory === rootDirectory) {
|
|
70488
|
+
for (const visitedDirectory of visitedDirectories) cache.set(visitedDirectory, null);
|
|
70489
|
+
return null;
|
|
70490
|
+
}
|
|
70491
|
+
currentDirectory = Path.dirname(currentDirectory);
|
|
70492
|
+
}
|
|
70493
|
+
};
|
|
70494
|
+
const collectPackageGlobalNames = (packageDirectory, rootDirectory) => {
|
|
70495
|
+
let directoryEntries;
|
|
70496
|
+
try {
|
|
70497
|
+
directoryEntries = NFS.readdirSync(packageDirectory, { withFileTypes: true });
|
|
70498
|
+
} catch {
|
|
70499
|
+
return [];
|
|
70500
|
+
}
|
|
70501
|
+
const configuredGlobalsPaths = [];
|
|
70502
|
+
for (const entry of directoryEntries) {
|
|
70503
|
+
if (!entry.isFile() && !entry.isSymbolicLink() || !CONFIG_FILENAMES.has(entry.name)) continue;
|
|
70504
|
+
const configGlobalsPaths = collectGlobalsPathsFromConfig(Path.join(packageDirectory, entry.name), packageDirectory);
|
|
70505
|
+
if (configGlobalsPaths.didFindActiveAutoImport) configuredGlobalsPaths.push(configGlobalsPaths.globalsPaths.toSorted());
|
|
70506
|
+
}
|
|
70507
|
+
if (configuredGlobalsPaths.length === 0) return [];
|
|
70508
|
+
const globalsPaths = configuredGlobalsPaths[0];
|
|
70509
|
+
if (configuredGlobalsPaths.some((candidatePaths) => candidatePaths.length !== globalsPaths.length || candidatePaths.some((candidatePath, index) => candidatePath !== globalsPaths[index]))) return [];
|
|
70510
|
+
const names = /* @__PURE__ */ new Set();
|
|
70511
|
+
for (const globalsPath of globalsPaths) for (const name of collectGeneratedGlobalNames(globalsPath, rootDirectory)) names.add(name);
|
|
70512
|
+
return [...names].sort();
|
|
70513
|
+
};
|
|
70514
|
+
const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }) => {
|
|
70515
|
+
const absoluteRootDirectory = Path.resolve(rootDirectory);
|
|
70516
|
+
const packageDirectoryCache = /* @__PURE__ */ new Map();
|
|
70517
|
+
const packageDirectories = /* @__PURE__ */ new Set();
|
|
70518
|
+
for (const candidateFile of candidateFiles) {
|
|
70519
|
+
const packageDirectory = findOwningPackageDirectory(Path.resolve(absoluteRootDirectory, candidateFile), absoluteRootDirectory, packageDirectoryCache);
|
|
70520
|
+
if (packageDirectory) packageDirectories.add(packageDirectory);
|
|
70521
|
+
}
|
|
70522
|
+
const scopes = [...packageDirectories].map((packageDirectory) => ({
|
|
70523
|
+
directory: Path.relative(absoluteRootDirectory, packageDirectory).replaceAll("\\", "/"),
|
|
70524
|
+
names: collectPackageGlobalNames(packageDirectory, absoluteRootDirectory)
|
|
70525
|
+
})).sort((firstScope, secondScope) => firstScope.directory.localeCompare(secondScope.directory));
|
|
70526
|
+
return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
|
|
70527
|
+
};
|
|
70276
70528
|
const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
|
|
70277
70529
|
const decodeFileDiagnostics = (raw) => {
|
|
70278
70530
|
if (!Array.isArray(raw)) return null;
|
|
@@ -72266,6 +72518,8 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
72266
72518
|
const runOxlint = async (options) => {
|
|
72267
72519
|
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;
|
|
72268
72520
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
72521
|
+
const runtimeGlobals = Array.isArray(userConfig?.runtimeGlobals) ? userConfig.runtimeGlobals.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
72522
|
+
let unpluginAutoImportGlobalScopes = [];
|
|
72269
72523
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
72270
72524
|
validateRuleRegistration();
|
|
72271
72525
|
resetManifestCaches();
|
|
@@ -72314,6 +72568,10 @@ const runOxlint = async (options) => {
|
|
|
72314
72568
|
await yieldToEventLoop();
|
|
72315
72569
|
const sizedScanFiles = includePaths === void 0 ? listSourceFilesWithSize(rootDirectory) : null;
|
|
72316
72570
|
const candidateFiles = includePaths !== void 0 ? includePaths : (sizedScanFiles ?? []).map((entry) => entry.path);
|
|
72571
|
+
unpluginAutoImportGlobalScopes = collectUnpluginAutoImportGlobalScopes({
|
|
72572
|
+
rootDirectory,
|
|
72573
|
+
candidateFiles
|
|
72574
|
+
});
|
|
72317
72575
|
const preparedHtmlSources = prepareHtmlLintSources(rootDirectory, configDirectory, candidateFiles);
|
|
72318
72576
|
const lintFiles = preparedHtmlSources.lintFiles;
|
|
72319
72577
|
const hasHtmlFiles = preparedHtmlSources.sourcePathByLintPath.size > 0;
|
|
@@ -72329,6 +72587,8 @@ const runOxlint = async (options) => {
|
|
|
72329
72587
|
ignoredTags,
|
|
72330
72588
|
includedTags,
|
|
72331
72589
|
includeTagDefaults,
|
|
72590
|
+
runtimeGlobals,
|
|
72591
|
+
unpluginAutoImportGlobalScopes,
|
|
72332
72592
|
serverAuthFunctionNames,
|
|
72333
72593
|
severityControls,
|
|
72334
72594
|
userPlugins,
|
|
@@ -74490,4 +74750,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
74490
74750
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
74491
74751
|
|
|
74492
74752
|
//# sourceMappingURL=index.js.map
|
|
74493
|
-
//# debugId=
|
|
74753
|
+
//# debugId=e6d636d4-ff95-5229-92f8-47807b2a44c4
|