@sarj/eslint-plugin 9.13.0 → 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/LICENSE +21 -0
- package/README.md +23 -3
- package/dist/index.cjs +1580 -661
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +1570 -651
- package/package.json +5 -3
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
|
|
3199
|
-
}
|
|
3200
|
-
if (elements.some((element) => element.type === AST_NODE_TYPES14.TSNamedTupleMember)) {
|
|
3201
|
-
return true;
|
|
3387
|
+
if (node.type === AST_NODE_TYPES15.TSTypeOperator && node.operator === "readonly") {
|
|
3388
|
+
return node.typeAnnotation === void 0 ? null : tupleReturnType(node.typeAnnotation, aliases, resolving);
|
|
3202
3389
|
}
|
|
3203
|
-
if (
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
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,69 +7078,76 @@ 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
|
-
function isObjectFreeze(node) {
|
|
7092
|
+
function isObjectFreeze(node, isUnshadowedGlobal) {
|
|
6742
7093
|
const inner = unwrapExpression(node);
|
|
6743
|
-
|
|
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) {
|
|
7095
|
+
const argument = inner.arguments[0];
|
|
7096
|
+
return argument !== void 0 && argument.type !== AST_NODE_TYPES36.SpreadElement && collectionKind(argument, isUnshadowedGlobal) === "literal";
|
|
7097
|
+
}
|
|
7098
|
+
return false;
|
|
6744
7099
|
}
|
|
6745
|
-
function collectionKind(node) {
|
|
7100
|
+
function collectionKind(node, isUnshadowedGlobal) {
|
|
6746
7101
|
const inner = unwrapExpression(node);
|
|
6747
|
-
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) {
|
|
7103
|
+
return collectionKind(inner.arguments[0], isUnshadowedGlobal);
|
|
7104
|
+
}
|
|
7105
|
+
if (inner.type === AST_NODE_TYPES36.ArrayExpression || inner.type === AST_NODE_TYPES36.ObjectExpression) {
|
|
6748
7106
|
return "literal";
|
|
6749
7107
|
}
|
|
6750
|
-
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)) {
|
|
6751
7109
|
return inner.callee.name;
|
|
6752
7110
|
}
|
|
6753
7111
|
return null;
|
|
6754
7112
|
}
|
|
6755
7113
|
function isReadonlyType(node, kind) {
|
|
6756
|
-
if (node.type ===
|
|
7114
|
+
if (node.type === AST_NODE_TYPES36.TSTypeOperator && node.operator === "readonly") {
|
|
6757
7115
|
return true;
|
|
6758
7116
|
}
|
|
6759
|
-
if (node.type !==
|
|
7117
|
+
if (node.type !== AST_NODE_TYPES36.TSTypeReference || node.typeName.type !== AST_NODE_TYPES36.Identifier) {
|
|
6760
7118
|
return false;
|
|
6761
7119
|
}
|
|
6762
7120
|
if (node.typeName.name === "Readonly") {
|
|
6763
|
-
return
|
|
7121
|
+
return kind === "literal";
|
|
6764
7122
|
}
|
|
6765
7123
|
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
6766
7124
|
}
|
|
6767
7125
|
function declaredReadonlyType(node, kind) {
|
|
6768
|
-
const annotation = node.id.type ===
|
|
7126
|
+
const annotation = node.id.type === AST_NODE_TYPES36.Identifier ? node.id.typeAnnotation : void 0;
|
|
6769
7127
|
if (annotation !== void 0 && isReadonlyType(annotation.typeAnnotation, kind)) {
|
|
6770
7128
|
return true;
|
|
6771
7129
|
}
|
|
6772
|
-
return node.init?.type ===
|
|
7130
|
+
return node.init?.type === AST_NODE_TYPES36.TSAsExpression && isReadonlyType(node.init.typeAnnotation, kind);
|
|
6773
7131
|
}
|
|
6774
7132
|
function referenceMutates(identifier) {
|
|
6775
7133
|
let member = identifier.parent;
|
|
6776
|
-
if (member?.type !==
|
|
6777
|
-
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";
|
|
6778
7136
|
}
|
|
6779
|
-
while (member.parent.type ===
|
|
7137
|
+
while (member.parent.type === AST_NODE_TYPES36.MemberExpression && member.parent.object === member) {
|
|
6780
7138
|
member = member.parent;
|
|
6781
7139
|
}
|
|
6782
7140
|
const parent = member.parent;
|
|
6783
|
-
if (parent?.type ===
|
|
7141
|
+
if (parent?.type === AST_NODE_TYPES36.AssignmentExpression && parent.left === member) {
|
|
6784
7142
|
return true;
|
|
6785
7143
|
}
|
|
6786
|
-
if (parent?.type ===
|
|
7144
|
+
if (parent?.type === AST_NODE_TYPES36.UpdateExpression && parent.argument === member) {
|
|
6787
7145
|
return true;
|
|
6788
7146
|
}
|
|
6789
|
-
if (parent?.type ===
|
|
7147
|
+
if (parent?.type === AST_NODE_TYPES36.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
6790
7148
|
return true;
|
|
6791
7149
|
}
|
|
6792
|
-
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);
|
|
6793
7151
|
}
|
|
6794
7152
|
var prefer_immutable_module_constant_default = createRule({
|
|
6795
7153
|
name: "prefer-immutable-module-constant",
|
|
@@ -6807,29 +7165,33 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
6807
7165
|
defaultOptions: [],
|
|
6808
7166
|
create(context) {
|
|
6809
7167
|
const sourceCode = context.sourceCode;
|
|
7168
|
+
const isUnshadowedGlobal = (identifier) => {
|
|
7169
|
+
const variable = ASTUtils4.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
7170
|
+
return variable === null || variable.defs.length === 0;
|
|
7171
|
+
};
|
|
6810
7172
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
6811
7173
|
return {};
|
|
6812
7174
|
}
|
|
6813
7175
|
return {
|
|
6814
7176
|
VariableDeclarator(node) {
|
|
6815
7177
|
const declaration = node.parent;
|
|
6816
|
-
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)) {
|
|
6817
7179
|
return;
|
|
6818
7180
|
}
|
|
6819
7181
|
const container = declaration.parent;
|
|
6820
|
-
if (container.type !==
|
|
7182
|
+
if (container.type !== AST_NODE_TYPES36.Program && !(container.type === AST_NODE_TYPES36.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES36.Program)) {
|
|
6821
7183
|
return;
|
|
6822
7184
|
}
|
|
6823
|
-
if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init)) {
|
|
7185
|
+
if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init, isUnshadowedGlobal)) {
|
|
6824
7186
|
return;
|
|
6825
7187
|
}
|
|
6826
|
-
const kind = collectionKind(node.init);
|
|
7188
|
+
const kind = collectionKind(node.init, isUnshadowedGlobal);
|
|
6827
7189
|
if (kind === null || declaredReadonlyType(node, kind)) {
|
|
6828
7190
|
return;
|
|
6829
7191
|
}
|
|
6830
7192
|
const variable = sourceCode.getDeclaredVariables(node)[0];
|
|
6831
7193
|
if (variable?.references.some(
|
|
6832
|
-
(reference) => reference.identifier.type ===
|
|
7194
|
+
(reference) => reference.identifier.type === AST_NODE_TYPES36.Identifier && referenceMutates(reference.identifier)
|
|
6833
7195
|
) === true) {
|
|
6834
7196
|
return;
|
|
6835
7197
|
}
|
|
@@ -6844,7 +7206,7 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
6844
7206
|
});
|
|
6845
7207
|
|
|
6846
7208
|
// src/rules/prefer-shadcn-primitives.ts
|
|
6847
|
-
import { AST_NODE_TYPES as
|
|
7209
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37 } from "@typescript-eslint/utils";
|
|
6848
7210
|
var SHADCN_PRIMITIVES = {
|
|
6849
7211
|
button: "Button",
|
|
6850
7212
|
dialog: "Dialog or AlertDialog family",
|
|
@@ -6865,15 +7227,15 @@ var LABELABLE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
6865
7227
|
"textarea"
|
|
6866
7228
|
]);
|
|
6867
7229
|
function rawElementName(node) {
|
|
6868
|
-
if (node.name.type !==
|
|
7230
|
+
if (node.name.type !== AST_NODE_TYPES37.JSXIdentifier) return null;
|
|
6869
7231
|
const name = node.name.name;
|
|
6870
7232
|
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
6871
7233
|
}
|
|
6872
7234
|
function staticExpressionString(expression) {
|
|
6873
|
-
if (expression.type ===
|
|
7235
|
+
if (expression.type === AST_NODE_TYPES37.Literal) {
|
|
6874
7236
|
return typeof expression.value === "string" ? expression.value : null;
|
|
6875
7237
|
}
|
|
6876
|
-
if (expression.type ===
|
|
7238
|
+
if (expression.type === AST_NODE_TYPES37.TemplateLiteral) {
|
|
6877
7239
|
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
6878
7240
|
for (const [index, substitution] of expression.expressions.entries()) {
|
|
6879
7241
|
const staticSubstitution = staticExpressionString(substitution);
|
|
@@ -6883,24 +7245,24 @@ function staticExpressionString(expression) {
|
|
|
6883
7245
|
}
|
|
6884
7246
|
return value;
|
|
6885
7247
|
}
|
|
6886
|
-
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) {
|
|
6887
7249
|
return staticExpressionString(expression.expression);
|
|
6888
7250
|
}
|
|
6889
7251
|
return null;
|
|
6890
7252
|
}
|
|
6891
7253
|
function staticString(value) {
|
|
6892
|
-
if (value?.type ===
|
|
7254
|
+
if (value?.type === AST_NODE_TYPES37.Literal) {
|
|
6893
7255
|
return typeof value.value === "string" ? value.value : null;
|
|
6894
7256
|
}
|
|
6895
|
-
if (value?.type !==
|
|
7257
|
+
if (value?.type !== AST_NODE_TYPES37.JSXExpressionContainer) return null;
|
|
6896
7258
|
return staticExpressionString(value.expression);
|
|
6897
7259
|
}
|
|
6898
7260
|
function effectiveAttribute(node, attributeName) {
|
|
6899
7261
|
for (const attribute of node.attributes.toReversed()) {
|
|
6900
|
-
if (attribute.type ===
|
|
7262
|
+
if (attribute.type === AST_NODE_TYPES37.JSXSpreadAttribute) {
|
|
6901
7263
|
return { kind: "unknown" };
|
|
6902
7264
|
}
|
|
6903
|
-
if (attribute.name.type !==
|
|
7265
|
+
if (attribute.name.type !== AST_NODE_TYPES37.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
6904
7266
|
continue;
|
|
6905
7267
|
}
|
|
6906
7268
|
const value = staticString(attribute.value);
|
|
@@ -6909,7 +7271,7 @@ function effectiveAttribute(node, attributeName) {
|
|
|
6909
7271
|
return { kind: "missing" };
|
|
6910
7272
|
}
|
|
6911
7273
|
function isLabelableElement(node) {
|
|
6912
|
-
if (node.openingElement.name.type !==
|
|
7274
|
+
if (node.openingElement.name.type !== AST_NODE_TYPES37.JSXIdentifier) {
|
|
6913
7275
|
return false;
|
|
6914
7276
|
}
|
|
6915
7277
|
const name = node.openingElement.name.name;
|
|
@@ -6921,10 +7283,10 @@ function isLabelableElement(node) {
|
|
|
6921
7283
|
}
|
|
6922
7284
|
function containsLabelableElement(node) {
|
|
6923
7285
|
return node.children.some((child) => {
|
|
6924
|
-
if (child.type ===
|
|
7286
|
+
if (child.type === AST_NODE_TYPES37.JSXElement) {
|
|
6925
7287
|
return isLabelableElement(child) || containsLabelableElement(child);
|
|
6926
7288
|
}
|
|
6927
|
-
if (child.type ===
|
|
7289
|
+
if (child.type === AST_NODE_TYPES37.JSXFragment) {
|
|
6928
7290
|
return containsLabelableElement(child);
|
|
6929
7291
|
}
|
|
6930
7292
|
return false;
|
|
@@ -6933,7 +7295,7 @@ function containsLabelableElement(node) {
|
|
|
6933
7295
|
function isStaticallyAssociatedLabel(node) {
|
|
6934
7296
|
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
6935
7297
|
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
6936
|
-
return node.parent.type ===
|
|
7298
|
+
return node.parent.type === AST_NODE_TYPES37.JSXElement && containsLabelableElement(node.parent);
|
|
6937
7299
|
}
|
|
6938
7300
|
function replacementFor(node, element) {
|
|
6939
7301
|
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
@@ -6977,7 +7339,7 @@ var prefer_shadcn_primitives_default = createRule({
|
|
|
6977
7339
|
});
|
|
6978
7340
|
|
|
6979
7341
|
// src/rules/prefer-module-level-constant.ts
|
|
6980
|
-
import { AST_NODE_TYPES as
|
|
7342
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
6981
7343
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6982
7344
|
var MAX_LITERAL_DEPTH = 4;
|
|
6983
7345
|
var IGNORE_PATTERNS2 = [
|
|
@@ -7006,9 +7368,9 @@ var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
|
7006
7368
|
"assign"
|
|
7007
7369
|
]);
|
|
7008
7370
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7371
|
+
AST_NODE_TYPES38.FunctionDeclaration,
|
|
7372
|
+
AST_NODE_TYPES38.FunctionExpression,
|
|
7373
|
+
AST_NODE_TYPES38.ArrowFunctionExpression
|
|
7012
7374
|
]);
|
|
7013
7375
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
7014
7376
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -7021,14 +7383,14 @@ function isLocalFixtureFile(filename) {
|
|
|
7021
7383
|
return isTestFile(filename) || isStoryFile(filename);
|
|
7022
7384
|
}
|
|
7023
7385
|
function unwrap3(node) {
|
|
7024
|
-
if (node.type ===
|
|
7386
|
+
if (node.type === AST_NODE_TYPES38.TSAsExpression || node.type === AST_NODE_TYPES38.TSSatisfiesExpression || node.type === AST_NODE_TYPES38.TSNonNullExpression) {
|
|
7025
7387
|
return unwrap3(node.expression);
|
|
7026
7388
|
}
|
|
7027
7389
|
return node;
|
|
7028
7390
|
}
|
|
7029
7391
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
7030
7392
|
function isRegexLiteral(node) {
|
|
7031
|
-
return node.type ===
|
|
7393
|
+
return node.type === AST_NODE_TYPES38.Literal && "regex" in node && node.regex !== void 0;
|
|
7032
7394
|
}
|
|
7033
7395
|
function isLiteralOnly(node, depth) {
|
|
7034
7396
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -7036,29 +7398,29 @@ function isLiteralOnly(node, depth) {
|
|
|
7036
7398
|
}
|
|
7037
7399
|
const inner = unwrap3(node);
|
|
7038
7400
|
switch (inner.type) {
|
|
7039
|
-
case
|
|
7401
|
+
case AST_NODE_TYPES38.Literal: {
|
|
7040
7402
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
7041
7403
|
}
|
|
7042
|
-
case
|
|
7404
|
+
case AST_NODE_TYPES38.TemplateLiteral: {
|
|
7043
7405
|
return inner.expressions.length === 0;
|
|
7044
7406
|
}
|
|
7045
|
-
case
|
|
7046
|
-
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";
|
|
7047
7409
|
}
|
|
7048
|
-
case
|
|
7410
|
+
case AST_NODE_TYPES38.ArrayExpression: {
|
|
7049
7411
|
return inner.elements.every(
|
|
7050
|
-
(el) => el !== null && el.type !==
|
|
7412
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES38.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
7051
7413
|
);
|
|
7052
7414
|
}
|
|
7053
|
-
case
|
|
7415
|
+
case AST_NODE_TYPES38.ObjectExpression: {
|
|
7054
7416
|
return inner.properties.every((prop) => {
|
|
7055
|
-
if (prop.type !==
|
|
7417
|
+
if (prop.type !== AST_NODE_TYPES38.Property) {
|
|
7056
7418
|
return false;
|
|
7057
7419
|
}
|
|
7058
7420
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
7059
7421
|
return false;
|
|
7060
7422
|
}
|
|
7061
|
-
if (prop.computed && prop.key.type !==
|
|
7423
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES38.Literal) {
|
|
7062
7424
|
return false;
|
|
7063
7425
|
}
|
|
7064
7426
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -7071,7 +7433,7 @@ function isLiteralOnly(node, depth) {
|
|
|
7071
7433
|
}
|
|
7072
7434
|
function unwrapObjectFreeze(node) {
|
|
7073
7435
|
const inner = unwrap3(node);
|
|
7074
|
-
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) {
|
|
7075
7437
|
return unwrap3(inner.arguments[0]);
|
|
7076
7438
|
}
|
|
7077
7439
|
return inner;
|
|
@@ -7087,19 +7449,19 @@ function classify(init, checkRegex) {
|
|
|
7087
7449
|
}
|
|
7088
7450
|
return { kind: "regex", size: 1 };
|
|
7089
7451
|
}
|
|
7090
|
-
if (node.type ===
|
|
7452
|
+
if (node.type === AST_NODE_TYPES38.ArrayExpression) {
|
|
7091
7453
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
7092
7454
|
}
|
|
7093
|
-
if (node.type ===
|
|
7455
|
+
if (node.type === AST_NODE_TYPES38.ObjectExpression) {
|
|
7094
7456
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
7095
7457
|
}
|
|
7096
|
-
if (node.type ===
|
|
7458
|
+
if (node.type === AST_NODE_TYPES38.NewExpression && node.callee.type === AST_NODE_TYPES38.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
7097
7459
|
const arg = node.arguments[0];
|
|
7098
|
-
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) {
|
|
7099
7461
|
return null;
|
|
7100
7462
|
}
|
|
7101
7463
|
const entries = unwrap3(arg);
|
|
7102
|
-
if (entries.type !==
|
|
7464
|
+
if (entries.type !== AST_NODE_TYPES38.ArrayExpression) {
|
|
7103
7465
|
return null;
|
|
7104
7466
|
}
|
|
7105
7467
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -7128,10 +7490,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
7128
7490
|
);
|
|
7129
7491
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
7130
7492
|
const callee = node.callee;
|
|
7131
|
-
if (callee.type ===
|
|
7493
|
+
if (callee.type === AST_NODE_TYPES38.Identifier && callee.name === "structuredClone") {
|
|
7132
7494
|
return true;
|
|
7133
7495
|
}
|
|
7134
|
-
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) {
|
|
7135
7497
|
return false;
|
|
7136
7498
|
}
|
|
7137
7499
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -7145,38 +7507,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
7145
7507
|
}
|
|
7146
7508
|
function isSafeRead(identifier) {
|
|
7147
7509
|
const parent = identifier.parent;
|
|
7148
|
-
if (parent.type ===
|
|
7510
|
+
if (parent.type === AST_NODE_TYPES38.MemberExpression) {
|
|
7149
7511
|
if (parent.object !== identifier) {
|
|
7150
7512
|
return true;
|
|
7151
7513
|
}
|
|
7152
7514
|
const grandparent = parent.parent;
|
|
7153
|
-
if (grandparent.type ===
|
|
7515
|
+
if (grandparent.type === AST_NODE_TYPES38.AssignmentExpression && grandparent.left === parent) {
|
|
7154
7516
|
return false;
|
|
7155
7517
|
}
|
|
7156
|
-
if (grandparent.type ===
|
|
7518
|
+
if (grandparent.type === AST_NODE_TYPES38.UpdateExpression) {
|
|
7157
7519
|
return false;
|
|
7158
7520
|
}
|
|
7159
|
-
if (grandparent.type ===
|
|
7521
|
+
if (grandparent.type === AST_NODE_TYPES38.UnaryExpression && grandparent.operator === "delete") {
|
|
7160
7522
|
return false;
|
|
7161
7523
|
}
|
|
7162
|
-
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) {
|
|
7163
7525
|
return false;
|
|
7164
7526
|
}
|
|
7165
7527
|
return true;
|
|
7166
7528
|
}
|
|
7167
|
-
if (parent.type ===
|
|
7529
|
+
if (parent.type === AST_NODE_TYPES38.ForOfStatement && parent.right === identifier) {
|
|
7168
7530
|
return true;
|
|
7169
7531
|
}
|
|
7170
|
-
if (parent.type ===
|
|
7532
|
+
if (parent.type === AST_NODE_TYPES38.SpreadElement) {
|
|
7171
7533
|
return true;
|
|
7172
7534
|
}
|
|
7173
|
-
if (parent.type ===
|
|
7535
|
+
if (parent.type === AST_NODE_TYPES38.BinaryExpression) {
|
|
7174
7536
|
return true;
|
|
7175
7537
|
}
|
|
7176
|
-
if (parent.type ===
|
|
7538
|
+
if (parent.type === AST_NODE_TYPES38.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
7177
7539
|
return true;
|
|
7178
7540
|
}
|
|
7179
|
-
if (parent.type ===
|
|
7541
|
+
if (parent.type === AST_NODE_TYPES38.UnaryExpression && parent.operator !== "delete") {
|
|
7180
7542
|
return true;
|
|
7181
7543
|
}
|
|
7182
7544
|
return false;
|
|
@@ -7200,7 +7562,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7200
7562
|
}
|
|
7201
7563
|
],
|
|
7202
7564
|
messages: {
|
|
7203
|
-
hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope so it is allocated once
|
|
7565
|
+
hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope in immutable form (`as const`, a readonly collection, or `Object.freeze`) so it is allocated once without exposing mutable shared state.",
|
|
7204
7566
|
hoistRegex: "`{{name}}` is a constant regex recompiled on every call. Hoist it to module scope."
|
|
7205
7567
|
}
|
|
7206
7568
|
},
|
|
@@ -7231,7 +7593,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7231
7593
|
if (reference.isWrite()) {
|
|
7232
7594
|
return false;
|
|
7233
7595
|
}
|
|
7234
|
-
if (reference.identifier.type !==
|
|
7596
|
+
if (reference.identifier.type !== AST_NODE_TYPES38.Identifier) {
|
|
7235
7597
|
return false;
|
|
7236
7598
|
}
|
|
7237
7599
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -7243,10 +7605,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7243
7605
|
return {
|
|
7244
7606
|
VariableDeclarator(node) {
|
|
7245
7607
|
const declaration = node.parent;
|
|
7246
|
-
if (declaration.type !==
|
|
7608
|
+
if (declaration.type !== AST_NODE_TYPES38.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
7247
7609
|
return;
|
|
7248
7610
|
}
|
|
7249
|
-
if (node.id.type !==
|
|
7611
|
+
if (node.id.type !== AST_NODE_TYPES38.Identifier || node.init === null) {
|
|
7250
7612
|
return;
|
|
7251
7613
|
}
|
|
7252
7614
|
if (enclosingFunction2(node) === null) {
|
|
@@ -7273,7 +7635,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7273
7635
|
});
|
|
7274
7636
|
|
|
7275
7637
|
// src/rules/prefer-module-level-schema.ts
|
|
7276
|
-
import { AST_NODE_TYPES as
|
|
7638
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39 } from "@typescript-eslint/utils";
|
|
7277
7639
|
|
|
7278
7640
|
// src/rules/_zod.ts
|
|
7279
7641
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -7339,9 +7701,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
7339
7701
|
"intl"
|
|
7340
7702
|
]);
|
|
7341
7703
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7704
|
+
AST_NODE_TYPES39.ArrowFunctionExpression,
|
|
7705
|
+
AST_NODE_TYPES39.FunctionDeclaration,
|
|
7706
|
+
AST_NODE_TYPES39.FunctionExpression
|
|
7345
7707
|
]);
|
|
7346
7708
|
function schemaExpression(node) {
|
|
7347
7709
|
let current = node;
|
|
@@ -7350,10 +7712,10 @@ function schemaExpression(node) {
|
|
|
7350
7712
|
if (parent === void 0) {
|
|
7351
7713
|
return current;
|
|
7352
7714
|
}
|
|
7353
|
-
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)) {
|
|
7354
7716
|
return current;
|
|
7355
7717
|
}
|
|
7356
|
-
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) {
|
|
7357
7719
|
current = parent;
|
|
7358
7720
|
continue;
|
|
7359
7721
|
}
|
|
@@ -7404,22 +7766,22 @@ function subtreeSome(root, predicate) {
|
|
|
7404
7766
|
function readsReceiver(node) {
|
|
7405
7767
|
return subtreeSome(
|
|
7406
7768
|
node,
|
|
7407
|
-
(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"
|
|
7408
7770
|
);
|
|
7409
7771
|
}
|
|
7410
7772
|
function buildsLocalizedText(node) {
|
|
7411
7773
|
return subtreeSome(node, (inner) => {
|
|
7412
|
-
if (inner.type ===
|
|
7774
|
+
if (inner.type === AST_NODE_TYPES39.TaggedTemplateExpression) {
|
|
7413
7775
|
return true;
|
|
7414
7776
|
}
|
|
7415
|
-
if (inner.type !==
|
|
7777
|
+
if (inner.type !== AST_NODE_TYPES39.CallExpression) {
|
|
7416
7778
|
return false;
|
|
7417
7779
|
}
|
|
7418
7780
|
const { callee } = inner;
|
|
7419
|
-
if (callee.type ===
|
|
7781
|
+
if (callee.type === AST_NODE_TYPES39.Identifier) {
|
|
7420
7782
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7421
7783
|
}
|
|
7422
|
-
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);
|
|
7423
7785
|
});
|
|
7424
7786
|
}
|
|
7425
7787
|
function collectReferences(scope, out) {
|
|
@@ -7476,15 +7838,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7476
7838
|
}
|
|
7477
7839
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7478
7840
|
function isZodCall(node) {
|
|
7479
|
-
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);
|
|
7480
7842
|
}
|
|
7481
7843
|
function isCovered(node) {
|
|
7482
7844
|
let current = node.parent ?? void 0;
|
|
7483
7845
|
while (current !== void 0) {
|
|
7484
|
-
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)) {
|
|
7485
7847
|
return true;
|
|
7486
7848
|
}
|
|
7487
|
-
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))) {
|
|
7488
7850
|
return true;
|
|
7489
7851
|
}
|
|
7490
7852
|
current = current.parent ?? void 0;
|
|
@@ -7499,11 +7861,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7499
7861
|
if (parent === void 0) {
|
|
7500
7862
|
return confirmed;
|
|
7501
7863
|
}
|
|
7502
|
-
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) {
|
|
7503
7865
|
current = parent;
|
|
7504
7866
|
continue;
|
|
7505
7867
|
}
|
|
7506
|
-
if (parent.type ===
|
|
7868
|
+
if (parent.type === AST_NODE_TYPES39.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7507
7869
|
current = schemaExpression(parent);
|
|
7508
7870
|
confirmed = current;
|
|
7509
7871
|
continue;
|
|
@@ -7513,7 +7875,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7513
7875
|
}
|
|
7514
7876
|
function isSchemaComposition(node) {
|
|
7515
7877
|
const { callee } = node;
|
|
7516
|
-
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);
|
|
7517
7879
|
return isCombinator || isZodCall(node);
|
|
7518
7880
|
}
|
|
7519
7881
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7547,13 +7909,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7547
7909
|
}
|
|
7548
7910
|
function ownerName(enclosing) {
|
|
7549
7911
|
const parent = enclosing.parent ?? void 0;
|
|
7550
|
-
if (enclosing.type ===
|
|
7912
|
+
if (enclosing.type === AST_NODE_TYPES39.FunctionDeclaration && enclosing.id !== null) {
|
|
7551
7913
|
return enclosing.id.name;
|
|
7552
7914
|
}
|
|
7553
|
-
if (parent !== void 0 && parent.type ===
|
|
7915
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES39.VariableDeclarator && parent.id.type === AST_NODE_TYPES39.Identifier) {
|
|
7554
7916
|
return parent.id.name;
|
|
7555
7917
|
}
|
|
7556
|
-
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) {
|
|
7557
7919
|
return parent.key.name;
|
|
7558
7920
|
}
|
|
7559
7921
|
return "this function";
|
|
@@ -7564,7 +7926,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7564
7926
|
return;
|
|
7565
7927
|
}
|
|
7566
7928
|
for (const specifier of node.specifiers) {
|
|
7567
|
-
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") {
|
|
7568
7930
|
zodNamespaces.add(specifier.local.name);
|
|
7569
7931
|
}
|
|
7570
7932
|
}
|
|
@@ -7574,7 +7936,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7574
7936
|
return;
|
|
7575
7937
|
}
|
|
7576
7938
|
const callee = node.callee;
|
|
7577
|
-
if (callee.property.type !==
|
|
7939
|
+
if (callee.property.type !== AST_NODE_TYPES39.Identifier) {
|
|
7578
7940
|
return;
|
|
7579
7941
|
}
|
|
7580
7942
|
const factory = callee.property.name;
|
|
@@ -7589,7 +7951,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7589
7951
|
return;
|
|
7590
7952
|
}
|
|
7591
7953
|
const shape = node.arguments[0];
|
|
7592
|
-
if (shape !== void 0 && shape.type ===
|
|
7954
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES39.ObjectExpression && shape.properties.length < minProperties) {
|
|
7593
7955
|
return;
|
|
7594
7956
|
}
|
|
7595
7957
|
const expression = schemaExpression(node);
|
|
@@ -7617,9 +7979,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7617
7979
|
});
|
|
7618
7980
|
|
|
7619
7981
|
// src/rules/prefer-native-random-uuid.ts
|
|
7620
|
-
import { AST_NODE_TYPES as
|
|
7982
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40, ASTUtils as ASTUtils5 } from "@typescript-eslint/utils";
|
|
7621
7983
|
function requireUuid(node) {
|
|
7622
|
-
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";
|
|
7623
7985
|
}
|
|
7624
7986
|
var prefer_native_random_uuid_default = createRule({
|
|
7625
7987
|
name: "prefer-native-random-uuid",
|
|
@@ -7640,7 +8002,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7640
8002
|
const directBindings = /* @__PURE__ */ new Set();
|
|
7641
8003
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7642
8004
|
function resolve(identifier) {
|
|
7643
|
-
return
|
|
8005
|
+
return ASTUtils5.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7644
8006
|
}
|
|
7645
8007
|
function record(identifier, destination) {
|
|
7646
8008
|
const variable = resolve(identifier);
|
|
@@ -7662,37 +8024,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7662
8024
|
ImportDeclaration(node) {
|
|
7663
8025
|
if (node.source.value !== "uuid") return;
|
|
7664
8026
|
for (const specifier of node.specifiers) {
|
|
7665
|
-
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")) {
|
|
7666
8028
|
record(specifier.local, directBindings);
|
|
7667
|
-
} else if (specifier.type ===
|
|
8029
|
+
} else if (specifier.type === AST_NODE_TYPES40.ImportNamespaceSpecifier) {
|
|
7668
8030
|
record(specifier.local, namespaceBindings);
|
|
7669
8031
|
}
|
|
7670
8032
|
}
|
|
7671
8033
|
},
|
|
7672
8034
|
VariableDeclarator(node) {
|
|
7673
8035
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7674
|
-
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) {
|
|
7675
8037
|
return;
|
|
7676
8038
|
}
|
|
7677
|
-
if (node.id.type ===
|
|
8039
|
+
if (node.id.type === AST_NODE_TYPES40.Identifier) {
|
|
7678
8040
|
record(node.id, namespaceBindings);
|
|
7679
8041
|
return;
|
|
7680
8042
|
}
|
|
7681
|
-
if (node.id.type !==
|
|
8043
|
+
if (node.id.type !== AST_NODE_TYPES40.ObjectPattern) return;
|
|
7682
8044
|
for (const property of node.id.properties) {
|
|
7683
|
-
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) {
|
|
7684
8046
|
record(property.value, directBindings);
|
|
7685
8047
|
}
|
|
7686
8048
|
}
|
|
7687
8049
|
},
|
|
7688
8050
|
"CallExpression:exit"(node) {
|
|
7689
8051
|
if (node.arguments.length !== 0) return;
|
|
7690
|
-
if (node.callee.type ===
|
|
8052
|
+
if (node.callee.type === AST_NODE_TYPES40.Identifier) {
|
|
7691
8053
|
const variable2 = resolve(node.callee);
|
|
7692
8054
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7693
8055
|
return;
|
|
7694
8056
|
}
|
|
7695
|
-
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") {
|
|
7696
8058
|
return;
|
|
7697
8059
|
}
|
|
7698
8060
|
const variable = resolve(node.callee.object);
|
|
@@ -7703,20 +8065,20 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7703
8065
|
});
|
|
7704
8066
|
|
|
7705
8067
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7706
|
-
import { AST_NODE_TYPES as
|
|
8068
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41 } from "@typescript-eslint/utils";
|
|
7707
8069
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7708
8070
|
function propertyName(node) {
|
|
7709
8071
|
const key = node.key;
|
|
7710
|
-
if (key.type ===
|
|
7711
|
-
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);
|
|
7712
8074
|
return "collection";
|
|
7713
8075
|
}
|
|
7714
8076
|
function isArrayType(node) {
|
|
7715
|
-
if (node.type ===
|
|
7716
|
-
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);
|
|
7717
8079
|
}
|
|
7718
8080
|
function isNullishType(node) {
|
|
7719
|
-
return node.type ===
|
|
8081
|
+
return node.type === AST_NODE_TYPES41.TSNullKeyword || node.type === AST_NODE_TYPES41.TSUndefinedKeyword;
|
|
7720
8082
|
}
|
|
7721
8083
|
function isNullableArrayOnly(node) {
|
|
7722
8084
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7744,7 +8106,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7744
8106
|
if (node.optional) return;
|
|
7745
8107
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7746
8108
|
if (annotation === void 0) return;
|
|
7747
|
-
if (annotation.type !==
|
|
8109
|
+
if (annotation.type !== AST_NODE_TYPES41.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7748
8110
|
return;
|
|
7749
8111
|
}
|
|
7750
8112
|
context.report({
|
|
@@ -7757,7 +8119,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7757
8119
|
TSPropertySignature: checkOptionalProperty,
|
|
7758
8120
|
PropertyDefinition: checkOptionalProperty,
|
|
7759
8121
|
TSTypeAliasDeclaration(node) {
|
|
7760
|
-
if (node.typeAnnotation.type !==
|
|
8122
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES41.TSUnionType) return;
|
|
7761
8123
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7762
8124
|
context.report({
|
|
7763
8125
|
node,
|
|
@@ -7770,13 +8132,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7770
8132
|
});
|
|
7771
8133
|
|
|
7772
8134
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7773
|
-
import { AST_NODE_TYPES as
|
|
8135
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42 } from "@typescript-eslint/utils";
|
|
7774
8136
|
var unwrap4 = (node) => {
|
|
7775
8137
|
let current = node;
|
|
7776
8138
|
while (current !== null && current !== void 0) {
|
|
7777
|
-
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) {
|
|
7778
8140
|
current = current.expression;
|
|
7779
|
-
} else if (current.type ===
|
|
8141
|
+
} else if (current.type === AST_NODE_TYPES42.ChainExpression) {
|
|
7780
8142
|
current = current.expression;
|
|
7781
8143
|
} else {
|
|
7782
8144
|
break;
|
|
@@ -7791,23 +8153,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7791
8153
|
]);
|
|
7792
8154
|
var isSchemaParseReference = (node) => {
|
|
7793
8155
|
const inner = unwrap4(node);
|
|
7794
|
-
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");
|
|
7795
8157
|
};
|
|
7796
8158
|
var isRawPayloadSource = (node) => {
|
|
7797
8159
|
let current = unwrap4(node);
|
|
7798
8160
|
if (current === null) return false;
|
|
7799
|
-
if (current.type ===
|
|
8161
|
+
if (current.type === AST_NODE_TYPES42.AwaitExpression) {
|
|
7800
8162
|
current = unwrap4(current.argument);
|
|
7801
8163
|
}
|
|
7802
|
-
if (current === null || current.type !==
|
|
8164
|
+
if (current === null || current.type !== AST_NODE_TYPES42.CallExpression) {
|
|
7803
8165
|
return false;
|
|
7804
8166
|
}
|
|
7805
8167
|
const callee = unwrap4(current.callee);
|
|
7806
|
-
if (callee === null || callee.type !==
|
|
8168
|
+
if (callee === null || callee.type !== AST_NODE_TYPES42.MemberExpression) {
|
|
7807
8169
|
return false;
|
|
7808
8170
|
}
|
|
7809
8171
|
const property = unwrap4(callee.property);
|
|
7810
|
-
if (property === null || property.type !==
|
|
8172
|
+
if (property === null || property.type !== AST_NODE_TYPES42.Identifier) {
|
|
7811
8173
|
return false;
|
|
7812
8174
|
}
|
|
7813
8175
|
if (property.name === "json") {
|
|
@@ -7817,16 +8179,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7817
8179
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7818
8180
|
}
|
|
7819
8181
|
const object = unwrap4(callee.object);
|
|
7820
|
-
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]);
|
|
7821
8183
|
};
|
|
7822
8184
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7823
8185
|
var isLocalFileRead = (node) => {
|
|
7824
8186
|
let found = false;
|
|
7825
8187
|
const visit = (current) => {
|
|
7826
8188
|
if (found || current === null || current === void 0) return;
|
|
7827
|
-
if (current.type ===
|
|
8189
|
+
if (current.type === AST_NODE_TYPES42.CallExpression) {
|
|
7828
8190
|
const callee = unwrap4(current.callee);
|
|
7829
|
-
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;
|
|
7830
8192
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7831
8193
|
found = true;
|
|
7832
8194
|
return;
|
|
@@ -7848,15 +8210,15 @@ var isLocalFileRead = (node) => {
|
|
|
7848
8210
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7849
8211
|
var isInsideAssertion = (node) => {
|
|
7850
8212
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7851
|
-
if (current.type !==
|
|
8213
|
+
if (current.type !== AST_NODE_TYPES42.CallExpression) continue;
|
|
7852
8214
|
let callee = current.callee;
|
|
7853
|
-
while (callee.type ===
|
|
8215
|
+
while (callee.type === AST_NODE_TYPES42.MemberExpression) {
|
|
7854
8216
|
callee = callee.object;
|
|
7855
8217
|
}
|
|
7856
|
-
if (callee.type ===
|
|
8218
|
+
if (callee.type === AST_NODE_TYPES42.CallExpression) {
|
|
7857
8219
|
callee = callee.callee;
|
|
7858
8220
|
}
|
|
7859
|
-
if (callee.type ===
|
|
8221
|
+
if (callee.type === AST_NODE_TYPES42.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7860
8222
|
return true;
|
|
7861
8223
|
}
|
|
7862
8224
|
}
|
|
@@ -7875,39 +8237,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7875
8237
|
var isValidationRead = (node) => {
|
|
7876
8238
|
let current = node;
|
|
7877
8239
|
let parent = current.parent;
|
|
7878
|
-
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)) {
|
|
7879
8241
|
current = parent;
|
|
7880
8242
|
parent = parent.parent;
|
|
7881
8243
|
}
|
|
7882
8244
|
if (parent === null || parent === void 0) return false;
|
|
7883
|
-
if (parent.type ===
|
|
8245
|
+
if (parent.type === AST_NODE_TYPES42.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7884
8246
|
return true;
|
|
7885
8247
|
}
|
|
7886
|
-
if (parent.type !==
|
|
8248
|
+
if (parent.type !== AST_NODE_TYPES42.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7887
8249
|
return false;
|
|
7888
8250
|
}
|
|
7889
8251
|
const callee = parent.callee;
|
|
7890
|
-
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") {
|
|
7891
8253
|
return parent.arguments.length === 1;
|
|
7892
8254
|
}
|
|
7893
|
-
return callee.type ===
|
|
8255
|
+
return callee.type === AST_NODE_TYPES42.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7894
8256
|
};
|
|
7895
8257
|
var isGuardTestPosition = (node) => {
|
|
7896
8258
|
let current = node;
|
|
7897
8259
|
let parent = current.parent;
|
|
7898
8260
|
while (parent !== void 0 && parent !== null) {
|
|
7899
8261
|
switch (parent.type) {
|
|
7900
|
-
case
|
|
7901
|
-
case
|
|
7902
|
-
case
|
|
8262
|
+
case AST_NODE_TYPES42.UnaryExpression:
|
|
8263
|
+
case AST_NODE_TYPES42.LogicalExpression:
|
|
8264
|
+
case AST_NODE_TYPES42.ChainExpression:
|
|
7903
8265
|
current = parent;
|
|
7904
8266
|
parent = parent.parent;
|
|
7905
8267
|
continue;
|
|
7906
|
-
case
|
|
7907
|
-
case
|
|
7908
|
-
case
|
|
7909
|
-
case
|
|
7910
|
-
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:
|
|
7911
8273
|
return parent.test === current;
|
|
7912
8274
|
default:
|
|
7913
8275
|
return false;
|
|
@@ -7917,7 +8279,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7917
8279
|
};
|
|
7918
8280
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7919
8281
|
const unwrapped = unwrap4(node);
|
|
7920
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8282
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES42.Identifier) {
|
|
7921
8283
|
return false;
|
|
7922
8284
|
}
|
|
7923
8285
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7960,11 +8322,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7960
8322
|
return {
|
|
7961
8323
|
VariableDeclarator(node) {
|
|
7962
8324
|
const scope = context.sourceCode.getScope(node);
|
|
7963
|
-
if (node.id.type ===
|
|
8325
|
+
if (node.id.type === AST_NODE_TYPES42.Identifier) {
|
|
7964
8326
|
trackInitializer(node);
|
|
7965
8327
|
return;
|
|
7966
8328
|
}
|
|
7967
|
-
if (node.id.type ===
|
|
8329
|
+
if (node.id.type === AST_NODE_TYPES42.ObjectPattern || node.id.type === AST_NODE_TYPES42.ArrayPattern) {
|
|
7968
8330
|
if (isRawPayloadSource(node.init)) {
|
|
7969
8331
|
if (!isFullyNarrowedPattern(node)) {
|
|
7970
8332
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7978,7 +8340,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7978
8340
|
},
|
|
7979
8341
|
AssignmentExpression(node) {
|
|
7980
8342
|
const scope = context.sourceCode.getScope(node);
|
|
7981
|
-
if (node.left.type ===
|
|
8343
|
+
if (node.left.type === AST_NODE_TYPES42.Identifier) {
|
|
7982
8344
|
const variable = findVariable2(scope, node.left.name);
|
|
7983
8345
|
if (variable === null) return;
|
|
7984
8346
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7988,7 +8350,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7988
8350
|
}
|
|
7989
8351
|
return;
|
|
7990
8352
|
}
|
|
7991
|
-
if (node.left.type ===
|
|
8353
|
+
if (node.left.type === AST_NODE_TYPES42.ObjectPattern || node.left.type === AST_NODE_TYPES42.ArrayPattern) {
|
|
7992
8354
|
if (isRawPayloadSource(node.right)) {
|
|
7993
8355
|
context.report({
|
|
7994
8356
|
node: node.left,
|
|
@@ -8005,15 +8367,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
8005
8367
|
}
|
|
8006
8368
|
},
|
|
8007
8369
|
CallExpression(node) {
|
|
8008
|
-
if (node.callee.type !==
|
|
8370
|
+
if (node.callee.type !== AST_NODE_TYPES42.Identifier) return;
|
|
8009
8371
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
8010
8372
|
return;
|
|
8011
8373
|
}
|
|
8012
8374
|
const scope = context.sourceCode.getScope(node);
|
|
8013
8375
|
for (const arg of node.arguments) {
|
|
8014
|
-
if (arg.type ===
|
|
8376
|
+
if (arg.type === AST_NODE_TYPES42.SpreadElement) continue;
|
|
8015
8377
|
const unwrapped = unwrap4(arg);
|
|
8016
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8378
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES42.Identifier) {
|
|
8017
8379
|
continue;
|
|
8018
8380
|
}
|
|
8019
8381
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -8027,13 +8389,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
8027
8389
|
const obj = unwrap4(node.object);
|
|
8028
8390
|
if (isRawPayloadSource(obj)) {
|
|
8029
8391
|
const parent = node.parent;
|
|
8030
|
-
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))) {
|
|
8031
8393
|
return;
|
|
8032
8394
|
}
|
|
8033
8395
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
8034
8396
|
return;
|
|
8035
8397
|
}
|
|
8036
|
-
if (obj !== null && obj.type ===
|
|
8398
|
+
if (obj !== null && obj.type === AST_NODE_TYPES42.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
8037
8399
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
8038
8400
|
const variable = findVariable2(scope, obj.name);
|
|
8039
8401
|
if (variable !== null) {
|
|
@@ -8046,7 +8408,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
8046
8408
|
});
|
|
8047
8409
|
|
|
8048
8410
|
// src/rules/prefer-semantic-colors.ts
|
|
8049
|
-
import { AST_NODE_TYPES as
|
|
8411
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43 } from "@typescript-eslint/utils";
|
|
8050
8412
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
8051
8413
|
import { dirname, join, parse } from "path";
|
|
8052
8414
|
|
|
@@ -8146,8 +8508,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
8146
8508
|
]);
|
|
8147
8509
|
function jsxElementName(node) {
|
|
8148
8510
|
const name = node.openingElement.name;
|
|
8149
|
-
if (name.type ===
|
|
8150
|
-
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) {
|
|
8151
8513
|
return name.property.name;
|
|
8152
8514
|
}
|
|
8153
8515
|
return null;
|
|
@@ -8173,7 +8535,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
8173
8535
|
var isInsideSvg = (node) => {
|
|
8174
8536
|
let current = node.parent;
|
|
8175
8537
|
while (current !== void 0 && current !== null) {
|
|
8176
|
-
if (current.type ===
|
|
8538
|
+
if (current.type === AST_NODE_TYPES43.JSXElement) {
|
|
8177
8539
|
const name = jsxElementName(current);
|
|
8178
8540
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
8179
8541
|
}
|
|
@@ -8184,7 +8546,7 @@ var isInsideSvg = (node) => {
|
|
|
8184
8546
|
var isInsideIconFactoryPath = (node) => {
|
|
8185
8547
|
let current = node.parent;
|
|
8186
8548
|
while (current !== void 0 && current !== null) {
|
|
8187
|
-
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") {
|
|
8188
8550
|
return true;
|
|
8189
8551
|
}
|
|
8190
8552
|
current = current.parent;
|
|
@@ -8321,12 +8683,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
8321
8683
|
return root !== null && workspaceHasMarker(root);
|
|
8322
8684
|
};
|
|
8323
8685
|
var propName = (key) => {
|
|
8324
|
-
if (key.type ===
|
|
8325
|
-
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;
|
|
8326
8688
|
return null;
|
|
8327
8689
|
};
|
|
8328
8690
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
8329
|
-
if (statement.type !==
|
|
8691
|
+
if (statement.type !== AST_NODE_TYPES43.ImportDeclaration && statement.type !== AST_NODE_TYPES43.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES43.ExportAllDeclaration) {
|
|
8330
8692
|
return false;
|
|
8331
8693
|
}
|
|
8332
8694
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -8378,27 +8740,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8378
8740
|
const checkClassNode = (node) => {
|
|
8379
8741
|
if (node === null) return;
|
|
8380
8742
|
switch (node.type) {
|
|
8381
|
-
case
|
|
8743
|
+
case AST_NODE_TYPES43.Literal:
|
|
8382
8744
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
8383
8745
|
break;
|
|
8384
|
-
case
|
|
8746
|
+
case AST_NODE_TYPES43.TemplateLiteral:
|
|
8385
8747
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
8386
8748
|
break;
|
|
8387
|
-
case
|
|
8749
|
+
case AST_NODE_TYPES43.ArrayExpression:
|
|
8388
8750
|
for (const element of node.elements) {
|
|
8389
|
-
if (element !== null && element.type !==
|
|
8751
|
+
if (element !== null && element.type !== AST_NODE_TYPES43.SpreadElement) checkClassNode(element);
|
|
8390
8752
|
}
|
|
8391
8753
|
break;
|
|
8392
|
-
case
|
|
8754
|
+
case AST_NODE_TYPES43.ObjectExpression:
|
|
8393
8755
|
for (const property of node.properties) {
|
|
8394
|
-
if (property.type ===
|
|
8756
|
+
if (property.type === AST_NODE_TYPES43.Property) checkClassNode(property.value);
|
|
8395
8757
|
}
|
|
8396
8758
|
break;
|
|
8397
|
-
case
|
|
8759
|
+
case AST_NODE_TYPES43.ConditionalExpression:
|
|
8398
8760
|
checkClassNode(node.consequent);
|
|
8399
8761
|
checkClassNode(node.alternate);
|
|
8400
8762
|
break;
|
|
8401
|
-
case
|
|
8763
|
+
case AST_NODE_TYPES43.LogicalExpression:
|
|
8402
8764
|
checkClassNode(node.right);
|
|
8403
8765
|
break;
|
|
8404
8766
|
default:
|
|
@@ -8406,32 +8768,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8406
8768
|
}
|
|
8407
8769
|
};
|
|
8408
8770
|
const checkColorValueNode = (node) => {
|
|
8409
|
-
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)) {
|
|
8410
8772
|
report(node, "inlineColor", { value: node.value });
|
|
8411
8773
|
}
|
|
8412
8774
|
};
|
|
8413
8775
|
return {
|
|
8414
8776
|
"JSXAttribute[name.name='className']"(node) {
|
|
8415
8777
|
if (node.value === null) return;
|
|
8416
|
-
if (node.value.type ===
|
|
8417
|
-
else if (node.value.type ===
|
|
8418
|
-
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) {
|
|
8419
8781
|
checkClassNode(node.value.expression);
|
|
8420
8782
|
}
|
|
8421
8783
|
}
|
|
8422
8784
|
},
|
|
8423
8785
|
CallExpression(node) {
|
|
8424
|
-
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)) {
|
|
8425
8787
|
importsEmailOrPdfRenderer = true;
|
|
8426
8788
|
}
|
|
8427
|
-
if (node.callee.type ===
|
|
8789
|
+
if (node.callee.type === AST_NODE_TYPES43.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8428
8790
|
for (const arg of node.arguments) {
|
|
8429
|
-
if (arg.type !==
|
|
8791
|
+
if (arg.type !== AST_NODE_TYPES43.SpreadElement) checkClassNode(arg);
|
|
8430
8792
|
}
|
|
8431
8793
|
}
|
|
8432
8794
|
},
|
|
8433
8795
|
VariableDeclarator(node) {
|
|
8434
|
-
if (node.id.type ===
|
|
8796
|
+
if (node.id.type === AST_NODE_TYPES43.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8435
8797
|
checkClassNode(node.init);
|
|
8436
8798
|
}
|
|
8437
8799
|
},
|
|
@@ -8441,9 +8803,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8441
8803
|
},
|
|
8442
8804
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8443
8805
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8444
|
-
if (node.value?.type !==
|
|
8806
|
+
if (node.value?.type !== AST_NODE_TYPES43.Literal) return;
|
|
8445
8807
|
const owner = node.parent.name;
|
|
8446
|
-
if (owner.type ===
|
|
8808
|
+
if (owner.type === AST_NODE_TYPES43.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8447
8809
|
return;
|
|
8448
8810
|
}
|
|
8449
8811
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8457,7 +8819,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8457
8819
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8458
8820
|
},
|
|
8459
8821
|
ImportExpression(node) {
|
|
8460
|
-
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)) {
|
|
8461
8823
|
importsEmailOrPdfRenderer = true;
|
|
8462
8824
|
}
|
|
8463
8825
|
},
|
|
@@ -8604,8 +8966,8 @@ var prefer_server_actions_default = createRule({
|
|
|
8604
8966
|
}
|
|
8605
8967
|
}
|
|
8606
8968
|
} else if (node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && !node.callee.computed) {
|
|
8607
|
-
const
|
|
8608
|
-
if (AXIOS_MUTATION_METHODS.has(
|
|
8969
|
+
const methodName2 = node.callee.property.name.toLowerCase();
|
|
8970
|
+
if (AXIOS_MUTATION_METHODS.has(methodName2)) {
|
|
8609
8971
|
const urlArg = node.arguments[0];
|
|
8610
8972
|
const hasHandlerArg = node.arguments.some(
|
|
8611
8973
|
(arg) => arg.type !== "SpreadElement" && isFunctionArgument(arg, context)
|
|
@@ -8663,7 +9025,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8663
9025
|
// src/rules/prefer-string-literal-union.ts
|
|
8664
9026
|
import {
|
|
8665
9027
|
ESLintUtils as ESLintUtils3,
|
|
8666
|
-
AST_NODE_TYPES as
|
|
9028
|
+
AST_NODE_TYPES as AST_NODE_TYPES44
|
|
8667
9029
|
} from "@typescript-eslint/utils";
|
|
8668
9030
|
import * as ts2 from "typescript";
|
|
8669
9031
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -8707,19 +9069,19 @@ function isChoiceLikeName(name) {
|
|
|
8707
9069
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8708
9070
|
}
|
|
8709
9071
|
function keyName(key) {
|
|
8710
|
-
if (key.type ===
|
|
9072
|
+
if (key.type === AST_NODE_TYPES44.Identifier) {
|
|
8711
9073
|
return key.name;
|
|
8712
9074
|
}
|
|
8713
|
-
if (key.type ===
|
|
9075
|
+
if (key.type === AST_NODE_TYPES44.Literal && typeof key.value === "string") {
|
|
8714
9076
|
return key.value;
|
|
8715
9077
|
}
|
|
8716
9078
|
return null;
|
|
8717
9079
|
}
|
|
8718
9080
|
function isStringLiteralMember(t) {
|
|
8719
|
-
return t.type ===
|
|
9081
|
+
return t.type === AST_NODE_TYPES44.TSLiteralType && t.literal.type === AST_NODE_TYPES44.Literal && typeof t.literal.value === "string";
|
|
8720
9082
|
}
|
|
8721
9083
|
function isStringLiteralUnion(node) {
|
|
8722
|
-
if (node?.type !==
|
|
9084
|
+
if (node?.type !== AST_NODE_TYPES44.TSUnionType) {
|
|
8723
9085
|
return false;
|
|
8724
9086
|
}
|
|
8725
9087
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8748,12 +9110,12 @@ function bindingSourceExpression(decl) {
|
|
|
8748
9110
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8749
9111
|
}
|
|
8750
9112
|
function refKey(node) {
|
|
8751
|
-
if (node.type ===
|
|
9113
|
+
if (node.type === AST_NODE_TYPES44.Identifier) {
|
|
8752
9114
|
return node.name;
|
|
8753
9115
|
}
|
|
8754
|
-
if (node.type ===
|
|
9116
|
+
if (node.type === AST_NODE_TYPES44.MemberExpression && !node.computed) {
|
|
8755
9117
|
const inner = refKey(node.object);
|
|
8756
|
-
if (inner === null || node.property.type !==
|
|
9118
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES44.Identifier) {
|
|
8757
9119
|
return null;
|
|
8758
9120
|
}
|
|
8759
9121
|
return `${inner}.${node.property.name}`;
|
|
@@ -8761,7 +9123,7 @@ function refKey(node) {
|
|
|
8761
9123
|
return null;
|
|
8762
9124
|
}
|
|
8763
9125
|
function strLiteral(node) {
|
|
8764
|
-
if (node.type ===
|
|
9126
|
+
if (node.type === AST_NODE_TYPES44.Literal && typeof node.value === "string") {
|
|
8765
9127
|
return node.value;
|
|
8766
9128
|
}
|
|
8767
9129
|
return null;
|
|
@@ -8914,7 +9276,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8914
9276
|
containersWithUnion.add(container);
|
|
8915
9277
|
return;
|
|
8916
9278
|
}
|
|
8917
|
-
if (typeNode?.type !==
|
|
9279
|
+
if (typeNode?.type !== AST_NODE_TYPES44.TSStringKeyword) {
|
|
8918
9280
|
return;
|
|
8919
9281
|
}
|
|
8920
9282
|
const name = keyName(key);
|
|
@@ -9002,10 +9364,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
9002
9364
|
}
|
|
9003
9365
|
};
|
|
9004
9366
|
function refKeyText(node) {
|
|
9005
|
-
if (node.type ===
|
|
9367
|
+
if (node.type === AST_NODE_TYPES44.BinaryExpression) {
|
|
9006
9368
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
9007
9369
|
}
|
|
9008
|
-
if (node.type ===
|
|
9370
|
+
if (node.type === AST_NODE_TYPES44.SwitchStatement) {
|
|
9009
9371
|
return refKey(node.discriminant) ?? "value";
|
|
9010
9372
|
}
|
|
9011
9373
|
return "value";
|
|
@@ -9014,7 +9376,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
9014
9376
|
});
|
|
9015
9377
|
|
|
9016
9378
|
// src/rules/prefer-whole-object-assertion.ts
|
|
9017
|
-
import { AST_NODE_TYPES as
|
|
9379
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45 } from "@typescript-eslint/utils";
|
|
9018
9380
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
9019
9381
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
9020
9382
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -9023,11 +9385,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
9023
9385
|
var MIN_RUN_LENGTH = 2;
|
|
9024
9386
|
function literalText(node, getText) {
|
|
9025
9387
|
switch (node.type) {
|
|
9026
|
-
case
|
|
9388
|
+
case AST_NODE_TYPES45.Literal:
|
|
9027
9389
|
return "regex" in node ? null : getText(node);
|
|
9028
|
-
case
|
|
9390
|
+
case AST_NODE_TYPES45.TemplateLiteral:
|
|
9029
9391
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
9030
|
-
case
|
|
9392
|
+
case AST_NODE_TYPES45.UnaryExpression:
|
|
9031
9393
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
9032
9394
|
default:
|
|
9033
9395
|
return null;
|
|
@@ -9035,15 +9397,15 @@ function literalText(node, getText) {
|
|
|
9035
9397
|
}
|
|
9036
9398
|
function isPureReceiver(node) {
|
|
9037
9399
|
switch (node.type) {
|
|
9038
|
-
case
|
|
9039
|
-
case
|
|
9400
|
+
case AST_NODE_TYPES45.Identifier:
|
|
9401
|
+
case AST_NODE_TYPES45.ThisExpression:
|
|
9040
9402
|
return true;
|
|
9041
|
-
case
|
|
9403
|
+
case AST_NODE_TYPES45.MemberExpression:
|
|
9042
9404
|
if (node.optional) {
|
|
9043
9405
|
return false;
|
|
9044
9406
|
}
|
|
9045
9407
|
if (node.computed) {
|
|
9046
|
-
return node.property.type ===
|
|
9408
|
+
return node.property.type === AST_NODE_TYPES45.Literal && isPureReceiver(node.object);
|
|
9047
9409
|
}
|
|
9048
9410
|
return isPureReceiver(node.object);
|
|
9049
9411
|
default:
|
|
@@ -9051,7 +9413,7 @@ function isPureReceiver(node) {
|
|
|
9051
9413
|
}
|
|
9052
9414
|
}
|
|
9053
9415
|
function literalIndex(node) {
|
|
9054
|
-
if (node.type !==
|
|
9416
|
+
if (node.type !== AST_NODE_TYPES45.Literal || typeof node.value !== "number") {
|
|
9055
9417
|
return null;
|
|
9056
9418
|
}
|
|
9057
9419
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -9077,24 +9439,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9077
9439
|
}
|
|
9078
9440
|
const { sourceCode } = context;
|
|
9079
9441
|
function parseAssertion(statement) {
|
|
9080
|
-
if (statement.type !==
|
|
9442
|
+
if (statement.type !== AST_NODE_TYPES45.ExpressionStatement) {
|
|
9081
9443
|
return null;
|
|
9082
9444
|
}
|
|
9083
9445
|
const call = statement.expression;
|
|
9084
|
-
if (call.type !==
|
|
9446
|
+
if (call.type !== AST_NODE_TYPES45.CallExpression) {
|
|
9085
9447
|
return null;
|
|
9086
9448
|
}
|
|
9087
9449
|
const callee = call.callee;
|
|
9088
|
-
if (callee.type !==
|
|
9450
|
+
if (callee.type !== AST_NODE_TYPES45.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES45.Identifier) {
|
|
9089
9451
|
return null;
|
|
9090
9452
|
}
|
|
9091
9453
|
const matcher = callee.property.name;
|
|
9092
9454
|
const expectCall = callee.object;
|
|
9093
|
-
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) {
|
|
9094
9456
|
return null;
|
|
9095
9457
|
}
|
|
9096
9458
|
const actual = expectCall.arguments[0];
|
|
9097
|
-
if (actual === void 0 || actual.type !==
|
|
9459
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES45.MemberExpression || actual.optional) {
|
|
9098
9460
|
return null;
|
|
9099
9461
|
}
|
|
9100
9462
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -9108,7 +9470,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9108
9470
|
}
|
|
9109
9471
|
key = { kind: "index", index };
|
|
9110
9472
|
} else {
|
|
9111
|
-
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)) {
|
|
9112
9474
|
return null;
|
|
9113
9475
|
}
|
|
9114
9476
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -9120,7 +9482,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9120
9482
|
return null;
|
|
9121
9483
|
}
|
|
9122
9484
|
const expected = call.arguments[0];
|
|
9123
|
-
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) {
|
|
9124
9486
|
return null;
|
|
9125
9487
|
}
|
|
9126
9488
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -9235,7 +9597,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9235
9597
|
});
|
|
9236
9598
|
|
|
9237
9599
|
// src/rules/prefer-zod-enum.ts
|
|
9238
|
-
import { AST_NODE_TYPES as
|
|
9600
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46 } from "@typescript-eslint/utils";
|
|
9239
9601
|
var prefer_zod_enum_default = createRule({
|
|
9240
9602
|
name: "prefer-zod-enum",
|
|
9241
9603
|
meta: {
|
|
@@ -9255,25 +9617,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
9255
9617
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
9256
9618
|
function enumValues(node) {
|
|
9257
9619
|
const callee = node.callee;
|
|
9258
|
-
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) {
|
|
9259
9621
|
return null;
|
|
9260
9622
|
}
|
|
9261
9623
|
const argument = node.arguments[0];
|
|
9262
|
-
if (argument === void 0 || argument.type !==
|
|
9624
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES46.ArrayExpression || argument.elements.length === 0) {
|
|
9263
9625
|
return null;
|
|
9264
9626
|
}
|
|
9265
9627
|
const values = [];
|
|
9266
9628
|
let canFix = true;
|
|
9267
9629
|
for (const element of argument.elements) {
|
|
9268
|
-
if (element?.type ===
|
|
9630
|
+
if (element?.type === AST_NODE_TYPES46.SpreadElement) {
|
|
9269
9631
|
canFix = false;
|
|
9270
9632
|
continue;
|
|
9271
9633
|
}
|
|
9272
|
-
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") {
|
|
9273
9635
|
return null;
|
|
9274
9636
|
}
|
|
9275
9637
|
const value = element.arguments[0];
|
|
9276
|
-
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") {
|
|
9277
9639
|
canFix = false;
|
|
9278
9640
|
continue;
|
|
9279
9641
|
}
|
|
@@ -9283,11 +9645,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
9283
9645
|
}
|
|
9284
9646
|
function buildFix(node, values) {
|
|
9285
9647
|
const argument = node.arguments[0];
|
|
9286
|
-
if (argument === void 0 || argument.type !==
|
|
9648
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES46.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
9287
9649
|
return void 0;
|
|
9288
9650
|
}
|
|
9289
9651
|
const callee = node.callee;
|
|
9290
|
-
if (callee.type !==
|
|
9652
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.property.type !== AST_NODE_TYPES46.Identifier) {
|
|
9291
9653
|
return void 0;
|
|
9292
9654
|
}
|
|
9293
9655
|
return (fixer) => [
|
|
@@ -9304,7 +9666,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9304
9666
|
return;
|
|
9305
9667
|
}
|
|
9306
9668
|
for (const specifier of node.specifiers) {
|
|
9307
|
-
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") {
|
|
9308
9670
|
zodNamespaces.add(specifier.local.name);
|
|
9309
9671
|
}
|
|
9310
9672
|
}
|
|
@@ -9326,7 +9688,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9326
9688
|
});
|
|
9327
9689
|
|
|
9328
9690
|
// src/rules/prefer-zod-infer.ts
|
|
9329
|
-
import { AST_NODE_TYPES as
|
|
9691
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47 } from "@typescript-eslint/utils";
|
|
9330
9692
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
9331
9693
|
"describe",
|
|
9332
9694
|
"refine",
|
|
@@ -9363,44 +9725,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
9363
9725
|
"Schema"
|
|
9364
9726
|
]);
|
|
9365
9727
|
var LEAF_NODE_TYPES = {
|
|
9366
|
-
string: [
|
|
9367
|
-
email: [
|
|
9368
|
-
url: [
|
|
9369
|
-
uuid: [
|
|
9370
|
-
ulid: [
|
|
9371
|
-
cuid: [
|
|
9372
|
-
cuid2: [
|
|
9373
|
-
nanoid: [
|
|
9374
|
-
iso: [
|
|
9375
|
-
number: [
|
|
9376
|
-
int: [
|
|
9377
|
-
float32: [
|
|
9378
|
-
float64: [
|
|
9379
|
-
boolean: [
|
|
9380
|
-
bigint: [
|
|
9381
|
-
symbol: [
|
|
9382
|
-
any: [
|
|
9383
|
-
unknown: [
|
|
9384
|
-
never: [
|
|
9385
|
-
void: [
|
|
9386
|
-
null: [
|
|
9387
|
-
undefined: [
|
|
9388
|
-
literal: [
|
|
9389
|
-
date: [
|
|
9390
|
-
array: [
|
|
9391
|
-
tuple: [
|
|
9392
|
-
object: [
|
|
9393
|
-
strictObject: [
|
|
9394
|
-
looseObject: [
|
|
9395
|
-
record: [
|
|
9396
|
-
map: [
|
|
9397
|
-
set: [
|
|
9398
|
-
promise: [
|
|
9399
|
-
enum: [
|
|
9400
|
-
nativeEnum: [
|
|
9401
|
-
union: [
|
|
9402
|
-
discriminatedUnion: [
|
|
9403
|
-
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]
|
|
9404
9766
|
};
|
|
9405
9767
|
function normalizeSchemaName(name) {
|
|
9406
9768
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9409,20 +9771,20 @@ function normalizeTypeName(name) {
|
|
|
9409
9771
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9410
9772
|
}
|
|
9411
9773
|
function unwrapNullish(annotation) {
|
|
9412
|
-
if (annotation.type !==
|
|
9774
|
+
if (annotation.type !== AST_NODE_TYPES47.TSUnionType) {
|
|
9413
9775
|
return {
|
|
9414
9776
|
core: annotation,
|
|
9415
|
-
nullable: annotation.type ===
|
|
9777
|
+
nullable: annotation.type === AST_NODE_TYPES47.TSNullKeyword
|
|
9416
9778
|
};
|
|
9417
9779
|
}
|
|
9418
9780
|
const rest = [];
|
|
9419
9781
|
let nullable = false;
|
|
9420
9782
|
for (const member of annotation.types) {
|
|
9421
|
-
if (member.type ===
|
|
9783
|
+
if (member.type === AST_NODE_TYPES47.TSNullKeyword) {
|
|
9422
9784
|
nullable = true;
|
|
9423
9785
|
continue;
|
|
9424
9786
|
}
|
|
9425
|
-
if (member.type ===
|
|
9787
|
+
if (member.type === AST_NODE_TYPES47.TSUndefinedKeyword) {
|
|
9426
9788
|
continue;
|
|
9427
9789
|
}
|
|
9428
9790
|
rest.push(member);
|
|
@@ -9487,35 +9849,35 @@ var prefer_zod_infer_default = createRule({
|
|
|
9487
9849
|
function zodCallChain(node) {
|
|
9488
9850
|
const chain = [];
|
|
9489
9851
|
let current = node;
|
|
9490
|
-
while (current.type ===
|
|
9852
|
+
while (current.type === AST_NODE_TYPES47.CallExpression) {
|
|
9491
9853
|
const callee = current.callee;
|
|
9492
|
-
if (callee.type !==
|
|
9854
|
+
if (callee.type !== AST_NODE_TYPES47.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES47.Identifier) {
|
|
9493
9855
|
return null;
|
|
9494
9856
|
}
|
|
9495
9857
|
chain.push(current);
|
|
9496
9858
|
const receiver = callee.object;
|
|
9497
|
-
if (receiver.type ===
|
|
9859
|
+
if (receiver.type === AST_NODE_TYPES47.Identifier) {
|
|
9498
9860
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9499
9861
|
}
|
|
9500
9862
|
current = receiver;
|
|
9501
9863
|
}
|
|
9502
9864
|
return null;
|
|
9503
9865
|
}
|
|
9504
|
-
function
|
|
9866
|
+
function methodName2(call) {
|
|
9505
9867
|
const callee = call.callee;
|
|
9506
|
-
return callee.type ===
|
|
9868
|
+
return callee.type === AST_NODE_TYPES47.MemberExpression && callee.property.type === AST_NODE_TYPES47.Identifier ? callee.property.name : "";
|
|
9507
9869
|
}
|
|
9508
9870
|
function schemaField(node) {
|
|
9509
9871
|
const modifiers = [];
|
|
9510
9872
|
let current = node;
|
|
9511
9873
|
let leaf = null;
|
|
9512
|
-
while (current.type ===
|
|
9874
|
+
while (current.type === AST_NODE_TYPES47.CallExpression) {
|
|
9513
9875
|
const callee = current.callee;
|
|
9514
|
-
if (callee.type !==
|
|
9876
|
+
if (callee.type !== AST_NODE_TYPES47.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES47.Identifier) {
|
|
9515
9877
|
break;
|
|
9516
9878
|
}
|
|
9517
9879
|
const receiver = callee.object;
|
|
9518
|
-
if (receiver.type ===
|
|
9880
|
+
if (receiver.type === AST_NODE_TYPES47.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9519
9881
|
leaf = callee.property.name;
|
|
9520
9882
|
break;
|
|
9521
9883
|
}
|
|
@@ -9538,24 +9900,24 @@ var prefer_zod_infer_default = createRule({
|
|
|
9538
9900
|
if (base === void 0) {
|
|
9539
9901
|
return null;
|
|
9540
9902
|
}
|
|
9541
|
-
const baseMethod =
|
|
9903
|
+
const baseMethod = methodName2(base);
|
|
9542
9904
|
if (baseMethod !== "object" && baseMethod !== "strictObject") {
|
|
9543
9905
|
return null;
|
|
9544
9906
|
}
|
|
9545
|
-
if (rest.some((call) => !SHAPE_PRESERVING_METHODS.has(
|
|
9907
|
+
if (rest.some((call) => !SHAPE_PRESERVING_METHODS.has(methodName2(call)))) {
|
|
9546
9908
|
return null;
|
|
9547
9909
|
}
|
|
9548
9910
|
const shape = base.arguments[0];
|
|
9549
|
-
if (shape === void 0 || shape.type !==
|
|
9911
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES47.ObjectExpression) {
|
|
9550
9912
|
return null;
|
|
9551
9913
|
}
|
|
9552
9914
|
const fields = /* @__PURE__ */ new Map();
|
|
9553
9915
|
for (const property of shape.properties) {
|
|
9554
|
-
if (property.type !==
|
|
9916
|
+
if (property.type !== AST_NODE_TYPES47.Property || property.computed) {
|
|
9555
9917
|
return null;
|
|
9556
9918
|
}
|
|
9557
9919
|
const { key } = property;
|
|
9558
|
-
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;
|
|
9559
9921
|
if (name === null) {
|
|
9560
9922
|
return null;
|
|
9561
9923
|
}
|
|
@@ -9566,11 +9928,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9566
9928
|
function typeMembers(members) {
|
|
9567
9929
|
const result = /* @__PURE__ */ new Map();
|
|
9568
9930
|
for (const member of members) {
|
|
9569
|
-
if (member.type !==
|
|
9931
|
+
if (member.type !== AST_NODE_TYPES47.TSPropertySignature || member.computed) {
|
|
9570
9932
|
return null;
|
|
9571
9933
|
}
|
|
9572
9934
|
const { key } = member;
|
|
9573
|
-
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;
|
|
9574
9936
|
if (name === null) {
|
|
9575
9937
|
return null;
|
|
9576
9938
|
}
|
|
@@ -9584,8 +9946,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9584
9946
|
return result.size === 0 ? null : result;
|
|
9585
9947
|
}
|
|
9586
9948
|
function collectConstrainedNames(node) {
|
|
9587
|
-
if (node.type ===
|
|
9588
|
-
if (node.typeName.type ===
|
|
9949
|
+
if (node.type === AST_NODE_TYPES47.TSTypeReference) {
|
|
9950
|
+
if (node.typeName.type === AST_NODE_TYPES47.Identifier) {
|
|
9589
9951
|
constrainedTypeNames.add(node.typeName.name);
|
|
9590
9952
|
}
|
|
9591
9953
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9593,11 +9955,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9593
9955
|
}
|
|
9594
9956
|
return;
|
|
9595
9957
|
}
|
|
9596
|
-
if (node.type ===
|
|
9958
|
+
if (node.type === AST_NODE_TYPES47.TSArrayType) {
|
|
9597
9959
|
collectConstrainedNames(node.elementType);
|
|
9598
9960
|
return;
|
|
9599
9961
|
}
|
|
9600
|
-
if (node.type ===
|
|
9962
|
+
if (node.type === AST_NODE_TYPES47.TSUnionType || node.type === AST_NODE_TYPES47.TSIntersectionType) {
|
|
9601
9963
|
for (const member of node.types) {
|
|
9602
9964
|
collectConstrainedNames(member);
|
|
9603
9965
|
}
|
|
@@ -9641,13 +10003,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9641
10003
|
return;
|
|
9642
10004
|
}
|
|
9643
10005
|
for (const specifier of node.specifiers) {
|
|
9644
|
-
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") {
|
|
9645
10007
|
zodNamespaces.add(specifier.local.name);
|
|
9646
10008
|
}
|
|
9647
10009
|
}
|
|
9648
10010
|
},
|
|
9649
10011
|
VariableDeclarator(node) {
|
|
9650
|
-
if (node.id.type !==
|
|
10012
|
+
if (node.id.type !== AST_NODE_TYPES47.Identifier || node.init == null) {
|
|
9651
10013
|
return;
|
|
9652
10014
|
}
|
|
9653
10015
|
const fields = schemaFields(node.init);
|
|
@@ -9657,14 +10019,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9657
10019
|
},
|
|
9658
10020
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9659
10021
|
"MemberExpression[computed=false]"(node) {
|
|
9660
|
-
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)) {
|
|
9661
10023
|
reshapedSchemaNames.add(node.object.name);
|
|
9662
10024
|
}
|
|
9663
10025
|
},
|
|
9664
10026
|
/** Records every type argument carried by a Zod constraint. */
|
|
9665
10027
|
TSTypeReference(node) {
|
|
9666
10028
|
const { typeName } = node;
|
|
9667
|
-
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;
|
|
9668
10030
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9669
10031
|
return;
|
|
9670
10032
|
}
|
|
@@ -9682,7 +10044,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9682
10044
|
}
|
|
9683
10045
|
},
|
|
9684
10046
|
TSTypeAliasDeclaration(node) {
|
|
9685
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
10047
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES47.TSTypeLiteral) {
|
|
9686
10048
|
return;
|
|
9687
10049
|
}
|
|
9688
10050
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9727,10 +10089,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9727
10089
|
});
|
|
9728
10090
|
|
|
9729
10091
|
// src/rules/require-assert-never.ts
|
|
9730
|
-
import { AST_NODE_TYPES as
|
|
10092
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48 } from "@typescript-eslint/utils";
|
|
9731
10093
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9732
|
-
if (statement.type ===
|
|
9733
|
-
if (statement.type ===
|
|
10094
|
+
if (statement.type === AST_NODE_TYPES48.EmptyStatement) return false;
|
|
10095
|
+
if (statement.type === AST_NODE_TYPES48.BlockStatement) {
|
|
9734
10096
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9735
10097
|
}
|
|
9736
10098
|
return true;
|
|
@@ -9746,7 +10108,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9746
10108
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9747
10109
|
}
|
|
9748
10110
|
const only = defaultCase.consequent[0];
|
|
9749
|
-
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) {
|
|
9750
10112
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9751
10113
|
}
|
|
9752
10114
|
return false;
|
|
@@ -9786,7 +10148,7 @@ var require_assert_never_default = createRule({
|
|
|
9786
10148
|
});
|
|
9787
10149
|
|
|
9788
10150
|
// src/rules/require-fetch-timeout.ts
|
|
9789
|
-
import { AST_NODE_TYPES as
|
|
10151
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49, ASTUtils as ASTUtils6 } from "@typescript-eslint/utils";
|
|
9790
10152
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9791
10153
|
"globalThis",
|
|
9792
10154
|
"window",
|
|
@@ -9802,14 +10164,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9802
10164
|
return false;
|
|
9803
10165
|
}
|
|
9804
10166
|
function initProvablyLacksSignal(init) {
|
|
9805
|
-
if (init.type !==
|
|
10167
|
+
if (init.type !== AST_NODE_TYPES49.ObjectExpression) {
|
|
9806
10168
|
return false;
|
|
9807
10169
|
}
|
|
9808
10170
|
for (const prop of init.properties) {
|
|
9809
|
-
if (prop.type ===
|
|
10171
|
+
if (prop.type === AST_NODE_TYPES49.SpreadElement) {
|
|
9810
10172
|
return false;
|
|
9811
10173
|
}
|
|
9812
|
-
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") {
|
|
9813
10175
|
return false;
|
|
9814
10176
|
}
|
|
9815
10177
|
if (prop.computed) {
|
|
@@ -9819,7 +10181,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9819
10181
|
return true;
|
|
9820
10182
|
}
|
|
9821
10183
|
function isStringish(node) {
|
|
9822
|
-
return node.type ===
|
|
10184
|
+
return node.type === AST_NODE_TYPES49.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES49.TemplateLiteral;
|
|
9823
10185
|
}
|
|
9824
10186
|
var require_fetch_timeout_default = createRule({
|
|
9825
10187
|
name: "require-fetch-timeout",
|
|
@@ -9856,14 +10218,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9856
10218
|
}
|
|
9857
10219
|
function resolvesToGlobal(identifier) {
|
|
9858
10220
|
const scope = context.sourceCode.getScope(identifier);
|
|
9859
|
-
const variable =
|
|
10221
|
+
const variable = ASTUtils6.findVariable(scope, identifier.name);
|
|
9860
10222
|
return variable === null || variable.defs.length === 0;
|
|
9861
10223
|
}
|
|
9862
10224
|
function isGlobalFetchCall2(callee) {
|
|
9863
|
-
if (callee.type ===
|
|
10225
|
+
if (callee.type === AST_NODE_TYPES49.Identifier) {
|
|
9864
10226
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9865
10227
|
}
|
|
9866
|
-
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);
|
|
9867
10229
|
}
|
|
9868
10230
|
return {
|
|
9869
10231
|
CallExpression(node) {
|
|
@@ -9883,28 +10245,51 @@ var require_fetch_timeout_default = createRule({
|
|
|
9883
10245
|
});
|
|
9884
10246
|
|
|
9885
10247
|
// src/rules/require-interface-for-injected-service.ts
|
|
9886
|
-
import { AST_NODE_TYPES as
|
|
10248
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50 } from "@typescript-eslint/utils";
|
|
9887
10249
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9888
10250
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9889
10251
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
9890
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)$/;
|
|
9891
10254
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9892
10255
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9893
10256
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9894
|
-
var
|
|
9895
|
-
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}` : "";
|
|
9896
10275
|
var readTypeReference = (annotation) => {
|
|
9897
|
-
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;
|
|
9898
10283
|
const { typeName } = annotation;
|
|
9899
|
-
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;
|
|
9900
10285
|
if (rightmost === null) return null;
|
|
9901
10286
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9902
10287
|
};
|
|
9903
10288
|
var namedParameterCollaborator = (annotated) => {
|
|
9904
10289
|
let target = annotated;
|
|
9905
|
-
if (target.type ===
|
|
9906
|
-
if (target.type ===
|
|
9907
|
-
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;
|
|
9908
10293
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9909
10294
|
if (reference === null) return null;
|
|
9910
10295
|
return { name: target.name, ...reference };
|
|
@@ -9912,8 +10297,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9912
10297
|
var propertySignatureTypes = (members) => {
|
|
9913
10298
|
const types = /* @__PURE__ */ new Map();
|
|
9914
10299
|
for (const member of members) {
|
|
9915
|
-
if (member.type !==
|
|
9916
|
-
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;
|
|
9917
10302
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9918
10303
|
if (reference === null) continue;
|
|
9919
10304
|
types.set(member.key.name, reference);
|
|
@@ -9924,18 +10309,18 @@ var fileTypeIndex = (program) => {
|
|
|
9924
10309
|
const objects = /* @__PURE__ */ new Map();
|
|
9925
10310
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9926
10311
|
for (const statement of program.body) {
|
|
9927
|
-
const declaration = statement.type ===
|
|
9928
|
-
if (declaration?.type ===
|
|
10312
|
+
const declaration = statement.type === AST_NODE_TYPES50.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10313
|
+
if (declaration?.type === AST_NODE_TYPES50.TSInterfaceDeclaration) {
|
|
9929
10314
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9930
10315
|
continue;
|
|
9931
10316
|
}
|
|
9932
|
-
if (declaration?.type !==
|
|
10317
|
+
if (declaration?.type !== AST_NODE_TYPES50.TSTypeAliasDeclaration) continue;
|
|
9933
10318
|
const aliased = declaration.typeAnnotation;
|
|
9934
|
-
if (aliased.type ===
|
|
10319
|
+
if (aliased.type === AST_NODE_TYPES50.TSFunctionType || aliased.type === AST_NODE_TYPES50.TSConstructorType) {
|
|
9935
10320
|
functionAliases.add(declaration.id.name);
|
|
9936
10321
|
continue;
|
|
9937
10322
|
}
|
|
9938
|
-
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) : [];
|
|
9939
10324
|
if (literals.length === 0) continue;
|
|
9940
10325
|
const merged = /* @__PURE__ */ new Map();
|
|
9941
10326
|
for (const literal of literals) {
|
|
@@ -9948,10 +10333,10 @@ var fileTypeIndex = (program) => {
|
|
|
9948
10333
|
return { objects, functionAliases };
|
|
9949
10334
|
};
|
|
9950
10335
|
var bagMemberTypes = (annotation, declared) => {
|
|
9951
|
-
if (annotation.type ===
|
|
10336
|
+
if (annotation.type === AST_NODE_TYPES50.TSTypeLiteral) {
|
|
9952
10337
|
return propertySignatureTypes(annotation.members);
|
|
9953
10338
|
}
|
|
9954
|
-
if (annotation.type !==
|
|
10339
|
+
if (annotation.type !== AST_NODE_TYPES50.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES50.Identifier) {
|
|
9955
10340
|
return null;
|
|
9956
10341
|
}
|
|
9957
10342
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9963,11 +10348,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9963
10348
|
if (members === null) return [];
|
|
9964
10349
|
const collaborators = [];
|
|
9965
10350
|
for (const property of pattern.properties) {
|
|
9966
|
-
if (property.type !==
|
|
9967
|
-
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;
|
|
9968
10353
|
const key = property.key.name;
|
|
9969
|
-
const bound = property.value.type ===
|
|
9970
|
-
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;
|
|
9971
10356
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9972
10357
|
const reference = members.get(key);
|
|
9973
10358
|
if (reference === void 0) continue;
|
|
@@ -9977,8 +10362,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9977
10362
|
};
|
|
9978
10363
|
var parameterCollaborators = (parameter, declared) => {
|
|
9979
10364
|
let target = parameter;
|
|
9980
|
-
if (target.type ===
|
|
9981
|
-
if (target.type ===
|
|
10365
|
+
if (target.type === AST_NODE_TYPES50.AssignmentPattern) target = target.left;
|
|
10366
|
+
if (target.type === AST_NODE_TYPES50.ObjectPattern) {
|
|
9982
10367
|
return objectPatternCollaborators(target, declared);
|
|
9983
10368
|
}
|
|
9984
10369
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9996,18 +10381,31 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9996
10381
|
const storedFrom = /* @__PURE__ */ new Set();
|
|
9997
10382
|
let constructedFields = 0;
|
|
9998
10383
|
if (body2 !== null && body2 !== void 0) {
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
const
|
|
10002
|
-
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
|
+
}
|
|
10003
10400
|
continue;
|
|
10004
10401
|
}
|
|
10005
|
-
|
|
10006
|
-
|
|
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) {
|
|
10007
10405
|
constructedFields += 1;
|
|
10008
|
-
} else if (source.type ===
|
|
10406
|
+
} else if (source.type === AST_NODE_TYPES50.Identifier) {
|
|
10009
10407
|
storedFrom.add(source.name);
|
|
10010
|
-
} else if (source.type ===
|
|
10408
|
+
} else if (source.type === AST_NODE_TYPES50.MemberExpression && source.object.type === AST_NODE_TYPES50.Identifier) {
|
|
10011
10409
|
storedFrom.add(source.object.name);
|
|
10012
10410
|
}
|
|
10013
10411
|
}
|
|
@@ -10015,12 +10413,13 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
10015
10413
|
const collaborators = [];
|
|
10016
10414
|
for (const parameter of ctor.value.params) {
|
|
10017
10415
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
10018
|
-
const stored = parameter.type ===
|
|
10416
|
+
const stored = parameter.type === AST_NODE_TYPES50.TSParameterProperty || storedFrom.has(reference.name);
|
|
10019
10417
|
if (!stored) continue;
|
|
10020
10418
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
10021
10419
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
10022
10420
|
if (typeParameters.has(reference.typeName)) continue;
|
|
10023
10421
|
if (BUILTIN_CONTAINER_TYPE_RE.test(reference.typeName)) continue;
|
|
10422
|
+
if (VALUE_TYPE_RE.test(reference.typeName)) continue;
|
|
10024
10423
|
if (declared().functionAliases.has(reference.typeName)) continue;
|
|
10025
10424
|
collaborators.push(reference);
|
|
10026
10425
|
}
|
|
@@ -10049,19 +10448,19 @@ var subtreeHas = (root, found) => {
|
|
|
10049
10448
|
return hit;
|
|
10050
10449
|
};
|
|
10051
10450
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
10052
|
-
if (node.type ===
|
|
10451
|
+
if (node.type === AST_NODE_TYPES50.CallExpression) {
|
|
10053
10452
|
const { callee } = node;
|
|
10054
|
-
if (callee.type ===
|
|
10055
|
-
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;
|
|
10056
10455
|
}
|
|
10057
|
-
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);
|
|
10058
10457
|
});
|
|
10059
10458
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
10060
10459
|
var fileInterfaceNames = (program) => {
|
|
10061
10460
|
const names = [];
|
|
10062
10461
|
for (const statement of program.body) {
|
|
10063
|
-
const declaration = statement.type ===
|
|
10064
|
-
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);
|
|
10065
10464
|
}
|
|
10066
10465
|
return names;
|
|
10067
10466
|
};
|
|
@@ -10076,28 +10475,153 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
10076
10475
|
return target.endsWith(other) || other.endsWith(target);
|
|
10077
10476
|
});
|
|
10078
10477
|
};
|
|
10079
|
-
var publicMethodNames = (body2) => {
|
|
10478
|
+
var publicMethodNames = (body2, functionAliases) => {
|
|
10080
10479
|
const names = [];
|
|
10081
10480
|
for (const member of body2.body) {
|
|
10082
|
-
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;
|
|
10083
10488
|
if (member.kind !== "method" || member.static) continue;
|
|
10084
10489
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
10085
|
-
if (member.key.type ===
|
|
10086
|
-
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);
|
|
10087
10492
|
else names.push("\u2026");
|
|
10088
10493
|
}
|
|
10089
10494
|
return names;
|
|
10090
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
|
+
}
|
|
10091
10615
|
var require_interface_for_injected_service_default = createRule({
|
|
10092
10616
|
name: "require-interface-for-injected-service",
|
|
10093
10617
|
meta: {
|
|
10094
10618
|
type: "suggestion",
|
|
10095
10619
|
docs: {
|
|
10096
|
-
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."
|
|
10097
10621
|
},
|
|
10098
10622
|
schema: [],
|
|
10099
10623
|
messages: {
|
|
10100
|
-
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."
|
|
10101
10625
|
}
|
|
10102
10626
|
},
|
|
10103
10627
|
defaultOptions: [],
|
|
@@ -10106,17 +10630,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10106
10630
|
if (isTestFile(filename) || isStoryFile(filename) || isScriptFile(filename)) return {};
|
|
10107
10631
|
if (isGeneratedFile(filename, context.sourceCode.getText())) return {};
|
|
10108
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);
|
|
10109
10636
|
const objectTypes = () => declaredTypes ??= fileTypeIndex(context.sourceCode.ast);
|
|
10110
10637
|
return {
|
|
10111
10638
|
ClassDeclaration(node) {
|
|
10112
10639
|
if (node.id === null) return;
|
|
10113
|
-
if (!
|
|
10640
|
+
if (!isExportedClass2(node, detachedExports)) return;
|
|
10114
10641
|
if (node.abstract === true) return;
|
|
10115
|
-
if (node.superClass !== null) return;
|
|
10116
|
-
if (node.implements.length > 0) return;
|
|
10117
10642
|
if (node.decorators.length > 0) return;
|
|
10118
10643
|
const ctor = node.body.body.find(
|
|
10119
|
-
(member) => member.type ===
|
|
10644
|
+
(member) => member.type === AST_NODE_TYPES50.MethodDefinition && member.kind === "constructor"
|
|
10120
10645
|
);
|
|
10121
10646
|
if (ctor === void 0) return;
|
|
10122
10647
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -10128,8 +10653,9 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10128
10653
|
if (constructedFields > collaborators.length) return;
|
|
10129
10654
|
if (isFrameworkWiring(node.body)) return;
|
|
10130
10655
|
if (isTransportWrapper(node.id.name, collaborators, context.sourceCode.ast)) return;
|
|
10131
|
-
const methods = publicMethodNames(node.body);
|
|
10656
|
+
const methods = publicMethodNames(node.body, objectTypes().functionAliases);
|
|
10132
10657
|
if (methods.length === 0) return;
|
|
10658
|
+
if (hasServicePort(node, methods, localClasses, localInterfaces)) return;
|
|
10133
10659
|
context.report({
|
|
10134
10660
|
node: node.id,
|
|
10135
10661
|
messageId: "requireInterface",
|
|
@@ -10145,37 +10671,37 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10145
10671
|
});
|
|
10146
10672
|
|
|
10147
10673
|
// src/rules/require-static-next-matcher.ts
|
|
10148
|
-
import { AST_NODE_TYPES as
|
|
10674
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51 } from "@typescript-eslint/utils";
|
|
10149
10675
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
10150
10676
|
function unwrapExpression2(node) {
|
|
10151
|
-
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) {
|
|
10152
10678
|
return unwrapExpression2(node.expression);
|
|
10153
10679
|
}
|
|
10154
10680
|
return node;
|
|
10155
10681
|
}
|
|
10156
10682
|
function isStaticValue(node) {
|
|
10157
10683
|
const value = unwrapExpression2(node);
|
|
10158
|
-
if (value.type ===
|
|
10684
|
+
if (value.type === AST_NODE_TYPES51.Literal) {
|
|
10159
10685
|
return true;
|
|
10160
10686
|
}
|
|
10161
|
-
if (value.type ===
|
|
10687
|
+
if (value.type === AST_NODE_TYPES51.TemplateLiteral) {
|
|
10162
10688
|
return value.expressions.length === 0;
|
|
10163
10689
|
}
|
|
10164
|
-
if (value.type ===
|
|
10690
|
+
if (value.type === AST_NODE_TYPES51.ArrayExpression) {
|
|
10165
10691
|
return value.elements.every(
|
|
10166
|
-
(element) => element !== null && element.type !==
|
|
10692
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES51.SpreadElement && isStaticValue(element)
|
|
10167
10693
|
);
|
|
10168
10694
|
}
|
|
10169
|
-
if (value.type ===
|
|
10695
|
+
if (value.type === AST_NODE_TYPES51.ObjectExpression) {
|
|
10170
10696
|
return value.properties.every(
|
|
10171
|
-
(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)
|
|
10172
10698
|
);
|
|
10173
10699
|
}
|
|
10174
10700
|
return false;
|
|
10175
10701
|
}
|
|
10176
10702
|
function propertyName2(property) {
|
|
10177
10703
|
if (property.computed) return null;
|
|
10178
|
-
if (property.key.type ===
|
|
10704
|
+
if (property.key.type === AST_NODE_TYPES51.Identifier) return property.key.name;
|
|
10179
10705
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
10180
10706
|
}
|
|
10181
10707
|
var require_static_next_matcher_default = createRule({
|
|
@@ -10197,19 +10723,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
10197
10723
|
}
|
|
10198
10724
|
return {
|
|
10199
10725
|
ExportNamedDeclaration(node) {
|
|
10200
|
-
if (node.declaration?.type !==
|
|
10726
|
+
if (node.declaration?.type !== AST_NODE_TYPES51.VariableDeclaration) {
|
|
10201
10727
|
return;
|
|
10202
10728
|
}
|
|
10203
10729
|
for (const declaration of node.declaration.declarations) {
|
|
10204
|
-
if (declaration.id.type !==
|
|
10730
|
+
if (declaration.id.type !== AST_NODE_TYPES51.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
10205
10731
|
continue;
|
|
10206
10732
|
}
|
|
10207
10733
|
const config = unwrapExpression2(declaration.init);
|
|
10208
|
-
if (config.type !==
|
|
10734
|
+
if (config.type !== AST_NODE_TYPES51.ObjectExpression) {
|
|
10209
10735
|
continue;
|
|
10210
10736
|
}
|
|
10211
10737
|
for (const property of config.properties) {
|
|
10212
|
-
if (property.type !==
|
|
10738
|
+
if (property.type !== AST_NODE_TYPES51.Property || propertyName2(property) !== "matcher" || property.value.type === AST_NODE_TYPES51.AssignmentPattern) {
|
|
10213
10739
|
continue;
|
|
10214
10740
|
}
|
|
10215
10741
|
if (!isStaticValue(property.value)) {
|
|
@@ -10223,18 +10749,18 @@ var require_static_next_matcher_default = createRule({
|
|
|
10223
10749
|
});
|
|
10224
10750
|
|
|
10225
10751
|
// src/rules/require-zod-form-validation.ts
|
|
10226
|
-
import { AST_NODE_TYPES as
|
|
10752
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52 } from "@typescript-eslint/utils";
|
|
10227
10753
|
var looksLikeZodSchema = (node) => {
|
|
10228
10754
|
let current = node;
|
|
10229
10755
|
while (true) {
|
|
10230
|
-
if (current.type ===
|
|
10756
|
+
if (current.type === AST_NODE_TYPES52.Identifier) {
|
|
10231
10757
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
10232
10758
|
}
|
|
10233
|
-
if (current.type ===
|
|
10759
|
+
if (current.type === AST_NODE_TYPES52.CallExpression) {
|
|
10234
10760
|
current = current.callee;
|
|
10235
10761
|
continue;
|
|
10236
10762
|
}
|
|
10237
|
-
if (current.type ===
|
|
10763
|
+
if (current.type === AST_NODE_TYPES52.MemberExpression) {
|
|
10238
10764
|
current = current.object;
|
|
10239
10765
|
continue;
|
|
10240
10766
|
}
|
|
@@ -10242,23 +10768,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
10242
10768
|
}
|
|
10243
10769
|
};
|
|
10244
10770
|
var isZodParseCall = (node) => {
|
|
10245
|
-
if (node.type !==
|
|
10771
|
+
if (node.type !== AST_NODE_TYPES52.CallExpression) return false;
|
|
10246
10772
|
const callee = node.callee;
|
|
10247
|
-
if (callee.type !==
|
|
10773
|
+
if (callee.type !== AST_NODE_TYPES52.MemberExpression) return false;
|
|
10248
10774
|
if (callee.computed) return false;
|
|
10249
|
-
if (callee.property.type !==
|
|
10775
|
+
if (callee.property.type !== AST_NODE_TYPES52.Identifier) return false;
|
|
10250
10776
|
const method = callee.property.name;
|
|
10251
10777
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
10252
10778
|
return looksLikeZodSchema(callee.object);
|
|
10253
10779
|
};
|
|
10254
10780
|
var isFormDataMethodCall = (node) => {
|
|
10255
10781
|
let current = node;
|
|
10256
|
-
if (current.type ===
|
|
10782
|
+
if (current.type === AST_NODE_TYPES52.AwaitExpression) {
|
|
10257
10783
|
current = current.argument;
|
|
10258
10784
|
}
|
|
10259
|
-
if (current.type !==
|
|
10785
|
+
if (current.type !== AST_NODE_TYPES52.CallExpression) return false;
|
|
10260
10786
|
const callee = current.callee;
|
|
10261
|
-
return callee.type ===
|
|
10787
|
+
return callee.type === AST_NODE_TYPES52.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES52.Identifier && callee.property.name === "formData";
|
|
10262
10788
|
};
|
|
10263
10789
|
var require_zod_form_validation_default = createRule({
|
|
10264
10790
|
name: "require-zod-form-validation",
|
|
@@ -10278,14 +10804,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
10278
10804
|
return {};
|
|
10279
10805
|
}
|
|
10280
10806
|
const isFormSourceIdentifier = (node) => {
|
|
10281
|
-
if (node.type !==
|
|
10807
|
+
if (node.type !== AST_NODE_TYPES52.Identifier) return false;
|
|
10282
10808
|
if (/formdata/i.test(node.name)) return true;
|
|
10283
10809
|
let scope = context.sourceCode.getScope(node);
|
|
10284
10810
|
while (scope !== null) {
|
|
10285
10811
|
const variable = scope.set.get(node.name);
|
|
10286
10812
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
10287
10813
|
const def = variable.defs[0];
|
|
10288
|
-
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) {
|
|
10289
10815
|
return isFormDataMethodCall(def.node.init);
|
|
10290
10816
|
}
|
|
10291
10817
|
return false;
|
|
@@ -10296,8 +10822,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
10296
10822
|
};
|
|
10297
10823
|
const isFormDataGetCall = (node) => {
|
|
10298
10824
|
const callee = node.callee;
|
|
10299
|
-
if (callee.type !==
|
|
10300
|
-
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") {
|
|
10301
10827
|
return false;
|
|
10302
10828
|
}
|
|
10303
10829
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -10312,11 +10838,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
10312
10838
|
};
|
|
10313
10839
|
const isInstanceofNarrowing = (node) => {
|
|
10314
10840
|
const parent = node.parent;
|
|
10315
|
-
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");
|
|
10316
10842
|
};
|
|
10317
10843
|
const boundDeclarator = (node) => {
|
|
10318
10844
|
const parent = node.parent;
|
|
10319
|
-
if (parent.type ===
|
|
10845
|
+
if (parent.type === AST_NODE_TYPES52.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES52.Identifier) {
|
|
10320
10846
|
return parent;
|
|
10321
10847
|
}
|
|
10322
10848
|
return null;
|
|
@@ -10374,8 +10900,395 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
10374
10900
|
}
|
|
10375
10901
|
});
|
|
10376
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
|
+
|
|
10377
11290
|
// src/rules/zod-naming-convention.ts
|
|
10378
|
-
import { AST_NODE_TYPES as
|
|
11291
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54 } from "@typescript-eslint/utils";
|
|
10379
11292
|
var CONVENTIONS = {
|
|
10380
11293
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
10381
11294
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -10400,15 +11313,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
10400
11313
|
"registry",
|
|
10401
11314
|
"implement"
|
|
10402
11315
|
]);
|
|
10403
|
-
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;
|
|
10404
11317
|
var calleeChainStartsWithZ = (node) => {
|
|
10405
11318
|
let current = node;
|
|
10406
|
-
while (current.type ===
|
|
11319
|
+
while (current.type === AST_NODE_TYPES54.MemberExpression) {
|
|
10407
11320
|
const receiver = current.object;
|
|
10408
|
-
if (receiver.type ===
|
|
11321
|
+
if (receiver.type === AST_NODE_TYPES54.Identifier && receiver.name === "z") {
|
|
10409
11322
|
return true;
|
|
10410
11323
|
}
|
|
10411
|
-
if (receiver.type ===
|
|
11324
|
+
if (receiver.type === AST_NODE_TYPES54.CallExpression) {
|
|
10412
11325
|
current = receiver.callee;
|
|
10413
11326
|
continue;
|
|
10414
11327
|
}
|
|
@@ -10453,13 +11366,13 @@ var zod_naming_convention_default = createRule({
|
|
|
10453
11366
|
VariableDeclarator(node) {
|
|
10454
11367
|
const init = node.init;
|
|
10455
11368
|
if (init === null || init === void 0) return;
|
|
10456
|
-
if (init.type !==
|
|
11369
|
+
if (init.type !== AST_NODE_TYPES54.CallExpression) return;
|
|
10457
11370
|
const callee = init.callee;
|
|
10458
|
-
if (callee.type !==
|
|
11371
|
+
if (callee.type !== AST_NODE_TYPES54.MemberExpression) return;
|
|
10459
11372
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
10460
11373
|
const terminal = terminalMethodName(callee);
|
|
10461
11374
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
10462
|
-
if (node.id.type !==
|
|
11375
|
+
if (node.id.type !== AST_NODE_TYPES54.Identifier) return;
|
|
10463
11376
|
if (test.test(node.id.name)) return;
|
|
10464
11377
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
10465
11378
|
context.report({
|
|
@@ -10544,6 +11457,7 @@ var rules = {
|
|
|
10544
11457
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
10545
11458
|
"no-log-only-catch": no_log_only_catch_default,
|
|
10546
11459
|
"no-long-comment": no_long_comment_default,
|
|
11460
|
+
"no-generic-single-export-module": no_generic_single_export_module_default,
|
|
10547
11461
|
"no-offset-pagination": no_offset_pagination_default,
|
|
10548
11462
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
10549
11463
|
"no-raw-env": no_raw_env_default,
|
|
@@ -10591,11 +11505,12 @@ var rules = {
|
|
|
10591
11505
|
"require-static-next-matcher": require_static_next_matcher_default,
|
|
10592
11506
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
10593
11507
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
11508
|
+
"stepdown": stepdown_default,
|
|
10594
11509
|
"zod-naming-convention": zod_naming_convention_default
|
|
10595
11510
|
};
|
|
10596
11511
|
var meta = {
|
|
10597
11512
|
name: "@sarj/eslint-plugin",
|
|
10598
|
-
version: "9.
|
|
11513
|
+
version: "9.14.0"
|
|
10599
11514
|
};
|
|
10600
11515
|
var applicationOnlyRules = [
|
|
10601
11516
|
"no-restricted-library-load",
|
|
@@ -10617,6 +11532,7 @@ var recommendedRules = {
|
|
|
10617
11532
|
"@sarj/no-json-stringify-error": "warn",
|
|
10618
11533
|
"@sarj/no-log-only-catch": "warn",
|
|
10619
11534
|
"@sarj/no-long-comment": "warn",
|
|
11535
|
+
"@sarj/no-generic-single-export-module": "warn",
|
|
10620
11536
|
"@sarj/no-offset-pagination": "warn",
|
|
10621
11537
|
"@sarj/no-positional-tuple-return": "warn",
|
|
10622
11538
|
"@sarj/no-repeated-string-literal": "warn",
|
|
@@ -10658,6 +11574,7 @@ var recommendedRules = {
|
|
|
10658
11574
|
"@sarj/require-static-next-matcher": "error",
|
|
10659
11575
|
"@sarj/require-zod-form-validation": "error",
|
|
10660
11576
|
"@sarj/store-insert-requires-on-conflict": "warn",
|
|
11577
|
+
"@sarj/stepdown": "warn",
|
|
10661
11578
|
"@sarj/zod-naming-convention": "warn"
|
|
10662
11579
|
};
|
|
10663
11580
|
var strictRules = {
|
|
@@ -10676,6 +11593,7 @@ var strictRules = {
|
|
|
10676
11593
|
"@sarj/no-json-stringify-error": "error",
|
|
10677
11594
|
"@sarj/no-log-only-catch": "error",
|
|
10678
11595
|
"@sarj/no-long-comment": "error",
|
|
11596
|
+
"@sarj/no-generic-single-export-module": "warn",
|
|
10679
11597
|
"@sarj/no-offset-pagination": "error",
|
|
10680
11598
|
"@sarj/no-positional-tuple-return": "error",
|
|
10681
11599
|
"@sarj/no-raw-env": "error",
|
|
@@ -10720,6 +11638,7 @@ var strictRules = {
|
|
|
10720
11638
|
"@sarj/require-static-next-matcher": "error",
|
|
10721
11639
|
"@sarj/require-zod-form-validation": "error",
|
|
10722
11640
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
11641
|
+
"@sarj/stepdown": "warn",
|
|
10723
11642
|
"@sarj/zod-naming-convention": "error"
|
|
10724
11643
|
};
|
|
10725
11644
|
var plugin = {
|