@sarj/eslint-plugin 9.8.0 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/index.cjs +722 -586
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +705 -569
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2382,8 +2382,60 @@ var no_hand_rolled_sleep_default = createRule({
|
|
|
2382
2382
|
}
|
|
2383
2383
|
});
|
|
2384
2384
|
|
|
2385
|
-
// src/rules/no-
|
|
2385
|
+
// src/rules/no-hand-rolled-spinner.ts
|
|
2386
2386
|
var import_utils14 = require("@typescript-eslint/utils");
|
|
2387
|
+
var DESIGN_SYSTEM_PATH = /(?:^|[/\\])components[/\\]ui[/\\]/u;
|
|
2388
|
+
var BORDER_WIDTH = /^border(?:-[0-9]+)?$/u;
|
|
2389
|
+
var TRANSPARENT_EDGE = /^border-[trbl]-transparent$/u;
|
|
2390
|
+
function staticClassName(attribute) {
|
|
2391
|
+
const value = attribute.value;
|
|
2392
|
+
if (value?.type === import_utils14.AST_NODE_TYPES.Literal && typeof value.value === "string") {
|
|
2393
|
+
return value.value;
|
|
2394
|
+
}
|
|
2395
|
+
if (value?.type === import_utils14.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === import_utils14.AST_NODE_TYPES.Literal && typeof value.expression.value === "string") {
|
|
2396
|
+
return value.expression.value;
|
|
2397
|
+
}
|
|
2398
|
+
return null;
|
|
2399
|
+
}
|
|
2400
|
+
var no_hand_rolled_spinner_default = createRule({
|
|
2401
|
+
name: "no-hand-rolled-spinner",
|
|
2402
|
+
meta: {
|
|
2403
|
+
type: "suggestion",
|
|
2404
|
+
docs: {
|
|
2405
|
+
description: "Disallow intrinsic elements styled as Tailwind border-ring spinners outside the design-system implementation."
|
|
2406
|
+
},
|
|
2407
|
+
schema: [],
|
|
2408
|
+
messages: {
|
|
2409
|
+
handRolledSpinner: "Use the design-system Spinner component instead of rebuilding a border-ring spinner with utility classes."
|
|
2410
|
+
}
|
|
2411
|
+
},
|
|
2412
|
+
defaultOptions: [],
|
|
2413
|
+
create(context) {
|
|
2414
|
+
if (DESIGN_SYSTEM_PATH.test(context.filename)) {
|
|
2415
|
+
return {};
|
|
2416
|
+
}
|
|
2417
|
+
return {
|
|
2418
|
+
JSXOpeningElement(node) {
|
|
2419
|
+
if (node.name.type !== import_utils14.AST_NODE_TYPES.JSXIdentifier || node.name.name !== "div" && node.name.name !== "span") {
|
|
2420
|
+
return;
|
|
2421
|
+
}
|
|
2422
|
+
const classNameAttribute = node.attributes.find(
|
|
2423
|
+
(attribute) => attribute.type === import_utils14.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils14.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "className"
|
|
2424
|
+
);
|
|
2425
|
+
if (classNameAttribute === void 0) return;
|
|
2426
|
+
const className = staticClassName(classNameAttribute);
|
|
2427
|
+
if (className === null) return;
|
|
2428
|
+
const classes = className.split(/\s+/u);
|
|
2429
|
+
if (classes.includes("animate-spin") && classes.includes("rounded-full") && classes.some((token) => BORDER_WIDTH.test(token)) && classes.some((token) => TRANSPARENT_EDGE.test(token))) {
|
|
2430
|
+
context.report({ node, messageId: "handRolledSpinner" });
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
};
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
|
|
2437
|
+
// src/rules/no-insecure-random-id.ts
|
|
2438
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
2387
2439
|
var STRONG_SECURITY_PATTERN = /token|secret|csrf|password|passwd|apikey|api[-_]?key|nonce|salt|uuid|authid/i;
|
|
2388
2440
|
var NON_SECURITY_ID_PATTERN = /temp|tmp|cache|correlation|request|req|trace|execution|dev|hmr|mock|test|perf|marker/i;
|
|
2389
2441
|
var PATH_OR_DOM_MARKER = /[\\/#]|\.[A-Za-z0-9]/;
|
|
@@ -2566,7 +2618,7 @@ var no_insecure_random_id_default = createRule({
|
|
|
2566
2618
|
});
|
|
2567
2619
|
|
|
2568
2620
|
// src/rules/no-json-stringify-error.ts
|
|
2569
|
-
var
|
|
2621
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
2570
2622
|
var ERROR_NAME_PATTERN = /^(e|err|error|ex|exc)$/i;
|
|
2571
2623
|
var ERROR_PROP_PATTERN = /^(cause|lastError|error|err|exception|originalError|innerError)$/i;
|
|
2572
2624
|
var SAFE_STRING_PROPS = /* @__PURE__ */ new Set(["message", "stack", "name"]);
|
|
@@ -2748,10 +2800,10 @@ var no_json_stringify_error_default = createRule({
|
|
|
2748
2800
|
});
|
|
2749
2801
|
|
|
2750
2802
|
// src/rules/no-log-only-catch.ts
|
|
2751
|
-
var
|
|
2803
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
2752
2804
|
|
|
2753
2805
|
// src/rules/_logging.ts
|
|
2754
|
-
var
|
|
2806
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
2755
2807
|
var LOG_METHODS = /* @__PURE__ */ new Set([
|
|
2756
2808
|
"debug",
|
|
2757
2809
|
"info",
|
|
@@ -2855,29 +2907,29 @@ function createLogMatcher(options = {}) {
|
|
|
2855
2907
|
// src/rules/no-log-only-catch.ts
|
|
2856
2908
|
var BENCHMARK_DIR_RE = /(?:^|[\\/])benchmarks?[\\/]/;
|
|
2857
2909
|
var SINGLE_STATEMENT_HOSTS = /* @__PURE__ */ new Set([
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2910
|
+
import_utils18.AST_NODE_TYPES.DoWhileStatement,
|
|
2911
|
+
import_utils18.AST_NODE_TYPES.ForInStatement,
|
|
2912
|
+
import_utils18.AST_NODE_TYPES.ForOfStatement,
|
|
2913
|
+
import_utils18.AST_NODE_TYPES.ForStatement,
|
|
2914
|
+
import_utils18.AST_NODE_TYPES.IfStatement,
|
|
2915
|
+
import_utils18.AST_NODE_TYPES.WhileStatement
|
|
2864
2916
|
]);
|
|
2865
2917
|
var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2918
|
+
import_utils18.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
2919
|
+
import_utils18.AST_NODE_TYPES.FunctionDeclaration,
|
|
2920
|
+
import_utils18.AST_NODE_TYPES.FunctionExpression
|
|
2869
2921
|
]);
|
|
2870
2922
|
function statementSlot(node) {
|
|
2871
2923
|
const parent = node.parent;
|
|
2872
2924
|
if (parent === void 0) return null;
|
|
2873
2925
|
let list;
|
|
2874
2926
|
switch (parent.type) {
|
|
2875
|
-
case
|
|
2876
|
-
case
|
|
2877
|
-
case
|
|
2927
|
+
case import_utils18.AST_NODE_TYPES.BlockStatement:
|
|
2928
|
+
case import_utils18.AST_NODE_TYPES.Program:
|
|
2929
|
+
case import_utils18.AST_NODE_TYPES.StaticBlock:
|
|
2878
2930
|
list = parent.body;
|
|
2879
2931
|
break;
|
|
2880
|
-
case
|
|
2932
|
+
case import_utils18.AST_NODE_TYPES.SwitchCase:
|
|
2881
2933
|
list = parent.consequent;
|
|
2882
2934
|
break;
|
|
2883
2935
|
default:
|
|
@@ -2896,20 +2948,20 @@ function hasFollowingStatement(node) {
|
|
|
2896
2948
|
function fallbackFollowsTry(tryStatement) {
|
|
2897
2949
|
const body2 = tryStatement.block.body;
|
|
2898
2950
|
const last = body2.at(-1);
|
|
2899
|
-
return last?.type ===
|
|
2951
|
+
return last?.type === import_utils18.AST_NODE_TYPES.ReturnStatement && hasFollowingStatement(tryStatement);
|
|
2900
2952
|
}
|
|
2901
2953
|
function isSeedValue(node) {
|
|
2902
|
-
const inner = node.type ===
|
|
2954
|
+
const inner = node.type === import_utils18.AST_NODE_TYPES.TSAsExpression ? node.expression : node;
|
|
2903
2955
|
switch (inner.type) {
|
|
2904
|
-
case
|
|
2956
|
+
case import_utils18.AST_NODE_TYPES.Literal:
|
|
2905
2957
|
return true;
|
|
2906
|
-
case
|
|
2958
|
+
case import_utils18.AST_NODE_TYPES.Identifier:
|
|
2907
2959
|
return inner.name === "undefined";
|
|
2908
|
-
case
|
|
2909
|
-
return inner.argument.type ===
|
|
2910
|
-
case
|
|
2960
|
+
case import_utils18.AST_NODE_TYPES.UnaryExpression:
|
|
2961
|
+
return inner.argument.type === import_utils18.AST_NODE_TYPES.Literal;
|
|
2962
|
+
case import_utils18.AST_NODE_TYPES.ArrayExpression:
|
|
2911
2963
|
return inner.elements.length === 0;
|
|
2912
|
-
case
|
|
2964
|
+
case import_utils18.AST_NODE_TYPES.ObjectExpression:
|
|
2913
2965
|
return inner.properties.length === 0;
|
|
2914
2966
|
default:
|
|
2915
2967
|
return false;
|
|
@@ -2919,14 +2971,14 @@ function seededFallbackHandled(tryStatement, scope) {
|
|
|
2919
2971
|
const slot = statementSlot(tryStatement);
|
|
2920
2972
|
if (slot === null || slot.index === 0) return false;
|
|
2921
2973
|
const previous = slot.list[slot.index - 1];
|
|
2922
|
-
if (previous?.type !==
|
|
2974
|
+
if (previous?.type !== import_utils18.AST_NODE_TYPES.VariableDeclaration || previous.kind === "const") {
|
|
2923
2975
|
return false;
|
|
2924
2976
|
}
|
|
2925
2977
|
const declarator = previous.declarations[0];
|
|
2926
2978
|
if (previous.declarations.length !== 1 || declarator === void 0) return false;
|
|
2927
|
-
if (declarator.id.type !==
|
|
2979
|
+
if (declarator.id.type !== import_utils18.AST_NODE_TYPES.Identifier) return false;
|
|
2928
2980
|
if (declarator.init == null || !isSeedValue(declarator.init)) return false;
|
|
2929
|
-
const variable =
|
|
2981
|
+
const variable = import_utils18.ASTUtils.findVariable(scope, declarator.id.name);
|
|
2930
2982
|
if (variable === null) return false;
|
|
2931
2983
|
const [tryStart, tryEnd] = tryStatement.block.range;
|
|
2932
2984
|
let writtenInTry = false;
|
|
@@ -2976,7 +3028,7 @@ var no_log_only_catch_default = createRule({
|
|
|
2976
3028
|
const tryStatement = node.parent;
|
|
2977
3029
|
if (hasCommentDirectlyAbove(tryStatement) || hasCommentDirectlyAbove(node)) return true;
|
|
2978
3030
|
const block = tryStatement.parent;
|
|
2979
|
-
if (block?.type !==
|
|
3031
|
+
if (block?.type !== import_utils18.AST_NODE_TYPES.BlockStatement || block.body.length !== 1 || block.parent === void 0 || !SINGLE_STATEMENT_HOSTS.has(block.parent.type)) {
|
|
2980
3032
|
return false;
|
|
2981
3033
|
}
|
|
2982
3034
|
return hasCommentDirectlyAbove(block.parent);
|
|
@@ -3013,7 +3065,7 @@ var no_log_only_catch_default = createRule({
|
|
|
3013
3065
|
});
|
|
3014
3066
|
|
|
3015
3067
|
// src/rules/_prose-budget.ts
|
|
3016
|
-
var
|
|
3068
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
3017
3069
|
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;
|
|
3018
3070
|
var LICENSE_RE2 = /\b(?:copyright|spdx-license-identifier|licensed under)\b/i;
|
|
3019
3071
|
var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
|
|
@@ -3069,25 +3121,25 @@ function proseGroups(filename, sourceCode, includeValueTags = false) {
|
|
|
3069
3121
|
return groups;
|
|
3070
3122
|
}
|
|
3071
3123
|
function annotatedParameter(parameter) {
|
|
3072
|
-
if (parameter.type ===
|
|
3073
|
-
const target = parameter.type ===
|
|
3124
|
+
if (parameter.type === import_utils19.AST_NODE_TYPES.TSParameterProperty) return annotatedParameter(parameter.parameter);
|
|
3125
|
+
const target = parameter.type === import_utils19.AST_NODE_TYPES.AssignmentPattern ? parameter.left : parameter;
|
|
3074
3126
|
return "typeAnnotation" in target && target.typeAnnotation != null;
|
|
3075
3127
|
}
|
|
3076
3128
|
function typedFunction(node) {
|
|
3077
3129
|
switch (node.type) {
|
|
3078
|
-
case
|
|
3079
|
-
case
|
|
3130
|
+
case import_utils19.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3131
|
+
case import_utils19.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3080
3132
|
return node.declaration != null && typedFunction(node.declaration);
|
|
3081
|
-
case
|
|
3082
|
-
case
|
|
3133
|
+
case import_utils19.AST_NODE_TYPES.FunctionDeclaration:
|
|
3134
|
+
case import_utils19.AST_NODE_TYPES.TSDeclareFunction:
|
|
3083
3135
|
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3084
|
-
case
|
|
3136
|
+
case import_utils19.AST_NODE_TYPES.VariableDeclaration: {
|
|
3085
3137
|
const init = node.declarations[0]?.init;
|
|
3086
|
-
return init != null && (init.type ===
|
|
3138
|
+
return init != null && (init.type === import_utils19.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils19.AST_NODE_TYPES.FunctionExpression) && init.returnType != null && init.params.every(annotatedParameter);
|
|
3087
3139
|
}
|
|
3088
|
-
case
|
|
3140
|
+
case import_utils19.AST_NODE_TYPES.MethodDefinition:
|
|
3089
3141
|
return node.value.returnType != null && node.value.params.every(annotatedParameter);
|
|
3090
|
-
case
|
|
3142
|
+
case import_utils19.AST_NODE_TYPES.TSMethodSignature:
|
|
3091
3143
|
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3092
3144
|
default:
|
|
3093
3145
|
return false;
|
|
@@ -3097,7 +3149,7 @@ function documentsTypedFunction(sourceCode, comment) {
|
|
|
3097
3149
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3098
3150
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return false;
|
|
3099
3151
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3100
|
-
while (node != null && node.type !==
|
|
3152
|
+
while (node != null && node.type !== import_utils19.AST_NODE_TYPES.Program) {
|
|
3101
3153
|
if (typedFunction(node)) return true;
|
|
3102
3154
|
node = node.parent ?? null;
|
|
3103
3155
|
}
|
|
@@ -3130,7 +3182,7 @@ var no_long_comment_default = createRule({
|
|
|
3130
3182
|
});
|
|
3131
3183
|
|
|
3132
3184
|
// src/rules/no-offset-pagination.ts
|
|
3133
|
-
var
|
|
3185
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
3134
3186
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:%s|%\(\w+\)s|\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
3135
3187
|
var OFFSET_GATE = /offset/i;
|
|
3136
3188
|
var no_offset_pagination_default = createRule({
|
|
@@ -3160,15 +3212,15 @@ var no_offset_pagination_default = createRule({
|
|
|
3160
3212
|
});
|
|
3161
3213
|
|
|
3162
3214
|
// src/rules/no-positional-tuple-return.ts
|
|
3163
|
-
var
|
|
3215
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
3164
3216
|
var MIN_ELEMENTS = 2;
|
|
3165
3217
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
3166
3218
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
3167
3219
|
function tupleReturnType(node) {
|
|
3168
|
-
if (node.type ===
|
|
3220
|
+
if (node.type === import_utils21.AST_NODE_TYPES.TSTupleType) {
|
|
3169
3221
|
return node;
|
|
3170
3222
|
}
|
|
3171
|
-
if (node.type ===
|
|
3223
|
+
if (node.type === import_utils21.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils21.AST_NODE_TYPES.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
3172
3224
|
const argument = node.typeArguments?.params[0];
|
|
3173
3225
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
3174
3226
|
}
|
|
@@ -3182,30 +3234,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
3182
3234
|
if (elements.length < MIN_ELEMENTS) {
|
|
3183
3235
|
return true;
|
|
3184
3236
|
}
|
|
3185
|
-
if (elements.some((element) => element.type ===
|
|
3237
|
+
if (elements.some((element) => element.type === import_utils21.AST_NODE_TYPES.TSRestType)) {
|
|
3186
3238
|
return true;
|
|
3187
3239
|
}
|
|
3188
|
-
if (elements.some((element) => element.type ===
|
|
3240
|
+
if (elements.some((element) => element.type === import_utils21.AST_NODE_TYPES.TSNamedTupleMember)) {
|
|
3189
3241
|
return true;
|
|
3190
3242
|
}
|
|
3191
|
-
if (elements[0]?.type ===
|
|
3243
|
+
if (elements[0]?.type === import_utils21.AST_NODE_TYPES.TSLiteralType) {
|
|
3192
3244
|
return true;
|
|
3193
3245
|
}
|
|
3194
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type ===
|
|
3246
|
+
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === import_utils21.AST_NODE_TYPES.TSFunctionType)) {
|
|
3195
3247
|
return true;
|
|
3196
3248
|
}
|
|
3197
3249
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
3198
3250
|
return texts.size === 1;
|
|
3199
3251
|
}
|
|
3200
3252
|
function functionName(node) {
|
|
3201
|
-
if (node.type ===
|
|
3253
|
+
if (node.type === import_utils21.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3202
3254
|
return node.id?.name ?? null;
|
|
3203
3255
|
}
|
|
3204
3256
|
const parent = node.parent;
|
|
3205
|
-
if (parent?.type ===
|
|
3257
|
+
if (parent?.type === import_utils21.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3206
3258
|
return parent.id.name;
|
|
3207
3259
|
}
|
|
3208
|
-
if ((parent?.type ===
|
|
3260
|
+
if ((parent?.type === import_utils21.AST_NODE_TYPES.MethodDefinition || parent?.type === import_utils21.AST_NODE_TYPES.PropertyDefinition || parent?.type === import_utils21.AST_NODE_TYPES.Property) && parent.key.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3209
3261
|
return parent.key.name;
|
|
3210
3262
|
}
|
|
3211
3263
|
return null;
|
|
@@ -3213,7 +3265,7 @@ function functionName(node) {
|
|
|
3213
3265
|
function isInlineExported(node) {
|
|
3214
3266
|
for (let current = node; current != null; current = current.parent) {
|
|
3215
3267
|
const parent = current.parent;
|
|
3216
|
-
if (parent?.type ===
|
|
3268
|
+
if (parent?.type === import_utils21.AST_NODE_TYPES.ExportNamedDeclaration || parent?.type === import_utils21.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
3217
3269
|
return true;
|
|
3218
3270
|
}
|
|
3219
3271
|
}
|
|
@@ -3222,18 +3274,18 @@ function isInlineExported(node) {
|
|
|
3222
3274
|
function moduleScopeBindingName(node) {
|
|
3223
3275
|
let current = node;
|
|
3224
3276
|
let child = node;
|
|
3225
|
-
while (current.parent != null && current.parent.type !==
|
|
3277
|
+
while (current.parent != null && current.parent.type !== import_utils21.AST_NODE_TYPES.Program) {
|
|
3226
3278
|
child = current;
|
|
3227
3279
|
current = current.parent;
|
|
3228
3280
|
}
|
|
3229
|
-
if (current.parent?.type !==
|
|
3281
|
+
if (current.parent?.type !== import_utils21.AST_NODE_TYPES.Program) {
|
|
3230
3282
|
return null;
|
|
3231
3283
|
}
|
|
3232
|
-
if (current.type ===
|
|
3284
|
+
if (current.type === import_utils21.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils21.AST_NODE_TYPES.ClassDeclaration) {
|
|
3233
3285
|
return current.id?.name ?? null;
|
|
3234
3286
|
}
|
|
3235
|
-
if (current.type ===
|
|
3236
|
-
if (child.type !==
|
|
3287
|
+
if (current.type === import_utils21.AST_NODE_TYPES.VariableDeclaration) {
|
|
3288
|
+
if (child.type !== import_utils21.AST_NODE_TYPES.VariableDeclarator || child.id.type !== import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3237
3289
|
return null;
|
|
3238
3290
|
}
|
|
3239
3291
|
return child.id.name;
|
|
@@ -3243,19 +3295,19 @@ function moduleScopeBindingName(node) {
|
|
|
3243
3295
|
function specifierExportedNames(program) {
|
|
3244
3296
|
const names = /* @__PURE__ */ new Set();
|
|
3245
3297
|
for (const statement of program.body) {
|
|
3246
|
-
if (statement.type ===
|
|
3298
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
3247
3299
|
for (const specifier of statement.specifiers) {
|
|
3248
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
3300
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3249
3301
|
names.add(specifier.local.name);
|
|
3250
3302
|
}
|
|
3251
3303
|
}
|
|
3252
3304
|
continue;
|
|
3253
3305
|
}
|
|
3254
|
-
if (statement.type ===
|
|
3306
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3255
3307
|
names.add(statement.declaration.name);
|
|
3256
3308
|
continue;
|
|
3257
3309
|
}
|
|
3258
|
-
if (statement.type ===
|
|
3310
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3259
3311
|
names.add(statement.expression.name);
|
|
3260
3312
|
}
|
|
3261
3313
|
}
|
|
@@ -3317,7 +3369,7 @@ var no_positional_tuple_return_default = createRule({
|
|
|
3317
3369
|
});
|
|
3318
3370
|
|
|
3319
3371
|
// src/rules/no-raw-env.ts
|
|
3320
|
-
var
|
|
3372
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
3321
3373
|
var CONFIG_FILE_RE = /(^|[\\/])[\w.-]+\.config\.[cm]?[jt]sx?$/;
|
|
3322
3374
|
var ENV_BOUNDARY_FILE_RE = /(^|[\\/])(?:env|client-env|server-env|client-settings|server-settings)\.[cm]?[jt]sx?$/;
|
|
3323
3375
|
var ENV_VALIDATION_MARKER_RE = /\bcreateEnv\s*\(|\bz\.object\s*\(|\.(?:safeParse|parse)\s*\(/;
|
|
@@ -3394,7 +3446,7 @@ var no_raw_env_default = createRule({
|
|
|
3394
3446
|
});
|
|
3395
3447
|
|
|
3396
3448
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
3397
|
-
var
|
|
3449
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
3398
3450
|
var DEFAULT_ALLOW = [
|
|
3399
3451
|
"[\\\\/]clients?[\\\\/]",
|
|
3400
3452
|
"-client\\.[cm]?[jt]sx?$",
|
|
@@ -3436,7 +3488,7 @@ function identifierLikeName(node) {
|
|
|
3436
3488
|
}
|
|
3437
3489
|
function isConstructedArgumentHandoff(node) {
|
|
3438
3490
|
const [first] = node.arguments;
|
|
3439
|
-
return node.arguments.length === 1 && first !== void 0 && first.type ===
|
|
3491
|
+
return node.arguments.length === 1 && first !== void 0 && first.type === import_utils23.AST_NODE_TYPES.NewExpression;
|
|
3440
3492
|
}
|
|
3441
3493
|
function isPresignedUrlTransfer(node) {
|
|
3442
3494
|
const first = node.arguments[0];
|
|
@@ -3505,9 +3557,9 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
3505
3557
|
});
|
|
3506
3558
|
|
|
3507
3559
|
// src/rules/no-restricted-library-load.ts
|
|
3508
|
-
var
|
|
3560
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
3509
3561
|
function literalModule(node) {
|
|
3510
|
-
return node?.type ===
|
|
3562
|
+
return node?.type === import_utils24.AST_NODE_TYPES.Literal && typeof node.value === "string" ? node.value : null;
|
|
3511
3563
|
}
|
|
3512
3564
|
function matchesModule(source, module2) {
|
|
3513
3565
|
return source === module2 || source.startsWith(`${module2}/`);
|
|
@@ -3566,7 +3618,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
3566
3618
|
});
|
|
3567
3619
|
}
|
|
3568
3620
|
function isUnshadowedRequire(node) {
|
|
3569
|
-
const variable =
|
|
3621
|
+
const variable = import_utils24.ASTUtils.findVariable(
|
|
3570
3622
|
context.sourceCode.getScope(node),
|
|
3571
3623
|
node.name
|
|
3572
3624
|
);
|
|
@@ -3579,9 +3631,9 @@ var no_restricted_library_load_default = createRule({
|
|
|
3579
3631
|
},
|
|
3580
3632
|
CallExpression(node) {
|
|
3581
3633
|
let requireIdentifier = null;
|
|
3582
|
-
if (node.callee.type ===
|
|
3634
|
+
if (node.callee.type === import_utils24.AST_NODE_TYPES.Identifier && node.callee.name === "require") {
|
|
3583
3635
|
requireIdentifier = node.callee;
|
|
3584
|
-
} else if (node.callee.type ===
|
|
3636
|
+
} else if (node.callee.type === import_utils24.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils24.AST_NODE_TYPES.Identifier && node.callee.object.name === "require" && node.callee.property.type === import_utils24.AST_NODE_TYPES.Identifier && node.callee.property.name === "resolve") {
|
|
3585
3637
|
requireIdentifier = node.callee.object;
|
|
3586
3638
|
}
|
|
3587
3639
|
if (requireIdentifier === null || !isUnshadowedRequire(requireIdentifier)) return;
|
|
@@ -3589,7 +3641,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
3589
3641
|
if (source !== null) report(node.arguments[0], source);
|
|
3590
3642
|
},
|
|
3591
3643
|
TSImportEqualsDeclaration(node) {
|
|
3592
|
-
if (node.moduleReference.type !==
|
|
3644
|
+
if (node.moduleReference.type !== import_utils24.AST_NODE_TYPES.TSExternalModuleReference) return;
|
|
3593
3645
|
const source = literalModule(node.moduleReference.expression);
|
|
3594
3646
|
if (source !== null) report(node.moduleReference.expression, source);
|
|
3595
3647
|
}
|
|
@@ -3598,16 +3650,16 @@ var no_restricted_library_load_default = createRule({
|
|
|
3598
3650
|
});
|
|
3599
3651
|
|
|
3600
3652
|
// src/rules/no-repeated-string-literal.ts
|
|
3601
|
-
var
|
|
3653
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
3602
3654
|
var MIN_LENGTH = 40;
|
|
3603
3655
|
var MIN_DISTINCT_SCOPES = 2;
|
|
3604
3656
|
var PREVIEW_LENGTH = 40;
|
|
3605
3657
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
3606
3658
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
3607
3659
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3660
|
+
import_utils25.AST_NODE_TYPES.FunctionDeclaration,
|
|
3661
|
+
import_utils25.AST_NODE_TYPES.FunctionExpression,
|
|
3662
|
+
import_utils25.AST_NODE_TYPES.ArrowFunctionExpression
|
|
3611
3663
|
]);
|
|
3612
3664
|
function isStructured(value) {
|
|
3613
3665
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -3629,8 +3681,8 @@ function isScaffolding(node) {
|
|
|
3629
3681
|
if (parent === void 0) {
|
|
3630
3682
|
return true;
|
|
3631
3683
|
}
|
|
3632
|
-
const isRequireSource = parent.type ===
|
|
3633
|
-
return parent.type ===
|
|
3684
|
+
const isRequireSource = parent.type === import_utils25.AST_NODE_TYPES.CallExpression && parent.callee.type === import_utils25.AST_NODE_TYPES.Identifier && parent.callee.name === "require";
|
|
3685
|
+
return parent.type === import_utils25.AST_NODE_TYPES.ImportDeclaration || parent.type === import_utils25.AST_NODE_TYPES.ImportExpression || parent.type === import_utils25.AST_NODE_TYPES.ExportNamedDeclaration || parent.type === import_utils25.AST_NODE_TYPES.ExportAllDeclaration || parent.type === import_utils25.AST_NODE_TYPES.TSImportType || parent.type === import_utils25.AST_NODE_TYPES.JSXAttribute || parent.type === import_utils25.AST_NODE_TYPES.TSLiteralType || isRequireSource;
|
|
3634
3686
|
}
|
|
3635
3687
|
var no_repeated_string_literal_default = createRule({
|
|
3636
3688
|
name: "no-repeated-string-literal",
|
|
@@ -3670,7 +3722,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3670
3722
|
}
|
|
3671
3723
|
},
|
|
3672
3724
|
TemplateLiteral(node) {
|
|
3673
|
-
if (node.parent.type ===
|
|
3725
|
+
if (node.parent.type === import_utils25.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
3674
3726
|
return;
|
|
3675
3727
|
}
|
|
3676
3728
|
const [only] = node.quasis;
|
|
@@ -3704,7 +3756,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3704
3756
|
});
|
|
3705
3757
|
|
|
3706
3758
|
// src/rules/no-restated-comment.ts
|
|
3707
|
-
var
|
|
3759
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
3708
3760
|
var MAX_WORDS = 8;
|
|
3709
3761
|
var MIN_CONTENT_TOKENS = 2;
|
|
3710
3762
|
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;
|
|
@@ -3757,7 +3809,7 @@ var no_restated_comment_default = createRule({
|
|
|
3757
3809
|
function labelsASiblingRun(comment) {
|
|
3758
3810
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3759
3811
|
if (token === null) return false;
|
|
3760
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
3812
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== import_utils26.AST_NODE_TYPES.Program; node = node.parent) {
|
|
3761
3813
|
if (headsSiblingRun(node)) return true;
|
|
3762
3814
|
}
|
|
3763
3815
|
return false;
|
|
@@ -3817,7 +3869,7 @@ var no_restated_comment_default = createRule({
|
|
|
3817
3869
|
});
|
|
3818
3870
|
|
|
3819
3871
|
// src/rules/no-restated-jsdoc.ts
|
|
3820
|
-
var
|
|
3872
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
3821
3873
|
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
3822
3874
|
"arg",
|
|
3823
3875
|
"argument",
|
|
@@ -3871,30 +3923,30 @@ function declarationNames(node) {
|
|
|
3871
3923
|
switch (node.type) {
|
|
3872
3924
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
3873
3925
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
3874
|
-
case
|
|
3875
|
-
case
|
|
3926
|
+
case import_utils27.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3927
|
+
case import_utils27.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3876
3928
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
3877
|
-
case
|
|
3878
|
-
case
|
|
3929
|
+
case import_utils27.AST_NODE_TYPES.FunctionDeclaration:
|
|
3930
|
+
case import_utils27.AST_NODE_TYPES.TSDeclareFunction:
|
|
3879
3931
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
3880
|
-
case
|
|
3881
|
-
case
|
|
3882
|
-
case
|
|
3883
|
-
case
|
|
3932
|
+
case import_utils27.AST_NODE_TYPES.ClassDeclaration:
|
|
3933
|
+
case import_utils27.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3934
|
+
case import_utils27.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3935
|
+
case import_utils27.AST_NODE_TYPES.TSEnumDeclaration:
|
|
3884
3936
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
3885
|
-
case
|
|
3937
|
+
case import_utils27.AST_NODE_TYPES.VariableDeclaration: {
|
|
3886
3938
|
const declarator = node.declarations[0];
|
|
3887
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
3939
|
+
if (declarator === void 0 || declarator.id.type !== import_utils27.AST_NODE_TYPES.Identifier) return null;
|
|
3888
3940
|
const init = declarator.init;
|
|
3889
|
-
const params = init != null && (init.type ===
|
|
3941
|
+
const params = init != null && (init.type === import_utils27.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils27.AST_NODE_TYPES.FunctionExpression) ? paramNames(init.params) : [];
|
|
3890
3942
|
return { name: declarator.id.name, params };
|
|
3891
3943
|
}
|
|
3892
|
-
case
|
|
3893
|
-
case
|
|
3894
|
-
case
|
|
3895
|
-
case
|
|
3896
|
-
if (node.key.type !==
|
|
3897
|
-
const params = node.type ===
|
|
3944
|
+
case import_utils27.AST_NODE_TYPES.MethodDefinition:
|
|
3945
|
+
case import_utils27.AST_NODE_TYPES.PropertyDefinition:
|
|
3946
|
+
case import_utils27.AST_NODE_TYPES.TSMethodSignature:
|
|
3947
|
+
case import_utils27.AST_NODE_TYPES.TSPropertySignature: {
|
|
3948
|
+
if (node.key.type !== import_utils27.AST_NODE_TYPES.Identifier) return null;
|
|
3949
|
+
const params = node.type === import_utils27.AST_NODE_TYPES.MethodDefinition ? paramNames(node.value.params) : node.type === import_utils27.AST_NODE_TYPES.TSMethodSignature ? paramNames(node.params) : [];
|
|
3898
3950
|
return { name: node.key.name, params };
|
|
3899
3951
|
}
|
|
3900
3952
|
default:
|
|
@@ -3904,9 +3956,9 @@ function declarationNames(node) {
|
|
|
3904
3956
|
function paramNames(params) {
|
|
3905
3957
|
const names = [];
|
|
3906
3958
|
for (const param of params) {
|
|
3907
|
-
const target = param.type ===
|
|
3908
|
-
if (target.type ===
|
|
3909
|
-
else if (target.type ===
|
|
3959
|
+
const target = param.type === import_utils27.AST_NODE_TYPES.AssignmentPattern ? param.left : param;
|
|
3960
|
+
if (target.type === import_utils27.AST_NODE_TYPES.Identifier) names.push(target.name);
|
|
3961
|
+
else if (target.type === import_utils27.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
3910
3962
|
}
|
|
3911
3963
|
return names;
|
|
3912
3964
|
}
|
|
@@ -3948,7 +4000,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3948
4000
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
3949
4001
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3950
4002
|
let declaration = null;
|
|
3951
|
-
while (node != null && node.type !==
|
|
4003
|
+
while (node != null && node.type !== import_utils27.AST_NODE_TYPES.Program) {
|
|
3952
4004
|
declaration = declarationNames(node);
|
|
3953
4005
|
if (declaration !== null) break;
|
|
3954
4006
|
node = node.parent ?? null;
|
|
@@ -4003,7 +4055,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
4003
4055
|
});
|
|
4004
4056
|
|
|
4005
4057
|
// src/rules/no-secret-in-log.ts
|
|
4006
|
-
var
|
|
4058
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
4007
4059
|
|
|
4008
4060
|
// src/rules/_secret-names.ts
|
|
4009
4061
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -4340,7 +4392,7 @@ var no_secret_in_log_default = createRule({
|
|
|
4340
4392
|
});
|
|
4341
4393
|
|
|
4342
4394
|
// src/rules/no-select-star.ts
|
|
4343
|
-
var
|
|
4395
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
4344
4396
|
var QUERY_SHAPE = /\bSELECT\b[\s\S]*?\bFROM\b/i;
|
|
4345
4397
|
var SELECT_KEYWORD = /\bSELECT\b/gi;
|
|
4346
4398
|
var FROM_KEYWORD = /^FROM\b/i;
|
|
@@ -4407,12 +4459,12 @@ var no_select_star_default = createRule({
|
|
|
4407
4459
|
});
|
|
4408
4460
|
|
|
4409
4461
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
4410
|
-
var
|
|
4462
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
4411
4463
|
function sentinelKind(arg) {
|
|
4412
4464
|
if (arg === null) {
|
|
4413
4465
|
return null;
|
|
4414
4466
|
}
|
|
4415
|
-
if (arg.type ===
|
|
4467
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Literal) {
|
|
4416
4468
|
if (arg.value === null) {
|
|
4417
4469
|
return "nullish";
|
|
4418
4470
|
}
|
|
@@ -4424,13 +4476,13 @@ function sentinelKind(arg) {
|
|
|
4424
4476
|
}
|
|
4425
4477
|
return null;
|
|
4426
4478
|
}
|
|
4427
|
-
if (arg.type ===
|
|
4479
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4428
4480
|
return "nullish";
|
|
4429
4481
|
}
|
|
4430
|
-
if (arg.type ===
|
|
4482
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ArrayExpression) {
|
|
4431
4483
|
return "array";
|
|
4432
4484
|
}
|
|
4433
|
-
if (arg.type ===
|
|
4485
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ObjectExpression) {
|
|
4434
4486
|
return "object";
|
|
4435
4487
|
}
|
|
4436
4488
|
return null;
|
|
@@ -4439,25 +4491,25 @@ function isSentinelArgument(arg) {
|
|
|
4439
4491
|
if (arg === null) {
|
|
4440
4492
|
return false;
|
|
4441
4493
|
}
|
|
4442
|
-
if (arg.type ===
|
|
4494
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Literal && arg.value === null) {
|
|
4443
4495
|
return true;
|
|
4444
4496
|
}
|
|
4445
|
-
if (arg.type ===
|
|
4497
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Literal && arg.value === false) {
|
|
4446
4498
|
return true;
|
|
4447
4499
|
}
|
|
4448
|
-
if (arg.type ===
|
|
4500
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4449
4501
|
return true;
|
|
4450
4502
|
}
|
|
4451
|
-
if (arg.type ===
|
|
4503
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ArrayExpression && arg.elements.length === 0) {
|
|
4452
4504
|
return true;
|
|
4453
4505
|
}
|
|
4454
|
-
if (arg.type ===
|
|
4506
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ObjectExpression && arg.properties.length === 0) {
|
|
4455
4507
|
return true;
|
|
4456
4508
|
}
|
|
4457
4509
|
return false;
|
|
4458
4510
|
}
|
|
4459
4511
|
function isFunctionNode(node) {
|
|
4460
|
-
return node.type ===
|
|
4512
|
+
return node.type === import_utils30.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils30.AST_NODE_TYPES.FunctionExpression || node.type === import_utils30.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
4461
4513
|
}
|
|
4462
4514
|
function isNode3(value) {
|
|
4463
4515
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -4497,24 +4549,24 @@ function walkWithinScope(node, visit) {
|
|
|
4497
4549
|
function containsThrow(node) {
|
|
4498
4550
|
return walkWithinScope(
|
|
4499
4551
|
node,
|
|
4500
|
-
(current) => current.type ===
|
|
4552
|
+
(current) => current.type === import_utils30.AST_NODE_TYPES.ThrowStatement
|
|
4501
4553
|
);
|
|
4502
4554
|
}
|
|
4503
4555
|
function bindsName(param, name) {
|
|
4504
4556
|
switch (param.type) {
|
|
4505
|
-
case
|
|
4557
|
+
case import_utils30.AST_NODE_TYPES.Identifier:
|
|
4506
4558
|
return param.name === name;
|
|
4507
|
-
case
|
|
4559
|
+
case import_utils30.AST_NODE_TYPES.AssignmentPattern:
|
|
4508
4560
|
return bindsName(param.left, name);
|
|
4509
|
-
case
|
|
4561
|
+
case import_utils30.AST_NODE_TYPES.RestElement:
|
|
4510
4562
|
return bindsName(param.argument, name);
|
|
4511
|
-
case
|
|
4563
|
+
case import_utils30.AST_NODE_TYPES.ArrayPattern:
|
|
4512
4564
|
return param.elements.some(
|
|
4513
4565
|
(element) => element !== null && bindsName(element, name)
|
|
4514
4566
|
);
|
|
4515
|
-
case
|
|
4567
|
+
case import_utils30.AST_NODE_TYPES.ObjectPattern:
|
|
4516
4568
|
return param.properties.some(
|
|
4517
|
-
(property) => property.type ===
|
|
4569
|
+
(property) => property.type === import_utils30.AST_NODE_TYPES.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
4518
4570
|
);
|
|
4519
4571
|
default:
|
|
4520
4572
|
return false;
|
|
@@ -4529,7 +4581,7 @@ function subtreeReadsName(node, name) {
|
|
|
4529
4581
|
if (found) {
|
|
4530
4582
|
return;
|
|
4531
4583
|
}
|
|
4532
|
-
if (current.type ===
|
|
4584
|
+
if (current.type === import_utils30.AST_NODE_TYPES.Identifier && current.name === name) {
|
|
4533
4585
|
found = true;
|
|
4534
4586
|
return;
|
|
4535
4587
|
}
|
|
@@ -4540,10 +4592,10 @@ function subtreeReadsName(node, name) {
|
|
|
4540
4592
|
if (key === "parent") {
|
|
4541
4593
|
continue;
|
|
4542
4594
|
}
|
|
4543
|
-
if (key === "key" && current.type ===
|
|
4595
|
+
if (key === "key" && current.type === import_utils30.AST_NODE_TYPES.Property && !current.computed) {
|
|
4544
4596
|
continue;
|
|
4545
4597
|
}
|
|
4546
|
-
if (key === "property" && current.type ===
|
|
4598
|
+
if (key === "property" && current.type === import_utils30.AST_NODE_TYPES.MemberExpression && !current.computed) {
|
|
4547
4599
|
continue;
|
|
4548
4600
|
}
|
|
4549
4601
|
const value = current[key];
|
|
@@ -4576,10 +4628,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4576
4628
|
"URLPattern"
|
|
4577
4629
|
]);
|
|
4578
4630
|
function isParseShapedNode(node) {
|
|
4579
|
-
if (node.type ===
|
|
4631
|
+
if (node.type === import_utils30.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils30.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4580
4632
|
return node.callee.property.name === "parse";
|
|
4581
4633
|
}
|
|
4582
|
-
if (node.type ===
|
|
4634
|
+
if (node.type === import_utils30.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4583
4635
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
4584
4636
|
}
|
|
4585
4637
|
return false;
|
|
@@ -4590,10 +4642,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
4590
4642
|
"arrayBuffer"
|
|
4591
4643
|
]);
|
|
4592
4644
|
function isBodyDecodeNode(node) {
|
|
4593
|
-
return node.type ===
|
|
4645
|
+
return node.type === import_utils30.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils30.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils30.AST_NODE_TYPES.Identifier && BODY_DECODE_METHODS.has(node.callee.property.name);
|
|
4594
4646
|
}
|
|
4595
4647
|
function returnsMatching(stmt, predicate) {
|
|
4596
|
-
return stmt.type ===
|
|
4648
|
+
return stmt.type === import_utils30.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
4597
4649
|
}
|
|
4598
4650
|
function enclosingReturnTypeNode(node) {
|
|
4599
4651
|
let current = node.parent;
|
|
@@ -4611,11 +4663,11 @@ function enclosingFunctionName(node) {
|
|
|
4611
4663
|
let current = node.parent;
|
|
4612
4664
|
while (current !== void 0 && current !== null) {
|
|
4613
4665
|
if (isFunctionNode(current)) {
|
|
4614
|
-
if ("id" in current && isNode3(current.id) && current.id.type ===
|
|
4666
|
+
if ("id" in current && isNode3(current.id) && current.id.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4615
4667
|
return current.id.name;
|
|
4616
4668
|
}
|
|
4617
4669
|
const parent = current.parent;
|
|
4618
|
-
if (parent?.type ===
|
|
4670
|
+
if (parent?.type === import_utils30.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4619
4671
|
return parent.id.name;
|
|
4620
4672
|
}
|
|
4621
4673
|
return null;
|
|
@@ -4636,10 +4688,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
4636
4688
|
return false;
|
|
4637
4689
|
}
|
|
4638
4690
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
4639
|
-
if (declared?.type ===
|
|
4691
|
+
if (declared?.type === import_utils30.AST_NODE_TYPES.TSTypeReference && declared.typeName.type === import_utils30.AST_NODE_TYPES.Identifier && declared.typeName.name === "Promise") {
|
|
4640
4692
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
4641
4693
|
}
|
|
4642
|
-
return declared?.type ===
|
|
4694
|
+
return declared?.type === import_utils30.AST_NODE_TYPES.TSBooleanKeyword;
|
|
4643
4695
|
}
|
|
4644
4696
|
function tryReturnsSafeParse(catchNode) {
|
|
4645
4697
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -4655,7 +4707,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
4655
4707
|
function enclosingFunctionBody(node) {
|
|
4656
4708
|
let current = node.parent;
|
|
4657
4709
|
while (current !== void 0 && current !== null) {
|
|
4658
|
-
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type ===
|
|
4710
|
+
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === import_utils30.AST_NODE_TYPES.BlockStatement) {
|
|
4659
4711
|
return current.body;
|
|
4660
4712
|
}
|
|
4661
4713
|
current = current.parent;
|
|
@@ -4668,7 +4720,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
4668
4720
|
return false;
|
|
4669
4721
|
}
|
|
4670
4722
|
return walkWithinScope(functionBody, (current) => {
|
|
4671
|
-
if (current.type !==
|
|
4723
|
+
if (current.type !== import_utils30.AST_NODE_TYPES.ReturnStatement) {
|
|
4672
4724
|
return false;
|
|
4673
4725
|
}
|
|
4674
4726
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -4687,13 +4739,13 @@ function returnedSentinelKinds(arg) {
|
|
|
4687
4739
|
kinds.add(direct);
|
|
4688
4740
|
return kinds;
|
|
4689
4741
|
}
|
|
4690
|
-
if (arg.type ===
|
|
4742
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ConditionalExpression) {
|
|
4691
4743
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
4692
4744
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
4693
4745
|
kinds.add(nested);
|
|
4694
4746
|
}
|
|
4695
4747
|
}
|
|
4696
|
-
} else if (arg.type ===
|
|
4748
|
+
} else if (arg.type === import_utils30.AST_NODE_TYPES.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
4697
4749
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
4698
4750
|
kinds.add(nested);
|
|
4699
4751
|
}
|
|
@@ -4736,7 +4788,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4736
4788
|
const matcher = createLogMatcher(loggingOptions);
|
|
4737
4789
|
function logsOrReportsError(catchBody, caughtName) {
|
|
4738
4790
|
return walkWithinScope(catchBody, (current) => {
|
|
4739
|
-
if (current.type !==
|
|
4791
|
+
if (current.type !== import_utils30.AST_NODE_TYPES.CallExpression) {
|
|
4740
4792
|
return false;
|
|
4741
4793
|
}
|
|
4742
4794
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -4753,7 +4805,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4753
4805
|
return;
|
|
4754
4806
|
}
|
|
4755
4807
|
const last = body2[body2.length - 1];
|
|
4756
|
-
if (last === void 0 || last.type !==
|
|
4808
|
+
if (last === void 0 || last.type !== import_utils30.AST_NODE_TYPES.ReturnStatement) {
|
|
4757
4809
|
return;
|
|
4758
4810
|
}
|
|
4759
4811
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -4762,7 +4814,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4762
4814
|
if (containsThrow(node.body)) {
|
|
4763
4815
|
return;
|
|
4764
4816
|
}
|
|
4765
|
-
const caughtName = node.param?.type ===
|
|
4817
|
+
const caughtName = node.param?.type === import_utils30.AST_NODE_TYPES.Identifier ? node.param.name : null;
|
|
4766
4818
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
4767
4819
|
return;
|
|
4768
4820
|
}
|
|
@@ -4789,9 +4841,9 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4789
4841
|
});
|
|
4790
4842
|
|
|
4791
4843
|
// src/rules/no-silent-promise-catch.ts
|
|
4792
|
-
var
|
|
4844
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
4793
4845
|
function isBodyParseCall(node) {
|
|
4794
|
-
return node.type ===
|
|
4846
|
+
return node.type === import_utils31.AST_NODE_TYPES.CallExpression && node.arguments.length === 0 && node.callee.type === import_utils31.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils31.AST_NODE_TYPES.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
4795
4847
|
}
|
|
4796
4848
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
4797
4849
|
"cancel",
|
|
@@ -4806,21 +4858,21 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
4806
4858
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
4807
4859
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
4808
4860
|
function isTeardownCall(node) {
|
|
4809
|
-
return node.type ===
|
|
4861
|
+
return node.type === import_utils31.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils31.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils31.AST_NODE_TYPES.Identifier && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
4810
4862
|
}
|
|
4811
4863
|
function isSilentExpression(node) {
|
|
4812
4864
|
switch (node.type) {
|
|
4813
|
-
case
|
|
4865
|
+
case import_utils31.AST_NODE_TYPES.Literal:
|
|
4814
4866
|
return !("regex" in node);
|
|
4815
|
-
case
|
|
4867
|
+
case import_utils31.AST_NODE_TYPES.Identifier:
|
|
4816
4868
|
return node.name === "undefined";
|
|
4817
|
-
case
|
|
4818
|
-
return node.operator === "void" && node.argument.type ===
|
|
4819
|
-
case
|
|
4869
|
+
case import_utils31.AST_NODE_TYPES.UnaryExpression:
|
|
4870
|
+
return node.operator === "void" && node.argument.type === import_utils31.AST_NODE_TYPES.Literal;
|
|
4871
|
+
case import_utils31.AST_NODE_TYPES.ObjectExpression:
|
|
4820
4872
|
return node.properties.length === 0;
|
|
4821
|
-
case
|
|
4873
|
+
case import_utils31.AST_NODE_TYPES.ArrayExpression:
|
|
4822
4874
|
return node.elements.length === 0;
|
|
4823
|
-
case
|
|
4875
|
+
case import_utils31.AST_NODE_TYPES.TSAsExpression:
|
|
4824
4876
|
return isSilentExpression(node.expression);
|
|
4825
4877
|
default:
|
|
4826
4878
|
return false;
|
|
@@ -4828,7 +4880,7 @@ function isSilentExpression(node) {
|
|
|
4828
4880
|
}
|
|
4829
4881
|
function isSilentHandler(handler) {
|
|
4830
4882
|
const body2 = handler.body;
|
|
4831
|
-
if (body2.type !==
|
|
4883
|
+
if (body2.type !== import_utils31.AST_NODE_TYPES.BlockStatement) {
|
|
4832
4884
|
return isSilentExpression(body2);
|
|
4833
4885
|
}
|
|
4834
4886
|
if (body2.body.length === 0) {
|
|
@@ -4836,7 +4888,7 @@ function isSilentHandler(handler) {
|
|
|
4836
4888
|
}
|
|
4837
4889
|
if (body2.body.length === 1) {
|
|
4838
4890
|
const only = body2.body[0];
|
|
4839
|
-
if (only !== void 0 && only.type ===
|
|
4891
|
+
if (only !== void 0 && only.type === import_utils31.AST_NODE_TYPES.ReturnStatement) {
|
|
4840
4892
|
return only.argument === null || isSilentExpression(only.argument);
|
|
4841
4893
|
}
|
|
4842
4894
|
}
|
|
@@ -4865,7 +4917,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4865
4917
|
return true;
|
|
4866
4918
|
}
|
|
4867
4919
|
let statement = call;
|
|
4868
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
4920
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== import_utils31.AST_NODE_TYPES.VariableDeclaration) {
|
|
4869
4921
|
statement = statement.parent;
|
|
4870
4922
|
}
|
|
4871
4923
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -4877,7 +4929,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4877
4929
|
};
|
|
4878
4930
|
return {
|
|
4879
4931
|
CallExpression(node) {
|
|
4880
|
-
if (node.callee.type !==
|
|
4932
|
+
if (node.callee.type !== import_utils31.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.property.type !== import_utils31.AST_NODE_TYPES.Identifier || node.callee.property.name !== "catch") {
|
|
4881
4933
|
return;
|
|
4882
4934
|
}
|
|
4883
4935
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -4886,14 +4938,14 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4886
4938
|
if (isTeardownCall(node.callee.object)) {
|
|
4887
4939
|
return;
|
|
4888
4940
|
}
|
|
4889
|
-
if (node.parent.type ===
|
|
4941
|
+
if (node.parent.type === import_utils31.AST_NODE_TYPES.MemberExpression && node.parent.object === node) {
|
|
4890
4942
|
return;
|
|
4891
4943
|
}
|
|
4892
4944
|
if (node.arguments.length !== 1) {
|
|
4893
4945
|
return;
|
|
4894
4946
|
}
|
|
4895
4947
|
const handler = node.arguments[0];
|
|
4896
|
-
if (handler === void 0 || handler.type !==
|
|
4948
|
+
if (handler === void 0 || handler.type !== import_utils31.AST_NODE_TYPES.ArrowFunctionExpression && handler.type !== import_utils31.AST_NODE_TYPES.FunctionExpression) {
|
|
4897
4949
|
return;
|
|
4898
4950
|
}
|
|
4899
4951
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -4908,7 +4960,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4908
4960
|
});
|
|
4909
4961
|
|
|
4910
4962
|
// src/rules/no-sleep-in-test-body.ts
|
|
4911
|
-
var
|
|
4963
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
4912
4964
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
4913
4965
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
4914
4966
|
"it",
|
|
@@ -4917,34 +4969,34 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
|
4917
4969
|
"afterEach"
|
|
4918
4970
|
]);
|
|
4919
4971
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4972
|
+
import_utils32.AST_NODE_TYPES.FunctionDeclaration,
|
|
4973
|
+
import_utils32.AST_NODE_TYPES.FunctionExpression,
|
|
4974
|
+
import_utils32.AST_NODE_TYPES.ArrowFunctionExpression
|
|
4923
4975
|
]);
|
|
4924
4976
|
function isNonzeroNumericLiteral(node) {
|
|
4925
|
-
return node?.type ===
|
|
4977
|
+
return node?.type === import_utils32.AST_NODE_TYPES.Literal && typeof node.value === "number" && node.value !== 0;
|
|
4926
4978
|
}
|
|
4927
4979
|
function isTimedSetTimeout(node) {
|
|
4928
|
-
return node.type ===
|
|
4980
|
+
return node.type === import_utils32.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils32.AST_NODE_TYPES.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
4929
4981
|
}
|
|
4930
4982
|
function isPromiseSleep(node) {
|
|
4931
|
-
if (node.callee.type !==
|
|
4983
|
+
if (node.callee.type !== import_utils32.AST_NODE_TYPES.Identifier || node.callee.name !== "Promise") {
|
|
4932
4984
|
return false;
|
|
4933
4985
|
}
|
|
4934
4986
|
const executor = node.arguments[0];
|
|
4935
|
-
if (executor?.type !==
|
|
4987
|
+
if (executor?.type !== import_utils32.AST_NODE_TYPES.ArrowFunctionExpression && executor?.type !== import_utils32.AST_NODE_TYPES.FunctionExpression) {
|
|
4936
4988
|
return false;
|
|
4937
4989
|
}
|
|
4938
4990
|
const body2 = executor.body;
|
|
4939
|
-
if (body2.type !==
|
|
4991
|
+
if (body2.type !== import_utils32.AST_NODE_TYPES.BlockStatement) {
|
|
4940
4992
|
return isTimedSetTimeout(body2);
|
|
4941
4993
|
}
|
|
4942
4994
|
return body2.body.some(
|
|
4943
|
-
(stmt) => stmt.type ===
|
|
4995
|
+
(stmt) => stmt.type === import_utils32.AST_NODE_TYPES.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
4944
4996
|
);
|
|
4945
4997
|
}
|
|
4946
4998
|
function isHelperSleep(node) {
|
|
4947
|
-
return node.callee.type ===
|
|
4999
|
+
return node.callee.type === import_utils32.AST_NODE_TYPES.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
4948
5000
|
}
|
|
4949
5001
|
function nearestEnclosingFunction2(node) {
|
|
4950
5002
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -4952,7 +5004,7 @@ function nearestEnclosingFunction2(node) {
|
|
|
4952
5004
|
continue;
|
|
4953
5005
|
}
|
|
4954
5006
|
const grandparent = current.parent;
|
|
4955
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
5007
|
+
const isPromiseExecutor = grandparent?.type === import_utils32.AST_NODE_TYPES.NewExpression && isPromiseSleep(grandparent);
|
|
4956
5008
|
if (!isPromiseExecutor) {
|
|
4957
5009
|
return current;
|
|
4958
5010
|
}
|
|
@@ -4960,23 +5012,23 @@ function nearestEnclosingFunction2(node) {
|
|
|
4960
5012
|
return null;
|
|
4961
5013
|
}
|
|
4962
5014
|
function testCallerName2(callee) {
|
|
4963
|
-
if (callee.type ===
|
|
5015
|
+
if (callee.type === import_utils32.AST_NODE_TYPES.Identifier) {
|
|
4964
5016
|
return callee.name;
|
|
4965
5017
|
}
|
|
4966
|
-
if (callee.type ===
|
|
5018
|
+
if (callee.type === import_utils32.AST_NODE_TYPES.MemberExpression) {
|
|
4967
5019
|
return testCallerName2(callee.object);
|
|
4968
5020
|
}
|
|
4969
|
-
if (callee.type ===
|
|
5021
|
+
if (callee.type === import_utils32.AST_NODE_TYPES.CallExpression) {
|
|
4970
5022
|
return testCallerName2(callee.callee);
|
|
4971
5023
|
}
|
|
4972
|
-
if (callee.type ===
|
|
5024
|
+
if (callee.type === import_utils32.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
4973
5025
|
return testCallerName2(callee.tag);
|
|
4974
5026
|
}
|
|
4975
5027
|
return null;
|
|
4976
5028
|
}
|
|
4977
5029
|
function isTestBody2(fn) {
|
|
4978
5030
|
const call = fn.parent;
|
|
4979
|
-
if (call?.type !==
|
|
5031
|
+
if (call?.type !== import_utils32.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
4980
5032
|
return false;
|
|
4981
5033
|
}
|
|
4982
5034
|
const name = testCallerName2(call.callee);
|
|
@@ -5022,7 +5074,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
5022
5074
|
});
|
|
5023
5075
|
|
|
5024
5076
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
5025
|
-
var
|
|
5077
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
5026
5078
|
var DEFAULT_METHODS2 = [
|
|
5027
5079
|
"prepare",
|
|
5028
5080
|
"put",
|
|
@@ -5041,7 +5093,7 @@ function compile2(patterns) {
|
|
|
5041
5093
|
}
|
|
5042
5094
|
function storageMethodName(node, methods) {
|
|
5043
5095
|
const callee = node.callee;
|
|
5044
|
-
if (callee.type !==
|
|
5096
|
+
if (callee.type !== import_utils33.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils33.AST_NODE_TYPES.Identifier) {
|
|
5045
5097
|
return null;
|
|
5046
5098
|
}
|
|
5047
5099
|
const name = callee.property.name;
|
|
@@ -5109,7 +5161,7 @@ var no_storage_in_stateless_modules_default = createRule({
|
|
|
5109
5161
|
});
|
|
5110
5162
|
|
|
5111
5163
|
// src/rules/no-string-concat-in-loop.ts
|
|
5112
|
-
var
|
|
5164
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
5113
5165
|
var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
5114
5166
|
"ForStatement",
|
|
5115
5167
|
"ForOfStatement",
|
|
@@ -5255,7 +5307,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
5255
5307
|
});
|
|
5256
5308
|
|
|
5257
5309
|
// src/rules/no-tautological-expect.ts
|
|
5258
|
-
var
|
|
5310
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
5259
5311
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
5260
5312
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
5261
5313
|
"toBeDefined",
|
|
@@ -5269,17 +5321,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
5269
5321
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
5270
5322
|
function isLiteral(node) {
|
|
5271
5323
|
switch (node.type) {
|
|
5272
|
-
case
|
|
5324
|
+
case import_utils35.AST_NODE_TYPES.Literal:
|
|
5273
5325
|
return true;
|
|
5274
|
-
case
|
|
5326
|
+
case import_utils35.AST_NODE_TYPES.TemplateLiteral:
|
|
5275
5327
|
return node.expressions.length === 0;
|
|
5276
|
-
case
|
|
5328
|
+
case import_utils35.AST_NODE_TYPES.UnaryExpression:
|
|
5277
5329
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
5278
|
-
case
|
|
5330
|
+
case import_utils35.AST_NODE_TYPES.ArrayExpression:
|
|
5279
5331
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
5280
|
-
case
|
|
5332
|
+
case import_utils35.AST_NODE_TYPES.ObjectExpression:
|
|
5281
5333
|
return node.properties.every(
|
|
5282
|
-
(property) => property.type ===
|
|
5334
|
+
(property) => property.type === import_utils35.AST_NODE_TYPES.Property && !property.computed && isLiteral(property.value)
|
|
5283
5335
|
);
|
|
5284
5336
|
default:
|
|
5285
5337
|
return false;
|
|
@@ -5287,7 +5339,7 @@ function isLiteral(node) {
|
|
|
5287
5339
|
}
|
|
5288
5340
|
function expectOperand(callee) {
|
|
5289
5341
|
const receiver = callee.object;
|
|
5290
|
-
if (receiver.type !==
|
|
5342
|
+
if (receiver.type !== import_utils35.AST_NODE_TYPES.CallExpression || receiver.callee.type !== import_utils35.AST_NODE_TYPES.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
5291
5343
|
return null;
|
|
5292
5344
|
}
|
|
5293
5345
|
return receiver.arguments[0] ?? null;
|
|
@@ -5317,10 +5369,10 @@ var no_tautological_expect_default = createRule({
|
|
|
5317
5369
|
return {
|
|
5318
5370
|
CallExpression(node) {
|
|
5319
5371
|
const callee = node.callee;
|
|
5320
|
-
if (callee.type !==
|
|
5372
|
+
if (callee.type !== import_utils35.AST_NODE_TYPES.MemberExpression || callee.computed) {
|
|
5321
5373
|
return;
|
|
5322
5374
|
}
|
|
5323
|
-
if (callee.property.type !==
|
|
5375
|
+
if (callee.property.type !== import_utils35.AST_NODE_TYPES.Identifier) {
|
|
5324
5376
|
return;
|
|
5325
5377
|
}
|
|
5326
5378
|
const matcher = callee.property.name;
|
|
@@ -5379,7 +5431,7 @@ var no_typed_doc_sections_default = createRule({
|
|
|
5379
5431
|
});
|
|
5380
5432
|
|
|
5381
5433
|
// src/rules/no-trailing-value-narration.ts
|
|
5382
|
-
var
|
|
5434
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5383
5435
|
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
5384
5436
|
var WORD_RE3 = /[A-Za-z]+(?:'[a-z]+)?|\d+(?:\.\d+)?/g;
|
|
5385
5437
|
var UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -5514,10 +5566,10 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5514
5566
|
});
|
|
5515
5567
|
|
|
5516
5568
|
// src/rules/no-declaration-comment-wall.ts
|
|
5517
|
-
var
|
|
5569
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5518
5570
|
|
|
5519
5571
|
// src/rules/_comment-wall.ts
|
|
5520
|
-
var
|
|
5572
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5521
5573
|
var WALL_DEFAULTS = {
|
|
5522
5574
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5523
5575
|
minCommentedMembers: 3,
|
|
@@ -5621,10 +5673,10 @@ function isWall(members, commented, restated, options) {
|
|
|
5621
5673
|
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5622
5674
|
}
|
|
5623
5675
|
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5676
|
+
import_utils37.AST_NODE_TYPES.FunctionExpression,
|
|
5677
|
+
import_utils37.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
5678
|
+
import_utils37.AST_NODE_TYPES.ObjectExpression,
|
|
5679
|
+
import_utils37.AST_NODE_TYPES.ArrayExpression
|
|
5628
5680
|
]);
|
|
5629
5681
|
function declarationRange(member) {
|
|
5630
5682
|
const body2 = bodyOf(member);
|
|
@@ -5632,10 +5684,10 @@ function declarationRange(member) {
|
|
|
5632
5684
|
return [member.range[0], body2.range[0]];
|
|
5633
5685
|
}
|
|
5634
5686
|
function bodyOf(member) {
|
|
5635
|
-
if (member.type ===
|
|
5687
|
+
if (member.type === import_utils37.AST_NODE_TYPES.MethodDefinition || member.type === import_utils37.AST_NODE_TYPES.TSAbstractMethodDefinition) {
|
|
5636
5688
|
return member.value.body ?? void 0;
|
|
5637
5689
|
}
|
|
5638
|
-
if (member.type ===
|
|
5690
|
+
if (member.type === import_utils37.AST_NODE_TYPES.Property || member.type === import_utils37.AST_NODE_TYPES.PropertyDefinition) {
|
|
5639
5691
|
const value = member.value;
|
|
5640
5692
|
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5641
5693
|
}
|
|
@@ -5645,12 +5697,12 @@ function bodyOf(member) {
|
|
|
5645
5697
|
// src/rules/no-declaration-comment-wall.ts
|
|
5646
5698
|
function named(node) {
|
|
5647
5699
|
switch (node.type) {
|
|
5648
|
-
case
|
|
5700
|
+
case import_utils38.AST_NODE_TYPES.TSEnumMember:
|
|
5649
5701
|
return { node, key: node.id };
|
|
5650
|
-
case
|
|
5651
|
-
case
|
|
5652
|
-
case
|
|
5653
|
-
case
|
|
5702
|
+
case import_utils38.AST_NODE_TYPES.PropertyDefinition:
|
|
5703
|
+
case import_utils38.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
|
5704
|
+
case import_utils38.AST_NODE_TYPES.MethodDefinition:
|
|
5705
|
+
case import_utils38.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
|
5654
5706
|
return node.computed ? void 0 : { node, key: node.key };
|
|
5655
5707
|
default:
|
|
5656
5708
|
return void 0;
|
|
@@ -5750,7 +5802,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5750
5802
|
});
|
|
5751
5803
|
|
|
5752
5804
|
// src/rules/no-union-in-comment.ts
|
|
5753
|
-
var
|
|
5805
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
5754
5806
|
var MAX_LITERAL_LENGTH = 28;
|
|
5755
5807
|
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5756
5808
|
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
@@ -5769,14 +5821,14 @@ var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
5769
5821
|
function isBareString(node) {
|
|
5770
5822
|
if (node === void 0) return false;
|
|
5771
5823
|
switch (node.type) {
|
|
5772
|
-
case
|
|
5824
|
+
case import_utils39.AST_NODE_TYPES.TSStringKeyword:
|
|
5773
5825
|
return true;
|
|
5774
5826
|
// `string[]` holds members of the same closed set, one element at a time.
|
|
5775
|
-
case
|
|
5827
|
+
case import_utils39.AST_NODE_TYPES.TSArrayType:
|
|
5776
5828
|
return isBareString(node.elementType);
|
|
5777
5829
|
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5778
5830
|
// — the checker collapses that one to `string`.
|
|
5779
|
-
case
|
|
5831
|
+
case import_utils39.AST_NODE_TYPES.TSUnionType:
|
|
5780
5832
|
return node.types.some((member) => isBareString(member));
|
|
5781
5833
|
default:
|
|
5782
5834
|
return false;
|
|
@@ -5786,13 +5838,13 @@ function rootCallee(node) {
|
|
|
5786
5838
|
let current = node;
|
|
5787
5839
|
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5788
5840
|
switch (current.type) {
|
|
5789
|
-
case
|
|
5841
|
+
case import_utils39.AST_NODE_TYPES.CallExpression:
|
|
5790
5842
|
current = current.callee;
|
|
5791
5843
|
break;
|
|
5792
|
-
case
|
|
5844
|
+
case import_utils39.AST_NODE_TYPES.MemberExpression:
|
|
5793
5845
|
current = current.object;
|
|
5794
5846
|
break;
|
|
5795
|
-
case
|
|
5847
|
+
case import_utils39.AST_NODE_TYPES.Identifier:
|
|
5796
5848
|
return current.name;
|
|
5797
5849
|
default:
|
|
5798
5850
|
return null;
|
|
@@ -5801,26 +5853,26 @@ function rootCallee(node) {
|
|
|
5801
5853
|
return null;
|
|
5802
5854
|
}
|
|
5803
5855
|
function nameOf(key) {
|
|
5804
|
-
if (key.type ===
|
|
5805
|
-
if (key.type ===
|
|
5856
|
+
if (key.type === import_utils39.AST_NODE_TYPES.Identifier) return key.name;
|
|
5857
|
+
if (key.type === import_utils39.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
5806
5858
|
return null;
|
|
5807
5859
|
}
|
|
5808
5860
|
function targetOf(node) {
|
|
5809
5861
|
switch (node.type) {
|
|
5810
|
-
case
|
|
5811
|
-
case
|
|
5862
|
+
case import_utils39.AST_NODE_TYPES.TSPropertySignature:
|
|
5863
|
+
case import_utils39.AST_NODE_TYPES.PropertyDefinition: {
|
|
5812
5864
|
const name = node.computed ? null : nameOf(node.key);
|
|
5813
5865
|
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5814
5866
|
return { node, name };
|
|
5815
5867
|
}
|
|
5816
|
-
case
|
|
5868
|
+
case import_utils39.AST_NODE_TYPES.Property: {
|
|
5817
5869
|
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5818
5870
|
const callee = rootCallee(node.value);
|
|
5819
5871
|
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5820
5872
|
return { node, name };
|
|
5821
5873
|
}
|
|
5822
|
-
case
|
|
5823
|
-
if (node.id.type !==
|
|
5874
|
+
case import_utils39.AST_NODE_TYPES.VariableDeclarator: {
|
|
5875
|
+
if (node.id.type !== import_utils39.AST_NODE_TYPES.Identifier) return null;
|
|
5824
5876
|
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5825
5877
|
return { node, name: node.id.name };
|
|
5826
5878
|
}
|
|
@@ -5869,7 +5921,7 @@ var no_union_in_comment_default = createRule({
|
|
|
5869
5921
|
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5870
5922
|
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5871
5923
|
}
|
|
5872
|
-
for (let node = anchor; node != null && node.type !==
|
|
5924
|
+
for (let node = anchor; node != null && node.type !== import_utils39.AST_NODE_TYPES.Program; node = node.parent) {
|
|
5873
5925
|
const target = targetOf(node);
|
|
5874
5926
|
if (target !== null) return target;
|
|
5875
5927
|
}
|
|
@@ -5898,9 +5950,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5898
5950
|
});
|
|
5899
5951
|
|
|
5900
5952
|
// src/rules/no-type-member-comment-wall.ts
|
|
5901
|
-
var
|
|
5953
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
5902
5954
|
function isNamedMember(node) {
|
|
5903
|
-
return (node.type ===
|
|
5955
|
+
return (node.type === import_utils40.AST_NODE_TYPES.TSPropertySignature || node.type === import_utils40.AST_NODE_TYPES.TSMethodSignature) && !node.computed;
|
|
5904
5956
|
}
|
|
5905
5957
|
var no_type_member_comment_wall_default = createRule({
|
|
5906
5958
|
name: "no-type-member-comment-wall",
|
|
@@ -5947,7 +5999,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5947
5999
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5948
6000
|
}
|
|
5949
6001
|
function check(node) {
|
|
5950
|
-
const members = node.type ===
|
|
6002
|
+
const members = node.type === import_utils40.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
|
5951
6003
|
const named2 = members.filter(isNamedMember);
|
|
5952
6004
|
if (named2.length === 0) return;
|
|
5953
6005
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5987,7 +6039,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5987
6039
|
});
|
|
5988
6040
|
|
|
5989
6041
|
// src/rules/no-unnecessary-use-client.ts
|
|
5990
|
-
var
|
|
6042
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
5991
6043
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5992
6044
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5993
6045
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -6013,13 +6065,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
6013
6065
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
6014
6066
|
var jsxRootName = (name) => {
|
|
6015
6067
|
let current = name;
|
|
6016
|
-
while (current.type ===
|
|
6068
|
+
while (current.type === import_utils41.AST_NODE_TYPES.JSXMemberExpression) {
|
|
6017
6069
|
current = current.object;
|
|
6018
6070
|
}
|
|
6019
|
-
return current.type ===
|
|
6071
|
+
return current.type === import_utils41.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
6020
6072
|
};
|
|
6021
6073
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
6022
|
-
if (node.type ===
|
|
6074
|
+
if (node.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
6023
6075
|
return imported.has(node.name);
|
|
6024
6076
|
}
|
|
6025
6077
|
for (const key of Object.keys(node)) {
|
|
@@ -6034,16 +6086,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
6034
6086
|
return false;
|
|
6035
6087
|
};
|
|
6036
6088
|
var isUseClientDirective = (node) => {
|
|
6037
|
-
return node.type ===
|
|
6089
|
+
return node.type === import_utils41.AST_NODE_TYPES.ExpressionStatement && node.expression.type === import_utils41.AST_NODE_TYPES.Literal && node.expression.value === "use client";
|
|
6038
6090
|
};
|
|
6039
6091
|
var isGlobalReference = (node, context) => {
|
|
6040
6092
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
6041
6093
|
const parent = node.parent;
|
|
6042
6094
|
if (parent !== void 0) {
|
|
6043
|
-
if (parent.type ===
|
|
6095
|
+
if (parent.type === import_utils41.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
6044
6096
|
return false;
|
|
6045
6097
|
}
|
|
6046
|
-
if (parent.type ===
|
|
6098
|
+
if (parent.type === import_utils41.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
6047
6099
|
return false;
|
|
6048
6100
|
}
|
|
6049
6101
|
if (parent.type.startsWith("TS")) {
|
|
@@ -6083,13 +6135,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6083
6135
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
6084
6136
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
6085
6137
|
const markIfHookOrContext = (callee) => {
|
|
6086
|
-
if (callee.type ===
|
|
6138
|
+
if (callee.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
6087
6139
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
6088
6140
|
hasClientIndicator = true;
|
|
6089
6141
|
}
|
|
6090
6142
|
return;
|
|
6091
6143
|
}
|
|
6092
|
-
if (callee.type ===
|
|
6144
|
+
if (callee.type === import_utils41.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
6093
6145
|
const name = callee.property.name;
|
|
6094
6146
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
6095
6147
|
hasClientIndicator = true;
|
|
@@ -6099,7 +6151,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6099
6151
|
return {
|
|
6100
6152
|
Program(node) {
|
|
6101
6153
|
for (const stmt of node.body) {
|
|
6102
|
-
if (stmt.type !==
|
|
6154
|
+
if (stmt.type !== import_utils41.AST_NODE_TYPES.ExpressionStatement) break;
|
|
6103
6155
|
if (isUseClientDirective(stmt)) {
|
|
6104
6156
|
directiveNode = stmt;
|
|
6105
6157
|
break;
|
|
@@ -6112,7 +6164,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6112
6164
|
},
|
|
6113
6165
|
JSXAttribute(node) {
|
|
6114
6166
|
if (directiveNode === null) return;
|
|
6115
|
-
if (node.name.type ===
|
|
6167
|
+
if (node.name.type === import_utils41.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
6116
6168
|
hasClientIndicator = true;
|
|
6117
6169
|
}
|
|
6118
6170
|
},
|
|
@@ -6179,18 +6231,18 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6179
6231
|
});
|
|
6180
6232
|
|
|
6181
6233
|
// src/rules/no-unsafe-mock-casting.ts
|
|
6182
|
-
var import_utils41 = require("@typescript-eslint/utils");
|
|
6183
6234
|
var import_utils42 = require("@typescript-eslint/utils");
|
|
6235
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
6184
6236
|
function isMockTypeReference(node) {
|
|
6185
|
-
if (node.type !==
|
|
6237
|
+
if (node.type !== import_utils43.AST_NODE_TYPES.TSTypeReference) {
|
|
6186
6238
|
return false;
|
|
6187
6239
|
}
|
|
6188
6240
|
const typeName = node.typeName;
|
|
6189
|
-
if (typeName.type ===
|
|
6241
|
+
if (typeName.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6190
6242
|
const name = typeName.name;
|
|
6191
6243
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
6192
6244
|
}
|
|
6193
|
-
if (typeName.type ===
|
|
6245
|
+
if (typeName.type === import_utils43.AST_NODE_TYPES.TSQualifiedName) {
|
|
6194
6246
|
const rightName = typeName.right.name;
|
|
6195
6247
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
6196
6248
|
}
|
|
@@ -6226,7 +6278,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
6226
6278
|
});
|
|
6227
6279
|
|
|
6228
6280
|
// src/rules/no-zod-native-enum.ts
|
|
6229
|
-
var
|
|
6281
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
6230
6282
|
var ts = __toESM(require("typescript"), 1);
|
|
6231
6283
|
var IGNORE_PATTERNS = [
|
|
6232
6284
|
/[\\/]generated[\\/]/,
|
|
@@ -6244,7 +6296,7 @@ function isZodModule(source) {
|
|
|
6244
6296
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
6245
6297
|
}
|
|
6246
6298
|
function unwrap2(node) {
|
|
6247
|
-
if (node.type ===
|
|
6299
|
+
if (node.type === import_utils44.AST_NODE_TYPES.TSAsExpression || node.type === import_utils44.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6248
6300
|
return unwrap2(node.expression);
|
|
6249
6301
|
}
|
|
6250
6302
|
return node;
|
|
@@ -6252,14 +6304,14 @@ function unwrap2(node) {
|
|
|
6252
6304
|
function stringValueTexts(node, sourceCode) {
|
|
6253
6305
|
const texts = [];
|
|
6254
6306
|
for (const prop of node.properties) {
|
|
6255
|
-
if (prop.type !==
|
|
6307
|
+
if (prop.type !== import_utils44.AST_NODE_TYPES.Property) {
|
|
6256
6308
|
return null;
|
|
6257
6309
|
}
|
|
6258
6310
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6259
6311
|
return null;
|
|
6260
6312
|
}
|
|
6261
6313
|
const value = prop.value;
|
|
6262
|
-
if (value.type !==
|
|
6314
|
+
if (value.type !== import_utils44.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
6263
6315
|
return null;
|
|
6264
6316
|
}
|
|
6265
6317
|
const text = sourceCode.getText(value);
|
|
@@ -6275,7 +6327,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6275
6327
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6276
6328
|
if (variable !== void 0) {
|
|
6277
6329
|
return variable.defs.some(
|
|
6278
|
-
(def) => def.node.type ===
|
|
6330
|
+
(def) => def.node.type === import_utils44.AST_NODE_TYPES.TSEnumDeclaration
|
|
6279
6331
|
);
|
|
6280
6332
|
}
|
|
6281
6333
|
current = current.upper;
|
|
@@ -6320,32 +6372,32 @@ var no_zod_native_enum_default = createRule({
|
|
|
6320
6372
|
}
|
|
6321
6373
|
let services;
|
|
6322
6374
|
try {
|
|
6323
|
-
services =
|
|
6375
|
+
services = import_utils44.ESLintUtils.getParserServices(context);
|
|
6324
6376
|
} catch {
|
|
6325
6377
|
services = null;
|
|
6326
6378
|
}
|
|
6327
6379
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6328
6380
|
function isZodMemberCall(node, api) {
|
|
6329
6381
|
const callee = node.callee;
|
|
6330
|
-
if (callee.type ===
|
|
6382
|
+
if (callee.type === import_utils44.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6331
6383
|
return callee.property.name === api;
|
|
6332
6384
|
}
|
|
6333
|
-
if (callee.type ===
|
|
6385
|
+
if (callee.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6334
6386
|
return zodImportedNames.get(callee.name) === api;
|
|
6335
6387
|
}
|
|
6336
6388
|
return false;
|
|
6337
6389
|
}
|
|
6338
6390
|
function buildFix(node) {
|
|
6339
6391
|
const callee = node.callee;
|
|
6340
|
-
if (callee.type !==
|
|
6392
|
+
if (callee.type !== import_utils44.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6341
6393
|
return null;
|
|
6342
6394
|
}
|
|
6343
6395
|
const arg = node.arguments[0];
|
|
6344
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6396
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === import_utils44.AST_NODE_TYPES.SpreadElement) {
|
|
6345
6397
|
return null;
|
|
6346
6398
|
}
|
|
6347
6399
|
const inner = unwrap2(arg);
|
|
6348
|
-
if (inner.type !==
|
|
6400
|
+
if (inner.type !== import_utils44.AST_NODE_TYPES.ObjectExpression) {
|
|
6349
6401
|
return null;
|
|
6350
6402
|
}
|
|
6351
6403
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6365,7 +6417,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6365
6417
|
return;
|
|
6366
6418
|
}
|
|
6367
6419
|
for (const spec of node.specifiers) {
|
|
6368
|
-
if (spec.type ===
|
|
6420
|
+
if (spec.type === import_utils44.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6369
6421
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6370
6422
|
}
|
|
6371
6423
|
}
|
|
@@ -6384,7 +6436,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6384
6436
|
return;
|
|
6385
6437
|
}
|
|
6386
6438
|
const arg = node.arguments[0];
|
|
6387
|
-
if (arg === void 0 || arg.type !==
|
|
6439
|
+
if (arg === void 0 || arg.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6388
6440
|
return;
|
|
6389
6441
|
}
|
|
6390
6442
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6401,7 +6453,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6401
6453
|
});
|
|
6402
6454
|
|
|
6403
6455
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6404
|
-
var
|
|
6456
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
6405
6457
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6406
6458
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6407
6459
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6414,36 +6466,36 @@ function isConstantReference(identifier) {
|
|
|
6414
6466
|
}
|
|
6415
6467
|
function isExcludedOperand(node) {
|
|
6416
6468
|
switch (node.type) {
|
|
6417
|
-
case
|
|
6469
|
+
case import_utils45.AST_NODE_TYPES.Literal:
|
|
6418
6470
|
return true;
|
|
6419
|
-
case
|
|
6471
|
+
case import_utils45.AST_NODE_TYPES.TemplateLiteral:
|
|
6420
6472
|
return node.expressions.length === 0;
|
|
6421
|
-
case
|
|
6473
|
+
case import_utils45.AST_NODE_TYPES.Identifier:
|
|
6422
6474
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6423
|
-
case
|
|
6424
|
-
return !node.computed && node.property.type ===
|
|
6475
|
+
case import_utils45.AST_NODE_TYPES.MemberExpression:
|
|
6476
|
+
return !node.computed && node.property.type === import_utils45.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6425
6477
|
default:
|
|
6426
6478
|
return false;
|
|
6427
6479
|
}
|
|
6428
6480
|
}
|
|
6429
6481
|
function operandName(node) {
|
|
6430
|
-
if (node.type ===
|
|
6482
|
+
if (node.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6431
6483
|
return node.name;
|
|
6432
6484
|
}
|
|
6433
|
-
if (node.type ===
|
|
6485
|
+
if (node.type === import_utils45.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6434
6486
|
return node.property.name;
|
|
6435
6487
|
}
|
|
6436
6488
|
return null;
|
|
6437
6489
|
}
|
|
6438
6490
|
function isSecretOperand(node) {
|
|
6439
|
-
if (node.type ===
|
|
6491
|
+
if (node.type === import_utils45.AST_NODE_TYPES.TemplateLiteral) {
|
|
6440
6492
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6441
6493
|
}
|
|
6442
6494
|
const name = operandName(node);
|
|
6443
6495
|
return name !== null && isAuthSecretName(name);
|
|
6444
6496
|
}
|
|
6445
6497
|
function secretNameOf(node) {
|
|
6446
|
-
if (node.type ===
|
|
6498
|
+
if (node.type === import_utils45.AST_NODE_TYPES.TemplateLiteral) {
|
|
6447
6499
|
for (const expression of node.expressions) {
|
|
6448
6500
|
const nested = secretNameOf(expression);
|
|
6449
6501
|
if (nested !== null) {
|
|
@@ -6495,8 +6547,8 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
6495
6547
|
});
|
|
6496
6548
|
|
|
6497
6549
|
// src/rules/prefer-discriminated-union.ts
|
|
6498
|
-
var import_utils45 = require("@typescript-eslint/utils");
|
|
6499
6550
|
var import_utils46 = require("@typescript-eslint/utils");
|
|
6551
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
6500
6552
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
6501
6553
|
"success",
|
|
6502
6554
|
"ok",
|
|
@@ -6506,27 +6558,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6506
6558
|
]);
|
|
6507
6559
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
6508
6560
|
function getMemberName(member) {
|
|
6509
|
-
if (member.type !==
|
|
6561
|
+
if (member.type !== import_utils47.AST_NODE_TYPES.TSPropertySignature) {
|
|
6510
6562
|
return null;
|
|
6511
6563
|
}
|
|
6512
6564
|
const { key } = member;
|
|
6513
|
-
if (key.type ===
|
|
6565
|
+
if (key.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6514
6566
|
return key.name;
|
|
6515
6567
|
}
|
|
6516
|
-
if (key.type ===
|
|
6568
|
+
if (key.type === import_utils47.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
6517
6569
|
return key.value;
|
|
6518
6570
|
}
|
|
6519
6571
|
return null;
|
|
6520
6572
|
}
|
|
6521
6573
|
function isBooleanTyped(member) {
|
|
6522
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6574
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils47.AST_NODE_TYPES.TSBooleanKeyword;
|
|
6523
6575
|
}
|
|
6524
6576
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
6525
6577
|
let hasStatusBoolean = false;
|
|
6526
6578
|
let optionalCount = 0;
|
|
6527
6579
|
let optionalPayloadCount = 0;
|
|
6528
6580
|
for (const member of typeLiteral.members) {
|
|
6529
|
-
if (member.type !==
|
|
6581
|
+
if (member.type !== import_utils47.AST_NODE_TYPES.TSPropertySignature) {
|
|
6530
6582
|
continue;
|
|
6531
6583
|
}
|
|
6532
6584
|
if (member.optional) {
|
|
@@ -6568,7 +6620,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6568
6620
|
TSInterfaceDeclaration(node) {
|
|
6569
6621
|
const synthetic = {
|
|
6570
6622
|
...node.body,
|
|
6571
|
-
type:
|
|
6623
|
+
type: import_utils47.AST_NODE_TYPES.TSTypeLiteral,
|
|
6572
6624
|
members: node.body.body
|
|
6573
6625
|
};
|
|
6574
6626
|
checkTypeLiteral(synthetic, node);
|
|
@@ -6581,7 +6633,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6581
6633
|
});
|
|
6582
6634
|
|
|
6583
6635
|
// src/rules/prefer-module-level-constant.ts
|
|
6584
|
-
var
|
|
6636
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6585
6637
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6586
6638
|
var MAX_LITERAL_DEPTH = 4;
|
|
6587
6639
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6610,9 +6662,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6610
6662
|
"assign"
|
|
6611
6663
|
]);
|
|
6612
6664
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6665
|
+
import_utils48.AST_NODE_TYPES.FunctionDeclaration,
|
|
6666
|
+
import_utils48.AST_NODE_TYPES.FunctionExpression,
|
|
6667
|
+
import_utils48.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6616
6668
|
]);
|
|
6617
6669
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6618
6670
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6625,14 +6677,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6625
6677
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6626
6678
|
}
|
|
6627
6679
|
function unwrap3(node) {
|
|
6628
|
-
if (node.type ===
|
|
6680
|
+
if (node.type === import_utils48.AST_NODE_TYPES.TSAsExpression || node.type === import_utils48.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils48.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6629
6681
|
return unwrap3(node.expression);
|
|
6630
6682
|
}
|
|
6631
6683
|
return node;
|
|
6632
6684
|
}
|
|
6633
6685
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6634
6686
|
function isRegexLiteral(node) {
|
|
6635
|
-
return node.type ===
|
|
6687
|
+
return node.type === import_utils48.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6636
6688
|
}
|
|
6637
6689
|
function isLiteralOnly(node, depth) {
|
|
6638
6690
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6640,29 +6692,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6640
6692
|
}
|
|
6641
6693
|
const inner = unwrap3(node);
|
|
6642
6694
|
switch (inner.type) {
|
|
6643
|
-
case
|
|
6695
|
+
case import_utils48.AST_NODE_TYPES.Literal: {
|
|
6644
6696
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6645
6697
|
}
|
|
6646
|
-
case
|
|
6698
|
+
case import_utils48.AST_NODE_TYPES.TemplateLiteral: {
|
|
6647
6699
|
return inner.expressions.length === 0;
|
|
6648
6700
|
}
|
|
6649
|
-
case
|
|
6650
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6701
|
+
case import_utils48.AST_NODE_TYPES.UnaryExpression: {
|
|
6702
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils48.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6651
6703
|
}
|
|
6652
|
-
case
|
|
6704
|
+
case import_utils48.AST_NODE_TYPES.ArrayExpression: {
|
|
6653
6705
|
return inner.elements.every(
|
|
6654
|
-
(el) => el !== null && el.type !==
|
|
6706
|
+
(el) => el !== null && el.type !== import_utils48.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6655
6707
|
);
|
|
6656
6708
|
}
|
|
6657
|
-
case
|
|
6709
|
+
case import_utils48.AST_NODE_TYPES.ObjectExpression: {
|
|
6658
6710
|
return inner.properties.every((prop) => {
|
|
6659
|
-
if (prop.type !==
|
|
6711
|
+
if (prop.type !== import_utils48.AST_NODE_TYPES.Property) {
|
|
6660
6712
|
return false;
|
|
6661
6713
|
}
|
|
6662
6714
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6663
6715
|
return false;
|
|
6664
6716
|
}
|
|
6665
|
-
if (prop.computed && prop.key.type !==
|
|
6717
|
+
if (prop.computed && prop.key.type !== import_utils48.AST_NODE_TYPES.Literal) {
|
|
6666
6718
|
return false;
|
|
6667
6719
|
}
|
|
6668
6720
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6675,7 +6727,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6675
6727
|
}
|
|
6676
6728
|
function unwrapObjectFreeze(node) {
|
|
6677
6729
|
const inner = unwrap3(node);
|
|
6678
|
-
if (inner.type ===
|
|
6730
|
+
if (inner.type === import_utils48.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils48.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils48.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils48.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils48.AST_NODE_TYPES.SpreadElement) {
|
|
6679
6731
|
return unwrap3(inner.arguments[0]);
|
|
6680
6732
|
}
|
|
6681
6733
|
return inner;
|
|
@@ -6691,19 +6743,19 @@ function classify(init, checkRegex) {
|
|
|
6691
6743
|
}
|
|
6692
6744
|
return { kind: "regex", size: 1 };
|
|
6693
6745
|
}
|
|
6694
|
-
if (node.type ===
|
|
6746
|
+
if (node.type === import_utils48.AST_NODE_TYPES.ArrayExpression) {
|
|
6695
6747
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6696
6748
|
}
|
|
6697
|
-
if (node.type ===
|
|
6749
|
+
if (node.type === import_utils48.AST_NODE_TYPES.ObjectExpression) {
|
|
6698
6750
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6699
6751
|
}
|
|
6700
|
-
if (node.type ===
|
|
6752
|
+
if (node.type === import_utils48.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils48.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6701
6753
|
const arg = node.arguments[0];
|
|
6702
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6754
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils48.AST_NODE_TYPES.SpreadElement) {
|
|
6703
6755
|
return null;
|
|
6704
6756
|
}
|
|
6705
6757
|
const entries = unwrap3(arg);
|
|
6706
|
-
if (entries.type !==
|
|
6758
|
+
if (entries.type !== import_utils48.AST_NODE_TYPES.ArrayExpression) {
|
|
6707
6759
|
return null;
|
|
6708
6760
|
}
|
|
6709
6761
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6732,10 +6784,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6732
6784
|
);
|
|
6733
6785
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6734
6786
|
const callee = node.callee;
|
|
6735
|
-
if (callee.type ===
|
|
6787
|
+
if (callee.type === import_utils48.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6736
6788
|
return true;
|
|
6737
6789
|
}
|
|
6738
|
-
if (callee.type !==
|
|
6790
|
+
if (callee.type !== import_utils48.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils48.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6739
6791
|
return false;
|
|
6740
6792
|
}
|
|
6741
6793
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6749,38 +6801,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6749
6801
|
}
|
|
6750
6802
|
function isSafeRead(identifier) {
|
|
6751
6803
|
const parent = identifier.parent;
|
|
6752
|
-
if (parent.type ===
|
|
6804
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.MemberExpression) {
|
|
6753
6805
|
if (parent.object !== identifier) {
|
|
6754
6806
|
return true;
|
|
6755
6807
|
}
|
|
6756
6808
|
const grandparent = parent.parent;
|
|
6757
|
-
if (grandparent.type ===
|
|
6809
|
+
if (grandparent.type === import_utils48.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6758
6810
|
return false;
|
|
6759
6811
|
}
|
|
6760
|
-
if (grandparent.type ===
|
|
6812
|
+
if (grandparent.type === import_utils48.AST_NODE_TYPES.UpdateExpression) {
|
|
6761
6813
|
return false;
|
|
6762
6814
|
}
|
|
6763
|
-
if (grandparent.type ===
|
|
6815
|
+
if (grandparent.type === import_utils48.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6764
6816
|
return false;
|
|
6765
6817
|
}
|
|
6766
|
-
if (!parent.computed && parent.property.type ===
|
|
6818
|
+
if (!parent.computed && parent.property.type === import_utils48.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils48.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6767
6819
|
return false;
|
|
6768
6820
|
}
|
|
6769
6821
|
return true;
|
|
6770
6822
|
}
|
|
6771
|
-
if (parent.type ===
|
|
6823
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6772
6824
|
return true;
|
|
6773
6825
|
}
|
|
6774
|
-
if (parent.type ===
|
|
6826
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.SpreadElement) {
|
|
6775
6827
|
return true;
|
|
6776
6828
|
}
|
|
6777
|
-
if (parent.type ===
|
|
6829
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.BinaryExpression) {
|
|
6778
6830
|
return true;
|
|
6779
6831
|
}
|
|
6780
|
-
if (parent.type ===
|
|
6832
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6781
6833
|
return true;
|
|
6782
6834
|
}
|
|
6783
|
-
if (parent.type ===
|
|
6835
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6784
6836
|
return true;
|
|
6785
6837
|
}
|
|
6786
6838
|
return false;
|
|
@@ -6835,7 +6887,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6835
6887
|
if (reference.isWrite()) {
|
|
6836
6888
|
return false;
|
|
6837
6889
|
}
|
|
6838
|
-
if (reference.identifier.type !==
|
|
6890
|
+
if (reference.identifier.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6839
6891
|
return false;
|
|
6840
6892
|
}
|
|
6841
6893
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6847,10 +6899,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6847
6899
|
return {
|
|
6848
6900
|
VariableDeclarator(node) {
|
|
6849
6901
|
const declaration = node.parent;
|
|
6850
|
-
if (declaration.type !==
|
|
6902
|
+
if (declaration.type !== import_utils48.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6851
6903
|
return;
|
|
6852
6904
|
}
|
|
6853
|
-
if (node.id.type !==
|
|
6905
|
+
if (node.id.type !== import_utils48.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6854
6906
|
return;
|
|
6855
6907
|
}
|
|
6856
6908
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6877,7 +6929,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6877
6929
|
});
|
|
6878
6930
|
|
|
6879
6931
|
// src/rules/prefer-module-level-schema.ts
|
|
6880
|
-
var
|
|
6932
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
6881
6933
|
|
|
6882
6934
|
// src/rules/_zod.ts
|
|
6883
6935
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6943,9 +6995,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6943
6995
|
"intl"
|
|
6944
6996
|
]);
|
|
6945
6997
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6998
|
+
import_utils49.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
6999
|
+
import_utils49.AST_NODE_TYPES.FunctionDeclaration,
|
|
7000
|
+
import_utils49.AST_NODE_TYPES.FunctionExpression
|
|
6949
7001
|
]);
|
|
6950
7002
|
function schemaExpression(node) {
|
|
6951
7003
|
let current = node;
|
|
@@ -6954,10 +7006,10 @@ function schemaExpression(node) {
|
|
|
6954
7006
|
if (parent === void 0) {
|
|
6955
7007
|
return current;
|
|
6956
7008
|
}
|
|
6957
|
-
if (parent.type ===
|
|
7009
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils49.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6958
7010
|
return current;
|
|
6959
7011
|
}
|
|
6960
|
-
if (parent.type ===
|
|
7012
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils49.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
6961
7013
|
current = parent;
|
|
6962
7014
|
continue;
|
|
6963
7015
|
}
|
|
@@ -7008,22 +7060,22 @@ function subtreeSome(root, predicate) {
|
|
|
7008
7060
|
function readsReceiver(node) {
|
|
7009
7061
|
return subtreeSome(
|
|
7010
7062
|
node,
|
|
7011
|
-
(inner) => inner.type ===
|
|
7063
|
+
(inner) => inner.type === import_utils49.AST_NODE_TYPES.ThisExpression || inner.type === import_utils49.AST_NODE_TYPES.Super || inner.type === import_utils49.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
7012
7064
|
);
|
|
7013
7065
|
}
|
|
7014
7066
|
function buildsLocalizedText(node) {
|
|
7015
7067
|
return subtreeSome(node, (inner) => {
|
|
7016
|
-
if (inner.type ===
|
|
7068
|
+
if (inner.type === import_utils49.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
7017
7069
|
return true;
|
|
7018
7070
|
}
|
|
7019
|
-
if (inner.type !==
|
|
7071
|
+
if (inner.type !== import_utils49.AST_NODE_TYPES.CallExpression) {
|
|
7020
7072
|
return false;
|
|
7021
7073
|
}
|
|
7022
7074
|
const { callee } = inner;
|
|
7023
|
-
if (callee.type ===
|
|
7075
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7024
7076
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7025
7077
|
}
|
|
7026
|
-
return callee.type ===
|
|
7078
|
+
return callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
7027
7079
|
});
|
|
7028
7080
|
}
|
|
7029
7081
|
function collectReferences(scope, out) {
|
|
@@ -7080,15 +7132,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7080
7132
|
}
|
|
7081
7133
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7082
7134
|
function isZodCall(node) {
|
|
7083
|
-
return node.type ===
|
|
7135
|
+
return node.type === import_utils49.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
7084
7136
|
}
|
|
7085
7137
|
function isCovered(node) {
|
|
7086
7138
|
let current = node.parent ?? void 0;
|
|
7087
7139
|
while (current !== void 0) {
|
|
7088
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7140
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
7089
7141
|
return true;
|
|
7090
7142
|
}
|
|
7091
|
-
if (current.type ===
|
|
7143
|
+
if (current.type === import_utils49.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils49.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
7092
7144
|
return true;
|
|
7093
7145
|
}
|
|
7094
7146
|
current = current.parent ?? void 0;
|
|
@@ -7103,11 +7155,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7103
7155
|
if (parent === void 0) {
|
|
7104
7156
|
return confirmed;
|
|
7105
7157
|
}
|
|
7106
|
-
if (parent.type ===
|
|
7158
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils49.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils49.AST_NODE_TYPES.ArrayExpression) {
|
|
7107
7159
|
current = parent;
|
|
7108
7160
|
continue;
|
|
7109
7161
|
}
|
|
7110
|
-
if (parent.type ===
|
|
7162
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7111
7163
|
current = schemaExpression(parent);
|
|
7112
7164
|
confirmed = current;
|
|
7113
7165
|
continue;
|
|
@@ -7117,7 +7169,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7117
7169
|
}
|
|
7118
7170
|
function isSchemaComposition(node) {
|
|
7119
7171
|
const { callee } = node;
|
|
7120
|
-
const isCombinator = callee.type ===
|
|
7172
|
+
const isCombinator = callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7121
7173
|
return isCombinator || isZodCall(node);
|
|
7122
7174
|
}
|
|
7123
7175
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7151,13 +7203,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7151
7203
|
}
|
|
7152
7204
|
function ownerName(enclosing) {
|
|
7153
7205
|
const parent = enclosing.parent ?? void 0;
|
|
7154
|
-
if (enclosing.type ===
|
|
7206
|
+
if (enclosing.type === import_utils49.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
7155
7207
|
return enclosing.id.name;
|
|
7156
7208
|
}
|
|
7157
|
-
if (parent !== void 0 && parent.type ===
|
|
7209
|
+
if (parent !== void 0 && parent.type === import_utils49.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7158
7210
|
return parent.id.name;
|
|
7159
7211
|
}
|
|
7160
|
-
if (parent !== void 0 && (parent.type ===
|
|
7212
|
+
if (parent !== void 0 && (parent.type === import_utils49.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils49.AST_NODE_TYPES.Property) && parent.key.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7161
7213
|
return parent.key.name;
|
|
7162
7214
|
}
|
|
7163
7215
|
return "this function";
|
|
@@ -7168,7 +7220,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7168
7220
|
return;
|
|
7169
7221
|
}
|
|
7170
7222
|
for (const specifier of node.specifiers) {
|
|
7171
|
-
if (specifier.type ===
|
|
7223
|
+
if (specifier.type === import_utils49.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils49.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils49.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils49.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
7172
7224
|
zodNamespaces.add(specifier.local.name);
|
|
7173
7225
|
}
|
|
7174
7226
|
}
|
|
@@ -7178,7 +7230,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7178
7230
|
return;
|
|
7179
7231
|
}
|
|
7180
7232
|
const callee = node.callee;
|
|
7181
|
-
if (callee.property.type !==
|
|
7233
|
+
if (callee.property.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7182
7234
|
return;
|
|
7183
7235
|
}
|
|
7184
7236
|
const factory = callee.property.name;
|
|
@@ -7193,7 +7245,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7193
7245
|
return;
|
|
7194
7246
|
}
|
|
7195
7247
|
const shape = node.arguments[0];
|
|
7196
|
-
if (shape !== void 0 && shape.type ===
|
|
7248
|
+
if (shape !== void 0 && shape.type === import_utils49.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
7197
7249
|
return;
|
|
7198
7250
|
}
|
|
7199
7251
|
const expression = schemaExpression(node);
|
|
@@ -7221,20 +7273,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7221
7273
|
});
|
|
7222
7274
|
|
|
7223
7275
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7224
|
-
var
|
|
7276
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7225
7277
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7226
7278
|
function propertyName(node) {
|
|
7227
7279
|
const key = node.key;
|
|
7228
|
-
if (key.type ===
|
|
7229
|
-
if (key.type ===
|
|
7280
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Identifier) return key.name;
|
|
7281
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Literal) return String(key.value);
|
|
7230
7282
|
return "collection";
|
|
7231
7283
|
}
|
|
7232
7284
|
function isArrayType(node) {
|
|
7233
|
-
if (node.type ===
|
|
7234
|
-
return node.type ===
|
|
7285
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TSArrayType) return true;
|
|
7286
|
+
return node.type === import_utils50.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils50.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7235
7287
|
}
|
|
7236
7288
|
function isNullishType(node) {
|
|
7237
|
-
return node.type ===
|
|
7289
|
+
return node.type === import_utils50.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils50.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7238
7290
|
}
|
|
7239
7291
|
function isNullableArrayOnly(node) {
|
|
7240
7292
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7262,7 +7314,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7262
7314
|
if (node.optional) return;
|
|
7263
7315
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7264
7316
|
if (annotation === void 0) return;
|
|
7265
|
-
if (annotation.type !==
|
|
7317
|
+
if (annotation.type !== import_utils50.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7266
7318
|
return;
|
|
7267
7319
|
}
|
|
7268
7320
|
context.report({
|
|
@@ -7275,7 +7327,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7275
7327
|
TSPropertySignature: checkOptionalProperty,
|
|
7276
7328
|
PropertyDefinition: checkOptionalProperty,
|
|
7277
7329
|
TSTypeAliasDeclaration(node) {
|
|
7278
|
-
if (node.typeAnnotation.type !==
|
|
7330
|
+
if (node.typeAnnotation.type !== import_utils50.AST_NODE_TYPES.TSUnionType) return;
|
|
7279
7331
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7280
7332
|
context.report({
|
|
7281
7333
|
node,
|
|
@@ -7288,9 +7340,9 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7288
7340
|
});
|
|
7289
7341
|
|
|
7290
7342
|
// src/rules/prefer-native-random-uuid.ts
|
|
7291
|
-
var
|
|
7343
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7292
7344
|
function requireUuid(node) {
|
|
7293
|
-
return node?.type ===
|
|
7345
|
+
return node?.type === import_utils51.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils51.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === import_utils51.AST_NODE_TYPES.Literal && node.arguments[0].value === "uuid";
|
|
7294
7346
|
}
|
|
7295
7347
|
var prefer_native_random_uuid_default = createRule({
|
|
7296
7348
|
name: "prefer-native-random-uuid",
|
|
@@ -7311,7 +7363,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7311
7363
|
const directBindings = /* @__PURE__ */ new Set();
|
|
7312
7364
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7313
7365
|
function resolve(identifier) {
|
|
7314
|
-
return
|
|
7366
|
+
return import_utils51.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7315
7367
|
}
|
|
7316
7368
|
function record(identifier, destination) {
|
|
7317
7369
|
const variable = resolve(identifier);
|
|
@@ -7333,37 +7385,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7333
7385
|
ImportDeclaration(node) {
|
|
7334
7386
|
if (node.source.value !== "uuid") return;
|
|
7335
7387
|
for (const specifier of node.specifiers) {
|
|
7336
|
-
if (specifier.type ===
|
|
7388
|
+
if (specifier.type === import_utils51.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils51.AST_NODE_TYPES.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7337
7389
|
record(specifier.local, directBindings);
|
|
7338
|
-
} else if (specifier.type ===
|
|
7390
|
+
} else if (specifier.type === import_utils51.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
7339
7391
|
record(specifier.local, namespaceBindings);
|
|
7340
7392
|
}
|
|
7341
7393
|
}
|
|
7342
7394
|
},
|
|
7343
7395
|
VariableDeclarator(node) {
|
|
7344
7396
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7345
|
-
if (node.init?.type !==
|
|
7397
|
+
if (node.init?.type !== import_utils51.AST_NODE_TYPES.CallExpression || node.init.callee.type !== import_utils51.AST_NODE_TYPES.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
7346
7398
|
return;
|
|
7347
7399
|
}
|
|
7348
|
-
if (node.id.type ===
|
|
7400
|
+
if (node.id.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7349
7401
|
record(node.id, namespaceBindings);
|
|
7350
7402
|
return;
|
|
7351
7403
|
}
|
|
7352
|
-
if (node.id.type !==
|
|
7404
|
+
if (node.id.type !== import_utils51.AST_NODE_TYPES.ObjectPattern) return;
|
|
7353
7405
|
for (const property of node.id.properties) {
|
|
7354
|
-
if (property.type ===
|
|
7406
|
+
if (property.type === import_utils51.AST_NODE_TYPES.Property && !property.computed && (property.key.type === import_utils51.AST_NODE_TYPES.Identifier && property.key.name === "v4" || property.key.type === import_utils51.AST_NODE_TYPES.Literal && property.key.value === "v4") && property.value.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7355
7407
|
record(property.value, directBindings);
|
|
7356
7408
|
}
|
|
7357
7409
|
}
|
|
7358
7410
|
},
|
|
7359
7411
|
"CallExpression:exit"(node) {
|
|
7360
7412
|
if (node.arguments.length !== 0) return;
|
|
7361
|
-
if (node.callee.type ===
|
|
7413
|
+
if (node.callee.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7362
7414
|
const variable2 = resolve(node.callee);
|
|
7363
7415
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7364
7416
|
return;
|
|
7365
7417
|
}
|
|
7366
|
-
if (node.callee.type !==
|
|
7418
|
+
if (node.callee.type !== import_utils51.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.object.type !== import_utils51.AST_NODE_TYPES.Identifier || node.callee.property.type !== import_utils51.AST_NODE_TYPES.Identifier || node.callee.property.name !== "v4") {
|
|
7367
7419
|
return;
|
|
7368
7420
|
}
|
|
7369
7421
|
const variable = resolve(node.callee.object);
|
|
@@ -7374,13 +7426,13 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7374
7426
|
});
|
|
7375
7427
|
|
|
7376
7428
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7377
|
-
var
|
|
7429
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7378
7430
|
var unwrap4 = (node) => {
|
|
7379
7431
|
let current = node;
|
|
7380
7432
|
while (current !== null && current !== void 0) {
|
|
7381
|
-
if (current.type ===
|
|
7433
|
+
if (current.type === import_utils52.AST_NODE_TYPES.TSAsExpression || current.type === import_utils52.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils52.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils52.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
7382
7434
|
current = current.expression;
|
|
7383
|
-
} else if (current.type ===
|
|
7435
|
+
} else if (current.type === import_utils52.AST_NODE_TYPES.ChainExpression) {
|
|
7384
7436
|
current = current.expression;
|
|
7385
7437
|
} else {
|
|
7386
7438
|
break;
|
|
@@ -7395,23 +7447,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7395
7447
|
]);
|
|
7396
7448
|
var isSchemaParseReference = (node) => {
|
|
7397
7449
|
const inner = unwrap4(node);
|
|
7398
|
-
return inner !== null && inner.type ===
|
|
7450
|
+
return inner !== null && inner.type === import_utils52.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils52.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7399
7451
|
};
|
|
7400
7452
|
var isRawPayloadSource = (node) => {
|
|
7401
7453
|
let current = unwrap4(node);
|
|
7402
7454
|
if (current === null) return false;
|
|
7403
|
-
if (current.type ===
|
|
7455
|
+
if (current.type === import_utils52.AST_NODE_TYPES.AwaitExpression) {
|
|
7404
7456
|
current = unwrap4(current.argument);
|
|
7405
7457
|
}
|
|
7406
|
-
if (current === null || current.type !==
|
|
7458
|
+
if (current === null || current.type !== import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7407
7459
|
return false;
|
|
7408
7460
|
}
|
|
7409
7461
|
const callee = unwrap4(current.callee);
|
|
7410
|
-
if (callee === null || callee.type !==
|
|
7462
|
+
if (callee === null || callee.type !== import_utils52.AST_NODE_TYPES.MemberExpression) {
|
|
7411
7463
|
return false;
|
|
7412
7464
|
}
|
|
7413
7465
|
const property = unwrap4(callee.property);
|
|
7414
|
-
if (property === null || property.type !==
|
|
7466
|
+
if (property === null || property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7415
7467
|
return false;
|
|
7416
7468
|
}
|
|
7417
7469
|
if (property.name === "json") {
|
|
@@ -7421,16 +7473,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7421
7473
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7422
7474
|
}
|
|
7423
7475
|
const object = unwrap4(callee.object);
|
|
7424
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7476
|
+
return property.name === "parse" && object !== null && object.type === import_utils52.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7425
7477
|
};
|
|
7426
7478
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7427
7479
|
var isLocalFileRead = (node) => {
|
|
7428
7480
|
let found = false;
|
|
7429
7481
|
const visit = (current) => {
|
|
7430
7482
|
if (found || current === null || current === void 0) return;
|
|
7431
|
-
if (current.type ===
|
|
7483
|
+
if (current.type === import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7432
7484
|
const callee = unwrap4(current.callee);
|
|
7433
|
-
const name = callee?.type ===
|
|
7485
|
+
const name = callee?.type === import_utils52.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils52.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils52.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
7434
7486
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7435
7487
|
found = true;
|
|
7436
7488
|
return;
|
|
@@ -7452,15 +7504,15 @@ var isLocalFileRead = (node) => {
|
|
|
7452
7504
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7453
7505
|
var isInsideAssertion = (node) => {
|
|
7454
7506
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7455
|
-
if (current.type !==
|
|
7507
|
+
if (current.type !== import_utils52.AST_NODE_TYPES.CallExpression) continue;
|
|
7456
7508
|
let callee = current.callee;
|
|
7457
|
-
while (callee.type ===
|
|
7509
|
+
while (callee.type === import_utils52.AST_NODE_TYPES.MemberExpression) {
|
|
7458
7510
|
callee = callee.object;
|
|
7459
7511
|
}
|
|
7460
|
-
if (callee.type ===
|
|
7512
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7461
7513
|
callee = callee.callee;
|
|
7462
7514
|
}
|
|
7463
|
-
if (callee.type ===
|
|
7515
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7464
7516
|
return true;
|
|
7465
7517
|
}
|
|
7466
7518
|
}
|
|
@@ -7479,39 +7531,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7479
7531
|
var isValidationRead = (node) => {
|
|
7480
7532
|
let current = node;
|
|
7481
7533
|
let parent = current.parent;
|
|
7482
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7534
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils52.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils52.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils52.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils52.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils52.AST_NODE_TYPES.ChainExpression)) {
|
|
7483
7535
|
current = parent;
|
|
7484
7536
|
parent = parent.parent;
|
|
7485
7537
|
}
|
|
7486
7538
|
if (parent === null || parent === void 0) return false;
|
|
7487
|
-
if (parent.type ===
|
|
7539
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7488
7540
|
return true;
|
|
7489
7541
|
}
|
|
7490
|
-
if (parent.type !==
|
|
7542
|
+
if (parent.type !== import_utils52.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7491
7543
|
return false;
|
|
7492
7544
|
}
|
|
7493
7545
|
const callee = parent.callee;
|
|
7494
|
-
if (callee.type ===
|
|
7546
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils52.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils52.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
7495
7547
|
return parent.arguments.length === 1;
|
|
7496
7548
|
}
|
|
7497
|
-
return callee.type ===
|
|
7549
|
+
return callee.type === import_utils52.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7498
7550
|
};
|
|
7499
7551
|
var isGuardTestPosition = (node) => {
|
|
7500
7552
|
let current = node;
|
|
7501
7553
|
let parent = current.parent;
|
|
7502
7554
|
while (parent !== void 0 && parent !== null) {
|
|
7503
7555
|
switch (parent.type) {
|
|
7504
|
-
case
|
|
7505
|
-
case
|
|
7506
|
-
case
|
|
7556
|
+
case import_utils52.AST_NODE_TYPES.UnaryExpression:
|
|
7557
|
+
case import_utils52.AST_NODE_TYPES.LogicalExpression:
|
|
7558
|
+
case import_utils52.AST_NODE_TYPES.ChainExpression:
|
|
7507
7559
|
current = parent;
|
|
7508
7560
|
parent = parent.parent;
|
|
7509
7561
|
continue;
|
|
7510
|
-
case
|
|
7511
|
-
case
|
|
7512
|
-
case
|
|
7513
|
-
case
|
|
7514
|
-
case
|
|
7562
|
+
case import_utils52.AST_NODE_TYPES.IfStatement:
|
|
7563
|
+
case import_utils52.AST_NODE_TYPES.ConditionalExpression:
|
|
7564
|
+
case import_utils52.AST_NODE_TYPES.WhileStatement:
|
|
7565
|
+
case import_utils52.AST_NODE_TYPES.DoWhileStatement:
|
|
7566
|
+
case import_utils52.AST_NODE_TYPES.ForStatement:
|
|
7515
7567
|
return parent.test === current;
|
|
7516
7568
|
default:
|
|
7517
7569
|
return false;
|
|
@@ -7521,7 +7573,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7521
7573
|
};
|
|
7522
7574
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7523
7575
|
const unwrapped = unwrap4(node);
|
|
7524
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7576
|
+
if (unwrapped === null || unwrapped.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7525
7577
|
return false;
|
|
7526
7578
|
}
|
|
7527
7579
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7564,11 +7616,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7564
7616
|
return {
|
|
7565
7617
|
VariableDeclarator(node) {
|
|
7566
7618
|
const scope = context.sourceCode.getScope(node);
|
|
7567
|
-
if (node.id.type ===
|
|
7619
|
+
if (node.id.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7568
7620
|
trackInitializer(node);
|
|
7569
7621
|
return;
|
|
7570
7622
|
}
|
|
7571
|
-
if (node.id.type ===
|
|
7623
|
+
if (node.id.type === import_utils52.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils52.AST_NODE_TYPES.ArrayPattern) {
|
|
7572
7624
|
if (isRawPayloadSource(node.init)) {
|
|
7573
7625
|
if (!isFullyNarrowedPattern(node)) {
|
|
7574
7626
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7582,7 +7634,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7582
7634
|
},
|
|
7583
7635
|
AssignmentExpression(node) {
|
|
7584
7636
|
const scope = context.sourceCode.getScope(node);
|
|
7585
|
-
if (node.left.type ===
|
|
7637
|
+
if (node.left.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7586
7638
|
const variable = findVariable2(scope, node.left.name);
|
|
7587
7639
|
if (variable === null) return;
|
|
7588
7640
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7592,7 +7644,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7592
7644
|
}
|
|
7593
7645
|
return;
|
|
7594
7646
|
}
|
|
7595
|
-
if (node.left.type ===
|
|
7647
|
+
if (node.left.type === import_utils52.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils52.AST_NODE_TYPES.ArrayPattern) {
|
|
7596
7648
|
if (isRawPayloadSource(node.right)) {
|
|
7597
7649
|
context.report({
|
|
7598
7650
|
node: node.left,
|
|
@@ -7609,15 +7661,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7609
7661
|
}
|
|
7610
7662
|
},
|
|
7611
7663
|
CallExpression(node) {
|
|
7612
|
-
if (node.callee.type !==
|
|
7664
|
+
if (node.callee.type !== import_utils52.AST_NODE_TYPES.Identifier) return;
|
|
7613
7665
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7614
7666
|
return;
|
|
7615
7667
|
}
|
|
7616
7668
|
const scope = context.sourceCode.getScope(node);
|
|
7617
7669
|
for (const arg of node.arguments) {
|
|
7618
|
-
if (arg.type ===
|
|
7670
|
+
if (arg.type === import_utils52.AST_NODE_TYPES.SpreadElement) continue;
|
|
7619
7671
|
const unwrapped = unwrap4(arg);
|
|
7620
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7672
|
+
if (unwrapped === null || unwrapped.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7621
7673
|
continue;
|
|
7622
7674
|
}
|
|
7623
7675
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7631,13 +7683,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7631
7683
|
const obj = unwrap4(node.object);
|
|
7632
7684
|
if (isRawPayloadSource(obj)) {
|
|
7633
7685
|
const parent = node.parent;
|
|
7634
|
-
if (parent.type ===
|
|
7686
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils52.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7635
7687
|
return;
|
|
7636
7688
|
}
|
|
7637
7689
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7638
7690
|
return;
|
|
7639
7691
|
}
|
|
7640
|
-
if (obj !== null && obj.type ===
|
|
7692
|
+
if (obj !== null && obj.type === import_utils52.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7641
7693
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7642
7694
|
const variable = findVariable2(scope, obj.name);
|
|
7643
7695
|
if (variable !== null) {
|
|
@@ -7650,7 +7702,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7650
7702
|
});
|
|
7651
7703
|
|
|
7652
7704
|
// src/rules/prefer-semantic-colors.ts
|
|
7653
|
-
var
|
|
7705
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7654
7706
|
var import_fs = require("fs");
|
|
7655
7707
|
var import_path = require("path");
|
|
7656
7708
|
|
|
@@ -7750,8 +7802,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7750
7802
|
]);
|
|
7751
7803
|
function jsxElementName(node) {
|
|
7752
7804
|
const name = node.openingElement.name;
|
|
7753
|
-
if (name.type ===
|
|
7754
|
-
if (name.type ===
|
|
7805
|
+
if (name.type === import_utils53.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
7806
|
+
if (name.type === import_utils53.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils53.AST_NODE_TYPES.JSXIdentifier) {
|
|
7755
7807
|
return name.property.name;
|
|
7756
7808
|
}
|
|
7757
7809
|
return null;
|
|
@@ -7777,7 +7829,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7777
7829
|
var isInsideSvg = (node) => {
|
|
7778
7830
|
let current = node.parent;
|
|
7779
7831
|
while (current !== void 0 && current !== null) {
|
|
7780
|
-
if (current.type ===
|
|
7832
|
+
if (current.type === import_utils53.AST_NODE_TYPES.JSXElement) {
|
|
7781
7833
|
const name = jsxElementName(current);
|
|
7782
7834
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7783
7835
|
}
|
|
@@ -7788,7 +7840,7 @@ var isInsideSvg = (node) => {
|
|
|
7788
7840
|
var isInsideIconFactoryPath = (node) => {
|
|
7789
7841
|
let current = node.parent;
|
|
7790
7842
|
while (current !== void 0 && current !== null) {
|
|
7791
|
-
if (current.type ===
|
|
7843
|
+
if (current.type === import_utils53.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils53.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils53.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils53.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7792
7844
|
return true;
|
|
7793
7845
|
}
|
|
7794
7846
|
current = current.parent;
|
|
@@ -7925,12 +7977,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7925
7977
|
return root !== null && workspaceHasMarker(root);
|
|
7926
7978
|
};
|
|
7927
7979
|
var propName = (key) => {
|
|
7928
|
-
if (key.type ===
|
|
7929
|
-
if (key.type ===
|
|
7980
|
+
if (key.type === import_utils53.AST_NODE_TYPES.Identifier) return key.name;
|
|
7981
|
+
if (key.type === import_utils53.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
7930
7982
|
return null;
|
|
7931
7983
|
};
|
|
7932
7984
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7933
|
-
if (statement.type !==
|
|
7985
|
+
if (statement.type !== import_utils53.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils53.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils53.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
7934
7986
|
return false;
|
|
7935
7987
|
}
|
|
7936
7988
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -7982,27 +8034,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7982
8034
|
const checkClassNode = (node) => {
|
|
7983
8035
|
if (node === null) return;
|
|
7984
8036
|
switch (node.type) {
|
|
7985
|
-
case
|
|
8037
|
+
case import_utils53.AST_NODE_TYPES.Literal:
|
|
7986
8038
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7987
8039
|
break;
|
|
7988
|
-
case
|
|
8040
|
+
case import_utils53.AST_NODE_TYPES.TemplateLiteral:
|
|
7989
8041
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7990
8042
|
break;
|
|
7991
|
-
case
|
|
8043
|
+
case import_utils53.AST_NODE_TYPES.ArrayExpression:
|
|
7992
8044
|
for (const element of node.elements) {
|
|
7993
|
-
if (element !== null && element.type !==
|
|
8045
|
+
if (element !== null && element.type !== import_utils53.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
7994
8046
|
}
|
|
7995
8047
|
break;
|
|
7996
|
-
case
|
|
8048
|
+
case import_utils53.AST_NODE_TYPES.ObjectExpression:
|
|
7997
8049
|
for (const property of node.properties) {
|
|
7998
|
-
if (property.type ===
|
|
8050
|
+
if (property.type === import_utils53.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
7999
8051
|
}
|
|
8000
8052
|
break;
|
|
8001
|
-
case
|
|
8053
|
+
case import_utils53.AST_NODE_TYPES.ConditionalExpression:
|
|
8002
8054
|
checkClassNode(node.consequent);
|
|
8003
8055
|
checkClassNode(node.alternate);
|
|
8004
8056
|
break;
|
|
8005
|
-
case
|
|
8057
|
+
case import_utils53.AST_NODE_TYPES.LogicalExpression:
|
|
8006
8058
|
checkClassNode(node.right);
|
|
8007
8059
|
break;
|
|
8008
8060
|
default:
|
|
@@ -8010,32 +8062,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8010
8062
|
}
|
|
8011
8063
|
};
|
|
8012
8064
|
const checkColorValueNode = (node) => {
|
|
8013
|
-
if (node.type ===
|
|
8065
|
+
if (node.type === import_utils53.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
8014
8066
|
report(node, "inlineColor", { value: node.value });
|
|
8015
8067
|
}
|
|
8016
8068
|
};
|
|
8017
8069
|
return {
|
|
8018
8070
|
"JSXAttribute[name.name='className']"(node) {
|
|
8019
8071
|
if (node.value === null) return;
|
|
8020
|
-
if (node.value.type ===
|
|
8021
|
-
else if (node.value.type ===
|
|
8022
|
-
if (node.value.expression.type !==
|
|
8072
|
+
if (node.value.type === import_utils53.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
8073
|
+
else if (node.value.type === import_utils53.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
8074
|
+
if (node.value.expression.type !== import_utils53.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
8023
8075
|
checkClassNode(node.value.expression);
|
|
8024
8076
|
}
|
|
8025
8077
|
}
|
|
8026
8078
|
},
|
|
8027
8079
|
CallExpression(node) {
|
|
8028
|
-
if (node.callee.type ===
|
|
8080
|
+
if (node.callee.type === import_utils53.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils53.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
8029
8081
|
importsEmailOrPdfRenderer = true;
|
|
8030
8082
|
}
|
|
8031
|
-
if (node.callee.type ===
|
|
8083
|
+
if (node.callee.type === import_utils53.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8032
8084
|
for (const arg of node.arguments) {
|
|
8033
|
-
if (arg.type !==
|
|
8085
|
+
if (arg.type !== import_utils53.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
8034
8086
|
}
|
|
8035
8087
|
}
|
|
8036
8088
|
},
|
|
8037
8089
|
VariableDeclarator(node) {
|
|
8038
|
-
if (node.id.type ===
|
|
8090
|
+
if (node.id.type === import_utils53.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8039
8091
|
checkClassNode(node.init);
|
|
8040
8092
|
}
|
|
8041
8093
|
},
|
|
@@ -8045,9 +8097,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8045
8097
|
},
|
|
8046
8098
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8047
8099
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8048
|
-
if (node.value?.type !==
|
|
8100
|
+
if (node.value?.type !== import_utils53.AST_NODE_TYPES.Literal) return;
|
|
8049
8101
|
const owner = node.parent.name;
|
|
8050
|
-
if (owner.type ===
|
|
8102
|
+
if (owner.type === import_utils53.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8051
8103
|
return;
|
|
8052
8104
|
}
|
|
8053
8105
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8061,7 +8113,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8061
8113
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8062
8114
|
},
|
|
8063
8115
|
ImportExpression(node) {
|
|
8064
|
-
if (node.source.type ===
|
|
8116
|
+
if (node.source.type === import_utils53.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8065
8117
|
importsEmailOrPdfRenderer = true;
|
|
8066
8118
|
}
|
|
8067
8119
|
},
|
|
@@ -8074,7 +8126,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8074
8126
|
});
|
|
8075
8127
|
|
|
8076
8128
|
// src/rules/prefer-server-actions.ts
|
|
8077
|
-
var
|
|
8129
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
8078
8130
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
8079
8131
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
8080
8132
|
var SKIP_FILE_REGEX = /(?:\.test\.[jt]sx?$|\.spec\.[jt]sx?$|-(?:test|spec)\.[jt]sx?$|\/tests?\/|\/__tests__\/|\/__testfixtures__\/|\/scripts?\/|\/app\/api\/.*\/route\.[jt]sx?$|\/pages\/api\/)/;
|
|
@@ -8265,7 +8317,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8265
8317
|
});
|
|
8266
8318
|
|
|
8267
8319
|
// src/rules/prefer-string-literal-union.ts
|
|
8268
|
-
var
|
|
8320
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8269
8321
|
var ts2 = __toESM(require("typescript"), 1);
|
|
8270
8322
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
8271
8323
|
"status",
|
|
@@ -8308,19 +8360,19 @@ function isChoiceLikeName(name) {
|
|
|
8308
8360
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8309
8361
|
}
|
|
8310
8362
|
function keyName(key) {
|
|
8311
|
-
if (key.type ===
|
|
8363
|
+
if (key.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8312
8364
|
return key.name;
|
|
8313
8365
|
}
|
|
8314
|
-
if (key.type ===
|
|
8366
|
+
if (key.type === import_utils55.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
8315
8367
|
return key.value;
|
|
8316
8368
|
}
|
|
8317
8369
|
return null;
|
|
8318
8370
|
}
|
|
8319
8371
|
function isStringLiteralMember(t) {
|
|
8320
|
-
return t.type ===
|
|
8372
|
+
return t.type === import_utils55.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils55.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
8321
8373
|
}
|
|
8322
8374
|
function isStringLiteralUnion(node) {
|
|
8323
|
-
if (node?.type !==
|
|
8375
|
+
if (node?.type !== import_utils55.AST_NODE_TYPES.TSUnionType) {
|
|
8324
8376
|
return false;
|
|
8325
8377
|
}
|
|
8326
8378
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8349,12 +8401,12 @@ function bindingSourceExpression(decl) {
|
|
|
8349
8401
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8350
8402
|
}
|
|
8351
8403
|
function refKey(node) {
|
|
8352
|
-
if (node.type ===
|
|
8404
|
+
if (node.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8353
8405
|
return node.name;
|
|
8354
8406
|
}
|
|
8355
|
-
if (node.type ===
|
|
8407
|
+
if (node.type === import_utils55.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
8356
8408
|
const inner = refKey(node.object);
|
|
8357
|
-
if (inner === null || node.property.type !==
|
|
8409
|
+
if (inner === null || node.property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8358
8410
|
return null;
|
|
8359
8411
|
}
|
|
8360
8412
|
return `${inner}.${node.property.name}`;
|
|
@@ -8362,7 +8414,7 @@ function refKey(node) {
|
|
|
8362
8414
|
return null;
|
|
8363
8415
|
}
|
|
8364
8416
|
function strLiteral(node) {
|
|
8365
|
-
if (node.type ===
|
|
8417
|
+
if (node.type === import_utils55.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
8366
8418
|
return node.value;
|
|
8367
8419
|
}
|
|
8368
8420
|
return null;
|
|
@@ -8403,7 +8455,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8403
8455
|
);
|
|
8404
8456
|
let services;
|
|
8405
8457
|
try {
|
|
8406
|
-
services =
|
|
8458
|
+
services = import_utils55.ESLintUtils.getParserServices(context);
|
|
8407
8459
|
} catch {
|
|
8408
8460
|
services = null;
|
|
8409
8461
|
}
|
|
@@ -8515,7 +8567,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8515
8567
|
containersWithUnion.add(container);
|
|
8516
8568
|
return;
|
|
8517
8569
|
}
|
|
8518
|
-
if (typeNode?.type !==
|
|
8570
|
+
if (typeNode?.type !== import_utils55.AST_NODE_TYPES.TSStringKeyword) {
|
|
8519
8571
|
return;
|
|
8520
8572
|
}
|
|
8521
8573
|
const name = keyName(key);
|
|
@@ -8603,10 +8655,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8603
8655
|
}
|
|
8604
8656
|
};
|
|
8605
8657
|
function refKeyText(node) {
|
|
8606
|
-
if (node.type ===
|
|
8658
|
+
if (node.type === import_utils55.AST_NODE_TYPES.BinaryExpression) {
|
|
8607
8659
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8608
8660
|
}
|
|
8609
|
-
if (node.type ===
|
|
8661
|
+
if (node.type === import_utils55.AST_NODE_TYPES.SwitchStatement) {
|
|
8610
8662
|
return refKey(node.discriminant) ?? "value";
|
|
8611
8663
|
}
|
|
8612
8664
|
return "value";
|
|
@@ -8615,7 +8667,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8615
8667
|
});
|
|
8616
8668
|
|
|
8617
8669
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8618
|
-
var
|
|
8670
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8619
8671
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8620
8672
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8621
8673
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8624,11 +8676,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8624
8676
|
var MIN_RUN_LENGTH = 2;
|
|
8625
8677
|
function literalText(node, getText) {
|
|
8626
8678
|
switch (node.type) {
|
|
8627
|
-
case
|
|
8679
|
+
case import_utils56.AST_NODE_TYPES.Literal:
|
|
8628
8680
|
return "regex" in node ? null : getText(node);
|
|
8629
|
-
case
|
|
8681
|
+
case import_utils56.AST_NODE_TYPES.TemplateLiteral:
|
|
8630
8682
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8631
|
-
case
|
|
8683
|
+
case import_utils56.AST_NODE_TYPES.UnaryExpression:
|
|
8632
8684
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8633
8685
|
default:
|
|
8634
8686
|
return null;
|
|
@@ -8636,15 +8688,15 @@ function literalText(node, getText) {
|
|
|
8636
8688
|
}
|
|
8637
8689
|
function isPureReceiver(node) {
|
|
8638
8690
|
switch (node.type) {
|
|
8639
|
-
case
|
|
8640
|
-
case
|
|
8691
|
+
case import_utils56.AST_NODE_TYPES.Identifier:
|
|
8692
|
+
case import_utils56.AST_NODE_TYPES.ThisExpression:
|
|
8641
8693
|
return true;
|
|
8642
|
-
case
|
|
8694
|
+
case import_utils56.AST_NODE_TYPES.MemberExpression:
|
|
8643
8695
|
if (node.optional) {
|
|
8644
8696
|
return false;
|
|
8645
8697
|
}
|
|
8646
8698
|
if (node.computed) {
|
|
8647
|
-
return node.property.type ===
|
|
8699
|
+
return node.property.type === import_utils56.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8648
8700
|
}
|
|
8649
8701
|
return isPureReceiver(node.object);
|
|
8650
8702
|
default:
|
|
@@ -8652,7 +8704,7 @@ function isPureReceiver(node) {
|
|
|
8652
8704
|
}
|
|
8653
8705
|
}
|
|
8654
8706
|
function literalIndex(node) {
|
|
8655
|
-
if (node.type !==
|
|
8707
|
+
if (node.type !== import_utils56.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8656
8708
|
return null;
|
|
8657
8709
|
}
|
|
8658
8710
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8678,24 +8730,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8678
8730
|
}
|
|
8679
8731
|
const { sourceCode } = context;
|
|
8680
8732
|
function parseAssertion(statement) {
|
|
8681
|
-
if (statement.type !==
|
|
8733
|
+
if (statement.type !== import_utils56.AST_NODE_TYPES.ExpressionStatement) {
|
|
8682
8734
|
return null;
|
|
8683
8735
|
}
|
|
8684
8736
|
const call = statement.expression;
|
|
8685
|
-
if (call.type !==
|
|
8737
|
+
if (call.type !== import_utils56.AST_NODE_TYPES.CallExpression) {
|
|
8686
8738
|
return null;
|
|
8687
8739
|
}
|
|
8688
8740
|
const callee = call.callee;
|
|
8689
|
-
if (callee.type !==
|
|
8741
|
+
if (callee.type !== import_utils56.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8690
8742
|
return null;
|
|
8691
8743
|
}
|
|
8692
8744
|
const matcher = callee.property.name;
|
|
8693
8745
|
const expectCall = callee.object;
|
|
8694
|
-
if (expectCall.type !==
|
|
8746
|
+
if (expectCall.type !== import_utils56.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils56.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8695
8747
|
return null;
|
|
8696
8748
|
}
|
|
8697
8749
|
const actual = expectCall.arguments[0];
|
|
8698
|
-
if (actual === void 0 || actual.type !==
|
|
8750
|
+
if (actual === void 0 || actual.type !== import_utils56.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8699
8751
|
return null;
|
|
8700
8752
|
}
|
|
8701
8753
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8709,7 +8761,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8709
8761
|
}
|
|
8710
8762
|
key = { kind: "index", index };
|
|
8711
8763
|
} else {
|
|
8712
|
-
if (actual.property.type !==
|
|
8764
|
+
if (actual.property.type !== import_utils56.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8713
8765
|
return null;
|
|
8714
8766
|
}
|
|
8715
8767
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8721,7 +8773,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8721
8773
|
return null;
|
|
8722
8774
|
}
|
|
8723
8775
|
const expected = call.arguments[0];
|
|
8724
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8776
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils56.AST_NODE_TYPES.SpreadElement) {
|
|
8725
8777
|
return null;
|
|
8726
8778
|
}
|
|
8727
8779
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8836,7 +8888,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8836
8888
|
});
|
|
8837
8889
|
|
|
8838
8890
|
// src/rules/prefer-zod-enum.ts
|
|
8839
|
-
var
|
|
8891
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8840
8892
|
var prefer_zod_enum_default = createRule({
|
|
8841
8893
|
name: "prefer-zod-enum",
|
|
8842
8894
|
meta: {
|
|
@@ -8856,25 +8908,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
8856
8908
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8857
8909
|
function enumValues(node) {
|
|
8858
8910
|
const callee = node.callee;
|
|
8859
|
-
if (callee.type !==
|
|
8911
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils57.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8860
8912
|
return null;
|
|
8861
8913
|
}
|
|
8862
8914
|
const argument = node.arguments[0];
|
|
8863
|
-
if (argument === void 0 || argument.type !==
|
|
8915
|
+
if (argument === void 0 || argument.type !== import_utils57.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
8864
8916
|
return null;
|
|
8865
8917
|
}
|
|
8866
8918
|
const values = [];
|
|
8867
8919
|
let canFix = true;
|
|
8868
8920
|
for (const element of argument.elements) {
|
|
8869
|
-
if (element?.type ===
|
|
8921
|
+
if (element?.type === import_utils57.AST_NODE_TYPES.SpreadElement) {
|
|
8870
8922
|
canFix = false;
|
|
8871
8923
|
continue;
|
|
8872
8924
|
}
|
|
8873
|
-
if (element === null || element.type !==
|
|
8925
|
+
if (element === null || element.type !== import_utils57.AST_NODE_TYPES.CallExpression || element.callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils57.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
8874
8926
|
return null;
|
|
8875
8927
|
}
|
|
8876
8928
|
const value = element.arguments[0];
|
|
8877
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
8929
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== import_utils57.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
8878
8930
|
canFix = false;
|
|
8879
8931
|
continue;
|
|
8880
8932
|
}
|
|
@@ -8884,11 +8936,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
8884
8936
|
}
|
|
8885
8937
|
function buildFix(node, values) {
|
|
8886
8938
|
const argument = node.arguments[0];
|
|
8887
|
-
if (argument === void 0 || argument.type !==
|
|
8939
|
+
if (argument === void 0 || argument.type !== import_utils57.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8888
8940
|
return void 0;
|
|
8889
8941
|
}
|
|
8890
8942
|
const callee = node.callee;
|
|
8891
|
-
if (callee.type !==
|
|
8943
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8892
8944
|
return void 0;
|
|
8893
8945
|
}
|
|
8894
8946
|
return (fixer) => [
|
|
@@ -8905,7 +8957,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8905
8957
|
return;
|
|
8906
8958
|
}
|
|
8907
8959
|
for (const specifier of node.specifiers) {
|
|
8908
|
-
if (specifier.type ===
|
|
8960
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils57.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils57.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils57.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8909
8961
|
zodNamespaces.add(specifier.local.name);
|
|
8910
8962
|
}
|
|
8911
8963
|
}
|
|
@@ -8927,7 +8979,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8927
8979
|
});
|
|
8928
8980
|
|
|
8929
8981
|
// src/rules/prefer-zod-infer.ts
|
|
8930
|
-
var
|
|
8982
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8931
8983
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8932
8984
|
"describe",
|
|
8933
8985
|
"refine",
|
|
@@ -8964,44 +9016,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8964
9016
|
"Schema"
|
|
8965
9017
|
]);
|
|
8966
9018
|
var LEAF_NODE_TYPES = {
|
|
8967
|
-
string: [
|
|
8968
|
-
email: [
|
|
8969
|
-
url: [
|
|
8970
|
-
uuid: [
|
|
8971
|
-
ulid: [
|
|
8972
|
-
cuid: [
|
|
8973
|
-
cuid2: [
|
|
8974
|
-
nanoid: [
|
|
8975
|
-
iso: [
|
|
8976
|
-
number: [
|
|
8977
|
-
int: [
|
|
8978
|
-
float32: [
|
|
8979
|
-
float64: [
|
|
8980
|
-
boolean: [
|
|
8981
|
-
bigint: [
|
|
8982
|
-
symbol: [
|
|
8983
|
-
any: [
|
|
8984
|
-
unknown: [
|
|
8985
|
-
never: [
|
|
8986
|
-
void: [
|
|
8987
|
-
null: [
|
|
8988
|
-
undefined: [
|
|
8989
|
-
literal: [
|
|
8990
|
-
date: [
|
|
8991
|
-
array: [
|
|
8992
|
-
tuple: [
|
|
8993
|
-
object: [
|
|
8994
|
-
strictObject: [
|
|
8995
|
-
looseObject: [
|
|
8996
|
-
record: [
|
|
8997
|
-
map: [
|
|
8998
|
-
set: [
|
|
8999
|
-
promise: [
|
|
9000
|
-
enum: [
|
|
9001
|
-
nativeEnum: [
|
|
9002
|
-
union: [
|
|
9003
|
-
discriminatedUnion: [
|
|
9004
|
-
intersection: [
|
|
9019
|
+
string: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9020
|
+
email: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9021
|
+
url: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9022
|
+
uuid: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9023
|
+
ulid: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9024
|
+
cuid: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9025
|
+
cuid2: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9026
|
+
nanoid: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9027
|
+
iso: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9028
|
+
number: [import_utils58.AST_NODE_TYPES.TSNumberKeyword],
|
|
9029
|
+
int: [import_utils58.AST_NODE_TYPES.TSNumberKeyword],
|
|
9030
|
+
float32: [import_utils58.AST_NODE_TYPES.TSNumberKeyword],
|
|
9031
|
+
float64: [import_utils58.AST_NODE_TYPES.TSNumberKeyword],
|
|
9032
|
+
boolean: [import_utils58.AST_NODE_TYPES.TSBooleanKeyword],
|
|
9033
|
+
bigint: [import_utils58.AST_NODE_TYPES.TSBigIntKeyword],
|
|
9034
|
+
symbol: [import_utils58.AST_NODE_TYPES.TSSymbolKeyword],
|
|
9035
|
+
any: [import_utils58.AST_NODE_TYPES.TSAnyKeyword],
|
|
9036
|
+
unknown: [import_utils58.AST_NODE_TYPES.TSUnknownKeyword],
|
|
9037
|
+
never: [import_utils58.AST_NODE_TYPES.TSNeverKeyword],
|
|
9038
|
+
void: [import_utils58.AST_NODE_TYPES.TSVoidKeyword],
|
|
9039
|
+
null: [import_utils58.AST_NODE_TYPES.TSNullKeyword],
|
|
9040
|
+
undefined: [import_utils58.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
9041
|
+
literal: [import_utils58.AST_NODE_TYPES.TSLiteralType],
|
|
9042
|
+
date: [import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9043
|
+
array: [import_utils58.AST_NODE_TYPES.TSArrayType, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9044
|
+
tuple: [import_utils58.AST_NODE_TYPES.TSTupleType],
|
|
9045
|
+
object: [import_utils58.AST_NODE_TYPES.TSTypeLiteral, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9046
|
+
strictObject: [import_utils58.AST_NODE_TYPES.TSTypeLiteral, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9047
|
+
looseObject: [import_utils58.AST_NODE_TYPES.TSTypeLiteral, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9048
|
+
record: [import_utils58.AST_NODE_TYPES.TSTypeReference, import_utils58.AST_NODE_TYPES.TSTypeLiteral],
|
|
9049
|
+
map: [import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9050
|
+
set: [import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9051
|
+
promise: [import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9052
|
+
enum: [import_utils58.AST_NODE_TYPES.TSUnionType, import_utils58.AST_NODE_TYPES.TSTypeReference, import_utils58.AST_NODE_TYPES.TSLiteralType],
|
|
9053
|
+
nativeEnum: [import_utils58.AST_NODE_TYPES.TSUnionType, import_utils58.AST_NODE_TYPES.TSTypeReference, import_utils58.AST_NODE_TYPES.TSLiteralType],
|
|
9054
|
+
union: [import_utils58.AST_NODE_TYPES.TSUnionType, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9055
|
+
discriminatedUnion: [import_utils58.AST_NODE_TYPES.TSUnionType, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9056
|
+
intersection: [import_utils58.AST_NODE_TYPES.TSIntersectionType, import_utils58.AST_NODE_TYPES.TSTypeReference]
|
|
9005
9057
|
};
|
|
9006
9058
|
function normalizeSchemaName(name) {
|
|
9007
9059
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9010,20 +9062,20 @@ function normalizeTypeName(name) {
|
|
|
9010
9062
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9011
9063
|
}
|
|
9012
9064
|
function unwrapNullish(annotation) {
|
|
9013
|
-
if (annotation.type !==
|
|
9065
|
+
if (annotation.type !== import_utils58.AST_NODE_TYPES.TSUnionType) {
|
|
9014
9066
|
return {
|
|
9015
9067
|
core: annotation,
|
|
9016
|
-
nullable: annotation.type ===
|
|
9068
|
+
nullable: annotation.type === import_utils58.AST_NODE_TYPES.TSNullKeyword
|
|
9017
9069
|
};
|
|
9018
9070
|
}
|
|
9019
9071
|
const rest = [];
|
|
9020
9072
|
let nullable = false;
|
|
9021
9073
|
for (const member of annotation.types) {
|
|
9022
|
-
if (member.type ===
|
|
9074
|
+
if (member.type === import_utils58.AST_NODE_TYPES.TSNullKeyword) {
|
|
9023
9075
|
nullable = true;
|
|
9024
9076
|
continue;
|
|
9025
9077
|
}
|
|
9026
|
-
if (member.type ===
|
|
9078
|
+
if (member.type === import_utils58.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
9027
9079
|
continue;
|
|
9028
9080
|
}
|
|
9029
9081
|
rest.push(member);
|
|
@@ -9088,14 +9140,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9088
9140
|
function zodCallChain(node) {
|
|
9089
9141
|
const chain = [];
|
|
9090
9142
|
let current = node;
|
|
9091
|
-
while (current.type ===
|
|
9143
|
+
while (current.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
9092
9144
|
const callee = current.callee;
|
|
9093
|
-
if (callee.type !==
|
|
9145
|
+
if (callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9094
9146
|
return null;
|
|
9095
9147
|
}
|
|
9096
9148
|
chain.push(current);
|
|
9097
9149
|
const receiver = callee.object;
|
|
9098
|
-
if (receiver.type ===
|
|
9150
|
+
if (receiver.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9099
9151
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9100
9152
|
}
|
|
9101
9153
|
current = receiver;
|
|
@@ -9104,19 +9156,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9104
9156
|
}
|
|
9105
9157
|
function methodName(call) {
|
|
9106
9158
|
const callee = call.callee;
|
|
9107
|
-
return callee.type ===
|
|
9159
|
+
return callee.type === import_utils58.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils58.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
9108
9160
|
}
|
|
9109
9161
|
function schemaField(node) {
|
|
9110
9162
|
const modifiers = [];
|
|
9111
9163
|
let current = node;
|
|
9112
9164
|
let leaf = null;
|
|
9113
|
-
while (current.type ===
|
|
9165
|
+
while (current.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
9114
9166
|
const callee = current.callee;
|
|
9115
|
-
if (callee.type !==
|
|
9167
|
+
if (callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9116
9168
|
break;
|
|
9117
9169
|
}
|
|
9118
9170
|
const receiver = callee.object;
|
|
9119
|
-
if (receiver.type ===
|
|
9171
|
+
if (receiver.type === import_utils58.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9120
9172
|
leaf = callee.property.name;
|
|
9121
9173
|
break;
|
|
9122
9174
|
}
|
|
@@ -9147,16 +9199,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9147
9199
|
return null;
|
|
9148
9200
|
}
|
|
9149
9201
|
const shape = base.arguments[0];
|
|
9150
|
-
if (shape === void 0 || shape.type !==
|
|
9202
|
+
if (shape === void 0 || shape.type !== import_utils58.AST_NODE_TYPES.ObjectExpression) {
|
|
9151
9203
|
return null;
|
|
9152
9204
|
}
|
|
9153
9205
|
const fields = /* @__PURE__ */ new Map();
|
|
9154
9206
|
for (const property of shape.properties) {
|
|
9155
|
-
if (property.type !==
|
|
9207
|
+
if (property.type !== import_utils58.AST_NODE_TYPES.Property || property.computed) {
|
|
9156
9208
|
return null;
|
|
9157
9209
|
}
|
|
9158
9210
|
const { key } = property;
|
|
9159
|
-
const name = key.type ===
|
|
9211
|
+
const name = key.type === import_utils58.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils58.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
9160
9212
|
if (name === null) {
|
|
9161
9213
|
return null;
|
|
9162
9214
|
}
|
|
@@ -9167,11 +9219,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9167
9219
|
function typeMembers(members) {
|
|
9168
9220
|
const result = /* @__PURE__ */ new Map();
|
|
9169
9221
|
for (const member of members) {
|
|
9170
|
-
if (member.type !==
|
|
9222
|
+
if (member.type !== import_utils58.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
9171
9223
|
return null;
|
|
9172
9224
|
}
|
|
9173
9225
|
const { key } = member;
|
|
9174
|
-
const name = key.type ===
|
|
9226
|
+
const name = key.type === import_utils58.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils58.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
9175
9227
|
if (name === null) {
|
|
9176
9228
|
return null;
|
|
9177
9229
|
}
|
|
@@ -9185,8 +9237,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9185
9237
|
return result.size === 0 ? null : result;
|
|
9186
9238
|
}
|
|
9187
9239
|
function collectConstrainedNames(node) {
|
|
9188
|
-
if (node.type ===
|
|
9189
|
-
if (node.typeName.type ===
|
|
9240
|
+
if (node.type === import_utils58.AST_NODE_TYPES.TSTypeReference) {
|
|
9241
|
+
if (node.typeName.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9190
9242
|
constrainedTypeNames.add(node.typeName.name);
|
|
9191
9243
|
}
|
|
9192
9244
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9194,11 +9246,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9194
9246
|
}
|
|
9195
9247
|
return;
|
|
9196
9248
|
}
|
|
9197
|
-
if (node.type ===
|
|
9249
|
+
if (node.type === import_utils58.AST_NODE_TYPES.TSArrayType) {
|
|
9198
9250
|
collectConstrainedNames(node.elementType);
|
|
9199
9251
|
return;
|
|
9200
9252
|
}
|
|
9201
|
-
if (node.type ===
|
|
9253
|
+
if (node.type === import_utils58.AST_NODE_TYPES.TSUnionType || node.type === import_utils58.AST_NODE_TYPES.TSIntersectionType) {
|
|
9202
9254
|
for (const member of node.types) {
|
|
9203
9255
|
collectConstrainedNames(member);
|
|
9204
9256
|
}
|
|
@@ -9242,13 +9294,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9242
9294
|
return;
|
|
9243
9295
|
}
|
|
9244
9296
|
for (const specifier of node.specifiers) {
|
|
9245
|
-
if (specifier.type ===
|
|
9297
|
+
if (specifier.type === import_utils58.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils58.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils58.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils58.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
9246
9298
|
zodNamespaces.add(specifier.local.name);
|
|
9247
9299
|
}
|
|
9248
9300
|
}
|
|
9249
9301
|
},
|
|
9250
9302
|
VariableDeclarator(node) {
|
|
9251
|
-
if (node.id.type !==
|
|
9303
|
+
if (node.id.type !== import_utils58.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
9252
9304
|
return;
|
|
9253
9305
|
}
|
|
9254
9306
|
const fields = schemaFields(node.init);
|
|
@@ -9258,14 +9310,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9258
9310
|
},
|
|
9259
9311
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9260
9312
|
"MemberExpression[computed=false]"(node) {
|
|
9261
|
-
if (node.object.type ===
|
|
9313
|
+
if (node.object.type === import_utils58.AST_NODE_TYPES.Identifier && node.property.type === import_utils58.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9262
9314
|
reshapedSchemaNames.add(node.object.name);
|
|
9263
9315
|
}
|
|
9264
9316
|
},
|
|
9265
9317
|
/** Records every type argument carried by a Zod constraint. */
|
|
9266
9318
|
TSTypeReference(node) {
|
|
9267
9319
|
const { typeName } = node;
|
|
9268
|
-
const referenced = typeName.type ===
|
|
9320
|
+
const referenced = typeName.type === import_utils58.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils58.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils58.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
9269
9321
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9270
9322
|
return;
|
|
9271
9323
|
}
|
|
@@ -9283,7 +9335,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9283
9335
|
}
|
|
9284
9336
|
},
|
|
9285
9337
|
TSTypeAliasDeclaration(node) {
|
|
9286
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9338
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils58.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9287
9339
|
return;
|
|
9288
9340
|
}
|
|
9289
9341
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9328,10 +9380,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9328
9380
|
});
|
|
9329
9381
|
|
|
9330
9382
|
// src/rules/require-assert-never.ts
|
|
9331
|
-
var
|
|
9383
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
9332
9384
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9333
|
-
if (statement.type ===
|
|
9334
|
-
if (statement.type ===
|
|
9385
|
+
if (statement.type === import_utils59.AST_NODE_TYPES.EmptyStatement) return false;
|
|
9386
|
+
if (statement.type === import_utils59.AST_NODE_TYPES.BlockStatement) {
|
|
9335
9387
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9336
9388
|
}
|
|
9337
9389
|
return true;
|
|
@@ -9347,7 +9399,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9347
9399
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9348
9400
|
}
|
|
9349
9401
|
const only = defaultCase.consequent[0];
|
|
9350
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9402
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils59.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
9351
9403
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9352
9404
|
}
|
|
9353
9405
|
return false;
|
|
@@ -9387,7 +9439,7 @@ var require_assert_never_default = createRule({
|
|
|
9387
9439
|
});
|
|
9388
9440
|
|
|
9389
9441
|
// src/rules/require-fetch-timeout.ts
|
|
9390
|
-
var
|
|
9442
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9391
9443
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9392
9444
|
"globalThis",
|
|
9393
9445
|
"window",
|
|
@@ -9403,14 +9455,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9403
9455
|
return false;
|
|
9404
9456
|
}
|
|
9405
9457
|
function initProvablyLacksSignal(init) {
|
|
9406
|
-
if (init.type !==
|
|
9458
|
+
if (init.type !== import_utils60.AST_NODE_TYPES.ObjectExpression) {
|
|
9407
9459
|
return false;
|
|
9408
9460
|
}
|
|
9409
9461
|
for (const prop of init.properties) {
|
|
9410
|
-
if (prop.type ===
|
|
9462
|
+
if (prop.type === import_utils60.AST_NODE_TYPES.SpreadElement) {
|
|
9411
9463
|
return false;
|
|
9412
9464
|
}
|
|
9413
|
-
if (prop.key.type ===
|
|
9465
|
+
if (prop.key.type === import_utils60.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils60.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
9414
9466
|
return false;
|
|
9415
9467
|
}
|
|
9416
9468
|
if (prop.computed) {
|
|
@@ -9420,7 +9472,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9420
9472
|
return true;
|
|
9421
9473
|
}
|
|
9422
9474
|
function isStringish(node) {
|
|
9423
|
-
return node.type ===
|
|
9475
|
+
return node.type === import_utils60.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils60.AST_NODE_TYPES.TemplateLiteral;
|
|
9424
9476
|
}
|
|
9425
9477
|
var require_fetch_timeout_default = createRule({
|
|
9426
9478
|
name: "require-fetch-timeout",
|
|
@@ -9457,14 +9509,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9457
9509
|
}
|
|
9458
9510
|
function resolvesToGlobal(identifier) {
|
|
9459
9511
|
const scope = context.sourceCode.getScope(identifier);
|
|
9460
|
-
const variable =
|
|
9512
|
+
const variable = import_utils60.ASTUtils.findVariable(scope, identifier.name);
|
|
9461
9513
|
return variable === null || variable.defs.length === 0;
|
|
9462
9514
|
}
|
|
9463
9515
|
function isGlobalFetchCall2(callee) {
|
|
9464
|
-
if (callee.type ===
|
|
9516
|
+
if (callee.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9465
9517
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9466
9518
|
}
|
|
9467
|
-
return callee.type ===
|
|
9519
|
+
return callee.type === import_utils60.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils60.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils60.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9468
9520
|
}
|
|
9469
9521
|
return {
|
|
9470
9522
|
CallExpression(node) {
|
|
@@ -9484,7 +9536,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9484
9536
|
});
|
|
9485
9537
|
|
|
9486
9538
|
// src/rules/require-interface-for-injected-service.ts
|
|
9487
|
-
var
|
|
9539
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9488
9540
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9489
9541
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9490
9542
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9492,20 +9544,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9492
9544
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9493
9545
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9494
9546
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9495
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9496
|
-
var qualifiedName = (name) => name.type ===
|
|
9547
|
+
var isExportedClass = (node) => node.parent.type === import_utils61.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils61.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
9548
|
+
var qualifiedName = (name) => name.type === import_utils61.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils61.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9497
9549
|
var readTypeReference = (annotation) => {
|
|
9498
|
-
if (annotation === void 0 || annotation.type !==
|
|
9550
|
+
if (annotation === void 0 || annotation.type !== import_utils61.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9499
9551
|
const { typeName } = annotation;
|
|
9500
|
-
const rightmost = typeName.type ===
|
|
9552
|
+
const rightmost = typeName.type === import_utils61.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils61.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
9501
9553
|
if (rightmost === null) return null;
|
|
9502
9554
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9503
9555
|
};
|
|
9504
9556
|
var namedParameterCollaborator = (annotated) => {
|
|
9505
9557
|
let target = annotated;
|
|
9506
|
-
if (target.type ===
|
|
9507
|
-
if (target.type ===
|
|
9508
|
-
if (target.type !==
|
|
9558
|
+
if (target.type === import_utils61.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
9559
|
+
if (target.type === import_utils61.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9560
|
+
if (target.type !== import_utils61.AST_NODE_TYPES.Identifier) return null;
|
|
9509
9561
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9510
9562
|
if (reference === null) return null;
|
|
9511
9563
|
return { name: target.name, ...reference };
|
|
@@ -9513,8 +9565,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9513
9565
|
var propertySignatureTypes = (members) => {
|
|
9514
9566
|
const types = /* @__PURE__ */ new Map();
|
|
9515
9567
|
for (const member of members) {
|
|
9516
|
-
if (member.type !==
|
|
9517
|
-
if (member.computed || member.key.type !==
|
|
9568
|
+
if (member.type !== import_utils61.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
9569
|
+
if (member.computed || member.key.type !== import_utils61.AST_NODE_TYPES.Identifier) continue;
|
|
9518
9570
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9519
9571
|
if (reference === null) continue;
|
|
9520
9572
|
types.set(member.key.name, reference);
|
|
@@ -9525,18 +9577,18 @@ var fileTypeIndex = (program) => {
|
|
|
9525
9577
|
const objects = /* @__PURE__ */ new Map();
|
|
9526
9578
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9527
9579
|
for (const statement of program.body) {
|
|
9528
|
-
const declaration = statement.type ===
|
|
9529
|
-
if (declaration?.type ===
|
|
9580
|
+
const declaration = statement.type === import_utils61.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9581
|
+
if (declaration?.type === import_utils61.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
9530
9582
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9531
9583
|
continue;
|
|
9532
9584
|
}
|
|
9533
|
-
if (declaration?.type !==
|
|
9585
|
+
if (declaration?.type !== import_utils61.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9534
9586
|
const aliased = declaration.typeAnnotation;
|
|
9535
|
-
if (aliased.type ===
|
|
9587
|
+
if (aliased.type === import_utils61.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils61.AST_NODE_TYPES.TSConstructorType) {
|
|
9536
9588
|
functionAliases.add(declaration.id.name);
|
|
9537
9589
|
continue;
|
|
9538
9590
|
}
|
|
9539
|
-
const literals = aliased.type ===
|
|
9591
|
+
const literals = aliased.type === import_utils61.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils61.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils61.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
9540
9592
|
if (literals.length === 0) continue;
|
|
9541
9593
|
const merged = /* @__PURE__ */ new Map();
|
|
9542
9594
|
for (const literal of literals) {
|
|
@@ -9549,10 +9601,10 @@ var fileTypeIndex = (program) => {
|
|
|
9549
9601
|
return { objects, functionAliases };
|
|
9550
9602
|
};
|
|
9551
9603
|
var bagMemberTypes = (annotation, declared) => {
|
|
9552
|
-
if (annotation.type ===
|
|
9604
|
+
if (annotation.type === import_utils61.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9553
9605
|
return propertySignatureTypes(annotation.members);
|
|
9554
9606
|
}
|
|
9555
|
-
if (annotation.type !==
|
|
9607
|
+
if (annotation.type !== import_utils61.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9556
9608
|
return null;
|
|
9557
9609
|
}
|
|
9558
9610
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9564,11 +9616,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9564
9616
|
if (members === null) return [];
|
|
9565
9617
|
const collaborators = [];
|
|
9566
9618
|
for (const property of pattern.properties) {
|
|
9567
|
-
if (property.type !==
|
|
9568
|
-
if (property.key.type !==
|
|
9619
|
+
if (property.type !== import_utils61.AST_NODE_TYPES.Property || property.computed) continue;
|
|
9620
|
+
if (property.key.type !== import_utils61.AST_NODE_TYPES.Identifier) continue;
|
|
9569
9621
|
const key = property.key.name;
|
|
9570
|
-
const bound = property.value.type ===
|
|
9571
|
-
if (bound.type !==
|
|
9622
|
+
const bound = property.value.type === import_utils61.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
9623
|
+
if (bound.type !== import_utils61.AST_NODE_TYPES.Identifier) continue;
|
|
9572
9624
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9573
9625
|
const reference = members.get(key);
|
|
9574
9626
|
if (reference === void 0) continue;
|
|
@@ -9578,8 +9630,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9578
9630
|
};
|
|
9579
9631
|
var parameterCollaborators = (parameter, declared) => {
|
|
9580
9632
|
let target = parameter;
|
|
9581
|
-
if (target.type ===
|
|
9582
|
-
if (target.type ===
|
|
9633
|
+
if (target.type === import_utils61.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9634
|
+
if (target.type === import_utils61.AST_NODE_TYPES.ObjectPattern) {
|
|
9583
9635
|
return objectPatternCollaborators(target, declared);
|
|
9584
9636
|
}
|
|
9585
9637
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9598,17 +9650,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9598
9650
|
let constructedFields = 0;
|
|
9599
9651
|
if (body2 !== null && body2 !== void 0) {
|
|
9600
9652
|
for (const statement of body2.body) {
|
|
9601
|
-
if (statement.type !==
|
|
9653
|
+
if (statement.type !== import_utils61.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9602
9654
|
const expression = statement.expression;
|
|
9603
|
-
if (expression.type !==
|
|
9655
|
+
if (expression.type !== import_utils61.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils61.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils61.AST_NODE_TYPES.ThisExpression) {
|
|
9604
9656
|
continue;
|
|
9605
9657
|
}
|
|
9606
9658
|
const source = expression.right;
|
|
9607
|
-
if (source.type ===
|
|
9659
|
+
if (source.type === import_utils61.AST_NODE_TYPES.NewExpression) {
|
|
9608
9660
|
constructedFields += 1;
|
|
9609
|
-
} else if (source.type ===
|
|
9661
|
+
} else if (source.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9610
9662
|
storedFrom.add(source.name);
|
|
9611
|
-
} else if (source.type ===
|
|
9663
|
+
} else if (source.type === import_utils61.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9612
9664
|
storedFrom.add(source.object.name);
|
|
9613
9665
|
}
|
|
9614
9666
|
}
|
|
@@ -9616,7 +9668,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9616
9668
|
const collaborators = [];
|
|
9617
9669
|
for (const parameter of ctor.value.params) {
|
|
9618
9670
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9619
|
-
const stored = parameter.type ===
|
|
9671
|
+
const stored = parameter.type === import_utils61.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9620
9672
|
if (!stored) continue;
|
|
9621
9673
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9622
9674
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9650,19 +9702,19 @@ var subtreeHas = (root, found) => {
|
|
|
9650
9702
|
return hit;
|
|
9651
9703
|
};
|
|
9652
9704
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9653
|
-
if (node.type ===
|
|
9705
|
+
if (node.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9654
9706
|
const { callee } = node;
|
|
9655
|
-
if (callee.type ===
|
|
9656
|
-
return callee.type ===
|
|
9707
|
+
if (callee.type === import_utils61.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9708
|
+
return callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9657
9709
|
}
|
|
9658
|
-
return node.type ===
|
|
9710
|
+
return node.type === import_utils61.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils61.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9659
9711
|
});
|
|
9660
9712
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9661
9713
|
var fileInterfaceNames = (program) => {
|
|
9662
9714
|
const names = [];
|
|
9663
9715
|
for (const statement of program.body) {
|
|
9664
|
-
const declaration = statement.type ===
|
|
9665
|
-
if (declaration?.type ===
|
|
9716
|
+
const declaration = statement.type === import_utils61.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9717
|
+
if (declaration?.type === import_utils61.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9666
9718
|
}
|
|
9667
9719
|
return names;
|
|
9668
9720
|
};
|
|
@@ -9680,11 +9732,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9680
9732
|
var publicMethodNames = (body2) => {
|
|
9681
9733
|
const names = [];
|
|
9682
9734
|
for (const member of body2.body) {
|
|
9683
|
-
if (member.type !==
|
|
9735
|
+
if (member.type !== import_utils61.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9684
9736
|
if (member.kind !== "method" || member.static) continue;
|
|
9685
9737
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9686
|
-
if (member.key.type ===
|
|
9687
|
-
if (member.key.type ===
|
|
9738
|
+
if (member.key.type === import_utils61.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
9739
|
+
if (member.key.type === import_utils61.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
9688
9740
|
else names.push("\u2026");
|
|
9689
9741
|
}
|
|
9690
9742
|
return names;
|
|
@@ -9717,7 +9769,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9717
9769
|
if (node.implements.length > 0) return;
|
|
9718
9770
|
if (node.decorators.length > 0) return;
|
|
9719
9771
|
const ctor = node.body.body.find(
|
|
9720
|
-
(member) => member.type ===
|
|
9772
|
+
(member) => member.type === import_utils61.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
9721
9773
|
);
|
|
9722
9774
|
if (ctor === void 0) return;
|
|
9723
9775
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9745,19 +9797,97 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9745
9797
|
}
|
|
9746
9798
|
});
|
|
9747
9799
|
|
|
9800
|
+
// src/rules/require-static-next-matcher.ts
|
|
9801
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
9802
|
+
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
9803
|
+
function unwrapExpression(node) {
|
|
9804
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSAsExpression || node.type === import_utils62.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils62.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils62.AST_NODE_TYPES.TSTypeAssertion) {
|
|
9805
|
+
return unwrapExpression(node.expression);
|
|
9806
|
+
}
|
|
9807
|
+
return node;
|
|
9808
|
+
}
|
|
9809
|
+
function isStaticValue(node) {
|
|
9810
|
+
const value = unwrapExpression(node);
|
|
9811
|
+
if (value.type === import_utils62.AST_NODE_TYPES.Literal) {
|
|
9812
|
+
return true;
|
|
9813
|
+
}
|
|
9814
|
+
if (value.type === import_utils62.AST_NODE_TYPES.TemplateLiteral) {
|
|
9815
|
+
return value.expressions.length === 0;
|
|
9816
|
+
}
|
|
9817
|
+
if (value.type === import_utils62.AST_NODE_TYPES.ArrayExpression) {
|
|
9818
|
+
return value.elements.every(
|
|
9819
|
+
(element) => element !== null && element.type !== import_utils62.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
9820
|
+
);
|
|
9821
|
+
}
|
|
9822
|
+
if (value.type === import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
9823
|
+
return value.properties.every(
|
|
9824
|
+
(property) => property.type === import_utils62.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils62.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
9825
|
+
);
|
|
9826
|
+
}
|
|
9827
|
+
return false;
|
|
9828
|
+
}
|
|
9829
|
+
function propertyName2(property) {
|
|
9830
|
+
if (property.computed) return null;
|
|
9831
|
+
if (property.key.type === import_utils62.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
9832
|
+
return typeof property.key.value === "string" ? property.key.value : null;
|
|
9833
|
+
}
|
|
9834
|
+
var require_static_next_matcher_default = createRule({
|
|
9835
|
+
name: "require-static-next-matcher",
|
|
9836
|
+
meta: {
|
|
9837
|
+
type: "problem",
|
|
9838
|
+
docs: {
|
|
9839
|
+
description: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals."
|
|
9840
|
+
},
|
|
9841
|
+
schema: [],
|
|
9842
|
+
messages: {
|
|
9843
|
+
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."
|
|
9844
|
+
}
|
|
9845
|
+
},
|
|
9846
|
+
defaultOptions: [],
|
|
9847
|
+
create(context) {
|
|
9848
|
+
if (!NEXT_ENTRY_FILE.test(context.filename)) {
|
|
9849
|
+
return {};
|
|
9850
|
+
}
|
|
9851
|
+
return {
|
|
9852
|
+
ExportNamedDeclaration(node) {
|
|
9853
|
+
if (node.declaration?.type !== import_utils62.AST_NODE_TYPES.VariableDeclaration) {
|
|
9854
|
+
return;
|
|
9855
|
+
}
|
|
9856
|
+
for (const declaration of node.declaration.declarations) {
|
|
9857
|
+
if (declaration.id.type !== import_utils62.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
9858
|
+
continue;
|
|
9859
|
+
}
|
|
9860
|
+
const config = unwrapExpression(declaration.init);
|
|
9861
|
+
if (config.type !== import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
9862
|
+
continue;
|
|
9863
|
+
}
|
|
9864
|
+
for (const property of config.properties) {
|
|
9865
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || propertyName2(property) !== "matcher" || property.value.type === import_utils62.AST_NODE_TYPES.AssignmentPattern) {
|
|
9866
|
+
continue;
|
|
9867
|
+
}
|
|
9868
|
+
if (!isStaticValue(property.value)) {
|
|
9869
|
+
context.report({ node: property.value, messageId: "dynamicMatcher" });
|
|
9870
|
+
}
|
|
9871
|
+
}
|
|
9872
|
+
}
|
|
9873
|
+
}
|
|
9874
|
+
};
|
|
9875
|
+
}
|
|
9876
|
+
});
|
|
9877
|
+
|
|
9748
9878
|
// src/rules/require-zod-form-validation.ts
|
|
9749
|
-
var
|
|
9879
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
9750
9880
|
var looksLikeZodSchema = (node) => {
|
|
9751
9881
|
let current = node;
|
|
9752
9882
|
while (true) {
|
|
9753
|
-
if (current.type ===
|
|
9883
|
+
if (current.type === import_utils63.AST_NODE_TYPES.Identifier) {
|
|
9754
9884
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9755
9885
|
}
|
|
9756
|
-
if (current.type ===
|
|
9886
|
+
if (current.type === import_utils63.AST_NODE_TYPES.CallExpression) {
|
|
9757
9887
|
current = current.callee;
|
|
9758
9888
|
continue;
|
|
9759
9889
|
}
|
|
9760
|
-
if (current.type ===
|
|
9890
|
+
if (current.type === import_utils63.AST_NODE_TYPES.MemberExpression) {
|
|
9761
9891
|
current = current.object;
|
|
9762
9892
|
continue;
|
|
9763
9893
|
}
|
|
@@ -9765,23 +9895,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9765
9895
|
}
|
|
9766
9896
|
};
|
|
9767
9897
|
var isZodParseCall = (node) => {
|
|
9768
|
-
if (node.type !==
|
|
9898
|
+
if (node.type !== import_utils63.AST_NODE_TYPES.CallExpression) return false;
|
|
9769
9899
|
const callee = node.callee;
|
|
9770
|
-
if (callee.type !==
|
|
9900
|
+
if (callee.type !== import_utils63.AST_NODE_TYPES.MemberExpression) return false;
|
|
9771
9901
|
if (callee.computed) return false;
|
|
9772
|
-
if (callee.property.type !==
|
|
9902
|
+
if (callee.property.type !== import_utils63.AST_NODE_TYPES.Identifier) return false;
|
|
9773
9903
|
const method = callee.property.name;
|
|
9774
9904
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9775
9905
|
return looksLikeZodSchema(callee.object);
|
|
9776
9906
|
};
|
|
9777
9907
|
var isFormDataMethodCall = (node) => {
|
|
9778
9908
|
let current = node;
|
|
9779
|
-
if (current.type ===
|
|
9909
|
+
if (current.type === import_utils63.AST_NODE_TYPES.AwaitExpression) {
|
|
9780
9910
|
current = current.argument;
|
|
9781
9911
|
}
|
|
9782
|
-
if (current.type !==
|
|
9912
|
+
if (current.type !== import_utils63.AST_NODE_TYPES.CallExpression) return false;
|
|
9783
9913
|
const callee = current.callee;
|
|
9784
|
-
return callee.type ===
|
|
9914
|
+
return callee.type === import_utils63.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils63.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
9785
9915
|
};
|
|
9786
9916
|
var require_zod_form_validation_default = createRule({
|
|
9787
9917
|
name: "require-zod-form-validation",
|
|
@@ -9801,14 +9931,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9801
9931
|
return {};
|
|
9802
9932
|
}
|
|
9803
9933
|
const isFormSourceIdentifier = (node) => {
|
|
9804
|
-
if (node.type !==
|
|
9934
|
+
if (node.type !== import_utils63.AST_NODE_TYPES.Identifier) return false;
|
|
9805
9935
|
if (/formdata/i.test(node.name)) return true;
|
|
9806
9936
|
let scope = context.sourceCode.getScope(node);
|
|
9807
9937
|
while (scope !== null) {
|
|
9808
9938
|
const variable = scope.set.get(node.name);
|
|
9809
9939
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9810
9940
|
const def = variable.defs[0];
|
|
9811
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
9941
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils63.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
9812
9942
|
return isFormDataMethodCall(def.node.init);
|
|
9813
9943
|
}
|
|
9814
9944
|
return false;
|
|
@@ -9819,8 +9949,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9819
9949
|
};
|
|
9820
9950
|
const isFormDataGetCall = (node) => {
|
|
9821
9951
|
const callee = node.callee;
|
|
9822
|
-
if (callee.type !==
|
|
9823
|
-
if (callee.property.type !==
|
|
9952
|
+
if (callee.type !== import_utils63.AST_NODE_TYPES.MemberExpression) return false;
|
|
9953
|
+
if (callee.property.type !== import_utils63.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
9824
9954
|
return false;
|
|
9825
9955
|
}
|
|
9826
9956
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9835,11 +9965,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9835
9965
|
};
|
|
9836
9966
|
const isInstanceofNarrowing = (node) => {
|
|
9837
9967
|
const parent = node.parent;
|
|
9838
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9968
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils63.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils63.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9839
9969
|
};
|
|
9840
9970
|
const boundDeclarator = (node) => {
|
|
9841
9971
|
const parent = node.parent;
|
|
9842
|
-
if (parent.type ===
|
|
9972
|
+
if (parent.type === import_utils63.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils63.AST_NODE_TYPES.Identifier) {
|
|
9843
9973
|
return parent;
|
|
9844
9974
|
}
|
|
9845
9975
|
return null;
|
|
@@ -9867,7 +9997,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
9867
9997
|
});
|
|
9868
9998
|
|
|
9869
9999
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
9870
|
-
var
|
|
10000
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
9871
10001
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
9872
10002
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
9873
10003
|
var INSERT_GATE = /insert/i;
|
|
@@ -9898,7 +10028,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9898
10028
|
});
|
|
9899
10029
|
|
|
9900
10030
|
// src/rules/zod-naming-convention.ts
|
|
9901
|
-
var
|
|
10031
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
9902
10032
|
var CONVENTIONS = {
|
|
9903
10033
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9904
10034
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9923,15 +10053,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9923
10053
|
"registry",
|
|
9924
10054
|
"implement"
|
|
9925
10055
|
]);
|
|
9926
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10056
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils65.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
9927
10057
|
var calleeChainStartsWithZ = (node) => {
|
|
9928
10058
|
let current = node;
|
|
9929
|
-
while (current.type ===
|
|
10059
|
+
while (current.type === import_utils65.AST_NODE_TYPES.MemberExpression) {
|
|
9930
10060
|
const receiver = current.object;
|
|
9931
|
-
if (receiver.type ===
|
|
10061
|
+
if (receiver.type === import_utils65.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
9932
10062
|
return true;
|
|
9933
10063
|
}
|
|
9934
|
-
if (receiver.type ===
|
|
10064
|
+
if (receiver.type === import_utils65.AST_NODE_TYPES.CallExpression) {
|
|
9935
10065
|
current = receiver.callee;
|
|
9936
10066
|
continue;
|
|
9937
10067
|
}
|
|
@@ -9976,13 +10106,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9976
10106
|
VariableDeclarator(node) {
|
|
9977
10107
|
const init = node.init;
|
|
9978
10108
|
if (init === null || init === void 0) return;
|
|
9979
|
-
if (init.type !==
|
|
10109
|
+
if (init.type !== import_utils65.AST_NODE_TYPES.CallExpression) return;
|
|
9980
10110
|
const callee = init.callee;
|
|
9981
|
-
if (callee.type !==
|
|
10111
|
+
if (callee.type !== import_utils65.AST_NODE_TYPES.MemberExpression) return;
|
|
9982
10112
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9983
10113
|
const terminal = terminalMethodName(callee);
|
|
9984
10114
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9985
|
-
if (node.id.type !==
|
|
10115
|
+
if (node.id.type !== import_utils65.AST_NODE_TYPES.Identifier) return;
|
|
9986
10116
|
if (test.test(node.id.name)) return;
|
|
9987
10117
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9988
10118
|
context.report({
|
|
@@ -10062,6 +10192,7 @@ var rules = {
|
|
|
10062
10192
|
"no-enum": no_enum_default,
|
|
10063
10193
|
"no-fat-try-blocks": no_fat_try_blocks_default,
|
|
10064
10194
|
"no-hand-rolled-sleep": no_hand_rolled_sleep_default,
|
|
10195
|
+
"no-hand-rolled-spinner": no_hand_rolled_spinner_default,
|
|
10065
10196
|
"no-insecure-random-id": no_insecure_random_id_default,
|
|
10066
10197
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
10067
10198
|
"no-log-only-catch": no_log_only_catch_default,
|
|
@@ -10107,13 +10238,14 @@ var rules = {
|
|
|
10107
10238
|
"require-assert-never": require_assert_never_default,
|
|
10108
10239
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
10109
10240
|
"require-interface-for-injected-service": require_interface_for_injected_service_default,
|
|
10241
|
+
"require-static-next-matcher": require_static_next_matcher_default,
|
|
10110
10242
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
10111
10243
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
10112
10244
|
"zod-naming-convention": zod_naming_convention_default
|
|
10113
10245
|
};
|
|
10114
10246
|
var meta = {
|
|
10115
10247
|
name: "@sarj/eslint-plugin",
|
|
10116
|
-
version: "9.
|
|
10248
|
+
version: "9.9.0"
|
|
10117
10249
|
};
|
|
10118
10250
|
var applicationOnlyRules = [
|
|
10119
10251
|
"no-restricted-library-load",
|
|
@@ -10129,6 +10261,7 @@ var recommendedRules = {
|
|
|
10129
10261
|
"@sarj/no-dynamic-sql": "warn",
|
|
10130
10262
|
"@sarj/no-fat-try-blocks": "warn",
|
|
10131
10263
|
"@sarj/no-hand-rolled-sleep": "warn",
|
|
10264
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10132
10265
|
"@sarj/no-insecure-random-id": "warn",
|
|
10133
10266
|
"@sarj/no-json-stringify-error": "warn",
|
|
10134
10267
|
"@sarj/no-log-only-catch": "warn",
|
|
@@ -10169,6 +10302,7 @@ var recommendedRules = {
|
|
|
10169
10302
|
"@sarj/require-assert-never": "error",
|
|
10170
10303
|
"@sarj/require-fetch-timeout": "warn",
|
|
10171
10304
|
"@sarj/require-interface-for-injected-service": "warn",
|
|
10305
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10172
10306
|
"@sarj/require-zod-form-validation": "error",
|
|
10173
10307
|
"@sarj/store-insert-requires-on-conflict": "warn",
|
|
10174
10308
|
"@sarj/zod-naming-convention": "warn"
|
|
@@ -10184,6 +10318,7 @@ var strictRules = {
|
|
|
10184
10318
|
"@sarj/no-enum": "error",
|
|
10185
10319
|
"@sarj/no-fat-try-blocks": "error",
|
|
10186
10320
|
"@sarj/no-hand-rolled-sleep": "error",
|
|
10321
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10187
10322
|
"@sarj/no-insecure-random-id": "error",
|
|
10188
10323
|
"@sarj/no-json-stringify-error": "error",
|
|
10189
10324
|
"@sarj/no-log-only-catch": "error",
|
|
@@ -10227,6 +10362,7 @@ var strictRules = {
|
|
|
10227
10362
|
"@sarj/require-assert-never": "error",
|
|
10228
10363
|
"@sarj/require-fetch-timeout": "error",
|
|
10229
10364
|
"@sarj/require-interface-for-injected-service": "error",
|
|
10365
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10230
10366
|
"@sarj/require-zod-form-validation": "error",
|
|
10231
10367
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
10232
10368
|
"@sarj/zod-naming-convention": "error"
|