@sarj/eslint-plugin 9.2.0 → 9.4.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 +1 -0
- package/dist/index.cjs +588 -358
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +583 -353
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -534,7 +534,72 @@ function restatesStatementHead(body, statement) {
|
|
|
534
534
|
// src/rules/no-comment-cruft.ts
|
|
535
535
|
var LEADING_PREAMBLE_MIN = 4;
|
|
536
536
|
var STEP_NARRATION_RE = /^(?:first(?:ly)?|second(?:ly)?|third(?:ly)?|then|next|after(?:wards| that)?|finally|lastly|now)\s*[,:]\s*\S/i;
|
|
537
|
-
var META_COMMENTARY_RE = /\b(?:
|
|
537
|
+
var META_COMMENTARY_RE = /\b(?:keeping (?:it|this) simple|could be (?:refactored|improved|cleaned up|simplified)|refactor(?:ed|ing)? (?:later|this)|not sure (?:if|whether|why|how)|quick[- ](?:and[- ]dirty|fix)|(?:a |bit of a )?hacky|is a hack|temporary (?:solution|workaround|fix|hack)|revisit (?:this|later|below)|clean (?:this|it) up|not ideal|placeholder for now)\b/i;
|
|
538
|
+
var FOR_NOW_RE = /\bfor now\b/i;
|
|
539
|
+
var DEFERRAL_STOPWORDS = /* @__PURE__ */ new Set([
|
|
540
|
+
"a",
|
|
541
|
+
"an",
|
|
542
|
+
"and",
|
|
543
|
+
"are",
|
|
544
|
+
"as",
|
|
545
|
+
"at",
|
|
546
|
+
"be",
|
|
547
|
+
"but",
|
|
548
|
+
"by",
|
|
549
|
+
"can",
|
|
550
|
+
"could",
|
|
551
|
+
"do",
|
|
552
|
+
"does",
|
|
553
|
+
"for",
|
|
554
|
+
"from",
|
|
555
|
+
"had",
|
|
556
|
+
"has",
|
|
557
|
+
"have",
|
|
558
|
+
"here",
|
|
559
|
+
"i",
|
|
560
|
+
"in",
|
|
561
|
+
"is",
|
|
562
|
+
"it",
|
|
563
|
+
"its",
|
|
564
|
+
"just",
|
|
565
|
+
"may",
|
|
566
|
+
"might",
|
|
567
|
+
"no",
|
|
568
|
+
"not",
|
|
569
|
+
"now",
|
|
570
|
+
"of",
|
|
571
|
+
"on",
|
|
572
|
+
"only",
|
|
573
|
+
"our",
|
|
574
|
+
"shall",
|
|
575
|
+
"should",
|
|
576
|
+
"so",
|
|
577
|
+
"still",
|
|
578
|
+
"that",
|
|
579
|
+
"the",
|
|
580
|
+
"then",
|
|
581
|
+
"there",
|
|
582
|
+
"this",
|
|
583
|
+
"to",
|
|
584
|
+
"us",
|
|
585
|
+
"was",
|
|
586
|
+
"we",
|
|
587
|
+
"were",
|
|
588
|
+
"will",
|
|
589
|
+
"with",
|
|
590
|
+
"would",
|
|
591
|
+
"you",
|
|
592
|
+
"your"
|
|
593
|
+
]);
|
|
594
|
+
var DEFERRAL_MAX_CONTENT_WORDS = 2;
|
|
595
|
+
function isBareDeferral(text) {
|
|
596
|
+
if (!FOR_NOW_RE.test(text)) return false;
|
|
597
|
+
const rest = text.replace(FOR_NOW_RE, " ");
|
|
598
|
+
const content = (rest.match(/[A-Za-z][\w']*/g) ?? []).filter(
|
|
599
|
+
(word) => !DEFERRAL_STOPWORDS.has(word.toLowerCase())
|
|
600
|
+
);
|
|
601
|
+
return content.length <= DEFERRAL_MAX_CONTENT_WORDS;
|
|
602
|
+
}
|
|
538
603
|
var DIRECTIVE_RE = /^(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|hack\b|xxx\b)/i;
|
|
539
604
|
var LICENSE_RE = /copyright|licen[cs]ed?|spdx|permission is hereby granted|all rights reserved/i;
|
|
540
605
|
var ENUMERATED_ITEM_RE = /^(?:\d+[.):]|[-*•])\s+\S/;
|
|
@@ -599,6 +664,7 @@ function isSectionLabel(text) {
|
|
|
599
664
|
const match = SECTION_LABEL_RE.exec(text);
|
|
600
665
|
return match !== null && SECTION_LABEL_WORDS.has((match[1] ?? "").toLowerCase());
|
|
601
666
|
}
|
|
667
|
+
var SHOUTED_LABEL_RE = /^[A-Z]{2,}(?:[ -][A-Z]{2,}){1,3}$/;
|
|
602
668
|
var HELPER_OPENER_RE = /^(?:a\s+)?helper\s+(?:function|method|component|hook|class|type|util(?:ity)?)\b/i;
|
|
603
669
|
var LETS_RE = /^let'?s\s+(?:not\s+|just\s+|now\s+|first\s+)?(?:add|append|assign|await|build|calculate|call|check|clear|close|compute|convert|copy|count|create|declare|decrement|define|delete|extract|fetch|filter|find|format|generate|get|handle|increment|init|initialise|initialize|insert|iterate|join|load|log|loop|map|merge|open|parse|print|process|push|read|remove|render|reset|return|save|send|set|setup|sort|split|start|stop|store|update|validate|wrap|write)(?:s|es|ed|ing)?\b/i;
|
|
604
670
|
var ENUMERATION_RE = /^(?:\d+[.)]\s+\S|(?:phase|step)\s+\d+\b)/i;
|
|
@@ -655,6 +721,7 @@ function isRedundantNarration(body, statementBelow, standalone, isolatedEnumerat
|
|
|
655
721
|
const justified = JUSTIFICATION_RE.test(t);
|
|
656
722
|
if (STEP_NARRATION_RE.test(t) && !justified) return true;
|
|
657
723
|
if (META_COMMENTARY_RE.test(t) && !justified) return true;
|
|
724
|
+
if (isBareDeferral(t) && !justified) return true;
|
|
658
725
|
if (HELPER_OPENER_RE.test(t) || LETS_RE.test(t)) return true;
|
|
659
726
|
const words = t.split(/\s+/);
|
|
660
727
|
if (words.length > 1 && words.length <= 4 && DUMMY_TRANSLATION_RE.test(t) && !/[():=]/.test(t)) {
|
|
@@ -752,6 +819,12 @@ var no_comment_cruft_default = createRule({
|
|
|
752
819
|
function isJsDoc(comment) {
|
|
753
820
|
return comment.type === "Block" && /^\*/.test(comment.value);
|
|
754
821
|
}
|
|
822
|
+
function isSectionJsDoc(comment) {
|
|
823
|
+
const texts = comment.value.split("\n").map(stripCommentMarker).filter((line) => line.length > 0 && !isDirective(line));
|
|
824
|
+
return texts.length > 0 && texts.every(
|
|
825
|
+
(text) => !isProtected(text) && (isBanner(text) || isSectionLabel(text) || SHOUTED_LABEL_RE.test(text.replace(/[.:]$/, "")))
|
|
826
|
+
);
|
|
827
|
+
}
|
|
755
828
|
function reportLeadingPreamble(comments, firstCodeLine) {
|
|
756
829
|
const leading = [];
|
|
757
830
|
let prevLine = null;
|
|
@@ -785,7 +858,13 @@ var no_comment_cruft_default = createRule({
|
|
|
785
858
|
for (let i = 0; i < comments.length; i++) {
|
|
786
859
|
const comment = comments[i];
|
|
787
860
|
if (comment === void 0) continue;
|
|
788
|
-
if (isJsDoc(comment)
|
|
861
|
+
if (isJsDoc(comment)) {
|
|
862
|
+
if (isStandalone(comment) && isSectionJsDoc(comment)) {
|
|
863
|
+
context.report({ node: comment, messageId: "sectionBanner" });
|
|
864
|
+
}
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
if (!isStandalone(comment)) continue;
|
|
789
868
|
if (LICENSE_RE.test(comment.value)) continue;
|
|
790
869
|
const texts = comment.value.split("\n").map(stripCommentMarker).filter((l) => l.length > 0 && !isDirective(l));
|
|
791
870
|
const firstText = texts[0];
|
|
@@ -5260,10 +5339,158 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5260
5339
|
}
|
|
5261
5340
|
});
|
|
5262
5341
|
|
|
5263
|
-
// src/rules/no-
|
|
5342
|
+
// src/rules/no-union-in-comment.ts
|
|
5264
5343
|
var import_utils36 = require("@typescript-eslint/utils");
|
|
5344
|
+
var MAX_LITERAL_LENGTH = 28;
|
|
5345
|
+
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5346
|
+
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
5347
|
+
var UNION_BODY_RE = new RegExp(String.raw`^${LITERAL}(?:\s*[|,/]\s*${LITERAL})+\.?$`);
|
|
5348
|
+
var LITERAL_G = new RegExp(LITERAL, "g");
|
|
5349
|
+
var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
5350
|
+
"char",
|
|
5351
|
+
"citext",
|
|
5352
|
+
"longtext",
|
|
5353
|
+
"mediumtext",
|
|
5354
|
+
"string",
|
|
5355
|
+
"text",
|
|
5356
|
+
"tinytext",
|
|
5357
|
+
"varchar"
|
|
5358
|
+
]);
|
|
5359
|
+
function isBareString(node) {
|
|
5360
|
+
if (node === void 0) return false;
|
|
5361
|
+
switch (node.type) {
|
|
5362
|
+
case import_utils36.AST_NODE_TYPES.TSStringKeyword:
|
|
5363
|
+
return true;
|
|
5364
|
+
// `string[]` holds members of the same closed set, one element at a time.
|
|
5365
|
+
case import_utils36.AST_NODE_TYPES.TSArrayType:
|
|
5366
|
+
return isBareString(node.elementType);
|
|
5367
|
+
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5368
|
+
// — the checker collapses that one to `string`.
|
|
5369
|
+
case import_utils36.AST_NODE_TYPES.TSUnionType:
|
|
5370
|
+
return node.types.some((member) => isBareString(member));
|
|
5371
|
+
default:
|
|
5372
|
+
return false;
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
function rootCallee(node) {
|
|
5376
|
+
let current = node;
|
|
5377
|
+
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5378
|
+
switch (current.type) {
|
|
5379
|
+
case import_utils36.AST_NODE_TYPES.CallExpression:
|
|
5380
|
+
current = current.callee;
|
|
5381
|
+
break;
|
|
5382
|
+
case import_utils36.AST_NODE_TYPES.MemberExpression:
|
|
5383
|
+
current = current.object;
|
|
5384
|
+
break;
|
|
5385
|
+
case import_utils36.AST_NODE_TYPES.Identifier:
|
|
5386
|
+
return current.name;
|
|
5387
|
+
default:
|
|
5388
|
+
return null;
|
|
5389
|
+
}
|
|
5390
|
+
}
|
|
5391
|
+
return null;
|
|
5392
|
+
}
|
|
5393
|
+
function nameOf(key) {
|
|
5394
|
+
if (key.type === import_utils36.AST_NODE_TYPES.Identifier) return key.name;
|
|
5395
|
+
if (key.type === import_utils36.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
5396
|
+
return null;
|
|
5397
|
+
}
|
|
5398
|
+
function targetOf(node) {
|
|
5399
|
+
switch (node.type) {
|
|
5400
|
+
case import_utils36.AST_NODE_TYPES.TSPropertySignature:
|
|
5401
|
+
case import_utils36.AST_NODE_TYPES.PropertyDefinition: {
|
|
5402
|
+
const name = node.computed ? null : nameOf(node.key);
|
|
5403
|
+
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5404
|
+
return { node, name };
|
|
5405
|
+
}
|
|
5406
|
+
case import_utils36.AST_NODE_TYPES.Property: {
|
|
5407
|
+
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5408
|
+
const callee = rootCallee(node.value);
|
|
5409
|
+
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5410
|
+
return { node, name };
|
|
5411
|
+
}
|
|
5412
|
+
case import_utils36.AST_NODE_TYPES.VariableDeclarator: {
|
|
5413
|
+
if (node.id.type !== import_utils36.AST_NODE_TYPES.Identifier) return null;
|
|
5414
|
+
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5415
|
+
return { node, name: node.id.name };
|
|
5416
|
+
}
|
|
5417
|
+
default:
|
|
5418
|
+
return null;
|
|
5419
|
+
}
|
|
5420
|
+
}
|
|
5421
|
+
function unionLiterals(body) {
|
|
5422
|
+
const list = body.replace(LEAD_IN_RE2, "").trim();
|
|
5423
|
+
if (!UNION_BODY_RE.test(list)) return null;
|
|
5424
|
+
const literals = (list.match(LITERAL_G) ?? []).map((raw) => raw.slice(1, -1));
|
|
5425
|
+
if (literals.some((literal) => literal.length === 0 || literal.length > MAX_LITERAL_LENGTH)) {
|
|
5426
|
+
return null;
|
|
5427
|
+
}
|
|
5428
|
+
return literals;
|
|
5429
|
+
}
|
|
5430
|
+
var no_union_in_comment_default = createRule({
|
|
5431
|
+
name: "no-union-in-comment",
|
|
5432
|
+
meta: {
|
|
5433
|
+
type: "suggestion",
|
|
5434
|
+
docs: {
|
|
5435
|
+
description: "Flag a comment that lists a `string` field's allowed values instead of the type listing them."
|
|
5436
|
+
},
|
|
5437
|
+
schema: [],
|
|
5438
|
+
messages: {
|
|
5439
|
+
unionInComment: 'This comment is a type \u2014 `{{name}}` still accepts every string, so the set it lists is enforced by nobody. Make it a string-literal union ("{{first}}" | \u2026) and delete the comment.'
|
|
5440
|
+
}
|
|
5441
|
+
},
|
|
5442
|
+
defaultOptions: [],
|
|
5443
|
+
create(context) {
|
|
5444
|
+
const sourceCode = context.sourceCode;
|
|
5445
|
+
if (isGeneratedFile(context.filename, sourceCode.text)) {
|
|
5446
|
+
return {};
|
|
5447
|
+
}
|
|
5448
|
+
function annotated(comment) {
|
|
5449
|
+
const before = sourceCode.getTokenBefore(comment, { includeComments: false });
|
|
5450
|
+
let anchor;
|
|
5451
|
+
if (before !== null && before.loc.end.line === comment.loc.start.line) {
|
|
5452
|
+
let token = before;
|
|
5453
|
+
while (token !== null && (token.value === "," || token.value === ";")) {
|
|
5454
|
+
token = sourceCode.getTokenBefore(token, { includeComments: false });
|
|
5455
|
+
}
|
|
5456
|
+
anchor = token === null ? null : sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
5457
|
+
} else {
|
|
5458
|
+
const after = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
5459
|
+
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5460
|
+
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5461
|
+
}
|
|
5462
|
+
for (let node = anchor; node != null && node.type !== import_utils36.AST_NODE_TYPES.Program; node = node.parent) {
|
|
5463
|
+
const target = targetOf(node);
|
|
5464
|
+
if (target !== null) return target;
|
|
5465
|
+
}
|
|
5466
|
+
return null;
|
|
5467
|
+
}
|
|
5468
|
+
return {
|
|
5469
|
+
Program() {
|
|
5470
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
5471
|
+
const body = comment.value.replace(/^\*+/, "").replace(/\*+$/, "").trim();
|
|
5472
|
+
if (body.length === 0) continue;
|
|
5473
|
+
const literals = unionLiterals(body);
|
|
5474
|
+
if (literals === null) continue;
|
|
5475
|
+
const target = annotated(comment);
|
|
5476
|
+
if (target === null) continue;
|
|
5477
|
+
const declaration = sourceCode.getText(target.node);
|
|
5478
|
+
if (literals.every((literal) => declaration.includes(literal))) continue;
|
|
5479
|
+
context.report({
|
|
5480
|
+
node: comment,
|
|
5481
|
+
messageId: "unionInComment",
|
|
5482
|
+
data: { name: target.name, first: literals[0] ?? "" }
|
|
5483
|
+
});
|
|
5484
|
+
}
|
|
5485
|
+
}
|
|
5486
|
+
};
|
|
5487
|
+
}
|
|
5488
|
+
});
|
|
5489
|
+
|
|
5490
|
+
// src/rules/no-type-member-comment-wall.ts
|
|
5491
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5265
5492
|
function isNamedMember(node) {
|
|
5266
|
-
return (node.type ===
|
|
5493
|
+
return (node.type === import_utils37.AST_NODE_TYPES.TSPropertySignature || node.type === import_utils37.AST_NODE_TYPES.TSMethodSignature) && !node.computed;
|
|
5267
5494
|
}
|
|
5268
5495
|
var no_type_member_comment_wall_default = createRule({
|
|
5269
5496
|
name: "no-type-member-comment-wall",
|
|
@@ -5310,7 +5537,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5310
5537
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5311
5538
|
}
|
|
5312
5539
|
function check(node) {
|
|
5313
|
-
const members = node.type ===
|
|
5540
|
+
const members = node.type === import_utils37.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
|
5314
5541
|
const named2 = members.filter(isNamedMember);
|
|
5315
5542
|
if (named2.length === 0) return;
|
|
5316
5543
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5350,7 +5577,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5350
5577
|
});
|
|
5351
5578
|
|
|
5352
5579
|
// src/rules/no-unnecessary-use-client.ts
|
|
5353
|
-
var
|
|
5580
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5354
5581
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5355
5582
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5356
5583
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -5376,13 +5603,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
5376
5603
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
5377
5604
|
var jsxRootName = (name) => {
|
|
5378
5605
|
let current = name;
|
|
5379
|
-
while (current.type ===
|
|
5606
|
+
while (current.type === import_utils38.AST_NODE_TYPES.JSXMemberExpression) {
|
|
5380
5607
|
current = current.object;
|
|
5381
5608
|
}
|
|
5382
|
-
return current.type ===
|
|
5609
|
+
return current.type === import_utils38.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
5383
5610
|
};
|
|
5384
5611
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
5385
|
-
if (node.type ===
|
|
5612
|
+
if (node.type === import_utils38.AST_NODE_TYPES.Identifier) {
|
|
5386
5613
|
return imported.has(node.name);
|
|
5387
5614
|
}
|
|
5388
5615
|
for (const key of Object.keys(node)) {
|
|
@@ -5397,16 +5624,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
5397
5624
|
return false;
|
|
5398
5625
|
};
|
|
5399
5626
|
var isUseClientDirective = (node) => {
|
|
5400
|
-
return node.type ===
|
|
5627
|
+
return node.type === import_utils38.AST_NODE_TYPES.ExpressionStatement && node.expression.type === import_utils38.AST_NODE_TYPES.Literal && node.expression.value === "use client";
|
|
5401
5628
|
};
|
|
5402
5629
|
var isGlobalReference = (node, context) => {
|
|
5403
5630
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
5404
5631
|
const parent = node.parent;
|
|
5405
5632
|
if (parent !== void 0) {
|
|
5406
|
-
if (parent.type ===
|
|
5633
|
+
if (parent.type === import_utils38.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
5407
5634
|
return false;
|
|
5408
5635
|
}
|
|
5409
|
-
if (parent.type ===
|
|
5636
|
+
if (parent.type === import_utils38.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
5410
5637
|
return false;
|
|
5411
5638
|
}
|
|
5412
5639
|
if (parent.type.startsWith("TS")) {
|
|
@@ -5446,13 +5673,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5446
5673
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
5447
5674
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
5448
5675
|
const markIfHookOrContext = (callee) => {
|
|
5449
|
-
if (callee.type ===
|
|
5676
|
+
if (callee.type === import_utils38.AST_NODE_TYPES.Identifier) {
|
|
5450
5677
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
5451
5678
|
hasClientIndicator = true;
|
|
5452
5679
|
}
|
|
5453
5680
|
return;
|
|
5454
5681
|
}
|
|
5455
|
-
if (callee.type ===
|
|
5682
|
+
if (callee.type === import_utils38.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils38.AST_NODE_TYPES.Identifier) {
|
|
5456
5683
|
const name = callee.property.name;
|
|
5457
5684
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
5458
5685
|
hasClientIndicator = true;
|
|
@@ -5462,7 +5689,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5462
5689
|
return {
|
|
5463
5690
|
Program(node) {
|
|
5464
5691
|
for (const stmt of node.body) {
|
|
5465
|
-
if (stmt.type !==
|
|
5692
|
+
if (stmt.type !== import_utils38.AST_NODE_TYPES.ExpressionStatement) break;
|
|
5466
5693
|
if (isUseClientDirective(stmt)) {
|
|
5467
5694
|
directiveNode = stmt;
|
|
5468
5695
|
break;
|
|
@@ -5475,7 +5702,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5475
5702
|
},
|
|
5476
5703
|
JSXAttribute(node) {
|
|
5477
5704
|
if (directiveNode === null) return;
|
|
5478
|
-
if (node.name.type ===
|
|
5705
|
+
if (node.name.type === import_utils38.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
5479
5706
|
hasClientIndicator = true;
|
|
5480
5707
|
}
|
|
5481
5708
|
},
|
|
@@ -5542,18 +5769,18 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5542
5769
|
});
|
|
5543
5770
|
|
|
5544
5771
|
// src/rules/no-unsafe-mock-casting.ts
|
|
5545
|
-
var import_utils38 = require("@typescript-eslint/utils");
|
|
5546
5772
|
var import_utils39 = require("@typescript-eslint/utils");
|
|
5773
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
5547
5774
|
function isMockTypeReference(node) {
|
|
5548
|
-
if (node.type !==
|
|
5775
|
+
if (node.type !== import_utils40.AST_NODE_TYPES.TSTypeReference) {
|
|
5549
5776
|
return false;
|
|
5550
5777
|
}
|
|
5551
5778
|
const typeName = node.typeName;
|
|
5552
|
-
if (typeName.type ===
|
|
5779
|
+
if (typeName.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5553
5780
|
const name = typeName.name;
|
|
5554
5781
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
5555
5782
|
}
|
|
5556
|
-
if (typeName.type ===
|
|
5783
|
+
if (typeName.type === import_utils40.AST_NODE_TYPES.TSQualifiedName) {
|
|
5557
5784
|
const rightName = typeName.right.name;
|
|
5558
5785
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
5559
5786
|
}
|
|
@@ -5589,7 +5816,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
5589
5816
|
});
|
|
5590
5817
|
|
|
5591
5818
|
// src/rules/no-zod-native-enum.ts
|
|
5592
|
-
var
|
|
5819
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
5593
5820
|
var ts = __toESM(require("typescript"), 1);
|
|
5594
5821
|
var IGNORE_PATTERNS = [
|
|
5595
5822
|
/[\\/]generated[\\/]/,
|
|
@@ -5607,7 +5834,7 @@ function isZodModule(source) {
|
|
|
5607
5834
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
5608
5835
|
}
|
|
5609
5836
|
function unwrap2(node) {
|
|
5610
|
-
if (node.type ===
|
|
5837
|
+
if (node.type === import_utils41.AST_NODE_TYPES.TSAsExpression || node.type === import_utils41.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
5611
5838
|
return unwrap2(node.expression);
|
|
5612
5839
|
}
|
|
5613
5840
|
return node;
|
|
@@ -5615,14 +5842,14 @@ function unwrap2(node) {
|
|
|
5615
5842
|
function stringValueTexts(node, sourceCode) {
|
|
5616
5843
|
const texts = [];
|
|
5617
5844
|
for (const prop of node.properties) {
|
|
5618
|
-
if (prop.type !==
|
|
5845
|
+
if (prop.type !== import_utils41.AST_NODE_TYPES.Property) {
|
|
5619
5846
|
return null;
|
|
5620
5847
|
}
|
|
5621
5848
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
5622
5849
|
return null;
|
|
5623
5850
|
}
|
|
5624
5851
|
const value = prop.value;
|
|
5625
|
-
if (value.type !==
|
|
5852
|
+
if (value.type !== import_utils41.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
5626
5853
|
return null;
|
|
5627
5854
|
}
|
|
5628
5855
|
const text = sourceCode.getText(value);
|
|
@@ -5638,7 +5865,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
5638
5865
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
5639
5866
|
if (variable !== void 0) {
|
|
5640
5867
|
return variable.defs.some(
|
|
5641
|
-
(def) => def.node.type ===
|
|
5868
|
+
(def) => def.node.type === import_utils41.AST_NODE_TYPES.TSEnumDeclaration
|
|
5642
5869
|
);
|
|
5643
5870
|
}
|
|
5644
5871
|
current = current.upper;
|
|
@@ -5683,32 +5910,32 @@ var no_zod_native_enum_default = createRule({
|
|
|
5683
5910
|
}
|
|
5684
5911
|
let services;
|
|
5685
5912
|
try {
|
|
5686
|
-
services =
|
|
5913
|
+
services = import_utils41.ESLintUtils.getParserServices(context);
|
|
5687
5914
|
} catch {
|
|
5688
5915
|
services = null;
|
|
5689
5916
|
}
|
|
5690
5917
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
5691
5918
|
function isZodMemberCall(node, api) {
|
|
5692
5919
|
const callee = node.callee;
|
|
5693
|
-
if (callee.type ===
|
|
5920
|
+
if (callee.type === import_utils41.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5694
5921
|
return callee.property.name === api;
|
|
5695
5922
|
}
|
|
5696
|
-
if (callee.type ===
|
|
5923
|
+
if (callee.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5697
5924
|
return zodImportedNames.get(callee.name) === api;
|
|
5698
5925
|
}
|
|
5699
5926
|
return false;
|
|
5700
5927
|
}
|
|
5701
5928
|
function buildFix(node) {
|
|
5702
5929
|
const callee = node.callee;
|
|
5703
|
-
if (callee.type !==
|
|
5930
|
+
if (callee.type !== import_utils41.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5704
5931
|
return null;
|
|
5705
5932
|
}
|
|
5706
5933
|
const arg = node.arguments[0];
|
|
5707
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
5934
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === import_utils41.AST_NODE_TYPES.SpreadElement) {
|
|
5708
5935
|
return null;
|
|
5709
5936
|
}
|
|
5710
5937
|
const inner = unwrap2(arg);
|
|
5711
|
-
if (inner.type !==
|
|
5938
|
+
if (inner.type !== import_utils41.AST_NODE_TYPES.ObjectExpression) {
|
|
5712
5939
|
return null;
|
|
5713
5940
|
}
|
|
5714
5941
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -5728,7 +5955,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5728
5955
|
return;
|
|
5729
5956
|
}
|
|
5730
5957
|
for (const spec of node.specifiers) {
|
|
5731
|
-
if (spec.type ===
|
|
5958
|
+
if (spec.type === import_utils41.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5732
5959
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
5733
5960
|
}
|
|
5734
5961
|
}
|
|
@@ -5747,7 +5974,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5747
5974
|
return;
|
|
5748
5975
|
}
|
|
5749
5976
|
const arg = node.arguments[0];
|
|
5750
|
-
if (arg === void 0 || arg.type !==
|
|
5977
|
+
if (arg === void 0 || arg.type !== import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5751
5978
|
return;
|
|
5752
5979
|
}
|
|
5753
5980
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -5764,7 +5991,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5764
5991
|
});
|
|
5765
5992
|
|
|
5766
5993
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
5767
|
-
var
|
|
5994
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
5768
5995
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
5769
5996
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
5770
5997
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -5777,36 +6004,36 @@ function isConstantReference(identifier) {
|
|
|
5777
6004
|
}
|
|
5778
6005
|
function isExcludedOperand(node) {
|
|
5779
6006
|
switch (node.type) {
|
|
5780
|
-
case
|
|
6007
|
+
case import_utils42.AST_NODE_TYPES.Literal:
|
|
5781
6008
|
return true;
|
|
5782
|
-
case
|
|
6009
|
+
case import_utils42.AST_NODE_TYPES.TemplateLiteral:
|
|
5783
6010
|
return node.expressions.length === 0;
|
|
5784
|
-
case
|
|
6011
|
+
case import_utils42.AST_NODE_TYPES.Identifier:
|
|
5785
6012
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
5786
|
-
case
|
|
5787
|
-
return !node.computed && node.property.type ===
|
|
6013
|
+
case import_utils42.AST_NODE_TYPES.MemberExpression:
|
|
6014
|
+
return !node.computed && node.property.type === import_utils42.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
5788
6015
|
default:
|
|
5789
6016
|
return false;
|
|
5790
6017
|
}
|
|
5791
6018
|
}
|
|
5792
6019
|
function operandName(node) {
|
|
5793
|
-
if (node.type ===
|
|
6020
|
+
if (node.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5794
6021
|
return node.name;
|
|
5795
6022
|
}
|
|
5796
|
-
if (node.type ===
|
|
6023
|
+
if (node.type === import_utils42.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5797
6024
|
return node.property.name;
|
|
5798
6025
|
}
|
|
5799
6026
|
return null;
|
|
5800
6027
|
}
|
|
5801
6028
|
function isSecretOperand(node) {
|
|
5802
|
-
if (node.type ===
|
|
6029
|
+
if (node.type === import_utils42.AST_NODE_TYPES.TemplateLiteral) {
|
|
5803
6030
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
5804
6031
|
}
|
|
5805
6032
|
const name = operandName(node);
|
|
5806
6033
|
return name !== null && isAuthSecretName(name);
|
|
5807
6034
|
}
|
|
5808
6035
|
function secretNameOf(node) {
|
|
5809
|
-
if (node.type ===
|
|
6036
|
+
if (node.type === import_utils42.AST_NODE_TYPES.TemplateLiteral) {
|
|
5810
6037
|
for (const expression of node.expressions) {
|
|
5811
6038
|
const nested = secretNameOf(expression);
|
|
5812
6039
|
if (nested !== null) {
|
|
@@ -5858,8 +6085,8 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
5858
6085
|
});
|
|
5859
6086
|
|
|
5860
6087
|
// src/rules/prefer-discriminated-union.ts
|
|
5861
|
-
var import_utils42 = require("@typescript-eslint/utils");
|
|
5862
6088
|
var import_utils43 = require("@typescript-eslint/utils");
|
|
6089
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
5863
6090
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
5864
6091
|
"success",
|
|
5865
6092
|
"ok",
|
|
@@ -5869,27 +6096,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
5869
6096
|
]);
|
|
5870
6097
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
5871
6098
|
function getMemberName(member) {
|
|
5872
|
-
if (member.type !==
|
|
6099
|
+
if (member.type !== import_utils44.AST_NODE_TYPES.TSPropertySignature) {
|
|
5873
6100
|
return null;
|
|
5874
6101
|
}
|
|
5875
6102
|
const { key } = member;
|
|
5876
|
-
if (key.type ===
|
|
6103
|
+
if (key.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
5877
6104
|
return key.name;
|
|
5878
6105
|
}
|
|
5879
|
-
if (key.type ===
|
|
6106
|
+
if (key.type === import_utils44.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
5880
6107
|
return key.value;
|
|
5881
6108
|
}
|
|
5882
6109
|
return null;
|
|
5883
6110
|
}
|
|
5884
6111
|
function isBooleanTyped(member) {
|
|
5885
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6112
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils44.AST_NODE_TYPES.TSBooleanKeyword;
|
|
5886
6113
|
}
|
|
5887
6114
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
5888
6115
|
let hasStatusBoolean = false;
|
|
5889
6116
|
let optionalCount = 0;
|
|
5890
6117
|
let optionalPayloadCount = 0;
|
|
5891
6118
|
for (const member of typeLiteral.members) {
|
|
5892
|
-
if (member.type !==
|
|
6119
|
+
if (member.type !== import_utils44.AST_NODE_TYPES.TSPropertySignature) {
|
|
5893
6120
|
continue;
|
|
5894
6121
|
}
|
|
5895
6122
|
if (member.optional) {
|
|
@@ -5931,7 +6158,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
5931
6158
|
TSInterfaceDeclaration(node) {
|
|
5932
6159
|
const synthetic = {
|
|
5933
6160
|
...node.body,
|
|
5934
|
-
type:
|
|
6161
|
+
type: import_utils44.AST_NODE_TYPES.TSTypeLiteral,
|
|
5935
6162
|
members: node.body.body
|
|
5936
6163
|
};
|
|
5937
6164
|
checkTypeLiteral(synthetic, node);
|
|
@@ -5944,7 +6171,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
5944
6171
|
});
|
|
5945
6172
|
|
|
5946
6173
|
// src/rules/prefer-module-level-constant.ts
|
|
5947
|
-
var
|
|
6174
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
5948
6175
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
5949
6176
|
var MAX_LITERAL_DEPTH = 4;
|
|
5950
6177
|
var IGNORE_PATTERNS2 = [
|
|
@@ -5973,9 +6200,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
5973
6200
|
"assign"
|
|
5974
6201
|
]);
|
|
5975
6202
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
6203
|
+
import_utils45.AST_NODE_TYPES.FunctionDeclaration,
|
|
6204
|
+
import_utils45.AST_NODE_TYPES.FunctionExpression,
|
|
6205
|
+
import_utils45.AST_NODE_TYPES.ArrowFunctionExpression
|
|
5979
6206
|
]);
|
|
5980
6207
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
5981
6208
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -5988,14 +6215,14 @@ function isLocalFixtureFile(filename) {
|
|
|
5988
6215
|
return isTestFile(filename) || isStoryFile(filename);
|
|
5989
6216
|
}
|
|
5990
6217
|
function unwrap3(node) {
|
|
5991
|
-
if (node.type ===
|
|
6218
|
+
if (node.type === import_utils45.AST_NODE_TYPES.TSAsExpression || node.type === import_utils45.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils45.AST_NODE_TYPES.TSNonNullExpression) {
|
|
5992
6219
|
return unwrap3(node.expression);
|
|
5993
6220
|
}
|
|
5994
6221
|
return node;
|
|
5995
6222
|
}
|
|
5996
6223
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
5997
6224
|
function isRegexLiteral(node) {
|
|
5998
|
-
return node.type ===
|
|
6225
|
+
return node.type === import_utils45.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
5999
6226
|
}
|
|
6000
6227
|
function isLiteralOnly(node, depth) {
|
|
6001
6228
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6003,29 +6230,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6003
6230
|
}
|
|
6004
6231
|
const inner = unwrap3(node);
|
|
6005
6232
|
switch (inner.type) {
|
|
6006
|
-
case
|
|
6233
|
+
case import_utils45.AST_NODE_TYPES.Literal: {
|
|
6007
6234
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6008
6235
|
}
|
|
6009
|
-
case
|
|
6236
|
+
case import_utils45.AST_NODE_TYPES.TemplateLiteral: {
|
|
6010
6237
|
return inner.expressions.length === 0;
|
|
6011
6238
|
}
|
|
6012
|
-
case
|
|
6013
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6239
|
+
case import_utils45.AST_NODE_TYPES.UnaryExpression: {
|
|
6240
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils45.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6014
6241
|
}
|
|
6015
|
-
case
|
|
6242
|
+
case import_utils45.AST_NODE_TYPES.ArrayExpression: {
|
|
6016
6243
|
return inner.elements.every(
|
|
6017
|
-
(el) => el !== null && el.type !==
|
|
6244
|
+
(el) => el !== null && el.type !== import_utils45.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6018
6245
|
);
|
|
6019
6246
|
}
|
|
6020
|
-
case
|
|
6247
|
+
case import_utils45.AST_NODE_TYPES.ObjectExpression: {
|
|
6021
6248
|
return inner.properties.every((prop) => {
|
|
6022
|
-
if (prop.type !==
|
|
6249
|
+
if (prop.type !== import_utils45.AST_NODE_TYPES.Property) {
|
|
6023
6250
|
return false;
|
|
6024
6251
|
}
|
|
6025
6252
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6026
6253
|
return false;
|
|
6027
6254
|
}
|
|
6028
|
-
if (prop.computed && prop.key.type !==
|
|
6255
|
+
if (prop.computed && prop.key.type !== import_utils45.AST_NODE_TYPES.Literal) {
|
|
6029
6256
|
return false;
|
|
6030
6257
|
}
|
|
6031
6258
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6038,7 +6265,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6038
6265
|
}
|
|
6039
6266
|
function unwrapObjectFreeze(node) {
|
|
6040
6267
|
const inner = unwrap3(node);
|
|
6041
|
-
if (inner.type ===
|
|
6268
|
+
if (inner.type === import_utils45.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils45.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils45.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils45.AST_NODE_TYPES.SpreadElement) {
|
|
6042
6269
|
return unwrap3(inner.arguments[0]);
|
|
6043
6270
|
}
|
|
6044
6271
|
return inner;
|
|
@@ -6054,19 +6281,19 @@ function classify(init, checkRegex) {
|
|
|
6054
6281
|
}
|
|
6055
6282
|
return { kind: "regex", size: 1 };
|
|
6056
6283
|
}
|
|
6057
|
-
if (node.type ===
|
|
6284
|
+
if (node.type === import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
6058
6285
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6059
6286
|
}
|
|
6060
|
-
if (node.type ===
|
|
6287
|
+
if (node.type === import_utils45.AST_NODE_TYPES.ObjectExpression) {
|
|
6061
6288
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6062
6289
|
}
|
|
6063
|
-
if (node.type ===
|
|
6290
|
+
if (node.type === import_utils45.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils45.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6064
6291
|
const arg = node.arguments[0];
|
|
6065
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6292
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils45.AST_NODE_TYPES.SpreadElement) {
|
|
6066
6293
|
return null;
|
|
6067
6294
|
}
|
|
6068
6295
|
const entries = unwrap3(arg);
|
|
6069
|
-
if (entries.type !==
|
|
6296
|
+
if (entries.type !== import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
6070
6297
|
return null;
|
|
6071
6298
|
}
|
|
6072
6299
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6095,10 +6322,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6095
6322
|
);
|
|
6096
6323
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6097
6324
|
const callee = node.callee;
|
|
6098
|
-
if (callee.type ===
|
|
6325
|
+
if (callee.type === import_utils45.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6099
6326
|
return true;
|
|
6100
6327
|
}
|
|
6101
|
-
if (callee.type !==
|
|
6328
|
+
if (callee.type !== import_utils45.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils45.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6102
6329
|
return false;
|
|
6103
6330
|
}
|
|
6104
6331
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6112,38 +6339,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6112
6339
|
}
|
|
6113
6340
|
function isSafeRead(identifier) {
|
|
6114
6341
|
const parent = identifier.parent;
|
|
6115
|
-
if (parent.type ===
|
|
6342
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.MemberExpression) {
|
|
6116
6343
|
if (parent.object !== identifier) {
|
|
6117
6344
|
return true;
|
|
6118
6345
|
}
|
|
6119
6346
|
const grandparent = parent.parent;
|
|
6120
|
-
if (grandparent.type ===
|
|
6347
|
+
if (grandparent.type === import_utils45.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6121
6348
|
return false;
|
|
6122
6349
|
}
|
|
6123
|
-
if (grandparent.type ===
|
|
6350
|
+
if (grandparent.type === import_utils45.AST_NODE_TYPES.UpdateExpression) {
|
|
6124
6351
|
return false;
|
|
6125
6352
|
}
|
|
6126
|
-
if (grandparent.type ===
|
|
6353
|
+
if (grandparent.type === import_utils45.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6127
6354
|
return false;
|
|
6128
6355
|
}
|
|
6129
|
-
if (!parent.computed && parent.property.type ===
|
|
6356
|
+
if (!parent.computed && parent.property.type === import_utils45.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils45.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6130
6357
|
return false;
|
|
6131
6358
|
}
|
|
6132
6359
|
return true;
|
|
6133
6360
|
}
|
|
6134
|
-
if (parent.type ===
|
|
6361
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6135
6362
|
return true;
|
|
6136
6363
|
}
|
|
6137
|
-
if (parent.type ===
|
|
6364
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.SpreadElement) {
|
|
6138
6365
|
return true;
|
|
6139
6366
|
}
|
|
6140
|
-
if (parent.type ===
|
|
6367
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.BinaryExpression) {
|
|
6141
6368
|
return true;
|
|
6142
6369
|
}
|
|
6143
|
-
if (parent.type ===
|
|
6370
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6144
6371
|
return true;
|
|
6145
6372
|
}
|
|
6146
|
-
if (parent.type ===
|
|
6373
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6147
6374
|
return true;
|
|
6148
6375
|
}
|
|
6149
6376
|
return false;
|
|
@@ -6198,7 +6425,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6198
6425
|
if (reference.isWrite()) {
|
|
6199
6426
|
return false;
|
|
6200
6427
|
}
|
|
6201
|
-
if (reference.identifier.type !==
|
|
6428
|
+
if (reference.identifier.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6202
6429
|
return false;
|
|
6203
6430
|
}
|
|
6204
6431
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6210,10 +6437,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6210
6437
|
return {
|
|
6211
6438
|
VariableDeclarator(node) {
|
|
6212
6439
|
const declaration = node.parent;
|
|
6213
|
-
if (declaration.type !==
|
|
6440
|
+
if (declaration.type !== import_utils45.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6214
6441
|
return;
|
|
6215
6442
|
}
|
|
6216
|
-
if (node.id.type !==
|
|
6443
|
+
if (node.id.type !== import_utils45.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6217
6444
|
return;
|
|
6218
6445
|
}
|
|
6219
6446
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6240,7 +6467,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6240
6467
|
});
|
|
6241
6468
|
|
|
6242
6469
|
// src/rules/prefer-module-level-schema.ts
|
|
6243
|
-
var
|
|
6470
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
6244
6471
|
|
|
6245
6472
|
// src/rules/_zod.ts
|
|
6246
6473
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6306,9 +6533,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6306
6533
|
"intl"
|
|
6307
6534
|
]);
|
|
6308
6535
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6536
|
+
import_utils46.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
6537
|
+
import_utils46.AST_NODE_TYPES.FunctionDeclaration,
|
|
6538
|
+
import_utils46.AST_NODE_TYPES.FunctionExpression
|
|
6312
6539
|
]);
|
|
6313
6540
|
function schemaExpression(node) {
|
|
6314
6541
|
let current = node;
|
|
@@ -6317,10 +6544,10 @@ function schemaExpression(node) {
|
|
|
6317
6544
|
if (parent === void 0) {
|
|
6318
6545
|
return current;
|
|
6319
6546
|
}
|
|
6320
|
-
if (parent.type ===
|
|
6547
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils46.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6321
6548
|
return current;
|
|
6322
6549
|
}
|
|
6323
|
-
if (parent.type ===
|
|
6550
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils46.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils46.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils46.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
6324
6551
|
current = parent;
|
|
6325
6552
|
continue;
|
|
6326
6553
|
}
|
|
@@ -6371,22 +6598,22 @@ function subtreeSome(root, predicate) {
|
|
|
6371
6598
|
function readsReceiver(node) {
|
|
6372
6599
|
return subtreeSome(
|
|
6373
6600
|
node,
|
|
6374
|
-
(inner) => inner.type ===
|
|
6601
|
+
(inner) => inner.type === import_utils46.AST_NODE_TYPES.ThisExpression || inner.type === import_utils46.AST_NODE_TYPES.Super || inner.type === import_utils46.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
6375
6602
|
);
|
|
6376
6603
|
}
|
|
6377
6604
|
function buildsLocalizedText(node) {
|
|
6378
6605
|
return subtreeSome(node, (inner) => {
|
|
6379
|
-
if (inner.type ===
|
|
6606
|
+
if (inner.type === import_utils46.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
6380
6607
|
return true;
|
|
6381
6608
|
}
|
|
6382
|
-
if (inner.type !==
|
|
6609
|
+
if (inner.type !== import_utils46.AST_NODE_TYPES.CallExpression) {
|
|
6383
6610
|
return false;
|
|
6384
6611
|
}
|
|
6385
6612
|
const { callee } = inner;
|
|
6386
|
-
if (callee.type ===
|
|
6613
|
+
if (callee.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6387
6614
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6388
6615
|
}
|
|
6389
|
-
return callee.type ===
|
|
6616
|
+
return callee.type === import_utils46.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils46.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6390
6617
|
});
|
|
6391
6618
|
}
|
|
6392
6619
|
function collectReferences(scope, out) {
|
|
@@ -6443,15 +6670,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6443
6670
|
}
|
|
6444
6671
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
6445
6672
|
function isZodCall(node) {
|
|
6446
|
-
return node.type ===
|
|
6673
|
+
return node.type === import_utils46.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils46.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils46.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
6447
6674
|
}
|
|
6448
6675
|
function isCovered(node) {
|
|
6449
6676
|
let current = node.parent ?? void 0;
|
|
6450
6677
|
while (current !== void 0) {
|
|
6451
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
6678
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils46.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils46.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
6452
6679
|
return true;
|
|
6453
6680
|
}
|
|
6454
|
-
if (current.type ===
|
|
6681
|
+
if (current.type === import_utils46.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils46.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils46.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils46.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
6455
6682
|
return true;
|
|
6456
6683
|
}
|
|
6457
6684
|
current = current.parent ?? void 0;
|
|
@@ -6466,11 +6693,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6466
6693
|
if (parent === void 0) {
|
|
6467
6694
|
return confirmed;
|
|
6468
6695
|
}
|
|
6469
|
-
if (parent.type ===
|
|
6696
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils46.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
6470
6697
|
current = parent;
|
|
6471
6698
|
continue;
|
|
6472
6699
|
}
|
|
6473
|
-
if (parent.type ===
|
|
6700
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
6474
6701
|
current = schemaExpression(parent);
|
|
6475
6702
|
confirmed = current;
|
|
6476
6703
|
continue;
|
|
@@ -6480,7 +6707,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6480
6707
|
}
|
|
6481
6708
|
function isSchemaComposition(node) {
|
|
6482
6709
|
const { callee } = node;
|
|
6483
|
-
const isCombinator = callee.type ===
|
|
6710
|
+
const isCombinator = callee.type === import_utils46.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils46.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
6484
6711
|
return isCombinator || isZodCall(node);
|
|
6485
6712
|
}
|
|
6486
6713
|
function closesOverNothing(node, enclosing) {
|
|
@@ -6514,13 +6741,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6514
6741
|
}
|
|
6515
6742
|
function ownerName(enclosing) {
|
|
6516
6743
|
const parent = enclosing.parent ?? void 0;
|
|
6517
|
-
if (enclosing.type ===
|
|
6744
|
+
if (enclosing.type === import_utils46.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
6518
6745
|
return enclosing.id.name;
|
|
6519
6746
|
}
|
|
6520
|
-
if (parent !== void 0 && parent.type ===
|
|
6747
|
+
if (parent !== void 0 && parent.type === import_utils46.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6521
6748
|
return parent.id.name;
|
|
6522
6749
|
}
|
|
6523
|
-
if (parent !== void 0 && (parent.type ===
|
|
6750
|
+
if (parent !== void 0 && (parent.type === import_utils46.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils46.AST_NODE_TYPES.Property) && parent.key.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6524
6751
|
return parent.key.name;
|
|
6525
6752
|
}
|
|
6526
6753
|
return "this function";
|
|
@@ -6531,7 +6758,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6531
6758
|
return;
|
|
6532
6759
|
}
|
|
6533
6760
|
for (const specifier of node.specifiers) {
|
|
6534
|
-
if (specifier.type ===
|
|
6761
|
+
if (specifier.type === import_utils46.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils46.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils46.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils46.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
6535
6762
|
zodNamespaces.add(specifier.local.name);
|
|
6536
6763
|
}
|
|
6537
6764
|
}
|
|
@@ -6541,7 +6768,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6541
6768
|
return;
|
|
6542
6769
|
}
|
|
6543
6770
|
const callee = node.callee;
|
|
6544
|
-
if (callee.property.type !==
|
|
6771
|
+
if (callee.property.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6545
6772
|
return;
|
|
6546
6773
|
}
|
|
6547
6774
|
const factory = callee.property.name;
|
|
@@ -6556,7 +6783,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6556
6783
|
return;
|
|
6557
6784
|
}
|
|
6558
6785
|
const shape = node.arguments[0];
|
|
6559
|
-
if (shape !== void 0 && shape.type ===
|
|
6786
|
+
if (shape !== void 0 && shape.type === import_utils46.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
6560
6787
|
return;
|
|
6561
6788
|
}
|
|
6562
6789
|
const expression = schemaExpression(node);
|
|
@@ -6584,20 +6811,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6584
6811
|
});
|
|
6585
6812
|
|
|
6586
6813
|
// src/rules/prefer-non-nullable-collection.ts
|
|
6587
|
-
var
|
|
6814
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
6588
6815
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
6589
6816
|
function propertyName(node) {
|
|
6590
6817
|
const key = node.key;
|
|
6591
|
-
if (key.type ===
|
|
6592
|
-
if (key.type ===
|
|
6818
|
+
if (key.type === import_utils47.AST_NODE_TYPES.Identifier) return key.name;
|
|
6819
|
+
if (key.type === import_utils47.AST_NODE_TYPES.Literal) return String(key.value);
|
|
6593
6820
|
return "collection";
|
|
6594
6821
|
}
|
|
6595
6822
|
function isArrayType(node) {
|
|
6596
|
-
if (node.type ===
|
|
6597
|
-
return node.type ===
|
|
6823
|
+
if (node.type === import_utils47.AST_NODE_TYPES.TSArrayType) return true;
|
|
6824
|
+
return node.type === import_utils47.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils47.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
6598
6825
|
}
|
|
6599
6826
|
function isNullishType(node) {
|
|
6600
|
-
return node.type ===
|
|
6827
|
+
return node.type === import_utils47.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils47.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
6601
6828
|
}
|
|
6602
6829
|
function isNullableArrayOnly(node) {
|
|
6603
6830
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -6624,7 +6851,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6624
6851
|
function checkOptionalProperty(node) {
|
|
6625
6852
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
6626
6853
|
if (annotation === void 0) return;
|
|
6627
|
-
if (annotation.type !==
|
|
6854
|
+
if (annotation.type !== import_utils47.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
6628
6855
|
return;
|
|
6629
6856
|
}
|
|
6630
6857
|
context.report({
|
|
@@ -6637,7 +6864,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6637
6864
|
TSPropertySignature: checkOptionalProperty,
|
|
6638
6865
|
PropertyDefinition: checkOptionalProperty,
|
|
6639
6866
|
TSTypeAliasDeclaration(node) {
|
|
6640
|
-
if (node.typeAnnotation.type !==
|
|
6867
|
+
if (node.typeAnnotation.type !== import_utils47.AST_NODE_TYPES.TSUnionType) return;
|
|
6641
6868
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
6642
6869
|
context.report({
|
|
6643
6870
|
node,
|
|
@@ -6650,13 +6877,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6650
6877
|
});
|
|
6651
6878
|
|
|
6652
6879
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
6653
|
-
var
|
|
6880
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6654
6881
|
var unwrap4 = (node) => {
|
|
6655
6882
|
let current = node;
|
|
6656
6883
|
while (current !== null && current !== void 0) {
|
|
6657
|
-
if (current.type ===
|
|
6884
|
+
if (current.type === import_utils48.AST_NODE_TYPES.TSAsExpression || current.type === import_utils48.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils48.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils48.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6658
6885
|
current = current.expression;
|
|
6659
|
-
} else if (current.type ===
|
|
6886
|
+
} else if (current.type === import_utils48.AST_NODE_TYPES.ChainExpression) {
|
|
6660
6887
|
current = current.expression;
|
|
6661
6888
|
} else {
|
|
6662
6889
|
break;
|
|
@@ -6671,23 +6898,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
6671
6898
|
]);
|
|
6672
6899
|
var isSchemaParseReference = (node) => {
|
|
6673
6900
|
const inner = unwrap4(node);
|
|
6674
|
-
return inner !== null && inner.type ===
|
|
6901
|
+
return inner !== null && inner.type === import_utils48.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils48.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
6675
6902
|
};
|
|
6676
6903
|
var isRawPayloadSource = (node) => {
|
|
6677
6904
|
let current = unwrap4(node);
|
|
6678
6905
|
if (current === null) return false;
|
|
6679
|
-
if (current.type ===
|
|
6906
|
+
if (current.type === import_utils48.AST_NODE_TYPES.AwaitExpression) {
|
|
6680
6907
|
current = unwrap4(current.argument);
|
|
6681
6908
|
}
|
|
6682
|
-
if (current === null || current.type !==
|
|
6909
|
+
if (current === null || current.type !== import_utils48.AST_NODE_TYPES.CallExpression) {
|
|
6683
6910
|
return false;
|
|
6684
6911
|
}
|
|
6685
6912
|
const callee = unwrap4(current.callee);
|
|
6686
|
-
if (callee === null || callee.type !==
|
|
6913
|
+
if (callee === null || callee.type !== import_utils48.AST_NODE_TYPES.MemberExpression) {
|
|
6687
6914
|
return false;
|
|
6688
6915
|
}
|
|
6689
6916
|
const property = unwrap4(callee.property);
|
|
6690
|
-
if (property === null || property.type !==
|
|
6917
|
+
if (property === null || property.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6691
6918
|
return false;
|
|
6692
6919
|
}
|
|
6693
6920
|
if (property.name === "json") {
|
|
@@ -6697,7 +6924,7 @@ var isRawPayloadSource = (node) => {
|
|
|
6697
6924
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
6698
6925
|
}
|
|
6699
6926
|
const object = unwrap4(callee.object);
|
|
6700
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
6927
|
+
return property.name === "parse" && object !== null && object.type === import_utils48.AST_NODE_TYPES.Identifier && object.name === "JSON" && // ...but not `JSON.parse(readFileSync(p, "utf8"))` — see isLocalFileRead.
|
|
6701
6928
|
!isLocalFileRead(current.arguments[0]);
|
|
6702
6929
|
};
|
|
6703
6930
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
@@ -6705,9 +6932,9 @@ var isLocalFileRead = (node) => {
|
|
|
6705
6932
|
let found = false;
|
|
6706
6933
|
const visit = (current) => {
|
|
6707
6934
|
if (found || current === null || current === void 0) return;
|
|
6708
|
-
if (current.type ===
|
|
6935
|
+
if (current.type === import_utils48.AST_NODE_TYPES.CallExpression) {
|
|
6709
6936
|
const callee = unwrap4(current.callee);
|
|
6710
|
-
const name = callee?.type ===
|
|
6937
|
+
const name = callee?.type === import_utils48.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils48.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils48.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
6711
6938
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
6712
6939
|
found = true;
|
|
6713
6940
|
return;
|
|
@@ -6729,15 +6956,15 @@ var isLocalFileRead = (node) => {
|
|
|
6729
6956
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
6730
6957
|
var isInsideAssertion = (node) => {
|
|
6731
6958
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
6732
|
-
if (current.type !==
|
|
6959
|
+
if (current.type !== import_utils48.AST_NODE_TYPES.CallExpression) continue;
|
|
6733
6960
|
let callee = current.callee;
|
|
6734
|
-
while (callee.type ===
|
|
6961
|
+
while (callee.type === import_utils48.AST_NODE_TYPES.MemberExpression) {
|
|
6735
6962
|
callee = callee.object;
|
|
6736
6963
|
}
|
|
6737
|
-
if (callee.type ===
|
|
6964
|
+
if (callee.type === import_utils48.AST_NODE_TYPES.CallExpression) {
|
|
6738
6965
|
callee = callee.callee;
|
|
6739
6966
|
}
|
|
6740
|
-
if (callee.type ===
|
|
6967
|
+
if (callee.type === import_utils48.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
6741
6968
|
return true;
|
|
6742
6969
|
}
|
|
6743
6970
|
}
|
|
@@ -6756,39 +6983,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
6756
6983
|
var isValidationRead = (node) => {
|
|
6757
6984
|
let current = node;
|
|
6758
6985
|
let parent = current.parent;
|
|
6759
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
6986
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils48.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils48.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils48.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils48.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils48.AST_NODE_TYPES.ChainExpression)) {
|
|
6760
6987
|
current = parent;
|
|
6761
6988
|
parent = parent.parent;
|
|
6762
6989
|
}
|
|
6763
6990
|
if (parent === null || parent === void 0) return false;
|
|
6764
|
-
if (parent.type ===
|
|
6991
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
6765
6992
|
return true;
|
|
6766
6993
|
}
|
|
6767
|
-
if (parent.type !==
|
|
6994
|
+
if (parent.type !== import_utils48.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
6768
6995
|
return false;
|
|
6769
6996
|
}
|
|
6770
6997
|
const callee = parent.callee;
|
|
6771
|
-
if (callee.type ===
|
|
6998
|
+
if (callee.type === import_utils48.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils48.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils48.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
6772
6999
|
return parent.arguments.length === 1;
|
|
6773
7000
|
}
|
|
6774
|
-
return callee.type ===
|
|
7001
|
+
return callee.type === import_utils48.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
6775
7002
|
};
|
|
6776
7003
|
var isGuardTestPosition = (node) => {
|
|
6777
7004
|
let current = node;
|
|
6778
7005
|
let parent = current.parent;
|
|
6779
7006
|
while (parent !== void 0 && parent !== null) {
|
|
6780
7007
|
switch (parent.type) {
|
|
6781
|
-
case
|
|
6782
|
-
case
|
|
6783
|
-
case
|
|
7008
|
+
case import_utils48.AST_NODE_TYPES.UnaryExpression:
|
|
7009
|
+
case import_utils48.AST_NODE_TYPES.LogicalExpression:
|
|
7010
|
+
case import_utils48.AST_NODE_TYPES.ChainExpression:
|
|
6784
7011
|
current = parent;
|
|
6785
7012
|
parent = parent.parent;
|
|
6786
7013
|
continue;
|
|
6787
|
-
case
|
|
6788
|
-
case
|
|
6789
|
-
case
|
|
6790
|
-
case
|
|
6791
|
-
case
|
|
7014
|
+
case import_utils48.AST_NODE_TYPES.IfStatement:
|
|
7015
|
+
case import_utils48.AST_NODE_TYPES.ConditionalExpression:
|
|
7016
|
+
case import_utils48.AST_NODE_TYPES.WhileStatement:
|
|
7017
|
+
case import_utils48.AST_NODE_TYPES.DoWhileStatement:
|
|
7018
|
+
case import_utils48.AST_NODE_TYPES.ForStatement:
|
|
6792
7019
|
return parent.test === current;
|
|
6793
7020
|
default:
|
|
6794
7021
|
return false;
|
|
@@ -6798,7 +7025,7 @@ var isGuardTestPosition = (node) => {
|
|
|
6798
7025
|
};
|
|
6799
7026
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
6800
7027
|
const unwrapped = unwrap4(node);
|
|
6801
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7028
|
+
if (unwrapped === null || unwrapped.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6802
7029
|
return false;
|
|
6803
7030
|
}
|
|
6804
7031
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -6841,11 +7068,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6841
7068
|
return {
|
|
6842
7069
|
VariableDeclarator(node) {
|
|
6843
7070
|
const scope = context.sourceCode.getScope(node);
|
|
6844
|
-
if (node.id.type ===
|
|
7071
|
+
if (node.id.type === import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6845
7072
|
trackInitializer(node);
|
|
6846
7073
|
return;
|
|
6847
7074
|
}
|
|
6848
|
-
if (node.id.type ===
|
|
7075
|
+
if (node.id.type === import_utils48.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils48.AST_NODE_TYPES.ArrayPattern) {
|
|
6849
7076
|
if (isRawPayloadSource(node.init)) {
|
|
6850
7077
|
if (!isFullyNarrowedPattern(node)) {
|
|
6851
7078
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -6859,7 +7086,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6859
7086
|
},
|
|
6860
7087
|
AssignmentExpression(node) {
|
|
6861
7088
|
const scope = context.sourceCode.getScope(node);
|
|
6862
|
-
if (node.left.type ===
|
|
7089
|
+
if (node.left.type === import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6863
7090
|
const variable = findVariable2(scope, node.left.name);
|
|
6864
7091
|
if (variable === null) return;
|
|
6865
7092
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -6869,7 +7096,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6869
7096
|
}
|
|
6870
7097
|
return;
|
|
6871
7098
|
}
|
|
6872
|
-
if (node.left.type ===
|
|
7099
|
+
if (node.left.type === import_utils48.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils48.AST_NODE_TYPES.ArrayPattern) {
|
|
6873
7100
|
if (isRawPayloadSource(node.right)) {
|
|
6874
7101
|
context.report({
|
|
6875
7102
|
node: node.left,
|
|
@@ -6886,15 +7113,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6886
7113
|
}
|
|
6887
7114
|
},
|
|
6888
7115
|
CallExpression(node) {
|
|
6889
|
-
if (node.callee.type !==
|
|
7116
|
+
if (node.callee.type !== import_utils48.AST_NODE_TYPES.Identifier) return;
|
|
6890
7117
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
6891
7118
|
return;
|
|
6892
7119
|
}
|
|
6893
7120
|
const scope = context.sourceCode.getScope(node);
|
|
6894
7121
|
for (const arg of node.arguments) {
|
|
6895
|
-
if (arg.type ===
|
|
7122
|
+
if (arg.type === import_utils48.AST_NODE_TYPES.SpreadElement) continue;
|
|
6896
7123
|
const unwrapped = unwrap4(arg);
|
|
6897
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7124
|
+
if (unwrapped === null || unwrapped.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
6898
7125
|
continue;
|
|
6899
7126
|
}
|
|
6900
7127
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -6908,13 +7135,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6908
7135
|
const obj = unwrap4(node.object);
|
|
6909
7136
|
if (isRawPayloadSource(obj)) {
|
|
6910
7137
|
const parent = node.parent;
|
|
6911
|
-
if (parent.type ===
|
|
7138
|
+
if (parent.type === import_utils48.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils48.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
6912
7139
|
return;
|
|
6913
7140
|
}
|
|
6914
7141
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
6915
7142
|
return;
|
|
6916
7143
|
}
|
|
6917
|
-
if (obj !== null && obj.type ===
|
|
7144
|
+
if (obj !== null && obj.type === import_utils48.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
6918
7145
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
6919
7146
|
const variable = findVariable2(scope, obj.name);
|
|
6920
7147
|
if (variable !== null) {
|
|
@@ -6927,7 +7154,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6927
7154
|
});
|
|
6928
7155
|
|
|
6929
7156
|
// src/rules/prefer-semantic-colors.ts
|
|
6930
|
-
var
|
|
7157
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
6931
7158
|
var import_fs = require("fs");
|
|
6932
7159
|
var import_path = require("path");
|
|
6933
7160
|
|
|
@@ -7027,8 +7254,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7027
7254
|
]);
|
|
7028
7255
|
function jsxElementName(node) {
|
|
7029
7256
|
const name = node.openingElement.name;
|
|
7030
|
-
if (name.type ===
|
|
7031
|
-
if (name.type ===
|
|
7257
|
+
if (name.type === import_utils49.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
7258
|
+
if (name.type === import_utils49.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils49.AST_NODE_TYPES.JSXIdentifier) {
|
|
7032
7259
|
return name.property.name;
|
|
7033
7260
|
}
|
|
7034
7261
|
return null;
|
|
@@ -7054,7 +7281,7 @@ var EMAIL_OR_PDF_IMPORT_RE = /@react-(?:email|pdf)\//;
|
|
|
7054
7281
|
var isInsideSvg = (node) => {
|
|
7055
7282
|
let current = node.parent;
|
|
7056
7283
|
while (current !== void 0 && current !== null) {
|
|
7057
|
-
if (current.type ===
|
|
7284
|
+
if (current.type === import_utils49.AST_NODE_TYPES.JSXElement) {
|
|
7058
7285
|
const name = jsxElementName(current);
|
|
7059
7286
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7060
7287
|
}
|
|
@@ -7065,7 +7292,7 @@ var isInsideSvg = (node) => {
|
|
|
7065
7292
|
var isInsideIconFactoryPath = (node) => {
|
|
7066
7293
|
let current = node.parent;
|
|
7067
7294
|
while (current !== void 0 && current !== null) {
|
|
7068
|
-
if (current.type ===
|
|
7295
|
+
if (current.type === import_utils49.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils49.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils49.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils49.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7069
7296
|
return true;
|
|
7070
7297
|
}
|
|
7071
7298
|
current = current.parent;
|
|
@@ -7202,8 +7429,8 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7202
7429
|
return root !== null && workspaceHasMarker(root);
|
|
7203
7430
|
};
|
|
7204
7431
|
var propName = (key) => {
|
|
7205
|
-
if (key.type ===
|
|
7206
|
-
if (key.type ===
|
|
7432
|
+
if (key.type === import_utils49.AST_NODE_TYPES.Identifier) return key.name;
|
|
7433
|
+
if (key.type === import_utils49.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
7207
7434
|
return null;
|
|
7208
7435
|
};
|
|
7209
7436
|
var prefer_semantic_colors_default = createRule({
|
|
@@ -7248,27 +7475,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7248
7475
|
const checkClassNode = (node) => {
|
|
7249
7476
|
if (node === null) return;
|
|
7250
7477
|
switch (node.type) {
|
|
7251
|
-
case
|
|
7478
|
+
case import_utils49.AST_NODE_TYPES.Literal:
|
|
7252
7479
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7253
7480
|
break;
|
|
7254
|
-
case
|
|
7481
|
+
case import_utils49.AST_NODE_TYPES.TemplateLiteral:
|
|
7255
7482
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7256
7483
|
break;
|
|
7257
|
-
case
|
|
7484
|
+
case import_utils49.AST_NODE_TYPES.ArrayExpression:
|
|
7258
7485
|
for (const element of node.elements) {
|
|
7259
|
-
if (element !== null && element.type !==
|
|
7486
|
+
if (element !== null && element.type !== import_utils49.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
7260
7487
|
}
|
|
7261
7488
|
break;
|
|
7262
|
-
case
|
|
7489
|
+
case import_utils49.AST_NODE_TYPES.ObjectExpression:
|
|
7263
7490
|
for (const property of node.properties) {
|
|
7264
|
-
if (property.type ===
|
|
7491
|
+
if (property.type === import_utils49.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
7265
7492
|
}
|
|
7266
7493
|
break;
|
|
7267
|
-
case
|
|
7494
|
+
case import_utils49.AST_NODE_TYPES.ConditionalExpression:
|
|
7268
7495
|
checkClassNode(node.consequent);
|
|
7269
7496
|
checkClassNode(node.alternate);
|
|
7270
7497
|
break;
|
|
7271
|
-
case
|
|
7498
|
+
case import_utils49.AST_NODE_TYPES.LogicalExpression:
|
|
7272
7499
|
checkClassNode(node.right);
|
|
7273
7500
|
break;
|
|
7274
7501
|
default:
|
|
@@ -7276,29 +7503,29 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7276
7503
|
}
|
|
7277
7504
|
};
|
|
7278
7505
|
const checkColorValueNode = (node) => {
|
|
7279
|
-
if (node.type ===
|
|
7506
|
+
if (node.type === import_utils49.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
7280
7507
|
context.report({ node, messageId: "inlineColor", data: { value: node.value } });
|
|
7281
7508
|
}
|
|
7282
7509
|
};
|
|
7283
7510
|
return {
|
|
7284
7511
|
"JSXAttribute[name.name='className']"(node) {
|
|
7285
7512
|
if (node.value === null) return;
|
|
7286
|
-
if (node.value.type ===
|
|
7287
|
-
else if (node.value.type ===
|
|
7288
|
-
if (node.value.expression.type !==
|
|
7513
|
+
if (node.value.type === import_utils49.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
7514
|
+
else if (node.value.type === import_utils49.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
7515
|
+
if (node.value.expression.type !== import_utils49.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
7289
7516
|
checkClassNode(node.value.expression);
|
|
7290
7517
|
}
|
|
7291
7518
|
}
|
|
7292
7519
|
},
|
|
7293
7520
|
CallExpression(node) {
|
|
7294
|
-
if (node.callee.type ===
|
|
7521
|
+
if (node.callee.type === import_utils49.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7295
7522
|
for (const arg of node.arguments) {
|
|
7296
|
-
if (arg.type !==
|
|
7523
|
+
if (arg.type !== import_utils49.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
7297
7524
|
}
|
|
7298
7525
|
}
|
|
7299
7526
|
},
|
|
7300
7527
|
VariableDeclarator(node) {
|
|
7301
|
-
if (node.id.type ===
|
|
7528
|
+
if (node.id.type === import_utils49.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
7302
7529
|
checkClassNode(node.init);
|
|
7303
7530
|
}
|
|
7304
7531
|
},
|
|
@@ -7310,9 +7537,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7310
7537
|
// Neutral drawing literals and anything inside an SVG defs container are
|
|
7311
7538
|
// structural, not UI tokens, so they never fire.
|
|
7312
7539
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
7313
|
-
if (node.value?.type !==
|
|
7540
|
+
if (node.value?.type !== import_utils49.AST_NODE_TYPES.Literal) return;
|
|
7314
7541
|
const owner = node.parent.name;
|
|
7315
|
-
if (owner.type ===
|
|
7542
|
+
if (owner.type === import_utils49.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
7316
7543
|
return;
|
|
7317
7544
|
}
|
|
7318
7545
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -7330,7 +7557,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7330
7557
|
});
|
|
7331
7558
|
|
|
7332
7559
|
// src/rules/prefer-server-actions.ts
|
|
7333
|
-
var
|
|
7560
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7334
7561
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
7335
7562
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
7336
7563
|
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\/)/;
|
|
@@ -7483,7 +7710,7 @@ var prefer_server_actions_default = createRule({
|
|
|
7483
7710
|
});
|
|
7484
7711
|
|
|
7485
7712
|
// src/rules/prefer-string-literal-union.ts
|
|
7486
|
-
var
|
|
7713
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7487
7714
|
var ts2 = __toESM(require("typescript"), 1);
|
|
7488
7715
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
7489
7716
|
"status",
|
|
@@ -7526,19 +7753,19 @@ function isChoiceLikeName(name) {
|
|
|
7526
7753
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
7527
7754
|
}
|
|
7528
7755
|
function keyName(key) {
|
|
7529
|
-
if (key.type ===
|
|
7756
|
+
if (key.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7530
7757
|
return key.name;
|
|
7531
7758
|
}
|
|
7532
|
-
if (key.type ===
|
|
7759
|
+
if (key.type === import_utils51.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
7533
7760
|
return key.value;
|
|
7534
7761
|
}
|
|
7535
7762
|
return null;
|
|
7536
7763
|
}
|
|
7537
7764
|
function isStringLiteralMember(t) {
|
|
7538
|
-
return t.type ===
|
|
7765
|
+
return t.type === import_utils51.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils51.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
7539
7766
|
}
|
|
7540
7767
|
function isStringLiteralUnion(node) {
|
|
7541
|
-
if (node?.type !==
|
|
7768
|
+
if (node?.type !== import_utils51.AST_NODE_TYPES.TSUnionType) {
|
|
7542
7769
|
return false;
|
|
7543
7770
|
}
|
|
7544
7771
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -7567,12 +7794,12 @@ function bindingSourceExpression(decl) {
|
|
|
7567
7794
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
7568
7795
|
}
|
|
7569
7796
|
function refKey(node) {
|
|
7570
|
-
if (node.type ===
|
|
7797
|
+
if (node.type === import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7571
7798
|
return node.name;
|
|
7572
7799
|
}
|
|
7573
|
-
if (node.type ===
|
|
7800
|
+
if (node.type === import_utils51.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
7574
7801
|
const inner = refKey(node.object);
|
|
7575
|
-
if (inner === null || node.property.type !==
|
|
7802
|
+
if (inner === null || node.property.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7576
7803
|
return null;
|
|
7577
7804
|
}
|
|
7578
7805
|
return `${inner}.${node.property.name}`;
|
|
@@ -7580,7 +7807,7 @@ function refKey(node) {
|
|
|
7580
7807
|
return null;
|
|
7581
7808
|
}
|
|
7582
7809
|
function strLiteral(node) {
|
|
7583
|
-
if (node.type ===
|
|
7810
|
+
if (node.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
7584
7811
|
return node.value;
|
|
7585
7812
|
}
|
|
7586
7813
|
return null;
|
|
@@ -7621,7 +7848,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7621
7848
|
);
|
|
7622
7849
|
let services;
|
|
7623
7850
|
try {
|
|
7624
|
-
services =
|
|
7851
|
+
services = import_utils51.ESLintUtils.getParserServices(context);
|
|
7625
7852
|
} catch {
|
|
7626
7853
|
services = null;
|
|
7627
7854
|
}
|
|
@@ -7733,7 +7960,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7733
7960
|
containersWithUnion.add(container);
|
|
7734
7961
|
return;
|
|
7735
7962
|
}
|
|
7736
|
-
if (typeNode?.type !==
|
|
7963
|
+
if (typeNode?.type !== import_utils51.AST_NODE_TYPES.TSStringKeyword) {
|
|
7737
7964
|
return;
|
|
7738
7965
|
}
|
|
7739
7966
|
const name = keyName(key);
|
|
@@ -7821,10 +8048,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7821
8048
|
}
|
|
7822
8049
|
};
|
|
7823
8050
|
function refKeyText(node) {
|
|
7824
|
-
if (node.type ===
|
|
8051
|
+
if (node.type === import_utils51.AST_NODE_TYPES.BinaryExpression) {
|
|
7825
8052
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
7826
8053
|
}
|
|
7827
|
-
if (node.type ===
|
|
8054
|
+
if (node.type === import_utils51.AST_NODE_TYPES.SwitchStatement) {
|
|
7828
8055
|
return refKey(node.discriminant) ?? "value";
|
|
7829
8056
|
}
|
|
7830
8057
|
return "value";
|
|
@@ -7833,7 +8060,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7833
8060
|
});
|
|
7834
8061
|
|
|
7835
8062
|
// src/rules/prefer-whole-object-assertion.ts
|
|
7836
|
-
var
|
|
8063
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7837
8064
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
7838
8065
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
7839
8066
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -7842,11 +8069,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
7842
8069
|
var MIN_RUN_LENGTH = 2;
|
|
7843
8070
|
function literalText(node, getText) {
|
|
7844
8071
|
switch (node.type) {
|
|
7845
|
-
case
|
|
8072
|
+
case import_utils52.AST_NODE_TYPES.Literal:
|
|
7846
8073
|
return "regex" in node ? null : getText(node);
|
|
7847
|
-
case
|
|
8074
|
+
case import_utils52.AST_NODE_TYPES.TemplateLiteral:
|
|
7848
8075
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
7849
|
-
case
|
|
8076
|
+
case import_utils52.AST_NODE_TYPES.UnaryExpression:
|
|
7850
8077
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
7851
8078
|
default:
|
|
7852
8079
|
return null;
|
|
@@ -7854,15 +8081,15 @@ function literalText(node, getText) {
|
|
|
7854
8081
|
}
|
|
7855
8082
|
function isPureReceiver(node) {
|
|
7856
8083
|
switch (node.type) {
|
|
7857
|
-
case
|
|
7858
|
-
case
|
|
8084
|
+
case import_utils52.AST_NODE_TYPES.Identifier:
|
|
8085
|
+
case import_utils52.AST_NODE_TYPES.ThisExpression:
|
|
7859
8086
|
return true;
|
|
7860
|
-
case
|
|
8087
|
+
case import_utils52.AST_NODE_TYPES.MemberExpression:
|
|
7861
8088
|
if (node.optional) {
|
|
7862
8089
|
return false;
|
|
7863
8090
|
}
|
|
7864
8091
|
if (node.computed) {
|
|
7865
|
-
return node.property.type ===
|
|
8092
|
+
return node.property.type === import_utils52.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
7866
8093
|
}
|
|
7867
8094
|
return isPureReceiver(node.object);
|
|
7868
8095
|
default:
|
|
@@ -7870,7 +8097,7 @@ function isPureReceiver(node) {
|
|
|
7870
8097
|
}
|
|
7871
8098
|
}
|
|
7872
8099
|
function literalIndex(node) {
|
|
7873
|
-
if (node.type !==
|
|
8100
|
+
if (node.type !== import_utils52.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
7874
8101
|
return null;
|
|
7875
8102
|
}
|
|
7876
8103
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -7896,24 +8123,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7896
8123
|
}
|
|
7897
8124
|
const { sourceCode } = context;
|
|
7898
8125
|
function parseAssertion(statement) {
|
|
7899
|
-
if (statement.type !==
|
|
8126
|
+
if (statement.type !== import_utils52.AST_NODE_TYPES.ExpressionStatement) {
|
|
7900
8127
|
return null;
|
|
7901
8128
|
}
|
|
7902
8129
|
const call = statement.expression;
|
|
7903
|
-
if (call.type !==
|
|
8130
|
+
if (call.type !== import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7904
8131
|
return null;
|
|
7905
8132
|
}
|
|
7906
8133
|
const callee = call.callee;
|
|
7907
|
-
if (callee.type !==
|
|
8134
|
+
if (callee.type !== import_utils52.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7908
8135
|
return null;
|
|
7909
8136
|
}
|
|
7910
8137
|
const matcher = callee.property.name;
|
|
7911
8138
|
const expectCall = callee.object;
|
|
7912
|
-
if (expectCall.type !==
|
|
8139
|
+
if (expectCall.type !== import_utils52.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils52.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
7913
8140
|
return null;
|
|
7914
8141
|
}
|
|
7915
8142
|
const actual = expectCall.arguments[0];
|
|
7916
|
-
if (actual === void 0 || actual.type !==
|
|
8143
|
+
if (actual === void 0 || actual.type !== import_utils52.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
7917
8144
|
return null;
|
|
7918
8145
|
}
|
|
7919
8146
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -7927,7 +8154,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7927
8154
|
}
|
|
7928
8155
|
key = { kind: "index", index };
|
|
7929
8156
|
} else {
|
|
7930
|
-
if (actual.property.type !==
|
|
8157
|
+
if (actual.property.type !== import_utils52.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
7931
8158
|
return null;
|
|
7932
8159
|
}
|
|
7933
8160
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -7939,7 +8166,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7939
8166
|
return null;
|
|
7940
8167
|
}
|
|
7941
8168
|
const expected = call.arguments[0];
|
|
7942
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8169
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils52.AST_NODE_TYPES.SpreadElement) {
|
|
7943
8170
|
return null;
|
|
7944
8171
|
}
|
|
7945
8172
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8054,7 +8281,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8054
8281
|
});
|
|
8055
8282
|
|
|
8056
8283
|
// src/rules/prefer-zod-enum.ts
|
|
8057
|
-
var
|
|
8284
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
8058
8285
|
var prefer_zod_enum_default = createRule({
|
|
8059
8286
|
name: "prefer-zod-enum",
|
|
8060
8287
|
meta: {
|
|
@@ -8074,20 +8301,20 @@ var prefer_zod_enum_default = createRule({
|
|
|
8074
8301
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8075
8302
|
function enumValues(node) {
|
|
8076
8303
|
const callee = node.callee;
|
|
8077
|
-
if (callee.type !==
|
|
8304
|
+
if (callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils53.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils53.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8078
8305
|
return null;
|
|
8079
8306
|
}
|
|
8080
8307
|
const argument = node.arguments[0];
|
|
8081
|
-
if (argument === void 0 || argument.type !==
|
|
8308
|
+
if (argument === void 0 || argument.type !== import_utils53.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
8082
8309
|
return null;
|
|
8083
8310
|
}
|
|
8084
8311
|
const values = [];
|
|
8085
8312
|
for (const element of argument.elements) {
|
|
8086
|
-
if (element === null || element.type !==
|
|
8313
|
+
if (element === null || element.type !== import_utils53.AST_NODE_TYPES.CallExpression || element.arguments.length !== 1 || element.callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils53.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils53.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
8087
8314
|
return null;
|
|
8088
8315
|
}
|
|
8089
8316
|
const value = element.arguments[0];
|
|
8090
|
-
if (value === void 0 || value.type !==
|
|
8317
|
+
if (value === void 0 || value.type !== import_utils53.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
8091
8318
|
return null;
|
|
8092
8319
|
}
|
|
8093
8320
|
values.push(value);
|
|
@@ -8096,11 +8323,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
8096
8323
|
}
|
|
8097
8324
|
function buildFix(node, values) {
|
|
8098
8325
|
const argument = node.arguments[0];
|
|
8099
|
-
if (argument === void 0 || argument.type !==
|
|
8326
|
+
if (argument === void 0 || argument.type !== import_utils53.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8100
8327
|
return void 0;
|
|
8101
8328
|
}
|
|
8102
8329
|
const callee = node.callee;
|
|
8103
|
-
if (callee.type !==
|
|
8330
|
+
if (callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
8104
8331
|
return void 0;
|
|
8105
8332
|
}
|
|
8106
8333
|
return (fixer) => [
|
|
@@ -8117,7 +8344,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8117
8344
|
return;
|
|
8118
8345
|
}
|
|
8119
8346
|
for (const specifier of node.specifiers) {
|
|
8120
|
-
if (specifier.type ===
|
|
8347
|
+
if (specifier.type === import_utils53.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils53.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils53.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils53.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8121
8348
|
zodNamespaces.add(specifier.local.name);
|
|
8122
8349
|
}
|
|
8123
8350
|
}
|
|
@@ -8139,7 +8366,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8139
8366
|
});
|
|
8140
8367
|
|
|
8141
8368
|
// src/rules/prefer-zod-infer.ts
|
|
8142
|
-
var
|
|
8369
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
8143
8370
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8144
8371
|
"describe",
|
|
8145
8372
|
"refine",
|
|
@@ -8176,44 +8403,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8176
8403
|
"Schema"
|
|
8177
8404
|
]);
|
|
8178
8405
|
var LEAF_NODE_TYPES = {
|
|
8179
|
-
string: [
|
|
8180
|
-
email: [
|
|
8181
|
-
url: [
|
|
8182
|
-
uuid: [
|
|
8183
|
-
ulid: [
|
|
8184
|
-
cuid: [
|
|
8185
|
-
cuid2: [
|
|
8186
|
-
nanoid: [
|
|
8187
|
-
iso: [
|
|
8188
|
-
number: [
|
|
8189
|
-
int: [
|
|
8190
|
-
float32: [
|
|
8191
|
-
float64: [
|
|
8192
|
-
boolean: [
|
|
8193
|
-
bigint: [
|
|
8194
|
-
symbol: [
|
|
8195
|
-
any: [
|
|
8196
|
-
unknown: [
|
|
8197
|
-
never: [
|
|
8198
|
-
void: [
|
|
8199
|
-
null: [
|
|
8200
|
-
undefined: [
|
|
8201
|
-
literal: [
|
|
8202
|
-
date: [
|
|
8203
|
-
array: [
|
|
8204
|
-
tuple: [
|
|
8205
|
-
object: [
|
|
8206
|
-
strictObject: [
|
|
8207
|
-
looseObject: [
|
|
8208
|
-
record: [
|
|
8209
|
-
map: [
|
|
8210
|
-
set: [
|
|
8211
|
-
promise: [
|
|
8212
|
-
enum: [
|
|
8213
|
-
nativeEnum: [
|
|
8214
|
-
union: [
|
|
8215
|
-
discriminatedUnion: [
|
|
8216
|
-
intersection: [
|
|
8406
|
+
string: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8407
|
+
email: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8408
|
+
url: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8409
|
+
uuid: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8410
|
+
ulid: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8411
|
+
cuid: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8412
|
+
cuid2: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8413
|
+
nanoid: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8414
|
+
iso: [import_utils54.AST_NODE_TYPES.TSStringKeyword],
|
|
8415
|
+
number: [import_utils54.AST_NODE_TYPES.TSNumberKeyword],
|
|
8416
|
+
int: [import_utils54.AST_NODE_TYPES.TSNumberKeyword],
|
|
8417
|
+
float32: [import_utils54.AST_NODE_TYPES.TSNumberKeyword],
|
|
8418
|
+
float64: [import_utils54.AST_NODE_TYPES.TSNumberKeyword],
|
|
8419
|
+
boolean: [import_utils54.AST_NODE_TYPES.TSBooleanKeyword],
|
|
8420
|
+
bigint: [import_utils54.AST_NODE_TYPES.TSBigIntKeyword],
|
|
8421
|
+
symbol: [import_utils54.AST_NODE_TYPES.TSSymbolKeyword],
|
|
8422
|
+
any: [import_utils54.AST_NODE_TYPES.TSAnyKeyword],
|
|
8423
|
+
unknown: [import_utils54.AST_NODE_TYPES.TSUnknownKeyword],
|
|
8424
|
+
never: [import_utils54.AST_NODE_TYPES.TSNeverKeyword],
|
|
8425
|
+
void: [import_utils54.AST_NODE_TYPES.TSVoidKeyword],
|
|
8426
|
+
null: [import_utils54.AST_NODE_TYPES.TSNullKeyword],
|
|
8427
|
+
undefined: [import_utils54.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
8428
|
+
literal: [import_utils54.AST_NODE_TYPES.TSLiteralType],
|
|
8429
|
+
date: [import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8430
|
+
array: [import_utils54.AST_NODE_TYPES.TSArrayType, import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8431
|
+
tuple: [import_utils54.AST_NODE_TYPES.TSTupleType],
|
|
8432
|
+
object: [import_utils54.AST_NODE_TYPES.TSTypeLiteral, import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8433
|
+
strictObject: [import_utils54.AST_NODE_TYPES.TSTypeLiteral, import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8434
|
+
looseObject: [import_utils54.AST_NODE_TYPES.TSTypeLiteral, import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8435
|
+
record: [import_utils54.AST_NODE_TYPES.TSTypeReference, import_utils54.AST_NODE_TYPES.TSTypeLiteral],
|
|
8436
|
+
map: [import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8437
|
+
set: [import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8438
|
+
promise: [import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8439
|
+
enum: [import_utils54.AST_NODE_TYPES.TSUnionType, import_utils54.AST_NODE_TYPES.TSTypeReference, import_utils54.AST_NODE_TYPES.TSLiteralType],
|
|
8440
|
+
nativeEnum: [import_utils54.AST_NODE_TYPES.TSUnionType, import_utils54.AST_NODE_TYPES.TSTypeReference, import_utils54.AST_NODE_TYPES.TSLiteralType],
|
|
8441
|
+
union: [import_utils54.AST_NODE_TYPES.TSUnionType, import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8442
|
+
discriminatedUnion: [import_utils54.AST_NODE_TYPES.TSUnionType, import_utils54.AST_NODE_TYPES.TSTypeReference],
|
|
8443
|
+
intersection: [import_utils54.AST_NODE_TYPES.TSIntersectionType, import_utils54.AST_NODE_TYPES.TSTypeReference]
|
|
8217
8444
|
};
|
|
8218
8445
|
function normalizeSchemaName(name) {
|
|
8219
8446
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8222,20 +8449,20 @@ function normalizeTypeName(name) {
|
|
|
8222
8449
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8223
8450
|
}
|
|
8224
8451
|
function unwrapNullish(annotation) {
|
|
8225
|
-
if (annotation.type !==
|
|
8452
|
+
if (annotation.type !== import_utils54.AST_NODE_TYPES.TSUnionType) {
|
|
8226
8453
|
return {
|
|
8227
8454
|
core: annotation,
|
|
8228
|
-
nullable: annotation.type ===
|
|
8455
|
+
nullable: annotation.type === import_utils54.AST_NODE_TYPES.TSNullKeyword
|
|
8229
8456
|
};
|
|
8230
8457
|
}
|
|
8231
8458
|
const rest = [];
|
|
8232
8459
|
let nullable = false;
|
|
8233
8460
|
for (const member of annotation.types) {
|
|
8234
|
-
if (member.type ===
|
|
8461
|
+
if (member.type === import_utils54.AST_NODE_TYPES.TSNullKeyword) {
|
|
8235
8462
|
nullable = true;
|
|
8236
8463
|
continue;
|
|
8237
8464
|
}
|
|
8238
|
-
if (member.type ===
|
|
8465
|
+
if (member.type === import_utils54.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
8239
8466
|
continue;
|
|
8240
8467
|
}
|
|
8241
8468
|
rest.push(member);
|
|
@@ -8300,14 +8527,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8300
8527
|
function zodCallChain(node) {
|
|
8301
8528
|
const chain = [];
|
|
8302
8529
|
let current = node;
|
|
8303
|
-
while (current.type ===
|
|
8530
|
+
while (current.type === import_utils54.AST_NODE_TYPES.CallExpression) {
|
|
8304
8531
|
const callee = current.callee;
|
|
8305
|
-
if (callee.type !==
|
|
8532
|
+
if (callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8306
8533
|
return null;
|
|
8307
8534
|
}
|
|
8308
8535
|
chain.push(current);
|
|
8309
8536
|
const receiver = callee.object;
|
|
8310
|
-
if (receiver.type ===
|
|
8537
|
+
if (receiver.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8311
8538
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
8312
8539
|
}
|
|
8313
8540
|
current = receiver;
|
|
@@ -8316,19 +8543,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
8316
8543
|
}
|
|
8317
8544
|
function methodName(call) {
|
|
8318
8545
|
const callee = call.callee;
|
|
8319
|
-
return callee.type ===
|
|
8546
|
+
return callee.type === import_utils54.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils54.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
8320
8547
|
}
|
|
8321
8548
|
function schemaField(node) {
|
|
8322
8549
|
const modifiers = [];
|
|
8323
8550
|
let current = node;
|
|
8324
8551
|
let leaf = null;
|
|
8325
|
-
while (current.type ===
|
|
8552
|
+
while (current.type === import_utils54.AST_NODE_TYPES.CallExpression) {
|
|
8326
8553
|
const callee = current.callee;
|
|
8327
|
-
if (callee.type !==
|
|
8554
|
+
if (callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8328
8555
|
break;
|
|
8329
8556
|
}
|
|
8330
8557
|
const receiver = callee.object;
|
|
8331
|
-
if (receiver.type ===
|
|
8558
|
+
if (receiver.type === import_utils54.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
8332
8559
|
leaf = callee.property.name;
|
|
8333
8560
|
break;
|
|
8334
8561
|
}
|
|
@@ -8359,16 +8586,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8359
8586
|
return null;
|
|
8360
8587
|
}
|
|
8361
8588
|
const shape = base.arguments[0];
|
|
8362
|
-
if (shape === void 0 || shape.type !==
|
|
8589
|
+
if (shape === void 0 || shape.type !== import_utils54.AST_NODE_TYPES.ObjectExpression) {
|
|
8363
8590
|
return null;
|
|
8364
8591
|
}
|
|
8365
8592
|
const fields = /* @__PURE__ */ new Map();
|
|
8366
8593
|
for (const property of shape.properties) {
|
|
8367
|
-
if (property.type !==
|
|
8594
|
+
if (property.type !== import_utils54.AST_NODE_TYPES.Property || property.computed) {
|
|
8368
8595
|
return null;
|
|
8369
8596
|
}
|
|
8370
8597
|
const { key } = property;
|
|
8371
|
-
const name = key.type ===
|
|
8598
|
+
const name = key.type === import_utils54.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils54.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8372
8599
|
if (name === null) {
|
|
8373
8600
|
return null;
|
|
8374
8601
|
}
|
|
@@ -8379,11 +8606,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8379
8606
|
function typeMembers(members) {
|
|
8380
8607
|
const result = /* @__PURE__ */ new Map();
|
|
8381
8608
|
for (const member of members) {
|
|
8382
|
-
if (member.type !==
|
|
8609
|
+
if (member.type !== import_utils54.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
8383
8610
|
return null;
|
|
8384
8611
|
}
|
|
8385
8612
|
const { key } = member;
|
|
8386
|
-
const name = key.type ===
|
|
8613
|
+
const name = key.type === import_utils54.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils54.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8387
8614
|
if (name === null) {
|
|
8388
8615
|
return null;
|
|
8389
8616
|
}
|
|
@@ -8397,8 +8624,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
8397
8624
|
return result.size === 0 ? null : result;
|
|
8398
8625
|
}
|
|
8399
8626
|
function collectConstrainedNames(node) {
|
|
8400
|
-
if (node.type ===
|
|
8401
|
-
if (node.typeName.type ===
|
|
8627
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeReference) {
|
|
8628
|
+
if (node.typeName.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8402
8629
|
constrainedTypeNames.add(node.typeName.name);
|
|
8403
8630
|
}
|
|
8404
8631
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -8406,11 +8633,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8406
8633
|
}
|
|
8407
8634
|
return;
|
|
8408
8635
|
}
|
|
8409
|
-
if (node.type ===
|
|
8636
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSArrayType) {
|
|
8410
8637
|
collectConstrainedNames(node.elementType);
|
|
8411
8638
|
return;
|
|
8412
8639
|
}
|
|
8413
|
-
if (node.type ===
|
|
8640
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSUnionType || node.type === import_utils54.AST_NODE_TYPES.TSIntersectionType) {
|
|
8414
8641
|
for (const member of node.types) {
|
|
8415
8642
|
collectConstrainedNames(member);
|
|
8416
8643
|
}
|
|
@@ -8454,13 +8681,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
8454
8681
|
return;
|
|
8455
8682
|
}
|
|
8456
8683
|
for (const specifier of node.specifiers) {
|
|
8457
|
-
if (specifier.type ===
|
|
8684
|
+
if (specifier.type === import_utils54.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils54.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils54.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils54.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8458
8685
|
zodNamespaces.add(specifier.local.name);
|
|
8459
8686
|
}
|
|
8460
8687
|
}
|
|
8461
8688
|
},
|
|
8462
8689
|
VariableDeclarator(node) {
|
|
8463
|
-
if (node.id.type !==
|
|
8690
|
+
if (node.id.type !== import_utils54.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
8464
8691
|
return;
|
|
8465
8692
|
}
|
|
8466
8693
|
const fields = schemaFields(node.init);
|
|
@@ -8470,14 +8697,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8470
8697
|
},
|
|
8471
8698
|
/** Guard (f): `XSchema.transform(...)` anywhere in the module. */
|
|
8472
8699
|
"MemberExpression[computed=false]"(node) {
|
|
8473
|
-
if (node.object.type ===
|
|
8700
|
+
if (node.object.type === import_utils54.AST_NODE_TYPES.Identifier && node.property.type === import_utils54.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
8474
8701
|
reshapedSchemaNames.add(node.object.name);
|
|
8475
8702
|
}
|
|
8476
8703
|
},
|
|
8477
8704
|
/** Guard (c): `z.ZodType<T>` and every other type argument it carries. */
|
|
8478
8705
|
TSTypeReference(node) {
|
|
8479
8706
|
const { typeName } = node;
|
|
8480
|
-
const referenced = typeName.type ===
|
|
8707
|
+
const referenced = typeName.type === import_utils54.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils54.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils54.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
8481
8708
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
8482
8709
|
return;
|
|
8483
8710
|
}
|
|
@@ -8495,7 +8722,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
8495
8722
|
}
|
|
8496
8723
|
},
|
|
8497
8724
|
TSTypeAliasDeclaration(node) {
|
|
8498
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
8725
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils54.AST_NODE_TYPES.TSTypeLiteral) {
|
|
8499
8726
|
return;
|
|
8500
8727
|
}
|
|
8501
8728
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -8540,10 +8767,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
8540
8767
|
});
|
|
8541
8768
|
|
|
8542
8769
|
// src/rules/require-assert-never.ts
|
|
8543
|
-
var
|
|
8770
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8544
8771
|
var isRuntimeHandlingStatement = (statement) => {
|
|
8545
|
-
if (statement.type ===
|
|
8546
|
-
if (statement.type ===
|
|
8772
|
+
if (statement.type === import_utils55.AST_NODE_TYPES.EmptyStatement) return false;
|
|
8773
|
+
if (statement.type === import_utils55.AST_NODE_TYPES.BlockStatement) {
|
|
8547
8774
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
8548
8775
|
}
|
|
8549
8776
|
return true;
|
|
@@ -8559,7 +8786,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
8559
8786
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
8560
8787
|
}
|
|
8561
8788
|
const only = defaultCase.consequent[0];
|
|
8562
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
8789
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils55.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
8563
8790
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
8564
8791
|
}
|
|
8565
8792
|
return false;
|
|
@@ -8599,7 +8826,7 @@ var require_assert_never_default = createRule({
|
|
|
8599
8826
|
});
|
|
8600
8827
|
|
|
8601
8828
|
// src/rules/require-fetch-timeout.ts
|
|
8602
|
-
var
|
|
8829
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8603
8830
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
8604
8831
|
"globalThis",
|
|
8605
8832
|
"window",
|
|
@@ -8615,14 +8842,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
8615
8842
|
return false;
|
|
8616
8843
|
}
|
|
8617
8844
|
function initProvablyLacksSignal(init) {
|
|
8618
|
-
if (init.type !==
|
|
8845
|
+
if (init.type !== import_utils56.AST_NODE_TYPES.ObjectExpression) {
|
|
8619
8846
|
return false;
|
|
8620
8847
|
}
|
|
8621
8848
|
for (const prop of init.properties) {
|
|
8622
|
-
if (prop.type ===
|
|
8849
|
+
if (prop.type === import_utils56.AST_NODE_TYPES.SpreadElement) {
|
|
8623
8850
|
return false;
|
|
8624
8851
|
}
|
|
8625
|
-
if (prop.key.type ===
|
|
8852
|
+
if (prop.key.type === import_utils56.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils56.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
8626
8853
|
return false;
|
|
8627
8854
|
}
|
|
8628
8855
|
if (prop.computed) {
|
|
@@ -8632,7 +8859,7 @@ function initProvablyLacksSignal(init) {
|
|
|
8632
8859
|
return true;
|
|
8633
8860
|
}
|
|
8634
8861
|
function isStringish(node) {
|
|
8635
|
-
return node.type ===
|
|
8862
|
+
return node.type === import_utils56.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils56.AST_NODE_TYPES.TemplateLiteral;
|
|
8636
8863
|
}
|
|
8637
8864
|
var require_fetch_timeout_default = createRule({
|
|
8638
8865
|
name: "require-fetch-timeout",
|
|
@@ -8669,14 +8896,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
8669
8896
|
}
|
|
8670
8897
|
function resolvesToGlobal(identifier) {
|
|
8671
8898
|
const scope = context.sourceCode.getScope(identifier);
|
|
8672
|
-
const variable =
|
|
8899
|
+
const variable = import_utils56.ASTUtils.findVariable(scope, identifier.name);
|
|
8673
8900
|
return variable === null || variable.defs.length === 0;
|
|
8674
8901
|
}
|
|
8675
8902
|
function isGlobalFetchCall2(callee) {
|
|
8676
|
-
if (callee.type ===
|
|
8903
|
+
if (callee.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8677
8904
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
8678
8905
|
}
|
|
8679
|
-
return callee.type ===
|
|
8906
|
+
return callee.type === import_utils56.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils56.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils56.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
8680
8907
|
}
|
|
8681
8908
|
return {
|
|
8682
8909
|
CallExpression(node) {
|
|
@@ -8696,7 +8923,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
8696
8923
|
});
|
|
8697
8924
|
|
|
8698
8925
|
// src/rules/require-interface-for-injected-service.ts
|
|
8699
|
-
var
|
|
8926
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8700
8927
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
8701
8928
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
8702
8929
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -8704,20 +8931,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
8704
8931
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
8705
8932
|
var ROUTER_FACTORY_NAME = "Router";
|
|
8706
8933
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
8707
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
8708
|
-
var qualifiedName = (name) => name.type ===
|
|
8934
|
+
var isExportedClass = (node) => node.parent.type === import_utils57.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils57.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
8935
|
+
var qualifiedName = (name) => name.type === import_utils57.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils57.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
8709
8936
|
var readTypeReference = (annotation) => {
|
|
8710
|
-
if (annotation === void 0 || annotation.type !==
|
|
8937
|
+
if (annotation === void 0 || annotation.type !== import_utils57.AST_NODE_TYPES.TSTypeReference) return null;
|
|
8711
8938
|
const { typeName } = annotation;
|
|
8712
|
-
const rightmost = typeName.type ===
|
|
8939
|
+
const rightmost = typeName.type === import_utils57.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils57.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
8713
8940
|
if (rightmost === null) return null;
|
|
8714
8941
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
8715
8942
|
};
|
|
8716
8943
|
var namedParameterCollaborator = (annotated) => {
|
|
8717
8944
|
let target = annotated;
|
|
8718
|
-
if (target.type ===
|
|
8719
|
-
if (target.type ===
|
|
8720
|
-
if (target.type !==
|
|
8945
|
+
if (target.type === import_utils57.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
8946
|
+
if (target.type === import_utils57.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
8947
|
+
if (target.type !== import_utils57.AST_NODE_TYPES.Identifier) return null;
|
|
8721
8948
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
8722
8949
|
if (reference === null) return null;
|
|
8723
8950
|
return { name: target.name, ...reference };
|
|
@@ -8725,8 +8952,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
8725
8952
|
var propertySignatureTypes = (members) => {
|
|
8726
8953
|
const types = /* @__PURE__ */ new Map();
|
|
8727
8954
|
for (const member of members) {
|
|
8728
|
-
if (member.type !==
|
|
8729
|
-
if (member.computed || member.key.type !==
|
|
8955
|
+
if (member.type !== import_utils57.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
8956
|
+
if (member.computed || member.key.type !== import_utils57.AST_NODE_TYPES.Identifier) continue;
|
|
8730
8957
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
8731
8958
|
if (reference === null) continue;
|
|
8732
8959
|
types.set(member.key.name, reference);
|
|
@@ -8737,18 +8964,18 @@ var fileTypeIndex = (program) => {
|
|
|
8737
8964
|
const objects = /* @__PURE__ */ new Map();
|
|
8738
8965
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
8739
8966
|
for (const statement of program.body) {
|
|
8740
|
-
const declaration = statement.type ===
|
|
8741
|
-
if (declaration?.type ===
|
|
8967
|
+
const declaration = statement.type === import_utils57.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
8968
|
+
if (declaration?.type === import_utils57.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
8742
8969
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
8743
8970
|
continue;
|
|
8744
8971
|
}
|
|
8745
|
-
if (declaration?.type !==
|
|
8972
|
+
if (declaration?.type !== import_utils57.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
8746
8973
|
const aliased = declaration.typeAnnotation;
|
|
8747
|
-
if (aliased.type ===
|
|
8974
|
+
if (aliased.type === import_utils57.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils57.AST_NODE_TYPES.TSConstructorType) {
|
|
8748
8975
|
functionAliases.add(declaration.id.name);
|
|
8749
8976
|
continue;
|
|
8750
8977
|
}
|
|
8751
|
-
const literals = aliased.type ===
|
|
8978
|
+
const literals = aliased.type === import_utils57.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils57.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils57.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
8752
8979
|
if (literals.length === 0) continue;
|
|
8753
8980
|
const merged = /* @__PURE__ */ new Map();
|
|
8754
8981
|
for (const literal of literals) {
|
|
@@ -8761,10 +8988,10 @@ var fileTypeIndex = (program) => {
|
|
|
8761
8988
|
return { objects, functionAliases };
|
|
8762
8989
|
};
|
|
8763
8990
|
var bagMemberTypes = (annotation, declared) => {
|
|
8764
|
-
if (annotation.type ===
|
|
8991
|
+
if (annotation.type === import_utils57.AST_NODE_TYPES.TSTypeLiteral) {
|
|
8765
8992
|
return propertySignatureTypes(annotation.members);
|
|
8766
8993
|
}
|
|
8767
|
-
if (annotation.type !==
|
|
8994
|
+
if (annotation.type !== import_utils57.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8768
8995
|
return null;
|
|
8769
8996
|
}
|
|
8770
8997
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -8776,11 +9003,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
8776
9003
|
if (members === null) return [];
|
|
8777
9004
|
const collaborators = [];
|
|
8778
9005
|
for (const property of pattern.properties) {
|
|
8779
|
-
if (property.type !==
|
|
8780
|
-
if (property.key.type !==
|
|
9006
|
+
if (property.type !== import_utils57.AST_NODE_TYPES.Property || property.computed) continue;
|
|
9007
|
+
if (property.key.type !== import_utils57.AST_NODE_TYPES.Identifier) continue;
|
|
8781
9008
|
const key = property.key.name;
|
|
8782
|
-
const bound = property.value.type ===
|
|
8783
|
-
if (bound.type !==
|
|
9009
|
+
const bound = property.value.type === import_utils57.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
9010
|
+
if (bound.type !== import_utils57.AST_NODE_TYPES.Identifier) continue;
|
|
8784
9011
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
8785
9012
|
const reference = members.get(key);
|
|
8786
9013
|
if (reference === void 0) continue;
|
|
@@ -8790,8 +9017,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
8790
9017
|
};
|
|
8791
9018
|
var parameterCollaborators = (parameter, declared) => {
|
|
8792
9019
|
let target = parameter;
|
|
8793
|
-
if (target.type ===
|
|
8794
|
-
if (target.type ===
|
|
9020
|
+
if (target.type === import_utils57.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9021
|
+
if (target.type === import_utils57.AST_NODE_TYPES.ObjectPattern) {
|
|
8795
9022
|
return objectPatternCollaborators(target, declared);
|
|
8796
9023
|
}
|
|
8797
9024
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -8810,17 +9037,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
8810
9037
|
let constructedFields = 0;
|
|
8811
9038
|
if (body !== null && body !== void 0) {
|
|
8812
9039
|
for (const statement of body.body) {
|
|
8813
|
-
if (statement.type !==
|
|
9040
|
+
if (statement.type !== import_utils57.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
8814
9041
|
const expression = statement.expression;
|
|
8815
|
-
if (expression.type !==
|
|
9042
|
+
if (expression.type !== import_utils57.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils57.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils57.AST_NODE_TYPES.ThisExpression) {
|
|
8816
9043
|
continue;
|
|
8817
9044
|
}
|
|
8818
9045
|
const source = expression.right;
|
|
8819
|
-
if (source.type ===
|
|
9046
|
+
if (source.type === import_utils57.AST_NODE_TYPES.NewExpression) {
|
|
8820
9047
|
constructedFields += 1;
|
|
8821
|
-
} else if (source.type ===
|
|
9048
|
+
} else if (source.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8822
9049
|
storedFrom.add(source.name);
|
|
8823
|
-
} else if (source.type ===
|
|
9050
|
+
} else if (source.type === import_utils57.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8824
9051
|
storedFrom.add(source.object.name);
|
|
8825
9052
|
}
|
|
8826
9053
|
}
|
|
@@ -8828,7 +9055,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
8828
9055
|
const collaborators = [];
|
|
8829
9056
|
for (const parameter of ctor.value.params) {
|
|
8830
9057
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
8831
|
-
const stored = parameter.type ===
|
|
9058
|
+
const stored = parameter.type === import_utils57.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
8832
9059
|
if (!stored) continue;
|
|
8833
9060
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
8834
9061
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -8862,19 +9089,19 @@ var subtreeHas = (root, found) => {
|
|
|
8862
9089
|
return hit;
|
|
8863
9090
|
};
|
|
8864
9091
|
var isFrameworkWiring = (body) => subtreeHas(body, (node) => {
|
|
8865
|
-
if (node.type ===
|
|
9092
|
+
if (node.type === import_utils57.AST_NODE_TYPES.CallExpression) {
|
|
8866
9093
|
const { callee } = node;
|
|
8867
|
-
if (callee.type ===
|
|
8868
|
-
return callee.type ===
|
|
9094
|
+
if (callee.type === import_utils57.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9095
|
+
return callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils57.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
8869
9096
|
}
|
|
8870
|
-
return node.type ===
|
|
9097
|
+
return node.type === import_utils57.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils57.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
8871
9098
|
});
|
|
8872
9099
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
8873
9100
|
var fileInterfaceNames = (program) => {
|
|
8874
9101
|
const names = [];
|
|
8875
9102
|
for (const statement of program.body) {
|
|
8876
|
-
const declaration = statement.type ===
|
|
8877
|
-
if (declaration?.type ===
|
|
9103
|
+
const declaration = statement.type === import_utils57.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9104
|
+
if (declaration?.type === import_utils57.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
8878
9105
|
}
|
|
8879
9106
|
return names;
|
|
8880
9107
|
};
|
|
@@ -8892,11 +9119,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
8892
9119
|
var publicMethodNames = (body) => {
|
|
8893
9120
|
const names = [];
|
|
8894
9121
|
for (const member of body.body) {
|
|
8895
|
-
if (member.type !==
|
|
9122
|
+
if (member.type !== import_utils57.AST_NODE_TYPES.MethodDefinition) continue;
|
|
8896
9123
|
if (member.kind !== "method" || member.static) continue;
|
|
8897
9124
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
8898
|
-
if (member.key.type ===
|
|
8899
|
-
if (member.key.type ===
|
|
9125
|
+
if (member.key.type === import_utils57.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
9126
|
+
if (member.key.type === import_utils57.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
8900
9127
|
else names.push("\u2026");
|
|
8901
9128
|
}
|
|
8902
9129
|
return names;
|
|
@@ -8929,7 +9156,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
8929
9156
|
if (node.implements.length > 0) return;
|
|
8930
9157
|
if (node.decorators.length > 0) return;
|
|
8931
9158
|
const ctor = node.body.body.find(
|
|
8932
|
-
(member) => member.type ===
|
|
9159
|
+
(member) => member.type === import_utils57.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
8933
9160
|
);
|
|
8934
9161
|
if (ctor === void 0) return;
|
|
8935
9162
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -8958,18 +9185,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
8958
9185
|
});
|
|
8959
9186
|
|
|
8960
9187
|
// src/rules/require-zod-form-validation.ts
|
|
8961
|
-
var
|
|
9188
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8962
9189
|
var looksLikeZodSchema = (node) => {
|
|
8963
9190
|
let current = node;
|
|
8964
9191
|
while (true) {
|
|
8965
|
-
if (current.type ===
|
|
9192
|
+
if (current.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8966
9193
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
8967
9194
|
}
|
|
8968
|
-
if (current.type ===
|
|
9195
|
+
if (current.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
8969
9196
|
current = current.callee;
|
|
8970
9197
|
continue;
|
|
8971
9198
|
}
|
|
8972
|
-
if (current.type ===
|
|
9199
|
+
if (current.type === import_utils58.AST_NODE_TYPES.MemberExpression) {
|
|
8973
9200
|
current = current.object;
|
|
8974
9201
|
continue;
|
|
8975
9202
|
}
|
|
@@ -8977,23 +9204,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
8977
9204
|
}
|
|
8978
9205
|
};
|
|
8979
9206
|
var isZodParseCall = (node) => {
|
|
8980
|
-
if (node.type !==
|
|
9207
|
+
if (node.type !== import_utils58.AST_NODE_TYPES.CallExpression) return false;
|
|
8981
9208
|
const callee = node.callee;
|
|
8982
|
-
if (callee.type !==
|
|
9209
|
+
if (callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression) return false;
|
|
8983
9210
|
if (callee.computed) return false;
|
|
8984
|
-
if (callee.property.type !==
|
|
9211
|
+
if (callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier) return false;
|
|
8985
9212
|
const method = callee.property.name;
|
|
8986
9213
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
8987
9214
|
return looksLikeZodSchema(callee.object);
|
|
8988
9215
|
};
|
|
8989
9216
|
var isFormDataMethodCall = (node) => {
|
|
8990
9217
|
let current = node;
|
|
8991
|
-
if (current.type ===
|
|
9218
|
+
if (current.type === import_utils58.AST_NODE_TYPES.AwaitExpression) {
|
|
8992
9219
|
current = current.argument;
|
|
8993
9220
|
}
|
|
8994
|
-
if (current.type !==
|
|
9221
|
+
if (current.type !== import_utils58.AST_NODE_TYPES.CallExpression) return false;
|
|
8995
9222
|
const callee = current.callee;
|
|
8996
|
-
return callee.type ===
|
|
9223
|
+
return callee.type === import_utils58.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils58.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
8997
9224
|
};
|
|
8998
9225
|
var require_zod_form_validation_default = createRule({
|
|
8999
9226
|
name: "require-zod-form-validation",
|
|
@@ -9013,14 +9240,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9013
9240
|
return {};
|
|
9014
9241
|
}
|
|
9015
9242
|
const isFormSourceIdentifier = (node) => {
|
|
9016
|
-
if (node.type !==
|
|
9243
|
+
if (node.type !== import_utils58.AST_NODE_TYPES.Identifier) return false;
|
|
9017
9244
|
if (/formdata/i.test(node.name)) return true;
|
|
9018
9245
|
let scope = context.sourceCode.getScope(node);
|
|
9019
9246
|
while (scope !== null) {
|
|
9020
9247
|
const variable = scope.set.get(node.name);
|
|
9021
9248
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9022
9249
|
const def = variable.defs[0];
|
|
9023
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
9250
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils58.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
9024
9251
|
return isFormDataMethodCall(def.node.init);
|
|
9025
9252
|
}
|
|
9026
9253
|
return false;
|
|
@@ -9031,8 +9258,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9031
9258
|
};
|
|
9032
9259
|
const isFormDataGetCall = (node) => {
|
|
9033
9260
|
const callee = node.callee;
|
|
9034
|
-
if (callee.type !==
|
|
9035
|
-
if (callee.property.type !==
|
|
9261
|
+
if (callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression) return false;
|
|
9262
|
+
if (callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
9036
9263
|
return false;
|
|
9037
9264
|
}
|
|
9038
9265
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9047,11 +9274,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9047
9274
|
};
|
|
9048
9275
|
const isInstanceofNarrowing = (node) => {
|
|
9049
9276
|
const parent = node.parent;
|
|
9050
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9277
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils58.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node;
|
|
9051
9278
|
};
|
|
9052
9279
|
const boundDeclarator = (node) => {
|
|
9053
9280
|
const parent = node.parent;
|
|
9054
|
-
if (parent.type ===
|
|
9281
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9055
9282
|
return parent;
|
|
9056
9283
|
}
|
|
9057
9284
|
return null;
|
|
@@ -9079,7 +9306,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
9079
9306
|
});
|
|
9080
9307
|
|
|
9081
9308
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
9082
|
-
var
|
|
9309
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
9083
9310
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
9084
9311
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
9085
9312
|
var INSERT_GATE = /insert/i;
|
|
@@ -9110,7 +9337,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9110
9337
|
});
|
|
9111
9338
|
|
|
9112
9339
|
// src/rules/zod-naming-convention.ts
|
|
9113
|
-
var
|
|
9340
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9114
9341
|
var CONVENTIONS = {
|
|
9115
9342
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9116
9343
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9135,15 +9362,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9135
9362
|
"registry",
|
|
9136
9363
|
"implement"
|
|
9137
9364
|
]);
|
|
9138
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
9365
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils60.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
9139
9366
|
var calleeChainStartsWithZ = (node) => {
|
|
9140
9367
|
let current = node;
|
|
9141
|
-
while (current.type ===
|
|
9368
|
+
while (current.type === import_utils60.AST_NODE_TYPES.MemberExpression) {
|
|
9142
9369
|
const receiver = current.object;
|
|
9143
|
-
if (receiver.type ===
|
|
9370
|
+
if (receiver.type === import_utils60.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
9144
9371
|
return true;
|
|
9145
9372
|
}
|
|
9146
|
-
if (receiver.type ===
|
|
9373
|
+
if (receiver.type === import_utils60.AST_NODE_TYPES.CallExpression) {
|
|
9147
9374
|
current = receiver.callee;
|
|
9148
9375
|
continue;
|
|
9149
9376
|
}
|
|
@@ -9188,13 +9415,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9188
9415
|
VariableDeclarator(node) {
|
|
9189
9416
|
const init = node.init;
|
|
9190
9417
|
if (init === null || init === void 0) return;
|
|
9191
|
-
if (init.type !==
|
|
9418
|
+
if (init.type !== import_utils60.AST_NODE_TYPES.CallExpression) return;
|
|
9192
9419
|
const callee = init.callee;
|
|
9193
|
-
if (callee.type !==
|
|
9420
|
+
if (callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression) return;
|
|
9194
9421
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9195
9422
|
const terminal = terminalMethodName(callee);
|
|
9196
9423
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9197
|
-
if (node.id.type !==
|
|
9424
|
+
if (node.id.type !== import_utils60.AST_NODE_TYPES.Identifier) return;
|
|
9198
9425
|
if (test.test(node.id.name)) return;
|
|
9199
9426
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9200
9427
|
context.report({
|
|
@@ -9294,6 +9521,7 @@ var rules = {
|
|
|
9294
9521
|
"no-tautological-expect": no_tautological_expect_default,
|
|
9295
9522
|
"no-trailing-value-narration": no_trailing_value_narration_default,
|
|
9296
9523
|
"no-declaration-comment-wall": no_declaration_comment_wall_default,
|
|
9524
|
+
"no-union-in-comment": no_union_in_comment_default,
|
|
9297
9525
|
"no-type-member-comment-wall": no_type_member_comment_wall_default,
|
|
9298
9526
|
"no-unnecessary-use-client": no_unnecessary_use_client_default,
|
|
9299
9527
|
"no-unsafe-mock-casting": no_unsafe_mock_casting_default,
|
|
@@ -9319,7 +9547,7 @@ var rules = {
|
|
|
9319
9547
|
};
|
|
9320
9548
|
var meta = {
|
|
9321
9549
|
name: "@sarj/eslint-plugin",
|
|
9322
|
-
version: "9.
|
|
9550
|
+
version: "9.4.0"
|
|
9323
9551
|
};
|
|
9324
9552
|
var recommendedRules = {
|
|
9325
9553
|
"@sarj/enforce-file-structure": "warn",
|
|
@@ -9348,6 +9576,7 @@ var recommendedRules = {
|
|
|
9348
9576
|
"@sarj/no-tautological-expect": "warn",
|
|
9349
9577
|
"@sarj/no-trailing-value-narration": "warn",
|
|
9350
9578
|
"@sarj/no-declaration-comment-wall": "warn",
|
|
9579
|
+
"@sarj/no-union-in-comment": "warn",
|
|
9351
9580
|
"@sarj/no-type-member-comment-wall": "warn",
|
|
9352
9581
|
"@sarj/no-unnecessary-use-client": "warn",
|
|
9353
9582
|
"@sarj/no-unsafe-mock-casting": "warn",
|
|
@@ -9402,6 +9631,7 @@ var strictRules = {
|
|
|
9402
9631
|
"@sarj/no-tautological-expect": "error",
|
|
9403
9632
|
"@sarj/no-trailing-value-narration": "error",
|
|
9404
9633
|
"@sarj/no-declaration-comment-wall": "error",
|
|
9634
|
+
"@sarj/no-union-in-comment": "error",
|
|
9405
9635
|
"@sarj/no-type-member-comment-wall": "error",
|
|
9406
9636
|
"@sarj/no-unnecessary-use-client": "error",
|
|
9407
9637
|
"@sarj/no-unsafe-mock-casting": "error",
|