@sarj/eslint-plugin 9.7.1 → 9.8.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 +38 -2
- package/dist/index.cjs +691 -504
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +682 -496
- 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,
|
|
@@ -3503,17 +3504,110 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
3503
3504
|
}
|
|
3504
3505
|
});
|
|
3505
3506
|
|
|
3506
|
-
// src/rules/no-
|
|
3507
|
+
// src/rules/no-restricted-library-load.ts
|
|
3507
3508
|
var import_utils23 = require("@typescript-eslint/utils");
|
|
3509
|
+
function literalModule(node) {
|
|
3510
|
+
return node?.type === import_utils23.AST_NODE_TYPES.Literal && typeof node.value === "string" ? node.value : null;
|
|
3511
|
+
}
|
|
3512
|
+
function matchesModule(source, module2) {
|
|
3513
|
+
return source === module2 || source.startsWith(`${module2}/`);
|
|
3514
|
+
}
|
|
3515
|
+
var no_restricted_library_load_default = createRule({
|
|
3516
|
+
name: "no-restricted-library-load",
|
|
3517
|
+
meta: {
|
|
3518
|
+
type: "problem",
|
|
3519
|
+
docs: {
|
|
3520
|
+
description: "Apply a configured library-replacement policy to literal dynamic imports, CommonJS loads, and TypeScript import-equals declarations."
|
|
3521
|
+
},
|
|
3522
|
+
schema: [
|
|
3523
|
+
{
|
|
3524
|
+
type: "object",
|
|
3525
|
+
additionalProperties: false,
|
|
3526
|
+
required: ["libraries"],
|
|
3527
|
+
properties: {
|
|
3528
|
+
libraries: {
|
|
3529
|
+
type: "array",
|
|
3530
|
+
items: {
|
|
3531
|
+
type: "object",
|
|
3532
|
+
additionalProperties: false,
|
|
3533
|
+
required: ["id", "module", "replacement"],
|
|
3534
|
+
properties: {
|
|
3535
|
+
id: { type: "string", minLength: 1 },
|
|
3536
|
+
module: { type: "string", minLength: 1 },
|
|
3537
|
+
replacement: { type: "string", minLength: 1 },
|
|
3538
|
+
note: { type: "string", minLength: 1 }
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
],
|
|
3545
|
+
messages: {
|
|
3546
|
+
restrictedLibraryLoad: "{{id}}: Replace runtime loading of {{module}} with {{replacement}}.{{note}}"
|
|
3547
|
+
}
|
|
3548
|
+
},
|
|
3549
|
+
defaultOptions: [{ libraries: [] }],
|
|
3550
|
+
create(context, [options]) {
|
|
3551
|
+
const restrictions = options.libraries;
|
|
3552
|
+
function report(node, source) {
|
|
3553
|
+
const restriction = restrictions.find(
|
|
3554
|
+
(entry) => matchesModule(source, entry.module)
|
|
3555
|
+
);
|
|
3556
|
+
if (restriction === void 0) return;
|
|
3557
|
+
context.report({
|
|
3558
|
+
node,
|
|
3559
|
+
messageId: "restrictedLibraryLoad",
|
|
3560
|
+
data: {
|
|
3561
|
+
id: restriction.id,
|
|
3562
|
+
module: restriction.module,
|
|
3563
|
+
replacement: restriction.replacement,
|
|
3564
|
+
note: restriction.note === void 0 ? "" : ` ${restriction.note}`
|
|
3565
|
+
}
|
|
3566
|
+
});
|
|
3567
|
+
}
|
|
3568
|
+
function isUnshadowedRequire(node) {
|
|
3569
|
+
const variable = import_utils23.ASTUtils.findVariable(
|
|
3570
|
+
context.sourceCode.getScope(node),
|
|
3571
|
+
node.name
|
|
3572
|
+
);
|
|
3573
|
+
return variable === null || variable.defs.length === 0;
|
|
3574
|
+
}
|
|
3575
|
+
return {
|
|
3576
|
+
ImportExpression(node) {
|
|
3577
|
+
const source = literalModule(node.source);
|
|
3578
|
+
if (source !== null) report(node.source, source);
|
|
3579
|
+
},
|
|
3580
|
+
CallExpression(node) {
|
|
3581
|
+
let requireIdentifier = null;
|
|
3582
|
+
if (node.callee.type === import_utils23.AST_NODE_TYPES.Identifier && node.callee.name === "require") {
|
|
3583
|
+
requireIdentifier = node.callee;
|
|
3584
|
+
} else if (node.callee.type === import_utils23.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils23.AST_NODE_TYPES.Identifier && node.callee.object.name === "require" && node.callee.property.type === import_utils23.AST_NODE_TYPES.Identifier && node.callee.property.name === "resolve") {
|
|
3585
|
+
requireIdentifier = node.callee.object;
|
|
3586
|
+
}
|
|
3587
|
+
if (requireIdentifier === null || !isUnshadowedRequire(requireIdentifier)) return;
|
|
3588
|
+
const source = literalModule(node.arguments[0]);
|
|
3589
|
+
if (source !== null) report(node.arguments[0], source);
|
|
3590
|
+
},
|
|
3591
|
+
TSImportEqualsDeclaration(node) {
|
|
3592
|
+
if (node.moduleReference.type !== import_utils23.AST_NODE_TYPES.TSExternalModuleReference) return;
|
|
3593
|
+
const source = literalModule(node.moduleReference.expression);
|
|
3594
|
+
if (source !== null) report(node.moduleReference.expression, source);
|
|
3595
|
+
}
|
|
3596
|
+
};
|
|
3597
|
+
}
|
|
3598
|
+
});
|
|
3599
|
+
|
|
3600
|
+
// src/rules/no-repeated-string-literal.ts
|
|
3601
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
3508
3602
|
var MIN_LENGTH = 40;
|
|
3509
3603
|
var MIN_DISTINCT_SCOPES = 2;
|
|
3510
3604
|
var PREVIEW_LENGTH = 40;
|
|
3511
3605
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
3512
3606
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
3513
3607
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3608
|
+
import_utils24.AST_NODE_TYPES.FunctionDeclaration,
|
|
3609
|
+
import_utils24.AST_NODE_TYPES.FunctionExpression,
|
|
3610
|
+
import_utils24.AST_NODE_TYPES.ArrowFunctionExpression
|
|
3517
3611
|
]);
|
|
3518
3612
|
function isStructured(value) {
|
|
3519
3613
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -3535,8 +3629,8 @@ function isScaffolding(node) {
|
|
|
3535
3629
|
if (parent === void 0) {
|
|
3536
3630
|
return true;
|
|
3537
3631
|
}
|
|
3538
|
-
const isRequireSource = parent.type ===
|
|
3539
|
-
return parent.type ===
|
|
3632
|
+
const isRequireSource = parent.type === import_utils24.AST_NODE_TYPES.CallExpression && parent.callee.type === import_utils24.AST_NODE_TYPES.Identifier && parent.callee.name === "require";
|
|
3633
|
+
return parent.type === import_utils24.AST_NODE_TYPES.ImportDeclaration || parent.type === import_utils24.AST_NODE_TYPES.ImportExpression || parent.type === import_utils24.AST_NODE_TYPES.ExportNamedDeclaration || parent.type === import_utils24.AST_NODE_TYPES.ExportAllDeclaration || parent.type === import_utils24.AST_NODE_TYPES.TSImportType || parent.type === import_utils24.AST_NODE_TYPES.JSXAttribute || parent.type === import_utils24.AST_NODE_TYPES.TSLiteralType || isRequireSource;
|
|
3540
3634
|
}
|
|
3541
3635
|
var no_repeated_string_literal_default = createRule({
|
|
3542
3636
|
name: "no-repeated-string-literal",
|
|
@@ -3576,7 +3670,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3576
3670
|
}
|
|
3577
3671
|
},
|
|
3578
3672
|
TemplateLiteral(node) {
|
|
3579
|
-
if (node.parent.type ===
|
|
3673
|
+
if (node.parent.type === import_utils24.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
3580
3674
|
return;
|
|
3581
3675
|
}
|
|
3582
3676
|
const [only] = node.quasis;
|
|
@@ -3610,7 +3704,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3610
3704
|
});
|
|
3611
3705
|
|
|
3612
3706
|
// src/rules/no-restated-comment.ts
|
|
3613
|
-
var
|
|
3707
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
3614
3708
|
var MAX_WORDS = 8;
|
|
3615
3709
|
var MIN_CONTENT_TOKENS = 2;
|
|
3616
3710
|
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 +3757,7 @@ var no_restated_comment_default = createRule({
|
|
|
3663
3757
|
function labelsASiblingRun(comment) {
|
|
3664
3758
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3665
3759
|
if (token === null) return false;
|
|
3666
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
3760
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== import_utils25.AST_NODE_TYPES.Program; node = node.parent) {
|
|
3667
3761
|
if (headsSiblingRun(node)) return true;
|
|
3668
3762
|
}
|
|
3669
3763
|
return false;
|
|
@@ -3723,7 +3817,7 @@ var no_restated_comment_default = createRule({
|
|
|
3723
3817
|
});
|
|
3724
3818
|
|
|
3725
3819
|
// src/rules/no-restated-jsdoc.ts
|
|
3726
|
-
var
|
|
3820
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
3727
3821
|
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
3728
3822
|
"arg",
|
|
3729
3823
|
"argument",
|
|
@@ -3777,30 +3871,30 @@ function declarationNames(node) {
|
|
|
3777
3871
|
switch (node.type) {
|
|
3778
3872
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
3779
3873
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
3780
|
-
case
|
|
3781
|
-
case
|
|
3874
|
+
case import_utils26.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3875
|
+
case import_utils26.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3782
3876
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
3783
|
-
case
|
|
3784
|
-
case
|
|
3877
|
+
case import_utils26.AST_NODE_TYPES.FunctionDeclaration:
|
|
3878
|
+
case import_utils26.AST_NODE_TYPES.TSDeclareFunction:
|
|
3785
3879
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
3786
|
-
case
|
|
3787
|
-
case
|
|
3788
|
-
case
|
|
3789
|
-
case
|
|
3880
|
+
case import_utils26.AST_NODE_TYPES.ClassDeclaration:
|
|
3881
|
+
case import_utils26.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3882
|
+
case import_utils26.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3883
|
+
case import_utils26.AST_NODE_TYPES.TSEnumDeclaration:
|
|
3790
3884
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
3791
|
-
case
|
|
3885
|
+
case import_utils26.AST_NODE_TYPES.VariableDeclaration: {
|
|
3792
3886
|
const declarator = node.declarations[0];
|
|
3793
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
3887
|
+
if (declarator === void 0 || declarator.id.type !== import_utils26.AST_NODE_TYPES.Identifier) return null;
|
|
3794
3888
|
const init = declarator.init;
|
|
3795
|
-
const params = init != null && (init.type ===
|
|
3889
|
+
const params = init != null && (init.type === import_utils26.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils26.AST_NODE_TYPES.FunctionExpression) ? paramNames(init.params) : [];
|
|
3796
3890
|
return { name: declarator.id.name, params };
|
|
3797
3891
|
}
|
|
3798
|
-
case
|
|
3799
|
-
case
|
|
3800
|
-
case
|
|
3801
|
-
case
|
|
3802
|
-
if (node.key.type !==
|
|
3803
|
-
const params = node.type ===
|
|
3892
|
+
case import_utils26.AST_NODE_TYPES.MethodDefinition:
|
|
3893
|
+
case import_utils26.AST_NODE_TYPES.PropertyDefinition:
|
|
3894
|
+
case import_utils26.AST_NODE_TYPES.TSMethodSignature:
|
|
3895
|
+
case import_utils26.AST_NODE_TYPES.TSPropertySignature: {
|
|
3896
|
+
if (node.key.type !== import_utils26.AST_NODE_TYPES.Identifier) return null;
|
|
3897
|
+
const params = node.type === import_utils26.AST_NODE_TYPES.MethodDefinition ? paramNames(node.value.params) : node.type === import_utils26.AST_NODE_TYPES.TSMethodSignature ? paramNames(node.params) : [];
|
|
3804
3898
|
return { name: node.key.name, params };
|
|
3805
3899
|
}
|
|
3806
3900
|
default:
|
|
@@ -3810,9 +3904,9 @@ function declarationNames(node) {
|
|
|
3810
3904
|
function paramNames(params) {
|
|
3811
3905
|
const names = [];
|
|
3812
3906
|
for (const param of params) {
|
|
3813
|
-
const target = param.type ===
|
|
3814
|
-
if (target.type ===
|
|
3815
|
-
else if (target.type ===
|
|
3907
|
+
const target = param.type === import_utils26.AST_NODE_TYPES.AssignmentPattern ? param.left : param;
|
|
3908
|
+
if (target.type === import_utils26.AST_NODE_TYPES.Identifier) names.push(target.name);
|
|
3909
|
+
else if (target.type === import_utils26.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
3816
3910
|
}
|
|
3817
3911
|
return names;
|
|
3818
3912
|
}
|
|
@@ -3854,7 +3948,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3854
3948
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
3855
3949
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3856
3950
|
let declaration = null;
|
|
3857
|
-
while (node != null && node.type !==
|
|
3951
|
+
while (node != null && node.type !== import_utils26.AST_NODE_TYPES.Program) {
|
|
3858
3952
|
declaration = declarationNames(node);
|
|
3859
3953
|
if (declaration !== null) break;
|
|
3860
3954
|
node = node.parent ?? null;
|
|
@@ -3909,7 +4003,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3909
4003
|
});
|
|
3910
4004
|
|
|
3911
4005
|
// src/rules/no-secret-in-log.ts
|
|
3912
|
-
var
|
|
4006
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
3913
4007
|
|
|
3914
4008
|
// src/rules/_secret-names.ts
|
|
3915
4009
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -4246,7 +4340,7 @@ var no_secret_in_log_default = createRule({
|
|
|
4246
4340
|
});
|
|
4247
4341
|
|
|
4248
4342
|
// src/rules/no-select-star.ts
|
|
4249
|
-
var
|
|
4343
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
4250
4344
|
var QUERY_SHAPE = /\bSELECT\b[\s\S]*?\bFROM\b/i;
|
|
4251
4345
|
var SELECT_KEYWORD = /\bSELECT\b/gi;
|
|
4252
4346
|
var FROM_KEYWORD = /^FROM\b/i;
|
|
@@ -4313,12 +4407,12 @@ var no_select_star_default = createRule({
|
|
|
4313
4407
|
});
|
|
4314
4408
|
|
|
4315
4409
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
4316
|
-
var
|
|
4410
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
4317
4411
|
function sentinelKind(arg) {
|
|
4318
4412
|
if (arg === null) {
|
|
4319
4413
|
return null;
|
|
4320
4414
|
}
|
|
4321
|
-
if (arg.type ===
|
|
4415
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.Literal) {
|
|
4322
4416
|
if (arg.value === null) {
|
|
4323
4417
|
return "nullish";
|
|
4324
4418
|
}
|
|
@@ -4330,13 +4424,13 @@ function sentinelKind(arg) {
|
|
|
4330
4424
|
}
|
|
4331
4425
|
return null;
|
|
4332
4426
|
}
|
|
4333
|
-
if (arg.type ===
|
|
4427
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4334
4428
|
return "nullish";
|
|
4335
4429
|
}
|
|
4336
|
-
if (arg.type ===
|
|
4430
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.ArrayExpression) {
|
|
4337
4431
|
return "array";
|
|
4338
4432
|
}
|
|
4339
|
-
if (arg.type ===
|
|
4433
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.ObjectExpression) {
|
|
4340
4434
|
return "object";
|
|
4341
4435
|
}
|
|
4342
4436
|
return null;
|
|
@@ -4345,25 +4439,25 @@ function isSentinelArgument(arg) {
|
|
|
4345
4439
|
if (arg === null) {
|
|
4346
4440
|
return false;
|
|
4347
4441
|
}
|
|
4348
|
-
if (arg.type ===
|
|
4442
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.Literal && arg.value === null) {
|
|
4349
4443
|
return true;
|
|
4350
4444
|
}
|
|
4351
|
-
if (arg.type ===
|
|
4445
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.Literal && arg.value === false) {
|
|
4352
4446
|
return true;
|
|
4353
4447
|
}
|
|
4354
|
-
if (arg.type ===
|
|
4448
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4355
4449
|
return true;
|
|
4356
4450
|
}
|
|
4357
|
-
if (arg.type ===
|
|
4451
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.ArrayExpression && arg.elements.length === 0) {
|
|
4358
4452
|
return true;
|
|
4359
4453
|
}
|
|
4360
|
-
if (arg.type ===
|
|
4454
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.ObjectExpression && arg.properties.length === 0) {
|
|
4361
4455
|
return true;
|
|
4362
4456
|
}
|
|
4363
4457
|
return false;
|
|
4364
4458
|
}
|
|
4365
4459
|
function isFunctionNode(node) {
|
|
4366
|
-
return node.type ===
|
|
4460
|
+
return node.type === import_utils29.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils29.AST_NODE_TYPES.FunctionExpression || node.type === import_utils29.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
4367
4461
|
}
|
|
4368
4462
|
function isNode3(value) {
|
|
4369
4463
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -4403,24 +4497,24 @@ function walkWithinScope(node, visit) {
|
|
|
4403
4497
|
function containsThrow(node) {
|
|
4404
4498
|
return walkWithinScope(
|
|
4405
4499
|
node,
|
|
4406
|
-
(current) => current.type ===
|
|
4500
|
+
(current) => current.type === import_utils29.AST_NODE_TYPES.ThrowStatement
|
|
4407
4501
|
);
|
|
4408
4502
|
}
|
|
4409
4503
|
function bindsName(param, name) {
|
|
4410
4504
|
switch (param.type) {
|
|
4411
|
-
case
|
|
4505
|
+
case import_utils29.AST_NODE_TYPES.Identifier:
|
|
4412
4506
|
return param.name === name;
|
|
4413
|
-
case
|
|
4507
|
+
case import_utils29.AST_NODE_TYPES.AssignmentPattern:
|
|
4414
4508
|
return bindsName(param.left, name);
|
|
4415
|
-
case
|
|
4509
|
+
case import_utils29.AST_NODE_TYPES.RestElement:
|
|
4416
4510
|
return bindsName(param.argument, name);
|
|
4417
|
-
case
|
|
4511
|
+
case import_utils29.AST_NODE_TYPES.ArrayPattern:
|
|
4418
4512
|
return param.elements.some(
|
|
4419
4513
|
(element) => element !== null && bindsName(element, name)
|
|
4420
4514
|
);
|
|
4421
|
-
case
|
|
4515
|
+
case import_utils29.AST_NODE_TYPES.ObjectPattern:
|
|
4422
4516
|
return param.properties.some(
|
|
4423
|
-
(property) => property.type ===
|
|
4517
|
+
(property) => property.type === import_utils29.AST_NODE_TYPES.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
4424
4518
|
);
|
|
4425
4519
|
default:
|
|
4426
4520
|
return false;
|
|
@@ -4435,7 +4529,7 @@ function subtreeReadsName(node, name) {
|
|
|
4435
4529
|
if (found) {
|
|
4436
4530
|
return;
|
|
4437
4531
|
}
|
|
4438
|
-
if (current.type ===
|
|
4532
|
+
if (current.type === import_utils29.AST_NODE_TYPES.Identifier && current.name === name) {
|
|
4439
4533
|
found = true;
|
|
4440
4534
|
return;
|
|
4441
4535
|
}
|
|
@@ -4446,10 +4540,10 @@ function subtreeReadsName(node, name) {
|
|
|
4446
4540
|
if (key === "parent") {
|
|
4447
4541
|
continue;
|
|
4448
4542
|
}
|
|
4449
|
-
if (key === "key" && current.type ===
|
|
4543
|
+
if (key === "key" && current.type === import_utils29.AST_NODE_TYPES.Property && !current.computed) {
|
|
4450
4544
|
continue;
|
|
4451
4545
|
}
|
|
4452
|
-
if (key === "property" && current.type ===
|
|
4546
|
+
if (key === "property" && current.type === import_utils29.AST_NODE_TYPES.MemberExpression && !current.computed) {
|
|
4453
4547
|
continue;
|
|
4454
4548
|
}
|
|
4455
4549
|
const value = current[key];
|
|
@@ -4482,10 +4576,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4482
4576
|
"URLPattern"
|
|
4483
4577
|
]);
|
|
4484
4578
|
function isParseShapedNode(node) {
|
|
4485
|
-
if (node.type ===
|
|
4579
|
+
if (node.type === import_utils29.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils29.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils29.AST_NODE_TYPES.Identifier) {
|
|
4486
4580
|
return node.callee.property.name === "parse";
|
|
4487
4581
|
}
|
|
4488
|
-
if (node.type ===
|
|
4582
|
+
if (node.type === import_utils29.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils29.AST_NODE_TYPES.Identifier) {
|
|
4489
4583
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
4490
4584
|
}
|
|
4491
4585
|
return false;
|
|
@@ -4496,10 +4590,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
4496
4590
|
"arrayBuffer"
|
|
4497
4591
|
]);
|
|
4498
4592
|
function isBodyDecodeNode(node) {
|
|
4499
|
-
return node.type ===
|
|
4593
|
+
return node.type === import_utils29.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils29.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils29.AST_NODE_TYPES.Identifier && BODY_DECODE_METHODS.has(node.callee.property.name);
|
|
4500
4594
|
}
|
|
4501
4595
|
function returnsMatching(stmt, predicate) {
|
|
4502
|
-
return stmt.type ===
|
|
4596
|
+
return stmt.type === import_utils29.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
4503
4597
|
}
|
|
4504
4598
|
function enclosingReturnTypeNode(node) {
|
|
4505
4599
|
let current = node.parent;
|
|
@@ -4517,11 +4611,11 @@ function enclosingFunctionName(node) {
|
|
|
4517
4611
|
let current = node.parent;
|
|
4518
4612
|
while (current !== void 0 && current !== null) {
|
|
4519
4613
|
if (isFunctionNode(current)) {
|
|
4520
|
-
if ("id" in current && isNode3(current.id) && current.id.type ===
|
|
4614
|
+
if ("id" in current && isNode3(current.id) && current.id.type === import_utils29.AST_NODE_TYPES.Identifier) {
|
|
4521
4615
|
return current.id.name;
|
|
4522
4616
|
}
|
|
4523
4617
|
const parent = current.parent;
|
|
4524
|
-
if (parent?.type ===
|
|
4618
|
+
if (parent?.type === import_utils29.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils29.AST_NODE_TYPES.Identifier) {
|
|
4525
4619
|
return parent.id.name;
|
|
4526
4620
|
}
|
|
4527
4621
|
return null;
|
|
@@ -4542,10 +4636,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
4542
4636
|
return false;
|
|
4543
4637
|
}
|
|
4544
4638
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
4545
|
-
if (declared?.type ===
|
|
4639
|
+
if (declared?.type === import_utils29.AST_NODE_TYPES.TSTypeReference && declared.typeName.type === import_utils29.AST_NODE_TYPES.Identifier && declared.typeName.name === "Promise") {
|
|
4546
4640
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
4547
4641
|
}
|
|
4548
|
-
return declared?.type ===
|
|
4642
|
+
return declared?.type === import_utils29.AST_NODE_TYPES.TSBooleanKeyword;
|
|
4549
4643
|
}
|
|
4550
4644
|
function tryReturnsSafeParse(catchNode) {
|
|
4551
4645
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -4561,7 +4655,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
4561
4655
|
function enclosingFunctionBody(node) {
|
|
4562
4656
|
let current = node.parent;
|
|
4563
4657
|
while (current !== void 0 && current !== null) {
|
|
4564
|
-
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type ===
|
|
4658
|
+
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === import_utils29.AST_NODE_TYPES.BlockStatement) {
|
|
4565
4659
|
return current.body;
|
|
4566
4660
|
}
|
|
4567
4661
|
current = current.parent;
|
|
@@ -4574,7 +4668,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
4574
4668
|
return false;
|
|
4575
4669
|
}
|
|
4576
4670
|
return walkWithinScope(functionBody, (current) => {
|
|
4577
|
-
if (current.type !==
|
|
4671
|
+
if (current.type !== import_utils29.AST_NODE_TYPES.ReturnStatement) {
|
|
4578
4672
|
return false;
|
|
4579
4673
|
}
|
|
4580
4674
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -4593,13 +4687,13 @@ function returnedSentinelKinds(arg) {
|
|
|
4593
4687
|
kinds.add(direct);
|
|
4594
4688
|
return kinds;
|
|
4595
4689
|
}
|
|
4596
|
-
if (arg.type ===
|
|
4690
|
+
if (arg.type === import_utils29.AST_NODE_TYPES.ConditionalExpression) {
|
|
4597
4691
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
4598
4692
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
4599
4693
|
kinds.add(nested);
|
|
4600
4694
|
}
|
|
4601
4695
|
}
|
|
4602
|
-
} else if (arg.type ===
|
|
4696
|
+
} else if (arg.type === import_utils29.AST_NODE_TYPES.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
4603
4697
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
4604
4698
|
kinds.add(nested);
|
|
4605
4699
|
}
|
|
@@ -4642,7 +4736,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4642
4736
|
const matcher = createLogMatcher(loggingOptions);
|
|
4643
4737
|
function logsOrReportsError(catchBody, caughtName) {
|
|
4644
4738
|
return walkWithinScope(catchBody, (current) => {
|
|
4645
|
-
if (current.type !==
|
|
4739
|
+
if (current.type !== import_utils29.AST_NODE_TYPES.CallExpression) {
|
|
4646
4740
|
return false;
|
|
4647
4741
|
}
|
|
4648
4742
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -4659,7 +4753,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4659
4753
|
return;
|
|
4660
4754
|
}
|
|
4661
4755
|
const last = body2[body2.length - 1];
|
|
4662
|
-
if (last === void 0 || last.type !==
|
|
4756
|
+
if (last === void 0 || last.type !== import_utils29.AST_NODE_TYPES.ReturnStatement) {
|
|
4663
4757
|
return;
|
|
4664
4758
|
}
|
|
4665
4759
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -4668,7 +4762,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4668
4762
|
if (containsThrow(node.body)) {
|
|
4669
4763
|
return;
|
|
4670
4764
|
}
|
|
4671
|
-
const caughtName = node.param?.type ===
|
|
4765
|
+
const caughtName = node.param?.type === import_utils29.AST_NODE_TYPES.Identifier ? node.param.name : null;
|
|
4672
4766
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
4673
4767
|
return;
|
|
4674
4768
|
}
|
|
@@ -4695,9 +4789,9 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4695
4789
|
});
|
|
4696
4790
|
|
|
4697
4791
|
// src/rules/no-silent-promise-catch.ts
|
|
4698
|
-
var
|
|
4792
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
4699
4793
|
function isBodyParseCall(node) {
|
|
4700
|
-
return node.type ===
|
|
4794
|
+
return node.type === import_utils30.AST_NODE_TYPES.CallExpression && node.arguments.length === 0 && node.callee.type === import_utils30.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils30.AST_NODE_TYPES.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
4701
4795
|
}
|
|
4702
4796
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
4703
4797
|
"cancel",
|
|
@@ -4712,21 +4806,21 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
4712
4806
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
4713
4807
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
4714
4808
|
function isTeardownCall(node) {
|
|
4715
|
-
return node.type ===
|
|
4809
|
+
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 && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
4716
4810
|
}
|
|
4717
4811
|
function isSilentExpression(node) {
|
|
4718
4812
|
switch (node.type) {
|
|
4719
|
-
case
|
|
4813
|
+
case import_utils30.AST_NODE_TYPES.Literal:
|
|
4720
4814
|
return !("regex" in node);
|
|
4721
|
-
case
|
|
4815
|
+
case import_utils30.AST_NODE_TYPES.Identifier:
|
|
4722
4816
|
return node.name === "undefined";
|
|
4723
|
-
case
|
|
4724
|
-
return node.operator === "void" && node.argument.type ===
|
|
4725
|
-
case
|
|
4817
|
+
case import_utils30.AST_NODE_TYPES.UnaryExpression:
|
|
4818
|
+
return node.operator === "void" && node.argument.type === import_utils30.AST_NODE_TYPES.Literal;
|
|
4819
|
+
case import_utils30.AST_NODE_TYPES.ObjectExpression:
|
|
4726
4820
|
return node.properties.length === 0;
|
|
4727
|
-
case
|
|
4821
|
+
case import_utils30.AST_NODE_TYPES.ArrayExpression:
|
|
4728
4822
|
return node.elements.length === 0;
|
|
4729
|
-
case
|
|
4823
|
+
case import_utils30.AST_NODE_TYPES.TSAsExpression:
|
|
4730
4824
|
return isSilentExpression(node.expression);
|
|
4731
4825
|
default:
|
|
4732
4826
|
return false;
|
|
@@ -4734,7 +4828,7 @@ function isSilentExpression(node) {
|
|
|
4734
4828
|
}
|
|
4735
4829
|
function isSilentHandler(handler) {
|
|
4736
4830
|
const body2 = handler.body;
|
|
4737
|
-
if (body2.type !==
|
|
4831
|
+
if (body2.type !== import_utils30.AST_NODE_TYPES.BlockStatement) {
|
|
4738
4832
|
return isSilentExpression(body2);
|
|
4739
4833
|
}
|
|
4740
4834
|
if (body2.body.length === 0) {
|
|
@@ -4742,7 +4836,7 @@ function isSilentHandler(handler) {
|
|
|
4742
4836
|
}
|
|
4743
4837
|
if (body2.body.length === 1) {
|
|
4744
4838
|
const only = body2.body[0];
|
|
4745
|
-
if (only !== void 0 && only.type ===
|
|
4839
|
+
if (only !== void 0 && only.type === import_utils30.AST_NODE_TYPES.ReturnStatement) {
|
|
4746
4840
|
return only.argument === null || isSilentExpression(only.argument);
|
|
4747
4841
|
}
|
|
4748
4842
|
}
|
|
@@ -4771,7 +4865,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4771
4865
|
return true;
|
|
4772
4866
|
}
|
|
4773
4867
|
let statement = call;
|
|
4774
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
4868
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== import_utils30.AST_NODE_TYPES.VariableDeclaration) {
|
|
4775
4869
|
statement = statement.parent;
|
|
4776
4870
|
}
|
|
4777
4871
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -4783,7 +4877,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4783
4877
|
};
|
|
4784
4878
|
return {
|
|
4785
4879
|
CallExpression(node) {
|
|
4786
|
-
if (node.callee.type !==
|
|
4880
|
+
if (node.callee.type !== import_utils30.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.property.type !== import_utils30.AST_NODE_TYPES.Identifier || node.callee.property.name !== "catch") {
|
|
4787
4881
|
return;
|
|
4788
4882
|
}
|
|
4789
4883
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -4792,14 +4886,14 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4792
4886
|
if (isTeardownCall(node.callee.object)) {
|
|
4793
4887
|
return;
|
|
4794
4888
|
}
|
|
4795
|
-
if (node.parent.type ===
|
|
4889
|
+
if (node.parent.type === import_utils30.AST_NODE_TYPES.MemberExpression && node.parent.object === node) {
|
|
4796
4890
|
return;
|
|
4797
4891
|
}
|
|
4798
4892
|
if (node.arguments.length !== 1) {
|
|
4799
4893
|
return;
|
|
4800
4894
|
}
|
|
4801
4895
|
const handler = node.arguments[0];
|
|
4802
|
-
if (handler === void 0 || handler.type !==
|
|
4896
|
+
if (handler === void 0 || handler.type !== import_utils30.AST_NODE_TYPES.ArrowFunctionExpression && handler.type !== import_utils30.AST_NODE_TYPES.FunctionExpression) {
|
|
4803
4897
|
return;
|
|
4804
4898
|
}
|
|
4805
4899
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -4814,7 +4908,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4814
4908
|
});
|
|
4815
4909
|
|
|
4816
4910
|
// src/rules/no-sleep-in-test-body.ts
|
|
4817
|
-
var
|
|
4911
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
4818
4912
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
4819
4913
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
4820
4914
|
"it",
|
|
@@ -4823,34 +4917,34 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
|
4823
4917
|
"afterEach"
|
|
4824
4918
|
]);
|
|
4825
4919
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4920
|
+
import_utils31.AST_NODE_TYPES.FunctionDeclaration,
|
|
4921
|
+
import_utils31.AST_NODE_TYPES.FunctionExpression,
|
|
4922
|
+
import_utils31.AST_NODE_TYPES.ArrowFunctionExpression
|
|
4829
4923
|
]);
|
|
4830
4924
|
function isNonzeroNumericLiteral(node) {
|
|
4831
|
-
return node?.type ===
|
|
4925
|
+
return node?.type === import_utils31.AST_NODE_TYPES.Literal && typeof node.value === "number" && node.value !== 0;
|
|
4832
4926
|
}
|
|
4833
4927
|
function isTimedSetTimeout(node) {
|
|
4834
|
-
return node.type ===
|
|
4928
|
+
return node.type === import_utils31.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils31.AST_NODE_TYPES.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
4835
4929
|
}
|
|
4836
4930
|
function isPromiseSleep(node) {
|
|
4837
|
-
if (node.callee.type !==
|
|
4931
|
+
if (node.callee.type !== import_utils31.AST_NODE_TYPES.Identifier || node.callee.name !== "Promise") {
|
|
4838
4932
|
return false;
|
|
4839
4933
|
}
|
|
4840
4934
|
const executor = node.arguments[0];
|
|
4841
|
-
if (executor?.type !==
|
|
4935
|
+
if (executor?.type !== import_utils31.AST_NODE_TYPES.ArrowFunctionExpression && executor?.type !== import_utils31.AST_NODE_TYPES.FunctionExpression) {
|
|
4842
4936
|
return false;
|
|
4843
4937
|
}
|
|
4844
4938
|
const body2 = executor.body;
|
|
4845
|
-
if (body2.type !==
|
|
4939
|
+
if (body2.type !== import_utils31.AST_NODE_TYPES.BlockStatement) {
|
|
4846
4940
|
return isTimedSetTimeout(body2);
|
|
4847
4941
|
}
|
|
4848
4942
|
return body2.body.some(
|
|
4849
|
-
(stmt) => stmt.type ===
|
|
4943
|
+
(stmt) => stmt.type === import_utils31.AST_NODE_TYPES.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
4850
4944
|
);
|
|
4851
4945
|
}
|
|
4852
4946
|
function isHelperSleep(node) {
|
|
4853
|
-
return node.callee.type ===
|
|
4947
|
+
return node.callee.type === import_utils31.AST_NODE_TYPES.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
4854
4948
|
}
|
|
4855
4949
|
function nearestEnclosingFunction2(node) {
|
|
4856
4950
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -4858,7 +4952,7 @@ function nearestEnclosingFunction2(node) {
|
|
|
4858
4952
|
continue;
|
|
4859
4953
|
}
|
|
4860
4954
|
const grandparent = current.parent;
|
|
4861
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
4955
|
+
const isPromiseExecutor = grandparent?.type === import_utils31.AST_NODE_TYPES.NewExpression && isPromiseSleep(grandparent);
|
|
4862
4956
|
if (!isPromiseExecutor) {
|
|
4863
4957
|
return current;
|
|
4864
4958
|
}
|
|
@@ -4866,23 +4960,23 @@ function nearestEnclosingFunction2(node) {
|
|
|
4866
4960
|
return null;
|
|
4867
4961
|
}
|
|
4868
4962
|
function testCallerName2(callee) {
|
|
4869
|
-
if (callee.type ===
|
|
4963
|
+
if (callee.type === import_utils31.AST_NODE_TYPES.Identifier) {
|
|
4870
4964
|
return callee.name;
|
|
4871
4965
|
}
|
|
4872
|
-
if (callee.type ===
|
|
4966
|
+
if (callee.type === import_utils31.AST_NODE_TYPES.MemberExpression) {
|
|
4873
4967
|
return testCallerName2(callee.object);
|
|
4874
4968
|
}
|
|
4875
|
-
if (callee.type ===
|
|
4969
|
+
if (callee.type === import_utils31.AST_NODE_TYPES.CallExpression) {
|
|
4876
4970
|
return testCallerName2(callee.callee);
|
|
4877
4971
|
}
|
|
4878
|
-
if (callee.type ===
|
|
4972
|
+
if (callee.type === import_utils31.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
4879
4973
|
return testCallerName2(callee.tag);
|
|
4880
4974
|
}
|
|
4881
4975
|
return null;
|
|
4882
4976
|
}
|
|
4883
4977
|
function isTestBody2(fn) {
|
|
4884
4978
|
const call = fn.parent;
|
|
4885
|
-
if (call?.type !==
|
|
4979
|
+
if (call?.type !== import_utils31.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
4886
4980
|
return false;
|
|
4887
4981
|
}
|
|
4888
4982
|
const name = testCallerName2(call.callee);
|
|
@@ -4928,7 +5022,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
4928
5022
|
});
|
|
4929
5023
|
|
|
4930
5024
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
4931
|
-
var
|
|
5025
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
4932
5026
|
var DEFAULT_METHODS2 = [
|
|
4933
5027
|
"prepare",
|
|
4934
5028
|
"put",
|
|
@@ -4947,7 +5041,7 @@ function compile2(patterns) {
|
|
|
4947
5041
|
}
|
|
4948
5042
|
function storageMethodName(node, methods) {
|
|
4949
5043
|
const callee = node.callee;
|
|
4950
|
-
if (callee.type !==
|
|
5044
|
+
if (callee.type !== import_utils32.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils32.AST_NODE_TYPES.Identifier) {
|
|
4951
5045
|
return null;
|
|
4952
5046
|
}
|
|
4953
5047
|
const name = callee.property.name;
|
|
@@ -5015,7 +5109,7 @@ var no_storage_in_stateless_modules_default = createRule({
|
|
|
5015
5109
|
});
|
|
5016
5110
|
|
|
5017
5111
|
// src/rules/no-string-concat-in-loop.ts
|
|
5018
|
-
var
|
|
5112
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
5019
5113
|
var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
5020
5114
|
"ForStatement",
|
|
5021
5115
|
"ForOfStatement",
|
|
@@ -5161,7 +5255,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
5161
5255
|
});
|
|
5162
5256
|
|
|
5163
5257
|
// src/rules/no-tautological-expect.ts
|
|
5164
|
-
var
|
|
5258
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
5165
5259
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
5166
5260
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
5167
5261
|
"toBeDefined",
|
|
@@ -5175,17 +5269,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
5175
5269
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
5176
5270
|
function isLiteral(node) {
|
|
5177
5271
|
switch (node.type) {
|
|
5178
|
-
case
|
|
5272
|
+
case import_utils34.AST_NODE_TYPES.Literal:
|
|
5179
5273
|
return true;
|
|
5180
|
-
case
|
|
5274
|
+
case import_utils34.AST_NODE_TYPES.TemplateLiteral:
|
|
5181
5275
|
return node.expressions.length === 0;
|
|
5182
|
-
case
|
|
5276
|
+
case import_utils34.AST_NODE_TYPES.UnaryExpression:
|
|
5183
5277
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
5184
|
-
case
|
|
5278
|
+
case import_utils34.AST_NODE_TYPES.ArrayExpression:
|
|
5185
5279
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
5186
|
-
case
|
|
5280
|
+
case import_utils34.AST_NODE_TYPES.ObjectExpression:
|
|
5187
5281
|
return node.properties.every(
|
|
5188
|
-
(property) => property.type ===
|
|
5282
|
+
(property) => property.type === import_utils34.AST_NODE_TYPES.Property && !property.computed && isLiteral(property.value)
|
|
5189
5283
|
);
|
|
5190
5284
|
default:
|
|
5191
5285
|
return false;
|
|
@@ -5193,7 +5287,7 @@ function isLiteral(node) {
|
|
|
5193
5287
|
}
|
|
5194
5288
|
function expectOperand(callee) {
|
|
5195
5289
|
const receiver = callee.object;
|
|
5196
|
-
if (receiver.type !==
|
|
5290
|
+
if (receiver.type !== import_utils34.AST_NODE_TYPES.CallExpression || receiver.callee.type !== import_utils34.AST_NODE_TYPES.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
5197
5291
|
return null;
|
|
5198
5292
|
}
|
|
5199
5293
|
return receiver.arguments[0] ?? null;
|
|
@@ -5223,10 +5317,10 @@ var no_tautological_expect_default = createRule({
|
|
|
5223
5317
|
return {
|
|
5224
5318
|
CallExpression(node) {
|
|
5225
5319
|
const callee = node.callee;
|
|
5226
|
-
if (callee.type !==
|
|
5320
|
+
if (callee.type !== import_utils34.AST_NODE_TYPES.MemberExpression || callee.computed) {
|
|
5227
5321
|
return;
|
|
5228
5322
|
}
|
|
5229
|
-
if (callee.property.type !==
|
|
5323
|
+
if (callee.property.type !== import_utils34.AST_NODE_TYPES.Identifier) {
|
|
5230
5324
|
return;
|
|
5231
5325
|
}
|
|
5232
5326
|
const matcher = callee.property.name;
|
|
@@ -5285,7 +5379,7 @@ var no_typed_doc_sections_default = createRule({
|
|
|
5285
5379
|
});
|
|
5286
5380
|
|
|
5287
5381
|
// src/rules/no-trailing-value-narration.ts
|
|
5288
|
-
var
|
|
5382
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
5289
5383
|
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
5290
5384
|
var WORD_RE3 = /[A-Za-z]+(?:'[a-z]+)?|\d+(?:\.\d+)?/g;
|
|
5291
5385
|
var UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -5420,10 +5514,10 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5420
5514
|
});
|
|
5421
5515
|
|
|
5422
5516
|
// src/rules/no-declaration-comment-wall.ts
|
|
5423
|
-
var
|
|
5517
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5424
5518
|
|
|
5425
5519
|
// src/rules/_comment-wall.ts
|
|
5426
|
-
var
|
|
5520
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5427
5521
|
var WALL_DEFAULTS = {
|
|
5428
5522
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5429
5523
|
minCommentedMembers: 3,
|
|
@@ -5527,10 +5621,10 @@ function isWall(members, commented, restated, options) {
|
|
|
5527
5621
|
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5528
5622
|
}
|
|
5529
5623
|
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5624
|
+
import_utils36.AST_NODE_TYPES.FunctionExpression,
|
|
5625
|
+
import_utils36.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
5626
|
+
import_utils36.AST_NODE_TYPES.ObjectExpression,
|
|
5627
|
+
import_utils36.AST_NODE_TYPES.ArrayExpression
|
|
5534
5628
|
]);
|
|
5535
5629
|
function declarationRange(member) {
|
|
5536
5630
|
const body2 = bodyOf(member);
|
|
@@ -5538,10 +5632,10 @@ function declarationRange(member) {
|
|
|
5538
5632
|
return [member.range[0], body2.range[0]];
|
|
5539
5633
|
}
|
|
5540
5634
|
function bodyOf(member) {
|
|
5541
|
-
if (member.type ===
|
|
5635
|
+
if (member.type === import_utils36.AST_NODE_TYPES.MethodDefinition || member.type === import_utils36.AST_NODE_TYPES.TSAbstractMethodDefinition) {
|
|
5542
5636
|
return member.value.body ?? void 0;
|
|
5543
5637
|
}
|
|
5544
|
-
if (member.type ===
|
|
5638
|
+
if (member.type === import_utils36.AST_NODE_TYPES.Property || member.type === import_utils36.AST_NODE_TYPES.PropertyDefinition) {
|
|
5545
5639
|
const value = member.value;
|
|
5546
5640
|
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5547
5641
|
}
|
|
@@ -5551,12 +5645,12 @@ function bodyOf(member) {
|
|
|
5551
5645
|
// src/rules/no-declaration-comment-wall.ts
|
|
5552
5646
|
function named(node) {
|
|
5553
5647
|
switch (node.type) {
|
|
5554
|
-
case
|
|
5648
|
+
case import_utils37.AST_NODE_TYPES.TSEnumMember:
|
|
5555
5649
|
return { node, key: node.id };
|
|
5556
|
-
case
|
|
5557
|
-
case
|
|
5558
|
-
case
|
|
5559
|
-
case
|
|
5650
|
+
case import_utils37.AST_NODE_TYPES.PropertyDefinition:
|
|
5651
|
+
case import_utils37.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
|
5652
|
+
case import_utils37.AST_NODE_TYPES.MethodDefinition:
|
|
5653
|
+
case import_utils37.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
|
5560
5654
|
return node.computed ? void 0 : { node, key: node.key };
|
|
5561
5655
|
default:
|
|
5562
5656
|
return void 0;
|
|
@@ -5656,7 +5750,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5656
5750
|
});
|
|
5657
5751
|
|
|
5658
5752
|
// src/rules/no-union-in-comment.ts
|
|
5659
|
-
var
|
|
5753
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5660
5754
|
var MAX_LITERAL_LENGTH = 28;
|
|
5661
5755
|
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5662
5756
|
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
@@ -5675,14 +5769,14 @@ var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
5675
5769
|
function isBareString(node) {
|
|
5676
5770
|
if (node === void 0) return false;
|
|
5677
5771
|
switch (node.type) {
|
|
5678
|
-
case
|
|
5772
|
+
case import_utils38.AST_NODE_TYPES.TSStringKeyword:
|
|
5679
5773
|
return true;
|
|
5680
5774
|
// `string[]` holds members of the same closed set, one element at a time.
|
|
5681
|
-
case
|
|
5775
|
+
case import_utils38.AST_NODE_TYPES.TSArrayType:
|
|
5682
5776
|
return isBareString(node.elementType);
|
|
5683
5777
|
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5684
5778
|
// — the checker collapses that one to `string`.
|
|
5685
|
-
case
|
|
5779
|
+
case import_utils38.AST_NODE_TYPES.TSUnionType:
|
|
5686
5780
|
return node.types.some((member) => isBareString(member));
|
|
5687
5781
|
default:
|
|
5688
5782
|
return false;
|
|
@@ -5692,13 +5786,13 @@ function rootCallee(node) {
|
|
|
5692
5786
|
let current = node;
|
|
5693
5787
|
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5694
5788
|
switch (current.type) {
|
|
5695
|
-
case
|
|
5789
|
+
case import_utils38.AST_NODE_TYPES.CallExpression:
|
|
5696
5790
|
current = current.callee;
|
|
5697
5791
|
break;
|
|
5698
|
-
case
|
|
5792
|
+
case import_utils38.AST_NODE_TYPES.MemberExpression:
|
|
5699
5793
|
current = current.object;
|
|
5700
5794
|
break;
|
|
5701
|
-
case
|
|
5795
|
+
case import_utils38.AST_NODE_TYPES.Identifier:
|
|
5702
5796
|
return current.name;
|
|
5703
5797
|
default:
|
|
5704
5798
|
return null;
|
|
@@ -5707,26 +5801,26 @@ function rootCallee(node) {
|
|
|
5707
5801
|
return null;
|
|
5708
5802
|
}
|
|
5709
5803
|
function nameOf(key) {
|
|
5710
|
-
if (key.type ===
|
|
5711
|
-
if (key.type ===
|
|
5804
|
+
if (key.type === import_utils38.AST_NODE_TYPES.Identifier) return key.name;
|
|
5805
|
+
if (key.type === import_utils38.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
5712
5806
|
return null;
|
|
5713
5807
|
}
|
|
5714
5808
|
function targetOf(node) {
|
|
5715
5809
|
switch (node.type) {
|
|
5716
|
-
case
|
|
5717
|
-
case
|
|
5810
|
+
case import_utils38.AST_NODE_TYPES.TSPropertySignature:
|
|
5811
|
+
case import_utils38.AST_NODE_TYPES.PropertyDefinition: {
|
|
5718
5812
|
const name = node.computed ? null : nameOf(node.key);
|
|
5719
5813
|
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5720
5814
|
return { node, name };
|
|
5721
5815
|
}
|
|
5722
|
-
case
|
|
5816
|
+
case import_utils38.AST_NODE_TYPES.Property: {
|
|
5723
5817
|
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5724
5818
|
const callee = rootCallee(node.value);
|
|
5725
5819
|
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5726
5820
|
return { node, name };
|
|
5727
5821
|
}
|
|
5728
|
-
case
|
|
5729
|
-
if (node.id.type !==
|
|
5822
|
+
case import_utils38.AST_NODE_TYPES.VariableDeclarator: {
|
|
5823
|
+
if (node.id.type !== import_utils38.AST_NODE_TYPES.Identifier) return null;
|
|
5730
5824
|
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5731
5825
|
return { node, name: node.id.name };
|
|
5732
5826
|
}
|
|
@@ -5775,7 +5869,7 @@ var no_union_in_comment_default = createRule({
|
|
|
5775
5869
|
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5776
5870
|
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5777
5871
|
}
|
|
5778
|
-
for (let node = anchor; node != null && node.type !==
|
|
5872
|
+
for (let node = anchor; node != null && node.type !== import_utils38.AST_NODE_TYPES.Program; node = node.parent) {
|
|
5779
5873
|
const target = targetOf(node);
|
|
5780
5874
|
if (target !== null) return target;
|
|
5781
5875
|
}
|
|
@@ -5804,9 +5898,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5804
5898
|
});
|
|
5805
5899
|
|
|
5806
5900
|
// src/rules/no-type-member-comment-wall.ts
|
|
5807
|
-
var
|
|
5901
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
5808
5902
|
function isNamedMember(node) {
|
|
5809
|
-
return (node.type ===
|
|
5903
|
+
return (node.type === import_utils39.AST_NODE_TYPES.TSPropertySignature || node.type === import_utils39.AST_NODE_TYPES.TSMethodSignature) && !node.computed;
|
|
5810
5904
|
}
|
|
5811
5905
|
var no_type_member_comment_wall_default = createRule({
|
|
5812
5906
|
name: "no-type-member-comment-wall",
|
|
@@ -5853,7 +5947,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5853
5947
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5854
5948
|
}
|
|
5855
5949
|
function check(node) {
|
|
5856
|
-
const members = node.type ===
|
|
5950
|
+
const members = node.type === import_utils39.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
|
5857
5951
|
const named2 = members.filter(isNamedMember);
|
|
5858
5952
|
if (named2.length === 0) return;
|
|
5859
5953
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5893,7 +5987,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5893
5987
|
});
|
|
5894
5988
|
|
|
5895
5989
|
// src/rules/no-unnecessary-use-client.ts
|
|
5896
|
-
var
|
|
5990
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
5897
5991
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5898
5992
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5899
5993
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -5919,13 +6013,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
5919
6013
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
5920
6014
|
var jsxRootName = (name) => {
|
|
5921
6015
|
let current = name;
|
|
5922
|
-
while (current.type ===
|
|
6016
|
+
while (current.type === import_utils40.AST_NODE_TYPES.JSXMemberExpression) {
|
|
5923
6017
|
current = current.object;
|
|
5924
6018
|
}
|
|
5925
|
-
return current.type ===
|
|
6019
|
+
return current.type === import_utils40.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
5926
6020
|
};
|
|
5927
6021
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
5928
|
-
if (node.type ===
|
|
6022
|
+
if (node.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5929
6023
|
return imported.has(node.name);
|
|
5930
6024
|
}
|
|
5931
6025
|
for (const key of Object.keys(node)) {
|
|
@@ -5940,16 +6034,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
5940
6034
|
return false;
|
|
5941
6035
|
};
|
|
5942
6036
|
var isUseClientDirective = (node) => {
|
|
5943
|
-
return node.type ===
|
|
6037
|
+
return node.type === import_utils40.AST_NODE_TYPES.ExpressionStatement && node.expression.type === import_utils40.AST_NODE_TYPES.Literal && node.expression.value === "use client";
|
|
5944
6038
|
};
|
|
5945
6039
|
var isGlobalReference = (node, context) => {
|
|
5946
6040
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
5947
6041
|
const parent = node.parent;
|
|
5948
6042
|
if (parent !== void 0) {
|
|
5949
|
-
if (parent.type ===
|
|
6043
|
+
if (parent.type === import_utils40.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
5950
6044
|
return false;
|
|
5951
6045
|
}
|
|
5952
|
-
if (parent.type ===
|
|
6046
|
+
if (parent.type === import_utils40.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
5953
6047
|
return false;
|
|
5954
6048
|
}
|
|
5955
6049
|
if (parent.type.startsWith("TS")) {
|
|
@@ -5989,13 +6083,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5989
6083
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
5990
6084
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
5991
6085
|
const markIfHookOrContext = (callee) => {
|
|
5992
|
-
if (callee.type ===
|
|
6086
|
+
if (callee.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5993
6087
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
5994
6088
|
hasClientIndicator = true;
|
|
5995
6089
|
}
|
|
5996
6090
|
return;
|
|
5997
6091
|
}
|
|
5998
|
-
if (callee.type ===
|
|
6092
|
+
if (callee.type === import_utils40.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5999
6093
|
const name = callee.property.name;
|
|
6000
6094
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
6001
6095
|
hasClientIndicator = true;
|
|
@@ -6005,7 +6099,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6005
6099
|
return {
|
|
6006
6100
|
Program(node) {
|
|
6007
6101
|
for (const stmt of node.body) {
|
|
6008
|
-
if (stmt.type !==
|
|
6102
|
+
if (stmt.type !== import_utils40.AST_NODE_TYPES.ExpressionStatement) break;
|
|
6009
6103
|
if (isUseClientDirective(stmt)) {
|
|
6010
6104
|
directiveNode = stmt;
|
|
6011
6105
|
break;
|
|
@@ -6018,7 +6112,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6018
6112
|
},
|
|
6019
6113
|
JSXAttribute(node) {
|
|
6020
6114
|
if (directiveNode === null) return;
|
|
6021
|
-
if (node.name.type ===
|
|
6115
|
+
if (node.name.type === import_utils40.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
6022
6116
|
hasClientIndicator = true;
|
|
6023
6117
|
}
|
|
6024
6118
|
},
|
|
@@ -6085,18 +6179,18 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
6085
6179
|
});
|
|
6086
6180
|
|
|
6087
6181
|
// src/rules/no-unsafe-mock-casting.ts
|
|
6088
|
-
var import_utils40 = require("@typescript-eslint/utils");
|
|
6089
6182
|
var import_utils41 = require("@typescript-eslint/utils");
|
|
6183
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
6090
6184
|
function isMockTypeReference(node) {
|
|
6091
|
-
if (node.type !==
|
|
6185
|
+
if (node.type !== import_utils42.AST_NODE_TYPES.TSTypeReference) {
|
|
6092
6186
|
return false;
|
|
6093
6187
|
}
|
|
6094
6188
|
const typeName = node.typeName;
|
|
6095
|
-
if (typeName.type ===
|
|
6189
|
+
if (typeName.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
6096
6190
|
const name = typeName.name;
|
|
6097
6191
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
6098
6192
|
}
|
|
6099
|
-
if (typeName.type ===
|
|
6193
|
+
if (typeName.type === import_utils42.AST_NODE_TYPES.TSQualifiedName) {
|
|
6100
6194
|
const rightName = typeName.right.name;
|
|
6101
6195
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
6102
6196
|
}
|
|
@@ -6132,7 +6226,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
6132
6226
|
});
|
|
6133
6227
|
|
|
6134
6228
|
// src/rules/no-zod-native-enum.ts
|
|
6135
|
-
var
|
|
6229
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
6136
6230
|
var ts = __toESM(require("typescript"), 1);
|
|
6137
6231
|
var IGNORE_PATTERNS = [
|
|
6138
6232
|
/[\\/]generated[\\/]/,
|
|
@@ -6150,7 +6244,7 @@ function isZodModule(source) {
|
|
|
6150
6244
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
6151
6245
|
}
|
|
6152
6246
|
function unwrap2(node) {
|
|
6153
|
-
if (node.type ===
|
|
6247
|
+
if (node.type === import_utils43.AST_NODE_TYPES.TSAsExpression || node.type === import_utils43.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6154
6248
|
return unwrap2(node.expression);
|
|
6155
6249
|
}
|
|
6156
6250
|
return node;
|
|
@@ -6158,14 +6252,14 @@ function unwrap2(node) {
|
|
|
6158
6252
|
function stringValueTexts(node, sourceCode) {
|
|
6159
6253
|
const texts = [];
|
|
6160
6254
|
for (const prop of node.properties) {
|
|
6161
|
-
if (prop.type !==
|
|
6255
|
+
if (prop.type !== import_utils43.AST_NODE_TYPES.Property) {
|
|
6162
6256
|
return null;
|
|
6163
6257
|
}
|
|
6164
6258
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6165
6259
|
return null;
|
|
6166
6260
|
}
|
|
6167
6261
|
const value = prop.value;
|
|
6168
|
-
if (value.type !==
|
|
6262
|
+
if (value.type !== import_utils43.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
6169
6263
|
return null;
|
|
6170
6264
|
}
|
|
6171
6265
|
const text = sourceCode.getText(value);
|
|
@@ -6181,7 +6275,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6181
6275
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6182
6276
|
if (variable !== void 0) {
|
|
6183
6277
|
return variable.defs.some(
|
|
6184
|
-
(def) => def.node.type ===
|
|
6278
|
+
(def) => def.node.type === import_utils43.AST_NODE_TYPES.TSEnumDeclaration
|
|
6185
6279
|
);
|
|
6186
6280
|
}
|
|
6187
6281
|
current = current.upper;
|
|
@@ -6226,32 +6320,32 @@ var no_zod_native_enum_default = createRule({
|
|
|
6226
6320
|
}
|
|
6227
6321
|
let services;
|
|
6228
6322
|
try {
|
|
6229
|
-
services =
|
|
6323
|
+
services = import_utils43.ESLintUtils.getParserServices(context);
|
|
6230
6324
|
} catch {
|
|
6231
6325
|
services = null;
|
|
6232
6326
|
}
|
|
6233
6327
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6234
6328
|
function isZodMemberCall(node, api) {
|
|
6235
6329
|
const callee = node.callee;
|
|
6236
|
-
if (callee.type ===
|
|
6330
|
+
if (callee.type === import_utils43.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6237
6331
|
return callee.property.name === api;
|
|
6238
6332
|
}
|
|
6239
|
-
if (callee.type ===
|
|
6333
|
+
if (callee.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6240
6334
|
return zodImportedNames.get(callee.name) === api;
|
|
6241
6335
|
}
|
|
6242
6336
|
return false;
|
|
6243
6337
|
}
|
|
6244
6338
|
function buildFix(node) {
|
|
6245
6339
|
const callee = node.callee;
|
|
6246
|
-
if (callee.type !==
|
|
6340
|
+
if (callee.type !== import_utils43.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6247
6341
|
return null;
|
|
6248
6342
|
}
|
|
6249
6343
|
const arg = node.arguments[0];
|
|
6250
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6344
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === import_utils43.AST_NODE_TYPES.SpreadElement) {
|
|
6251
6345
|
return null;
|
|
6252
6346
|
}
|
|
6253
6347
|
const inner = unwrap2(arg);
|
|
6254
|
-
if (inner.type !==
|
|
6348
|
+
if (inner.type !== import_utils43.AST_NODE_TYPES.ObjectExpression) {
|
|
6255
6349
|
return null;
|
|
6256
6350
|
}
|
|
6257
6351
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6271,7 +6365,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6271
6365
|
return;
|
|
6272
6366
|
}
|
|
6273
6367
|
for (const spec of node.specifiers) {
|
|
6274
|
-
if (spec.type ===
|
|
6368
|
+
if (spec.type === import_utils43.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6275
6369
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6276
6370
|
}
|
|
6277
6371
|
}
|
|
@@ -6290,7 +6384,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6290
6384
|
return;
|
|
6291
6385
|
}
|
|
6292
6386
|
const arg = node.arguments[0];
|
|
6293
|
-
if (arg === void 0 || arg.type !==
|
|
6387
|
+
if (arg === void 0 || arg.type !== import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6294
6388
|
return;
|
|
6295
6389
|
}
|
|
6296
6390
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6307,7 +6401,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6307
6401
|
});
|
|
6308
6402
|
|
|
6309
6403
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6310
|
-
var
|
|
6404
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
6311
6405
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6312
6406
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6313
6407
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6320,36 +6414,36 @@ function isConstantReference(identifier) {
|
|
|
6320
6414
|
}
|
|
6321
6415
|
function isExcludedOperand(node) {
|
|
6322
6416
|
switch (node.type) {
|
|
6323
|
-
case
|
|
6417
|
+
case import_utils44.AST_NODE_TYPES.Literal:
|
|
6324
6418
|
return true;
|
|
6325
|
-
case
|
|
6419
|
+
case import_utils44.AST_NODE_TYPES.TemplateLiteral:
|
|
6326
6420
|
return node.expressions.length === 0;
|
|
6327
|
-
case
|
|
6421
|
+
case import_utils44.AST_NODE_TYPES.Identifier:
|
|
6328
6422
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6329
|
-
case
|
|
6330
|
-
return !node.computed && node.property.type ===
|
|
6423
|
+
case import_utils44.AST_NODE_TYPES.MemberExpression:
|
|
6424
|
+
return !node.computed && node.property.type === import_utils44.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6331
6425
|
default:
|
|
6332
6426
|
return false;
|
|
6333
6427
|
}
|
|
6334
6428
|
}
|
|
6335
6429
|
function operandName(node) {
|
|
6336
|
-
if (node.type ===
|
|
6430
|
+
if (node.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6337
6431
|
return node.name;
|
|
6338
6432
|
}
|
|
6339
|
-
if (node.type ===
|
|
6433
|
+
if (node.type === import_utils44.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6340
6434
|
return node.property.name;
|
|
6341
6435
|
}
|
|
6342
6436
|
return null;
|
|
6343
6437
|
}
|
|
6344
6438
|
function isSecretOperand(node) {
|
|
6345
|
-
if (node.type ===
|
|
6439
|
+
if (node.type === import_utils44.AST_NODE_TYPES.TemplateLiteral) {
|
|
6346
6440
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6347
6441
|
}
|
|
6348
6442
|
const name = operandName(node);
|
|
6349
6443
|
return name !== null && isAuthSecretName(name);
|
|
6350
6444
|
}
|
|
6351
6445
|
function secretNameOf(node) {
|
|
6352
|
-
if (node.type ===
|
|
6446
|
+
if (node.type === import_utils44.AST_NODE_TYPES.TemplateLiteral) {
|
|
6353
6447
|
for (const expression of node.expressions) {
|
|
6354
6448
|
const nested = secretNameOf(expression);
|
|
6355
6449
|
if (nested !== null) {
|
|
@@ -6401,8 +6495,8 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
6401
6495
|
});
|
|
6402
6496
|
|
|
6403
6497
|
// src/rules/prefer-discriminated-union.ts
|
|
6404
|
-
var import_utils44 = require("@typescript-eslint/utils");
|
|
6405
6498
|
var import_utils45 = require("@typescript-eslint/utils");
|
|
6499
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
6406
6500
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
6407
6501
|
"success",
|
|
6408
6502
|
"ok",
|
|
@@ -6412,27 +6506,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6412
6506
|
]);
|
|
6413
6507
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
6414
6508
|
function getMemberName(member) {
|
|
6415
|
-
if (member.type !==
|
|
6509
|
+
if (member.type !== import_utils46.AST_NODE_TYPES.TSPropertySignature) {
|
|
6416
6510
|
return null;
|
|
6417
6511
|
}
|
|
6418
6512
|
const { key } = member;
|
|
6419
|
-
if (key.type ===
|
|
6513
|
+
if (key.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6420
6514
|
return key.name;
|
|
6421
6515
|
}
|
|
6422
|
-
if (key.type ===
|
|
6516
|
+
if (key.type === import_utils46.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
6423
6517
|
return key.value;
|
|
6424
6518
|
}
|
|
6425
6519
|
return null;
|
|
6426
6520
|
}
|
|
6427
6521
|
function isBooleanTyped(member) {
|
|
6428
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6522
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils46.AST_NODE_TYPES.TSBooleanKeyword;
|
|
6429
6523
|
}
|
|
6430
6524
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
6431
6525
|
let hasStatusBoolean = false;
|
|
6432
6526
|
let optionalCount = 0;
|
|
6433
6527
|
let optionalPayloadCount = 0;
|
|
6434
6528
|
for (const member of typeLiteral.members) {
|
|
6435
|
-
if (member.type !==
|
|
6529
|
+
if (member.type !== import_utils46.AST_NODE_TYPES.TSPropertySignature) {
|
|
6436
6530
|
continue;
|
|
6437
6531
|
}
|
|
6438
6532
|
if (member.optional) {
|
|
@@ -6474,7 +6568,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6474
6568
|
TSInterfaceDeclaration(node) {
|
|
6475
6569
|
const synthetic = {
|
|
6476
6570
|
...node.body,
|
|
6477
|
-
type:
|
|
6571
|
+
type: import_utils46.AST_NODE_TYPES.TSTypeLiteral,
|
|
6478
6572
|
members: node.body.body
|
|
6479
6573
|
};
|
|
6480
6574
|
checkTypeLiteral(synthetic, node);
|
|
@@ -6487,7 +6581,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6487
6581
|
});
|
|
6488
6582
|
|
|
6489
6583
|
// src/rules/prefer-module-level-constant.ts
|
|
6490
|
-
var
|
|
6584
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
6491
6585
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6492
6586
|
var MAX_LITERAL_DEPTH = 4;
|
|
6493
6587
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6516,9 +6610,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6516
6610
|
"assign"
|
|
6517
6611
|
]);
|
|
6518
6612
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6613
|
+
import_utils47.AST_NODE_TYPES.FunctionDeclaration,
|
|
6614
|
+
import_utils47.AST_NODE_TYPES.FunctionExpression,
|
|
6615
|
+
import_utils47.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6522
6616
|
]);
|
|
6523
6617
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6524
6618
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6531,14 +6625,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6531
6625
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6532
6626
|
}
|
|
6533
6627
|
function unwrap3(node) {
|
|
6534
|
-
if (node.type ===
|
|
6628
|
+
if (node.type === import_utils47.AST_NODE_TYPES.TSAsExpression || node.type === import_utils47.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils47.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6535
6629
|
return unwrap3(node.expression);
|
|
6536
6630
|
}
|
|
6537
6631
|
return node;
|
|
6538
6632
|
}
|
|
6539
6633
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6540
6634
|
function isRegexLiteral(node) {
|
|
6541
|
-
return node.type ===
|
|
6635
|
+
return node.type === import_utils47.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6542
6636
|
}
|
|
6543
6637
|
function isLiteralOnly(node, depth) {
|
|
6544
6638
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6546,29 +6640,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6546
6640
|
}
|
|
6547
6641
|
const inner = unwrap3(node);
|
|
6548
6642
|
switch (inner.type) {
|
|
6549
|
-
case
|
|
6643
|
+
case import_utils47.AST_NODE_TYPES.Literal: {
|
|
6550
6644
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6551
6645
|
}
|
|
6552
|
-
case
|
|
6646
|
+
case import_utils47.AST_NODE_TYPES.TemplateLiteral: {
|
|
6553
6647
|
return inner.expressions.length === 0;
|
|
6554
6648
|
}
|
|
6555
|
-
case
|
|
6556
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6649
|
+
case import_utils47.AST_NODE_TYPES.UnaryExpression: {
|
|
6650
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils47.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6557
6651
|
}
|
|
6558
|
-
case
|
|
6652
|
+
case import_utils47.AST_NODE_TYPES.ArrayExpression: {
|
|
6559
6653
|
return inner.elements.every(
|
|
6560
|
-
(el) => el !== null && el.type !==
|
|
6654
|
+
(el) => el !== null && el.type !== import_utils47.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6561
6655
|
);
|
|
6562
6656
|
}
|
|
6563
|
-
case
|
|
6657
|
+
case import_utils47.AST_NODE_TYPES.ObjectExpression: {
|
|
6564
6658
|
return inner.properties.every((prop) => {
|
|
6565
|
-
if (prop.type !==
|
|
6659
|
+
if (prop.type !== import_utils47.AST_NODE_TYPES.Property) {
|
|
6566
6660
|
return false;
|
|
6567
6661
|
}
|
|
6568
6662
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6569
6663
|
return false;
|
|
6570
6664
|
}
|
|
6571
|
-
if (prop.computed && prop.key.type !==
|
|
6665
|
+
if (prop.computed && prop.key.type !== import_utils47.AST_NODE_TYPES.Literal) {
|
|
6572
6666
|
return false;
|
|
6573
6667
|
}
|
|
6574
6668
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6581,7 +6675,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6581
6675
|
}
|
|
6582
6676
|
function unwrapObjectFreeze(node) {
|
|
6583
6677
|
const inner = unwrap3(node);
|
|
6584
|
-
if (inner.type ===
|
|
6678
|
+
if (inner.type === import_utils47.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils47.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils47.AST_NODE_TYPES.SpreadElement) {
|
|
6585
6679
|
return unwrap3(inner.arguments[0]);
|
|
6586
6680
|
}
|
|
6587
6681
|
return inner;
|
|
@@ -6597,19 +6691,19 @@ function classify(init, checkRegex) {
|
|
|
6597
6691
|
}
|
|
6598
6692
|
return { kind: "regex", size: 1 };
|
|
6599
6693
|
}
|
|
6600
|
-
if (node.type ===
|
|
6694
|
+
if (node.type === import_utils47.AST_NODE_TYPES.ArrayExpression) {
|
|
6601
6695
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6602
6696
|
}
|
|
6603
|
-
if (node.type ===
|
|
6697
|
+
if (node.type === import_utils47.AST_NODE_TYPES.ObjectExpression) {
|
|
6604
6698
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6605
6699
|
}
|
|
6606
|
-
if (node.type ===
|
|
6700
|
+
if (node.type === import_utils47.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils47.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6607
6701
|
const arg = node.arguments[0];
|
|
6608
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6702
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils47.AST_NODE_TYPES.SpreadElement) {
|
|
6609
6703
|
return null;
|
|
6610
6704
|
}
|
|
6611
6705
|
const entries = unwrap3(arg);
|
|
6612
|
-
if (entries.type !==
|
|
6706
|
+
if (entries.type !== import_utils47.AST_NODE_TYPES.ArrayExpression) {
|
|
6613
6707
|
return null;
|
|
6614
6708
|
}
|
|
6615
6709
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6638,10 +6732,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6638
6732
|
);
|
|
6639
6733
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6640
6734
|
const callee = node.callee;
|
|
6641
|
-
if (callee.type ===
|
|
6735
|
+
if (callee.type === import_utils47.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6642
6736
|
return true;
|
|
6643
6737
|
}
|
|
6644
|
-
if (callee.type !==
|
|
6738
|
+
if (callee.type !== import_utils47.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils47.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6645
6739
|
return false;
|
|
6646
6740
|
}
|
|
6647
6741
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6655,38 +6749,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6655
6749
|
}
|
|
6656
6750
|
function isSafeRead(identifier) {
|
|
6657
6751
|
const parent = identifier.parent;
|
|
6658
|
-
if (parent.type ===
|
|
6752
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.MemberExpression) {
|
|
6659
6753
|
if (parent.object !== identifier) {
|
|
6660
6754
|
return true;
|
|
6661
6755
|
}
|
|
6662
6756
|
const grandparent = parent.parent;
|
|
6663
|
-
if (grandparent.type ===
|
|
6757
|
+
if (grandparent.type === import_utils47.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6664
6758
|
return false;
|
|
6665
6759
|
}
|
|
6666
|
-
if (grandparent.type ===
|
|
6760
|
+
if (grandparent.type === import_utils47.AST_NODE_TYPES.UpdateExpression) {
|
|
6667
6761
|
return false;
|
|
6668
6762
|
}
|
|
6669
|
-
if (grandparent.type ===
|
|
6763
|
+
if (grandparent.type === import_utils47.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6670
6764
|
return false;
|
|
6671
6765
|
}
|
|
6672
|
-
if (!parent.computed && parent.property.type ===
|
|
6766
|
+
if (!parent.computed && parent.property.type === import_utils47.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils47.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6673
6767
|
return false;
|
|
6674
6768
|
}
|
|
6675
6769
|
return true;
|
|
6676
6770
|
}
|
|
6677
|
-
if (parent.type ===
|
|
6771
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6678
6772
|
return true;
|
|
6679
6773
|
}
|
|
6680
|
-
if (parent.type ===
|
|
6774
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.SpreadElement) {
|
|
6681
6775
|
return true;
|
|
6682
6776
|
}
|
|
6683
|
-
if (parent.type ===
|
|
6777
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.BinaryExpression) {
|
|
6684
6778
|
return true;
|
|
6685
6779
|
}
|
|
6686
|
-
if (parent.type ===
|
|
6780
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6687
6781
|
return true;
|
|
6688
6782
|
}
|
|
6689
|
-
if (parent.type ===
|
|
6783
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6690
6784
|
return true;
|
|
6691
6785
|
}
|
|
6692
6786
|
return false;
|
|
@@ -6741,7 +6835,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6741
6835
|
if (reference.isWrite()) {
|
|
6742
6836
|
return false;
|
|
6743
6837
|
}
|
|
6744
|
-
if (reference.identifier.type !==
|
|
6838
|
+
if (reference.identifier.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6745
6839
|
return false;
|
|
6746
6840
|
}
|
|
6747
6841
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6753,10 +6847,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6753
6847
|
return {
|
|
6754
6848
|
VariableDeclarator(node) {
|
|
6755
6849
|
const declaration = node.parent;
|
|
6756
|
-
if (declaration.type !==
|
|
6850
|
+
if (declaration.type !== import_utils47.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6757
6851
|
return;
|
|
6758
6852
|
}
|
|
6759
|
-
if (node.id.type !==
|
|
6853
|
+
if (node.id.type !== import_utils47.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6760
6854
|
return;
|
|
6761
6855
|
}
|
|
6762
6856
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6783,7 +6877,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6783
6877
|
});
|
|
6784
6878
|
|
|
6785
6879
|
// src/rules/prefer-module-level-schema.ts
|
|
6786
|
-
var
|
|
6880
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6787
6881
|
|
|
6788
6882
|
// src/rules/_zod.ts
|
|
6789
6883
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6849,9 +6943,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6849
6943
|
"intl"
|
|
6850
6944
|
]);
|
|
6851
6945
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6946
|
+
import_utils48.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
6947
|
+
import_utils48.AST_NODE_TYPES.FunctionDeclaration,
|
|
6948
|
+
import_utils48.AST_NODE_TYPES.FunctionExpression
|
|
6855
6949
|
]);
|
|
6856
6950
|
function schemaExpression(node) {
|
|
6857
6951
|
let current = node;
|
|
@@ -6860,10 +6954,10 @@ function schemaExpression(node) {
|
|
|
6860
6954
|
if (parent === void 0) {
|
|
6861
6955
|
return current;
|
|
6862
6956
|
}
|
|
6863
|
-
if (parent.type ===
|
|
6957
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils48.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6864
6958
|
return current;
|
|
6865
6959
|
}
|
|
6866
|
-
if (parent.type ===
|
|
6960
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils48.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils48.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils48.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
6867
6961
|
current = parent;
|
|
6868
6962
|
continue;
|
|
6869
6963
|
}
|
|
@@ -6914,22 +7008,22 @@ function subtreeSome(root, predicate) {
|
|
|
6914
7008
|
function readsReceiver(node) {
|
|
6915
7009
|
return subtreeSome(
|
|
6916
7010
|
node,
|
|
6917
|
-
(inner) => inner.type ===
|
|
7011
|
+
(inner) => inner.type === import_utils48.AST_NODE_TYPES.ThisExpression || inner.type === import_utils48.AST_NODE_TYPES.Super || inner.type === import_utils48.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
6918
7012
|
);
|
|
6919
7013
|
}
|
|
6920
7014
|
function buildsLocalizedText(node) {
|
|
6921
7015
|
return subtreeSome(node, (inner) => {
|
|
6922
|
-
if (inner.type ===
|
|
7016
|
+
if (inner.type === import_utils48.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
6923
7017
|
return true;
|
|
6924
7018
|
}
|
|
6925
|
-
if (inner.type !==
|
|
7019
|
+
if (inner.type !== import_utils48.AST_NODE_TYPES.CallExpression) {
|
|
6926
7020
|
return false;
|
|
6927
7021
|
}
|
|
6928
7022
|
const { callee } = inner;
|
|
6929
|
-
if (callee.type ===
|
|
7023
|
+
if (callee.type === import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6930
7024
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6931
7025
|
}
|
|
6932
|
-
return callee.type ===
|
|
7026
|
+
return callee.type === import_utils48.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils48.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6933
7027
|
});
|
|
6934
7028
|
}
|
|
6935
7029
|
function collectReferences(scope, out) {
|
|
@@ -6986,15 +7080,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6986
7080
|
}
|
|
6987
7081
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
6988
7082
|
function isZodCall(node) {
|
|
6989
|
-
return node.type ===
|
|
7083
|
+
return node.type === import_utils48.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils48.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils48.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
6990
7084
|
}
|
|
6991
7085
|
function isCovered(node) {
|
|
6992
7086
|
let current = node.parent ?? void 0;
|
|
6993
7087
|
while (current !== void 0) {
|
|
6994
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7088
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils48.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils48.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
6995
7089
|
return true;
|
|
6996
7090
|
}
|
|
6997
|
-
if (current.type ===
|
|
7091
|
+
if (current.type === import_utils48.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils48.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils48.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils48.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
6998
7092
|
return true;
|
|
6999
7093
|
}
|
|
7000
7094
|
current = current.parent ?? void 0;
|
|
@@ -7009,11 +7103,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7009
7103
|
if (parent === void 0) {
|
|
7010
7104
|
return confirmed;
|
|
7011
7105
|
}
|
|
7012
|
-
if (parent.type ===
|
|
7106
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils48.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils48.AST_NODE_TYPES.ArrayExpression) {
|
|
7013
7107
|
current = parent;
|
|
7014
7108
|
continue;
|
|
7015
7109
|
}
|
|
7016
|
-
if (parent.type ===
|
|
7110
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7017
7111
|
current = schemaExpression(parent);
|
|
7018
7112
|
confirmed = current;
|
|
7019
7113
|
continue;
|
|
@@ -7023,7 +7117,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7023
7117
|
}
|
|
7024
7118
|
function isSchemaComposition(node) {
|
|
7025
7119
|
const { callee } = node;
|
|
7026
|
-
const isCombinator = callee.type ===
|
|
7120
|
+
const isCombinator = callee.type === import_utils48.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils48.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7027
7121
|
return isCombinator || isZodCall(node);
|
|
7028
7122
|
}
|
|
7029
7123
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7057,13 +7151,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7057
7151
|
}
|
|
7058
7152
|
function ownerName(enclosing) {
|
|
7059
7153
|
const parent = enclosing.parent ?? void 0;
|
|
7060
|
-
if (enclosing.type ===
|
|
7154
|
+
if (enclosing.type === import_utils48.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
7061
7155
|
return enclosing.id.name;
|
|
7062
7156
|
}
|
|
7063
|
-
if (parent !== void 0 && parent.type ===
|
|
7157
|
+
if (parent !== void 0 && parent.type === import_utils48.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils48.AST_NODE_TYPES.Identifier) {
|
|
7064
7158
|
return parent.id.name;
|
|
7065
7159
|
}
|
|
7066
|
-
if (parent !== void 0 && (parent.type ===
|
|
7160
|
+
if (parent !== void 0 && (parent.type === import_utils48.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils48.AST_NODE_TYPES.Property) && parent.key.type === import_utils48.AST_NODE_TYPES.Identifier) {
|
|
7067
7161
|
return parent.key.name;
|
|
7068
7162
|
}
|
|
7069
7163
|
return "this function";
|
|
@@ -7074,7 +7168,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7074
7168
|
return;
|
|
7075
7169
|
}
|
|
7076
7170
|
for (const specifier of node.specifiers) {
|
|
7077
|
-
if (specifier.type ===
|
|
7171
|
+
if (specifier.type === import_utils48.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils48.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils48.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils48.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
7078
7172
|
zodNamespaces.add(specifier.local.name);
|
|
7079
7173
|
}
|
|
7080
7174
|
}
|
|
@@ -7084,7 +7178,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7084
7178
|
return;
|
|
7085
7179
|
}
|
|
7086
7180
|
const callee = node.callee;
|
|
7087
|
-
if (callee.property.type !==
|
|
7181
|
+
if (callee.property.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
7088
7182
|
return;
|
|
7089
7183
|
}
|
|
7090
7184
|
const factory = callee.property.name;
|
|
@@ -7099,7 +7193,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7099
7193
|
return;
|
|
7100
7194
|
}
|
|
7101
7195
|
const shape = node.arguments[0];
|
|
7102
|
-
if (shape !== void 0 && shape.type ===
|
|
7196
|
+
if (shape !== void 0 && shape.type === import_utils48.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
7103
7197
|
return;
|
|
7104
7198
|
}
|
|
7105
7199
|
const expression = schemaExpression(node);
|
|
@@ -7127,20 +7221,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7127
7221
|
});
|
|
7128
7222
|
|
|
7129
7223
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7130
|
-
var
|
|
7224
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
7131
7225
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7132
7226
|
function propertyName(node) {
|
|
7133
7227
|
const key = node.key;
|
|
7134
|
-
if (key.type ===
|
|
7135
|
-
if (key.type ===
|
|
7228
|
+
if (key.type === import_utils49.AST_NODE_TYPES.Identifier) return key.name;
|
|
7229
|
+
if (key.type === import_utils49.AST_NODE_TYPES.Literal) return String(key.value);
|
|
7136
7230
|
return "collection";
|
|
7137
7231
|
}
|
|
7138
7232
|
function isArrayType(node) {
|
|
7139
|
-
if (node.type ===
|
|
7140
|
-
return node.type ===
|
|
7233
|
+
if (node.type === import_utils49.AST_NODE_TYPES.TSArrayType) return true;
|
|
7234
|
+
return node.type === import_utils49.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils49.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7141
7235
|
}
|
|
7142
7236
|
function isNullishType(node) {
|
|
7143
|
-
return node.type ===
|
|
7237
|
+
return node.type === import_utils49.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils49.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7144
7238
|
}
|
|
7145
7239
|
function isNullableArrayOnly(node) {
|
|
7146
7240
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7168,7 +7262,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7168
7262
|
if (node.optional) return;
|
|
7169
7263
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7170
7264
|
if (annotation === void 0) return;
|
|
7171
|
-
if (annotation.type !==
|
|
7265
|
+
if (annotation.type !== import_utils49.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7172
7266
|
return;
|
|
7173
7267
|
}
|
|
7174
7268
|
context.report({
|
|
@@ -7181,7 +7275,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7181
7275
|
TSPropertySignature: checkOptionalProperty,
|
|
7182
7276
|
PropertyDefinition: checkOptionalProperty,
|
|
7183
7277
|
TSTypeAliasDeclaration(node) {
|
|
7184
|
-
if (node.typeAnnotation.type !==
|
|
7278
|
+
if (node.typeAnnotation.type !== import_utils49.AST_NODE_TYPES.TSUnionType) return;
|
|
7185
7279
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7186
7280
|
context.report({
|
|
7187
7281
|
node,
|
|
@@ -7193,14 +7287,100 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7193
7287
|
}
|
|
7194
7288
|
});
|
|
7195
7289
|
|
|
7290
|
+
// src/rules/prefer-native-random-uuid.ts
|
|
7291
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7292
|
+
function requireUuid(node) {
|
|
7293
|
+
return node?.type === import_utils50.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils50.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === import_utils50.AST_NODE_TYPES.Literal && node.arguments[0].value === "uuid";
|
|
7294
|
+
}
|
|
7295
|
+
var prefer_native_random_uuid_default = createRule({
|
|
7296
|
+
name: "prefer-native-random-uuid",
|
|
7297
|
+
meta: {
|
|
7298
|
+
type: "suggestion",
|
|
7299
|
+
docs: {
|
|
7300
|
+
description: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package."
|
|
7301
|
+
},
|
|
7302
|
+
hasSuggestions: true,
|
|
7303
|
+
schema: [],
|
|
7304
|
+
messages: {
|
|
7305
|
+
preferNative: "Use the Node 22 native `globalThis.crypto.randomUUID()` instead of the `uuid` package for UUID v4.",
|
|
7306
|
+
replaceWithNative: "Replace this UUID v4 call with the native implementation."
|
|
7307
|
+
}
|
|
7308
|
+
},
|
|
7309
|
+
defaultOptions: [],
|
|
7310
|
+
create(context) {
|
|
7311
|
+
const directBindings = /* @__PURE__ */ new Set();
|
|
7312
|
+
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7313
|
+
function resolve(identifier) {
|
|
7314
|
+
return import_utils50.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7315
|
+
}
|
|
7316
|
+
function record(identifier, destination) {
|
|
7317
|
+
const variable = resolve(identifier);
|
|
7318
|
+
if (variable !== null) destination.add(variable);
|
|
7319
|
+
}
|
|
7320
|
+
function report(node) {
|
|
7321
|
+
context.report({
|
|
7322
|
+
node,
|
|
7323
|
+
messageId: "preferNative",
|
|
7324
|
+
suggest: [
|
|
7325
|
+
{
|
|
7326
|
+
messageId: "replaceWithNative",
|
|
7327
|
+
fix: (fixer) => fixer.replaceText(node, "globalThis.crypto.randomUUID()")
|
|
7328
|
+
}
|
|
7329
|
+
]
|
|
7330
|
+
});
|
|
7331
|
+
}
|
|
7332
|
+
return {
|
|
7333
|
+
ImportDeclaration(node) {
|
|
7334
|
+
if (node.source.value !== "uuid") return;
|
|
7335
|
+
for (const specifier of node.specifiers) {
|
|
7336
|
+
if (specifier.type === import_utils50.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils50.AST_NODE_TYPES.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7337
|
+
record(specifier.local, directBindings);
|
|
7338
|
+
} else if (specifier.type === import_utils50.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
7339
|
+
record(specifier.local, namespaceBindings);
|
|
7340
|
+
}
|
|
7341
|
+
}
|
|
7342
|
+
},
|
|
7343
|
+
VariableDeclarator(node) {
|
|
7344
|
+
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7345
|
+
if (node.init?.type !== import_utils50.AST_NODE_TYPES.CallExpression || node.init.callee.type !== import_utils50.AST_NODE_TYPES.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
7346
|
+
return;
|
|
7347
|
+
}
|
|
7348
|
+
if (node.id.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7349
|
+
record(node.id, namespaceBindings);
|
|
7350
|
+
return;
|
|
7351
|
+
}
|
|
7352
|
+
if (node.id.type !== import_utils50.AST_NODE_TYPES.ObjectPattern) return;
|
|
7353
|
+
for (const property of node.id.properties) {
|
|
7354
|
+
if (property.type === import_utils50.AST_NODE_TYPES.Property && !property.computed && (property.key.type === import_utils50.AST_NODE_TYPES.Identifier && property.key.name === "v4" || property.key.type === import_utils50.AST_NODE_TYPES.Literal && property.key.value === "v4") && property.value.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7355
|
+
record(property.value, directBindings);
|
|
7356
|
+
}
|
|
7357
|
+
}
|
|
7358
|
+
},
|
|
7359
|
+
"CallExpression:exit"(node) {
|
|
7360
|
+
if (node.arguments.length !== 0) return;
|
|
7361
|
+
if (node.callee.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7362
|
+
const variable2 = resolve(node.callee);
|
|
7363
|
+
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7364
|
+
return;
|
|
7365
|
+
}
|
|
7366
|
+
if (node.callee.type !== import_utils50.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.object.type !== import_utils50.AST_NODE_TYPES.Identifier || node.callee.property.type !== import_utils50.AST_NODE_TYPES.Identifier || node.callee.property.name !== "v4") {
|
|
7367
|
+
return;
|
|
7368
|
+
}
|
|
7369
|
+
const variable = resolve(node.callee.object);
|
|
7370
|
+
if (variable !== null && namespaceBindings.has(variable)) report(node);
|
|
7371
|
+
}
|
|
7372
|
+
};
|
|
7373
|
+
}
|
|
7374
|
+
});
|
|
7375
|
+
|
|
7196
7376
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7197
|
-
var
|
|
7377
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7198
7378
|
var unwrap4 = (node) => {
|
|
7199
7379
|
let current = node;
|
|
7200
7380
|
while (current !== null && current !== void 0) {
|
|
7201
|
-
if (current.type ===
|
|
7381
|
+
if (current.type === import_utils51.AST_NODE_TYPES.TSAsExpression || current.type === import_utils51.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils51.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils51.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
7202
7382
|
current = current.expression;
|
|
7203
|
-
} else if (current.type ===
|
|
7383
|
+
} else if (current.type === import_utils51.AST_NODE_TYPES.ChainExpression) {
|
|
7204
7384
|
current = current.expression;
|
|
7205
7385
|
} else {
|
|
7206
7386
|
break;
|
|
@@ -7215,23 +7395,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7215
7395
|
]);
|
|
7216
7396
|
var isSchemaParseReference = (node) => {
|
|
7217
7397
|
const inner = unwrap4(node);
|
|
7218
|
-
return inner !== null && inner.type ===
|
|
7398
|
+
return inner !== null && inner.type === import_utils51.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils51.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7219
7399
|
};
|
|
7220
7400
|
var isRawPayloadSource = (node) => {
|
|
7221
7401
|
let current = unwrap4(node);
|
|
7222
7402
|
if (current === null) return false;
|
|
7223
|
-
if (current.type ===
|
|
7403
|
+
if (current.type === import_utils51.AST_NODE_TYPES.AwaitExpression) {
|
|
7224
7404
|
current = unwrap4(current.argument);
|
|
7225
7405
|
}
|
|
7226
|
-
if (current === null || current.type !==
|
|
7406
|
+
if (current === null || current.type !== import_utils51.AST_NODE_TYPES.CallExpression) {
|
|
7227
7407
|
return false;
|
|
7228
7408
|
}
|
|
7229
7409
|
const callee = unwrap4(current.callee);
|
|
7230
|
-
if (callee === null || callee.type !==
|
|
7410
|
+
if (callee === null || callee.type !== import_utils51.AST_NODE_TYPES.MemberExpression) {
|
|
7231
7411
|
return false;
|
|
7232
7412
|
}
|
|
7233
7413
|
const property = unwrap4(callee.property);
|
|
7234
|
-
if (property === null || property.type !==
|
|
7414
|
+
if (property === null || property.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7235
7415
|
return false;
|
|
7236
7416
|
}
|
|
7237
7417
|
if (property.name === "json") {
|
|
@@ -7241,16 +7421,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7241
7421
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7242
7422
|
}
|
|
7243
7423
|
const object = unwrap4(callee.object);
|
|
7244
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7424
|
+
return property.name === "parse" && object !== null && object.type === import_utils51.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7245
7425
|
};
|
|
7246
7426
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7247
7427
|
var isLocalFileRead = (node) => {
|
|
7248
7428
|
let found = false;
|
|
7249
7429
|
const visit = (current) => {
|
|
7250
7430
|
if (found || current === null || current === void 0) return;
|
|
7251
|
-
if (current.type ===
|
|
7431
|
+
if (current.type === import_utils51.AST_NODE_TYPES.CallExpression) {
|
|
7252
7432
|
const callee = unwrap4(current.callee);
|
|
7253
|
-
const name = callee?.type ===
|
|
7433
|
+
const name = callee?.type === import_utils51.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils51.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils51.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
7254
7434
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7255
7435
|
found = true;
|
|
7256
7436
|
return;
|
|
@@ -7272,15 +7452,15 @@ var isLocalFileRead = (node) => {
|
|
|
7272
7452
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7273
7453
|
var isInsideAssertion = (node) => {
|
|
7274
7454
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7275
|
-
if (current.type !==
|
|
7455
|
+
if (current.type !== import_utils51.AST_NODE_TYPES.CallExpression) continue;
|
|
7276
7456
|
let callee = current.callee;
|
|
7277
|
-
while (callee.type ===
|
|
7457
|
+
while (callee.type === import_utils51.AST_NODE_TYPES.MemberExpression) {
|
|
7278
7458
|
callee = callee.object;
|
|
7279
7459
|
}
|
|
7280
|
-
if (callee.type ===
|
|
7460
|
+
if (callee.type === import_utils51.AST_NODE_TYPES.CallExpression) {
|
|
7281
7461
|
callee = callee.callee;
|
|
7282
7462
|
}
|
|
7283
|
-
if (callee.type ===
|
|
7463
|
+
if (callee.type === import_utils51.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7284
7464
|
return true;
|
|
7285
7465
|
}
|
|
7286
7466
|
}
|
|
@@ -7299,39 +7479,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7299
7479
|
var isValidationRead = (node) => {
|
|
7300
7480
|
let current = node;
|
|
7301
7481
|
let parent = current.parent;
|
|
7302
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7482
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils51.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils51.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils51.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils51.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils51.AST_NODE_TYPES.ChainExpression)) {
|
|
7303
7483
|
current = parent;
|
|
7304
7484
|
parent = parent.parent;
|
|
7305
7485
|
}
|
|
7306
7486
|
if (parent === null || parent === void 0) return false;
|
|
7307
|
-
if (parent.type ===
|
|
7487
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7308
7488
|
return true;
|
|
7309
7489
|
}
|
|
7310
|
-
if (parent.type !==
|
|
7490
|
+
if (parent.type !== import_utils51.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7311
7491
|
return false;
|
|
7312
7492
|
}
|
|
7313
7493
|
const callee = parent.callee;
|
|
7314
|
-
if (callee.type ===
|
|
7494
|
+
if (callee.type === import_utils51.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils51.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils51.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
7315
7495
|
return parent.arguments.length === 1;
|
|
7316
7496
|
}
|
|
7317
|
-
return callee.type ===
|
|
7497
|
+
return callee.type === import_utils51.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7318
7498
|
};
|
|
7319
7499
|
var isGuardTestPosition = (node) => {
|
|
7320
7500
|
let current = node;
|
|
7321
7501
|
let parent = current.parent;
|
|
7322
7502
|
while (parent !== void 0 && parent !== null) {
|
|
7323
7503
|
switch (parent.type) {
|
|
7324
|
-
case
|
|
7325
|
-
case
|
|
7326
|
-
case
|
|
7504
|
+
case import_utils51.AST_NODE_TYPES.UnaryExpression:
|
|
7505
|
+
case import_utils51.AST_NODE_TYPES.LogicalExpression:
|
|
7506
|
+
case import_utils51.AST_NODE_TYPES.ChainExpression:
|
|
7327
7507
|
current = parent;
|
|
7328
7508
|
parent = parent.parent;
|
|
7329
7509
|
continue;
|
|
7330
|
-
case
|
|
7331
|
-
case
|
|
7332
|
-
case
|
|
7333
|
-
case
|
|
7334
|
-
case
|
|
7510
|
+
case import_utils51.AST_NODE_TYPES.IfStatement:
|
|
7511
|
+
case import_utils51.AST_NODE_TYPES.ConditionalExpression:
|
|
7512
|
+
case import_utils51.AST_NODE_TYPES.WhileStatement:
|
|
7513
|
+
case import_utils51.AST_NODE_TYPES.DoWhileStatement:
|
|
7514
|
+
case import_utils51.AST_NODE_TYPES.ForStatement:
|
|
7335
7515
|
return parent.test === current;
|
|
7336
7516
|
default:
|
|
7337
7517
|
return false;
|
|
@@ -7341,7 +7521,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7341
7521
|
};
|
|
7342
7522
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7343
7523
|
const unwrapped = unwrap4(node);
|
|
7344
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7524
|
+
if (unwrapped === null || unwrapped.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7345
7525
|
return false;
|
|
7346
7526
|
}
|
|
7347
7527
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7384,11 +7564,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7384
7564
|
return {
|
|
7385
7565
|
VariableDeclarator(node) {
|
|
7386
7566
|
const scope = context.sourceCode.getScope(node);
|
|
7387
|
-
if (node.id.type ===
|
|
7567
|
+
if (node.id.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7388
7568
|
trackInitializer(node);
|
|
7389
7569
|
return;
|
|
7390
7570
|
}
|
|
7391
|
-
if (node.id.type ===
|
|
7571
|
+
if (node.id.type === import_utils51.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils51.AST_NODE_TYPES.ArrayPattern) {
|
|
7392
7572
|
if (isRawPayloadSource(node.init)) {
|
|
7393
7573
|
if (!isFullyNarrowedPattern(node)) {
|
|
7394
7574
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7402,7 +7582,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7402
7582
|
},
|
|
7403
7583
|
AssignmentExpression(node) {
|
|
7404
7584
|
const scope = context.sourceCode.getScope(node);
|
|
7405
|
-
if (node.left.type ===
|
|
7585
|
+
if (node.left.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7406
7586
|
const variable = findVariable2(scope, node.left.name);
|
|
7407
7587
|
if (variable === null) return;
|
|
7408
7588
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7412,7 +7592,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7412
7592
|
}
|
|
7413
7593
|
return;
|
|
7414
7594
|
}
|
|
7415
|
-
if (node.left.type ===
|
|
7595
|
+
if (node.left.type === import_utils51.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils51.AST_NODE_TYPES.ArrayPattern) {
|
|
7416
7596
|
if (isRawPayloadSource(node.right)) {
|
|
7417
7597
|
context.report({
|
|
7418
7598
|
node: node.left,
|
|
@@ -7429,15 +7609,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7429
7609
|
}
|
|
7430
7610
|
},
|
|
7431
7611
|
CallExpression(node) {
|
|
7432
|
-
if (node.callee.type !==
|
|
7612
|
+
if (node.callee.type !== import_utils51.AST_NODE_TYPES.Identifier) return;
|
|
7433
7613
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7434
7614
|
return;
|
|
7435
7615
|
}
|
|
7436
7616
|
const scope = context.sourceCode.getScope(node);
|
|
7437
7617
|
for (const arg of node.arguments) {
|
|
7438
|
-
if (arg.type ===
|
|
7618
|
+
if (arg.type === import_utils51.AST_NODE_TYPES.SpreadElement) continue;
|
|
7439
7619
|
const unwrapped = unwrap4(arg);
|
|
7440
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7620
|
+
if (unwrapped === null || unwrapped.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7441
7621
|
continue;
|
|
7442
7622
|
}
|
|
7443
7623
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7451,13 +7631,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7451
7631
|
const obj = unwrap4(node.object);
|
|
7452
7632
|
if (isRawPayloadSource(obj)) {
|
|
7453
7633
|
const parent = node.parent;
|
|
7454
|
-
if (parent.type ===
|
|
7634
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils51.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7455
7635
|
return;
|
|
7456
7636
|
}
|
|
7457
7637
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7458
7638
|
return;
|
|
7459
7639
|
}
|
|
7460
|
-
if (obj !== null && obj.type ===
|
|
7640
|
+
if (obj !== null && obj.type === import_utils51.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7461
7641
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7462
7642
|
const variable = findVariable2(scope, obj.name);
|
|
7463
7643
|
if (variable !== null) {
|
|
@@ -7470,7 +7650,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7470
7650
|
});
|
|
7471
7651
|
|
|
7472
7652
|
// src/rules/prefer-semantic-colors.ts
|
|
7473
|
-
var
|
|
7653
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7474
7654
|
var import_fs = require("fs");
|
|
7475
7655
|
var import_path = require("path");
|
|
7476
7656
|
|
|
@@ -7570,8 +7750,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7570
7750
|
]);
|
|
7571
7751
|
function jsxElementName(node) {
|
|
7572
7752
|
const name = node.openingElement.name;
|
|
7573
|
-
if (name.type ===
|
|
7574
|
-
if (name.type ===
|
|
7753
|
+
if (name.type === import_utils52.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
7754
|
+
if (name.type === import_utils52.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils52.AST_NODE_TYPES.JSXIdentifier) {
|
|
7575
7755
|
return name.property.name;
|
|
7576
7756
|
}
|
|
7577
7757
|
return null;
|
|
@@ -7597,7 +7777,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7597
7777
|
var isInsideSvg = (node) => {
|
|
7598
7778
|
let current = node.parent;
|
|
7599
7779
|
while (current !== void 0 && current !== null) {
|
|
7600
|
-
if (current.type ===
|
|
7780
|
+
if (current.type === import_utils52.AST_NODE_TYPES.JSXElement) {
|
|
7601
7781
|
const name = jsxElementName(current);
|
|
7602
7782
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7603
7783
|
}
|
|
@@ -7608,7 +7788,7 @@ var isInsideSvg = (node) => {
|
|
|
7608
7788
|
var isInsideIconFactoryPath = (node) => {
|
|
7609
7789
|
let current = node.parent;
|
|
7610
7790
|
while (current !== void 0 && current !== null) {
|
|
7611
|
-
if (current.type ===
|
|
7791
|
+
if (current.type === import_utils52.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils52.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils52.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils52.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7612
7792
|
return true;
|
|
7613
7793
|
}
|
|
7614
7794
|
current = current.parent;
|
|
@@ -7745,12 +7925,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7745
7925
|
return root !== null && workspaceHasMarker(root);
|
|
7746
7926
|
};
|
|
7747
7927
|
var propName = (key) => {
|
|
7748
|
-
if (key.type ===
|
|
7749
|
-
if (key.type ===
|
|
7928
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Identifier) return key.name;
|
|
7929
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
7750
7930
|
return null;
|
|
7751
7931
|
};
|
|
7752
7932
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7753
|
-
if (statement.type !==
|
|
7933
|
+
if (statement.type !== import_utils52.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils52.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils52.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
7754
7934
|
return false;
|
|
7755
7935
|
}
|
|
7756
7936
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -7802,27 +7982,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7802
7982
|
const checkClassNode = (node) => {
|
|
7803
7983
|
if (node === null) return;
|
|
7804
7984
|
switch (node.type) {
|
|
7805
|
-
case
|
|
7985
|
+
case import_utils52.AST_NODE_TYPES.Literal:
|
|
7806
7986
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7807
7987
|
break;
|
|
7808
|
-
case
|
|
7988
|
+
case import_utils52.AST_NODE_TYPES.TemplateLiteral:
|
|
7809
7989
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7810
7990
|
break;
|
|
7811
|
-
case
|
|
7991
|
+
case import_utils52.AST_NODE_TYPES.ArrayExpression:
|
|
7812
7992
|
for (const element of node.elements) {
|
|
7813
|
-
if (element !== null && element.type !==
|
|
7993
|
+
if (element !== null && element.type !== import_utils52.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
7814
7994
|
}
|
|
7815
7995
|
break;
|
|
7816
|
-
case
|
|
7996
|
+
case import_utils52.AST_NODE_TYPES.ObjectExpression:
|
|
7817
7997
|
for (const property of node.properties) {
|
|
7818
|
-
if (property.type ===
|
|
7998
|
+
if (property.type === import_utils52.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
7819
7999
|
}
|
|
7820
8000
|
break;
|
|
7821
|
-
case
|
|
8001
|
+
case import_utils52.AST_NODE_TYPES.ConditionalExpression:
|
|
7822
8002
|
checkClassNode(node.consequent);
|
|
7823
8003
|
checkClassNode(node.alternate);
|
|
7824
8004
|
break;
|
|
7825
|
-
case
|
|
8005
|
+
case import_utils52.AST_NODE_TYPES.LogicalExpression:
|
|
7826
8006
|
checkClassNode(node.right);
|
|
7827
8007
|
break;
|
|
7828
8008
|
default:
|
|
@@ -7830,32 +8010,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7830
8010
|
}
|
|
7831
8011
|
};
|
|
7832
8012
|
const checkColorValueNode = (node) => {
|
|
7833
|
-
if (node.type ===
|
|
8013
|
+
if (node.type === import_utils52.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
7834
8014
|
report(node, "inlineColor", { value: node.value });
|
|
7835
8015
|
}
|
|
7836
8016
|
};
|
|
7837
8017
|
return {
|
|
7838
8018
|
"JSXAttribute[name.name='className']"(node) {
|
|
7839
8019
|
if (node.value === null) return;
|
|
7840
|
-
if (node.value.type ===
|
|
7841
|
-
else if (node.value.type ===
|
|
7842
|
-
if (node.value.expression.type !==
|
|
8020
|
+
if (node.value.type === import_utils52.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
8021
|
+
else if (node.value.type === import_utils52.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
8022
|
+
if (node.value.expression.type !== import_utils52.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
7843
8023
|
checkClassNode(node.value.expression);
|
|
7844
8024
|
}
|
|
7845
8025
|
}
|
|
7846
8026
|
},
|
|
7847
8027
|
CallExpression(node) {
|
|
7848
|
-
if (node.callee.type ===
|
|
8028
|
+
if (node.callee.type === import_utils52.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils52.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
7849
8029
|
importsEmailOrPdfRenderer = true;
|
|
7850
8030
|
}
|
|
7851
|
-
if (node.callee.type ===
|
|
8031
|
+
if (node.callee.type === import_utils52.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7852
8032
|
for (const arg of node.arguments) {
|
|
7853
|
-
if (arg.type !==
|
|
8033
|
+
if (arg.type !== import_utils52.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
7854
8034
|
}
|
|
7855
8035
|
}
|
|
7856
8036
|
},
|
|
7857
8037
|
VariableDeclarator(node) {
|
|
7858
|
-
if (node.id.type ===
|
|
8038
|
+
if (node.id.type === import_utils52.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
7859
8039
|
checkClassNode(node.init);
|
|
7860
8040
|
}
|
|
7861
8041
|
},
|
|
@@ -7865,9 +8045,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7865
8045
|
},
|
|
7866
8046
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
7867
8047
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
7868
|
-
if (node.value?.type !==
|
|
8048
|
+
if (node.value?.type !== import_utils52.AST_NODE_TYPES.Literal) return;
|
|
7869
8049
|
const owner = node.parent.name;
|
|
7870
|
-
if (owner.type ===
|
|
8050
|
+
if (owner.type === import_utils52.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
7871
8051
|
return;
|
|
7872
8052
|
}
|
|
7873
8053
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -7881,7 +8061,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7881
8061
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
7882
8062
|
},
|
|
7883
8063
|
ImportExpression(node) {
|
|
7884
|
-
if (node.source.type ===
|
|
8064
|
+
if (node.source.type === import_utils52.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
7885
8065
|
importsEmailOrPdfRenderer = true;
|
|
7886
8066
|
}
|
|
7887
8067
|
},
|
|
@@ -7894,7 +8074,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7894
8074
|
});
|
|
7895
8075
|
|
|
7896
8076
|
// src/rules/prefer-server-actions.ts
|
|
7897
|
-
var
|
|
8077
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7898
8078
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
7899
8079
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
7900
8080
|
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 +8265,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8085
8265
|
});
|
|
8086
8266
|
|
|
8087
8267
|
// src/rules/prefer-string-literal-union.ts
|
|
8088
|
-
var
|
|
8268
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
8089
8269
|
var ts2 = __toESM(require("typescript"), 1);
|
|
8090
8270
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
8091
8271
|
"status",
|
|
@@ -8128,19 +8308,19 @@ function isChoiceLikeName(name) {
|
|
|
8128
8308
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8129
8309
|
}
|
|
8130
8310
|
function keyName(key) {
|
|
8131
|
-
if (key.type ===
|
|
8311
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8132
8312
|
return key.name;
|
|
8133
8313
|
}
|
|
8134
|
-
if (key.type ===
|
|
8314
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
8135
8315
|
return key.value;
|
|
8136
8316
|
}
|
|
8137
8317
|
return null;
|
|
8138
8318
|
}
|
|
8139
8319
|
function isStringLiteralMember(t) {
|
|
8140
|
-
return t.type ===
|
|
8320
|
+
return t.type === import_utils54.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils54.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
8141
8321
|
}
|
|
8142
8322
|
function isStringLiteralUnion(node) {
|
|
8143
|
-
if (node?.type !==
|
|
8323
|
+
if (node?.type !== import_utils54.AST_NODE_TYPES.TSUnionType) {
|
|
8144
8324
|
return false;
|
|
8145
8325
|
}
|
|
8146
8326
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8169,12 +8349,12 @@ function bindingSourceExpression(decl) {
|
|
|
8169
8349
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8170
8350
|
}
|
|
8171
8351
|
function refKey(node) {
|
|
8172
|
-
if (node.type ===
|
|
8352
|
+
if (node.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8173
8353
|
return node.name;
|
|
8174
8354
|
}
|
|
8175
|
-
if (node.type ===
|
|
8355
|
+
if (node.type === import_utils54.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
8176
8356
|
const inner = refKey(node.object);
|
|
8177
|
-
if (inner === null || node.property.type !==
|
|
8357
|
+
if (inner === null || node.property.type !== import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8178
8358
|
return null;
|
|
8179
8359
|
}
|
|
8180
8360
|
return `${inner}.${node.property.name}`;
|
|
@@ -8182,7 +8362,7 @@ function refKey(node) {
|
|
|
8182
8362
|
return null;
|
|
8183
8363
|
}
|
|
8184
8364
|
function strLiteral(node) {
|
|
8185
|
-
if (node.type ===
|
|
8365
|
+
if (node.type === import_utils54.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
8186
8366
|
return node.value;
|
|
8187
8367
|
}
|
|
8188
8368
|
return null;
|
|
@@ -8223,7 +8403,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8223
8403
|
);
|
|
8224
8404
|
let services;
|
|
8225
8405
|
try {
|
|
8226
|
-
services =
|
|
8406
|
+
services = import_utils54.ESLintUtils.getParserServices(context);
|
|
8227
8407
|
} catch {
|
|
8228
8408
|
services = null;
|
|
8229
8409
|
}
|
|
@@ -8335,7 +8515,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8335
8515
|
containersWithUnion.add(container);
|
|
8336
8516
|
return;
|
|
8337
8517
|
}
|
|
8338
|
-
if (typeNode?.type !==
|
|
8518
|
+
if (typeNode?.type !== import_utils54.AST_NODE_TYPES.TSStringKeyword) {
|
|
8339
8519
|
return;
|
|
8340
8520
|
}
|
|
8341
8521
|
const name = keyName(key);
|
|
@@ -8423,10 +8603,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8423
8603
|
}
|
|
8424
8604
|
};
|
|
8425
8605
|
function refKeyText(node) {
|
|
8426
|
-
if (node.type ===
|
|
8606
|
+
if (node.type === import_utils54.AST_NODE_TYPES.BinaryExpression) {
|
|
8427
8607
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8428
8608
|
}
|
|
8429
|
-
if (node.type ===
|
|
8609
|
+
if (node.type === import_utils54.AST_NODE_TYPES.SwitchStatement) {
|
|
8430
8610
|
return refKey(node.discriminant) ?? "value";
|
|
8431
8611
|
}
|
|
8432
8612
|
return "value";
|
|
@@ -8435,7 +8615,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8435
8615
|
});
|
|
8436
8616
|
|
|
8437
8617
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8438
|
-
var
|
|
8618
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8439
8619
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8440
8620
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8441
8621
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8444,11 +8624,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8444
8624
|
var MIN_RUN_LENGTH = 2;
|
|
8445
8625
|
function literalText(node, getText) {
|
|
8446
8626
|
switch (node.type) {
|
|
8447
|
-
case
|
|
8627
|
+
case import_utils55.AST_NODE_TYPES.Literal:
|
|
8448
8628
|
return "regex" in node ? null : getText(node);
|
|
8449
|
-
case
|
|
8629
|
+
case import_utils55.AST_NODE_TYPES.TemplateLiteral:
|
|
8450
8630
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8451
|
-
case
|
|
8631
|
+
case import_utils55.AST_NODE_TYPES.UnaryExpression:
|
|
8452
8632
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8453
8633
|
default:
|
|
8454
8634
|
return null;
|
|
@@ -8456,15 +8636,15 @@ function literalText(node, getText) {
|
|
|
8456
8636
|
}
|
|
8457
8637
|
function isPureReceiver(node) {
|
|
8458
8638
|
switch (node.type) {
|
|
8459
|
-
case
|
|
8460
|
-
case
|
|
8639
|
+
case import_utils55.AST_NODE_TYPES.Identifier:
|
|
8640
|
+
case import_utils55.AST_NODE_TYPES.ThisExpression:
|
|
8461
8641
|
return true;
|
|
8462
|
-
case
|
|
8642
|
+
case import_utils55.AST_NODE_TYPES.MemberExpression:
|
|
8463
8643
|
if (node.optional) {
|
|
8464
8644
|
return false;
|
|
8465
8645
|
}
|
|
8466
8646
|
if (node.computed) {
|
|
8467
|
-
return node.property.type ===
|
|
8647
|
+
return node.property.type === import_utils55.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8468
8648
|
}
|
|
8469
8649
|
return isPureReceiver(node.object);
|
|
8470
8650
|
default:
|
|
@@ -8472,7 +8652,7 @@ function isPureReceiver(node) {
|
|
|
8472
8652
|
}
|
|
8473
8653
|
}
|
|
8474
8654
|
function literalIndex(node) {
|
|
8475
|
-
if (node.type !==
|
|
8655
|
+
if (node.type !== import_utils55.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8476
8656
|
return null;
|
|
8477
8657
|
}
|
|
8478
8658
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8498,24 +8678,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8498
8678
|
}
|
|
8499
8679
|
const { sourceCode } = context;
|
|
8500
8680
|
function parseAssertion(statement) {
|
|
8501
|
-
if (statement.type !==
|
|
8681
|
+
if (statement.type !== import_utils55.AST_NODE_TYPES.ExpressionStatement) {
|
|
8502
8682
|
return null;
|
|
8503
8683
|
}
|
|
8504
8684
|
const call = statement.expression;
|
|
8505
|
-
if (call.type !==
|
|
8685
|
+
if (call.type !== import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
8506
8686
|
return null;
|
|
8507
8687
|
}
|
|
8508
8688
|
const callee = call.callee;
|
|
8509
|
-
if (callee.type !==
|
|
8689
|
+
if (callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8510
8690
|
return null;
|
|
8511
8691
|
}
|
|
8512
8692
|
const matcher = callee.property.name;
|
|
8513
8693
|
const expectCall = callee.object;
|
|
8514
|
-
if (expectCall.type !==
|
|
8694
|
+
if (expectCall.type !== import_utils55.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils55.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8515
8695
|
return null;
|
|
8516
8696
|
}
|
|
8517
8697
|
const actual = expectCall.arguments[0];
|
|
8518
|
-
if (actual === void 0 || actual.type !==
|
|
8698
|
+
if (actual === void 0 || actual.type !== import_utils55.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8519
8699
|
return null;
|
|
8520
8700
|
}
|
|
8521
8701
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8529,7 +8709,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8529
8709
|
}
|
|
8530
8710
|
key = { kind: "index", index };
|
|
8531
8711
|
} else {
|
|
8532
|
-
if (actual.property.type !==
|
|
8712
|
+
if (actual.property.type !== import_utils55.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8533
8713
|
return null;
|
|
8534
8714
|
}
|
|
8535
8715
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8541,7 +8721,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8541
8721
|
return null;
|
|
8542
8722
|
}
|
|
8543
8723
|
const expected = call.arguments[0];
|
|
8544
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8724
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils55.AST_NODE_TYPES.SpreadElement) {
|
|
8545
8725
|
return null;
|
|
8546
8726
|
}
|
|
8547
8727
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8656,7 +8836,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8656
8836
|
});
|
|
8657
8837
|
|
|
8658
8838
|
// src/rules/prefer-zod-enum.ts
|
|
8659
|
-
var
|
|
8839
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8660
8840
|
var prefer_zod_enum_default = createRule({
|
|
8661
8841
|
name: "prefer-zod-enum",
|
|
8662
8842
|
meta: {
|
|
@@ -8676,25 +8856,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
8676
8856
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8677
8857
|
function enumValues(node) {
|
|
8678
8858
|
const callee = node.callee;
|
|
8679
|
-
if (callee.type !==
|
|
8859
|
+
if (callee.type !== import_utils56.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils56.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils56.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8680
8860
|
return null;
|
|
8681
8861
|
}
|
|
8682
8862
|
const argument = node.arguments[0];
|
|
8683
|
-
if (argument === void 0 || argument.type !==
|
|
8863
|
+
if (argument === void 0 || argument.type !== import_utils56.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
8684
8864
|
return null;
|
|
8685
8865
|
}
|
|
8686
8866
|
const values = [];
|
|
8687
8867
|
let canFix = true;
|
|
8688
8868
|
for (const element of argument.elements) {
|
|
8689
|
-
if (element?.type ===
|
|
8869
|
+
if (element?.type === import_utils56.AST_NODE_TYPES.SpreadElement) {
|
|
8690
8870
|
canFix = false;
|
|
8691
8871
|
continue;
|
|
8692
8872
|
}
|
|
8693
|
-
if (element === null || element.type !==
|
|
8873
|
+
if (element === null || element.type !== import_utils56.AST_NODE_TYPES.CallExpression || element.callee.type !== import_utils56.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils56.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils56.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
8694
8874
|
return null;
|
|
8695
8875
|
}
|
|
8696
8876
|
const value = element.arguments[0];
|
|
8697
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
8877
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== import_utils56.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
8698
8878
|
canFix = false;
|
|
8699
8879
|
continue;
|
|
8700
8880
|
}
|
|
@@ -8704,11 +8884,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
8704
8884
|
}
|
|
8705
8885
|
function buildFix(node, values) {
|
|
8706
8886
|
const argument = node.arguments[0];
|
|
8707
|
-
if (argument === void 0 || argument.type !==
|
|
8887
|
+
if (argument === void 0 || argument.type !== import_utils56.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8708
8888
|
return void 0;
|
|
8709
8889
|
}
|
|
8710
8890
|
const callee = node.callee;
|
|
8711
|
-
if (callee.type !==
|
|
8891
|
+
if (callee.type !== import_utils56.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8712
8892
|
return void 0;
|
|
8713
8893
|
}
|
|
8714
8894
|
return (fixer) => [
|
|
@@ -8725,7 +8905,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8725
8905
|
return;
|
|
8726
8906
|
}
|
|
8727
8907
|
for (const specifier of node.specifiers) {
|
|
8728
|
-
if (specifier.type ===
|
|
8908
|
+
if (specifier.type === import_utils56.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils56.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils56.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils56.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8729
8909
|
zodNamespaces.add(specifier.local.name);
|
|
8730
8910
|
}
|
|
8731
8911
|
}
|
|
@@ -8747,7 +8927,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8747
8927
|
});
|
|
8748
8928
|
|
|
8749
8929
|
// src/rules/prefer-zod-infer.ts
|
|
8750
|
-
var
|
|
8930
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8751
8931
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8752
8932
|
"describe",
|
|
8753
8933
|
"refine",
|
|
@@ -8784,44 +8964,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8784
8964
|
"Schema"
|
|
8785
8965
|
]);
|
|
8786
8966
|
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: [
|
|
8967
|
+
string: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8968
|
+
email: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8969
|
+
url: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8970
|
+
uuid: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8971
|
+
ulid: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8972
|
+
cuid: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8973
|
+
cuid2: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8974
|
+
nanoid: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8975
|
+
iso: [import_utils57.AST_NODE_TYPES.TSStringKeyword],
|
|
8976
|
+
number: [import_utils57.AST_NODE_TYPES.TSNumberKeyword],
|
|
8977
|
+
int: [import_utils57.AST_NODE_TYPES.TSNumberKeyword],
|
|
8978
|
+
float32: [import_utils57.AST_NODE_TYPES.TSNumberKeyword],
|
|
8979
|
+
float64: [import_utils57.AST_NODE_TYPES.TSNumberKeyword],
|
|
8980
|
+
boolean: [import_utils57.AST_NODE_TYPES.TSBooleanKeyword],
|
|
8981
|
+
bigint: [import_utils57.AST_NODE_TYPES.TSBigIntKeyword],
|
|
8982
|
+
symbol: [import_utils57.AST_NODE_TYPES.TSSymbolKeyword],
|
|
8983
|
+
any: [import_utils57.AST_NODE_TYPES.TSAnyKeyword],
|
|
8984
|
+
unknown: [import_utils57.AST_NODE_TYPES.TSUnknownKeyword],
|
|
8985
|
+
never: [import_utils57.AST_NODE_TYPES.TSNeverKeyword],
|
|
8986
|
+
void: [import_utils57.AST_NODE_TYPES.TSVoidKeyword],
|
|
8987
|
+
null: [import_utils57.AST_NODE_TYPES.TSNullKeyword],
|
|
8988
|
+
undefined: [import_utils57.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
8989
|
+
literal: [import_utils57.AST_NODE_TYPES.TSLiteralType],
|
|
8990
|
+
date: [import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
8991
|
+
array: [import_utils57.AST_NODE_TYPES.TSArrayType, import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
8992
|
+
tuple: [import_utils57.AST_NODE_TYPES.TSTupleType],
|
|
8993
|
+
object: [import_utils57.AST_NODE_TYPES.TSTypeLiteral, import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
8994
|
+
strictObject: [import_utils57.AST_NODE_TYPES.TSTypeLiteral, import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
8995
|
+
looseObject: [import_utils57.AST_NODE_TYPES.TSTypeLiteral, import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
8996
|
+
record: [import_utils57.AST_NODE_TYPES.TSTypeReference, import_utils57.AST_NODE_TYPES.TSTypeLiteral],
|
|
8997
|
+
map: [import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
8998
|
+
set: [import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
8999
|
+
promise: [import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
9000
|
+
enum: [import_utils57.AST_NODE_TYPES.TSUnionType, import_utils57.AST_NODE_TYPES.TSTypeReference, import_utils57.AST_NODE_TYPES.TSLiteralType],
|
|
9001
|
+
nativeEnum: [import_utils57.AST_NODE_TYPES.TSUnionType, import_utils57.AST_NODE_TYPES.TSTypeReference, import_utils57.AST_NODE_TYPES.TSLiteralType],
|
|
9002
|
+
union: [import_utils57.AST_NODE_TYPES.TSUnionType, import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
9003
|
+
discriminatedUnion: [import_utils57.AST_NODE_TYPES.TSUnionType, import_utils57.AST_NODE_TYPES.TSTypeReference],
|
|
9004
|
+
intersection: [import_utils57.AST_NODE_TYPES.TSIntersectionType, import_utils57.AST_NODE_TYPES.TSTypeReference]
|
|
8825
9005
|
};
|
|
8826
9006
|
function normalizeSchemaName(name) {
|
|
8827
9007
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8830,20 +9010,20 @@ function normalizeTypeName(name) {
|
|
|
8830
9010
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8831
9011
|
}
|
|
8832
9012
|
function unwrapNullish(annotation) {
|
|
8833
|
-
if (annotation.type !==
|
|
9013
|
+
if (annotation.type !== import_utils57.AST_NODE_TYPES.TSUnionType) {
|
|
8834
9014
|
return {
|
|
8835
9015
|
core: annotation,
|
|
8836
|
-
nullable: annotation.type ===
|
|
9016
|
+
nullable: annotation.type === import_utils57.AST_NODE_TYPES.TSNullKeyword
|
|
8837
9017
|
};
|
|
8838
9018
|
}
|
|
8839
9019
|
const rest = [];
|
|
8840
9020
|
let nullable = false;
|
|
8841
9021
|
for (const member of annotation.types) {
|
|
8842
|
-
if (member.type ===
|
|
9022
|
+
if (member.type === import_utils57.AST_NODE_TYPES.TSNullKeyword) {
|
|
8843
9023
|
nullable = true;
|
|
8844
9024
|
continue;
|
|
8845
9025
|
}
|
|
8846
|
-
if (member.type ===
|
|
9026
|
+
if (member.type === import_utils57.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
8847
9027
|
continue;
|
|
8848
9028
|
}
|
|
8849
9029
|
rest.push(member);
|
|
@@ -8908,14 +9088,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8908
9088
|
function zodCallChain(node) {
|
|
8909
9089
|
const chain = [];
|
|
8910
9090
|
let current = node;
|
|
8911
|
-
while (current.type ===
|
|
9091
|
+
while (current.type === import_utils57.AST_NODE_TYPES.CallExpression) {
|
|
8912
9092
|
const callee = current.callee;
|
|
8913
|
-
if (callee.type !==
|
|
9093
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8914
9094
|
return null;
|
|
8915
9095
|
}
|
|
8916
9096
|
chain.push(current);
|
|
8917
9097
|
const receiver = callee.object;
|
|
8918
|
-
if (receiver.type ===
|
|
9098
|
+
if (receiver.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8919
9099
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
8920
9100
|
}
|
|
8921
9101
|
current = receiver;
|
|
@@ -8924,19 +9104,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
8924
9104
|
}
|
|
8925
9105
|
function methodName(call) {
|
|
8926
9106
|
const callee = call.callee;
|
|
8927
|
-
return callee.type ===
|
|
9107
|
+
return callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils57.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
8928
9108
|
}
|
|
8929
9109
|
function schemaField(node) {
|
|
8930
9110
|
const modifiers = [];
|
|
8931
9111
|
let current = node;
|
|
8932
9112
|
let leaf = null;
|
|
8933
|
-
while (current.type ===
|
|
9113
|
+
while (current.type === import_utils57.AST_NODE_TYPES.CallExpression) {
|
|
8934
9114
|
const callee = current.callee;
|
|
8935
|
-
if (callee.type !==
|
|
9115
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8936
9116
|
break;
|
|
8937
9117
|
}
|
|
8938
9118
|
const receiver = callee.object;
|
|
8939
|
-
if (receiver.type ===
|
|
9119
|
+
if (receiver.type === import_utils57.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
8940
9120
|
leaf = callee.property.name;
|
|
8941
9121
|
break;
|
|
8942
9122
|
}
|
|
@@ -8967,16 +9147,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8967
9147
|
return null;
|
|
8968
9148
|
}
|
|
8969
9149
|
const shape = base.arguments[0];
|
|
8970
|
-
if (shape === void 0 || shape.type !==
|
|
9150
|
+
if (shape === void 0 || shape.type !== import_utils57.AST_NODE_TYPES.ObjectExpression) {
|
|
8971
9151
|
return null;
|
|
8972
9152
|
}
|
|
8973
9153
|
const fields = /* @__PURE__ */ new Map();
|
|
8974
9154
|
for (const property of shape.properties) {
|
|
8975
|
-
if (property.type !==
|
|
9155
|
+
if (property.type !== import_utils57.AST_NODE_TYPES.Property || property.computed) {
|
|
8976
9156
|
return null;
|
|
8977
9157
|
}
|
|
8978
9158
|
const { key } = property;
|
|
8979
|
-
const name = key.type ===
|
|
9159
|
+
const name = key.type === import_utils57.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils57.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8980
9160
|
if (name === null) {
|
|
8981
9161
|
return null;
|
|
8982
9162
|
}
|
|
@@ -8987,11 +9167,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8987
9167
|
function typeMembers(members) {
|
|
8988
9168
|
const result = /* @__PURE__ */ new Map();
|
|
8989
9169
|
for (const member of members) {
|
|
8990
|
-
if (member.type !==
|
|
9170
|
+
if (member.type !== import_utils57.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
8991
9171
|
return null;
|
|
8992
9172
|
}
|
|
8993
9173
|
const { key } = member;
|
|
8994
|
-
const name = key.type ===
|
|
9174
|
+
const name = key.type === import_utils57.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils57.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8995
9175
|
if (name === null) {
|
|
8996
9176
|
return null;
|
|
8997
9177
|
}
|
|
@@ -9005,8 +9185,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9005
9185
|
return result.size === 0 ? null : result;
|
|
9006
9186
|
}
|
|
9007
9187
|
function collectConstrainedNames(node) {
|
|
9008
|
-
if (node.type ===
|
|
9009
|
-
if (node.typeName.type ===
|
|
9188
|
+
if (node.type === import_utils57.AST_NODE_TYPES.TSTypeReference) {
|
|
9189
|
+
if (node.typeName.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
9010
9190
|
constrainedTypeNames.add(node.typeName.name);
|
|
9011
9191
|
}
|
|
9012
9192
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9014,11 +9194,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9014
9194
|
}
|
|
9015
9195
|
return;
|
|
9016
9196
|
}
|
|
9017
|
-
if (node.type ===
|
|
9197
|
+
if (node.type === import_utils57.AST_NODE_TYPES.TSArrayType) {
|
|
9018
9198
|
collectConstrainedNames(node.elementType);
|
|
9019
9199
|
return;
|
|
9020
9200
|
}
|
|
9021
|
-
if (node.type ===
|
|
9201
|
+
if (node.type === import_utils57.AST_NODE_TYPES.TSUnionType || node.type === import_utils57.AST_NODE_TYPES.TSIntersectionType) {
|
|
9022
9202
|
for (const member of node.types) {
|
|
9023
9203
|
collectConstrainedNames(member);
|
|
9024
9204
|
}
|
|
@@ -9062,13 +9242,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9062
9242
|
return;
|
|
9063
9243
|
}
|
|
9064
9244
|
for (const specifier of node.specifiers) {
|
|
9065
|
-
if (specifier.type ===
|
|
9245
|
+
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") {
|
|
9066
9246
|
zodNamespaces.add(specifier.local.name);
|
|
9067
9247
|
}
|
|
9068
9248
|
}
|
|
9069
9249
|
},
|
|
9070
9250
|
VariableDeclarator(node) {
|
|
9071
|
-
if (node.id.type !==
|
|
9251
|
+
if (node.id.type !== import_utils57.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
9072
9252
|
return;
|
|
9073
9253
|
}
|
|
9074
9254
|
const fields = schemaFields(node.init);
|
|
@@ -9078,14 +9258,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9078
9258
|
},
|
|
9079
9259
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9080
9260
|
"MemberExpression[computed=false]"(node) {
|
|
9081
|
-
if (node.object.type ===
|
|
9261
|
+
if (node.object.type === import_utils57.AST_NODE_TYPES.Identifier && node.property.type === import_utils57.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9082
9262
|
reshapedSchemaNames.add(node.object.name);
|
|
9083
9263
|
}
|
|
9084
9264
|
},
|
|
9085
9265
|
/** Records every type argument carried by a Zod constraint. */
|
|
9086
9266
|
TSTypeReference(node) {
|
|
9087
9267
|
const { typeName } = node;
|
|
9088
|
-
const referenced = typeName.type ===
|
|
9268
|
+
const referenced = typeName.type === import_utils57.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils57.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils57.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
9089
9269
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9090
9270
|
return;
|
|
9091
9271
|
}
|
|
@@ -9103,7 +9283,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9103
9283
|
}
|
|
9104
9284
|
},
|
|
9105
9285
|
TSTypeAliasDeclaration(node) {
|
|
9106
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9286
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils57.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9107
9287
|
return;
|
|
9108
9288
|
}
|
|
9109
9289
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9148,10 +9328,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9148
9328
|
});
|
|
9149
9329
|
|
|
9150
9330
|
// src/rules/require-assert-never.ts
|
|
9151
|
-
var
|
|
9331
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
9152
9332
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9153
|
-
if (statement.type ===
|
|
9154
|
-
if (statement.type ===
|
|
9333
|
+
if (statement.type === import_utils58.AST_NODE_TYPES.EmptyStatement) return false;
|
|
9334
|
+
if (statement.type === import_utils58.AST_NODE_TYPES.BlockStatement) {
|
|
9155
9335
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9156
9336
|
}
|
|
9157
9337
|
return true;
|
|
@@ -9167,7 +9347,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9167
9347
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9168
9348
|
}
|
|
9169
9349
|
const only = defaultCase.consequent[0];
|
|
9170
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9350
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils58.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
9171
9351
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9172
9352
|
}
|
|
9173
9353
|
return false;
|
|
@@ -9207,7 +9387,7 @@ var require_assert_never_default = createRule({
|
|
|
9207
9387
|
});
|
|
9208
9388
|
|
|
9209
9389
|
// src/rules/require-fetch-timeout.ts
|
|
9210
|
-
var
|
|
9390
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
9211
9391
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9212
9392
|
"globalThis",
|
|
9213
9393
|
"window",
|
|
@@ -9223,14 +9403,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9223
9403
|
return false;
|
|
9224
9404
|
}
|
|
9225
9405
|
function initProvablyLacksSignal(init) {
|
|
9226
|
-
if (init.type !==
|
|
9406
|
+
if (init.type !== import_utils59.AST_NODE_TYPES.ObjectExpression) {
|
|
9227
9407
|
return false;
|
|
9228
9408
|
}
|
|
9229
9409
|
for (const prop of init.properties) {
|
|
9230
|
-
if (prop.type ===
|
|
9410
|
+
if (prop.type === import_utils59.AST_NODE_TYPES.SpreadElement) {
|
|
9231
9411
|
return false;
|
|
9232
9412
|
}
|
|
9233
|
-
if (prop.key.type ===
|
|
9413
|
+
if (prop.key.type === import_utils59.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils59.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
9234
9414
|
return false;
|
|
9235
9415
|
}
|
|
9236
9416
|
if (prop.computed) {
|
|
@@ -9240,7 +9420,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9240
9420
|
return true;
|
|
9241
9421
|
}
|
|
9242
9422
|
function isStringish(node) {
|
|
9243
|
-
return node.type ===
|
|
9423
|
+
return node.type === import_utils59.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils59.AST_NODE_TYPES.TemplateLiteral;
|
|
9244
9424
|
}
|
|
9245
9425
|
var require_fetch_timeout_default = createRule({
|
|
9246
9426
|
name: "require-fetch-timeout",
|
|
@@ -9277,14 +9457,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9277
9457
|
}
|
|
9278
9458
|
function resolvesToGlobal(identifier) {
|
|
9279
9459
|
const scope = context.sourceCode.getScope(identifier);
|
|
9280
|
-
const variable =
|
|
9460
|
+
const variable = import_utils59.ASTUtils.findVariable(scope, identifier.name);
|
|
9281
9461
|
return variable === null || variable.defs.length === 0;
|
|
9282
9462
|
}
|
|
9283
9463
|
function isGlobalFetchCall2(callee) {
|
|
9284
|
-
if (callee.type ===
|
|
9464
|
+
if (callee.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9285
9465
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9286
9466
|
}
|
|
9287
|
-
return callee.type ===
|
|
9467
|
+
return callee.type === import_utils59.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils59.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils59.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9288
9468
|
}
|
|
9289
9469
|
return {
|
|
9290
9470
|
CallExpression(node) {
|
|
@@ -9304,7 +9484,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9304
9484
|
});
|
|
9305
9485
|
|
|
9306
9486
|
// src/rules/require-interface-for-injected-service.ts
|
|
9307
|
-
var
|
|
9487
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9308
9488
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9309
9489
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9310
9490
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9312,20 +9492,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9312
9492
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9313
9493
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9314
9494
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9315
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9316
|
-
var qualifiedName = (name) => name.type ===
|
|
9495
|
+
var isExportedClass = (node) => node.parent.type === import_utils60.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils60.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
9496
|
+
var qualifiedName = (name) => name.type === import_utils60.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils60.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9317
9497
|
var readTypeReference = (annotation) => {
|
|
9318
|
-
if (annotation === void 0 || annotation.type !==
|
|
9498
|
+
if (annotation === void 0 || annotation.type !== import_utils60.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9319
9499
|
const { typeName } = annotation;
|
|
9320
|
-
const rightmost = typeName.type ===
|
|
9500
|
+
const rightmost = typeName.type === import_utils60.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils60.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
9321
9501
|
if (rightmost === null) return null;
|
|
9322
9502
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9323
9503
|
};
|
|
9324
9504
|
var namedParameterCollaborator = (annotated) => {
|
|
9325
9505
|
let target = annotated;
|
|
9326
|
-
if (target.type ===
|
|
9327
|
-
if (target.type ===
|
|
9328
|
-
if (target.type !==
|
|
9506
|
+
if (target.type === import_utils60.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
9507
|
+
if (target.type === import_utils60.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9508
|
+
if (target.type !== import_utils60.AST_NODE_TYPES.Identifier) return null;
|
|
9329
9509
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9330
9510
|
if (reference === null) return null;
|
|
9331
9511
|
return { name: target.name, ...reference };
|
|
@@ -9333,8 +9513,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9333
9513
|
var propertySignatureTypes = (members) => {
|
|
9334
9514
|
const types = /* @__PURE__ */ new Map();
|
|
9335
9515
|
for (const member of members) {
|
|
9336
|
-
if (member.type !==
|
|
9337
|
-
if (member.computed || member.key.type !==
|
|
9516
|
+
if (member.type !== import_utils60.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
9517
|
+
if (member.computed || member.key.type !== import_utils60.AST_NODE_TYPES.Identifier) continue;
|
|
9338
9518
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9339
9519
|
if (reference === null) continue;
|
|
9340
9520
|
types.set(member.key.name, reference);
|
|
@@ -9345,18 +9525,18 @@ var fileTypeIndex = (program) => {
|
|
|
9345
9525
|
const objects = /* @__PURE__ */ new Map();
|
|
9346
9526
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9347
9527
|
for (const statement of program.body) {
|
|
9348
|
-
const declaration = statement.type ===
|
|
9349
|
-
if (declaration?.type ===
|
|
9528
|
+
const declaration = statement.type === import_utils60.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9529
|
+
if (declaration?.type === import_utils60.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
9350
9530
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9351
9531
|
continue;
|
|
9352
9532
|
}
|
|
9353
|
-
if (declaration?.type !==
|
|
9533
|
+
if (declaration?.type !== import_utils60.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9354
9534
|
const aliased = declaration.typeAnnotation;
|
|
9355
|
-
if (aliased.type ===
|
|
9535
|
+
if (aliased.type === import_utils60.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils60.AST_NODE_TYPES.TSConstructorType) {
|
|
9356
9536
|
functionAliases.add(declaration.id.name);
|
|
9357
9537
|
continue;
|
|
9358
9538
|
}
|
|
9359
|
-
const literals = aliased.type ===
|
|
9539
|
+
const literals = aliased.type === import_utils60.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils60.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils60.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
9360
9540
|
if (literals.length === 0) continue;
|
|
9361
9541
|
const merged = /* @__PURE__ */ new Map();
|
|
9362
9542
|
for (const literal of literals) {
|
|
@@ -9369,10 +9549,10 @@ var fileTypeIndex = (program) => {
|
|
|
9369
9549
|
return { objects, functionAliases };
|
|
9370
9550
|
};
|
|
9371
9551
|
var bagMemberTypes = (annotation, declared) => {
|
|
9372
|
-
if (annotation.type ===
|
|
9552
|
+
if (annotation.type === import_utils60.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9373
9553
|
return propertySignatureTypes(annotation.members);
|
|
9374
9554
|
}
|
|
9375
|
-
if (annotation.type !==
|
|
9555
|
+
if (annotation.type !== import_utils60.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9376
9556
|
return null;
|
|
9377
9557
|
}
|
|
9378
9558
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9384,11 +9564,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9384
9564
|
if (members === null) return [];
|
|
9385
9565
|
const collaborators = [];
|
|
9386
9566
|
for (const property of pattern.properties) {
|
|
9387
|
-
if (property.type !==
|
|
9388
|
-
if (property.key.type !==
|
|
9567
|
+
if (property.type !== import_utils60.AST_NODE_TYPES.Property || property.computed) continue;
|
|
9568
|
+
if (property.key.type !== import_utils60.AST_NODE_TYPES.Identifier) continue;
|
|
9389
9569
|
const key = property.key.name;
|
|
9390
|
-
const bound = property.value.type ===
|
|
9391
|
-
if (bound.type !==
|
|
9570
|
+
const bound = property.value.type === import_utils60.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
9571
|
+
if (bound.type !== import_utils60.AST_NODE_TYPES.Identifier) continue;
|
|
9392
9572
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9393
9573
|
const reference = members.get(key);
|
|
9394
9574
|
if (reference === void 0) continue;
|
|
@@ -9398,8 +9578,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9398
9578
|
};
|
|
9399
9579
|
var parameterCollaborators = (parameter, declared) => {
|
|
9400
9580
|
let target = parameter;
|
|
9401
|
-
if (target.type ===
|
|
9402
|
-
if (target.type ===
|
|
9581
|
+
if (target.type === import_utils60.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9582
|
+
if (target.type === import_utils60.AST_NODE_TYPES.ObjectPattern) {
|
|
9403
9583
|
return objectPatternCollaborators(target, declared);
|
|
9404
9584
|
}
|
|
9405
9585
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9418,17 +9598,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9418
9598
|
let constructedFields = 0;
|
|
9419
9599
|
if (body2 !== null && body2 !== void 0) {
|
|
9420
9600
|
for (const statement of body2.body) {
|
|
9421
|
-
if (statement.type !==
|
|
9601
|
+
if (statement.type !== import_utils60.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9422
9602
|
const expression = statement.expression;
|
|
9423
|
-
if (expression.type !==
|
|
9603
|
+
if (expression.type !== import_utils60.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils60.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils60.AST_NODE_TYPES.ThisExpression) {
|
|
9424
9604
|
continue;
|
|
9425
9605
|
}
|
|
9426
9606
|
const source = expression.right;
|
|
9427
|
-
if (source.type ===
|
|
9607
|
+
if (source.type === import_utils60.AST_NODE_TYPES.NewExpression) {
|
|
9428
9608
|
constructedFields += 1;
|
|
9429
|
-
} else if (source.type ===
|
|
9609
|
+
} else if (source.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9430
9610
|
storedFrom.add(source.name);
|
|
9431
|
-
} else if (source.type ===
|
|
9611
|
+
} else if (source.type === import_utils60.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9432
9612
|
storedFrom.add(source.object.name);
|
|
9433
9613
|
}
|
|
9434
9614
|
}
|
|
@@ -9436,7 +9616,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9436
9616
|
const collaborators = [];
|
|
9437
9617
|
for (const parameter of ctor.value.params) {
|
|
9438
9618
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9439
|
-
const stored = parameter.type ===
|
|
9619
|
+
const stored = parameter.type === import_utils60.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9440
9620
|
if (!stored) continue;
|
|
9441
9621
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9442
9622
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9470,19 +9650,19 @@ var subtreeHas = (root, found) => {
|
|
|
9470
9650
|
return hit;
|
|
9471
9651
|
};
|
|
9472
9652
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9473
|
-
if (node.type ===
|
|
9653
|
+
if (node.type === import_utils60.AST_NODE_TYPES.CallExpression) {
|
|
9474
9654
|
const { callee } = node;
|
|
9475
|
-
if (callee.type ===
|
|
9476
|
-
return callee.type ===
|
|
9655
|
+
if (callee.type === import_utils60.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9656
|
+
return callee.type === import_utils60.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils60.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9477
9657
|
}
|
|
9478
|
-
return node.type ===
|
|
9658
|
+
return node.type === import_utils60.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils60.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9479
9659
|
});
|
|
9480
9660
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9481
9661
|
var fileInterfaceNames = (program) => {
|
|
9482
9662
|
const names = [];
|
|
9483
9663
|
for (const statement of program.body) {
|
|
9484
|
-
const declaration = statement.type ===
|
|
9485
|
-
if (declaration?.type ===
|
|
9664
|
+
const declaration = statement.type === import_utils60.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9665
|
+
if (declaration?.type === import_utils60.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9486
9666
|
}
|
|
9487
9667
|
return names;
|
|
9488
9668
|
};
|
|
@@ -9500,11 +9680,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9500
9680
|
var publicMethodNames = (body2) => {
|
|
9501
9681
|
const names = [];
|
|
9502
9682
|
for (const member of body2.body) {
|
|
9503
|
-
if (member.type !==
|
|
9683
|
+
if (member.type !== import_utils60.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9504
9684
|
if (member.kind !== "method" || member.static) continue;
|
|
9505
9685
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9506
|
-
if (member.key.type ===
|
|
9507
|
-
if (member.key.type ===
|
|
9686
|
+
if (member.key.type === import_utils60.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
9687
|
+
if (member.key.type === import_utils60.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
9508
9688
|
else names.push("\u2026");
|
|
9509
9689
|
}
|
|
9510
9690
|
return names;
|
|
@@ -9537,7 +9717,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9537
9717
|
if (node.implements.length > 0) return;
|
|
9538
9718
|
if (node.decorators.length > 0) return;
|
|
9539
9719
|
const ctor = node.body.body.find(
|
|
9540
|
-
(member) => member.type ===
|
|
9720
|
+
(member) => member.type === import_utils60.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
9541
9721
|
);
|
|
9542
9722
|
if (ctor === void 0) return;
|
|
9543
9723
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9566,18 +9746,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9566
9746
|
});
|
|
9567
9747
|
|
|
9568
9748
|
// src/rules/require-zod-form-validation.ts
|
|
9569
|
-
var
|
|
9749
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9570
9750
|
var looksLikeZodSchema = (node) => {
|
|
9571
9751
|
let current = node;
|
|
9572
9752
|
while (true) {
|
|
9573
|
-
if (current.type ===
|
|
9753
|
+
if (current.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9574
9754
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9575
9755
|
}
|
|
9576
|
-
if (current.type ===
|
|
9756
|
+
if (current.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9577
9757
|
current = current.callee;
|
|
9578
9758
|
continue;
|
|
9579
9759
|
}
|
|
9580
|
-
if (current.type ===
|
|
9760
|
+
if (current.type === import_utils61.AST_NODE_TYPES.MemberExpression) {
|
|
9581
9761
|
current = current.object;
|
|
9582
9762
|
continue;
|
|
9583
9763
|
}
|
|
@@ -9585,23 +9765,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9585
9765
|
}
|
|
9586
9766
|
};
|
|
9587
9767
|
var isZodParseCall = (node) => {
|
|
9588
|
-
if (node.type !==
|
|
9768
|
+
if (node.type !== import_utils61.AST_NODE_TYPES.CallExpression) return false;
|
|
9589
9769
|
const callee = node.callee;
|
|
9590
|
-
if (callee.type !==
|
|
9770
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression) return false;
|
|
9591
9771
|
if (callee.computed) return false;
|
|
9592
|
-
if (callee.property.type !==
|
|
9772
|
+
if (callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) return false;
|
|
9593
9773
|
const method = callee.property.name;
|
|
9594
9774
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9595
9775
|
return looksLikeZodSchema(callee.object);
|
|
9596
9776
|
};
|
|
9597
9777
|
var isFormDataMethodCall = (node) => {
|
|
9598
9778
|
let current = node;
|
|
9599
|
-
if (current.type ===
|
|
9779
|
+
if (current.type === import_utils61.AST_NODE_TYPES.AwaitExpression) {
|
|
9600
9780
|
current = current.argument;
|
|
9601
9781
|
}
|
|
9602
|
-
if (current.type !==
|
|
9782
|
+
if (current.type !== import_utils61.AST_NODE_TYPES.CallExpression) return false;
|
|
9603
9783
|
const callee = current.callee;
|
|
9604
|
-
return callee.type ===
|
|
9784
|
+
return callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
9605
9785
|
};
|
|
9606
9786
|
var require_zod_form_validation_default = createRule({
|
|
9607
9787
|
name: "require-zod-form-validation",
|
|
@@ -9621,14 +9801,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9621
9801
|
return {};
|
|
9622
9802
|
}
|
|
9623
9803
|
const isFormSourceIdentifier = (node) => {
|
|
9624
|
-
if (node.type !==
|
|
9804
|
+
if (node.type !== import_utils61.AST_NODE_TYPES.Identifier) return false;
|
|
9625
9805
|
if (/formdata/i.test(node.name)) return true;
|
|
9626
9806
|
let scope = context.sourceCode.getScope(node);
|
|
9627
9807
|
while (scope !== null) {
|
|
9628
9808
|
const variable = scope.set.get(node.name);
|
|
9629
9809
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9630
9810
|
const def = variable.defs[0];
|
|
9631
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
9811
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils61.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
9632
9812
|
return isFormDataMethodCall(def.node.init);
|
|
9633
9813
|
}
|
|
9634
9814
|
return false;
|
|
@@ -9639,8 +9819,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9639
9819
|
};
|
|
9640
9820
|
const isFormDataGetCall = (node) => {
|
|
9641
9821
|
const callee = node.callee;
|
|
9642
|
-
if (callee.type !==
|
|
9643
|
-
if (callee.property.type !==
|
|
9822
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression) return false;
|
|
9823
|
+
if (callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
9644
9824
|
return false;
|
|
9645
9825
|
}
|
|
9646
9826
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9655,11 +9835,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9655
9835
|
};
|
|
9656
9836
|
const isInstanceofNarrowing = (node) => {
|
|
9657
9837
|
const parent = node.parent;
|
|
9658
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9838
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils61.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils61.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9659
9839
|
};
|
|
9660
9840
|
const boundDeclarator = (node) => {
|
|
9661
9841
|
const parent = node.parent;
|
|
9662
|
-
if (parent.type ===
|
|
9842
|
+
if (parent.type === import_utils61.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9663
9843
|
return parent;
|
|
9664
9844
|
}
|
|
9665
9845
|
return null;
|
|
@@ -9687,7 +9867,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
9687
9867
|
});
|
|
9688
9868
|
|
|
9689
9869
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
9690
|
-
var
|
|
9870
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
9691
9871
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
9692
9872
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
9693
9873
|
var INSERT_GATE = /insert/i;
|
|
@@ -9718,7 +9898,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9718
9898
|
});
|
|
9719
9899
|
|
|
9720
9900
|
// src/rules/zod-naming-convention.ts
|
|
9721
|
-
var
|
|
9901
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
9722
9902
|
var CONVENTIONS = {
|
|
9723
9903
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9724
9904
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9743,15 +9923,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9743
9923
|
"registry",
|
|
9744
9924
|
"implement"
|
|
9745
9925
|
]);
|
|
9746
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
9926
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils63.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
9747
9927
|
var calleeChainStartsWithZ = (node) => {
|
|
9748
9928
|
let current = node;
|
|
9749
|
-
while (current.type ===
|
|
9929
|
+
while (current.type === import_utils63.AST_NODE_TYPES.MemberExpression) {
|
|
9750
9930
|
const receiver = current.object;
|
|
9751
|
-
if (receiver.type ===
|
|
9931
|
+
if (receiver.type === import_utils63.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
9752
9932
|
return true;
|
|
9753
9933
|
}
|
|
9754
|
-
if (receiver.type ===
|
|
9934
|
+
if (receiver.type === import_utils63.AST_NODE_TYPES.CallExpression) {
|
|
9755
9935
|
current = receiver.callee;
|
|
9756
9936
|
continue;
|
|
9757
9937
|
}
|
|
@@ -9796,13 +9976,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9796
9976
|
VariableDeclarator(node) {
|
|
9797
9977
|
const init = node.init;
|
|
9798
9978
|
if (init === null || init === void 0) return;
|
|
9799
|
-
if (init.type !==
|
|
9979
|
+
if (init.type !== import_utils63.AST_NODE_TYPES.CallExpression) return;
|
|
9800
9980
|
const callee = init.callee;
|
|
9801
|
-
if (callee.type !==
|
|
9981
|
+
if (callee.type !== import_utils63.AST_NODE_TYPES.MemberExpression) return;
|
|
9802
9982
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9803
9983
|
const terminal = terminalMethodName(callee);
|
|
9804
9984
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9805
|
-
if (node.id.type !==
|
|
9985
|
+
if (node.id.type !== import_utils63.AST_NODE_TYPES.Identifier) return;
|
|
9806
9986
|
if (test.test(node.id.name)) return;
|
|
9807
9987
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9808
9988
|
context.report({
|
|
@@ -9890,6 +10070,7 @@ var rules = {
|
|
|
9890
10070
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
9891
10071
|
"no-raw-env": no_raw_env_default,
|
|
9892
10072
|
"no-raw-fetch-outside-clients": no_raw_fetch_outside_clients_default,
|
|
10073
|
+
"no-restricted-library-load": no_restricted_library_load_default,
|
|
9893
10074
|
"no-repeated-string-literal": no_repeated_string_literal_default,
|
|
9894
10075
|
"no-restated-comment": no_restated_comment_default,
|
|
9895
10076
|
"no-restated-jsdoc": no_restated_jsdoc_default,
|
|
@@ -9914,6 +10095,7 @@ var rules = {
|
|
|
9914
10095
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
9915
10096
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
9916
10097
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
10098
|
+
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
9917
10099
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
9918
10100
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
9919
10101
|
"prefer-server-actions": prefer_server_actions_default,
|
|
@@ -9931,8 +10113,12 @@ var rules = {
|
|
|
9931
10113
|
};
|
|
9932
10114
|
var meta = {
|
|
9933
10115
|
name: "@sarj/eslint-plugin",
|
|
9934
|
-
version: "9.
|
|
10116
|
+
version: "9.8.0"
|
|
9935
10117
|
};
|
|
10118
|
+
var applicationOnlyRules = [
|
|
10119
|
+
"no-restricted-library-load",
|
|
10120
|
+
"prefer-native-random-uuid"
|
|
10121
|
+
];
|
|
9936
10122
|
var recommendedRules = {
|
|
9937
10123
|
"@sarj/enforce-file-structure": "warn",
|
|
9938
10124
|
"@sarj/no-async-callback-in-wait-for": "warn",
|
|
@@ -10069,6 +10255,7 @@ plugin.configs.strict = {
|
|
|
10069
10255
|
var index_default = plugin;
|
|
10070
10256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10071
10257
|
0 && (module.exports = {
|
|
10258
|
+
applicationOnlyRules,
|
|
10072
10259
|
recommendedRules,
|
|
10073
10260
|
renamedRules,
|
|
10074
10261
|
retiredRules,
|