@sarj/eslint-plugin 9.8.0 → 9.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/index.cjs +898 -646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -5
- package/dist/index.d.ts +29 -5
- package/dist/index.js +881 -629
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.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);
|
|
@@ -6580,8 +6632,121 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6580
6632
|
}
|
|
6581
6633
|
});
|
|
6582
6634
|
|
|
6635
|
+
// src/rules/prefer-input-group-search.ts
|
|
6636
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6637
|
+
var INPUT_MODULE = /(?:^|\/)components\/ui\/input$/u;
|
|
6638
|
+
var INPUT_GROUP_MODULE = /(?:^|\/)components\/ui\/input-group$/u;
|
|
6639
|
+
var MAX_JSX_DISTANCE = 2;
|
|
6640
|
+
function localNamedImports(node, importedName) {
|
|
6641
|
+
return node.specifiers.filter(
|
|
6642
|
+
(specifier) => specifier.type === import_utils48.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils48.AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value) === importedName
|
|
6643
|
+
).map((specifier) => specifier.local.name);
|
|
6644
|
+
}
|
|
6645
|
+
function elementName(node) {
|
|
6646
|
+
return node.name.type === import_utils48.AST_NODE_TYPES.JSXIdentifier ? node.name.name : null;
|
|
6647
|
+
}
|
|
6648
|
+
function jsxAncestors(occurrence) {
|
|
6649
|
+
return occurrence.ancestors.filter(
|
|
6650
|
+
(ancestor) => ancestor.type === import_utils48.AST_NODE_TYPES.JSXElement
|
|
6651
|
+
);
|
|
6652
|
+
}
|
|
6653
|
+
function isWithinInputGroup(occurrence, inputGroupNames) {
|
|
6654
|
+
return jsxAncestors(occurrence).some(
|
|
6655
|
+
(ancestor) => inputGroupNames.has(elementName(ancestor.openingElement) ?? "")
|
|
6656
|
+
);
|
|
6657
|
+
}
|
|
6658
|
+
function nearestEligibleCommonAncestor(search, input, inputGroupNames) {
|
|
6659
|
+
const searchAncestors = jsxAncestors(search);
|
|
6660
|
+
const inputAncestorList = jsxAncestors(input);
|
|
6661
|
+
const inputAncestors = new Set(inputAncestorList);
|
|
6662
|
+
for (let index = searchAncestors.length - 1; index >= 0; index -= 1) {
|
|
6663
|
+
const ancestor = searchAncestors[index];
|
|
6664
|
+
if (ancestor === void 0) continue;
|
|
6665
|
+
if (!inputAncestors.has(ancestor)) continue;
|
|
6666
|
+
const searchDistance = searchAncestors.length - index - 1;
|
|
6667
|
+
const inputDistance = inputAncestorList.length - inputAncestorList.indexOf(ancestor) - 1;
|
|
6668
|
+
if (searchDistance > MAX_JSX_DISTANCE || inputDistance > MAX_JSX_DISTANCE) {
|
|
6669
|
+
return null;
|
|
6670
|
+
}
|
|
6671
|
+
if (inputGroupNames.has(elementName(ancestor.openingElement) ?? "")) {
|
|
6672
|
+
return null;
|
|
6673
|
+
}
|
|
6674
|
+
return ancestor;
|
|
6675
|
+
}
|
|
6676
|
+
return null;
|
|
6677
|
+
}
|
|
6678
|
+
var prefer_input_group_search_default = createRule({
|
|
6679
|
+
name: "prefer-input-group-search",
|
|
6680
|
+
meta: {
|
|
6681
|
+
type: "suggestion",
|
|
6682
|
+
docs: {
|
|
6683
|
+
description: "Require search icons and shared Input controls in the same visual wrapper to use InputGroup."
|
|
6684
|
+
},
|
|
6685
|
+
schema: [],
|
|
6686
|
+
messages: {
|
|
6687
|
+
preferInputGroup: "Use InputGroup with InputGroupAddon and InputGroupInput for this search field."
|
|
6688
|
+
}
|
|
6689
|
+
},
|
|
6690
|
+
defaultOptions: [],
|
|
6691
|
+
create(context) {
|
|
6692
|
+
const inputNames = /* @__PURE__ */ new Set();
|
|
6693
|
+
const inputGroupNames = /* @__PURE__ */ new Set();
|
|
6694
|
+
const searchNames = /* @__PURE__ */ new Set();
|
|
6695
|
+
const inputs = [];
|
|
6696
|
+
const searches = [];
|
|
6697
|
+
return {
|
|
6698
|
+
ImportDeclaration(node) {
|
|
6699
|
+
const source = String(node.source.value);
|
|
6700
|
+
if (source === "lucide-react") {
|
|
6701
|
+
localNamedImports(node, "Search").forEach(
|
|
6702
|
+
(name) => searchNames.add(name)
|
|
6703
|
+
);
|
|
6704
|
+
} else if (INPUT_MODULE.test(source)) {
|
|
6705
|
+
localNamedImports(node, "Input").forEach(
|
|
6706
|
+
(name) => inputNames.add(name)
|
|
6707
|
+
);
|
|
6708
|
+
} else if (INPUT_GROUP_MODULE.test(source)) {
|
|
6709
|
+
localNamedImports(node, "InputGroup").forEach(
|
|
6710
|
+
(name) => inputGroupNames.add(name)
|
|
6711
|
+
);
|
|
6712
|
+
}
|
|
6713
|
+
},
|
|
6714
|
+
JSXOpeningElement(node) {
|
|
6715
|
+
const name = elementName(node);
|
|
6716
|
+
if (name === null) return;
|
|
6717
|
+
const occurrence = {
|
|
6718
|
+
ancestors: context.sourceCode.getAncestors(node),
|
|
6719
|
+
node
|
|
6720
|
+
};
|
|
6721
|
+
if (searchNames.has(name)) searches.push(occurrence);
|
|
6722
|
+
if (inputNames.has(name)) inputs.push(occurrence);
|
|
6723
|
+
},
|
|
6724
|
+
"Program:exit"() {
|
|
6725
|
+
const reported = /* @__PURE__ */ new Set();
|
|
6726
|
+
for (const search of searches) {
|
|
6727
|
+
if (isWithinInputGroup(search, inputGroupNames)) continue;
|
|
6728
|
+
for (const input of inputs) {
|
|
6729
|
+
if (isWithinInputGroup(input, inputGroupNames)) continue;
|
|
6730
|
+
const wrapper = nearestEligibleCommonAncestor(
|
|
6731
|
+
search,
|
|
6732
|
+
input,
|
|
6733
|
+
inputGroupNames
|
|
6734
|
+
);
|
|
6735
|
+
if (wrapper === null || reported.has(wrapper)) continue;
|
|
6736
|
+
reported.add(wrapper);
|
|
6737
|
+
context.report({
|
|
6738
|
+
node: wrapper.openingElement,
|
|
6739
|
+
messageId: "preferInputGroup"
|
|
6740
|
+
});
|
|
6741
|
+
}
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6744
|
+
};
|
|
6745
|
+
}
|
|
6746
|
+
});
|
|
6747
|
+
|
|
6583
6748
|
// src/rules/prefer-module-level-constant.ts
|
|
6584
|
-
var
|
|
6749
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
6585
6750
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6586
6751
|
var MAX_LITERAL_DEPTH = 4;
|
|
6587
6752
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6610,9 +6775,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6610
6775
|
"assign"
|
|
6611
6776
|
]);
|
|
6612
6777
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6778
|
+
import_utils49.AST_NODE_TYPES.FunctionDeclaration,
|
|
6779
|
+
import_utils49.AST_NODE_TYPES.FunctionExpression,
|
|
6780
|
+
import_utils49.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6616
6781
|
]);
|
|
6617
6782
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6618
6783
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6625,14 +6790,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6625
6790
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6626
6791
|
}
|
|
6627
6792
|
function unwrap3(node) {
|
|
6628
|
-
if (node.type ===
|
|
6793
|
+
if (node.type === import_utils49.AST_NODE_TYPES.TSAsExpression || node.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6629
6794
|
return unwrap3(node.expression);
|
|
6630
6795
|
}
|
|
6631
6796
|
return node;
|
|
6632
6797
|
}
|
|
6633
6798
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6634
6799
|
function isRegexLiteral(node) {
|
|
6635
|
-
return node.type ===
|
|
6800
|
+
return node.type === import_utils49.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6636
6801
|
}
|
|
6637
6802
|
function isLiteralOnly(node, depth) {
|
|
6638
6803
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6640,29 +6805,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6640
6805
|
}
|
|
6641
6806
|
const inner = unwrap3(node);
|
|
6642
6807
|
switch (inner.type) {
|
|
6643
|
-
case
|
|
6808
|
+
case import_utils49.AST_NODE_TYPES.Literal: {
|
|
6644
6809
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6645
6810
|
}
|
|
6646
|
-
case
|
|
6811
|
+
case import_utils49.AST_NODE_TYPES.TemplateLiteral: {
|
|
6647
6812
|
return inner.expressions.length === 0;
|
|
6648
6813
|
}
|
|
6649
|
-
case
|
|
6650
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6814
|
+
case import_utils49.AST_NODE_TYPES.UnaryExpression: {
|
|
6815
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils49.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6651
6816
|
}
|
|
6652
|
-
case
|
|
6817
|
+
case import_utils49.AST_NODE_TYPES.ArrayExpression: {
|
|
6653
6818
|
return inner.elements.every(
|
|
6654
|
-
(el) => el !== null && el.type !==
|
|
6819
|
+
(el) => el !== null && el.type !== import_utils49.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6655
6820
|
);
|
|
6656
6821
|
}
|
|
6657
|
-
case
|
|
6822
|
+
case import_utils49.AST_NODE_TYPES.ObjectExpression: {
|
|
6658
6823
|
return inner.properties.every((prop) => {
|
|
6659
|
-
if (prop.type !==
|
|
6824
|
+
if (prop.type !== import_utils49.AST_NODE_TYPES.Property) {
|
|
6660
6825
|
return false;
|
|
6661
6826
|
}
|
|
6662
6827
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6663
6828
|
return false;
|
|
6664
6829
|
}
|
|
6665
|
-
if (prop.computed && prop.key.type !==
|
|
6830
|
+
if (prop.computed && prop.key.type !== import_utils49.AST_NODE_TYPES.Literal) {
|
|
6666
6831
|
return false;
|
|
6667
6832
|
}
|
|
6668
6833
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6675,7 +6840,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6675
6840
|
}
|
|
6676
6841
|
function unwrapObjectFreeze(node) {
|
|
6677
6842
|
const inner = unwrap3(node);
|
|
6678
|
-
if (inner.type ===
|
|
6843
|
+
if (inner.type === import_utils49.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils49.AST_NODE_TYPES.SpreadElement) {
|
|
6679
6844
|
return unwrap3(inner.arguments[0]);
|
|
6680
6845
|
}
|
|
6681
6846
|
return inner;
|
|
@@ -6691,19 +6856,19 @@ function classify(init, checkRegex) {
|
|
|
6691
6856
|
}
|
|
6692
6857
|
return { kind: "regex", size: 1 };
|
|
6693
6858
|
}
|
|
6694
|
-
if (node.type ===
|
|
6859
|
+
if (node.type === import_utils49.AST_NODE_TYPES.ArrayExpression) {
|
|
6695
6860
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6696
6861
|
}
|
|
6697
|
-
if (node.type ===
|
|
6862
|
+
if (node.type === import_utils49.AST_NODE_TYPES.ObjectExpression) {
|
|
6698
6863
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6699
6864
|
}
|
|
6700
|
-
if (node.type ===
|
|
6865
|
+
if (node.type === import_utils49.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils49.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6701
6866
|
const arg = node.arguments[0];
|
|
6702
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6867
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils49.AST_NODE_TYPES.SpreadElement) {
|
|
6703
6868
|
return null;
|
|
6704
6869
|
}
|
|
6705
6870
|
const entries = unwrap3(arg);
|
|
6706
|
-
if (entries.type !==
|
|
6871
|
+
if (entries.type !== import_utils49.AST_NODE_TYPES.ArrayExpression) {
|
|
6707
6872
|
return null;
|
|
6708
6873
|
}
|
|
6709
6874
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6732,10 +6897,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6732
6897
|
);
|
|
6733
6898
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6734
6899
|
const callee = node.callee;
|
|
6735
|
-
if (callee.type ===
|
|
6900
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6736
6901
|
return true;
|
|
6737
6902
|
}
|
|
6738
|
-
if (callee.type !==
|
|
6903
|
+
if (callee.type !== import_utils49.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils49.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
6739
6904
|
return false;
|
|
6740
6905
|
}
|
|
6741
6906
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6749,38 +6914,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6749
6914
|
}
|
|
6750
6915
|
function isSafeRead(identifier) {
|
|
6751
6916
|
const parent = identifier.parent;
|
|
6752
|
-
if (parent.type ===
|
|
6917
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.MemberExpression) {
|
|
6753
6918
|
if (parent.object !== identifier) {
|
|
6754
6919
|
return true;
|
|
6755
6920
|
}
|
|
6756
6921
|
const grandparent = parent.parent;
|
|
6757
|
-
if (grandparent.type ===
|
|
6922
|
+
if (grandparent.type === import_utils49.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6758
6923
|
return false;
|
|
6759
6924
|
}
|
|
6760
|
-
if (grandparent.type ===
|
|
6925
|
+
if (grandparent.type === import_utils49.AST_NODE_TYPES.UpdateExpression) {
|
|
6761
6926
|
return false;
|
|
6762
6927
|
}
|
|
6763
|
-
if (grandparent.type ===
|
|
6928
|
+
if (grandparent.type === import_utils49.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6764
6929
|
return false;
|
|
6765
6930
|
}
|
|
6766
|
-
if (!parent.computed && parent.property.type ===
|
|
6931
|
+
if (!parent.computed && parent.property.type === import_utils49.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils49.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6767
6932
|
return false;
|
|
6768
6933
|
}
|
|
6769
6934
|
return true;
|
|
6770
6935
|
}
|
|
6771
|
-
if (parent.type ===
|
|
6936
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6772
6937
|
return true;
|
|
6773
6938
|
}
|
|
6774
|
-
if (parent.type ===
|
|
6939
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.SpreadElement) {
|
|
6775
6940
|
return true;
|
|
6776
6941
|
}
|
|
6777
|
-
if (parent.type ===
|
|
6942
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.BinaryExpression) {
|
|
6778
6943
|
return true;
|
|
6779
6944
|
}
|
|
6780
|
-
if (parent.type ===
|
|
6945
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6781
6946
|
return true;
|
|
6782
6947
|
}
|
|
6783
|
-
if (parent.type ===
|
|
6948
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6784
6949
|
return true;
|
|
6785
6950
|
}
|
|
6786
6951
|
return false;
|
|
@@ -6835,7 +7000,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6835
7000
|
if (reference.isWrite()) {
|
|
6836
7001
|
return false;
|
|
6837
7002
|
}
|
|
6838
|
-
if (reference.identifier.type !==
|
|
7003
|
+
if (reference.identifier.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
6839
7004
|
return false;
|
|
6840
7005
|
}
|
|
6841
7006
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6847,10 +7012,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6847
7012
|
return {
|
|
6848
7013
|
VariableDeclarator(node) {
|
|
6849
7014
|
const declaration = node.parent;
|
|
6850
|
-
if (declaration.type !==
|
|
7015
|
+
if (declaration.type !== import_utils49.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6851
7016
|
return;
|
|
6852
7017
|
}
|
|
6853
|
-
if (node.id.type !==
|
|
7018
|
+
if (node.id.type !== import_utils49.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6854
7019
|
return;
|
|
6855
7020
|
}
|
|
6856
7021
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6877,7 +7042,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6877
7042
|
});
|
|
6878
7043
|
|
|
6879
7044
|
// src/rules/prefer-module-level-schema.ts
|
|
6880
|
-
var
|
|
7045
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
6881
7046
|
|
|
6882
7047
|
// src/rules/_zod.ts
|
|
6883
7048
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6943,9 +7108,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6943
7108
|
"intl"
|
|
6944
7109
|
]);
|
|
6945
7110
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
7111
|
+
import_utils50.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
7112
|
+
import_utils50.AST_NODE_TYPES.FunctionDeclaration,
|
|
7113
|
+
import_utils50.AST_NODE_TYPES.FunctionExpression
|
|
6949
7114
|
]);
|
|
6950
7115
|
function schemaExpression(node) {
|
|
6951
7116
|
let current = node;
|
|
@@ -6954,10 +7119,10 @@ function schemaExpression(node) {
|
|
|
6954
7119
|
if (parent === void 0) {
|
|
6955
7120
|
return current;
|
|
6956
7121
|
}
|
|
6957
|
-
if (parent.type ===
|
|
7122
|
+
if (parent.type === import_utils50.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils50.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6958
7123
|
return current;
|
|
6959
7124
|
}
|
|
6960
|
-
if (parent.type ===
|
|
7125
|
+
if (parent.type === import_utils50.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils50.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils50.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils50.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
6961
7126
|
current = parent;
|
|
6962
7127
|
continue;
|
|
6963
7128
|
}
|
|
@@ -7008,22 +7173,22 @@ function subtreeSome(root, predicate) {
|
|
|
7008
7173
|
function readsReceiver(node) {
|
|
7009
7174
|
return subtreeSome(
|
|
7010
7175
|
node,
|
|
7011
|
-
(inner) => inner.type ===
|
|
7176
|
+
(inner) => inner.type === import_utils50.AST_NODE_TYPES.ThisExpression || inner.type === import_utils50.AST_NODE_TYPES.Super || inner.type === import_utils50.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
7012
7177
|
);
|
|
7013
7178
|
}
|
|
7014
7179
|
function buildsLocalizedText(node) {
|
|
7015
7180
|
return subtreeSome(node, (inner) => {
|
|
7016
|
-
if (inner.type ===
|
|
7181
|
+
if (inner.type === import_utils50.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
7017
7182
|
return true;
|
|
7018
7183
|
}
|
|
7019
|
-
if (inner.type !==
|
|
7184
|
+
if (inner.type !== import_utils50.AST_NODE_TYPES.CallExpression) {
|
|
7020
7185
|
return false;
|
|
7021
7186
|
}
|
|
7022
7187
|
const { callee } = inner;
|
|
7023
|
-
if (callee.type ===
|
|
7188
|
+
if (callee.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7024
7189
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7025
7190
|
}
|
|
7026
|
-
return callee.type ===
|
|
7191
|
+
return callee.type === import_utils50.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils50.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
7027
7192
|
});
|
|
7028
7193
|
}
|
|
7029
7194
|
function collectReferences(scope, out) {
|
|
@@ -7080,15 +7245,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7080
7245
|
}
|
|
7081
7246
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7082
7247
|
function isZodCall(node) {
|
|
7083
|
-
return node.type ===
|
|
7248
|
+
return node.type === import_utils50.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils50.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils50.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
7084
7249
|
}
|
|
7085
7250
|
function isCovered(node) {
|
|
7086
7251
|
let current = node.parent ?? void 0;
|
|
7087
7252
|
while (current !== void 0) {
|
|
7088
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7253
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils50.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils50.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
7089
7254
|
return true;
|
|
7090
7255
|
}
|
|
7091
|
-
if (current.type ===
|
|
7256
|
+
if (current.type === import_utils50.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils50.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils50.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils50.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
7092
7257
|
return true;
|
|
7093
7258
|
}
|
|
7094
7259
|
current = current.parent ?? void 0;
|
|
@@ -7103,11 +7268,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7103
7268
|
if (parent === void 0) {
|
|
7104
7269
|
return confirmed;
|
|
7105
7270
|
}
|
|
7106
|
-
if (parent.type ===
|
|
7271
|
+
if (parent.type === import_utils50.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils50.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils50.AST_NODE_TYPES.ArrayExpression) {
|
|
7107
7272
|
current = parent;
|
|
7108
7273
|
continue;
|
|
7109
7274
|
}
|
|
7110
|
-
if (parent.type ===
|
|
7275
|
+
if (parent.type === import_utils50.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7111
7276
|
current = schemaExpression(parent);
|
|
7112
7277
|
confirmed = current;
|
|
7113
7278
|
continue;
|
|
@@ -7117,7 +7282,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7117
7282
|
}
|
|
7118
7283
|
function isSchemaComposition(node) {
|
|
7119
7284
|
const { callee } = node;
|
|
7120
|
-
const isCombinator = callee.type ===
|
|
7285
|
+
const isCombinator = callee.type === import_utils50.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils50.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7121
7286
|
return isCombinator || isZodCall(node);
|
|
7122
7287
|
}
|
|
7123
7288
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7151,13 +7316,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7151
7316
|
}
|
|
7152
7317
|
function ownerName(enclosing) {
|
|
7153
7318
|
const parent = enclosing.parent ?? void 0;
|
|
7154
|
-
if (enclosing.type ===
|
|
7319
|
+
if (enclosing.type === import_utils50.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
7155
7320
|
return enclosing.id.name;
|
|
7156
7321
|
}
|
|
7157
|
-
if (parent !== void 0 && parent.type ===
|
|
7322
|
+
if (parent !== void 0 && parent.type === import_utils50.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7158
7323
|
return parent.id.name;
|
|
7159
7324
|
}
|
|
7160
|
-
if (parent !== void 0 && (parent.type ===
|
|
7325
|
+
if (parent !== void 0 && (parent.type === import_utils50.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils50.AST_NODE_TYPES.Property) && parent.key.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7161
7326
|
return parent.key.name;
|
|
7162
7327
|
}
|
|
7163
7328
|
return "this function";
|
|
@@ -7168,7 +7333,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7168
7333
|
return;
|
|
7169
7334
|
}
|
|
7170
7335
|
for (const specifier of node.specifiers) {
|
|
7171
|
-
if (specifier.type ===
|
|
7336
|
+
if (specifier.type === import_utils50.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils50.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils50.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils50.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
7172
7337
|
zodNamespaces.add(specifier.local.name);
|
|
7173
7338
|
}
|
|
7174
7339
|
}
|
|
@@ -7178,7 +7343,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7178
7343
|
return;
|
|
7179
7344
|
}
|
|
7180
7345
|
const callee = node.callee;
|
|
7181
|
-
if (callee.property.type !==
|
|
7346
|
+
if (callee.property.type !== import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7182
7347
|
return;
|
|
7183
7348
|
}
|
|
7184
7349
|
const factory = callee.property.name;
|
|
@@ -7193,7 +7358,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7193
7358
|
return;
|
|
7194
7359
|
}
|
|
7195
7360
|
const shape = node.arguments[0];
|
|
7196
|
-
if (shape !== void 0 && shape.type ===
|
|
7361
|
+
if (shape !== void 0 && shape.type === import_utils50.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
7197
7362
|
return;
|
|
7198
7363
|
}
|
|
7199
7364
|
const expression = schemaExpression(node);
|
|
@@ -7220,77 +7385,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7220
7385
|
}
|
|
7221
7386
|
});
|
|
7222
7387
|
|
|
7223
|
-
// src/rules/prefer-non-nullable-collection.ts
|
|
7224
|
-
var import_utils49 = require("@typescript-eslint/utils");
|
|
7225
|
-
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7226
|
-
function propertyName(node) {
|
|
7227
|
-
const key = node.key;
|
|
7228
|
-
if (key.type === import_utils49.AST_NODE_TYPES.Identifier) return key.name;
|
|
7229
|
-
if (key.type === import_utils49.AST_NODE_TYPES.Literal) return String(key.value);
|
|
7230
|
-
return "collection";
|
|
7231
|
-
}
|
|
7232
|
-
function isArrayType(node) {
|
|
7233
|
-
if (node.type === import_utils49.AST_NODE_TYPES.TSArrayType) return true;
|
|
7234
|
-
return node.type === import_utils49.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils49.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7235
|
-
}
|
|
7236
|
-
function isNullishType(node) {
|
|
7237
|
-
return node.type === import_utils49.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils49.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7238
|
-
}
|
|
7239
|
-
function isNullableArrayOnly(node) {
|
|
7240
|
-
const values = node.types.filter((member) => !isNullishType(member));
|
|
7241
|
-
return values.length > 0 && values.length < node.types.length && values.every(isArrayType);
|
|
7242
|
-
}
|
|
7243
|
-
var prefer_non_nullable_collection_default = createRule({
|
|
7244
|
-
name: "prefer-non-nullable-collection",
|
|
7245
|
-
meta: {
|
|
7246
|
-
type: "suggestion",
|
|
7247
|
-
docs: {
|
|
7248
|
-
description: "Require declared data-shape properties and direct aliases to use non-null arrays instead of explicit nullish unions."
|
|
7249
|
-
},
|
|
7250
|
-
schema: [],
|
|
7251
|
-
messages: {
|
|
7252
|
-
preferNonNullableCollection: "`{{name}}` is a nullable array, so nullish and `[]` represent the same empty collection. Use a non-null array and default omitted values to `[]`."
|
|
7253
|
-
}
|
|
7254
|
-
},
|
|
7255
|
-
defaultOptions: [],
|
|
7256
|
-
create(context) {
|
|
7257
|
-
const normalizedFilename = context.filename.replaceAll("\\", "/");
|
|
7258
|
-
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || /\/(?:vendor|vendored)\//u.test(normalizedFilename)) {
|
|
7259
|
-
return {};
|
|
7260
|
-
}
|
|
7261
|
-
function checkOptionalProperty(node) {
|
|
7262
|
-
if (node.optional) return;
|
|
7263
|
-
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7264
|
-
if (annotation === void 0) return;
|
|
7265
|
-
if (annotation.type !== import_utils49.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7266
|
-
return;
|
|
7267
|
-
}
|
|
7268
|
-
context.report({
|
|
7269
|
-
node,
|
|
7270
|
-
messageId: "preferNonNullableCollection",
|
|
7271
|
-
data: { name: propertyName(node) }
|
|
7272
|
-
});
|
|
7273
|
-
}
|
|
7274
|
-
return {
|
|
7275
|
-
TSPropertySignature: checkOptionalProperty,
|
|
7276
|
-
PropertyDefinition: checkOptionalProperty,
|
|
7277
|
-
TSTypeAliasDeclaration(node) {
|
|
7278
|
-
if (node.typeAnnotation.type !== import_utils49.AST_NODE_TYPES.TSUnionType) return;
|
|
7279
|
-
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7280
|
-
context.report({
|
|
7281
|
-
node,
|
|
7282
|
-
messageId: "preferNonNullableCollection",
|
|
7283
|
-
data: { name: node.id.name }
|
|
7284
|
-
});
|
|
7285
|
-
}
|
|
7286
|
-
};
|
|
7287
|
-
}
|
|
7288
|
-
});
|
|
7289
|
-
|
|
7290
7388
|
// src/rules/prefer-native-random-uuid.ts
|
|
7291
|
-
var
|
|
7389
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7292
7390
|
function requireUuid(node) {
|
|
7293
|
-
return node?.type ===
|
|
7391
|
+
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
7392
|
}
|
|
7295
7393
|
var prefer_native_random_uuid_default = createRule({
|
|
7296
7394
|
name: "prefer-native-random-uuid",
|
|
@@ -7311,7 +7409,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7311
7409
|
const directBindings = /* @__PURE__ */ new Set();
|
|
7312
7410
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7313
7411
|
function resolve(identifier) {
|
|
7314
|
-
return
|
|
7412
|
+
return import_utils51.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7315
7413
|
}
|
|
7316
7414
|
function record(identifier, destination) {
|
|
7317
7415
|
const variable = resolve(identifier);
|
|
@@ -7333,37 +7431,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7333
7431
|
ImportDeclaration(node) {
|
|
7334
7432
|
if (node.source.value !== "uuid") return;
|
|
7335
7433
|
for (const specifier of node.specifiers) {
|
|
7336
|
-
if (specifier.type ===
|
|
7434
|
+
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
7435
|
record(specifier.local, directBindings);
|
|
7338
|
-
} else if (specifier.type ===
|
|
7436
|
+
} else if (specifier.type === import_utils51.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
7339
7437
|
record(specifier.local, namespaceBindings);
|
|
7340
7438
|
}
|
|
7341
7439
|
}
|
|
7342
7440
|
},
|
|
7343
7441
|
VariableDeclarator(node) {
|
|
7344
7442
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7345
|
-
if (node.init?.type !==
|
|
7443
|
+
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
7444
|
return;
|
|
7347
7445
|
}
|
|
7348
|
-
if (node.id.type ===
|
|
7446
|
+
if (node.id.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7349
7447
|
record(node.id, namespaceBindings);
|
|
7350
7448
|
return;
|
|
7351
7449
|
}
|
|
7352
|
-
if (node.id.type !==
|
|
7450
|
+
if (node.id.type !== import_utils51.AST_NODE_TYPES.ObjectPattern) return;
|
|
7353
7451
|
for (const property of node.id.properties) {
|
|
7354
|
-
if (property.type ===
|
|
7452
|
+
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
7453
|
record(property.value, directBindings);
|
|
7356
7454
|
}
|
|
7357
7455
|
}
|
|
7358
7456
|
},
|
|
7359
7457
|
"CallExpression:exit"(node) {
|
|
7360
7458
|
if (node.arguments.length !== 0) return;
|
|
7361
|
-
if (node.callee.type ===
|
|
7459
|
+
if (node.callee.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7362
7460
|
const variable2 = resolve(node.callee);
|
|
7363
7461
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7364
7462
|
return;
|
|
7365
7463
|
}
|
|
7366
|
-
if (node.callee.type !==
|
|
7464
|
+
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
7465
|
return;
|
|
7368
7466
|
}
|
|
7369
7467
|
const variable = resolve(node.callee.object);
|
|
@@ -7373,14 +7471,81 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7373
7471
|
}
|
|
7374
7472
|
});
|
|
7375
7473
|
|
|
7474
|
+
// src/rules/prefer-non-nullable-collection.ts
|
|
7475
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7476
|
+
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7477
|
+
function propertyName(node) {
|
|
7478
|
+
const key = node.key;
|
|
7479
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Identifier) return key.name;
|
|
7480
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Literal) return String(key.value);
|
|
7481
|
+
return "collection";
|
|
7482
|
+
}
|
|
7483
|
+
function isArrayType(node) {
|
|
7484
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSArrayType) return true;
|
|
7485
|
+
return node.type === import_utils52.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils52.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7486
|
+
}
|
|
7487
|
+
function isNullishType(node) {
|
|
7488
|
+
return node.type === import_utils52.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils52.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7489
|
+
}
|
|
7490
|
+
function isNullableArrayOnly(node) {
|
|
7491
|
+
const values = node.types.filter((member) => !isNullishType(member));
|
|
7492
|
+
return values.length > 0 && values.length < node.types.length && values.every(isArrayType);
|
|
7493
|
+
}
|
|
7494
|
+
var prefer_non_nullable_collection_default = createRule({
|
|
7495
|
+
name: "prefer-non-nullable-collection",
|
|
7496
|
+
meta: {
|
|
7497
|
+
type: "suggestion",
|
|
7498
|
+
docs: {
|
|
7499
|
+
description: "Require declared data-shape properties and direct aliases to use non-null arrays instead of explicit nullish unions."
|
|
7500
|
+
},
|
|
7501
|
+
schema: [],
|
|
7502
|
+
messages: {
|
|
7503
|
+
preferNonNullableCollection: "`{{name}}` is a nullable array, so nullish and `[]` represent the same empty collection. Use a non-null array and default omitted values to `[]`."
|
|
7504
|
+
}
|
|
7505
|
+
},
|
|
7506
|
+
defaultOptions: [],
|
|
7507
|
+
create(context) {
|
|
7508
|
+
const normalizedFilename = context.filename.replaceAll("\\", "/");
|
|
7509
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || /\/(?:vendor|vendored)\//u.test(normalizedFilename)) {
|
|
7510
|
+
return {};
|
|
7511
|
+
}
|
|
7512
|
+
function checkOptionalProperty(node) {
|
|
7513
|
+
if (node.optional) return;
|
|
7514
|
+
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7515
|
+
if (annotation === void 0) return;
|
|
7516
|
+
if (annotation.type !== import_utils52.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7517
|
+
return;
|
|
7518
|
+
}
|
|
7519
|
+
context.report({
|
|
7520
|
+
node,
|
|
7521
|
+
messageId: "preferNonNullableCollection",
|
|
7522
|
+
data: { name: propertyName(node) }
|
|
7523
|
+
});
|
|
7524
|
+
}
|
|
7525
|
+
return {
|
|
7526
|
+
TSPropertySignature: checkOptionalProperty,
|
|
7527
|
+
PropertyDefinition: checkOptionalProperty,
|
|
7528
|
+
TSTypeAliasDeclaration(node) {
|
|
7529
|
+
if (node.typeAnnotation.type !== import_utils52.AST_NODE_TYPES.TSUnionType) return;
|
|
7530
|
+
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7531
|
+
context.report({
|
|
7532
|
+
node,
|
|
7533
|
+
messageId: "preferNonNullableCollection",
|
|
7534
|
+
data: { name: node.id.name }
|
|
7535
|
+
});
|
|
7536
|
+
}
|
|
7537
|
+
};
|
|
7538
|
+
}
|
|
7539
|
+
});
|
|
7540
|
+
|
|
7376
7541
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7377
|
-
var
|
|
7542
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7378
7543
|
var unwrap4 = (node) => {
|
|
7379
7544
|
let current = node;
|
|
7380
7545
|
while (current !== null && current !== void 0) {
|
|
7381
|
-
if (current.type ===
|
|
7546
|
+
if (current.type === import_utils53.AST_NODE_TYPES.TSAsExpression || current.type === import_utils53.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils53.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils53.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
7382
7547
|
current = current.expression;
|
|
7383
|
-
} else if (current.type ===
|
|
7548
|
+
} else if (current.type === import_utils53.AST_NODE_TYPES.ChainExpression) {
|
|
7384
7549
|
current = current.expression;
|
|
7385
7550
|
} else {
|
|
7386
7551
|
break;
|
|
@@ -7395,23 +7560,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7395
7560
|
]);
|
|
7396
7561
|
var isSchemaParseReference = (node) => {
|
|
7397
7562
|
const inner = unwrap4(node);
|
|
7398
|
-
return inner !== null && inner.type ===
|
|
7563
|
+
return inner !== null && inner.type === import_utils53.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils53.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7399
7564
|
};
|
|
7400
7565
|
var isRawPayloadSource = (node) => {
|
|
7401
7566
|
let current = unwrap4(node);
|
|
7402
7567
|
if (current === null) return false;
|
|
7403
|
-
if (current.type ===
|
|
7568
|
+
if (current.type === import_utils53.AST_NODE_TYPES.AwaitExpression) {
|
|
7404
7569
|
current = unwrap4(current.argument);
|
|
7405
7570
|
}
|
|
7406
|
-
if (current === null || current.type !==
|
|
7571
|
+
if (current === null || current.type !== import_utils53.AST_NODE_TYPES.CallExpression) {
|
|
7407
7572
|
return false;
|
|
7408
7573
|
}
|
|
7409
7574
|
const callee = unwrap4(current.callee);
|
|
7410
|
-
if (callee === null || callee.type !==
|
|
7575
|
+
if (callee === null || callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression) {
|
|
7411
7576
|
return false;
|
|
7412
7577
|
}
|
|
7413
7578
|
const property = unwrap4(callee.property);
|
|
7414
|
-
if (property === null || property.type !==
|
|
7579
|
+
if (property === null || property.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7415
7580
|
return false;
|
|
7416
7581
|
}
|
|
7417
7582
|
if (property.name === "json") {
|
|
@@ -7421,16 +7586,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7421
7586
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7422
7587
|
}
|
|
7423
7588
|
const object = unwrap4(callee.object);
|
|
7424
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7589
|
+
return property.name === "parse" && object !== null && object.type === import_utils53.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7425
7590
|
};
|
|
7426
7591
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7427
7592
|
var isLocalFileRead = (node) => {
|
|
7428
7593
|
let found = false;
|
|
7429
7594
|
const visit = (current) => {
|
|
7430
7595
|
if (found || current === null || current === void 0) return;
|
|
7431
|
-
if (current.type ===
|
|
7596
|
+
if (current.type === import_utils53.AST_NODE_TYPES.CallExpression) {
|
|
7432
7597
|
const callee = unwrap4(current.callee);
|
|
7433
|
-
const name = callee?.type ===
|
|
7598
|
+
const name = callee?.type === import_utils53.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils53.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils53.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
7434
7599
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7435
7600
|
found = true;
|
|
7436
7601
|
return;
|
|
@@ -7452,15 +7617,15 @@ var isLocalFileRead = (node) => {
|
|
|
7452
7617
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7453
7618
|
var isInsideAssertion = (node) => {
|
|
7454
7619
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7455
|
-
if (current.type !==
|
|
7620
|
+
if (current.type !== import_utils53.AST_NODE_TYPES.CallExpression) continue;
|
|
7456
7621
|
let callee = current.callee;
|
|
7457
|
-
while (callee.type ===
|
|
7622
|
+
while (callee.type === import_utils53.AST_NODE_TYPES.MemberExpression) {
|
|
7458
7623
|
callee = callee.object;
|
|
7459
7624
|
}
|
|
7460
|
-
if (callee.type ===
|
|
7625
|
+
if (callee.type === import_utils53.AST_NODE_TYPES.CallExpression) {
|
|
7461
7626
|
callee = callee.callee;
|
|
7462
7627
|
}
|
|
7463
|
-
if (callee.type ===
|
|
7628
|
+
if (callee.type === import_utils53.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7464
7629
|
return true;
|
|
7465
7630
|
}
|
|
7466
7631
|
}
|
|
@@ -7479,39 +7644,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7479
7644
|
var isValidationRead = (node) => {
|
|
7480
7645
|
let current = node;
|
|
7481
7646
|
let parent = current.parent;
|
|
7482
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7647
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils53.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils53.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils53.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils53.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils53.AST_NODE_TYPES.ChainExpression)) {
|
|
7483
7648
|
current = parent;
|
|
7484
7649
|
parent = parent.parent;
|
|
7485
7650
|
}
|
|
7486
7651
|
if (parent === null || parent === void 0) return false;
|
|
7487
|
-
if (parent.type ===
|
|
7652
|
+
if (parent.type === import_utils53.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7488
7653
|
return true;
|
|
7489
7654
|
}
|
|
7490
|
-
if (parent.type !==
|
|
7655
|
+
if (parent.type !== import_utils53.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7491
7656
|
return false;
|
|
7492
7657
|
}
|
|
7493
7658
|
const callee = parent.callee;
|
|
7494
|
-
if (callee.type ===
|
|
7659
|
+
if (callee.type === import_utils53.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils53.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils53.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
7495
7660
|
return parent.arguments.length === 1;
|
|
7496
7661
|
}
|
|
7497
|
-
return callee.type ===
|
|
7662
|
+
return callee.type === import_utils53.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7498
7663
|
};
|
|
7499
7664
|
var isGuardTestPosition = (node) => {
|
|
7500
7665
|
let current = node;
|
|
7501
7666
|
let parent = current.parent;
|
|
7502
7667
|
while (parent !== void 0 && parent !== null) {
|
|
7503
7668
|
switch (parent.type) {
|
|
7504
|
-
case
|
|
7505
|
-
case
|
|
7506
|
-
case
|
|
7669
|
+
case import_utils53.AST_NODE_TYPES.UnaryExpression:
|
|
7670
|
+
case import_utils53.AST_NODE_TYPES.LogicalExpression:
|
|
7671
|
+
case import_utils53.AST_NODE_TYPES.ChainExpression:
|
|
7507
7672
|
current = parent;
|
|
7508
7673
|
parent = parent.parent;
|
|
7509
7674
|
continue;
|
|
7510
|
-
case
|
|
7511
|
-
case
|
|
7512
|
-
case
|
|
7513
|
-
case
|
|
7514
|
-
case
|
|
7675
|
+
case import_utils53.AST_NODE_TYPES.IfStatement:
|
|
7676
|
+
case import_utils53.AST_NODE_TYPES.ConditionalExpression:
|
|
7677
|
+
case import_utils53.AST_NODE_TYPES.WhileStatement:
|
|
7678
|
+
case import_utils53.AST_NODE_TYPES.DoWhileStatement:
|
|
7679
|
+
case import_utils53.AST_NODE_TYPES.ForStatement:
|
|
7515
7680
|
return parent.test === current;
|
|
7516
7681
|
default:
|
|
7517
7682
|
return false;
|
|
@@ -7521,7 +7686,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7521
7686
|
};
|
|
7522
7687
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7523
7688
|
const unwrapped = unwrap4(node);
|
|
7524
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7689
|
+
if (unwrapped === null || unwrapped.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7525
7690
|
return false;
|
|
7526
7691
|
}
|
|
7527
7692
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7564,11 +7729,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7564
7729
|
return {
|
|
7565
7730
|
VariableDeclarator(node) {
|
|
7566
7731
|
const scope = context.sourceCode.getScope(node);
|
|
7567
|
-
if (node.id.type ===
|
|
7732
|
+
if (node.id.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7568
7733
|
trackInitializer(node);
|
|
7569
7734
|
return;
|
|
7570
7735
|
}
|
|
7571
|
-
if (node.id.type ===
|
|
7736
|
+
if (node.id.type === import_utils53.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils53.AST_NODE_TYPES.ArrayPattern) {
|
|
7572
7737
|
if (isRawPayloadSource(node.init)) {
|
|
7573
7738
|
if (!isFullyNarrowedPattern(node)) {
|
|
7574
7739
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7582,7 +7747,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7582
7747
|
},
|
|
7583
7748
|
AssignmentExpression(node) {
|
|
7584
7749
|
const scope = context.sourceCode.getScope(node);
|
|
7585
|
-
if (node.left.type ===
|
|
7750
|
+
if (node.left.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7586
7751
|
const variable = findVariable2(scope, node.left.name);
|
|
7587
7752
|
if (variable === null) return;
|
|
7588
7753
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7592,7 +7757,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7592
7757
|
}
|
|
7593
7758
|
return;
|
|
7594
7759
|
}
|
|
7595
|
-
if (node.left.type ===
|
|
7760
|
+
if (node.left.type === import_utils53.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils53.AST_NODE_TYPES.ArrayPattern) {
|
|
7596
7761
|
if (isRawPayloadSource(node.right)) {
|
|
7597
7762
|
context.report({
|
|
7598
7763
|
node: node.left,
|
|
@@ -7609,15 +7774,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7609
7774
|
}
|
|
7610
7775
|
},
|
|
7611
7776
|
CallExpression(node) {
|
|
7612
|
-
if (node.callee.type !==
|
|
7777
|
+
if (node.callee.type !== import_utils53.AST_NODE_TYPES.Identifier) return;
|
|
7613
7778
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7614
7779
|
return;
|
|
7615
7780
|
}
|
|
7616
7781
|
const scope = context.sourceCode.getScope(node);
|
|
7617
7782
|
for (const arg of node.arguments) {
|
|
7618
|
-
if (arg.type ===
|
|
7783
|
+
if (arg.type === import_utils53.AST_NODE_TYPES.SpreadElement) continue;
|
|
7619
7784
|
const unwrapped = unwrap4(arg);
|
|
7620
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7785
|
+
if (unwrapped === null || unwrapped.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7621
7786
|
continue;
|
|
7622
7787
|
}
|
|
7623
7788
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7631,13 +7796,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7631
7796
|
const obj = unwrap4(node.object);
|
|
7632
7797
|
if (isRawPayloadSource(obj)) {
|
|
7633
7798
|
const parent = node.parent;
|
|
7634
|
-
if (parent.type ===
|
|
7799
|
+
if (parent.type === import_utils53.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils53.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7635
7800
|
return;
|
|
7636
7801
|
}
|
|
7637
7802
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7638
7803
|
return;
|
|
7639
7804
|
}
|
|
7640
|
-
if (obj !== null && obj.type ===
|
|
7805
|
+
if (obj !== null && obj.type === import_utils53.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7641
7806
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7642
7807
|
const variable = findVariable2(scope, obj.name);
|
|
7643
7808
|
if (variable !== null) {
|
|
@@ -7650,7 +7815,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7650
7815
|
});
|
|
7651
7816
|
|
|
7652
7817
|
// src/rules/prefer-semantic-colors.ts
|
|
7653
|
-
var
|
|
7818
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
7654
7819
|
var import_fs = require("fs");
|
|
7655
7820
|
var import_path = require("path");
|
|
7656
7821
|
|
|
@@ -7750,8 +7915,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7750
7915
|
]);
|
|
7751
7916
|
function jsxElementName(node) {
|
|
7752
7917
|
const name = node.openingElement.name;
|
|
7753
|
-
if (name.type ===
|
|
7754
|
-
if (name.type ===
|
|
7918
|
+
if (name.type === import_utils54.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
7919
|
+
if (name.type === import_utils54.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils54.AST_NODE_TYPES.JSXIdentifier) {
|
|
7755
7920
|
return name.property.name;
|
|
7756
7921
|
}
|
|
7757
7922
|
return null;
|
|
@@ -7777,7 +7942,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7777
7942
|
var isInsideSvg = (node) => {
|
|
7778
7943
|
let current = node.parent;
|
|
7779
7944
|
while (current !== void 0 && current !== null) {
|
|
7780
|
-
if (current.type ===
|
|
7945
|
+
if (current.type === import_utils54.AST_NODE_TYPES.JSXElement) {
|
|
7781
7946
|
const name = jsxElementName(current);
|
|
7782
7947
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7783
7948
|
}
|
|
@@ -7788,7 +7953,7 @@ var isInsideSvg = (node) => {
|
|
|
7788
7953
|
var isInsideIconFactoryPath = (node) => {
|
|
7789
7954
|
let current = node.parent;
|
|
7790
7955
|
while (current !== void 0 && current !== null) {
|
|
7791
|
-
if (current.type ===
|
|
7956
|
+
if (current.type === import_utils54.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils54.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils54.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils54.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7792
7957
|
return true;
|
|
7793
7958
|
}
|
|
7794
7959
|
current = current.parent;
|
|
@@ -7925,12 +8090,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7925
8090
|
return root !== null && workspaceHasMarker(root);
|
|
7926
8091
|
};
|
|
7927
8092
|
var propName = (key) => {
|
|
7928
|
-
if (key.type ===
|
|
7929
|
-
if (key.type ===
|
|
8093
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Identifier) return key.name;
|
|
8094
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
7930
8095
|
return null;
|
|
7931
8096
|
};
|
|
7932
8097
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7933
|
-
if (statement.type !==
|
|
8098
|
+
if (statement.type !== import_utils54.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils54.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils54.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
7934
8099
|
return false;
|
|
7935
8100
|
}
|
|
7936
8101
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -7982,27 +8147,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7982
8147
|
const checkClassNode = (node) => {
|
|
7983
8148
|
if (node === null) return;
|
|
7984
8149
|
switch (node.type) {
|
|
7985
|
-
case
|
|
8150
|
+
case import_utils54.AST_NODE_TYPES.Literal:
|
|
7986
8151
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7987
8152
|
break;
|
|
7988
|
-
case
|
|
8153
|
+
case import_utils54.AST_NODE_TYPES.TemplateLiteral:
|
|
7989
8154
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7990
8155
|
break;
|
|
7991
|
-
case
|
|
8156
|
+
case import_utils54.AST_NODE_TYPES.ArrayExpression:
|
|
7992
8157
|
for (const element of node.elements) {
|
|
7993
|
-
if (element !== null && element.type !==
|
|
8158
|
+
if (element !== null && element.type !== import_utils54.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
7994
8159
|
}
|
|
7995
8160
|
break;
|
|
7996
|
-
case
|
|
8161
|
+
case import_utils54.AST_NODE_TYPES.ObjectExpression:
|
|
7997
8162
|
for (const property of node.properties) {
|
|
7998
|
-
if (property.type ===
|
|
8163
|
+
if (property.type === import_utils54.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
7999
8164
|
}
|
|
8000
8165
|
break;
|
|
8001
|
-
case
|
|
8166
|
+
case import_utils54.AST_NODE_TYPES.ConditionalExpression:
|
|
8002
8167
|
checkClassNode(node.consequent);
|
|
8003
8168
|
checkClassNode(node.alternate);
|
|
8004
8169
|
break;
|
|
8005
|
-
case
|
|
8170
|
+
case import_utils54.AST_NODE_TYPES.LogicalExpression:
|
|
8006
8171
|
checkClassNode(node.right);
|
|
8007
8172
|
break;
|
|
8008
8173
|
default:
|
|
@@ -8010,32 +8175,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8010
8175
|
}
|
|
8011
8176
|
};
|
|
8012
8177
|
const checkColorValueNode = (node) => {
|
|
8013
|
-
if (node.type ===
|
|
8178
|
+
if (node.type === import_utils54.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
8014
8179
|
report(node, "inlineColor", { value: node.value });
|
|
8015
8180
|
}
|
|
8016
8181
|
};
|
|
8017
8182
|
return {
|
|
8018
8183
|
"JSXAttribute[name.name='className']"(node) {
|
|
8019
8184
|
if (node.value === null) return;
|
|
8020
|
-
if (node.value.type ===
|
|
8021
|
-
else if (node.value.type ===
|
|
8022
|
-
if (node.value.expression.type !==
|
|
8185
|
+
if (node.value.type === import_utils54.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
8186
|
+
else if (node.value.type === import_utils54.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
8187
|
+
if (node.value.expression.type !== import_utils54.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
8023
8188
|
checkClassNode(node.value.expression);
|
|
8024
8189
|
}
|
|
8025
8190
|
}
|
|
8026
8191
|
},
|
|
8027
8192
|
CallExpression(node) {
|
|
8028
|
-
if (node.callee.type ===
|
|
8193
|
+
if (node.callee.type === import_utils54.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils54.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
8029
8194
|
importsEmailOrPdfRenderer = true;
|
|
8030
8195
|
}
|
|
8031
|
-
if (node.callee.type ===
|
|
8196
|
+
if (node.callee.type === import_utils54.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8032
8197
|
for (const arg of node.arguments) {
|
|
8033
|
-
if (arg.type !==
|
|
8198
|
+
if (arg.type !== import_utils54.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
8034
8199
|
}
|
|
8035
8200
|
}
|
|
8036
8201
|
},
|
|
8037
8202
|
VariableDeclarator(node) {
|
|
8038
|
-
if (node.id.type ===
|
|
8203
|
+
if (node.id.type === import_utils54.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8039
8204
|
checkClassNode(node.init);
|
|
8040
8205
|
}
|
|
8041
8206
|
},
|
|
@@ -8045,9 +8210,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8045
8210
|
},
|
|
8046
8211
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8047
8212
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8048
|
-
if (node.value?.type !==
|
|
8213
|
+
if (node.value?.type !== import_utils54.AST_NODE_TYPES.Literal) return;
|
|
8049
8214
|
const owner = node.parent.name;
|
|
8050
|
-
if (owner.type ===
|
|
8215
|
+
if (owner.type === import_utils54.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8051
8216
|
return;
|
|
8052
8217
|
}
|
|
8053
8218
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8061,7 +8226,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8061
8226
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8062
8227
|
},
|
|
8063
8228
|
ImportExpression(node) {
|
|
8064
|
-
if (node.source.type ===
|
|
8229
|
+
if (node.source.type === import_utils54.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8065
8230
|
importsEmailOrPdfRenderer = true;
|
|
8066
8231
|
}
|
|
8067
8232
|
},
|
|
@@ -8074,7 +8239,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8074
8239
|
});
|
|
8075
8240
|
|
|
8076
8241
|
// src/rules/prefer-server-actions.ts
|
|
8077
|
-
var
|
|
8242
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8078
8243
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
8079
8244
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
8080
8245
|
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 +8430,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8265
8430
|
});
|
|
8266
8431
|
|
|
8267
8432
|
// src/rules/prefer-string-literal-union.ts
|
|
8268
|
-
var
|
|
8433
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8269
8434
|
var ts2 = __toESM(require("typescript"), 1);
|
|
8270
8435
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
8271
8436
|
"status",
|
|
@@ -8308,19 +8473,19 @@ function isChoiceLikeName(name) {
|
|
|
8308
8473
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8309
8474
|
}
|
|
8310
8475
|
function keyName(key) {
|
|
8311
|
-
if (key.type ===
|
|
8476
|
+
if (key.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8312
8477
|
return key.name;
|
|
8313
8478
|
}
|
|
8314
|
-
if (key.type ===
|
|
8479
|
+
if (key.type === import_utils56.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
8315
8480
|
return key.value;
|
|
8316
8481
|
}
|
|
8317
8482
|
return null;
|
|
8318
8483
|
}
|
|
8319
8484
|
function isStringLiteralMember(t) {
|
|
8320
|
-
return t.type ===
|
|
8485
|
+
return t.type === import_utils56.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils56.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
8321
8486
|
}
|
|
8322
8487
|
function isStringLiteralUnion(node) {
|
|
8323
|
-
if (node?.type !==
|
|
8488
|
+
if (node?.type !== import_utils56.AST_NODE_TYPES.TSUnionType) {
|
|
8324
8489
|
return false;
|
|
8325
8490
|
}
|
|
8326
8491
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8349,12 +8514,12 @@ function bindingSourceExpression(decl) {
|
|
|
8349
8514
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8350
8515
|
}
|
|
8351
8516
|
function refKey(node) {
|
|
8352
|
-
if (node.type ===
|
|
8517
|
+
if (node.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8353
8518
|
return node.name;
|
|
8354
8519
|
}
|
|
8355
|
-
if (node.type ===
|
|
8520
|
+
if (node.type === import_utils56.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
8356
8521
|
const inner = refKey(node.object);
|
|
8357
|
-
if (inner === null || node.property.type !==
|
|
8522
|
+
if (inner === null || node.property.type !== import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8358
8523
|
return null;
|
|
8359
8524
|
}
|
|
8360
8525
|
return `${inner}.${node.property.name}`;
|
|
@@ -8362,7 +8527,7 @@ function refKey(node) {
|
|
|
8362
8527
|
return null;
|
|
8363
8528
|
}
|
|
8364
8529
|
function strLiteral(node) {
|
|
8365
|
-
if (node.type ===
|
|
8530
|
+
if (node.type === import_utils56.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
8366
8531
|
return node.value;
|
|
8367
8532
|
}
|
|
8368
8533
|
return null;
|
|
@@ -8403,7 +8568,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8403
8568
|
);
|
|
8404
8569
|
let services;
|
|
8405
8570
|
try {
|
|
8406
|
-
services =
|
|
8571
|
+
services = import_utils56.ESLintUtils.getParserServices(context);
|
|
8407
8572
|
} catch {
|
|
8408
8573
|
services = null;
|
|
8409
8574
|
}
|
|
@@ -8515,7 +8680,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8515
8680
|
containersWithUnion.add(container);
|
|
8516
8681
|
return;
|
|
8517
8682
|
}
|
|
8518
|
-
if (typeNode?.type !==
|
|
8683
|
+
if (typeNode?.type !== import_utils56.AST_NODE_TYPES.TSStringKeyword) {
|
|
8519
8684
|
return;
|
|
8520
8685
|
}
|
|
8521
8686
|
const name = keyName(key);
|
|
@@ -8603,10 +8768,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8603
8768
|
}
|
|
8604
8769
|
};
|
|
8605
8770
|
function refKeyText(node) {
|
|
8606
|
-
if (node.type ===
|
|
8771
|
+
if (node.type === import_utils56.AST_NODE_TYPES.BinaryExpression) {
|
|
8607
8772
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8608
8773
|
}
|
|
8609
|
-
if (node.type ===
|
|
8774
|
+
if (node.type === import_utils56.AST_NODE_TYPES.SwitchStatement) {
|
|
8610
8775
|
return refKey(node.discriminant) ?? "value";
|
|
8611
8776
|
}
|
|
8612
8777
|
return "value";
|
|
@@ -8615,7 +8780,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8615
8780
|
});
|
|
8616
8781
|
|
|
8617
8782
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8618
|
-
var
|
|
8783
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8619
8784
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8620
8785
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8621
8786
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8624,11 +8789,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8624
8789
|
var MIN_RUN_LENGTH = 2;
|
|
8625
8790
|
function literalText(node, getText) {
|
|
8626
8791
|
switch (node.type) {
|
|
8627
|
-
case
|
|
8792
|
+
case import_utils57.AST_NODE_TYPES.Literal:
|
|
8628
8793
|
return "regex" in node ? null : getText(node);
|
|
8629
|
-
case
|
|
8794
|
+
case import_utils57.AST_NODE_TYPES.TemplateLiteral:
|
|
8630
8795
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8631
|
-
case
|
|
8796
|
+
case import_utils57.AST_NODE_TYPES.UnaryExpression:
|
|
8632
8797
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8633
8798
|
default:
|
|
8634
8799
|
return null;
|
|
@@ -8636,15 +8801,15 @@ function literalText(node, getText) {
|
|
|
8636
8801
|
}
|
|
8637
8802
|
function isPureReceiver(node) {
|
|
8638
8803
|
switch (node.type) {
|
|
8639
|
-
case
|
|
8640
|
-
case
|
|
8804
|
+
case import_utils57.AST_NODE_TYPES.Identifier:
|
|
8805
|
+
case import_utils57.AST_NODE_TYPES.ThisExpression:
|
|
8641
8806
|
return true;
|
|
8642
|
-
case
|
|
8807
|
+
case import_utils57.AST_NODE_TYPES.MemberExpression:
|
|
8643
8808
|
if (node.optional) {
|
|
8644
8809
|
return false;
|
|
8645
8810
|
}
|
|
8646
8811
|
if (node.computed) {
|
|
8647
|
-
return node.property.type ===
|
|
8812
|
+
return node.property.type === import_utils57.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8648
8813
|
}
|
|
8649
8814
|
return isPureReceiver(node.object);
|
|
8650
8815
|
default:
|
|
@@ -8652,7 +8817,7 @@ function isPureReceiver(node) {
|
|
|
8652
8817
|
}
|
|
8653
8818
|
}
|
|
8654
8819
|
function literalIndex(node) {
|
|
8655
|
-
if (node.type !==
|
|
8820
|
+
if (node.type !== import_utils57.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8656
8821
|
return null;
|
|
8657
8822
|
}
|
|
8658
8823
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8678,24 +8843,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8678
8843
|
}
|
|
8679
8844
|
const { sourceCode } = context;
|
|
8680
8845
|
function parseAssertion(statement) {
|
|
8681
|
-
if (statement.type !==
|
|
8846
|
+
if (statement.type !== import_utils57.AST_NODE_TYPES.ExpressionStatement) {
|
|
8682
8847
|
return null;
|
|
8683
8848
|
}
|
|
8684
8849
|
const call = statement.expression;
|
|
8685
|
-
if (call.type !==
|
|
8850
|
+
if (call.type !== import_utils57.AST_NODE_TYPES.CallExpression) {
|
|
8686
8851
|
return null;
|
|
8687
8852
|
}
|
|
8688
8853
|
const callee = call.callee;
|
|
8689
|
-
if (callee.type !==
|
|
8854
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8690
8855
|
return null;
|
|
8691
8856
|
}
|
|
8692
8857
|
const matcher = callee.property.name;
|
|
8693
8858
|
const expectCall = callee.object;
|
|
8694
|
-
if (expectCall.type !==
|
|
8859
|
+
if (expectCall.type !== import_utils57.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils57.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8695
8860
|
return null;
|
|
8696
8861
|
}
|
|
8697
8862
|
const actual = expectCall.arguments[0];
|
|
8698
|
-
if (actual === void 0 || actual.type !==
|
|
8863
|
+
if (actual === void 0 || actual.type !== import_utils57.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8699
8864
|
return null;
|
|
8700
8865
|
}
|
|
8701
8866
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8709,7 +8874,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8709
8874
|
}
|
|
8710
8875
|
key = { kind: "index", index };
|
|
8711
8876
|
} else {
|
|
8712
|
-
if (actual.property.type !==
|
|
8877
|
+
if (actual.property.type !== import_utils57.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8713
8878
|
return null;
|
|
8714
8879
|
}
|
|
8715
8880
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8721,7 +8886,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8721
8886
|
return null;
|
|
8722
8887
|
}
|
|
8723
8888
|
const expected = call.arguments[0];
|
|
8724
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8889
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils57.AST_NODE_TYPES.SpreadElement) {
|
|
8725
8890
|
return null;
|
|
8726
8891
|
}
|
|
8727
8892
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8836,7 +9001,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8836
9001
|
});
|
|
8837
9002
|
|
|
8838
9003
|
// src/rules/prefer-zod-enum.ts
|
|
8839
|
-
var
|
|
9004
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8840
9005
|
var prefer_zod_enum_default = createRule({
|
|
8841
9006
|
name: "prefer-zod-enum",
|
|
8842
9007
|
meta: {
|
|
@@ -8856,25 +9021,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
8856
9021
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8857
9022
|
function enumValues(node) {
|
|
8858
9023
|
const callee = node.callee;
|
|
8859
|
-
if (callee.type !==
|
|
9024
|
+
if (callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils58.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8860
9025
|
return null;
|
|
8861
9026
|
}
|
|
8862
9027
|
const argument = node.arguments[0];
|
|
8863
|
-
if (argument === void 0 || argument.type !==
|
|
9028
|
+
if (argument === void 0 || argument.type !== import_utils58.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
8864
9029
|
return null;
|
|
8865
9030
|
}
|
|
8866
9031
|
const values = [];
|
|
8867
9032
|
let canFix = true;
|
|
8868
9033
|
for (const element of argument.elements) {
|
|
8869
|
-
if (element?.type ===
|
|
9034
|
+
if (element?.type === import_utils58.AST_NODE_TYPES.SpreadElement) {
|
|
8870
9035
|
canFix = false;
|
|
8871
9036
|
continue;
|
|
8872
9037
|
}
|
|
8873
|
-
if (element === null || element.type !==
|
|
9038
|
+
if (element === null || element.type !== import_utils58.AST_NODE_TYPES.CallExpression || element.callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils58.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
8874
9039
|
return null;
|
|
8875
9040
|
}
|
|
8876
9041
|
const value = element.arguments[0];
|
|
8877
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
9042
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== import_utils58.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
8878
9043
|
canFix = false;
|
|
8879
9044
|
continue;
|
|
8880
9045
|
}
|
|
@@ -8884,11 +9049,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
8884
9049
|
}
|
|
8885
9050
|
function buildFix(node, values) {
|
|
8886
9051
|
const argument = node.arguments[0];
|
|
8887
|
-
if (argument === void 0 || argument.type !==
|
|
9052
|
+
if (argument === void 0 || argument.type !== import_utils58.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8888
9053
|
return void 0;
|
|
8889
9054
|
}
|
|
8890
9055
|
const callee = node.callee;
|
|
8891
|
-
if (callee.type !==
|
|
9056
|
+
if (callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8892
9057
|
return void 0;
|
|
8893
9058
|
}
|
|
8894
9059
|
return (fixer) => [
|
|
@@ -8905,7 +9070,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8905
9070
|
return;
|
|
8906
9071
|
}
|
|
8907
9072
|
for (const specifier of node.specifiers) {
|
|
8908
|
-
if (specifier.type ===
|
|
9073
|
+
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") {
|
|
8909
9074
|
zodNamespaces.add(specifier.local.name);
|
|
8910
9075
|
}
|
|
8911
9076
|
}
|
|
@@ -8927,7 +9092,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8927
9092
|
});
|
|
8928
9093
|
|
|
8929
9094
|
// src/rules/prefer-zod-infer.ts
|
|
8930
|
-
var
|
|
9095
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
8931
9096
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8932
9097
|
"describe",
|
|
8933
9098
|
"refine",
|
|
@@ -8964,44 +9129,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8964
9129
|
"Schema"
|
|
8965
9130
|
]);
|
|
8966
9131
|
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: [
|
|
9132
|
+
string: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9133
|
+
email: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9134
|
+
url: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9135
|
+
uuid: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9136
|
+
ulid: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9137
|
+
cuid: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9138
|
+
cuid2: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9139
|
+
nanoid: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9140
|
+
iso: [import_utils59.AST_NODE_TYPES.TSStringKeyword],
|
|
9141
|
+
number: [import_utils59.AST_NODE_TYPES.TSNumberKeyword],
|
|
9142
|
+
int: [import_utils59.AST_NODE_TYPES.TSNumberKeyword],
|
|
9143
|
+
float32: [import_utils59.AST_NODE_TYPES.TSNumberKeyword],
|
|
9144
|
+
float64: [import_utils59.AST_NODE_TYPES.TSNumberKeyword],
|
|
9145
|
+
boolean: [import_utils59.AST_NODE_TYPES.TSBooleanKeyword],
|
|
9146
|
+
bigint: [import_utils59.AST_NODE_TYPES.TSBigIntKeyword],
|
|
9147
|
+
symbol: [import_utils59.AST_NODE_TYPES.TSSymbolKeyword],
|
|
9148
|
+
any: [import_utils59.AST_NODE_TYPES.TSAnyKeyword],
|
|
9149
|
+
unknown: [import_utils59.AST_NODE_TYPES.TSUnknownKeyword],
|
|
9150
|
+
never: [import_utils59.AST_NODE_TYPES.TSNeverKeyword],
|
|
9151
|
+
void: [import_utils59.AST_NODE_TYPES.TSVoidKeyword],
|
|
9152
|
+
null: [import_utils59.AST_NODE_TYPES.TSNullKeyword],
|
|
9153
|
+
undefined: [import_utils59.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
9154
|
+
literal: [import_utils59.AST_NODE_TYPES.TSLiteralType],
|
|
9155
|
+
date: [import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9156
|
+
array: [import_utils59.AST_NODE_TYPES.TSArrayType, import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9157
|
+
tuple: [import_utils59.AST_NODE_TYPES.TSTupleType],
|
|
9158
|
+
object: [import_utils59.AST_NODE_TYPES.TSTypeLiteral, import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9159
|
+
strictObject: [import_utils59.AST_NODE_TYPES.TSTypeLiteral, import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9160
|
+
looseObject: [import_utils59.AST_NODE_TYPES.TSTypeLiteral, import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9161
|
+
record: [import_utils59.AST_NODE_TYPES.TSTypeReference, import_utils59.AST_NODE_TYPES.TSTypeLiteral],
|
|
9162
|
+
map: [import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9163
|
+
set: [import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9164
|
+
promise: [import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9165
|
+
enum: [import_utils59.AST_NODE_TYPES.TSUnionType, import_utils59.AST_NODE_TYPES.TSTypeReference, import_utils59.AST_NODE_TYPES.TSLiteralType],
|
|
9166
|
+
nativeEnum: [import_utils59.AST_NODE_TYPES.TSUnionType, import_utils59.AST_NODE_TYPES.TSTypeReference, import_utils59.AST_NODE_TYPES.TSLiteralType],
|
|
9167
|
+
union: [import_utils59.AST_NODE_TYPES.TSUnionType, import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9168
|
+
discriminatedUnion: [import_utils59.AST_NODE_TYPES.TSUnionType, import_utils59.AST_NODE_TYPES.TSTypeReference],
|
|
9169
|
+
intersection: [import_utils59.AST_NODE_TYPES.TSIntersectionType, import_utils59.AST_NODE_TYPES.TSTypeReference]
|
|
9005
9170
|
};
|
|
9006
9171
|
function normalizeSchemaName(name) {
|
|
9007
9172
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9010,20 +9175,20 @@ function normalizeTypeName(name) {
|
|
|
9010
9175
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9011
9176
|
}
|
|
9012
9177
|
function unwrapNullish(annotation) {
|
|
9013
|
-
if (annotation.type !==
|
|
9178
|
+
if (annotation.type !== import_utils59.AST_NODE_TYPES.TSUnionType) {
|
|
9014
9179
|
return {
|
|
9015
9180
|
core: annotation,
|
|
9016
|
-
nullable: annotation.type ===
|
|
9181
|
+
nullable: annotation.type === import_utils59.AST_NODE_TYPES.TSNullKeyword
|
|
9017
9182
|
};
|
|
9018
9183
|
}
|
|
9019
9184
|
const rest = [];
|
|
9020
9185
|
let nullable = false;
|
|
9021
9186
|
for (const member of annotation.types) {
|
|
9022
|
-
if (member.type ===
|
|
9187
|
+
if (member.type === import_utils59.AST_NODE_TYPES.TSNullKeyword) {
|
|
9023
9188
|
nullable = true;
|
|
9024
9189
|
continue;
|
|
9025
9190
|
}
|
|
9026
|
-
if (member.type ===
|
|
9191
|
+
if (member.type === import_utils59.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
9027
9192
|
continue;
|
|
9028
9193
|
}
|
|
9029
9194
|
rest.push(member);
|
|
@@ -9088,14 +9253,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9088
9253
|
function zodCallChain(node) {
|
|
9089
9254
|
const chain = [];
|
|
9090
9255
|
let current = node;
|
|
9091
|
-
while (current.type ===
|
|
9256
|
+
while (current.type === import_utils59.AST_NODE_TYPES.CallExpression) {
|
|
9092
9257
|
const callee = current.callee;
|
|
9093
|
-
if (callee.type !==
|
|
9258
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9094
9259
|
return null;
|
|
9095
9260
|
}
|
|
9096
9261
|
chain.push(current);
|
|
9097
9262
|
const receiver = callee.object;
|
|
9098
|
-
if (receiver.type ===
|
|
9263
|
+
if (receiver.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9099
9264
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9100
9265
|
}
|
|
9101
9266
|
current = receiver;
|
|
@@ -9104,19 +9269,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9104
9269
|
}
|
|
9105
9270
|
function methodName(call) {
|
|
9106
9271
|
const callee = call.callee;
|
|
9107
|
-
return callee.type ===
|
|
9272
|
+
return callee.type === import_utils59.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils59.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
9108
9273
|
}
|
|
9109
9274
|
function schemaField(node) {
|
|
9110
9275
|
const modifiers = [];
|
|
9111
9276
|
let current = node;
|
|
9112
9277
|
let leaf = null;
|
|
9113
|
-
while (current.type ===
|
|
9278
|
+
while (current.type === import_utils59.AST_NODE_TYPES.CallExpression) {
|
|
9114
9279
|
const callee = current.callee;
|
|
9115
|
-
if (callee.type !==
|
|
9280
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9116
9281
|
break;
|
|
9117
9282
|
}
|
|
9118
9283
|
const receiver = callee.object;
|
|
9119
|
-
if (receiver.type ===
|
|
9284
|
+
if (receiver.type === import_utils59.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9120
9285
|
leaf = callee.property.name;
|
|
9121
9286
|
break;
|
|
9122
9287
|
}
|
|
@@ -9147,16 +9312,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9147
9312
|
return null;
|
|
9148
9313
|
}
|
|
9149
9314
|
const shape = base.arguments[0];
|
|
9150
|
-
if (shape === void 0 || shape.type !==
|
|
9315
|
+
if (shape === void 0 || shape.type !== import_utils59.AST_NODE_TYPES.ObjectExpression) {
|
|
9151
9316
|
return null;
|
|
9152
9317
|
}
|
|
9153
9318
|
const fields = /* @__PURE__ */ new Map();
|
|
9154
9319
|
for (const property of shape.properties) {
|
|
9155
|
-
if (property.type !==
|
|
9320
|
+
if (property.type !== import_utils59.AST_NODE_TYPES.Property || property.computed) {
|
|
9156
9321
|
return null;
|
|
9157
9322
|
}
|
|
9158
9323
|
const { key } = property;
|
|
9159
|
-
const name = key.type ===
|
|
9324
|
+
const name = key.type === import_utils59.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils59.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
9160
9325
|
if (name === null) {
|
|
9161
9326
|
return null;
|
|
9162
9327
|
}
|
|
@@ -9167,11 +9332,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9167
9332
|
function typeMembers(members) {
|
|
9168
9333
|
const result = /* @__PURE__ */ new Map();
|
|
9169
9334
|
for (const member of members) {
|
|
9170
|
-
if (member.type !==
|
|
9335
|
+
if (member.type !== import_utils59.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
9171
9336
|
return null;
|
|
9172
9337
|
}
|
|
9173
9338
|
const { key } = member;
|
|
9174
|
-
const name = key.type ===
|
|
9339
|
+
const name = key.type === import_utils59.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils59.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
9175
9340
|
if (name === null) {
|
|
9176
9341
|
return null;
|
|
9177
9342
|
}
|
|
@@ -9185,8 +9350,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9185
9350
|
return result.size === 0 ? null : result;
|
|
9186
9351
|
}
|
|
9187
9352
|
function collectConstrainedNames(node) {
|
|
9188
|
-
if (node.type ===
|
|
9189
|
-
if (node.typeName.type ===
|
|
9353
|
+
if (node.type === import_utils59.AST_NODE_TYPES.TSTypeReference) {
|
|
9354
|
+
if (node.typeName.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9190
9355
|
constrainedTypeNames.add(node.typeName.name);
|
|
9191
9356
|
}
|
|
9192
9357
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9194,11 +9359,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9194
9359
|
}
|
|
9195
9360
|
return;
|
|
9196
9361
|
}
|
|
9197
|
-
if (node.type ===
|
|
9362
|
+
if (node.type === import_utils59.AST_NODE_TYPES.TSArrayType) {
|
|
9198
9363
|
collectConstrainedNames(node.elementType);
|
|
9199
9364
|
return;
|
|
9200
9365
|
}
|
|
9201
|
-
if (node.type ===
|
|
9366
|
+
if (node.type === import_utils59.AST_NODE_TYPES.TSUnionType || node.type === import_utils59.AST_NODE_TYPES.TSIntersectionType) {
|
|
9202
9367
|
for (const member of node.types) {
|
|
9203
9368
|
collectConstrainedNames(member);
|
|
9204
9369
|
}
|
|
@@ -9242,13 +9407,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9242
9407
|
return;
|
|
9243
9408
|
}
|
|
9244
9409
|
for (const specifier of node.specifiers) {
|
|
9245
|
-
if (specifier.type ===
|
|
9410
|
+
if (specifier.type === import_utils59.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils59.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils59.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils59.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
9246
9411
|
zodNamespaces.add(specifier.local.name);
|
|
9247
9412
|
}
|
|
9248
9413
|
}
|
|
9249
9414
|
},
|
|
9250
9415
|
VariableDeclarator(node) {
|
|
9251
|
-
if (node.id.type !==
|
|
9416
|
+
if (node.id.type !== import_utils59.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
9252
9417
|
return;
|
|
9253
9418
|
}
|
|
9254
9419
|
const fields = schemaFields(node.init);
|
|
@@ -9258,14 +9423,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9258
9423
|
},
|
|
9259
9424
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9260
9425
|
"MemberExpression[computed=false]"(node) {
|
|
9261
|
-
if (node.object.type ===
|
|
9426
|
+
if (node.object.type === import_utils59.AST_NODE_TYPES.Identifier && node.property.type === import_utils59.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9262
9427
|
reshapedSchemaNames.add(node.object.name);
|
|
9263
9428
|
}
|
|
9264
9429
|
},
|
|
9265
9430
|
/** Records every type argument carried by a Zod constraint. */
|
|
9266
9431
|
TSTypeReference(node) {
|
|
9267
9432
|
const { typeName } = node;
|
|
9268
|
-
const referenced = typeName.type ===
|
|
9433
|
+
const referenced = typeName.type === import_utils59.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils59.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils59.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
9269
9434
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9270
9435
|
return;
|
|
9271
9436
|
}
|
|
@@ -9283,7 +9448,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9283
9448
|
}
|
|
9284
9449
|
},
|
|
9285
9450
|
TSTypeAliasDeclaration(node) {
|
|
9286
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9451
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils59.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9287
9452
|
return;
|
|
9288
9453
|
}
|
|
9289
9454
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9328,10 +9493,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9328
9493
|
});
|
|
9329
9494
|
|
|
9330
9495
|
// src/rules/require-assert-never.ts
|
|
9331
|
-
var
|
|
9496
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9332
9497
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9333
|
-
if (statement.type ===
|
|
9334
|
-
if (statement.type ===
|
|
9498
|
+
if (statement.type === import_utils60.AST_NODE_TYPES.EmptyStatement) return false;
|
|
9499
|
+
if (statement.type === import_utils60.AST_NODE_TYPES.BlockStatement) {
|
|
9335
9500
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9336
9501
|
}
|
|
9337
9502
|
return true;
|
|
@@ -9347,7 +9512,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9347
9512
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9348
9513
|
}
|
|
9349
9514
|
const only = defaultCase.consequent[0];
|
|
9350
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9515
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils60.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
9351
9516
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9352
9517
|
}
|
|
9353
9518
|
return false;
|
|
@@ -9387,7 +9552,7 @@ var require_assert_never_default = createRule({
|
|
|
9387
9552
|
});
|
|
9388
9553
|
|
|
9389
9554
|
// src/rules/require-fetch-timeout.ts
|
|
9390
|
-
var
|
|
9555
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9391
9556
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9392
9557
|
"globalThis",
|
|
9393
9558
|
"window",
|
|
@@ -9403,14 +9568,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9403
9568
|
return false;
|
|
9404
9569
|
}
|
|
9405
9570
|
function initProvablyLacksSignal(init) {
|
|
9406
|
-
if (init.type !==
|
|
9571
|
+
if (init.type !== import_utils61.AST_NODE_TYPES.ObjectExpression) {
|
|
9407
9572
|
return false;
|
|
9408
9573
|
}
|
|
9409
9574
|
for (const prop of init.properties) {
|
|
9410
|
-
if (prop.type ===
|
|
9575
|
+
if (prop.type === import_utils61.AST_NODE_TYPES.SpreadElement) {
|
|
9411
9576
|
return false;
|
|
9412
9577
|
}
|
|
9413
|
-
if (prop.key.type ===
|
|
9578
|
+
if (prop.key.type === import_utils61.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils61.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
9414
9579
|
return false;
|
|
9415
9580
|
}
|
|
9416
9581
|
if (prop.computed) {
|
|
@@ -9420,7 +9585,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9420
9585
|
return true;
|
|
9421
9586
|
}
|
|
9422
9587
|
function isStringish(node) {
|
|
9423
|
-
return node.type ===
|
|
9588
|
+
return node.type === import_utils61.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils61.AST_NODE_TYPES.TemplateLiteral;
|
|
9424
9589
|
}
|
|
9425
9590
|
var require_fetch_timeout_default = createRule({
|
|
9426
9591
|
name: "require-fetch-timeout",
|
|
@@ -9457,14 +9622,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9457
9622
|
}
|
|
9458
9623
|
function resolvesToGlobal(identifier) {
|
|
9459
9624
|
const scope = context.sourceCode.getScope(identifier);
|
|
9460
|
-
const variable =
|
|
9625
|
+
const variable = import_utils61.ASTUtils.findVariable(scope, identifier.name);
|
|
9461
9626
|
return variable === null || variable.defs.length === 0;
|
|
9462
9627
|
}
|
|
9463
9628
|
function isGlobalFetchCall2(callee) {
|
|
9464
|
-
if (callee.type ===
|
|
9629
|
+
if (callee.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9465
9630
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9466
9631
|
}
|
|
9467
|
-
return callee.type ===
|
|
9632
|
+
return callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils61.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9468
9633
|
}
|
|
9469
9634
|
return {
|
|
9470
9635
|
CallExpression(node) {
|
|
@@ -9484,7 +9649,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9484
9649
|
});
|
|
9485
9650
|
|
|
9486
9651
|
// src/rules/require-interface-for-injected-service.ts
|
|
9487
|
-
var
|
|
9652
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
9488
9653
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9489
9654
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9490
9655
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9492,20 +9657,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9492
9657
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9493
9658
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9494
9659
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9495
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9496
|
-
var qualifiedName = (name) => name.type ===
|
|
9660
|
+
var isExportedClass = (node) => node.parent.type === import_utils62.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils62.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
9661
|
+
var qualifiedName = (name) => name.type === import_utils62.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils62.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9497
9662
|
var readTypeReference = (annotation) => {
|
|
9498
|
-
if (annotation === void 0 || annotation.type !==
|
|
9663
|
+
if (annotation === void 0 || annotation.type !== import_utils62.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9499
9664
|
const { typeName } = annotation;
|
|
9500
|
-
const rightmost = typeName.type ===
|
|
9665
|
+
const rightmost = typeName.type === import_utils62.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils62.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
9501
9666
|
if (rightmost === null) return null;
|
|
9502
9667
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9503
9668
|
};
|
|
9504
9669
|
var namedParameterCollaborator = (annotated) => {
|
|
9505
9670
|
let target = annotated;
|
|
9506
|
-
if (target.type ===
|
|
9507
|
-
if (target.type ===
|
|
9508
|
-
if (target.type !==
|
|
9671
|
+
if (target.type === import_utils62.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
9672
|
+
if (target.type === import_utils62.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9673
|
+
if (target.type !== import_utils62.AST_NODE_TYPES.Identifier) return null;
|
|
9509
9674
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9510
9675
|
if (reference === null) return null;
|
|
9511
9676
|
return { name: target.name, ...reference };
|
|
@@ -9513,8 +9678,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9513
9678
|
var propertySignatureTypes = (members) => {
|
|
9514
9679
|
const types = /* @__PURE__ */ new Map();
|
|
9515
9680
|
for (const member of members) {
|
|
9516
|
-
if (member.type !==
|
|
9517
|
-
if (member.computed || member.key.type !==
|
|
9681
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
9682
|
+
if (member.computed || member.key.type !== import_utils62.AST_NODE_TYPES.Identifier) continue;
|
|
9518
9683
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9519
9684
|
if (reference === null) continue;
|
|
9520
9685
|
types.set(member.key.name, reference);
|
|
@@ -9525,18 +9690,18 @@ var fileTypeIndex = (program) => {
|
|
|
9525
9690
|
const objects = /* @__PURE__ */ new Map();
|
|
9526
9691
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9527
9692
|
for (const statement of program.body) {
|
|
9528
|
-
const declaration = statement.type ===
|
|
9529
|
-
if (declaration?.type ===
|
|
9693
|
+
const declaration = statement.type === import_utils62.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9694
|
+
if (declaration?.type === import_utils62.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
9530
9695
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9531
9696
|
continue;
|
|
9532
9697
|
}
|
|
9533
|
-
if (declaration?.type !==
|
|
9698
|
+
if (declaration?.type !== import_utils62.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9534
9699
|
const aliased = declaration.typeAnnotation;
|
|
9535
|
-
if (aliased.type ===
|
|
9700
|
+
if (aliased.type === import_utils62.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils62.AST_NODE_TYPES.TSConstructorType) {
|
|
9536
9701
|
functionAliases.add(declaration.id.name);
|
|
9537
9702
|
continue;
|
|
9538
9703
|
}
|
|
9539
|
-
const literals = aliased.type ===
|
|
9704
|
+
const literals = aliased.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils62.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
9540
9705
|
if (literals.length === 0) continue;
|
|
9541
9706
|
const merged = /* @__PURE__ */ new Map();
|
|
9542
9707
|
for (const literal of literals) {
|
|
@@ -9549,10 +9714,10 @@ var fileTypeIndex = (program) => {
|
|
|
9549
9714
|
return { objects, functionAliases };
|
|
9550
9715
|
};
|
|
9551
9716
|
var bagMemberTypes = (annotation, declared) => {
|
|
9552
|
-
if (annotation.type ===
|
|
9717
|
+
if (annotation.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9553
9718
|
return propertySignatureTypes(annotation.members);
|
|
9554
9719
|
}
|
|
9555
|
-
if (annotation.type !==
|
|
9720
|
+
if (annotation.type !== import_utils62.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils62.AST_NODE_TYPES.Identifier) {
|
|
9556
9721
|
return null;
|
|
9557
9722
|
}
|
|
9558
9723
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9564,11 +9729,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9564
9729
|
if (members === null) return [];
|
|
9565
9730
|
const collaborators = [];
|
|
9566
9731
|
for (const property of pattern.properties) {
|
|
9567
|
-
if (property.type !==
|
|
9568
|
-
if (property.key.type !==
|
|
9732
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || property.computed) continue;
|
|
9733
|
+
if (property.key.type !== import_utils62.AST_NODE_TYPES.Identifier) continue;
|
|
9569
9734
|
const key = property.key.name;
|
|
9570
|
-
const bound = property.value.type ===
|
|
9571
|
-
if (bound.type !==
|
|
9735
|
+
const bound = property.value.type === import_utils62.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
9736
|
+
if (bound.type !== import_utils62.AST_NODE_TYPES.Identifier) continue;
|
|
9572
9737
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9573
9738
|
const reference = members.get(key);
|
|
9574
9739
|
if (reference === void 0) continue;
|
|
@@ -9578,8 +9743,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9578
9743
|
};
|
|
9579
9744
|
var parameterCollaborators = (parameter, declared) => {
|
|
9580
9745
|
let target = parameter;
|
|
9581
|
-
if (target.type ===
|
|
9582
|
-
if (target.type ===
|
|
9746
|
+
if (target.type === import_utils62.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9747
|
+
if (target.type === import_utils62.AST_NODE_TYPES.ObjectPattern) {
|
|
9583
9748
|
return objectPatternCollaborators(target, declared);
|
|
9584
9749
|
}
|
|
9585
9750
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9598,17 +9763,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9598
9763
|
let constructedFields = 0;
|
|
9599
9764
|
if (body2 !== null && body2 !== void 0) {
|
|
9600
9765
|
for (const statement of body2.body) {
|
|
9601
|
-
if (statement.type !==
|
|
9766
|
+
if (statement.type !== import_utils62.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9602
9767
|
const expression = statement.expression;
|
|
9603
|
-
if (expression.type !==
|
|
9768
|
+
if (expression.type !== import_utils62.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils62.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils62.AST_NODE_TYPES.ThisExpression) {
|
|
9604
9769
|
continue;
|
|
9605
9770
|
}
|
|
9606
9771
|
const source = expression.right;
|
|
9607
|
-
if (source.type ===
|
|
9772
|
+
if (source.type === import_utils62.AST_NODE_TYPES.NewExpression) {
|
|
9608
9773
|
constructedFields += 1;
|
|
9609
|
-
} else if (source.type ===
|
|
9774
|
+
} else if (source.type === import_utils62.AST_NODE_TYPES.Identifier) {
|
|
9610
9775
|
storedFrom.add(source.name);
|
|
9611
|
-
} else if (source.type ===
|
|
9776
|
+
} else if (source.type === import_utils62.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils62.AST_NODE_TYPES.Identifier) {
|
|
9612
9777
|
storedFrom.add(source.object.name);
|
|
9613
9778
|
}
|
|
9614
9779
|
}
|
|
@@ -9616,7 +9781,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9616
9781
|
const collaborators = [];
|
|
9617
9782
|
for (const parameter of ctor.value.params) {
|
|
9618
9783
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9619
|
-
const stored = parameter.type ===
|
|
9784
|
+
const stored = parameter.type === import_utils62.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9620
9785
|
if (!stored) continue;
|
|
9621
9786
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9622
9787
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9650,19 +9815,19 @@ var subtreeHas = (root, found) => {
|
|
|
9650
9815
|
return hit;
|
|
9651
9816
|
};
|
|
9652
9817
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9653
|
-
if (node.type ===
|
|
9818
|
+
if (node.type === import_utils62.AST_NODE_TYPES.CallExpression) {
|
|
9654
9819
|
const { callee } = node;
|
|
9655
|
-
if (callee.type ===
|
|
9656
|
-
return callee.type ===
|
|
9820
|
+
if (callee.type === import_utils62.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9821
|
+
return callee.type === import_utils62.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils62.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9657
9822
|
}
|
|
9658
|
-
return node.type ===
|
|
9823
|
+
return node.type === import_utils62.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils62.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9659
9824
|
});
|
|
9660
9825
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9661
9826
|
var fileInterfaceNames = (program) => {
|
|
9662
9827
|
const names = [];
|
|
9663
9828
|
for (const statement of program.body) {
|
|
9664
|
-
const declaration = statement.type ===
|
|
9665
|
-
if (declaration?.type ===
|
|
9829
|
+
const declaration = statement.type === import_utils62.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9830
|
+
if (declaration?.type === import_utils62.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9666
9831
|
}
|
|
9667
9832
|
return names;
|
|
9668
9833
|
};
|
|
@@ -9680,11 +9845,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9680
9845
|
var publicMethodNames = (body2) => {
|
|
9681
9846
|
const names = [];
|
|
9682
9847
|
for (const member of body2.body) {
|
|
9683
|
-
if (member.type !==
|
|
9848
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9684
9849
|
if (member.kind !== "method" || member.static) continue;
|
|
9685
9850
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9686
|
-
if (member.key.type ===
|
|
9687
|
-
if (member.key.type ===
|
|
9851
|
+
if (member.key.type === import_utils62.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
9852
|
+
if (member.key.type === import_utils62.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
9688
9853
|
else names.push("\u2026");
|
|
9689
9854
|
}
|
|
9690
9855
|
return names;
|
|
@@ -9717,7 +9882,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9717
9882
|
if (node.implements.length > 0) return;
|
|
9718
9883
|
if (node.decorators.length > 0) return;
|
|
9719
9884
|
const ctor = node.body.body.find(
|
|
9720
|
-
(member) => member.type ===
|
|
9885
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
9721
9886
|
);
|
|
9722
9887
|
if (ctor === void 0) return;
|
|
9723
9888
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9745,19 +9910,97 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9745
9910
|
}
|
|
9746
9911
|
});
|
|
9747
9912
|
|
|
9913
|
+
// src/rules/require-static-next-matcher.ts
|
|
9914
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
9915
|
+
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
9916
|
+
function unwrapExpression(node) {
|
|
9917
|
+
if (node.type === import_utils63.AST_NODE_TYPES.TSAsExpression || node.type === import_utils63.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils63.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils63.AST_NODE_TYPES.TSTypeAssertion) {
|
|
9918
|
+
return unwrapExpression(node.expression);
|
|
9919
|
+
}
|
|
9920
|
+
return node;
|
|
9921
|
+
}
|
|
9922
|
+
function isStaticValue(node) {
|
|
9923
|
+
const value = unwrapExpression(node);
|
|
9924
|
+
if (value.type === import_utils63.AST_NODE_TYPES.Literal) {
|
|
9925
|
+
return true;
|
|
9926
|
+
}
|
|
9927
|
+
if (value.type === import_utils63.AST_NODE_TYPES.TemplateLiteral) {
|
|
9928
|
+
return value.expressions.length === 0;
|
|
9929
|
+
}
|
|
9930
|
+
if (value.type === import_utils63.AST_NODE_TYPES.ArrayExpression) {
|
|
9931
|
+
return value.elements.every(
|
|
9932
|
+
(element) => element !== null && element.type !== import_utils63.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
9933
|
+
);
|
|
9934
|
+
}
|
|
9935
|
+
if (value.type === import_utils63.AST_NODE_TYPES.ObjectExpression) {
|
|
9936
|
+
return value.properties.every(
|
|
9937
|
+
(property) => property.type === import_utils63.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils63.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
9938
|
+
);
|
|
9939
|
+
}
|
|
9940
|
+
return false;
|
|
9941
|
+
}
|
|
9942
|
+
function propertyName2(property) {
|
|
9943
|
+
if (property.computed) return null;
|
|
9944
|
+
if (property.key.type === import_utils63.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
9945
|
+
return typeof property.key.value === "string" ? property.key.value : null;
|
|
9946
|
+
}
|
|
9947
|
+
var require_static_next_matcher_default = createRule({
|
|
9948
|
+
name: "require-static-next-matcher",
|
|
9949
|
+
meta: {
|
|
9950
|
+
type: "problem",
|
|
9951
|
+
docs: {
|
|
9952
|
+
description: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals."
|
|
9953
|
+
},
|
|
9954
|
+
schema: [],
|
|
9955
|
+
messages: {
|
|
9956
|
+
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."
|
|
9957
|
+
}
|
|
9958
|
+
},
|
|
9959
|
+
defaultOptions: [],
|
|
9960
|
+
create(context) {
|
|
9961
|
+
if (!NEXT_ENTRY_FILE.test(context.filename)) {
|
|
9962
|
+
return {};
|
|
9963
|
+
}
|
|
9964
|
+
return {
|
|
9965
|
+
ExportNamedDeclaration(node) {
|
|
9966
|
+
if (node.declaration?.type !== import_utils63.AST_NODE_TYPES.VariableDeclaration) {
|
|
9967
|
+
return;
|
|
9968
|
+
}
|
|
9969
|
+
for (const declaration of node.declaration.declarations) {
|
|
9970
|
+
if (declaration.id.type !== import_utils63.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
9971
|
+
continue;
|
|
9972
|
+
}
|
|
9973
|
+
const config = unwrapExpression(declaration.init);
|
|
9974
|
+
if (config.type !== import_utils63.AST_NODE_TYPES.ObjectExpression) {
|
|
9975
|
+
continue;
|
|
9976
|
+
}
|
|
9977
|
+
for (const property of config.properties) {
|
|
9978
|
+
if (property.type !== import_utils63.AST_NODE_TYPES.Property || propertyName2(property) !== "matcher" || property.value.type === import_utils63.AST_NODE_TYPES.AssignmentPattern) {
|
|
9979
|
+
continue;
|
|
9980
|
+
}
|
|
9981
|
+
if (!isStaticValue(property.value)) {
|
|
9982
|
+
context.report({ node: property.value, messageId: "dynamicMatcher" });
|
|
9983
|
+
}
|
|
9984
|
+
}
|
|
9985
|
+
}
|
|
9986
|
+
}
|
|
9987
|
+
};
|
|
9988
|
+
}
|
|
9989
|
+
});
|
|
9990
|
+
|
|
9748
9991
|
// src/rules/require-zod-form-validation.ts
|
|
9749
|
-
var
|
|
9992
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
9750
9993
|
var looksLikeZodSchema = (node) => {
|
|
9751
9994
|
let current = node;
|
|
9752
9995
|
while (true) {
|
|
9753
|
-
if (current.type ===
|
|
9996
|
+
if (current.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9754
9997
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9755
9998
|
}
|
|
9756
|
-
if (current.type ===
|
|
9999
|
+
if (current.type === import_utils64.AST_NODE_TYPES.CallExpression) {
|
|
9757
10000
|
current = current.callee;
|
|
9758
10001
|
continue;
|
|
9759
10002
|
}
|
|
9760
|
-
if (current.type ===
|
|
10003
|
+
if (current.type === import_utils64.AST_NODE_TYPES.MemberExpression) {
|
|
9761
10004
|
current = current.object;
|
|
9762
10005
|
continue;
|
|
9763
10006
|
}
|
|
@@ -9765,23 +10008,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9765
10008
|
}
|
|
9766
10009
|
};
|
|
9767
10010
|
var isZodParseCall = (node) => {
|
|
9768
|
-
if (node.type !==
|
|
10011
|
+
if (node.type !== import_utils64.AST_NODE_TYPES.CallExpression) return false;
|
|
9769
10012
|
const callee = node.callee;
|
|
9770
|
-
if (callee.type !==
|
|
10013
|
+
if (callee.type !== import_utils64.AST_NODE_TYPES.MemberExpression) return false;
|
|
9771
10014
|
if (callee.computed) return false;
|
|
9772
|
-
if (callee.property.type !==
|
|
10015
|
+
if (callee.property.type !== import_utils64.AST_NODE_TYPES.Identifier) return false;
|
|
9773
10016
|
const method = callee.property.name;
|
|
9774
10017
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9775
10018
|
return looksLikeZodSchema(callee.object);
|
|
9776
10019
|
};
|
|
9777
10020
|
var isFormDataMethodCall = (node) => {
|
|
9778
10021
|
let current = node;
|
|
9779
|
-
if (current.type ===
|
|
10022
|
+
if (current.type === import_utils64.AST_NODE_TYPES.AwaitExpression) {
|
|
9780
10023
|
current = current.argument;
|
|
9781
10024
|
}
|
|
9782
|
-
if (current.type !==
|
|
10025
|
+
if (current.type !== import_utils64.AST_NODE_TYPES.CallExpression) return false;
|
|
9783
10026
|
const callee = current.callee;
|
|
9784
|
-
return callee.type ===
|
|
10027
|
+
return callee.type === import_utils64.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils64.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
9785
10028
|
};
|
|
9786
10029
|
var require_zod_form_validation_default = createRule({
|
|
9787
10030
|
name: "require-zod-form-validation",
|
|
@@ -9801,14 +10044,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9801
10044
|
return {};
|
|
9802
10045
|
}
|
|
9803
10046
|
const isFormSourceIdentifier = (node) => {
|
|
9804
|
-
if (node.type !==
|
|
10047
|
+
if (node.type !== import_utils64.AST_NODE_TYPES.Identifier) return false;
|
|
9805
10048
|
if (/formdata/i.test(node.name)) return true;
|
|
9806
10049
|
let scope = context.sourceCode.getScope(node);
|
|
9807
10050
|
while (scope !== null) {
|
|
9808
10051
|
const variable = scope.set.get(node.name);
|
|
9809
10052
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9810
10053
|
const def = variable.defs[0];
|
|
9811
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
10054
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils64.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
9812
10055
|
return isFormDataMethodCall(def.node.init);
|
|
9813
10056
|
}
|
|
9814
10057
|
return false;
|
|
@@ -9819,8 +10062,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9819
10062
|
};
|
|
9820
10063
|
const isFormDataGetCall = (node) => {
|
|
9821
10064
|
const callee = node.callee;
|
|
9822
|
-
if (callee.type !==
|
|
9823
|
-
if (callee.property.type !==
|
|
10065
|
+
if (callee.type !== import_utils64.AST_NODE_TYPES.MemberExpression) return false;
|
|
10066
|
+
if (callee.property.type !== import_utils64.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
9824
10067
|
return false;
|
|
9825
10068
|
}
|
|
9826
10069
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9835,11 +10078,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9835
10078
|
};
|
|
9836
10079
|
const isInstanceofNarrowing = (node) => {
|
|
9837
10080
|
const parent = node.parent;
|
|
9838
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
10081
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils64.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils64.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9839
10082
|
};
|
|
9840
10083
|
const boundDeclarator = (node) => {
|
|
9841
10084
|
const parent = node.parent;
|
|
9842
|
-
if (parent.type ===
|
|
10085
|
+
if (parent.type === import_utils64.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9843
10086
|
return parent;
|
|
9844
10087
|
}
|
|
9845
10088
|
return null;
|
|
@@ -9867,7 +10110,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
9867
10110
|
});
|
|
9868
10111
|
|
|
9869
10112
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
9870
|
-
var
|
|
10113
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
9871
10114
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
9872
10115
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
9873
10116
|
var INSERT_GATE = /insert/i;
|
|
@@ -9898,7 +10141,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9898
10141
|
});
|
|
9899
10142
|
|
|
9900
10143
|
// src/rules/zod-naming-convention.ts
|
|
9901
|
-
var
|
|
10144
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
9902
10145
|
var CONVENTIONS = {
|
|
9903
10146
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9904
10147
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9923,15 +10166,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9923
10166
|
"registry",
|
|
9924
10167
|
"implement"
|
|
9925
10168
|
]);
|
|
9926
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10169
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils66.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
9927
10170
|
var calleeChainStartsWithZ = (node) => {
|
|
9928
10171
|
let current = node;
|
|
9929
|
-
while (current.type ===
|
|
10172
|
+
while (current.type === import_utils66.AST_NODE_TYPES.MemberExpression) {
|
|
9930
10173
|
const receiver = current.object;
|
|
9931
|
-
if (receiver.type ===
|
|
10174
|
+
if (receiver.type === import_utils66.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
9932
10175
|
return true;
|
|
9933
10176
|
}
|
|
9934
|
-
if (receiver.type ===
|
|
10177
|
+
if (receiver.type === import_utils66.AST_NODE_TYPES.CallExpression) {
|
|
9935
10178
|
current = receiver.callee;
|
|
9936
10179
|
continue;
|
|
9937
10180
|
}
|
|
@@ -9976,13 +10219,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9976
10219
|
VariableDeclarator(node) {
|
|
9977
10220
|
const init = node.init;
|
|
9978
10221
|
if (init === null || init === void 0) return;
|
|
9979
|
-
if (init.type !==
|
|
10222
|
+
if (init.type !== import_utils66.AST_NODE_TYPES.CallExpression) return;
|
|
9980
10223
|
const callee = init.callee;
|
|
9981
|
-
if (callee.type !==
|
|
10224
|
+
if (callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression) return;
|
|
9982
10225
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9983
10226
|
const terminal = terminalMethodName(callee);
|
|
9984
10227
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9985
|
-
if (node.id.type !==
|
|
10228
|
+
if (node.id.type !== import_utils66.AST_NODE_TYPES.Identifier) return;
|
|
9986
10229
|
if (test.test(node.id.name)) return;
|
|
9987
10230
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9988
10231
|
context.report({
|
|
@@ -10062,6 +10305,7 @@ var rules = {
|
|
|
10062
10305
|
"no-enum": no_enum_default,
|
|
10063
10306
|
"no-fat-try-blocks": no_fat_try_blocks_default,
|
|
10064
10307
|
"no-hand-rolled-sleep": no_hand_rolled_sleep_default,
|
|
10308
|
+
"no-hand-rolled-spinner": no_hand_rolled_spinner_default,
|
|
10065
10309
|
"no-insecure-random-id": no_insecure_random_id_default,
|
|
10066
10310
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
10067
10311
|
"no-log-only-catch": no_log_only_catch_default,
|
|
@@ -10092,10 +10336,11 @@ var rules = {
|
|
|
10092
10336
|
"no-zod-native-enum": no_zod_native_enum_default,
|
|
10093
10337
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
10094
10338
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
10339
|
+
"prefer-input-group-search": prefer_input_group_search_default,
|
|
10095
10340
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
10096
10341
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
10097
|
-
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
10098
10342
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
10343
|
+
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
10099
10344
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
10100
10345
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
10101
10346
|
"prefer-server-actions": prefer_server_actions_default,
|
|
@@ -10107,13 +10352,14 @@ var rules = {
|
|
|
10107
10352
|
"require-assert-never": require_assert_never_default,
|
|
10108
10353
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
10109
10354
|
"require-interface-for-injected-service": require_interface_for_injected_service_default,
|
|
10355
|
+
"require-static-next-matcher": require_static_next_matcher_default,
|
|
10110
10356
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
10111
10357
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
10112
10358
|
"zod-naming-convention": zod_naming_convention_default
|
|
10113
10359
|
};
|
|
10114
10360
|
var meta = {
|
|
10115
10361
|
name: "@sarj/eslint-plugin",
|
|
10116
|
-
version: "9.
|
|
10362
|
+
version: "9.10.0"
|
|
10117
10363
|
};
|
|
10118
10364
|
var applicationOnlyRules = [
|
|
10119
10365
|
"no-restricted-library-load",
|
|
@@ -10129,6 +10375,7 @@ var recommendedRules = {
|
|
|
10129
10375
|
"@sarj/no-dynamic-sql": "warn",
|
|
10130
10376
|
"@sarj/no-fat-try-blocks": "warn",
|
|
10131
10377
|
"@sarj/no-hand-rolled-sleep": "warn",
|
|
10378
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10132
10379
|
"@sarj/no-insecure-random-id": "warn",
|
|
10133
10380
|
"@sarj/no-json-stringify-error": "warn",
|
|
10134
10381
|
"@sarj/no-log-only-catch": "warn",
|
|
@@ -10155,6 +10402,7 @@ var recommendedRules = {
|
|
|
10155
10402
|
"@sarj/no-zod-native-enum": "warn",
|
|
10156
10403
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10157
10404
|
"@sarj/prefer-discriminated-union": "warn",
|
|
10405
|
+
"@sarj/prefer-input-group-search": "error",
|
|
10158
10406
|
"@sarj/prefer-module-level-constant": "warn",
|
|
10159
10407
|
"@sarj/prefer-module-level-schema": "warn",
|
|
10160
10408
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
@@ -10169,6 +10417,7 @@ var recommendedRules = {
|
|
|
10169
10417
|
"@sarj/require-assert-never": "error",
|
|
10170
10418
|
"@sarj/require-fetch-timeout": "warn",
|
|
10171
10419
|
"@sarj/require-interface-for-injected-service": "warn",
|
|
10420
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10172
10421
|
"@sarj/require-zod-form-validation": "error",
|
|
10173
10422
|
"@sarj/store-insert-requires-on-conflict": "warn",
|
|
10174
10423
|
"@sarj/zod-naming-convention": "warn"
|
|
@@ -10184,6 +10433,7 @@ var strictRules = {
|
|
|
10184
10433
|
"@sarj/no-enum": "error",
|
|
10185
10434
|
"@sarj/no-fat-try-blocks": "error",
|
|
10186
10435
|
"@sarj/no-hand-rolled-sleep": "error",
|
|
10436
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10187
10437
|
"@sarj/no-insecure-random-id": "error",
|
|
10188
10438
|
"@sarj/no-json-stringify-error": "error",
|
|
10189
10439
|
"@sarj/no-log-only-catch": "error",
|
|
@@ -10213,6 +10463,7 @@ var strictRules = {
|
|
|
10213
10463
|
"@sarj/no-zod-native-enum": "error",
|
|
10214
10464
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10215
10465
|
"@sarj/prefer-discriminated-union": "error",
|
|
10466
|
+
"@sarj/prefer-input-group-search": "error",
|
|
10216
10467
|
"@sarj/prefer-module-level-constant": "error",
|
|
10217
10468
|
"@sarj/prefer-module-level-schema": "error",
|
|
10218
10469
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
@@ -10227,6 +10478,7 @@ var strictRules = {
|
|
|
10227
10478
|
"@sarj/require-assert-never": "error",
|
|
10228
10479
|
"@sarj/require-fetch-timeout": "error",
|
|
10229
10480
|
"@sarj/require-interface-for-injected-service": "error",
|
|
10481
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10230
10482
|
"@sarj/require-zod-form-validation": "error",
|
|
10231
10483
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
10232
10484
|
"@sarj/zod-naming-convention": "error"
|