@sarj/eslint-plugin 9.7.1 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -2
- package/dist/index.cjs +894 -571
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +877 -555
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
applicationOnlyRules: () => applicationOnlyRules,
|
|
33
34
|
default: () => index_default,
|
|
34
35
|
recommendedRules: () => recommendedRules,
|
|
35
36
|
renamedRules: () => renamedRules,
|
|
@@ -2381,8 +2382,60 @@ var no_hand_rolled_sleep_default = createRule({
|
|
|
2381
2382
|
}
|
|
2382
2383
|
});
|
|
2383
2384
|
|
|
2384
|
-
// src/rules/no-
|
|
2385
|
+
// src/rules/no-hand-rolled-spinner.ts
|
|
2385
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");
|
|
2386
2439
|
var STRONG_SECURITY_PATTERN = /token|secret|csrf|password|passwd|apikey|api[-_]?key|nonce|salt|uuid|authid/i;
|
|
2387
2440
|
var NON_SECURITY_ID_PATTERN = /temp|tmp|cache|correlation|request|req|trace|execution|dev|hmr|mock|test|perf|marker/i;
|
|
2388
2441
|
var PATH_OR_DOM_MARKER = /[\\/#]|\.[A-Za-z0-9]/;
|
|
@@ -2565,7 +2618,7 @@ var no_insecure_random_id_default = createRule({
|
|
|
2565
2618
|
});
|
|
2566
2619
|
|
|
2567
2620
|
// src/rules/no-json-stringify-error.ts
|
|
2568
|
-
var
|
|
2621
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
2569
2622
|
var ERROR_NAME_PATTERN = /^(e|err|error|ex|exc)$/i;
|
|
2570
2623
|
var ERROR_PROP_PATTERN = /^(cause|lastError|error|err|exception|originalError|innerError)$/i;
|
|
2571
2624
|
var SAFE_STRING_PROPS = /* @__PURE__ */ new Set(["message", "stack", "name"]);
|
|
@@ -2747,10 +2800,10 @@ var no_json_stringify_error_default = createRule({
|
|
|
2747
2800
|
});
|
|
2748
2801
|
|
|
2749
2802
|
// src/rules/no-log-only-catch.ts
|
|
2750
|
-
var
|
|
2803
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
2751
2804
|
|
|
2752
2805
|
// src/rules/_logging.ts
|
|
2753
|
-
var
|
|
2806
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
2754
2807
|
var LOG_METHODS = /* @__PURE__ */ new Set([
|
|
2755
2808
|
"debug",
|
|
2756
2809
|
"info",
|
|
@@ -2854,29 +2907,29 @@ function createLogMatcher(options = {}) {
|
|
|
2854
2907
|
// src/rules/no-log-only-catch.ts
|
|
2855
2908
|
var BENCHMARK_DIR_RE = /(?:^|[\\/])benchmarks?[\\/]/;
|
|
2856
2909
|
var SINGLE_STATEMENT_HOSTS = /* @__PURE__ */ new Set([
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
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
|
|
2863
2916
|
]);
|
|
2864
2917
|
var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2918
|
+
import_utils18.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
2919
|
+
import_utils18.AST_NODE_TYPES.FunctionDeclaration,
|
|
2920
|
+
import_utils18.AST_NODE_TYPES.FunctionExpression
|
|
2868
2921
|
]);
|
|
2869
2922
|
function statementSlot(node) {
|
|
2870
2923
|
const parent = node.parent;
|
|
2871
2924
|
if (parent === void 0) return null;
|
|
2872
2925
|
let list;
|
|
2873
2926
|
switch (parent.type) {
|
|
2874
|
-
case
|
|
2875
|
-
case
|
|
2876
|
-
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:
|
|
2877
2930
|
list = parent.body;
|
|
2878
2931
|
break;
|
|
2879
|
-
case
|
|
2932
|
+
case import_utils18.AST_NODE_TYPES.SwitchCase:
|
|
2880
2933
|
list = parent.consequent;
|
|
2881
2934
|
break;
|
|
2882
2935
|
default:
|
|
@@ -2895,20 +2948,20 @@ function hasFollowingStatement(node) {
|
|
|
2895
2948
|
function fallbackFollowsTry(tryStatement) {
|
|
2896
2949
|
const body2 = tryStatement.block.body;
|
|
2897
2950
|
const last = body2.at(-1);
|
|
2898
|
-
return last?.type ===
|
|
2951
|
+
return last?.type === import_utils18.AST_NODE_TYPES.ReturnStatement && hasFollowingStatement(tryStatement);
|
|
2899
2952
|
}
|
|
2900
2953
|
function isSeedValue(node) {
|
|
2901
|
-
const inner = node.type ===
|
|
2954
|
+
const inner = node.type === import_utils18.AST_NODE_TYPES.TSAsExpression ? node.expression : node;
|
|
2902
2955
|
switch (inner.type) {
|
|
2903
|
-
case
|
|
2956
|
+
case import_utils18.AST_NODE_TYPES.Literal:
|
|
2904
2957
|
return true;
|
|
2905
|
-
case
|
|
2958
|
+
case import_utils18.AST_NODE_TYPES.Identifier:
|
|
2906
2959
|
return inner.name === "undefined";
|
|
2907
|
-
case
|
|
2908
|
-
return inner.argument.type ===
|
|
2909
|
-
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:
|
|
2910
2963
|
return inner.elements.length === 0;
|
|
2911
|
-
case
|
|
2964
|
+
case import_utils18.AST_NODE_TYPES.ObjectExpression:
|
|
2912
2965
|
return inner.properties.length === 0;
|
|
2913
2966
|
default:
|
|
2914
2967
|
return false;
|
|
@@ -2918,14 +2971,14 @@ function seededFallbackHandled(tryStatement, scope) {
|
|
|
2918
2971
|
const slot = statementSlot(tryStatement);
|
|
2919
2972
|
if (slot === null || slot.index === 0) return false;
|
|
2920
2973
|
const previous = slot.list[slot.index - 1];
|
|
2921
|
-
if (previous?.type !==
|
|
2974
|
+
if (previous?.type !== import_utils18.AST_NODE_TYPES.VariableDeclaration || previous.kind === "const") {
|
|
2922
2975
|
return false;
|
|
2923
2976
|
}
|
|
2924
2977
|
const declarator = previous.declarations[0];
|
|
2925
2978
|
if (previous.declarations.length !== 1 || declarator === void 0) return false;
|
|
2926
|
-
if (declarator.id.type !==
|
|
2979
|
+
if (declarator.id.type !== import_utils18.AST_NODE_TYPES.Identifier) return false;
|
|
2927
2980
|
if (declarator.init == null || !isSeedValue(declarator.init)) return false;
|
|
2928
|
-
const variable =
|
|
2981
|
+
const variable = import_utils18.ASTUtils.findVariable(scope, declarator.id.name);
|
|
2929
2982
|
if (variable === null) return false;
|
|
2930
2983
|
const [tryStart, tryEnd] = tryStatement.block.range;
|
|
2931
2984
|
let writtenInTry = false;
|
|
@@ -2975,7 +3028,7 @@ var no_log_only_catch_default = createRule({
|
|
|
2975
3028
|
const tryStatement = node.parent;
|
|
2976
3029
|
if (hasCommentDirectlyAbove(tryStatement) || hasCommentDirectlyAbove(node)) return true;
|
|
2977
3030
|
const block = tryStatement.parent;
|
|
2978
|
-
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)) {
|
|
2979
3032
|
return false;
|
|
2980
3033
|
}
|
|
2981
3034
|
return hasCommentDirectlyAbove(block.parent);
|
|
@@ -3012,7 +3065,7 @@ var no_log_only_catch_default = createRule({
|
|
|
3012
3065
|
});
|
|
3013
3066
|
|
|
3014
3067
|
// src/rules/_prose-budget.ts
|
|
3015
|
-
var
|
|
3068
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
3016
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;
|
|
3017
3070
|
var LICENSE_RE2 = /\b(?:copyright|spdx-license-identifier|licensed under)\b/i;
|
|
3018
3071
|
var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
|
|
@@ -3068,25 +3121,25 @@ function proseGroups(filename, sourceCode, includeValueTags = false) {
|
|
|
3068
3121
|
return groups;
|
|
3069
3122
|
}
|
|
3070
3123
|
function annotatedParameter(parameter) {
|
|
3071
|
-
if (parameter.type ===
|
|
3072
|
-
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;
|
|
3073
3126
|
return "typeAnnotation" in target && target.typeAnnotation != null;
|
|
3074
3127
|
}
|
|
3075
3128
|
function typedFunction(node) {
|
|
3076
3129
|
switch (node.type) {
|
|
3077
|
-
case
|
|
3078
|
-
case
|
|
3130
|
+
case import_utils19.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3131
|
+
case import_utils19.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3079
3132
|
return node.declaration != null && typedFunction(node.declaration);
|
|
3080
|
-
case
|
|
3081
|
-
case
|
|
3133
|
+
case import_utils19.AST_NODE_TYPES.FunctionDeclaration:
|
|
3134
|
+
case import_utils19.AST_NODE_TYPES.TSDeclareFunction:
|
|
3082
3135
|
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3083
|
-
case
|
|
3136
|
+
case import_utils19.AST_NODE_TYPES.VariableDeclaration: {
|
|
3084
3137
|
const init = node.declarations[0]?.init;
|
|
3085
|
-
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);
|
|
3086
3139
|
}
|
|
3087
|
-
case
|
|
3140
|
+
case import_utils19.AST_NODE_TYPES.MethodDefinition:
|
|
3088
3141
|
return node.value.returnType != null && node.value.params.every(annotatedParameter);
|
|
3089
|
-
case
|
|
3142
|
+
case import_utils19.AST_NODE_TYPES.TSMethodSignature:
|
|
3090
3143
|
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3091
3144
|
default:
|
|
3092
3145
|
return false;
|
|
@@ -3096,7 +3149,7 @@ function documentsTypedFunction(sourceCode, comment) {
|
|
|
3096
3149
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3097
3150
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return false;
|
|
3098
3151
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3099
|
-
while (node != null && node.type !==
|
|
3152
|
+
while (node != null && node.type !== import_utils19.AST_NODE_TYPES.Program) {
|
|
3100
3153
|
if (typedFunction(node)) return true;
|
|
3101
3154
|
node = node.parent ?? null;
|
|
3102
3155
|
}
|
|
@@ -3129,7 +3182,7 @@ var no_long_comment_default = createRule({
|
|
|
3129
3182
|
});
|
|
3130
3183
|
|
|
3131
3184
|
// src/rules/no-offset-pagination.ts
|
|
3132
|
-
var
|
|
3185
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
3133
3186
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:%s|%\(\w+\)s|\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
3134
3187
|
var OFFSET_GATE = /offset/i;
|
|
3135
3188
|
var no_offset_pagination_default = createRule({
|
|
@@ -3159,15 +3212,15 @@ var no_offset_pagination_default = createRule({
|
|
|
3159
3212
|
});
|
|
3160
3213
|
|
|
3161
3214
|
// src/rules/no-positional-tuple-return.ts
|
|
3162
|
-
var
|
|
3215
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
3163
3216
|
var MIN_ELEMENTS = 2;
|
|
3164
3217
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
3165
3218
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
3166
3219
|
function tupleReturnType(node) {
|
|
3167
|
-
if (node.type ===
|
|
3220
|
+
if (node.type === import_utils21.AST_NODE_TYPES.TSTupleType) {
|
|
3168
3221
|
return node;
|
|
3169
3222
|
}
|
|
3170
|
-
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)) {
|
|
3171
3224
|
const argument = node.typeArguments?.params[0];
|
|
3172
3225
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
3173
3226
|
}
|
|
@@ -3181,30 +3234,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
3181
3234
|
if (elements.length < MIN_ELEMENTS) {
|
|
3182
3235
|
return true;
|
|
3183
3236
|
}
|
|
3184
|
-
if (elements.some((element) => element.type ===
|
|
3237
|
+
if (elements.some((element) => element.type === import_utils21.AST_NODE_TYPES.TSRestType)) {
|
|
3185
3238
|
return true;
|
|
3186
3239
|
}
|
|
3187
|
-
if (elements.some((element) => element.type ===
|
|
3240
|
+
if (elements.some((element) => element.type === import_utils21.AST_NODE_TYPES.TSNamedTupleMember)) {
|
|
3188
3241
|
return true;
|
|
3189
3242
|
}
|
|
3190
|
-
if (elements[0]?.type ===
|
|
3243
|
+
if (elements[0]?.type === import_utils21.AST_NODE_TYPES.TSLiteralType) {
|
|
3191
3244
|
return true;
|
|
3192
3245
|
}
|
|
3193
|
-
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)) {
|
|
3194
3247
|
return true;
|
|
3195
3248
|
}
|
|
3196
3249
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
3197
3250
|
return texts.size === 1;
|
|
3198
3251
|
}
|
|
3199
3252
|
function functionName(node) {
|
|
3200
|
-
if (node.type ===
|
|
3253
|
+
if (node.type === import_utils21.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3201
3254
|
return node.id?.name ?? null;
|
|
3202
3255
|
}
|
|
3203
3256
|
const parent = node.parent;
|
|
3204
|
-
if (parent?.type ===
|
|
3257
|
+
if (parent?.type === import_utils21.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3205
3258
|
return parent.id.name;
|
|
3206
3259
|
}
|
|
3207
|
-
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) {
|
|
3208
3261
|
return parent.key.name;
|
|
3209
3262
|
}
|
|
3210
3263
|
return null;
|
|
@@ -3212,7 +3265,7 @@ function functionName(node) {
|
|
|
3212
3265
|
function isInlineExported(node) {
|
|
3213
3266
|
for (let current = node; current != null; current = current.parent) {
|
|
3214
3267
|
const parent = current.parent;
|
|
3215
|
-
if (parent?.type ===
|
|
3268
|
+
if (parent?.type === import_utils21.AST_NODE_TYPES.ExportNamedDeclaration || parent?.type === import_utils21.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
3216
3269
|
return true;
|
|
3217
3270
|
}
|
|
3218
3271
|
}
|
|
@@ -3221,18 +3274,18 @@ function isInlineExported(node) {
|
|
|
3221
3274
|
function moduleScopeBindingName(node) {
|
|
3222
3275
|
let current = node;
|
|
3223
3276
|
let child = node;
|
|
3224
|
-
while (current.parent != null && current.parent.type !==
|
|
3277
|
+
while (current.parent != null && current.parent.type !== import_utils21.AST_NODE_TYPES.Program) {
|
|
3225
3278
|
child = current;
|
|
3226
3279
|
current = current.parent;
|
|
3227
3280
|
}
|
|
3228
|
-
if (current.parent?.type !==
|
|
3281
|
+
if (current.parent?.type !== import_utils21.AST_NODE_TYPES.Program) {
|
|
3229
3282
|
return null;
|
|
3230
3283
|
}
|
|
3231
|
-
if (current.type ===
|
|
3284
|
+
if (current.type === import_utils21.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils21.AST_NODE_TYPES.ClassDeclaration) {
|
|
3232
3285
|
return current.id?.name ?? null;
|
|
3233
3286
|
}
|
|
3234
|
-
if (current.type ===
|
|
3235
|
-
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) {
|
|
3236
3289
|
return null;
|
|
3237
3290
|
}
|
|
3238
3291
|
return child.id.name;
|
|
@@ -3242,19 +3295,19 @@ function moduleScopeBindingName(node) {
|
|
|
3242
3295
|
function specifierExportedNames(program) {
|
|
3243
3296
|
const names = /* @__PURE__ */ new Set();
|
|
3244
3297
|
for (const statement of program.body) {
|
|
3245
|
-
if (statement.type ===
|
|
3298
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
3246
3299
|
for (const specifier of statement.specifiers) {
|
|
3247
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
3300
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3248
3301
|
names.add(specifier.local.name);
|
|
3249
3302
|
}
|
|
3250
3303
|
}
|
|
3251
3304
|
continue;
|
|
3252
3305
|
}
|
|
3253
|
-
if (statement.type ===
|
|
3306
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3254
3307
|
names.add(statement.declaration.name);
|
|
3255
3308
|
continue;
|
|
3256
3309
|
}
|
|
3257
|
-
if (statement.type ===
|
|
3310
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3258
3311
|
names.add(statement.expression.name);
|
|
3259
3312
|
}
|
|
3260
3313
|
}
|
|
@@ -3316,7 +3369,7 @@ var no_positional_tuple_return_default = createRule({
|
|
|
3316
3369
|
});
|
|
3317
3370
|
|
|
3318
3371
|
// src/rules/no-raw-env.ts
|
|
3319
|
-
var
|
|
3372
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
3320
3373
|
var CONFIG_FILE_RE = /(^|[\\/])[\w.-]+\.config\.[cm]?[jt]sx?$/;
|
|
3321
3374
|
var ENV_BOUNDARY_FILE_RE = /(^|[\\/])(?:env|client-env|server-env|client-settings|server-settings)\.[cm]?[jt]sx?$/;
|
|
3322
3375
|
var ENV_VALIDATION_MARKER_RE = /\bcreateEnv\s*\(|\bz\.object\s*\(|\.(?:safeParse|parse)\s*\(/;
|
|
@@ -3393,7 +3446,7 @@ var no_raw_env_default = createRule({
|
|
|
3393
3446
|
});
|
|
3394
3447
|
|
|
3395
3448
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
3396
|
-
var
|
|
3449
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
3397
3450
|
var DEFAULT_ALLOW = [
|
|
3398
3451
|
"[\\\\/]clients?[\\\\/]",
|
|
3399
3452
|
"-client\\.[cm]?[jt]sx?$",
|
|
@@ -3435,7 +3488,7 @@ function identifierLikeName(node) {
|
|
|
3435
3488
|
}
|
|
3436
3489
|
function isConstructedArgumentHandoff(node) {
|
|
3437
3490
|
const [first] = node.arguments;
|
|
3438
|
-
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;
|
|
3439
3492
|
}
|
|
3440
3493
|
function isPresignedUrlTransfer(node) {
|
|
3441
3494
|
const first = node.arguments[0];
|
|
@@ -3503,17 +3556,110 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
3503
3556
|
}
|
|
3504
3557
|
});
|
|
3505
3558
|
|
|
3559
|
+
// src/rules/no-restricted-library-load.ts
|
|
3560
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
3561
|
+
function literalModule(node) {
|
|
3562
|
+
return node?.type === import_utils24.AST_NODE_TYPES.Literal && typeof node.value === "string" ? node.value : null;
|
|
3563
|
+
}
|
|
3564
|
+
function matchesModule(source, module2) {
|
|
3565
|
+
return source === module2 || source.startsWith(`${module2}/`);
|
|
3566
|
+
}
|
|
3567
|
+
var no_restricted_library_load_default = createRule({
|
|
3568
|
+
name: "no-restricted-library-load",
|
|
3569
|
+
meta: {
|
|
3570
|
+
type: "problem",
|
|
3571
|
+
docs: {
|
|
3572
|
+
description: "Apply a configured library-replacement policy to literal dynamic imports, CommonJS loads, and TypeScript import-equals declarations."
|
|
3573
|
+
},
|
|
3574
|
+
schema: [
|
|
3575
|
+
{
|
|
3576
|
+
type: "object",
|
|
3577
|
+
additionalProperties: false,
|
|
3578
|
+
required: ["libraries"],
|
|
3579
|
+
properties: {
|
|
3580
|
+
libraries: {
|
|
3581
|
+
type: "array",
|
|
3582
|
+
items: {
|
|
3583
|
+
type: "object",
|
|
3584
|
+
additionalProperties: false,
|
|
3585
|
+
required: ["id", "module", "replacement"],
|
|
3586
|
+
properties: {
|
|
3587
|
+
id: { type: "string", minLength: 1 },
|
|
3588
|
+
module: { type: "string", minLength: 1 },
|
|
3589
|
+
replacement: { type: "string", minLength: 1 },
|
|
3590
|
+
note: { type: "string", minLength: 1 }
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
],
|
|
3597
|
+
messages: {
|
|
3598
|
+
restrictedLibraryLoad: "{{id}}: Replace runtime loading of {{module}} with {{replacement}}.{{note}}"
|
|
3599
|
+
}
|
|
3600
|
+
},
|
|
3601
|
+
defaultOptions: [{ libraries: [] }],
|
|
3602
|
+
create(context, [options]) {
|
|
3603
|
+
const restrictions = options.libraries;
|
|
3604
|
+
function report(node, source) {
|
|
3605
|
+
const restriction = restrictions.find(
|
|
3606
|
+
(entry) => matchesModule(source, entry.module)
|
|
3607
|
+
);
|
|
3608
|
+
if (restriction === void 0) return;
|
|
3609
|
+
context.report({
|
|
3610
|
+
node,
|
|
3611
|
+
messageId: "restrictedLibraryLoad",
|
|
3612
|
+
data: {
|
|
3613
|
+
id: restriction.id,
|
|
3614
|
+
module: restriction.module,
|
|
3615
|
+
replacement: restriction.replacement,
|
|
3616
|
+
note: restriction.note === void 0 ? "" : ` ${restriction.note}`
|
|
3617
|
+
}
|
|
3618
|
+
});
|
|
3619
|
+
}
|
|
3620
|
+
function isUnshadowedRequire(node) {
|
|
3621
|
+
const variable = import_utils24.ASTUtils.findVariable(
|
|
3622
|
+
context.sourceCode.getScope(node),
|
|
3623
|
+
node.name
|
|
3624
|
+
);
|
|
3625
|
+
return variable === null || variable.defs.length === 0;
|
|
3626
|
+
}
|
|
3627
|
+
return {
|
|
3628
|
+
ImportExpression(node) {
|
|
3629
|
+
const source = literalModule(node.source);
|
|
3630
|
+
if (source !== null) report(node.source, source);
|
|
3631
|
+
},
|
|
3632
|
+
CallExpression(node) {
|
|
3633
|
+
let requireIdentifier = null;
|
|
3634
|
+
if (node.callee.type === import_utils24.AST_NODE_TYPES.Identifier && node.callee.name === "require") {
|
|
3635
|
+
requireIdentifier = node.callee;
|
|
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") {
|
|
3637
|
+
requireIdentifier = node.callee.object;
|
|
3638
|
+
}
|
|
3639
|
+
if (requireIdentifier === null || !isUnshadowedRequire(requireIdentifier)) return;
|
|
3640
|
+
const source = literalModule(node.arguments[0]);
|
|
3641
|
+
if (source !== null) report(node.arguments[0], source);
|
|
3642
|
+
},
|
|
3643
|
+
TSImportEqualsDeclaration(node) {
|
|
3644
|
+
if (node.moduleReference.type !== import_utils24.AST_NODE_TYPES.TSExternalModuleReference) return;
|
|
3645
|
+
const source = literalModule(node.moduleReference.expression);
|
|
3646
|
+
if (source !== null) report(node.moduleReference.expression, source);
|
|
3647
|
+
}
|
|
3648
|
+
};
|
|
3649
|
+
}
|
|
3650
|
+
});
|
|
3651
|
+
|
|
3506
3652
|
// src/rules/no-repeated-string-literal.ts
|
|
3507
|
-
var
|
|
3653
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
3508
3654
|
var MIN_LENGTH = 40;
|
|
3509
3655
|
var MIN_DISTINCT_SCOPES = 2;
|
|
3510
3656
|
var PREVIEW_LENGTH = 40;
|
|
3511
3657
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
3512
3658
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
3513
3659
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3660
|
+
import_utils25.AST_NODE_TYPES.FunctionDeclaration,
|
|
3661
|
+
import_utils25.AST_NODE_TYPES.FunctionExpression,
|
|
3662
|
+
import_utils25.AST_NODE_TYPES.ArrowFunctionExpression
|
|
3517
3663
|
]);
|
|
3518
3664
|
function isStructured(value) {
|
|
3519
3665
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -3535,8 +3681,8 @@ function isScaffolding(node) {
|
|
|
3535
3681
|
if (parent === void 0) {
|
|
3536
3682
|
return true;
|
|
3537
3683
|
}
|
|
3538
|
-
const isRequireSource = parent.type ===
|
|
3539
|
-
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;
|
|
3540
3686
|
}
|
|
3541
3687
|
var no_repeated_string_literal_default = createRule({
|
|
3542
3688
|
name: "no-repeated-string-literal",
|
|
@@ -3576,7 +3722,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3576
3722
|
}
|
|
3577
3723
|
},
|
|
3578
3724
|
TemplateLiteral(node) {
|
|
3579
|
-
if (node.parent.type ===
|
|
3725
|
+
if (node.parent.type === import_utils25.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
3580
3726
|
return;
|
|
3581
3727
|
}
|
|
3582
3728
|
const [only] = node.quasis;
|
|
@@ -3610,7 +3756,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3610
3756
|
});
|
|
3611
3757
|
|
|
3612
3758
|
// src/rules/no-restated-comment.ts
|
|
3613
|
-
var
|
|
3759
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
3614
3760
|
var MAX_WORDS = 8;
|
|
3615
3761
|
var MIN_CONTENT_TOKENS = 2;
|
|
3616
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;
|
|
@@ -3663,7 +3809,7 @@ var no_restated_comment_default = createRule({
|
|
|
3663
3809
|
function labelsASiblingRun(comment) {
|
|
3664
3810
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3665
3811
|
if (token === null) return false;
|
|
3666
|
-
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) {
|
|
3667
3813
|
if (headsSiblingRun(node)) return true;
|
|
3668
3814
|
}
|
|
3669
3815
|
return false;
|
|
@@ -3723,7 +3869,7 @@ var no_restated_comment_default = createRule({
|
|
|
3723
3869
|
});
|
|
3724
3870
|
|
|
3725
3871
|
// src/rules/no-restated-jsdoc.ts
|
|
3726
|
-
var
|
|
3872
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
3727
3873
|
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
3728
3874
|
"arg",
|
|
3729
3875
|
"argument",
|
|
@@ -3777,30 +3923,30 @@ function declarationNames(node) {
|
|
|
3777
3923
|
switch (node.type) {
|
|
3778
3924
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
3779
3925
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
3780
|
-
case
|
|
3781
|
-
case
|
|
3926
|
+
case import_utils27.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3927
|
+
case import_utils27.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3782
3928
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
3783
|
-
case
|
|
3784
|
-
case
|
|
3929
|
+
case import_utils27.AST_NODE_TYPES.FunctionDeclaration:
|
|
3930
|
+
case import_utils27.AST_NODE_TYPES.TSDeclareFunction:
|
|
3785
3931
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
3786
|
-
case
|
|
3787
|
-
case
|
|
3788
|
-
case
|
|
3789
|
-
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:
|
|
3790
3936
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
3791
|
-
case
|
|
3937
|
+
case import_utils27.AST_NODE_TYPES.VariableDeclaration: {
|
|
3792
3938
|
const declarator = node.declarations[0];
|
|
3793
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
3939
|
+
if (declarator === void 0 || declarator.id.type !== import_utils27.AST_NODE_TYPES.Identifier) return null;
|
|
3794
3940
|
const init = declarator.init;
|
|
3795
|
-
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) : [];
|
|
3796
3942
|
return { name: declarator.id.name, params };
|
|
3797
3943
|
}
|
|
3798
|
-
case
|
|
3799
|
-
case
|
|
3800
|
-
case
|
|
3801
|
-
case
|
|
3802
|
-
if (node.key.type !==
|
|
3803
|
-
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) : [];
|
|
3804
3950
|
return { name: node.key.name, params };
|
|
3805
3951
|
}
|
|
3806
3952
|
default:
|
|
@@ -3810,9 +3956,9 @@ function declarationNames(node) {
|
|
|
3810
3956
|
function paramNames(params) {
|
|
3811
3957
|
const names = [];
|
|
3812
3958
|
for (const param of params) {
|
|
3813
|
-
const target = param.type ===
|
|
3814
|
-
if (target.type ===
|
|
3815
|
-
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;
|
|
3816
3962
|
}
|
|
3817
3963
|
return names;
|
|
3818
3964
|
}
|
|
@@ -3854,7 +4000,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3854
4000
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
3855
4001
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3856
4002
|
let declaration = null;
|
|
3857
|
-
while (node != null && node.type !==
|
|
4003
|
+
while (node != null && node.type !== import_utils27.AST_NODE_TYPES.Program) {
|
|
3858
4004
|
declaration = declarationNames(node);
|
|
3859
4005
|
if (declaration !== null) break;
|
|
3860
4006
|
node = node.parent ?? null;
|
|
@@ -3909,7 +4055,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3909
4055
|
});
|
|
3910
4056
|
|
|
3911
4057
|
// src/rules/no-secret-in-log.ts
|
|
3912
|
-
var
|
|
4058
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
3913
4059
|
|
|
3914
4060
|
// src/rules/_secret-names.ts
|
|
3915
4061
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -4246,7 +4392,7 @@ var no_secret_in_log_default = createRule({
|
|
|
4246
4392
|
});
|
|
4247
4393
|
|
|
4248
4394
|
// src/rules/no-select-star.ts
|
|
4249
|
-
var
|
|
4395
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
4250
4396
|
var QUERY_SHAPE = /\bSELECT\b[\s\S]*?\bFROM\b/i;
|
|
4251
4397
|
var SELECT_KEYWORD = /\bSELECT\b/gi;
|
|
4252
4398
|
var FROM_KEYWORD = /^FROM\b/i;
|
|
@@ -4313,12 +4459,12 @@ var no_select_star_default = createRule({
|
|
|
4313
4459
|
});
|
|
4314
4460
|
|
|
4315
4461
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
4316
|
-
var
|
|
4462
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
4317
4463
|
function sentinelKind(arg) {
|
|
4318
4464
|
if (arg === null) {
|
|
4319
4465
|
return null;
|
|
4320
4466
|
}
|
|
4321
|
-
if (arg.type ===
|
|
4467
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Literal) {
|
|
4322
4468
|
if (arg.value === null) {
|
|
4323
4469
|
return "nullish";
|
|
4324
4470
|
}
|
|
@@ -4330,13 +4476,13 @@ function sentinelKind(arg) {
|
|
|
4330
4476
|
}
|
|
4331
4477
|
return null;
|
|
4332
4478
|
}
|
|
4333
|
-
if (arg.type ===
|
|
4479
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4334
4480
|
return "nullish";
|
|
4335
4481
|
}
|
|
4336
|
-
if (arg.type ===
|
|
4482
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ArrayExpression) {
|
|
4337
4483
|
return "array";
|
|
4338
4484
|
}
|
|
4339
|
-
if (arg.type ===
|
|
4485
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ObjectExpression) {
|
|
4340
4486
|
return "object";
|
|
4341
4487
|
}
|
|
4342
4488
|
return null;
|
|
@@ -4345,25 +4491,25 @@ function isSentinelArgument(arg) {
|
|
|
4345
4491
|
if (arg === null) {
|
|
4346
4492
|
return false;
|
|
4347
4493
|
}
|
|
4348
|
-
if (arg.type ===
|
|
4494
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Literal && arg.value === null) {
|
|
4349
4495
|
return true;
|
|
4350
4496
|
}
|
|
4351
|
-
if (arg.type ===
|
|
4497
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Literal && arg.value === false) {
|
|
4352
4498
|
return true;
|
|
4353
4499
|
}
|
|
4354
|
-
if (arg.type ===
|
|
4500
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4355
4501
|
return true;
|
|
4356
4502
|
}
|
|
4357
|
-
if (arg.type ===
|
|
4503
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ArrayExpression && arg.elements.length === 0) {
|
|
4358
4504
|
return true;
|
|
4359
4505
|
}
|
|
4360
|
-
if (arg.type ===
|
|
4506
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ObjectExpression && arg.properties.length === 0) {
|
|
4361
4507
|
return true;
|
|
4362
4508
|
}
|
|
4363
4509
|
return false;
|
|
4364
4510
|
}
|
|
4365
4511
|
function isFunctionNode(node) {
|
|
4366
|
-
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;
|
|
4367
4513
|
}
|
|
4368
4514
|
function isNode3(value) {
|
|
4369
4515
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -4403,24 +4549,24 @@ function walkWithinScope(node, visit) {
|
|
|
4403
4549
|
function containsThrow(node) {
|
|
4404
4550
|
return walkWithinScope(
|
|
4405
4551
|
node,
|
|
4406
|
-
(current) => current.type ===
|
|
4552
|
+
(current) => current.type === import_utils30.AST_NODE_TYPES.ThrowStatement
|
|
4407
4553
|
);
|
|
4408
4554
|
}
|
|
4409
4555
|
function bindsName(param, name) {
|
|
4410
4556
|
switch (param.type) {
|
|
4411
|
-
case
|
|
4557
|
+
case import_utils30.AST_NODE_TYPES.Identifier:
|
|
4412
4558
|
return param.name === name;
|
|
4413
|
-
case
|
|
4559
|
+
case import_utils30.AST_NODE_TYPES.AssignmentPattern:
|
|
4414
4560
|
return bindsName(param.left, name);
|
|
4415
|
-
case
|
|
4561
|
+
case import_utils30.AST_NODE_TYPES.RestElement:
|
|
4416
4562
|
return bindsName(param.argument, name);
|
|
4417
|
-
case
|
|
4563
|
+
case import_utils30.AST_NODE_TYPES.ArrayPattern:
|
|
4418
4564
|
return param.elements.some(
|
|
4419
4565
|
(element) => element !== null && bindsName(element, name)
|
|
4420
4566
|
);
|
|
4421
|
-
case
|
|
4567
|
+
case import_utils30.AST_NODE_TYPES.ObjectPattern:
|
|
4422
4568
|
return param.properties.some(
|
|
4423
|
-
(property) => property.type ===
|
|
4569
|
+
(property) => property.type === import_utils30.AST_NODE_TYPES.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
4424
4570
|
);
|
|
4425
4571
|
default:
|
|
4426
4572
|
return false;
|
|
@@ -4435,7 +4581,7 @@ function subtreeReadsName(node, name) {
|
|
|
4435
4581
|
if (found) {
|
|
4436
4582
|
return;
|
|
4437
4583
|
}
|
|
4438
|
-
if (current.type ===
|
|
4584
|
+
if (current.type === import_utils30.AST_NODE_TYPES.Identifier && current.name === name) {
|
|
4439
4585
|
found = true;
|
|
4440
4586
|
return;
|
|
4441
4587
|
}
|
|
@@ -4446,10 +4592,10 @@ function subtreeReadsName(node, name) {
|
|
|
4446
4592
|
if (key === "parent") {
|
|
4447
4593
|
continue;
|
|
4448
4594
|
}
|
|
4449
|
-
if (key === "key" && current.type ===
|
|
4595
|
+
if (key === "key" && current.type === import_utils30.AST_NODE_TYPES.Property && !current.computed) {
|
|
4450
4596
|
continue;
|
|
4451
4597
|
}
|
|
4452
|
-
if (key === "property" && current.type ===
|
|
4598
|
+
if (key === "property" && current.type === import_utils30.AST_NODE_TYPES.MemberExpression && !current.computed) {
|
|
4453
4599
|
continue;
|
|
4454
4600
|
}
|
|
4455
4601
|
const value = current[key];
|
|
@@ -4482,10 +4628,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4482
4628
|
"URLPattern"
|
|
4483
4629
|
]);
|
|
4484
4630
|
function isParseShapedNode(node) {
|
|
4485
|
-
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) {
|
|
4486
4632
|
return node.callee.property.name === "parse";
|
|
4487
4633
|
}
|
|
4488
|
-
if (node.type ===
|
|
4634
|
+
if (node.type === import_utils30.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4489
4635
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
4490
4636
|
}
|
|
4491
4637
|
return false;
|
|
@@ -4496,10 +4642,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
4496
4642
|
"arrayBuffer"
|
|
4497
4643
|
]);
|
|
4498
4644
|
function isBodyDecodeNode(node) {
|
|
4499
|
-
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);
|
|
4500
4646
|
}
|
|
4501
4647
|
function returnsMatching(stmt, predicate) {
|
|
4502
|
-
return stmt.type ===
|
|
4648
|
+
return stmt.type === import_utils30.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
4503
4649
|
}
|
|
4504
4650
|
function enclosingReturnTypeNode(node) {
|
|
4505
4651
|
let current = node.parent;
|
|
@@ -4517,11 +4663,11 @@ function enclosingFunctionName(node) {
|
|
|
4517
4663
|
let current = node.parent;
|
|
4518
4664
|
while (current !== void 0 && current !== null) {
|
|
4519
4665
|
if (isFunctionNode(current)) {
|
|
4520
|
-
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) {
|
|
4521
4667
|
return current.id.name;
|
|
4522
4668
|
}
|
|
4523
4669
|
const parent = current.parent;
|
|
4524
|
-
if (parent?.type ===
|
|
4670
|
+
if (parent?.type === import_utils30.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4525
4671
|
return parent.id.name;
|
|
4526
4672
|
}
|
|
4527
4673
|
return null;
|
|
@@ -4542,10 +4688,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
4542
4688
|
return false;
|
|
4543
4689
|
}
|
|
4544
4690
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
4545
|
-
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") {
|
|
4546
4692
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
4547
4693
|
}
|
|
4548
|
-
return declared?.type ===
|
|
4694
|
+
return declared?.type === import_utils30.AST_NODE_TYPES.TSBooleanKeyword;
|
|
4549
4695
|
}
|
|
4550
4696
|
function tryReturnsSafeParse(catchNode) {
|
|
4551
4697
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -4561,7 +4707,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
4561
4707
|
function enclosingFunctionBody(node) {
|
|
4562
4708
|
let current = node.parent;
|
|
4563
4709
|
while (current !== void 0 && current !== null) {
|
|
4564
|
-
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) {
|
|
4565
4711
|
return current.body;
|
|
4566
4712
|
}
|
|
4567
4713
|
current = current.parent;
|
|
@@ -4574,7 +4720,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
4574
4720
|
return false;
|
|
4575
4721
|
}
|
|
4576
4722
|
return walkWithinScope(functionBody, (current) => {
|
|
4577
|
-
if (current.type !==
|
|
4723
|
+
if (current.type !== import_utils30.AST_NODE_TYPES.ReturnStatement) {
|
|
4578
4724
|
return false;
|
|
4579
4725
|
}
|
|
4580
4726
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -4593,13 +4739,13 @@ function returnedSentinelKinds(arg) {
|
|
|
4593
4739
|
kinds.add(direct);
|
|
4594
4740
|
return kinds;
|
|
4595
4741
|
}
|
|
4596
|
-
if (arg.type ===
|
|
4742
|
+
if (arg.type === import_utils30.AST_NODE_TYPES.ConditionalExpression) {
|
|
4597
4743
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
4598
4744
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
4599
4745
|
kinds.add(nested);
|
|
4600
4746
|
}
|
|
4601
4747
|
}
|
|
4602
|
-
} else if (arg.type ===
|
|
4748
|
+
} else if (arg.type === import_utils30.AST_NODE_TYPES.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
4603
4749
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
4604
4750
|
kinds.add(nested);
|
|
4605
4751
|
}
|
|
@@ -4642,7 +4788,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4642
4788
|
const matcher = createLogMatcher(loggingOptions);
|
|
4643
4789
|
function logsOrReportsError(catchBody, caughtName) {
|
|
4644
4790
|
return walkWithinScope(catchBody, (current) => {
|
|
4645
|
-
if (current.type !==
|
|
4791
|
+
if (current.type !== import_utils30.AST_NODE_TYPES.CallExpression) {
|
|
4646
4792
|
return false;
|
|
4647
4793
|
}
|
|
4648
4794
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -4659,7 +4805,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4659
4805
|
return;
|
|
4660
4806
|
}
|
|
4661
4807
|
const last = body2[body2.length - 1];
|
|
4662
|
-
if (last === void 0 || last.type !==
|
|
4808
|
+
if (last === void 0 || last.type !== import_utils30.AST_NODE_TYPES.ReturnStatement) {
|
|
4663
4809
|
return;
|
|
4664
4810
|
}
|
|
4665
4811
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -4668,7 +4814,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4668
4814
|
if (containsThrow(node.body)) {
|
|
4669
4815
|
return;
|
|
4670
4816
|
}
|
|
4671
|
-
const caughtName = node.param?.type ===
|
|
4817
|
+
const caughtName = node.param?.type === import_utils30.AST_NODE_TYPES.Identifier ? node.param.name : null;
|
|
4672
4818
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
4673
4819
|
return;
|
|
4674
4820
|
}
|
|
@@ -4695,9 +4841,9 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4695
4841
|
});
|
|
4696
4842
|
|
|
4697
4843
|
// src/rules/no-silent-promise-catch.ts
|
|
4698
|
-
var
|
|
4844
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
4699
4845
|
function isBodyParseCall(node) {
|
|
4700
|
-
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");
|
|
4701
4847
|
}
|
|
4702
4848
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
4703
4849
|
"cancel",
|
|
@@ -4712,21 +4858,21 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
4712
4858
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
4713
4859
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
4714
4860
|
function isTeardownCall(node) {
|
|
4715
|
-
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);
|
|
4716
4862
|
}
|
|
4717
4863
|
function isSilentExpression(node) {
|
|
4718
4864
|
switch (node.type) {
|
|
4719
|
-
case
|
|
4865
|
+
case import_utils31.AST_NODE_TYPES.Literal:
|
|
4720
4866
|
return !("regex" in node);
|
|
4721
|
-
case
|
|
4867
|
+
case import_utils31.AST_NODE_TYPES.Identifier:
|
|
4722
4868
|
return node.name === "undefined";
|
|
4723
|
-
case
|
|
4724
|
-
return node.operator === "void" && node.argument.type ===
|
|
4725
|
-
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:
|
|
4726
4872
|
return node.properties.length === 0;
|
|
4727
|
-
case
|
|
4873
|
+
case import_utils31.AST_NODE_TYPES.ArrayExpression:
|
|
4728
4874
|
return node.elements.length === 0;
|
|
4729
|
-
case
|
|
4875
|
+
case import_utils31.AST_NODE_TYPES.TSAsExpression:
|
|
4730
4876
|
return isSilentExpression(node.expression);
|
|
4731
4877
|
default:
|
|
4732
4878
|
return false;
|
|
@@ -4734,7 +4880,7 @@ function isSilentExpression(node) {
|
|
|
4734
4880
|
}
|
|
4735
4881
|
function isSilentHandler(handler) {
|
|
4736
4882
|
const body2 = handler.body;
|
|
4737
|
-
if (body2.type !==
|
|
4883
|
+
if (body2.type !== import_utils31.AST_NODE_TYPES.BlockStatement) {
|
|
4738
4884
|
return isSilentExpression(body2);
|
|
4739
4885
|
}
|
|
4740
4886
|
if (body2.body.length === 0) {
|
|
@@ -4742,7 +4888,7 @@ function isSilentHandler(handler) {
|
|
|
4742
4888
|
}
|
|
4743
4889
|
if (body2.body.length === 1) {
|
|
4744
4890
|
const only = body2.body[0];
|
|
4745
|
-
if (only !== void 0 && only.type ===
|
|
4891
|
+
if (only !== void 0 && only.type === import_utils31.AST_NODE_TYPES.ReturnStatement) {
|
|
4746
4892
|
return only.argument === null || isSilentExpression(only.argument);
|
|
4747
4893
|
}
|
|
4748
4894
|
}
|
|
@@ -4771,7 +4917,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4771
4917
|
return true;
|
|
4772
4918
|
}
|
|
4773
4919
|
let statement = call;
|
|
4774
|
-
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) {
|
|
4775
4921
|
statement = statement.parent;
|
|
4776
4922
|
}
|
|
4777
4923
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -4783,7 +4929,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4783
4929
|
};
|
|
4784
4930
|
return {
|
|
4785
4931
|
CallExpression(node) {
|
|
4786
|
-
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") {
|
|
4787
4933
|
return;
|
|
4788
4934
|
}
|
|
4789
4935
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -4792,14 +4938,14 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4792
4938
|
if (isTeardownCall(node.callee.object)) {
|
|
4793
4939
|
return;
|
|
4794
4940
|
}
|
|
4795
|
-
if (node.parent.type ===
|
|
4941
|
+
if (node.parent.type === import_utils31.AST_NODE_TYPES.MemberExpression && node.parent.object === node) {
|
|
4796
4942
|
return;
|
|
4797
4943
|
}
|
|
4798
4944
|
if (node.arguments.length !== 1) {
|
|
4799
4945
|
return;
|
|
4800
4946
|
}
|
|
4801
4947
|
const handler = node.arguments[0];
|
|
4802
|
-
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) {
|
|
4803
4949
|
return;
|
|
4804
4950
|
}
|
|
4805
4951
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -4814,7 +4960,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4814
4960
|
});
|
|
4815
4961
|
|
|
4816
4962
|
// src/rules/no-sleep-in-test-body.ts
|
|
4817
|
-
var
|
|
4963
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
4818
4964
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
4819
4965
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
4820
4966
|
"it",
|
|
@@ -4823,34 +4969,34 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
|
4823
4969
|
"afterEach"
|
|
4824
4970
|
]);
|
|
4825
4971
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4972
|
+
import_utils32.AST_NODE_TYPES.FunctionDeclaration,
|
|
4973
|
+
import_utils32.AST_NODE_TYPES.FunctionExpression,
|
|
4974
|
+
import_utils32.AST_NODE_TYPES.ArrowFunctionExpression
|
|
4829
4975
|
]);
|
|
4830
4976
|
function isNonzeroNumericLiteral(node) {
|
|
4831
|
-
return node?.type ===
|
|
4977
|
+
return node?.type === import_utils32.AST_NODE_TYPES.Literal && typeof node.value === "number" && node.value !== 0;
|
|
4832
4978
|
}
|
|
4833
4979
|
function isTimedSetTimeout(node) {
|
|
4834
|
-
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]);
|
|
4835
4981
|
}
|
|
4836
4982
|
function isPromiseSleep(node) {
|
|
4837
|
-
if (node.callee.type !==
|
|
4983
|
+
if (node.callee.type !== import_utils32.AST_NODE_TYPES.Identifier || node.callee.name !== "Promise") {
|
|
4838
4984
|
return false;
|
|
4839
4985
|
}
|
|
4840
4986
|
const executor = node.arguments[0];
|
|
4841
|
-
if (executor?.type !==
|
|
4987
|
+
if (executor?.type !== import_utils32.AST_NODE_TYPES.ArrowFunctionExpression && executor?.type !== import_utils32.AST_NODE_TYPES.FunctionExpression) {
|
|
4842
4988
|
return false;
|
|
4843
4989
|
}
|
|
4844
4990
|
const body2 = executor.body;
|
|
4845
|
-
if (body2.type !==
|
|
4991
|
+
if (body2.type !== import_utils32.AST_NODE_TYPES.BlockStatement) {
|
|
4846
4992
|
return isTimedSetTimeout(body2);
|
|
4847
4993
|
}
|
|
4848
4994
|
return body2.body.some(
|
|
4849
|
-
(stmt) => stmt.type ===
|
|
4995
|
+
(stmt) => stmt.type === import_utils32.AST_NODE_TYPES.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
4850
4996
|
);
|
|
4851
4997
|
}
|
|
4852
4998
|
function isHelperSleep(node) {
|
|
4853
|
-
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]);
|
|
4854
5000
|
}
|
|
4855
5001
|
function nearestEnclosingFunction2(node) {
|
|
4856
5002
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -4858,7 +5004,7 @@ function nearestEnclosingFunction2(node) {
|
|
|
4858
5004
|
continue;
|
|
4859
5005
|
}
|
|
4860
5006
|
const grandparent = current.parent;
|
|
4861
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
5007
|
+
const isPromiseExecutor = grandparent?.type === import_utils32.AST_NODE_TYPES.NewExpression && isPromiseSleep(grandparent);
|
|
4862
5008
|
if (!isPromiseExecutor) {
|
|
4863
5009
|
return current;
|
|
4864
5010
|
}
|
|
@@ -4866,23 +5012,23 @@ function nearestEnclosingFunction2(node) {
|
|
|
4866
5012
|
return null;
|
|
4867
5013
|
}
|
|
4868
5014
|
function testCallerName2(callee) {
|
|
4869
|
-
if (callee.type ===
|
|
5015
|
+
if (callee.type === import_utils32.AST_NODE_TYPES.Identifier) {
|
|
4870
5016
|
return callee.name;
|
|
4871
5017
|
}
|
|
4872
|
-
if (callee.type ===
|
|
5018
|
+
if (callee.type === import_utils32.AST_NODE_TYPES.MemberExpression) {
|
|
4873
5019
|
return testCallerName2(callee.object);
|
|
4874
5020
|
}
|
|
4875
|
-
if (callee.type ===
|
|
5021
|
+
if (callee.type === import_utils32.AST_NODE_TYPES.CallExpression) {
|
|
4876
5022
|
return testCallerName2(callee.callee);
|
|
4877
5023
|
}
|
|
4878
|
-
if (callee.type ===
|
|
5024
|
+
if (callee.type === import_utils32.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
4879
5025
|
return testCallerName2(callee.tag);
|
|
4880
5026
|
}
|
|
4881
5027
|
return null;
|
|
4882
5028
|
}
|
|
4883
5029
|
function isTestBody2(fn) {
|
|
4884
5030
|
const call = fn.parent;
|
|
4885
|
-
if (call?.type !==
|
|
5031
|
+
if (call?.type !== import_utils32.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
4886
5032
|
return false;
|
|
4887
5033
|
}
|
|
4888
5034
|
const name = testCallerName2(call.callee);
|
|
@@ -4928,7 +5074,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
4928
5074
|
});
|
|
4929
5075
|
|
|
4930
5076
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
4931
|
-
var
|
|
5077
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
4932
5078
|
var DEFAULT_METHODS2 = [
|
|
4933
5079
|
"prepare",
|
|
4934
5080
|
"put",
|
|
@@ -4947,7 +5093,7 @@ function compile2(patterns) {
|
|
|
4947
5093
|
}
|
|
4948
5094
|
function storageMethodName(node, methods) {
|
|
4949
5095
|
const callee = node.callee;
|
|
4950
|
-
if (callee.type !==
|
|
5096
|
+
if (callee.type !== import_utils33.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils33.AST_NODE_TYPES.Identifier) {
|
|
4951
5097
|
return null;
|
|
4952
5098
|
}
|
|
4953
5099
|
const name = callee.property.name;
|
|
@@ -5015,7 +5161,7 @@ var no_storage_in_stateless_modules_default = createRule({
|
|
|
5015
5161
|
});
|
|
5016
5162
|
|
|
5017
5163
|
// src/rules/no-string-concat-in-loop.ts
|
|
5018
|
-
var
|
|
5164
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
5019
5165
|
var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
5020
5166
|
"ForStatement",
|
|
5021
5167
|
"ForOfStatement",
|
|
@@ -5161,7 +5307,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
5161
5307
|
});
|
|
5162
5308
|
|
|
5163
5309
|
// src/rules/no-tautological-expect.ts
|
|
5164
|
-
var
|
|
5310
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
5165
5311
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
5166
5312
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
5167
5313
|
"toBeDefined",
|
|
@@ -5175,17 +5321,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
5175
5321
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
5176
5322
|
function isLiteral(node) {
|
|
5177
5323
|
switch (node.type) {
|
|
5178
|
-
case
|
|
5324
|
+
case import_utils35.AST_NODE_TYPES.Literal:
|
|
5179
5325
|
return true;
|
|
5180
|
-
case
|
|
5326
|
+
case import_utils35.AST_NODE_TYPES.TemplateLiteral:
|
|
5181
5327
|
return node.expressions.length === 0;
|
|
5182
|
-
case
|
|
5328
|
+
case import_utils35.AST_NODE_TYPES.UnaryExpression:
|
|
5183
5329
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
5184
|
-
case
|
|
5330
|
+
case import_utils35.AST_NODE_TYPES.ArrayExpression:
|
|
5185
5331
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
5186
|
-
case
|
|
5332
|
+
case import_utils35.AST_NODE_TYPES.ObjectExpression:
|
|
5187
5333
|
return node.properties.every(
|
|
5188
|
-
(property) => property.type ===
|
|
5334
|
+
(property) => property.type === import_utils35.AST_NODE_TYPES.Property && !property.computed && isLiteral(property.value)
|
|
5189
5335
|
);
|
|
5190
5336
|
default:
|
|
5191
5337
|
return false;
|
|
@@ -5193,7 +5339,7 @@ function isLiteral(node) {
|
|
|
5193
5339
|
}
|
|
5194
5340
|
function expectOperand(callee) {
|
|
5195
5341
|
const receiver = callee.object;
|
|
5196
|
-
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) {
|
|
5197
5343
|
return null;
|
|
5198
5344
|
}
|
|
5199
5345
|
return receiver.arguments[0] ?? null;
|
|
@@ -5223,10 +5369,10 @@ var no_tautological_expect_default = createRule({
|
|
|
5223
5369
|
return {
|
|
5224
5370
|
CallExpression(node) {
|
|
5225
5371
|
const callee = node.callee;
|
|
5226
|
-
if (callee.type !==
|
|
5372
|
+
if (callee.type !== import_utils35.AST_NODE_TYPES.MemberExpression || callee.computed) {
|
|
5227
5373
|
return;
|
|
5228
5374
|
}
|
|
5229
|
-
if (callee.property.type !==
|
|
5375
|
+
if (callee.property.type !== import_utils35.AST_NODE_TYPES.Identifier) {
|
|
5230
5376
|
return;
|
|
5231
5377
|
}
|
|
5232
5378
|
const matcher = callee.property.name;
|
|
@@ -5285,7 +5431,7 @@ var no_typed_doc_sections_default = createRule({
|
|
|
5285
5431
|
});
|
|
5286
5432
|
|
|
5287
5433
|
// src/rules/no-trailing-value-narration.ts
|
|
5288
|
-
var
|
|
5434
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5289
5435
|
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
5290
5436
|
var WORD_RE3 = /[A-Za-z]+(?:'[a-z]+)?|\d+(?:\.\d+)?/g;
|
|
5291
5437
|
var UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -5420,10 +5566,10 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5420
5566
|
});
|
|
5421
5567
|
|
|
5422
5568
|
// src/rules/no-declaration-comment-wall.ts
|
|
5423
|
-
var
|
|
5569
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5424
5570
|
|
|
5425
5571
|
// src/rules/_comment-wall.ts
|
|
5426
|
-
var
|
|
5572
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5427
5573
|
var WALL_DEFAULTS = {
|
|
5428
5574
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5429
5575
|
minCommentedMembers: 3,
|
|
@@ -5527,10 +5673,10 @@ function isWall(members, commented, restated, options) {
|
|
|
5527
5673
|
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5528
5674
|
}
|
|
5529
5675
|
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
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
|
|
5534
5680
|
]);
|
|
5535
5681
|
function declarationRange(member) {
|
|
5536
5682
|
const body2 = bodyOf(member);
|
|
@@ -5538,10 +5684,10 @@ function declarationRange(member) {
|
|
|
5538
5684
|
return [member.range[0], body2.range[0]];
|
|
5539
5685
|
}
|
|
5540
5686
|
function bodyOf(member) {
|
|
5541
|
-
if (member.type ===
|
|
5687
|
+
if (member.type === import_utils37.AST_NODE_TYPES.MethodDefinition || member.type === import_utils37.AST_NODE_TYPES.TSAbstractMethodDefinition) {
|
|
5542
5688
|
return member.value.body ?? void 0;
|
|
5543
5689
|
}
|
|
5544
|
-
if (member.type ===
|
|
5690
|
+
if (member.type === import_utils37.AST_NODE_TYPES.Property || member.type === import_utils37.AST_NODE_TYPES.PropertyDefinition) {
|
|
5545
5691
|
const value = member.value;
|
|
5546
5692
|
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5547
5693
|
}
|
|
@@ -5551,12 +5697,12 @@ function bodyOf(member) {
|
|
|
5551
5697
|
// src/rules/no-declaration-comment-wall.ts
|
|
5552
5698
|
function named(node) {
|
|
5553
5699
|
switch (node.type) {
|
|
5554
|
-
case
|
|
5700
|
+
case import_utils38.AST_NODE_TYPES.TSEnumMember:
|
|
5555
5701
|
return { node, key: node.id };
|
|
5556
|
-
case
|
|
5557
|
-
case
|
|
5558
|
-
case
|
|
5559
|
-
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:
|
|
5560
5706
|
return node.computed ? void 0 : { node, key: node.key };
|
|
5561
5707
|
default:
|
|
5562
5708
|
return void 0;
|
|
@@ -5656,7 +5802,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5656
5802
|
});
|
|
5657
5803
|
|
|
5658
5804
|
// src/rules/no-union-in-comment.ts
|
|
5659
|
-
var
|
|
5805
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
5660
5806
|
var MAX_LITERAL_LENGTH = 28;
|
|
5661
5807
|
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5662
5808
|
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
@@ -5675,14 +5821,14 @@ var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
5675
5821
|
function isBareString(node) {
|
|
5676
5822
|
if (node === void 0) return false;
|
|
5677
5823
|
switch (node.type) {
|
|
5678
|
-
case
|
|
5824
|
+
case import_utils39.AST_NODE_TYPES.TSStringKeyword:
|
|
5679
5825
|
return true;
|
|
5680
5826
|
// `string[]` holds members of the same closed set, one element at a time.
|
|
5681
|
-
case
|
|
5827
|
+
case import_utils39.AST_NODE_TYPES.TSArrayType:
|
|
5682
5828
|
return isBareString(node.elementType);
|
|
5683
5829
|
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5684
5830
|
// — the checker collapses that one to `string`.
|
|
5685
|
-
case
|
|
5831
|
+
case import_utils39.AST_NODE_TYPES.TSUnionType:
|
|
5686
5832
|
return node.types.some((member) => isBareString(member));
|
|
5687
5833
|
default:
|
|
5688
5834
|
return false;
|
|
@@ -5692,13 +5838,13 @@ function rootCallee(node) {
|
|
|
5692
5838
|
let current = node;
|
|
5693
5839
|
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5694
5840
|
switch (current.type) {
|
|
5695
|
-
case
|
|
5841
|
+
case import_utils39.AST_NODE_TYPES.CallExpression:
|
|
5696
5842
|
current = current.callee;
|
|
5697
5843
|
break;
|
|
5698
|
-
case
|
|
5844
|
+
case import_utils39.AST_NODE_TYPES.MemberExpression:
|
|
5699
5845
|
current = current.object;
|
|
5700
5846
|
break;
|
|
5701
|
-
case
|
|
5847
|
+
case import_utils39.AST_NODE_TYPES.Identifier:
|
|
5702
5848
|
return current.name;
|
|
5703
5849
|
default:
|
|
5704
5850
|
return null;
|
|
@@ -5707,26 +5853,26 @@ function rootCallee(node) {
|
|
|
5707
5853
|
return null;
|
|
5708
5854
|
}
|
|
5709
5855
|
function nameOf(key) {
|
|
5710
|
-
if (key.type ===
|
|
5711
|
-
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;
|
|
5712
5858
|
return null;
|
|
5713
5859
|
}
|
|
5714
5860
|
function targetOf(node) {
|
|
5715
5861
|
switch (node.type) {
|
|
5716
|
-
case
|
|
5717
|
-
case
|
|
5862
|
+
case import_utils39.AST_NODE_TYPES.TSPropertySignature:
|
|
5863
|
+
case import_utils39.AST_NODE_TYPES.PropertyDefinition: {
|
|
5718
5864
|
const name = node.computed ? null : nameOf(node.key);
|
|
5719
5865
|
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5720
5866
|
return { node, name };
|
|
5721
5867
|
}
|
|
5722
|
-
case
|
|
5868
|
+
case import_utils39.AST_NODE_TYPES.Property: {
|
|
5723
5869
|
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5724
5870
|
const callee = rootCallee(node.value);
|
|
5725
5871
|
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5726
5872
|
return { node, name };
|
|
5727
5873
|
}
|
|
5728
|
-
case
|
|
5729
|
-
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;
|
|
5730
5876
|
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5731
5877
|
return { node, name: node.id.name };
|
|
5732
5878
|
}
|
|
@@ -5775,7 +5921,7 @@ var no_union_in_comment_default = createRule({
|
|
|
5775
5921
|
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5776
5922
|
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5777
5923
|
}
|
|
5778
|
-
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) {
|
|
5779
5925
|
const target = targetOf(node);
|
|
5780
5926
|
if (target !== null) return target;
|
|
5781
5927
|
}
|
|
@@ -5804,9 +5950,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5804
5950
|
});
|
|
5805
5951
|
|
|
5806
5952
|
// src/rules/no-type-member-comment-wall.ts
|
|
5807
|
-
var
|
|
5953
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
5808
5954
|
function isNamedMember(node) {
|
|
5809
|
-
return (node.type ===
|
|
5955
|
+
return (node.type === import_utils40.AST_NODE_TYPES.TSPropertySignature || node.type === import_utils40.AST_NODE_TYPES.TSMethodSignature) && !node.computed;
|
|
5810
5956
|
}
|
|
5811
5957
|
var no_type_member_comment_wall_default = createRule({
|
|
5812
5958
|
name: "no-type-member-comment-wall",
|
|
@@ -5853,7 +5999,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5853
5999
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5854
6000
|
}
|
|
5855
6001
|
function check(node) {
|
|
5856
|
-
const members = node.type ===
|
|
6002
|
+
const members = node.type === import_utils40.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
|
5857
6003
|
const named2 = members.filter(isNamedMember);
|
|
5858
6004
|
if (named2.length === 0) return;
|
|
5859
6005
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5893,7 +6039,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5893
6039
|
});
|
|
5894
6040
|
|
|
5895
6041
|
// src/rules/no-unnecessary-use-client.ts
|
|
5896
|
-
var
|
|
6042
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
5897
6043
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5898
6044
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5899
6045
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -5919,13 +6065,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
5919
6065
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
5920
6066
|
var jsxRootName = (name) => {
|
|
5921
6067
|
let current = name;
|
|
5922
|
-
while (current.type ===
|
|
6068
|
+
while (current.type === import_utils41.AST_NODE_TYPES.JSXMemberExpression) {
|
|
5923
6069
|
current = current.object;
|
|
5924
6070
|
}
|
|
5925
|
-
return current.type ===
|
|
6071
|
+
return current.type === import_utils41.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
5926
6072
|
};
|
|
5927
6073
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
5928
|
-
if (node.type ===
|
|
6074
|
+
if (node.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5929
6075
|
return imported.has(node.name);
|
|
5930
6076
|
}
|
|
5931
6077
|
for (const key of Object.keys(node)) {
|
|
@@ -5940,16 +6086,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
5940
6086
|
return false;
|
|
5941
6087
|
};
|
|
5942
6088
|
var isUseClientDirective = (node) => {
|
|
5943
|
-
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";
|
|
5944
6090
|
};
|
|
5945
6091
|
var isGlobalReference = (node, context) => {
|
|
5946
6092
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
5947
6093
|
const parent = node.parent;
|
|
5948
6094
|
if (parent !== void 0) {
|
|
5949
|
-
if (parent.type ===
|
|
6095
|
+
if (parent.type === import_utils41.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
5950
6096
|
return false;
|
|
5951
6097
|
}
|
|
5952
|
-
if (parent.type ===
|
|
6098
|
+
if (parent.type === import_utils41.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
5953
6099
|
return false;
|
|
5954
6100
|
}
|
|
5955
6101
|
if (parent.type.startsWith("TS")) {
|
|
@@ -5989,13 +6135,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5989
6135
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
5990
6136
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
5991
6137
|
const markIfHookOrContext = (callee) => {
|
|
5992
|
-
if (callee.type ===
|
|
6138
|
+
if (callee.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5993
6139
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
5994
6140
|
hasClientIndicator = true;
|
|
5995
6141
|
}
|
|
5996
6142
|
return;
|
|
5997
6143
|
}
|
|
5998
|
-
if (callee.type ===
|
|
6144
|
+
if (callee.type === import_utils41.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5999
6145
|
const name = callee.property.name;
|
|
6000
6146
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
6001
6147
|
hasClientIndicator = true;
|
|
@@ -6005,7 +6151,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6005
6151
|
return {
|
|
6006
6152
|
Program(node) {
|
|
6007
6153
|
for (const stmt of node.body) {
|
|
6008
|
-
if (stmt.type !==
|
|
6154
|
+
if (stmt.type !== import_utils41.AST_NODE_TYPES.ExpressionStatement) break;
|
|
6009
6155
|
if (isUseClientDirective(stmt)) {
|
|
6010
6156
|
directiveNode = stmt;
|
|
6011
6157
|
break;
|
|
@@ -6018,7 +6164,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6018
6164
|
},
|
|
6019
6165
|
JSXAttribute(node) {
|
|
6020
6166
|
if (directiveNode === null) return;
|
|
6021
|
-
if (node.name.type ===
|
|
6167
|
+
if (node.name.type === import_utils41.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
6022
6168
|
hasClientIndicator = true;
|
|
6023
6169
|
}
|
|
6024
6170
|
},
|
|
@@ -6085,18 +6231,18 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6085
6231
|
});
|
|
6086
6232
|
|
|
6087
6233
|
// src/rules/no-unsafe-mock-casting.ts
|
|
6088
|
-
var
|
|
6089
|
-
var
|
|
6234
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
6235
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
6090
6236
|
function isMockTypeReference(node) {
|
|
6091
|
-
if (node.type !==
|
|
6237
|
+
if (node.type !== import_utils43.AST_NODE_TYPES.TSTypeReference) {
|
|
6092
6238
|
return false;
|
|
6093
6239
|
}
|
|
6094
6240
|
const typeName = node.typeName;
|
|
6095
|
-
if (typeName.type ===
|
|
6241
|
+
if (typeName.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6096
6242
|
const name = typeName.name;
|
|
6097
6243
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
6098
6244
|
}
|
|
6099
|
-
if (typeName.type ===
|
|
6245
|
+
if (typeName.type === import_utils43.AST_NODE_TYPES.TSQualifiedName) {
|
|
6100
6246
|
const rightName = typeName.right.name;
|
|
6101
6247
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
6102
6248
|
}
|
|
@@ -6132,7 +6278,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
6132
6278
|
});
|
|
6133
6279
|
|
|
6134
6280
|
// src/rules/no-zod-native-enum.ts
|
|
6135
|
-
var
|
|
6281
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
6136
6282
|
var ts = __toESM(require("typescript"), 1);
|
|
6137
6283
|
var IGNORE_PATTERNS = [
|
|
6138
6284
|
/[\\/]generated[\\/]/,
|
|
@@ -6150,7 +6296,7 @@ function isZodModule(source) {
|
|
|
6150
6296
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
6151
6297
|
}
|
|
6152
6298
|
function unwrap2(node) {
|
|
6153
|
-
if (node.type ===
|
|
6299
|
+
if (node.type === import_utils44.AST_NODE_TYPES.TSAsExpression || node.type === import_utils44.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6154
6300
|
return unwrap2(node.expression);
|
|
6155
6301
|
}
|
|
6156
6302
|
return node;
|
|
@@ -6158,14 +6304,14 @@ function unwrap2(node) {
|
|
|
6158
6304
|
function stringValueTexts(node, sourceCode) {
|
|
6159
6305
|
const texts = [];
|
|
6160
6306
|
for (const prop of node.properties) {
|
|
6161
|
-
if (prop.type !==
|
|
6307
|
+
if (prop.type !== import_utils44.AST_NODE_TYPES.Property) {
|
|
6162
6308
|
return null;
|
|
6163
6309
|
}
|
|
6164
6310
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6165
6311
|
return null;
|
|
6166
6312
|
}
|
|
6167
6313
|
const value = prop.value;
|
|
6168
|
-
if (value.type !==
|
|
6314
|
+
if (value.type !== import_utils44.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
6169
6315
|
return null;
|
|
6170
6316
|
}
|
|
6171
6317
|
const text = sourceCode.getText(value);
|
|
@@ -6181,7 +6327,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6181
6327
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6182
6328
|
if (variable !== void 0) {
|
|
6183
6329
|
return variable.defs.some(
|
|
6184
|
-
(def) => def.node.type ===
|
|
6330
|
+
(def) => def.node.type === import_utils44.AST_NODE_TYPES.TSEnumDeclaration
|
|
6185
6331
|
);
|
|
6186
6332
|
}
|
|
6187
6333
|
current = current.upper;
|
|
@@ -6226,32 +6372,32 @@ var no_zod_native_enum_default = createRule({
|
|
|
6226
6372
|
}
|
|
6227
6373
|
let services;
|
|
6228
6374
|
try {
|
|
6229
|
-
services =
|
|
6375
|
+
services = import_utils44.ESLintUtils.getParserServices(context);
|
|
6230
6376
|
} catch {
|
|
6231
6377
|
services = null;
|
|
6232
6378
|
}
|
|
6233
6379
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6234
6380
|
function isZodMemberCall(node, api) {
|
|
6235
6381
|
const callee = node.callee;
|
|
6236
|
-
if (callee.type ===
|
|
6382
|
+
if (callee.type === import_utils44.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6237
6383
|
return callee.property.name === api;
|
|
6238
6384
|
}
|
|
6239
|
-
if (callee.type ===
|
|
6385
|
+
if (callee.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6240
6386
|
return zodImportedNames.get(callee.name) === api;
|
|
6241
6387
|
}
|
|
6242
6388
|
return false;
|
|
6243
6389
|
}
|
|
6244
6390
|
function buildFix(node) {
|
|
6245
6391
|
const callee = node.callee;
|
|
6246
|
-
if (callee.type !==
|
|
6392
|
+
if (callee.type !== import_utils44.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6247
6393
|
return null;
|
|
6248
6394
|
}
|
|
6249
6395
|
const arg = node.arguments[0];
|
|
6250
|
-
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) {
|
|
6251
6397
|
return null;
|
|
6252
6398
|
}
|
|
6253
6399
|
const inner = unwrap2(arg);
|
|
6254
|
-
if (inner.type !==
|
|
6400
|
+
if (inner.type !== import_utils44.AST_NODE_TYPES.ObjectExpression) {
|
|
6255
6401
|
return null;
|
|
6256
6402
|
}
|
|
6257
6403
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6271,7 +6417,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6271
6417
|
return;
|
|
6272
6418
|
}
|
|
6273
6419
|
for (const spec of node.specifiers) {
|
|
6274
|
-
if (spec.type ===
|
|
6420
|
+
if (spec.type === import_utils44.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6275
6421
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6276
6422
|
}
|
|
6277
6423
|
}
|
|
@@ -6290,7 +6436,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6290
6436
|
return;
|
|
6291
6437
|
}
|
|
6292
6438
|
const arg = node.arguments[0];
|
|
6293
|
-
if (arg === void 0 || arg.type !==
|
|
6439
|
+
if (arg === void 0 || arg.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6294
6440
|
return;
|
|
6295
6441
|
}
|
|
6296
6442
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6307,7 +6453,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6307
6453
|
});
|
|
6308
6454
|
|
|
6309
6455
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6310
|
-
var
|
|
6456
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
6311
6457
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6312
6458
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6313
6459
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6320,36 +6466,36 @@ function isConstantReference(identifier) {
|
|
|
6320
6466
|
}
|
|
6321
6467
|
function isExcludedOperand(node) {
|
|
6322
6468
|
switch (node.type) {
|
|
6323
|
-
case
|
|
6469
|
+
case import_utils45.AST_NODE_TYPES.Literal:
|
|
6324
6470
|
return true;
|
|
6325
|
-
case
|
|
6471
|
+
case import_utils45.AST_NODE_TYPES.TemplateLiteral:
|
|
6326
6472
|
return node.expressions.length === 0;
|
|
6327
|
-
case
|
|
6473
|
+
case import_utils45.AST_NODE_TYPES.Identifier:
|
|
6328
6474
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6329
|
-
case
|
|
6330
|
-
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));
|
|
6331
6477
|
default:
|
|
6332
6478
|
return false;
|
|
6333
6479
|
}
|
|
6334
6480
|
}
|
|
6335
6481
|
function operandName(node) {
|
|
6336
|
-
if (node.type ===
|
|
6482
|
+
if (node.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6337
6483
|
return node.name;
|
|
6338
6484
|
}
|
|
6339
|
-
if (node.type ===
|
|
6485
|
+
if (node.type === import_utils45.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6340
6486
|
return node.property.name;
|
|
6341
6487
|
}
|
|
6342
6488
|
return null;
|
|
6343
6489
|
}
|
|
6344
6490
|
function isSecretOperand(node) {
|
|
6345
|
-
if (node.type ===
|
|
6491
|
+
if (node.type === import_utils45.AST_NODE_TYPES.TemplateLiteral) {
|
|
6346
6492
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6347
6493
|
}
|
|
6348
6494
|
const name = operandName(node);
|
|
6349
6495
|
return name !== null && isAuthSecretName(name);
|
|
6350
6496
|
}
|
|
6351
6497
|
function secretNameOf(node) {
|
|
6352
|
-
if (node.type ===
|
|
6498
|
+
if (node.type === import_utils45.AST_NODE_TYPES.TemplateLiteral) {
|
|
6353
6499
|
for (const expression of node.expressions) {
|
|
6354
6500
|
const nested = secretNameOf(expression);
|
|
6355
6501
|
if (nested !== null) {
|
|
@@ -6401,8 +6547,8 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
6401
6547
|
});
|
|
6402
6548
|
|
|
6403
6549
|
// src/rules/prefer-discriminated-union.ts
|
|
6404
|
-
var
|
|
6405
|
-
var
|
|
6550
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
6551
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
6406
6552
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
6407
6553
|
"success",
|
|
6408
6554
|
"ok",
|
|
@@ -6412,27 +6558,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6412
6558
|
]);
|
|
6413
6559
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
6414
6560
|
function getMemberName(member) {
|
|
6415
|
-
if (member.type !==
|
|
6561
|
+
if (member.type !== import_utils47.AST_NODE_TYPES.TSPropertySignature) {
|
|
6416
6562
|
return null;
|
|
6417
6563
|
}
|
|
6418
6564
|
const { key } = member;
|
|
6419
|
-
if (key.type ===
|
|
6565
|
+
if (key.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6420
6566
|
return key.name;
|
|
6421
6567
|
}
|
|
6422
|
-
if (key.type ===
|
|
6568
|
+
if (key.type === import_utils47.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
6423
6569
|
return key.value;
|
|
6424
6570
|
}
|
|
6425
6571
|
return null;
|
|
6426
6572
|
}
|
|
6427
6573
|
function isBooleanTyped(member) {
|
|
6428
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6574
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils47.AST_NODE_TYPES.TSBooleanKeyword;
|
|
6429
6575
|
}
|
|
6430
6576
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
6431
6577
|
let hasStatusBoolean = false;
|
|
6432
6578
|
let optionalCount = 0;
|
|
6433
6579
|
let optionalPayloadCount = 0;
|
|
6434
6580
|
for (const member of typeLiteral.members) {
|
|
6435
|
-
if (member.type !==
|
|
6581
|
+
if (member.type !== import_utils47.AST_NODE_TYPES.TSPropertySignature) {
|
|
6436
6582
|
continue;
|
|
6437
6583
|
}
|
|
6438
6584
|
if (member.optional) {
|
|
@@ -6474,7 +6620,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6474
6620
|
TSInterfaceDeclaration(node) {
|
|
6475
6621
|
const synthetic = {
|
|
6476
6622
|
...node.body,
|
|
6477
|
-
type:
|
|
6623
|
+
type: import_utils47.AST_NODE_TYPES.TSTypeLiteral,
|
|
6478
6624
|
members: node.body.body
|
|
6479
6625
|
};
|
|
6480
6626
|
checkTypeLiteral(synthetic, node);
|
|
@@ -6487,7 +6633,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6487
6633
|
});
|
|
6488
6634
|
|
|
6489
6635
|
// src/rules/prefer-module-level-constant.ts
|
|
6490
|
-
var
|
|
6636
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6491
6637
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6492
6638
|
var MAX_LITERAL_DEPTH = 4;
|
|
6493
6639
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6516,9 +6662,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6516
6662
|
"assign"
|
|
6517
6663
|
]);
|
|
6518
6664
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6665
|
+
import_utils48.AST_NODE_TYPES.FunctionDeclaration,
|
|
6666
|
+
import_utils48.AST_NODE_TYPES.FunctionExpression,
|
|
6667
|
+
import_utils48.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6522
6668
|
]);
|
|
6523
6669
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6524
6670
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6531,14 +6677,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6531
6677
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6532
6678
|
}
|
|
6533
6679
|
function unwrap3(node) {
|
|
6534
|
-
if (node.type ===
|
|
6680
|
+
if (node.type === import_utils48.AST_NODE_TYPES.TSAsExpression || node.type === import_utils48.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils48.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6535
6681
|
return unwrap3(node.expression);
|
|
6536
6682
|
}
|
|
6537
6683
|
return node;
|
|
6538
6684
|
}
|
|
6539
6685
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6540
6686
|
function isRegexLiteral(node) {
|
|
6541
|
-
return node.type ===
|
|
6687
|
+
return node.type === import_utils48.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6542
6688
|
}
|
|
6543
6689
|
function isLiteralOnly(node, depth) {
|
|
6544
6690
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6546,29 +6692,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6546
6692
|
}
|
|
6547
6693
|
const inner = unwrap3(node);
|
|
6548
6694
|
switch (inner.type) {
|
|
6549
|
-
case
|
|
6695
|
+
case import_utils48.AST_NODE_TYPES.Literal: {
|
|
6550
6696
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6551
6697
|
}
|
|
6552
|
-
case
|
|
6698
|
+
case import_utils48.AST_NODE_TYPES.TemplateLiteral: {
|
|
6553
6699
|
return inner.expressions.length === 0;
|
|
6554
6700
|
}
|
|
6555
|
-
case
|
|
6556
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6701
|
+
case import_utils48.AST_NODE_TYPES.UnaryExpression: {
|
|
6702
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils48.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6557
6703
|
}
|
|
6558
|
-
case
|
|
6704
|
+
case import_utils48.AST_NODE_TYPES.ArrayExpression: {
|
|
6559
6705
|
return inner.elements.every(
|
|
6560
|
-
(el) => el !== null && el.type !==
|
|
6706
|
+
(el) => el !== null && el.type !== import_utils48.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6561
6707
|
);
|
|
6562
6708
|
}
|
|
6563
|
-
case
|
|
6709
|
+
case import_utils48.AST_NODE_TYPES.ObjectExpression: {
|
|
6564
6710
|
return inner.properties.every((prop) => {
|
|
6565
|
-
if (prop.type !==
|
|
6711
|
+
if (prop.type !== import_utils48.AST_NODE_TYPES.Property) {
|
|
6566
6712
|
return false;
|
|
6567
6713
|
}
|
|
6568
6714
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6569
6715
|
return false;
|
|
6570
6716
|
}
|
|
6571
|
-
if (prop.computed && prop.key.type !==
|
|
6717
|
+
if (prop.computed && prop.key.type !== import_utils48.AST_NODE_TYPES.Literal) {
|
|
6572
6718
|
return false;
|
|
6573
6719
|
}
|
|
6574
6720
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6581,7 +6727,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6581
6727
|
}
|
|
6582
6728
|
function unwrapObjectFreeze(node) {
|
|
6583
6729
|
const inner = unwrap3(node);
|
|
6584
|
-
if (inner.type ===
|
|
6730
|
+
if (inner.type === import_utils48.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils48.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils48.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils48.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils48.AST_NODE_TYPES.SpreadElement) {
|
|
6585
6731
|
return unwrap3(inner.arguments[0]);
|
|
6586
6732
|
}
|
|
6587
6733
|
return inner;
|
|
@@ -6597,19 +6743,19 @@ function classify(init, checkRegex) {
|
|
|
6597
6743
|
}
|
|
6598
6744
|
return { kind: "regex", size: 1 };
|
|
6599
6745
|
}
|
|
6600
|
-
if (node.type ===
|
|
6746
|
+
if (node.type === import_utils48.AST_NODE_TYPES.ArrayExpression) {
|
|
6601
6747
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6602
6748
|
}
|
|
6603
|
-
if (node.type ===
|
|
6749
|
+
if (node.type === import_utils48.AST_NODE_TYPES.ObjectExpression) {
|
|
6604
6750
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6605
6751
|
}
|
|
6606
|
-
if (node.type ===
|
|
6752
|
+
if (node.type === import_utils48.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils48.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6607
6753
|
const arg = node.arguments[0];
|
|
6608
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6754
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils48.AST_NODE_TYPES.SpreadElement) {
|
|
6609
6755
|
return null;
|
|
6610
6756
|
}
|
|
6611
6757
|
const entries = unwrap3(arg);
|
|
6612
|
-
if (entries.type !==
|
|
6758
|
+
if (entries.type !== import_utils48.AST_NODE_TYPES.ArrayExpression) {
|
|
6613
6759
|
return null;
|
|
6614
6760
|
}
|
|
6615
6761
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6638,10 +6784,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6638
6784
|
);
|
|
6639
6785
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6640
6786
|
const callee = node.callee;
|
|
6641
|
-
if (callee.type ===
|
|
6787
|
+
if (callee.type === import_utils48.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6642
6788
|
return true;
|
|
6643
6789
|
}
|
|
6644
|
-
if (callee.type !==
|
|
6790
|
+
if (callee.type !== import_utils48.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils48.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6645
6791
|
return false;
|
|
6646
6792
|
}
|
|
6647
6793
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6655,38 +6801,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6655
6801
|
}
|
|
6656
6802
|
function isSafeRead(identifier) {
|
|
6657
6803
|
const parent = identifier.parent;
|
|
6658
|
-
if (parent.type ===
|
|
6804
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.MemberExpression) {
|
|
6659
6805
|
if (parent.object !== identifier) {
|
|
6660
6806
|
return true;
|
|
6661
6807
|
}
|
|
6662
6808
|
const grandparent = parent.parent;
|
|
6663
|
-
if (grandparent.type ===
|
|
6809
|
+
if (grandparent.type === import_utils48.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6664
6810
|
return false;
|
|
6665
6811
|
}
|
|
6666
|
-
if (grandparent.type ===
|
|
6812
|
+
if (grandparent.type === import_utils48.AST_NODE_TYPES.UpdateExpression) {
|
|
6667
6813
|
return false;
|
|
6668
6814
|
}
|
|
6669
|
-
if (grandparent.type ===
|
|
6815
|
+
if (grandparent.type === import_utils48.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6670
6816
|
return false;
|
|
6671
6817
|
}
|
|
6672
|
-
if (!parent.computed && parent.property.type ===
|
|
6818
|
+
if (!parent.computed && parent.property.type === import_utils48.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils48.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6673
6819
|
return false;
|
|
6674
6820
|
}
|
|
6675
6821
|
return true;
|
|
6676
6822
|
}
|
|
6677
|
-
if (parent.type ===
|
|
6823
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6678
6824
|
return true;
|
|
6679
6825
|
}
|
|
6680
|
-
if (parent.type ===
|
|
6826
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.SpreadElement) {
|
|
6681
6827
|
return true;
|
|
6682
6828
|
}
|
|
6683
|
-
if (parent.type ===
|
|
6829
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.BinaryExpression) {
|
|
6684
6830
|
return true;
|
|
6685
6831
|
}
|
|
6686
|
-
if (parent.type ===
|
|
6832
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6687
6833
|
return true;
|
|
6688
6834
|
}
|
|
6689
|
-
if (parent.type ===
|
|
6835
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6690
6836
|
return true;
|
|
6691
6837
|
}
|
|
6692
6838
|
return false;
|
|
@@ -6741,7 +6887,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6741
6887
|
if (reference.isWrite()) {
|
|
6742
6888
|
return false;
|
|
6743
6889
|
}
|
|
6744
|
-
if (reference.identifier.type !==
|
|
6890
|
+
if (reference.identifier.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6745
6891
|
return false;
|
|
6746
6892
|
}
|
|
6747
6893
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6753,10 +6899,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6753
6899
|
return {
|
|
6754
6900
|
VariableDeclarator(node) {
|
|
6755
6901
|
const declaration = node.parent;
|
|
6756
|
-
if (declaration.type !==
|
|
6902
|
+
if (declaration.type !== import_utils48.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6757
6903
|
return;
|
|
6758
6904
|
}
|
|
6759
|
-
if (node.id.type !==
|
|
6905
|
+
if (node.id.type !== import_utils48.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6760
6906
|
return;
|
|
6761
6907
|
}
|
|
6762
6908
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6783,7 +6929,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6783
6929
|
});
|
|
6784
6930
|
|
|
6785
6931
|
// src/rules/prefer-module-level-schema.ts
|
|
6786
|
-
var
|
|
6932
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
6787
6933
|
|
|
6788
6934
|
// src/rules/_zod.ts
|
|
6789
6935
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6849,9 +6995,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6849
6995
|
"intl"
|
|
6850
6996
|
]);
|
|
6851
6997
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6998
|
+
import_utils49.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
6999
|
+
import_utils49.AST_NODE_TYPES.FunctionDeclaration,
|
|
7000
|
+
import_utils49.AST_NODE_TYPES.FunctionExpression
|
|
6855
7001
|
]);
|
|
6856
7002
|
function schemaExpression(node) {
|
|
6857
7003
|
let current = node;
|
|
@@ -6860,10 +7006,10 @@ function schemaExpression(node) {
|
|
|
6860
7006
|
if (parent === void 0) {
|
|
6861
7007
|
return current;
|
|
6862
7008
|
}
|
|
6863
|
-
if (parent.type ===
|
|
7009
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils49.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6864
7010
|
return current;
|
|
6865
7011
|
}
|
|
6866
|
-
if (parent.type ===
|
|
7012
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils49.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
6867
7013
|
current = parent;
|
|
6868
7014
|
continue;
|
|
6869
7015
|
}
|
|
@@ -6914,22 +7060,22 @@ function subtreeSome(root, predicate) {
|
|
|
6914
7060
|
function readsReceiver(node) {
|
|
6915
7061
|
return subtreeSome(
|
|
6916
7062
|
node,
|
|
6917
|
-
(inner) => inner.type ===
|
|
7063
|
+
(inner) => inner.type === import_utils49.AST_NODE_TYPES.ThisExpression || inner.type === import_utils49.AST_NODE_TYPES.Super || inner.type === import_utils49.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
6918
7064
|
);
|
|
6919
7065
|
}
|
|
6920
7066
|
function buildsLocalizedText(node) {
|
|
6921
7067
|
return subtreeSome(node, (inner) => {
|
|
6922
|
-
if (inner.type ===
|
|
7068
|
+
if (inner.type === import_utils49.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
6923
7069
|
return true;
|
|
6924
7070
|
}
|
|
6925
|
-
if (inner.type !==
|
|
7071
|
+
if (inner.type !== import_utils49.AST_NODE_TYPES.CallExpression) {
|
|
6926
7072
|
return false;
|
|
6927
7073
|
}
|
|
6928
7074
|
const { callee } = inner;
|
|
6929
|
-
if (callee.type ===
|
|
7075
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
6930
7076
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6931
7077
|
}
|
|
6932
|
-
return callee.type ===
|
|
7078
|
+
return callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6933
7079
|
});
|
|
6934
7080
|
}
|
|
6935
7081
|
function collectReferences(scope, out) {
|
|
@@ -6986,15 +7132,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6986
7132
|
}
|
|
6987
7133
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
6988
7134
|
function isZodCall(node) {
|
|
6989
|
-
return node.type ===
|
|
7135
|
+
return node.type === import_utils49.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
6990
7136
|
}
|
|
6991
7137
|
function isCovered(node) {
|
|
6992
7138
|
let current = node.parent ?? void 0;
|
|
6993
7139
|
while (current !== void 0) {
|
|
6994
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7140
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
6995
7141
|
return true;
|
|
6996
7142
|
}
|
|
6997
|
-
if (current.type ===
|
|
7143
|
+
if (current.type === import_utils49.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils49.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
6998
7144
|
return true;
|
|
6999
7145
|
}
|
|
7000
7146
|
current = current.parent ?? void 0;
|
|
@@ -7009,11 +7155,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7009
7155
|
if (parent === void 0) {
|
|
7010
7156
|
return confirmed;
|
|
7011
7157
|
}
|
|
7012
|
-
if (parent.type ===
|
|
7158
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils49.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils49.AST_NODE_TYPES.ArrayExpression) {
|
|
7013
7159
|
current = parent;
|
|
7014
7160
|
continue;
|
|
7015
7161
|
}
|
|
7016
|
-
if (parent.type ===
|
|
7162
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7017
7163
|
current = schemaExpression(parent);
|
|
7018
7164
|
confirmed = current;
|
|
7019
7165
|
continue;
|
|
@@ -7023,7 +7169,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7023
7169
|
}
|
|
7024
7170
|
function isSchemaComposition(node) {
|
|
7025
7171
|
const { callee } = node;
|
|
7026
|
-
const isCombinator = callee.type ===
|
|
7172
|
+
const isCombinator = callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7027
7173
|
return isCombinator || isZodCall(node);
|
|
7028
7174
|
}
|
|
7029
7175
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7057,13 +7203,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7057
7203
|
}
|
|
7058
7204
|
function ownerName(enclosing) {
|
|
7059
7205
|
const parent = enclosing.parent ?? void 0;
|
|
7060
|
-
if (enclosing.type ===
|
|
7206
|
+
if (enclosing.type === import_utils49.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
7061
7207
|
return enclosing.id.name;
|
|
7062
7208
|
}
|
|
7063
|
-
if (parent !== void 0 && parent.type ===
|
|
7209
|
+
if (parent !== void 0 && parent.type === import_utils49.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7064
7210
|
return parent.id.name;
|
|
7065
7211
|
}
|
|
7066
|
-
if (parent !== void 0 && (parent.type ===
|
|
7212
|
+
if (parent !== void 0 && (parent.type === import_utils49.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils49.AST_NODE_TYPES.Property) && parent.key.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7067
7213
|
return parent.key.name;
|
|
7068
7214
|
}
|
|
7069
7215
|
return "this function";
|
|
@@ -7074,7 +7220,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7074
7220
|
return;
|
|
7075
7221
|
}
|
|
7076
7222
|
for (const specifier of node.specifiers) {
|
|
7077
|
-
if (specifier.type ===
|
|
7223
|
+
if (specifier.type === import_utils49.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils49.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils49.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils49.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
7078
7224
|
zodNamespaces.add(specifier.local.name);
|
|
7079
7225
|
}
|
|
7080
7226
|
}
|
|
@@ -7084,7 +7230,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7084
7230
|
return;
|
|
7085
7231
|
}
|
|
7086
7232
|
const callee = node.callee;
|
|
7087
|
-
if (callee.property.type !==
|
|
7233
|
+
if (callee.property.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7088
7234
|
return;
|
|
7089
7235
|
}
|
|
7090
7236
|
const factory = callee.property.name;
|
|
@@ -7099,7 +7245,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7099
7245
|
return;
|
|
7100
7246
|
}
|
|
7101
7247
|
const shape = node.arguments[0];
|
|
7102
|
-
if (shape !== void 0 && shape.type ===
|
|
7248
|
+
if (shape !== void 0 && shape.type === import_utils49.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
7103
7249
|
return;
|
|
7104
7250
|
}
|
|
7105
7251
|
const expression = schemaExpression(node);
|
|
@@ -7127,20 +7273,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7127
7273
|
});
|
|
7128
7274
|
|
|
7129
7275
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7130
|
-
var
|
|
7276
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7131
7277
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7132
7278
|
function propertyName(node) {
|
|
7133
7279
|
const key = node.key;
|
|
7134
|
-
if (key.type ===
|
|
7135
|
-
if (key.type ===
|
|
7280
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Identifier) return key.name;
|
|
7281
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Literal) return String(key.value);
|
|
7136
7282
|
return "collection";
|
|
7137
7283
|
}
|
|
7138
7284
|
function isArrayType(node) {
|
|
7139
|
-
if (node.type ===
|
|
7140
|
-
return node.type ===
|
|
7285
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TSArrayType) return true;
|
|
7286
|
+
return node.type === import_utils50.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils50.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7141
7287
|
}
|
|
7142
7288
|
function isNullishType(node) {
|
|
7143
|
-
return node.type ===
|
|
7289
|
+
return node.type === import_utils50.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils50.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7144
7290
|
}
|
|
7145
7291
|
function isNullableArrayOnly(node) {
|
|
7146
7292
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7168,7 +7314,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7168
7314
|
if (node.optional) return;
|
|
7169
7315
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7170
7316
|
if (annotation === void 0) return;
|
|
7171
|
-
if (annotation.type !==
|
|
7317
|
+
if (annotation.type !== import_utils50.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7172
7318
|
return;
|
|
7173
7319
|
}
|
|
7174
7320
|
context.report({
|
|
@@ -7181,7 +7327,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7181
7327
|
TSPropertySignature: checkOptionalProperty,
|
|
7182
7328
|
PropertyDefinition: checkOptionalProperty,
|
|
7183
7329
|
TSTypeAliasDeclaration(node) {
|
|
7184
|
-
if (node.typeAnnotation.type !==
|
|
7330
|
+
if (node.typeAnnotation.type !== import_utils50.AST_NODE_TYPES.TSUnionType) return;
|
|
7185
7331
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7186
7332
|
context.report({
|
|
7187
7333
|
node,
|
|
@@ -7193,14 +7339,100 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7193
7339
|
}
|
|
7194
7340
|
});
|
|
7195
7341
|
|
|
7342
|
+
// src/rules/prefer-native-random-uuid.ts
|
|
7343
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7344
|
+
function requireUuid(node) {
|
|
7345
|
+
return node?.type === import_utils51.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils51.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === import_utils51.AST_NODE_TYPES.Literal && node.arguments[0].value === "uuid";
|
|
7346
|
+
}
|
|
7347
|
+
var prefer_native_random_uuid_default = createRule({
|
|
7348
|
+
name: "prefer-native-random-uuid",
|
|
7349
|
+
meta: {
|
|
7350
|
+
type: "suggestion",
|
|
7351
|
+
docs: {
|
|
7352
|
+
description: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package."
|
|
7353
|
+
},
|
|
7354
|
+
hasSuggestions: true,
|
|
7355
|
+
schema: [],
|
|
7356
|
+
messages: {
|
|
7357
|
+
preferNative: "Use the Node 22 native `globalThis.crypto.randomUUID()` instead of the `uuid` package for UUID v4.",
|
|
7358
|
+
replaceWithNative: "Replace this UUID v4 call with the native implementation."
|
|
7359
|
+
}
|
|
7360
|
+
},
|
|
7361
|
+
defaultOptions: [],
|
|
7362
|
+
create(context) {
|
|
7363
|
+
const directBindings = /* @__PURE__ */ new Set();
|
|
7364
|
+
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7365
|
+
function resolve(identifier) {
|
|
7366
|
+
return import_utils51.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7367
|
+
}
|
|
7368
|
+
function record(identifier, destination) {
|
|
7369
|
+
const variable = resolve(identifier);
|
|
7370
|
+
if (variable !== null) destination.add(variable);
|
|
7371
|
+
}
|
|
7372
|
+
function report(node) {
|
|
7373
|
+
context.report({
|
|
7374
|
+
node,
|
|
7375
|
+
messageId: "preferNative",
|
|
7376
|
+
suggest: [
|
|
7377
|
+
{
|
|
7378
|
+
messageId: "replaceWithNative",
|
|
7379
|
+
fix: (fixer) => fixer.replaceText(node, "globalThis.crypto.randomUUID()")
|
|
7380
|
+
}
|
|
7381
|
+
]
|
|
7382
|
+
});
|
|
7383
|
+
}
|
|
7384
|
+
return {
|
|
7385
|
+
ImportDeclaration(node) {
|
|
7386
|
+
if (node.source.value !== "uuid") return;
|
|
7387
|
+
for (const specifier of node.specifiers) {
|
|
7388
|
+
if (specifier.type === import_utils51.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils51.AST_NODE_TYPES.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7389
|
+
record(specifier.local, directBindings);
|
|
7390
|
+
} else if (specifier.type === import_utils51.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
7391
|
+
record(specifier.local, namespaceBindings);
|
|
7392
|
+
}
|
|
7393
|
+
}
|
|
7394
|
+
},
|
|
7395
|
+
VariableDeclarator(node) {
|
|
7396
|
+
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7397
|
+
if (node.init?.type !== import_utils51.AST_NODE_TYPES.CallExpression || node.init.callee.type !== import_utils51.AST_NODE_TYPES.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
7398
|
+
return;
|
|
7399
|
+
}
|
|
7400
|
+
if (node.id.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7401
|
+
record(node.id, namespaceBindings);
|
|
7402
|
+
return;
|
|
7403
|
+
}
|
|
7404
|
+
if (node.id.type !== import_utils51.AST_NODE_TYPES.ObjectPattern) return;
|
|
7405
|
+
for (const property of node.id.properties) {
|
|
7406
|
+
if (property.type === import_utils51.AST_NODE_TYPES.Property && !property.computed && (property.key.type === import_utils51.AST_NODE_TYPES.Identifier && property.key.name === "v4" || property.key.type === import_utils51.AST_NODE_TYPES.Literal && property.key.value === "v4") && property.value.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7407
|
+
record(property.value, directBindings);
|
|
7408
|
+
}
|
|
7409
|
+
}
|
|
7410
|
+
},
|
|
7411
|
+
"CallExpression:exit"(node) {
|
|
7412
|
+
if (node.arguments.length !== 0) return;
|
|
7413
|
+
if (node.callee.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7414
|
+
const variable2 = resolve(node.callee);
|
|
7415
|
+
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7416
|
+
return;
|
|
7417
|
+
}
|
|
7418
|
+
if (node.callee.type !== import_utils51.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.object.type !== import_utils51.AST_NODE_TYPES.Identifier || node.callee.property.type !== import_utils51.AST_NODE_TYPES.Identifier || node.callee.property.name !== "v4") {
|
|
7419
|
+
return;
|
|
7420
|
+
}
|
|
7421
|
+
const variable = resolve(node.callee.object);
|
|
7422
|
+
if (variable !== null && namespaceBindings.has(variable)) report(node);
|
|
7423
|
+
}
|
|
7424
|
+
};
|
|
7425
|
+
}
|
|
7426
|
+
});
|
|
7427
|
+
|
|
7196
7428
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7197
|
-
var
|
|
7429
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7198
7430
|
var unwrap4 = (node) => {
|
|
7199
7431
|
let current = node;
|
|
7200
7432
|
while (current !== null && current !== void 0) {
|
|
7201
|
-
if (current.type ===
|
|
7433
|
+
if (current.type === import_utils52.AST_NODE_TYPES.TSAsExpression || current.type === import_utils52.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils52.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils52.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
7202
7434
|
current = current.expression;
|
|
7203
|
-
} else if (current.type ===
|
|
7435
|
+
} else if (current.type === import_utils52.AST_NODE_TYPES.ChainExpression) {
|
|
7204
7436
|
current = current.expression;
|
|
7205
7437
|
} else {
|
|
7206
7438
|
break;
|
|
@@ -7215,23 +7447,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7215
7447
|
]);
|
|
7216
7448
|
var isSchemaParseReference = (node) => {
|
|
7217
7449
|
const inner = unwrap4(node);
|
|
7218
|
-
return inner !== null && inner.type ===
|
|
7450
|
+
return inner !== null && inner.type === import_utils52.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils52.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7219
7451
|
};
|
|
7220
7452
|
var isRawPayloadSource = (node) => {
|
|
7221
7453
|
let current = unwrap4(node);
|
|
7222
7454
|
if (current === null) return false;
|
|
7223
|
-
if (current.type ===
|
|
7455
|
+
if (current.type === import_utils52.AST_NODE_TYPES.AwaitExpression) {
|
|
7224
7456
|
current = unwrap4(current.argument);
|
|
7225
7457
|
}
|
|
7226
|
-
if (current === null || current.type !==
|
|
7458
|
+
if (current === null || current.type !== import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7227
7459
|
return false;
|
|
7228
7460
|
}
|
|
7229
7461
|
const callee = unwrap4(current.callee);
|
|
7230
|
-
if (callee === null || callee.type !==
|
|
7462
|
+
if (callee === null || callee.type !== import_utils52.AST_NODE_TYPES.MemberExpression) {
|
|
7231
7463
|
return false;
|
|
7232
7464
|
}
|
|
7233
7465
|
const property = unwrap4(callee.property);
|
|
7234
|
-
if (property === null || property.type !==
|
|
7466
|
+
if (property === null || property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7235
7467
|
return false;
|
|
7236
7468
|
}
|
|
7237
7469
|
if (property.name === "json") {
|
|
@@ -7241,16 +7473,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7241
7473
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7242
7474
|
}
|
|
7243
7475
|
const object = unwrap4(callee.object);
|
|
7244
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7476
|
+
return property.name === "parse" && object !== null && object.type === import_utils52.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7245
7477
|
};
|
|
7246
7478
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7247
7479
|
var isLocalFileRead = (node) => {
|
|
7248
7480
|
let found = false;
|
|
7249
7481
|
const visit = (current) => {
|
|
7250
7482
|
if (found || current === null || current === void 0) return;
|
|
7251
|
-
if (current.type ===
|
|
7483
|
+
if (current.type === import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7252
7484
|
const callee = unwrap4(current.callee);
|
|
7253
|
-
const name = callee?.type ===
|
|
7485
|
+
const name = callee?.type === import_utils52.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils52.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils52.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
7254
7486
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7255
7487
|
found = true;
|
|
7256
7488
|
return;
|
|
@@ -7272,15 +7504,15 @@ var isLocalFileRead = (node) => {
|
|
|
7272
7504
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7273
7505
|
var isInsideAssertion = (node) => {
|
|
7274
7506
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7275
|
-
if (current.type !==
|
|
7507
|
+
if (current.type !== import_utils52.AST_NODE_TYPES.CallExpression) continue;
|
|
7276
7508
|
let callee = current.callee;
|
|
7277
|
-
while (callee.type ===
|
|
7509
|
+
while (callee.type === import_utils52.AST_NODE_TYPES.MemberExpression) {
|
|
7278
7510
|
callee = callee.object;
|
|
7279
7511
|
}
|
|
7280
|
-
if (callee.type ===
|
|
7512
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7281
7513
|
callee = callee.callee;
|
|
7282
7514
|
}
|
|
7283
|
-
if (callee.type ===
|
|
7515
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7284
7516
|
return true;
|
|
7285
7517
|
}
|
|
7286
7518
|
}
|
|
@@ -7299,39 +7531,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7299
7531
|
var isValidationRead = (node) => {
|
|
7300
7532
|
let current = node;
|
|
7301
7533
|
let parent = current.parent;
|
|
7302
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7534
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils52.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils52.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils52.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils52.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils52.AST_NODE_TYPES.ChainExpression)) {
|
|
7303
7535
|
current = parent;
|
|
7304
7536
|
parent = parent.parent;
|
|
7305
7537
|
}
|
|
7306
7538
|
if (parent === null || parent === void 0) return false;
|
|
7307
|
-
if (parent.type ===
|
|
7539
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7308
7540
|
return true;
|
|
7309
7541
|
}
|
|
7310
|
-
if (parent.type !==
|
|
7542
|
+
if (parent.type !== import_utils52.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7311
7543
|
return false;
|
|
7312
7544
|
}
|
|
7313
7545
|
const callee = parent.callee;
|
|
7314
|
-
if (callee.type ===
|
|
7546
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils52.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils52.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
7315
7547
|
return parent.arguments.length === 1;
|
|
7316
7548
|
}
|
|
7317
|
-
return callee.type ===
|
|
7549
|
+
return callee.type === import_utils52.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7318
7550
|
};
|
|
7319
7551
|
var isGuardTestPosition = (node) => {
|
|
7320
7552
|
let current = node;
|
|
7321
7553
|
let parent = current.parent;
|
|
7322
7554
|
while (parent !== void 0 && parent !== null) {
|
|
7323
7555
|
switch (parent.type) {
|
|
7324
|
-
case
|
|
7325
|
-
case
|
|
7326
|
-
case
|
|
7556
|
+
case import_utils52.AST_NODE_TYPES.UnaryExpression:
|
|
7557
|
+
case import_utils52.AST_NODE_TYPES.LogicalExpression:
|
|
7558
|
+
case import_utils52.AST_NODE_TYPES.ChainExpression:
|
|
7327
7559
|
current = parent;
|
|
7328
7560
|
parent = parent.parent;
|
|
7329
7561
|
continue;
|
|
7330
|
-
case
|
|
7331
|
-
case
|
|
7332
|
-
case
|
|
7333
|
-
case
|
|
7334
|
-
case
|
|
7562
|
+
case import_utils52.AST_NODE_TYPES.IfStatement:
|
|
7563
|
+
case import_utils52.AST_NODE_TYPES.ConditionalExpression:
|
|
7564
|
+
case import_utils52.AST_NODE_TYPES.WhileStatement:
|
|
7565
|
+
case import_utils52.AST_NODE_TYPES.DoWhileStatement:
|
|
7566
|
+
case import_utils52.AST_NODE_TYPES.ForStatement:
|
|
7335
7567
|
return parent.test === current;
|
|
7336
7568
|
default:
|
|
7337
7569
|
return false;
|
|
@@ -7341,7 +7573,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7341
7573
|
};
|
|
7342
7574
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7343
7575
|
const unwrapped = unwrap4(node);
|
|
7344
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7576
|
+
if (unwrapped === null || unwrapped.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7345
7577
|
return false;
|
|
7346
7578
|
}
|
|
7347
7579
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7384,11 +7616,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7384
7616
|
return {
|
|
7385
7617
|
VariableDeclarator(node) {
|
|
7386
7618
|
const scope = context.sourceCode.getScope(node);
|
|
7387
|
-
if (node.id.type ===
|
|
7619
|
+
if (node.id.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7388
7620
|
trackInitializer(node);
|
|
7389
7621
|
return;
|
|
7390
7622
|
}
|
|
7391
|
-
if (node.id.type ===
|
|
7623
|
+
if (node.id.type === import_utils52.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils52.AST_NODE_TYPES.ArrayPattern) {
|
|
7392
7624
|
if (isRawPayloadSource(node.init)) {
|
|
7393
7625
|
if (!isFullyNarrowedPattern(node)) {
|
|
7394
7626
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7402,7 +7634,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7402
7634
|
},
|
|
7403
7635
|
AssignmentExpression(node) {
|
|
7404
7636
|
const scope = context.sourceCode.getScope(node);
|
|
7405
|
-
if (node.left.type ===
|
|
7637
|
+
if (node.left.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7406
7638
|
const variable = findVariable2(scope, node.left.name);
|
|
7407
7639
|
if (variable === null) return;
|
|
7408
7640
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7412,7 +7644,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7412
7644
|
}
|
|
7413
7645
|
return;
|
|
7414
7646
|
}
|
|
7415
|
-
if (node.left.type ===
|
|
7647
|
+
if (node.left.type === import_utils52.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils52.AST_NODE_TYPES.ArrayPattern) {
|
|
7416
7648
|
if (isRawPayloadSource(node.right)) {
|
|
7417
7649
|
context.report({
|
|
7418
7650
|
node: node.left,
|
|
@@ -7429,15 +7661,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7429
7661
|
}
|
|
7430
7662
|
},
|
|
7431
7663
|
CallExpression(node) {
|
|
7432
|
-
if (node.callee.type !==
|
|
7664
|
+
if (node.callee.type !== import_utils52.AST_NODE_TYPES.Identifier) return;
|
|
7433
7665
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7434
7666
|
return;
|
|
7435
7667
|
}
|
|
7436
7668
|
const scope = context.sourceCode.getScope(node);
|
|
7437
7669
|
for (const arg of node.arguments) {
|
|
7438
|
-
if (arg.type ===
|
|
7670
|
+
if (arg.type === import_utils52.AST_NODE_TYPES.SpreadElement) continue;
|
|
7439
7671
|
const unwrapped = unwrap4(arg);
|
|
7440
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7672
|
+
if (unwrapped === null || unwrapped.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7441
7673
|
continue;
|
|
7442
7674
|
}
|
|
7443
7675
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7451,13 +7683,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7451
7683
|
const obj = unwrap4(node.object);
|
|
7452
7684
|
if (isRawPayloadSource(obj)) {
|
|
7453
7685
|
const parent = node.parent;
|
|
7454
|
-
if (parent.type ===
|
|
7686
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils52.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7455
7687
|
return;
|
|
7456
7688
|
}
|
|
7457
7689
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7458
7690
|
return;
|
|
7459
7691
|
}
|
|
7460
|
-
if (obj !== null && obj.type ===
|
|
7692
|
+
if (obj !== null && obj.type === import_utils52.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7461
7693
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7462
7694
|
const variable = findVariable2(scope, obj.name);
|
|
7463
7695
|
if (variable !== null) {
|
|
@@ -7470,7 +7702,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7470
7702
|
});
|
|
7471
7703
|
|
|
7472
7704
|
// src/rules/prefer-semantic-colors.ts
|
|
7473
|
-
var
|
|
7705
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7474
7706
|
var import_fs = require("fs");
|
|
7475
7707
|
var import_path = require("path");
|
|
7476
7708
|
|
|
@@ -7570,8 +7802,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7570
7802
|
]);
|
|
7571
7803
|
function jsxElementName(node) {
|
|
7572
7804
|
const name = node.openingElement.name;
|
|
7573
|
-
if (name.type ===
|
|
7574
|
-
if (name.type ===
|
|
7805
|
+
if (name.type === import_utils53.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
7806
|
+
if (name.type === import_utils53.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils53.AST_NODE_TYPES.JSXIdentifier) {
|
|
7575
7807
|
return name.property.name;
|
|
7576
7808
|
}
|
|
7577
7809
|
return null;
|
|
@@ -7597,7 +7829,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7597
7829
|
var isInsideSvg = (node) => {
|
|
7598
7830
|
let current = node.parent;
|
|
7599
7831
|
while (current !== void 0 && current !== null) {
|
|
7600
|
-
if (current.type ===
|
|
7832
|
+
if (current.type === import_utils53.AST_NODE_TYPES.JSXElement) {
|
|
7601
7833
|
const name = jsxElementName(current);
|
|
7602
7834
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7603
7835
|
}
|
|
@@ -7608,7 +7840,7 @@ var isInsideSvg = (node) => {
|
|
|
7608
7840
|
var isInsideIconFactoryPath = (node) => {
|
|
7609
7841
|
let current = node.parent;
|
|
7610
7842
|
while (current !== void 0 && current !== null) {
|
|
7611
|
-
if (current.type ===
|
|
7843
|
+
if (current.type === import_utils53.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils53.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils53.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils53.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7612
7844
|
return true;
|
|
7613
7845
|
}
|
|
7614
7846
|
current = current.parent;
|
|
@@ -7745,12 +7977,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7745
7977
|
return root !== null && workspaceHasMarker(root);
|
|
7746
7978
|
};
|
|
7747
7979
|
var propName = (key) => {
|
|
7748
|
-
if (key.type ===
|
|
7749
|
-
if (key.type ===
|
|
7980
|
+
if (key.type === import_utils53.AST_NODE_TYPES.Identifier) return key.name;
|
|
7981
|
+
if (key.type === import_utils53.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
7750
7982
|
return null;
|
|
7751
7983
|
};
|
|
7752
7984
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7753
|
-
if (statement.type !==
|
|
7985
|
+
if (statement.type !== import_utils53.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils53.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils53.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
7754
7986
|
return false;
|
|
7755
7987
|
}
|
|
7756
7988
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -7802,27 +8034,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7802
8034
|
const checkClassNode = (node) => {
|
|
7803
8035
|
if (node === null) return;
|
|
7804
8036
|
switch (node.type) {
|
|
7805
|
-
case
|
|
8037
|
+
case import_utils53.AST_NODE_TYPES.Literal:
|
|
7806
8038
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7807
8039
|
break;
|
|
7808
|
-
case
|
|
8040
|
+
case import_utils53.AST_NODE_TYPES.TemplateLiteral:
|
|
7809
8041
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7810
8042
|
break;
|
|
7811
|
-
case
|
|
8043
|
+
case import_utils53.AST_NODE_TYPES.ArrayExpression:
|
|
7812
8044
|
for (const element of node.elements) {
|
|
7813
|
-
if (element !== null && element.type !==
|
|
8045
|
+
if (element !== null && element.type !== import_utils53.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
7814
8046
|
}
|
|
7815
8047
|
break;
|
|
7816
|
-
case
|
|
8048
|
+
case import_utils53.AST_NODE_TYPES.ObjectExpression:
|
|
7817
8049
|
for (const property of node.properties) {
|
|
7818
|
-
if (property.type ===
|
|
8050
|
+
if (property.type === import_utils53.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
7819
8051
|
}
|
|
7820
8052
|
break;
|
|
7821
|
-
case
|
|
8053
|
+
case import_utils53.AST_NODE_TYPES.ConditionalExpression:
|
|
7822
8054
|
checkClassNode(node.consequent);
|
|
7823
8055
|
checkClassNode(node.alternate);
|
|
7824
8056
|
break;
|
|
7825
|
-
case
|
|
8057
|
+
case import_utils53.AST_NODE_TYPES.LogicalExpression:
|
|
7826
8058
|
checkClassNode(node.right);
|
|
7827
8059
|
break;
|
|
7828
8060
|
default:
|
|
@@ -7830,32 +8062,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7830
8062
|
}
|
|
7831
8063
|
};
|
|
7832
8064
|
const checkColorValueNode = (node) => {
|
|
7833
|
-
if (node.type ===
|
|
8065
|
+
if (node.type === import_utils53.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
7834
8066
|
report(node, "inlineColor", { value: node.value });
|
|
7835
8067
|
}
|
|
7836
8068
|
};
|
|
7837
8069
|
return {
|
|
7838
8070
|
"JSXAttribute[name.name='className']"(node) {
|
|
7839
8071
|
if (node.value === null) return;
|
|
7840
|
-
if (node.value.type ===
|
|
7841
|
-
else if (node.value.type ===
|
|
7842
|
-
if (node.value.expression.type !==
|
|
8072
|
+
if (node.value.type === import_utils53.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
8073
|
+
else if (node.value.type === import_utils53.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
8074
|
+
if (node.value.expression.type !== import_utils53.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
7843
8075
|
checkClassNode(node.value.expression);
|
|
7844
8076
|
}
|
|
7845
8077
|
}
|
|
7846
8078
|
},
|
|
7847
8079
|
CallExpression(node) {
|
|
7848
|
-
if (node.callee.type ===
|
|
8080
|
+
if (node.callee.type === import_utils53.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils53.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
7849
8081
|
importsEmailOrPdfRenderer = true;
|
|
7850
8082
|
}
|
|
7851
|
-
if (node.callee.type ===
|
|
8083
|
+
if (node.callee.type === import_utils53.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7852
8084
|
for (const arg of node.arguments) {
|
|
7853
|
-
if (arg.type !==
|
|
8085
|
+
if (arg.type !== import_utils53.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
7854
8086
|
}
|
|
7855
8087
|
}
|
|
7856
8088
|
},
|
|
7857
8089
|
VariableDeclarator(node) {
|
|
7858
|
-
if (node.id.type ===
|
|
8090
|
+
if (node.id.type === import_utils53.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
7859
8091
|
checkClassNode(node.init);
|
|
7860
8092
|
}
|
|
7861
8093
|
},
|
|
@@ -7865,9 +8097,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7865
8097
|
},
|
|
7866
8098
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
7867
8099
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
7868
|
-
if (node.value?.type !==
|
|
8100
|
+
if (node.value?.type !== import_utils53.AST_NODE_TYPES.Literal) return;
|
|
7869
8101
|
const owner = node.parent.name;
|
|
7870
|
-
if (owner.type ===
|
|
8102
|
+
if (owner.type === import_utils53.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
7871
8103
|
return;
|
|
7872
8104
|
}
|
|
7873
8105
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -7881,7 +8113,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7881
8113
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
7882
8114
|
},
|
|
7883
8115
|
ImportExpression(node) {
|
|
7884
|
-
if (node.source.type ===
|
|
8116
|
+
if (node.source.type === import_utils53.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
7885
8117
|
importsEmailOrPdfRenderer = true;
|
|
7886
8118
|
}
|
|
7887
8119
|
},
|
|
@@ -7894,7 +8126,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7894
8126
|
});
|
|
7895
8127
|
|
|
7896
8128
|
// src/rules/prefer-server-actions.ts
|
|
7897
|
-
var
|
|
8129
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
7898
8130
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
7899
8131
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
7900
8132
|
var SKIP_FILE_REGEX = /(?:\.test\.[jt]sx?$|\.spec\.[jt]sx?$|-(?:test|spec)\.[jt]sx?$|\/tests?\/|\/__tests__\/|\/__testfixtures__\/|\/scripts?\/|\/app\/api\/.*\/route\.[jt]sx?$|\/pages\/api\/)/;
|
|
@@ -8085,7 +8317,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8085
8317
|
});
|
|
8086
8318
|
|
|
8087
8319
|
// src/rules/prefer-string-literal-union.ts
|
|
8088
|
-
var
|
|
8320
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8089
8321
|
var ts2 = __toESM(require("typescript"), 1);
|
|
8090
8322
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
8091
8323
|
"status",
|
|
@@ -8128,19 +8360,19 @@ function isChoiceLikeName(name) {
|
|
|
8128
8360
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8129
8361
|
}
|
|
8130
8362
|
function keyName(key) {
|
|
8131
|
-
if (key.type ===
|
|
8363
|
+
if (key.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8132
8364
|
return key.name;
|
|
8133
8365
|
}
|
|
8134
|
-
if (key.type ===
|
|
8366
|
+
if (key.type === import_utils55.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
8135
8367
|
return key.value;
|
|
8136
8368
|
}
|
|
8137
8369
|
return null;
|
|
8138
8370
|
}
|
|
8139
8371
|
function isStringLiteralMember(t) {
|
|
8140
|
-
return t.type ===
|
|
8372
|
+
return t.type === import_utils55.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils55.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
8141
8373
|
}
|
|
8142
8374
|
function isStringLiteralUnion(node) {
|
|
8143
|
-
if (node?.type !==
|
|
8375
|
+
if (node?.type !== import_utils55.AST_NODE_TYPES.TSUnionType) {
|
|
8144
8376
|
return false;
|
|
8145
8377
|
}
|
|
8146
8378
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8169,12 +8401,12 @@ function bindingSourceExpression(decl) {
|
|
|
8169
8401
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8170
8402
|
}
|
|
8171
8403
|
function refKey(node) {
|
|
8172
|
-
if (node.type ===
|
|
8404
|
+
if (node.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8173
8405
|
return node.name;
|
|
8174
8406
|
}
|
|
8175
|
-
if (node.type ===
|
|
8407
|
+
if (node.type === import_utils55.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
8176
8408
|
const inner = refKey(node.object);
|
|
8177
|
-
if (inner === null || node.property.type !==
|
|
8409
|
+
if (inner === null || node.property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8178
8410
|
return null;
|
|
8179
8411
|
}
|
|
8180
8412
|
return `${inner}.${node.property.name}`;
|
|
@@ -8182,7 +8414,7 @@ function refKey(node) {
|
|
|
8182
8414
|
return null;
|
|
8183
8415
|
}
|
|
8184
8416
|
function strLiteral(node) {
|
|
8185
|
-
if (node.type ===
|
|
8417
|
+
if (node.type === import_utils55.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
8186
8418
|
return node.value;
|
|
8187
8419
|
}
|
|
8188
8420
|
return null;
|
|
@@ -8223,7 +8455,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8223
8455
|
);
|
|
8224
8456
|
let services;
|
|
8225
8457
|
try {
|
|
8226
|
-
services =
|
|
8458
|
+
services = import_utils55.ESLintUtils.getParserServices(context);
|
|
8227
8459
|
} catch {
|
|
8228
8460
|
services = null;
|
|
8229
8461
|
}
|
|
@@ -8335,7 +8567,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8335
8567
|
containersWithUnion.add(container);
|
|
8336
8568
|
return;
|
|
8337
8569
|
}
|
|
8338
|
-
if (typeNode?.type !==
|
|
8570
|
+
if (typeNode?.type !== import_utils55.AST_NODE_TYPES.TSStringKeyword) {
|
|
8339
8571
|
return;
|
|
8340
8572
|
}
|
|
8341
8573
|
const name = keyName(key);
|
|
@@ -8423,10 +8655,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8423
8655
|
}
|
|
8424
8656
|
};
|
|
8425
8657
|
function refKeyText(node) {
|
|
8426
|
-
if (node.type ===
|
|
8658
|
+
if (node.type === import_utils55.AST_NODE_TYPES.BinaryExpression) {
|
|
8427
8659
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8428
8660
|
}
|
|
8429
|
-
if (node.type ===
|
|
8661
|
+
if (node.type === import_utils55.AST_NODE_TYPES.SwitchStatement) {
|
|
8430
8662
|
return refKey(node.discriminant) ?? "value";
|
|
8431
8663
|
}
|
|
8432
8664
|
return "value";
|
|
@@ -8435,7 +8667,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8435
8667
|
});
|
|
8436
8668
|
|
|
8437
8669
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8438
|
-
var
|
|
8670
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8439
8671
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8440
8672
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8441
8673
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8444,11 +8676,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8444
8676
|
var MIN_RUN_LENGTH = 2;
|
|
8445
8677
|
function literalText(node, getText) {
|
|
8446
8678
|
switch (node.type) {
|
|
8447
|
-
case
|
|
8679
|
+
case import_utils56.AST_NODE_TYPES.Literal:
|
|
8448
8680
|
return "regex" in node ? null : getText(node);
|
|
8449
|
-
case
|
|
8681
|
+
case import_utils56.AST_NODE_TYPES.TemplateLiteral:
|
|
8450
8682
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8451
|
-
case
|
|
8683
|
+
case import_utils56.AST_NODE_TYPES.UnaryExpression:
|
|
8452
8684
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8453
8685
|
default:
|
|
8454
8686
|
return null;
|
|
@@ -8456,15 +8688,15 @@ function literalText(node, getText) {
|
|
|
8456
8688
|
}
|
|
8457
8689
|
function isPureReceiver(node) {
|
|
8458
8690
|
switch (node.type) {
|
|
8459
|
-
case
|
|
8460
|
-
case
|
|
8691
|
+
case import_utils56.AST_NODE_TYPES.Identifier:
|
|
8692
|
+
case import_utils56.AST_NODE_TYPES.ThisExpression:
|
|
8461
8693
|
return true;
|
|
8462
|
-
case
|
|
8694
|
+
case import_utils56.AST_NODE_TYPES.MemberExpression:
|
|
8463
8695
|
if (node.optional) {
|
|
8464
8696
|
return false;
|
|
8465
8697
|
}
|
|
8466
8698
|
if (node.computed) {
|
|
8467
|
-
return node.property.type ===
|
|
8699
|
+
return node.property.type === import_utils56.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8468
8700
|
}
|
|
8469
8701
|
return isPureReceiver(node.object);
|
|
8470
8702
|
default:
|
|
@@ -8472,7 +8704,7 @@ function isPureReceiver(node) {
|
|
|
8472
8704
|
}
|
|
8473
8705
|
}
|
|
8474
8706
|
function literalIndex(node) {
|
|
8475
|
-
if (node.type !==
|
|
8707
|
+
if (node.type !== import_utils56.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8476
8708
|
return null;
|
|
8477
8709
|
}
|
|
8478
8710
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8498,24 +8730,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8498
8730
|
}
|
|
8499
8731
|
const { sourceCode } = context;
|
|
8500
8732
|
function parseAssertion(statement) {
|
|
8501
|
-
if (statement.type !==
|
|
8733
|
+
if (statement.type !== import_utils56.AST_NODE_TYPES.ExpressionStatement) {
|
|
8502
8734
|
return null;
|
|
8503
8735
|
}
|
|
8504
8736
|
const call = statement.expression;
|
|
8505
|
-
if (call.type !==
|
|
8737
|
+
if (call.type !== import_utils56.AST_NODE_TYPES.CallExpression) {
|
|
8506
8738
|
return null;
|
|
8507
8739
|
}
|
|
8508
8740
|
const callee = call.callee;
|
|
8509
|
-
if (callee.type !==
|
|
8741
|
+
if (callee.type !== import_utils56.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8510
8742
|
return null;
|
|
8511
8743
|
}
|
|
8512
8744
|
const matcher = callee.property.name;
|
|
8513
8745
|
const expectCall = callee.object;
|
|
8514
|
-
if (expectCall.type !==
|
|
8746
|
+
if (expectCall.type !== import_utils56.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils56.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8515
8747
|
return null;
|
|
8516
8748
|
}
|
|
8517
8749
|
const actual = expectCall.arguments[0];
|
|
8518
|
-
if (actual === void 0 || actual.type !==
|
|
8750
|
+
if (actual === void 0 || actual.type !== import_utils56.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8519
8751
|
return null;
|
|
8520
8752
|
}
|
|
8521
8753
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8529,7 +8761,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8529
8761
|
}
|
|
8530
8762
|
key = { kind: "index", index };
|
|
8531
8763
|
} else {
|
|
8532
|
-
if (actual.property.type !==
|
|
8764
|
+
if (actual.property.type !== import_utils56.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8533
8765
|
return null;
|
|
8534
8766
|
}
|
|
8535
8767
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8541,7 +8773,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8541
8773
|
return null;
|
|
8542
8774
|
}
|
|
8543
8775
|
const expected = call.arguments[0];
|
|
8544
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8776
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils56.AST_NODE_TYPES.SpreadElement) {
|
|
8545
8777
|
return null;
|
|
8546
8778
|
}
|
|
8547
8779
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8656,7 +8888,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8656
8888
|
});
|
|
8657
8889
|
|
|
8658
8890
|
// src/rules/prefer-zod-enum.ts
|
|
8659
|
-
var
|
|
8891
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8660
8892
|
var prefer_zod_enum_default = createRule({
|
|
8661
8893
|
name: "prefer-zod-enum",
|
|
8662
8894
|
meta: {
|
|
@@ -8676,25 +8908,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
8676
8908
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8677
8909
|
function enumValues(node) {
|
|
8678
8910
|
const callee = node.callee;
|
|
8679
|
-
if (callee.type !==
|
|
8911
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils57.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8680
8912
|
return null;
|
|
8681
8913
|
}
|
|
8682
8914
|
const argument = node.arguments[0];
|
|
8683
|
-
if (argument === void 0 || argument.type !==
|
|
8915
|
+
if (argument === void 0 || argument.type !== import_utils57.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
8684
8916
|
return null;
|
|
8685
8917
|
}
|
|
8686
8918
|
const values = [];
|
|
8687
8919
|
let canFix = true;
|
|
8688
8920
|
for (const element of argument.elements) {
|
|
8689
|
-
if (element?.type ===
|
|
8921
|
+
if (element?.type === import_utils57.AST_NODE_TYPES.SpreadElement) {
|
|
8690
8922
|
canFix = false;
|
|
8691
8923
|
continue;
|
|
8692
8924
|
}
|
|
8693
|
-
if (element === null || element.type !==
|
|
8925
|
+
if (element === null || element.type !== import_utils57.AST_NODE_TYPES.CallExpression || element.callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils57.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
8694
8926
|
return null;
|
|
8695
8927
|
}
|
|
8696
8928
|
const value = element.arguments[0];
|
|
8697
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
8929
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== import_utils57.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
8698
8930
|
canFix = false;
|
|
8699
8931
|
continue;
|
|
8700
8932
|
}
|
|
@@ -8704,11 +8936,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
8704
8936
|
}
|
|
8705
8937
|
function buildFix(node, values) {
|
|
8706
8938
|
const argument = node.arguments[0];
|
|
8707
|
-
if (argument === void 0 || argument.type !==
|
|
8939
|
+
if (argument === void 0 || argument.type !== import_utils57.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8708
8940
|
return void 0;
|
|
8709
8941
|
}
|
|
8710
8942
|
const callee = node.callee;
|
|
8711
|
-
if (callee.type !==
|
|
8943
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8712
8944
|
return void 0;
|
|
8713
8945
|
}
|
|
8714
8946
|
return (fixer) => [
|
|
@@ -8725,7 +8957,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8725
8957
|
return;
|
|
8726
8958
|
}
|
|
8727
8959
|
for (const specifier of node.specifiers) {
|
|
8728
|
-
if (specifier.type ===
|
|
8960
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils57.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils57.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils57.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8729
8961
|
zodNamespaces.add(specifier.local.name);
|
|
8730
8962
|
}
|
|
8731
8963
|
}
|
|
@@ -8747,7 +8979,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8747
8979
|
});
|
|
8748
8980
|
|
|
8749
8981
|
// src/rules/prefer-zod-infer.ts
|
|
8750
|
-
var
|
|
8982
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8751
8983
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8752
8984
|
"describe",
|
|
8753
8985
|
"refine",
|
|
@@ -8784,44 +9016,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8784
9016
|
"Schema"
|
|
8785
9017
|
]);
|
|
8786
9018
|
var LEAF_NODE_TYPES = {
|
|
8787
|
-
string: [
|
|
8788
|
-
email: [
|
|
8789
|
-
url: [
|
|
8790
|
-
uuid: [
|
|
8791
|
-
ulid: [
|
|
8792
|
-
cuid: [
|
|
8793
|
-
cuid2: [
|
|
8794
|
-
nanoid: [
|
|
8795
|
-
iso: [
|
|
8796
|
-
number: [
|
|
8797
|
-
int: [
|
|
8798
|
-
float32: [
|
|
8799
|
-
float64: [
|
|
8800
|
-
boolean: [
|
|
8801
|
-
bigint: [
|
|
8802
|
-
symbol: [
|
|
8803
|
-
any: [
|
|
8804
|
-
unknown: [
|
|
8805
|
-
never: [
|
|
8806
|
-
void: [
|
|
8807
|
-
null: [
|
|
8808
|
-
undefined: [
|
|
8809
|
-
literal: [
|
|
8810
|
-
date: [
|
|
8811
|
-
array: [
|
|
8812
|
-
tuple: [
|
|
8813
|
-
object: [
|
|
8814
|
-
strictObject: [
|
|
8815
|
-
looseObject: [
|
|
8816
|
-
record: [
|
|
8817
|
-
map: [
|
|
8818
|
-
set: [
|
|
8819
|
-
promise: [
|
|
8820
|
-
enum: [
|
|
8821
|
-
nativeEnum: [
|
|
8822
|
-
union: [
|
|
8823
|
-
discriminatedUnion: [
|
|
8824
|
-
intersection: [
|
|
9019
|
+
string: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9020
|
+
email: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9021
|
+
url: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9022
|
+
uuid: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9023
|
+
ulid: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9024
|
+
cuid: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9025
|
+
cuid2: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9026
|
+
nanoid: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9027
|
+
iso: [import_utils58.AST_NODE_TYPES.TSStringKeyword],
|
|
9028
|
+
number: [import_utils58.AST_NODE_TYPES.TSNumberKeyword],
|
|
9029
|
+
int: [import_utils58.AST_NODE_TYPES.TSNumberKeyword],
|
|
9030
|
+
float32: [import_utils58.AST_NODE_TYPES.TSNumberKeyword],
|
|
9031
|
+
float64: [import_utils58.AST_NODE_TYPES.TSNumberKeyword],
|
|
9032
|
+
boolean: [import_utils58.AST_NODE_TYPES.TSBooleanKeyword],
|
|
9033
|
+
bigint: [import_utils58.AST_NODE_TYPES.TSBigIntKeyword],
|
|
9034
|
+
symbol: [import_utils58.AST_NODE_TYPES.TSSymbolKeyword],
|
|
9035
|
+
any: [import_utils58.AST_NODE_TYPES.TSAnyKeyword],
|
|
9036
|
+
unknown: [import_utils58.AST_NODE_TYPES.TSUnknownKeyword],
|
|
9037
|
+
never: [import_utils58.AST_NODE_TYPES.TSNeverKeyword],
|
|
9038
|
+
void: [import_utils58.AST_NODE_TYPES.TSVoidKeyword],
|
|
9039
|
+
null: [import_utils58.AST_NODE_TYPES.TSNullKeyword],
|
|
9040
|
+
undefined: [import_utils58.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
9041
|
+
literal: [import_utils58.AST_NODE_TYPES.TSLiteralType],
|
|
9042
|
+
date: [import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9043
|
+
array: [import_utils58.AST_NODE_TYPES.TSArrayType, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9044
|
+
tuple: [import_utils58.AST_NODE_TYPES.TSTupleType],
|
|
9045
|
+
object: [import_utils58.AST_NODE_TYPES.TSTypeLiteral, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9046
|
+
strictObject: [import_utils58.AST_NODE_TYPES.TSTypeLiteral, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9047
|
+
looseObject: [import_utils58.AST_NODE_TYPES.TSTypeLiteral, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9048
|
+
record: [import_utils58.AST_NODE_TYPES.TSTypeReference, import_utils58.AST_NODE_TYPES.TSTypeLiteral],
|
|
9049
|
+
map: [import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9050
|
+
set: [import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9051
|
+
promise: [import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9052
|
+
enum: [import_utils58.AST_NODE_TYPES.TSUnionType, import_utils58.AST_NODE_TYPES.TSTypeReference, import_utils58.AST_NODE_TYPES.TSLiteralType],
|
|
9053
|
+
nativeEnum: [import_utils58.AST_NODE_TYPES.TSUnionType, import_utils58.AST_NODE_TYPES.TSTypeReference, import_utils58.AST_NODE_TYPES.TSLiteralType],
|
|
9054
|
+
union: [import_utils58.AST_NODE_TYPES.TSUnionType, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9055
|
+
discriminatedUnion: [import_utils58.AST_NODE_TYPES.TSUnionType, import_utils58.AST_NODE_TYPES.TSTypeReference],
|
|
9056
|
+
intersection: [import_utils58.AST_NODE_TYPES.TSIntersectionType, import_utils58.AST_NODE_TYPES.TSTypeReference]
|
|
8825
9057
|
};
|
|
8826
9058
|
function normalizeSchemaName(name) {
|
|
8827
9059
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8830,20 +9062,20 @@ function normalizeTypeName(name) {
|
|
|
8830
9062
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8831
9063
|
}
|
|
8832
9064
|
function unwrapNullish(annotation) {
|
|
8833
|
-
if (annotation.type !==
|
|
9065
|
+
if (annotation.type !== import_utils58.AST_NODE_TYPES.TSUnionType) {
|
|
8834
9066
|
return {
|
|
8835
9067
|
core: annotation,
|
|
8836
|
-
nullable: annotation.type ===
|
|
9068
|
+
nullable: annotation.type === import_utils58.AST_NODE_TYPES.TSNullKeyword
|
|
8837
9069
|
};
|
|
8838
9070
|
}
|
|
8839
9071
|
const rest = [];
|
|
8840
9072
|
let nullable = false;
|
|
8841
9073
|
for (const member of annotation.types) {
|
|
8842
|
-
if (member.type ===
|
|
9074
|
+
if (member.type === import_utils58.AST_NODE_TYPES.TSNullKeyword) {
|
|
8843
9075
|
nullable = true;
|
|
8844
9076
|
continue;
|
|
8845
9077
|
}
|
|
8846
|
-
if (member.type ===
|
|
9078
|
+
if (member.type === import_utils58.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
8847
9079
|
continue;
|
|
8848
9080
|
}
|
|
8849
9081
|
rest.push(member);
|
|
@@ -8908,14 +9140,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8908
9140
|
function zodCallChain(node) {
|
|
8909
9141
|
const chain = [];
|
|
8910
9142
|
let current = node;
|
|
8911
|
-
while (current.type ===
|
|
9143
|
+
while (current.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
8912
9144
|
const callee = current.callee;
|
|
8913
|
-
if (callee.type !==
|
|
9145
|
+
if (callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8914
9146
|
return null;
|
|
8915
9147
|
}
|
|
8916
9148
|
chain.push(current);
|
|
8917
9149
|
const receiver = callee.object;
|
|
8918
|
-
if (receiver.type ===
|
|
9150
|
+
if (receiver.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8919
9151
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
8920
9152
|
}
|
|
8921
9153
|
current = receiver;
|
|
@@ -8924,19 +9156,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
8924
9156
|
}
|
|
8925
9157
|
function methodName(call) {
|
|
8926
9158
|
const callee = call.callee;
|
|
8927
|
-
return callee.type ===
|
|
9159
|
+
return callee.type === import_utils58.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils58.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
8928
9160
|
}
|
|
8929
9161
|
function schemaField(node) {
|
|
8930
9162
|
const modifiers = [];
|
|
8931
9163
|
let current = node;
|
|
8932
9164
|
let leaf = null;
|
|
8933
|
-
while (current.type ===
|
|
9165
|
+
while (current.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
8934
9166
|
const callee = current.callee;
|
|
8935
|
-
if (callee.type !==
|
|
9167
|
+
if (callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8936
9168
|
break;
|
|
8937
9169
|
}
|
|
8938
9170
|
const receiver = callee.object;
|
|
8939
|
-
if (receiver.type ===
|
|
9171
|
+
if (receiver.type === import_utils58.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
8940
9172
|
leaf = callee.property.name;
|
|
8941
9173
|
break;
|
|
8942
9174
|
}
|
|
@@ -8967,16 +9199,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8967
9199
|
return null;
|
|
8968
9200
|
}
|
|
8969
9201
|
const shape = base.arguments[0];
|
|
8970
|
-
if (shape === void 0 || shape.type !==
|
|
9202
|
+
if (shape === void 0 || shape.type !== import_utils58.AST_NODE_TYPES.ObjectExpression) {
|
|
8971
9203
|
return null;
|
|
8972
9204
|
}
|
|
8973
9205
|
const fields = /* @__PURE__ */ new Map();
|
|
8974
9206
|
for (const property of shape.properties) {
|
|
8975
|
-
if (property.type !==
|
|
9207
|
+
if (property.type !== import_utils58.AST_NODE_TYPES.Property || property.computed) {
|
|
8976
9208
|
return null;
|
|
8977
9209
|
}
|
|
8978
9210
|
const { key } = property;
|
|
8979
|
-
const name = key.type ===
|
|
9211
|
+
const name = key.type === import_utils58.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils58.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8980
9212
|
if (name === null) {
|
|
8981
9213
|
return null;
|
|
8982
9214
|
}
|
|
@@ -8987,11 +9219,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8987
9219
|
function typeMembers(members) {
|
|
8988
9220
|
const result = /* @__PURE__ */ new Map();
|
|
8989
9221
|
for (const member of members) {
|
|
8990
|
-
if (member.type !==
|
|
9222
|
+
if (member.type !== import_utils58.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
8991
9223
|
return null;
|
|
8992
9224
|
}
|
|
8993
9225
|
const { key } = member;
|
|
8994
|
-
const name = key.type ===
|
|
9226
|
+
const name = key.type === import_utils58.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils58.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8995
9227
|
if (name === null) {
|
|
8996
9228
|
return null;
|
|
8997
9229
|
}
|
|
@@ -9005,8 +9237,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9005
9237
|
return result.size === 0 ? null : result;
|
|
9006
9238
|
}
|
|
9007
9239
|
function collectConstrainedNames(node) {
|
|
9008
|
-
if (node.type ===
|
|
9009
|
-
if (node.typeName.type ===
|
|
9240
|
+
if (node.type === import_utils58.AST_NODE_TYPES.TSTypeReference) {
|
|
9241
|
+
if (node.typeName.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9010
9242
|
constrainedTypeNames.add(node.typeName.name);
|
|
9011
9243
|
}
|
|
9012
9244
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9014,11 +9246,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9014
9246
|
}
|
|
9015
9247
|
return;
|
|
9016
9248
|
}
|
|
9017
|
-
if (node.type ===
|
|
9249
|
+
if (node.type === import_utils58.AST_NODE_TYPES.TSArrayType) {
|
|
9018
9250
|
collectConstrainedNames(node.elementType);
|
|
9019
9251
|
return;
|
|
9020
9252
|
}
|
|
9021
|
-
if (node.type ===
|
|
9253
|
+
if (node.type === import_utils58.AST_NODE_TYPES.TSUnionType || node.type === import_utils58.AST_NODE_TYPES.TSIntersectionType) {
|
|
9022
9254
|
for (const member of node.types) {
|
|
9023
9255
|
collectConstrainedNames(member);
|
|
9024
9256
|
}
|
|
@@ -9062,13 +9294,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9062
9294
|
return;
|
|
9063
9295
|
}
|
|
9064
9296
|
for (const specifier of node.specifiers) {
|
|
9065
|
-
if (specifier.type ===
|
|
9297
|
+
if (specifier.type === import_utils58.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils58.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils58.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils58.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
9066
9298
|
zodNamespaces.add(specifier.local.name);
|
|
9067
9299
|
}
|
|
9068
9300
|
}
|
|
9069
9301
|
},
|
|
9070
9302
|
VariableDeclarator(node) {
|
|
9071
|
-
if (node.id.type !==
|
|
9303
|
+
if (node.id.type !== import_utils58.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
9072
9304
|
return;
|
|
9073
9305
|
}
|
|
9074
9306
|
const fields = schemaFields(node.init);
|
|
@@ -9078,14 +9310,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9078
9310
|
},
|
|
9079
9311
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9080
9312
|
"MemberExpression[computed=false]"(node) {
|
|
9081
|
-
if (node.object.type ===
|
|
9313
|
+
if (node.object.type === import_utils58.AST_NODE_TYPES.Identifier && node.property.type === import_utils58.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9082
9314
|
reshapedSchemaNames.add(node.object.name);
|
|
9083
9315
|
}
|
|
9084
9316
|
},
|
|
9085
9317
|
/** Records every type argument carried by a Zod constraint. */
|
|
9086
9318
|
TSTypeReference(node) {
|
|
9087
9319
|
const { typeName } = node;
|
|
9088
|
-
const referenced = typeName.type ===
|
|
9320
|
+
const referenced = typeName.type === import_utils58.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils58.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils58.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
9089
9321
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9090
9322
|
return;
|
|
9091
9323
|
}
|
|
@@ -9103,7 +9335,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9103
9335
|
}
|
|
9104
9336
|
},
|
|
9105
9337
|
TSTypeAliasDeclaration(node) {
|
|
9106
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9338
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils58.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9107
9339
|
return;
|
|
9108
9340
|
}
|
|
9109
9341
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9148,10 +9380,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9148
9380
|
});
|
|
9149
9381
|
|
|
9150
9382
|
// src/rules/require-assert-never.ts
|
|
9151
|
-
var
|
|
9383
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
9152
9384
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9153
|
-
if (statement.type ===
|
|
9154
|
-
if (statement.type ===
|
|
9385
|
+
if (statement.type === import_utils59.AST_NODE_TYPES.EmptyStatement) return false;
|
|
9386
|
+
if (statement.type === import_utils59.AST_NODE_TYPES.BlockStatement) {
|
|
9155
9387
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9156
9388
|
}
|
|
9157
9389
|
return true;
|
|
@@ -9167,7 +9399,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9167
9399
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9168
9400
|
}
|
|
9169
9401
|
const only = defaultCase.consequent[0];
|
|
9170
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9402
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils59.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
9171
9403
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9172
9404
|
}
|
|
9173
9405
|
return false;
|
|
@@ -9207,7 +9439,7 @@ var require_assert_never_default = createRule({
|
|
|
9207
9439
|
});
|
|
9208
9440
|
|
|
9209
9441
|
// src/rules/require-fetch-timeout.ts
|
|
9210
|
-
var
|
|
9442
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9211
9443
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9212
9444
|
"globalThis",
|
|
9213
9445
|
"window",
|
|
@@ -9223,14 +9455,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9223
9455
|
return false;
|
|
9224
9456
|
}
|
|
9225
9457
|
function initProvablyLacksSignal(init) {
|
|
9226
|
-
if (init.type !==
|
|
9458
|
+
if (init.type !== import_utils60.AST_NODE_TYPES.ObjectExpression) {
|
|
9227
9459
|
return false;
|
|
9228
9460
|
}
|
|
9229
9461
|
for (const prop of init.properties) {
|
|
9230
|
-
if (prop.type ===
|
|
9462
|
+
if (prop.type === import_utils60.AST_NODE_TYPES.SpreadElement) {
|
|
9231
9463
|
return false;
|
|
9232
9464
|
}
|
|
9233
|
-
if (prop.key.type ===
|
|
9465
|
+
if (prop.key.type === import_utils60.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils60.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
9234
9466
|
return false;
|
|
9235
9467
|
}
|
|
9236
9468
|
if (prop.computed) {
|
|
@@ -9240,7 +9472,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9240
9472
|
return true;
|
|
9241
9473
|
}
|
|
9242
9474
|
function isStringish(node) {
|
|
9243
|
-
return node.type ===
|
|
9475
|
+
return node.type === import_utils60.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils60.AST_NODE_TYPES.TemplateLiteral;
|
|
9244
9476
|
}
|
|
9245
9477
|
var require_fetch_timeout_default = createRule({
|
|
9246
9478
|
name: "require-fetch-timeout",
|
|
@@ -9277,14 +9509,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9277
9509
|
}
|
|
9278
9510
|
function resolvesToGlobal(identifier) {
|
|
9279
9511
|
const scope = context.sourceCode.getScope(identifier);
|
|
9280
|
-
const variable =
|
|
9512
|
+
const variable = import_utils60.ASTUtils.findVariable(scope, identifier.name);
|
|
9281
9513
|
return variable === null || variable.defs.length === 0;
|
|
9282
9514
|
}
|
|
9283
9515
|
function isGlobalFetchCall2(callee) {
|
|
9284
|
-
if (callee.type ===
|
|
9516
|
+
if (callee.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9285
9517
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9286
9518
|
}
|
|
9287
|
-
return callee.type ===
|
|
9519
|
+
return callee.type === import_utils60.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils60.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils60.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9288
9520
|
}
|
|
9289
9521
|
return {
|
|
9290
9522
|
CallExpression(node) {
|
|
@@ -9304,7 +9536,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9304
9536
|
});
|
|
9305
9537
|
|
|
9306
9538
|
// src/rules/require-interface-for-injected-service.ts
|
|
9307
|
-
var
|
|
9539
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9308
9540
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9309
9541
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9310
9542
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9312,20 +9544,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9312
9544
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9313
9545
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9314
9546
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9315
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9316
|
-
var qualifiedName = (name) => name.type ===
|
|
9547
|
+
var isExportedClass = (node) => node.parent.type === import_utils61.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils61.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
9548
|
+
var qualifiedName = (name) => name.type === import_utils61.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils61.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9317
9549
|
var readTypeReference = (annotation) => {
|
|
9318
|
-
if (annotation === void 0 || annotation.type !==
|
|
9550
|
+
if (annotation === void 0 || annotation.type !== import_utils61.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9319
9551
|
const { typeName } = annotation;
|
|
9320
|
-
const rightmost = typeName.type ===
|
|
9552
|
+
const rightmost = typeName.type === import_utils61.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils61.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
9321
9553
|
if (rightmost === null) return null;
|
|
9322
9554
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9323
9555
|
};
|
|
9324
9556
|
var namedParameterCollaborator = (annotated) => {
|
|
9325
9557
|
let target = annotated;
|
|
9326
|
-
if (target.type ===
|
|
9327
|
-
if (target.type ===
|
|
9328
|
-
if (target.type !==
|
|
9558
|
+
if (target.type === import_utils61.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
9559
|
+
if (target.type === import_utils61.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9560
|
+
if (target.type !== import_utils61.AST_NODE_TYPES.Identifier) return null;
|
|
9329
9561
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9330
9562
|
if (reference === null) return null;
|
|
9331
9563
|
return { name: target.name, ...reference };
|
|
@@ -9333,8 +9565,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9333
9565
|
var propertySignatureTypes = (members) => {
|
|
9334
9566
|
const types = /* @__PURE__ */ new Map();
|
|
9335
9567
|
for (const member of members) {
|
|
9336
|
-
if (member.type !==
|
|
9337
|
-
if (member.computed || member.key.type !==
|
|
9568
|
+
if (member.type !== import_utils61.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
9569
|
+
if (member.computed || member.key.type !== import_utils61.AST_NODE_TYPES.Identifier) continue;
|
|
9338
9570
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9339
9571
|
if (reference === null) continue;
|
|
9340
9572
|
types.set(member.key.name, reference);
|
|
@@ -9345,18 +9577,18 @@ var fileTypeIndex = (program) => {
|
|
|
9345
9577
|
const objects = /* @__PURE__ */ new Map();
|
|
9346
9578
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9347
9579
|
for (const statement of program.body) {
|
|
9348
|
-
const declaration = statement.type ===
|
|
9349
|
-
if (declaration?.type ===
|
|
9580
|
+
const declaration = statement.type === import_utils61.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9581
|
+
if (declaration?.type === import_utils61.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
9350
9582
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9351
9583
|
continue;
|
|
9352
9584
|
}
|
|
9353
|
-
if (declaration?.type !==
|
|
9585
|
+
if (declaration?.type !== import_utils61.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9354
9586
|
const aliased = declaration.typeAnnotation;
|
|
9355
|
-
if (aliased.type ===
|
|
9587
|
+
if (aliased.type === import_utils61.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils61.AST_NODE_TYPES.TSConstructorType) {
|
|
9356
9588
|
functionAliases.add(declaration.id.name);
|
|
9357
9589
|
continue;
|
|
9358
9590
|
}
|
|
9359
|
-
const literals = aliased.type ===
|
|
9591
|
+
const literals = aliased.type === import_utils61.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils61.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils61.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
9360
9592
|
if (literals.length === 0) continue;
|
|
9361
9593
|
const merged = /* @__PURE__ */ new Map();
|
|
9362
9594
|
for (const literal of literals) {
|
|
@@ -9369,10 +9601,10 @@ var fileTypeIndex = (program) => {
|
|
|
9369
9601
|
return { objects, functionAliases };
|
|
9370
9602
|
};
|
|
9371
9603
|
var bagMemberTypes = (annotation, declared) => {
|
|
9372
|
-
if (annotation.type ===
|
|
9604
|
+
if (annotation.type === import_utils61.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9373
9605
|
return propertySignatureTypes(annotation.members);
|
|
9374
9606
|
}
|
|
9375
|
-
if (annotation.type !==
|
|
9607
|
+
if (annotation.type !== import_utils61.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9376
9608
|
return null;
|
|
9377
9609
|
}
|
|
9378
9610
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9384,11 +9616,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9384
9616
|
if (members === null) return [];
|
|
9385
9617
|
const collaborators = [];
|
|
9386
9618
|
for (const property of pattern.properties) {
|
|
9387
|
-
if (property.type !==
|
|
9388
|
-
if (property.key.type !==
|
|
9619
|
+
if (property.type !== import_utils61.AST_NODE_TYPES.Property || property.computed) continue;
|
|
9620
|
+
if (property.key.type !== import_utils61.AST_NODE_TYPES.Identifier) continue;
|
|
9389
9621
|
const key = property.key.name;
|
|
9390
|
-
const bound = property.value.type ===
|
|
9391
|
-
if (bound.type !==
|
|
9622
|
+
const bound = property.value.type === import_utils61.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
9623
|
+
if (bound.type !== import_utils61.AST_NODE_TYPES.Identifier) continue;
|
|
9392
9624
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9393
9625
|
const reference = members.get(key);
|
|
9394
9626
|
if (reference === void 0) continue;
|
|
@@ -9398,8 +9630,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9398
9630
|
};
|
|
9399
9631
|
var parameterCollaborators = (parameter, declared) => {
|
|
9400
9632
|
let target = parameter;
|
|
9401
|
-
if (target.type ===
|
|
9402
|
-
if (target.type ===
|
|
9633
|
+
if (target.type === import_utils61.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9634
|
+
if (target.type === import_utils61.AST_NODE_TYPES.ObjectPattern) {
|
|
9403
9635
|
return objectPatternCollaborators(target, declared);
|
|
9404
9636
|
}
|
|
9405
9637
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9418,17 +9650,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9418
9650
|
let constructedFields = 0;
|
|
9419
9651
|
if (body2 !== null && body2 !== void 0) {
|
|
9420
9652
|
for (const statement of body2.body) {
|
|
9421
|
-
if (statement.type !==
|
|
9653
|
+
if (statement.type !== import_utils61.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9422
9654
|
const expression = statement.expression;
|
|
9423
|
-
if (expression.type !==
|
|
9655
|
+
if (expression.type !== import_utils61.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils61.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils61.AST_NODE_TYPES.ThisExpression) {
|
|
9424
9656
|
continue;
|
|
9425
9657
|
}
|
|
9426
9658
|
const source = expression.right;
|
|
9427
|
-
if (source.type ===
|
|
9659
|
+
if (source.type === import_utils61.AST_NODE_TYPES.NewExpression) {
|
|
9428
9660
|
constructedFields += 1;
|
|
9429
|
-
} else if (source.type ===
|
|
9661
|
+
} else if (source.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9430
9662
|
storedFrom.add(source.name);
|
|
9431
|
-
} else if (source.type ===
|
|
9663
|
+
} else if (source.type === import_utils61.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9432
9664
|
storedFrom.add(source.object.name);
|
|
9433
9665
|
}
|
|
9434
9666
|
}
|
|
@@ -9436,7 +9668,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9436
9668
|
const collaborators = [];
|
|
9437
9669
|
for (const parameter of ctor.value.params) {
|
|
9438
9670
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9439
|
-
const stored = parameter.type ===
|
|
9671
|
+
const stored = parameter.type === import_utils61.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9440
9672
|
if (!stored) continue;
|
|
9441
9673
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9442
9674
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9470,19 +9702,19 @@ var subtreeHas = (root, found) => {
|
|
|
9470
9702
|
return hit;
|
|
9471
9703
|
};
|
|
9472
9704
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9473
|
-
if (node.type ===
|
|
9705
|
+
if (node.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9474
9706
|
const { callee } = node;
|
|
9475
|
-
if (callee.type ===
|
|
9476
|
-
return callee.type ===
|
|
9707
|
+
if (callee.type === import_utils61.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9708
|
+
return callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9477
9709
|
}
|
|
9478
|
-
return node.type ===
|
|
9710
|
+
return node.type === import_utils61.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils61.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9479
9711
|
});
|
|
9480
9712
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9481
9713
|
var fileInterfaceNames = (program) => {
|
|
9482
9714
|
const names = [];
|
|
9483
9715
|
for (const statement of program.body) {
|
|
9484
|
-
const declaration = statement.type ===
|
|
9485
|
-
if (declaration?.type ===
|
|
9716
|
+
const declaration = statement.type === import_utils61.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9717
|
+
if (declaration?.type === import_utils61.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9486
9718
|
}
|
|
9487
9719
|
return names;
|
|
9488
9720
|
};
|
|
@@ -9500,11 +9732,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9500
9732
|
var publicMethodNames = (body2) => {
|
|
9501
9733
|
const names = [];
|
|
9502
9734
|
for (const member of body2.body) {
|
|
9503
|
-
if (member.type !==
|
|
9735
|
+
if (member.type !== import_utils61.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9504
9736
|
if (member.kind !== "method" || member.static) continue;
|
|
9505
9737
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9506
|
-
if (member.key.type ===
|
|
9507
|
-
if (member.key.type ===
|
|
9738
|
+
if (member.key.type === import_utils61.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
9739
|
+
if (member.key.type === import_utils61.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
9508
9740
|
else names.push("\u2026");
|
|
9509
9741
|
}
|
|
9510
9742
|
return names;
|
|
@@ -9537,7 +9769,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9537
9769
|
if (node.implements.length > 0) return;
|
|
9538
9770
|
if (node.decorators.length > 0) return;
|
|
9539
9771
|
const ctor = node.body.body.find(
|
|
9540
|
-
(member) => member.type ===
|
|
9772
|
+
(member) => member.type === import_utils61.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
9541
9773
|
);
|
|
9542
9774
|
if (ctor === void 0) return;
|
|
9543
9775
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9565,19 +9797,97 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9565
9797
|
}
|
|
9566
9798
|
});
|
|
9567
9799
|
|
|
9800
|
+
// src/rules/require-static-next-matcher.ts
|
|
9801
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
9802
|
+
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
9803
|
+
function unwrapExpression(node) {
|
|
9804
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSAsExpression || node.type === import_utils62.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils62.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils62.AST_NODE_TYPES.TSTypeAssertion) {
|
|
9805
|
+
return unwrapExpression(node.expression);
|
|
9806
|
+
}
|
|
9807
|
+
return node;
|
|
9808
|
+
}
|
|
9809
|
+
function isStaticValue(node) {
|
|
9810
|
+
const value = unwrapExpression(node);
|
|
9811
|
+
if (value.type === import_utils62.AST_NODE_TYPES.Literal) {
|
|
9812
|
+
return true;
|
|
9813
|
+
}
|
|
9814
|
+
if (value.type === import_utils62.AST_NODE_TYPES.TemplateLiteral) {
|
|
9815
|
+
return value.expressions.length === 0;
|
|
9816
|
+
}
|
|
9817
|
+
if (value.type === import_utils62.AST_NODE_TYPES.ArrayExpression) {
|
|
9818
|
+
return value.elements.every(
|
|
9819
|
+
(element) => element !== null && element.type !== import_utils62.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
9820
|
+
);
|
|
9821
|
+
}
|
|
9822
|
+
if (value.type === import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
9823
|
+
return value.properties.every(
|
|
9824
|
+
(property) => property.type === import_utils62.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils62.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
9825
|
+
);
|
|
9826
|
+
}
|
|
9827
|
+
return false;
|
|
9828
|
+
}
|
|
9829
|
+
function propertyName2(property) {
|
|
9830
|
+
if (property.computed) return null;
|
|
9831
|
+
if (property.key.type === import_utils62.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
9832
|
+
return typeof property.key.value === "string" ? property.key.value : null;
|
|
9833
|
+
}
|
|
9834
|
+
var require_static_next_matcher_default = createRule({
|
|
9835
|
+
name: "require-static-next-matcher",
|
|
9836
|
+
meta: {
|
|
9837
|
+
type: "problem",
|
|
9838
|
+
docs: {
|
|
9839
|
+
description: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals."
|
|
9840
|
+
},
|
|
9841
|
+
schema: [],
|
|
9842
|
+
messages: {
|
|
9843
|
+
dynamicMatcher: "Next.js matcher values must contain only literal arrays and objects. Calls, identifiers, concatenation, interpolated templates, and spreads are not statically analyzable and fail the production build."
|
|
9844
|
+
}
|
|
9845
|
+
},
|
|
9846
|
+
defaultOptions: [],
|
|
9847
|
+
create(context) {
|
|
9848
|
+
if (!NEXT_ENTRY_FILE.test(context.filename)) {
|
|
9849
|
+
return {};
|
|
9850
|
+
}
|
|
9851
|
+
return {
|
|
9852
|
+
ExportNamedDeclaration(node) {
|
|
9853
|
+
if (node.declaration?.type !== import_utils62.AST_NODE_TYPES.VariableDeclaration) {
|
|
9854
|
+
return;
|
|
9855
|
+
}
|
|
9856
|
+
for (const declaration of node.declaration.declarations) {
|
|
9857
|
+
if (declaration.id.type !== import_utils62.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
9858
|
+
continue;
|
|
9859
|
+
}
|
|
9860
|
+
const config = unwrapExpression(declaration.init);
|
|
9861
|
+
if (config.type !== import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
9862
|
+
continue;
|
|
9863
|
+
}
|
|
9864
|
+
for (const property of config.properties) {
|
|
9865
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || propertyName2(property) !== "matcher" || property.value.type === import_utils62.AST_NODE_TYPES.AssignmentPattern) {
|
|
9866
|
+
continue;
|
|
9867
|
+
}
|
|
9868
|
+
if (!isStaticValue(property.value)) {
|
|
9869
|
+
context.report({ node: property.value, messageId: "dynamicMatcher" });
|
|
9870
|
+
}
|
|
9871
|
+
}
|
|
9872
|
+
}
|
|
9873
|
+
}
|
|
9874
|
+
};
|
|
9875
|
+
}
|
|
9876
|
+
});
|
|
9877
|
+
|
|
9568
9878
|
// src/rules/require-zod-form-validation.ts
|
|
9569
|
-
var
|
|
9879
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
9570
9880
|
var looksLikeZodSchema = (node) => {
|
|
9571
9881
|
let current = node;
|
|
9572
9882
|
while (true) {
|
|
9573
|
-
if (current.type ===
|
|
9883
|
+
if (current.type === import_utils63.AST_NODE_TYPES.Identifier) {
|
|
9574
9884
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9575
9885
|
}
|
|
9576
|
-
if (current.type ===
|
|
9886
|
+
if (current.type === import_utils63.AST_NODE_TYPES.CallExpression) {
|
|
9577
9887
|
current = current.callee;
|
|
9578
9888
|
continue;
|
|
9579
9889
|
}
|
|
9580
|
-
if (current.type ===
|
|
9890
|
+
if (current.type === import_utils63.AST_NODE_TYPES.MemberExpression) {
|
|
9581
9891
|
current = current.object;
|
|
9582
9892
|
continue;
|
|
9583
9893
|
}
|
|
@@ -9585,23 +9895,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9585
9895
|
}
|
|
9586
9896
|
};
|
|
9587
9897
|
var isZodParseCall = (node) => {
|
|
9588
|
-
if (node.type !==
|
|
9898
|
+
if (node.type !== import_utils63.AST_NODE_TYPES.CallExpression) return false;
|
|
9589
9899
|
const callee = node.callee;
|
|
9590
|
-
if (callee.type !==
|
|
9900
|
+
if (callee.type !== import_utils63.AST_NODE_TYPES.MemberExpression) return false;
|
|
9591
9901
|
if (callee.computed) return false;
|
|
9592
|
-
if (callee.property.type !==
|
|
9902
|
+
if (callee.property.type !== import_utils63.AST_NODE_TYPES.Identifier) return false;
|
|
9593
9903
|
const method = callee.property.name;
|
|
9594
9904
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9595
9905
|
return looksLikeZodSchema(callee.object);
|
|
9596
9906
|
};
|
|
9597
9907
|
var isFormDataMethodCall = (node) => {
|
|
9598
9908
|
let current = node;
|
|
9599
|
-
if (current.type ===
|
|
9909
|
+
if (current.type === import_utils63.AST_NODE_TYPES.AwaitExpression) {
|
|
9600
9910
|
current = current.argument;
|
|
9601
9911
|
}
|
|
9602
|
-
if (current.type !==
|
|
9912
|
+
if (current.type !== import_utils63.AST_NODE_TYPES.CallExpression) return false;
|
|
9603
9913
|
const callee = current.callee;
|
|
9604
|
-
return callee.type ===
|
|
9914
|
+
return callee.type === import_utils63.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils63.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
9605
9915
|
};
|
|
9606
9916
|
var require_zod_form_validation_default = createRule({
|
|
9607
9917
|
name: "require-zod-form-validation",
|
|
@@ -9621,14 +9931,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9621
9931
|
return {};
|
|
9622
9932
|
}
|
|
9623
9933
|
const isFormSourceIdentifier = (node) => {
|
|
9624
|
-
if (node.type !==
|
|
9934
|
+
if (node.type !== import_utils63.AST_NODE_TYPES.Identifier) return false;
|
|
9625
9935
|
if (/formdata/i.test(node.name)) return true;
|
|
9626
9936
|
let scope = context.sourceCode.getScope(node);
|
|
9627
9937
|
while (scope !== null) {
|
|
9628
9938
|
const variable = scope.set.get(node.name);
|
|
9629
9939
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9630
9940
|
const def = variable.defs[0];
|
|
9631
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
9941
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils63.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
9632
9942
|
return isFormDataMethodCall(def.node.init);
|
|
9633
9943
|
}
|
|
9634
9944
|
return false;
|
|
@@ -9639,8 +9949,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9639
9949
|
};
|
|
9640
9950
|
const isFormDataGetCall = (node) => {
|
|
9641
9951
|
const callee = node.callee;
|
|
9642
|
-
if (callee.type !==
|
|
9643
|
-
if (callee.property.type !==
|
|
9952
|
+
if (callee.type !== import_utils63.AST_NODE_TYPES.MemberExpression) return false;
|
|
9953
|
+
if (callee.property.type !== import_utils63.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
9644
9954
|
return false;
|
|
9645
9955
|
}
|
|
9646
9956
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9655,11 +9965,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9655
9965
|
};
|
|
9656
9966
|
const isInstanceofNarrowing = (node) => {
|
|
9657
9967
|
const parent = node.parent;
|
|
9658
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9968
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils63.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils63.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9659
9969
|
};
|
|
9660
9970
|
const boundDeclarator = (node) => {
|
|
9661
9971
|
const parent = node.parent;
|
|
9662
|
-
if (parent.type ===
|
|
9972
|
+
if (parent.type === import_utils63.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils63.AST_NODE_TYPES.Identifier) {
|
|
9663
9973
|
return parent;
|
|
9664
9974
|
}
|
|
9665
9975
|
return null;
|
|
@@ -9687,7 +9997,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
9687
9997
|
});
|
|
9688
9998
|
|
|
9689
9999
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
9690
|
-
var
|
|
10000
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
9691
10001
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
9692
10002
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
9693
10003
|
var INSERT_GATE = /insert/i;
|
|
@@ -9718,7 +10028,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9718
10028
|
});
|
|
9719
10029
|
|
|
9720
10030
|
// src/rules/zod-naming-convention.ts
|
|
9721
|
-
var
|
|
10031
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
9722
10032
|
var CONVENTIONS = {
|
|
9723
10033
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9724
10034
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9743,15 +10053,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9743
10053
|
"registry",
|
|
9744
10054
|
"implement"
|
|
9745
10055
|
]);
|
|
9746
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10056
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils65.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
9747
10057
|
var calleeChainStartsWithZ = (node) => {
|
|
9748
10058
|
let current = node;
|
|
9749
|
-
while (current.type ===
|
|
10059
|
+
while (current.type === import_utils65.AST_NODE_TYPES.MemberExpression) {
|
|
9750
10060
|
const receiver = current.object;
|
|
9751
|
-
if (receiver.type ===
|
|
10061
|
+
if (receiver.type === import_utils65.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
9752
10062
|
return true;
|
|
9753
10063
|
}
|
|
9754
|
-
if (receiver.type ===
|
|
10064
|
+
if (receiver.type === import_utils65.AST_NODE_TYPES.CallExpression) {
|
|
9755
10065
|
current = receiver.callee;
|
|
9756
10066
|
continue;
|
|
9757
10067
|
}
|
|
@@ -9796,13 +10106,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9796
10106
|
VariableDeclarator(node) {
|
|
9797
10107
|
const init = node.init;
|
|
9798
10108
|
if (init === null || init === void 0) return;
|
|
9799
|
-
if (init.type !==
|
|
10109
|
+
if (init.type !== import_utils65.AST_NODE_TYPES.CallExpression) return;
|
|
9800
10110
|
const callee = init.callee;
|
|
9801
|
-
if (callee.type !==
|
|
10111
|
+
if (callee.type !== import_utils65.AST_NODE_TYPES.MemberExpression) return;
|
|
9802
10112
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9803
10113
|
const terminal = terminalMethodName(callee);
|
|
9804
10114
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9805
|
-
if (node.id.type !==
|
|
10115
|
+
if (node.id.type !== import_utils65.AST_NODE_TYPES.Identifier) return;
|
|
9806
10116
|
if (test.test(node.id.name)) return;
|
|
9807
10117
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9808
10118
|
context.report({
|
|
@@ -9882,6 +10192,7 @@ var rules = {
|
|
|
9882
10192
|
"no-enum": no_enum_default,
|
|
9883
10193
|
"no-fat-try-blocks": no_fat_try_blocks_default,
|
|
9884
10194
|
"no-hand-rolled-sleep": no_hand_rolled_sleep_default,
|
|
10195
|
+
"no-hand-rolled-spinner": no_hand_rolled_spinner_default,
|
|
9885
10196
|
"no-insecure-random-id": no_insecure_random_id_default,
|
|
9886
10197
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
9887
10198
|
"no-log-only-catch": no_log_only_catch_default,
|
|
@@ -9890,6 +10201,7 @@ var rules = {
|
|
|
9890
10201
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
9891
10202
|
"no-raw-env": no_raw_env_default,
|
|
9892
10203
|
"no-raw-fetch-outside-clients": no_raw_fetch_outside_clients_default,
|
|
10204
|
+
"no-restricted-library-load": no_restricted_library_load_default,
|
|
9893
10205
|
"no-repeated-string-literal": no_repeated_string_literal_default,
|
|
9894
10206
|
"no-restated-comment": no_restated_comment_default,
|
|
9895
10207
|
"no-restated-jsdoc": no_restated_jsdoc_default,
|
|
@@ -9914,6 +10226,7 @@ var rules = {
|
|
|
9914
10226
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
9915
10227
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
9916
10228
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
10229
|
+
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
9917
10230
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
9918
10231
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
9919
10232
|
"prefer-server-actions": prefer_server_actions_default,
|
|
@@ -9925,14 +10238,19 @@ var rules = {
|
|
|
9925
10238
|
"require-assert-never": require_assert_never_default,
|
|
9926
10239
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
9927
10240
|
"require-interface-for-injected-service": require_interface_for_injected_service_default,
|
|
10241
|
+
"require-static-next-matcher": require_static_next_matcher_default,
|
|
9928
10242
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
9929
10243
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
9930
10244
|
"zod-naming-convention": zod_naming_convention_default
|
|
9931
10245
|
};
|
|
9932
10246
|
var meta = {
|
|
9933
10247
|
name: "@sarj/eslint-plugin",
|
|
9934
|
-
version: "9.
|
|
10248
|
+
version: "9.9.0"
|
|
9935
10249
|
};
|
|
10250
|
+
var applicationOnlyRules = [
|
|
10251
|
+
"no-restricted-library-load",
|
|
10252
|
+
"prefer-native-random-uuid"
|
|
10253
|
+
];
|
|
9936
10254
|
var recommendedRules = {
|
|
9937
10255
|
"@sarj/enforce-file-structure": "warn",
|
|
9938
10256
|
"@sarj/no-async-callback-in-wait-for": "warn",
|
|
@@ -9943,6 +10261,7 @@ var recommendedRules = {
|
|
|
9943
10261
|
"@sarj/no-dynamic-sql": "warn",
|
|
9944
10262
|
"@sarj/no-fat-try-blocks": "warn",
|
|
9945
10263
|
"@sarj/no-hand-rolled-sleep": "warn",
|
|
10264
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
9946
10265
|
"@sarj/no-insecure-random-id": "warn",
|
|
9947
10266
|
"@sarj/no-json-stringify-error": "warn",
|
|
9948
10267
|
"@sarj/no-log-only-catch": "warn",
|
|
@@ -9983,6 +10302,7 @@ var recommendedRules = {
|
|
|
9983
10302
|
"@sarj/require-assert-never": "error",
|
|
9984
10303
|
"@sarj/require-fetch-timeout": "warn",
|
|
9985
10304
|
"@sarj/require-interface-for-injected-service": "warn",
|
|
10305
|
+
"@sarj/require-static-next-matcher": "error",
|
|
9986
10306
|
"@sarj/require-zod-form-validation": "error",
|
|
9987
10307
|
"@sarj/store-insert-requires-on-conflict": "warn",
|
|
9988
10308
|
"@sarj/zod-naming-convention": "warn"
|
|
@@ -9998,6 +10318,7 @@ var strictRules = {
|
|
|
9998
10318
|
"@sarj/no-enum": "error",
|
|
9999
10319
|
"@sarj/no-fat-try-blocks": "error",
|
|
10000
10320
|
"@sarj/no-hand-rolled-sleep": "error",
|
|
10321
|
+
"@sarj/no-hand-rolled-spinner": "error",
|
|
10001
10322
|
"@sarj/no-insecure-random-id": "error",
|
|
10002
10323
|
"@sarj/no-json-stringify-error": "error",
|
|
10003
10324
|
"@sarj/no-log-only-catch": "error",
|
|
@@ -10041,6 +10362,7 @@ var strictRules = {
|
|
|
10041
10362
|
"@sarj/require-assert-never": "error",
|
|
10042
10363
|
"@sarj/require-fetch-timeout": "error",
|
|
10043
10364
|
"@sarj/require-interface-for-injected-service": "error",
|
|
10365
|
+
"@sarj/require-static-next-matcher": "error",
|
|
10044
10366
|
"@sarj/require-zod-form-validation": "error",
|
|
10045
10367
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
10046
10368
|
"@sarj/zod-naming-convention": "error"
|
|
@@ -10069,6 +10391,7 @@ plugin.configs.strict = {
|
|
|
10069
10391
|
var index_default = plugin;
|
|
10070
10392
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10071
10393
|
0 && (module.exports = {
|
|
10394
|
+
applicationOnlyRules,
|
|
10072
10395
|
recommendedRules,
|
|
10073
10396
|
renamedRules,
|
|
10074
10397
|
retiredRules,
|