@sarj/eslint-plugin 9.8.0 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/index.cjs +722 -586
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +705 -569
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2340,6 +2340,58 @@ var no_hand_rolled_sleep_default = createRule({
|
|
|
2340
2340
|
}
|
|
2341
2341
|
});
|
|
2342
2342
|
|
|
2343
|
+
// src/rules/no-hand-rolled-spinner.ts
|
|
2344
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES11 } from "@typescript-eslint/utils";
|
|
2345
|
+
var DESIGN_SYSTEM_PATH = /(?:^|[/\\])components[/\\]ui[/\\]/u;
|
|
2346
|
+
var BORDER_WIDTH = /^border(?:-[0-9]+)?$/u;
|
|
2347
|
+
var TRANSPARENT_EDGE = /^border-[trbl]-transparent$/u;
|
|
2348
|
+
function staticClassName(attribute) {
|
|
2349
|
+
const value = attribute.value;
|
|
2350
|
+
if (value?.type === AST_NODE_TYPES11.Literal && typeof value.value === "string") {
|
|
2351
|
+
return value.value;
|
|
2352
|
+
}
|
|
2353
|
+
if (value?.type === AST_NODE_TYPES11.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES11.Literal && typeof value.expression.value === "string") {
|
|
2354
|
+
return value.expression.value;
|
|
2355
|
+
}
|
|
2356
|
+
return null;
|
|
2357
|
+
}
|
|
2358
|
+
var no_hand_rolled_spinner_default = createRule({
|
|
2359
|
+
name: "no-hand-rolled-spinner",
|
|
2360
|
+
meta: {
|
|
2361
|
+
type: "suggestion",
|
|
2362
|
+
docs: {
|
|
2363
|
+
description: "Disallow intrinsic elements styled as Tailwind border-ring spinners outside the design-system implementation."
|
|
2364
|
+
},
|
|
2365
|
+
schema: [],
|
|
2366
|
+
messages: {
|
|
2367
|
+
handRolledSpinner: "Use the design-system Spinner component instead of rebuilding a border-ring spinner with utility classes."
|
|
2368
|
+
}
|
|
2369
|
+
},
|
|
2370
|
+
defaultOptions: [],
|
|
2371
|
+
create(context) {
|
|
2372
|
+
if (DESIGN_SYSTEM_PATH.test(context.filename)) {
|
|
2373
|
+
return {};
|
|
2374
|
+
}
|
|
2375
|
+
return {
|
|
2376
|
+
JSXOpeningElement(node) {
|
|
2377
|
+
if (node.name.type !== AST_NODE_TYPES11.JSXIdentifier || node.name.name !== "div" && node.name.name !== "span") {
|
|
2378
|
+
return;
|
|
2379
|
+
}
|
|
2380
|
+
const classNameAttribute = node.attributes.find(
|
|
2381
|
+
(attribute) => attribute.type === AST_NODE_TYPES11.JSXAttribute && attribute.name.type === AST_NODE_TYPES11.JSXIdentifier && attribute.name.name === "className"
|
|
2382
|
+
);
|
|
2383
|
+
if (classNameAttribute === void 0) return;
|
|
2384
|
+
const className = staticClassName(classNameAttribute);
|
|
2385
|
+
if (className === null) return;
|
|
2386
|
+
const classes = className.split(/\s+/u);
|
|
2387
|
+
if (classes.includes("animate-spin") && classes.includes("rounded-full") && classes.some((token) => BORDER_WIDTH.test(token)) && classes.some((token) => TRANSPARENT_EDGE.test(token))) {
|
|
2388
|
+
context.report({ node, messageId: "handRolledSpinner" });
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
});
|
|
2394
|
+
|
|
2343
2395
|
// src/rules/no-insecure-random-id.ts
|
|
2344
2396
|
import "@typescript-eslint/utils";
|
|
2345
2397
|
var STRONG_SECURITY_PATTERN = /token|secret|csrf|password|passwd|apikey|api[-_]?key|nonce|salt|uuid|authid/i;
|
|
@@ -2706,7 +2758,7 @@ var no_json_stringify_error_default = createRule({
|
|
|
2706
2758
|
});
|
|
2707
2759
|
|
|
2708
2760
|
// src/rules/no-log-only-catch.ts
|
|
2709
|
-
import { AST_NODE_TYPES as
|
|
2761
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES12, ASTUtils } from "@typescript-eslint/utils";
|
|
2710
2762
|
|
|
2711
2763
|
// src/rules/_logging.ts
|
|
2712
2764
|
import "@typescript-eslint/utils";
|
|
@@ -2813,29 +2865,29 @@ function createLogMatcher(options = {}) {
|
|
|
2813
2865
|
// src/rules/no-log-only-catch.ts
|
|
2814
2866
|
var BENCHMARK_DIR_RE = /(?:^|[\\/])benchmarks?[\\/]/;
|
|
2815
2867
|
var SINGLE_STATEMENT_HOSTS = /* @__PURE__ */ new Set([
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2868
|
+
AST_NODE_TYPES12.DoWhileStatement,
|
|
2869
|
+
AST_NODE_TYPES12.ForInStatement,
|
|
2870
|
+
AST_NODE_TYPES12.ForOfStatement,
|
|
2871
|
+
AST_NODE_TYPES12.ForStatement,
|
|
2872
|
+
AST_NODE_TYPES12.IfStatement,
|
|
2873
|
+
AST_NODE_TYPES12.WhileStatement
|
|
2822
2874
|
]);
|
|
2823
2875
|
var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2876
|
+
AST_NODE_TYPES12.ArrowFunctionExpression,
|
|
2877
|
+
AST_NODE_TYPES12.FunctionDeclaration,
|
|
2878
|
+
AST_NODE_TYPES12.FunctionExpression
|
|
2827
2879
|
]);
|
|
2828
2880
|
function statementSlot(node) {
|
|
2829
2881
|
const parent = node.parent;
|
|
2830
2882
|
if (parent === void 0) return null;
|
|
2831
2883
|
let list;
|
|
2832
2884
|
switch (parent.type) {
|
|
2833
|
-
case
|
|
2834
|
-
case
|
|
2835
|
-
case
|
|
2885
|
+
case AST_NODE_TYPES12.BlockStatement:
|
|
2886
|
+
case AST_NODE_TYPES12.Program:
|
|
2887
|
+
case AST_NODE_TYPES12.StaticBlock:
|
|
2836
2888
|
list = parent.body;
|
|
2837
2889
|
break;
|
|
2838
|
-
case
|
|
2890
|
+
case AST_NODE_TYPES12.SwitchCase:
|
|
2839
2891
|
list = parent.consequent;
|
|
2840
2892
|
break;
|
|
2841
2893
|
default:
|
|
@@ -2854,20 +2906,20 @@ function hasFollowingStatement(node) {
|
|
|
2854
2906
|
function fallbackFollowsTry(tryStatement) {
|
|
2855
2907
|
const body2 = tryStatement.block.body;
|
|
2856
2908
|
const last = body2.at(-1);
|
|
2857
|
-
return last?.type ===
|
|
2909
|
+
return last?.type === AST_NODE_TYPES12.ReturnStatement && hasFollowingStatement(tryStatement);
|
|
2858
2910
|
}
|
|
2859
2911
|
function isSeedValue(node) {
|
|
2860
|
-
const inner = node.type ===
|
|
2912
|
+
const inner = node.type === AST_NODE_TYPES12.TSAsExpression ? node.expression : node;
|
|
2861
2913
|
switch (inner.type) {
|
|
2862
|
-
case
|
|
2914
|
+
case AST_NODE_TYPES12.Literal:
|
|
2863
2915
|
return true;
|
|
2864
|
-
case
|
|
2916
|
+
case AST_NODE_TYPES12.Identifier:
|
|
2865
2917
|
return inner.name === "undefined";
|
|
2866
|
-
case
|
|
2867
|
-
return inner.argument.type ===
|
|
2868
|
-
case
|
|
2918
|
+
case AST_NODE_TYPES12.UnaryExpression:
|
|
2919
|
+
return inner.argument.type === AST_NODE_TYPES12.Literal;
|
|
2920
|
+
case AST_NODE_TYPES12.ArrayExpression:
|
|
2869
2921
|
return inner.elements.length === 0;
|
|
2870
|
-
case
|
|
2922
|
+
case AST_NODE_TYPES12.ObjectExpression:
|
|
2871
2923
|
return inner.properties.length === 0;
|
|
2872
2924
|
default:
|
|
2873
2925
|
return false;
|
|
@@ -2877,12 +2929,12 @@ function seededFallbackHandled(tryStatement, scope) {
|
|
|
2877
2929
|
const slot = statementSlot(tryStatement);
|
|
2878
2930
|
if (slot === null || slot.index === 0) return false;
|
|
2879
2931
|
const previous = slot.list[slot.index - 1];
|
|
2880
|
-
if (previous?.type !==
|
|
2932
|
+
if (previous?.type !== AST_NODE_TYPES12.VariableDeclaration || previous.kind === "const") {
|
|
2881
2933
|
return false;
|
|
2882
2934
|
}
|
|
2883
2935
|
const declarator = previous.declarations[0];
|
|
2884
2936
|
if (previous.declarations.length !== 1 || declarator === void 0) return false;
|
|
2885
|
-
if (declarator.id.type !==
|
|
2937
|
+
if (declarator.id.type !== AST_NODE_TYPES12.Identifier) return false;
|
|
2886
2938
|
if (declarator.init == null || !isSeedValue(declarator.init)) return false;
|
|
2887
2939
|
const variable = ASTUtils.findVariable(scope, declarator.id.name);
|
|
2888
2940
|
if (variable === null) return false;
|
|
@@ -2934,7 +2986,7 @@ var no_log_only_catch_default = createRule({
|
|
|
2934
2986
|
const tryStatement = node.parent;
|
|
2935
2987
|
if (hasCommentDirectlyAbove(tryStatement) || hasCommentDirectlyAbove(node)) return true;
|
|
2936
2988
|
const block = tryStatement.parent;
|
|
2937
|
-
if (block?.type !==
|
|
2989
|
+
if (block?.type !== AST_NODE_TYPES12.BlockStatement || block.body.length !== 1 || block.parent === void 0 || !SINGLE_STATEMENT_HOSTS.has(block.parent.type)) {
|
|
2938
2990
|
return false;
|
|
2939
2991
|
}
|
|
2940
2992
|
return hasCommentDirectlyAbove(block.parent);
|
|
@@ -2971,7 +3023,7 @@ var no_log_only_catch_default = createRule({
|
|
|
2971
3023
|
});
|
|
2972
3024
|
|
|
2973
3025
|
// src/rules/_prose-budget.ts
|
|
2974
|
-
import { AST_NODE_TYPES as
|
|
3026
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES13 } from "@typescript-eslint/utils";
|
|
2975
3027
|
var DIRECTIVE_RE2 = /^(?:!|eslint\b|eslint-|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|@vite|webpack|@jsx|@jest-environment|@vitest-environment|#__|todo\b|fixme\b|hack\b)/i;
|
|
2976
3028
|
var LICENSE_RE2 = /\b(?:copyright|spdx-license-identifier|licensed under)\b/i;
|
|
2977
3029
|
var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
|
|
@@ -3027,25 +3079,25 @@ function proseGroups(filename, sourceCode, includeValueTags = false) {
|
|
|
3027
3079
|
return groups;
|
|
3028
3080
|
}
|
|
3029
3081
|
function annotatedParameter(parameter) {
|
|
3030
|
-
if (parameter.type ===
|
|
3031
|
-
const target = parameter.type ===
|
|
3082
|
+
if (parameter.type === AST_NODE_TYPES13.TSParameterProperty) return annotatedParameter(parameter.parameter);
|
|
3083
|
+
const target = parameter.type === AST_NODE_TYPES13.AssignmentPattern ? parameter.left : parameter;
|
|
3032
3084
|
return "typeAnnotation" in target && target.typeAnnotation != null;
|
|
3033
3085
|
}
|
|
3034
3086
|
function typedFunction(node) {
|
|
3035
3087
|
switch (node.type) {
|
|
3036
|
-
case
|
|
3037
|
-
case
|
|
3088
|
+
case AST_NODE_TYPES13.ExportNamedDeclaration:
|
|
3089
|
+
case AST_NODE_TYPES13.ExportDefaultDeclaration:
|
|
3038
3090
|
return node.declaration != null && typedFunction(node.declaration);
|
|
3039
|
-
case
|
|
3040
|
-
case
|
|
3091
|
+
case AST_NODE_TYPES13.FunctionDeclaration:
|
|
3092
|
+
case AST_NODE_TYPES13.TSDeclareFunction:
|
|
3041
3093
|
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3042
|
-
case
|
|
3094
|
+
case AST_NODE_TYPES13.VariableDeclaration: {
|
|
3043
3095
|
const init = node.declarations[0]?.init;
|
|
3044
|
-
return init != null && (init.type ===
|
|
3096
|
+
return init != null && (init.type === AST_NODE_TYPES13.ArrowFunctionExpression || init.type === AST_NODE_TYPES13.FunctionExpression) && init.returnType != null && init.params.every(annotatedParameter);
|
|
3045
3097
|
}
|
|
3046
|
-
case
|
|
3098
|
+
case AST_NODE_TYPES13.MethodDefinition:
|
|
3047
3099
|
return node.value.returnType != null && node.value.params.every(annotatedParameter);
|
|
3048
|
-
case
|
|
3100
|
+
case AST_NODE_TYPES13.TSMethodSignature:
|
|
3049
3101
|
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3050
3102
|
default:
|
|
3051
3103
|
return false;
|
|
@@ -3055,7 +3107,7 @@ function documentsTypedFunction(sourceCode, comment) {
|
|
|
3055
3107
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3056
3108
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return false;
|
|
3057
3109
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3058
|
-
while (node != null && node.type !==
|
|
3110
|
+
while (node != null && node.type !== AST_NODE_TYPES13.Program) {
|
|
3059
3111
|
if (typedFunction(node)) return true;
|
|
3060
3112
|
node = node.parent ?? null;
|
|
3061
3113
|
}
|
|
@@ -3118,15 +3170,15 @@ var no_offset_pagination_default = createRule({
|
|
|
3118
3170
|
});
|
|
3119
3171
|
|
|
3120
3172
|
// src/rules/no-positional-tuple-return.ts
|
|
3121
|
-
import { AST_NODE_TYPES as
|
|
3173
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14 } from "@typescript-eslint/utils";
|
|
3122
3174
|
var MIN_ELEMENTS = 2;
|
|
3123
3175
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
3124
3176
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
3125
3177
|
function tupleReturnType(node) {
|
|
3126
|
-
if (node.type ===
|
|
3178
|
+
if (node.type === AST_NODE_TYPES14.TSTupleType) {
|
|
3127
3179
|
return node;
|
|
3128
3180
|
}
|
|
3129
|
-
if (node.type ===
|
|
3181
|
+
if (node.type === AST_NODE_TYPES14.TSTypeReference && node.typeName.type === AST_NODE_TYPES14.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
3130
3182
|
const argument = node.typeArguments?.params[0];
|
|
3131
3183
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
3132
3184
|
}
|
|
@@ -3140,30 +3192,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
3140
3192
|
if (elements.length < MIN_ELEMENTS) {
|
|
3141
3193
|
return true;
|
|
3142
3194
|
}
|
|
3143
|
-
if (elements.some((element) => element.type ===
|
|
3195
|
+
if (elements.some((element) => element.type === AST_NODE_TYPES14.TSRestType)) {
|
|
3144
3196
|
return true;
|
|
3145
3197
|
}
|
|
3146
|
-
if (elements.some((element) => element.type ===
|
|
3198
|
+
if (elements.some((element) => element.type === AST_NODE_TYPES14.TSNamedTupleMember)) {
|
|
3147
3199
|
return true;
|
|
3148
3200
|
}
|
|
3149
|
-
if (elements[0]?.type ===
|
|
3201
|
+
if (elements[0]?.type === AST_NODE_TYPES14.TSLiteralType) {
|
|
3150
3202
|
return true;
|
|
3151
3203
|
}
|
|
3152
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type ===
|
|
3204
|
+
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === AST_NODE_TYPES14.TSFunctionType)) {
|
|
3153
3205
|
return true;
|
|
3154
3206
|
}
|
|
3155
3207
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
3156
3208
|
return texts.size === 1;
|
|
3157
3209
|
}
|
|
3158
3210
|
function functionName(node) {
|
|
3159
|
-
if (node.type ===
|
|
3211
|
+
if (node.type === AST_NODE_TYPES14.FunctionDeclaration) {
|
|
3160
3212
|
return node.id?.name ?? null;
|
|
3161
3213
|
}
|
|
3162
3214
|
const parent = node.parent;
|
|
3163
|
-
if (parent?.type ===
|
|
3215
|
+
if (parent?.type === AST_NODE_TYPES14.VariableDeclarator && parent.id.type === AST_NODE_TYPES14.Identifier) {
|
|
3164
3216
|
return parent.id.name;
|
|
3165
3217
|
}
|
|
3166
|
-
if ((parent?.type ===
|
|
3218
|
+
if ((parent?.type === AST_NODE_TYPES14.MethodDefinition || parent?.type === AST_NODE_TYPES14.PropertyDefinition || parent?.type === AST_NODE_TYPES14.Property) && parent.key.type === AST_NODE_TYPES14.Identifier) {
|
|
3167
3219
|
return parent.key.name;
|
|
3168
3220
|
}
|
|
3169
3221
|
return null;
|
|
@@ -3171,7 +3223,7 @@ function functionName(node) {
|
|
|
3171
3223
|
function isInlineExported(node) {
|
|
3172
3224
|
for (let current = node; current != null; current = current.parent) {
|
|
3173
3225
|
const parent = current.parent;
|
|
3174
|
-
if (parent?.type ===
|
|
3226
|
+
if (parent?.type === AST_NODE_TYPES14.ExportNamedDeclaration || parent?.type === AST_NODE_TYPES14.ExportDefaultDeclaration) {
|
|
3175
3227
|
return true;
|
|
3176
3228
|
}
|
|
3177
3229
|
}
|
|
@@ -3180,18 +3232,18 @@ function isInlineExported(node) {
|
|
|
3180
3232
|
function moduleScopeBindingName(node) {
|
|
3181
3233
|
let current = node;
|
|
3182
3234
|
let child = node;
|
|
3183
|
-
while (current.parent != null && current.parent.type !==
|
|
3235
|
+
while (current.parent != null && current.parent.type !== AST_NODE_TYPES14.Program) {
|
|
3184
3236
|
child = current;
|
|
3185
3237
|
current = current.parent;
|
|
3186
3238
|
}
|
|
3187
|
-
if (current.parent?.type !==
|
|
3239
|
+
if (current.parent?.type !== AST_NODE_TYPES14.Program) {
|
|
3188
3240
|
return null;
|
|
3189
3241
|
}
|
|
3190
|
-
if (current.type ===
|
|
3242
|
+
if (current.type === AST_NODE_TYPES14.FunctionDeclaration || current.type === AST_NODE_TYPES14.ClassDeclaration) {
|
|
3191
3243
|
return current.id?.name ?? null;
|
|
3192
3244
|
}
|
|
3193
|
-
if (current.type ===
|
|
3194
|
-
if (child.type !==
|
|
3245
|
+
if (current.type === AST_NODE_TYPES14.VariableDeclaration) {
|
|
3246
|
+
if (child.type !== AST_NODE_TYPES14.VariableDeclarator || child.id.type !== AST_NODE_TYPES14.Identifier) {
|
|
3195
3247
|
return null;
|
|
3196
3248
|
}
|
|
3197
3249
|
return child.id.name;
|
|
@@ -3201,19 +3253,19 @@ function moduleScopeBindingName(node) {
|
|
|
3201
3253
|
function specifierExportedNames(program) {
|
|
3202
3254
|
const names = /* @__PURE__ */ new Set();
|
|
3203
3255
|
for (const statement of program.body) {
|
|
3204
|
-
if (statement.type ===
|
|
3256
|
+
if (statement.type === AST_NODE_TYPES14.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
3205
3257
|
for (const specifier of statement.specifiers) {
|
|
3206
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
3258
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES14.Identifier) {
|
|
3207
3259
|
names.add(specifier.local.name);
|
|
3208
3260
|
}
|
|
3209
3261
|
}
|
|
3210
3262
|
continue;
|
|
3211
3263
|
}
|
|
3212
|
-
if (statement.type ===
|
|
3264
|
+
if (statement.type === AST_NODE_TYPES14.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES14.Identifier) {
|
|
3213
3265
|
names.add(statement.declaration.name);
|
|
3214
3266
|
continue;
|
|
3215
3267
|
}
|
|
3216
|
-
if (statement.type ===
|
|
3268
|
+
if (statement.type === AST_NODE_TYPES14.TSExportAssignment && statement.expression.type === AST_NODE_TYPES14.Identifier) {
|
|
3217
3269
|
names.add(statement.expression.name);
|
|
3218
3270
|
}
|
|
3219
3271
|
}
|
|
@@ -3352,7 +3404,7 @@ var no_raw_env_default = createRule({
|
|
|
3352
3404
|
});
|
|
3353
3405
|
|
|
3354
3406
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
3355
|
-
import { AST_NODE_TYPES as
|
|
3407
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15 } from "@typescript-eslint/utils";
|
|
3356
3408
|
var DEFAULT_ALLOW = [
|
|
3357
3409
|
"[\\\\/]clients?[\\\\/]",
|
|
3358
3410
|
"-client\\.[cm]?[jt]sx?$",
|
|
@@ -3394,7 +3446,7 @@ function identifierLikeName(node) {
|
|
|
3394
3446
|
}
|
|
3395
3447
|
function isConstructedArgumentHandoff(node) {
|
|
3396
3448
|
const [first] = node.arguments;
|
|
3397
|
-
return node.arguments.length === 1 && first !== void 0 && first.type ===
|
|
3449
|
+
return node.arguments.length === 1 && first !== void 0 && first.type === AST_NODE_TYPES15.NewExpression;
|
|
3398
3450
|
}
|
|
3399
3451
|
function isPresignedUrlTransfer(node) {
|
|
3400
3452
|
const first = node.arguments[0];
|
|
@@ -3463,9 +3515,9 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
3463
3515
|
});
|
|
3464
3516
|
|
|
3465
3517
|
// src/rules/no-restricted-library-load.ts
|
|
3466
|
-
import { AST_NODE_TYPES as
|
|
3518
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES16, ASTUtils as ASTUtils2 } from "@typescript-eslint/utils";
|
|
3467
3519
|
function literalModule(node) {
|
|
3468
|
-
return node?.type ===
|
|
3520
|
+
return node?.type === AST_NODE_TYPES16.Literal && typeof node.value === "string" ? node.value : null;
|
|
3469
3521
|
}
|
|
3470
3522
|
function matchesModule(source, module) {
|
|
3471
3523
|
return source === module || source.startsWith(`${module}/`);
|
|
@@ -3537,9 +3589,9 @@ var no_restricted_library_load_default = createRule({
|
|
|
3537
3589
|
},
|
|
3538
3590
|
CallExpression(node) {
|
|
3539
3591
|
let requireIdentifier = null;
|
|
3540
|
-
if (node.callee.type ===
|
|
3592
|
+
if (node.callee.type === AST_NODE_TYPES16.Identifier && node.callee.name === "require") {
|
|
3541
3593
|
requireIdentifier = node.callee;
|
|
3542
|
-
} else if (node.callee.type ===
|
|
3594
|
+
} else if (node.callee.type === AST_NODE_TYPES16.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES16.Identifier && node.callee.object.name === "require" && node.callee.property.type === AST_NODE_TYPES16.Identifier && node.callee.property.name === "resolve") {
|
|
3543
3595
|
requireIdentifier = node.callee.object;
|
|
3544
3596
|
}
|
|
3545
3597
|
if (requireIdentifier === null || !isUnshadowedRequire(requireIdentifier)) return;
|
|
@@ -3547,7 +3599,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
3547
3599
|
if (source !== null) report(node.arguments[0], source);
|
|
3548
3600
|
},
|
|
3549
3601
|
TSImportEqualsDeclaration(node) {
|
|
3550
|
-
if (node.moduleReference.type !==
|
|
3602
|
+
if (node.moduleReference.type !== AST_NODE_TYPES16.TSExternalModuleReference) return;
|
|
3551
3603
|
const source = literalModule(node.moduleReference.expression);
|
|
3552
3604
|
if (source !== null) report(node.moduleReference.expression, source);
|
|
3553
3605
|
}
|
|
@@ -3556,16 +3608,16 @@ var no_restricted_library_load_default = createRule({
|
|
|
3556
3608
|
});
|
|
3557
3609
|
|
|
3558
3610
|
// src/rules/no-repeated-string-literal.ts
|
|
3559
|
-
import { AST_NODE_TYPES as
|
|
3611
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES17 } from "@typescript-eslint/utils";
|
|
3560
3612
|
var MIN_LENGTH = 40;
|
|
3561
3613
|
var MIN_DISTINCT_SCOPES = 2;
|
|
3562
3614
|
var PREVIEW_LENGTH = 40;
|
|
3563
3615
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
3564
3616
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
3565
3617
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3618
|
+
AST_NODE_TYPES17.FunctionDeclaration,
|
|
3619
|
+
AST_NODE_TYPES17.FunctionExpression,
|
|
3620
|
+
AST_NODE_TYPES17.ArrowFunctionExpression
|
|
3569
3621
|
]);
|
|
3570
3622
|
function isStructured(value) {
|
|
3571
3623
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -3587,8 +3639,8 @@ function isScaffolding(node) {
|
|
|
3587
3639
|
if (parent === void 0) {
|
|
3588
3640
|
return true;
|
|
3589
3641
|
}
|
|
3590
|
-
const isRequireSource = parent.type ===
|
|
3591
|
-
return parent.type ===
|
|
3642
|
+
const isRequireSource = parent.type === AST_NODE_TYPES17.CallExpression && parent.callee.type === AST_NODE_TYPES17.Identifier && parent.callee.name === "require";
|
|
3643
|
+
return parent.type === AST_NODE_TYPES17.ImportDeclaration || parent.type === AST_NODE_TYPES17.ImportExpression || parent.type === AST_NODE_TYPES17.ExportNamedDeclaration || parent.type === AST_NODE_TYPES17.ExportAllDeclaration || parent.type === AST_NODE_TYPES17.TSImportType || parent.type === AST_NODE_TYPES17.JSXAttribute || parent.type === AST_NODE_TYPES17.TSLiteralType || isRequireSource;
|
|
3592
3644
|
}
|
|
3593
3645
|
var no_repeated_string_literal_default = createRule({
|
|
3594
3646
|
name: "no-repeated-string-literal",
|
|
@@ -3628,7 +3680,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3628
3680
|
}
|
|
3629
3681
|
},
|
|
3630
3682
|
TemplateLiteral(node) {
|
|
3631
|
-
if (node.parent.type ===
|
|
3683
|
+
if (node.parent.type === AST_NODE_TYPES17.TaggedTemplateExpression) {
|
|
3632
3684
|
return;
|
|
3633
3685
|
}
|
|
3634
3686
|
const [only] = node.quasis;
|
|
@@ -3662,7 +3714,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3662
3714
|
});
|
|
3663
3715
|
|
|
3664
3716
|
// src/rules/no-restated-comment.ts
|
|
3665
|
-
import { AST_NODE_TYPES as
|
|
3717
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES18 } from "@typescript-eslint/utils";
|
|
3666
3718
|
var MAX_WORDS = 8;
|
|
3667
3719
|
var MIN_CONTENT_TOKENS = 2;
|
|
3668
3720
|
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;
|
|
@@ -3715,7 +3767,7 @@ var no_restated_comment_default = createRule({
|
|
|
3715
3767
|
function labelsASiblingRun(comment) {
|
|
3716
3768
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3717
3769
|
if (token === null) return false;
|
|
3718
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
3770
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== AST_NODE_TYPES18.Program; node = node.parent) {
|
|
3719
3771
|
if (headsSiblingRun(node)) return true;
|
|
3720
3772
|
}
|
|
3721
3773
|
return false;
|
|
@@ -3775,7 +3827,7 @@ var no_restated_comment_default = createRule({
|
|
|
3775
3827
|
});
|
|
3776
3828
|
|
|
3777
3829
|
// src/rules/no-restated-jsdoc.ts
|
|
3778
|
-
import { AST_NODE_TYPES as
|
|
3830
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES19 } from "@typescript-eslint/utils";
|
|
3779
3831
|
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
3780
3832
|
"arg",
|
|
3781
3833
|
"argument",
|
|
@@ -3829,30 +3881,30 @@ function declarationNames(node) {
|
|
|
3829
3881
|
switch (node.type) {
|
|
3830
3882
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
3831
3883
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
3832
|
-
case
|
|
3833
|
-
case
|
|
3884
|
+
case AST_NODE_TYPES19.ExportNamedDeclaration:
|
|
3885
|
+
case AST_NODE_TYPES19.ExportDefaultDeclaration:
|
|
3834
3886
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
3835
|
-
case
|
|
3836
|
-
case
|
|
3887
|
+
case AST_NODE_TYPES19.FunctionDeclaration:
|
|
3888
|
+
case AST_NODE_TYPES19.TSDeclareFunction:
|
|
3837
3889
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
3838
|
-
case
|
|
3839
|
-
case
|
|
3840
|
-
case
|
|
3841
|
-
case
|
|
3890
|
+
case AST_NODE_TYPES19.ClassDeclaration:
|
|
3891
|
+
case AST_NODE_TYPES19.TSInterfaceDeclaration:
|
|
3892
|
+
case AST_NODE_TYPES19.TSTypeAliasDeclaration:
|
|
3893
|
+
case AST_NODE_TYPES19.TSEnumDeclaration:
|
|
3842
3894
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
3843
|
-
case
|
|
3895
|
+
case AST_NODE_TYPES19.VariableDeclaration: {
|
|
3844
3896
|
const declarator = node.declarations[0];
|
|
3845
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
3897
|
+
if (declarator === void 0 || declarator.id.type !== AST_NODE_TYPES19.Identifier) return null;
|
|
3846
3898
|
const init = declarator.init;
|
|
3847
|
-
const params = init != null && (init.type ===
|
|
3899
|
+
const params = init != null && (init.type === AST_NODE_TYPES19.ArrowFunctionExpression || init.type === AST_NODE_TYPES19.FunctionExpression) ? paramNames(init.params) : [];
|
|
3848
3900
|
return { name: declarator.id.name, params };
|
|
3849
3901
|
}
|
|
3850
|
-
case
|
|
3851
|
-
case
|
|
3852
|
-
case
|
|
3853
|
-
case
|
|
3854
|
-
if (node.key.type !==
|
|
3855
|
-
const params = node.type ===
|
|
3902
|
+
case AST_NODE_TYPES19.MethodDefinition:
|
|
3903
|
+
case AST_NODE_TYPES19.PropertyDefinition:
|
|
3904
|
+
case AST_NODE_TYPES19.TSMethodSignature:
|
|
3905
|
+
case AST_NODE_TYPES19.TSPropertySignature: {
|
|
3906
|
+
if (node.key.type !== AST_NODE_TYPES19.Identifier) return null;
|
|
3907
|
+
const params = node.type === AST_NODE_TYPES19.MethodDefinition ? paramNames(node.value.params) : node.type === AST_NODE_TYPES19.TSMethodSignature ? paramNames(node.params) : [];
|
|
3856
3908
|
return { name: node.key.name, params };
|
|
3857
3909
|
}
|
|
3858
3910
|
default:
|
|
@@ -3862,9 +3914,9 @@ function declarationNames(node) {
|
|
|
3862
3914
|
function paramNames(params) {
|
|
3863
3915
|
const names = [];
|
|
3864
3916
|
for (const param of params) {
|
|
3865
|
-
const target = param.type ===
|
|
3866
|
-
if (target.type ===
|
|
3867
|
-
else if (target.type ===
|
|
3917
|
+
const target = param.type === AST_NODE_TYPES19.AssignmentPattern ? param.left : param;
|
|
3918
|
+
if (target.type === AST_NODE_TYPES19.Identifier) names.push(target.name);
|
|
3919
|
+
else if (target.type === AST_NODE_TYPES19.TSParameterProperty) continue;
|
|
3868
3920
|
}
|
|
3869
3921
|
return names;
|
|
3870
3922
|
}
|
|
@@ -3906,7 +3958,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3906
3958
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
3907
3959
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3908
3960
|
let declaration = null;
|
|
3909
|
-
while (node != null && node.type !==
|
|
3961
|
+
while (node != null && node.type !== AST_NODE_TYPES19.Program) {
|
|
3910
3962
|
declaration = declarationNames(node);
|
|
3911
3963
|
if (declaration !== null) break;
|
|
3912
3964
|
node = node.parent ?? null;
|
|
@@ -4365,12 +4417,12 @@ var no_select_star_default = createRule({
|
|
|
4365
4417
|
});
|
|
4366
4418
|
|
|
4367
4419
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
4368
|
-
import { AST_NODE_TYPES as
|
|
4420
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES20 } from "@typescript-eslint/utils";
|
|
4369
4421
|
function sentinelKind(arg) {
|
|
4370
4422
|
if (arg === null) {
|
|
4371
4423
|
return null;
|
|
4372
4424
|
}
|
|
4373
|
-
if (arg.type ===
|
|
4425
|
+
if (arg.type === AST_NODE_TYPES20.Literal) {
|
|
4374
4426
|
if (arg.value === null) {
|
|
4375
4427
|
return "nullish";
|
|
4376
4428
|
}
|
|
@@ -4382,13 +4434,13 @@ function sentinelKind(arg) {
|
|
|
4382
4434
|
}
|
|
4383
4435
|
return null;
|
|
4384
4436
|
}
|
|
4385
|
-
if (arg.type ===
|
|
4437
|
+
if (arg.type === AST_NODE_TYPES20.Identifier && arg.name === "undefined") {
|
|
4386
4438
|
return "nullish";
|
|
4387
4439
|
}
|
|
4388
|
-
if (arg.type ===
|
|
4440
|
+
if (arg.type === AST_NODE_TYPES20.ArrayExpression) {
|
|
4389
4441
|
return "array";
|
|
4390
4442
|
}
|
|
4391
|
-
if (arg.type ===
|
|
4443
|
+
if (arg.type === AST_NODE_TYPES20.ObjectExpression) {
|
|
4392
4444
|
return "object";
|
|
4393
4445
|
}
|
|
4394
4446
|
return null;
|
|
@@ -4397,25 +4449,25 @@ function isSentinelArgument(arg) {
|
|
|
4397
4449
|
if (arg === null) {
|
|
4398
4450
|
return false;
|
|
4399
4451
|
}
|
|
4400
|
-
if (arg.type ===
|
|
4452
|
+
if (arg.type === AST_NODE_TYPES20.Literal && arg.value === null) {
|
|
4401
4453
|
return true;
|
|
4402
4454
|
}
|
|
4403
|
-
if (arg.type ===
|
|
4455
|
+
if (arg.type === AST_NODE_TYPES20.Literal && arg.value === false) {
|
|
4404
4456
|
return true;
|
|
4405
4457
|
}
|
|
4406
|
-
if (arg.type ===
|
|
4458
|
+
if (arg.type === AST_NODE_TYPES20.Identifier && arg.name === "undefined") {
|
|
4407
4459
|
return true;
|
|
4408
4460
|
}
|
|
4409
|
-
if (arg.type ===
|
|
4461
|
+
if (arg.type === AST_NODE_TYPES20.ArrayExpression && arg.elements.length === 0) {
|
|
4410
4462
|
return true;
|
|
4411
4463
|
}
|
|
4412
|
-
if (arg.type ===
|
|
4464
|
+
if (arg.type === AST_NODE_TYPES20.ObjectExpression && arg.properties.length === 0) {
|
|
4413
4465
|
return true;
|
|
4414
4466
|
}
|
|
4415
4467
|
return false;
|
|
4416
4468
|
}
|
|
4417
4469
|
function isFunctionNode(node) {
|
|
4418
|
-
return node.type ===
|
|
4470
|
+
return node.type === AST_NODE_TYPES20.FunctionDeclaration || node.type === AST_NODE_TYPES20.FunctionExpression || node.type === AST_NODE_TYPES20.ArrowFunctionExpression;
|
|
4419
4471
|
}
|
|
4420
4472
|
function isNode3(value) {
|
|
4421
4473
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -4455,24 +4507,24 @@ function walkWithinScope(node, visit) {
|
|
|
4455
4507
|
function containsThrow(node) {
|
|
4456
4508
|
return walkWithinScope(
|
|
4457
4509
|
node,
|
|
4458
|
-
(current) => current.type ===
|
|
4510
|
+
(current) => current.type === AST_NODE_TYPES20.ThrowStatement
|
|
4459
4511
|
);
|
|
4460
4512
|
}
|
|
4461
4513
|
function bindsName(param, name) {
|
|
4462
4514
|
switch (param.type) {
|
|
4463
|
-
case
|
|
4515
|
+
case AST_NODE_TYPES20.Identifier:
|
|
4464
4516
|
return param.name === name;
|
|
4465
|
-
case
|
|
4517
|
+
case AST_NODE_TYPES20.AssignmentPattern:
|
|
4466
4518
|
return bindsName(param.left, name);
|
|
4467
|
-
case
|
|
4519
|
+
case AST_NODE_TYPES20.RestElement:
|
|
4468
4520
|
return bindsName(param.argument, name);
|
|
4469
|
-
case
|
|
4521
|
+
case AST_NODE_TYPES20.ArrayPattern:
|
|
4470
4522
|
return param.elements.some(
|
|
4471
4523
|
(element) => element !== null && bindsName(element, name)
|
|
4472
4524
|
);
|
|
4473
|
-
case
|
|
4525
|
+
case AST_NODE_TYPES20.ObjectPattern:
|
|
4474
4526
|
return param.properties.some(
|
|
4475
|
-
(property) => property.type ===
|
|
4527
|
+
(property) => property.type === AST_NODE_TYPES20.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
4476
4528
|
);
|
|
4477
4529
|
default:
|
|
4478
4530
|
return false;
|
|
@@ -4487,7 +4539,7 @@ function subtreeReadsName(node, name) {
|
|
|
4487
4539
|
if (found) {
|
|
4488
4540
|
return;
|
|
4489
4541
|
}
|
|
4490
|
-
if (current.type ===
|
|
4542
|
+
if (current.type === AST_NODE_TYPES20.Identifier && current.name === name) {
|
|
4491
4543
|
found = true;
|
|
4492
4544
|
return;
|
|
4493
4545
|
}
|
|
@@ -4498,10 +4550,10 @@ function subtreeReadsName(node, name) {
|
|
|
4498
4550
|
if (key === "parent") {
|
|
4499
4551
|
continue;
|
|
4500
4552
|
}
|
|
4501
|
-
if (key === "key" && current.type ===
|
|
4553
|
+
if (key === "key" && current.type === AST_NODE_TYPES20.Property && !current.computed) {
|
|
4502
4554
|
continue;
|
|
4503
4555
|
}
|
|
4504
|
-
if (key === "property" && current.type ===
|
|
4556
|
+
if (key === "property" && current.type === AST_NODE_TYPES20.MemberExpression && !current.computed) {
|
|
4505
4557
|
continue;
|
|
4506
4558
|
}
|
|
4507
4559
|
const value = current[key];
|
|
@@ -4534,10 +4586,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4534
4586
|
"URLPattern"
|
|
4535
4587
|
]);
|
|
4536
4588
|
function isParseShapedNode(node) {
|
|
4537
|
-
if (node.type ===
|
|
4589
|
+
if (node.type === AST_NODE_TYPES20.CallExpression && node.callee.type === AST_NODE_TYPES20.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES20.Identifier) {
|
|
4538
4590
|
return node.callee.property.name === "parse";
|
|
4539
4591
|
}
|
|
4540
|
-
if (node.type ===
|
|
4592
|
+
if (node.type === AST_NODE_TYPES20.NewExpression && node.callee.type === AST_NODE_TYPES20.Identifier) {
|
|
4541
4593
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
4542
4594
|
}
|
|
4543
4595
|
return false;
|
|
@@ -4548,10 +4600,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
4548
4600
|
"arrayBuffer"
|
|
4549
4601
|
]);
|
|
4550
4602
|
function isBodyDecodeNode(node) {
|
|
4551
|
-
return node.type ===
|
|
4603
|
+
return node.type === AST_NODE_TYPES20.CallExpression && node.callee.type === AST_NODE_TYPES20.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES20.Identifier && BODY_DECODE_METHODS.has(node.callee.property.name);
|
|
4552
4604
|
}
|
|
4553
4605
|
function returnsMatching(stmt, predicate) {
|
|
4554
|
-
return stmt.type ===
|
|
4606
|
+
return stmt.type === AST_NODE_TYPES20.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
4555
4607
|
}
|
|
4556
4608
|
function enclosingReturnTypeNode(node) {
|
|
4557
4609
|
let current = node.parent;
|
|
@@ -4569,11 +4621,11 @@ function enclosingFunctionName(node) {
|
|
|
4569
4621
|
let current = node.parent;
|
|
4570
4622
|
while (current !== void 0 && current !== null) {
|
|
4571
4623
|
if (isFunctionNode(current)) {
|
|
4572
|
-
if ("id" in current && isNode3(current.id) && current.id.type ===
|
|
4624
|
+
if ("id" in current && isNode3(current.id) && current.id.type === AST_NODE_TYPES20.Identifier) {
|
|
4573
4625
|
return current.id.name;
|
|
4574
4626
|
}
|
|
4575
4627
|
const parent = current.parent;
|
|
4576
|
-
if (parent?.type ===
|
|
4628
|
+
if (parent?.type === AST_NODE_TYPES20.VariableDeclarator && parent.id.type === AST_NODE_TYPES20.Identifier) {
|
|
4577
4629
|
return parent.id.name;
|
|
4578
4630
|
}
|
|
4579
4631
|
return null;
|
|
@@ -4594,10 +4646,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
4594
4646
|
return false;
|
|
4595
4647
|
}
|
|
4596
4648
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
4597
|
-
if (declared?.type ===
|
|
4649
|
+
if (declared?.type === AST_NODE_TYPES20.TSTypeReference && declared.typeName.type === AST_NODE_TYPES20.Identifier && declared.typeName.name === "Promise") {
|
|
4598
4650
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
4599
4651
|
}
|
|
4600
|
-
return declared?.type ===
|
|
4652
|
+
return declared?.type === AST_NODE_TYPES20.TSBooleanKeyword;
|
|
4601
4653
|
}
|
|
4602
4654
|
function tryReturnsSafeParse(catchNode) {
|
|
4603
4655
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -4613,7 +4665,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
4613
4665
|
function enclosingFunctionBody(node) {
|
|
4614
4666
|
let current = node.parent;
|
|
4615
4667
|
while (current !== void 0 && current !== null) {
|
|
4616
|
-
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type ===
|
|
4668
|
+
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === AST_NODE_TYPES20.BlockStatement) {
|
|
4617
4669
|
return current.body;
|
|
4618
4670
|
}
|
|
4619
4671
|
current = current.parent;
|
|
@@ -4626,7 +4678,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
4626
4678
|
return false;
|
|
4627
4679
|
}
|
|
4628
4680
|
return walkWithinScope(functionBody, (current) => {
|
|
4629
|
-
if (current.type !==
|
|
4681
|
+
if (current.type !== AST_NODE_TYPES20.ReturnStatement) {
|
|
4630
4682
|
return false;
|
|
4631
4683
|
}
|
|
4632
4684
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -4645,13 +4697,13 @@ function returnedSentinelKinds(arg) {
|
|
|
4645
4697
|
kinds.add(direct);
|
|
4646
4698
|
return kinds;
|
|
4647
4699
|
}
|
|
4648
|
-
if (arg.type ===
|
|
4700
|
+
if (arg.type === AST_NODE_TYPES20.ConditionalExpression) {
|
|
4649
4701
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
4650
4702
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
4651
4703
|
kinds.add(nested);
|
|
4652
4704
|
}
|
|
4653
4705
|
}
|
|
4654
|
-
} else if (arg.type ===
|
|
4706
|
+
} else if (arg.type === AST_NODE_TYPES20.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
4655
4707
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
4656
4708
|
kinds.add(nested);
|
|
4657
4709
|
}
|
|
@@ -4694,7 +4746,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4694
4746
|
const matcher = createLogMatcher(loggingOptions);
|
|
4695
4747
|
function logsOrReportsError(catchBody, caughtName) {
|
|
4696
4748
|
return walkWithinScope(catchBody, (current) => {
|
|
4697
|
-
if (current.type !==
|
|
4749
|
+
if (current.type !== AST_NODE_TYPES20.CallExpression) {
|
|
4698
4750
|
return false;
|
|
4699
4751
|
}
|
|
4700
4752
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -4711,7 +4763,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4711
4763
|
return;
|
|
4712
4764
|
}
|
|
4713
4765
|
const last = body2[body2.length - 1];
|
|
4714
|
-
if (last === void 0 || last.type !==
|
|
4766
|
+
if (last === void 0 || last.type !== AST_NODE_TYPES20.ReturnStatement) {
|
|
4715
4767
|
return;
|
|
4716
4768
|
}
|
|
4717
4769
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -4720,7 +4772,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4720
4772
|
if (containsThrow(node.body)) {
|
|
4721
4773
|
return;
|
|
4722
4774
|
}
|
|
4723
|
-
const caughtName = node.param?.type ===
|
|
4775
|
+
const caughtName = node.param?.type === AST_NODE_TYPES20.Identifier ? node.param.name : null;
|
|
4724
4776
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
4725
4777
|
return;
|
|
4726
4778
|
}
|
|
@@ -4747,9 +4799,9 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4747
4799
|
});
|
|
4748
4800
|
|
|
4749
4801
|
// src/rules/no-silent-promise-catch.ts
|
|
4750
|
-
import { AST_NODE_TYPES as
|
|
4802
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES21 } from "@typescript-eslint/utils";
|
|
4751
4803
|
function isBodyParseCall(node) {
|
|
4752
|
-
return node.type ===
|
|
4804
|
+
return node.type === AST_NODE_TYPES21.CallExpression && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES21.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES21.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
4753
4805
|
}
|
|
4754
4806
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
4755
4807
|
"cancel",
|
|
@@ -4764,21 +4816,21 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
4764
4816
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
4765
4817
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
4766
4818
|
function isTeardownCall(node) {
|
|
4767
|
-
return node.type ===
|
|
4819
|
+
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 && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
4768
4820
|
}
|
|
4769
4821
|
function isSilentExpression(node) {
|
|
4770
4822
|
switch (node.type) {
|
|
4771
|
-
case
|
|
4823
|
+
case AST_NODE_TYPES21.Literal:
|
|
4772
4824
|
return !("regex" in node);
|
|
4773
|
-
case
|
|
4825
|
+
case AST_NODE_TYPES21.Identifier:
|
|
4774
4826
|
return node.name === "undefined";
|
|
4775
|
-
case
|
|
4776
|
-
return node.operator === "void" && node.argument.type ===
|
|
4777
|
-
case
|
|
4827
|
+
case AST_NODE_TYPES21.UnaryExpression:
|
|
4828
|
+
return node.operator === "void" && node.argument.type === AST_NODE_TYPES21.Literal;
|
|
4829
|
+
case AST_NODE_TYPES21.ObjectExpression:
|
|
4778
4830
|
return node.properties.length === 0;
|
|
4779
|
-
case
|
|
4831
|
+
case AST_NODE_TYPES21.ArrayExpression:
|
|
4780
4832
|
return node.elements.length === 0;
|
|
4781
|
-
case
|
|
4833
|
+
case AST_NODE_TYPES21.TSAsExpression:
|
|
4782
4834
|
return isSilentExpression(node.expression);
|
|
4783
4835
|
default:
|
|
4784
4836
|
return false;
|
|
@@ -4786,7 +4838,7 @@ function isSilentExpression(node) {
|
|
|
4786
4838
|
}
|
|
4787
4839
|
function isSilentHandler(handler) {
|
|
4788
4840
|
const body2 = handler.body;
|
|
4789
|
-
if (body2.type !==
|
|
4841
|
+
if (body2.type !== AST_NODE_TYPES21.BlockStatement) {
|
|
4790
4842
|
return isSilentExpression(body2);
|
|
4791
4843
|
}
|
|
4792
4844
|
if (body2.body.length === 0) {
|
|
@@ -4794,7 +4846,7 @@ function isSilentHandler(handler) {
|
|
|
4794
4846
|
}
|
|
4795
4847
|
if (body2.body.length === 1) {
|
|
4796
4848
|
const only = body2.body[0];
|
|
4797
|
-
if (only !== void 0 && only.type ===
|
|
4849
|
+
if (only !== void 0 && only.type === AST_NODE_TYPES21.ReturnStatement) {
|
|
4798
4850
|
return only.argument === null || isSilentExpression(only.argument);
|
|
4799
4851
|
}
|
|
4800
4852
|
}
|
|
@@ -4823,7 +4875,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4823
4875
|
return true;
|
|
4824
4876
|
}
|
|
4825
4877
|
let statement = call;
|
|
4826
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
4878
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== AST_NODE_TYPES21.VariableDeclaration) {
|
|
4827
4879
|
statement = statement.parent;
|
|
4828
4880
|
}
|
|
4829
4881
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -4835,7 +4887,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4835
4887
|
};
|
|
4836
4888
|
return {
|
|
4837
4889
|
CallExpression(node) {
|
|
4838
|
-
if (node.callee.type !==
|
|
4890
|
+
if (node.callee.type !== AST_NODE_TYPES21.MemberExpression || node.callee.computed || node.callee.property.type !== AST_NODE_TYPES21.Identifier || node.callee.property.name !== "catch") {
|
|
4839
4891
|
return;
|
|
4840
4892
|
}
|
|
4841
4893
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -4844,14 +4896,14 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4844
4896
|
if (isTeardownCall(node.callee.object)) {
|
|
4845
4897
|
return;
|
|
4846
4898
|
}
|
|
4847
|
-
if (node.parent.type ===
|
|
4899
|
+
if (node.parent.type === AST_NODE_TYPES21.MemberExpression && node.parent.object === node) {
|
|
4848
4900
|
return;
|
|
4849
4901
|
}
|
|
4850
4902
|
if (node.arguments.length !== 1) {
|
|
4851
4903
|
return;
|
|
4852
4904
|
}
|
|
4853
4905
|
const handler = node.arguments[0];
|
|
4854
|
-
if (handler === void 0 || handler.type !==
|
|
4906
|
+
if (handler === void 0 || handler.type !== AST_NODE_TYPES21.ArrowFunctionExpression && handler.type !== AST_NODE_TYPES21.FunctionExpression) {
|
|
4855
4907
|
return;
|
|
4856
4908
|
}
|
|
4857
4909
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -4866,7 +4918,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4866
4918
|
});
|
|
4867
4919
|
|
|
4868
4920
|
// src/rules/no-sleep-in-test-body.ts
|
|
4869
|
-
import { AST_NODE_TYPES as
|
|
4921
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES22 } from "@typescript-eslint/utils";
|
|
4870
4922
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
4871
4923
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
4872
4924
|
"it",
|
|
@@ -4875,34 +4927,34 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
|
4875
4927
|
"afterEach"
|
|
4876
4928
|
]);
|
|
4877
4929
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4930
|
+
AST_NODE_TYPES22.FunctionDeclaration,
|
|
4931
|
+
AST_NODE_TYPES22.FunctionExpression,
|
|
4932
|
+
AST_NODE_TYPES22.ArrowFunctionExpression
|
|
4881
4933
|
]);
|
|
4882
4934
|
function isNonzeroNumericLiteral(node) {
|
|
4883
|
-
return node?.type ===
|
|
4935
|
+
return node?.type === AST_NODE_TYPES22.Literal && typeof node.value === "number" && node.value !== 0;
|
|
4884
4936
|
}
|
|
4885
4937
|
function isTimedSetTimeout(node) {
|
|
4886
|
-
return node.type ===
|
|
4938
|
+
return node.type === AST_NODE_TYPES22.CallExpression && node.callee.type === AST_NODE_TYPES22.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
4887
4939
|
}
|
|
4888
4940
|
function isPromiseSleep(node) {
|
|
4889
|
-
if (node.callee.type !==
|
|
4941
|
+
if (node.callee.type !== AST_NODE_TYPES22.Identifier || node.callee.name !== "Promise") {
|
|
4890
4942
|
return false;
|
|
4891
4943
|
}
|
|
4892
4944
|
const executor = node.arguments[0];
|
|
4893
|
-
if (executor?.type !==
|
|
4945
|
+
if (executor?.type !== AST_NODE_TYPES22.ArrowFunctionExpression && executor?.type !== AST_NODE_TYPES22.FunctionExpression) {
|
|
4894
4946
|
return false;
|
|
4895
4947
|
}
|
|
4896
4948
|
const body2 = executor.body;
|
|
4897
|
-
if (body2.type !==
|
|
4949
|
+
if (body2.type !== AST_NODE_TYPES22.BlockStatement) {
|
|
4898
4950
|
return isTimedSetTimeout(body2);
|
|
4899
4951
|
}
|
|
4900
4952
|
return body2.body.some(
|
|
4901
|
-
(stmt) => stmt.type ===
|
|
4953
|
+
(stmt) => stmt.type === AST_NODE_TYPES22.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
4902
4954
|
);
|
|
4903
4955
|
}
|
|
4904
4956
|
function isHelperSleep(node) {
|
|
4905
|
-
return node.callee.type ===
|
|
4957
|
+
return node.callee.type === AST_NODE_TYPES22.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
4906
4958
|
}
|
|
4907
4959
|
function nearestEnclosingFunction2(node) {
|
|
4908
4960
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -4910,7 +4962,7 @@ function nearestEnclosingFunction2(node) {
|
|
|
4910
4962
|
continue;
|
|
4911
4963
|
}
|
|
4912
4964
|
const grandparent = current.parent;
|
|
4913
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
4965
|
+
const isPromiseExecutor = grandparent?.type === AST_NODE_TYPES22.NewExpression && isPromiseSleep(grandparent);
|
|
4914
4966
|
if (!isPromiseExecutor) {
|
|
4915
4967
|
return current;
|
|
4916
4968
|
}
|
|
@@ -4918,23 +4970,23 @@ function nearestEnclosingFunction2(node) {
|
|
|
4918
4970
|
return null;
|
|
4919
4971
|
}
|
|
4920
4972
|
function testCallerName2(callee) {
|
|
4921
|
-
if (callee.type ===
|
|
4973
|
+
if (callee.type === AST_NODE_TYPES22.Identifier) {
|
|
4922
4974
|
return callee.name;
|
|
4923
4975
|
}
|
|
4924
|
-
if (callee.type ===
|
|
4976
|
+
if (callee.type === AST_NODE_TYPES22.MemberExpression) {
|
|
4925
4977
|
return testCallerName2(callee.object);
|
|
4926
4978
|
}
|
|
4927
|
-
if (callee.type ===
|
|
4979
|
+
if (callee.type === AST_NODE_TYPES22.CallExpression) {
|
|
4928
4980
|
return testCallerName2(callee.callee);
|
|
4929
4981
|
}
|
|
4930
|
-
if (callee.type ===
|
|
4982
|
+
if (callee.type === AST_NODE_TYPES22.TaggedTemplateExpression) {
|
|
4931
4983
|
return testCallerName2(callee.tag);
|
|
4932
4984
|
}
|
|
4933
4985
|
return null;
|
|
4934
4986
|
}
|
|
4935
4987
|
function isTestBody2(fn) {
|
|
4936
4988
|
const call = fn.parent;
|
|
4937
|
-
if (call?.type !==
|
|
4989
|
+
if (call?.type !== AST_NODE_TYPES22.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
4938
4990
|
return false;
|
|
4939
4991
|
}
|
|
4940
4992
|
const name = testCallerName2(call.callee);
|
|
@@ -4980,7 +5032,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
4980
5032
|
});
|
|
4981
5033
|
|
|
4982
5034
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
4983
|
-
import { AST_NODE_TYPES as
|
|
5035
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES23 } from "@typescript-eslint/utils";
|
|
4984
5036
|
var DEFAULT_METHODS2 = [
|
|
4985
5037
|
"prepare",
|
|
4986
5038
|
"put",
|
|
@@ -4999,7 +5051,7 @@ function compile2(patterns) {
|
|
|
4999
5051
|
}
|
|
5000
5052
|
function storageMethodName(node, methods) {
|
|
5001
5053
|
const callee = node.callee;
|
|
5002
|
-
if (callee.type !==
|
|
5054
|
+
if (callee.type !== AST_NODE_TYPES23.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES23.Identifier) {
|
|
5003
5055
|
return null;
|
|
5004
5056
|
}
|
|
5005
5057
|
const name = callee.property.name;
|
|
@@ -5213,7 +5265,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
5213
5265
|
});
|
|
5214
5266
|
|
|
5215
5267
|
// src/rules/no-tautological-expect.ts
|
|
5216
|
-
import { AST_NODE_TYPES as
|
|
5268
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES24 } from "@typescript-eslint/utils";
|
|
5217
5269
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
5218
5270
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
5219
5271
|
"toBeDefined",
|
|
@@ -5227,17 +5279,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
5227
5279
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
5228
5280
|
function isLiteral(node) {
|
|
5229
5281
|
switch (node.type) {
|
|
5230
|
-
case
|
|
5282
|
+
case AST_NODE_TYPES24.Literal:
|
|
5231
5283
|
return true;
|
|
5232
|
-
case
|
|
5284
|
+
case AST_NODE_TYPES24.TemplateLiteral:
|
|
5233
5285
|
return node.expressions.length === 0;
|
|
5234
|
-
case
|
|
5286
|
+
case AST_NODE_TYPES24.UnaryExpression:
|
|
5235
5287
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
5236
|
-
case
|
|
5288
|
+
case AST_NODE_TYPES24.ArrayExpression:
|
|
5237
5289
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
5238
|
-
case
|
|
5290
|
+
case AST_NODE_TYPES24.ObjectExpression:
|
|
5239
5291
|
return node.properties.every(
|
|
5240
|
-
(property) => property.type ===
|
|
5292
|
+
(property) => property.type === AST_NODE_TYPES24.Property && !property.computed && isLiteral(property.value)
|
|
5241
5293
|
);
|
|
5242
5294
|
default:
|
|
5243
5295
|
return false;
|
|
@@ -5245,7 +5297,7 @@ function isLiteral(node) {
|
|
|
5245
5297
|
}
|
|
5246
5298
|
function expectOperand(callee) {
|
|
5247
5299
|
const receiver = callee.object;
|
|
5248
|
-
if (receiver.type !==
|
|
5300
|
+
if (receiver.type !== AST_NODE_TYPES24.CallExpression || receiver.callee.type !== AST_NODE_TYPES24.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
5249
5301
|
return null;
|
|
5250
5302
|
}
|
|
5251
5303
|
return receiver.arguments[0] ?? null;
|
|
@@ -5275,10 +5327,10 @@ var no_tautological_expect_default = createRule({
|
|
|
5275
5327
|
return {
|
|
5276
5328
|
CallExpression(node) {
|
|
5277
5329
|
const callee = node.callee;
|
|
5278
|
-
if (callee.type !==
|
|
5330
|
+
if (callee.type !== AST_NODE_TYPES24.MemberExpression || callee.computed) {
|
|
5279
5331
|
return;
|
|
5280
5332
|
}
|
|
5281
|
-
if (callee.property.type !==
|
|
5333
|
+
if (callee.property.type !== AST_NODE_TYPES24.Identifier) {
|
|
5282
5334
|
return;
|
|
5283
5335
|
}
|
|
5284
5336
|
const matcher = callee.property.name;
|
|
@@ -5472,10 +5524,10 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5472
5524
|
});
|
|
5473
5525
|
|
|
5474
5526
|
// src/rules/no-declaration-comment-wall.ts
|
|
5475
|
-
import { AST_NODE_TYPES as
|
|
5527
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES26 } from "@typescript-eslint/utils";
|
|
5476
5528
|
|
|
5477
5529
|
// src/rules/_comment-wall.ts
|
|
5478
|
-
import { AST_NODE_TYPES as
|
|
5530
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES25 } from "@typescript-eslint/utils";
|
|
5479
5531
|
var WALL_DEFAULTS = {
|
|
5480
5532
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5481
5533
|
minCommentedMembers: 3,
|
|
@@ -5579,10 +5631,10 @@ function isWall(members, commented, restated, options) {
|
|
|
5579
5631
|
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5580
5632
|
}
|
|
5581
5633
|
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5634
|
+
AST_NODE_TYPES25.FunctionExpression,
|
|
5635
|
+
AST_NODE_TYPES25.ArrowFunctionExpression,
|
|
5636
|
+
AST_NODE_TYPES25.ObjectExpression,
|
|
5637
|
+
AST_NODE_TYPES25.ArrayExpression
|
|
5586
5638
|
]);
|
|
5587
5639
|
function declarationRange(member) {
|
|
5588
5640
|
const body2 = bodyOf(member);
|
|
@@ -5590,10 +5642,10 @@ function declarationRange(member) {
|
|
|
5590
5642
|
return [member.range[0], body2.range[0]];
|
|
5591
5643
|
}
|
|
5592
5644
|
function bodyOf(member) {
|
|
5593
|
-
if (member.type ===
|
|
5645
|
+
if (member.type === AST_NODE_TYPES25.MethodDefinition || member.type === AST_NODE_TYPES25.TSAbstractMethodDefinition) {
|
|
5594
5646
|
return member.value.body ?? void 0;
|
|
5595
5647
|
}
|
|
5596
|
-
if (member.type ===
|
|
5648
|
+
if (member.type === AST_NODE_TYPES25.Property || member.type === AST_NODE_TYPES25.PropertyDefinition) {
|
|
5597
5649
|
const value = member.value;
|
|
5598
5650
|
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5599
5651
|
}
|
|
@@ -5603,12 +5655,12 @@ function bodyOf(member) {
|
|
|
5603
5655
|
// src/rules/no-declaration-comment-wall.ts
|
|
5604
5656
|
function named(node) {
|
|
5605
5657
|
switch (node.type) {
|
|
5606
|
-
case
|
|
5658
|
+
case AST_NODE_TYPES26.TSEnumMember:
|
|
5607
5659
|
return { node, key: node.id };
|
|
5608
|
-
case
|
|
5609
|
-
case
|
|
5610
|
-
case
|
|
5611
|
-
case
|
|
5660
|
+
case AST_NODE_TYPES26.PropertyDefinition:
|
|
5661
|
+
case AST_NODE_TYPES26.TSAbstractPropertyDefinition:
|
|
5662
|
+
case AST_NODE_TYPES26.MethodDefinition:
|
|
5663
|
+
case AST_NODE_TYPES26.TSAbstractMethodDefinition:
|
|
5612
5664
|
return node.computed ? void 0 : { node, key: node.key };
|
|
5613
5665
|
default:
|
|
5614
5666
|
return void 0;
|
|
@@ -5708,7 +5760,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5708
5760
|
});
|
|
5709
5761
|
|
|
5710
5762
|
// src/rules/no-union-in-comment.ts
|
|
5711
|
-
import { AST_NODE_TYPES as
|
|
5763
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES27 } from "@typescript-eslint/utils";
|
|
5712
5764
|
var MAX_LITERAL_LENGTH = 28;
|
|
5713
5765
|
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5714
5766
|
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
@@ -5727,14 +5779,14 @@ var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
5727
5779
|
function isBareString(node) {
|
|
5728
5780
|
if (node === void 0) return false;
|
|
5729
5781
|
switch (node.type) {
|
|
5730
|
-
case
|
|
5782
|
+
case AST_NODE_TYPES27.TSStringKeyword:
|
|
5731
5783
|
return true;
|
|
5732
5784
|
// `string[]` holds members of the same closed set, one element at a time.
|
|
5733
|
-
case
|
|
5785
|
+
case AST_NODE_TYPES27.TSArrayType:
|
|
5734
5786
|
return isBareString(node.elementType);
|
|
5735
5787
|
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5736
5788
|
// — the checker collapses that one to `string`.
|
|
5737
|
-
case
|
|
5789
|
+
case AST_NODE_TYPES27.TSUnionType:
|
|
5738
5790
|
return node.types.some((member) => isBareString(member));
|
|
5739
5791
|
default:
|
|
5740
5792
|
return false;
|
|
@@ -5744,13 +5796,13 @@ function rootCallee(node) {
|
|
|
5744
5796
|
let current = node;
|
|
5745
5797
|
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5746
5798
|
switch (current.type) {
|
|
5747
|
-
case
|
|
5799
|
+
case AST_NODE_TYPES27.CallExpression:
|
|
5748
5800
|
current = current.callee;
|
|
5749
5801
|
break;
|
|
5750
|
-
case
|
|
5802
|
+
case AST_NODE_TYPES27.MemberExpression:
|
|
5751
5803
|
current = current.object;
|
|
5752
5804
|
break;
|
|
5753
|
-
case
|
|
5805
|
+
case AST_NODE_TYPES27.Identifier:
|
|
5754
5806
|
return current.name;
|
|
5755
5807
|
default:
|
|
5756
5808
|
return null;
|
|
@@ -5759,26 +5811,26 @@ function rootCallee(node) {
|
|
|
5759
5811
|
return null;
|
|
5760
5812
|
}
|
|
5761
5813
|
function nameOf(key) {
|
|
5762
|
-
if (key.type ===
|
|
5763
|
-
if (key.type ===
|
|
5814
|
+
if (key.type === AST_NODE_TYPES27.Identifier) return key.name;
|
|
5815
|
+
if (key.type === AST_NODE_TYPES27.Literal && typeof key.value === "string") return key.value;
|
|
5764
5816
|
return null;
|
|
5765
5817
|
}
|
|
5766
5818
|
function targetOf(node) {
|
|
5767
5819
|
switch (node.type) {
|
|
5768
|
-
case
|
|
5769
|
-
case
|
|
5820
|
+
case AST_NODE_TYPES27.TSPropertySignature:
|
|
5821
|
+
case AST_NODE_TYPES27.PropertyDefinition: {
|
|
5770
5822
|
const name = node.computed ? null : nameOf(node.key);
|
|
5771
5823
|
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5772
5824
|
return { node, name };
|
|
5773
5825
|
}
|
|
5774
|
-
case
|
|
5826
|
+
case AST_NODE_TYPES27.Property: {
|
|
5775
5827
|
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5776
5828
|
const callee = rootCallee(node.value);
|
|
5777
5829
|
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5778
5830
|
return { node, name };
|
|
5779
5831
|
}
|
|
5780
|
-
case
|
|
5781
|
-
if (node.id.type !==
|
|
5832
|
+
case AST_NODE_TYPES27.VariableDeclarator: {
|
|
5833
|
+
if (node.id.type !== AST_NODE_TYPES27.Identifier) return null;
|
|
5782
5834
|
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5783
5835
|
return { node, name: node.id.name };
|
|
5784
5836
|
}
|
|
@@ -5827,7 +5879,7 @@ var no_union_in_comment_default = createRule({
|
|
|
5827
5879
|
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5828
5880
|
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5829
5881
|
}
|
|
5830
|
-
for (let node = anchor; node != null && node.type !==
|
|
5882
|
+
for (let node = anchor; node != null && node.type !== AST_NODE_TYPES27.Program; node = node.parent) {
|
|
5831
5883
|
const target = targetOf(node);
|
|
5832
5884
|
if (target !== null) return target;
|
|
5833
5885
|
}
|
|
@@ -5856,9 +5908,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5856
5908
|
});
|
|
5857
5909
|
|
|
5858
5910
|
// src/rules/no-type-member-comment-wall.ts
|
|
5859
|
-
import { AST_NODE_TYPES as
|
|
5911
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES28 } from "@typescript-eslint/utils";
|
|
5860
5912
|
function isNamedMember(node) {
|
|
5861
|
-
return (node.type ===
|
|
5913
|
+
return (node.type === AST_NODE_TYPES28.TSPropertySignature || node.type === AST_NODE_TYPES28.TSMethodSignature) && !node.computed;
|
|
5862
5914
|
}
|
|
5863
5915
|
var no_type_member_comment_wall_default = createRule({
|
|
5864
5916
|
name: "no-type-member-comment-wall",
|
|
@@ -5905,7 +5957,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5905
5957
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5906
5958
|
}
|
|
5907
5959
|
function check(node) {
|
|
5908
|
-
const members = node.type ===
|
|
5960
|
+
const members = node.type === AST_NODE_TYPES28.TSInterfaceBody ? node.body : node.members;
|
|
5909
5961
|
const named2 = members.filter(isNamedMember);
|
|
5910
5962
|
if (named2.length === 0) return;
|
|
5911
5963
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5945,7 +5997,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5945
5997
|
});
|
|
5946
5998
|
|
|
5947
5999
|
// src/rules/no-unnecessary-use-client.ts
|
|
5948
|
-
import { AST_NODE_TYPES as
|
|
6000
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES29 } from "@typescript-eslint/utils";
|
|
5949
6001
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5950
6002
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5951
6003
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -5971,13 +6023,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
5971
6023
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
5972
6024
|
var jsxRootName = (name) => {
|
|
5973
6025
|
let current = name;
|
|
5974
|
-
while (current.type ===
|
|
6026
|
+
while (current.type === AST_NODE_TYPES29.JSXMemberExpression) {
|
|
5975
6027
|
current = current.object;
|
|
5976
6028
|
}
|
|
5977
|
-
return current.type ===
|
|
6029
|
+
return current.type === AST_NODE_TYPES29.JSXIdentifier ? current.name : "";
|
|
5978
6030
|
};
|
|
5979
6031
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
5980
|
-
if (node.type ===
|
|
6032
|
+
if (node.type === AST_NODE_TYPES29.Identifier) {
|
|
5981
6033
|
return imported.has(node.name);
|
|
5982
6034
|
}
|
|
5983
6035
|
for (const key of Object.keys(node)) {
|
|
@@ -5992,16 +6044,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
5992
6044
|
return false;
|
|
5993
6045
|
};
|
|
5994
6046
|
var isUseClientDirective = (node) => {
|
|
5995
|
-
return node.type ===
|
|
6047
|
+
return node.type === AST_NODE_TYPES29.ExpressionStatement && node.expression.type === AST_NODE_TYPES29.Literal && node.expression.value === "use client";
|
|
5996
6048
|
};
|
|
5997
6049
|
var isGlobalReference = (node, context) => {
|
|
5998
6050
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
5999
6051
|
const parent = node.parent;
|
|
6000
6052
|
if (parent !== void 0) {
|
|
6001
|
-
if (parent.type ===
|
|
6053
|
+
if (parent.type === AST_NODE_TYPES29.MemberExpression && parent.property === node && !parent.computed) {
|
|
6002
6054
|
return false;
|
|
6003
6055
|
}
|
|
6004
|
-
if (parent.type ===
|
|
6056
|
+
if (parent.type === AST_NODE_TYPES29.Property && parent.key === node && !parent.computed) {
|
|
6005
6057
|
return false;
|
|
6006
6058
|
}
|
|
6007
6059
|
if (parent.type.startsWith("TS")) {
|
|
@@ -6041,13 +6093,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6041
6093
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
6042
6094
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
6043
6095
|
const markIfHookOrContext = (callee) => {
|
|
6044
|
-
if (callee.type ===
|
|
6096
|
+
if (callee.type === AST_NODE_TYPES29.Identifier) {
|
|
6045
6097
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
6046
6098
|
hasClientIndicator = true;
|
|
6047
6099
|
}
|
|
6048
6100
|
return;
|
|
6049
6101
|
}
|
|
6050
|
-
if (callee.type ===
|
|
6102
|
+
if (callee.type === AST_NODE_TYPES29.MemberExpression && callee.property.type === AST_NODE_TYPES29.Identifier) {
|
|
6051
6103
|
const name = callee.property.name;
|
|
6052
6104
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
6053
6105
|
hasClientIndicator = true;
|
|
@@ -6057,7 +6109,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6057
6109
|
return {
|
|
6058
6110
|
Program(node) {
|
|
6059
6111
|
for (const stmt of node.body) {
|
|
6060
|
-
if (stmt.type !==
|
|
6112
|
+
if (stmt.type !== AST_NODE_TYPES29.ExpressionStatement) break;
|
|
6061
6113
|
if (isUseClientDirective(stmt)) {
|
|
6062
6114
|
directiveNode = stmt;
|
|
6063
6115
|
break;
|
|
@@ -6070,7 +6122,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6070
6122
|
},
|
|
6071
6123
|
JSXAttribute(node) {
|
|
6072
6124
|
if (directiveNode === null) return;
|
|
6073
|
-
if (node.name.type ===
|
|
6125
|
+
if (node.name.type === AST_NODE_TYPES29.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
6074
6126
|
hasClientIndicator = true;
|
|
6075
6127
|
}
|
|
6076
6128
|
},
|
|
@@ -6138,17 +6190,17 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6138
6190
|
|
|
6139
6191
|
// src/rules/no-unsafe-mock-casting.ts
|
|
6140
6192
|
import "@typescript-eslint/utils";
|
|
6141
|
-
import { AST_NODE_TYPES as
|
|
6193
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES30 } from "@typescript-eslint/utils";
|
|
6142
6194
|
function isMockTypeReference(node) {
|
|
6143
|
-
if (node.type !==
|
|
6195
|
+
if (node.type !== AST_NODE_TYPES30.TSTypeReference) {
|
|
6144
6196
|
return false;
|
|
6145
6197
|
}
|
|
6146
6198
|
const typeName = node.typeName;
|
|
6147
|
-
if (typeName.type ===
|
|
6199
|
+
if (typeName.type === AST_NODE_TYPES30.Identifier) {
|
|
6148
6200
|
const name = typeName.name;
|
|
6149
6201
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
6150
6202
|
}
|
|
6151
|
-
if (typeName.type ===
|
|
6203
|
+
if (typeName.type === AST_NODE_TYPES30.TSQualifiedName) {
|
|
6152
6204
|
const rightName = typeName.right.name;
|
|
6153
6205
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
6154
6206
|
}
|
|
@@ -6186,7 +6238,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
6186
6238
|
// src/rules/no-zod-native-enum.ts
|
|
6187
6239
|
import {
|
|
6188
6240
|
ESLintUtils as ESLintUtils2,
|
|
6189
|
-
AST_NODE_TYPES as
|
|
6241
|
+
AST_NODE_TYPES as AST_NODE_TYPES31
|
|
6190
6242
|
} from "@typescript-eslint/utils";
|
|
6191
6243
|
import * as ts from "typescript";
|
|
6192
6244
|
var IGNORE_PATTERNS = [
|
|
@@ -6205,7 +6257,7 @@ function isZodModule(source) {
|
|
|
6205
6257
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
6206
6258
|
}
|
|
6207
6259
|
function unwrap2(node) {
|
|
6208
|
-
if (node.type ===
|
|
6260
|
+
if (node.type === AST_NODE_TYPES31.TSAsExpression || node.type === AST_NODE_TYPES31.TSSatisfiesExpression) {
|
|
6209
6261
|
return unwrap2(node.expression);
|
|
6210
6262
|
}
|
|
6211
6263
|
return node;
|
|
@@ -6213,14 +6265,14 @@ function unwrap2(node) {
|
|
|
6213
6265
|
function stringValueTexts(node, sourceCode) {
|
|
6214
6266
|
const texts = [];
|
|
6215
6267
|
for (const prop of node.properties) {
|
|
6216
|
-
if (prop.type !==
|
|
6268
|
+
if (prop.type !== AST_NODE_TYPES31.Property) {
|
|
6217
6269
|
return null;
|
|
6218
6270
|
}
|
|
6219
6271
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6220
6272
|
return null;
|
|
6221
6273
|
}
|
|
6222
6274
|
const value = prop.value;
|
|
6223
|
-
if (value.type !==
|
|
6275
|
+
if (value.type !== AST_NODE_TYPES31.Literal || typeof value.value !== "string") {
|
|
6224
6276
|
return null;
|
|
6225
6277
|
}
|
|
6226
6278
|
const text = sourceCode.getText(value);
|
|
@@ -6236,7 +6288,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6236
6288
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6237
6289
|
if (variable !== void 0) {
|
|
6238
6290
|
return variable.defs.some(
|
|
6239
|
-
(def) => def.node.type ===
|
|
6291
|
+
(def) => def.node.type === AST_NODE_TYPES31.TSEnumDeclaration
|
|
6240
6292
|
);
|
|
6241
6293
|
}
|
|
6242
6294
|
current = current.upper;
|
|
@@ -6288,25 +6340,25 @@ var no_zod_native_enum_default = createRule({
|
|
|
6288
6340
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6289
6341
|
function isZodMemberCall(node, api) {
|
|
6290
6342
|
const callee = node.callee;
|
|
6291
|
-
if (callee.type ===
|
|
6343
|
+
if (callee.type === AST_NODE_TYPES31.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES31.Identifier) {
|
|
6292
6344
|
return callee.property.name === api;
|
|
6293
6345
|
}
|
|
6294
|
-
if (callee.type ===
|
|
6346
|
+
if (callee.type === AST_NODE_TYPES31.Identifier) {
|
|
6295
6347
|
return zodImportedNames.get(callee.name) === api;
|
|
6296
6348
|
}
|
|
6297
6349
|
return false;
|
|
6298
6350
|
}
|
|
6299
6351
|
function buildFix(node) {
|
|
6300
6352
|
const callee = node.callee;
|
|
6301
|
-
if (callee.type !==
|
|
6353
|
+
if (callee.type !== AST_NODE_TYPES31.MemberExpression || callee.property.type !== AST_NODE_TYPES31.Identifier) {
|
|
6302
6354
|
return null;
|
|
6303
6355
|
}
|
|
6304
6356
|
const arg = node.arguments[0];
|
|
6305
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6357
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === AST_NODE_TYPES31.SpreadElement) {
|
|
6306
6358
|
return null;
|
|
6307
6359
|
}
|
|
6308
6360
|
const inner = unwrap2(arg);
|
|
6309
|
-
if (inner.type !==
|
|
6361
|
+
if (inner.type !== AST_NODE_TYPES31.ObjectExpression) {
|
|
6310
6362
|
return null;
|
|
6311
6363
|
}
|
|
6312
6364
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6326,7 +6378,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6326
6378
|
return;
|
|
6327
6379
|
}
|
|
6328
6380
|
for (const spec of node.specifiers) {
|
|
6329
|
-
if (spec.type ===
|
|
6381
|
+
if (spec.type === AST_NODE_TYPES31.ImportSpecifier && spec.imported.type === AST_NODE_TYPES31.Identifier) {
|
|
6330
6382
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6331
6383
|
}
|
|
6332
6384
|
}
|
|
@@ -6345,7 +6397,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6345
6397
|
return;
|
|
6346
6398
|
}
|
|
6347
6399
|
const arg = node.arguments[0];
|
|
6348
|
-
if (arg === void 0 || arg.type !==
|
|
6400
|
+
if (arg === void 0 || arg.type !== AST_NODE_TYPES31.Identifier) {
|
|
6349
6401
|
return;
|
|
6350
6402
|
}
|
|
6351
6403
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6362,7 +6414,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6362
6414
|
});
|
|
6363
6415
|
|
|
6364
6416
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6365
|
-
import { AST_NODE_TYPES as
|
|
6417
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES32 } from "@typescript-eslint/utils";
|
|
6366
6418
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6367
6419
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6368
6420
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6375,36 +6427,36 @@ function isConstantReference(identifier) {
|
|
|
6375
6427
|
}
|
|
6376
6428
|
function isExcludedOperand(node) {
|
|
6377
6429
|
switch (node.type) {
|
|
6378
|
-
case
|
|
6430
|
+
case AST_NODE_TYPES32.Literal:
|
|
6379
6431
|
return true;
|
|
6380
|
-
case
|
|
6432
|
+
case AST_NODE_TYPES32.TemplateLiteral:
|
|
6381
6433
|
return node.expressions.length === 0;
|
|
6382
|
-
case
|
|
6434
|
+
case AST_NODE_TYPES32.Identifier:
|
|
6383
6435
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6384
|
-
case
|
|
6385
|
-
return !node.computed && node.property.type ===
|
|
6436
|
+
case AST_NODE_TYPES32.MemberExpression:
|
|
6437
|
+
return !node.computed && node.property.type === AST_NODE_TYPES32.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6386
6438
|
default:
|
|
6387
6439
|
return false;
|
|
6388
6440
|
}
|
|
6389
6441
|
}
|
|
6390
6442
|
function operandName(node) {
|
|
6391
|
-
if (node.type ===
|
|
6443
|
+
if (node.type === AST_NODE_TYPES32.Identifier) {
|
|
6392
6444
|
return node.name;
|
|
6393
6445
|
}
|
|
6394
|
-
if (node.type ===
|
|
6446
|
+
if (node.type === AST_NODE_TYPES32.MemberExpression && !node.computed && node.property.type === AST_NODE_TYPES32.Identifier) {
|
|
6395
6447
|
return node.property.name;
|
|
6396
6448
|
}
|
|
6397
6449
|
return null;
|
|
6398
6450
|
}
|
|
6399
6451
|
function isSecretOperand(node) {
|
|
6400
|
-
if (node.type ===
|
|
6452
|
+
if (node.type === AST_NODE_TYPES32.TemplateLiteral) {
|
|
6401
6453
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6402
6454
|
}
|
|
6403
6455
|
const name = operandName(node);
|
|
6404
6456
|
return name !== null && isAuthSecretName(name);
|
|
6405
6457
|
}
|
|
6406
6458
|
function secretNameOf(node) {
|
|
6407
|
-
if (node.type ===
|
|
6459
|
+
if (node.type === AST_NODE_TYPES32.TemplateLiteral) {
|
|
6408
6460
|
for (const expression of node.expressions) {
|
|
6409
6461
|
const nested = secretNameOf(expression);
|
|
6410
6462
|
if (nested !== null) {
|
|
@@ -6457,7 +6509,7 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
6457
6509
|
|
|
6458
6510
|
// src/rules/prefer-discriminated-union.ts
|
|
6459
6511
|
import "@typescript-eslint/utils";
|
|
6460
|
-
import { AST_NODE_TYPES as
|
|
6512
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES33 } from "@typescript-eslint/utils";
|
|
6461
6513
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
6462
6514
|
"success",
|
|
6463
6515
|
"ok",
|
|
@@ -6467,27 +6519,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6467
6519
|
]);
|
|
6468
6520
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
6469
6521
|
function getMemberName(member) {
|
|
6470
|
-
if (member.type !==
|
|
6522
|
+
if (member.type !== AST_NODE_TYPES33.TSPropertySignature) {
|
|
6471
6523
|
return null;
|
|
6472
6524
|
}
|
|
6473
6525
|
const { key } = member;
|
|
6474
|
-
if (key.type ===
|
|
6526
|
+
if (key.type === AST_NODE_TYPES33.Identifier) {
|
|
6475
6527
|
return key.name;
|
|
6476
6528
|
}
|
|
6477
|
-
if (key.type ===
|
|
6529
|
+
if (key.type === AST_NODE_TYPES33.Literal && typeof key.value === "string") {
|
|
6478
6530
|
return key.value;
|
|
6479
6531
|
}
|
|
6480
6532
|
return null;
|
|
6481
6533
|
}
|
|
6482
6534
|
function isBooleanTyped(member) {
|
|
6483
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6535
|
+
return member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES33.TSBooleanKeyword;
|
|
6484
6536
|
}
|
|
6485
6537
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
6486
6538
|
let hasStatusBoolean = false;
|
|
6487
6539
|
let optionalCount = 0;
|
|
6488
6540
|
let optionalPayloadCount = 0;
|
|
6489
6541
|
for (const member of typeLiteral.members) {
|
|
6490
|
-
if (member.type !==
|
|
6542
|
+
if (member.type !== AST_NODE_TYPES33.TSPropertySignature) {
|
|
6491
6543
|
continue;
|
|
6492
6544
|
}
|
|
6493
6545
|
if (member.optional) {
|
|
@@ -6529,7 +6581,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6529
6581
|
TSInterfaceDeclaration(node) {
|
|
6530
6582
|
const synthetic = {
|
|
6531
6583
|
...node.body,
|
|
6532
|
-
type:
|
|
6584
|
+
type: AST_NODE_TYPES33.TSTypeLiteral,
|
|
6533
6585
|
members: node.body.body
|
|
6534
6586
|
};
|
|
6535
6587
|
checkTypeLiteral(synthetic, node);
|
|
@@ -6542,7 +6594,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6542
6594
|
});
|
|
6543
6595
|
|
|
6544
6596
|
// src/rules/prefer-module-level-constant.ts
|
|
6545
|
-
import { AST_NODE_TYPES as
|
|
6597
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES34 } from "@typescript-eslint/utils";
|
|
6546
6598
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6547
6599
|
var MAX_LITERAL_DEPTH = 4;
|
|
6548
6600
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6571,9 +6623,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6571
6623
|
"assign"
|
|
6572
6624
|
]);
|
|
6573
6625
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6626
|
+
AST_NODE_TYPES34.FunctionDeclaration,
|
|
6627
|
+
AST_NODE_TYPES34.FunctionExpression,
|
|
6628
|
+
AST_NODE_TYPES34.ArrowFunctionExpression
|
|
6577
6629
|
]);
|
|
6578
6630
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6579
6631
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6586,14 +6638,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6586
6638
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6587
6639
|
}
|
|
6588
6640
|
function unwrap3(node) {
|
|
6589
|
-
if (node.type ===
|
|
6641
|
+
if (node.type === AST_NODE_TYPES34.TSAsExpression || node.type === AST_NODE_TYPES34.TSSatisfiesExpression || node.type === AST_NODE_TYPES34.TSNonNullExpression) {
|
|
6590
6642
|
return unwrap3(node.expression);
|
|
6591
6643
|
}
|
|
6592
6644
|
return node;
|
|
6593
6645
|
}
|
|
6594
6646
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6595
6647
|
function isRegexLiteral(node) {
|
|
6596
|
-
return node.type ===
|
|
6648
|
+
return node.type === AST_NODE_TYPES34.Literal && "regex" in node && node.regex !== void 0;
|
|
6597
6649
|
}
|
|
6598
6650
|
function isLiteralOnly(node, depth) {
|
|
6599
6651
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6601,29 +6653,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6601
6653
|
}
|
|
6602
6654
|
const inner = unwrap3(node);
|
|
6603
6655
|
switch (inner.type) {
|
|
6604
|
-
case
|
|
6656
|
+
case AST_NODE_TYPES34.Literal: {
|
|
6605
6657
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6606
6658
|
}
|
|
6607
|
-
case
|
|
6659
|
+
case AST_NODE_TYPES34.TemplateLiteral: {
|
|
6608
6660
|
return inner.expressions.length === 0;
|
|
6609
6661
|
}
|
|
6610
|
-
case
|
|
6611
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6662
|
+
case AST_NODE_TYPES34.UnaryExpression: {
|
|
6663
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES34.Literal && typeof inner.argument.value === "number";
|
|
6612
6664
|
}
|
|
6613
|
-
case
|
|
6665
|
+
case AST_NODE_TYPES34.ArrayExpression: {
|
|
6614
6666
|
return inner.elements.every(
|
|
6615
|
-
(el) => el !== null && el.type !==
|
|
6667
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES34.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6616
6668
|
);
|
|
6617
6669
|
}
|
|
6618
|
-
case
|
|
6670
|
+
case AST_NODE_TYPES34.ObjectExpression: {
|
|
6619
6671
|
return inner.properties.every((prop) => {
|
|
6620
|
-
if (prop.type !==
|
|
6672
|
+
if (prop.type !== AST_NODE_TYPES34.Property) {
|
|
6621
6673
|
return false;
|
|
6622
6674
|
}
|
|
6623
6675
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6624
6676
|
return false;
|
|
6625
6677
|
}
|
|
6626
|
-
if (prop.computed && prop.key.type !==
|
|
6678
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES34.Literal) {
|
|
6627
6679
|
return false;
|
|
6628
6680
|
}
|
|
6629
6681
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6636,7 +6688,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6636
6688
|
}
|
|
6637
6689
|
function unwrapObjectFreeze(node) {
|
|
6638
6690
|
const inner = unwrap3(node);
|
|
6639
|
-
if (inner.type ===
|
|
6691
|
+
if (inner.type === AST_NODE_TYPES34.CallExpression && inner.callee.type === AST_NODE_TYPES34.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES34.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES34.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES34.SpreadElement) {
|
|
6640
6692
|
return unwrap3(inner.arguments[0]);
|
|
6641
6693
|
}
|
|
6642
6694
|
return inner;
|
|
@@ -6652,19 +6704,19 @@ function classify(init, checkRegex) {
|
|
|
6652
6704
|
}
|
|
6653
6705
|
return { kind: "regex", size: 1 };
|
|
6654
6706
|
}
|
|
6655
|
-
if (node.type ===
|
|
6707
|
+
if (node.type === AST_NODE_TYPES34.ArrayExpression) {
|
|
6656
6708
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6657
6709
|
}
|
|
6658
|
-
if (node.type ===
|
|
6710
|
+
if (node.type === AST_NODE_TYPES34.ObjectExpression) {
|
|
6659
6711
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6660
6712
|
}
|
|
6661
|
-
if (node.type ===
|
|
6713
|
+
if (node.type === AST_NODE_TYPES34.NewExpression && node.callee.type === AST_NODE_TYPES34.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6662
6714
|
const arg = node.arguments[0];
|
|
6663
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6715
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES34.SpreadElement) {
|
|
6664
6716
|
return null;
|
|
6665
6717
|
}
|
|
6666
6718
|
const entries = unwrap3(arg);
|
|
6667
|
-
if (entries.type !==
|
|
6719
|
+
if (entries.type !== AST_NODE_TYPES34.ArrayExpression) {
|
|
6668
6720
|
return null;
|
|
6669
6721
|
}
|
|
6670
6722
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6693,10 +6745,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6693
6745
|
);
|
|
6694
6746
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6695
6747
|
const callee = node.callee;
|
|
6696
|
-
if (callee.type ===
|
|
6748
|
+
if (callee.type === AST_NODE_TYPES34.Identifier && callee.name === "structuredClone") {
|
|
6697
6749
|
return true;
|
|
6698
6750
|
}
|
|
6699
|
-
if (callee.type !==
|
|
6751
|
+
if (callee.type !== AST_NODE_TYPES34.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES34.Identifier || callee.property.type !== AST_NODE_TYPES34.Identifier) {
|
|
6700
6752
|
return false;
|
|
6701
6753
|
}
|
|
6702
6754
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6710,38 +6762,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6710
6762
|
}
|
|
6711
6763
|
function isSafeRead(identifier) {
|
|
6712
6764
|
const parent = identifier.parent;
|
|
6713
|
-
if (parent.type ===
|
|
6765
|
+
if (parent.type === AST_NODE_TYPES34.MemberExpression) {
|
|
6714
6766
|
if (parent.object !== identifier) {
|
|
6715
6767
|
return true;
|
|
6716
6768
|
}
|
|
6717
6769
|
const grandparent = parent.parent;
|
|
6718
|
-
if (grandparent.type ===
|
|
6770
|
+
if (grandparent.type === AST_NODE_TYPES34.AssignmentExpression && grandparent.left === parent) {
|
|
6719
6771
|
return false;
|
|
6720
6772
|
}
|
|
6721
|
-
if (grandparent.type ===
|
|
6773
|
+
if (grandparent.type === AST_NODE_TYPES34.UpdateExpression) {
|
|
6722
6774
|
return false;
|
|
6723
6775
|
}
|
|
6724
|
-
if (grandparent.type ===
|
|
6776
|
+
if (grandparent.type === AST_NODE_TYPES34.UnaryExpression && grandparent.operator === "delete") {
|
|
6725
6777
|
return false;
|
|
6726
6778
|
}
|
|
6727
|
-
if (!parent.computed && parent.property.type ===
|
|
6779
|
+
if (!parent.computed && parent.property.type === AST_NODE_TYPES34.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === AST_NODE_TYPES34.CallExpression && grandparent.callee === parent) {
|
|
6728
6780
|
return false;
|
|
6729
6781
|
}
|
|
6730
6782
|
return true;
|
|
6731
6783
|
}
|
|
6732
|
-
if (parent.type ===
|
|
6784
|
+
if (parent.type === AST_NODE_TYPES34.ForOfStatement && parent.right === identifier) {
|
|
6733
6785
|
return true;
|
|
6734
6786
|
}
|
|
6735
|
-
if (parent.type ===
|
|
6787
|
+
if (parent.type === AST_NODE_TYPES34.SpreadElement) {
|
|
6736
6788
|
return true;
|
|
6737
6789
|
}
|
|
6738
|
-
if (parent.type ===
|
|
6790
|
+
if (parent.type === AST_NODE_TYPES34.BinaryExpression) {
|
|
6739
6791
|
return true;
|
|
6740
6792
|
}
|
|
6741
|
-
if (parent.type ===
|
|
6793
|
+
if (parent.type === AST_NODE_TYPES34.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6742
6794
|
return true;
|
|
6743
6795
|
}
|
|
6744
|
-
if (parent.type ===
|
|
6796
|
+
if (parent.type === AST_NODE_TYPES34.UnaryExpression && parent.operator !== "delete") {
|
|
6745
6797
|
return true;
|
|
6746
6798
|
}
|
|
6747
6799
|
return false;
|
|
@@ -6796,7 +6848,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6796
6848
|
if (reference.isWrite()) {
|
|
6797
6849
|
return false;
|
|
6798
6850
|
}
|
|
6799
|
-
if (reference.identifier.type !==
|
|
6851
|
+
if (reference.identifier.type !== AST_NODE_TYPES34.Identifier) {
|
|
6800
6852
|
return false;
|
|
6801
6853
|
}
|
|
6802
6854
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6808,10 +6860,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6808
6860
|
return {
|
|
6809
6861
|
VariableDeclarator(node) {
|
|
6810
6862
|
const declaration = node.parent;
|
|
6811
|
-
if (declaration.type !==
|
|
6863
|
+
if (declaration.type !== AST_NODE_TYPES34.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6812
6864
|
return;
|
|
6813
6865
|
}
|
|
6814
|
-
if (node.id.type !==
|
|
6866
|
+
if (node.id.type !== AST_NODE_TYPES34.Identifier || node.init === null) {
|
|
6815
6867
|
return;
|
|
6816
6868
|
}
|
|
6817
6869
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6838,7 +6890,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6838
6890
|
});
|
|
6839
6891
|
|
|
6840
6892
|
// src/rules/prefer-module-level-schema.ts
|
|
6841
|
-
import { AST_NODE_TYPES as
|
|
6893
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35 } from "@typescript-eslint/utils";
|
|
6842
6894
|
|
|
6843
6895
|
// src/rules/_zod.ts
|
|
6844
6896
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6904,9 +6956,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6904
6956
|
"intl"
|
|
6905
6957
|
]);
|
|
6906
6958
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6959
|
+
AST_NODE_TYPES35.ArrowFunctionExpression,
|
|
6960
|
+
AST_NODE_TYPES35.FunctionDeclaration,
|
|
6961
|
+
AST_NODE_TYPES35.FunctionExpression
|
|
6910
6962
|
]);
|
|
6911
6963
|
function schemaExpression(node) {
|
|
6912
6964
|
let current = node;
|
|
@@ -6915,10 +6967,10 @@ function schemaExpression(node) {
|
|
|
6915
6967
|
if (parent === void 0) {
|
|
6916
6968
|
return current;
|
|
6917
6969
|
}
|
|
6918
|
-
if (parent.type ===
|
|
6970
|
+
if (parent.type === AST_NODE_TYPES35.MemberExpression && parent.object === current && !parent.computed && parent.property.type === AST_NODE_TYPES35.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6919
6971
|
return current;
|
|
6920
6972
|
}
|
|
6921
|
-
if (parent.type ===
|
|
6973
|
+
if (parent.type === AST_NODE_TYPES35.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES35.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES35.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES35.TSNonNullExpression && parent.expression === current) {
|
|
6922
6974
|
current = parent;
|
|
6923
6975
|
continue;
|
|
6924
6976
|
}
|
|
@@ -6969,22 +7021,22 @@ function subtreeSome(root, predicate) {
|
|
|
6969
7021
|
function readsReceiver(node) {
|
|
6970
7022
|
return subtreeSome(
|
|
6971
7023
|
node,
|
|
6972
|
-
(inner) => inner.type ===
|
|
7024
|
+
(inner) => inner.type === AST_NODE_TYPES35.ThisExpression || inner.type === AST_NODE_TYPES35.Super || inner.type === AST_NODE_TYPES35.Identifier && inner.name === "arguments"
|
|
6973
7025
|
);
|
|
6974
7026
|
}
|
|
6975
7027
|
function buildsLocalizedText(node) {
|
|
6976
7028
|
return subtreeSome(node, (inner) => {
|
|
6977
|
-
if (inner.type ===
|
|
7029
|
+
if (inner.type === AST_NODE_TYPES35.TaggedTemplateExpression) {
|
|
6978
7030
|
return true;
|
|
6979
7031
|
}
|
|
6980
|
-
if (inner.type !==
|
|
7032
|
+
if (inner.type !== AST_NODE_TYPES35.CallExpression) {
|
|
6981
7033
|
return false;
|
|
6982
7034
|
}
|
|
6983
7035
|
const { callee } = inner;
|
|
6984
|
-
if (callee.type ===
|
|
7036
|
+
if (callee.type === AST_NODE_TYPES35.Identifier) {
|
|
6985
7037
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6986
7038
|
}
|
|
6987
|
-
return callee.type ===
|
|
7039
|
+
return callee.type === AST_NODE_TYPES35.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES35.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6988
7040
|
});
|
|
6989
7041
|
}
|
|
6990
7042
|
function collectReferences(scope, out) {
|
|
@@ -7041,15 +7093,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7041
7093
|
}
|
|
7042
7094
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7043
7095
|
function isZodCall(node) {
|
|
7044
|
-
return node.type ===
|
|
7096
|
+
return node.type === AST_NODE_TYPES35.CallExpression && node.callee.type === AST_NODE_TYPES35.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES35.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
7045
7097
|
}
|
|
7046
7098
|
function isCovered(node) {
|
|
7047
7099
|
let current = node.parent ?? void 0;
|
|
7048
7100
|
while (current !== void 0) {
|
|
7049
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7101
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES35.MemberExpression && current.callee.property.type === AST_NODE_TYPES35.Identifier && factories.has(current.callee.property.name)) {
|
|
7050
7102
|
return true;
|
|
7051
7103
|
}
|
|
7052
|
-
if (current.type ===
|
|
7104
|
+
if (current.type === AST_NODE_TYPES35.CallExpression && (current.callee.type === AST_NODE_TYPES35.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === AST_NODE_TYPES35.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES35.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
7053
7105
|
return true;
|
|
7054
7106
|
}
|
|
7055
7107
|
current = current.parent ?? void 0;
|
|
@@ -7064,11 +7116,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7064
7116
|
if (parent === void 0) {
|
|
7065
7117
|
return confirmed;
|
|
7066
7118
|
}
|
|
7067
|
-
if (parent.type ===
|
|
7119
|
+
if (parent.type === AST_NODE_TYPES35.Property && parent.value === current || parent.type === AST_NODE_TYPES35.ObjectExpression || parent.type === AST_NODE_TYPES35.ArrayExpression) {
|
|
7068
7120
|
current = parent;
|
|
7069
7121
|
continue;
|
|
7070
7122
|
}
|
|
7071
|
-
if (parent.type ===
|
|
7123
|
+
if (parent.type === AST_NODE_TYPES35.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7072
7124
|
current = schemaExpression(parent);
|
|
7073
7125
|
confirmed = current;
|
|
7074
7126
|
continue;
|
|
@@ -7078,7 +7130,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7078
7130
|
}
|
|
7079
7131
|
function isSchemaComposition(node) {
|
|
7080
7132
|
const { callee } = node;
|
|
7081
|
-
const isCombinator = callee.type ===
|
|
7133
|
+
const isCombinator = callee.type === AST_NODE_TYPES35.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES35.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7082
7134
|
return isCombinator || isZodCall(node);
|
|
7083
7135
|
}
|
|
7084
7136
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7112,13 +7164,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7112
7164
|
}
|
|
7113
7165
|
function ownerName(enclosing) {
|
|
7114
7166
|
const parent = enclosing.parent ?? void 0;
|
|
7115
|
-
if (enclosing.type ===
|
|
7167
|
+
if (enclosing.type === AST_NODE_TYPES35.FunctionDeclaration && enclosing.id !== null) {
|
|
7116
7168
|
return enclosing.id.name;
|
|
7117
7169
|
}
|
|
7118
|
-
if (parent !== void 0 && parent.type ===
|
|
7170
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES35.VariableDeclarator && parent.id.type === AST_NODE_TYPES35.Identifier) {
|
|
7119
7171
|
return parent.id.name;
|
|
7120
7172
|
}
|
|
7121
|
-
if (parent !== void 0 && (parent.type ===
|
|
7173
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES35.MethodDefinition || parent.type === AST_NODE_TYPES35.Property) && parent.key.type === AST_NODE_TYPES35.Identifier) {
|
|
7122
7174
|
return parent.key.name;
|
|
7123
7175
|
}
|
|
7124
7176
|
return "this function";
|
|
@@ -7129,7 +7181,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7129
7181
|
return;
|
|
7130
7182
|
}
|
|
7131
7183
|
for (const specifier of node.specifiers) {
|
|
7132
|
-
if (specifier.type ===
|
|
7184
|
+
if (specifier.type === AST_NODE_TYPES35.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES35.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES35.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES35.Identifier && specifier.imported.name === "z") {
|
|
7133
7185
|
zodNamespaces.add(specifier.local.name);
|
|
7134
7186
|
}
|
|
7135
7187
|
}
|
|
@@ -7139,7 +7191,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7139
7191
|
return;
|
|
7140
7192
|
}
|
|
7141
7193
|
const callee = node.callee;
|
|
7142
|
-
if (callee.property.type !==
|
|
7194
|
+
if (callee.property.type !== AST_NODE_TYPES35.Identifier) {
|
|
7143
7195
|
return;
|
|
7144
7196
|
}
|
|
7145
7197
|
const factory = callee.property.name;
|
|
@@ -7154,7 +7206,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7154
7206
|
return;
|
|
7155
7207
|
}
|
|
7156
7208
|
const shape = node.arguments[0];
|
|
7157
|
-
if (shape !== void 0 && shape.type ===
|
|
7209
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES35.ObjectExpression && shape.properties.length < minProperties) {
|
|
7158
7210
|
return;
|
|
7159
7211
|
}
|
|
7160
7212
|
const expression = schemaExpression(node);
|
|
@@ -7182,20 +7234,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7182
7234
|
});
|
|
7183
7235
|
|
|
7184
7236
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7185
|
-
import { AST_NODE_TYPES as
|
|
7237
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36 } from "@typescript-eslint/utils";
|
|
7186
7238
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7187
7239
|
function propertyName(node) {
|
|
7188
7240
|
const key = node.key;
|
|
7189
|
-
if (key.type ===
|
|
7190
|
-
if (key.type ===
|
|
7241
|
+
if (key.type === AST_NODE_TYPES36.Identifier) return key.name;
|
|
7242
|
+
if (key.type === AST_NODE_TYPES36.Literal) return String(key.value);
|
|
7191
7243
|
return "collection";
|
|
7192
7244
|
}
|
|
7193
7245
|
function isArrayType(node) {
|
|
7194
|
-
if (node.type ===
|
|
7195
|
-
return node.type ===
|
|
7246
|
+
if (node.type === AST_NODE_TYPES36.TSArrayType) return true;
|
|
7247
|
+
return node.type === AST_NODE_TYPES36.TSTypeReference && node.typeName.type === AST_NODE_TYPES36.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7196
7248
|
}
|
|
7197
7249
|
function isNullishType(node) {
|
|
7198
|
-
return node.type ===
|
|
7250
|
+
return node.type === AST_NODE_TYPES36.TSNullKeyword || node.type === AST_NODE_TYPES36.TSUndefinedKeyword;
|
|
7199
7251
|
}
|
|
7200
7252
|
function isNullableArrayOnly(node) {
|
|
7201
7253
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7223,7 +7275,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7223
7275
|
if (node.optional) return;
|
|
7224
7276
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7225
7277
|
if (annotation === void 0) return;
|
|
7226
|
-
if (annotation.type !==
|
|
7278
|
+
if (annotation.type !== AST_NODE_TYPES36.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7227
7279
|
return;
|
|
7228
7280
|
}
|
|
7229
7281
|
context.report({
|
|
@@ -7236,7 +7288,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7236
7288
|
TSPropertySignature: checkOptionalProperty,
|
|
7237
7289
|
PropertyDefinition: checkOptionalProperty,
|
|
7238
7290
|
TSTypeAliasDeclaration(node) {
|
|
7239
|
-
if (node.typeAnnotation.type !==
|
|
7291
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES36.TSUnionType) return;
|
|
7240
7292
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7241
7293
|
context.report({
|
|
7242
7294
|
node,
|
|
@@ -7249,9 +7301,9 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7249
7301
|
});
|
|
7250
7302
|
|
|
7251
7303
|
// src/rules/prefer-native-random-uuid.ts
|
|
7252
|
-
import { AST_NODE_TYPES as
|
|
7304
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37, ASTUtils as ASTUtils3 } from "@typescript-eslint/utils";
|
|
7253
7305
|
function requireUuid(node) {
|
|
7254
|
-
return node?.type ===
|
|
7306
|
+
return node?.type === AST_NODE_TYPES37.CallExpression && node.callee.type === AST_NODE_TYPES37.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === AST_NODE_TYPES37.Literal && node.arguments[0].value === "uuid";
|
|
7255
7307
|
}
|
|
7256
7308
|
var prefer_native_random_uuid_default = createRule({
|
|
7257
7309
|
name: "prefer-native-random-uuid",
|
|
@@ -7294,37 +7346,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7294
7346
|
ImportDeclaration(node) {
|
|
7295
7347
|
if (node.source.value !== "uuid") return;
|
|
7296
7348
|
for (const specifier of node.specifiers) {
|
|
7297
|
-
if (specifier.type ===
|
|
7349
|
+
if (specifier.type === AST_NODE_TYPES37.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES37.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7298
7350
|
record(specifier.local, directBindings);
|
|
7299
|
-
} else if (specifier.type ===
|
|
7351
|
+
} else if (specifier.type === AST_NODE_TYPES37.ImportNamespaceSpecifier) {
|
|
7300
7352
|
record(specifier.local, namespaceBindings);
|
|
7301
7353
|
}
|
|
7302
7354
|
}
|
|
7303
7355
|
},
|
|
7304
7356
|
VariableDeclarator(node) {
|
|
7305
7357
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7306
|
-
if (node.init?.type !==
|
|
7358
|
+
if (node.init?.type !== AST_NODE_TYPES37.CallExpression || node.init.callee.type !== AST_NODE_TYPES37.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
7307
7359
|
return;
|
|
7308
7360
|
}
|
|
7309
|
-
if (node.id.type ===
|
|
7361
|
+
if (node.id.type === AST_NODE_TYPES37.Identifier) {
|
|
7310
7362
|
record(node.id, namespaceBindings);
|
|
7311
7363
|
return;
|
|
7312
7364
|
}
|
|
7313
|
-
if (node.id.type !==
|
|
7365
|
+
if (node.id.type !== AST_NODE_TYPES37.ObjectPattern) return;
|
|
7314
7366
|
for (const property of node.id.properties) {
|
|
7315
|
-
if (property.type ===
|
|
7367
|
+
if (property.type === AST_NODE_TYPES37.Property && !property.computed && (property.key.type === AST_NODE_TYPES37.Identifier && property.key.name === "v4" || property.key.type === AST_NODE_TYPES37.Literal && property.key.value === "v4") && property.value.type === AST_NODE_TYPES37.Identifier) {
|
|
7316
7368
|
record(property.value, directBindings);
|
|
7317
7369
|
}
|
|
7318
7370
|
}
|
|
7319
7371
|
},
|
|
7320
7372
|
"CallExpression:exit"(node) {
|
|
7321
7373
|
if (node.arguments.length !== 0) return;
|
|
7322
|
-
if (node.callee.type ===
|
|
7374
|
+
if (node.callee.type === AST_NODE_TYPES37.Identifier) {
|
|
7323
7375
|
const variable2 = resolve(node.callee);
|
|
7324
7376
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7325
7377
|
return;
|
|
7326
7378
|
}
|
|
7327
|
-
if (node.callee.type !==
|
|
7379
|
+
if (node.callee.type !== AST_NODE_TYPES37.MemberExpression || node.callee.computed || node.callee.object.type !== AST_NODE_TYPES37.Identifier || node.callee.property.type !== AST_NODE_TYPES37.Identifier || node.callee.property.name !== "v4") {
|
|
7328
7380
|
return;
|
|
7329
7381
|
}
|
|
7330
7382
|
const variable = resolve(node.callee.object);
|
|
@@ -7335,13 +7387,13 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7335
7387
|
});
|
|
7336
7388
|
|
|
7337
7389
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7338
|
-
import { AST_NODE_TYPES as
|
|
7390
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
7339
7391
|
var unwrap4 = (node) => {
|
|
7340
7392
|
let current = node;
|
|
7341
7393
|
while (current !== null && current !== void 0) {
|
|
7342
|
-
if (current.type ===
|
|
7394
|
+
if (current.type === AST_NODE_TYPES38.TSAsExpression || current.type === AST_NODE_TYPES38.TSTypeAssertion || current.type === AST_NODE_TYPES38.TSNonNullExpression || current.type === AST_NODE_TYPES38.TSSatisfiesExpression) {
|
|
7343
7395
|
current = current.expression;
|
|
7344
|
-
} else if (current.type ===
|
|
7396
|
+
} else if (current.type === AST_NODE_TYPES38.ChainExpression) {
|
|
7345
7397
|
current = current.expression;
|
|
7346
7398
|
} else {
|
|
7347
7399
|
break;
|
|
@@ -7356,23 +7408,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7356
7408
|
]);
|
|
7357
7409
|
var isSchemaParseReference = (node) => {
|
|
7358
7410
|
const inner = unwrap4(node);
|
|
7359
|
-
return inner !== null && inner.type ===
|
|
7411
|
+
return inner !== null && inner.type === AST_NODE_TYPES38.MemberExpression && !inner.computed && inner.property.type === AST_NODE_TYPES38.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7360
7412
|
};
|
|
7361
7413
|
var isRawPayloadSource = (node) => {
|
|
7362
7414
|
let current = unwrap4(node);
|
|
7363
7415
|
if (current === null) return false;
|
|
7364
|
-
if (current.type ===
|
|
7416
|
+
if (current.type === AST_NODE_TYPES38.AwaitExpression) {
|
|
7365
7417
|
current = unwrap4(current.argument);
|
|
7366
7418
|
}
|
|
7367
|
-
if (current === null || current.type !==
|
|
7419
|
+
if (current === null || current.type !== AST_NODE_TYPES38.CallExpression) {
|
|
7368
7420
|
return false;
|
|
7369
7421
|
}
|
|
7370
7422
|
const callee = unwrap4(current.callee);
|
|
7371
|
-
if (callee === null || callee.type !==
|
|
7423
|
+
if (callee === null || callee.type !== AST_NODE_TYPES38.MemberExpression) {
|
|
7372
7424
|
return false;
|
|
7373
7425
|
}
|
|
7374
7426
|
const property = unwrap4(callee.property);
|
|
7375
|
-
if (property === null || property.type !==
|
|
7427
|
+
if (property === null || property.type !== AST_NODE_TYPES38.Identifier) {
|
|
7376
7428
|
return false;
|
|
7377
7429
|
}
|
|
7378
7430
|
if (property.name === "json") {
|
|
@@ -7382,16 +7434,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7382
7434
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7383
7435
|
}
|
|
7384
7436
|
const object = unwrap4(callee.object);
|
|
7385
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7437
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES38.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7386
7438
|
};
|
|
7387
7439
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7388
7440
|
var isLocalFileRead = (node) => {
|
|
7389
7441
|
let found = false;
|
|
7390
7442
|
const visit = (current) => {
|
|
7391
7443
|
if (found || current === null || current === void 0) return;
|
|
7392
|
-
if (current.type ===
|
|
7444
|
+
if (current.type === AST_NODE_TYPES38.CallExpression) {
|
|
7393
7445
|
const callee = unwrap4(current.callee);
|
|
7394
|
-
const name = callee?.type ===
|
|
7446
|
+
const name = callee?.type === AST_NODE_TYPES38.Identifier ? callee.name : callee?.type === AST_NODE_TYPES38.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES38.Identifier ? callee.property.name : null;
|
|
7395
7447
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7396
7448
|
found = true;
|
|
7397
7449
|
return;
|
|
@@ -7413,15 +7465,15 @@ var isLocalFileRead = (node) => {
|
|
|
7413
7465
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7414
7466
|
var isInsideAssertion = (node) => {
|
|
7415
7467
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7416
|
-
if (current.type !==
|
|
7468
|
+
if (current.type !== AST_NODE_TYPES38.CallExpression) continue;
|
|
7417
7469
|
let callee = current.callee;
|
|
7418
|
-
while (callee.type ===
|
|
7470
|
+
while (callee.type === AST_NODE_TYPES38.MemberExpression) {
|
|
7419
7471
|
callee = callee.object;
|
|
7420
7472
|
}
|
|
7421
|
-
if (callee.type ===
|
|
7473
|
+
if (callee.type === AST_NODE_TYPES38.CallExpression) {
|
|
7422
7474
|
callee = callee.callee;
|
|
7423
7475
|
}
|
|
7424
|
-
if (callee.type ===
|
|
7476
|
+
if (callee.type === AST_NODE_TYPES38.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7425
7477
|
return true;
|
|
7426
7478
|
}
|
|
7427
7479
|
}
|
|
@@ -7440,39 +7492,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7440
7492
|
var isValidationRead = (node) => {
|
|
7441
7493
|
let current = node;
|
|
7442
7494
|
let parent = current.parent;
|
|
7443
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7495
|
+
while (parent !== null && parent !== void 0 && (parent.type === AST_NODE_TYPES38.TSAsExpression || parent.type === AST_NODE_TYPES38.TSTypeAssertion || parent.type === AST_NODE_TYPES38.TSNonNullExpression || parent.type === AST_NODE_TYPES38.TSSatisfiesExpression || parent.type === AST_NODE_TYPES38.ChainExpression)) {
|
|
7444
7496
|
current = parent;
|
|
7445
7497
|
parent = parent.parent;
|
|
7446
7498
|
}
|
|
7447
7499
|
if (parent === null || parent === void 0) return false;
|
|
7448
|
-
if (parent.type ===
|
|
7500
|
+
if (parent.type === AST_NODE_TYPES38.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7449
7501
|
return true;
|
|
7450
7502
|
}
|
|
7451
|
-
if (parent.type !==
|
|
7503
|
+
if (parent.type !== AST_NODE_TYPES38.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7452
7504
|
return false;
|
|
7453
7505
|
}
|
|
7454
7506
|
const callee = parent.callee;
|
|
7455
|
-
if (callee.type ===
|
|
7507
|
+
if (callee.type === AST_NODE_TYPES38.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES38.Identifier && callee.object.name === "Array" && callee.property.type === AST_NODE_TYPES38.Identifier && callee.property.name === "isArray") {
|
|
7456
7508
|
return parent.arguments.length === 1;
|
|
7457
7509
|
}
|
|
7458
|
-
return callee.type ===
|
|
7510
|
+
return callee.type === AST_NODE_TYPES38.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7459
7511
|
};
|
|
7460
7512
|
var isGuardTestPosition = (node) => {
|
|
7461
7513
|
let current = node;
|
|
7462
7514
|
let parent = current.parent;
|
|
7463
7515
|
while (parent !== void 0 && parent !== null) {
|
|
7464
7516
|
switch (parent.type) {
|
|
7465
|
-
case
|
|
7466
|
-
case
|
|
7467
|
-
case
|
|
7517
|
+
case AST_NODE_TYPES38.UnaryExpression:
|
|
7518
|
+
case AST_NODE_TYPES38.LogicalExpression:
|
|
7519
|
+
case AST_NODE_TYPES38.ChainExpression:
|
|
7468
7520
|
current = parent;
|
|
7469
7521
|
parent = parent.parent;
|
|
7470
7522
|
continue;
|
|
7471
|
-
case
|
|
7472
|
-
case
|
|
7473
|
-
case
|
|
7474
|
-
case
|
|
7475
|
-
case
|
|
7523
|
+
case AST_NODE_TYPES38.IfStatement:
|
|
7524
|
+
case AST_NODE_TYPES38.ConditionalExpression:
|
|
7525
|
+
case AST_NODE_TYPES38.WhileStatement:
|
|
7526
|
+
case AST_NODE_TYPES38.DoWhileStatement:
|
|
7527
|
+
case AST_NODE_TYPES38.ForStatement:
|
|
7476
7528
|
return parent.test === current;
|
|
7477
7529
|
default:
|
|
7478
7530
|
return false;
|
|
@@ -7482,7 +7534,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7482
7534
|
};
|
|
7483
7535
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7484
7536
|
const unwrapped = unwrap4(node);
|
|
7485
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7537
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES38.Identifier) {
|
|
7486
7538
|
return false;
|
|
7487
7539
|
}
|
|
7488
7540
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7525,11 +7577,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7525
7577
|
return {
|
|
7526
7578
|
VariableDeclarator(node) {
|
|
7527
7579
|
const scope = context.sourceCode.getScope(node);
|
|
7528
|
-
if (node.id.type ===
|
|
7580
|
+
if (node.id.type === AST_NODE_TYPES38.Identifier) {
|
|
7529
7581
|
trackInitializer(node);
|
|
7530
7582
|
return;
|
|
7531
7583
|
}
|
|
7532
|
-
if (node.id.type ===
|
|
7584
|
+
if (node.id.type === AST_NODE_TYPES38.ObjectPattern || node.id.type === AST_NODE_TYPES38.ArrayPattern) {
|
|
7533
7585
|
if (isRawPayloadSource(node.init)) {
|
|
7534
7586
|
if (!isFullyNarrowedPattern(node)) {
|
|
7535
7587
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7543,7 +7595,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7543
7595
|
},
|
|
7544
7596
|
AssignmentExpression(node) {
|
|
7545
7597
|
const scope = context.sourceCode.getScope(node);
|
|
7546
|
-
if (node.left.type ===
|
|
7598
|
+
if (node.left.type === AST_NODE_TYPES38.Identifier) {
|
|
7547
7599
|
const variable = findVariable2(scope, node.left.name);
|
|
7548
7600
|
if (variable === null) return;
|
|
7549
7601
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7553,7 +7605,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7553
7605
|
}
|
|
7554
7606
|
return;
|
|
7555
7607
|
}
|
|
7556
|
-
if (node.left.type ===
|
|
7608
|
+
if (node.left.type === AST_NODE_TYPES38.ObjectPattern || node.left.type === AST_NODE_TYPES38.ArrayPattern) {
|
|
7557
7609
|
if (isRawPayloadSource(node.right)) {
|
|
7558
7610
|
context.report({
|
|
7559
7611
|
node: node.left,
|
|
@@ -7570,15 +7622,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7570
7622
|
}
|
|
7571
7623
|
},
|
|
7572
7624
|
CallExpression(node) {
|
|
7573
|
-
if (node.callee.type !==
|
|
7625
|
+
if (node.callee.type !== AST_NODE_TYPES38.Identifier) return;
|
|
7574
7626
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7575
7627
|
return;
|
|
7576
7628
|
}
|
|
7577
7629
|
const scope = context.sourceCode.getScope(node);
|
|
7578
7630
|
for (const arg of node.arguments) {
|
|
7579
|
-
if (arg.type ===
|
|
7631
|
+
if (arg.type === AST_NODE_TYPES38.SpreadElement) continue;
|
|
7580
7632
|
const unwrapped = unwrap4(arg);
|
|
7581
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7633
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES38.Identifier) {
|
|
7582
7634
|
continue;
|
|
7583
7635
|
}
|
|
7584
7636
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7592,13 +7644,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7592
7644
|
const obj = unwrap4(node.object);
|
|
7593
7645
|
if (isRawPayloadSource(obj)) {
|
|
7594
7646
|
const parent = node.parent;
|
|
7595
|
-
if (parent.type ===
|
|
7647
|
+
if (parent.type === AST_NODE_TYPES38.CallExpression && parent.callee === node && node.property.type === AST_NODE_TYPES38.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7596
7648
|
return;
|
|
7597
7649
|
}
|
|
7598
7650
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7599
7651
|
return;
|
|
7600
7652
|
}
|
|
7601
|
-
if (obj !== null && obj.type ===
|
|
7653
|
+
if (obj !== null && obj.type === AST_NODE_TYPES38.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7602
7654
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7603
7655
|
const variable = findVariable2(scope, obj.name);
|
|
7604
7656
|
if (variable !== null) {
|
|
@@ -7611,7 +7663,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7611
7663
|
});
|
|
7612
7664
|
|
|
7613
7665
|
// src/rules/prefer-semantic-colors.ts
|
|
7614
|
-
import { AST_NODE_TYPES as
|
|
7666
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39 } from "@typescript-eslint/utils";
|
|
7615
7667
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
7616
7668
|
import { dirname, join, parse } from "path";
|
|
7617
7669
|
|
|
@@ -7711,8 +7763,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7711
7763
|
]);
|
|
7712
7764
|
function jsxElementName(node) {
|
|
7713
7765
|
const name = node.openingElement.name;
|
|
7714
|
-
if (name.type ===
|
|
7715
|
-
if (name.type ===
|
|
7766
|
+
if (name.type === AST_NODE_TYPES39.JSXIdentifier) return name.name;
|
|
7767
|
+
if (name.type === AST_NODE_TYPES39.JSXMemberExpression && name.property.type === AST_NODE_TYPES39.JSXIdentifier) {
|
|
7716
7768
|
return name.property.name;
|
|
7717
7769
|
}
|
|
7718
7770
|
return null;
|
|
@@ -7738,7 +7790,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7738
7790
|
var isInsideSvg = (node) => {
|
|
7739
7791
|
let current = node.parent;
|
|
7740
7792
|
while (current !== void 0 && current !== null) {
|
|
7741
|
-
if (current.type ===
|
|
7793
|
+
if (current.type === AST_NODE_TYPES39.JSXElement) {
|
|
7742
7794
|
const name = jsxElementName(current);
|
|
7743
7795
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7744
7796
|
}
|
|
@@ -7749,7 +7801,7 @@ var isInsideSvg = (node) => {
|
|
|
7749
7801
|
var isInsideIconFactoryPath = (node) => {
|
|
7750
7802
|
let current = node.parent;
|
|
7751
7803
|
while (current !== void 0 && current !== null) {
|
|
7752
|
-
if (current.type ===
|
|
7804
|
+
if (current.type === AST_NODE_TYPES39.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES39.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES39.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES39.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7753
7805
|
return true;
|
|
7754
7806
|
}
|
|
7755
7807
|
current = current.parent;
|
|
@@ -7886,12 +7938,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7886
7938
|
return root !== null && workspaceHasMarker(root);
|
|
7887
7939
|
};
|
|
7888
7940
|
var propName = (key) => {
|
|
7889
|
-
if (key.type ===
|
|
7890
|
-
if (key.type ===
|
|
7941
|
+
if (key.type === AST_NODE_TYPES39.Identifier) return key.name;
|
|
7942
|
+
if (key.type === AST_NODE_TYPES39.Literal && typeof key.value === "string") return key.value;
|
|
7891
7943
|
return null;
|
|
7892
7944
|
};
|
|
7893
7945
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7894
|
-
if (statement.type !==
|
|
7946
|
+
if (statement.type !== AST_NODE_TYPES39.ImportDeclaration && statement.type !== AST_NODE_TYPES39.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES39.ExportAllDeclaration) {
|
|
7895
7947
|
return false;
|
|
7896
7948
|
}
|
|
7897
7949
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -7943,27 +7995,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7943
7995
|
const checkClassNode = (node) => {
|
|
7944
7996
|
if (node === null) return;
|
|
7945
7997
|
switch (node.type) {
|
|
7946
|
-
case
|
|
7998
|
+
case AST_NODE_TYPES39.Literal:
|
|
7947
7999
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7948
8000
|
break;
|
|
7949
|
-
case
|
|
8001
|
+
case AST_NODE_TYPES39.TemplateLiteral:
|
|
7950
8002
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7951
8003
|
break;
|
|
7952
|
-
case
|
|
8004
|
+
case AST_NODE_TYPES39.ArrayExpression:
|
|
7953
8005
|
for (const element of node.elements) {
|
|
7954
|
-
if (element !== null && element.type !==
|
|
8006
|
+
if (element !== null && element.type !== AST_NODE_TYPES39.SpreadElement) checkClassNode(element);
|
|
7955
8007
|
}
|
|
7956
8008
|
break;
|
|
7957
|
-
case
|
|
8009
|
+
case AST_NODE_TYPES39.ObjectExpression:
|
|
7958
8010
|
for (const property of node.properties) {
|
|
7959
|
-
if (property.type ===
|
|
8011
|
+
if (property.type === AST_NODE_TYPES39.Property) checkClassNode(property.value);
|
|
7960
8012
|
}
|
|
7961
8013
|
break;
|
|
7962
|
-
case
|
|
8014
|
+
case AST_NODE_TYPES39.ConditionalExpression:
|
|
7963
8015
|
checkClassNode(node.consequent);
|
|
7964
8016
|
checkClassNode(node.alternate);
|
|
7965
8017
|
break;
|
|
7966
|
-
case
|
|
8018
|
+
case AST_NODE_TYPES39.LogicalExpression:
|
|
7967
8019
|
checkClassNode(node.right);
|
|
7968
8020
|
break;
|
|
7969
8021
|
default:
|
|
@@ -7971,32 +8023,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7971
8023
|
}
|
|
7972
8024
|
};
|
|
7973
8025
|
const checkColorValueNode = (node) => {
|
|
7974
|
-
if (node.type ===
|
|
8026
|
+
if (node.type === AST_NODE_TYPES39.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
7975
8027
|
report(node, "inlineColor", { value: node.value });
|
|
7976
8028
|
}
|
|
7977
8029
|
};
|
|
7978
8030
|
return {
|
|
7979
8031
|
"JSXAttribute[name.name='className']"(node) {
|
|
7980
8032
|
if (node.value === null) return;
|
|
7981
|
-
if (node.value.type ===
|
|
7982
|
-
else if (node.value.type ===
|
|
7983
|
-
if (node.value.expression.type !==
|
|
8033
|
+
if (node.value.type === AST_NODE_TYPES39.Literal) checkClassNode(node.value);
|
|
8034
|
+
else if (node.value.type === AST_NODE_TYPES39.JSXExpressionContainer) {
|
|
8035
|
+
if (node.value.expression.type !== AST_NODE_TYPES39.JSXEmptyExpression) {
|
|
7984
8036
|
checkClassNode(node.value.expression);
|
|
7985
8037
|
}
|
|
7986
8038
|
}
|
|
7987
8039
|
},
|
|
7988
8040
|
CallExpression(node) {
|
|
7989
|
-
if (node.callee.type ===
|
|
8041
|
+
if (node.callee.type === AST_NODE_TYPES39.Identifier && node.callee.name === "require" && node.arguments[0]?.type === AST_NODE_TYPES39.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
7990
8042
|
importsEmailOrPdfRenderer = true;
|
|
7991
8043
|
}
|
|
7992
|
-
if (node.callee.type ===
|
|
8044
|
+
if (node.callee.type === AST_NODE_TYPES39.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7993
8045
|
for (const arg of node.arguments) {
|
|
7994
|
-
if (arg.type !==
|
|
8046
|
+
if (arg.type !== AST_NODE_TYPES39.SpreadElement) checkClassNode(arg);
|
|
7995
8047
|
}
|
|
7996
8048
|
}
|
|
7997
8049
|
},
|
|
7998
8050
|
VariableDeclarator(node) {
|
|
7999
|
-
if (node.id.type ===
|
|
8051
|
+
if (node.id.type === AST_NODE_TYPES39.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8000
8052
|
checkClassNode(node.init);
|
|
8001
8053
|
}
|
|
8002
8054
|
},
|
|
@@ -8006,9 +8058,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8006
8058
|
},
|
|
8007
8059
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8008
8060
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8009
|
-
if (node.value?.type !==
|
|
8061
|
+
if (node.value?.type !== AST_NODE_TYPES39.Literal) return;
|
|
8010
8062
|
const owner = node.parent.name;
|
|
8011
|
-
if (owner.type ===
|
|
8063
|
+
if (owner.type === AST_NODE_TYPES39.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8012
8064
|
return;
|
|
8013
8065
|
}
|
|
8014
8066
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8022,7 +8074,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8022
8074
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8023
8075
|
},
|
|
8024
8076
|
ImportExpression(node) {
|
|
8025
|
-
if (node.source.type ===
|
|
8077
|
+
if (node.source.type === AST_NODE_TYPES39.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8026
8078
|
importsEmailOrPdfRenderer = true;
|
|
8027
8079
|
}
|
|
8028
8080
|
},
|
|
@@ -8228,7 +8280,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8228
8280
|
// src/rules/prefer-string-literal-union.ts
|
|
8229
8281
|
import {
|
|
8230
8282
|
ESLintUtils as ESLintUtils3,
|
|
8231
|
-
AST_NODE_TYPES as
|
|
8283
|
+
AST_NODE_TYPES as AST_NODE_TYPES40
|
|
8232
8284
|
} from "@typescript-eslint/utils";
|
|
8233
8285
|
import * as ts2 from "typescript";
|
|
8234
8286
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -8272,19 +8324,19 @@ function isChoiceLikeName(name) {
|
|
|
8272
8324
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8273
8325
|
}
|
|
8274
8326
|
function keyName(key) {
|
|
8275
|
-
if (key.type ===
|
|
8327
|
+
if (key.type === AST_NODE_TYPES40.Identifier) {
|
|
8276
8328
|
return key.name;
|
|
8277
8329
|
}
|
|
8278
|
-
if (key.type ===
|
|
8330
|
+
if (key.type === AST_NODE_TYPES40.Literal && typeof key.value === "string") {
|
|
8279
8331
|
return key.value;
|
|
8280
8332
|
}
|
|
8281
8333
|
return null;
|
|
8282
8334
|
}
|
|
8283
8335
|
function isStringLiteralMember(t) {
|
|
8284
|
-
return t.type ===
|
|
8336
|
+
return t.type === AST_NODE_TYPES40.TSLiteralType && t.literal.type === AST_NODE_TYPES40.Literal && typeof t.literal.value === "string";
|
|
8285
8337
|
}
|
|
8286
8338
|
function isStringLiteralUnion(node) {
|
|
8287
|
-
if (node?.type !==
|
|
8339
|
+
if (node?.type !== AST_NODE_TYPES40.TSUnionType) {
|
|
8288
8340
|
return false;
|
|
8289
8341
|
}
|
|
8290
8342
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8313,12 +8365,12 @@ function bindingSourceExpression(decl) {
|
|
|
8313
8365
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8314
8366
|
}
|
|
8315
8367
|
function refKey(node) {
|
|
8316
|
-
if (node.type ===
|
|
8368
|
+
if (node.type === AST_NODE_TYPES40.Identifier) {
|
|
8317
8369
|
return node.name;
|
|
8318
8370
|
}
|
|
8319
|
-
if (node.type ===
|
|
8371
|
+
if (node.type === AST_NODE_TYPES40.MemberExpression && !node.computed) {
|
|
8320
8372
|
const inner = refKey(node.object);
|
|
8321
|
-
if (inner === null || node.property.type !==
|
|
8373
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES40.Identifier) {
|
|
8322
8374
|
return null;
|
|
8323
8375
|
}
|
|
8324
8376
|
return `${inner}.${node.property.name}`;
|
|
@@ -8326,7 +8378,7 @@ function refKey(node) {
|
|
|
8326
8378
|
return null;
|
|
8327
8379
|
}
|
|
8328
8380
|
function strLiteral(node) {
|
|
8329
|
-
if (node.type ===
|
|
8381
|
+
if (node.type === AST_NODE_TYPES40.Literal && typeof node.value === "string") {
|
|
8330
8382
|
return node.value;
|
|
8331
8383
|
}
|
|
8332
8384
|
return null;
|
|
@@ -8479,7 +8531,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8479
8531
|
containersWithUnion.add(container);
|
|
8480
8532
|
return;
|
|
8481
8533
|
}
|
|
8482
|
-
if (typeNode?.type !==
|
|
8534
|
+
if (typeNode?.type !== AST_NODE_TYPES40.TSStringKeyword) {
|
|
8483
8535
|
return;
|
|
8484
8536
|
}
|
|
8485
8537
|
const name = keyName(key);
|
|
@@ -8567,10 +8619,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8567
8619
|
}
|
|
8568
8620
|
};
|
|
8569
8621
|
function refKeyText(node) {
|
|
8570
|
-
if (node.type ===
|
|
8622
|
+
if (node.type === AST_NODE_TYPES40.BinaryExpression) {
|
|
8571
8623
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8572
8624
|
}
|
|
8573
|
-
if (node.type ===
|
|
8625
|
+
if (node.type === AST_NODE_TYPES40.SwitchStatement) {
|
|
8574
8626
|
return refKey(node.discriminant) ?? "value";
|
|
8575
8627
|
}
|
|
8576
8628
|
return "value";
|
|
@@ -8579,7 +8631,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8579
8631
|
});
|
|
8580
8632
|
|
|
8581
8633
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8582
|
-
import { AST_NODE_TYPES as
|
|
8634
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41 } from "@typescript-eslint/utils";
|
|
8583
8635
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8584
8636
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8585
8637
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8588,11 +8640,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8588
8640
|
var MIN_RUN_LENGTH = 2;
|
|
8589
8641
|
function literalText(node, getText) {
|
|
8590
8642
|
switch (node.type) {
|
|
8591
|
-
case
|
|
8643
|
+
case AST_NODE_TYPES41.Literal:
|
|
8592
8644
|
return "regex" in node ? null : getText(node);
|
|
8593
|
-
case
|
|
8645
|
+
case AST_NODE_TYPES41.TemplateLiteral:
|
|
8594
8646
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8595
|
-
case
|
|
8647
|
+
case AST_NODE_TYPES41.UnaryExpression:
|
|
8596
8648
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8597
8649
|
default:
|
|
8598
8650
|
return null;
|
|
@@ -8600,15 +8652,15 @@ function literalText(node, getText) {
|
|
|
8600
8652
|
}
|
|
8601
8653
|
function isPureReceiver(node) {
|
|
8602
8654
|
switch (node.type) {
|
|
8603
|
-
case
|
|
8604
|
-
case
|
|
8655
|
+
case AST_NODE_TYPES41.Identifier:
|
|
8656
|
+
case AST_NODE_TYPES41.ThisExpression:
|
|
8605
8657
|
return true;
|
|
8606
|
-
case
|
|
8658
|
+
case AST_NODE_TYPES41.MemberExpression:
|
|
8607
8659
|
if (node.optional) {
|
|
8608
8660
|
return false;
|
|
8609
8661
|
}
|
|
8610
8662
|
if (node.computed) {
|
|
8611
|
-
return node.property.type ===
|
|
8663
|
+
return node.property.type === AST_NODE_TYPES41.Literal && isPureReceiver(node.object);
|
|
8612
8664
|
}
|
|
8613
8665
|
return isPureReceiver(node.object);
|
|
8614
8666
|
default:
|
|
@@ -8616,7 +8668,7 @@ function isPureReceiver(node) {
|
|
|
8616
8668
|
}
|
|
8617
8669
|
}
|
|
8618
8670
|
function literalIndex(node) {
|
|
8619
|
-
if (node.type !==
|
|
8671
|
+
if (node.type !== AST_NODE_TYPES41.Literal || typeof node.value !== "number") {
|
|
8620
8672
|
return null;
|
|
8621
8673
|
}
|
|
8622
8674
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8642,24 +8694,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8642
8694
|
}
|
|
8643
8695
|
const { sourceCode } = context;
|
|
8644
8696
|
function parseAssertion(statement) {
|
|
8645
|
-
if (statement.type !==
|
|
8697
|
+
if (statement.type !== AST_NODE_TYPES41.ExpressionStatement) {
|
|
8646
8698
|
return null;
|
|
8647
8699
|
}
|
|
8648
8700
|
const call = statement.expression;
|
|
8649
|
-
if (call.type !==
|
|
8701
|
+
if (call.type !== AST_NODE_TYPES41.CallExpression) {
|
|
8650
8702
|
return null;
|
|
8651
8703
|
}
|
|
8652
8704
|
const callee = call.callee;
|
|
8653
|
-
if (callee.type !==
|
|
8705
|
+
if (callee.type !== AST_NODE_TYPES41.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES41.Identifier) {
|
|
8654
8706
|
return null;
|
|
8655
8707
|
}
|
|
8656
8708
|
const matcher = callee.property.name;
|
|
8657
8709
|
const expectCall = callee.object;
|
|
8658
|
-
if (expectCall.type !==
|
|
8710
|
+
if (expectCall.type !== AST_NODE_TYPES41.CallExpression || expectCall.callee.type !== AST_NODE_TYPES41.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8659
8711
|
return null;
|
|
8660
8712
|
}
|
|
8661
8713
|
const actual = expectCall.arguments[0];
|
|
8662
|
-
if (actual === void 0 || actual.type !==
|
|
8714
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES41.MemberExpression || actual.optional) {
|
|
8663
8715
|
return null;
|
|
8664
8716
|
}
|
|
8665
8717
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8673,7 +8725,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8673
8725
|
}
|
|
8674
8726
|
key = { kind: "index", index };
|
|
8675
8727
|
} else {
|
|
8676
|
-
if (actual.property.type !==
|
|
8728
|
+
if (actual.property.type !== AST_NODE_TYPES41.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8677
8729
|
return null;
|
|
8678
8730
|
}
|
|
8679
8731
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8685,7 +8737,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8685
8737
|
return null;
|
|
8686
8738
|
}
|
|
8687
8739
|
const expected = call.arguments[0];
|
|
8688
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8740
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES41.SpreadElement) {
|
|
8689
8741
|
return null;
|
|
8690
8742
|
}
|
|
8691
8743
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8800,7 +8852,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8800
8852
|
});
|
|
8801
8853
|
|
|
8802
8854
|
// src/rules/prefer-zod-enum.ts
|
|
8803
|
-
import { AST_NODE_TYPES as
|
|
8855
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42 } from "@typescript-eslint/utils";
|
|
8804
8856
|
var prefer_zod_enum_default = createRule({
|
|
8805
8857
|
name: "prefer-zod-enum",
|
|
8806
8858
|
meta: {
|
|
@@ -8820,25 +8872,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
8820
8872
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8821
8873
|
function enumValues(node) {
|
|
8822
8874
|
const callee = node.callee;
|
|
8823
|
-
if (callee.type !==
|
|
8875
|
+
if (callee.type !== AST_NODE_TYPES42.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES42.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== AST_NODE_TYPES42.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8824
8876
|
return null;
|
|
8825
8877
|
}
|
|
8826
8878
|
const argument = node.arguments[0];
|
|
8827
|
-
if (argument === void 0 || argument.type !==
|
|
8879
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES42.ArrayExpression || argument.elements.length === 0) {
|
|
8828
8880
|
return null;
|
|
8829
8881
|
}
|
|
8830
8882
|
const values = [];
|
|
8831
8883
|
let canFix = true;
|
|
8832
8884
|
for (const element of argument.elements) {
|
|
8833
|
-
if (element?.type ===
|
|
8885
|
+
if (element?.type === AST_NODE_TYPES42.SpreadElement) {
|
|
8834
8886
|
canFix = false;
|
|
8835
8887
|
continue;
|
|
8836
8888
|
}
|
|
8837
|
-
if (element === null || element.type !==
|
|
8889
|
+
if (element === null || element.type !== AST_NODE_TYPES42.CallExpression || element.callee.type !== AST_NODE_TYPES42.MemberExpression || element.callee.computed || element.callee.object.type !== AST_NODE_TYPES42.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== AST_NODE_TYPES42.Identifier || element.callee.property.name !== "literal") {
|
|
8838
8890
|
return null;
|
|
8839
8891
|
}
|
|
8840
8892
|
const value = element.arguments[0];
|
|
8841
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
8893
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== AST_NODE_TYPES42.Literal || typeof value.value !== "string") {
|
|
8842
8894
|
canFix = false;
|
|
8843
8895
|
continue;
|
|
8844
8896
|
}
|
|
@@ -8848,11 +8900,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
8848
8900
|
}
|
|
8849
8901
|
function buildFix(node, values) {
|
|
8850
8902
|
const argument = node.arguments[0];
|
|
8851
|
-
if (argument === void 0 || argument.type !==
|
|
8903
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES42.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8852
8904
|
return void 0;
|
|
8853
8905
|
}
|
|
8854
8906
|
const callee = node.callee;
|
|
8855
|
-
if (callee.type !==
|
|
8907
|
+
if (callee.type !== AST_NODE_TYPES42.MemberExpression || callee.property.type !== AST_NODE_TYPES42.Identifier) {
|
|
8856
8908
|
return void 0;
|
|
8857
8909
|
}
|
|
8858
8910
|
return (fixer) => [
|
|
@@ -8869,7 +8921,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8869
8921
|
return;
|
|
8870
8922
|
}
|
|
8871
8923
|
for (const specifier of node.specifiers) {
|
|
8872
|
-
if (specifier.type ===
|
|
8924
|
+
if (specifier.type === AST_NODE_TYPES42.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES42.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES42.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES42.Identifier && specifier.imported.name === "z") {
|
|
8873
8925
|
zodNamespaces.add(specifier.local.name);
|
|
8874
8926
|
}
|
|
8875
8927
|
}
|
|
@@ -8891,7 +8943,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8891
8943
|
});
|
|
8892
8944
|
|
|
8893
8945
|
// src/rules/prefer-zod-infer.ts
|
|
8894
|
-
import { AST_NODE_TYPES as
|
|
8946
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43 } from "@typescript-eslint/utils";
|
|
8895
8947
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8896
8948
|
"describe",
|
|
8897
8949
|
"refine",
|
|
@@ -8928,44 +8980,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8928
8980
|
"Schema"
|
|
8929
8981
|
]);
|
|
8930
8982
|
var LEAF_NODE_TYPES = {
|
|
8931
|
-
string: [
|
|
8932
|
-
email: [
|
|
8933
|
-
url: [
|
|
8934
|
-
uuid: [
|
|
8935
|
-
ulid: [
|
|
8936
|
-
cuid: [
|
|
8937
|
-
cuid2: [
|
|
8938
|
-
nanoid: [
|
|
8939
|
-
iso: [
|
|
8940
|
-
number: [
|
|
8941
|
-
int: [
|
|
8942
|
-
float32: [
|
|
8943
|
-
float64: [
|
|
8944
|
-
boolean: [
|
|
8945
|
-
bigint: [
|
|
8946
|
-
symbol: [
|
|
8947
|
-
any: [
|
|
8948
|
-
unknown: [
|
|
8949
|
-
never: [
|
|
8950
|
-
void: [
|
|
8951
|
-
null: [
|
|
8952
|
-
undefined: [
|
|
8953
|
-
literal: [
|
|
8954
|
-
date: [
|
|
8955
|
-
array: [
|
|
8956
|
-
tuple: [
|
|
8957
|
-
object: [
|
|
8958
|
-
strictObject: [
|
|
8959
|
-
looseObject: [
|
|
8960
|
-
record: [
|
|
8961
|
-
map: [
|
|
8962
|
-
set: [
|
|
8963
|
-
promise: [
|
|
8964
|
-
enum: [
|
|
8965
|
-
nativeEnum: [
|
|
8966
|
-
union: [
|
|
8967
|
-
discriminatedUnion: [
|
|
8968
|
-
intersection: [
|
|
8983
|
+
string: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8984
|
+
email: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8985
|
+
url: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8986
|
+
uuid: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8987
|
+
ulid: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8988
|
+
cuid: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8989
|
+
cuid2: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8990
|
+
nanoid: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8991
|
+
iso: [AST_NODE_TYPES43.TSStringKeyword],
|
|
8992
|
+
number: [AST_NODE_TYPES43.TSNumberKeyword],
|
|
8993
|
+
int: [AST_NODE_TYPES43.TSNumberKeyword],
|
|
8994
|
+
float32: [AST_NODE_TYPES43.TSNumberKeyword],
|
|
8995
|
+
float64: [AST_NODE_TYPES43.TSNumberKeyword],
|
|
8996
|
+
boolean: [AST_NODE_TYPES43.TSBooleanKeyword],
|
|
8997
|
+
bigint: [AST_NODE_TYPES43.TSBigIntKeyword],
|
|
8998
|
+
symbol: [AST_NODE_TYPES43.TSSymbolKeyword],
|
|
8999
|
+
any: [AST_NODE_TYPES43.TSAnyKeyword],
|
|
9000
|
+
unknown: [AST_NODE_TYPES43.TSUnknownKeyword],
|
|
9001
|
+
never: [AST_NODE_TYPES43.TSNeverKeyword],
|
|
9002
|
+
void: [AST_NODE_TYPES43.TSVoidKeyword],
|
|
9003
|
+
null: [AST_NODE_TYPES43.TSNullKeyword],
|
|
9004
|
+
undefined: [AST_NODE_TYPES43.TSUndefinedKeyword],
|
|
9005
|
+
literal: [AST_NODE_TYPES43.TSLiteralType],
|
|
9006
|
+
date: [AST_NODE_TYPES43.TSTypeReference],
|
|
9007
|
+
array: [AST_NODE_TYPES43.TSArrayType, AST_NODE_TYPES43.TSTypeReference],
|
|
9008
|
+
tuple: [AST_NODE_TYPES43.TSTupleType],
|
|
9009
|
+
object: [AST_NODE_TYPES43.TSTypeLiteral, AST_NODE_TYPES43.TSTypeReference],
|
|
9010
|
+
strictObject: [AST_NODE_TYPES43.TSTypeLiteral, AST_NODE_TYPES43.TSTypeReference],
|
|
9011
|
+
looseObject: [AST_NODE_TYPES43.TSTypeLiteral, AST_NODE_TYPES43.TSTypeReference],
|
|
9012
|
+
record: [AST_NODE_TYPES43.TSTypeReference, AST_NODE_TYPES43.TSTypeLiteral],
|
|
9013
|
+
map: [AST_NODE_TYPES43.TSTypeReference],
|
|
9014
|
+
set: [AST_NODE_TYPES43.TSTypeReference],
|
|
9015
|
+
promise: [AST_NODE_TYPES43.TSTypeReference],
|
|
9016
|
+
enum: [AST_NODE_TYPES43.TSUnionType, AST_NODE_TYPES43.TSTypeReference, AST_NODE_TYPES43.TSLiteralType],
|
|
9017
|
+
nativeEnum: [AST_NODE_TYPES43.TSUnionType, AST_NODE_TYPES43.TSTypeReference, AST_NODE_TYPES43.TSLiteralType],
|
|
9018
|
+
union: [AST_NODE_TYPES43.TSUnionType, AST_NODE_TYPES43.TSTypeReference],
|
|
9019
|
+
discriminatedUnion: [AST_NODE_TYPES43.TSUnionType, AST_NODE_TYPES43.TSTypeReference],
|
|
9020
|
+
intersection: [AST_NODE_TYPES43.TSIntersectionType, AST_NODE_TYPES43.TSTypeReference]
|
|
8969
9021
|
};
|
|
8970
9022
|
function normalizeSchemaName(name) {
|
|
8971
9023
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8974,20 +9026,20 @@ function normalizeTypeName(name) {
|
|
|
8974
9026
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8975
9027
|
}
|
|
8976
9028
|
function unwrapNullish(annotation) {
|
|
8977
|
-
if (annotation.type !==
|
|
9029
|
+
if (annotation.type !== AST_NODE_TYPES43.TSUnionType) {
|
|
8978
9030
|
return {
|
|
8979
9031
|
core: annotation,
|
|
8980
|
-
nullable: annotation.type ===
|
|
9032
|
+
nullable: annotation.type === AST_NODE_TYPES43.TSNullKeyword
|
|
8981
9033
|
};
|
|
8982
9034
|
}
|
|
8983
9035
|
const rest = [];
|
|
8984
9036
|
let nullable = false;
|
|
8985
9037
|
for (const member of annotation.types) {
|
|
8986
|
-
if (member.type ===
|
|
9038
|
+
if (member.type === AST_NODE_TYPES43.TSNullKeyword) {
|
|
8987
9039
|
nullable = true;
|
|
8988
9040
|
continue;
|
|
8989
9041
|
}
|
|
8990
|
-
if (member.type ===
|
|
9042
|
+
if (member.type === AST_NODE_TYPES43.TSUndefinedKeyword) {
|
|
8991
9043
|
continue;
|
|
8992
9044
|
}
|
|
8993
9045
|
rest.push(member);
|
|
@@ -9052,14 +9104,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9052
9104
|
function zodCallChain(node) {
|
|
9053
9105
|
const chain = [];
|
|
9054
9106
|
let current = node;
|
|
9055
|
-
while (current.type ===
|
|
9107
|
+
while (current.type === AST_NODE_TYPES43.CallExpression) {
|
|
9056
9108
|
const callee = current.callee;
|
|
9057
|
-
if (callee.type !==
|
|
9109
|
+
if (callee.type !== AST_NODE_TYPES43.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES43.Identifier) {
|
|
9058
9110
|
return null;
|
|
9059
9111
|
}
|
|
9060
9112
|
chain.push(current);
|
|
9061
9113
|
const receiver = callee.object;
|
|
9062
|
-
if (receiver.type ===
|
|
9114
|
+
if (receiver.type === AST_NODE_TYPES43.Identifier) {
|
|
9063
9115
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9064
9116
|
}
|
|
9065
9117
|
current = receiver;
|
|
@@ -9068,19 +9120,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9068
9120
|
}
|
|
9069
9121
|
function methodName(call) {
|
|
9070
9122
|
const callee = call.callee;
|
|
9071
|
-
return callee.type ===
|
|
9123
|
+
return callee.type === AST_NODE_TYPES43.MemberExpression && callee.property.type === AST_NODE_TYPES43.Identifier ? callee.property.name : "";
|
|
9072
9124
|
}
|
|
9073
9125
|
function schemaField(node) {
|
|
9074
9126
|
const modifiers = [];
|
|
9075
9127
|
let current = node;
|
|
9076
9128
|
let leaf = null;
|
|
9077
|
-
while (current.type ===
|
|
9129
|
+
while (current.type === AST_NODE_TYPES43.CallExpression) {
|
|
9078
9130
|
const callee = current.callee;
|
|
9079
|
-
if (callee.type !==
|
|
9131
|
+
if (callee.type !== AST_NODE_TYPES43.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES43.Identifier) {
|
|
9080
9132
|
break;
|
|
9081
9133
|
}
|
|
9082
9134
|
const receiver = callee.object;
|
|
9083
|
-
if (receiver.type ===
|
|
9135
|
+
if (receiver.type === AST_NODE_TYPES43.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9084
9136
|
leaf = callee.property.name;
|
|
9085
9137
|
break;
|
|
9086
9138
|
}
|
|
@@ -9111,16 +9163,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9111
9163
|
return null;
|
|
9112
9164
|
}
|
|
9113
9165
|
const shape = base.arguments[0];
|
|
9114
|
-
if (shape === void 0 || shape.type !==
|
|
9166
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES43.ObjectExpression) {
|
|
9115
9167
|
return null;
|
|
9116
9168
|
}
|
|
9117
9169
|
const fields = /* @__PURE__ */ new Map();
|
|
9118
9170
|
for (const property of shape.properties) {
|
|
9119
|
-
if (property.type !==
|
|
9171
|
+
if (property.type !== AST_NODE_TYPES43.Property || property.computed) {
|
|
9120
9172
|
return null;
|
|
9121
9173
|
}
|
|
9122
9174
|
const { key } = property;
|
|
9123
|
-
const name = key.type ===
|
|
9175
|
+
const name = key.type === AST_NODE_TYPES43.Identifier ? key.name : key.type === AST_NODE_TYPES43.Literal && typeof key.value === "string" ? key.value : null;
|
|
9124
9176
|
if (name === null) {
|
|
9125
9177
|
return null;
|
|
9126
9178
|
}
|
|
@@ -9131,11 +9183,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9131
9183
|
function typeMembers(members) {
|
|
9132
9184
|
const result = /* @__PURE__ */ new Map();
|
|
9133
9185
|
for (const member of members) {
|
|
9134
|
-
if (member.type !==
|
|
9186
|
+
if (member.type !== AST_NODE_TYPES43.TSPropertySignature || member.computed) {
|
|
9135
9187
|
return null;
|
|
9136
9188
|
}
|
|
9137
9189
|
const { key } = member;
|
|
9138
|
-
const name = key.type ===
|
|
9190
|
+
const name = key.type === AST_NODE_TYPES43.Identifier ? key.name : key.type === AST_NODE_TYPES43.Literal && typeof key.value === "string" ? key.value : null;
|
|
9139
9191
|
if (name === null) {
|
|
9140
9192
|
return null;
|
|
9141
9193
|
}
|
|
@@ -9149,8 +9201,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9149
9201
|
return result.size === 0 ? null : result;
|
|
9150
9202
|
}
|
|
9151
9203
|
function collectConstrainedNames(node) {
|
|
9152
|
-
if (node.type ===
|
|
9153
|
-
if (node.typeName.type ===
|
|
9204
|
+
if (node.type === AST_NODE_TYPES43.TSTypeReference) {
|
|
9205
|
+
if (node.typeName.type === AST_NODE_TYPES43.Identifier) {
|
|
9154
9206
|
constrainedTypeNames.add(node.typeName.name);
|
|
9155
9207
|
}
|
|
9156
9208
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9158,11 +9210,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9158
9210
|
}
|
|
9159
9211
|
return;
|
|
9160
9212
|
}
|
|
9161
|
-
if (node.type ===
|
|
9213
|
+
if (node.type === AST_NODE_TYPES43.TSArrayType) {
|
|
9162
9214
|
collectConstrainedNames(node.elementType);
|
|
9163
9215
|
return;
|
|
9164
9216
|
}
|
|
9165
|
-
if (node.type ===
|
|
9217
|
+
if (node.type === AST_NODE_TYPES43.TSUnionType || node.type === AST_NODE_TYPES43.TSIntersectionType) {
|
|
9166
9218
|
for (const member of node.types) {
|
|
9167
9219
|
collectConstrainedNames(member);
|
|
9168
9220
|
}
|
|
@@ -9206,13 +9258,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9206
9258
|
return;
|
|
9207
9259
|
}
|
|
9208
9260
|
for (const specifier of node.specifiers) {
|
|
9209
|
-
if (specifier.type ===
|
|
9261
|
+
if (specifier.type === AST_NODE_TYPES43.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES43.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES43.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES43.Identifier && specifier.imported.name === "z") {
|
|
9210
9262
|
zodNamespaces.add(specifier.local.name);
|
|
9211
9263
|
}
|
|
9212
9264
|
}
|
|
9213
9265
|
},
|
|
9214
9266
|
VariableDeclarator(node) {
|
|
9215
|
-
if (node.id.type !==
|
|
9267
|
+
if (node.id.type !== AST_NODE_TYPES43.Identifier || node.init == null) {
|
|
9216
9268
|
return;
|
|
9217
9269
|
}
|
|
9218
9270
|
const fields = schemaFields(node.init);
|
|
@@ -9222,14 +9274,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9222
9274
|
},
|
|
9223
9275
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9224
9276
|
"MemberExpression[computed=false]"(node) {
|
|
9225
|
-
if (node.object.type ===
|
|
9277
|
+
if (node.object.type === AST_NODE_TYPES43.Identifier && node.property.type === AST_NODE_TYPES43.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9226
9278
|
reshapedSchemaNames.add(node.object.name);
|
|
9227
9279
|
}
|
|
9228
9280
|
},
|
|
9229
9281
|
/** Records every type argument carried by a Zod constraint. */
|
|
9230
9282
|
TSTypeReference(node) {
|
|
9231
9283
|
const { typeName } = node;
|
|
9232
|
-
const referenced = typeName.type ===
|
|
9284
|
+
const referenced = typeName.type === AST_NODE_TYPES43.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES43.TSQualifiedName && typeName.right.type === AST_NODE_TYPES43.Identifier ? typeName.right.name : null;
|
|
9233
9285
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9234
9286
|
return;
|
|
9235
9287
|
}
|
|
@@ -9247,7 +9299,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9247
9299
|
}
|
|
9248
9300
|
},
|
|
9249
9301
|
TSTypeAliasDeclaration(node) {
|
|
9250
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9302
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES43.TSTypeLiteral) {
|
|
9251
9303
|
return;
|
|
9252
9304
|
}
|
|
9253
9305
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9292,10 +9344,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9292
9344
|
});
|
|
9293
9345
|
|
|
9294
9346
|
// src/rules/require-assert-never.ts
|
|
9295
|
-
import { AST_NODE_TYPES as
|
|
9347
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44 } from "@typescript-eslint/utils";
|
|
9296
9348
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9297
|
-
if (statement.type ===
|
|
9298
|
-
if (statement.type ===
|
|
9349
|
+
if (statement.type === AST_NODE_TYPES44.EmptyStatement) return false;
|
|
9350
|
+
if (statement.type === AST_NODE_TYPES44.BlockStatement) {
|
|
9299
9351
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9300
9352
|
}
|
|
9301
9353
|
return true;
|
|
@@ -9311,7 +9363,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9311
9363
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9312
9364
|
}
|
|
9313
9365
|
const only = defaultCase.consequent[0];
|
|
9314
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9366
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES44.BlockStatement && only.body.length === 0) {
|
|
9315
9367
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9316
9368
|
}
|
|
9317
9369
|
return false;
|
|
@@ -9351,7 +9403,7 @@ var require_assert_never_default = createRule({
|
|
|
9351
9403
|
});
|
|
9352
9404
|
|
|
9353
9405
|
// src/rules/require-fetch-timeout.ts
|
|
9354
|
-
import { AST_NODE_TYPES as
|
|
9406
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
|
|
9355
9407
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9356
9408
|
"globalThis",
|
|
9357
9409
|
"window",
|
|
@@ -9367,14 +9419,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9367
9419
|
return false;
|
|
9368
9420
|
}
|
|
9369
9421
|
function initProvablyLacksSignal(init) {
|
|
9370
|
-
if (init.type !==
|
|
9422
|
+
if (init.type !== AST_NODE_TYPES45.ObjectExpression) {
|
|
9371
9423
|
return false;
|
|
9372
9424
|
}
|
|
9373
9425
|
for (const prop of init.properties) {
|
|
9374
|
-
if (prop.type ===
|
|
9426
|
+
if (prop.type === AST_NODE_TYPES45.SpreadElement) {
|
|
9375
9427
|
return false;
|
|
9376
9428
|
}
|
|
9377
|
-
if (prop.key.type ===
|
|
9429
|
+
if (prop.key.type === AST_NODE_TYPES45.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES45.Literal && prop.key.value === "signal") {
|
|
9378
9430
|
return false;
|
|
9379
9431
|
}
|
|
9380
9432
|
if (prop.computed) {
|
|
@@ -9384,7 +9436,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9384
9436
|
return true;
|
|
9385
9437
|
}
|
|
9386
9438
|
function isStringish(node) {
|
|
9387
|
-
return node.type ===
|
|
9439
|
+
return node.type === AST_NODE_TYPES45.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES45.TemplateLiteral;
|
|
9388
9440
|
}
|
|
9389
9441
|
var require_fetch_timeout_default = createRule({
|
|
9390
9442
|
name: "require-fetch-timeout",
|
|
@@ -9425,10 +9477,10 @@ var require_fetch_timeout_default = createRule({
|
|
|
9425
9477
|
return variable === null || variable.defs.length === 0;
|
|
9426
9478
|
}
|
|
9427
9479
|
function isGlobalFetchCall2(callee) {
|
|
9428
|
-
if (callee.type ===
|
|
9480
|
+
if (callee.type === AST_NODE_TYPES45.Identifier) {
|
|
9429
9481
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9430
9482
|
}
|
|
9431
|
-
return callee.type ===
|
|
9483
|
+
return callee.type === AST_NODE_TYPES45.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES45.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES45.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9432
9484
|
}
|
|
9433
9485
|
return {
|
|
9434
9486
|
CallExpression(node) {
|
|
@@ -9448,7 +9500,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9448
9500
|
});
|
|
9449
9501
|
|
|
9450
9502
|
// src/rules/require-interface-for-injected-service.ts
|
|
9451
|
-
import { AST_NODE_TYPES as
|
|
9503
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46 } from "@typescript-eslint/utils";
|
|
9452
9504
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9453
9505
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9454
9506
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9456,20 +9508,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9456
9508
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9457
9509
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9458
9510
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9459
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9460
|
-
var qualifiedName = (name) => name.type ===
|
|
9511
|
+
var isExportedClass = (node) => node.parent.type === AST_NODE_TYPES46.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES46.ExportDefaultDeclaration;
|
|
9512
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES46.Identifier ? name.name : name.type === AST_NODE_TYPES46.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9461
9513
|
var readTypeReference = (annotation) => {
|
|
9462
|
-
if (annotation === void 0 || annotation.type !==
|
|
9514
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES46.TSTypeReference) return null;
|
|
9463
9515
|
const { typeName } = annotation;
|
|
9464
|
-
const rightmost = typeName.type ===
|
|
9516
|
+
const rightmost = typeName.type === AST_NODE_TYPES46.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES46.TSQualifiedName ? typeName.right.name : null;
|
|
9465
9517
|
if (rightmost === null) return null;
|
|
9466
9518
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9467
9519
|
};
|
|
9468
9520
|
var namedParameterCollaborator = (annotated) => {
|
|
9469
9521
|
let target = annotated;
|
|
9470
|
-
if (target.type ===
|
|
9471
|
-
if (target.type ===
|
|
9472
|
-
if (target.type !==
|
|
9522
|
+
if (target.type === AST_NODE_TYPES46.TSParameterProperty) target = target.parameter;
|
|
9523
|
+
if (target.type === AST_NODE_TYPES46.AssignmentPattern) target = target.left;
|
|
9524
|
+
if (target.type !== AST_NODE_TYPES46.Identifier) return null;
|
|
9473
9525
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9474
9526
|
if (reference === null) return null;
|
|
9475
9527
|
return { name: target.name, ...reference };
|
|
@@ -9477,8 +9529,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9477
9529
|
var propertySignatureTypes = (members) => {
|
|
9478
9530
|
const types = /* @__PURE__ */ new Map();
|
|
9479
9531
|
for (const member of members) {
|
|
9480
|
-
if (member.type !==
|
|
9481
|
-
if (member.computed || member.key.type !==
|
|
9532
|
+
if (member.type !== AST_NODE_TYPES46.TSPropertySignature) continue;
|
|
9533
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES46.Identifier) continue;
|
|
9482
9534
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9483
9535
|
if (reference === null) continue;
|
|
9484
9536
|
types.set(member.key.name, reference);
|
|
@@ -9489,18 +9541,18 @@ var fileTypeIndex = (program) => {
|
|
|
9489
9541
|
const objects = /* @__PURE__ */ new Map();
|
|
9490
9542
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9491
9543
|
for (const statement of program.body) {
|
|
9492
|
-
const declaration = statement.type ===
|
|
9493
|
-
if (declaration?.type ===
|
|
9544
|
+
const declaration = statement.type === AST_NODE_TYPES46.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9545
|
+
if (declaration?.type === AST_NODE_TYPES46.TSInterfaceDeclaration) {
|
|
9494
9546
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9495
9547
|
continue;
|
|
9496
9548
|
}
|
|
9497
|
-
if (declaration?.type !==
|
|
9549
|
+
if (declaration?.type !== AST_NODE_TYPES46.TSTypeAliasDeclaration) continue;
|
|
9498
9550
|
const aliased = declaration.typeAnnotation;
|
|
9499
|
-
if (aliased.type ===
|
|
9551
|
+
if (aliased.type === AST_NODE_TYPES46.TSFunctionType || aliased.type === AST_NODE_TYPES46.TSConstructorType) {
|
|
9500
9552
|
functionAliases.add(declaration.id.name);
|
|
9501
9553
|
continue;
|
|
9502
9554
|
}
|
|
9503
|
-
const literals = aliased.type ===
|
|
9555
|
+
const literals = aliased.type === AST_NODE_TYPES46.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES46.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES46.TSTypeLiteral) : [];
|
|
9504
9556
|
if (literals.length === 0) continue;
|
|
9505
9557
|
const merged = /* @__PURE__ */ new Map();
|
|
9506
9558
|
for (const literal of literals) {
|
|
@@ -9513,10 +9565,10 @@ var fileTypeIndex = (program) => {
|
|
|
9513
9565
|
return { objects, functionAliases };
|
|
9514
9566
|
};
|
|
9515
9567
|
var bagMemberTypes = (annotation, declared) => {
|
|
9516
|
-
if (annotation.type ===
|
|
9568
|
+
if (annotation.type === AST_NODE_TYPES46.TSTypeLiteral) {
|
|
9517
9569
|
return propertySignatureTypes(annotation.members);
|
|
9518
9570
|
}
|
|
9519
|
-
if (annotation.type !==
|
|
9571
|
+
if (annotation.type !== AST_NODE_TYPES46.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES46.Identifier) {
|
|
9520
9572
|
return null;
|
|
9521
9573
|
}
|
|
9522
9574
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9528,11 +9580,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9528
9580
|
if (members === null) return [];
|
|
9529
9581
|
const collaborators = [];
|
|
9530
9582
|
for (const property of pattern.properties) {
|
|
9531
|
-
if (property.type !==
|
|
9532
|
-
if (property.key.type !==
|
|
9583
|
+
if (property.type !== AST_NODE_TYPES46.Property || property.computed) continue;
|
|
9584
|
+
if (property.key.type !== AST_NODE_TYPES46.Identifier) continue;
|
|
9533
9585
|
const key = property.key.name;
|
|
9534
|
-
const bound = property.value.type ===
|
|
9535
|
-
if (bound.type !==
|
|
9586
|
+
const bound = property.value.type === AST_NODE_TYPES46.AssignmentPattern ? property.value.left : property.value;
|
|
9587
|
+
if (bound.type !== AST_NODE_TYPES46.Identifier) continue;
|
|
9536
9588
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9537
9589
|
const reference = members.get(key);
|
|
9538
9590
|
if (reference === void 0) continue;
|
|
@@ -9542,8 +9594,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9542
9594
|
};
|
|
9543
9595
|
var parameterCollaborators = (parameter, declared) => {
|
|
9544
9596
|
let target = parameter;
|
|
9545
|
-
if (target.type ===
|
|
9546
|
-
if (target.type ===
|
|
9597
|
+
if (target.type === AST_NODE_TYPES46.AssignmentPattern) target = target.left;
|
|
9598
|
+
if (target.type === AST_NODE_TYPES46.ObjectPattern) {
|
|
9547
9599
|
return objectPatternCollaborators(target, declared);
|
|
9548
9600
|
}
|
|
9549
9601
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9562,17 +9614,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9562
9614
|
let constructedFields = 0;
|
|
9563
9615
|
if (body2 !== null && body2 !== void 0) {
|
|
9564
9616
|
for (const statement of body2.body) {
|
|
9565
|
-
if (statement.type !==
|
|
9617
|
+
if (statement.type !== AST_NODE_TYPES46.ExpressionStatement) continue;
|
|
9566
9618
|
const expression = statement.expression;
|
|
9567
|
-
if (expression.type !==
|
|
9619
|
+
if (expression.type !== AST_NODE_TYPES46.AssignmentExpression || expression.operator !== "=" || expression.left.type !== AST_NODE_TYPES46.MemberExpression || expression.left.object.type !== AST_NODE_TYPES46.ThisExpression) {
|
|
9568
9620
|
continue;
|
|
9569
9621
|
}
|
|
9570
9622
|
const source = expression.right;
|
|
9571
|
-
if (source.type ===
|
|
9623
|
+
if (source.type === AST_NODE_TYPES46.NewExpression) {
|
|
9572
9624
|
constructedFields += 1;
|
|
9573
|
-
} else if (source.type ===
|
|
9625
|
+
} else if (source.type === AST_NODE_TYPES46.Identifier) {
|
|
9574
9626
|
storedFrom.add(source.name);
|
|
9575
|
-
} else if (source.type ===
|
|
9627
|
+
} else if (source.type === AST_NODE_TYPES46.MemberExpression && source.object.type === AST_NODE_TYPES46.Identifier) {
|
|
9576
9628
|
storedFrom.add(source.object.name);
|
|
9577
9629
|
}
|
|
9578
9630
|
}
|
|
@@ -9580,7 +9632,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9580
9632
|
const collaborators = [];
|
|
9581
9633
|
for (const parameter of ctor.value.params) {
|
|
9582
9634
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9583
|
-
const stored = parameter.type ===
|
|
9635
|
+
const stored = parameter.type === AST_NODE_TYPES46.TSParameterProperty || storedFrom.has(reference.name);
|
|
9584
9636
|
if (!stored) continue;
|
|
9585
9637
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9586
9638
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9614,19 +9666,19 @@ var subtreeHas = (root, found) => {
|
|
|
9614
9666
|
return hit;
|
|
9615
9667
|
};
|
|
9616
9668
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9617
|
-
if (node.type ===
|
|
9669
|
+
if (node.type === AST_NODE_TYPES46.CallExpression) {
|
|
9618
9670
|
const { callee } = node;
|
|
9619
|
-
if (callee.type ===
|
|
9620
|
-
return callee.type ===
|
|
9671
|
+
if (callee.type === AST_NODE_TYPES46.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9672
|
+
return callee.type === AST_NODE_TYPES46.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES46.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9621
9673
|
}
|
|
9622
|
-
return node.type ===
|
|
9674
|
+
return node.type === AST_NODE_TYPES46.TSTypeReference && node.typeName.type === AST_NODE_TYPES46.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9623
9675
|
});
|
|
9624
9676
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9625
9677
|
var fileInterfaceNames = (program) => {
|
|
9626
9678
|
const names = [];
|
|
9627
9679
|
for (const statement of program.body) {
|
|
9628
|
-
const declaration = statement.type ===
|
|
9629
|
-
if (declaration?.type ===
|
|
9680
|
+
const declaration = statement.type === AST_NODE_TYPES46.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9681
|
+
if (declaration?.type === AST_NODE_TYPES46.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9630
9682
|
}
|
|
9631
9683
|
return names;
|
|
9632
9684
|
};
|
|
@@ -9644,11 +9696,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9644
9696
|
var publicMethodNames = (body2) => {
|
|
9645
9697
|
const names = [];
|
|
9646
9698
|
for (const member of body2.body) {
|
|
9647
|
-
if (member.type !==
|
|
9699
|
+
if (member.type !== AST_NODE_TYPES46.MethodDefinition) continue;
|
|
9648
9700
|
if (member.kind !== "method" || member.static) continue;
|
|
9649
9701
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9650
|
-
if (member.key.type ===
|
|
9651
|
-
if (member.key.type ===
|
|
9702
|
+
if (member.key.type === AST_NODE_TYPES46.PrivateIdentifier) continue;
|
|
9703
|
+
if (member.key.type === AST_NODE_TYPES46.Identifier) names.push(member.key.name);
|
|
9652
9704
|
else names.push("\u2026");
|
|
9653
9705
|
}
|
|
9654
9706
|
return names;
|
|
@@ -9681,7 +9733,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9681
9733
|
if (node.implements.length > 0) return;
|
|
9682
9734
|
if (node.decorators.length > 0) return;
|
|
9683
9735
|
const ctor = node.body.body.find(
|
|
9684
|
-
(member) => member.type ===
|
|
9736
|
+
(member) => member.type === AST_NODE_TYPES46.MethodDefinition && member.kind === "constructor"
|
|
9685
9737
|
);
|
|
9686
9738
|
if (ctor === void 0) return;
|
|
9687
9739
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9709,19 +9761,97 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9709
9761
|
}
|
|
9710
9762
|
});
|
|
9711
9763
|
|
|
9764
|
+
// src/rules/require-static-next-matcher.ts
|
|
9765
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47 } from "@typescript-eslint/utils";
|
|
9766
|
+
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
9767
|
+
function unwrapExpression(node) {
|
|
9768
|
+
if (node.type === AST_NODE_TYPES47.TSAsExpression || node.type === AST_NODE_TYPES47.TSSatisfiesExpression || node.type === AST_NODE_TYPES47.TSNonNullExpression || node.type === AST_NODE_TYPES47.TSTypeAssertion) {
|
|
9769
|
+
return unwrapExpression(node.expression);
|
|
9770
|
+
}
|
|
9771
|
+
return node;
|
|
9772
|
+
}
|
|
9773
|
+
function isStaticValue(node) {
|
|
9774
|
+
const value = unwrapExpression(node);
|
|
9775
|
+
if (value.type === AST_NODE_TYPES47.Literal) {
|
|
9776
|
+
return true;
|
|
9777
|
+
}
|
|
9778
|
+
if (value.type === AST_NODE_TYPES47.TemplateLiteral) {
|
|
9779
|
+
return value.expressions.length === 0;
|
|
9780
|
+
}
|
|
9781
|
+
if (value.type === AST_NODE_TYPES47.ArrayExpression) {
|
|
9782
|
+
return value.elements.every(
|
|
9783
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES47.SpreadElement && isStaticValue(element)
|
|
9784
|
+
);
|
|
9785
|
+
}
|
|
9786
|
+
if (value.type === AST_NODE_TYPES47.ObjectExpression) {
|
|
9787
|
+
return value.properties.every(
|
|
9788
|
+
(property) => property.type === AST_NODE_TYPES47.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES47.AssignmentPattern && isStaticValue(property.value)
|
|
9789
|
+
);
|
|
9790
|
+
}
|
|
9791
|
+
return false;
|
|
9792
|
+
}
|
|
9793
|
+
function propertyName2(property) {
|
|
9794
|
+
if (property.computed) return null;
|
|
9795
|
+
if (property.key.type === AST_NODE_TYPES47.Identifier) return property.key.name;
|
|
9796
|
+
return typeof property.key.value === "string" ? property.key.value : null;
|
|
9797
|
+
}
|
|
9798
|
+
var require_static_next_matcher_default = createRule({
|
|
9799
|
+
name: "require-static-next-matcher",
|
|
9800
|
+
meta: {
|
|
9801
|
+
type: "problem",
|
|
9802
|
+
docs: {
|
|
9803
|
+
description: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals."
|
|
9804
|
+
},
|
|
9805
|
+
schema: [],
|
|
9806
|
+
messages: {
|
|
9807
|
+
dynamicMatcher: "Next.js matcher values must contain only literal arrays and objects. Calls, identifiers, concatenation, interpolated templates, and spreads are not statically analyzable and fail the production build."
|
|
9808
|
+
}
|
|
9809
|
+
},
|
|
9810
|
+
defaultOptions: [],
|
|
9811
|
+
create(context) {
|
|
9812
|
+
if (!NEXT_ENTRY_FILE.test(context.filename)) {
|
|
9813
|
+
return {};
|
|
9814
|
+
}
|
|
9815
|
+
return {
|
|
9816
|
+
ExportNamedDeclaration(node) {
|
|
9817
|
+
if (node.declaration?.type !== AST_NODE_TYPES47.VariableDeclaration) {
|
|
9818
|
+
return;
|
|
9819
|
+
}
|
|
9820
|
+
for (const declaration of node.declaration.declarations) {
|
|
9821
|
+
if (declaration.id.type !== AST_NODE_TYPES47.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
9822
|
+
continue;
|
|
9823
|
+
}
|
|
9824
|
+
const config = unwrapExpression(declaration.init);
|
|
9825
|
+
if (config.type !== AST_NODE_TYPES47.ObjectExpression) {
|
|
9826
|
+
continue;
|
|
9827
|
+
}
|
|
9828
|
+
for (const property of config.properties) {
|
|
9829
|
+
if (property.type !== AST_NODE_TYPES47.Property || propertyName2(property) !== "matcher" || property.value.type === AST_NODE_TYPES47.AssignmentPattern) {
|
|
9830
|
+
continue;
|
|
9831
|
+
}
|
|
9832
|
+
if (!isStaticValue(property.value)) {
|
|
9833
|
+
context.report({ node: property.value, messageId: "dynamicMatcher" });
|
|
9834
|
+
}
|
|
9835
|
+
}
|
|
9836
|
+
}
|
|
9837
|
+
}
|
|
9838
|
+
};
|
|
9839
|
+
}
|
|
9840
|
+
});
|
|
9841
|
+
|
|
9712
9842
|
// src/rules/require-zod-form-validation.ts
|
|
9713
|
-
import { AST_NODE_TYPES as
|
|
9843
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48 } from "@typescript-eslint/utils";
|
|
9714
9844
|
var looksLikeZodSchema = (node) => {
|
|
9715
9845
|
let current = node;
|
|
9716
9846
|
while (true) {
|
|
9717
|
-
if (current.type ===
|
|
9847
|
+
if (current.type === AST_NODE_TYPES48.Identifier) {
|
|
9718
9848
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9719
9849
|
}
|
|
9720
|
-
if (current.type ===
|
|
9850
|
+
if (current.type === AST_NODE_TYPES48.CallExpression) {
|
|
9721
9851
|
current = current.callee;
|
|
9722
9852
|
continue;
|
|
9723
9853
|
}
|
|
9724
|
-
if (current.type ===
|
|
9854
|
+
if (current.type === AST_NODE_TYPES48.MemberExpression) {
|
|
9725
9855
|
current = current.object;
|
|
9726
9856
|
continue;
|
|
9727
9857
|
}
|
|
@@ -9729,23 +9859,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9729
9859
|
}
|
|
9730
9860
|
};
|
|
9731
9861
|
var isZodParseCall = (node) => {
|
|
9732
|
-
if (node.type !==
|
|
9862
|
+
if (node.type !== AST_NODE_TYPES48.CallExpression) return false;
|
|
9733
9863
|
const callee = node.callee;
|
|
9734
|
-
if (callee.type !==
|
|
9864
|
+
if (callee.type !== AST_NODE_TYPES48.MemberExpression) return false;
|
|
9735
9865
|
if (callee.computed) return false;
|
|
9736
|
-
if (callee.property.type !==
|
|
9866
|
+
if (callee.property.type !== AST_NODE_TYPES48.Identifier) return false;
|
|
9737
9867
|
const method = callee.property.name;
|
|
9738
9868
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9739
9869
|
return looksLikeZodSchema(callee.object);
|
|
9740
9870
|
};
|
|
9741
9871
|
var isFormDataMethodCall = (node) => {
|
|
9742
9872
|
let current = node;
|
|
9743
|
-
if (current.type ===
|
|
9873
|
+
if (current.type === AST_NODE_TYPES48.AwaitExpression) {
|
|
9744
9874
|
current = current.argument;
|
|
9745
9875
|
}
|
|
9746
|
-
if (current.type !==
|
|
9876
|
+
if (current.type !== AST_NODE_TYPES48.CallExpression) return false;
|
|
9747
9877
|
const callee = current.callee;
|
|
9748
|
-
return callee.type ===
|
|
9878
|
+
return callee.type === AST_NODE_TYPES48.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES48.Identifier && callee.property.name === "formData";
|
|
9749
9879
|
};
|
|
9750
9880
|
var require_zod_form_validation_default = createRule({
|
|
9751
9881
|
name: "require-zod-form-validation",
|
|
@@ -9765,14 +9895,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9765
9895
|
return {};
|
|
9766
9896
|
}
|
|
9767
9897
|
const isFormSourceIdentifier = (node) => {
|
|
9768
|
-
if (node.type !==
|
|
9898
|
+
if (node.type !== AST_NODE_TYPES48.Identifier) return false;
|
|
9769
9899
|
if (/formdata/i.test(node.name)) return true;
|
|
9770
9900
|
let scope = context.sourceCode.getScope(node);
|
|
9771
9901
|
while (scope !== null) {
|
|
9772
9902
|
const variable = scope.set.get(node.name);
|
|
9773
9903
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9774
9904
|
const def = variable.defs[0];
|
|
9775
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
9905
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES48.VariableDeclarator && def.node.init !== null) {
|
|
9776
9906
|
return isFormDataMethodCall(def.node.init);
|
|
9777
9907
|
}
|
|
9778
9908
|
return false;
|
|
@@ -9783,8 +9913,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9783
9913
|
};
|
|
9784
9914
|
const isFormDataGetCall = (node) => {
|
|
9785
9915
|
const callee = node.callee;
|
|
9786
|
-
if (callee.type !==
|
|
9787
|
-
if (callee.property.type !==
|
|
9916
|
+
if (callee.type !== AST_NODE_TYPES48.MemberExpression) return false;
|
|
9917
|
+
if (callee.property.type !== AST_NODE_TYPES48.Identifier || callee.property.name !== "get") {
|
|
9788
9918
|
return false;
|
|
9789
9919
|
}
|
|
9790
9920
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9799,11 +9929,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9799
9929
|
};
|
|
9800
9930
|
const isInstanceofNarrowing = (node) => {
|
|
9801
9931
|
const parent = node.parent;
|
|
9802
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9932
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES48.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES48.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9803
9933
|
};
|
|
9804
9934
|
const boundDeclarator = (node) => {
|
|
9805
9935
|
const parent = node.parent;
|
|
9806
|
-
if (parent.type ===
|
|
9936
|
+
if (parent.type === AST_NODE_TYPES48.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES48.Identifier) {
|
|
9807
9937
|
return parent;
|
|
9808
9938
|
}
|
|
9809
9939
|
return null;
|
|
@@ -9862,7 +9992,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9862
9992
|
});
|
|
9863
9993
|
|
|
9864
9994
|
// src/rules/zod-naming-convention.ts
|
|
9865
|
-
import { AST_NODE_TYPES as
|
|
9995
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49 } from "@typescript-eslint/utils";
|
|
9866
9996
|
var CONVENTIONS = {
|
|
9867
9997
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9868
9998
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9887,15 +10017,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9887
10017
|
"registry",
|
|
9888
10018
|
"implement"
|
|
9889
10019
|
]);
|
|
9890
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10020
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES49.Identifier ? callee.property.name : null;
|
|
9891
10021
|
var calleeChainStartsWithZ = (node) => {
|
|
9892
10022
|
let current = node;
|
|
9893
|
-
while (current.type ===
|
|
10023
|
+
while (current.type === AST_NODE_TYPES49.MemberExpression) {
|
|
9894
10024
|
const receiver = current.object;
|
|
9895
|
-
if (receiver.type ===
|
|
10025
|
+
if (receiver.type === AST_NODE_TYPES49.Identifier && receiver.name === "z") {
|
|
9896
10026
|
return true;
|
|
9897
10027
|
}
|
|
9898
|
-
if (receiver.type ===
|
|
10028
|
+
if (receiver.type === AST_NODE_TYPES49.CallExpression) {
|
|
9899
10029
|
current = receiver.callee;
|
|
9900
10030
|
continue;
|
|
9901
10031
|
}
|
|
@@ -9940,13 +10070,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9940
10070
|
VariableDeclarator(node) {
|
|
9941
10071
|
const init = node.init;
|
|
9942
10072
|
if (init === null || init === void 0) return;
|
|
9943
|
-
if (init.type !==
|
|
10073
|
+
if (init.type !== AST_NODE_TYPES49.CallExpression) return;
|
|
9944
10074
|
const callee = init.callee;
|
|
9945
|
-
if (callee.type !==
|
|
10075
|
+
if (callee.type !== AST_NODE_TYPES49.MemberExpression) return;
|
|
9946
10076
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9947
10077
|
const terminal = terminalMethodName(callee);
|
|
9948
10078
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9949
|
-
if (node.id.type !==
|
|
10079
|
+
if (node.id.type !== AST_NODE_TYPES49.Identifier) return;
|
|
9950
10080
|
if (test.test(node.id.name)) return;
|
|
9951
10081
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9952
10082
|
context.report({
|
|
@@ -10026,6 +10156,7 @@ var rules = {
|
|
|
10026
10156
|
"no-enum": no_enum_default,
|
|
10027
10157
|
"no-fat-try-blocks": no_fat_try_blocks_default,
|
|
10028
10158
|
"no-hand-rolled-sleep": no_hand_rolled_sleep_default,
|
|
10159
|
+
"no-hand-rolled-spinner": no_hand_rolled_spinner_default,
|
|
10029
10160
|
"no-insecure-random-id": no_insecure_random_id_default,
|
|
10030
10161
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
10031
10162
|
"no-log-only-catch": no_log_only_catch_default,
|
|
@@ -10071,13 +10202,14 @@ var rules = {
|
|
|
10071
10202
|
"require-assert-never": require_assert_never_default,
|
|
10072
10203
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
10073
10204
|
"require-interface-for-injected-service": require_interface_for_injected_service_default,
|
|
10205
|
+
"require-static-next-matcher": require_static_next_matcher_default,
|
|
10074
10206
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
10075
10207
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
10076
10208
|
"zod-naming-convention": zod_naming_convention_default
|
|
10077
10209
|
};
|
|
10078
10210
|
var meta = {
|
|
10079
10211
|
name: "@sarj/eslint-plugin",
|
|
10080
|
-
version: "9.
|
|
10212
|
+
version: "9.9.0"
|
|
10081
10213
|
};
|
|
10082
10214
|
var applicationOnlyRules = [
|
|
10083
10215
|
"no-restricted-library-load",
|
|
@@ -10093,6 +10225,7 @@ var recommendedRules = {
|
|
|
10093
10225
|
"@sarj/no-dynamic-sql": "warn",
|
|
10094
10226
|
"@sarj/no-fat-try-blocks": "warn",
|
|
10095
10227
|
"@sarj/no-hand-rolled-sleep": "warn",
|
|
10228
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10096
10229
|
"@sarj/no-insecure-random-id": "warn",
|
|
10097
10230
|
"@sarj/no-json-stringify-error": "warn",
|
|
10098
10231
|
"@sarj/no-log-only-catch": "warn",
|
|
@@ -10133,6 +10266,7 @@ var recommendedRules = {
|
|
|
10133
10266
|
"@sarj/require-assert-never": "error",
|
|
10134
10267
|
"@sarj/require-fetch-timeout": "warn",
|
|
10135
10268
|
"@sarj/require-interface-for-injected-service": "warn",
|
|
10269
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10136
10270
|
"@sarj/require-zod-form-validation": "error",
|
|
10137
10271
|
"@sarj/store-insert-requires-on-conflict": "warn",
|
|
10138
10272
|
"@sarj/zod-naming-convention": "warn"
|
|
@@ -10148,6 +10282,7 @@ var strictRules = {
|
|
|
10148
10282
|
"@sarj/no-enum": "error",
|
|
10149
10283
|
"@sarj/no-fat-try-blocks": "error",
|
|
10150
10284
|
"@sarj/no-hand-rolled-sleep": "error",
|
|
10285
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10151
10286
|
"@sarj/no-insecure-random-id": "error",
|
|
10152
10287
|
"@sarj/no-json-stringify-error": "error",
|
|
10153
10288
|
"@sarj/no-log-only-catch": "error",
|
|
@@ -10191,6 +10326,7 @@ var strictRules = {
|
|
|
10191
10326
|
"@sarj/require-assert-never": "error",
|
|
10192
10327
|
"@sarj/require-fetch-timeout": "error",
|
|
10193
10328
|
"@sarj/require-interface-for-injected-service": "error",
|
|
10329
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10194
10330
|
"@sarj/require-zod-form-validation": "error",
|
|
10195
10331
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
10196
10332
|
"@sarj/zod-naming-convention": "error"
|