@sarj/eslint-plugin 9.7.0 → 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 +39 -3
- package/dist/index.cjs +692 -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 +683 -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));
|
|
@@ -7165,9 +7259,10 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7165
7259
|
return {};
|
|
7166
7260
|
}
|
|
7167
7261
|
function checkOptionalProperty(node) {
|
|
7262
|
+
if (node.optional) return;
|
|
7168
7263
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7169
7264
|
if (annotation === void 0) return;
|
|
7170
|
-
if (annotation.type !==
|
|
7265
|
+
if (annotation.type !== import_utils49.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7171
7266
|
return;
|
|
7172
7267
|
}
|
|
7173
7268
|
context.report({
|
|
@@ -7180,7 +7275,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7180
7275
|
TSPropertySignature: checkOptionalProperty,
|
|
7181
7276
|
PropertyDefinition: checkOptionalProperty,
|
|
7182
7277
|
TSTypeAliasDeclaration(node) {
|
|
7183
|
-
if (node.typeAnnotation.type !==
|
|
7278
|
+
if (node.typeAnnotation.type !== import_utils49.AST_NODE_TYPES.TSUnionType) return;
|
|
7184
7279
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7185
7280
|
context.report({
|
|
7186
7281
|
node,
|
|
@@ -7192,14 +7287,100 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7192
7287
|
}
|
|
7193
7288
|
});
|
|
7194
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
|
+
|
|
7195
7376
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7196
|
-
var
|
|
7377
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7197
7378
|
var unwrap4 = (node) => {
|
|
7198
7379
|
let current = node;
|
|
7199
7380
|
while (current !== null && current !== void 0) {
|
|
7200
|
-
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) {
|
|
7201
7382
|
current = current.expression;
|
|
7202
|
-
} else if (current.type ===
|
|
7383
|
+
} else if (current.type === import_utils51.AST_NODE_TYPES.ChainExpression) {
|
|
7203
7384
|
current = current.expression;
|
|
7204
7385
|
} else {
|
|
7205
7386
|
break;
|
|
@@ -7214,23 +7395,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7214
7395
|
]);
|
|
7215
7396
|
var isSchemaParseReference = (node) => {
|
|
7216
7397
|
const inner = unwrap4(node);
|
|
7217
|
-
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");
|
|
7218
7399
|
};
|
|
7219
7400
|
var isRawPayloadSource = (node) => {
|
|
7220
7401
|
let current = unwrap4(node);
|
|
7221
7402
|
if (current === null) return false;
|
|
7222
|
-
if (current.type ===
|
|
7403
|
+
if (current.type === import_utils51.AST_NODE_TYPES.AwaitExpression) {
|
|
7223
7404
|
current = unwrap4(current.argument);
|
|
7224
7405
|
}
|
|
7225
|
-
if (current === null || current.type !==
|
|
7406
|
+
if (current === null || current.type !== import_utils51.AST_NODE_TYPES.CallExpression) {
|
|
7226
7407
|
return false;
|
|
7227
7408
|
}
|
|
7228
7409
|
const callee = unwrap4(current.callee);
|
|
7229
|
-
if (callee === null || callee.type !==
|
|
7410
|
+
if (callee === null || callee.type !== import_utils51.AST_NODE_TYPES.MemberExpression) {
|
|
7230
7411
|
return false;
|
|
7231
7412
|
}
|
|
7232
7413
|
const property = unwrap4(callee.property);
|
|
7233
|
-
if (property === null || property.type !==
|
|
7414
|
+
if (property === null || property.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7234
7415
|
return false;
|
|
7235
7416
|
}
|
|
7236
7417
|
if (property.name === "json") {
|
|
@@ -7240,16 +7421,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7240
7421
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7241
7422
|
}
|
|
7242
7423
|
const object = unwrap4(callee.object);
|
|
7243
|
-
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]);
|
|
7244
7425
|
};
|
|
7245
7426
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7246
7427
|
var isLocalFileRead = (node) => {
|
|
7247
7428
|
let found = false;
|
|
7248
7429
|
const visit = (current) => {
|
|
7249
7430
|
if (found || current === null || current === void 0) return;
|
|
7250
|
-
if (current.type ===
|
|
7431
|
+
if (current.type === import_utils51.AST_NODE_TYPES.CallExpression) {
|
|
7251
7432
|
const callee = unwrap4(current.callee);
|
|
7252
|
-
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;
|
|
7253
7434
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7254
7435
|
found = true;
|
|
7255
7436
|
return;
|
|
@@ -7271,15 +7452,15 @@ var isLocalFileRead = (node) => {
|
|
|
7271
7452
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7272
7453
|
var isInsideAssertion = (node) => {
|
|
7273
7454
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7274
|
-
if (current.type !==
|
|
7455
|
+
if (current.type !== import_utils51.AST_NODE_TYPES.CallExpression) continue;
|
|
7275
7456
|
let callee = current.callee;
|
|
7276
|
-
while (callee.type ===
|
|
7457
|
+
while (callee.type === import_utils51.AST_NODE_TYPES.MemberExpression) {
|
|
7277
7458
|
callee = callee.object;
|
|
7278
7459
|
}
|
|
7279
|
-
if (callee.type ===
|
|
7460
|
+
if (callee.type === import_utils51.AST_NODE_TYPES.CallExpression) {
|
|
7280
7461
|
callee = callee.callee;
|
|
7281
7462
|
}
|
|
7282
|
-
if (callee.type ===
|
|
7463
|
+
if (callee.type === import_utils51.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7283
7464
|
return true;
|
|
7284
7465
|
}
|
|
7285
7466
|
}
|
|
@@ -7298,39 +7479,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7298
7479
|
var isValidationRead = (node) => {
|
|
7299
7480
|
let current = node;
|
|
7300
7481
|
let parent = current.parent;
|
|
7301
|
-
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)) {
|
|
7302
7483
|
current = parent;
|
|
7303
7484
|
parent = parent.parent;
|
|
7304
7485
|
}
|
|
7305
7486
|
if (parent === null || parent === void 0) return false;
|
|
7306
|
-
if (parent.type ===
|
|
7487
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7307
7488
|
return true;
|
|
7308
7489
|
}
|
|
7309
|
-
if (parent.type !==
|
|
7490
|
+
if (parent.type !== import_utils51.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7310
7491
|
return false;
|
|
7311
7492
|
}
|
|
7312
7493
|
const callee = parent.callee;
|
|
7313
|
-
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") {
|
|
7314
7495
|
return parent.arguments.length === 1;
|
|
7315
7496
|
}
|
|
7316
|
-
return callee.type ===
|
|
7497
|
+
return callee.type === import_utils51.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7317
7498
|
};
|
|
7318
7499
|
var isGuardTestPosition = (node) => {
|
|
7319
7500
|
let current = node;
|
|
7320
7501
|
let parent = current.parent;
|
|
7321
7502
|
while (parent !== void 0 && parent !== null) {
|
|
7322
7503
|
switch (parent.type) {
|
|
7323
|
-
case
|
|
7324
|
-
case
|
|
7325
|
-
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:
|
|
7326
7507
|
current = parent;
|
|
7327
7508
|
parent = parent.parent;
|
|
7328
7509
|
continue;
|
|
7329
|
-
case
|
|
7330
|
-
case
|
|
7331
|
-
case
|
|
7332
|
-
case
|
|
7333
|
-
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:
|
|
7334
7515
|
return parent.test === current;
|
|
7335
7516
|
default:
|
|
7336
7517
|
return false;
|
|
@@ -7340,7 +7521,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7340
7521
|
};
|
|
7341
7522
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7342
7523
|
const unwrapped = unwrap4(node);
|
|
7343
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7524
|
+
if (unwrapped === null || unwrapped.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7344
7525
|
return false;
|
|
7345
7526
|
}
|
|
7346
7527
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7383,11 +7564,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7383
7564
|
return {
|
|
7384
7565
|
VariableDeclarator(node) {
|
|
7385
7566
|
const scope = context.sourceCode.getScope(node);
|
|
7386
|
-
if (node.id.type ===
|
|
7567
|
+
if (node.id.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7387
7568
|
trackInitializer(node);
|
|
7388
7569
|
return;
|
|
7389
7570
|
}
|
|
7390
|
-
if (node.id.type ===
|
|
7571
|
+
if (node.id.type === import_utils51.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils51.AST_NODE_TYPES.ArrayPattern) {
|
|
7391
7572
|
if (isRawPayloadSource(node.init)) {
|
|
7392
7573
|
if (!isFullyNarrowedPattern(node)) {
|
|
7393
7574
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7401,7 +7582,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7401
7582
|
},
|
|
7402
7583
|
AssignmentExpression(node) {
|
|
7403
7584
|
const scope = context.sourceCode.getScope(node);
|
|
7404
|
-
if (node.left.type ===
|
|
7585
|
+
if (node.left.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7405
7586
|
const variable = findVariable2(scope, node.left.name);
|
|
7406
7587
|
if (variable === null) return;
|
|
7407
7588
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7411,7 +7592,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7411
7592
|
}
|
|
7412
7593
|
return;
|
|
7413
7594
|
}
|
|
7414
|
-
if (node.left.type ===
|
|
7595
|
+
if (node.left.type === import_utils51.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils51.AST_NODE_TYPES.ArrayPattern) {
|
|
7415
7596
|
if (isRawPayloadSource(node.right)) {
|
|
7416
7597
|
context.report({
|
|
7417
7598
|
node: node.left,
|
|
@@ -7428,15 +7609,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7428
7609
|
}
|
|
7429
7610
|
},
|
|
7430
7611
|
CallExpression(node) {
|
|
7431
|
-
if (node.callee.type !==
|
|
7612
|
+
if (node.callee.type !== import_utils51.AST_NODE_TYPES.Identifier) return;
|
|
7432
7613
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7433
7614
|
return;
|
|
7434
7615
|
}
|
|
7435
7616
|
const scope = context.sourceCode.getScope(node);
|
|
7436
7617
|
for (const arg of node.arguments) {
|
|
7437
|
-
if (arg.type ===
|
|
7618
|
+
if (arg.type === import_utils51.AST_NODE_TYPES.SpreadElement) continue;
|
|
7438
7619
|
const unwrapped = unwrap4(arg);
|
|
7439
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7620
|
+
if (unwrapped === null || unwrapped.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7440
7621
|
continue;
|
|
7441
7622
|
}
|
|
7442
7623
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7450,13 +7631,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7450
7631
|
const obj = unwrap4(node.object);
|
|
7451
7632
|
if (isRawPayloadSource(obj)) {
|
|
7452
7633
|
const parent = node.parent;
|
|
7453
|
-
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))) {
|
|
7454
7635
|
return;
|
|
7455
7636
|
}
|
|
7456
7637
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7457
7638
|
return;
|
|
7458
7639
|
}
|
|
7459
|
-
if (obj !== null && obj.type ===
|
|
7640
|
+
if (obj !== null && obj.type === import_utils51.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7460
7641
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7461
7642
|
const variable = findVariable2(scope, obj.name);
|
|
7462
7643
|
if (variable !== null) {
|
|
@@ -7469,7 +7650,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7469
7650
|
});
|
|
7470
7651
|
|
|
7471
7652
|
// src/rules/prefer-semantic-colors.ts
|
|
7472
|
-
var
|
|
7653
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7473
7654
|
var import_fs = require("fs");
|
|
7474
7655
|
var import_path = require("path");
|
|
7475
7656
|
|
|
@@ -7569,8 +7750,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7569
7750
|
]);
|
|
7570
7751
|
function jsxElementName(node) {
|
|
7571
7752
|
const name = node.openingElement.name;
|
|
7572
|
-
if (name.type ===
|
|
7573
|
-
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) {
|
|
7574
7755
|
return name.property.name;
|
|
7575
7756
|
}
|
|
7576
7757
|
return null;
|
|
@@ -7596,7 +7777,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7596
7777
|
var isInsideSvg = (node) => {
|
|
7597
7778
|
let current = node.parent;
|
|
7598
7779
|
while (current !== void 0 && current !== null) {
|
|
7599
|
-
if (current.type ===
|
|
7780
|
+
if (current.type === import_utils52.AST_NODE_TYPES.JSXElement) {
|
|
7600
7781
|
const name = jsxElementName(current);
|
|
7601
7782
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7602
7783
|
}
|
|
@@ -7607,7 +7788,7 @@ var isInsideSvg = (node) => {
|
|
|
7607
7788
|
var isInsideIconFactoryPath = (node) => {
|
|
7608
7789
|
let current = node.parent;
|
|
7609
7790
|
while (current !== void 0 && current !== null) {
|
|
7610
|
-
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") {
|
|
7611
7792
|
return true;
|
|
7612
7793
|
}
|
|
7613
7794
|
current = current.parent;
|
|
@@ -7744,12 +7925,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7744
7925
|
return root !== null && workspaceHasMarker(root);
|
|
7745
7926
|
};
|
|
7746
7927
|
var propName = (key) => {
|
|
7747
|
-
if (key.type ===
|
|
7748
|
-
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;
|
|
7749
7930
|
return null;
|
|
7750
7931
|
};
|
|
7751
7932
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7752
|
-
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) {
|
|
7753
7934
|
return false;
|
|
7754
7935
|
}
|
|
7755
7936
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -7801,27 +7982,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7801
7982
|
const checkClassNode = (node) => {
|
|
7802
7983
|
if (node === null) return;
|
|
7803
7984
|
switch (node.type) {
|
|
7804
|
-
case
|
|
7985
|
+
case import_utils52.AST_NODE_TYPES.Literal:
|
|
7805
7986
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7806
7987
|
break;
|
|
7807
|
-
case
|
|
7988
|
+
case import_utils52.AST_NODE_TYPES.TemplateLiteral:
|
|
7808
7989
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7809
7990
|
break;
|
|
7810
|
-
case
|
|
7991
|
+
case import_utils52.AST_NODE_TYPES.ArrayExpression:
|
|
7811
7992
|
for (const element of node.elements) {
|
|
7812
|
-
if (element !== null && element.type !==
|
|
7993
|
+
if (element !== null && element.type !== import_utils52.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
7813
7994
|
}
|
|
7814
7995
|
break;
|
|
7815
|
-
case
|
|
7996
|
+
case import_utils52.AST_NODE_TYPES.ObjectExpression:
|
|
7816
7997
|
for (const property of node.properties) {
|
|
7817
|
-
if (property.type ===
|
|
7998
|
+
if (property.type === import_utils52.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
7818
7999
|
}
|
|
7819
8000
|
break;
|
|
7820
|
-
case
|
|
8001
|
+
case import_utils52.AST_NODE_TYPES.ConditionalExpression:
|
|
7821
8002
|
checkClassNode(node.consequent);
|
|
7822
8003
|
checkClassNode(node.alternate);
|
|
7823
8004
|
break;
|
|
7824
|
-
case
|
|
8005
|
+
case import_utils52.AST_NODE_TYPES.LogicalExpression:
|
|
7825
8006
|
checkClassNode(node.right);
|
|
7826
8007
|
break;
|
|
7827
8008
|
default:
|
|
@@ -7829,32 +8010,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7829
8010
|
}
|
|
7830
8011
|
};
|
|
7831
8012
|
const checkColorValueNode = (node) => {
|
|
7832
|
-
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)) {
|
|
7833
8014
|
report(node, "inlineColor", { value: node.value });
|
|
7834
8015
|
}
|
|
7835
8016
|
};
|
|
7836
8017
|
return {
|
|
7837
8018
|
"JSXAttribute[name.name='className']"(node) {
|
|
7838
8019
|
if (node.value === null) return;
|
|
7839
|
-
if (node.value.type ===
|
|
7840
|
-
else if (node.value.type ===
|
|
7841
|
-
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) {
|
|
7842
8023
|
checkClassNode(node.value.expression);
|
|
7843
8024
|
}
|
|
7844
8025
|
}
|
|
7845
8026
|
},
|
|
7846
8027
|
CallExpression(node) {
|
|
7847
|
-
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)) {
|
|
7848
8029
|
importsEmailOrPdfRenderer = true;
|
|
7849
8030
|
}
|
|
7850
|
-
if (node.callee.type ===
|
|
8031
|
+
if (node.callee.type === import_utils52.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7851
8032
|
for (const arg of node.arguments) {
|
|
7852
|
-
if (arg.type !==
|
|
8033
|
+
if (arg.type !== import_utils52.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
7853
8034
|
}
|
|
7854
8035
|
}
|
|
7855
8036
|
},
|
|
7856
8037
|
VariableDeclarator(node) {
|
|
7857
|
-
if (node.id.type ===
|
|
8038
|
+
if (node.id.type === import_utils52.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
7858
8039
|
checkClassNode(node.init);
|
|
7859
8040
|
}
|
|
7860
8041
|
},
|
|
@@ -7864,9 +8045,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7864
8045
|
},
|
|
7865
8046
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
7866
8047
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
7867
|
-
if (node.value?.type !==
|
|
8048
|
+
if (node.value?.type !== import_utils52.AST_NODE_TYPES.Literal) return;
|
|
7868
8049
|
const owner = node.parent.name;
|
|
7869
|
-
if (owner.type ===
|
|
8050
|
+
if (owner.type === import_utils52.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
7870
8051
|
return;
|
|
7871
8052
|
}
|
|
7872
8053
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -7880,7 +8061,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7880
8061
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
7881
8062
|
},
|
|
7882
8063
|
ImportExpression(node) {
|
|
7883
|
-
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)) {
|
|
7884
8065
|
importsEmailOrPdfRenderer = true;
|
|
7885
8066
|
}
|
|
7886
8067
|
},
|
|
@@ -7893,7 +8074,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7893
8074
|
});
|
|
7894
8075
|
|
|
7895
8076
|
// src/rules/prefer-server-actions.ts
|
|
7896
|
-
var
|
|
8077
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7897
8078
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
7898
8079
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
7899
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\/)/;
|
|
@@ -8084,7 +8265,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8084
8265
|
});
|
|
8085
8266
|
|
|
8086
8267
|
// src/rules/prefer-string-literal-union.ts
|
|
8087
|
-
var
|
|
8268
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
8088
8269
|
var ts2 = __toESM(require("typescript"), 1);
|
|
8089
8270
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
8090
8271
|
"status",
|
|
@@ -8127,19 +8308,19 @@ function isChoiceLikeName(name) {
|
|
|
8127
8308
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8128
8309
|
}
|
|
8129
8310
|
function keyName(key) {
|
|
8130
|
-
if (key.type ===
|
|
8311
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8131
8312
|
return key.name;
|
|
8132
8313
|
}
|
|
8133
|
-
if (key.type ===
|
|
8314
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
8134
8315
|
return key.value;
|
|
8135
8316
|
}
|
|
8136
8317
|
return null;
|
|
8137
8318
|
}
|
|
8138
8319
|
function isStringLiteralMember(t) {
|
|
8139
|
-
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";
|
|
8140
8321
|
}
|
|
8141
8322
|
function isStringLiteralUnion(node) {
|
|
8142
|
-
if (node?.type !==
|
|
8323
|
+
if (node?.type !== import_utils54.AST_NODE_TYPES.TSUnionType) {
|
|
8143
8324
|
return false;
|
|
8144
8325
|
}
|
|
8145
8326
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8168,12 +8349,12 @@ function bindingSourceExpression(decl) {
|
|
|
8168
8349
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8169
8350
|
}
|
|
8170
8351
|
function refKey(node) {
|
|
8171
|
-
if (node.type ===
|
|
8352
|
+
if (node.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8172
8353
|
return node.name;
|
|
8173
8354
|
}
|
|
8174
|
-
if (node.type ===
|
|
8355
|
+
if (node.type === import_utils54.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
8175
8356
|
const inner = refKey(node.object);
|
|
8176
|
-
if (inner === null || node.property.type !==
|
|
8357
|
+
if (inner === null || node.property.type !== import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8177
8358
|
return null;
|
|
8178
8359
|
}
|
|
8179
8360
|
return `${inner}.${node.property.name}`;
|
|
@@ -8181,7 +8362,7 @@ function refKey(node) {
|
|
|
8181
8362
|
return null;
|
|
8182
8363
|
}
|
|
8183
8364
|
function strLiteral(node) {
|
|
8184
|
-
if (node.type ===
|
|
8365
|
+
if (node.type === import_utils54.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
8185
8366
|
return node.value;
|
|
8186
8367
|
}
|
|
8187
8368
|
return null;
|
|
@@ -8222,7 +8403,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8222
8403
|
);
|
|
8223
8404
|
let services;
|
|
8224
8405
|
try {
|
|
8225
|
-
services =
|
|
8406
|
+
services = import_utils54.ESLintUtils.getParserServices(context);
|
|
8226
8407
|
} catch {
|
|
8227
8408
|
services = null;
|
|
8228
8409
|
}
|
|
@@ -8334,7 +8515,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8334
8515
|
containersWithUnion.add(container);
|
|
8335
8516
|
return;
|
|
8336
8517
|
}
|
|
8337
|
-
if (typeNode?.type !==
|
|
8518
|
+
if (typeNode?.type !== import_utils54.AST_NODE_TYPES.TSStringKeyword) {
|
|
8338
8519
|
return;
|
|
8339
8520
|
}
|
|
8340
8521
|
const name = keyName(key);
|
|
@@ -8422,10 +8603,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8422
8603
|
}
|
|
8423
8604
|
};
|
|
8424
8605
|
function refKeyText(node) {
|
|
8425
|
-
if (node.type ===
|
|
8606
|
+
if (node.type === import_utils54.AST_NODE_TYPES.BinaryExpression) {
|
|
8426
8607
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8427
8608
|
}
|
|
8428
|
-
if (node.type ===
|
|
8609
|
+
if (node.type === import_utils54.AST_NODE_TYPES.SwitchStatement) {
|
|
8429
8610
|
return refKey(node.discriminant) ?? "value";
|
|
8430
8611
|
}
|
|
8431
8612
|
return "value";
|
|
@@ -8434,7 +8615,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8434
8615
|
});
|
|
8435
8616
|
|
|
8436
8617
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8437
|
-
var
|
|
8618
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8438
8619
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8439
8620
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8440
8621
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8443,11 +8624,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8443
8624
|
var MIN_RUN_LENGTH = 2;
|
|
8444
8625
|
function literalText(node, getText) {
|
|
8445
8626
|
switch (node.type) {
|
|
8446
|
-
case
|
|
8627
|
+
case import_utils55.AST_NODE_TYPES.Literal:
|
|
8447
8628
|
return "regex" in node ? null : getText(node);
|
|
8448
|
-
case
|
|
8629
|
+
case import_utils55.AST_NODE_TYPES.TemplateLiteral:
|
|
8449
8630
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8450
|
-
case
|
|
8631
|
+
case import_utils55.AST_NODE_TYPES.UnaryExpression:
|
|
8451
8632
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8452
8633
|
default:
|
|
8453
8634
|
return null;
|
|
@@ -8455,15 +8636,15 @@ function literalText(node, getText) {
|
|
|
8455
8636
|
}
|
|
8456
8637
|
function isPureReceiver(node) {
|
|
8457
8638
|
switch (node.type) {
|
|
8458
|
-
case
|
|
8459
|
-
case
|
|
8639
|
+
case import_utils55.AST_NODE_TYPES.Identifier:
|
|
8640
|
+
case import_utils55.AST_NODE_TYPES.ThisExpression:
|
|
8460
8641
|
return true;
|
|
8461
|
-
case
|
|
8642
|
+
case import_utils55.AST_NODE_TYPES.MemberExpression:
|
|
8462
8643
|
if (node.optional) {
|
|
8463
8644
|
return false;
|
|
8464
8645
|
}
|
|
8465
8646
|
if (node.computed) {
|
|
8466
|
-
return node.property.type ===
|
|
8647
|
+
return node.property.type === import_utils55.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8467
8648
|
}
|
|
8468
8649
|
return isPureReceiver(node.object);
|
|
8469
8650
|
default:
|
|
@@ -8471,7 +8652,7 @@ function isPureReceiver(node) {
|
|
|
8471
8652
|
}
|
|
8472
8653
|
}
|
|
8473
8654
|
function literalIndex(node) {
|
|
8474
|
-
if (node.type !==
|
|
8655
|
+
if (node.type !== import_utils55.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8475
8656
|
return null;
|
|
8476
8657
|
}
|
|
8477
8658
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8497,24 +8678,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8497
8678
|
}
|
|
8498
8679
|
const { sourceCode } = context;
|
|
8499
8680
|
function parseAssertion(statement) {
|
|
8500
|
-
if (statement.type !==
|
|
8681
|
+
if (statement.type !== import_utils55.AST_NODE_TYPES.ExpressionStatement) {
|
|
8501
8682
|
return null;
|
|
8502
8683
|
}
|
|
8503
8684
|
const call = statement.expression;
|
|
8504
|
-
if (call.type !==
|
|
8685
|
+
if (call.type !== import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
8505
8686
|
return null;
|
|
8506
8687
|
}
|
|
8507
8688
|
const callee = call.callee;
|
|
8508
|
-
if (callee.type !==
|
|
8689
|
+
if (callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8509
8690
|
return null;
|
|
8510
8691
|
}
|
|
8511
8692
|
const matcher = callee.property.name;
|
|
8512
8693
|
const expectCall = callee.object;
|
|
8513
|
-
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) {
|
|
8514
8695
|
return null;
|
|
8515
8696
|
}
|
|
8516
8697
|
const actual = expectCall.arguments[0];
|
|
8517
|
-
if (actual === void 0 || actual.type !==
|
|
8698
|
+
if (actual === void 0 || actual.type !== import_utils55.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8518
8699
|
return null;
|
|
8519
8700
|
}
|
|
8520
8701
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8528,7 +8709,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8528
8709
|
}
|
|
8529
8710
|
key = { kind: "index", index };
|
|
8530
8711
|
} else {
|
|
8531
|
-
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)) {
|
|
8532
8713
|
return null;
|
|
8533
8714
|
}
|
|
8534
8715
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8540,7 +8721,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8540
8721
|
return null;
|
|
8541
8722
|
}
|
|
8542
8723
|
const expected = call.arguments[0];
|
|
8543
|
-
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) {
|
|
8544
8725
|
return null;
|
|
8545
8726
|
}
|
|
8546
8727
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8655,7 +8836,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8655
8836
|
});
|
|
8656
8837
|
|
|
8657
8838
|
// src/rules/prefer-zod-enum.ts
|
|
8658
|
-
var
|
|
8839
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8659
8840
|
var prefer_zod_enum_default = createRule({
|
|
8660
8841
|
name: "prefer-zod-enum",
|
|
8661
8842
|
meta: {
|
|
@@ -8675,25 +8856,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
8675
8856
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8676
8857
|
function enumValues(node) {
|
|
8677
8858
|
const callee = node.callee;
|
|
8678
|
-
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) {
|
|
8679
8860
|
return null;
|
|
8680
8861
|
}
|
|
8681
8862
|
const argument = node.arguments[0];
|
|
8682
|
-
if (argument === void 0 || argument.type !==
|
|
8863
|
+
if (argument === void 0 || argument.type !== import_utils56.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
8683
8864
|
return null;
|
|
8684
8865
|
}
|
|
8685
8866
|
const values = [];
|
|
8686
8867
|
let canFix = true;
|
|
8687
8868
|
for (const element of argument.elements) {
|
|
8688
|
-
if (element?.type ===
|
|
8869
|
+
if (element?.type === import_utils56.AST_NODE_TYPES.SpreadElement) {
|
|
8689
8870
|
canFix = false;
|
|
8690
8871
|
continue;
|
|
8691
8872
|
}
|
|
8692
|
-
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") {
|
|
8693
8874
|
return null;
|
|
8694
8875
|
}
|
|
8695
8876
|
const value = element.arguments[0];
|
|
8696
|
-
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") {
|
|
8697
8878
|
canFix = false;
|
|
8698
8879
|
continue;
|
|
8699
8880
|
}
|
|
@@ -8703,11 +8884,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
8703
8884
|
}
|
|
8704
8885
|
function buildFix(node, values) {
|
|
8705
8886
|
const argument = node.arguments[0];
|
|
8706
|
-
if (argument === void 0 || argument.type !==
|
|
8887
|
+
if (argument === void 0 || argument.type !== import_utils56.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8707
8888
|
return void 0;
|
|
8708
8889
|
}
|
|
8709
8890
|
const callee = node.callee;
|
|
8710
|
-
if (callee.type !==
|
|
8891
|
+
if (callee.type !== import_utils56.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8711
8892
|
return void 0;
|
|
8712
8893
|
}
|
|
8713
8894
|
return (fixer) => [
|
|
@@ -8724,7 +8905,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8724
8905
|
return;
|
|
8725
8906
|
}
|
|
8726
8907
|
for (const specifier of node.specifiers) {
|
|
8727
|
-
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") {
|
|
8728
8909
|
zodNamespaces.add(specifier.local.name);
|
|
8729
8910
|
}
|
|
8730
8911
|
}
|
|
@@ -8746,7 +8927,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8746
8927
|
});
|
|
8747
8928
|
|
|
8748
8929
|
// src/rules/prefer-zod-infer.ts
|
|
8749
|
-
var
|
|
8930
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8750
8931
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8751
8932
|
"describe",
|
|
8752
8933
|
"refine",
|
|
@@ -8783,44 +8964,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8783
8964
|
"Schema"
|
|
8784
8965
|
]);
|
|
8785
8966
|
var LEAF_NODE_TYPES = {
|
|
8786
|
-
string: [
|
|
8787
|
-
email: [
|
|
8788
|
-
url: [
|
|
8789
|
-
uuid: [
|
|
8790
|
-
ulid: [
|
|
8791
|
-
cuid: [
|
|
8792
|
-
cuid2: [
|
|
8793
|
-
nanoid: [
|
|
8794
|
-
iso: [
|
|
8795
|
-
number: [
|
|
8796
|
-
int: [
|
|
8797
|
-
float32: [
|
|
8798
|
-
float64: [
|
|
8799
|
-
boolean: [
|
|
8800
|
-
bigint: [
|
|
8801
|
-
symbol: [
|
|
8802
|
-
any: [
|
|
8803
|
-
unknown: [
|
|
8804
|
-
never: [
|
|
8805
|
-
void: [
|
|
8806
|
-
null: [
|
|
8807
|
-
undefined: [
|
|
8808
|
-
literal: [
|
|
8809
|
-
date: [
|
|
8810
|
-
array: [
|
|
8811
|
-
tuple: [
|
|
8812
|
-
object: [
|
|
8813
|
-
strictObject: [
|
|
8814
|
-
looseObject: [
|
|
8815
|
-
record: [
|
|
8816
|
-
map: [
|
|
8817
|
-
set: [
|
|
8818
|
-
promise: [
|
|
8819
|
-
enum: [
|
|
8820
|
-
nativeEnum: [
|
|
8821
|
-
union: [
|
|
8822
|
-
discriminatedUnion: [
|
|
8823
|
-
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]
|
|
8824
9005
|
};
|
|
8825
9006
|
function normalizeSchemaName(name) {
|
|
8826
9007
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8829,20 +9010,20 @@ function normalizeTypeName(name) {
|
|
|
8829
9010
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8830
9011
|
}
|
|
8831
9012
|
function unwrapNullish(annotation) {
|
|
8832
|
-
if (annotation.type !==
|
|
9013
|
+
if (annotation.type !== import_utils57.AST_NODE_TYPES.TSUnionType) {
|
|
8833
9014
|
return {
|
|
8834
9015
|
core: annotation,
|
|
8835
|
-
nullable: annotation.type ===
|
|
9016
|
+
nullable: annotation.type === import_utils57.AST_NODE_TYPES.TSNullKeyword
|
|
8836
9017
|
};
|
|
8837
9018
|
}
|
|
8838
9019
|
const rest = [];
|
|
8839
9020
|
let nullable = false;
|
|
8840
9021
|
for (const member of annotation.types) {
|
|
8841
|
-
if (member.type ===
|
|
9022
|
+
if (member.type === import_utils57.AST_NODE_TYPES.TSNullKeyword) {
|
|
8842
9023
|
nullable = true;
|
|
8843
9024
|
continue;
|
|
8844
9025
|
}
|
|
8845
|
-
if (member.type ===
|
|
9026
|
+
if (member.type === import_utils57.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
8846
9027
|
continue;
|
|
8847
9028
|
}
|
|
8848
9029
|
rest.push(member);
|
|
@@ -8907,14 +9088,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8907
9088
|
function zodCallChain(node) {
|
|
8908
9089
|
const chain = [];
|
|
8909
9090
|
let current = node;
|
|
8910
|
-
while (current.type ===
|
|
9091
|
+
while (current.type === import_utils57.AST_NODE_TYPES.CallExpression) {
|
|
8911
9092
|
const callee = current.callee;
|
|
8912
|
-
if (callee.type !==
|
|
9093
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8913
9094
|
return null;
|
|
8914
9095
|
}
|
|
8915
9096
|
chain.push(current);
|
|
8916
9097
|
const receiver = callee.object;
|
|
8917
|
-
if (receiver.type ===
|
|
9098
|
+
if (receiver.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8918
9099
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
8919
9100
|
}
|
|
8920
9101
|
current = receiver;
|
|
@@ -8923,19 +9104,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
8923
9104
|
}
|
|
8924
9105
|
function methodName(call) {
|
|
8925
9106
|
const callee = call.callee;
|
|
8926
|
-
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 : "";
|
|
8927
9108
|
}
|
|
8928
9109
|
function schemaField(node) {
|
|
8929
9110
|
const modifiers = [];
|
|
8930
9111
|
let current = node;
|
|
8931
9112
|
let leaf = null;
|
|
8932
|
-
while (current.type ===
|
|
9113
|
+
while (current.type === import_utils57.AST_NODE_TYPES.CallExpression) {
|
|
8933
9114
|
const callee = current.callee;
|
|
8934
|
-
if (callee.type !==
|
|
9115
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8935
9116
|
break;
|
|
8936
9117
|
}
|
|
8937
9118
|
const receiver = callee.object;
|
|
8938
|
-
if (receiver.type ===
|
|
9119
|
+
if (receiver.type === import_utils57.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
8939
9120
|
leaf = callee.property.name;
|
|
8940
9121
|
break;
|
|
8941
9122
|
}
|
|
@@ -8966,16 +9147,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8966
9147
|
return null;
|
|
8967
9148
|
}
|
|
8968
9149
|
const shape = base.arguments[0];
|
|
8969
|
-
if (shape === void 0 || shape.type !==
|
|
9150
|
+
if (shape === void 0 || shape.type !== import_utils57.AST_NODE_TYPES.ObjectExpression) {
|
|
8970
9151
|
return null;
|
|
8971
9152
|
}
|
|
8972
9153
|
const fields = /* @__PURE__ */ new Map();
|
|
8973
9154
|
for (const property of shape.properties) {
|
|
8974
|
-
if (property.type !==
|
|
9155
|
+
if (property.type !== import_utils57.AST_NODE_TYPES.Property || property.computed) {
|
|
8975
9156
|
return null;
|
|
8976
9157
|
}
|
|
8977
9158
|
const { key } = property;
|
|
8978
|
-
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;
|
|
8979
9160
|
if (name === null) {
|
|
8980
9161
|
return null;
|
|
8981
9162
|
}
|
|
@@ -8986,11 +9167,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8986
9167
|
function typeMembers(members) {
|
|
8987
9168
|
const result = /* @__PURE__ */ new Map();
|
|
8988
9169
|
for (const member of members) {
|
|
8989
|
-
if (member.type !==
|
|
9170
|
+
if (member.type !== import_utils57.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
8990
9171
|
return null;
|
|
8991
9172
|
}
|
|
8992
9173
|
const { key } = member;
|
|
8993
|
-
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;
|
|
8994
9175
|
if (name === null) {
|
|
8995
9176
|
return null;
|
|
8996
9177
|
}
|
|
@@ -9004,8 +9185,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9004
9185
|
return result.size === 0 ? null : result;
|
|
9005
9186
|
}
|
|
9006
9187
|
function collectConstrainedNames(node) {
|
|
9007
|
-
if (node.type ===
|
|
9008
|
-
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) {
|
|
9009
9190
|
constrainedTypeNames.add(node.typeName.name);
|
|
9010
9191
|
}
|
|
9011
9192
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9013,11 +9194,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9013
9194
|
}
|
|
9014
9195
|
return;
|
|
9015
9196
|
}
|
|
9016
|
-
if (node.type ===
|
|
9197
|
+
if (node.type === import_utils57.AST_NODE_TYPES.TSArrayType) {
|
|
9017
9198
|
collectConstrainedNames(node.elementType);
|
|
9018
9199
|
return;
|
|
9019
9200
|
}
|
|
9020
|
-
if (node.type ===
|
|
9201
|
+
if (node.type === import_utils57.AST_NODE_TYPES.TSUnionType || node.type === import_utils57.AST_NODE_TYPES.TSIntersectionType) {
|
|
9021
9202
|
for (const member of node.types) {
|
|
9022
9203
|
collectConstrainedNames(member);
|
|
9023
9204
|
}
|
|
@@ -9061,13 +9242,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9061
9242
|
return;
|
|
9062
9243
|
}
|
|
9063
9244
|
for (const specifier of node.specifiers) {
|
|
9064
|
-
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") {
|
|
9065
9246
|
zodNamespaces.add(specifier.local.name);
|
|
9066
9247
|
}
|
|
9067
9248
|
}
|
|
9068
9249
|
},
|
|
9069
9250
|
VariableDeclarator(node) {
|
|
9070
|
-
if (node.id.type !==
|
|
9251
|
+
if (node.id.type !== import_utils57.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
9071
9252
|
return;
|
|
9072
9253
|
}
|
|
9073
9254
|
const fields = schemaFields(node.init);
|
|
@@ -9077,14 +9258,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9077
9258
|
},
|
|
9078
9259
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9079
9260
|
"MemberExpression[computed=false]"(node) {
|
|
9080
|
-
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)) {
|
|
9081
9262
|
reshapedSchemaNames.add(node.object.name);
|
|
9082
9263
|
}
|
|
9083
9264
|
},
|
|
9084
9265
|
/** Records every type argument carried by a Zod constraint. */
|
|
9085
9266
|
TSTypeReference(node) {
|
|
9086
9267
|
const { typeName } = node;
|
|
9087
|
-
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;
|
|
9088
9269
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9089
9270
|
return;
|
|
9090
9271
|
}
|
|
@@ -9102,7 +9283,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9102
9283
|
}
|
|
9103
9284
|
},
|
|
9104
9285
|
TSTypeAliasDeclaration(node) {
|
|
9105
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9286
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils57.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9106
9287
|
return;
|
|
9107
9288
|
}
|
|
9108
9289
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9147,10 +9328,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9147
9328
|
});
|
|
9148
9329
|
|
|
9149
9330
|
// src/rules/require-assert-never.ts
|
|
9150
|
-
var
|
|
9331
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
9151
9332
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9152
|
-
if (statement.type ===
|
|
9153
|
-
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) {
|
|
9154
9335
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9155
9336
|
}
|
|
9156
9337
|
return true;
|
|
@@ -9166,7 +9347,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9166
9347
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9167
9348
|
}
|
|
9168
9349
|
const only = defaultCase.consequent[0];
|
|
9169
|
-
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) {
|
|
9170
9351
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9171
9352
|
}
|
|
9172
9353
|
return false;
|
|
@@ -9206,7 +9387,7 @@ var require_assert_never_default = createRule({
|
|
|
9206
9387
|
});
|
|
9207
9388
|
|
|
9208
9389
|
// src/rules/require-fetch-timeout.ts
|
|
9209
|
-
var
|
|
9390
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
9210
9391
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9211
9392
|
"globalThis",
|
|
9212
9393
|
"window",
|
|
@@ -9222,14 +9403,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9222
9403
|
return false;
|
|
9223
9404
|
}
|
|
9224
9405
|
function initProvablyLacksSignal(init) {
|
|
9225
|
-
if (init.type !==
|
|
9406
|
+
if (init.type !== import_utils59.AST_NODE_TYPES.ObjectExpression) {
|
|
9226
9407
|
return false;
|
|
9227
9408
|
}
|
|
9228
9409
|
for (const prop of init.properties) {
|
|
9229
|
-
if (prop.type ===
|
|
9410
|
+
if (prop.type === import_utils59.AST_NODE_TYPES.SpreadElement) {
|
|
9230
9411
|
return false;
|
|
9231
9412
|
}
|
|
9232
|
-
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") {
|
|
9233
9414
|
return false;
|
|
9234
9415
|
}
|
|
9235
9416
|
if (prop.computed) {
|
|
@@ -9239,7 +9420,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9239
9420
|
return true;
|
|
9240
9421
|
}
|
|
9241
9422
|
function isStringish(node) {
|
|
9242
|
-
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;
|
|
9243
9424
|
}
|
|
9244
9425
|
var require_fetch_timeout_default = createRule({
|
|
9245
9426
|
name: "require-fetch-timeout",
|
|
@@ -9276,14 +9457,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9276
9457
|
}
|
|
9277
9458
|
function resolvesToGlobal(identifier) {
|
|
9278
9459
|
const scope = context.sourceCode.getScope(identifier);
|
|
9279
|
-
const variable =
|
|
9460
|
+
const variable = import_utils59.ASTUtils.findVariable(scope, identifier.name);
|
|
9280
9461
|
return variable === null || variable.defs.length === 0;
|
|
9281
9462
|
}
|
|
9282
9463
|
function isGlobalFetchCall2(callee) {
|
|
9283
|
-
if (callee.type ===
|
|
9464
|
+
if (callee.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9284
9465
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9285
9466
|
}
|
|
9286
|
-
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);
|
|
9287
9468
|
}
|
|
9288
9469
|
return {
|
|
9289
9470
|
CallExpression(node) {
|
|
@@ -9303,7 +9484,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9303
9484
|
});
|
|
9304
9485
|
|
|
9305
9486
|
// src/rules/require-interface-for-injected-service.ts
|
|
9306
|
-
var
|
|
9487
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9307
9488
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9308
9489
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9309
9490
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9311,20 +9492,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9311
9492
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9312
9493
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9313
9494
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9314
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9315
|
-
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}` : "";
|
|
9316
9497
|
var readTypeReference = (annotation) => {
|
|
9317
|
-
if (annotation === void 0 || annotation.type !==
|
|
9498
|
+
if (annotation === void 0 || annotation.type !== import_utils60.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9318
9499
|
const { typeName } = annotation;
|
|
9319
|
-
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;
|
|
9320
9501
|
if (rightmost === null) return null;
|
|
9321
9502
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9322
9503
|
};
|
|
9323
9504
|
var namedParameterCollaborator = (annotated) => {
|
|
9324
9505
|
let target = annotated;
|
|
9325
|
-
if (target.type ===
|
|
9326
|
-
if (target.type ===
|
|
9327
|
-
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;
|
|
9328
9509
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9329
9510
|
if (reference === null) return null;
|
|
9330
9511
|
return { name: target.name, ...reference };
|
|
@@ -9332,8 +9513,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9332
9513
|
var propertySignatureTypes = (members) => {
|
|
9333
9514
|
const types = /* @__PURE__ */ new Map();
|
|
9334
9515
|
for (const member of members) {
|
|
9335
|
-
if (member.type !==
|
|
9336
|
-
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;
|
|
9337
9518
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9338
9519
|
if (reference === null) continue;
|
|
9339
9520
|
types.set(member.key.name, reference);
|
|
@@ -9344,18 +9525,18 @@ var fileTypeIndex = (program) => {
|
|
|
9344
9525
|
const objects = /* @__PURE__ */ new Map();
|
|
9345
9526
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9346
9527
|
for (const statement of program.body) {
|
|
9347
|
-
const declaration = statement.type ===
|
|
9348
|
-
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) {
|
|
9349
9530
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9350
9531
|
continue;
|
|
9351
9532
|
}
|
|
9352
|
-
if (declaration?.type !==
|
|
9533
|
+
if (declaration?.type !== import_utils60.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9353
9534
|
const aliased = declaration.typeAnnotation;
|
|
9354
|
-
if (aliased.type ===
|
|
9535
|
+
if (aliased.type === import_utils60.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils60.AST_NODE_TYPES.TSConstructorType) {
|
|
9355
9536
|
functionAliases.add(declaration.id.name);
|
|
9356
9537
|
continue;
|
|
9357
9538
|
}
|
|
9358
|
-
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) : [];
|
|
9359
9540
|
if (literals.length === 0) continue;
|
|
9360
9541
|
const merged = /* @__PURE__ */ new Map();
|
|
9361
9542
|
for (const literal of literals) {
|
|
@@ -9368,10 +9549,10 @@ var fileTypeIndex = (program) => {
|
|
|
9368
9549
|
return { objects, functionAliases };
|
|
9369
9550
|
};
|
|
9370
9551
|
var bagMemberTypes = (annotation, declared) => {
|
|
9371
|
-
if (annotation.type ===
|
|
9552
|
+
if (annotation.type === import_utils60.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9372
9553
|
return propertySignatureTypes(annotation.members);
|
|
9373
9554
|
}
|
|
9374
|
-
if (annotation.type !==
|
|
9555
|
+
if (annotation.type !== import_utils60.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9375
9556
|
return null;
|
|
9376
9557
|
}
|
|
9377
9558
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9383,11 +9564,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9383
9564
|
if (members === null) return [];
|
|
9384
9565
|
const collaborators = [];
|
|
9385
9566
|
for (const property of pattern.properties) {
|
|
9386
|
-
if (property.type !==
|
|
9387
|
-
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;
|
|
9388
9569
|
const key = property.key.name;
|
|
9389
|
-
const bound = property.value.type ===
|
|
9390
|
-
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;
|
|
9391
9572
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9392
9573
|
const reference = members.get(key);
|
|
9393
9574
|
if (reference === void 0) continue;
|
|
@@ -9397,8 +9578,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9397
9578
|
};
|
|
9398
9579
|
var parameterCollaborators = (parameter, declared) => {
|
|
9399
9580
|
let target = parameter;
|
|
9400
|
-
if (target.type ===
|
|
9401
|
-
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) {
|
|
9402
9583
|
return objectPatternCollaborators(target, declared);
|
|
9403
9584
|
}
|
|
9404
9585
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9417,17 +9598,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9417
9598
|
let constructedFields = 0;
|
|
9418
9599
|
if (body2 !== null && body2 !== void 0) {
|
|
9419
9600
|
for (const statement of body2.body) {
|
|
9420
|
-
if (statement.type !==
|
|
9601
|
+
if (statement.type !== import_utils60.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9421
9602
|
const expression = statement.expression;
|
|
9422
|
-
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) {
|
|
9423
9604
|
continue;
|
|
9424
9605
|
}
|
|
9425
9606
|
const source = expression.right;
|
|
9426
|
-
if (source.type ===
|
|
9607
|
+
if (source.type === import_utils60.AST_NODE_TYPES.NewExpression) {
|
|
9427
9608
|
constructedFields += 1;
|
|
9428
|
-
} else if (source.type ===
|
|
9609
|
+
} else if (source.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9429
9610
|
storedFrom.add(source.name);
|
|
9430
|
-
} else if (source.type ===
|
|
9611
|
+
} else if (source.type === import_utils60.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9431
9612
|
storedFrom.add(source.object.name);
|
|
9432
9613
|
}
|
|
9433
9614
|
}
|
|
@@ -9435,7 +9616,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9435
9616
|
const collaborators = [];
|
|
9436
9617
|
for (const parameter of ctor.value.params) {
|
|
9437
9618
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9438
|
-
const stored = parameter.type ===
|
|
9619
|
+
const stored = parameter.type === import_utils60.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9439
9620
|
if (!stored) continue;
|
|
9440
9621
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9441
9622
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9469,19 +9650,19 @@ var subtreeHas = (root, found) => {
|
|
|
9469
9650
|
return hit;
|
|
9470
9651
|
};
|
|
9471
9652
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9472
|
-
if (node.type ===
|
|
9653
|
+
if (node.type === import_utils60.AST_NODE_TYPES.CallExpression) {
|
|
9473
9654
|
const { callee } = node;
|
|
9474
|
-
if (callee.type ===
|
|
9475
|
-
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;
|
|
9476
9657
|
}
|
|
9477
|
-
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);
|
|
9478
9659
|
});
|
|
9479
9660
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9480
9661
|
var fileInterfaceNames = (program) => {
|
|
9481
9662
|
const names = [];
|
|
9482
9663
|
for (const statement of program.body) {
|
|
9483
|
-
const declaration = statement.type ===
|
|
9484
|
-
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);
|
|
9485
9666
|
}
|
|
9486
9667
|
return names;
|
|
9487
9668
|
};
|
|
@@ -9499,11 +9680,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9499
9680
|
var publicMethodNames = (body2) => {
|
|
9500
9681
|
const names = [];
|
|
9501
9682
|
for (const member of body2.body) {
|
|
9502
|
-
if (member.type !==
|
|
9683
|
+
if (member.type !== import_utils60.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9503
9684
|
if (member.kind !== "method" || member.static) continue;
|
|
9504
9685
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9505
|
-
if (member.key.type ===
|
|
9506
|
-
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);
|
|
9507
9688
|
else names.push("\u2026");
|
|
9508
9689
|
}
|
|
9509
9690
|
return names;
|
|
@@ -9536,7 +9717,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9536
9717
|
if (node.implements.length > 0) return;
|
|
9537
9718
|
if (node.decorators.length > 0) return;
|
|
9538
9719
|
const ctor = node.body.body.find(
|
|
9539
|
-
(member) => member.type ===
|
|
9720
|
+
(member) => member.type === import_utils60.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
9540
9721
|
);
|
|
9541
9722
|
if (ctor === void 0) return;
|
|
9542
9723
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9565,18 +9746,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9565
9746
|
});
|
|
9566
9747
|
|
|
9567
9748
|
// src/rules/require-zod-form-validation.ts
|
|
9568
|
-
var
|
|
9749
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9569
9750
|
var looksLikeZodSchema = (node) => {
|
|
9570
9751
|
let current = node;
|
|
9571
9752
|
while (true) {
|
|
9572
|
-
if (current.type ===
|
|
9753
|
+
if (current.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9573
9754
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9574
9755
|
}
|
|
9575
|
-
if (current.type ===
|
|
9756
|
+
if (current.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9576
9757
|
current = current.callee;
|
|
9577
9758
|
continue;
|
|
9578
9759
|
}
|
|
9579
|
-
if (current.type ===
|
|
9760
|
+
if (current.type === import_utils61.AST_NODE_TYPES.MemberExpression) {
|
|
9580
9761
|
current = current.object;
|
|
9581
9762
|
continue;
|
|
9582
9763
|
}
|
|
@@ -9584,23 +9765,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9584
9765
|
}
|
|
9585
9766
|
};
|
|
9586
9767
|
var isZodParseCall = (node) => {
|
|
9587
|
-
if (node.type !==
|
|
9768
|
+
if (node.type !== import_utils61.AST_NODE_TYPES.CallExpression) return false;
|
|
9588
9769
|
const callee = node.callee;
|
|
9589
|
-
if (callee.type !==
|
|
9770
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression) return false;
|
|
9590
9771
|
if (callee.computed) return false;
|
|
9591
|
-
if (callee.property.type !==
|
|
9772
|
+
if (callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) return false;
|
|
9592
9773
|
const method = callee.property.name;
|
|
9593
9774
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9594
9775
|
return looksLikeZodSchema(callee.object);
|
|
9595
9776
|
};
|
|
9596
9777
|
var isFormDataMethodCall = (node) => {
|
|
9597
9778
|
let current = node;
|
|
9598
|
-
if (current.type ===
|
|
9779
|
+
if (current.type === import_utils61.AST_NODE_TYPES.AwaitExpression) {
|
|
9599
9780
|
current = current.argument;
|
|
9600
9781
|
}
|
|
9601
|
-
if (current.type !==
|
|
9782
|
+
if (current.type !== import_utils61.AST_NODE_TYPES.CallExpression) return false;
|
|
9602
9783
|
const callee = current.callee;
|
|
9603
|
-
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";
|
|
9604
9785
|
};
|
|
9605
9786
|
var require_zod_form_validation_default = createRule({
|
|
9606
9787
|
name: "require-zod-form-validation",
|
|
@@ -9620,14 +9801,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9620
9801
|
return {};
|
|
9621
9802
|
}
|
|
9622
9803
|
const isFormSourceIdentifier = (node) => {
|
|
9623
|
-
if (node.type !==
|
|
9804
|
+
if (node.type !== import_utils61.AST_NODE_TYPES.Identifier) return false;
|
|
9624
9805
|
if (/formdata/i.test(node.name)) return true;
|
|
9625
9806
|
let scope = context.sourceCode.getScope(node);
|
|
9626
9807
|
while (scope !== null) {
|
|
9627
9808
|
const variable = scope.set.get(node.name);
|
|
9628
9809
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9629
9810
|
const def = variable.defs[0];
|
|
9630
|
-
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) {
|
|
9631
9812
|
return isFormDataMethodCall(def.node.init);
|
|
9632
9813
|
}
|
|
9633
9814
|
return false;
|
|
@@ -9638,8 +9819,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9638
9819
|
};
|
|
9639
9820
|
const isFormDataGetCall = (node) => {
|
|
9640
9821
|
const callee = node.callee;
|
|
9641
|
-
if (callee.type !==
|
|
9642
|
-
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") {
|
|
9643
9824
|
return false;
|
|
9644
9825
|
}
|
|
9645
9826
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9654,11 +9835,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9654
9835
|
};
|
|
9655
9836
|
const isInstanceofNarrowing = (node) => {
|
|
9656
9837
|
const parent = node.parent;
|
|
9657
|
-
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");
|
|
9658
9839
|
};
|
|
9659
9840
|
const boundDeclarator = (node) => {
|
|
9660
9841
|
const parent = node.parent;
|
|
9661
|
-
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) {
|
|
9662
9843
|
return parent;
|
|
9663
9844
|
}
|
|
9664
9845
|
return null;
|
|
@@ -9686,7 +9867,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
9686
9867
|
});
|
|
9687
9868
|
|
|
9688
9869
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
9689
|
-
var
|
|
9870
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
9690
9871
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
9691
9872
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
9692
9873
|
var INSERT_GATE = /insert/i;
|
|
@@ -9717,7 +9898,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9717
9898
|
});
|
|
9718
9899
|
|
|
9719
9900
|
// src/rules/zod-naming-convention.ts
|
|
9720
|
-
var
|
|
9901
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
9721
9902
|
var CONVENTIONS = {
|
|
9722
9903
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9723
9904
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9742,15 +9923,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9742
9923
|
"registry",
|
|
9743
9924
|
"implement"
|
|
9744
9925
|
]);
|
|
9745
|
-
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;
|
|
9746
9927
|
var calleeChainStartsWithZ = (node) => {
|
|
9747
9928
|
let current = node;
|
|
9748
|
-
while (current.type ===
|
|
9929
|
+
while (current.type === import_utils63.AST_NODE_TYPES.MemberExpression) {
|
|
9749
9930
|
const receiver = current.object;
|
|
9750
|
-
if (receiver.type ===
|
|
9931
|
+
if (receiver.type === import_utils63.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
9751
9932
|
return true;
|
|
9752
9933
|
}
|
|
9753
|
-
if (receiver.type ===
|
|
9934
|
+
if (receiver.type === import_utils63.AST_NODE_TYPES.CallExpression) {
|
|
9754
9935
|
current = receiver.callee;
|
|
9755
9936
|
continue;
|
|
9756
9937
|
}
|
|
@@ -9795,13 +9976,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9795
9976
|
VariableDeclarator(node) {
|
|
9796
9977
|
const init = node.init;
|
|
9797
9978
|
if (init === null || init === void 0) return;
|
|
9798
|
-
if (init.type !==
|
|
9979
|
+
if (init.type !== import_utils63.AST_NODE_TYPES.CallExpression) return;
|
|
9799
9980
|
const callee = init.callee;
|
|
9800
|
-
if (callee.type !==
|
|
9981
|
+
if (callee.type !== import_utils63.AST_NODE_TYPES.MemberExpression) return;
|
|
9801
9982
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9802
9983
|
const terminal = terminalMethodName(callee);
|
|
9803
9984
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9804
|
-
if (node.id.type !==
|
|
9985
|
+
if (node.id.type !== import_utils63.AST_NODE_TYPES.Identifier) return;
|
|
9805
9986
|
if (test.test(node.id.name)) return;
|
|
9806
9987
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9807
9988
|
context.report({
|
|
@@ -9889,6 +10070,7 @@ var rules = {
|
|
|
9889
10070
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
9890
10071
|
"no-raw-env": no_raw_env_default,
|
|
9891
10072
|
"no-raw-fetch-outside-clients": no_raw_fetch_outside_clients_default,
|
|
10073
|
+
"no-restricted-library-load": no_restricted_library_load_default,
|
|
9892
10074
|
"no-repeated-string-literal": no_repeated_string_literal_default,
|
|
9893
10075
|
"no-restated-comment": no_restated_comment_default,
|
|
9894
10076
|
"no-restated-jsdoc": no_restated_jsdoc_default,
|
|
@@ -9913,6 +10095,7 @@ var rules = {
|
|
|
9913
10095
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
9914
10096
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
9915
10097
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
10098
|
+
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
9916
10099
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
9917
10100
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
9918
10101
|
"prefer-server-actions": prefer_server_actions_default,
|
|
@@ -9930,8 +10113,12 @@ var rules = {
|
|
|
9930
10113
|
};
|
|
9931
10114
|
var meta = {
|
|
9932
10115
|
name: "@sarj/eslint-plugin",
|
|
9933
|
-
version: "9.
|
|
10116
|
+
version: "9.8.0"
|
|
9934
10117
|
};
|
|
10118
|
+
var applicationOnlyRules = [
|
|
10119
|
+
"no-restricted-library-load",
|
|
10120
|
+
"prefer-native-random-uuid"
|
|
10121
|
+
];
|
|
9935
10122
|
var recommendedRules = {
|
|
9936
10123
|
"@sarj/enforce-file-structure": "warn",
|
|
9937
10124
|
"@sarj/no-async-callback-in-wait-for": "warn",
|
|
@@ -10068,6 +10255,7 @@ plugin.configs.strict = {
|
|
|
10068
10255
|
var index_default = plugin;
|
|
10069
10256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10070
10257
|
0 && (module.exports = {
|
|
10258
|
+
applicationOnlyRules,
|
|
10071
10259
|
recommendedRules,
|
|
10072
10260
|
renamedRules,
|
|
10073
10261
|
retiredRules,
|