@sarj/eslint-plugin 9.8.0 → 9.10.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 +10 -0
- package/dist/index.cjs +898 -646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -5
- package/dist/index.d.ts +29 -5
- package/dist/index.js +881 -629
- 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);
|
|
@@ -6541,8 +6593,121 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6541
6593
|
}
|
|
6542
6594
|
});
|
|
6543
6595
|
|
|
6596
|
+
// src/rules/prefer-input-group-search.ts
|
|
6597
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES34 } from "@typescript-eslint/utils";
|
|
6598
|
+
var INPUT_MODULE = /(?:^|\/)components\/ui\/input$/u;
|
|
6599
|
+
var INPUT_GROUP_MODULE = /(?:^|\/)components\/ui\/input-group$/u;
|
|
6600
|
+
var MAX_JSX_DISTANCE = 2;
|
|
6601
|
+
function localNamedImports(node, importedName) {
|
|
6602
|
+
return node.specifiers.filter(
|
|
6603
|
+
(specifier) => specifier.type === AST_NODE_TYPES34.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES34.Identifier ? specifier.imported.name : specifier.imported.value) === importedName
|
|
6604
|
+
).map((specifier) => specifier.local.name);
|
|
6605
|
+
}
|
|
6606
|
+
function elementName(node) {
|
|
6607
|
+
return node.name.type === AST_NODE_TYPES34.JSXIdentifier ? node.name.name : null;
|
|
6608
|
+
}
|
|
6609
|
+
function jsxAncestors(occurrence) {
|
|
6610
|
+
return occurrence.ancestors.filter(
|
|
6611
|
+
(ancestor) => ancestor.type === AST_NODE_TYPES34.JSXElement
|
|
6612
|
+
);
|
|
6613
|
+
}
|
|
6614
|
+
function isWithinInputGroup(occurrence, inputGroupNames) {
|
|
6615
|
+
return jsxAncestors(occurrence).some(
|
|
6616
|
+
(ancestor) => inputGroupNames.has(elementName(ancestor.openingElement) ?? "")
|
|
6617
|
+
);
|
|
6618
|
+
}
|
|
6619
|
+
function nearestEligibleCommonAncestor(search, input, inputGroupNames) {
|
|
6620
|
+
const searchAncestors = jsxAncestors(search);
|
|
6621
|
+
const inputAncestorList = jsxAncestors(input);
|
|
6622
|
+
const inputAncestors = new Set(inputAncestorList);
|
|
6623
|
+
for (let index = searchAncestors.length - 1; index >= 0; index -= 1) {
|
|
6624
|
+
const ancestor = searchAncestors[index];
|
|
6625
|
+
if (ancestor === void 0) continue;
|
|
6626
|
+
if (!inputAncestors.has(ancestor)) continue;
|
|
6627
|
+
const searchDistance = searchAncestors.length - index - 1;
|
|
6628
|
+
const inputDistance = inputAncestorList.length - inputAncestorList.indexOf(ancestor) - 1;
|
|
6629
|
+
if (searchDistance > MAX_JSX_DISTANCE || inputDistance > MAX_JSX_DISTANCE) {
|
|
6630
|
+
return null;
|
|
6631
|
+
}
|
|
6632
|
+
if (inputGroupNames.has(elementName(ancestor.openingElement) ?? "")) {
|
|
6633
|
+
return null;
|
|
6634
|
+
}
|
|
6635
|
+
return ancestor;
|
|
6636
|
+
}
|
|
6637
|
+
return null;
|
|
6638
|
+
}
|
|
6639
|
+
var prefer_input_group_search_default = createRule({
|
|
6640
|
+
name: "prefer-input-group-search",
|
|
6641
|
+
meta: {
|
|
6642
|
+
type: "suggestion",
|
|
6643
|
+
docs: {
|
|
6644
|
+
description: "Require search icons and shared Input controls in the same visual wrapper to use InputGroup."
|
|
6645
|
+
},
|
|
6646
|
+
schema: [],
|
|
6647
|
+
messages: {
|
|
6648
|
+
preferInputGroup: "Use InputGroup with InputGroupAddon and InputGroupInput for this search field."
|
|
6649
|
+
}
|
|
6650
|
+
},
|
|
6651
|
+
defaultOptions: [],
|
|
6652
|
+
create(context) {
|
|
6653
|
+
const inputNames = /* @__PURE__ */ new Set();
|
|
6654
|
+
const inputGroupNames = /* @__PURE__ */ new Set();
|
|
6655
|
+
const searchNames = /* @__PURE__ */ new Set();
|
|
6656
|
+
const inputs = [];
|
|
6657
|
+
const searches = [];
|
|
6658
|
+
return {
|
|
6659
|
+
ImportDeclaration(node) {
|
|
6660
|
+
const source = String(node.source.value);
|
|
6661
|
+
if (source === "lucide-react") {
|
|
6662
|
+
localNamedImports(node, "Search").forEach(
|
|
6663
|
+
(name) => searchNames.add(name)
|
|
6664
|
+
);
|
|
6665
|
+
} else if (INPUT_MODULE.test(source)) {
|
|
6666
|
+
localNamedImports(node, "Input").forEach(
|
|
6667
|
+
(name) => inputNames.add(name)
|
|
6668
|
+
);
|
|
6669
|
+
} else if (INPUT_GROUP_MODULE.test(source)) {
|
|
6670
|
+
localNamedImports(node, "InputGroup").forEach(
|
|
6671
|
+
(name) => inputGroupNames.add(name)
|
|
6672
|
+
);
|
|
6673
|
+
}
|
|
6674
|
+
},
|
|
6675
|
+
JSXOpeningElement(node) {
|
|
6676
|
+
const name = elementName(node);
|
|
6677
|
+
if (name === null) return;
|
|
6678
|
+
const occurrence = {
|
|
6679
|
+
ancestors: context.sourceCode.getAncestors(node),
|
|
6680
|
+
node
|
|
6681
|
+
};
|
|
6682
|
+
if (searchNames.has(name)) searches.push(occurrence);
|
|
6683
|
+
if (inputNames.has(name)) inputs.push(occurrence);
|
|
6684
|
+
},
|
|
6685
|
+
"Program:exit"() {
|
|
6686
|
+
const reported = /* @__PURE__ */ new Set();
|
|
6687
|
+
for (const search of searches) {
|
|
6688
|
+
if (isWithinInputGroup(search, inputGroupNames)) continue;
|
|
6689
|
+
for (const input of inputs) {
|
|
6690
|
+
if (isWithinInputGroup(input, inputGroupNames)) continue;
|
|
6691
|
+
const wrapper = nearestEligibleCommonAncestor(
|
|
6692
|
+
search,
|
|
6693
|
+
input,
|
|
6694
|
+
inputGroupNames
|
|
6695
|
+
);
|
|
6696
|
+
if (wrapper === null || reported.has(wrapper)) continue;
|
|
6697
|
+
reported.add(wrapper);
|
|
6698
|
+
context.report({
|
|
6699
|
+
node: wrapper.openingElement,
|
|
6700
|
+
messageId: "preferInputGroup"
|
|
6701
|
+
});
|
|
6702
|
+
}
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
};
|
|
6706
|
+
}
|
|
6707
|
+
});
|
|
6708
|
+
|
|
6544
6709
|
// src/rules/prefer-module-level-constant.ts
|
|
6545
|
-
import { AST_NODE_TYPES as
|
|
6710
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35 } from "@typescript-eslint/utils";
|
|
6546
6711
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6547
6712
|
var MAX_LITERAL_DEPTH = 4;
|
|
6548
6713
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6571,9 +6736,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6571
6736
|
"assign"
|
|
6572
6737
|
]);
|
|
6573
6738
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6739
|
+
AST_NODE_TYPES35.FunctionDeclaration,
|
|
6740
|
+
AST_NODE_TYPES35.FunctionExpression,
|
|
6741
|
+
AST_NODE_TYPES35.ArrowFunctionExpression
|
|
6577
6742
|
]);
|
|
6578
6743
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6579
6744
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6586,14 +6751,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6586
6751
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6587
6752
|
}
|
|
6588
6753
|
function unwrap3(node) {
|
|
6589
|
-
if (node.type ===
|
|
6754
|
+
if (node.type === AST_NODE_TYPES35.TSAsExpression || node.type === AST_NODE_TYPES35.TSSatisfiesExpression || node.type === AST_NODE_TYPES35.TSNonNullExpression) {
|
|
6590
6755
|
return unwrap3(node.expression);
|
|
6591
6756
|
}
|
|
6592
6757
|
return node;
|
|
6593
6758
|
}
|
|
6594
6759
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6595
6760
|
function isRegexLiteral(node) {
|
|
6596
|
-
return node.type ===
|
|
6761
|
+
return node.type === AST_NODE_TYPES35.Literal && "regex" in node && node.regex !== void 0;
|
|
6597
6762
|
}
|
|
6598
6763
|
function isLiteralOnly(node, depth) {
|
|
6599
6764
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6601,29 +6766,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6601
6766
|
}
|
|
6602
6767
|
const inner = unwrap3(node);
|
|
6603
6768
|
switch (inner.type) {
|
|
6604
|
-
case
|
|
6769
|
+
case AST_NODE_TYPES35.Literal: {
|
|
6605
6770
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6606
6771
|
}
|
|
6607
|
-
case
|
|
6772
|
+
case AST_NODE_TYPES35.TemplateLiteral: {
|
|
6608
6773
|
return inner.expressions.length === 0;
|
|
6609
6774
|
}
|
|
6610
|
-
case
|
|
6611
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6775
|
+
case AST_NODE_TYPES35.UnaryExpression: {
|
|
6776
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES35.Literal && typeof inner.argument.value === "number";
|
|
6612
6777
|
}
|
|
6613
|
-
case
|
|
6778
|
+
case AST_NODE_TYPES35.ArrayExpression: {
|
|
6614
6779
|
return inner.elements.every(
|
|
6615
|
-
(el) => el !== null && el.type !==
|
|
6780
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES35.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6616
6781
|
);
|
|
6617
6782
|
}
|
|
6618
|
-
case
|
|
6783
|
+
case AST_NODE_TYPES35.ObjectExpression: {
|
|
6619
6784
|
return inner.properties.every((prop) => {
|
|
6620
|
-
if (prop.type !==
|
|
6785
|
+
if (prop.type !== AST_NODE_TYPES35.Property) {
|
|
6621
6786
|
return false;
|
|
6622
6787
|
}
|
|
6623
6788
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6624
6789
|
return false;
|
|
6625
6790
|
}
|
|
6626
|
-
if (prop.computed && prop.key.type !==
|
|
6791
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES35.Literal) {
|
|
6627
6792
|
return false;
|
|
6628
6793
|
}
|
|
6629
6794
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6636,7 +6801,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6636
6801
|
}
|
|
6637
6802
|
function unwrapObjectFreeze(node) {
|
|
6638
6803
|
const inner = unwrap3(node);
|
|
6639
|
-
if (inner.type ===
|
|
6804
|
+
if (inner.type === AST_NODE_TYPES35.CallExpression && inner.callee.type === AST_NODE_TYPES35.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES35.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES35.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES35.SpreadElement) {
|
|
6640
6805
|
return unwrap3(inner.arguments[0]);
|
|
6641
6806
|
}
|
|
6642
6807
|
return inner;
|
|
@@ -6652,19 +6817,19 @@ function classify(init, checkRegex) {
|
|
|
6652
6817
|
}
|
|
6653
6818
|
return { kind: "regex", size: 1 };
|
|
6654
6819
|
}
|
|
6655
|
-
if (node.type ===
|
|
6820
|
+
if (node.type === AST_NODE_TYPES35.ArrayExpression) {
|
|
6656
6821
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6657
6822
|
}
|
|
6658
|
-
if (node.type ===
|
|
6823
|
+
if (node.type === AST_NODE_TYPES35.ObjectExpression) {
|
|
6659
6824
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6660
6825
|
}
|
|
6661
|
-
if (node.type ===
|
|
6826
|
+
if (node.type === AST_NODE_TYPES35.NewExpression && node.callee.type === AST_NODE_TYPES35.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6662
6827
|
const arg = node.arguments[0];
|
|
6663
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6828
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES35.SpreadElement) {
|
|
6664
6829
|
return null;
|
|
6665
6830
|
}
|
|
6666
6831
|
const entries = unwrap3(arg);
|
|
6667
|
-
if (entries.type !==
|
|
6832
|
+
if (entries.type !== AST_NODE_TYPES35.ArrayExpression) {
|
|
6668
6833
|
return null;
|
|
6669
6834
|
}
|
|
6670
6835
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6693,10 +6858,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6693
6858
|
);
|
|
6694
6859
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6695
6860
|
const callee = node.callee;
|
|
6696
|
-
if (callee.type ===
|
|
6861
|
+
if (callee.type === AST_NODE_TYPES35.Identifier && callee.name === "structuredClone") {
|
|
6697
6862
|
return true;
|
|
6698
6863
|
}
|
|
6699
|
-
if (callee.type !==
|
|
6864
|
+
if (callee.type !== AST_NODE_TYPES35.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES35.Identifier || callee.property.type !== AST_NODE_TYPES35.Identifier) {
|
|
6700
6865
|
return false;
|
|
6701
6866
|
}
|
|
6702
6867
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6710,38 +6875,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6710
6875
|
}
|
|
6711
6876
|
function isSafeRead(identifier) {
|
|
6712
6877
|
const parent = identifier.parent;
|
|
6713
|
-
if (parent.type ===
|
|
6878
|
+
if (parent.type === AST_NODE_TYPES35.MemberExpression) {
|
|
6714
6879
|
if (parent.object !== identifier) {
|
|
6715
6880
|
return true;
|
|
6716
6881
|
}
|
|
6717
6882
|
const grandparent = parent.parent;
|
|
6718
|
-
if (grandparent.type ===
|
|
6883
|
+
if (grandparent.type === AST_NODE_TYPES35.AssignmentExpression && grandparent.left === parent) {
|
|
6719
6884
|
return false;
|
|
6720
6885
|
}
|
|
6721
|
-
if (grandparent.type ===
|
|
6886
|
+
if (grandparent.type === AST_NODE_TYPES35.UpdateExpression) {
|
|
6722
6887
|
return false;
|
|
6723
6888
|
}
|
|
6724
|
-
if (grandparent.type ===
|
|
6889
|
+
if (grandparent.type === AST_NODE_TYPES35.UnaryExpression && grandparent.operator === "delete") {
|
|
6725
6890
|
return false;
|
|
6726
6891
|
}
|
|
6727
|
-
if (!parent.computed && parent.property.type ===
|
|
6892
|
+
if (!parent.computed && parent.property.type === AST_NODE_TYPES35.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === AST_NODE_TYPES35.CallExpression && grandparent.callee === parent) {
|
|
6728
6893
|
return false;
|
|
6729
6894
|
}
|
|
6730
6895
|
return true;
|
|
6731
6896
|
}
|
|
6732
|
-
if (parent.type ===
|
|
6897
|
+
if (parent.type === AST_NODE_TYPES35.ForOfStatement && parent.right === identifier) {
|
|
6733
6898
|
return true;
|
|
6734
6899
|
}
|
|
6735
|
-
if (parent.type ===
|
|
6900
|
+
if (parent.type === AST_NODE_TYPES35.SpreadElement) {
|
|
6736
6901
|
return true;
|
|
6737
6902
|
}
|
|
6738
|
-
if (parent.type ===
|
|
6903
|
+
if (parent.type === AST_NODE_TYPES35.BinaryExpression) {
|
|
6739
6904
|
return true;
|
|
6740
6905
|
}
|
|
6741
|
-
if (parent.type ===
|
|
6906
|
+
if (parent.type === AST_NODE_TYPES35.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6742
6907
|
return true;
|
|
6743
6908
|
}
|
|
6744
|
-
if (parent.type ===
|
|
6909
|
+
if (parent.type === AST_NODE_TYPES35.UnaryExpression && parent.operator !== "delete") {
|
|
6745
6910
|
return true;
|
|
6746
6911
|
}
|
|
6747
6912
|
return false;
|
|
@@ -6796,7 +6961,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6796
6961
|
if (reference.isWrite()) {
|
|
6797
6962
|
return false;
|
|
6798
6963
|
}
|
|
6799
|
-
if (reference.identifier.type !==
|
|
6964
|
+
if (reference.identifier.type !== AST_NODE_TYPES35.Identifier) {
|
|
6800
6965
|
return false;
|
|
6801
6966
|
}
|
|
6802
6967
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6808,10 +6973,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6808
6973
|
return {
|
|
6809
6974
|
VariableDeclarator(node) {
|
|
6810
6975
|
const declaration = node.parent;
|
|
6811
|
-
if (declaration.type !==
|
|
6976
|
+
if (declaration.type !== AST_NODE_TYPES35.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6812
6977
|
return;
|
|
6813
6978
|
}
|
|
6814
|
-
if (node.id.type !==
|
|
6979
|
+
if (node.id.type !== AST_NODE_TYPES35.Identifier || node.init === null) {
|
|
6815
6980
|
return;
|
|
6816
6981
|
}
|
|
6817
6982
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6838,7 +7003,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6838
7003
|
});
|
|
6839
7004
|
|
|
6840
7005
|
// src/rules/prefer-module-level-schema.ts
|
|
6841
|
-
import { AST_NODE_TYPES as
|
|
7006
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36 } from "@typescript-eslint/utils";
|
|
6842
7007
|
|
|
6843
7008
|
// src/rules/_zod.ts
|
|
6844
7009
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6904,9 +7069,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6904
7069
|
"intl"
|
|
6905
7070
|
]);
|
|
6906
7071
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
7072
|
+
AST_NODE_TYPES36.ArrowFunctionExpression,
|
|
7073
|
+
AST_NODE_TYPES36.FunctionDeclaration,
|
|
7074
|
+
AST_NODE_TYPES36.FunctionExpression
|
|
6910
7075
|
]);
|
|
6911
7076
|
function schemaExpression(node) {
|
|
6912
7077
|
let current = node;
|
|
@@ -6915,10 +7080,10 @@ function schemaExpression(node) {
|
|
|
6915
7080
|
if (parent === void 0) {
|
|
6916
7081
|
return current;
|
|
6917
7082
|
}
|
|
6918
|
-
if (parent.type ===
|
|
7083
|
+
if (parent.type === AST_NODE_TYPES36.MemberExpression && parent.object === current && !parent.computed && parent.property.type === AST_NODE_TYPES36.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6919
7084
|
return current;
|
|
6920
7085
|
}
|
|
6921
|
-
if (parent.type ===
|
|
7086
|
+
if (parent.type === AST_NODE_TYPES36.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES36.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES36.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES36.TSNonNullExpression && parent.expression === current) {
|
|
6922
7087
|
current = parent;
|
|
6923
7088
|
continue;
|
|
6924
7089
|
}
|
|
@@ -6969,22 +7134,22 @@ function subtreeSome(root, predicate) {
|
|
|
6969
7134
|
function readsReceiver(node) {
|
|
6970
7135
|
return subtreeSome(
|
|
6971
7136
|
node,
|
|
6972
|
-
(inner) => inner.type ===
|
|
7137
|
+
(inner) => inner.type === AST_NODE_TYPES36.ThisExpression || inner.type === AST_NODE_TYPES36.Super || inner.type === AST_NODE_TYPES36.Identifier && inner.name === "arguments"
|
|
6973
7138
|
);
|
|
6974
7139
|
}
|
|
6975
7140
|
function buildsLocalizedText(node) {
|
|
6976
7141
|
return subtreeSome(node, (inner) => {
|
|
6977
|
-
if (inner.type ===
|
|
7142
|
+
if (inner.type === AST_NODE_TYPES36.TaggedTemplateExpression) {
|
|
6978
7143
|
return true;
|
|
6979
7144
|
}
|
|
6980
|
-
if (inner.type !==
|
|
7145
|
+
if (inner.type !== AST_NODE_TYPES36.CallExpression) {
|
|
6981
7146
|
return false;
|
|
6982
7147
|
}
|
|
6983
7148
|
const { callee } = inner;
|
|
6984
|
-
if (callee.type ===
|
|
7149
|
+
if (callee.type === AST_NODE_TYPES36.Identifier) {
|
|
6985
7150
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6986
7151
|
}
|
|
6987
|
-
return callee.type ===
|
|
7152
|
+
return callee.type === AST_NODE_TYPES36.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES36.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6988
7153
|
});
|
|
6989
7154
|
}
|
|
6990
7155
|
function collectReferences(scope, out) {
|
|
@@ -7041,15 +7206,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7041
7206
|
}
|
|
7042
7207
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7043
7208
|
function isZodCall(node) {
|
|
7044
|
-
return node.type ===
|
|
7209
|
+
return node.type === AST_NODE_TYPES36.CallExpression && node.callee.type === AST_NODE_TYPES36.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES36.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
7045
7210
|
}
|
|
7046
7211
|
function isCovered(node) {
|
|
7047
7212
|
let current = node.parent ?? void 0;
|
|
7048
7213
|
while (current !== void 0) {
|
|
7049
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7214
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES36.MemberExpression && current.callee.property.type === AST_NODE_TYPES36.Identifier && factories.has(current.callee.property.name)) {
|
|
7050
7215
|
return true;
|
|
7051
7216
|
}
|
|
7052
|
-
if (current.type ===
|
|
7217
|
+
if (current.type === AST_NODE_TYPES36.CallExpression && (current.callee.type === AST_NODE_TYPES36.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === AST_NODE_TYPES36.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES36.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
7053
7218
|
return true;
|
|
7054
7219
|
}
|
|
7055
7220
|
current = current.parent ?? void 0;
|
|
@@ -7064,11 +7229,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7064
7229
|
if (parent === void 0) {
|
|
7065
7230
|
return confirmed;
|
|
7066
7231
|
}
|
|
7067
|
-
if (parent.type ===
|
|
7232
|
+
if (parent.type === AST_NODE_TYPES36.Property && parent.value === current || parent.type === AST_NODE_TYPES36.ObjectExpression || parent.type === AST_NODE_TYPES36.ArrayExpression) {
|
|
7068
7233
|
current = parent;
|
|
7069
7234
|
continue;
|
|
7070
7235
|
}
|
|
7071
|
-
if (parent.type ===
|
|
7236
|
+
if (parent.type === AST_NODE_TYPES36.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7072
7237
|
current = schemaExpression(parent);
|
|
7073
7238
|
confirmed = current;
|
|
7074
7239
|
continue;
|
|
@@ -7078,7 +7243,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7078
7243
|
}
|
|
7079
7244
|
function isSchemaComposition(node) {
|
|
7080
7245
|
const { callee } = node;
|
|
7081
|
-
const isCombinator = callee.type ===
|
|
7246
|
+
const isCombinator = callee.type === AST_NODE_TYPES36.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES36.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7082
7247
|
return isCombinator || isZodCall(node);
|
|
7083
7248
|
}
|
|
7084
7249
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7112,13 +7277,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7112
7277
|
}
|
|
7113
7278
|
function ownerName(enclosing) {
|
|
7114
7279
|
const parent = enclosing.parent ?? void 0;
|
|
7115
|
-
if (enclosing.type ===
|
|
7280
|
+
if (enclosing.type === AST_NODE_TYPES36.FunctionDeclaration && enclosing.id !== null) {
|
|
7116
7281
|
return enclosing.id.name;
|
|
7117
7282
|
}
|
|
7118
|
-
if (parent !== void 0 && parent.type ===
|
|
7283
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES36.VariableDeclarator && parent.id.type === AST_NODE_TYPES36.Identifier) {
|
|
7119
7284
|
return parent.id.name;
|
|
7120
7285
|
}
|
|
7121
|
-
if (parent !== void 0 && (parent.type ===
|
|
7286
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES36.MethodDefinition || parent.type === AST_NODE_TYPES36.Property) && parent.key.type === AST_NODE_TYPES36.Identifier) {
|
|
7122
7287
|
return parent.key.name;
|
|
7123
7288
|
}
|
|
7124
7289
|
return "this function";
|
|
@@ -7129,7 +7294,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7129
7294
|
return;
|
|
7130
7295
|
}
|
|
7131
7296
|
for (const specifier of node.specifiers) {
|
|
7132
|
-
if (specifier.type ===
|
|
7297
|
+
if (specifier.type === AST_NODE_TYPES36.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES36.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES36.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES36.Identifier && specifier.imported.name === "z") {
|
|
7133
7298
|
zodNamespaces.add(specifier.local.name);
|
|
7134
7299
|
}
|
|
7135
7300
|
}
|
|
@@ -7139,7 +7304,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7139
7304
|
return;
|
|
7140
7305
|
}
|
|
7141
7306
|
const callee = node.callee;
|
|
7142
|
-
if (callee.property.type !==
|
|
7307
|
+
if (callee.property.type !== AST_NODE_TYPES36.Identifier) {
|
|
7143
7308
|
return;
|
|
7144
7309
|
}
|
|
7145
7310
|
const factory = callee.property.name;
|
|
@@ -7154,7 +7319,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7154
7319
|
return;
|
|
7155
7320
|
}
|
|
7156
7321
|
const shape = node.arguments[0];
|
|
7157
|
-
if (shape !== void 0 && shape.type ===
|
|
7322
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES36.ObjectExpression && shape.properties.length < minProperties) {
|
|
7158
7323
|
return;
|
|
7159
7324
|
}
|
|
7160
7325
|
const expression = schemaExpression(node);
|
|
@@ -7181,77 +7346,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7181
7346
|
}
|
|
7182
7347
|
});
|
|
7183
7348
|
|
|
7184
|
-
// src/rules/prefer-non-nullable-collection.ts
|
|
7185
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES35 } from "@typescript-eslint/utils";
|
|
7186
|
-
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7187
|
-
function propertyName(node) {
|
|
7188
|
-
const key = node.key;
|
|
7189
|
-
if (key.type === AST_NODE_TYPES35.Identifier) return key.name;
|
|
7190
|
-
if (key.type === AST_NODE_TYPES35.Literal) return String(key.value);
|
|
7191
|
-
return "collection";
|
|
7192
|
-
}
|
|
7193
|
-
function isArrayType(node) {
|
|
7194
|
-
if (node.type === AST_NODE_TYPES35.TSArrayType) return true;
|
|
7195
|
-
return node.type === AST_NODE_TYPES35.TSTypeReference && node.typeName.type === AST_NODE_TYPES35.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7196
|
-
}
|
|
7197
|
-
function isNullishType(node) {
|
|
7198
|
-
return node.type === AST_NODE_TYPES35.TSNullKeyword || node.type === AST_NODE_TYPES35.TSUndefinedKeyword;
|
|
7199
|
-
}
|
|
7200
|
-
function isNullableArrayOnly(node) {
|
|
7201
|
-
const values = node.types.filter((member) => !isNullishType(member));
|
|
7202
|
-
return values.length > 0 && values.length < node.types.length && values.every(isArrayType);
|
|
7203
|
-
}
|
|
7204
|
-
var prefer_non_nullable_collection_default = createRule({
|
|
7205
|
-
name: "prefer-non-nullable-collection",
|
|
7206
|
-
meta: {
|
|
7207
|
-
type: "suggestion",
|
|
7208
|
-
docs: {
|
|
7209
|
-
description: "Require declared data-shape properties and direct aliases to use non-null arrays instead of explicit nullish unions."
|
|
7210
|
-
},
|
|
7211
|
-
schema: [],
|
|
7212
|
-
messages: {
|
|
7213
|
-
preferNonNullableCollection: "`{{name}}` is a nullable array, so nullish and `[]` represent the same empty collection. Use a non-null array and default omitted values to `[]`."
|
|
7214
|
-
}
|
|
7215
|
-
},
|
|
7216
|
-
defaultOptions: [],
|
|
7217
|
-
create(context) {
|
|
7218
|
-
const normalizedFilename = context.filename.replaceAll("\\", "/");
|
|
7219
|
-
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || /\/(?:vendor|vendored)\//u.test(normalizedFilename)) {
|
|
7220
|
-
return {};
|
|
7221
|
-
}
|
|
7222
|
-
function checkOptionalProperty(node) {
|
|
7223
|
-
if (node.optional) return;
|
|
7224
|
-
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7225
|
-
if (annotation === void 0) return;
|
|
7226
|
-
if (annotation.type !== AST_NODE_TYPES35.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7227
|
-
return;
|
|
7228
|
-
}
|
|
7229
|
-
context.report({
|
|
7230
|
-
node,
|
|
7231
|
-
messageId: "preferNonNullableCollection",
|
|
7232
|
-
data: { name: propertyName(node) }
|
|
7233
|
-
});
|
|
7234
|
-
}
|
|
7235
|
-
return {
|
|
7236
|
-
TSPropertySignature: checkOptionalProperty,
|
|
7237
|
-
PropertyDefinition: checkOptionalProperty,
|
|
7238
|
-
TSTypeAliasDeclaration(node) {
|
|
7239
|
-
if (node.typeAnnotation.type !== AST_NODE_TYPES35.TSUnionType) return;
|
|
7240
|
-
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7241
|
-
context.report({
|
|
7242
|
-
node,
|
|
7243
|
-
messageId: "preferNonNullableCollection",
|
|
7244
|
-
data: { name: node.id.name }
|
|
7245
|
-
});
|
|
7246
|
-
}
|
|
7247
|
-
};
|
|
7248
|
-
}
|
|
7249
|
-
});
|
|
7250
|
-
|
|
7251
7349
|
// src/rules/prefer-native-random-uuid.ts
|
|
7252
|
-
import { AST_NODE_TYPES as
|
|
7350
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37, ASTUtils as ASTUtils3 } from "@typescript-eslint/utils";
|
|
7253
7351
|
function requireUuid(node) {
|
|
7254
|
-
return node?.type ===
|
|
7352
|
+
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
7353
|
}
|
|
7256
7354
|
var prefer_native_random_uuid_default = createRule({
|
|
7257
7355
|
name: "prefer-native-random-uuid",
|
|
@@ -7294,37 +7392,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7294
7392
|
ImportDeclaration(node) {
|
|
7295
7393
|
if (node.source.value !== "uuid") return;
|
|
7296
7394
|
for (const specifier of node.specifiers) {
|
|
7297
|
-
if (specifier.type ===
|
|
7395
|
+
if (specifier.type === AST_NODE_TYPES37.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES37.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7298
7396
|
record(specifier.local, directBindings);
|
|
7299
|
-
} else if (specifier.type ===
|
|
7397
|
+
} else if (specifier.type === AST_NODE_TYPES37.ImportNamespaceSpecifier) {
|
|
7300
7398
|
record(specifier.local, namespaceBindings);
|
|
7301
7399
|
}
|
|
7302
7400
|
}
|
|
7303
7401
|
},
|
|
7304
7402
|
VariableDeclarator(node) {
|
|
7305
7403
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7306
|
-
if (node.init?.type !==
|
|
7404
|
+
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
7405
|
return;
|
|
7308
7406
|
}
|
|
7309
|
-
if (node.id.type ===
|
|
7407
|
+
if (node.id.type === AST_NODE_TYPES37.Identifier) {
|
|
7310
7408
|
record(node.id, namespaceBindings);
|
|
7311
7409
|
return;
|
|
7312
7410
|
}
|
|
7313
|
-
if (node.id.type !==
|
|
7411
|
+
if (node.id.type !== AST_NODE_TYPES37.ObjectPattern) return;
|
|
7314
7412
|
for (const property of node.id.properties) {
|
|
7315
|
-
if (property.type ===
|
|
7413
|
+
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
7414
|
record(property.value, directBindings);
|
|
7317
7415
|
}
|
|
7318
7416
|
}
|
|
7319
7417
|
},
|
|
7320
7418
|
"CallExpression:exit"(node) {
|
|
7321
7419
|
if (node.arguments.length !== 0) return;
|
|
7322
|
-
if (node.callee.type ===
|
|
7420
|
+
if (node.callee.type === AST_NODE_TYPES37.Identifier) {
|
|
7323
7421
|
const variable2 = resolve(node.callee);
|
|
7324
7422
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7325
7423
|
return;
|
|
7326
7424
|
}
|
|
7327
|
-
if (node.callee.type !==
|
|
7425
|
+
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
7426
|
return;
|
|
7329
7427
|
}
|
|
7330
7428
|
const variable = resolve(node.callee.object);
|
|
@@ -7334,14 +7432,81 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7334
7432
|
}
|
|
7335
7433
|
});
|
|
7336
7434
|
|
|
7435
|
+
// src/rules/prefer-non-nullable-collection.ts
|
|
7436
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
7437
|
+
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7438
|
+
function propertyName(node) {
|
|
7439
|
+
const key = node.key;
|
|
7440
|
+
if (key.type === AST_NODE_TYPES38.Identifier) return key.name;
|
|
7441
|
+
if (key.type === AST_NODE_TYPES38.Literal) return String(key.value);
|
|
7442
|
+
return "collection";
|
|
7443
|
+
}
|
|
7444
|
+
function isArrayType(node) {
|
|
7445
|
+
if (node.type === AST_NODE_TYPES38.TSArrayType) return true;
|
|
7446
|
+
return node.type === AST_NODE_TYPES38.TSTypeReference && node.typeName.type === AST_NODE_TYPES38.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7447
|
+
}
|
|
7448
|
+
function isNullishType(node) {
|
|
7449
|
+
return node.type === AST_NODE_TYPES38.TSNullKeyword || node.type === AST_NODE_TYPES38.TSUndefinedKeyword;
|
|
7450
|
+
}
|
|
7451
|
+
function isNullableArrayOnly(node) {
|
|
7452
|
+
const values = node.types.filter((member) => !isNullishType(member));
|
|
7453
|
+
return values.length > 0 && values.length < node.types.length && values.every(isArrayType);
|
|
7454
|
+
}
|
|
7455
|
+
var prefer_non_nullable_collection_default = createRule({
|
|
7456
|
+
name: "prefer-non-nullable-collection",
|
|
7457
|
+
meta: {
|
|
7458
|
+
type: "suggestion",
|
|
7459
|
+
docs: {
|
|
7460
|
+
description: "Require declared data-shape properties and direct aliases to use non-null arrays instead of explicit nullish unions."
|
|
7461
|
+
},
|
|
7462
|
+
schema: [],
|
|
7463
|
+
messages: {
|
|
7464
|
+
preferNonNullableCollection: "`{{name}}` is a nullable array, so nullish and `[]` represent the same empty collection. Use a non-null array and default omitted values to `[]`."
|
|
7465
|
+
}
|
|
7466
|
+
},
|
|
7467
|
+
defaultOptions: [],
|
|
7468
|
+
create(context) {
|
|
7469
|
+
const normalizedFilename = context.filename.replaceAll("\\", "/");
|
|
7470
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || /\/(?:vendor|vendored)\//u.test(normalizedFilename)) {
|
|
7471
|
+
return {};
|
|
7472
|
+
}
|
|
7473
|
+
function checkOptionalProperty(node) {
|
|
7474
|
+
if (node.optional) return;
|
|
7475
|
+
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7476
|
+
if (annotation === void 0) return;
|
|
7477
|
+
if (annotation.type !== AST_NODE_TYPES38.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7478
|
+
return;
|
|
7479
|
+
}
|
|
7480
|
+
context.report({
|
|
7481
|
+
node,
|
|
7482
|
+
messageId: "preferNonNullableCollection",
|
|
7483
|
+
data: { name: propertyName(node) }
|
|
7484
|
+
});
|
|
7485
|
+
}
|
|
7486
|
+
return {
|
|
7487
|
+
TSPropertySignature: checkOptionalProperty,
|
|
7488
|
+
PropertyDefinition: checkOptionalProperty,
|
|
7489
|
+
TSTypeAliasDeclaration(node) {
|
|
7490
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES38.TSUnionType) return;
|
|
7491
|
+
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7492
|
+
context.report({
|
|
7493
|
+
node,
|
|
7494
|
+
messageId: "preferNonNullableCollection",
|
|
7495
|
+
data: { name: node.id.name }
|
|
7496
|
+
});
|
|
7497
|
+
}
|
|
7498
|
+
};
|
|
7499
|
+
}
|
|
7500
|
+
});
|
|
7501
|
+
|
|
7337
7502
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7338
|
-
import { AST_NODE_TYPES as
|
|
7503
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39 } from "@typescript-eslint/utils";
|
|
7339
7504
|
var unwrap4 = (node) => {
|
|
7340
7505
|
let current = node;
|
|
7341
7506
|
while (current !== null && current !== void 0) {
|
|
7342
|
-
if (current.type ===
|
|
7507
|
+
if (current.type === AST_NODE_TYPES39.TSAsExpression || current.type === AST_NODE_TYPES39.TSTypeAssertion || current.type === AST_NODE_TYPES39.TSNonNullExpression || current.type === AST_NODE_TYPES39.TSSatisfiesExpression) {
|
|
7343
7508
|
current = current.expression;
|
|
7344
|
-
} else if (current.type ===
|
|
7509
|
+
} else if (current.type === AST_NODE_TYPES39.ChainExpression) {
|
|
7345
7510
|
current = current.expression;
|
|
7346
7511
|
} else {
|
|
7347
7512
|
break;
|
|
@@ -7356,23 +7521,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7356
7521
|
]);
|
|
7357
7522
|
var isSchemaParseReference = (node) => {
|
|
7358
7523
|
const inner = unwrap4(node);
|
|
7359
|
-
return inner !== null && inner.type ===
|
|
7524
|
+
return inner !== null && inner.type === AST_NODE_TYPES39.MemberExpression && !inner.computed && inner.property.type === AST_NODE_TYPES39.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7360
7525
|
};
|
|
7361
7526
|
var isRawPayloadSource = (node) => {
|
|
7362
7527
|
let current = unwrap4(node);
|
|
7363
7528
|
if (current === null) return false;
|
|
7364
|
-
if (current.type ===
|
|
7529
|
+
if (current.type === AST_NODE_TYPES39.AwaitExpression) {
|
|
7365
7530
|
current = unwrap4(current.argument);
|
|
7366
7531
|
}
|
|
7367
|
-
if (current === null || current.type !==
|
|
7532
|
+
if (current === null || current.type !== AST_NODE_TYPES39.CallExpression) {
|
|
7368
7533
|
return false;
|
|
7369
7534
|
}
|
|
7370
7535
|
const callee = unwrap4(current.callee);
|
|
7371
|
-
if (callee === null || callee.type !==
|
|
7536
|
+
if (callee === null || callee.type !== AST_NODE_TYPES39.MemberExpression) {
|
|
7372
7537
|
return false;
|
|
7373
7538
|
}
|
|
7374
7539
|
const property = unwrap4(callee.property);
|
|
7375
|
-
if (property === null || property.type !==
|
|
7540
|
+
if (property === null || property.type !== AST_NODE_TYPES39.Identifier) {
|
|
7376
7541
|
return false;
|
|
7377
7542
|
}
|
|
7378
7543
|
if (property.name === "json") {
|
|
@@ -7382,16 +7547,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7382
7547
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7383
7548
|
}
|
|
7384
7549
|
const object = unwrap4(callee.object);
|
|
7385
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7550
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES39.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7386
7551
|
};
|
|
7387
7552
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7388
7553
|
var isLocalFileRead = (node) => {
|
|
7389
7554
|
let found = false;
|
|
7390
7555
|
const visit = (current) => {
|
|
7391
7556
|
if (found || current === null || current === void 0) return;
|
|
7392
|
-
if (current.type ===
|
|
7557
|
+
if (current.type === AST_NODE_TYPES39.CallExpression) {
|
|
7393
7558
|
const callee = unwrap4(current.callee);
|
|
7394
|
-
const name = callee?.type ===
|
|
7559
|
+
const name = callee?.type === AST_NODE_TYPES39.Identifier ? callee.name : callee?.type === AST_NODE_TYPES39.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES39.Identifier ? callee.property.name : null;
|
|
7395
7560
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7396
7561
|
found = true;
|
|
7397
7562
|
return;
|
|
@@ -7413,15 +7578,15 @@ var isLocalFileRead = (node) => {
|
|
|
7413
7578
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7414
7579
|
var isInsideAssertion = (node) => {
|
|
7415
7580
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7416
|
-
if (current.type !==
|
|
7581
|
+
if (current.type !== AST_NODE_TYPES39.CallExpression) continue;
|
|
7417
7582
|
let callee = current.callee;
|
|
7418
|
-
while (callee.type ===
|
|
7583
|
+
while (callee.type === AST_NODE_TYPES39.MemberExpression) {
|
|
7419
7584
|
callee = callee.object;
|
|
7420
7585
|
}
|
|
7421
|
-
if (callee.type ===
|
|
7586
|
+
if (callee.type === AST_NODE_TYPES39.CallExpression) {
|
|
7422
7587
|
callee = callee.callee;
|
|
7423
7588
|
}
|
|
7424
|
-
if (callee.type ===
|
|
7589
|
+
if (callee.type === AST_NODE_TYPES39.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7425
7590
|
return true;
|
|
7426
7591
|
}
|
|
7427
7592
|
}
|
|
@@ -7440,39 +7605,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7440
7605
|
var isValidationRead = (node) => {
|
|
7441
7606
|
let current = node;
|
|
7442
7607
|
let parent = current.parent;
|
|
7443
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7608
|
+
while (parent !== null && parent !== void 0 && (parent.type === AST_NODE_TYPES39.TSAsExpression || parent.type === AST_NODE_TYPES39.TSTypeAssertion || parent.type === AST_NODE_TYPES39.TSNonNullExpression || parent.type === AST_NODE_TYPES39.TSSatisfiesExpression || parent.type === AST_NODE_TYPES39.ChainExpression)) {
|
|
7444
7609
|
current = parent;
|
|
7445
7610
|
parent = parent.parent;
|
|
7446
7611
|
}
|
|
7447
7612
|
if (parent === null || parent === void 0) return false;
|
|
7448
|
-
if (parent.type ===
|
|
7613
|
+
if (parent.type === AST_NODE_TYPES39.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7449
7614
|
return true;
|
|
7450
7615
|
}
|
|
7451
|
-
if (parent.type !==
|
|
7616
|
+
if (parent.type !== AST_NODE_TYPES39.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7452
7617
|
return false;
|
|
7453
7618
|
}
|
|
7454
7619
|
const callee = parent.callee;
|
|
7455
|
-
if (callee.type ===
|
|
7620
|
+
if (callee.type === AST_NODE_TYPES39.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES39.Identifier && callee.object.name === "Array" && callee.property.type === AST_NODE_TYPES39.Identifier && callee.property.name === "isArray") {
|
|
7456
7621
|
return parent.arguments.length === 1;
|
|
7457
7622
|
}
|
|
7458
|
-
return callee.type ===
|
|
7623
|
+
return callee.type === AST_NODE_TYPES39.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7459
7624
|
};
|
|
7460
7625
|
var isGuardTestPosition = (node) => {
|
|
7461
7626
|
let current = node;
|
|
7462
7627
|
let parent = current.parent;
|
|
7463
7628
|
while (parent !== void 0 && parent !== null) {
|
|
7464
7629
|
switch (parent.type) {
|
|
7465
|
-
case
|
|
7466
|
-
case
|
|
7467
|
-
case
|
|
7630
|
+
case AST_NODE_TYPES39.UnaryExpression:
|
|
7631
|
+
case AST_NODE_TYPES39.LogicalExpression:
|
|
7632
|
+
case AST_NODE_TYPES39.ChainExpression:
|
|
7468
7633
|
current = parent;
|
|
7469
7634
|
parent = parent.parent;
|
|
7470
7635
|
continue;
|
|
7471
|
-
case
|
|
7472
|
-
case
|
|
7473
|
-
case
|
|
7474
|
-
case
|
|
7475
|
-
case
|
|
7636
|
+
case AST_NODE_TYPES39.IfStatement:
|
|
7637
|
+
case AST_NODE_TYPES39.ConditionalExpression:
|
|
7638
|
+
case AST_NODE_TYPES39.WhileStatement:
|
|
7639
|
+
case AST_NODE_TYPES39.DoWhileStatement:
|
|
7640
|
+
case AST_NODE_TYPES39.ForStatement:
|
|
7476
7641
|
return parent.test === current;
|
|
7477
7642
|
default:
|
|
7478
7643
|
return false;
|
|
@@ -7482,7 +7647,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7482
7647
|
};
|
|
7483
7648
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7484
7649
|
const unwrapped = unwrap4(node);
|
|
7485
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7650
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES39.Identifier) {
|
|
7486
7651
|
return false;
|
|
7487
7652
|
}
|
|
7488
7653
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7525,11 +7690,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7525
7690
|
return {
|
|
7526
7691
|
VariableDeclarator(node) {
|
|
7527
7692
|
const scope = context.sourceCode.getScope(node);
|
|
7528
|
-
if (node.id.type ===
|
|
7693
|
+
if (node.id.type === AST_NODE_TYPES39.Identifier) {
|
|
7529
7694
|
trackInitializer(node);
|
|
7530
7695
|
return;
|
|
7531
7696
|
}
|
|
7532
|
-
if (node.id.type ===
|
|
7697
|
+
if (node.id.type === AST_NODE_TYPES39.ObjectPattern || node.id.type === AST_NODE_TYPES39.ArrayPattern) {
|
|
7533
7698
|
if (isRawPayloadSource(node.init)) {
|
|
7534
7699
|
if (!isFullyNarrowedPattern(node)) {
|
|
7535
7700
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7543,7 +7708,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7543
7708
|
},
|
|
7544
7709
|
AssignmentExpression(node) {
|
|
7545
7710
|
const scope = context.sourceCode.getScope(node);
|
|
7546
|
-
if (node.left.type ===
|
|
7711
|
+
if (node.left.type === AST_NODE_TYPES39.Identifier) {
|
|
7547
7712
|
const variable = findVariable2(scope, node.left.name);
|
|
7548
7713
|
if (variable === null) return;
|
|
7549
7714
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7553,7 +7718,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7553
7718
|
}
|
|
7554
7719
|
return;
|
|
7555
7720
|
}
|
|
7556
|
-
if (node.left.type ===
|
|
7721
|
+
if (node.left.type === AST_NODE_TYPES39.ObjectPattern || node.left.type === AST_NODE_TYPES39.ArrayPattern) {
|
|
7557
7722
|
if (isRawPayloadSource(node.right)) {
|
|
7558
7723
|
context.report({
|
|
7559
7724
|
node: node.left,
|
|
@@ -7570,15 +7735,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7570
7735
|
}
|
|
7571
7736
|
},
|
|
7572
7737
|
CallExpression(node) {
|
|
7573
|
-
if (node.callee.type !==
|
|
7738
|
+
if (node.callee.type !== AST_NODE_TYPES39.Identifier) return;
|
|
7574
7739
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7575
7740
|
return;
|
|
7576
7741
|
}
|
|
7577
7742
|
const scope = context.sourceCode.getScope(node);
|
|
7578
7743
|
for (const arg of node.arguments) {
|
|
7579
|
-
if (arg.type ===
|
|
7744
|
+
if (arg.type === AST_NODE_TYPES39.SpreadElement) continue;
|
|
7580
7745
|
const unwrapped = unwrap4(arg);
|
|
7581
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7746
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES39.Identifier) {
|
|
7582
7747
|
continue;
|
|
7583
7748
|
}
|
|
7584
7749
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7592,13 +7757,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7592
7757
|
const obj = unwrap4(node.object);
|
|
7593
7758
|
if (isRawPayloadSource(obj)) {
|
|
7594
7759
|
const parent = node.parent;
|
|
7595
|
-
if (parent.type ===
|
|
7760
|
+
if (parent.type === AST_NODE_TYPES39.CallExpression && parent.callee === node && node.property.type === AST_NODE_TYPES39.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7596
7761
|
return;
|
|
7597
7762
|
}
|
|
7598
7763
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7599
7764
|
return;
|
|
7600
7765
|
}
|
|
7601
|
-
if (obj !== null && obj.type ===
|
|
7766
|
+
if (obj !== null && obj.type === AST_NODE_TYPES39.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7602
7767
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7603
7768
|
const variable = findVariable2(scope, obj.name);
|
|
7604
7769
|
if (variable !== null) {
|
|
@@ -7611,7 +7776,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7611
7776
|
});
|
|
7612
7777
|
|
|
7613
7778
|
// src/rules/prefer-semantic-colors.ts
|
|
7614
|
-
import { AST_NODE_TYPES as
|
|
7779
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40 } from "@typescript-eslint/utils";
|
|
7615
7780
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
7616
7781
|
import { dirname, join, parse } from "path";
|
|
7617
7782
|
|
|
@@ -7711,8 +7876,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7711
7876
|
]);
|
|
7712
7877
|
function jsxElementName(node) {
|
|
7713
7878
|
const name = node.openingElement.name;
|
|
7714
|
-
if (name.type ===
|
|
7715
|
-
if (name.type ===
|
|
7879
|
+
if (name.type === AST_NODE_TYPES40.JSXIdentifier) return name.name;
|
|
7880
|
+
if (name.type === AST_NODE_TYPES40.JSXMemberExpression && name.property.type === AST_NODE_TYPES40.JSXIdentifier) {
|
|
7716
7881
|
return name.property.name;
|
|
7717
7882
|
}
|
|
7718
7883
|
return null;
|
|
@@ -7738,7 +7903,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7738
7903
|
var isInsideSvg = (node) => {
|
|
7739
7904
|
let current = node.parent;
|
|
7740
7905
|
while (current !== void 0 && current !== null) {
|
|
7741
|
-
if (current.type ===
|
|
7906
|
+
if (current.type === AST_NODE_TYPES40.JSXElement) {
|
|
7742
7907
|
const name = jsxElementName(current);
|
|
7743
7908
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7744
7909
|
}
|
|
@@ -7749,7 +7914,7 @@ var isInsideSvg = (node) => {
|
|
|
7749
7914
|
var isInsideIconFactoryPath = (node) => {
|
|
7750
7915
|
let current = node.parent;
|
|
7751
7916
|
while (current !== void 0 && current !== null) {
|
|
7752
|
-
if (current.type ===
|
|
7917
|
+
if (current.type === AST_NODE_TYPES40.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES40.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES40.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES40.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7753
7918
|
return true;
|
|
7754
7919
|
}
|
|
7755
7920
|
current = current.parent;
|
|
@@ -7886,12 +8051,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7886
8051
|
return root !== null && workspaceHasMarker(root);
|
|
7887
8052
|
};
|
|
7888
8053
|
var propName = (key) => {
|
|
7889
|
-
if (key.type ===
|
|
7890
|
-
if (key.type ===
|
|
8054
|
+
if (key.type === AST_NODE_TYPES40.Identifier) return key.name;
|
|
8055
|
+
if (key.type === AST_NODE_TYPES40.Literal && typeof key.value === "string") return key.value;
|
|
7891
8056
|
return null;
|
|
7892
8057
|
};
|
|
7893
8058
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7894
|
-
if (statement.type !==
|
|
8059
|
+
if (statement.type !== AST_NODE_TYPES40.ImportDeclaration && statement.type !== AST_NODE_TYPES40.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES40.ExportAllDeclaration) {
|
|
7895
8060
|
return false;
|
|
7896
8061
|
}
|
|
7897
8062
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -7943,27 +8108,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7943
8108
|
const checkClassNode = (node) => {
|
|
7944
8109
|
if (node === null) return;
|
|
7945
8110
|
switch (node.type) {
|
|
7946
|
-
case
|
|
8111
|
+
case AST_NODE_TYPES40.Literal:
|
|
7947
8112
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7948
8113
|
break;
|
|
7949
|
-
case
|
|
8114
|
+
case AST_NODE_TYPES40.TemplateLiteral:
|
|
7950
8115
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7951
8116
|
break;
|
|
7952
|
-
case
|
|
8117
|
+
case AST_NODE_TYPES40.ArrayExpression:
|
|
7953
8118
|
for (const element of node.elements) {
|
|
7954
|
-
if (element !== null && element.type !==
|
|
8119
|
+
if (element !== null && element.type !== AST_NODE_TYPES40.SpreadElement) checkClassNode(element);
|
|
7955
8120
|
}
|
|
7956
8121
|
break;
|
|
7957
|
-
case
|
|
8122
|
+
case AST_NODE_TYPES40.ObjectExpression:
|
|
7958
8123
|
for (const property of node.properties) {
|
|
7959
|
-
if (property.type ===
|
|
8124
|
+
if (property.type === AST_NODE_TYPES40.Property) checkClassNode(property.value);
|
|
7960
8125
|
}
|
|
7961
8126
|
break;
|
|
7962
|
-
case
|
|
8127
|
+
case AST_NODE_TYPES40.ConditionalExpression:
|
|
7963
8128
|
checkClassNode(node.consequent);
|
|
7964
8129
|
checkClassNode(node.alternate);
|
|
7965
8130
|
break;
|
|
7966
|
-
case
|
|
8131
|
+
case AST_NODE_TYPES40.LogicalExpression:
|
|
7967
8132
|
checkClassNode(node.right);
|
|
7968
8133
|
break;
|
|
7969
8134
|
default:
|
|
@@ -7971,32 +8136,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7971
8136
|
}
|
|
7972
8137
|
};
|
|
7973
8138
|
const checkColorValueNode = (node) => {
|
|
7974
|
-
if (node.type ===
|
|
8139
|
+
if (node.type === AST_NODE_TYPES40.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
7975
8140
|
report(node, "inlineColor", { value: node.value });
|
|
7976
8141
|
}
|
|
7977
8142
|
};
|
|
7978
8143
|
return {
|
|
7979
8144
|
"JSXAttribute[name.name='className']"(node) {
|
|
7980
8145
|
if (node.value === null) return;
|
|
7981
|
-
if (node.value.type ===
|
|
7982
|
-
else if (node.value.type ===
|
|
7983
|
-
if (node.value.expression.type !==
|
|
8146
|
+
if (node.value.type === AST_NODE_TYPES40.Literal) checkClassNode(node.value);
|
|
8147
|
+
else if (node.value.type === AST_NODE_TYPES40.JSXExpressionContainer) {
|
|
8148
|
+
if (node.value.expression.type !== AST_NODE_TYPES40.JSXEmptyExpression) {
|
|
7984
8149
|
checkClassNode(node.value.expression);
|
|
7985
8150
|
}
|
|
7986
8151
|
}
|
|
7987
8152
|
},
|
|
7988
8153
|
CallExpression(node) {
|
|
7989
|
-
if (node.callee.type ===
|
|
8154
|
+
if (node.callee.type === AST_NODE_TYPES40.Identifier && node.callee.name === "require" && node.arguments[0]?.type === AST_NODE_TYPES40.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
7990
8155
|
importsEmailOrPdfRenderer = true;
|
|
7991
8156
|
}
|
|
7992
|
-
if (node.callee.type ===
|
|
8157
|
+
if (node.callee.type === AST_NODE_TYPES40.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7993
8158
|
for (const arg of node.arguments) {
|
|
7994
|
-
if (arg.type !==
|
|
8159
|
+
if (arg.type !== AST_NODE_TYPES40.SpreadElement) checkClassNode(arg);
|
|
7995
8160
|
}
|
|
7996
8161
|
}
|
|
7997
8162
|
},
|
|
7998
8163
|
VariableDeclarator(node) {
|
|
7999
|
-
if (node.id.type ===
|
|
8164
|
+
if (node.id.type === AST_NODE_TYPES40.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8000
8165
|
checkClassNode(node.init);
|
|
8001
8166
|
}
|
|
8002
8167
|
},
|
|
@@ -8006,9 +8171,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8006
8171
|
},
|
|
8007
8172
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8008
8173
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8009
|
-
if (node.value?.type !==
|
|
8174
|
+
if (node.value?.type !== AST_NODE_TYPES40.Literal) return;
|
|
8010
8175
|
const owner = node.parent.name;
|
|
8011
|
-
if (owner.type ===
|
|
8176
|
+
if (owner.type === AST_NODE_TYPES40.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8012
8177
|
return;
|
|
8013
8178
|
}
|
|
8014
8179
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8022,7 +8187,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8022
8187
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8023
8188
|
},
|
|
8024
8189
|
ImportExpression(node) {
|
|
8025
|
-
if (node.source.type ===
|
|
8190
|
+
if (node.source.type === AST_NODE_TYPES40.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8026
8191
|
importsEmailOrPdfRenderer = true;
|
|
8027
8192
|
}
|
|
8028
8193
|
},
|
|
@@ -8228,7 +8393,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8228
8393
|
// src/rules/prefer-string-literal-union.ts
|
|
8229
8394
|
import {
|
|
8230
8395
|
ESLintUtils as ESLintUtils3,
|
|
8231
|
-
AST_NODE_TYPES as
|
|
8396
|
+
AST_NODE_TYPES as AST_NODE_TYPES41
|
|
8232
8397
|
} from "@typescript-eslint/utils";
|
|
8233
8398
|
import * as ts2 from "typescript";
|
|
8234
8399
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -8272,19 +8437,19 @@ function isChoiceLikeName(name) {
|
|
|
8272
8437
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8273
8438
|
}
|
|
8274
8439
|
function keyName(key) {
|
|
8275
|
-
if (key.type ===
|
|
8440
|
+
if (key.type === AST_NODE_TYPES41.Identifier) {
|
|
8276
8441
|
return key.name;
|
|
8277
8442
|
}
|
|
8278
|
-
if (key.type ===
|
|
8443
|
+
if (key.type === AST_NODE_TYPES41.Literal && typeof key.value === "string") {
|
|
8279
8444
|
return key.value;
|
|
8280
8445
|
}
|
|
8281
8446
|
return null;
|
|
8282
8447
|
}
|
|
8283
8448
|
function isStringLiteralMember(t) {
|
|
8284
|
-
return t.type ===
|
|
8449
|
+
return t.type === AST_NODE_TYPES41.TSLiteralType && t.literal.type === AST_NODE_TYPES41.Literal && typeof t.literal.value === "string";
|
|
8285
8450
|
}
|
|
8286
8451
|
function isStringLiteralUnion(node) {
|
|
8287
|
-
if (node?.type !==
|
|
8452
|
+
if (node?.type !== AST_NODE_TYPES41.TSUnionType) {
|
|
8288
8453
|
return false;
|
|
8289
8454
|
}
|
|
8290
8455
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8313,12 +8478,12 @@ function bindingSourceExpression(decl) {
|
|
|
8313
8478
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8314
8479
|
}
|
|
8315
8480
|
function refKey(node) {
|
|
8316
|
-
if (node.type ===
|
|
8481
|
+
if (node.type === AST_NODE_TYPES41.Identifier) {
|
|
8317
8482
|
return node.name;
|
|
8318
8483
|
}
|
|
8319
|
-
if (node.type ===
|
|
8484
|
+
if (node.type === AST_NODE_TYPES41.MemberExpression && !node.computed) {
|
|
8320
8485
|
const inner = refKey(node.object);
|
|
8321
|
-
if (inner === null || node.property.type !==
|
|
8486
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES41.Identifier) {
|
|
8322
8487
|
return null;
|
|
8323
8488
|
}
|
|
8324
8489
|
return `${inner}.${node.property.name}`;
|
|
@@ -8326,7 +8491,7 @@ function refKey(node) {
|
|
|
8326
8491
|
return null;
|
|
8327
8492
|
}
|
|
8328
8493
|
function strLiteral(node) {
|
|
8329
|
-
if (node.type ===
|
|
8494
|
+
if (node.type === AST_NODE_TYPES41.Literal && typeof node.value === "string") {
|
|
8330
8495
|
return node.value;
|
|
8331
8496
|
}
|
|
8332
8497
|
return null;
|
|
@@ -8479,7 +8644,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8479
8644
|
containersWithUnion.add(container);
|
|
8480
8645
|
return;
|
|
8481
8646
|
}
|
|
8482
|
-
if (typeNode?.type !==
|
|
8647
|
+
if (typeNode?.type !== AST_NODE_TYPES41.TSStringKeyword) {
|
|
8483
8648
|
return;
|
|
8484
8649
|
}
|
|
8485
8650
|
const name = keyName(key);
|
|
@@ -8567,10 +8732,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8567
8732
|
}
|
|
8568
8733
|
};
|
|
8569
8734
|
function refKeyText(node) {
|
|
8570
|
-
if (node.type ===
|
|
8735
|
+
if (node.type === AST_NODE_TYPES41.BinaryExpression) {
|
|
8571
8736
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8572
8737
|
}
|
|
8573
|
-
if (node.type ===
|
|
8738
|
+
if (node.type === AST_NODE_TYPES41.SwitchStatement) {
|
|
8574
8739
|
return refKey(node.discriminant) ?? "value";
|
|
8575
8740
|
}
|
|
8576
8741
|
return "value";
|
|
@@ -8579,7 +8744,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8579
8744
|
});
|
|
8580
8745
|
|
|
8581
8746
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8582
|
-
import { AST_NODE_TYPES as
|
|
8747
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42 } from "@typescript-eslint/utils";
|
|
8583
8748
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8584
8749
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8585
8750
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8588,11 +8753,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8588
8753
|
var MIN_RUN_LENGTH = 2;
|
|
8589
8754
|
function literalText(node, getText) {
|
|
8590
8755
|
switch (node.type) {
|
|
8591
|
-
case
|
|
8756
|
+
case AST_NODE_TYPES42.Literal:
|
|
8592
8757
|
return "regex" in node ? null : getText(node);
|
|
8593
|
-
case
|
|
8758
|
+
case AST_NODE_TYPES42.TemplateLiteral:
|
|
8594
8759
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8595
|
-
case
|
|
8760
|
+
case AST_NODE_TYPES42.UnaryExpression:
|
|
8596
8761
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8597
8762
|
default:
|
|
8598
8763
|
return null;
|
|
@@ -8600,15 +8765,15 @@ function literalText(node, getText) {
|
|
|
8600
8765
|
}
|
|
8601
8766
|
function isPureReceiver(node) {
|
|
8602
8767
|
switch (node.type) {
|
|
8603
|
-
case
|
|
8604
|
-
case
|
|
8768
|
+
case AST_NODE_TYPES42.Identifier:
|
|
8769
|
+
case AST_NODE_TYPES42.ThisExpression:
|
|
8605
8770
|
return true;
|
|
8606
|
-
case
|
|
8771
|
+
case AST_NODE_TYPES42.MemberExpression:
|
|
8607
8772
|
if (node.optional) {
|
|
8608
8773
|
return false;
|
|
8609
8774
|
}
|
|
8610
8775
|
if (node.computed) {
|
|
8611
|
-
return node.property.type ===
|
|
8776
|
+
return node.property.type === AST_NODE_TYPES42.Literal && isPureReceiver(node.object);
|
|
8612
8777
|
}
|
|
8613
8778
|
return isPureReceiver(node.object);
|
|
8614
8779
|
default:
|
|
@@ -8616,7 +8781,7 @@ function isPureReceiver(node) {
|
|
|
8616
8781
|
}
|
|
8617
8782
|
}
|
|
8618
8783
|
function literalIndex(node) {
|
|
8619
|
-
if (node.type !==
|
|
8784
|
+
if (node.type !== AST_NODE_TYPES42.Literal || typeof node.value !== "number") {
|
|
8620
8785
|
return null;
|
|
8621
8786
|
}
|
|
8622
8787
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8642,24 +8807,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8642
8807
|
}
|
|
8643
8808
|
const { sourceCode } = context;
|
|
8644
8809
|
function parseAssertion(statement) {
|
|
8645
|
-
if (statement.type !==
|
|
8810
|
+
if (statement.type !== AST_NODE_TYPES42.ExpressionStatement) {
|
|
8646
8811
|
return null;
|
|
8647
8812
|
}
|
|
8648
8813
|
const call = statement.expression;
|
|
8649
|
-
if (call.type !==
|
|
8814
|
+
if (call.type !== AST_NODE_TYPES42.CallExpression) {
|
|
8650
8815
|
return null;
|
|
8651
8816
|
}
|
|
8652
8817
|
const callee = call.callee;
|
|
8653
|
-
if (callee.type !==
|
|
8818
|
+
if (callee.type !== AST_NODE_TYPES42.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES42.Identifier) {
|
|
8654
8819
|
return null;
|
|
8655
8820
|
}
|
|
8656
8821
|
const matcher = callee.property.name;
|
|
8657
8822
|
const expectCall = callee.object;
|
|
8658
|
-
if (expectCall.type !==
|
|
8823
|
+
if (expectCall.type !== AST_NODE_TYPES42.CallExpression || expectCall.callee.type !== AST_NODE_TYPES42.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8659
8824
|
return null;
|
|
8660
8825
|
}
|
|
8661
8826
|
const actual = expectCall.arguments[0];
|
|
8662
|
-
if (actual === void 0 || actual.type !==
|
|
8827
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES42.MemberExpression || actual.optional) {
|
|
8663
8828
|
return null;
|
|
8664
8829
|
}
|
|
8665
8830
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8673,7 +8838,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8673
8838
|
}
|
|
8674
8839
|
key = { kind: "index", index };
|
|
8675
8840
|
} else {
|
|
8676
|
-
if (actual.property.type !==
|
|
8841
|
+
if (actual.property.type !== AST_NODE_TYPES42.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8677
8842
|
return null;
|
|
8678
8843
|
}
|
|
8679
8844
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8685,7 +8850,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8685
8850
|
return null;
|
|
8686
8851
|
}
|
|
8687
8852
|
const expected = call.arguments[0];
|
|
8688
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8853
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES42.SpreadElement) {
|
|
8689
8854
|
return null;
|
|
8690
8855
|
}
|
|
8691
8856
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8800,7 +8965,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8800
8965
|
});
|
|
8801
8966
|
|
|
8802
8967
|
// src/rules/prefer-zod-enum.ts
|
|
8803
|
-
import { AST_NODE_TYPES as
|
|
8968
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43 } from "@typescript-eslint/utils";
|
|
8804
8969
|
var prefer_zod_enum_default = createRule({
|
|
8805
8970
|
name: "prefer-zod-enum",
|
|
8806
8971
|
meta: {
|
|
@@ -8820,25 +8985,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
8820
8985
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8821
8986
|
function enumValues(node) {
|
|
8822
8987
|
const callee = node.callee;
|
|
8823
|
-
if (callee.type !==
|
|
8988
|
+
if (callee.type !== AST_NODE_TYPES43.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES43.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== AST_NODE_TYPES43.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8824
8989
|
return null;
|
|
8825
8990
|
}
|
|
8826
8991
|
const argument = node.arguments[0];
|
|
8827
|
-
if (argument === void 0 || argument.type !==
|
|
8992
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES43.ArrayExpression || argument.elements.length === 0) {
|
|
8828
8993
|
return null;
|
|
8829
8994
|
}
|
|
8830
8995
|
const values = [];
|
|
8831
8996
|
let canFix = true;
|
|
8832
8997
|
for (const element of argument.elements) {
|
|
8833
|
-
if (element?.type ===
|
|
8998
|
+
if (element?.type === AST_NODE_TYPES43.SpreadElement) {
|
|
8834
8999
|
canFix = false;
|
|
8835
9000
|
continue;
|
|
8836
9001
|
}
|
|
8837
|
-
if (element === null || element.type !==
|
|
9002
|
+
if (element === null || element.type !== AST_NODE_TYPES43.CallExpression || element.callee.type !== AST_NODE_TYPES43.MemberExpression || element.callee.computed || element.callee.object.type !== AST_NODE_TYPES43.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== AST_NODE_TYPES43.Identifier || element.callee.property.name !== "literal") {
|
|
8838
9003
|
return null;
|
|
8839
9004
|
}
|
|
8840
9005
|
const value = element.arguments[0];
|
|
8841
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
9006
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== AST_NODE_TYPES43.Literal || typeof value.value !== "string") {
|
|
8842
9007
|
canFix = false;
|
|
8843
9008
|
continue;
|
|
8844
9009
|
}
|
|
@@ -8848,11 +9013,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
8848
9013
|
}
|
|
8849
9014
|
function buildFix(node, values) {
|
|
8850
9015
|
const argument = node.arguments[0];
|
|
8851
|
-
if (argument === void 0 || argument.type !==
|
|
9016
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES43.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8852
9017
|
return void 0;
|
|
8853
9018
|
}
|
|
8854
9019
|
const callee = node.callee;
|
|
8855
|
-
if (callee.type !==
|
|
9020
|
+
if (callee.type !== AST_NODE_TYPES43.MemberExpression || callee.property.type !== AST_NODE_TYPES43.Identifier) {
|
|
8856
9021
|
return void 0;
|
|
8857
9022
|
}
|
|
8858
9023
|
return (fixer) => [
|
|
@@ -8869,7 +9034,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8869
9034
|
return;
|
|
8870
9035
|
}
|
|
8871
9036
|
for (const specifier of node.specifiers) {
|
|
8872
|
-
if (specifier.type ===
|
|
9037
|
+
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") {
|
|
8873
9038
|
zodNamespaces.add(specifier.local.name);
|
|
8874
9039
|
}
|
|
8875
9040
|
}
|
|
@@ -8891,7 +9056,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8891
9056
|
});
|
|
8892
9057
|
|
|
8893
9058
|
// src/rules/prefer-zod-infer.ts
|
|
8894
|
-
import { AST_NODE_TYPES as
|
|
9059
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44 } from "@typescript-eslint/utils";
|
|
8895
9060
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8896
9061
|
"describe",
|
|
8897
9062
|
"refine",
|
|
@@ -8928,44 +9093,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8928
9093
|
"Schema"
|
|
8929
9094
|
]);
|
|
8930
9095
|
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: [
|
|
9096
|
+
string: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9097
|
+
email: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9098
|
+
url: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9099
|
+
uuid: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9100
|
+
ulid: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9101
|
+
cuid: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9102
|
+
cuid2: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9103
|
+
nanoid: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9104
|
+
iso: [AST_NODE_TYPES44.TSStringKeyword],
|
|
9105
|
+
number: [AST_NODE_TYPES44.TSNumberKeyword],
|
|
9106
|
+
int: [AST_NODE_TYPES44.TSNumberKeyword],
|
|
9107
|
+
float32: [AST_NODE_TYPES44.TSNumberKeyword],
|
|
9108
|
+
float64: [AST_NODE_TYPES44.TSNumberKeyword],
|
|
9109
|
+
boolean: [AST_NODE_TYPES44.TSBooleanKeyword],
|
|
9110
|
+
bigint: [AST_NODE_TYPES44.TSBigIntKeyword],
|
|
9111
|
+
symbol: [AST_NODE_TYPES44.TSSymbolKeyword],
|
|
9112
|
+
any: [AST_NODE_TYPES44.TSAnyKeyword],
|
|
9113
|
+
unknown: [AST_NODE_TYPES44.TSUnknownKeyword],
|
|
9114
|
+
never: [AST_NODE_TYPES44.TSNeverKeyword],
|
|
9115
|
+
void: [AST_NODE_TYPES44.TSVoidKeyword],
|
|
9116
|
+
null: [AST_NODE_TYPES44.TSNullKeyword],
|
|
9117
|
+
undefined: [AST_NODE_TYPES44.TSUndefinedKeyword],
|
|
9118
|
+
literal: [AST_NODE_TYPES44.TSLiteralType],
|
|
9119
|
+
date: [AST_NODE_TYPES44.TSTypeReference],
|
|
9120
|
+
array: [AST_NODE_TYPES44.TSArrayType, AST_NODE_TYPES44.TSTypeReference],
|
|
9121
|
+
tuple: [AST_NODE_TYPES44.TSTupleType],
|
|
9122
|
+
object: [AST_NODE_TYPES44.TSTypeLiteral, AST_NODE_TYPES44.TSTypeReference],
|
|
9123
|
+
strictObject: [AST_NODE_TYPES44.TSTypeLiteral, AST_NODE_TYPES44.TSTypeReference],
|
|
9124
|
+
looseObject: [AST_NODE_TYPES44.TSTypeLiteral, AST_NODE_TYPES44.TSTypeReference],
|
|
9125
|
+
record: [AST_NODE_TYPES44.TSTypeReference, AST_NODE_TYPES44.TSTypeLiteral],
|
|
9126
|
+
map: [AST_NODE_TYPES44.TSTypeReference],
|
|
9127
|
+
set: [AST_NODE_TYPES44.TSTypeReference],
|
|
9128
|
+
promise: [AST_NODE_TYPES44.TSTypeReference],
|
|
9129
|
+
enum: [AST_NODE_TYPES44.TSUnionType, AST_NODE_TYPES44.TSTypeReference, AST_NODE_TYPES44.TSLiteralType],
|
|
9130
|
+
nativeEnum: [AST_NODE_TYPES44.TSUnionType, AST_NODE_TYPES44.TSTypeReference, AST_NODE_TYPES44.TSLiteralType],
|
|
9131
|
+
union: [AST_NODE_TYPES44.TSUnionType, AST_NODE_TYPES44.TSTypeReference],
|
|
9132
|
+
discriminatedUnion: [AST_NODE_TYPES44.TSUnionType, AST_NODE_TYPES44.TSTypeReference],
|
|
9133
|
+
intersection: [AST_NODE_TYPES44.TSIntersectionType, AST_NODE_TYPES44.TSTypeReference]
|
|
8969
9134
|
};
|
|
8970
9135
|
function normalizeSchemaName(name) {
|
|
8971
9136
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8974,20 +9139,20 @@ function normalizeTypeName(name) {
|
|
|
8974
9139
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8975
9140
|
}
|
|
8976
9141
|
function unwrapNullish(annotation) {
|
|
8977
|
-
if (annotation.type !==
|
|
9142
|
+
if (annotation.type !== AST_NODE_TYPES44.TSUnionType) {
|
|
8978
9143
|
return {
|
|
8979
9144
|
core: annotation,
|
|
8980
|
-
nullable: annotation.type ===
|
|
9145
|
+
nullable: annotation.type === AST_NODE_TYPES44.TSNullKeyword
|
|
8981
9146
|
};
|
|
8982
9147
|
}
|
|
8983
9148
|
const rest = [];
|
|
8984
9149
|
let nullable = false;
|
|
8985
9150
|
for (const member of annotation.types) {
|
|
8986
|
-
if (member.type ===
|
|
9151
|
+
if (member.type === AST_NODE_TYPES44.TSNullKeyword) {
|
|
8987
9152
|
nullable = true;
|
|
8988
9153
|
continue;
|
|
8989
9154
|
}
|
|
8990
|
-
if (member.type ===
|
|
9155
|
+
if (member.type === AST_NODE_TYPES44.TSUndefinedKeyword) {
|
|
8991
9156
|
continue;
|
|
8992
9157
|
}
|
|
8993
9158
|
rest.push(member);
|
|
@@ -9052,14 +9217,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9052
9217
|
function zodCallChain(node) {
|
|
9053
9218
|
const chain = [];
|
|
9054
9219
|
let current = node;
|
|
9055
|
-
while (current.type ===
|
|
9220
|
+
while (current.type === AST_NODE_TYPES44.CallExpression) {
|
|
9056
9221
|
const callee = current.callee;
|
|
9057
|
-
if (callee.type !==
|
|
9222
|
+
if (callee.type !== AST_NODE_TYPES44.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES44.Identifier) {
|
|
9058
9223
|
return null;
|
|
9059
9224
|
}
|
|
9060
9225
|
chain.push(current);
|
|
9061
9226
|
const receiver = callee.object;
|
|
9062
|
-
if (receiver.type ===
|
|
9227
|
+
if (receiver.type === AST_NODE_TYPES44.Identifier) {
|
|
9063
9228
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9064
9229
|
}
|
|
9065
9230
|
current = receiver;
|
|
@@ -9068,19 +9233,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9068
9233
|
}
|
|
9069
9234
|
function methodName(call) {
|
|
9070
9235
|
const callee = call.callee;
|
|
9071
|
-
return callee.type ===
|
|
9236
|
+
return callee.type === AST_NODE_TYPES44.MemberExpression && callee.property.type === AST_NODE_TYPES44.Identifier ? callee.property.name : "";
|
|
9072
9237
|
}
|
|
9073
9238
|
function schemaField(node) {
|
|
9074
9239
|
const modifiers = [];
|
|
9075
9240
|
let current = node;
|
|
9076
9241
|
let leaf = null;
|
|
9077
|
-
while (current.type ===
|
|
9242
|
+
while (current.type === AST_NODE_TYPES44.CallExpression) {
|
|
9078
9243
|
const callee = current.callee;
|
|
9079
|
-
if (callee.type !==
|
|
9244
|
+
if (callee.type !== AST_NODE_TYPES44.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES44.Identifier) {
|
|
9080
9245
|
break;
|
|
9081
9246
|
}
|
|
9082
9247
|
const receiver = callee.object;
|
|
9083
|
-
if (receiver.type ===
|
|
9248
|
+
if (receiver.type === AST_NODE_TYPES44.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9084
9249
|
leaf = callee.property.name;
|
|
9085
9250
|
break;
|
|
9086
9251
|
}
|
|
@@ -9111,16 +9276,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9111
9276
|
return null;
|
|
9112
9277
|
}
|
|
9113
9278
|
const shape = base.arguments[0];
|
|
9114
|
-
if (shape === void 0 || shape.type !==
|
|
9279
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES44.ObjectExpression) {
|
|
9115
9280
|
return null;
|
|
9116
9281
|
}
|
|
9117
9282
|
const fields = /* @__PURE__ */ new Map();
|
|
9118
9283
|
for (const property of shape.properties) {
|
|
9119
|
-
if (property.type !==
|
|
9284
|
+
if (property.type !== AST_NODE_TYPES44.Property || property.computed) {
|
|
9120
9285
|
return null;
|
|
9121
9286
|
}
|
|
9122
9287
|
const { key } = property;
|
|
9123
|
-
const name = key.type ===
|
|
9288
|
+
const name = key.type === AST_NODE_TYPES44.Identifier ? key.name : key.type === AST_NODE_TYPES44.Literal && typeof key.value === "string" ? key.value : null;
|
|
9124
9289
|
if (name === null) {
|
|
9125
9290
|
return null;
|
|
9126
9291
|
}
|
|
@@ -9131,11 +9296,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9131
9296
|
function typeMembers(members) {
|
|
9132
9297
|
const result = /* @__PURE__ */ new Map();
|
|
9133
9298
|
for (const member of members) {
|
|
9134
|
-
if (member.type !==
|
|
9299
|
+
if (member.type !== AST_NODE_TYPES44.TSPropertySignature || member.computed) {
|
|
9135
9300
|
return null;
|
|
9136
9301
|
}
|
|
9137
9302
|
const { key } = member;
|
|
9138
|
-
const name = key.type ===
|
|
9303
|
+
const name = key.type === AST_NODE_TYPES44.Identifier ? key.name : key.type === AST_NODE_TYPES44.Literal && typeof key.value === "string" ? key.value : null;
|
|
9139
9304
|
if (name === null) {
|
|
9140
9305
|
return null;
|
|
9141
9306
|
}
|
|
@@ -9149,8 +9314,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9149
9314
|
return result.size === 0 ? null : result;
|
|
9150
9315
|
}
|
|
9151
9316
|
function collectConstrainedNames(node) {
|
|
9152
|
-
if (node.type ===
|
|
9153
|
-
if (node.typeName.type ===
|
|
9317
|
+
if (node.type === AST_NODE_TYPES44.TSTypeReference) {
|
|
9318
|
+
if (node.typeName.type === AST_NODE_TYPES44.Identifier) {
|
|
9154
9319
|
constrainedTypeNames.add(node.typeName.name);
|
|
9155
9320
|
}
|
|
9156
9321
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9158,11 +9323,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9158
9323
|
}
|
|
9159
9324
|
return;
|
|
9160
9325
|
}
|
|
9161
|
-
if (node.type ===
|
|
9326
|
+
if (node.type === AST_NODE_TYPES44.TSArrayType) {
|
|
9162
9327
|
collectConstrainedNames(node.elementType);
|
|
9163
9328
|
return;
|
|
9164
9329
|
}
|
|
9165
|
-
if (node.type ===
|
|
9330
|
+
if (node.type === AST_NODE_TYPES44.TSUnionType || node.type === AST_NODE_TYPES44.TSIntersectionType) {
|
|
9166
9331
|
for (const member of node.types) {
|
|
9167
9332
|
collectConstrainedNames(member);
|
|
9168
9333
|
}
|
|
@@ -9206,13 +9371,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9206
9371
|
return;
|
|
9207
9372
|
}
|
|
9208
9373
|
for (const specifier of node.specifiers) {
|
|
9209
|
-
if (specifier.type ===
|
|
9374
|
+
if (specifier.type === AST_NODE_TYPES44.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES44.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES44.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES44.Identifier && specifier.imported.name === "z") {
|
|
9210
9375
|
zodNamespaces.add(specifier.local.name);
|
|
9211
9376
|
}
|
|
9212
9377
|
}
|
|
9213
9378
|
},
|
|
9214
9379
|
VariableDeclarator(node) {
|
|
9215
|
-
if (node.id.type !==
|
|
9380
|
+
if (node.id.type !== AST_NODE_TYPES44.Identifier || node.init == null) {
|
|
9216
9381
|
return;
|
|
9217
9382
|
}
|
|
9218
9383
|
const fields = schemaFields(node.init);
|
|
@@ -9222,14 +9387,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9222
9387
|
},
|
|
9223
9388
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9224
9389
|
"MemberExpression[computed=false]"(node) {
|
|
9225
|
-
if (node.object.type ===
|
|
9390
|
+
if (node.object.type === AST_NODE_TYPES44.Identifier && node.property.type === AST_NODE_TYPES44.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9226
9391
|
reshapedSchemaNames.add(node.object.name);
|
|
9227
9392
|
}
|
|
9228
9393
|
},
|
|
9229
9394
|
/** Records every type argument carried by a Zod constraint. */
|
|
9230
9395
|
TSTypeReference(node) {
|
|
9231
9396
|
const { typeName } = node;
|
|
9232
|
-
const referenced = typeName.type ===
|
|
9397
|
+
const referenced = typeName.type === AST_NODE_TYPES44.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES44.TSQualifiedName && typeName.right.type === AST_NODE_TYPES44.Identifier ? typeName.right.name : null;
|
|
9233
9398
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9234
9399
|
return;
|
|
9235
9400
|
}
|
|
@@ -9247,7 +9412,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9247
9412
|
}
|
|
9248
9413
|
},
|
|
9249
9414
|
TSTypeAliasDeclaration(node) {
|
|
9250
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9415
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES44.TSTypeLiteral) {
|
|
9251
9416
|
return;
|
|
9252
9417
|
}
|
|
9253
9418
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9292,10 +9457,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9292
9457
|
});
|
|
9293
9458
|
|
|
9294
9459
|
// src/rules/require-assert-never.ts
|
|
9295
|
-
import { AST_NODE_TYPES as
|
|
9460
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45 } from "@typescript-eslint/utils";
|
|
9296
9461
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9297
|
-
if (statement.type ===
|
|
9298
|
-
if (statement.type ===
|
|
9462
|
+
if (statement.type === AST_NODE_TYPES45.EmptyStatement) return false;
|
|
9463
|
+
if (statement.type === AST_NODE_TYPES45.BlockStatement) {
|
|
9299
9464
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9300
9465
|
}
|
|
9301
9466
|
return true;
|
|
@@ -9311,7 +9476,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9311
9476
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9312
9477
|
}
|
|
9313
9478
|
const only = defaultCase.consequent[0];
|
|
9314
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9479
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES45.BlockStatement && only.body.length === 0) {
|
|
9315
9480
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9316
9481
|
}
|
|
9317
9482
|
return false;
|
|
@@ -9351,7 +9516,7 @@ var require_assert_never_default = createRule({
|
|
|
9351
9516
|
});
|
|
9352
9517
|
|
|
9353
9518
|
// src/rules/require-fetch-timeout.ts
|
|
9354
|
-
import { AST_NODE_TYPES as
|
|
9519
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
|
|
9355
9520
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9356
9521
|
"globalThis",
|
|
9357
9522
|
"window",
|
|
@@ -9367,14 +9532,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9367
9532
|
return false;
|
|
9368
9533
|
}
|
|
9369
9534
|
function initProvablyLacksSignal(init) {
|
|
9370
|
-
if (init.type !==
|
|
9535
|
+
if (init.type !== AST_NODE_TYPES46.ObjectExpression) {
|
|
9371
9536
|
return false;
|
|
9372
9537
|
}
|
|
9373
9538
|
for (const prop of init.properties) {
|
|
9374
|
-
if (prop.type ===
|
|
9539
|
+
if (prop.type === AST_NODE_TYPES46.SpreadElement) {
|
|
9375
9540
|
return false;
|
|
9376
9541
|
}
|
|
9377
|
-
if (prop.key.type ===
|
|
9542
|
+
if (prop.key.type === AST_NODE_TYPES46.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES46.Literal && prop.key.value === "signal") {
|
|
9378
9543
|
return false;
|
|
9379
9544
|
}
|
|
9380
9545
|
if (prop.computed) {
|
|
@@ -9384,7 +9549,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9384
9549
|
return true;
|
|
9385
9550
|
}
|
|
9386
9551
|
function isStringish(node) {
|
|
9387
|
-
return node.type ===
|
|
9552
|
+
return node.type === AST_NODE_TYPES46.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES46.TemplateLiteral;
|
|
9388
9553
|
}
|
|
9389
9554
|
var require_fetch_timeout_default = createRule({
|
|
9390
9555
|
name: "require-fetch-timeout",
|
|
@@ -9425,10 +9590,10 @@ var require_fetch_timeout_default = createRule({
|
|
|
9425
9590
|
return variable === null || variable.defs.length === 0;
|
|
9426
9591
|
}
|
|
9427
9592
|
function isGlobalFetchCall2(callee) {
|
|
9428
|
-
if (callee.type ===
|
|
9593
|
+
if (callee.type === AST_NODE_TYPES46.Identifier) {
|
|
9429
9594
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9430
9595
|
}
|
|
9431
|
-
return callee.type ===
|
|
9596
|
+
return callee.type === AST_NODE_TYPES46.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES46.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES46.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9432
9597
|
}
|
|
9433
9598
|
return {
|
|
9434
9599
|
CallExpression(node) {
|
|
@@ -9448,7 +9613,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9448
9613
|
});
|
|
9449
9614
|
|
|
9450
9615
|
// src/rules/require-interface-for-injected-service.ts
|
|
9451
|
-
import { AST_NODE_TYPES as
|
|
9616
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47 } from "@typescript-eslint/utils";
|
|
9452
9617
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9453
9618
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9454
9619
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9456,20 +9621,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9456
9621
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9457
9622
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9458
9623
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9459
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9460
|
-
var qualifiedName = (name) => name.type ===
|
|
9624
|
+
var isExportedClass = (node) => node.parent.type === AST_NODE_TYPES47.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES47.ExportDefaultDeclaration;
|
|
9625
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES47.Identifier ? name.name : name.type === AST_NODE_TYPES47.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9461
9626
|
var readTypeReference = (annotation) => {
|
|
9462
|
-
if (annotation === void 0 || annotation.type !==
|
|
9627
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES47.TSTypeReference) return null;
|
|
9463
9628
|
const { typeName } = annotation;
|
|
9464
|
-
const rightmost = typeName.type ===
|
|
9629
|
+
const rightmost = typeName.type === AST_NODE_TYPES47.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES47.TSQualifiedName ? typeName.right.name : null;
|
|
9465
9630
|
if (rightmost === null) return null;
|
|
9466
9631
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9467
9632
|
};
|
|
9468
9633
|
var namedParameterCollaborator = (annotated) => {
|
|
9469
9634
|
let target = annotated;
|
|
9470
|
-
if (target.type ===
|
|
9471
|
-
if (target.type ===
|
|
9472
|
-
if (target.type !==
|
|
9635
|
+
if (target.type === AST_NODE_TYPES47.TSParameterProperty) target = target.parameter;
|
|
9636
|
+
if (target.type === AST_NODE_TYPES47.AssignmentPattern) target = target.left;
|
|
9637
|
+
if (target.type !== AST_NODE_TYPES47.Identifier) return null;
|
|
9473
9638
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9474
9639
|
if (reference === null) return null;
|
|
9475
9640
|
return { name: target.name, ...reference };
|
|
@@ -9477,8 +9642,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9477
9642
|
var propertySignatureTypes = (members) => {
|
|
9478
9643
|
const types = /* @__PURE__ */ new Map();
|
|
9479
9644
|
for (const member of members) {
|
|
9480
|
-
if (member.type !==
|
|
9481
|
-
if (member.computed || member.key.type !==
|
|
9645
|
+
if (member.type !== AST_NODE_TYPES47.TSPropertySignature) continue;
|
|
9646
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES47.Identifier) continue;
|
|
9482
9647
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9483
9648
|
if (reference === null) continue;
|
|
9484
9649
|
types.set(member.key.name, reference);
|
|
@@ -9489,18 +9654,18 @@ var fileTypeIndex = (program) => {
|
|
|
9489
9654
|
const objects = /* @__PURE__ */ new Map();
|
|
9490
9655
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9491
9656
|
for (const statement of program.body) {
|
|
9492
|
-
const declaration = statement.type ===
|
|
9493
|
-
if (declaration?.type ===
|
|
9657
|
+
const declaration = statement.type === AST_NODE_TYPES47.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9658
|
+
if (declaration?.type === AST_NODE_TYPES47.TSInterfaceDeclaration) {
|
|
9494
9659
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9495
9660
|
continue;
|
|
9496
9661
|
}
|
|
9497
|
-
if (declaration?.type !==
|
|
9662
|
+
if (declaration?.type !== AST_NODE_TYPES47.TSTypeAliasDeclaration) continue;
|
|
9498
9663
|
const aliased = declaration.typeAnnotation;
|
|
9499
|
-
if (aliased.type ===
|
|
9664
|
+
if (aliased.type === AST_NODE_TYPES47.TSFunctionType || aliased.type === AST_NODE_TYPES47.TSConstructorType) {
|
|
9500
9665
|
functionAliases.add(declaration.id.name);
|
|
9501
9666
|
continue;
|
|
9502
9667
|
}
|
|
9503
|
-
const literals = aliased.type ===
|
|
9668
|
+
const literals = aliased.type === AST_NODE_TYPES47.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES47.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES47.TSTypeLiteral) : [];
|
|
9504
9669
|
if (literals.length === 0) continue;
|
|
9505
9670
|
const merged = /* @__PURE__ */ new Map();
|
|
9506
9671
|
for (const literal of literals) {
|
|
@@ -9513,10 +9678,10 @@ var fileTypeIndex = (program) => {
|
|
|
9513
9678
|
return { objects, functionAliases };
|
|
9514
9679
|
};
|
|
9515
9680
|
var bagMemberTypes = (annotation, declared) => {
|
|
9516
|
-
if (annotation.type ===
|
|
9681
|
+
if (annotation.type === AST_NODE_TYPES47.TSTypeLiteral) {
|
|
9517
9682
|
return propertySignatureTypes(annotation.members);
|
|
9518
9683
|
}
|
|
9519
|
-
if (annotation.type !==
|
|
9684
|
+
if (annotation.type !== AST_NODE_TYPES47.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES47.Identifier) {
|
|
9520
9685
|
return null;
|
|
9521
9686
|
}
|
|
9522
9687
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9528,11 +9693,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9528
9693
|
if (members === null) return [];
|
|
9529
9694
|
const collaborators = [];
|
|
9530
9695
|
for (const property of pattern.properties) {
|
|
9531
|
-
if (property.type !==
|
|
9532
|
-
if (property.key.type !==
|
|
9696
|
+
if (property.type !== AST_NODE_TYPES47.Property || property.computed) continue;
|
|
9697
|
+
if (property.key.type !== AST_NODE_TYPES47.Identifier) continue;
|
|
9533
9698
|
const key = property.key.name;
|
|
9534
|
-
const bound = property.value.type ===
|
|
9535
|
-
if (bound.type !==
|
|
9699
|
+
const bound = property.value.type === AST_NODE_TYPES47.AssignmentPattern ? property.value.left : property.value;
|
|
9700
|
+
if (bound.type !== AST_NODE_TYPES47.Identifier) continue;
|
|
9536
9701
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9537
9702
|
const reference = members.get(key);
|
|
9538
9703
|
if (reference === void 0) continue;
|
|
@@ -9542,8 +9707,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9542
9707
|
};
|
|
9543
9708
|
var parameterCollaborators = (parameter, declared) => {
|
|
9544
9709
|
let target = parameter;
|
|
9545
|
-
if (target.type ===
|
|
9546
|
-
if (target.type ===
|
|
9710
|
+
if (target.type === AST_NODE_TYPES47.AssignmentPattern) target = target.left;
|
|
9711
|
+
if (target.type === AST_NODE_TYPES47.ObjectPattern) {
|
|
9547
9712
|
return objectPatternCollaborators(target, declared);
|
|
9548
9713
|
}
|
|
9549
9714
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9562,17 +9727,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9562
9727
|
let constructedFields = 0;
|
|
9563
9728
|
if (body2 !== null && body2 !== void 0) {
|
|
9564
9729
|
for (const statement of body2.body) {
|
|
9565
|
-
if (statement.type !==
|
|
9730
|
+
if (statement.type !== AST_NODE_TYPES47.ExpressionStatement) continue;
|
|
9566
9731
|
const expression = statement.expression;
|
|
9567
|
-
if (expression.type !==
|
|
9732
|
+
if (expression.type !== AST_NODE_TYPES47.AssignmentExpression || expression.operator !== "=" || expression.left.type !== AST_NODE_TYPES47.MemberExpression || expression.left.object.type !== AST_NODE_TYPES47.ThisExpression) {
|
|
9568
9733
|
continue;
|
|
9569
9734
|
}
|
|
9570
9735
|
const source = expression.right;
|
|
9571
|
-
if (source.type ===
|
|
9736
|
+
if (source.type === AST_NODE_TYPES47.NewExpression) {
|
|
9572
9737
|
constructedFields += 1;
|
|
9573
|
-
} else if (source.type ===
|
|
9738
|
+
} else if (source.type === AST_NODE_TYPES47.Identifier) {
|
|
9574
9739
|
storedFrom.add(source.name);
|
|
9575
|
-
} else if (source.type ===
|
|
9740
|
+
} else if (source.type === AST_NODE_TYPES47.MemberExpression && source.object.type === AST_NODE_TYPES47.Identifier) {
|
|
9576
9741
|
storedFrom.add(source.object.name);
|
|
9577
9742
|
}
|
|
9578
9743
|
}
|
|
@@ -9580,7 +9745,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9580
9745
|
const collaborators = [];
|
|
9581
9746
|
for (const parameter of ctor.value.params) {
|
|
9582
9747
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9583
|
-
const stored = parameter.type ===
|
|
9748
|
+
const stored = parameter.type === AST_NODE_TYPES47.TSParameterProperty || storedFrom.has(reference.name);
|
|
9584
9749
|
if (!stored) continue;
|
|
9585
9750
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9586
9751
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9614,19 +9779,19 @@ var subtreeHas = (root, found) => {
|
|
|
9614
9779
|
return hit;
|
|
9615
9780
|
};
|
|
9616
9781
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9617
|
-
if (node.type ===
|
|
9782
|
+
if (node.type === AST_NODE_TYPES47.CallExpression) {
|
|
9618
9783
|
const { callee } = node;
|
|
9619
|
-
if (callee.type ===
|
|
9620
|
-
return callee.type ===
|
|
9784
|
+
if (callee.type === AST_NODE_TYPES47.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9785
|
+
return callee.type === AST_NODE_TYPES47.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES47.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9621
9786
|
}
|
|
9622
|
-
return node.type ===
|
|
9787
|
+
return node.type === AST_NODE_TYPES47.TSTypeReference && node.typeName.type === AST_NODE_TYPES47.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9623
9788
|
});
|
|
9624
9789
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9625
9790
|
var fileInterfaceNames = (program) => {
|
|
9626
9791
|
const names = [];
|
|
9627
9792
|
for (const statement of program.body) {
|
|
9628
|
-
const declaration = statement.type ===
|
|
9629
|
-
if (declaration?.type ===
|
|
9793
|
+
const declaration = statement.type === AST_NODE_TYPES47.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9794
|
+
if (declaration?.type === AST_NODE_TYPES47.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9630
9795
|
}
|
|
9631
9796
|
return names;
|
|
9632
9797
|
};
|
|
@@ -9644,11 +9809,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9644
9809
|
var publicMethodNames = (body2) => {
|
|
9645
9810
|
const names = [];
|
|
9646
9811
|
for (const member of body2.body) {
|
|
9647
|
-
if (member.type !==
|
|
9812
|
+
if (member.type !== AST_NODE_TYPES47.MethodDefinition) continue;
|
|
9648
9813
|
if (member.kind !== "method" || member.static) continue;
|
|
9649
9814
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9650
|
-
if (member.key.type ===
|
|
9651
|
-
if (member.key.type ===
|
|
9815
|
+
if (member.key.type === AST_NODE_TYPES47.PrivateIdentifier) continue;
|
|
9816
|
+
if (member.key.type === AST_NODE_TYPES47.Identifier) names.push(member.key.name);
|
|
9652
9817
|
else names.push("\u2026");
|
|
9653
9818
|
}
|
|
9654
9819
|
return names;
|
|
@@ -9681,7 +9846,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9681
9846
|
if (node.implements.length > 0) return;
|
|
9682
9847
|
if (node.decorators.length > 0) return;
|
|
9683
9848
|
const ctor = node.body.body.find(
|
|
9684
|
-
(member) => member.type ===
|
|
9849
|
+
(member) => member.type === AST_NODE_TYPES47.MethodDefinition && member.kind === "constructor"
|
|
9685
9850
|
);
|
|
9686
9851
|
if (ctor === void 0) return;
|
|
9687
9852
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9709,19 +9874,97 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9709
9874
|
}
|
|
9710
9875
|
});
|
|
9711
9876
|
|
|
9877
|
+
// src/rules/require-static-next-matcher.ts
|
|
9878
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48 } from "@typescript-eslint/utils";
|
|
9879
|
+
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
9880
|
+
function unwrapExpression(node) {
|
|
9881
|
+
if (node.type === AST_NODE_TYPES48.TSAsExpression || node.type === AST_NODE_TYPES48.TSSatisfiesExpression || node.type === AST_NODE_TYPES48.TSNonNullExpression || node.type === AST_NODE_TYPES48.TSTypeAssertion) {
|
|
9882
|
+
return unwrapExpression(node.expression);
|
|
9883
|
+
}
|
|
9884
|
+
return node;
|
|
9885
|
+
}
|
|
9886
|
+
function isStaticValue(node) {
|
|
9887
|
+
const value = unwrapExpression(node);
|
|
9888
|
+
if (value.type === AST_NODE_TYPES48.Literal) {
|
|
9889
|
+
return true;
|
|
9890
|
+
}
|
|
9891
|
+
if (value.type === AST_NODE_TYPES48.TemplateLiteral) {
|
|
9892
|
+
return value.expressions.length === 0;
|
|
9893
|
+
}
|
|
9894
|
+
if (value.type === AST_NODE_TYPES48.ArrayExpression) {
|
|
9895
|
+
return value.elements.every(
|
|
9896
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES48.SpreadElement && isStaticValue(element)
|
|
9897
|
+
);
|
|
9898
|
+
}
|
|
9899
|
+
if (value.type === AST_NODE_TYPES48.ObjectExpression) {
|
|
9900
|
+
return value.properties.every(
|
|
9901
|
+
(property) => property.type === AST_NODE_TYPES48.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES48.AssignmentPattern && isStaticValue(property.value)
|
|
9902
|
+
);
|
|
9903
|
+
}
|
|
9904
|
+
return false;
|
|
9905
|
+
}
|
|
9906
|
+
function propertyName2(property) {
|
|
9907
|
+
if (property.computed) return null;
|
|
9908
|
+
if (property.key.type === AST_NODE_TYPES48.Identifier) return property.key.name;
|
|
9909
|
+
return typeof property.key.value === "string" ? property.key.value : null;
|
|
9910
|
+
}
|
|
9911
|
+
var require_static_next_matcher_default = createRule({
|
|
9912
|
+
name: "require-static-next-matcher",
|
|
9913
|
+
meta: {
|
|
9914
|
+
type: "problem",
|
|
9915
|
+
docs: {
|
|
9916
|
+
description: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals."
|
|
9917
|
+
},
|
|
9918
|
+
schema: [],
|
|
9919
|
+
messages: {
|
|
9920
|
+
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."
|
|
9921
|
+
}
|
|
9922
|
+
},
|
|
9923
|
+
defaultOptions: [],
|
|
9924
|
+
create(context) {
|
|
9925
|
+
if (!NEXT_ENTRY_FILE.test(context.filename)) {
|
|
9926
|
+
return {};
|
|
9927
|
+
}
|
|
9928
|
+
return {
|
|
9929
|
+
ExportNamedDeclaration(node) {
|
|
9930
|
+
if (node.declaration?.type !== AST_NODE_TYPES48.VariableDeclaration) {
|
|
9931
|
+
return;
|
|
9932
|
+
}
|
|
9933
|
+
for (const declaration of node.declaration.declarations) {
|
|
9934
|
+
if (declaration.id.type !== AST_NODE_TYPES48.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
9935
|
+
continue;
|
|
9936
|
+
}
|
|
9937
|
+
const config = unwrapExpression(declaration.init);
|
|
9938
|
+
if (config.type !== AST_NODE_TYPES48.ObjectExpression) {
|
|
9939
|
+
continue;
|
|
9940
|
+
}
|
|
9941
|
+
for (const property of config.properties) {
|
|
9942
|
+
if (property.type !== AST_NODE_TYPES48.Property || propertyName2(property) !== "matcher" || property.value.type === AST_NODE_TYPES48.AssignmentPattern) {
|
|
9943
|
+
continue;
|
|
9944
|
+
}
|
|
9945
|
+
if (!isStaticValue(property.value)) {
|
|
9946
|
+
context.report({ node: property.value, messageId: "dynamicMatcher" });
|
|
9947
|
+
}
|
|
9948
|
+
}
|
|
9949
|
+
}
|
|
9950
|
+
}
|
|
9951
|
+
};
|
|
9952
|
+
}
|
|
9953
|
+
});
|
|
9954
|
+
|
|
9712
9955
|
// src/rules/require-zod-form-validation.ts
|
|
9713
|
-
import { AST_NODE_TYPES as
|
|
9956
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49 } from "@typescript-eslint/utils";
|
|
9714
9957
|
var looksLikeZodSchema = (node) => {
|
|
9715
9958
|
let current = node;
|
|
9716
9959
|
while (true) {
|
|
9717
|
-
if (current.type ===
|
|
9960
|
+
if (current.type === AST_NODE_TYPES49.Identifier) {
|
|
9718
9961
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9719
9962
|
}
|
|
9720
|
-
if (current.type ===
|
|
9963
|
+
if (current.type === AST_NODE_TYPES49.CallExpression) {
|
|
9721
9964
|
current = current.callee;
|
|
9722
9965
|
continue;
|
|
9723
9966
|
}
|
|
9724
|
-
if (current.type ===
|
|
9967
|
+
if (current.type === AST_NODE_TYPES49.MemberExpression) {
|
|
9725
9968
|
current = current.object;
|
|
9726
9969
|
continue;
|
|
9727
9970
|
}
|
|
@@ -9729,23 +9972,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9729
9972
|
}
|
|
9730
9973
|
};
|
|
9731
9974
|
var isZodParseCall = (node) => {
|
|
9732
|
-
if (node.type !==
|
|
9975
|
+
if (node.type !== AST_NODE_TYPES49.CallExpression) return false;
|
|
9733
9976
|
const callee = node.callee;
|
|
9734
|
-
if (callee.type !==
|
|
9977
|
+
if (callee.type !== AST_NODE_TYPES49.MemberExpression) return false;
|
|
9735
9978
|
if (callee.computed) return false;
|
|
9736
|
-
if (callee.property.type !==
|
|
9979
|
+
if (callee.property.type !== AST_NODE_TYPES49.Identifier) return false;
|
|
9737
9980
|
const method = callee.property.name;
|
|
9738
9981
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9739
9982
|
return looksLikeZodSchema(callee.object);
|
|
9740
9983
|
};
|
|
9741
9984
|
var isFormDataMethodCall = (node) => {
|
|
9742
9985
|
let current = node;
|
|
9743
|
-
if (current.type ===
|
|
9986
|
+
if (current.type === AST_NODE_TYPES49.AwaitExpression) {
|
|
9744
9987
|
current = current.argument;
|
|
9745
9988
|
}
|
|
9746
|
-
if (current.type !==
|
|
9989
|
+
if (current.type !== AST_NODE_TYPES49.CallExpression) return false;
|
|
9747
9990
|
const callee = current.callee;
|
|
9748
|
-
return callee.type ===
|
|
9991
|
+
return callee.type === AST_NODE_TYPES49.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES49.Identifier && callee.property.name === "formData";
|
|
9749
9992
|
};
|
|
9750
9993
|
var require_zod_form_validation_default = createRule({
|
|
9751
9994
|
name: "require-zod-form-validation",
|
|
@@ -9765,14 +10008,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9765
10008
|
return {};
|
|
9766
10009
|
}
|
|
9767
10010
|
const isFormSourceIdentifier = (node) => {
|
|
9768
|
-
if (node.type !==
|
|
10011
|
+
if (node.type !== AST_NODE_TYPES49.Identifier) return false;
|
|
9769
10012
|
if (/formdata/i.test(node.name)) return true;
|
|
9770
10013
|
let scope = context.sourceCode.getScope(node);
|
|
9771
10014
|
while (scope !== null) {
|
|
9772
10015
|
const variable = scope.set.get(node.name);
|
|
9773
10016
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9774
10017
|
const def = variable.defs[0];
|
|
9775
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
10018
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES49.VariableDeclarator && def.node.init !== null) {
|
|
9776
10019
|
return isFormDataMethodCall(def.node.init);
|
|
9777
10020
|
}
|
|
9778
10021
|
return false;
|
|
@@ -9783,8 +10026,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9783
10026
|
};
|
|
9784
10027
|
const isFormDataGetCall = (node) => {
|
|
9785
10028
|
const callee = node.callee;
|
|
9786
|
-
if (callee.type !==
|
|
9787
|
-
if (callee.property.type !==
|
|
10029
|
+
if (callee.type !== AST_NODE_TYPES49.MemberExpression) return false;
|
|
10030
|
+
if (callee.property.type !== AST_NODE_TYPES49.Identifier || callee.property.name !== "get") {
|
|
9788
10031
|
return false;
|
|
9789
10032
|
}
|
|
9790
10033
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9799,11 +10042,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9799
10042
|
};
|
|
9800
10043
|
const isInstanceofNarrowing = (node) => {
|
|
9801
10044
|
const parent = node.parent;
|
|
9802
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
10045
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES49.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES49.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9803
10046
|
};
|
|
9804
10047
|
const boundDeclarator = (node) => {
|
|
9805
10048
|
const parent = node.parent;
|
|
9806
|
-
if (parent.type ===
|
|
10049
|
+
if (parent.type === AST_NODE_TYPES49.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES49.Identifier) {
|
|
9807
10050
|
return parent;
|
|
9808
10051
|
}
|
|
9809
10052
|
return null;
|
|
@@ -9862,7 +10105,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9862
10105
|
});
|
|
9863
10106
|
|
|
9864
10107
|
// src/rules/zod-naming-convention.ts
|
|
9865
|
-
import { AST_NODE_TYPES as
|
|
10108
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50 } from "@typescript-eslint/utils";
|
|
9866
10109
|
var CONVENTIONS = {
|
|
9867
10110
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9868
10111
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9887,15 +10130,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9887
10130
|
"registry",
|
|
9888
10131
|
"implement"
|
|
9889
10132
|
]);
|
|
9890
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10133
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES50.Identifier ? callee.property.name : null;
|
|
9891
10134
|
var calleeChainStartsWithZ = (node) => {
|
|
9892
10135
|
let current = node;
|
|
9893
|
-
while (current.type ===
|
|
10136
|
+
while (current.type === AST_NODE_TYPES50.MemberExpression) {
|
|
9894
10137
|
const receiver = current.object;
|
|
9895
|
-
if (receiver.type ===
|
|
10138
|
+
if (receiver.type === AST_NODE_TYPES50.Identifier && receiver.name === "z") {
|
|
9896
10139
|
return true;
|
|
9897
10140
|
}
|
|
9898
|
-
if (receiver.type ===
|
|
10141
|
+
if (receiver.type === AST_NODE_TYPES50.CallExpression) {
|
|
9899
10142
|
current = receiver.callee;
|
|
9900
10143
|
continue;
|
|
9901
10144
|
}
|
|
@@ -9940,13 +10183,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9940
10183
|
VariableDeclarator(node) {
|
|
9941
10184
|
const init = node.init;
|
|
9942
10185
|
if (init === null || init === void 0) return;
|
|
9943
|
-
if (init.type !==
|
|
10186
|
+
if (init.type !== AST_NODE_TYPES50.CallExpression) return;
|
|
9944
10187
|
const callee = init.callee;
|
|
9945
|
-
if (callee.type !==
|
|
10188
|
+
if (callee.type !== AST_NODE_TYPES50.MemberExpression) return;
|
|
9946
10189
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9947
10190
|
const terminal = terminalMethodName(callee);
|
|
9948
10191
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9949
|
-
if (node.id.type !==
|
|
10192
|
+
if (node.id.type !== AST_NODE_TYPES50.Identifier) return;
|
|
9950
10193
|
if (test.test(node.id.name)) return;
|
|
9951
10194
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9952
10195
|
context.report({
|
|
@@ -10026,6 +10269,7 @@ var rules = {
|
|
|
10026
10269
|
"no-enum": no_enum_default,
|
|
10027
10270
|
"no-fat-try-blocks": no_fat_try_blocks_default,
|
|
10028
10271
|
"no-hand-rolled-sleep": no_hand_rolled_sleep_default,
|
|
10272
|
+
"no-hand-rolled-spinner": no_hand_rolled_spinner_default,
|
|
10029
10273
|
"no-insecure-random-id": no_insecure_random_id_default,
|
|
10030
10274
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
10031
10275
|
"no-log-only-catch": no_log_only_catch_default,
|
|
@@ -10056,10 +10300,11 @@ var rules = {
|
|
|
10056
10300
|
"no-zod-native-enum": no_zod_native_enum_default,
|
|
10057
10301
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
10058
10302
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
10303
|
+
"prefer-input-group-search": prefer_input_group_search_default,
|
|
10059
10304
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
10060
10305
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
10061
|
-
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
10062
10306
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
10307
|
+
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
10063
10308
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
10064
10309
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
10065
10310
|
"prefer-server-actions": prefer_server_actions_default,
|
|
@@ -10071,13 +10316,14 @@ var rules = {
|
|
|
10071
10316
|
"require-assert-never": require_assert_never_default,
|
|
10072
10317
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
10073
10318
|
"require-interface-for-injected-service": require_interface_for_injected_service_default,
|
|
10319
|
+
"require-static-next-matcher": require_static_next_matcher_default,
|
|
10074
10320
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
10075
10321
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
10076
10322
|
"zod-naming-convention": zod_naming_convention_default
|
|
10077
10323
|
};
|
|
10078
10324
|
var meta = {
|
|
10079
10325
|
name: "@sarj/eslint-plugin",
|
|
10080
|
-
version: "9.
|
|
10326
|
+
version: "9.10.0"
|
|
10081
10327
|
};
|
|
10082
10328
|
var applicationOnlyRules = [
|
|
10083
10329
|
"no-restricted-library-load",
|
|
@@ -10093,6 +10339,7 @@ var recommendedRules = {
|
|
|
10093
10339
|
"@sarj/no-dynamic-sql": "warn",
|
|
10094
10340
|
"@sarj/no-fat-try-blocks": "warn",
|
|
10095
10341
|
"@sarj/no-hand-rolled-sleep": "warn",
|
|
10342
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10096
10343
|
"@sarj/no-insecure-random-id": "warn",
|
|
10097
10344
|
"@sarj/no-json-stringify-error": "warn",
|
|
10098
10345
|
"@sarj/no-log-only-catch": "warn",
|
|
@@ -10119,6 +10366,7 @@ var recommendedRules = {
|
|
|
10119
10366
|
"@sarj/no-zod-native-enum": "warn",
|
|
10120
10367
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10121
10368
|
"@sarj/prefer-discriminated-union": "warn",
|
|
10369
|
+
"@sarj/prefer-input-group-search": "error",
|
|
10122
10370
|
"@sarj/prefer-module-level-constant": "warn",
|
|
10123
10371
|
"@sarj/prefer-module-level-schema": "warn",
|
|
10124
10372
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
@@ -10133,6 +10381,7 @@ var recommendedRules = {
|
|
|
10133
10381
|
"@sarj/require-assert-never": "error",
|
|
10134
10382
|
"@sarj/require-fetch-timeout": "warn",
|
|
10135
10383
|
"@sarj/require-interface-for-injected-service": "warn",
|
|
10384
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10136
10385
|
"@sarj/require-zod-form-validation": "error",
|
|
10137
10386
|
"@sarj/store-insert-requires-on-conflict": "warn",
|
|
10138
10387
|
"@sarj/zod-naming-convention": "warn"
|
|
@@ -10148,6 +10397,7 @@ var strictRules = {
|
|
|
10148
10397
|
"@sarj/no-enum": "error",
|
|
10149
10398
|
"@sarj/no-fat-try-blocks": "error",
|
|
10150
10399
|
"@sarj/no-hand-rolled-sleep": "error",
|
|
10400
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10151
10401
|
"@sarj/no-insecure-random-id": "error",
|
|
10152
10402
|
"@sarj/no-json-stringify-error": "error",
|
|
10153
10403
|
"@sarj/no-log-only-catch": "error",
|
|
@@ -10177,6 +10427,7 @@ var strictRules = {
|
|
|
10177
10427
|
"@sarj/no-zod-native-enum": "error",
|
|
10178
10428
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10179
10429
|
"@sarj/prefer-discriminated-union": "error",
|
|
10430
|
+
"@sarj/prefer-input-group-search": "error",
|
|
10180
10431
|
"@sarj/prefer-module-level-constant": "error",
|
|
10181
10432
|
"@sarj/prefer-module-level-schema": "error",
|
|
10182
10433
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
@@ -10191,6 +10442,7 @@ var strictRules = {
|
|
|
10191
10442
|
"@sarj/require-assert-never": "error",
|
|
10192
10443
|
"@sarj/require-fetch-timeout": "error",
|
|
10193
10444
|
"@sarj/require-interface-for-injected-service": "error",
|
|
10445
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10194
10446
|
"@sarj/require-zod-form-validation": "error",
|
|
10195
10447
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
10196
10448
|
"@sarj/zod-naming-convention": "error"
|