@sarj/eslint-plugin 9.13.1 → 9.14.0
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 +22 -2
- package/dist/index.cjs +1566 -658
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +1556 -648
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -13,9 +13,10 @@ var createRule = ESLintUtils.RuleCreator(examplesUrl);
|
|
|
13
13
|
var SCRIPT_FILE_RE = /([\\/]scripts[\\/])|(\.mjs$)/;
|
|
14
14
|
var STORY_FILE_RE = /\.stories\.[cm]?[jt]sx?$/i;
|
|
15
15
|
var STORY_TREE_RE = /(^|\/)stories(?:[_-][^/]*)?\//i;
|
|
16
|
-
var GENERATED_FILE_RE = /([\\/](?:generated|openapi-gen|graphql[\\/]types|vendor|vendored|third[-_]?party)[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)|(\.types\.[cm]?ts$)
|
|
16
|
+
var GENERATED_FILE_RE = /((?:^|[\\/])(?:generated|__generated__|openapi-gen|graphql[\\/]types|vendor|vendored|third[-_]?party)[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)|(\.types\.[cm]?ts$)/i;
|
|
17
17
|
var EXTERNAL_TREE_RE = /[\\/]external[\\/]/;
|
|
18
18
|
var GENERATED_MARKER_RE = /(?:@generated\b|this file (?:is|was|has been)[\w\s,'-]{0,40}?generated|auto-?generated file\b|generated (?:with|by)|generated (?:graphql )?types|do not edit(?: directly| manually)?|do not (?:modify|change) this file)/i;
|
|
19
|
+
var COMMENT_LINE_RE = /^\s*(?:\/\/|\/\*+|\*|#)/;
|
|
19
20
|
var TEST_BASENAME_RE = /[.\-_](test|spec|e2e)\.[cm]?[jt]sx?$/;
|
|
20
21
|
var TEST_INTEGRATION_BASENAME_RE = /\.integration\.[cm]?[jt]sx?$/;
|
|
21
22
|
var TEST_DIR_RE = /(^|\/)(tests?|__tests__|__mocks__|fixtures|__fixtures__|__testfixtures__|e2e|integration)\//;
|
|
@@ -46,7 +47,7 @@ function isGeneratedFile(filename, sourceText = "", gates = []) {
|
|
|
46
47
|
if (gates.includes("externalTree") && EXTERNAL_TREE_RE.test(normalized)) {
|
|
47
48
|
return true;
|
|
48
49
|
}
|
|
49
|
-
return
|
|
50
|
+
return sourceText.slice(0, 2048).split("\n").some((line) => COMMENT_LINE_RE.test(line) && GENERATED_MARKER_RE.test(line));
|
|
50
51
|
}
|
|
51
52
|
function isScriptFile(filename) {
|
|
52
53
|
return SCRIPT_FILE_RE.test(filename);
|
|
@@ -3141,6 +3142,202 @@ var no_long_comment_default = createRule({
|
|
|
3141
3142
|
}
|
|
3142
3143
|
});
|
|
3143
3144
|
|
|
3145
|
+
// src/rules/no-generic-single-export-module.ts
|
|
3146
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14, ASTUtils as ASTUtils2 } from "@typescript-eslint/utils";
|
|
3147
|
+
var GENERIC_STEMS = /* @__PURE__ */ new Set([
|
|
3148
|
+
"base",
|
|
3149
|
+
"common",
|
|
3150
|
+
"constant",
|
|
3151
|
+
"constants",
|
|
3152
|
+
"core",
|
|
3153
|
+
"enum",
|
|
3154
|
+
"enums",
|
|
3155
|
+
"helper",
|
|
3156
|
+
"helpers",
|
|
3157
|
+
"misc",
|
|
3158
|
+
"model",
|
|
3159
|
+
"models",
|
|
3160
|
+
"shared",
|
|
3161
|
+
"stuff",
|
|
3162
|
+
"type",
|
|
3163
|
+
"types",
|
|
3164
|
+
"util",
|
|
3165
|
+
"utils"
|
|
3166
|
+
]);
|
|
3167
|
+
var CONVENTIONAL_STEMS = /* @__PURE__ */ new Set(["base", "models"]);
|
|
3168
|
+
var CJS_OBJECT_EXPORT_METHODS = /* @__PURE__ */ new Set(["assign", "defineProperties", "defineProperty"]);
|
|
3169
|
+
function fileParts(filename) {
|
|
3170
|
+
const base = filename.replaceAll("\\", "/").split("/").at(-1) ?? "";
|
|
3171
|
+
const extension = base.match(/(\.[cm]?[jt]sx?)$/u)?.[1] ?? ".ts";
|
|
3172
|
+
const segments = base.slice(0, -extension.length).split(".");
|
|
3173
|
+
return {
|
|
3174
|
+
extension,
|
|
3175
|
+
stem: segments[0]?.toLowerCase() ?? "",
|
|
3176
|
+
suffixes: segments.slice(1)
|
|
3177
|
+
};
|
|
3178
|
+
}
|
|
3179
|
+
function declaredNames(declaration) {
|
|
3180
|
+
if (declaration.declare === true) return [];
|
|
3181
|
+
if (declaration.type === AST_NODE_TYPES14.FunctionDeclaration || declaration.type === AST_NODE_TYPES14.ClassDeclaration || declaration.type === AST_NODE_TYPES14.TSEnumDeclaration) {
|
|
3182
|
+
if (declaration.type === AST_NODE_TYPES14.TSEnumDeclaration && declaration.const) return [];
|
|
3183
|
+
return declaration.id === null ? [] : [declaration.id.name];
|
|
3184
|
+
}
|
|
3185
|
+
if (declaration.type === AST_NODE_TYPES14.TSModuleDeclaration && declaration.id.type === AST_NODE_TYPES14.Identifier) {
|
|
3186
|
+
return [declaration.id.name];
|
|
3187
|
+
}
|
|
3188
|
+
if (declaration.type !== AST_NODE_TYPES14.VariableDeclaration) return [];
|
|
3189
|
+
return declaration.declarations.flatMap(
|
|
3190
|
+
(item) => item.id.type === AST_NODE_TYPES14.Identifier ? [item.id.name] : []
|
|
3191
|
+
);
|
|
3192
|
+
}
|
|
3193
|
+
function typeOnlyBindings(program) {
|
|
3194
|
+
const names = /* @__PURE__ */ new Set();
|
|
3195
|
+
const runtimeNames = /* @__PURE__ */ new Set();
|
|
3196
|
+
for (const statement of program.body) {
|
|
3197
|
+
const declaration = statement.type === AST_NODE_TYPES14.ExportNamedDeclaration ? statement.declaration : statement;
|
|
3198
|
+
if (declaration?.type === AST_NODE_TYPES14.TSInterfaceDeclaration || declaration?.type === AST_NODE_TYPES14.TSTypeAliasDeclaration) {
|
|
3199
|
+
names.add(declaration.id.name);
|
|
3200
|
+
continue;
|
|
3201
|
+
}
|
|
3202
|
+
if (declaration?.type === AST_NODE_TYPES14.TSEnumDeclaration && declaration.const) {
|
|
3203
|
+
names.add(declaration.id.name);
|
|
3204
|
+
continue;
|
|
3205
|
+
}
|
|
3206
|
+
if (statement.type === AST_NODE_TYPES14.ImportDeclaration) {
|
|
3207
|
+
for (const specifier of statement.specifiers) {
|
|
3208
|
+
if (statement.importKind === "type" || specifier.type === AST_NODE_TYPES14.ImportSpecifier && specifier.importKind === "type") {
|
|
3209
|
+
names.add(specifier.local.name);
|
|
3210
|
+
} else {
|
|
3211
|
+
runtimeNames.add(specifier.local.name);
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
continue;
|
|
3215
|
+
}
|
|
3216
|
+
if (declaration?.type === AST_NODE_TYPES14.TSDeclareFunction && declaration.id !== null) {
|
|
3217
|
+
names.add(declaration.id.name);
|
|
3218
|
+
continue;
|
|
3219
|
+
}
|
|
3220
|
+
if (declaration !== null && declaration.declare === true) {
|
|
3221
|
+
if ((declaration.type === AST_NODE_TYPES14.ClassDeclaration || declaration.type === AST_NODE_TYPES14.FunctionDeclaration || declaration.type === AST_NODE_TYPES14.TSEnumDeclaration || declaration.type === AST_NODE_TYPES14.TSModuleDeclaration) && declaration.id !== null && declaration.id.type === AST_NODE_TYPES14.Identifier) names.add(declaration.id.name);
|
|
3222
|
+
if (declaration.type === AST_NODE_TYPES14.VariableDeclaration) {
|
|
3223
|
+
for (const item of declaration.declarations) {
|
|
3224
|
+
if (item.id.type === AST_NODE_TYPES14.Identifier) names.add(item.id.name);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
continue;
|
|
3228
|
+
}
|
|
3229
|
+
if (declaration !== null && "type" in declaration) {
|
|
3230
|
+
for (const name of declaredNames(declaration)) {
|
|
3231
|
+
runtimeNames.add(name);
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
return new Set([...names].filter((name) => !runtimeNames.has(name)));
|
|
3236
|
+
}
|
|
3237
|
+
function runtimeExports(program) {
|
|
3238
|
+
const exports = [];
|
|
3239
|
+
const typeBindings = typeOnlyBindings(program);
|
|
3240
|
+
let ambiguous = false;
|
|
3241
|
+
for (const statement of program.body) {
|
|
3242
|
+
if (statement.type === AST_NODE_TYPES14.ExportAllDeclaration) {
|
|
3243
|
+
if (statement.exportKind !== "type") ambiguous = true;
|
|
3244
|
+
continue;
|
|
3245
|
+
}
|
|
3246
|
+
if (statement.type === AST_NODE_TYPES14.ExportDefaultDeclaration) {
|
|
3247
|
+
const declaration = statement.declaration;
|
|
3248
|
+
if (declaration.type === AST_NODE_TYPES14.Identifier) {
|
|
3249
|
+
if (!typeBindings.has(declaration.name)) {
|
|
3250
|
+
exports.push({ key: "default", name: declaration.name, node: statement });
|
|
3251
|
+
}
|
|
3252
|
+
} else if ((declaration.type === AST_NODE_TYPES14.FunctionDeclaration || declaration.type === AST_NODE_TYPES14.ClassDeclaration) && declaration.id !== null && declaration.declare !== true) exports.push({ key: "default", name: declaration.id.name, node: declaration });
|
|
3253
|
+
else if (declaration.type !== AST_NODE_TYPES14.TSInterfaceDeclaration && declaration.type !== AST_NODE_TYPES14.TSTypeAliasDeclaration) ambiguous = true;
|
|
3254
|
+
continue;
|
|
3255
|
+
}
|
|
3256
|
+
if (statement.type !== AST_NODE_TYPES14.ExportNamedDeclaration || statement.exportKind === "type") continue;
|
|
3257
|
+
if (statement.source !== null) {
|
|
3258
|
+
if (statement.specifiers.some((specifier) => specifier.exportKind !== "type")) ambiguous = true;
|
|
3259
|
+
continue;
|
|
3260
|
+
}
|
|
3261
|
+
if (statement.declaration !== null) {
|
|
3262
|
+
const declaration = statement.declaration;
|
|
3263
|
+
exports.push(...declaredNames(declaration).map((name) => ({ key: name, name, node: declaration })));
|
|
3264
|
+
}
|
|
3265
|
+
for (const specifier of statement.specifiers) {
|
|
3266
|
+
if (specifier.exportKind === "type" || typeBindings.has(specifier.local.name)) continue;
|
|
3267
|
+
const exported = specifier.exported.type === AST_NODE_TYPES14.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
3268
|
+
const local = specifier.local.name;
|
|
3269
|
+
exports.push({ key: exported, name: exported === "default" ? local : exported, node: specifier });
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
const unique = new Map(exports.map((entry) => [entry.key, entry]));
|
|
3273
|
+
return { exports: [...unique.values()], ambiguous };
|
|
3274
|
+
}
|
|
3275
|
+
function kebabCase(name) {
|
|
3276
|
+
return name.replaceAll(/oauth/giu, "Oauth").replaceAll(/graphql/giu, "Graphql").replaceAll(/grpc/giu, "Grpc").replaceAll(/([a-z\d])([A-Z])/gu, "$1-$2").replaceAll(/([A-Z]+)([A-Z][a-z])/gu, "$1-$2").replaceAll(/[_\s]+/gu, "-").replaceAll(/-+/gu, "-").replaceAll(/^-|-$/gu, "").toLowerCase();
|
|
3277
|
+
}
|
|
3278
|
+
function isGlobalIdentifier(context, node) {
|
|
3279
|
+
const variable = ASTUtils2.findVariable(context.sourceCode.getScope(node), node.name);
|
|
3280
|
+
return variable === null || variable.defs.length === 0;
|
|
3281
|
+
}
|
|
3282
|
+
function isConventionalFrameworkUtility(filename, exported) {
|
|
3283
|
+
const normalized = filename.replaceAll("\\", "/");
|
|
3284
|
+
return exported === "cn" && /(?:^|\/)lib\/utils\.[cm]?[jt]sx?$/u.test(normalized);
|
|
3285
|
+
}
|
|
3286
|
+
function memberPropertyName(node) {
|
|
3287
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES14.Identifier) return node.property.name;
|
|
3288
|
+
return node.computed && node.property.type === AST_NODE_TYPES14.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
3289
|
+
}
|
|
3290
|
+
var no_generic_single_export_module_default = createRule({
|
|
3291
|
+
name: "no-generic-single-export-module",
|
|
3292
|
+
meta: {
|
|
3293
|
+
type: "suggestion",
|
|
3294
|
+
docs: { description: "Disallow generic module stems when one runtime export already names the responsibility." },
|
|
3295
|
+
schema: [],
|
|
3296
|
+
messages: {
|
|
3297
|
+
genericSingleExport: "Module stem `{{stem}}` is generic and its only runtime export is `{{exported}}`; rename the file to `{{expected}}`."
|
|
3298
|
+
}
|
|
3299
|
+
},
|
|
3300
|
+
defaultOptions: [],
|
|
3301
|
+
create(context) {
|
|
3302
|
+
const file = fileParts(context.filename);
|
|
3303
|
+
const { stem: stem3 } = file;
|
|
3304
|
+
if (!GENERIC_STEMS.has(stem3) || CONVENTIONAL_STEMS.has(stem3) || isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
3305
|
+
let hasCommonJsExport = false;
|
|
3306
|
+
return {
|
|
3307
|
+
CallExpression(node) {
|
|
3308
|
+
const first = node.arguments[0];
|
|
3309
|
+
if (first?.type === AST_NODE_TYPES14.Identifier && first.name === "exports" && isGlobalIdentifier(context, first) && node.callee.type === AST_NODE_TYPES14.MemberExpression && node.callee.object.type === AST_NODE_TYPES14.Identifier && node.callee.object.name === "Object" && isGlobalIdentifier(context, node.callee.object) && memberPropertyName(node.callee) !== null && CJS_OBJECT_EXPORT_METHODS.has(memberPropertyName(node.callee))) hasCommonJsExport = true;
|
|
3310
|
+
},
|
|
3311
|
+
MemberExpression(node) {
|
|
3312
|
+
if (node.object.type === AST_NODE_TYPES14.Identifier && node.object.name === "exports" && isGlobalIdentifier(context, node.object)) hasCommonJsExport = true;
|
|
3313
|
+
if (node.object.type === AST_NODE_TYPES14.Identifier && node.object.name === "module" && isGlobalIdentifier(context, node.object) && memberPropertyName(node) === "exports") hasCommonJsExport = true;
|
|
3314
|
+
},
|
|
3315
|
+
"Program:exit"(program) {
|
|
3316
|
+
if (hasCommonJsExport) return;
|
|
3317
|
+
const exports = runtimeExports(program);
|
|
3318
|
+
if (exports.ambiguous || exports.exports.length !== 1) return;
|
|
3319
|
+
const onlyExport = exports.exports[0];
|
|
3320
|
+
if (onlyExport === void 0) return;
|
|
3321
|
+
const { name: exported, node } = onlyExport;
|
|
3322
|
+
if (isConventionalFrameworkUtility(context.filename, exported)) return;
|
|
3323
|
+
const expectedStem = kebabCase(exported);
|
|
3324
|
+
const suffixStem = file.suffixes.map(kebabCase).join("-");
|
|
3325
|
+
const currentResponsibility = [stem3, suffixStem].filter(Boolean).join("-");
|
|
3326
|
+
if (expectedStem === currentResponsibility || GENERIC_STEMS.has(expectedStem) || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(expectedStem)) return;
|
|
3327
|
+
const suffixTail = suffixStem === "" ? "" : `-${suffixStem}`;
|
|
3328
|
+
const renameStem = suffixTail !== "" && expectedStem.endsWith(suffixTail) ? expectedStem.slice(0, -suffixTail.length) : expectedStem;
|
|
3329
|
+
if (renameStem === "" || GENERIC_STEMS.has(renameStem)) return;
|
|
3330
|
+
const suffix = file.suffixes.map((part) => `.${kebabCase(part)}`).join("");
|
|
3331
|
+
context.report({
|
|
3332
|
+
node,
|
|
3333
|
+
messageId: "genericSingleExport",
|
|
3334
|
+
data: { stem: stem3, exported, expected: `${renameStem}${suffix}${file.extension}` }
|
|
3335
|
+
});
|
|
3336
|
+
}
|
|
3337
|
+
};
|
|
3338
|
+
}
|
|
3339
|
+
});
|
|
3340
|
+
|
|
3144
3341
|
// src/rules/no-offset-pagination.ts
|
|
3145
3342
|
import "@typescript-eslint/utils";
|
|
3146
3343
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:%s|%\(\w+\)s|\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
@@ -3172,60 +3369,57 @@ var no_offset_pagination_default = createRule({
|
|
|
3172
3369
|
});
|
|
3173
3370
|
|
|
3174
3371
|
// src/rules/no-positional-tuple-return.ts
|
|
3175
|
-
import { AST_NODE_TYPES as
|
|
3372
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15 } from "@typescript-eslint/utils";
|
|
3176
3373
|
var MIN_ELEMENTS = 2;
|
|
3177
|
-
var
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
if (node.type === AST_NODE_TYPES14.TSTupleType) {
|
|
3374
|
+
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited", "Readonly"]);
|
|
3375
|
+
function tupleReturnType(node, aliases, resolving = /* @__PURE__ */ new Set()) {
|
|
3376
|
+
if (node.type === AST_NODE_TYPES15.TSTupleType) {
|
|
3181
3377
|
return node;
|
|
3182
3378
|
}
|
|
3183
|
-
if (node.type ===
|
|
3184
|
-
const argument = node.typeArguments?.params
|
|
3185
|
-
return argument === void 0 ? null : tupleReturnType(argument);
|
|
3379
|
+
if (node.type === AST_NODE_TYPES15.TSTypeReference && node.typeName.type === AST_NODE_TYPES15.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
3380
|
+
const argument = node.typeArguments?.params.at(0);
|
|
3381
|
+
return argument === void 0 ? null : tupleReturnType(argument, aliases, resolving);
|
|
3186
3382
|
}
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
return sourceCode.getText(node).replaceAll(/\s+/g, " ").trim();
|
|
3191
|
-
}
|
|
3192
|
-
function isPermittedTuple(tuple, sourceCode) {
|
|
3193
|
-
const elements = tuple.elementTypes;
|
|
3194
|
-
if (elements.length < MIN_ELEMENTS) {
|
|
3195
|
-
return true;
|
|
3383
|
+
if (node.type === AST_NODE_TYPES15.TSTypeReference && node.typeName.type === AST_NODE_TYPES15.Identifier && !resolving.has(node.typeName.name)) {
|
|
3384
|
+
const target = aliases.get(node.typeName.name);
|
|
3385
|
+
if (target !== void 0) return tupleReturnType(target, aliases, /* @__PURE__ */ new Set([...resolving, node.typeName.name]));
|
|
3196
3386
|
}
|
|
3197
|
-
if (
|
|
3198
|
-
return
|
|
3387
|
+
if (node.type === AST_NODE_TYPES15.TSTypeOperator && node.operator === "readonly") {
|
|
3388
|
+
return node.typeAnnotation === void 0 ? null : tupleReturnType(node.typeAnnotation, aliases, resolving);
|
|
3199
3389
|
}
|
|
3200
|
-
if (
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
}
|
|
3206
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === AST_NODE_TYPES14.TSFunctionType)) {
|
|
3207
|
-
return true;
|
|
3390
|
+
if (node.type === AST_NODE_TYPES15.TSUnionType || node.type === AST_NODE_TYPES15.TSIntersectionType) {
|
|
3391
|
+
for (const member of node.types) {
|
|
3392
|
+
const tuple = tupleReturnType(member, aliases, resolving);
|
|
3393
|
+
if (tuple !== null) return tuple;
|
|
3394
|
+
}
|
|
3208
3395
|
}
|
|
3209
|
-
|
|
3210
|
-
return texts.size === 1;
|
|
3396
|
+
return null;
|
|
3211
3397
|
}
|
|
3212
3398
|
function functionName(node) {
|
|
3213
|
-
if (node.type ===
|
|
3214
|
-
|
|
3399
|
+
if (node.type === AST_NODE_TYPES15.FunctionDeclaration) {
|
|
3400
|
+
if (node.id !== null) return node.id.name;
|
|
3401
|
+
return node.parent?.type === AST_NODE_TYPES15.ExportDefaultDeclaration ? "default" : null;
|
|
3215
3402
|
}
|
|
3216
|
-
|
|
3217
|
-
|
|
3403
|
+
let wrapped = node;
|
|
3404
|
+
while ((wrapped.parent?.type === AST_NODE_TYPES15.TSAsExpression || wrapped.parent?.type === AST_NODE_TYPES15.TSSatisfiesExpression || wrapped.parent?.type === AST_NODE_TYPES15.TSNonNullExpression) && wrapped.parent.expression === wrapped) {
|
|
3405
|
+
wrapped = wrapped.parent;
|
|
3406
|
+
}
|
|
3407
|
+
const parent = wrapped.parent;
|
|
3408
|
+
if (parent?.type === AST_NODE_TYPES15.ExportDefaultDeclaration) return "default";
|
|
3409
|
+
if (parent?.type === AST_NODE_TYPES15.VariableDeclarator && parent.id.type === AST_NODE_TYPES15.Identifier) {
|
|
3218
3410
|
return parent.id.name;
|
|
3219
3411
|
}
|
|
3220
|
-
if ((parent?.type ===
|
|
3412
|
+
if ((parent?.type === AST_NODE_TYPES15.MethodDefinition || parent?.type === AST_NODE_TYPES15.TSAbstractMethodDefinition || parent?.type === AST_NODE_TYPES15.PropertyDefinition || parent?.type === AST_NODE_TYPES15.Property) && parent.key.type === AST_NODE_TYPES15.Identifier) {
|
|
3413
|
+
if ((parent.type === AST_NODE_TYPES15.MethodDefinition || parent.type === AST_NODE_TYPES15.TSAbstractMethodDefinition || parent.type === AST_NODE_TYPES15.PropertyDefinition) && (parent.accessibility === "private" || parent.accessibility === "protected")) return null;
|
|
3221
3414
|
return parent.key.name;
|
|
3222
3415
|
}
|
|
3223
3416
|
return null;
|
|
3224
3417
|
}
|
|
3225
3418
|
function isInlineExported(node) {
|
|
3419
|
+
if (moduleScopeBindingName(node) === null) return false;
|
|
3226
3420
|
for (let current = node; current != null; current = current.parent) {
|
|
3227
3421
|
const parent = current.parent;
|
|
3228
|
-
if (parent?.type ===
|
|
3422
|
+
if (parent?.type === AST_NODE_TYPES15.ExportNamedDeclaration || parent?.type === AST_NODE_TYPES15.ExportDefaultDeclaration) {
|
|
3229
3423
|
return true;
|
|
3230
3424
|
}
|
|
3231
3425
|
}
|
|
@@ -3233,46 +3427,154 @@ function isInlineExported(node) {
|
|
|
3233
3427
|
}
|
|
3234
3428
|
function moduleScopeBindingName(node) {
|
|
3235
3429
|
let current = node;
|
|
3236
|
-
|
|
3237
|
-
while (current.parent != null && current.parent.type !== AST_NODE_TYPES14.Program) {
|
|
3238
|
-
child = current;
|
|
3430
|
+
while (current.parent != null && current.parent.type !== AST_NODE_TYPES15.Program) {
|
|
3239
3431
|
current = current.parent;
|
|
3240
3432
|
}
|
|
3241
|
-
if (current.parent?.type !==
|
|
3433
|
+
if (current.parent?.type !== AST_NODE_TYPES15.Program) {
|
|
3242
3434
|
return null;
|
|
3243
3435
|
}
|
|
3244
|
-
|
|
3245
|
-
|
|
3436
|
+
let topLevel = current;
|
|
3437
|
+
if (current.type === AST_NODE_TYPES15.ExportNamedDeclaration || current.type === AST_NODE_TYPES15.ExportDefaultDeclaration) {
|
|
3438
|
+
topLevel = current.declaration;
|
|
3246
3439
|
}
|
|
3247
|
-
if (
|
|
3248
|
-
|
|
3249
|
-
|
|
3440
|
+
if (topLevel === null) return null;
|
|
3441
|
+
if (topLevel.type === AST_NODE_TYPES15.FunctionDeclaration) {
|
|
3442
|
+
if (topLevel !== node) return null;
|
|
3443
|
+
return topLevel.id?.name ?? (current.type === AST_NODE_TYPES15.ExportDefaultDeclaration ? "default" : null);
|
|
3444
|
+
}
|
|
3445
|
+
if ((topLevel.type === AST_NODE_TYPES15.ArrowFunctionExpression || topLevel.type === AST_NODE_TYPES15.FunctionExpression) && topLevel === node && current.type === AST_NODE_TYPES15.ExportDefaultDeclaration) {
|
|
3446
|
+
return "default";
|
|
3447
|
+
}
|
|
3448
|
+
if (topLevel.type === AST_NODE_TYPES15.ClassDeclaration) {
|
|
3449
|
+
let owner = node.parent;
|
|
3450
|
+
while (owner !== void 0 && owner.parent !== topLevel.body) owner = owner.parent;
|
|
3451
|
+
return (owner?.type === AST_NODE_TYPES15.MethodDefinition || owner?.type === AST_NODE_TYPES15.TSAbstractMethodDefinition || owner?.type === AST_NODE_TYPES15.PropertyDefinition) && owner.value === node ? topLevel.id?.name ?? (current.type === AST_NODE_TYPES15.ExportDefaultDeclaration ? "default" : null) : null;
|
|
3452
|
+
}
|
|
3453
|
+
if (topLevel.type === AST_NODE_TYPES15.VariableDeclaration) {
|
|
3454
|
+
for (const declarator of topLevel.declarations) {
|
|
3455
|
+
let initializer = declarator.init;
|
|
3456
|
+
while (initializer?.type === AST_NODE_TYPES15.TSAsExpression || initializer?.type === AST_NODE_TYPES15.TSSatisfiesExpression || initializer?.type === AST_NODE_TYPES15.TSNonNullExpression) initializer = initializer.expression;
|
|
3457
|
+
if (declarator.id.type === AST_NODE_TYPES15.Identifier && initializer === node) return declarator.id.name;
|
|
3458
|
+
if (declarator.id.type === AST_NODE_TYPES15.Identifier && (initializer?.type === AST_NODE_TYPES15.ClassExpression || initializer?.type === AST_NODE_TYPES15.ObjectExpression)) {
|
|
3459
|
+
let owner = node.parent;
|
|
3460
|
+
const container = initializer.type === AST_NODE_TYPES15.ClassExpression ? initializer.body : initializer;
|
|
3461
|
+
while (owner !== void 0 && owner.parent !== container) owner = owner.parent;
|
|
3462
|
+
if ((owner?.type === AST_NODE_TYPES15.MethodDefinition || owner?.type === AST_NODE_TYPES15.PropertyDefinition || owner?.type === AST_NODE_TYPES15.Property) && owner.value === node) return declarator.id.name;
|
|
3463
|
+
}
|
|
3250
3464
|
}
|
|
3251
|
-
return child.id.name;
|
|
3252
3465
|
}
|
|
3253
3466
|
return null;
|
|
3254
3467
|
}
|
|
3255
3468
|
function specifierExportedNames(program) {
|
|
3256
3469
|
const names = /* @__PURE__ */ new Set();
|
|
3257
3470
|
for (const statement of program.body) {
|
|
3258
|
-
if (statement.type ===
|
|
3471
|
+
if (statement.type === AST_NODE_TYPES15.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
3259
3472
|
for (const specifier of statement.specifiers) {
|
|
3260
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
3473
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES15.Identifier) {
|
|
3261
3474
|
names.add(specifier.local.name);
|
|
3262
3475
|
}
|
|
3263
3476
|
}
|
|
3264
3477
|
continue;
|
|
3265
3478
|
}
|
|
3266
|
-
if (statement.type ===
|
|
3479
|
+
if (statement.type === AST_NODE_TYPES15.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES15.Identifier) {
|
|
3267
3480
|
names.add(statement.declaration.name);
|
|
3268
3481
|
continue;
|
|
3269
3482
|
}
|
|
3270
|
-
if (statement.type ===
|
|
3483
|
+
if (statement.type === AST_NODE_TYPES15.TSExportAssignment && statement.expression.type === AST_NODE_TYPES15.Identifier) {
|
|
3271
3484
|
names.add(statement.expression.name);
|
|
3272
3485
|
}
|
|
3273
3486
|
}
|
|
3274
3487
|
return names;
|
|
3275
3488
|
}
|
|
3489
|
+
function exportedTypeNames(program) {
|
|
3490
|
+
const names = /* @__PURE__ */ new Set();
|
|
3491
|
+
for (const statement of program.body) {
|
|
3492
|
+
if (statement.type !== AST_NODE_TYPES15.ExportNamedDeclaration || statement.source !== null) continue;
|
|
3493
|
+
if (statement.declaration?.type === AST_NODE_TYPES15.TSInterfaceDeclaration || statement.declaration?.type === AST_NODE_TYPES15.TSTypeAliasDeclaration) names.add(statement.declaration.id.name);
|
|
3494
|
+
for (const specifier of statement.specifiers) names.add(specifier.local.name);
|
|
3495
|
+
}
|
|
3496
|
+
for (const statement of program.body) {
|
|
3497
|
+
if (statement.type === AST_NODE_TYPES15.ExportDefaultDeclaration && (statement.declaration.type === AST_NODE_TYPES15.TSInterfaceDeclaration || statement.declaration.type === AST_NODE_TYPES15.TSTypeAliasDeclaration)) names.add(statement.declaration.id.name);
|
|
3498
|
+
}
|
|
3499
|
+
return names;
|
|
3500
|
+
}
|
|
3501
|
+
function typeAliases(program) {
|
|
3502
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
3503
|
+
for (const statement of program.body) {
|
|
3504
|
+
const declaration = statement.type === AST_NODE_TYPES15.ExportNamedDeclaration ? statement.declaration : statement;
|
|
3505
|
+
if (declaration?.type === AST_NODE_TYPES15.TSTypeAliasDeclaration) {
|
|
3506
|
+
aliases.set(declaration.id.name, declaration.typeAnnotation);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
return aliases;
|
|
3510
|
+
}
|
|
3511
|
+
function callableReturnType(node, aliases, resolving = /* @__PURE__ */ new Set()) {
|
|
3512
|
+
if (node.type === AST_NODE_TYPES15.TSFunctionType) return node.returnType?.typeAnnotation ?? null;
|
|
3513
|
+
if (node.type === AST_NODE_TYPES15.TSTypeReference && node.typeName.type === AST_NODE_TYPES15.Identifier && !resolving.has(node.typeName.name)) {
|
|
3514
|
+
const target = aliases.get(node.typeName.name);
|
|
3515
|
+
if (target !== void 0) {
|
|
3516
|
+
return callableReturnType(target, aliases, /* @__PURE__ */ new Set([...resolving, node.typeName.name]));
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
return null;
|
|
3520
|
+
}
|
|
3521
|
+
function publiclyReachableTypeNames(program, exported) {
|
|
3522
|
+
const names = new Set(exported);
|
|
3523
|
+
const interfaces = /* @__PURE__ */ new Map();
|
|
3524
|
+
for (const statement of program.body) {
|
|
3525
|
+
const declaration = statement.type === AST_NODE_TYPES15.ExportNamedDeclaration ? statement.declaration : statement;
|
|
3526
|
+
if (declaration?.type === AST_NODE_TYPES15.TSInterfaceDeclaration) {
|
|
3527
|
+
interfaces.set(declaration.id.name, declaration.extends);
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
for (let pass = 0; pass < interfaces.size; pass += 1) {
|
|
3531
|
+
let changed = false;
|
|
3532
|
+
for (const name of [...names]) {
|
|
3533
|
+
for (const heritage of interfaces.get(name) ?? []) {
|
|
3534
|
+
if (heritage.expression.type === AST_NODE_TYPES15.Identifier && !names.has(heritage.expression.name)) {
|
|
3535
|
+
names.add(heritage.expression.name);
|
|
3536
|
+
changed = true;
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
if (!changed) break;
|
|
3541
|
+
}
|
|
3542
|
+
return names;
|
|
3543
|
+
}
|
|
3544
|
+
function owningInterface(node) {
|
|
3545
|
+
for (let current = node.parent; current !== void 0; current = current.parent) {
|
|
3546
|
+
if (current.type === AST_NODE_TYPES15.TSInterfaceDeclaration) return current;
|
|
3547
|
+
if (current.type === AST_NODE_TYPES15.Program) return null;
|
|
3548
|
+
}
|
|
3549
|
+
return null;
|
|
3550
|
+
}
|
|
3551
|
+
function owningTypeAlias(node) {
|
|
3552
|
+
for (let current = node.parent; current !== void 0; current = current.parent) {
|
|
3553
|
+
if (current.type === AST_NODE_TYPES15.TSTypeAliasDeclaration) return current;
|
|
3554
|
+
if (current.type === AST_NODE_TYPES15.Program) return null;
|
|
3555
|
+
}
|
|
3556
|
+
return null;
|
|
3557
|
+
}
|
|
3558
|
+
function owningClass(node) {
|
|
3559
|
+
for (let current = node.parent; current !== void 0; current = current.parent) {
|
|
3560
|
+
if (current.type === AST_NODE_TYPES15.ClassDeclaration || current.type === AST_NODE_TYPES15.ClassExpression) {
|
|
3561
|
+
return current;
|
|
3562
|
+
}
|
|
3563
|
+
if (current.type === AST_NODE_TYPES15.Program) return null;
|
|
3564
|
+
}
|
|
3565
|
+
return null;
|
|
3566
|
+
}
|
|
3567
|
+
function isExportedClass(node, specifierExports) {
|
|
3568
|
+
if (node.parent.type === AST_NODE_TYPES15.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES15.ExportDefaultDeclaration) return true;
|
|
3569
|
+
if (node.type === AST_NODE_TYPES15.ClassDeclaration) {
|
|
3570
|
+
return node.id !== null && node.parent.type === AST_NODE_TYPES15.Program && specifierExports.has(node.id.name);
|
|
3571
|
+
}
|
|
3572
|
+
if (node.parent.type === AST_NODE_TYPES15.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES15.Identifier) return specifierExports.has(node.parent.id.name) || isInlineExported(node);
|
|
3573
|
+
return false;
|
|
3574
|
+
}
|
|
3575
|
+
function isExportedInterface(node, exports) {
|
|
3576
|
+
return node.parent.type === AST_NODE_TYPES15.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES15.ExportDefaultDeclaration || node.parent.type === AST_NODE_TYPES15.Program && exports.has(node.id.name);
|
|
3577
|
+
}
|
|
3276
3578
|
function isExported(node, specifierExports) {
|
|
3277
3579
|
if (isInlineExported(node)) {
|
|
3278
3580
|
return true;
|
|
@@ -3288,42 +3590,91 @@ var no_positional_tuple_return_default = createRule({
|
|
|
3288
3590
|
meta: {
|
|
3289
3591
|
type: "suggestion",
|
|
3290
3592
|
docs: {
|
|
3291
|
-
description: "Disallow returning a
|
|
3593
|
+
description: "Disallow returning a multi-field tuple from an exported function; return a named object so call sites cannot mismatch slots."
|
|
3292
3594
|
},
|
|
3293
3595
|
schema: [],
|
|
3294
3596
|
messages: {
|
|
3295
|
-
noPositionalTupleReturn: "Exported `{{name}}` returns a
|
|
3597
|
+
noPositionalTupleReturn: "Exported `{{name}}` returns a {{count}}-field tuple, so consumers depend on positional slots that can be reordered silently. Return a named object instead."
|
|
3296
3598
|
}
|
|
3297
3599
|
},
|
|
3298
3600
|
defaultOptions: [],
|
|
3299
3601
|
create(context) {
|
|
3602
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
3300
3603
|
const specifierExports = specifierExportedNames(context.sourceCode.ast);
|
|
3604
|
+
const typeExports = publiclyReachableTypeNames(
|
|
3605
|
+
context.sourceCode.ast,
|
|
3606
|
+
exportedTypeNames(context.sourceCode.ast)
|
|
3607
|
+
);
|
|
3608
|
+
const aliases = typeAliases(context.sourceCode.ast);
|
|
3609
|
+
const report = (annotation, name) => {
|
|
3610
|
+
const tuple = tupleReturnType(annotation, aliases);
|
|
3611
|
+
if (tuple === null || tuple.elementTypes.length < MIN_ELEMENTS) return;
|
|
3612
|
+
context.report({
|
|
3613
|
+
node: tuple,
|
|
3614
|
+
messageId: "noPositionalTupleReturn",
|
|
3615
|
+
data: { name, count: String(tuple.elementTypes.length) }
|
|
3616
|
+
});
|
|
3617
|
+
};
|
|
3301
3618
|
const check = (node) => {
|
|
3302
3619
|
const annotation = node.returnType?.typeAnnotation;
|
|
3303
3620
|
if (annotation === void 0) {
|
|
3304
3621
|
return;
|
|
3305
3622
|
}
|
|
3306
|
-
const tuple = tupleReturnType(annotation);
|
|
3307
|
-
if (tuple === null || isPermittedTuple(tuple, context.sourceCode)) {
|
|
3308
|
-
return;
|
|
3309
|
-
}
|
|
3310
3623
|
const name = functionName(node);
|
|
3311
|
-
if (name === null
|
|
3624
|
+
if (name === null) {
|
|
3312
3625
|
return;
|
|
3313
3626
|
}
|
|
3314
3627
|
if (!isExported(node, specifierExports)) {
|
|
3315
3628
|
return;
|
|
3316
3629
|
}
|
|
3317
|
-
|
|
3318
|
-
node: tuple,
|
|
3319
|
-
messageId: "noPositionalTupleReturn",
|
|
3320
|
-
data: { name, count: String(tuple.elementTypes.length) }
|
|
3321
|
-
});
|
|
3630
|
+
report(annotation, name);
|
|
3322
3631
|
};
|
|
3323
3632
|
return {
|
|
3324
3633
|
FunctionDeclaration: check,
|
|
3325
3634
|
FunctionExpression: check,
|
|
3326
|
-
ArrowFunctionExpression: check
|
|
3635
|
+
ArrowFunctionExpression: check,
|
|
3636
|
+
TSEmptyBodyFunctionExpression: check,
|
|
3637
|
+
TSDeclareFunction(node) {
|
|
3638
|
+
if (node.id === null || node.returnType === void 0 || node.parent.type !== AST_NODE_TYPES15.ExportNamedDeclaration && node.parent.type !== AST_NODE_TYPES15.ExportDefaultDeclaration && !specifierExports.has(node.id.name)) return;
|
|
3639
|
+
report(node.returnType.typeAnnotation, node.id.name);
|
|
3640
|
+
},
|
|
3641
|
+
TSCallSignatureDeclaration(node) {
|
|
3642
|
+
const owner = owningInterface(node);
|
|
3643
|
+
if (owner === null || !isExportedInterface(owner, typeExports) || node.returnType === void 0) return;
|
|
3644
|
+
report(node.returnType.typeAnnotation, `${owner.id.name}.call`);
|
|
3645
|
+
},
|
|
3646
|
+
TSMethodSignature(node) {
|
|
3647
|
+
const owner = owningInterface(node);
|
|
3648
|
+
const alias = owningTypeAlias(node);
|
|
3649
|
+
if ((owner === null || !isExportedInterface(owner, typeExports)) && (alias === null || !typeExports.has(alias.id.name)) || node.returnType === void 0 || node.key.type !== AST_NODE_TYPES15.Identifier) return;
|
|
3650
|
+
report(node.returnType.typeAnnotation, `${owner?.id.name ?? alias?.id.name ?? "type"}.${node.key.name}`);
|
|
3651
|
+
},
|
|
3652
|
+
TSTypeAliasDeclaration(node) {
|
|
3653
|
+
if (!typeExports.has(node.id.name)) return;
|
|
3654
|
+
const returnType = callableReturnType(node.typeAnnotation, aliases);
|
|
3655
|
+
if (returnType !== null) report(returnType, node.id.name);
|
|
3656
|
+
},
|
|
3657
|
+
TSPropertySignature(node) {
|
|
3658
|
+
const owner = owningInterface(node);
|
|
3659
|
+
const alias = owningTypeAlias(node);
|
|
3660
|
+
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
3661
|
+
if ((owner === null || !isExportedInterface(owner, typeExports)) && (alias === null || !typeExports.has(alias.id.name)) || node.key.type !== AST_NODE_TYPES15.Identifier || annotation === void 0) return;
|
|
3662
|
+
const returnType = callableReturnType(annotation, aliases);
|
|
3663
|
+
if (returnType !== null) {
|
|
3664
|
+
report(returnType, `${owner?.id.name ?? alias?.id.name ?? "type"}.${node.key.name}`);
|
|
3665
|
+
}
|
|
3666
|
+
},
|
|
3667
|
+
PropertyDefinition(node) {
|
|
3668
|
+
if (node.accessibility === "private" || node.accessibility === "protected") return;
|
|
3669
|
+
const owner = owningClass(node);
|
|
3670
|
+
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
3671
|
+
if (owner === null || !isExportedClass(owner, specifierExports) || annotation === void 0) return;
|
|
3672
|
+
const returnType = callableReturnType(annotation, aliases);
|
|
3673
|
+
if (returnType !== null) {
|
|
3674
|
+
const name = node.key.type === AST_NODE_TYPES15.Identifier ? node.key.name : "property";
|
|
3675
|
+
report(returnType, name);
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3327
3678
|
};
|
|
3328
3679
|
}
|
|
3329
3680
|
});
|
|
@@ -3406,7 +3757,7 @@ var no_raw_env_default = createRule({
|
|
|
3406
3757
|
});
|
|
3407
3758
|
|
|
3408
3759
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
3409
|
-
import { AST_NODE_TYPES as
|
|
3760
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES16 } from "@typescript-eslint/utils";
|
|
3410
3761
|
var DEFAULT_ALLOW = [
|
|
3411
3762
|
"[\\\\/]clients?[\\\\/]",
|
|
3412
3763
|
"-client\\.[cm]?[jt]sx?$",
|
|
@@ -3448,7 +3799,7 @@ function identifierLikeName(node) {
|
|
|
3448
3799
|
}
|
|
3449
3800
|
function isConstructedArgumentHandoff(node) {
|
|
3450
3801
|
const [first] = node.arguments;
|
|
3451
|
-
return node.arguments.length === 1 && first !== void 0 && first.type ===
|
|
3802
|
+
return node.arguments.length === 1 && first !== void 0 && first.type === AST_NODE_TYPES16.NewExpression;
|
|
3452
3803
|
}
|
|
3453
3804
|
function isPresignedUrlTransfer(node) {
|
|
3454
3805
|
const first = node.arguments[0];
|
|
@@ -3517,9 +3868,9 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
3517
3868
|
});
|
|
3518
3869
|
|
|
3519
3870
|
// src/rules/no-restricted-library-load.ts
|
|
3520
|
-
import { AST_NODE_TYPES as
|
|
3871
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES17, ASTUtils as ASTUtils3 } from "@typescript-eslint/utils";
|
|
3521
3872
|
function literalModule(node) {
|
|
3522
|
-
return node?.type ===
|
|
3873
|
+
return node?.type === AST_NODE_TYPES17.Literal && typeof node.value === "string" ? node.value : null;
|
|
3523
3874
|
}
|
|
3524
3875
|
function matchesModule(source, module) {
|
|
3525
3876
|
return source === module || source.startsWith(`${module}/`);
|
|
@@ -3578,7 +3929,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
3578
3929
|
});
|
|
3579
3930
|
}
|
|
3580
3931
|
function isUnshadowedRequire(node) {
|
|
3581
|
-
const variable =
|
|
3932
|
+
const variable = ASTUtils3.findVariable(
|
|
3582
3933
|
context.sourceCode.getScope(node),
|
|
3583
3934
|
node.name
|
|
3584
3935
|
);
|
|
@@ -3591,9 +3942,9 @@ var no_restricted_library_load_default = createRule({
|
|
|
3591
3942
|
},
|
|
3592
3943
|
CallExpression(node) {
|
|
3593
3944
|
let requireIdentifier = null;
|
|
3594
|
-
if (node.callee.type ===
|
|
3945
|
+
if (node.callee.type === AST_NODE_TYPES17.Identifier && node.callee.name === "require") {
|
|
3595
3946
|
requireIdentifier = node.callee;
|
|
3596
|
-
} else if (node.callee.type ===
|
|
3947
|
+
} else if (node.callee.type === AST_NODE_TYPES17.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES17.Identifier && node.callee.object.name === "require" && node.callee.property.type === AST_NODE_TYPES17.Identifier && node.callee.property.name === "resolve") {
|
|
3597
3948
|
requireIdentifier = node.callee.object;
|
|
3598
3949
|
}
|
|
3599
3950
|
if (requireIdentifier === null || !isUnshadowedRequire(requireIdentifier)) return;
|
|
@@ -3601,7 +3952,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
3601
3952
|
if (source !== null) report(node.arguments[0], source);
|
|
3602
3953
|
},
|
|
3603
3954
|
TSImportEqualsDeclaration(node) {
|
|
3604
|
-
if (node.moduleReference.type !==
|
|
3955
|
+
if (node.moduleReference.type !== AST_NODE_TYPES17.TSExternalModuleReference) return;
|
|
3605
3956
|
const source = literalModule(node.moduleReference.expression);
|
|
3606
3957
|
if (source !== null) report(node.moduleReference.expression, source);
|
|
3607
3958
|
}
|
|
@@ -3610,16 +3961,16 @@ var no_restricted_library_load_default = createRule({
|
|
|
3610
3961
|
});
|
|
3611
3962
|
|
|
3612
3963
|
// src/rules/no-repeated-string-literal.ts
|
|
3613
|
-
import { AST_NODE_TYPES as
|
|
3964
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES18 } from "@typescript-eslint/utils";
|
|
3614
3965
|
var MIN_LENGTH = 40;
|
|
3615
3966
|
var MIN_DISTINCT_SCOPES = 2;
|
|
3616
3967
|
var PREVIEW_LENGTH = 40;
|
|
3617
3968
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
3618
3969
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
3619
3970
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3971
|
+
AST_NODE_TYPES18.FunctionDeclaration,
|
|
3972
|
+
AST_NODE_TYPES18.FunctionExpression,
|
|
3973
|
+
AST_NODE_TYPES18.ArrowFunctionExpression
|
|
3623
3974
|
]);
|
|
3624
3975
|
function isStructured(value) {
|
|
3625
3976
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -3641,8 +3992,8 @@ function isScaffolding(node) {
|
|
|
3641
3992
|
if (parent === void 0) {
|
|
3642
3993
|
return true;
|
|
3643
3994
|
}
|
|
3644
|
-
const isRequireSource = parent.type ===
|
|
3645
|
-
return parent.type ===
|
|
3995
|
+
const isRequireSource = parent.type === AST_NODE_TYPES18.CallExpression && parent.callee.type === AST_NODE_TYPES18.Identifier && parent.callee.name === "require";
|
|
3996
|
+
return parent.type === AST_NODE_TYPES18.ImportDeclaration || parent.type === AST_NODE_TYPES18.ImportExpression || parent.type === AST_NODE_TYPES18.ExportNamedDeclaration || parent.type === AST_NODE_TYPES18.ExportAllDeclaration || parent.type === AST_NODE_TYPES18.TSImportType || parent.type === AST_NODE_TYPES18.JSXAttribute || parent.type === AST_NODE_TYPES18.TSLiteralType || isRequireSource;
|
|
3646
3997
|
}
|
|
3647
3998
|
var no_repeated_string_literal_default = createRule({
|
|
3648
3999
|
name: "no-repeated-string-literal",
|
|
@@ -3682,7 +4033,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3682
4033
|
}
|
|
3683
4034
|
},
|
|
3684
4035
|
TemplateLiteral(node) {
|
|
3685
|
-
if (node.parent.type ===
|
|
4036
|
+
if (node.parent.type === AST_NODE_TYPES18.TaggedTemplateExpression) {
|
|
3686
4037
|
return;
|
|
3687
4038
|
}
|
|
3688
4039
|
const [only] = node.quasis;
|
|
@@ -3716,7 +4067,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3716
4067
|
});
|
|
3717
4068
|
|
|
3718
4069
|
// src/rules/no-restated-comment.ts
|
|
3719
|
-
import { AST_NODE_TYPES as
|
|
4070
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES19 } from "@typescript-eslint/utils";
|
|
3720
4071
|
var MAX_WORDS = 8;
|
|
3721
4072
|
var MIN_CONTENT_TOKENS = 2;
|
|
3722
4073
|
var DIRECTIVE_RE3 = /^(eslint\b|eslint-|sarj-noqa\b|@ts-|prettier-ignore|prettier\b|biome-|c8\b|v8\b|istanbul\b|@type\b|@vite|webpack|<reference|<amd|global\b|noinspection|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
@@ -3769,7 +4120,7 @@ var no_restated_comment_default = createRule({
|
|
|
3769
4120
|
function labelsASiblingRun(comment) {
|
|
3770
4121
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3771
4122
|
if (token === null) return false;
|
|
3772
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
4123
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== AST_NODE_TYPES19.Program; node = node.parent) {
|
|
3773
4124
|
if (headsSiblingRun(node)) return true;
|
|
3774
4125
|
}
|
|
3775
4126
|
return false;
|
|
@@ -3829,7 +4180,7 @@ var no_restated_comment_default = createRule({
|
|
|
3829
4180
|
});
|
|
3830
4181
|
|
|
3831
4182
|
// src/rules/no-restated-jsdoc.ts
|
|
3832
|
-
import { AST_NODE_TYPES as
|
|
4183
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES20 } from "@typescript-eslint/utils";
|
|
3833
4184
|
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
3834
4185
|
"arg",
|
|
3835
4186
|
"argument",
|
|
@@ -3883,30 +4234,30 @@ function declarationNames(node) {
|
|
|
3883
4234
|
switch (node.type) {
|
|
3884
4235
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
3885
4236
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
3886
|
-
case
|
|
3887
|
-
case
|
|
4237
|
+
case AST_NODE_TYPES20.ExportNamedDeclaration:
|
|
4238
|
+
case AST_NODE_TYPES20.ExportDefaultDeclaration:
|
|
3888
4239
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
3889
|
-
case
|
|
3890
|
-
case
|
|
4240
|
+
case AST_NODE_TYPES20.FunctionDeclaration:
|
|
4241
|
+
case AST_NODE_TYPES20.TSDeclareFunction:
|
|
3891
4242
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
3892
|
-
case
|
|
3893
|
-
case
|
|
3894
|
-
case
|
|
3895
|
-
case
|
|
4243
|
+
case AST_NODE_TYPES20.ClassDeclaration:
|
|
4244
|
+
case AST_NODE_TYPES20.TSInterfaceDeclaration:
|
|
4245
|
+
case AST_NODE_TYPES20.TSTypeAliasDeclaration:
|
|
4246
|
+
case AST_NODE_TYPES20.TSEnumDeclaration:
|
|
3896
4247
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
3897
|
-
case
|
|
4248
|
+
case AST_NODE_TYPES20.VariableDeclaration: {
|
|
3898
4249
|
const declarator = node.declarations[0];
|
|
3899
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
4250
|
+
if (declarator === void 0 || declarator.id.type !== AST_NODE_TYPES20.Identifier) return null;
|
|
3900
4251
|
const init = declarator.init;
|
|
3901
|
-
const params = init != null && (init.type ===
|
|
4252
|
+
const params = init != null && (init.type === AST_NODE_TYPES20.ArrowFunctionExpression || init.type === AST_NODE_TYPES20.FunctionExpression) ? paramNames(init.params) : [];
|
|
3902
4253
|
return { name: declarator.id.name, params };
|
|
3903
4254
|
}
|
|
3904
|
-
case
|
|
3905
|
-
case
|
|
3906
|
-
case
|
|
3907
|
-
case
|
|
3908
|
-
if (node.key.type !==
|
|
3909
|
-
const params = node.type ===
|
|
4255
|
+
case AST_NODE_TYPES20.MethodDefinition:
|
|
4256
|
+
case AST_NODE_TYPES20.PropertyDefinition:
|
|
4257
|
+
case AST_NODE_TYPES20.TSMethodSignature:
|
|
4258
|
+
case AST_NODE_TYPES20.TSPropertySignature: {
|
|
4259
|
+
if (node.key.type !== AST_NODE_TYPES20.Identifier) return null;
|
|
4260
|
+
const params = node.type === AST_NODE_TYPES20.MethodDefinition ? paramNames(node.value.params) : node.type === AST_NODE_TYPES20.TSMethodSignature ? paramNames(node.params) : [];
|
|
3910
4261
|
return { name: node.key.name, params };
|
|
3911
4262
|
}
|
|
3912
4263
|
default:
|
|
@@ -3916,9 +4267,9 @@ function declarationNames(node) {
|
|
|
3916
4267
|
function paramNames(params) {
|
|
3917
4268
|
const names = [];
|
|
3918
4269
|
for (const param of params) {
|
|
3919
|
-
const target = param.type ===
|
|
3920
|
-
if (target.type ===
|
|
3921
|
-
else if (target.type ===
|
|
4270
|
+
const target = param.type === AST_NODE_TYPES20.AssignmentPattern ? param.left : param;
|
|
4271
|
+
if (target.type === AST_NODE_TYPES20.Identifier) names.push(target.name);
|
|
4272
|
+
else if (target.type === AST_NODE_TYPES20.TSParameterProperty) continue;
|
|
3922
4273
|
}
|
|
3923
4274
|
return names;
|
|
3924
4275
|
}
|
|
@@ -3960,7 +4311,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3960
4311
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
3961
4312
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3962
4313
|
let declaration = null;
|
|
3963
|
-
while (node != null && node.type !==
|
|
4314
|
+
while (node != null && node.type !== AST_NODE_TYPES20.Program) {
|
|
3964
4315
|
declaration = declarationNames(node);
|
|
3965
4316
|
if (declaration !== null) break;
|
|
3966
4317
|
node = node.parent ?? null;
|
|
@@ -4419,12 +4770,12 @@ var no_select_star_default = createRule({
|
|
|
4419
4770
|
});
|
|
4420
4771
|
|
|
4421
4772
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
4422
|
-
import { AST_NODE_TYPES as
|
|
4773
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES21 } from "@typescript-eslint/utils";
|
|
4423
4774
|
function sentinelKind(arg) {
|
|
4424
4775
|
if (arg === null) {
|
|
4425
4776
|
return null;
|
|
4426
4777
|
}
|
|
4427
|
-
if (arg.type ===
|
|
4778
|
+
if (arg.type === AST_NODE_TYPES21.Literal) {
|
|
4428
4779
|
if (arg.value === null) {
|
|
4429
4780
|
return "nullish";
|
|
4430
4781
|
}
|
|
@@ -4436,13 +4787,13 @@ function sentinelKind(arg) {
|
|
|
4436
4787
|
}
|
|
4437
4788
|
return null;
|
|
4438
4789
|
}
|
|
4439
|
-
if (arg.type ===
|
|
4790
|
+
if (arg.type === AST_NODE_TYPES21.Identifier && arg.name === "undefined") {
|
|
4440
4791
|
return "nullish";
|
|
4441
4792
|
}
|
|
4442
|
-
if (arg.type ===
|
|
4793
|
+
if (arg.type === AST_NODE_TYPES21.ArrayExpression) {
|
|
4443
4794
|
return "array";
|
|
4444
4795
|
}
|
|
4445
|
-
if (arg.type ===
|
|
4796
|
+
if (arg.type === AST_NODE_TYPES21.ObjectExpression) {
|
|
4446
4797
|
return "object";
|
|
4447
4798
|
}
|
|
4448
4799
|
return null;
|
|
@@ -4451,25 +4802,25 @@ function isSentinelArgument(arg) {
|
|
|
4451
4802
|
if (arg === null) {
|
|
4452
4803
|
return false;
|
|
4453
4804
|
}
|
|
4454
|
-
if (arg.type ===
|
|
4805
|
+
if (arg.type === AST_NODE_TYPES21.Literal && arg.value === null) {
|
|
4455
4806
|
return true;
|
|
4456
4807
|
}
|
|
4457
|
-
if (arg.type ===
|
|
4808
|
+
if (arg.type === AST_NODE_TYPES21.Literal && arg.value === false) {
|
|
4458
4809
|
return true;
|
|
4459
4810
|
}
|
|
4460
|
-
if (arg.type ===
|
|
4811
|
+
if (arg.type === AST_NODE_TYPES21.Identifier && arg.name === "undefined") {
|
|
4461
4812
|
return true;
|
|
4462
4813
|
}
|
|
4463
|
-
if (arg.type ===
|
|
4814
|
+
if (arg.type === AST_NODE_TYPES21.ArrayExpression && arg.elements.length === 0) {
|
|
4464
4815
|
return true;
|
|
4465
4816
|
}
|
|
4466
|
-
if (arg.type ===
|
|
4817
|
+
if (arg.type === AST_NODE_TYPES21.ObjectExpression && arg.properties.length === 0) {
|
|
4467
4818
|
return true;
|
|
4468
4819
|
}
|
|
4469
4820
|
return false;
|
|
4470
4821
|
}
|
|
4471
4822
|
function isFunctionNode(node) {
|
|
4472
|
-
return node.type ===
|
|
4823
|
+
return node.type === AST_NODE_TYPES21.FunctionDeclaration || node.type === AST_NODE_TYPES21.FunctionExpression || node.type === AST_NODE_TYPES21.ArrowFunctionExpression;
|
|
4473
4824
|
}
|
|
4474
4825
|
function isNode3(value) {
|
|
4475
4826
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -4509,24 +4860,24 @@ function walkWithinScope(node, visit) {
|
|
|
4509
4860
|
function containsThrow(node) {
|
|
4510
4861
|
return walkWithinScope(
|
|
4511
4862
|
node,
|
|
4512
|
-
(current) => current.type ===
|
|
4863
|
+
(current) => current.type === AST_NODE_TYPES21.ThrowStatement
|
|
4513
4864
|
);
|
|
4514
4865
|
}
|
|
4515
4866
|
function bindsName(param, name) {
|
|
4516
4867
|
switch (param.type) {
|
|
4517
|
-
case
|
|
4868
|
+
case AST_NODE_TYPES21.Identifier:
|
|
4518
4869
|
return param.name === name;
|
|
4519
|
-
case
|
|
4870
|
+
case AST_NODE_TYPES21.AssignmentPattern:
|
|
4520
4871
|
return bindsName(param.left, name);
|
|
4521
|
-
case
|
|
4872
|
+
case AST_NODE_TYPES21.RestElement:
|
|
4522
4873
|
return bindsName(param.argument, name);
|
|
4523
|
-
case
|
|
4874
|
+
case AST_NODE_TYPES21.ArrayPattern:
|
|
4524
4875
|
return param.elements.some(
|
|
4525
4876
|
(element) => element !== null && bindsName(element, name)
|
|
4526
4877
|
);
|
|
4527
|
-
case
|
|
4878
|
+
case AST_NODE_TYPES21.ObjectPattern:
|
|
4528
4879
|
return param.properties.some(
|
|
4529
|
-
(property) => property.type ===
|
|
4880
|
+
(property) => property.type === AST_NODE_TYPES21.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
4530
4881
|
);
|
|
4531
4882
|
default:
|
|
4532
4883
|
return false;
|
|
@@ -4541,7 +4892,7 @@ function subtreeReadsName(node, name) {
|
|
|
4541
4892
|
if (found) {
|
|
4542
4893
|
return;
|
|
4543
4894
|
}
|
|
4544
|
-
if (current.type ===
|
|
4895
|
+
if (current.type === AST_NODE_TYPES21.Identifier && current.name === name) {
|
|
4545
4896
|
found = true;
|
|
4546
4897
|
return;
|
|
4547
4898
|
}
|
|
@@ -4552,10 +4903,10 @@ function subtreeReadsName(node, name) {
|
|
|
4552
4903
|
if (key === "parent") {
|
|
4553
4904
|
continue;
|
|
4554
4905
|
}
|
|
4555
|
-
if (key === "key" && current.type ===
|
|
4906
|
+
if (key === "key" && current.type === AST_NODE_TYPES21.Property && !current.computed) {
|
|
4556
4907
|
continue;
|
|
4557
4908
|
}
|
|
4558
|
-
if (key === "property" && current.type ===
|
|
4909
|
+
if (key === "property" && current.type === AST_NODE_TYPES21.MemberExpression && !current.computed) {
|
|
4559
4910
|
continue;
|
|
4560
4911
|
}
|
|
4561
4912
|
const value = current[key];
|
|
@@ -4588,10 +4939,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4588
4939
|
"URLPattern"
|
|
4589
4940
|
]);
|
|
4590
4941
|
function isParseShapedNode(node) {
|
|
4591
|
-
if (node.type ===
|
|
4942
|
+
if (node.type === AST_NODE_TYPES21.CallExpression && node.callee.type === AST_NODE_TYPES21.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES21.Identifier) {
|
|
4592
4943
|
return node.callee.property.name === "parse";
|
|
4593
4944
|
}
|
|
4594
|
-
if (node.type ===
|
|
4945
|
+
if (node.type === AST_NODE_TYPES21.NewExpression && node.callee.type === AST_NODE_TYPES21.Identifier) {
|
|
4595
4946
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
4596
4947
|
}
|
|
4597
4948
|
return false;
|
|
@@ -4602,10 +4953,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
4602
4953
|
"arrayBuffer"
|
|
4603
4954
|
]);
|
|
4604
4955
|
function isBodyDecodeNode(node) {
|
|
4605
|
-
return node.type ===
|
|
4956
|
+
return node.type === AST_NODE_TYPES21.CallExpression && node.callee.type === AST_NODE_TYPES21.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES21.Identifier && BODY_DECODE_METHODS.has(node.callee.property.name);
|
|
4606
4957
|
}
|
|
4607
4958
|
function returnsMatching(stmt, predicate) {
|
|
4608
|
-
return stmt.type ===
|
|
4959
|
+
return stmt.type === AST_NODE_TYPES21.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
4609
4960
|
}
|
|
4610
4961
|
function enclosingReturnTypeNode(node) {
|
|
4611
4962
|
let current = node.parent;
|
|
@@ -4623,11 +4974,11 @@ function enclosingFunctionName(node) {
|
|
|
4623
4974
|
let current = node.parent;
|
|
4624
4975
|
while (current !== void 0 && current !== null) {
|
|
4625
4976
|
if (isFunctionNode(current)) {
|
|
4626
|
-
if ("id" in current && isNode3(current.id) && current.id.type ===
|
|
4977
|
+
if ("id" in current && isNode3(current.id) && current.id.type === AST_NODE_TYPES21.Identifier) {
|
|
4627
4978
|
return current.id.name;
|
|
4628
4979
|
}
|
|
4629
4980
|
const parent = current.parent;
|
|
4630
|
-
if (parent?.type ===
|
|
4981
|
+
if (parent?.type === AST_NODE_TYPES21.VariableDeclarator && parent.id.type === AST_NODE_TYPES21.Identifier) {
|
|
4631
4982
|
return parent.id.name;
|
|
4632
4983
|
}
|
|
4633
4984
|
return null;
|
|
@@ -4648,10 +4999,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
4648
4999
|
return false;
|
|
4649
5000
|
}
|
|
4650
5001
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
4651
|
-
if (declared?.type ===
|
|
5002
|
+
if (declared?.type === AST_NODE_TYPES21.TSTypeReference && declared.typeName.type === AST_NODE_TYPES21.Identifier && declared.typeName.name === "Promise") {
|
|
4652
5003
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
4653
5004
|
}
|
|
4654
|
-
return declared?.type ===
|
|
5005
|
+
return declared?.type === AST_NODE_TYPES21.TSBooleanKeyword;
|
|
4655
5006
|
}
|
|
4656
5007
|
function tryReturnsSafeParse(catchNode) {
|
|
4657
5008
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -4667,7 +5018,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
4667
5018
|
function enclosingFunctionBody(node) {
|
|
4668
5019
|
let current = node.parent;
|
|
4669
5020
|
while (current !== void 0 && current !== null) {
|
|
4670
|
-
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type ===
|
|
5021
|
+
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === AST_NODE_TYPES21.BlockStatement) {
|
|
4671
5022
|
return current.body;
|
|
4672
5023
|
}
|
|
4673
5024
|
current = current.parent;
|
|
@@ -4680,7 +5031,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
4680
5031
|
return false;
|
|
4681
5032
|
}
|
|
4682
5033
|
return walkWithinScope(functionBody, (current) => {
|
|
4683
|
-
if (current.type !==
|
|
5034
|
+
if (current.type !== AST_NODE_TYPES21.ReturnStatement) {
|
|
4684
5035
|
return false;
|
|
4685
5036
|
}
|
|
4686
5037
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -4699,13 +5050,13 @@ function returnedSentinelKinds(arg) {
|
|
|
4699
5050
|
kinds.add(direct);
|
|
4700
5051
|
return kinds;
|
|
4701
5052
|
}
|
|
4702
|
-
if (arg.type ===
|
|
5053
|
+
if (arg.type === AST_NODE_TYPES21.ConditionalExpression) {
|
|
4703
5054
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
4704
5055
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
4705
5056
|
kinds.add(nested);
|
|
4706
5057
|
}
|
|
4707
5058
|
}
|
|
4708
|
-
} else if (arg.type ===
|
|
5059
|
+
} else if (arg.type === AST_NODE_TYPES21.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
4709
5060
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
4710
5061
|
kinds.add(nested);
|
|
4711
5062
|
}
|
|
@@ -4748,7 +5099,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4748
5099
|
const matcher = createLogMatcher(loggingOptions);
|
|
4749
5100
|
function logsOrReportsError(catchBody, caughtName) {
|
|
4750
5101
|
return walkWithinScope(catchBody, (current) => {
|
|
4751
|
-
if (current.type !==
|
|
5102
|
+
if (current.type !== AST_NODE_TYPES21.CallExpression) {
|
|
4752
5103
|
return false;
|
|
4753
5104
|
}
|
|
4754
5105
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -4765,7 +5116,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4765
5116
|
return;
|
|
4766
5117
|
}
|
|
4767
5118
|
const last = body2[body2.length - 1];
|
|
4768
|
-
if (last === void 0 || last.type !==
|
|
5119
|
+
if (last === void 0 || last.type !== AST_NODE_TYPES21.ReturnStatement) {
|
|
4769
5120
|
return;
|
|
4770
5121
|
}
|
|
4771
5122
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -4774,7 +5125,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4774
5125
|
if (containsThrow(node.body)) {
|
|
4775
5126
|
return;
|
|
4776
5127
|
}
|
|
4777
|
-
const caughtName = node.param?.type ===
|
|
5128
|
+
const caughtName = node.param?.type === AST_NODE_TYPES21.Identifier ? node.param.name : null;
|
|
4778
5129
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
4779
5130
|
return;
|
|
4780
5131
|
}
|
|
@@ -4801,9 +5152,9 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4801
5152
|
});
|
|
4802
5153
|
|
|
4803
5154
|
// src/rules/no-silent-promise-catch.ts
|
|
4804
|
-
import { AST_NODE_TYPES as
|
|
5155
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES22 } from "@typescript-eslint/utils";
|
|
4805
5156
|
function isBodyParseCall(node) {
|
|
4806
|
-
return node.type ===
|
|
5157
|
+
return node.type === AST_NODE_TYPES22.CallExpression && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES22.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES22.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
4807
5158
|
}
|
|
4808
5159
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
4809
5160
|
"cancel",
|
|
@@ -4818,21 +5169,21 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
4818
5169
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
4819
5170
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
4820
5171
|
function isTeardownCall(node) {
|
|
4821
|
-
return node.type ===
|
|
5172
|
+
return node.type === AST_NODE_TYPES22.CallExpression && node.callee.type === AST_NODE_TYPES22.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES22.Identifier && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
4822
5173
|
}
|
|
4823
5174
|
function isSilentExpression(node) {
|
|
4824
5175
|
switch (node.type) {
|
|
4825
|
-
case
|
|
5176
|
+
case AST_NODE_TYPES22.Literal:
|
|
4826
5177
|
return !("regex" in node);
|
|
4827
|
-
case
|
|
5178
|
+
case AST_NODE_TYPES22.Identifier:
|
|
4828
5179
|
return node.name === "undefined";
|
|
4829
|
-
case
|
|
4830
|
-
return node.operator === "void" && node.argument.type ===
|
|
4831
|
-
case
|
|
5180
|
+
case AST_NODE_TYPES22.UnaryExpression:
|
|
5181
|
+
return node.operator === "void" && node.argument.type === AST_NODE_TYPES22.Literal;
|
|
5182
|
+
case AST_NODE_TYPES22.ObjectExpression:
|
|
4832
5183
|
return node.properties.length === 0;
|
|
4833
|
-
case
|
|
5184
|
+
case AST_NODE_TYPES22.ArrayExpression:
|
|
4834
5185
|
return node.elements.length === 0;
|
|
4835
|
-
case
|
|
5186
|
+
case AST_NODE_TYPES22.TSAsExpression:
|
|
4836
5187
|
return isSilentExpression(node.expression);
|
|
4837
5188
|
default:
|
|
4838
5189
|
return false;
|
|
@@ -4840,7 +5191,7 @@ function isSilentExpression(node) {
|
|
|
4840
5191
|
}
|
|
4841
5192
|
function isSilentHandler(handler) {
|
|
4842
5193
|
const body2 = handler.body;
|
|
4843
|
-
if (body2.type !==
|
|
5194
|
+
if (body2.type !== AST_NODE_TYPES22.BlockStatement) {
|
|
4844
5195
|
return isSilentExpression(body2);
|
|
4845
5196
|
}
|
|
4846
5197
|
if (body2.body.length === 0) {
|
|
@@ -4848,7 +5199,7 @@ function isSilentHandler(handler) {
|
|
|
4848
5199
|
}
|
|
4849
5200
|
if (body2.body.length === 1) {
|
|
4850
5201
|
const only = body2.body[0];
|
|
4851
|
-
if (only !== void 0 && only.type ===
|
|
5202
|
+
if (only !== void 0 && only.type === AST_NODE_TYPES22.ReturnStatement) {
|
|
4852
5203
|
return only.argument === null || isSilentExpression(only.argument);
|
|
4853
5204
|
}
|
|
4854
5205
|
}
|
|
@@ -4877,7 +5228,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4877
5228
|
return true;
|
|
4878
5229
|
}
|
|
4879
5230
|
let statement = call;
|
|
4880
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
5231
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== AST_NODE_TYPES22.VariableDeclaration) {
|
|
4881
5232
|
statement = statement.parent;
|
|
4882
5233
|
}
|
|
4883
5234
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -4889,7 +5240,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4889
5240
|
};
|
|
4890
5241
|
return {
|
|
4891
5242
|
CallExpression(node) {
|
|
4892
|
-
if (node.callee.type !==
|
|
5243
|
+
if (node.callee.type !== AST_NODE_TYPES22.MemberExpression || node.callee.computed || node.callee.property.type !== AST_NODE_TYPES22.Identifier || node.callee.property.name !== "catch") {
|
|
4893
5244
|
return;
|
|
4894
5245
|
}
|
|
4895
5246
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -4898,14 +5249,14 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4898
5249
|
if (isTeardownCall(node.callee.object)) {
|
|
4899
5250
|
return;
|
|
4900
5251
|
}
|
|
4901
|
-
if (node.parent.type ===
|
|
5252
|
+
if (node.parent.type === AST_NODE_TYPES22.MemberExpression && node.parent.object === node) {
|
|
4902
5253
|
return;
|
|
4903
5254
|
}
|
|
4904
5255
|
if (node.arguments.length !== 1) {
|
|
4905
5256
|
return;
|
|
4906
5257
|
}
|
|
4907
5258
|
const handler = node.arguments[0];
|
|
4908
|
-
if (handler === void 0 || handler.type !==
|
|
5259
|
+
if (handler === void 0 || handler.type !== AST_NODE_TYPES22.ArrowFunctionExpression && handler.type !== AST_NODE_TYPES22.FunctionExpression) {
|
|
4909
5260
|
return;
|
|
4910
5261
|
}
|
|
4911
5262
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -4920,7 +5271,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4920
5271
|
});
|
|
4921
5272
|
|
|
4922
5273
|
// src/rules/no-sleep-in-test-body.ts
|
|
4923
|
-
import { AST_NODE_TYPES as
|
|
5274
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES23 } from "@typescript-eslint/utils";
|
|
4924
5275
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
4925
5276
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
4926
5277
|
"it",
|
|
@@ -4929,34 +5280,34 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
|
4929
5280
|
"afterEach"
|
|
4930
5281
|
]);
|
|
4931
5282
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
5283
|
+
AST_NODE_TYPES23.FunctionDeclaration,
|
|
5284
|
+
AST_NODE_TYPES23.FunctionExpression,
|
|
5285
|
+
AST_NODE_TYPES23.ArrowFunctionExpression
|
|
4935
5286
|
]);
|
|
4936
5287
|
function isNonzeroNumericLiteral(node) {
|
|
4937
|
-
return node?.type ===
|
|
5288
|
+
return node?.type === AST_NODE_TYPES23.Literal && typeof node.value === "number" && node.value !== 0;
|
|
4938
5289
|
}
|
|
4939
5290
|
function isTimedSetTimeout(node) {
|
|
4940
|
-
return node.type ===
|
|
5291
|
+
return node.type === AST_NODE_TYPES23.CallExpression && node.callee.type === AST_NODE_TYPES23.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
4941
5292
|
}
|
|
4942
5293
|
function isPromiseSleep(node) {
|
|
4943
|
-
if (node.callee.type !==
|
|
5294
|
+
if (node.callee.type !== AST_NODE_TYPES23.Identifier || node.callee.name !== "Promise") {
|
|
4944
5295
|
return false;
|
|
4945
5296
|
}
|
|
4946
5297
|
const executor = node.arguments[0];
|
|
4947
|
-
if (executor?.type !==
|
|
5298
|
+
if (executor?.type !== AST_NODE_TYPES23.ArrowFunctionExpression && executor?.type !== AST_NODE_TYPES23.FunctionExpression) {
|
|
4948
5299
|
return false;
|
|
4949
5300
|
}
|
|
4950
5301
|
const body2 = executor.body;
|
|
4951
|
-
if (body2.type !==
|
|
5302
|
+
if (body2.type !== AST_NODE_TYPES23.BlockStatement) {
|
|
4952
5303
|
return isTimedSetTimeout(body2);
|
|
4953
5304
|
}
|
|
4954
5305
|
return body2.body.some(
|
|
4955
|
-
(stmt) => stmt.type ===
|
|
5306
|
+
(stmt) => stmt.type === AST_NODE_TYPES23.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
4956
5307
|
);
|
|
4957
5308
|
}
|
|
4958
5309
|
function isHelperSleep(node) {
|
|
4959
|
-
return node.callee.type ===
|
|
5310
|
+
return node.callee.type === AST_NODE_TYPES23.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
4960
5311
|
}
|
|
4961
5312
|
function nearestEnclosingFunction2(node) {
|
|
4962
5313
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -4964,7 +5315,7 @@ function nearestEnclosingFunction2(node) {
|
|
|
4964
5315
|
continue;
|
|
4965
5316
|
}
|
|
4966
5317
|
const grandparent = current.parent;
|
|
4967
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
5318
|
+
const isPromiseExecutor = grandparent?.type === AST_NODE_TYPES23.NewExpression && isPromiseSleep(grandparent);
|
|
4968
5319
|
if (!isPromiseExecutor) {
|
|
4969
5320
|
return current;
|
|
4970
5321
|
}
|
|
@@ -4972,23 +5323,23 @@ function nearestEnclosingFunction2(node) {
|
|
|
4972
5323
|
return null;
|
|
4973
5324
|
}
|
|
4974
5325
|
function testCallerName2(callee) {
|
|
4975
|
-
if (callee.type ===
|
|
5326
|
+
if (callee.type === AST_NODE_TYPES23.Identifier) {
|
|
4976
5327
|
return callee.name;
|
|
4977
5328
|
}
|
|
4978
|
-
if (callee.type ===
|
|
5329
|
+
if (callee.type === AST_NODE_TYPES23.MemberExpression) {
|
|
4979
5330
|
return testCallerName2(callee.object);
|
|
4980
5331
|
}
|
|
4981
|
-
if (callee.type ===
|
|
5332
|
+
if (callee.type === AST_NODE_TYPES23.CallExpression) {
|
|
4982
5333
|
return testCallerName2(callee.callee);
|
|
4983
5334
|
}
|
|
4984
|
-
if (callee.type ===
|
|
5335
|
+
if (callee.type === AST_NODE_TYPES23.TaggedTemplateExpression) {
|
|
4985
5336
|
return testCallerName2(callee.tag);
|
|
4986
5337
|
}
|
|
4987
5338
|
return null;
|
|
4988
5339
|
}
|
|
4989
5340
|
function isTestBody2(fn) {
|
|
4990
5341
|
const call = fn.parent;
|
|
4991
|
-
if (call?.type !==
|
|
5342
|
+
if (call?.type !== AST_NODE_TYPES23.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
4992
5343
|
return false;
|
|
4993
5344
|
}
|
|
4994
5345
|
const name = testCallerName2(call.callee);
|
|
@@ -5034,7 +5385,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
5034
5385
|
});
|
|
5035
5386
|
|
|
5036
5387
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
5037
|
-
import { AST_NODE_TYPES as
|
|
5388
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES24 } from "@typescript-eslint/utils";
|
|
5038
5389
|
var DEFAULT_METHODS2 = [
|
|
5039
5390
|
"prepare",
|
|
5040
5391
|
"put",
|
|
@@ -5053,7 +5404,7 @@ function compile2(patterns) {
|
|
|
5053
5404
|
}
|
|
5054
5405
|
function storageMethodName(node, methods) {
|
|
5055
5406
|
const callee = node.callee;
|
|
5056
|
-
if (callee.type !==
|
|
5407
|
+
if (callee.type !== AST_NODE_TYPES24.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES24.Identifier) {
|
|
5057
5408
|
return null;
|
|
5058
5409
|
}
|
|
5059
5410
|
const name = callee.property.name;
|
|
@@ -5267,7 +5618,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
5267
5618
|
});
|
|
5268
5619
|
|
|
5269
5620
|
// src/rules/no-tautological-expect.ts
|
|
5270
|
-
import { AST_NODE_TYPES as
|
|
5621
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES25 } from "@typescript-eslint/utils";
|
|
5271
5622
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
5272
5623
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
5273
5624
|
"toBeDefined",
|
|
@@ -5281,17 +5632,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
5281
5632
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
5282
5633
|
function isLiteral(node) {
|
|
5283
5634
|
switch (node.type) {
|
|
5284
|
-
case
|
|
5635
|
+
case AST_NODE_TYPES25.Literal:
|
|
5285
5636
|
return true;
|
|
5286
|
-
case
|
|
5637
|
+
case AST_NODE_TYPES25.TemplateLiteral:
|
|
5287
5638
|
return node.expressions.length === 0;
|
|
5288
|
-
case
|
|
5639
|
+
case AST_NODE_TYPES25.UnaryExpression:
|
|
5289
5640
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
5290
|
-
case
|
|
5641
|
+
case AST_NODE_TYPES25.ArrayExpression:
|
|
5291
5642
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
5292
|
-
case
|
|
5643
|
+
case AST_NODE_TYPES25.ObjectExpression:
|
|
5293
5644
|
return node.properties.every(
|
|
5294
|
-
(property) => property.type ===
|
|
5645
|
+
(property) => property.type === AST_NODE_TYPES25.Property && !property.computed && isLiteral(property.value)
|
|
5295
5646
|
);
|
|
5296
5647
|
default:
|
|
5297
5648
|
return false;
|
|
@@ -5299,7 +5650,7 @@ function isLiteral(node) {
|
|
|
5299
5650
|
}
|
|
5300
5651
|
function expectOperand(callee) {
|
|
5301
5652
|
const receiver = callee.object;
|
|
5302
|
-
if (receiver.type !==
|
|
5653
|
+
if (receiver.type !== AST_NODE_TYPES25.CallExpression || receiver.callee.type !== AST_NODE_TYPES25.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
5303
5654
|
return null;
|
|
5304
5655
|
}
|
|
5305
5656
|
return receiver.arguments[0] ?? null;
|
|
@@ -5329,10 +5680,10 @@ var no_tautological_expect_default = createRule({
|
|
|
5329
5680
|
return {
|
|
5330
5681
|
CallExpression(node) {
|
|
5331
5682
|
const callee = node.callee;
|
|
5332
|
-
if (callee.type !==
|
|
5683
|
+
if (callee.type !== AST_NODE_TYPES25.MemberExpression || callee.computed) {
|
|
5333
5684
|
return;
|
|
5334
5685
|
}
|
|
5335
|
-
if (callee.property.type !==
|
|
5686
|
+
if (callee.property.type !== AST_NODE_TYPES25.Identifier) {
|
|
5336
5687
|
return;
|
|
5337
5688
|
}
|
|
5338
5689
|
const matcher = callee.property.name;
|
|
@@ -5526,10 +5877,10 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5526
5877
|
});
|
|
5527
5878
|
|
|
5528
5879
|
// src/rules/no-declaration-comment-wall.ts
|
|
5529
|
-
import { AST_NODE_TYPES as
|
|
5880
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES27 } from "@typescript-eslint/utils";
|
|
5530
5881
|
|
|
5531
5882
|
// src/rules/_comment-wall.ts
|
|
5532
|
-
import { AST_NODE_TYPES as
|
|
5883
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES26 } from "@typescript-eslint/utils";
|
|
5533
5884
|
var WALL_DEFAULTS = {
|
|
5534
5885
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5535
5886
|
minCommentedMembers: 3,
|
|
@@ -5633,10 +5984,10 @@ function isWall(members, commented, restated, options) {
|
|
|
5633
5984
|
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5634
5985
|
}
|
|
5635
5986
|
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5987
|
+
AST_NODE_TYPES26.FunctionExpression,
|
|
5988
|
+
AST_NODE_TYPES26.ArrowFunctionExpression,
|
|
5989
|
+
AST_NODE_TYPES26.ObjectExpression,
|
|
5990
|
+
AST_NODE_TYPES26.ArrayExpression
|
|
5640
5991
|
]);
|
|
5641
5992
|
function declarationRange(member) {
|
|
5642
5993
|
const body2 = bodyOf(member);
|
|
@@ -5644,10 +5995,10 @@ function declarationRange(member) {
|
|
|
5644
5995
|
return [member.range[0], body2.range[0]];
|
|
5645
5996
|
}
|
|
5646
5997
|
function bodyOf(member) {
|
|
5647
|
-
if (member.type ===
|
|
5998
|
+
if (member.type === AST_NODE_TYPES26.MethodDefinition || member.type === AST_NODE_TYPES26.TSAbstractMethodDefinition) {
|
|
5648
5999
|
return member.value.body ?? void 0;
|
|
5649
6000
|
}
|
|
5650
|
-
if (member.type ===
|
|
6001
|
+
if (member.type === AST_NODE_TYPES26.Property || member.type === AST_NODE_TYPES26.PropertyDefinition) {
|
|
5651
6002
|
const value = member.value;
|
|
5652
6003
|
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5653
6004
|
}
|
|
@@ -5657,12 +6008,12 @@ function bodyOf(member) {
|
|
|
5657
6008
|
// src/rules/no-declaration-comment-wall.ts
|
|
5658
6009
|
function named(node) {
|
|
5659
6010
|
switch (node.type) {
|
|
5660
|
-
case
|
|
6011
|
+
case AST_NODE_TYPES27.TSEnumMember:
|
|
5661
6012
|
return { node, key: node.id };
|
|
5662
|
-
case
|
|
5663
|
-
case
|
|
5664
|
-
case
|
|
5665
|
-
case
|
|
6013
|
+
case AST_NODE_TYPES27.PropertyDefinition:
|
|
6014
|
+
case AST_NODE_TYPES27.TSAbstractPropertyDefinition:
|
|
6015
|
+
case AST_NODE_TYPES27.MethodDefinition:
|
|
6016
|
+
case AST_NODE_TYPES27.TSAbstractMethodDefinition:
|
|
5666
6017
|
return node.computed ? void 0 : { node, key: node.key };
|
|
5667
6018
|
default:
|
|
5668
6019
|
return void 0;
|
|
@@ -5762,7 +6113,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5762
6113
|
});
|
|
5763
6114
|
|
|
5764
6115
|
// src/rules/no-union-in-comment.ts
|
|
5765
|
-
import { AST_NODE_TYPES as
|
|
6116
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES28 } from "@typescript-eslint/utils";
|
|
5766
6117
|
var MAX_LITERAL_LENGTH = 28;
|
|
5767
6118
|
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5768
6119
|
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
@@ -5781,14 +6132,14 @@ var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
5781
6132
|
function isBareString(node) {
|
|
5782
6133
|
if (node === void 0) return false;
|
|
5783
6134
|
switch (node.type) {
|
|
5784
|
-
case
|
|
6135
|
+
case AST_NODE_TYPES28.TSStringKeyword:
|
|
5785
6136
|
return true;
|
|
5786
6137
|
// `string[]` holds members of the same closed set, one element at a time.
|
|
5787
|
-
case
|
|
6138
|
+
case AST_NODE_TYPES28.TSArrayType:
|
|
5788
6139
|
return isBareString(node.elementType);
|
|
5789
6140
|
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5790
6141
|
// — the checker collapses that one to `string`.
|
|
5791
|
-
case
|
|
6142
|
+
case AST_NODE_TYPES28.TSUnionType:
|
|
5792
6143
|
return node.types.some((member) => isBareString(member));
|
|
5793
6144
|
default:
|
|
5794
6145
|
return false;
|
|
@@ -5798,13 +6149,13 @@ function rootCallee(node) {
|
|
|
5798
6149
|
let current = node;
|
|
5799
6150
|
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5800
6151
|
switch (current.type) {
|
|
5801
|
-
case
|
|
6152
|
+
case AST_NODE_TYPES28.CallExpression:
|
|
5802
6153
|
current = current.callee;
|
|
5803
6154
|
break;
|
|
5804
|
-
case
|
|
6155
|
+
case AST_NODE_TYPES28.MemberExpression:
|
|
5805
6156
|
current = current.object;
|
|
5806
6157
|
break;
|
|
5807
|
-
case
|
|
6158
|
+
case AST_NODE_TYPES28.Identifier:
|
|
5808
6159
|
return current.name;
|
|
5809
6160
|
default:
|
|
5810
6161
|
return null;
|
|
@@ -5813,26 +6164,26 @@ function rootCallee(node) {
|
|
|
5813
6164
|
return null;
|
|
5814
6165
|
}
|
|
5815
6166
|
function nameOf(key) {
|
|
5816
|
-
if (key.type ===
|
|
5817
|
-
if (key.type ===
|
|
6167
|
+
if (key.type === AST_NODE_TYPES28.Identifier) return key.name;
|
|
6168
|
+
if (key.type === AST_NODE_TYPES28.Literal && typeof key.value === "string") return key.value;
|
|
5818
6169
|
return null;
|
|
5819
6170
|
}
|
|
5820
6171
|
function targetOf(node) {
|
|
5821
6172
|
switch (node.type) {
|
|
5822
|
-
case
|
|
5823
|
-
case
|
|
6173
|
+
case AST_NODE_TYPES28.TSPropertySignature:
|
|
6174
|
+
case AST_NODE_TYPES28.PropertyDefinition: {
|
|
5824
6175
|
const name = node.computed ? null : nameOf(node.key);
|
|
5825
6176
|
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5826
6177
|
return { node, name };
|
|
5827
6178
|
}
|
|
5828
|
-
case
|
|
6179
|
+
case AST_NODE_TYPES28.Property: {
|
|
5829
6180
|
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5830
6181
|
const callee = rootCallee(node.value);
|
|
5831
6182
|
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5832
6183
|
return { node, name };
|
|
5833
6184
|
}
|
|
5834
|
-
case
|
|
5835
|
-
if (node.id.type !==
|
|
6185
|
+
case AST_NODE_TYPES28.VariableDeclarator: {
|
|
6186
|
+
if (node.id.type !== AST_NODE_TYPES28.Identifier) return null;
|
|
5836
6187
|
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5837
6188
|
return { node, name: node.id.name };
|
|
5838
6189
|
}
|
|
@@ -5881,7 +6232,7 @@ var no_union_in_comment_default = createRule({
|
|
|
5881
6232
|
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5882
6233
|
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5883
6234
|
}
|
|
5884
|
-
for (let node = anchor; node != null && node.type !==
|
|
6235
|
+
for (let node = anchor; node != null && node.type !== AST_NODE_TYPES28.Program; node = node.parent) {
|
|
5885
6236
|
const target = targetOf(node);
|
|
5886
6237
|
if (target !== null) return target;
|
|
5887
6238
|
}
|
|
@@ -5910,9 +6261,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5910
6261
|
});
|
|
5911
6262
|
|
|
5912
6263
|
// src/rules/no-type-member-comment-wall.ts
|
|
5913
|
-
import { AST_NODE_TYPES as
|
|
6264
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES29 } from "@typescript-eslint/utils";
|
|
5914
6265
|
function isNamedMember(node) {
|
|
5915
|
-
return (node.type ===
|
|
6266
|
+
return (node.type === AST_NODE_TYPES29.TSPropertySignature || node.type === AST_NODE_TYPES29.TSMethodSignature) && !node.computed;
|
|
5916
6267
|
}
|
|
5917
6268
|
var no_type_member_comment_wall_default = createRule({
|
|
5918
6269
|
name: "no-type-member-comment-wall",
|
|
@@ -5959,7 +6310,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5959
6310
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5960
6311
|
}
|
|
5961
6312
|
function check(node) {
|
|
5962
|
-
const members = node.type ===
|
|
6313
|
+
const members = node.type === AST_NODE_TYPES29.TSInterfaceBody ? node.body : node.members;
|
|
5963
6314
|
const named2 = members.filter(isNamedMember);
|
|
5964
6315
|
if (named2.length === 0) return;
|
|
5965
6316
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5999,7 +6350,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5999
6350
|
});
|
|
6000
6351
|
|
|
6001
6352
|
// src/rules/no-unnecessary-use-client.ts
|
|
6002
|
-
import { AST_NODE_TYPES as
|
|
6353
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES30 } from "@typescript-eslint/utils";
|
|
6003
6354
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
6004
6355
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
6005
6356
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -6025,13 +6376,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
6025
6376
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
6026
6377
|
var jsxRootName = (name) => {
|
|
6027
6378
|
let current = name;
|
|
6028
|
-
while (current.type ===
|
|
6379
|
+
while (current.type === AST_NODE_TYPES30.JSXMemberExpression) {
|
|
6029
6380
|
current = current.object;
|
|
6030
6381
|
}
|
|
6031
|
-
return current.type ===
|
|
6382
|
+
return current.type === AST_NODE_TYPES30.JSXIdentifier ? current.name : "";
|
|
6032
6383
|
};
|
|
6033
6384
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
6034
|
-
if (node.type ===
|
|
6385
|
+
if (node.type === AST_NODE_TYPES30.Identifier) {
|
|
6035
6386
|
return imported.has(node.name);
|
|
6036
6387
|
}
|
|
6037
6388
|
for (const key of Object.keys(node)) {
|
|
@@ -6046,16 +6397,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
6046
6397
|
return false;
|
|
6047
6398
|
};
|
|
6048
6399
|
var isUseClientDirective = (node) => {
|
|
6049
|
-
return node.type ===
|
|
6400
|
+
return node.type === AST_NODE_TYPES30.ExpressionStatement && node.expression.type === AST_NODE_TYPES30.Literal && node.expression.value === "use client";
|
|
6050
6401
|
};
|
|
6051
6402
|
var isGlobalReference = (node, context) => {
|
|
6052
6403
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
6053
6404
|
const parent = node.parent;
|
|
6054
6405
|
if (parent !== void 0) {
|
|
6055
|
-
if (parent.type ===
|
|
6406
|
+
if (parent.type === AST_NODE_TYPES30.MemberExpression && parent.property === node && !parent.computed) {
|
|
6056
6407
|
return false;
|
|
6057
6408
|
}
|
|
6058
|
-
if (parent.type ===
|
|
6409
|
+
if (parent.type === AST_NODE_TYPES30.Property && parent.key === node && !parent.computed) {
|
|
6059
6410
|
return false;
|
|
6060
6411
|
}
|
|
6061
6412
|
if (parent.type.startsWith("TS")) {
|
|
@@ -6095,13 +6446,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6095
6446
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
6096
6447
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
6097
6448
|
const markIfHookOrContext = (callee) => {
|
|
6098
|
-
if (callee.type ===
|
|
6449
|
+
if (callee.type === AST_NODE_TYPES30.Identifier) {
|
|
6099
6450
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
6100
6451
|
hasClientIndicator = true;
|
|
6101
6452
|
}
|
|
6102
6453
|
return;
|
|
6103
6454
|
}
|
|
6104
|
-
if (callee.type ===
|
|
6455
|
+
if (callee.type === AST_NODE_TYPES30.MemberExpression && callee.property.type === AST_NODE_TYPES30.Identifier) {
|
|
6105
6456
|
const name = callee.property.name;
|
|
6106
6457
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
6107
6458
|
hasClientIndicator = true;
|
|
@@ -6111,7 +6462,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6111
6462
|
return {
|
|
6112
6463
|
Program(node) {
|
|
6113
6464
|
for (const stmt of node.body) {
|
|
6114
|
-
if (stmt.type !==
|
|
6465
|
+
if (stmt.type !== AST_NODE_TYPES30.ExpressionStatement) break;
|
|
6115
6466
|
if (isUseClientDirective(stmt)) {
|
|
6116
6467
|
directiveNode = stmt;
|
|
6117
6468
|
break;
|
|
@@ -6124,7 +6475,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6124
6475
|
},
|
|
6125
6476
|
JSXAttribute(node) {
|
|
6126
6477
|
if (directiveNode === null) return;
|
|
6127
|
-
if (node.name.type ===
|
|
6478
|
+
if (node.name.type === AST_NODE_TYPES30.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
6128
6479
|
hasClientIndicator = true;
|
|
6129
6480
|
}
|
|
6130
6481
|
},
|
|
@@ -6192,17 +6543,17 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6192
6543
|
|
|
6193
6544
|
// src/rules/no-unsafe-mock-casting.ts
|
|
6194
6545
|
import "@typescript-eslint/utils";
|
|
6195
|
-
import { AST_NODE_TYPES as
|
|
6546
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES31 } from "@typescript-eslint/utils";
|
|
6196
6547
|
function isMockTypeReference(node) {
|
|
6197
|
-
if (node.type !==
|
|
6548
|
+
if (node.type !== AST_NODE_TYPES31.TSTypeReference) {
|
|
6198
6549
|
return false;
|
|
6199
6550
|
}
|
|
6200
6551
|
const typeName = node.typeName;
|
|
6201
|
-
if (typeName.type ===
|
|
6552
|
+
if (typeName.type === AST_NODE_TYPES31.Identifier) {
|
|
6202
6553
|
const name = typeName.name;
|
|
6203
6554
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
6204
6555
|
}
|
|
6205
|
-
if (typeName.type ===
|
|
6556
|
+
if (typeName.type === AST_NODE_TYPES31.TSQualifiedName) {
|
|
6206
6557
|
const rightName = typeName.right.name;
|
|
6207
6558
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
6208
6559
|
}
|
|
@@ -6240,7 +6591,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
6240
6591
|
// src/rules/no-zod-native-enum.ts
|
|
6241
6592
|
import {
|
|
6242
6593
|
ESLintUtils as ESLintUtils2,
|
|
6243
|
-
AST_NODE_TYPES as
|
|
6594
|
+
AST_NODE_TYPES as AST_NODE_TYPES32
|
|
6244
6595
|
} from "@typescript-eslint/utils";
|
|
6245
6596
|
import * as ts from "typescript";
|
|
6246
6597
|
var IGNORE_PATTERNS = [
|
|
@@ -6259,7 +6610,7 @@ function isZodModule(source) {
|
|
|
6259
6610
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
6260
6611
|
}
|
|
6261
6612
|
function unwrap2(node) {
|
|
6262
|
-
if (node.type ===
|
|
6613
|
+
if (node.type === AST_NODE_TYPES32.TSAsExpression || node.type === AST_NODE_TYPES32.TSSatisfiesExpression) {
|
|
6263
6614
|
return unwrap2(node.expression);
|
|
6264
6615
|
}
|
|
6265
6616
|
return node;
|
|
@@ -6267,14 +6618,14 @@ function unwrap2(node) {
|
|
|
6267
6618
|
function stringValueTexts(node, sourceCode) {
|
|
6268
6619
|
const texts = [];
|
|
6269
6620
|
for (const prop of node.properties) {
|
|
6270
|
-
if (prop.type !==
|
|
6621
|
+
if (prop.type !== AST_NODE_TYPES32.Property) {
|
|
6271
6622
|
return null;
|
|
6272
6623
|
}
|
|
6273
6624
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6274
6625
|
return null;
|
|
6275
6626
|
}
|
|
6276
6627
|
const value = prop.value;
|
|
6277
|
-
if (value.type !==
|
|
6628
|
+
if (value.type !== AST_NODE_TYPES32.Literal || typeof value.value !== "string") {
|
|
6278
6629
|
return null;
|
|
6279
6630
|
}
|
|
6280
6631
|
const text = sourceCode.getText(value);
|
|
@@ -6290,7 +6641,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6290
6641
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6291
6642
|
if (variable !== void 0) {
|
|
6292
6643
|
return variable.defs.some(
|
|
6293
|
-
(def) => def.node.type ===
|
|
6644
|
+
(def) => def.node.type === AST_NODE_TYPES32.TSEnumDeclaration
|
|
6294
6645
|
);
|
|
6295
6646
|
}
|
|
6296
6647
|
current = current.upper;
|
|
@@ -6342,25 +6693,25 @@ var no_zod_native_enum_default = createRule({
|
|
|
6342
6693
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6343
6694
|
function isZodMemberCall(node, api) {
|
|
6344
6695
|
const callee = node.callee;
|
|
6345
|
-
if (callee.type ===
|
|
6696
|
+
if (callee.type === AST_NODE_TYPES32.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES32.Identifier) {
|
|
6346
6697
|
return callee.property.name === api;
|
|
6347
6698
|
}
|
|
6348
|
-
if (callee.type ===
|
|
6699
|
+
if (callee.type === AST_NODE_TYPES32.Identifier) {
|
|
6349
6700
|
return zodImportedNames.get(callee.name) === api;
|
|
6350
6701
|
}
|
|
6351
6702
|
return false;
|
|
6352
6703
|
}
|
|
6353
6704
|
function buildFix(node) {
|
|
6354
6705
|
const callee = node.callee;
|
|
6355
|
-
if (callee.type !==
|
|
6706
|
+
if (callee.type !== AST_NODE_TYPES32.MemberExpression || callee.property.type !== AST_NODE_TYPES32.Identifier) {
|
|
6356
6707
|
return null;
|
|
6357
6708
|
}
|
|
6358
6709
|
const arg = node.arguments[0];
|
|
6359
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6710
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === AST_NODE_TYPES32.SpreadElement) {
|
|
6360
6711
|
return null;
|
|
6361
6712
|
}
|
|
6362
6713
|
const inner = unwrap2(arg);
|
|
6363
|
-
if (inner.type !==
|
|
6714
|
+
if (inner.type !== AST_NODE_TYPES32.ObjectExpression) {
|
|
6364
6715
|
return null;
|
|
6365
6716
|
}
|
|
6366
6717
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6380,7 +6731,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6380
6731
|
return;
|
|
6381
6732
|
}
|
|
6382
6733
|
for (const spec of node.specifiers) {
|
|
6383
|
-
if (spec.type ===
|
|
6734
|
+
if (spec.type === AST_NODE_TYPES32.ImportSpecifier && spec.imported.type === AST_NODE_TYPES32.Identifier) {
|
|
6384
6735
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6385
6736
|
}
|
|
6386
6737
|
}
|
|
@@ -6399,7 +6750,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6399
6750
|
return;
|
|
6400
6751
|
}
|
|
6401
6752
|
const arg = node.arguments[0];
|
|
6402
|
-
if (arg === void 0 || arg.type !==
|
|
6753
|
+
if (arg === void 0 || arg.type !== AST_NODE_TYPES32.Identifier) {
|
|
6403
6754
|
return;
|
|
6404
6755
|
}
|
|
6405
6756
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6416,7 +6767,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6416
6767
|
});
|
|
6417
6768
|
|
|
6418
6769
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6419
|
-
import { AST_NODE_TYPES as
|
|
6770
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES33 } from "@typescript-eslint/utils";
|
|
6420
6771
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6421
6772
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6422
6773
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6429,36 +6780,36 @@ function isConstantReference(identifier) {
|
|
|
6429
6780
|
}
|
|
6430
6781
|
function isExcludedOperand(node) {
|
|
6431
6782
|
switch (node.type) {
|
|
6432
|
-
case
|
|
6783
|
+
case AST_NODE_TYPES33.Literal:
|
|
6433
6784
|
return true;
|
|
6434
|
-
case
|
|
6785
|
+
case AST_NODE_TYPES33.TemplateLiteral:
|
|
6435
6786
|
return node.expressions.length === 0;
|
|
6436
|
-
case
|
|
6787
|
+
case AST_NODE_TYPES33.Identifier:
|
|
6437
6788
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6438
|
-
case
|
|
6439
|
-
return !node.computed && node.property.type ===
|
|
6789
|
+
case AST_NODE_TYPES33.MemberExpression:
|
|
6790
|
+
return !node.computed && node.property.type === AST_NODE_TYPES33.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6440
6791
|
default:
|
|
6441
6792
|
return false;
|
|
6442
6793
|
}
|
|
6443
6794
|
}
|
|
6444
6795
|
function operandName(node) {
|
|
6445
|
-
if (node.type ===
|
|
6796
|
+
if (node.type === AST_NODE_TYPES33.Identifier) {
|
|
6446
6797
|
return node.name;
|
|
6447
6798
|
}
|
|
6448
|
-
if (node.type ===
|
|
6799
|
+
if (node.type === AST_NODE_TYPES33.MemberExpression && !node.computed && node.property.type === AST_NODE_TYPES33.Identifier) {
|
|
6449
6800
|
return node.property.name;
|
|
6450
6801
|
}
|
|
6451
6802
|
return null;
|
|
6452
6803
|
}
|
|
6453
6804
|
function isSecretOperand(node) {
|
|
6454
|
-
if (node.type ===
|
|
6805
|
+
if (node.type === AST_NODE_TYPES33.TemplateLiteral) {
|
|
6455
6806
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6456
6807
|
}
|
|
6457
6808
|
const name = operandName(node);
|
|
6458
6809
|
return name !== null && isAuthSecretName(name);
|
|
6459
6810
|
}
|
|
6460
6811
|
function secretNameOf(node) {
|
|
6461
|
-
if (node.type ===
|
|
6812
|
+
if (node.type === AST_NODE_TYPES33.TemplateLiteral) {
|
|
6462
6813
|
for (const expression of node.expressions) {
|
|
6463
6814
|
const nested = secretNameOf(expression);
|
|
6464
6815
|
if (nested !== null) {
|
|
@@ -6511,7 +6862,7 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
6511
6862
|
|
|
6512
6863
|
// src/rules/prefer-discriminated-union.ts
|
|
6513
6864
|
import "@typescript-eslint/utils";
|
|
6514
|
-
import { AST_NODE_TYPES as
|
|
6865
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES34 } from "@typescript-eslint/utils";
|
|
6515
6866
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
6516
6867
|
"success",
|
|
6517
6868
|
"ok",
|
|
@@ -6521,27 +6872,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6521
6872
|
]);
|
|
6522
6873
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
6523
6874
|
function getMemberName(member) {
|
|
6524
|
-
if (member.type !==
|
|
6875
|
+
if (member.type !== AST_NODE_TYPES34.TSPropertySignature) {
|
|
6525
6876
|
return null;
|
|
6526
6877
|
}
|
|
6527
6878
|
const { key } = member;
|
|
6528
|
-
if (key.type ===
|
|
6879
|
+
if (key.type === AST_NODE_TYPES34.Identifier) {
|
|
6529
6880
|
return key.name;
|
|
6530
6881
|
}
|
|
6531
|
-
if (key.type ===
|
|
6882
|
+
if (key.type === AST_NODE_TYPES34.Literal && typeof key.value === "string") {
|
|
6532
6883
|
return key.value;
|
|
6533
6884
|
}
|
|
6534
6885
|
return null;
|
|
6535
6886
|
}
|
|
6536
6887
|
function isBooleanTyped(member) {
|
|
6537
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6888
|
+
return member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES34.TSBooleanKeyword;
|
|
6538
6889
|
}
|
|
6539
6890
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
6540
6891
|
let hasStatusBoolean = false;
|
|
6541
6892
|
let optionalCount = 0;
|
|
6542
6893
|
let optionalPayloadCount = 0;
|
|
6543
6894
|
for (const member of typeLiteral.members) {
|
|
6544
|
-
if (member.type !==
|
|
6895
|
+
if (member.type !== AST_NODE_TYPES34.TSPropertySignature) {
|
|
6545
6896
|
continue;
|
|
6546
6897
|
}
|
|
6547
6898
|
if (member.optional) {
|
|
@@ -6583,7 +6934,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6583
6934
|
TSInterfaceDeclaration(node) {
|
|
6584
6935
|
const synthetic = {
|
|
6585
6936
|
...node.body,
|
|
6586
|
-
type:
|
|
6937
|
+
type: AST_NODE_TYPES34.TSTypeLiteral,
|
|
6587
6938
|
members: node.body.body
|
|
6588
6939
|
};
|
|
6589
6940
|
checkTypeLiteral(synthetic, node);
|
|
@@ -6596,21 +6947,21 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6596
6947
|
});
|
|
6597
6948
|
|
|
6598
6949
|
// src/rules/prefer-input-group-search.ts
|
|
6599
|
-
import { AST_NODE_TYPES as
|
|
6950
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35 } from "@typescript-eslint/utils";
|
|
6600
6951
|
var INPUT_MODULE = /(?:^|\/)components\/ui\/input$/u;
|
|
6601
6952
|
var INPUT_GROUP_MODULE = /(?:^|\/)components\/ui\/input-group$/u;
|
|
6602
6953
|
var MAX_JSX_DISTANCE = 2;
|
|
6603
6954
|
function localNamedImports(node, importedName) {
|
|
6604
6955
|
return node.specifiers.filter(
|
|
6605
|
-
(specifier) => specifier.type ===
|
|
6956
|
+
(specifier) => specifier.type === AST_NODE_TYPES35.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES35.Identifier ? specifier.imported.name : specifier.imported.value) === importedName
|
|
6606
6957
|
).map((specifier) => specifier.local.name);
|
|
6607
6958
|
}
|
|
6608
6959
|
function elementName(node) {
|
|
6609
|
-
return node.name.type ===
|
|
6960
|
+
return node.name.type === AST_NODE_TYPES35.JSXIdentifier ? node.name.name : null;
|
|
6610
6961
|
}
|
|
6611
6962
|
function jsxAncestors(occurrence) {
|
|
6612
6963
|
return occurrence.ancestors.filter(
|
|
6613
|
-
(ancestor) => ancestor.type ===
|
|
6964
|
+
(ancestor) => ancestor.type === AST_NODE_TYPES35.JSXElement
|
|
6614
6965
|
);
|
|
6615
6966
|
}
|
|
6616
6967
|
function isWithinInputGroup(occurrence, inputGroupNames) {
|
|
@@ -6709,7 +7060,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
6709
7060
|
});
|
|
6710
7061
|
|
|
6711
7062
|
// src/rules/prefer-immutable-module-constant.ts
|
|
6712
|
-
import { AST_NODE_TYPES as
|
|
7063
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
|
|
6713
7064
|
var CONSTANT_NAME = /^_?[A-Z][A-Z0-9_]*$/;
|
|
6714
7065
|
var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
6715
7066
|
"add",
|
|
@@ -6727,43 +7078,43 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6727
7078
|
"unshift"
|
|
6728
7079
|
]);
|
|
6729
7080
|
function isAsConst(node, sourceText) {
|
|
6730
|
-
if (node.type ===
|
|
7081
|
+
if (node.type === AST_NODE_TYPES36.TSSatisfiesExpression) {
|
|
6731
7082
|
return isAsConst(node.expression, sourceText);
|
|
6732
7083
|
}
|
|
6733
|
-
return node.type ===
|
|
7084
|
+
return node.type === AST_NODE_TYPES36.TSAsExpression && sourceText(node.typeAnnotation).trim() === "const";
|
|
6734
7085
|
}
|
|
6735
7086
|
function unwrapExpression(node) {
|
|
6736
|
-
if (node.type ===
|
|
7087
|
+
if (node.type === AST_NODE_TYPES36.TSAsExpression || node.type === AST_NODE_TYPES36.TSSatisfiesExpression || node.type === AST_NODE_TYPES36.TSNonNullExpression) {
|
|
6737
7088
|
return unwrapExpression(node.expression);
|
|
6738
7089
|
}
|
|
6739
7090
|
return node;
|
|
6740
7091
|
}
|
|
6741
7092
|
function isObjectFreeze(node, isUnshadowedGlobal) {
|
|
6742
7093
|
const inner = unwrapExpression(node);
|
|
6743
|
-
if (inner.type ===
|
|
7094
|
+
if (inner.type === AST_NODE_TYPES36.CallExpression && inner.callee.type === AST_NODE_TYPES36.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES36.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === AST_NODE_TYPES36.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1) {
|
|
6744
7095
|
const argument = inner.arguments[0];
|
|
6745
|
-
return argument !== void 0 && argument.type !==
|
|
7096
|
+
return argument !== void 0 && argument.type !== AST_NODE_TYPES36.SpreadElement && collectionKind(argument, isUnshadowedGlobal) === "literal";
|
|
6746
7097
|
}
|
|
6747
7098
|
return false;
|
|
6748
7099
|
}
|
|
6749
7100
|
function collectionKind(node, isUnshadowedGlobal) {
|
|
6750
7101
|
const inner = unwrapExpression(node);
|
|
6751
|
-
if (inner.type ===
|
|
7102
|
+
if (inner.type === AST_NODE_TYPES36.CallExpression && inner.callee.type === AST_NODE_TYPES36.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES36.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === AST_NODE_TYPES36.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES36.SpreadElement) {
|
|
6752
7103
|
return collectionKind(inner.arguments[0], isUnshadowedGlobal);
|
|
6753
7104
|
}
|
|
6754
|
-
if (inner.type ===
|
|
7105
|
+
if (inner.type === AST_NODE_TYPES36.ArrayExpression || inner.type === AST_NODE_TYPES36.ObjectExpression) {
|
|
6755
7106
|
return "literal";
|
|
6756
7107
|
}
|
|
6757
|
-
if (inner.type ===
|
|
7108
|
+
if (inner.type === AST_NODE_TYPES36.NewExpression && inner.callee.type === AST_NODE_TYPES36.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map") && isUnshadowedGlobal(inner.callee)) {
|
|
6758
7109
|
return inner.callee.name;
|
|
6759
7110
|
}
|
|
6760
7111
|
return null;
|
|
6761
7112
|
}
|
|
6762
7113
|
function isReadonlyType(node, kind) {
|
|
6763
|
-
if (node.type ===
|
|
7114
|
+
if (node.type === AST_NODE_TYPES36.TSTypeOperator && node.operator === "readonly") {
|
|
6764
7115
|
return true;
|
|
6765
7116
|
}
|
|
6766
|
-
if (node.type !==
|
|
7117
|
+
if (node.type !== AST_NODE_TYPES36.TSTypeReference || node.typeName.type !== AST_NODE_TYPES36.Identifier) {
|
|
6767
7118
|
return false;
|
|
6768
7119
|
}
|
|
6769
7120
|
if (node.typeName.name === "Readonly") {
|
|
@@ -6772,31 +7123,31 @@ function isReadonlyType(node, kind) {
|
|
|
6772
7123
|
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
6773
7124
|
}
|
|
6774
7125
|
function declaredReadonlyType(node, kind) {
|
|
6775
|
-
const annotation = node.id.type ===
|
|
7126
|
+
const annotation = node.id.type === AST_NODE_TYPES36.Identifier ? node.id.typeAnnotation : void 0;
|
|
6776
7127
|
if (annotation !== void 0 && isReadonlyType(annotation.typeAnnotation, kind)) {
|
|
6777
7128
|
return true;
|
|
6778
7129
|
}
|
|
6779
|
-
return node.init?.type ===
|
|
7130
|
+
return node.init?.type === AST_NODE_TYPES36.TSAsExpression && isReadonlyType(node.init.typeAnnotation, kind);
|
|
6780
7131
|
}
|
|
6781
7132
|
function referenceMutates(identifier) {
|
|
6782
7133
|
let member = identifier.parent;
|
|
6783
|
-
if (member?.type !==
|
|
6784
|
-
return member?.type ===
|
|
7134
|
+
if (member?.type !== AST_NODE_TYPES36.MemberExpression || member.object !== identifier) {
|
|
7135
|
+
return member?.type === AST_NODE_TYPES36.CallExpression && member.arguments[0] === identifier && member.callee.type === AST_NODE_TYPES36.MemberExpression && !member.callee.computed && member.callee.object.type === AST_NODE_TYPES36.Identifier && member.callee.object.name === "Object" && member.callee.property.type === AST_NODE_TYPES36.Identifier && member.callee.property.name === "assign";
|
|
6785
7136
|
}
|
|
6786
|
-
while (member.parent.type ===
|
|
7137
|
+
while (member.parent.type === AST_NODE_TYPES36.MemberExpression && member.parent.object === member) {
|
|
6787
7138
|
member = member.parent;
|
|
6788
7139
|
}
|
|
6789
7140
|
const parent = member.parent;
|
|
6790
|
-
if (parent?.type ===
|
|
7141
|
+
if (parent?.type === AST_NODE_TYPES36.AssignmentExpression && parent.left === member) {
|
|
6791
7142
|
return true;
|
|
6792
7143
|
}
|
|
6793
|
-
if (parent?.type ===
|
|
7144
|
+
if (parent?.type === AST_NODE_TYPES36.UpdateExpression && parent.argument === member) {
|
|
6794
7145
|
return true;
|
|
6795
7146
|
}
|
|
6796
|
-
if (parent?.type ===
|
|
7147
|
+
if (parent?.type === AST_NODE_TYPES36.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
6797
7148
|
return true;
|
|
6798
7149
|
}
|
|
6799
|
-
return parent?.type ===
|
|
7150
|
+
return parent?.type === AST_NODE_TYPES36.CallExpression && parent.callee === member && member.property.type === AST_NODE_TYPES36.Identifier && MUTATING_METHODS.has(member.property.name);
|
|
6800
7151
|
}
|
|
6801
7152
|
var prefer_immutable_module_constant_default = createRule({
|
|
6802
7153
|
name: "prefer-immutable-module-constant",
|
|
@@ -6815,7 +7166,7 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
6815
7166
|
create(context) {
|
|
6816
7167
|
const sourceCode = context.sourceCode;
|
|
6817
7168
|
const isUnshadowedGlobal = (identifier) => {
|
|
6818
|
-
const variable =
|
|
7169
|
+
const variable = ASTUtils4.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
6819
7170
|
return variable === null || variable.defs.length === 0;
|
|
6820
7171
|
};
|
|
6821
7172
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
@@ -6824,11 +7175,11 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
6824
7175
|
return {
|
|
6825
7176
|
VariableDeclarator(node) {
|
|
6826
7177
|
const declaration = node.parent;
|
|
6827
|
-
if (declaration.type !==
|
|
7178
|
+
if (declaration.type !== AST_NODE_TYPES36.VariableDeclaration || declaration.kind !== "const" || node.id.type !== AST_NODE_TYPES36.Identifier || node.init === null || !CONSTANT_NAME.test(node.id.name)) {
|
|
6828
7179
|
return;
|
|
6829
7180
|
}
|
|
6830
7181
|
const container = declaration.parent;
|
|
6831
|
-
if (container.type !==
|
|
7182
|
+
if (container.type !== AST_NODE_TYPES36.Program && !(container.type === AST_NODE_TYPES36.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES36.Program)) {
|
|
6832
7183
|
return;
|
|
6833
7184
|
}
|
|
6834
7185
|
if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init, isUnshadowedGlobal)) {
|
|
@@ -6840,7 +7191,7 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
6840
7191
|
}
|
|
6841
7192
|
const variable = sourceCode.getDeclaredVariables(node)[0];
|
|
6842
7193
|
if (variable?.references.some(
|
|
6843
|
-
(reference) => reference.identifier.type ===
|
|
7194
|
+
(reference) => reference.identifier.type === AST_NODE_TYPES36.Identifier && referenceMutates(reference.identifier)
|
|
6844
7195
|
) === true) {
|
|
6845
7196
|
return;
|
|
6846
7197
|
}
|
|
@@ -6855,7 +7206,7 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
6855
7206
|
});
|
|
6856
7207
|
|
|
6857
7208
|
// src/rules/prefer-shadcn-primitives.ts
|
|
6858
|
-
import { AST_NODE_TYPES as
|
|
7209
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37 } from "@typescript-eslint/utils";
|
|
6859
7210
|
var SHADCN_PRIMITIVES = {
|
|
6860
7211
|
button: "Button",
|
|
6861
7212
|
dialog: "Dialog or AlertDialog family",
|
|
@@ -6876,15 +7227,15 @@ var LABELABLE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
6876
7227
|
"textarea"
|
|
6877
7228
|
]);
|
|
6878
7229
|
function rawElementName(node) {
|
|
6879
|
-
if (node.name.type !==
|
|
7230
|
+
if (node.name.type !== AST_NODE_TYPES37.JSXIdentifier) return null;
|
|
6880
7231
|
const name = node.name.name;
|
|
6881
7232
|
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
6882
7233
|
}
|
|
6883
7234
|
function staticExpressionString(expression) {
|
|
6884
|
-
if (expression.type ===
|
|
7235
|
+
if (expression.type === AST_NODE_TYPES37.Literal) {
|
|
6885
7236
|
return typeof expression.value === "string" ? expression.value : null;
|
|
6886
7237
|
}
|
|
6887
|
-
if (expression.type ===
|
|
7238
|
+
if (expression.type === AST_NODE_TYPES37.TemplateLiteral) {
|
|
6888
7239
|
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
6889
7240
|
for (const [index, substitution] of expression.expressions.entries()) {
|
|
6890
7241
|
const staticSubstitution = staticExpressionString(substitution);
|
|
@@ -6894,24 +7245,24 @@ function staticExpressionString(expression) {
|
|
|
6894
7245
|
}
|
|
6895
7246
|
return value;
|
|
6896
7247
|
}
|
|
6897
|
-
if (expression.type ===
|
|
7248
|
+
if (expression.type === AST_NODE_TYPES37.TSAsExpression || expression.type === AST_NODE_TYPES37.TSNonNullExpression || expression.type === AST_NODE_TYPES37.TSSatisfiesExpression || expression.type === AST_NODE_TYPES37.TSTypeAssertion) {
|
|
6898
7249
|
return staticExpressionString(expression.expression);
|
|
6899
7250
|
}
|
|
6900
7251
|
return null;
|
|
6901
7252
|
}
|
|
6902
7253
|
function staticString(value) {
|
|
6903
|
-
if (value?.type ===
|
|
7254
|
+
if (value?.type === AST_NODE_TYPES37.Literal) {
|
|
6904
7255
|
return typeof value.value === "string" ? value.value : null;
|
|
6905
7256
|
}
|
|
6906
|
-
if (value?.type !==
|
|
7257
|
+
if (value?.type !== AST_NODE_TYPES37.JSXExpressionContainer) return null;
|
|
6907
7258
|
return staticExpressionString(value.expression);
|
|
6908
7259
|
}
|
|
6909
7260
|
function effectiveAttribute(node, attributeName) {
|
|
6910
7261
|
for (const attribute of node.attributes.toReversed()) {
|
|
6911
|
-
if (attribute.type ===
|
|
7262
|
+
if (attribute.type === AST_NODE_TYPES37.JSXSpreadAttribute) {
|
|
6912
7263
|
return { kind: "unknown" };
|
|
6913
7264
|
}
|
|
6914
|
-
if (attribute.name.type !==
|
|
7265
|
+
if (attribute.name.type !== AST_NODE_TYPES37.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
6915
7266
|
continue;
|
|
6916
7267
|
}
|
|
6917
7268
|
const value = staticString(attribute.value);
|
|
@@ -6920,7 +7271,7 @@ function effectiveAttribute(node, attributeName) {
|
|
|
6920
7271
|
return { kind: "missing" };
|
|
6921
7272
|
}
|
|
6922
7273
|
function isLabelableElement(node) {
|
|
6923
|
-
if (node.openingElement.name.type !==
|
|
7274
|
+
if (node.openingElement.name.type !== AST_NODE_TYPES37.JSXIdentifier) {
|
|
6924
7275
|
return false;
|
|
6925
7276
|
}
|
|
6926
7277
|
const name = node.openingElement.name.name;
|
|
@@ -6932,10 +7283,10 @@ function isLabelableElement(node) {
|
|
|
6932
7283
|
}
|
|
6933
7284
|
function containsLabelableElement(node) {
|
|
6934
7285
|
return node.children.some((child) => {
|
|
6935
|
-
if (child.type ===
|
|
7286
|
+
if (child.type === AST_NODE_TYPES37.JSXElement) {
|
|
6936
7287
|
return isLabelableElement(child) || containsLabelableElement(child);
|
|
6937
7288
|
}
|
|
6938
|
-
if (child.type ===
|
|
7289
|
+
if (child.type === AST_NODE_TYPES37.JSXFragment) {
|
|
6939
7290
|
return containsLabelableElement(child);
|
|
6940
7291
|
}
|
|
6941
7292
|
return false;
|
|
@@ -6944,7 +7295,7 @@ function containsLabelableElement(node) {
|
|
|
6944
7295
|
function isStaticallyAssociatedLabel(node) {
|
|
6945
7296
|
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
6946
7297
|
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
6947
|
-
return node.parent.type ===
|
|
7298
|
+
return node.parent.type === AST_NODE_TYPES37.JSXElement && containsLabelableElement(node.parent);
|
|
6948
7299
|
}
|
|
6949
7300
|
function replacementFor(node, element) {
|
|
6950
7301
|
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
@@ -6988,7 +7339,7 @@ var prefer_shadcn_primitives_default = createRule({
|
|
|
6988
7339
|
});
|
|
6989
7340
|
|
|
6990
7341
|
// src/rules/prefer-module-level-constant.ts
|
|
6991
|
-
import { AST_NODE_TYPES as
|
|
7342
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
6992
7343
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6993
7344
|
var MAX_LITERAL_DEPTH = 4;
|
|
6994
7345
|
var IGNORE_PATTERNS2 = [
|
|
@@ -7017,9 +7368,9 @@ var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
|
7017
7368
|
"assign"
|
|
7018
7369
|
]);
|
|
7019
7370
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7371
|
+
AST_NODE_TYPES38.FunctionDeclaration,
|
|
7372
|
+
AST_NODE_TYPES38.FunctionExpression,
|
|
7373
|
+
AST_NODE_TYPES38.ArrowFunctionExpression
|
|
7023
7374
|
]);
|
|
7024
7375
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
7025
7376
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -7032,14 +7383,14 @@ function isLocalFixtureFile(filename) {
|
|
|
7032
7383
|
return isTestFile(filename) || isStoryFile(filename);
|
|
7033
7384
|
}
|
|
7034
7385
|
function unwrap3(node) {
|
|
7035
|
-
if (node.type ===
|
|
7386
|
+
if (node.type === AST_NODE_TYPES38.TSAsExpression || node.type === AST_NODE_TYPES38.TSSatisfiesExpression || node.type === AST_NODE_TYPES38.TSNonNullExpression) {
|
|
7036
7387
|
return unwrap3(node.expression);
|
|
7037
7388
|
}
|
|
7038
7389
|
return node;
|
|
7039
7390
|
}
|
|
7040
7391
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
7041
7392
|
function isRegexLiteral(node) {
|
|
7042
|
-
return node.type ===
|
|
7393
|
+
return node.type === AST_NODE_TYPES38.Literal && "regex" in node && node.regex !== void 0;
|
|
7043
7394
|
}
|
|
7044
7395
|
function isLiteralOnly(node, depth) {
|
|
7045
7396
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -7047,29 +7398,29 @@ function isLiteralOnly(node, depth) {
|
|
|
7047
7398
|
}
|
|
7048
7399
|
const inner = unwrap3(node);
|
|
7049
7400
|
switch (inner.type) {
|
|
7050
|
-
case
|
|
7401
|
+
case AST_NODE_TYPES38.Literal: {
|
|
7051
7402
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
7052
7403
|
}
|
|
7053
|
-
case
|
|
7404
|
+
case AST_NODE_TYPES38.TemplateLiteral: {
|
|
7054
7405
|
return inner.expressions.length === 0;
|
|
7055
7406
|
}
|
|
7056
|
-
case
|
|
7057
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
7407
|
+
case AST_NODE_TYPES38.UnaryExpression: {
|
|
7408
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES38.Literal && typeof inner.argument.value === "number";
|
|
7058
7409
|
}
|
|
7059
|
-
case
|
|
7410
|
+
case AST_NODE_TYPES38.ArrayExpression: {
|
|
7060
7411
|
return inner.elements.every(
|
|
7061
|
-
(el) => el !== null && el.type !==
|
|
7412
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES38.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
7062
7413
|
);
|
|
7063
7414
|
}
|
|
7064
|
-
case
|
|
7415
|
+
case AST_NODE_TYPES38.ObjectExpression: {
|
|
7065
7416
|
return inner.properties.every((prop) => {
|
|
7066
|
-
if (prop.type !==
|
|
7417
|
+
if (prop.type !== AST_NODE_TYPES38.Property) {
|
|
7067
7418
|
return false;
|
|
7068
7419
|
}
|
|
7069
7420
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
7070
7421
|
return false;
|
|
7071
7422
|
}
|
|
7072
|
-
if (prop.computed && prop.key.type !==
|
|
7423
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES38.Literal) {
|
|
7073
7424
|
return false;
|
|
7074
7425
|
}
|
|
7075
7426
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -7082,7 +7433,7 @@ function isLiteralOnly(node, depth) {
|
|
|
7082
7433
|
}
|
|
7083
7434
|
function unwrapObjectFreeze(node) {
|
|
7084
7435
|
const inner = unwrap3(node);
|
|
7085
|
-
if (inner.type ===
|
|
7436
|
+
if (inner.type === AST_NODE_TYPES38.CallExpression && inner.callee.type === AST_NODE_TYPES38.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES38.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES38.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES38.SpreadElement) {
|
|
7086
7437
|
return unwrap3(inner.arguments[0]);
|
|
7087
7438
|
}
|
|
7088
7439
|
return inner;
|
|
@@ -7098,19 +7449,19 @@ function classify(init, checkRegex) {
|
|
|
7098
7449
|
}
|
|
7099
7450
|
return { kind: "regex", size: 1 };
|
|
7100
7451
|
}
|
|
7101
|
-
if (node.type ===
|
|
7452
|
+
if (node.type === AST_NODE_TYPES38.ArrayExpression) {
|
|
7102
7453
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
7103
7454
|
}
|
|
7104
|
-
if (node.type ===
|
|
7455
|
+
if (node.type === AST_NODE_TYPES38.ObjectExpression) {
|
|
7105
7456
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
7106
7457
|
}
|
|
7107
|
-
if (node.type ===
|
|
7458
|
+
if (node.type === AST_NODE_TYPES38.NewExpression && node.callee.type === AST_NODE_TYPES38.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
7108
7459
|
const arg = node.arguments[0];
|
|
7109
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
7460
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES38.SpreadElement) {
|
|
7110
7461
|
return null;
|
|
7111
7462
|
}
|
|
7112
7463
|
const entries = unwrap3(arg);
|
|
7113
|
-
if (entries.type !==
|
|
7464
|
+
if (entries.type !== AST_NODE_TYPES38.ArrayExpression) {
|
|
7114
7465
|
return null;
|
|
7115
7466
|
}
|
|
7116
7467
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -7139,10 +7490,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
7139
7490
|
);
|
|
7140
7491
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
7141
7492
|
const callee = node.callee;
|
|
7142
|
-
if (callee.type ===
|
|
7493
|
+
if (callee.type === AST_NODE_TYPES38.Identifier && callee.name === "structuredClone") {
|
|
7143
7494
|
return true;
|
|
7144
7495
|
}
|
|
7145
|
-
if (callee.type !==
|
|
7496
|
+
if (callee.type !== AST_NODE_TYPES38.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES38.Identifier || callee.property.type !== AST_NODE_TYPES38.Identifier) {
|
|
7146
7497
|
return false;
|
|
7147
7498
|
}
|
|
7148
7499
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -7156,38 +7507,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
7156
7507
|
}
|
|
7157
7508
|
function isSafeRead(identifier) {
|
|
7158
7509
|
const parent = identifier.parent;
|
|
7159
|
-
if (parent.type ===
|
|
7510
|
+
if (parent.type === AST_NODE_TYPES38.MemberExpression) {
|
|
7160
7511
|
if (parent.object !== identifier) {
|
|
7161
7512
|
return true;
|
|
7162
7513
|
}
|
|
7163
7514
|
const grandparent = parent.parent;
|
|
7164
|
-
if (grandparent.type ===
|
|
7515
|
+
if (grandparent.type === AST_NODE_TYPES38.AssignmentExpression && grandparent.left === parent) {
|
|
7165
7516
|
return false;
|
|
7166
7517
|
}
|
|
7167
|
-
if (grandparent.type ===
|
|
7518
|
+
if (grandparent.type === AST_NODE_TYPES38.UpdateExpression) {
|
|
7168
7519
|
return false;
|
|
7169
7520
|
}
|
|
7170
|
-
if (grandparent.type ===
|
|
7521
|
+
if (grandparent.type === AST_NODE_TYPES38.UnaryExpression && grandparent.operator === "delete") {
|
|
7171
7522
|
return false;
|
|
7172
7523
|
}
|
|
7173
|
-
if (!parent.computed && parent.property.type ===
|
|
7524
|
+
if (!parent.computed && parent.property.type === AST_NODE_TYPES38.Identifier && MUTATING_METHODS2.has(parent.property.name) && grandparent.type === AST_NODE_TYPES38.CallExpression && grandparent.callee === parent) {
|
|
7174
7525
|
return false;
|
|
7175
7526
|
}
|
|
7176
7527
|
return true;
|
|
7177
7528
|
}
|
|
7178
|
-
if (parent.type ===
|
|
7529
|
+
if (parent.type === AST_NODE_TYPES38.ForOfStatement && parent.right === identifier) {
|
|
7179
7530
|
return true;
|
|
7180
7531
|
}
|
|
7181
|
-
if (parent.type ===
|
|
7532
|
+
if (parent.type === AST_NODE_TYPES38.SpreadElement) {
|
|
7182
7533
|
return true;
|
|
7183
7534
|
}
|
|
7184
|
-
if (parent.type ===
|
|
7535
|
+
if (parent.type === AST_NODE_TYPES38.BinaryExpression) {
|
|
7185
7536
|
return true;
|
|
7186
7537
|
}
|
|
7187
|
-
if (parent.type ===
|
|
7538
|
+
if (parent.type === AST_NODE_TYPES38.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
7188
7539
|
return true;
|
|
7189
7540
|
}
|
|
7190
|
-
if (parent.type ===
|
|
7541
|
+
if (parent.type === AST_NODE_TYPES38.UnaryExpression && parent.operator !== "delete") {
|
|
7191
7542
|
return true;
|
|
7192
7543
|
}
|
|
7193
7544
|
return false;
|
|
@@ -7242,7 +7593,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7242
7593
|
if (reference.isWrite()) {
|
|
7243
7594
|
return false;
|
|
7244
7595
|
}
|
|
7245
|
-
if (reference.identifier.type !==
|
|
7596
|
+
if (reference.identifier.type !== AST_NODE_TYPES38.Identifier) {
|
|
7246
7597
|
return false;
|
|
7247
7598
|
}
|
|
7248
7599
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -7254,10 +7605,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7254
7605
|
return {
|
|
7255
7606
|
VariableDeclarator(node) {
|
|
7256
7607
|
const declaration = node.parent;
|
|
7257
|
-
if (declaration.type !==
|
|
7608
|
+
if (declaration.type !== AST_NODE_TYPES38.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
7258
7609
|
return;
|
|
7259
7610
|
}
|
|
7260
|
-
if (node.id.type !==
|
|
7611
|
+
if (node.id.type !== AST_NODE_TYPES38.Identifier || node.init === null) {
|
|
7261
7612
|
return;
|
|
7262
7613
|
}
|
|
7263
7614
|
if (enclosingFunction2(node) === null) {
|
|
@@ -7284,7 +7635,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7284
7635
|
});
|
|
7285
7636
|
|
|
7286
7637
|
// src/rules/prefer-module-level-schema.ts
|
|
7287
|
-
import { AST_NODE_TYPES as
|
|
7638
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39 } from "@typescript-eslint/utils";
|
|
7288
7639
|
|
|
7289
7640
|
// src/rules/_zod.ts
|
|
7290
7641
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -7350,9 +7701,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
7350
7701
|
"intl"
|
|
7351
7702
|
]);
|
|
7352
7703
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7704
|
+
AST_NODE_TYPES39.ArrowFunctionExpression,
|
|
7705
|
+
AST_NODE_TYPES39.FunctionDeclaration,
|
|
7706
|
+
AST_NODE_TYPES39.FunctionExpression
|
|
7356
7707
|
]);
|
|
7357
7708
|
function schemaExpression(node) {
|
|
7358
7709
|
let current = node;
|
|
@@ -7361,10 +7712,10 @@ function schemaExpression(node) {
|
|
|
7361
7712
|
if (parent === void 0) {
|
|
7362
7713
|
return current;
|
|
7363
7714
|
}
|
|
7364
|
-
if (parent.type ===
|
|
7715
|
+
if (parent.type === AST_NODE_TYPES39.MemberExpression && parent.object === current && !parent.computed && parent.property.type === AST_NODE_TYPES39.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
7365
7716
|
return current;
|
|
7366
7717
|
}
|
|
7367
|
-
if (parent.type ===
|
|
7718
|
+
if (parent.type === AST_NODE_TYPES39.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES39.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES39.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES39.TSNonNullExpression && parent.expression === current) {
|
|
7368
7719
|
current = parent;
|
|
7369
7720
|
continue;
|
|
7370
7721
|
}
|
|
@@ -7415,22 +7766,22 @@ function subtreeSome(root, predicate) {
|
|
|
7415
7766
|
function readsReceiver(node) {
|
|
7416
7767
|
return subtreeSome(
|
|
7417
7768
|
node,
|
|
7418
|
-
(inner) => inner.type ===
|
|
7769
|
+
(inner) => inner.type === AST_NODE_TYPES39.ThisExpression || inner.type === AST_NODE_TYPES39.Super || inner.type === AST_NODE_TYPES39.Identifier && inner.name === "arguments"
|
|
7419
7770
|
);
|
|
7420
7771
|
}
|
|
7421
7772
|
function buildsLocalizedText(node) {
|
|
7422
7773
|
return subtreeSome(node, (inner) => {
|
|
7423
|
-
if (inner.type ===
|
|
7774
|
+
if (inner.type === AST_NODE_TYPES39.TaggedTemplateExpression) {
|
|
7424
7775
|
return true;
|
|
7425
7776
|
}
|
|
7426
|
-
if (inner.type !==
|
|
7777
|
+
if (inner.type !== AST_NODE_TYPES39.CallExpression) {
|
|
7427
7778
|
return false;
|
|
7428
7779
|
}
|
|
7429
7780
|
const { callee } = inner;
|
|
7430
|
-
if (callee.type ===
|
|
7781
|
+
if (callee.type === AST_NODE_TYPES39.Identifier) {
|
|
7431
7782
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7432
7783
|
}
|
|
7433
|
-
return callee.type ===
|
|
7784
|
+
return callee.type === AST_NODE_TYPES39.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES39.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
7434
7785
|
});
|
|
7435
7786
|
}
|
|
7436
7787
|
function collectReferences(scope, out) {
|
|
@@ -7487,15 +7838,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7487
7838
|
}
|
|
7488
7839
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7489
7840
|
function isZodCall(node) {
|
|
7490
|
-
return node.type ===
|
|
7841
|
+
return node.type === AST_NODE_TYPES39.CallExpression && node.callee.type === AST_NODE_TYPES39.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES39.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
7491
7842
|
}
|
|
7492
7843
|
function isCovered(node) {
|
|
7493
7844
|
let current = node.parent ?? void 0;
|
|
7494
7845
|
while (current !== void 0) {
|
|
7495
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7846
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES39.MemberExpression && current.callee.property.type === AST_NODE_TYPES39.Identifier && factories.has(current.callee.property.name)) {
|
|
7496
7847
|
return true;
|
|
7497
7848
|
}
|
|
7498
|
-
if (current.type ===
|
|
7849
|
+
if (current.type === AST_NODE_TYPES39.CallExpression && (current.callee.type === AST_NODE_TYPES39.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === AST_NODE_TYPES39.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES39.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
7499
7850
|
return true;
|
|
7500
7851
|
}
|
|
7501
7852
|
current = current.parent ?? void 0;
|
|
@@ -7510,11 +7861,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7510
7861
|
if (parent === void 0) {
|
|
7511
7862
|
return confirmed;
|
|
7512
7863
|
}
|
|
7513
|
-
if (parent.type ===
|
|
7864
|
+
if (parent.type === AST_NODE_TYPES39.Property && parent.value === current || parent.type === AST_NODE_TYPES39.ObjectExpression || parent.type === AST_NODE_TYPES39.ArrayExpression) {
|
|
7514
7865
|
current = parent;
|
|
7515
7866
|
continue;
|
|
7516
7867
|
}
|
|
7517
|
-
if (parent.type ===
|
|
7868
|
+
if (parent.type === AST_NODE_TYPES39.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7518
7869
|
current = schemaExpression(parent);
|
|
7519
7870
|
confirmed = current;
|
|
7520
7871
|
continue;
|
|
@@ -7524,7 +7875,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7524
7875
|
}
|
|
7525
7876
|
function isSchemaComposition(node) {
|
|
7526
7877
|
const { callee } = node;
|
|
7527
|
-
const isCombinator = callee.type ===
|
|
7878
|
+
const isCombinator = callee.type === AST_NODE_TYPES39.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES39.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7528
7879
|
return isCombinator || isZodCall(node);
|
|
7529
7880
|
}
|
|
7530
7881
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7558,13 +7909,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7558
7909
|
}
|
|
7559
7910
|
function ownerName(enclosing) {
|
|
7560
7911
|
const parent = enclosing.parent ?? void 0;
|
|
7561
|
-
if (enclosing.type ===
|
|
7912
|
+
if (enclosing.type === AST_NODE_TYPES39.FunctionDeclaration && enclosing.id !== null) {
|
|
7562
7913
|
return enclosing.id.name;
|
|
7563
7914
|
}
|
|
7564
|
-
if (parent !== void 0 && parent.type ===
|
|
7915
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES39.VariableDeclarator && parent.id.type === AST_NODE_TYPES39.Identifier) {
|
|
7565
7916
|
return parent.id.name;
|
|
7566
7917
|
}
|
|
7567
|
-
if (parent !== void 0 && (parent.type ===
|
|
7918
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES39.MethodDefinition || parent.type === AST_NODE_TYPES39.Property) && parent.key.type === AST_NODE_TYPES39.Identifier) {
|
|
7568
7919
|
return parent.key.name;
|
|
7569
7920
|
}
|
|
7570
7921
|
return "this function";
|
|
@@ -7575,7 +7926,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7575
7926
|
return;
|
|
7576
7927
|
}
|
|
7577
7928
|
for (const specifier of node.specifiers) {
|
|
7578
|
-
if (specifier.type ===
|
|
7929
|
+
if (specifier.type === AST_NODE_TYPES39.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES39.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES39.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES39.Identifier && specifier.imported.name === "z") {
|
|
7579
7930
|
zodNamespaces.add(specifier.local.name);
|
|
7580
7931
|
}
|
|
7581
7932
|
}
|
|
@@ -7585,7 +7936,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7585
7936
|
return;
|
|
7586
7937
|
}
|
|
7587
7938
|
const callee = node.callee;
|
|
7588
|
-
if (callee.property.type !==
|
|
7939
|
+
if (callee.property.type !== AST_NODE_TYPES39.Identifier) {
|
|
7589
7940
|
return;
|
|
7590
7941
|
}
|
|
7591
7942
|
const factory = callee.property.name;
|
|
@@ -7600,7 +7951,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7600
7951
|
return;
|
|
7601
7952
|
}
|
|
7602
7953
|
const shape = node.arguments[0];
|
|
7603
|
-
if (shape !== void 0 && shape.type ===
|
|
7954
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES39.ObjectExpression && shape.properties.length < minProperties) {
|
|
7604
7955
|
return;
|
|
7605
7956
|
}
|
|
7606
7957
|
const expression = schemaExpression(node);
|
|
@@ -7628,9 +7979,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7628
7979
|
});
|
|
7629
7980
|
|
|
7630
7981
|
// src/rules/prefer-native-random-uuid.ts
|
|
7631
|
-
import { AST_NODE_TYPES as
|
|
7982
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40, ASTUtils as ASTUtils5 } from "@typescript-eslint/utils";
|
|
7632
7983
|
function requireUuid(node) {
|
|
7633
|
-
return node?.type ===
|
|
7984
|
+
return node?.type === AST_NODE_TYPES40.CallExpression && node.callee.type === AST_NODE_TYPES40.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === AST_NODE_TYPES40.Literal && node.arguments[0].value === "uuid";
|
|
7634
7985
|
}
|
|
7635
7986
|
var prefer_native_random_uuid_default = createRule({
|
|
7636
7987
|
name: "prefer-native-random-uuid",
|
|
@@ -7651,7 +8002,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7651
8002
|
const directBindings = /* @__PURE__ */ new Set();
|
|
7652
8003
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7653
8004
|
function resolve(identifier) {
|
|
7654
|
-
return
|
|
8005
|
+
return ASTUtils5.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7655
8006
|
}
|
|
7656
8007
|
function record(identifier, destination) {
|
|
7657
8008
|
const variable = resolve(identifier);
|
|
@@ -7673,37 +8024,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7673
8024
|
ImportDeclaration(node) {
|
|
7674
8025
|
if (node.source.value !== "uuid") return;
|
|
7675
8026
|
for (const specifier of node.specifiers) {
|
|
7676
|
-
if (specifier.type ===
|
|
8027
|
+
if (specifier.type === AST_NODE_TYPES40.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES40.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7677
8028
|
record(specifier.local, directBindings);
|
|
7678
|
-
} else if (specifier.type ===
|
|
8029
|
+
} else if (specifier.type === AST_NODE_TYPES40.ImportNamespaceSpecifier) {
|
|
7679
8030
|
record(specifier.local, namespaceBindings);
|
|
7680
8031
|
}
|
|
7681
8032
|
}
|
|
7682
8033
|
},
|
|
7683
8034
|
VariableDeclarator(node) {
|
|
7684
8035
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7685
|
-
if (node.init?.type !==
|
|
8036
|
+
if (node.init?.type !== AST_NODE_TYPES40.CallExpression || node.init.callee.type !== AST_NODE_TYPES40.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
7686
8037
|
return;
|
|
7687
8038
|
}
|
|
7688
|
-
if (node.id.type ===
|
|
8039
|
+
if (node.id.type === AST_NODE_TYPES40.Identifier) {
|
|
7689
8040
|
record(node.id, namespaceBindings);
|
|
7690
8041
|
return;
|
|
7691
8042
|
}
|
|
7692
|
-
if (node.id.type !==
|
|
8043
|
+
if (node.id.type !== AST_NODE_TYPES40.ObjectPattern) return;
|
|
7693
8044
|
for (const property of node.id.properties) {
|
|
7694
|
-
if (property.type ===
|
|
8045
|
+
if (property.type === AST_NODE_TYPES40.Property && !property.computed && (property.key.type === AST_NODE_TYPES40.Identifier && property.key.name === "v4" || property.key.type === AST_NODE_TYPES40.Literal && property.key.value === "v4") && property.value.type === AST_NODE_TYPES40.Identifier) {
|
|
7695
8046
|
record(property.value, directBindings);
|
|
7696
8047
|
}
|
|
7697
8048
|
}
|
|
7698
8049
|
},
|
|
7699
8050
|
"CallExpression:exit"(node) {
|
|
7700
8051
|
if (node.arguments.length !== 0) return;
|
|
7701
|
-
if (node.callee.type ===
|
|
8052
|
+
if (node.callee.type === AST_NODE_TYPES40.Identifier) {
|
|
7702
8053
|
const variable2 = resolve(node.callee);
|
|
7703
8054
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7704
8055
|
return;
|
|
7705
8056
|
}
|
|
7706
|
-
if (node.callee.type !==
|
|
8057
|
+
if (node.callee.type !== AST_NODE_TYPES40.MemberExpression || node.callee.computed || node.callee.object.type !== AST_NODE_TYPES40.Identifier || node.callee.property.type !== AST_NODE_TYPES40.Identifier || node.callee.property.name !== "v4") {
|
|
7707
8058
|
return;
|
|
7708
8059
|
}
|
|
7709
8060
|
const variable = resolve(node.callee.object);
|
|
@@ -7714,20 +8065,20 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7714
8065
|
});
|
|
7715
8066
|
|
|
7716
8067
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7717
|
-
import { AST_NODE_TYPES as
|
|
8068
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41 } from "@typescript-eslint/utils";
|
|
7718
8069
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7719
8070
|
function propertyName(node) {
|
|
7720
8071
|
const key = node.key;
|
|
7721
|
-
if (key.type ===
|
|
7722
|
-
if (key.type ===
|
|
8072
|
+
if (key.type === AST_NODE_TYPES41.Identifier) return key.name;
|
|
8073
|
+
if (key.type === AST_NODE_TYPES41.Literal) return String(key.value);
|
|
7723
8074
|
return "collection";
|
|
7724
8075
|
}
|
|
7725
8076
|
function isArrayType(node) {
|
|
7726
|
-
if (node.type ===
|
|
7727
|
-
return node.type ===
|
|
8077
|
+
if (node.type === AST_NODE_TYPES41.TSArrayType) return true;
|
|
8078
|
+
return node.type === AST_NODE_TYPES41.TSTypeReference && node.typeName.type === AST_NODE_TYPES41.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7728
8079
|
}
|
|
7729
8080
|
function isNullishType(node) {
|
|
7730
|
-
return node.type ===
|
|
8081
|
+
return node.type === AST_NODE_TYPES41.TSNullKeyword || node.type === AST_NODE_TYPES41.TSUndefinedKeyword;
|
|
7731
8082
|
}
|
|
7732
8083
|
function isNullableArrayOnly(node) {
|
|
7733
8084
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7755,7 +8106,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7755
8106
|
if (node.optional) return;
|
|
7756
8107
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7757
8108
|
if (annotation === void 0) return;
|
|
7758
|
-
if (annotation.type !==
|
|
8109
|
+
if (annotation.type !== AST_NODE_TYPES41.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7759
8110
|
return;
|
|
7760
8111
|
}
|
|
7761
8112
|
context.report({
|
|
@@ -7768,7 +8119,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7768
8119
|
TSPropertySignature: checkOptionalProperty,
|
|
7769
8120
|
PropertyDefinition: checkOptionalProperty,
|
|
7770
8121
|
TSTypeAliasDeclaration(node) {
|
|
7771
|
-
if (node.typeAnnotation.type !==
|
|
8122
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES41.TSUnionType) return;
|
|
7772
8123
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7773
8124
|
context.report({
|
|
7774
8125
|
node,
|
|
@@ -7781,13 +8132,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7781
8132
|
});
|
|
7782
8133
|
|
|
7783
8134
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7784
|
-
import { AST_NODE_TYPES as
|
|
8135
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42 } from "@typescript-eslint/utils";
|
|
7785
8136
|
var unwrap4 = (node) => {
|
|
7786
8137
|
let current = node;
|
|
7787
8138
|
while (current !== null && current !== void 0) {
|
|
7788
|
-
if (current.type ===
|
|
8139
|
+
if (current.type === AST_NODE_TYPES42.TSAsExpression || current.type === AST_NODE_TYPES42.TSTypeAssertion || current.type === AST_NODE_TYPES42.TSNonNullExpression || current.type === AST_NODE_TYPES42.TSSatisfiesExpression) {
|
|
7789
8140
|
current = current.expression;
|
|
7790
|
-
} else if (current.type ===
|
|
8141
|
+
} else if (current.type === AST_NODE_TYPES42.ChainExpression) {
|
|
7791
8142
|
current = current.expression;
|
|
7792
8143
|
} else {
|
|
7793
8144
|
break;
|
|
@@ -7802,23 +8153,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7802
8153
|
]);
|
|
7803
8154
|
var isSchemaParseReference = (node) => {
|
|
7804
8155
|
const inner = unwrap4(node);
|
|
7805
|
-
return inner !== null && inner.type ===
|
|
8156
|
+
return inner !== null && inner.type === AST_NODE_TYPES42.MemberExpression && !inner.computed && inner.property.type === AST_NODE_TYPES42.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7806
8157
|
};
|
|
7807
8158
|
var isRawPayloadSource = (node) => {
|
|
7808
8159
|
let current = unwrap4(node);
|
|
7809
8160
|
if (current === null) return false;
|
|
7810
|
-
if (current.type ===
|
|
8161
|
+
if (current.type === AST_NODE_TYPES42.AwaitExpression) {
|
|
7811
8162
|
current = unwrap4(current.argument);
|
|
7812
8163
|
}
|
|
7813
|
-
if (current === null || current.type !==
|
|
8164
|
+
if (current === null || current.type !== AST_NODE_TYPES42.CallExpression) {
|
|
7814
8165
|
return false;
|
|
7815
8166
|
}
|
|
7816
8167
|
const callee = unwrap4(current.callee);
|
|
7817
|
-
if (callee === null || callee.type !==
|
|
8168
|
+
if (callee === null || callee.type !== AST_NODE_TYPES42.MemberExpression) {
|
|
7818
8169
|
return false;
|
|
7819
8170
|
}
|
|
7820
8171
|
const property = unwrap4(callee.property);
|
|
7821
|
-
if (property === null || property.type !==
|
|
8172
|
+
if (property === null || property.type !== AST_NODE_TYPES42.Identifier) {
|
|
7822
8173
|
return false;
|
|
7823
8174
|
}
|
|
7824
8175
|
if (property.name === "json") {
|
|
@@ -7828,16 +8179,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7828
8179
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7829
8180
|
}
|
|
7830
8181
|
const object = unwrap4(callee.object);
|
|
7831
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
8182
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES42.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7832
8183
|
};
|
|
7833
8184
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7834
8185
|
var isLocalFileRead = (node) => {
|
|
7835
8186
|
let found = false;
|
|
7836
8187
|
const visit = (current) => {
|
|
7837
8188
|
if (found || current === null || current === void 0) return;
|
|
7838
|
-
if (current.type ===
|
|
8189
|
+
if (current.type === AST_NODE_TYPES42.CallExpression) {
|
|
7839
8190
|
const callee = unwrap4(current.callee);
|
|
7840
|
-
const name = callee?.type ===
|
|
8191
|
+
const name = callee?.type === AST_NODE_TYPES42.Identifier ? callee.name : callee?.type === AST_NODE_TYPES42.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES42.Identifier ? callee.property.name : null;
|
|
7841
8192
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7842
8193
|
found = true;
|
|
7843
8194
|
return;
|
|
@@ -7859,15 +8210,15 @@ var isLocalFileRead = (node) => {
|
|
|
7859
8210
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7860
8211
|
var isInsideAssertion = (node) => {
|
|
7861
8212
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7862
|
-
if (current.type !==
|
|
8213
|
+
if (current.type !== AST_NODE_TYPES42.CallExpression) continue;
|
|
7863
8214
|
let callee = current.callee;
|
|
7864
|
-
while (callee.type ===
|
|
8215
|
+
while (callee.type === AST_NODE_TYPES42.MemberExpression) {
|
|
7865
8216
|
callee = callee.object;
|
|
7866
8217
|
}
|
|
7867
|
-
if (callee.type ===
|
|
8218
|
+
if (callee.type === AST_NODE_TYPES42.CallExpression) {
|
|
7868
8219
|
callee = callee.callee;
|
|
7869
8220
|
}
|
|
7870
|
-
if (callee.type ===
|
|
8221
|
+
if (callee.type === AST_NODE_TYPES42.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7871
8222
|
return true;
|
|
7872
8223
|
}
|
|
7873
8224
|
}
|
|
@@ -7886,39 +8237,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7886
8237
|
var isValidationRead = (node) => {
|
|
7887
8238
|
let current = node;
|
|
7888
8239
|
let parent = current.parent;
|
|
7889
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
8240
|
+
while (parent !== null && parent !== void 0 && (parent.type === AST_NODE_TYPES42.TSAsExpression || parent.type === AST_NODE_TYPES42.TSTypeAssertion || parent.type === AST_NODE_TYPES42.TSNonNullExpression || parent.type === AST_NODE_TYPES42.TSSatisfiesExpression || parent.type === AST_NODE_TYPES42.ChainExpression)) {
|
|
7890
8241
|
current = parent;
|
|
7891
8242
|
parent = parent.parent;
|
|
7892
8243
|
}
|
|
7893
8244
|
if (parent === null || parent === void 0) return false;
|
|
7894
|
-
if (parent.type ===
|
|
8245
|
+
if (parent.type === AST_NODE_TYPES42.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7895
8246
|
return true;
|
|
7896
8247
|
}
|
|
7897
|
-
if (parent.type !==
|
|
8248
|
+
if (parent.type !== AST_NODE_TYPES42.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7898
8249
|
return false;
|
|
7899
8250
|
}
|
|
7900
8251
|
const callee = parent.callee;
|
|
7901
|
-
if (callee.type ===
|
|
8252
|
+
if (callee.type === AST_NODE_TYPES42.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES42.Identifier && callee.object.name === "Array" && callee.property.type === AST_NODE_TYPES42.Identifier && callee.property.name === "isArray") {
|
|
7902
8253
|
return parent.arguments.length === 1;
|
|
7903
8254
|
}
|
|
7904
|
-
return callee.type ===
|
|
8255
|
+
return callee.type === AST_NODE_TYPES42.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7905
8256
|
};
|
|
7906
8257
|
var isGuardTestPosition = (node) => {
|
|
7907
8258
|
let current = node;
|
|
7908
8259
|
let parent = current.parent;
|
|
7909
8260
|
while (parent !== void 0 && parent !== null) {
|
|
7910
8261
|
switch (parent.type) {
|
|
7911
|
-
case
|
|
7912
|
-
case
|
|
7913
|
-
case
|
|
8262
|
+
case AST_NODE_TYPES42.UnaryExpression:
|
|
8263
|
+
case AST_NODE_TYPES42.LogicalExpression:
|
|
8264
|
+
case AST_NODE_TYPES42.ChainExpression:
|
|
7914
8265
|
current = parent;
|
|
7915
8266
|
parent = parent.parent;
|
|
7916
8267
|
continue;
|
|
7917
|
-
case
|
|
7918
|
-
case
|
|
7919
|
-
case
|
|
7920
|
-
case
|
|
7921
|
-
case
|
|
8268
|
+
case AST_NODE_TYPES42.IfStatement:
|
|
8269
|
+
case AST_NODE_TYPES42.ConditionalExpression:
|
|
8270
|
+
case AST_NODE_TYPES42.WhileStatement:
|
|
8271
|
+
case AST_NODE_TYPES42.DoWhileStatement:
|
|
8272
|
+
case AST_NODE_TYPES42.ForStatement:
|
|
7922
8273
|
return parent.test === current;
|
|
7923
8274
|
default:
|
|
7924
8275
|
return false;
|
|
@@ -7928,7 +8279,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7928
8279
|
};
|
|
7929
8280
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7930
8281
|
const unwrapped = unwrap4(node);
|
|
7931
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8282
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES42.Identifier) {
|
|
7932
8283
|
return false;
|
|
7933
8284
|
}
|
|
7934
8285
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7971,11 +8322,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7971
8322
|
return {
|
|
7972
8323
|
VariableDeclarator(node) {
|
|
7973
8324
|
const scope = context.sourceCode.getScope(node);
|
|
7974
|
-
if (node.id.type ===
|
|
8325
|
+
if (node.id.type === AST_NODE_TYPES42.Identifier) {
|
|
7975
8326
|
trackInitializer(node);
|
|
7976
8327
|
return;
|
|
7977
8328
|
}
|
|
7978
|
-
if (node.id.type ===
|
|
8329
|
+
if (node.id.type === AST_NODE_TYPES42.ObjectPattern || node.id.type === AST_NODE_TYPES42.ArrayPattern) {
|
|
7979
8330
|
if (isRawPayloadSource(node.init)) {
|
|
7980
8331
|
if (!isFullyNarrowedPattern(node)) {
|
|
7981
8332
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7989,7 +8340,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7989
8340
|
},
|
|
7990
8341
|
AssignmentExpression(node) {
|
|
7991
8342
|
const scope = context.sourceCode.getScope(node);
|
|
7992
|
-
if (node.left.type ===
|
|
8343
|
+
if (node.left.type === AST_NODE_TYPES42.Identifier) {
|
|
7993
8344
|
const variable = findVariable2(scope, node.left.name);
|
|
7994
8345
|
if (variable === null) return;
|
|
7995
8346
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7999,7 +8350,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7999
8350
|
}
|
|
8000
8351
|
return;
|
|
8001
8352
|
}
|
|
8002
|
-
if (node.left.type ===
|
|
8353
|
+
if (node.left.type === AST_NODE_TYPES42.ObjectPattern || node.left.type === AST_NODE_TYPES42.ArrayPattern) {
|
|
8003
8354
|
if (isRawPayloadSource(node.right)) {
|
|
8004
8355
|
context.report({
|
|
8005
8356
|
node: node.left,
|
|
@@ -8016,15 +8367,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
8016
8367
|
}
|
|
8017
8368
|
},
|
|
8018
8369
|
CallExpression(node) {
|
|
8019
|
-
if (node.callee.type !==
|
|
8370
|
+
if (node.callee.type !== AST_NODE_TYPES42.Identifier) return;
|
|
8020
8371
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
8021
8372
|
return;
|
|
8022
8373
|
}
|
|
8023
8374
|
const scope = context.sourceCode.getScope(node);
|
|
8024
8375
|
for (const arg of node.arguments) {
|
|
8025
|
-
if (arg.type ===
|
|
8376
|
+
if (arg.type === AST_NODE_TYPES42.SpreadElement) continue;
|
|
8026
8377
|
const unwrapped = unwrap4(arg);
|
|
8027
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8378
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES42.Identifier) {
|
|
8028
8379
|
continue;
|
|
8029
8380
|
}
|
|
8030
8381
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -8038,13 +8389,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
8038
8389
|
const obj = unwrap4(node.object);
|
|
8039
8390
|
if (isRawPayloadSource(obj)) {
|
|
8040
8391
|
const parent = node.parent;
|
|
8041
|
-
if (parent.type ===
|
|
8392
|
+
if (parent.type === AST_NODE_TYPES42.CallExpression && parent.callee === node && node.property.type === AST_NODE_TYPES42.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
8042
8393
|
return;
|
|
8043
8394
|
}
|
|
8044
8395
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
8045
8396
|
return;
|
|
8046
8397
|
}
|
|
8047
|
-
if (obj !== null && obj.type ===
|
|
8398
|
+
if (obj !== null && obj.type === AST_NODE_TYPES42.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
8048
8399
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
8049
8400
|
const variable = findVariable2(scope, obj.name);
|
|
8050
8401
|
if (variable !== null) {
|
|
@@ -8057,7 +8408,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
8057
8408
|
});
|
|
8058
8409
|
|
|
8059
8410
|
// src/rules/prefer-semantic-colors.ts
|
|
8060
|
-
import { AST_NODE_TYPES as
|
|
8411
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43 } from "@typescript-eslint/utils";
|
|
8061
8412
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
8062
8413
|
import { dirname, join, parse } from "path";
|
|
8063
8414
|
|
|
@@ -8157,8 +8508,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
8157
8508
|
]);
|
|
8158
8509
|
function jsxElementName(node) {
|
|
8159
8510
|
const name = node.openingElement.name;
|
|
8160
|
-
if (name.type ===
|
|
8161
|
-
if (name.type ===
|
|
8511
|
+
if (name.type === AST_NODE_TYPES43.JSXIdentifier) return name.name;
|
|
8512
|
+
if (name.type === AST_NODE_TYPES43.JSXMemberExpression && name.property.type === AST_NODE_TYPES43.JSXIdentifier) {
|
|
8162
8513
|
return name.property.name;
|
|
8163
8514
|
}
|
|
8164
8515
|
return null;
|
|
@@ -8184,7 +8535,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
8184
8535
|
var isInsideSvg = (node) => {
|
|
8185
8536
|
let current = node.parent;
|
|
8186
8537
|
while (current !== void 0 && current !== null) {
|
|
8187
|
-
if (current.type ===
|
|
8538
|
+
if (current.type === AST_NODE_TYPES43.JSXElement) {
|
|
8188
8539
|
const name = jsxElementName(current);
|
|
8189
8540
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
8190
8541
|
}
|
|
@@ -8195,7 +8546,7 @@ var isInsideSvg = (node) => {
|
|
|
8195
8546
|
var isInsideIconFactoryPath = (node) => {
|
|
8196
8547
|
let current = node.parent;
|
|
8197
8548
|
while (current !== void 0 && current !== null) {
|
|
8198
|
-
if (current.type ===
|
|
8549
|
+
if (current.type === AST_NODE_TYPES43.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES43.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES43.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES43.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
8199
8550
|
return true;
|
|
8200
8551
|
}
|
|
8201
8552
|
current = current.parent;
|
|
@@ -8332,12 +8683,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
8332
8683
|
return root !== null && workspaceHasMarker(root);
|
|
8333
8684
|
};
|
|
8334
8685
|
var propName = (key) => {
|
|
8335
|
-
if (key.type ===
|
|
8336
|
-
if (key.type ===
|
|
8686
|
+
if (key.type === AST_NODE_TYPES43.Identifier) return key.name;
|
|
8687
|
+
if (key.type === AST_NODE_TYPES43.Literal && typeof key.value === "string") return key.value;
|
|
8337
8688
|
return null;
|
|
8338
8689
|
};
|
|
8339
8690
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
8340
|
-
if (statement.type !==
|
|
8691
|
+
if (statement.type !== AST_NODE_TYPES43.ImportDeclaration && statement.type !== AST_NODE_TYPES43.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES43.ExportAllDeclaration) {
|
|
8341
8692
|
return false;
|
|
8342
8693
|
}
|
|
8343
8694
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -8389,27 +8740,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8389
8740
|
const checkClassNode = (node) => {
|
|
8390
8741
|
if (node === null) return;
|
|
8391
8742
|
switch (node.type) {
|
|
8392
|
-
case
|
|
8743
|
+
case AST_NODE_TYPES43.Literal:
|
|
8393
8744
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
8394
8745
|
break;
|
|
8395
|
-
case
|
|
8746
|
+
case AST_NODE_TYPES43.TemplateLiteral:
|
|
8396
8747
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
8397
8748
|
break;
|
|
8398
|
-
case
|
|
8749
|
+
case AST_NODE_TYPES43.ArrayExpression:
|
|
8399
8750
|
for (const element of node.elements) {
|
|
8400
|
-
if (element !== null && element.type !==
|
|
8751
|
+
if (element !== null && element.type !== AST_NODE_TYPES43.SpreadElement) checkClassNode(element);
|
|
8401
8752
|
}
|
|
8402
8753
|
break;
|
|
8403
|
-
case
|
|
8754
|
+
case AST_NODE_TYPES43.ObjectExpression:
|
|
8404
8755
|
for (const property of node.properties) {
|
|
8405
|
-
if (property.type ===
|
|
8756
|
+
if (property.type === AST_NODE_TYPES43.Property) checkClassNode(property.value);
|
|
8406
8757
|
}
|
|
8407
8758
|
break;
|
|
8408
|
-
case
|
|
8759
|
+
case AST_NODE_TYPES43.ConditionalExpression:
|
|
8409
8760
|
checkClassNode(node.consequent);
|
|
8410
8761
|
checkClassNode(node.alternate);
|
|
8411
8762
|
break;
|
|
8412
|
-
case
|
|
8763
|
+
case AST_NODE_TYPES43.LogicalExpression:
|
|
8413
8764
|
checkClassNode(node.right);
|
|
8414
8765
|
break;
|
|
8415
8766
|
default:
|
|
@@ -8417,32 +8768,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8417
8768
|
}
|
|
8418
8769
|
};
|
|
8419
8770
|
const checkColorValueNode = (node) => {
|
|
8420
|
-
if (node.type ===
|
|
8771
|
+
if (node.type === AST_NODE_TYPES43.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
8421
8772
|
report(node, "inlineColor", { value: node.value });
|
|
8422
8773
|
}
|
|
8423
8774
|
};
|
|
8424
8775
|
return {
|
|
8425
8776
|
"JSXAttribute[name.name='className']"(node) {
|
|
8426
8777
|
if (node.value === null) return;
|
|
8427
|
-
if (node.value.type ===
|
|
8428
|
-
else if (node.value.type ===
|
|
8429
|
-
if (node.value.expression.type !==
|
|
8778
|
+
if (node.value.type === AST_NODE_TYPES43.Literal) checkClassNode(node.value);
|
|
8779
|
+
else if (node.value.type === AST_NODE_TYPES43.JSXExpressionContainer) {
|
|
8780
|
+
if (node.value.expression.type !== AST_NODE_TYPES43.JSXEmptyExpression) {
|
|
8430
8781
|
checkClassNode(node.value.expression);
|
|
8431
8782
|
}
|
|
8432
8783
|
}
|
|
8433
8784
|
},
|
|
8434
8785
|
CallExpression(node) {
|
|
8435
|
-
if (node.callee.type ===
|
|
8786
|
+
if (node.callee.type === AST_NODE_TYPES43.Identifier && node.callee.name === "require" && node.arguments[0]?.type === AST_NODE_TYPES43.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
8436
8787
|
importsEmailOrPdfRenderer = true;
|
|
8437
8788
|
}
|
|
8438
|
-
if (node.callee.type ===
|
|
8789
|
+
if (node.callee.type === AST_NODE_TYPES43.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8439
8790
|
for (const arg of node.arguments) {
|
|
8440
|
-
if (arg.type !==
|
|
8791
|
+
if (arg.type !== AST_NODE_TYPES43.SpreadElement) checkClassNode(arg);
|
|
8441
8792
|
}
|
|
8442
8793
|
}
|
|
8443
8794
|
},
|
|
8444
8795
|
VariableDeclarator(node) {
|
|
8445
|
-
if (node.id.type ===
|
|
8796
|
+
if (node.id.type === AST_NODE_TYPES43.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8446
8797
|
checkClassNode(node.init);
|
|
8447
8798
|
}
|
|
8448
8799
|
},
|
|
@@ -8452,9 +8803,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8452
8803
|
},
|
|
8453
8804
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8454
8805
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8455
|
-
if (node.value?.type !==
|
|
8806
|
+
if (node.value?.type !== AST_NODE_TYPES43.Literal) return;
|
|
8456
8807
|
const owner = node.parent.name;
|
|
8457
|
-
if (owner.type ===
|
|
8808
|
+
if (owner.type === AST_NODE_TYPES43.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8458
8809
|
return;
|
|
8459
8810
|
}
|
|
8460
8811
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8468,7 +8819,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8468
8819
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8469
8820
|
},
|
|
8470
8821
|
ImportExpression(node) {
|
|
8471
|
-
if (node.source.type ===
|
|
8822
|
+
if (node.source.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8472
8823
|
importsEmailOrPdfRenderer = true;
|
|
8473
8824
|
}
|
|
8474
8825
|
},
|
|
@@ -8615,8 +8966,8 @@ var prefer_server_actions_default = createRule({
|
|
|
8615
8966
|
}
|
|
8616
8967
|
}
|
|
8617
8968
|
} else if (node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && !node.callee.computed) {
|
|
8618
|
-
const
|
|
8619
|
-
if (AXIOS_MUTATION_METHODS.has(
|
|
8969
|
+
const methodName2 = node.callee.property.name.toLowerCase();
|
|
8970
|
+
if (AXIOS_MUTATION_METHODS.has(methodName2)) {
|
|
8620
8971
|
const urlArg = node.arguments[0];
|
|
8621
8972
|
const hasHandlerArg = node.arguments.some(
|
|
8622
8973
|
(arg) => arg.type !== "SpreadElement" && isFunctionArgument(arg, context)
|
|
@@ -8674,7 +9025,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8674
9025
|
// src/rules/prefer-string-literal-union.ts
|
|
8675
9026
|
import {
|
|
8676
9027
|
ESLintUtils as ESLintUtils3,
|
|
8677
|
-
AST_NODE_TYPES as
|
|
9028
|
+
AST_NODE_TYPES as AST_NODE_TYPES44
|
|
8678
9029
|
} from "@typescript-eslint/utils";
|
|
8679
9030
|
import * as ts2 from "typescript";
|
|
8680
9031
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -8718,19 +9069,19 @@ function isChoiceLikeName(name) {
|
|
|
8718
9069
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8719
9070
|
}
|
|
8720
9071
|
function keyName(key) {
|
|
8721
|
-
if (key.type ===
|
|
9072
|
+
if (key.type === AST_NODE_TYPES44.Identifier) {
|
|
8722
9073
|
return key.name;
|
|
8723
9074
|
}
|
|
8724
|
-
if (key.type ===
|
|
9075
|
+
if (key.type === AST_NODE_TYPES44.Literal && typeof key.value === "string") {
|
|
8725
9076
|
return key.value;
|
|
8726
9077
|
}
|
|
8727
9078
|
return null;
|
|
8728
9079
|
}
|
|
8729
9080
|
function isStringLiteralMember(t) {
|
|
8730
|
-
return t.type ===
|
|
9081
|
+
return t.type === AST_NODE_TYPES44.TSLiteralType && t.literal.type === AST_NODE_TYPES44.Literal && typeof t.literal.value === "string";
|
|
8731
9082
|
}
|
|
8732
9083
|
function isStringLiteralUnion(node) {
|
|
8733
|
-
if (node?.type !==
|
|
9084
|
+
if (node?.type !== AST_NODE_TYPES44.TSUnionType) {
|
|
8734
9085
|
return false;
|
|
8735
9086
|
}
|
|
8736
9087
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8759,12 +9110,12 @@ function bindingSourceExpression(decl) {
|
|
|
8759
9110
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8760
9111
|
}
|
|
8761
9112
|
function refKey(node) {
|
|
8762
|
-
if (node.type ===
|
|
9113
|
+
if (node.type === AST_NODE_TYPES44.Identifier) {
|
|
8763
9114
|
return node.name;
|
|
8764
9115
|
}
|
|
8765
|
-
if (node.type ===
|
|
9116
|
+
if (node.type === AST_NODE_TYPES44.MemberExpression && !node.computed) {
|
|
8766
9117
|
const inner = refKey(node.object);
|
|
8767
|
-
if (inner === null || node.property.type !==
|
|
9118
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES44.Identifier) {
|
|
8768
9119
|
return null;
|
|
8769
9120
|
}
|
|
8770
9121
|
return `${inner}.${node.property.name}`;
|
|
@@ -8772,7 +9123,7 @@ function refKey(node) {
|
|
|
8772
9123
|
return null;
|
|
8773
9124
|
}
|
|
8774
9125
|
function strLiteral(node) {
|
|
8775
|
-
if (node.type ===
|
|
9126
|
+
if (node.type === AST_NODE_TYPES44.Literal && typeof node.value === "string") {
|
|
8776
9127
|
return node.value;
|
|
8777
9128
|
}
|
|
8778
9129
|
return null;
|
|
@@ -8925,7 +9276,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8925
9276
|
containersWithUnion.add(container);
|
|
8926
9277
|
return;
|
|
8927
9278
|
}
|
|
8928
|
-
if (typeNode?.type !==
|
|
9279
|
+
if (typeNode?.type !== AST_NODE_TYPES44.TSStringKeyword) {
|
|
8929
9280
|
return;
|
|
8930
9281
|
}
|
|
8931
9282
|
const name = keyName(key);
|
|
@@ -9013,10 +9364,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
9013
9364
|
}
|
|
9014
9365
|
};
|
|
9015
9366
|
function refKeyText(node) {
|
|
9016
|
-
if (node.type ===
|
|
9367
|
+
if (node.type === AST_NODE_TYPES44.BinaryExpression) {
|
|
9017
9368
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
9018
9369
|
}
|
|
9019
|
-
if (node.type ===
|
|
9370
|
+
if (node.type === AST_NODE_TYPES44.SwitchStatement) {
|
|
9020
9371
|
return refKey(node.discriminant) ?? "value";
|
|
9021
9372
|
}
|
|
9022
9373
|
return "value";
|
|
@@ -9025,7 +9376,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
9025
9376
|
});
|
|
9026
9377
|
|
|
9027
9378
|
// src/rules/prefer-whole-object-assertion.ts
|
|
9028
|
-
import { AST_NODE_TYPES as
|
|
9379
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45 } from "@typescript-eslint/utils";
|
|
9029
9380
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
9030
9381
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
9031
9382
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -9034,11 +9385,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
9034
9385
|
var MIN_RUN_LENGTH = 2;
|
|
9035
9386
|
function literalText(node, getText) {
|
|
9036
9387
|
switch (node.type) {
|
|
9037
|
-
case
|
|
9388
|
+
case AST_NODE_TYPES45.Literal:
|
|
9038
9389
|
return "regex" in node ? null : getText(node);
|
|
9039
|
-
case
|
|
9390
|
+
case AST_NODE_TYPES45.TemplateLiteral:
|
|
9040
9391
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
9041
|
-
case
|
|
9392
|
+
case AST_NODE_TYPES45.UnaryExpression:
|
|
9042
9393
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
9043
9394
|
default:
|
|
9044
9395
|
return null;
|
|
@@ -9046,15 +9397,15 @@ function literalText(node, getText) {
|
|
|
9046
9397
|
}
|
|
9047
9398
|
function isPureReceiver(node) {
|
|
9048
9399
|
switch (node.type) {
|
|
9049
|
-
case
|
|
9050
|
-
case
|
|
9400
|
+
case AST_NODE_TYPES45.Identifier:
|
|
9401
|
+
case AST_NODE_TYPES45.ThisExpression:
|
|
9051
9402
|
return true;
|
|
9052
|
-
case
|
|
9403
|
+
case AST_NODE_TYPES45.MemberExpression:
|
|
9053
9404
|
if (node.optional) {
|
|
9054
9405
|
return false;
|
|
9055
9406
|
}
|
|
9056
9407
|
if (node.computed) {
|
|
9057
|
-
return node.property.type ===
|
|
9408
|
+
return node.property.type === AST_NODE_TYPES45.Literal && isPureReceiver(node.object);
|
|
9058
9409
|
}
|
|
9059
9410
|
return isPureReceiver(node.object);
|
|
9060
9411
|
default:
|
|
@@ -9062,7 +9413,7 @@ function isPureReceiver(node) {
|
|
|
9062
9413
|
}
|
|
9063
9414
|
}
|
|
9064
9415
|
function literalIndex(node) {
|
|
9065
|
-
if (node.type !==
|
|
9416
|
+
if (node.type !== AST_NODE_TYPES45.Literal || typeof node.value !== "number") {
|
|
9066
9417
|
return null;
|
|
9067
9418
|
}
|
|
9068
9419
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -9088,24 +9439,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9088
9439
|
}
|
|
9089
9440
|
const { sourceCode } = context;
|
|
9090
9441
|
function parseAssertion(statement) {
|
|
9091
|
-
if (statement.type !==
|
|
9442
|
+
if (statement.type !== AST_NODE_TYPES45.ExpressionStatement) {
|
|
9092
9443
|
return null;
|
|
9093
9444
|
}
|
|
9094
9445
|
const call = statement.expression;
|
|
9095
|
-
if (call.type !==
|
|
9446
|
+
if (call.type !== AST_NODE_TYPES45.CallExpression) {
|
|
9096
9447
|
return null;
|
|
9097
9448
|
}
|
|
9098
9449
|
const callee = call.callee;
|
|
9099
|
-
if (callee.type !==
|
|
9450
|
+
if (callee.type !== AST_NODE_TYPES45.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES45.Identifier) {
|
|
9100
9451
|
return null;
|
|
9101
9452
|
}
|
|
9102
9453
|
const matcher = callee.property.name;
|
|
9103
9454
|
const expectCall = callee.object;
|
|
9104
|
-
if (expectCall.type !==
|
|
9455
|
+
if (expectCall.type !== AST_NODE_TYPES45.CallExpression || expectCall.callee.type !== AST_NODE_TYPES45.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
9105
9456
|
return null;
|
|
9106
9457
|
}
|
|
9107
9458
|
const actual = expectCall.arguments[0];
|
|
9108
|
-
if (actual === void 0 || actual.type !==
|
|
9459
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES45.MemberExpression || actual.optional) {
|
|
9109
9460
|
return null;
|
|
9110
9461
|
}
|
|
9111
9462
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -9119,7 +9470,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9119
9470
|
}
|
|
9120
9471
|
key = { kind: "index", index };
|
|
9121
9472
|
} else {
|
|
9122
|
-
if (actual.property.type !==
|
|
9473
|
+
if (actual.property.type !== AST_NODE_TYPES45.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
9123
9474
|
return null;
|
|
9124
9475
|
}
|
|
9125
9476
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -9131,7 +9482,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9131
9482
|
return null;
|
|
9132
9483
|
}
|
|
9133
9484
|
const expected = call.arguments[0];
|
|
9134
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
9485
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES45.SpreadElement) {
|
|
9135
9486
|
return null;
|
|
9136
9487
|
}
|
|
9137
9488
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -9246,7 +9597,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9246
9597
|
});
|
|
9247
9598
|
|
|
9248
9599
|
// src/rules/prefer-zod-enum.ts
|
|
9249
|
-
import { AST_NODE_TYPES as
|
|
9600
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46 } from "@typescript-eslint/utils";
|
|
9250
9601
|
var prefer_zod_enum_default = createRule({
|
|
9251
9602
|
name: "prefer-zod-enum",
|
|
9252
9603
|
meta: {
|
|
@@ -9266,25 +9617,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
9266
9617
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
9267
9618
|
function enumValues(node) {
|
|
9268
9619
|
const callee = node.callee;
|
|
9269
|
-
if (callee.type !==
|
|
9620
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES46.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== AST_NODE_TYPES46.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
9270
9621
|
return null;
|
|
9271
9622
|
}
|
|
9272
9623
|
const argument = node.arguments[0];
|
|
9273
|
-
if (argument === void 0 || argument.type !==
|
|
9624
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES46.ArrayExpression || argument.elements.length === 0) {
|
|
9274
9625
|
return null;
|
|
9275
9626
|
}
|
|
9276
9627
|
const values = [];
|
|
9277
9628
|
let canFix = true;
|
|
9278
9629
|
for (const element of argument.elements) {
|
|
9279
|
-
if (element?.type ===
|
|
9630
|
+
if (element?.type === AST_NODE_TYPES46.SpreadElement) {
|
|
9280
9631
|
canFix = false;
|
|
9281
9632
|
continue;
|
|
9282
9633
|
}
|
|
9283
|
-
if (element === null || element.type !==
|
|
9634
|
+
if (element === null || element.type !== AST_NODE_TYPES46.CallExpression || element.callee.type !== AST_NODE_TYPES46.MemberExpression || element.callee.computed || element.callee.object.type !== AST_NODE_TYPES46.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== AST_NODE_TYPES46.Identifier || element.callee.property.name !== "literal") {
|
|
9284
9635
|
return null;
|
|
9285
9636
|
}
|
|
9286
9637
|
const value = element.arguments[0];
|
|
9287
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
9638
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== AST_NODE_TYPES46.Literal || typeof value.value !== "string") {
|
|
9288
9639
|
canFix = false;
|
|
9289
9640
|
continue;
|
|
9290
9641
|
}
|
|
@@ -9294,11 +9645,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
9294
9645
|
}
|
|
9295
9646
|
function buildFix(node, values) {
|
|
9296
9647
|
const argument = node.arguments[0];
|
|
9297
|
-
if (argument === void 0 || argument.type !==
|
|
9648
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES46.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
9298
9649
|
return void 0;
|
|
9299
9650
|
}
|
|
9300
9651
|
const callee = node.callee;
|
|
9301
|
-
if (callee.type !==
|
|
9652
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.property.type !== AST_NODE_TYPES46.Identifier) {
|
|
9302
9653
|
return void 0;
|
|
9303
9654
|
}
|
|
9304
9655
|
return (fixer) => [
|
|
@@ -9315,7 +9666,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9315
9666
|
return;
|
|
9316
9667
|
}
|
|
9317
9668
|
for (const specifier of node.specifiers) {
|
|
9318
|
-
if (specifier.type ===
|
|
9669
|
+
if (specifier.type === AST_NODE_TYPES46.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES46.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES46.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES46.Identifier && specifier.imported.name === "z") {
|
|
9319
9670
|
zodNamespaces.add(specifier.local.name);
|
|
9320
9671
|
}
|
|
9321
9672
|
}
|
|
@@ -9337,7 +9688,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9337
9688
|
});
|
|
9338
9689
|
|
|
9339
9690
|
// src/rules/prefer-zod-infer.ts
|
|
9340
|
-
import { AST_NODE_TYPES as
|
|
9691
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47 } from "@typescript-eslint/utils";
|
|
9341
9692
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
9342
9693
|
"describe",
|
|
9343
9694
|
"refine",
|
|
@@ -9374,44 +9725,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
9374
9725
|
"Schema"
|
|
9375
9726
|
]);
|
|
9376
9727
|
var LEAF_NODE_TYPES = {
|
|
9377
|
-
string: [
|
|
9378
|
-
email: [
|
|
9379
|
-
url: [
|
|
9380
|
-
uuid: [
|
|
9381
|
-
ulid: [
|
|
9382
|
-
cuid: [
|
|
9383
|
-
cuid2: [
|
|
9384
|
-
nanoid: [
|
|
9385
|
-
iso: [
|
|
9386
|
-
number: [
|
|
9387
|
-
int: [
|
|
9388
|
-
float32: [
|
|
9389
|
-
float64: [
|
|
9390
|
-
boolean: [
|
|
9391
|
-
bigint: [
|
|
9392
|
-
symbol: [
|
|
9393
|
-
any: [
|
|
9394
|
-
unknown: [
|
|
9395
|
-
never: [
|
|
9396
|
-
void: [
|
|
9397
|
-
null: [
|
|
9398
|
-
undefined: [
|
|
9399
|
-
literal: [
|
|
9400
|
-
date: [
|
|
9401
|
-
array: [
|
|
9402
|
-
tuple: [
|
|
9403
|
-
object: [
|
|
9404
|
-
strictObject: [
|
|
9405
|
-
looseObject: [
|
|
9406
|
-
record: [
|
|
9407
|
-
map: [
|
|
9408
|
-
set: [
|
|
9409
|
-
promise: [
|
|
9410
|
-
enum: [
|
|
9411
|
-
nativeEnum: [
|
|
9412
|
-
union: [
|
|
9413
|
-
discriminatedUnion: [
|
|
9414
|
-
intersection: [
|
|
9728
|
+
string: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9729
|
+
email: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9730
|
+
url: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9731
|
+
uuid: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9732
|
+
ulid: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9733
|
+
cuid: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9734
|
+
cuid2: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9735
|
+
nanoid: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9736
|
+
iso: [AST_NODE_TYPES47.TSStringKeyword],
|
|
9737
|
+
number: [AST_NODE_TYPES47.TSNumberKeyword],
|
|
9738
|
+
int: [AST_NODE_TYPES47.TSNumberKeyword],
|
|
9739
|
+
float32: [AST_NODE_TYPES47.TSNumberKeyword],
|
|
9740
|
+
float64: [AST_NODE_TYPES47.TSNumberKeyword],
|
|
9741
|
+
boolean: [AST_NODE_TYPES47.TSBooleanKeyword],
|
|
9742
|
+
bigint: [AST_NODE_TYPES47.TSBigIntKeyword],
|
|
9743
|
+
symbol: [AST_NODE_TYPES47.TSSymbolKeyword],
|
|
9744
|
+
any: [AST_NODE_TYPES47.TSAnyKeyword],
|
|
9745
|
+
unknown: [AST_NODE_TYPES47.TSUnknownKeyword],
|
|
9746
|
+
never: [AST_NODE_TYPES47.TSNeverKeyword],
|
|
9747
|
+
void: [AST_NODE_TYPES47.TSVoidKeyword],
|
|
9748
|
+
null: [AST_NODE_TYPES47.TSNullKeyword],
|
|
9749
|
+
undefined: [AST_NODE_TYPES47.TSUndefinedKeyword],
|
|
9750
|
+
literal: [AST_NODE_TYPES47.TSLiteralType],
|
|
9751
|
+
date: [AST_NODE_TYPES47.TSTypeReference],
|
|
9752
|
+
array: [AST_NODE_TYPES47.TSArrayType, AST_NODE_TYPES47.TSTypeReference],
|
|
9753
|
+
tuple: [AST_NODE_TYPES47.TSTupleType],
|
|
9754
|
+
object: [AST_NODE_TYPES47.TSTypeLiteral, AST_NODE_TYPES47.TSTypeReference],
|
|
9755
|
+
strictObject: [AST_NODE_TYPES47.TSTypeLiteral, AST_NODE_TYPES47.TSTypeReference],
|
|
9756
|
+
looseObject: [AST_NODE_TYPES47.TSTypeLiteral, AST_NODE_TYPES47.TSTypeReference],
|
|
9757
|
+
record: [AST_NODE_TYPES47.TSTypeReference, AST_NODE_TYPES47.TSTypeLiteral],
|
|
9758
|
+
map: [AST_NODE_TYPES47.TSTypeReference],
|
|
9759
|
+
set: [AST_NODE_TYPES47.TSTypeReference],
|
|
9760
|
+
promise: [AST_NODE_TYPES47.TSTypeReference],
|
|
9761
|
+
enum: [AST_NODE_TYPES47.TSUnionType, AST_NODE_TYPES47.TSTypeReference, AST_NODE_TYPES47.TSLiteralType],
|
|
9762
|
+
nativeEnum: [AST_NODE_TYPES47.TSUnionType, AST_NODE_TYPES47.TSTypeReference, AST_NODE_TYPES47.TSLiteralType],
|
|
9763
|
+
union: [AST_NODE_TYPES47.TSUnionType, AST_NODE_TYPES47.TSTypeReference],
|
|
9764
|
+
discriminatedUnion: [AST_NODE_TYPES47.TSUnionType, AST_NODE_TYPES47.TSTypeReference],
|
|
9765
|
+
intersection: [AST_NODE_TYPES47.TSIntersectionType, AST_NODE_TYPES47.TSTypeReference]
|
|
9415
9766
|
};
|
|
9416
9767
|
function normalizeSchemaName(name) {
|
|
9417
9768
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9420,20 +9771,20 @@ function normalizeTypeName(name) {
|
|
|
9420
9771
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9421
9772
|
}
|
|
9422
9773
|
function unwrapNullish(annotation) {
|
|
9423
|
-
if (annotation.type !==
|
|
9774
|
+
if (annotation.type !== AST_NODE_TYPES47.TSUnionType) {
|
|
9424
9775
|
return {
|
|
9425
9776
|
core: annotation,
|
|
9426
|
-
nullable: annotation.type ===
|
|
9777
|
+
nullable: annotation.type === AST_NODE_TYPES47.TSNullKeyword
|
|
9427
9778
|
};
|
|
9428
9779
|
}
|
|
9429
9780
|
const rest = [];
|
|
9430
9781
|
let nullable = false;
|
|
9431
9782
|
for (const member of annotation.types) {
|
|
9432
|
-
if (member.type ===
|
|
9783
|
+
if (member.type === AST_NODE_TYPES47.TSNullKeyword) {
|
|
9433
9784
|
nullable = true;
|
|
9434
9785
|
continue;
|
|
9435
9786
|
}
|
|
9436
|
-
if (member.type ===
|
|
9787
|
+
if (member.type === AST_NODE_TYPES47.TSUndefinedKeyword) {
|
|
9437
9788
|
continue;
|
|
9438
9789
|
}
|
|
9439
9790
|
rest.push(member);
|
|
@@ -9498,35 +9849,35 @@ var prefer_zod_infer_default = createRule({
|
|
|
9498
9849
|
function zodCallChain(node) {
|
|
9499
9850
|
const chain = [];
|
|
9500
9851
|
let current = node;
|
|
9501
|
-
while (current.type ===
|
|
9852
|
+
while (current.type === AST_NODE_TYPES47.CallExpression) {
|
|
9502
9853
|
const callee = current.callee;
|
|
9503
|
-
if (callee.type !==
|
|
9854
|
+
if (callee.type !== AST_NODE_TYPES47.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES47.Identifier) {
|
|
9504
9855
|
return null;
|
|
9505
9856
|
}
|
|
9506
9857
|
chain.push(current);
|
|
9507
9858
|
const receiver = callee.object;
|
|
9508
|
-
if (receiver.type ===
|
|
9859
|
+
if (receiver.type === AST_NODE_TYPES47.Identifier) {
|
|
9509
9860
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9510
9861
|
}
|
|
9511
9862
|
current = receiver;
|
|
9512
9863
|
}
|
|
9513
9864
|
return null;
|
|
9514
9865
|
}
|
|
9515
|
-
function
|
|
9866
|
+
function methodName2(call) {
|
|
9516
9867
|
const callee = call.callee;
|
|
9517
|
-
return callee.type ===
|
|
9868
|
+
return callee.type === AST_NODE_TYPES47.MemberExpression && callee.property.type === AST_NODE_TYPES47.Identifier ? callee.property.name : "";
|
|
9518
9869
|
}
|
|
9519
9870
|
function schemaField(node) {
|
|
9520
9871
|
const modifiers = [];
|
|
9521
9872
|
let current = node;
|
|
9522
9873
|
let leaf = null;
|
|
9523
|
-
while (current.type ===
|
|
9874
|
+
while (current.type === AST_NODE_TYPES47.CallExpression) {
|
|
9524
9875
|
const callee = current.callee;
|
|
9525
|
-
if (callee.type !==
|
|
9876
|
+
if (callee.type !== AST_NODE_TYPES47.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES47.Identifier) {
|
|
9526
9877
|
break;
|
|
9527
9878
|
}
|
|
9528
9879
|
const receiver = callee.object;
|
|
9529
|
-
if (receiver.type ===
|
|
9880
|
+
if (receiver.type === AST_NODE_TYPES47.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9530
9881
|
leaf = callee.property.name;
|
|
9531
9882
|
break;
|
|
9532
9883
|
}
|
|
@@ -9549,24 +9900,24 @@ var prefer_zod_infer_default = createRule({
|
|
|
9549
9900
|
if (base === void 0) {
|
|
9550
9901
|
return null;
|
|
9551
9902
|
}
|
|
9552
|
-
const baseMethod =
|
|
9903
|
+
const baseMethod = methodName2(base);
|
|
9553
9904
|
if (baseMethod !== "object" && baseMethod !== "strictObject") {
|
|
9554
9905
|
return null;
|
|
9555
9906
|
}
|
|
9556
|
-
if (rest.some((call) => !SHAPE_PRESERVING_METHODS.has(
|
|
9907
|
+
if (rest.some((call) => !SHAPE_PRESERVING_METHODS.has(methodName2(call)))) {
|
|
9557
9908
|
return null;
|
|
9558
9909
|
}
|
|
9559
9910
|
const shape = base.arguments[0];
|
|
9560
|
-
if (shape === void 0 || shape.type !==
|
|
9911
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES47.ObjectExpression) {
|
|
9561
9912
|
return null;
|
|
9562
9913
|
}
|
|
9563
9914
|
const fields = /* @__PURE__ */ new Map();
|
|
9564
9915
|
for (const property of shape.properties) {
|
|
9565
|
-
if (property.type !==
|
|
9916
|
+
if (property.type !== AST_NODE_TYPES47.Property || property.computed) {
|
|
9566
9917
|
return null;
|
|
9567
9918
|
}
|
|
9568
9919
|
const { key } = property;
|
|
9569
|
-
const name = key.type ===
|
|
9920
|
+
const name = key.type === AST_NODE_TYPES47.Identifier ? key.name : key.type === AST_NODE_TYPES47.Literal && typeof key.value === "string" ? key.value : null;
|
|
9570
9921
|
if (name === null) {
|
|
9571
9922
|
return null;
|
|
9572
9923
|
}
|
|
@@ -9577,11 +9928,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9577
9928
|
function typeMembers(members) {
|
|
9578
9929
|
const result = /* @__PURE__ */ new Map();
|
|
9579
9930
|
for (const member of members) {
|
|
9580
|
-
if (member.type !==
|
|
9931
|
+
if (member.type !== AST_NODE_TYPES47.TSPropertySignature || member.computed) {
|
|
9581
9932
|
return null;
|
|
9582
9933
|
}
|
|
9583
9934
|
const { key } = member;
|
|
9584
|
-
const name = key.type ===
|
|
9935
|
+
const name = key.type === AST_NODE_TYPES47.Identifier ? key.name : key.type === AST_NODE_TYPES47.Literal && typeof key.value === "string" ? key.value : null;
|
|
9585
9936
|
if (name === null) {
|
|
9586
9937
|
return null;
|
|
9587
9938
|
}
|
|
@@ -9595,8 +9946,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9595
9946
|
return result.size === 0 ? null : result;
|
|
9596
9947
|
}
|
|
9597
9948
|
function collectConstrainedNames(node) {
|
|
9598
|
-
if (node.type ===
|
|
9599
|
-
if (node.typeName.type ===
|
|
9949
|
+
if (node.type === AST_NODE_TYPES47.TSTypeReference) {
|
|
9950
|
+
if (node.typeName.type === AST_NODE_TYPES47.Identifier) {
|
|
9600
9951
|
constrainedTypeNames.add(node.typeName.name);
|
|
9601
9952
|
}
|
|
9602
9953
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9604,11 +9955,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9604
9955
|
}
|
|
9605
9956
|
return;
|
|
9606
9957
|
}
|
|
9607
|
-
if (node.type ===
|
|
9958
|
+
if (node.type === AST_NODE_TYPES47.TSArrayType) {
|
|
9608
9959
|
collectConstrainedNames(node.elementType);
|
|
9609
9960
|
return;
|
|
9610
9961
|
}
|
|
9611
|
-
if (node.type ===
|
|
9962
|
+
if (node.type === AST_NODE_TYPES47.TSUnionType || node.type === AST_NODE_TYPES47.TSIntersectionType) {
|
|
9612
9963
|
for (const member of node.types) {
|
|
9613
9964
|
collectConstrainedNames(member);
|
|
9614
9965
|
}
|
|
@@ -9652,13 +10003,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9652
10003
|
return;
|
|
9653
10004
|
}
|
|
9654
10005
|
for (const specifier of node.specifiers) {
|
|
9655
|
-
if (specifier.type ===
|
|
10006
|
+
if (specifier.type === AST_NODE_TYPES47.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES47.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES47.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES47.Identifier && specifier.imported.name === "z") {
|
|
9656
10007
|
zodNamespaces.add(specifier.local.name);
|
|
9657
10008
|
}
|
|
9658
10009
|
}
|
|
9659
10010
|
},
|
|
9660
10011
|
VariableDeclarator(node) {
|
|
9661
|
-
if (node.id.type !==
|
|
10012
|
+
if (node.id.type !== AST_NODE_TYPES47.Identifier || node.init == null) {
|
|
9662
10013
|
return;
|
|
9663
10014
|
}
|
|
9664
10015
|
const fields = schemaFields(node.init);
|
|
@@ -9668,14 +10019,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9668
10019
|
},
|
|
9669
10020
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9670
10021
|
"MemberExpression[computed=false]"(node) {
|
|
9671
|
-
if (node.object.type ===
|
|
10022
|
+
if (node.object.type === AST_NODE_TYPES47.Identifier && node.property.type === AST_NODE_TYPES47.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9672
10023
|
reshapedSchemaNames.add(node.object.name);
|
|
9673
10024
|
}
|
|
9674
10025
|
},
|
|
9675
10026
|
/** Records every type argument carried by a Zod constraint. */
|
|
9676
10027
|
TSTypeReference(node) {
|
|
9677
10028
|
const { typeName } = node;
|
|
9678
|
-
const referenced = typeName.type ===
|
|
10029
|
+
const referenced = typeName.type === AST_NODE_TYPES47.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES47.TSQualifiedName && typeName.right.type === AST_NODE_TYPES47.Identifier ? typeName.right.name : null;
|
|
9679
10030
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9680
10031
|
return;
|
|
9681
10032
|
}
|
|
@@ -9693,7 +10044,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9693
10044
|
}
|
|
9694
10045
|
},
|
|
9695
10046
|
TSTypeAliasDeclaration(node) {
|
|
9696
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
10047
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES47.TSTypeLiteral) {
|
|
9697
10048
|
return;
|
|
9698
10049
|
}
|
|
9699
10050
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9738,10 +10089,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9738
10089
|
});
|
|
9739
10090
|
|
|
9740
10091
|
// src/rules/require-assert-never.ts
|
|
9741
|
-
import { AST_NODE_TYPES as
|
|
10092
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48 } from "@typescript-eslint/utils";
|
|
9742
10093
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9743
|
-
if (statement.type ===
|
|
9744
|
-
if (statement.type ===
|
|
10094
|
+
if (statement.type === AST_NODE_TYPES48.EmptyStatement) return false;
|
|
10095
|
+
if (statement.type === AST_NODE_TYPES48.BlockStatement) {
|
|
9745
10096
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9746
10097
|
}
|
|
9747
10098
|
return true;
|
|
@@ -9757,7 +10108,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9757
10108
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9758
10109
|
}
|
|
9759
10110
|
const only = defaultCase.consequent[0];
|
|
9760
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
10111
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES48.BlockStatement && only.body.length === 0) {
|
|
9761
10112
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9762
10113
|
}
|
|
9763
10114
|
return false;
|
|
@@ -9797,7 +10148,7 @@ var require_assert_never_default = createRule({
|
|
|
9797
10148
|
});
|
|
9798
10149
|
|
|
9799
10150
|
// src/rules/require-fetch-timeout.ts
|
|
9800
|
-
import { AST_NODE_TYPES as
|
|
10151
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49, ASTUtils as ASTUtils6 } from "@typescript-eslint/utils";
|
|
9801
10152
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9802
10153
|
"globalThis",
|
|
9803
10154
|
"window",
|
|
@@ -9813,14 +10164,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9813
10164
|
return false;
|
|
9814
10165
|
}
|
|
9815
10166
|
function initProvablyLacksSignal(init) {
|
|
9816
|
-
if (init.type !==
|
|
10167
|
+
if (init.type !== AST_NODE_TYPES49.ObjectExpression) {
|
|
9817
10168
|
return false;
|
|
9818
10169
|
}
|
|
9819
10170
|
for (const prop of init.properties) {
|
|
9820
|
-
if (prop.type ===
|
|
10171
|
+
if (prop.type === AST_NODE_TYPES49.SpreadElement) {
|
|
9821
10172
|
return false;
|
|
9822
10173
|
}
|
|
9823
|
-
if (prop.key.type ===
|
|
10174
|
+
if (prop.key.type === AST_NODE_TYPES49.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES49.Literal && prop.key.value === "signal") {
|
|
9824
10175
|
return false;
|
|
9825
10176
|
}
|
|
9826
10177
|
if (prop.computed) {
|
|
@@ -9830,7 +10181,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9830
10181
|
return true;
|
|
9831
10182
|
}
|
|
9832
10183
|
function isStringish(node) {
|
|
9833
|
-
return node.type ===
|
|
10184
|
+
return node.type === AST_NODE_TYPES49.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES49.TemplateLiteral;
|
|
9834
10185
|
}
|
|
9835
10186
|
var require_fetch_timeout_default = createRule({
|
|
9836
10187
|
name: "require-fetch-timeout",
|
|
@@ -9867,14 +10218,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9867
10218
|
}
|
|
9868
10219
|
function resolvesToGlobal(identifier) {
|
|
9869
10220
|
const scope = context.sourceCode.getScope(identifier);
|
|
9870
|
-
const variable =
|
|
10221
|
+
const variable = ASTUtils6.findVariable(scope, identifier.name);
|
|
9871
10222
|
return variable === null || variable.defs.length === 0;
|
|
9872
10223
|
}
|
|
9873
10224
|
function isGlobalFetchCall2(callee) {
|
|
9874
|
-
if (callee.type ===
|
|
10225
|
+
if (callee.type === AST_NODE_TYPES49.Identifier) {
|
|
9875
10226
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9876
10227
|
}
|
|
9877
|
-
return callee.type ===
|
|
10228
|
+
return callee.type === AST_NODE_TYPES49.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES49.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES49.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9878
10229
|
}
|
|
9879
10230
|
return {
|
|
9880
10231
|
CallExpression(node) {
|
|
@@ -9894,28 +10245,51 @@ var require_fetch_timeout_default = createRule({
|
|
|
9894
10245
|
});
|
|
9895
10246
|
|
|
9896
10247
|
// src/rules/require-interface-for-injected-service.ts
|
|
9897
|
-
import { AST_NODE_TYPES as
|
|
10248
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50 } from "@typescript-eslint/utils";
|
|
9898
10249
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9899
10250
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9900
10251
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
9901
10252
|
var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|ReadonlyArray|ReadonlyMap|ReadonlySet|Promise|Partial|Required|Readonly|Pick|Omit|Exclude|Extract|NonNullable|Awaited|Parameters|ReturnType|InstanceType)$/;
|
|
10253
|
+
var VALUE_TYPE_RE = /^(?:ArrayBuffer|Blob|Buffer|Date|RegExp|URL|URLSearchParams)$/;
|
|
9902
10254
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9903
10255
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9904
10256
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9905
|
-
var
|
|
9906
|
-
var
|
|
10257
|
+
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
10258
|
+
var detachedValueExports = (program) => {
|
|
10259
|
+
const names = /* @__PURE__ */ new Set();
|
|
10260
|
+
for (const statement of program.body) {
|
|
10261
|
+
if (statement.type === AST_NODE_TYPES50.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
10262
|
+
for (const specifier of statement.specifiers) {
|
|
10263
|
+
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
10264
|
+
}
|
|
10265
|
+
} else if (statement.type === AST_NODE_TYPES50.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES50.Identifier) {
|
|
10266
|
+
names.add(statement.declaration.name);
|
|
10267
|
+
} else if (statement.type === AST_NODE_TYPES50.TSExportAssignment && statement.expression.type === AST_NODE_TYPES50.Identifier) {
|
|
10268
|
+
names.add(statement.expression.name);
|
|
10269
|
+
}
|
|
10270
|
+
}
|
|
10271
|
+
return names;
|
|
10272
|
+
};
|
|
10273
|
+
var isExportedClass2 = (node, detached) => node.parent.type === AST_NODE_TYPES50.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES50.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
10274
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES50.Identifier ? name.name : name.type === AST_NODE_TYPES50.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9907
10275
|
var readTypeReference = (annotation) => {
|
|
9908
|
-
if (annotation ===
|
|
10276
|
+
if (annotation?.type === AST_NODE_TYPES50.TSUnionType) {
|
|
10277
|
+
const members = annotation.types.filter(
|
|
10278
|
+
(member) => member.type !== AST_NODE_TYPES50.TSUndefinedKeyword && member.type !== AST_NODE_TYPES50.TSNullKeyword
|
|
10279
|
+
);
|
|
10280
|
+
annotation = members.length === 1 ? members[0] : void 0;
|
|
10281
|
+
}
|
|
10282
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES50.TSTypeReference) return null;
|
|
9909
10283
|
const { typeName } = annotation;
|
|
9910
|
-
const rightmost = typeName.type ===
|
|
10284
|
+
const rightmost = typeName.type === AST_NODE_TYPES50.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES50.TSQualifiedName ? typeName.right.name : null;
|
|
9911
10285
|
if (rightmost === null) return null;
|
|
9912
10286
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9913
10287
|
};
|
|
9914
10288
|
var namedParameterCollaborator = (annotated) => {
|
|
9915
10289
|
let target = annotated;
|
|
9916
|
-
if (target.type ===
|
|
9917
|
-
if (target.type ===
|
|
9918
|
-
if (target.type !==
|
|
10290
|
+
if (target.type === AST_NODE_TYPES50.TSParameterProperty) target = target.parameter;
|
|
10291
|
+
if (target.type === AST_NODE_TYPES50.AssignmentPattern) target = target.left;
|
|
10292
|
+
if (target.type !== AST_NODE_TYPES50.Identifier) return null;
|
|
9919
10293
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9920
10294
|
if (reference === null) return null;
|
|
9921
10295
|
return { name: target.name, ...reference };
|
|
@@ -9923,8 +10297,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9923
10297
|
var propertySignatureTypes = (members) => {
|
|
9924
10298
|
const types = /* @__PURE__ */ new Map();
|
|
9925
10299
|
for (const member of members) {
|
|
9926
|
-
if (member.type !==
|
|
9927
|
-
if (member.computed || member.key.type !==
|
|
10300
|
+
if (member.type !== AST_NODE_TYPES50.TSPropertySignature) continue;
|
|
10301
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES50.Identifier) continue;
|
|
9928
10302
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9929
10303
|
if (reference === null) continue;
|
|
9930
10304
|
types.set(member.key.name, reference);
|
|
@@ -9935,18 +10309,18 @@ var fileTypeIndex = (program) => {
|
|
|
9935
10309
|
const objects = /* @__PURE__ */ new Map();
|
|
9936
10310
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9937
10311
|
for (const statement of program.body) {
|
|
9938
|
-
const declaration = statement.type ===
|
|
9939
|
-
if (declaration?.type ===
|
|
10312
|
+
const declaration = statement.type === AST_NODE_TYPES50.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10313
|
+
if (declaration?.type === AST_NODE_TYPES50.TSInterfaceDeclaration) {
|
|
9940
10314
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9941
10315
|
continue;
|
|
9942
10316
|
}
|
|
9943
|
-
if (declaration?.type !==
|
|
10317
|
+
if (declaration?.type !== AST_NODE_TYPES50.TSTypeAliasDeclaration) continue;
|
|
9944
10318
|
const aliased = declaration.typeAnnotation;
|
|
9945
|
-
if (aliased.type ===
|
|
10319
|
+
if (aliased.type === AST_NODE_TYPES50.TSFunctionType || aliased.type === AST_NODE_TYPES50.TSConstructorType) {
|
|
9946
10320
|
functionAliases.add(declaration.id.name);
|
|
9947
10321
|
continue;
|
|
9948
10322
|
}
|
|
9949
|
-
const literals = aliased.type ===
|
|
10323
|
+
const literals = aliased.type === AST_NODE_TYPES50.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES50.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES50.TSTypeLiteral) : [];
|
|
9950
10324
|
if (literals.length === 0) continue;
|
|
9951
10325
|
const merged = /* @__PURE__ */ new Map();
|
|
9952
10326
|
for (const literal of literals) {
|
|
@@ -9959,10 +10333,10 @@ var fileTypeIndex = (program) => {
|
|
|
9959
10333
|
return { objects, functionAliases };
|
|
9960
10334
|
};
|
|
9961
10335
|
var bagMemberTypes = (annotation, declared) => {
|
|
9962
|
-
if (annotation.type ===
|
|
10336
|
+
if (annotation.type === AST_NODE_TYPES50.TSTypeLiteral) {
|
|
9963
10337
|
return propertySignatureTypes(annotation.members);
|
|
9964
10338
|
}
|
|
9965
|
-
if (annotation.type !==
|
|
10339
|
+
if (annotation.type !== AST_NODE_TYPES50.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES50.Identifier) {
|
|
9966
10340
|
return null;
|
|
9967
10341
|
}
|
|
9968
10342
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9974,11 +10348,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9974
10348
|
if (members === null) return [];
|
|
9975
10349
|
const collaborators = [];
|
|
9976
10350
|
for (const property of pattern.properties) {
|
|
9977
|
-
if (property.type !==
|
|
9978
|
-
if (property.key.type !==
|
|
10351
|
+
if (property.type !== AST_NODE_TYPES50.Property || property.computed) continue;
|
|
10352
|
+
if (property.key.type !== AST_NODE_TYPES50.Identifier) continue;
|
|
9979
10353
|
const key = property.key.name;
|
|
9980
|
-
const bound = property.value.type ===
|
|
9981
|
-
if (bound.type !==
|
|
10354
|
+
const bound = property.value.type === AST_NODE_TYPES50.AssignmentPattern ? property.value.left : property.value;
|
|
10355
|
+
if (bound.type !== AST_NODE_TYPES50.Identifier) continue;
|
|
9982
10356
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9983
10357
|
const reference = members.get(key);
|
|
9984
10358
|
if (reference === void 0) continue;
|
|
@@ -9988,8 +10362,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9988
10362
|
};
|
|
9989
10363
|
var parameterCollaborators = (parameter, declared) => {
|
|
9990
10364
|
let target = parameter;
|
|
9991
|
-
if (target.type ===
|
|
9992
|
-
if (target.type ===
|
|
10365
|
+
if (target.type === AST_NODE_TYPES50.AssignmentPattern) target = target.left;
|
|
10366
|
+
if (target.type === AST_NODE_TYPES50.ObjectPattern) {
|
|
9993
10367
|
return objectPatternCollaborators(target, declared);
|
|
9994
10368
|
}
|
|
9995
10369
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -10007,18 +10381,31 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
10007
10381
|
const storedFrom = /* @__PURE__ */ new Set();
|
|
10008
10382
|
let constructedFields = 0;
|
|
10009
10383
|
if (body2 !== null && body2 !== void 0) {
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
const
|
|
10013
|
-
if (
|
|
10384
|
+
const pending = [...body2.body];
|
|
10385
|
+
while (pending.length > 0) {
|
|
10386
|
+
const current = pending.pop();
|
|
10387
|
+
if (current === void 0) break;
|
|
10388
|
+
if (current.type === AST_NODE_TYPES50.ArrowFunctionExpression || current.type === AST_NODE_TYPES50.FunctionExpression || current.type === AST_NODE_TYPES50.FunctionDeclaration || current.type === AST_NODE_TYPES50.ClassExpression || current.type === AST_NODE_TYPES50.ClassDeclaration) continue;
|
|
10389
|
+
const expression = current.type === AST_NODE_TYPES50.ExpressionStatement ? current.expression : null;
|
|
10390
|
+
if (expression?.type !== AST_NODE_TYPES50.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== AST_NODE_TYPES50.MemberExpression || expression.left.object.type !== AST_NODE_TYPES50.ThisExpression) {
|
|
10391
|
+
for (const key of Object.keys(current)) {
|
|
10392
|
+
if (key === "parent") continue;
|
|
10393
|
+
const value = current[key];
|
|
10394
|
+
for (const child of Array.isArray(value) ? value : [value]) {
|
|
10395
|
+
if (child !== null && typeof child === "object" && typeof child.type === "string") {
|
|
10396
|
+
pending.push(child);
|
|
10397
|
+
}
|
|
10398
|
+
}
|
|
10399
|
+
}
|
|
10014
10400
|
continue;
|
|
10015
10401
|
}
|
|
10016
|
-
|
|
10017
|
-
|
|
10402
|
+
let source = expression.right;
|
|
10403
|
+
while (source.type === AST_NODE_TYPES50.TSNonNullExpression || source.type === AST_NODE_TYPES50.TSAsExpression || source.type === AST_NODE_TYPES50.TSSatisfiesExpression || source.type === AST_NODE_TYPES50.TSTypeAssertion) source = source.expression;
|
|
10404
|
+
if (source.type === AST_NODE_TYPES50.NewExpression) {
|
|
10018
10405
|
constructedFields += 1;
|
|
10019
|
-
} else if (source.type ===
|
|
10406
|
+
} else if (source.type === AST_NODE_TYPES50.Identifier) {
|
|
10020
10407
|
storedFrom.add(source.name);
|
|
10021
|
-
} else if (source.type ===
|
|
10408
|
+
} else if (source.type === AST_NODE_TYPES50.MemberExpression && source.object.type === AST_NODE_TYPES50.Identifier) {
|
|
10022
10409
|
storedFrom.add(source.object.name);
|
|
10023
10410
|
}
|
|
10024
10411
|
}
|
|
@@ -10026,12 +10413,13 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
10026
10413
|
const collaborators = [];
|
|
10027
10414
|
for (const parameter of ctor.value.params) {
|
|
10028
10415
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
10029
|
-
const stored = parameter.type ===
|
|
10416
|
+
const stored = parameter.type === AST_NODE_TYPES50.TSParameterProperty || storedFrom.has(reference.name);
|
|
10030
10417
|
if (!stored) continue;
|
|
10031
10418
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
10032
10419
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
10033
10420
|
if (typeParameters.has(reference.typeName)) continue;
|
|
10034
10421
|
if (BUILTIN_CONTAINER_TYPE_RE.test(reference.typeName)) continue;
|
|
10422
|
+
if (VALUE_TYPE_RE.test(reference.typeName)) continue;
|
|
10035
10423
|
if (declared().functionAliases.has(reference.typeName)) continue;
|
|
10036
10424
|
collaborators.push(reference);
|
|
10037
10425
|
}
|
|
@@ -10060,19 +10448,19 @@ var subtreeHas = (root, found) => {
|
|
|
10060
10448
|
return hit;
|
|
10061
10449
|
};
|
|
10062
10450
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
10063
|
-
if (node.type ===
|
|
10451
|
+
if (node.type === AST_NODE_TYPES50.CallExpression) {
|
|
10064
10452
|
const { callee } = node;
|
|
10065
|
-
if (callee.type ===
|
|
10066
|
-
return callee.type ===
|
|
10453
|
+
if (callee.type === AST_NODE_TYPES50.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
10454
|
+
return callee.type === AST_NODE_TYPES50.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES50.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
10067
10455
|
}
|
|
10068
|
-
return node.type ===
|
|
10456
|
+
return node.type === AST_NODE_TYPES50.TSTypeReference && node.typeName.type === AST_NODE_TYPES50.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
10069
10457
|
});
|
|
10070
10458
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
10071
10459
|
var fileInterfaceNames = (program) => {
|
|
10072
10460
|
const names = [];
|
|
10073
10461
|
for (const statement of program.body) {
|
|
10074
|
-
const declaration = statement.type ===
|
|
10075
|
-
if (declaration?.type ===
|
|
10462
|
+
const declaration = statement.type === AST_NODE_TYPES50.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10463
|
+
if (declaration?.type === AST_NODE_TYPES50.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
10076
10464
|
}
|
|
10077
10465
|
return names;
|
|
10078
10466
|
};
|
|
@@ -10087,28 +10475,153 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
10087
10475
|
return target.endsWith(other) || other.endsWith(target);
|
|
10088
10476
|
});
|
|
10089
10477
|
};
|
|
10090
|
-
var publicMethodNames = (body2) => {
|
|
10478
|
+
var publicMethodNames = (body2, functionAliases) => {
|
|
10091
10479
|
const names = [];
|
|
10092
10480
|
for (const member of body2.body) {
|
|
10093
|
-
if (member.type
|
|
10481
|
+
if (member.type === AST_NODE_TYPES50.PropertyDefinition) {
|
|
10482
|
+
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
10483
|
+
if (member.value?.type !== AST_NODE_TYPES50.ArrowFunctionExpression && member.value?.type !== AST_NODE_TYPES50.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES50.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES50.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === AST_NODE_TYPES50.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
10484
|
+
names.push(member.key.type === AST_NODE_TYPES50.Identifier ? member.key.name : "\u2026");
|
|
10485
|
+
continue;
|
|
10486
|
+
}
|
|
10487
|
+
if (member.type !== AST_NODE_TYPES50.MethodDefinition) continue;
|
|
10094
10488
|
if (member.kind !== "method" || member.static) continue;
|
|
10095
10489
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
10096
|
-
if (member.key.type ===
|
|
10097
|
-
if (member.key.type ===
|
|
10490
|
+
if (member.key.type === AST_NODE_TYPES50.PrivateIdentifier) continue;
|
|
10491
|
+
if (member.key.type === AST_NODE_TYPES50.Identifier) names.push(member.key.name);
|
|
10098
10492
|
else names.push("\u2026");
|
|
10099
10493
|
}
|
|
10100
10494
|
return names;
|
|
10101
10495
|
};
|
|
10496
|
+
function localClassAbstractness(program) {
|
|
10497
|
+
const classes = /* @__PURE__ */ new Map();
|
|
10498
|
+
const parents = /* @__PURE__ */ new Map();
|
|
10499
|
+
for (const statement of program.body) {
|
|
10500
|
+
const declaration = statement.type === AST_NODE_TYPES50.ExportNamedDeclaration || statement.type === AST_NODE_TYPES50.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
10501
|
+
if (declaration?.type === AST_NODE_TYPES50.ClassDeclaration && declaration.id !== null) {
|
|
10502
|
+
classes.set(declaration.id.name, declaration.abstract === true);
|
|
10503
|
+
if (declaration.superClass?.type === AST_NODE_TYPES50.Identifier) {
|
|
10504
|
+
parents.set(declaration.id.name, declaration.superClass.name);
|
|
10505
|
+
}
|
|
10506
|
+
}
|
|
10507
|
+
}
|
|
10508
|
+
for (let pass = 0; pass < classes.size; pass += 1) {
|
|
10509
|
+
let changed = false;
|
|
10510
|
+
for (const [name, parent] of parents) {
|
|
10511
|
+
if (classes.get(name) !== true && classes.get(parent) === true) {
|
|
10512
|
+
classes.set(name, true);
|
|
10513
|
+
changed = true;
|
|
10514
|
+
}
|
|
10515
|
+
}
|
|
10516
|
+
if (!changed) break;
|
|
10517
|
+
}
|
|
10518
|
+
return classes;
|
|
10519
|
+
}
|
|
10520
|
+
function localInterfaceSurfaces(program) {
|
|
10521
|
+
const interfaces = /* @__PURE__ */ new Map();
|
|
10522
|
+
const parents = /* @__PURE__ */ new Map();
|
|
10523
|
+
const functionAliases = /* @__PURE__ */ new Set();
|
|
10524
|
+
for (const statement of program.body) {
|
|
10525
|
+
const declaration = statement.type === AST_NODE_TYPES50.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10526
|
+
if (declaration?.type === AST_NODE_TYPES50.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === AST_NODE_TYPES50.TSFunctionType || declaration.typeAnnotation.type === AST_NODE_TYPES50.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
10527
|
+
}
|
|
10528
|
+
for (const statement of program.body) {
|
|
10529
|
+
const declaration = statement.type === AST_NODE_TYPES50.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10530
|
+
if (declaration?.type === AST_NODE_TYPES50.TSTypeAliasDeclaration) {
|
|
10531
|
+
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
10532
|
+
const parts = declaration.typeAnnotation.type === AST_NODE_TYPES50.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
10533
|
+
const inherited = parents.get(declaration.id.name) ?? [];
|
|
10534
|
+
for (const part of parts) {
|
|
10535
|
+
if (part.type === AST_NODE_TYPES50.TSTypeReference && part.typeName.type === AST_NODE_TYPES50.Identifier) {
|
|
10536
|
+
inherited.push(part.typeName.name);
|
|
10537
|
+
continue;
|
|
10538
|
+
}
|
|
10539
|
+
if (part.type !== AST_NODE_TYPES50.TSTypeLiteral) continue;
|
|
10540
|
+
for (const member of part.members) {
|
|
10541
|
+
if (member.type !== AST_NODE_TYPES50.TSMethodSignature && member.type !== AST_NODE_TYPES50.TSPropertySignature) continue;
|
|
10542
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES50.Identifier) continue;
|
|
10543
|
+
if (member.type === AST_NODE_TYPES50.TSMethodSignature) {
|
|
10544
|
+
callables2.add(member.key.name);
|
|
10545
|
+
continue;
|
|
10546
|
+
}
|
|
10547
|
+
if (member.type !== AST_NODE_TYPES50.TSPropertySignature) continue;
|
|
10548
|
+
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
10549
|
+
if (annotation?.type === AST_NODE_TYPES50.TSFunctionType || annotation?.type === AST_NODE_TYPES50.TSTypeReference && annotation.typeName.type === AST_NODE_TYPES50.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(member.key.name);
|
|
10550
|
+
}
|
|
10551
|
+
}
|
|
10552
|
+
interfaces.set(declaration.id.name, callables2);
|
|
10553
|
+
parents.set(declaration.id.name, inherited);
|
|
10554
|
+
continue;
|
|
10555
|
+
}
|
|
10556
|
+
if (declaration?.type !== AST_NODE_TYPES50.TSInterfaceDeclaration) continue;
|
|
10557
|
+
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
10558
|
+
for (const member of declaration.body.body) {
|
|
10559
|
+
if (member.type !== AST_NODE_TYPES50.TSMethodSignature && member.type !== AST_NODE_TYPES50.TSPropertySignature) continue;
|
|
10560
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES50.Identifier) continue;
|
|
10561
|
+
if (member.type === AST_NODE_TYPES50.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES50.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES50.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === AST_NODE_TYPES50.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(member.key.name);
|
|
10562
|
+
}
|
|
10563
|
+
interfaces.set(declaration.id.name, callables);
|
|
10564
|
+
parents.set(
|
|
10565
|
+
declaration.id.name,
|
|
10566
|
+
[
|
|
10567
|
+
...parents.get(declaration.id.name) ?? [],
|
|
10568
|
+
...declaration.extends.flatMap(
|
|
10569
|
+
(heritage) => heritage.expression.type === AST_NODE_TYPES50.Identifier ? [heritage.expression.name] : ["*"]
|
|
10570
|
+
)
|
|
10571
|
+
]
|
|
10572
|
+
);
|
|
10573
|
+
}
|
|
10574
|
+
for (let pass = 0; pass <= interfaces.size; pass += 1) {
|
|
10575
|
+
let changed = false;
|
|
10576
|
+
for (const [name, inherited] of parents) {
|
|
10577
|
+
const surface = interfaces.get(name);
|
|
10578
|
+
if (surface === void 0) continue;
|
|
10579
|
+
for (const parent of inherited) {
|
|
10580
|
+
const parentSurface = interfaces.get(parent);
|
|
10581
|
+
const additions = parentSurface ?? /* @__PURE__ */ new Set(["*"]);
|
|
10582
|
+
for (const method of additions) {
|
|
10583
|
+
if (!surface.has(method)) {
|
|
10584
|
+
surface.add(method);
|
|
10585
|
+
changed = true;
|
|
10586
|
+
}
|
|
10587
|
+
}
|
|
10588
|
+
}
|
|
10589
|
+
}
|
|
10590
|
+
if (!changed) break;
|
|
10591
|
+
}
|
|
10592
|
+
return interfaces;
|
|
10593
|
+
}
|
|
10594
|
+
function hasServicePort(node, methods, classes, interfaces) {
|
|
10595
|
+
if (node.superClass !== null) {
|
|
10596
|
+
if (node.superClass.type !== AST_NODE_TYPES50.Identifier) return true;
|
|
10597
|
+
const localAbstract = classes.get(node.superClass.name);
|
|
10598
|
+
if (localAbstract === void 0 || localAbstract) return true;
|
|
10599
|
+
}
|
|
10600
|
+
if (node.implements.length === 0) return false;
|
|
10601
|
+
const combined = /* @__PURE__ */ new Set();
|
|
10602
|
+
for (const implementation of node.implements) {
|
|
10603
|
+
if (implementation.expression.type !== AST_NODE_TYPES50.Identifier) return true;
|
|
10604
|
+
const name = implementation.expression.name;
|
|
10605
|
+
const localAbstract = classes.get(name);
|
|
10606
|
+
if (localAbstract === true) return true;
|
|
10607
|
+
const surface = interfaces.get(name);
|
|
10608
|
+
if (surface === void 0 && localAbstract === void 0) return true;
|
|
10609
|
+
if (surface === void 0) continue;
|
|
10610
|
+
if (surface.has("*")) return true;
|
|
10611
|
+
for (const method of surface) combined.add(method);
|
|
10612
|
+
}
|
|
10613
|
+
return methods.every((method) => combined.has(method));
|
|
10614
|
+
}
|
|
10102
10615
|
var require_interface_for_injected_service_default = createRule({
|
|
10103
10616
|
name: "require-interface-for-injected-service",
|
|
10104
10617
|
meta: {
|
|
10105
10618
|
type: "suggestion",
|
|
10106
10619
|
docs: {
|
|
10107
|
-
description: "An exported service class with constructor-injected collaborators
|
|
10620
|
+
description: "An exported service class with constructor-injected collaborators should declare the interface its public callable surface implements."
|
|
10108
10621
|
},
|
|
10109
10622
|
schema: [],
|
|
10110
10623
|
messages: {
|
|
10111
|
-
requireInterface: "`{{name}}` stores injected collaborator(s) ({{deps}}) but
|
|
10624
|
+
requireInterface: "`{{name}}` stores injected collaborator(s) ({{deps}}) but declares no service interface. Extract its public callable surface ({{methods}}) into a port and declare `class {{name}} implements <Interface>` so consumers can inject that port."
|
|
10112
10625
|
}
|
|
10113
10626
|
},
|
|
10114
10627
|
defaultOptions: [],
|
|
@@ -10117,17 +10630,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10117
10630
|
if (isTestFile(filename) || isStoryFile(filename) || isScriptFile(filename)) return {};
|
|
10118
10631
|
if (isGeneratedFile(filename, context.sourceCode.getText())) return {};
|
|
10119
10632
|
let declaredTypes = null;
|
|
10633
|
+
const detachedExports = detachedValueExports(context.sourceCode.ast);
|
|
10634
|
+
const localClasses = localClassAbstractness(context.sourceCode.ast);
|
|
10635
|
+
const localInterfaces = localInterfaceSurfaces(context.sourceCode.ast);
|
|
10120
10636
|
const objectTypes = () => declaredTypes ??= fileTypeIndex(context.sourceCode.ast);
|
|
10121
10637
|
return {
|
|
10122
10638
|
ClassDeclaration(node) {
|
|
10123
10639
|
if (node.id === null) return;
|
|
10124
|
-
if (!
|
|
10640
|
+
if (!isExportedClass2(node, detachedExports)) return;
|
|
10125
10641
|
if (node.abstract === true) return;
|
|
10126
|
-
if (node.superClass !== null) return;
|
|
10127
|
-
if (node.implements.length > 0) return;
|
|
10128
10642
|
if (node.decorators.length > 0) return;
|
|
10129
10643
|
const ctor = node.body.body.find(
|
|
10130
|
-
(member) => member.type ===
|
|
10644
|
+
(member) => member.type === AST_NODE_TYPES50.MethodDefinition && member.kind === "constructor"
|
|
10131
10645
|
);
|
|
10132
10646
|
if (ctor === void 0) return;
|
|
10133
10647
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -10139,8 +10653,9 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10139
10653
|
if (constructedFields > collaborators.length) return;
|
|
10140
10654
|
if (isFrameworkWiring(node.body)) return;
|
|
10141
10655
|
if (isTransportWrapper(node.id.name, collaborators, context.sourceCode.ast)) return;
|
|
10142
|
-
const methods = publicMethodNames(node.body);
|
|
10656
|
+
const methods = publicMethodNames(node.body, objectTypes().functionAliases);
|
|
10143
10657
|
if (methods.length === 0) return;
|
|
10658
|
+
if (hasServicePort(node, methods, localClasses, localInterfaces)) return;
|
|
10144
10659
|
context.report({
|
|
10145
10660
|
node: node.id,
|
|
10146
10661
|
messageId: "requireInterface",
|
|
@@ -10156,37 +10671,37 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10156
10671
|
});
|
|
10157
10672
|
|
|
10158
10673
|
// src/rules/require-static-next-matcher.ts
|
|
10159
|
-
import { AST_NODE_TYPES as
|
|
10674
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51 } from "@typescript-eslint/utils";
|
|
10160
10675
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
10161
10676
|
function unwrapExpression2(node) {
|
|
10162
|
-
if (node.type ===
|
|
10677
|
+
if (node.type === AST_NODE_TYPES51.TSAsExpression || node.type === AST_NODE_TYPES51.TSSatisfiesExpression || node.type === AST_NODE_TYPES51.TSNonNullExpression || node.type === AST_NODE_TYPES51.TSTypeAssertion) {
|
|
10163
10678
|
return unwrapExpression2(node.expression);
|
|
10164
10679
|
}
|
|
10165
10680
|
return node;
|
|
10166
10681
|
}
|
|
10167
10682
|
function isStaticValue(node) {
|
|
10168
10683
|
const value = unwrapExpression2(node);
|
|
10169
|
-
if (value.type ===
|
|
10684
|
+
if (value.type === AST_NODE_TYPES51.Literal) {
|
|
10170
10685
|
return true;
|
|
10171
10686
|
}
|
|
10172
|
-
if (value.type ===
|
|
10687
|
+
if (value.type === AST_NODE_TYPES51.TemplateLiteral) {
|
|
10173
10688
|
return value.expressions.length === 0;
|
|
10174
10689
|
}
|
|
10175
|
-
if (value.type ===
|
|
10690
|
+
if (value.type === AST_NODE_TYPES51.ArrayExpression) {
|
|
10176
10691
|
return value.elements.every(
|
|
10177
|
-
(element) => element !== null && element.type !==
|
|
10692
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES51.SpreadElement && isStaticValue(element)
|
|
10178
10693
|
);
|
|
10179
10694
|
}
|
|
10180
|
-
if (value.type ===
|
|
10695
|
+
if (value.type === AST_NODE_TYPES51.ObjectExpression) {
|
|
10181
10696
|
return value.properties.every(
|
|
10182
|
-
(property) => property.type ===
|
|
10697
|
+
(property) => property.type === AST_NODE_TYPES51.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES51.AssignmentPattern && isStaticValue(property.value)
|
|
10183
10698
|
);
|
|
10184
10699
|
}
|
|
10185
10700
|
return false;
|
|
10186
10701
|
}
|
|
10187
10702
|
function propertyName2(property) {
|
|
10188
10703
|
if (property.computed) return null;
|
|
10189
|
-
if (property.key.type ===
|
|
10704
|
+
if (property.key.type === AST_NODE_TYPES51.Identifier) return property.key.name;
|
|
10190
10705
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
10191
10706
|
}
|
|
10192
10707
|
var require_static_next_matcher_default = createRule({
|
|
@@ -10208,19 +10723,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
10208
10723
|
}
|
|
10209
10724
|
return {
|
|
10210
10725
|
ExportNamedDeclaration(node) {
|
|
10211
|
-
if (node.declaration?.type !==
|
|
10726
|
+
if (node.declaration?.type !== AST_NODE_TYPES51.VariableDeclaration) {
|
|
10212
10727
|
return;
|
|
10213
10728
|
}
|
|
10214
10729
|
for (const declaration of node.declaration.declarations) {
|
|
10215
|
-
if (declaration.id.type !==
|
|
10730
|
+
if (declaration.id.type !== AST_NODE_TYPES51.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
10216
10731
|
continue;
|
|
10217
10732
|
}
|
|
10218
10733
|
const config = unwrapExpression2(declaration.init);
|
|
10219
|
-
if (config.type !==
|
|
10734
|
+
if (config.type !== AST_NODE_TYPES51.ObjectExpression) {
|
|
10220
10735
|
continue;
|
|
10221
10736
|
}
|
|
10222
10737
|
for (const property of config.properties) {
|
|
10223
|
-
if (property.type !==
|
|
10738
|
+
if (property.type !== AST_NODE_TYPES51.Property || propertyName2(property) !== "matcher" || property.value.type === AST_NODE_TYPES51.AssignmentPattern) {
|
|
10224
10739
|
continue;
|
|
10225
10740
|
}
|
|
10226
10741
|
if (!isStaticValue(property.value)) {
|
|
@@ -10234,18 +10749,18 @@ var require_static_next_matcher_default = createRule({
|
|
|
10234
10749
|
});
|
|
10235
10750
|
|
|
10236
10751
|
// src/rules/require-zod-form-validation.ts
|
|
10237
|
-
import { AST_NODE_TYPES as
|
|
10752
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52 } from "@typescript-eslint/utils";
|
|
10238
10753
|
var looksLikeZodSchema = (node) => {
|
|
10239
10754
|
let current = node;
|
|
10240
10755
|
while (true) {
|
|
10241
|
-
if (current.type ===
|
|
10756
|
+
if (current.type === AST_NODE_TYPES52.Identifier) {
|
|
10242
10757
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
10243
10758
|
}
|
|
10244
|
-
if (current.type ===
|
|
10759
|
+
if (current.type === AST_NODE_TYPES52.CallExpression) {
|
|
10245
10760
|
current = current.callee;
|
|
10246
10761
|
continue;
|
|
10247
10762
|
}
|
|
10248
|
-
if (current.type ===
|
|
10763
|
+
if (current.type === AST_NODE_TYPES52.MemberExpression) {
|
|
10249
10764
|
current = current.object;
|
|
10250
10765
|
continue;
|
|
10251
10766
|
}
|
|
@@ -10253,23 +10768,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
10253
10768
|
}
|
|
10254
10769
|
};
|
|
10255
10770
|
var isZodParseCall = (node) => {
|
|
10256
|
-
if (node.type !==
|
|
10771
|
+
if (node.type !== AST_NODE_TYPES52.CallExpression) return false;
|
|
10257
10772
|
const callee = node.callee;
|
|
10258
|
-
if (callee.type !==
|
|
10773
|
+
if (callee.type !== AST_NODE_TYPES52.MemberExpression) return false;
|
|
10259
10774
|
if (callee.computed) return false;
|
|
10260
|
-
if (callee.property.type !==
|
|
10775
|
+
if (callee.property.type !== AST_NODE_TYPES52.Identifier) return false;
|
|
10261
10776
|
const method = callee.property.name;
|
|
10262
10777
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
10263
10778
|
return looksLikeZodSchema(callee.object);
|
|
10264
10779
|
};
|
|
10265
10780
|
var isFormDataMethodCall = (node) => {
|
|
10266
10781
|
let current = node;
|
|
10267
|
-
if (current.type ===
|
|
10782
|
+
if (current.type === AST_NODE_TYPES52.AwaitExpression) {
|
|
10268
10783
|
current = current.argument;
|
|
10269
10784
|
}
|
|
10270
|
-
if (current.type !==
|
|
10785
|
+
if (current.type !== AST_NODE_TYPES52.CallExpression) return false;
|
|
10271
10786
|
const callee = current.callee;
|
|
10272
|
-
return callee.type ===
|
|
10787
|
+
return callee.type === AST_NODE_TYPES52.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES52.Identifier && callee.property.name === "formData";
|
|
10273
10788
|
};
|
|
10274
10789
|
var require_zod_form_validation_default = createRule({
|
|
10275
10790
|
name: "require-zod-form-validation",
|
|
@@ -10289,14 +10804,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
10289
10804
|
return {};
|
|
10290
10805
|
}
|
|
10291
10806
|
const isFormSourceIdentifier = (node) => {
|
|
10292
|
-
if (node.type !==
|
|
10807
|
+
if (node.type !== AST_NODE_TYPES52.Identifier) return false;
|
|
10293
10808
|
if (/formdata/i.test(node.name)) return true;
|
|
10294
10809
|
let scope = context.sourceCode.getScope(node);
|
|
10295
10810
|
while (scope !== null) {
|
|
10296
10811
|
const variable = scope.set.get(node.name);
|
|
10297
10812
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
10298
10813
|
const def = variable.defs[0];
|
|
10299
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
10814
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES52.VariableDeclarator && def.node.init !== null) {
|
|
10300
10815
|
return isFormDataMethodCall(def.node.init);
|
|
10301
10816
|
}
|
|
10302
10817
|
return false;
|
|
@@ -10307,8 +10822,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
10307
10822
|
};
|
|
10308
10823
|
const isFormDataGetCall = (node) => {
|
|
10309
10824
|
const callee = node.callee;
|
|
10310
|
-
if (callee.type !==
|
|
10311
|
-
if (callee.property.type !==
|
|
10825
|
+
if (callee.type !== AST_NODE_TYPES52.MemberExpression) return false;
|
|
10826
|
+
if (callee.property.type !== AST_NODE_TYPES52.Identifier || callee.property.name !== "get") {
|
|
10312
10827
|
return false;
|
|
10313
10828
|
}
|
|
10314
10829
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -10323,11 +10838,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
10323
10838
|
};
|
|
10324
10839
|
const isInstanceofNarrowing = (node) => {
|
|
10325
10840
|
const parent = node.parent;
|
|
10326
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
10841
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES52.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES52.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
10327
10842
|
};
|
|
10328
10843
|
const boundDeclarator = (node) => {
|
|
10329
10844
|
const parent = node.parent;
|
|
10330
|
-
if (parent.type ===
|
|
10845
|
+
if (parent.type === AST_NODE_TYPES52.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES52.Identifier) {
|
|
10331
10846
|
return parent;
|
|
10332
10847
|
}
|
|
10333
10848
|
return null;
|
|
@@ -10385,8 +10900,395 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
10385
10900
|
}
|
|
10386
10901
|
});
|
|
10387
10902
|
|
|
10903
|
+
// src/rules/stepdown.ts
|
|
10904
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES53, ASTUtils as ASTUtils7 } from "@typescript-eslint/utils";
|
|
10905
|
+
function isFunction(node) {
|
|
10906
|
+
return node.type === AST_NODE_TYPES53.ArrowFunctionExpression || node.type === AST_NODE_TYPES53.FunctionDeclaration || node.type === AST_NODE_TYPES53.FunctionExpression;
|
|
10907
|
+
}
|
|
10908
|
+
function cycleComponents(graph) {
|
|
10909
|
+
const nodes = /* @__PURE__ */ new Set();
|
|
10910
|
+
const reverse = /* @__PURE__ */ new Map();
|
|
10911
|
+
for (const [caller, callees] of graph) {
|
|
10912
|
+
nodes.add(caller);
|
|
10913
|
+
for (const callee of callees) {
|
|
10914
|
+
nodes.add(callee);
|
|
10915
|
+
const incoming = reverse.get(callee) ?? /* @__PURE__ */ new Set();
|
|
10916
|
+
incoming.add(caller);
|
|
10917
|
+
reverse.set(callee, incoming);
|
|
10918
|
+
}
|
|
10919
|
+
}
|
|
10920
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10921
|
+
const finishOrder = [];
|
|
10922
|
+
for (const root of nodes) {
|
|
10923
|
+
if (seen.has(root)) continue;
|
|
10924
|
+
const pending = [
|
|
10925
|
+
{ name: root, exiting: false }
|
|
10926
|
+
];
|
|
10927
|
+
while (pending.length > 0) {
|
|
10928
|
+
const current = pending.pop();
|
|
10929
|
+
if (current === void 0) break;
|
|
10930
|
+
if (current.exiting) {
|
|
10931
|
+
finishOrder.push(current.name);
|
|
10932
|
+
continue;
|
|
10933
|
+
}
|
|
10934
|
+
if (seen.has(current.name)) continue;
|
|
10935
|
+
seen.add(current.name);
|
|
10936
|
+
pending.push({ name: current.name, exiting: true });
|
|
10937
|
+
for (const callee of graph.get(current.name) ?? []) {
|
|
10938
|
+
if (!seen.has(callee)) pending.push({ name: callee, exiting: false });
|
|
10939
|
+
}
|
|
10940
|
+
}
|
|
10941
|
+
}
|
|
10942
|
+
const components = /* @__PURE__ */ new Map();
|
|
10943
|
+
let nextComponent = 0;
|
|
10944
|
+
const assigned = /* @__PURE__ */ new Set();
|
|
10945
|
+
for (let index = finishOrder.length - 1; index >= 0; index -= 1) {
|
|
10946
|
+
const root = finishOrder[index];
|
|
10947
|
+
if (root === void 0 || assigned.has(root)) continue;
|
|
10948
|
+
const members = [];
|
|
10949
|
+
const pending = [root];
|
|
10950
|
+
assigned.add(root);
|
|
10951
|
+
while (pending.length > 0) {
|
|
10952
|
+
const member = pending.pop();
|
|
10953
|
+
if (member === void 0) break;
|
|
10954
|
+
members.push(member);
|
|
10955
|
+
for (const caller of reverse.get(member) ?? []) {
|
|
10956
|
+
if (!assigned.has(caller)) {
|
|
10957
|
+
assigned.add(caller);
|
|
10958
|
+
pending.push(caller);
|
|
10959
|
+
}
|
|
10960
|
+
}
|
|
10961
|
+
}
|
|
10962
|
+
if (members.length > 1) {
|
|
10963
|
+
for (const cyclicName of members) components.set(cyclicName, nextComponent);
|
|
10964
|
+
nextComponent += 1;
|
|
10965
|
+
}
|
|
10966
|
+
}
|
|
10967
|
+
return components;
|
|
10968
|
+
}
|
|
10969
|
+
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned) {
|
|
10970
|
+
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
10971
|
+
const cycles = cycleComponents(calls);
|
|
10972
|
+
const callers = /* @__PURE__ */ new Map();
|
|
10973
|
+
for (const [caller, callees] of calls) {
|
|
10974
|
+
for (const callee of callees) {
|
|
10975
|
+
if (caller === callee) continue;
|
|
10976
|
+
const names = callers.get(callee) ?? /* @__PURE__ */ new Set();
|
|
10977
|
+
names.add(caller);
|
|
10978
|
+
callers.set(callee, names);
|
|
10979
|
+
}
|
|
10980
|
+
}
|
|
10981
|
+
for (const helper of candidates) {
|
|
10982
|
+
const helperCallers = [...callers.get(helper.name) ?? []];
|
|
10983
|
+
if (pinned.has(helper.name) || helperCallers.length !== 1) continue;
|
|
10984
|
+
const callerName = helperCallers[0];
|
|
10985
|
+
if (callerName === void 0 || cycles.has(helper.name) && cycles.get(helper.name) === cycles.get(callerName)) continue;
|
|
10986
|
+
const caller = byName.get(callerName);
|
|
10987
|
+
if (caller === void 0 || helper.node.range[0] >= caller.node.range[0]) continue;
|
|
10988
|
+
context.report({
|
|
10989
|
+
node: helper.node,
|
|
10990
|
+
messageId: "helperAboveOnlyCaller",
|
|
10991
|
+
data: { helper: helper.name, caller: callerName }
|
|
10992
|
+
});
|
|
10993
|
+
}
|
|
10994
|
+
}
|
|
10995
|
+
function exportedNames(program) {
|
|
10996
|
+
const names = /* @__PURE__ */ new Set();
|
|
10997
|
+
for (const statement of program.body) {
|
|
10998
|
+
if (statement.type !== AST_NODE_TYPES53.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
10999
|
+
if (statement.declaration?.type === AST_NODE_TYPES53.FunctionDeclaration && statement.declaration.id !== null) {
|
|
11000
|
+
names.add(statement.declaration.id.name);
|
|
11001
|
+
}
|
|
11002
|
+
if (statement.declaration?.type === AST_NODE_TYPES53.VariableDeclaration) {
|
|
11003
|
+
for (const declarator of statement.declaration.declarations) {
|
|
11004
|
+
if (declarator.id.type === AST_NODE_TYPES53.Identifier) names.add(declarator.id.name);
|
|
11005
|
+
}
|
|
11006
|
+
}
|
|
11007
|
+
for (const specifier of statement.specifiers) {
|
|
11008
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES53.Identifier) {
|
|
11009
|
+
names.add(specifier.local.name);
|
|
11010
|
+
}
|
|
11011
|
+
}
|
|
11012
|
+
}
|
|
11013
|
+
for (const statement of program.body) {
|
|
11014
|
+
if (statement.type === AST_NODE_TYPES53.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES53.Identifier) names.add(statement.declaration.name);
|
|
11015
|
+
if (statement.type === AST_NODE_TYPES53.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES53.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
11016
|
+
}
|
|
11017
|
+
return names;
|
|
11018
|
+
}
|
|
11019
|
+
function moduleDefinitions(program) {
|
|
11020
|
+
const definitions = [];
|
|
11021
|
+
for (const statement of program.body) {
|
|
11022
|
+
const node = statement.type === AST_NODE_TYPES53.ExportNamedDeclaration || statement.type === AST_NODE_TYPES53.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
11023
|
+
if (node?.type === AST_NODE_TYPES53.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
11024
|
+
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
11025
|
+
continue;
|
|
11026
|
+
}
|
|
11027
|
+
if (node?.type !== AST_NODE_TYPES53.VariableDeclaration || node.kind !== "const") continue;
|
|
11028
|
+
for (const declarator of node.declarations) {
|
|
11029
|
+
if (declarator.id.type === AST_NODE_TYPES53.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
11030
|
+
definitions.push({
|
|
11031
|
+
name: declarator.id.name,
|
|
11032
|
+
node: declarator,
|
|
11033
|
+
functionNode: declarator.init,
|
|
11034
|
+
bindingNode: declarator
|
|
11035
|
+
});
|
|
11036
|
+
}
|
|
11037
|
+
}
|
|
11038
|
+
}
|
|
11039
|
+
return definitions;
|
|
11040
|
+
}
|
|
11041
|
+
function moduleScope(context, program) {
|
|
11042
|
+
const declarations = moduleDefinitions(program);
|
|
11043
|
+
const counts = /* @__PURE__ */ new Map();
|
|
11044
|
+
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
11045
|
+
const overloadNames = new Set(
|
|
11046
|
+
program.body.flatMap((statement) => {
|
|
11047
|
+
const node = statement.type === AST_NODE_TYPES53.ExportNamedDeclaration ? statement.declaration : statement;
|
|
11048
|
+
return node?.type === AST_NODE_TYPES53.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
11049
|
+
})
|
|
11050
|
+
);
|
|
11051
|
+
const exported = exportedNames(program);
|
|
11052
|
+
const scopeDefinitions = declarations.filter((node) => counts.get(node.name) === 1 && !overloadNames.has(node.name));
|
|
11053
|
+
const definitions = scopeDefinitions.filter((definition) => !exported.has(definition.name));
|
|
11054
|
+
const byFunction = new Map(scopeDefinitions.map((definition) => [definition.functionNode, definition]));
|
|
11055
|
+
const calls = /* @__PURE__ */ new Map();
|
|
11056
|
+
const pinned = /* @__PURE__ */ new Set();
|
|
11057
|
+
for (const definition of scopeDefinitions) {
|
|
11058
|
+
const variable = context.sourceCode.getDeclaredVariables(definition.bindingNode)[0];
|
|
11059
|
+
for (const reference of variable?.references ?? []) {
|
|
11060
|
+
if (reference.isWrite() && reference.init !== true) {
|
|
11061
|
+
pinned.add(definition.name);
|
|
11062
|
+
continue;
|
|
11063
|
+
}
|
|
11064
|
+
if (!reference.isRead()) continue;
|
|
11065
|
+
const identifier = reference.identifier;
|
|
11066
|
+
const ancestors = context.sourceCode.getAncestors(identifier);
|
|
11067
|
+
const nearestFunction = [...ancestors].reverse().find(isFunction);
|
|
11068
|
+
const parent = identifier.parent;
|
|
11069
|
+
const callerDefinition = nearestFunction === void 0 ? void 0 : byFunction.get(nearestFunction);
|
|
11070
|
+
if (callerDefinition === void 0 || parent.type !== AST_NODE_TYPES53.CallExpression || parent.callee !== identifier) {
|
|
11071
|
+
pinned.add(definition.name);
|
|
11072
|
+
continue;
|
|
11073
|
+
}
|
|
11074
|
+
const caller = callerDefinition.name;
|
|
11075
|
+
const callees = calls.get(caller) ?? /* @__PURE__ */ new Set();
|
|
11076
|
+
callees.add(definition.name);
|
|
11077
|
+
calls.set(caller, callees);
|
|
11078
|
+
}
|
|
11079
|
+
}
|
|
11080
|
+
reportMisordered(context, definitions, scopeDefinitions, calls, pinned);
|
|
11081
|
+
}
|
|
11082
|
+
function methodName(node) {
|
|
11083
|
+
if (node.key.type === AST_NODE_TYPES53.PrivateIdentifier) return `#${node.key.name}`;
|
|
11084
|
+
return !node.computed && node.key.type === AST_NODE_TYPES53.Identifier ? node.key.name : null;
|
|
11085
|
+
}
|
|
11086
|
+
function referencedMethod(context, node, classVariables) {
|
|
11087
|
+
const objectVariable = node.object.type === AST_NODE_TYPES53.Identifier ? ASTUtils7.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
11088
|
+
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
11089
|
+
if (node.object.type !== AST_NODE_TYPES53.ThisExpression && !isClassReference) return null;
|
|
11090
|
+
if (node.property.type === AST_NODE_TYPES53.PrivateIdentifier) return `#${node.property.name}`;
|
|
11091
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES53.Identifier) return node.property.name;
|
|
11092
|
+
return node.computed && node.property.type === AST_NODE_TYPES53.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
11093
|
+
}
|
|
11094
|
+
function referencedPropertyName(node) {
|
|
11095
|
+
if (node.property.type === AST_NODE_TYPES53.PrivateIdentifier) return `#${node.property.name}`;
|
|
11096
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES53.Identifier) return node.property.name;
|
|
11097
|
+
return node.computed && node.property.type === AST_NODE_TYPES53.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
11098
|
+
}
|
|
11099
|
+
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
11100
|
+
visit(node, nestedFunction);
|
|
11101
|
+
const nested = nestedFunction || isFunction(node);
|
|
11102
|
+
for (const key of visitorKeys[node.type] ?? []) {
|
|
11103
|
+
const child = node[key];
|
|
11104
|
+
if (Array.isArray(child)) {
|
|
11105
|
+
for (const item of child) if (typeof item === "object" && item !== null && "type" in item) walk(item, visitorKeys, visit, nested);
|
|
11106
|
+
} else if (typeof child === "object" && child !== null && "type" in child) {
|
|
11107
|
+
walk(child, visitorKeys, visit, nested);
|
|
11108
|
+
}
|
|
11109
|
+
}
|
|
11110
|
+
}
|
|
11111
|
+
function classScope(context, node, computedReferenceNames) {
|
|
11112
|
+
const methods = node.body.body.filter(
|
|
11113
|
+
(member) => member.type === AST_NODE_TYPES53.MethodDefinition
|
|
11114
|
+
);
|
|
11115
|
+
const counts = /* @__PURE__ */ new Map();
|
|
11116
|
+
for (const method of methods) {
|
|
11117
|
+
const name = methodName(method);
|
|
11118
|
+
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
11119
|
+
}
|
|
11120
|
+
for (const member of node.body.body) {
|
|
11121
|
+
if (member.type !== AST_NODE_TYPES53.TSAbstractMethodDefinition) continue;
|
|
11122
|
+
const name = !member.computed && member.key.type === AST_NODE_TYPES53.Identifier ? member.key.name : null;
|
|
11123
|
+
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
11124
|
+
}
|
|
11125
|
+
const scopeDefinitions = methods.flatMap((method) => {
|
|
11126
|
+
const name = methodName(method);
|
|
11127
|
+
return name !== null && counts.get(name) === 1 ? [{ name, node: method }] : [];
|
|
11128
|
+
});
|
|
11129
|
+
const definitions = methods.flatMap((method) => {
|
|
11130
|
+
const name = methodName(method);
|
|
11131
|
+
const isPrivate = method.accessibility === "private" || method.key.type === AST_NODE_TYPES53.PrivateIdentifier;
|
|
11132
|
+
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
11133
|
+
});
|
|
11134
|
+
if (definitions.length === 0) return;
|
|
11135
|
+
const privateNames = new Set(definitions.map((definition) => definition.name));
|
|
11136
|
+
const calls = /* @__PURE__ */ new Map();
|
|
11137
|
+
const pinned = /* @__PURE__ */ new Set();
|
|
11138
|
+
const classVariables = /* @__PURE__ */ new Set();
|
|
11139
|
+
if (node.id !== null) {
|
|
11140
|
+
const internal = ASTUtils7.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
11141
|
+
if (internal !== null) classVariables.add(internal);
|
|
11142
|
+
}
|
|
11143
|
+
if (node.type === AST_NODE_TYPES53.ClassExpression && node.parent.type === AST_NODE_TYPES53.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES53.Identifier) {
|
|
11144
|
+
const outer = ASTUtils7.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
11145
|
+
if (outer !== null) classVariables.add(outer);
|
|
11146
|
+
}
|
|
11147
|
+
for (const method of methods) {
|
|
11148
|
+
const caller = methodName(method);
|
|
11149
|
+
if (caller === null || method.value.body === null) continue;
|
|
11150
|
+
const methodClassVariables = new Set(classVariables);
|
|
11151
|
+
const methodAliases = /* @__PURE__ */ new Set();
|
|
11152
|
+
const parameterDecoratorNodes = /* @__PURE__ */ new Set();
|
|
11153
|
+
for (const parameter of method.value.params) {
|
|
11154
|
+
for (const decorator of parameter.decorators) {
|
|
11155
|
+
walk(decorator, context.sourceCode.visitorKeys, (current) => parameterDecoratorNodes.add(current));
|
|
11156
|
+
}
|
|
11157
|
+
}
|
|
11158
|
+
const thisValue = (value) => {
|
|
11159
|
+
let current = value;
|
|
11160
|
+
while (current?.type === AST_NODE_TYPES53.TSAsExpression || current?.type === AST_NODE_TYPES53.TSSatisfiesExpression || current?.type === AST_NODE_TYPES53.TSNonNullExpression) current = current.expression;
|
|
11161
|
+
return current?.type === AST_NODE_TYPES53.ThisExpression;
|
|
11162
|
+
};
|
|
11163
|
+
const collectAlias = (current, nestedFunction) => {
|
|
11164
|
+
if (nestedFunction || current.type !== AST_NODE_TYPES53.VariableDeclarator && current.type !== AST_NODE_TYPES53.AssignmentPattern) return;
|
|
11165
|
+
if (current.type === AST_NODE_TYPES53.VariableDeclarator && (current.parent.type !== AST_NODE_TYPES53.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
11166
|
+
const binding = current.type === AST_NODE_TYPES53.VariableDeclarator ? current.id : current.left;
|
|
11167
|
+
const value = current.type === AST_NODE_TYPES53.VariableDeclarator ? current.init : current.right;
|
|
11168
|
+
if (!thisValue(value)) return;
|
|
11169
|
+
if (binding.type === AST_NODE_TYPES53.ObjectPattern) {
|
|
11170
|
+
for (const property of binding.properties) {
|
|
11171
|
+
if (property.type === AST_NODE_TYPES53.RestElement) {
|
|
11172
|
+
for (const name of privateNames) pinned.add(name);
|
|
11173
|
+
} else if (property.key.type === AST_NODE_TYPES53.Identifier && privateNames.has(property.key.name)) {
|
|
11174
|
+
pinned.add(property.key.name);
|
|
11175
|
+
}
|
|
11176
|
+
}
|
|
11177
|
+
return;
|
|
11178
|
+
}
|
|
11179
|
+
if (binding.type !== AST_NODE_TYPES53.Identifier) return;
|
|
11180
|
+
const variable = ASTUtils7.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
11181
|
+
if (variable !== null) {
|
|
11182
|
+
methodClassVariables.add(variable);
|
|
11183
|
+
methodAliases.add(variable);
|
|
11184
|
+
}
|
|
11185
|
+
};
|
|
11186
|
+
for (const parameter of method.value.params) {
|
|
11187
|
+
walk(parameter, context.sourceCode.visitorKeys, collectAlias);
|
|
11188
|
+
}
|
|
11189
|
+
for (const statement of method.value.body.body) {
|
|
11190
|
+
walk(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
11191
|
+
}
|
|
11192
|
+
const visitCall = (current, nestedFunction) => {
|
|
11193
|
+
if (current.type === AST_NODE_TYPES53.VariableDeclarator && current.id.type === AST_NODE_TYPES53.ObjectPattern && thisValue(current.init)) {
|
|
11194
|
+
for (const property of current.id.properties) {
|
|
11195
|
+
if (property.type === AST_NODE_TYPES53.RestElement) {
|
|
11196
|
+
for (const name of privateNames) pinned.add(name);
|
|
11197
|
+
continue;
|
|
11198
|
+
}
|
|
11199
|
+
if (property.type === AST_NODE_TYPES53.Property && property.key.type === AST_NODE_TYPES53.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
11200
|
+
}
|
|
11201
|
+
}
|
|
11202
|
+
if (current.type !== AST_NODE_TYPES53.MemberExpression) return;
|
|
11203
|
+
const target = referencedMethod(context, current, methodClassVariables);
|
|
11204
|
+
if (target === null) {
|
|
11205
|
+
const possibleTarget = referencedPropertyName(current);
|
|
11206
|
+
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
11207
|
+
return;
|
|
11208
|
+
}
|
|
11209
|
+
if (!privateNames.has(target)) return;
|
|
11210
|
+
const objectVariable = current.object.type === AST_NODE_TYPES53.Identifier ? ASTUtils7.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
11211
|
+
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
11212
|
+
pinned.add(target);
|
|
11213
|
+
return;
|
|
11214
|
+
}
|
|
11215
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== AST_NODE_TYPES53.CallExpression || current.parent.callee !== current) {
|
|
11216
|
+
pinned.add(target);
|
|
11217
|
+
return;
|
|
11218
|
+
}
|
|
11219
|
+
const callees = calls.get(caller) ?? /* @__PURE__ */ new Set();
|
|
11220
|
+
callees.add(target);
|
|
11221
|
+
calls.set(caller, callees);
|
|
11222
|
+
};
|
|
11223
|
+
for (const decorator of method.decorators) {
|
|
11224
|
+
walk(decorator, context.sourceCode.visitorKeys, visitCall, true);
|
|
11225
|
+
}
|
|
11226
|
+
if (method.computed) walk(method.key, context.sourceCode.visitorKeys, visitCall, true);
|
|
11227
|
+
for (const parameter of method.value.params) {
|
|
11228
|
+
walk(parameter, context.sourceCode.visitorKeys, visitCall);
|
|
11229
|
+
}
|
|
11230
|
+
for (const statement of method.value.body.body) {
|
|
11231
|
+
walk(statement, context.sourceCode.visitorKeys, visitCall);
|
|
11232
|
+
}
|
|
11233
|
+
}
|
|
11234
|
+
for (const member of node.body.body) {
|
|
11235
|
+
if (member.type === AST_NODE_TYPES53.MethodDefinition || member.type === AST_NODE_TYPES53.TSAbstractMethodDefinition) continue;
|
|
11236
|
+
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
11237
|
+
if (current.type !== AST_NODE_TYPES53.MemberExpression) return;
|
|
11238
|
+
const target = referencedMethod(context, current, classVariables);
|
|
11239
|
+
const possibleTarget = target ?? referencedPropertyName(current);
|
|
11240
|
+
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
11241
|
+
});
|
|
11242
|
+
}
|
|
11243
|
+
for (const name of privateNames) if (computedReferenceNames.has(name)) pinned.add(name);
|
|
11244
|
+
const accessibility = new Map(
|
|
11245
|
+
scopeDefinitions.map((definition) => {
|
|
11246
|
+
const method = definition.node;
|
|
11247
|
+
const accessibility2 = method.key.type === AST_NODE_TYPES53.PrivateIdentifier ? "private" : method.accessibility ?? "public";
|
|
11248
|
+
return [definition.name, accessibility2];
|
|
11249
|
+
})
|
|
11250
|
+
);
|
|
11251
|
+
for (const [caller, callees] of calls) {
|
|
11252
|
+
if (accessibility.get(caller) === "private") continue;
|
|
11253
|
+
for (const callee of callees) pinned.add(callee);
|
|
11254
|
+
}
|
|
11255
|
+
reportMisordered(context, definitions, scopeDefinitions, calls, pinned);
|
|
11256
|
+
}
|
|
11257
|
+
var stepdown_default = createRule({
|
|
11258
|
+
name: "stepdown",
|
|
11259
|
+
meta: {
|
|
11260
|
+
type: "suggestion",
|
|
11261
|
+
docs: { description: "Place a private helper below its sole direct same-scope caller." },
|
|
11262
|
+
schema: [],
|
|
11263
|
+
messages: {
|
|
11264
|
+
helperAboveOnlyCaller: "Private helper `{{helper}}` is defined above its only caller `{{caller}}`; move it below the caller."
|
|
11265
|
+
}
|
|
11266
|
+
},
|
|
11267
|
+
defaultOptions: [],
|
|
11268
|
+
create(context) {
|
|
11269
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
11270
|
+
const classes = [];
|
|
11271
|
+
return {
|
|
11272
|
+
ClassDeclaration: (node) => {
|
|
11273
|
+
classes.push(node);
|
|
11274
|
+
},
|
|
11275
|
+
ClassExpression: (node) => {
|
|
11276
|
+
classes.push(node);
|
|
11277
|
+
},
|
|
11278
|
+
"Program:exit": (program) => {
|
|
11279
|
+
moduleScope(context, program);
|
|
11280
|
+
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
11281
|
+
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
11282
|
+
if (node.type === AST_NODE_TYPES53.MemberExpression && node.computed && node.property.type === AST_NODE_TYPES53.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
11283
|
+
});
|
|
11284
|
+
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
11285
|
+
}
|
|
11286
|
+
};
|
|
11287
|
+
}
|
|
11288
|
+
});
|
|
11289
|
+
|
|
10388
11290
|
// src/rules/zod-naming-convention.ts
|
|
10389
|
-
import { AST_NODE_TYPES as
|
|
11291
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54 } from "@typescript-eslint/utils";
|
|
10390
11292
|
var CONVENTIONS = {
|
|
10391
11293
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
10392
11294
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -10411,15 +11313,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
10411
11313
|
"registry",
|
|
10412
11314
|
"implement"
|
|
10413
11315
|
]);
|
|
10414
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
11316
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES54.Identifier ? callee.property.name : null;
|
|
10415
11317
|
var calleeChainStartsWithZ = (node) => {
|
|
10416
11318
|
let current = node;
|
|
10417
|
-
while (current.type ===
|
|
11319
|
+
while (current.type === AST_NODE_TYPES54.MemberExpression) {
|
|
10418
11320
|
const receiver = current.object;
|
|
10419
|
-
if (receiver.type ===
|
|
11321
|
+
if (receiver.type === AST_NODE_TYPES54.Identifier && receiver.name === "z") {
|
|
10420
11322
|
return true;
|
|
10421
11323
|
}
|
|
10422
|
-
if (receiver.type ===
|
|
11324
|
+
if (receiver.type === AST_NODE_TYPES54.CallExpression) {
|
|
10423
11325
|
current = receiver.callee;
|
|
10424
11326
|
continue;
|
|
10425
11327
|
}
|
|
@@ -10464,13 +11366,13 @@ var zod_naming_convention_default = createRule({
|
|
|
10464
11366
|
VariableDeclarator(node) {
|
|
10465
11367
|
const init = node.init;
|
|
10466
11368
|
if (init === null || init === void 0) return;
|
|
10467
|
-
if (init.type !==
|
|
11369
|
+
if (init.type !== AST_NODE_TYPES54.CallExpression) return;
|
|
10468
11370
|
const callee = init.callee;
|
|
10469
|
-
if (callee.type !==
|
|
11371
|
+
if (callee.type !== AST_NODE_TYPES54.MemberExpression) return;
|
|
10470
11372
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
10471
11373
|
const terminal = terminalMethodName(callee);
|
|
10472
11374
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
10473
|
-
if (node.id.type !==
|
|
11375
|
+
if (node.id.type !== AST_NODE_TYPES54.Identifier) return;
|
|
10474
11376
|
if (test.test(node.id.name)) return;
|
|
10475
11377
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
10476
11378
|
context.report({
|
|
@@ -10555,6 +11457,7 @@ var rules = {
|
|
|
10555
11457
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
10556
11458
|
"no-log-only-catch": no_log_only_catch_default,
|
|
10557
11459
|
"no-long-comment": no_long_comment_default,
|
|
11460
|
+
"no-generic-single-export-module": no_generic_single_export_module_default,
|
|
10558
11461
|
"no-offset-pagination": no_offset_pagination_default,
|
|
10559
11462
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
10560
11463
|
"no-raw-env": no_raw_env_default,
|
|
@@ -10602,11 +11505,12 @@ var rules = {
|
|
|
10602
11505
|
"require-static-next-matcher": require_static_next_matcher_default,
|
|
10603
11506
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
10604
11507
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
11508
|
+
"stepdown": stepdown_default,
|
|
10605
11509
|
"zod-naming-convention": zod_naming_convention_default
|
|
10606
11510
|
};
|
|
10607
11511
|
var meta = {
|
|
10608
11512
|
name: "@sarj/eslint-plugin",
|
|
10609
|
-
version: "9.
|
|
11513
|
+
version: "9.14.0"
|
|
10610
11514
|
};
|
|
10611
11515
|
var applicationOnlyRules = [
|
|
10612
11516
|
"no-restricted-library-load",
|
|
@@ -10628,6 +11532,7 @@ var recommendedRules = {
|
|
|
10628
11532
|
"@sarj/no-json-stringify-error": "warn",
|
|
10629
11533
|
"@sarj/no-log-only-catch": "warn",
|
|
10630
11534
|
"@sarj/no-long-comment": "warn",
|
|
11535
|
+
"@sarj/no-generic-single-export-module": "warn",
|
|
10631
11536
|
"@sarj/no-offset-pagination": "warn",
|
|
10632
11537
|
"@sarj/no-positional-tuple-return": "warn",
|
|
10633
11538
|
"@sarj/no-repeated-string-literal": "warn",
|
|
@@ -10669,6 +11574,7 @@ var recommendedRules = {
|
|
|
10669
11574
|
"@sarj/require-static-next-matcher": "error",
|
|
10670
11575
|
"@sarj/require-zod-form-validation": "error",
|
|
10671
11576
|
"@sarj/store-insert-requires-on-conflict": "warn",
|
|
11577
|
+
"@sarj/stepdown": "warn",
|
|
10672
11578
|
"@sarj/zod-naming-convention": "warn"
|
|
10673
11579
|
};
|
|
10674
11580
|
var strictRules = {
|
|
@@ -10687,6 +11593,7 @@ var strictRules = {
|
|
|
10687
11593
|
"@sarj/no-json-stringify-error": "error",
|
|
10688
11594
|
"@sarj/no-log-only-catch": "error",
|
|
10689
11595
|
"@sarj/no-long-comment": "error",
|
|
11596
|
+
"@sarj/no-generic-single-export-module": "warn",
|
|
10690
11597
|
"@sarj/no-offset-pagination": "error",
|
|
10691
11598
|
"@sarj/no-positional-tuple-return": "error",
|
|
10692
11599
|
"@sarj/no-raw-env": "error",
|
|
@@ -10731,6 +11638,7 @@ var strictRules = {
|
|
|
10731
11638
|
"@sarj/require-static-next-matcher": "error",
|
|
10732
11639
|
"@sarj/require-zod-form-validation": "error",
|
|
10733
11640
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
11641
|
+
"@sarj/stepdown": "warn",
|
|
10734
11642
|
"@sarj/zod-naming-convention": "error"
|
|
10735
11643
|
};
|
|
10736
11644
|
var plugin = {
|