@sarj/eslint-plugin 9.5.0 → 9.7.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 +8 -11
- package/dist/index.cjs +1064 -675
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -16
- package/dist/index.d.ts +29 -16
- package/dist/index.js +1053 -664
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -45,10 +45,10 @@ var import_utils2 = require("@typescript-eslint/utils");
|
|
|
45
45
|
// src/rules/_docs.ts
|
|
46
46
|
var import_utils = require("@typescript-eslint/utils");
|
|
47
47
|
var REPO_BLOB = "https://github.com/sarj-ai/standards/blob/main";
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var createRule = import_utils.ESLintUtils.RuleCreator(
|
|
48
|
+
var TESTS_DIR = "packages/typescript/tests/rules";
|
|
49
|
+
var examplesPath = (name) => `${TESTS_DIR}/${name}.test.ts`;
|
|
50
|
+
var examplesUrl = (name) => `${REPO_BLOB}/${examplesPath(name)}`;
|
|
51
|
+
var createRule = import_utils.ESLintUtils.RuleCreator(examplesUrl);
|
|
52
52
|
|
|
53
53
|
// src/rules/_paths.ts
|
|
54
54
|
var SCRIPT_FILE_RE = /([\\/]scripts[\\/])|(\.mjs$)/;
|
|
@@ -133,8 +133,8 @@ var enforce_file_structure_default = createRule({
|
|
|
133
133
|
}
|
|
134
134
|
return {
|
|
135
135
|
Program(node) {
|
|
136
|
-
const
|
|
137
|
-
const misplacedUseServer =
|
|
136
|
+
const body2 = node.body;
|
|
137
|
+
const misplacedUseServer = body2.find(
|
|
138
138
|
(statement, index) => index > 0 && isUseServerDirective(statement)
|
|
139
139
|
);
|
|
140
140
|
if (misplacedUseServer !== void 0) {
|
|
@@ -145,7 +145,7 @@ var enforce_file_structure_default = createRule({
|
|
|
145
145
|
}
|
|
146
146
|
let seenBody = false;
|
|
147
147
|
let inMisplacedRun = false;
|
|
148
|
-
for (const statement of
|
|
148
|
+
for (const statement of body2) {
|
|
149
149
|
if (isStringDirective(statement)) continue;
|
|
150
150
|
switch (classifyStatement(statement)) {
|
|
151
151
|
case "reexport":
|
|
@@ -366,11 +366,11 @@ var PROTECTED_SIGNALS = [
|
|
|
366
366
|
SECURITY_RE,
|
|
367
367
|
VENDOR_RE
|
|
368
368
|
];
|
|
369
|
-
function isProtected(
|
|
370
|
-
return PROTECTED_SIGNALS.some((signal) => signal.test(
|
|
369
|
+
function isProtected(body2) {
|
|
370
|
+
return PROTECTED_SIGNALS.some((signal) => signal.test(body2));
|
|
371
371
|
}
|
|
372
|
-
function hasExternalReference(
|
|
373
|
-
return REF_RE.test(
|
|
372
|
+
function hasExternalReference(body2) {
|
|
373
|
+
return REF_RE.test(body2);
|
|
374
374
|
}
|
|
375
375
|
var STOPWORDS = new Set(
|
|
376
376
|
`a an the this that these those it its their his her our your my
|
|
@@ -518,9 +518,9 @@ function restatableStatementBelow(comment, sourceCode) {
|
|
|
518
518
|
}
|
|
519
519
|
return null;
|
|
520
520
|
}
|
|
521
|
-
function restatesStatementHead(
|
|
521
|
+
function restatesStatementHead(body2, statement) {
|
|
522
522
|
if (statement === null) return false;
|
|
523
|
-
const words =
|
|
523
|
+
const words = body2.match(/[A-Za-z][\w$]*/g) ?? [];
|
|
524
524
|
const opener = words[0];
|
|
525
525
|
if (opener === void 0 || words.length > NARRATION_MAX_WORDS) return false;
|
|
526
526
|
if (!NARRATION_VERB_RE.test(opener)) return false;
|
|
@@ -533,6 +533,14 @@ function restatesStatementHead(body, statement) {
|
|
|
533
533
|
|
|
534
534
|
// src/rules/no-comment-cruft.ts
|
|
535
535
|
var LEADING_PREAMBLE_MIN = 4;
|
|
536
|
+
var WALL_MIN_STATEMENTS = 4;
|
|
537
|
+
var WALL_MIN_COMMENTS = 3;
|
|
538
|
+
var WALL_MIN_COMMENTED_RATIO = 0.6;
|
|
539
|
+
var WALL_MIN_WEAK_RATIO = 0.75;
|
|
540
|
+
var WALL_MAX_WORDS = 18;
|
|
541
|
+
var WALL_MAX_NOVEL_WORDS = 2;
|
|
542
|
+
var WALL_NARRATION_RE = /^(?:first(?:ly)?|second(?:ly)?|third(?:ly)?|then|next|now|finally|lastly|add|append|assign|await|build|calculate|call|check|clear|close|compute|convert|copy|count|create|declare|define|delete|extract|fetch|filter|find|format|generate|get|handle|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|d|ed|ing)?\b/i;
|
|
543
|
+
var WALL_STEP_PREFIX_RE = /^(?:\d+[.)]|(?:phase|step)\s+\d+\s*:)\s*/i;
|
|
536
544
|
var STEP_NARRATION_RE = /^(?:first(?:ly)?|second(?:ly)?|third(?:ly)?|then|next|after(?:wards| that)?|finally|lastly|now)\s*[,:]\s*\S/i;
|
|
537
545
|
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
546
|
var FOR_NOW_RE = /\bfor now\b/i;
|
|
@@ -711,11 +719,11 @@ function isProse(text) {
|
|
|
711
719
|
return false;
|
|
712
720
|
}
|
|
713
721
|
var JUSTIFICATION_RE = /\b(?:because|since|until|due to|so that|so we|so it|so the|otherwise|which is why|in order to|to avoid|to work around|to prevent|backwards? compat(?:ibility)?|for compatibility)\b/i;
|
|
714
|
-
function restatesWholeStatement(
|
|
715
|
-
return statement !== null && restatesStatementHead(
|
|
722
|
+
function restatesWholeStatement(body2, statement) {
|
|
723
|
+
return statement !== null && restatesStatementHead(body2, statement.replaceAll("(", " "));
|
|
716
724
|
}
|
|
717
|
-
function isRedundantNarration(
|
|
718
|
-
const t =
|
|
725
|
+
function isRedundantNarration(body2, statementBelow, standalone, isolatedEnumeration, nested) {
|
|
726
|
+
const t = body2.trim();
|
|
719
727
|
if (!t || looksLikeCode(t) || hasPseudocode(t)) return false;
|
|
720
728
|
if (standalone) {
|
|
721
729
|
const justified = JUSTIFICATION_RE.test(t);
|
|
@@ -745,6 +753,63 @@ var STATEMENT_CONTAINERS = /* @__PURE__ */ new Set([
|
|
|
745
753
|
import_utils6.AST_NODE_TYPES.TSModuleBlock,
|
|
746
754
|
import_utils6.AST_NODE_TYPES.TSInterfaceBody
|
|
747
755
|
]);
|
|
756
|
+
function directStatements(container) {
|
|
757
|
+
switch (container.type) {
|
|
758
|
+
case import_utils6.AST_NODE_TYPES.Program:
|
|
759
|
+
case import_utils6.AST_NODE_TYPES.BlockStatement:
|
|
760
|
+
case import_utils6.AST_NODE_TYPES.ClassBody:
|
|
761
|
+
case import_utils6.AST_NODE_TYPES.StaticBlock:
|
|
762
|
+
case import_utils6.AST_NODE_TYPES.TSModuleBlock:
|
|
763
|
+
return container.body;
|
|
764
|
+
case import_utils6.AST_NODE_TYPES.SwitchCase:
|
|
765
|
+
return container.consequent;
|
|
766
|
+
case import_utils6.AST_NODE_TYPES.TSInterfaceBody:
|
|
767
|
+
return container.body;
|
|
768
|
+
default:
|
|
769
|
+
return [];
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
var WALL_STATEMENTS = /* @__PURE__ */ new Set([
|
|
773
|
+
import_utils6.AST_NODE_TYPES.ExpressionStatement,
|
|
774
|
+
import_utils6.AST_NODE_TYPES.ReturnStatement,
|
|
775
|
+
import_utils6.AST_NODE_TYPES.ThrowStatement,
|
|
776
|
+
import_utils6.AST_NODE_TYPES.VariableDeclaration,
|
|
777
|
+
import_utils6.AST_NODE_TYPES.IfStatement,
|
|
778
|
+
import_utils6.AST_NODE_TYPES.ForStatement,
|
|
779
|
+
import_utils6.AST_NODE_TYPES.ForOfStatement,
|
|
780
|
+
import_utils6.AST_NODE_TYPES.ForInStatement,
|
|
781
|
+
import_utils6.AST_NODE_TYPES.WhileStatement,
|
|
782
|
+
import_utils6.AST_NODE_TYPES.DoWhileStatement,
|
|
783
|
+
import_utils6.AST_NODE_TYPES.SwitchStatement,
|
|
784
|
+
import_utils6.AST_NODE_TYPES.TryStatement
|
|
785
|
+
]);
|
|
786
|
+
function statementAttachmentBelow(comment, sourceCode) {
|
|
787
|
+
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
788
|
+
if (token === null || token.loc.start.line !== comment.loc.end.line + 1 || token.loc.start.column !== comment.loc.start.column) {
|
|
789
|
+
return null;
|
|
790
|
+
}
|
|
791
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node?.parent != null; node = node.parent) {
|
|
792
|
+
if (!STATEMENT_CONTAINERS.has(node.parent.type) || !WALL_STATEMENTS.has(node.type)) {
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
const siblings = directStatements(node.parent);
|
|
796
|
+
const index = siblings.indexOf(node);
|
|
797
|
+
return index < 0 ? null : { container: node.parent, index, statement: sourceCode.getText(node) };
|
|
798
|
+
}
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
function isWeakWalkthroughComment(body2, statement) {
|
|
802
|
+
const normalized = body2.replace(WALL_STEP_PREFIX_RE, "");
|
|
803
|
+
if (normalized.length === 0 || normalized.endsWith("?") || normalized.split(/\s+/).length > WALL_MAX_WORDS || isDirective(normalized) || isProtected(normalized) || !WALL_NARRATION_RE.test(normalized)) {
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
const words = contentTokens(normalized);
|
|
807
|
+
const described = words.slice(1);
|
|
808
|
+
if (described.length === 0) return false;
|
|
809
|
+
const code = codeTokens(statement);
|
|
810
|
+
const matched = described.filter((word) => restates([word], code)).length;
|
|
811
|
+
return matched / described.length >= 0.5 && described.length - matched <= WALL_MAX_NOVEL_WORDS;
|
|
812
|
+
}
|
|
748
813
|
var TYPE_MEMBER_CONTAINERS = /* @__PURE__ */ new Set([
|
|
749
814
|
import_utils6.AST_NODE_TYPES.TSInterfaceBody,
|
|
750
815
|
import_utils6.AST_NODE_TYPES.TSTypeLiteral
|
|
@@ -771,8 +836,8 @@ var LEAD_IN_SCAN_LIMIT = 24;
|
|
|
771
836
|
function hasIllustrationLeadInAbove(comments, index) {
|
|
772
837
|
for (let i = index - 1; i >= 0 && index - i <= LEAD_IN_SCAN_LIMIT; i--) {
|
|
773
838
|
if (!areAdjacentLineComments(comments[i], comments[i + 1])) return false;
|
|
774
|
-
const
|
|
775
|
-
if (
|
|
839
|
+
const body2 = stripCommentMarker(comments[i]?.value ?? "");
|
|
840
|
+
if (body2.length > 0 && body2.endsWith(":")) return true;
|
|
776
841
|
}
|
|
777
842
|
return false;
|
|
778
843
|
}
|
|
@@ -800,6 +865,7 @@ var no_comment_cruft_default = createRule({
|
|
|
800
865
|
commentedOutCode: "Commented-out code \u2014 delete it; git history remembers.",
|
|
801
866
|
sectionBanner: "Section-banner / region comment \u2014 structure code with functions, not ASCII rules.",
|
|
802
867
|
fileHeaderPreamble: "File-header comment preamble \u2014 use a brief doc comment for the why, not a block of `//` lines.",
|
|
868
|
+
commentWall: "Statement comment wall ({{count}} narrated steps) \u2014 delete the walkthrough and name the operations in code; keep only constraints or rationale.",
|
|
803
869
|
redundantNarration: "Comment narrates the code \u2014 delete it or say *why*, not *what*. Code is self-documenting.",
|
|
804
870
|
untrackedTodo: "Untracked TODO/FIXME marker \u2014 add an issue ticket or context link."
|
|
805
871
|
}
|
|
@@ -819,6 +885,48 @@ var no_comment_cruft_default = createRule({
|
|
|
819
885
|
function isJsDoc(comment) {
|
|
820
886
|
return comment.type === "Block" && /^\*/.test(comment.value);
|
|
821
887
|
}
|
|
888
|
+
function findCommentWalls(comments) {
|
|
889
|
+
const attached = /* @__PURE__ */ new Map();
|
|
890
|
+
for (const comment of comments) {
|
|
891
|
+
if (comment.type !== "Line" || !isStandalone(comment)) continue;
|
|
892
|
+
const attachment = statementAttachmentBelow(comment, sourceCode);
|
|
893
|
+
if (attachment === null) continue;
|
|
894
|
+
const body2 = stripCommentMarker(comment.value);
|
|
895
|
+
const entries = attached.get(attachment.container) ?? [];
|
|
896
|
+
entries.push({
|
|
897
|
+
comment,
|
|
898
|
+
index: attachment.index,
|
|
899
|
+
weak: isWeakWalkthroughComment(body2, attachment.statement)
|
|
900
|
+
});
|
|
901
|
+
attached.set(attachment.container, entries);
|
|
902
|
+
}
|
|
903
|
+
const walls = [];
|
|
904
|
+
for (const entries of attached.values()) {
|
|
905
|
+
const sorted = entries.toSorted((left, right) => left.index - right.index);
|
|
906
|
+
const clusters = [];
|
|
907
|
+
for (const entry of sorted) {
|
|
908
|
+
const cluster = clusters.at(-1);
|
|
909
|
+
if (cluster !== void 0 && entry.index <= (cluster.at(-1)?.index ?? 0) + 2) {
|
|
910
|
+
cluster.push(entry);
|
|
911
|
+
} else {
|
|
912
|
+
clusters.push([entry]);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
for (const cluster of clusters) {
|
|
916
|
+
const firstIndex = cluster[0]?.index;
|
|
917
|
+
const lastIndex = cluster.at(-1)?.index;
|
|
918
|
+
if (firstIndex === void 0 || lastIndex === void 0) continue;
|
|
919
|
+
const span = lastIndex - firstIndex + 1;
|
|
920
|
+
const weak = cluster.filter((entry) => entry.weak).map((entry) => entry.comment);
|
|
921
|
+
if (span < WALL_MIN_STATEMENTS || weak.length < WALL_MIN_COMMENTS || cluster.length / span < WALL_MIN_COMMENTED_RATIO || weak.length / cluster.length < WALL_MIN_WEAK_RATIO) {
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
const leader = weak[0];
|
|
925
|
+
if (leader !== void 0) walls.push({ leader, members: new Set(weak) });
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
return walls;
|
|
929
|
+
}
|
|
822
930
|
function isSectionJsDoc(comment) {
|
|
823
931
|
const texts = comment.value.split("\n").map(stripCommentMarker).filter((line) => line.length > 0 && !isDirective(line));
|
|
824
932
|
return texts.length > 0 && texts.every(
|
|
@@ -832,8 +940,8 @@ var no_comment_cruft_default = createRule({
|
|
|
832
940
|
if (comment.type !== "Line") break;
|
|
833
941
|
if (comment.loc.start.line >= firstCodeLine) break;
|
|
834
942
|
if (!isStandalone(comment)) break;
|
|
835
|
-
const
|
|
836
|
-
if (isDirective(
|
|
943
|
+
const body2 = stripCommentMarker(comment.value);
|
|
944
|
+
if (isDirective(body2) || body2.startsWith("!")) continue;
|
|
837
945
|
if (prevLine !== null && comment.loc.start.line !== prevLine + 1) break;
|
|
838
946
|
leading.push(comment);
|
|
839
947
|
prevLine = comment.loc.start.line;
|
|
@@ -841,8 +949,8 @@ var no_comment_cruft_default = createRule({
|
|
|
841
949
|
const first = leading[0];
|
|
842
950
|
if (first === void 0 || leading.length < LEADING_PREAMBLE_MIN) return;
|
|
843
951
|
const bodies = leading.map((c) => stripCommentMarker(c.value));
|
|
844
|
-
if (bodies.some((
|
|
845
|
-
if (bodies.some((
|
|
952
|
+
if (bodies.some((body2) => LICENSE_RE.test(body2))) return;
|
|
953
|
+
if (bodies.some((body2) => isProse(body2))) return;
|
|
846
954
|
if (bodies.filter(isEnumeratedProseItem).length >= ENUMERATED_PREAMBLE_MIN_ITEMS) {
|
|
847
955
|
return;
|
|
848
956
|
}
|
|
@@ -851,6 +959,9 @@ var no_comment_cruft_default = createRule({
|
|
|
851
959
|
return {
|
|
852
960
|
Program() {
|
|
853
961
|
const comments = sourceCode.getAllComments();
|
|
962
|
+
const walls = findCommentWalls(comments);
|
|
963
|
+
const wallByLeader = new Map(walls.map((wall) => [wall.leader, wall]));
|
|
964
|
+
const wallMembers = new Set(walls.flatMap((wall) => [...wall.members]));
|
|
854
965
|
const firstCodeLine = sourceCode.ast.tokens[0]?.loc.start.line ?? Number.MAX_SAFE_INTEGER;
|
|
855
966
|
const enumerated = comments.filter(
|
|
856
967
|
(c) => c.type === "Line" && ENUMERATION_RE.test(stripCommentMarker(c.value))
|
|
@@ -858,6 +969,16 @@ var no_comment_cruft_default = createRule({
|
|
|
858
969
|
for (let i = 0; i < comments.length; i++) {
|
|
859
970
|
const comment = comments[i];
|
|
860
971
|
if (comment === void 0) continue;
|
|
972
|
+
const wall = wallByLeader.get(comment);
|
|
973
|
+
if (wall !== void 0) {
|
|
974
|
+
context.report({
|
|
975
|
+
node: comment,
|
|
976
|
+
messageId: "commentWall",
|
|
977
|
+
data: { count: String(wall.members.size) }
|
|
978
|
+
});
|
|
979
|
+
continue;
|
|
980
|
+
}
|
|
981
|
+
if (wallMembers.has(comment)) continue;
|
|
861
982
|
if (isJsDoc(comment)) {
|
|
862
983
|
if (isStandalone(comment) && isSectionJsDoc(comment)) {
|
|
863
984
|
context.report({ node: comment, messageId: "sectionBanner" });
|
|
@@ -890,11 +1011,11 @@ var no_comment_cruft_default = createRule({
|
|
|
890
1011
|
continue;
|
|
891
1012
|
}
|
|
892
1013
|
if (comment.type === "Line" && texts.length === 1) {
|
|
893
|
-
const
|
|
1014
|
+
const body2 = texts[0];
|
|
894
1015
|
const statement = restatableStatementBelow(comment, sourceCode);
|
|
895
1016
|
const standalone = !isInsideCommentRun(comments, i);
|
|
896
1017
|
const nested = container !== null && !STATEMENT_CONTAINERS.has(container.type);
|
|
897
|
-
if (
|
|
1018
|
+
if (body2 !== void 0 && !runCitesAReference(comments, i) && isRedundantNarration(body2, statement, standalone, enumerated.length === 1, nested)) {
|
|
898
1019
|
context.report({ node: comment, messageId: "redundantNarration" });
|
|
899
1020
|
}
|
|
900
1021
|
}
|
|
@@ -908,11 +1029,12 @@ var no_comment_cruft_default = createRule({
|
|
|
908
1029
|
// src/rules/no-conditional-in-test.ts
|
|
909
1030
|
var import_utils7 = require("@typescript-eslint/utils");
|
|
910
1031
|
var TEST_CALLERS = /* @__PURE__ */ new Set(["it", "test"]);
|
|
911
|
-
var
|
|
1032
|
+
var NON_TEST_MEMBERS = /* @__PURE__ */ new Set([
|
|
912
1033
|
"afterAll",
|
|
913
1034
|
"afterEach",
|
|
914
1035
|
"beforeAll",
|
|
915
|
-
"beforeEach"
|
|
1036
|
+
"beforeEach",
|
|
1037
|
+
"describe"
|
|
916
1038
|
]);
|
|
917
1039
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
918
1040
|
import_utils7.AST_NODE_TYPES.FunctionDeclaration,
|
|
@@ -952,12 +1074,27 @@ function testCallerName(callee) {
|
|
|
952
1074
|
}
|
|
953
1075
|
return null;
|
|
954
1076
|
}
|
|
1077
|
+
function hasNonTestMember(callee) {
|
|
1078
|
+
if (callee.type === import_utils7.AST_NODE_TYPES.MemberExpression) {
|
|
1079
|
+
if (!callee.computed && callee.property.type === import_utils7.AST_NODE_TYPES.Identifier && NON_TEST_MEMBERS.has(callee.property.name)) {
|
|
1080
|
+
return true;
|
|
1081
|
+
}
|
|
1082
|
+
return hasNonTestMember(callee.object);
|
|
1083
|
+
}
|
|
1084
|
+
if (callee.type === import_utils7.AST_NODE_TYPES.CallExpression) {
|
|
1085
|
+
return hasNonTestMember(callee.callee);
|
|
1086
|
+
}
|
|
1087
|
+
if (callee.type === import_utils7.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
1088
|
+
return hasNonTestMember(callee.tag);
|
|
1089
|
+
}
|
|
1090
|
+
return false;
|
|
1091
|
+
}
|
|
955
1092
|
function isTestBody(fn) {
|
|
956
1093
|
const call = fn.parent;
|
|
957
1094
|
if (call?.type !== import_utils7.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
958
1095
|
return false;
|
|
959
1096
|
}
|
|
960
|
-
if (
|
|
1097
|
+
if (hasNonTestMember(call.callee)) {
|
|
961
1098
|
return false;
|
|
962
1099
|
}
|
|
963
1100
|
const name = testCallerName(call.callee);
|
|
@@ -1683,6 +1820,7 @@ var no_enum_default = createRule({
|
|
|
1683
1820
|
properties: {
|
|
1684
1821
|
ignoreFiles: {
|
|
1685
1822
|
type: "array",
|
|
1823
|
+
description: "Additional generated-file globs to ignore; shared generated paths and header markers are always ignored.",
|
|
1686
1824
|
items: { type: "string" }
|
|
1687
1825
|
}
|
|
1688
1826
|
}
|
|
@@ -1892,8 +2030,8 @@ function handlerRethrows(handler) {
|
|
|
1892
2030
|
if (handler === null) {
|
|
1893
2031
|
return false;
|
|
1894
2032
|
}
|
|
1895
|
-
const
|
|
1896
|
-
const last =
|
|
2033
|
+
const body2 = handler.body.body;
|
|
2034
|
+
const last = body2[body2.length - 1];
|
|
1897
2035
|
return last !== void 0 && last.type === import_utils12.AST_NODE_TYPES.ThrowStatement;
|
|
1898
2036
|
}
|
|
1899
2037
|
var PASS_THROUGH_PARENTS = /* @__PURE__ */ new Set([
|
|
@@ -1927,8 +2065,8 @@ function unwrapAwait(expr) {
|
|
|
1927
2065
|
return inner.type === import_utils12.AST_NODE_TYPES.AwaitExpression ? unwrap(inner.argument) : inner;
|
|
1928
2066
|
}
|
|
1929
2067
|
function handlerEndsByHandingOff(handler) {
|
|
1930
|
-
const
|
|
1931
|
-
const last =
|
|
2068
|
+
const body2 = handler.body.body;
|
|
2069
|
+
const last = body2[body2.length - 1];
|
|
1932
2070
|
if (last === void 0) {
|
|
1933
2071
|
return false;
|
|
1934
2072
|
}
|
|
@@ -2502,8 +2640,8 @@ function negatedInstanceofErrorSubject(test) {
|
|
|
2502
2640
|
return null;
|
|
2503
2641
|
}
|
|
2504
2642
|
function branchTerminates(branch) {
|
|
2505
|
-
const
|
|
2506
|
-
const last =
|
|
2643
|
+
const body2 = branch.type === "BlockStatement" ? branch.body : [branch];
|
|
2644
|
+
const last = body2[body2.length - 1];
|
|
2507
2645
|
return last !== void 0 && (last.type === "ReturnStatement" || last.type === "ThrowStatement");
|
|
2508
2646
|
}
|
|
2509
2647
|
function isNarrowedByEarlyReturn(node, argExpr, sourceCode) {
|
|
@@ -2755,8 +2893,8 @@ function hasFollowingStatement(node) {
|
|
|
2755
2893
|
return false;
|
|
2756
2894
|
}
|
|
2757
2895
|
function fallbackFollowsTry(tryStatement) {
|
|
2758
|
-
const
|
|
2759
|
-
const last =
|
|
2896
|
+
const body2 = tryStatement.block.body;
|
|
2897
|
+
const last = body2.at(-1);
|
|
2760
2898
|
return last?.type === import_utils17.AST_NODE_TYPES.ReturnStatement && hasFollowingStatement(tryStatement);
|
|
2761
2899
|
}
|
|
2762
2900
|
function isSeedValue(node) {
|
|
@@ -2873,8 +3011,125 @@ var no_log_only_catch_default = createRule({
|
|
|
2873
3011
|
}
|
|
2874
3012
|
});
|
|
2875
3013
|
|
|
2876
|
-
// src/rules/
|
|
3014
|
+
// src/rules/_prose-budget.ts
|
|
2877
3015
|
var import_utils18 = require("@typescript-eslint/utils");
|
|
3016
|
+
var DIRECTIVE_RE2 = /^(?:!|eslint\b|eslint-|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|@vite|webpack|@jsx|@jest-environment|@vitest-environment|#__|todo\b|fixme\b|hack\b)/i;
|
|
3017
|
+
var LICENSE_RE2 = /\b(?:copyright|spdx-license-identifier|licensed under)\b/i;
|
|
3018
|
+
var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
|
|
3019
|
+
var VALUE_TAG_RE = /@(example|deprecated|see|remarks|throws|internal|public|alpha|beta|since|template|fileoverview)\b/i;
|
|
3020
|
+
var BOUNDARY_RE = /(?<=[.!?])["'`)\]]*\s+(?=[A-Z0-9`])/;
|
|
3021
|
+
var BULLET_RE = /^\s*(?:[-*+] |\d+[.)] )/;
|
|
3022
|
+
function body(comment) {
|
|
3023
|
+
return comment.value.replace(/^\*/, "").split("\n").map((line) => line.replace(/^\s*\*?\s?/, "")).join("\n").trim();
|
|
3024
|
+
}
|
|
3025
|
+
function eligible(text, includeValueTags) {
|
|
3026
|
+
return text.length > 0 && !DIRECTIVE_RE2.test(text) && !LICENSE_RE2.test(text) && (includeValueTags || !VALUE_TAG_RE.test(text));
|
|
3027
|
+
}
|
|
3028
|
+
function sentenceUnits(text) {
|
|
3029
|
+
const cleaned = text.replace(/https?:\/\/\S+/g, "URL").replace(/`[^`\n]+`/g, "CODE").replace(/\b\d+\.\d+\b/g, "NUMBER").replace(/\b(?:e\.g\.|i\.e\.|vs\.|etc\.)/gi, "ABBREVIATION");
|
|
3030
|
+
let units = 0;
|
|
3031
|
+
const prose = [];
|
|
3032
|
+
for (const raw of cleaned.split("\n")) {
|
|
3033
|
+
const line = raw.trim();
|
|
3034
|
+
if (line.length === 0 || /^[A-Za-z][A-Za-z ]+:$/.test(line)) continue;
|
|
3035
|
+
if (BULLET_RE.test(line)) units += 1;
|
|
3036
|
+
else prose.push(line);
|
|
3037
|
+
}
|
|
3038
|
+
if (prose.length > 0) units += prose.join(" ").split(BOUNDARY_RE).length;
|
|
3039
|
+
return units;
|
|
3040
|
+
}
|
|
3041
|
+
function proseGroups(filename, sourceCode, includeValueTags = false) {
|
|
3042
|
+
if (isGeneratedFile(filename, sourceCode.text) || isStoryFile(filename)) return [];
|
|
3043
|
+
const groups = [];
|
|
3044
|
+
let run = [];
|
|
3045
|
+
const flush = () => {
|
|
3046
|
+
if (run.length === 0) return;
|
|
3047
|
+
const text = run.map(body).join("\n");
|
|
3048
|
+
if (eligible(text, includeValueTags)) groups.push({ comment: run[0], text, hasTypedTags: TYPED_TAG_RE.test(text) });
|
|
3049
|
+
run = [];
|
|
3050
|
+
};
|
|
3051
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
3052
|
+
const text = body(comment);
|
|
3053
|
+
if (comment.type === "Block") {
|
|
3054
|
+
flush();
|
|
3055
|
+
if (eligible(text, includeValueTags)) groups.push({ comment, text, hasTypedTags: TYPED_TAG_RE.test(text) });
|
|
3056
|
+
continue;
|
|
3057
|
+
}
|
|
3058
|
+
const ownLine = sourceCode.lines[comment.loc.start.line - 1]?.slice(0, comment.loc.start.column).trim() === "";
|
|
3059
|
+
if (!ownLine || !eligible(text, includeValueTags)) {
|
|
3060
|
+
flush();
|
|
3061
|
+
continue;
|
|
3062
|
+
}
|
|
3063
|
+
const previous = run.at(-1);
|
|
3064
|
+
if (previous !== void 0 && (comment.loc.start.line !== previous.loc.end.line + 1 || comment.loc.start.column !== previous.loc.start.column)) flush();
|
|
3065
|
+
run.push(comment);
|
|
3066
|
+
}
|
|
3067
|
+
flush();
|
|
3068
|
+
return groups;
|
|
3069
|
+
}
|
|
3070
|
+
function annotatedParameter(parameter) {
|
|
3071
|
+
if (parameter.type === import_utils18.AST_NODE_TYPES.TSParameterProperty) return annotatedParameter(parameter.parameter);
|
|
3072
|
+
const target = parameter.type === import_utils18.AST_NODE_TYPES.AssignmentPattern ? parameter.left : parameter;
|
|
3073
|
+
return "typeAnnotation" in target && target.typeAnnotation != null;
|
|
3074
|
+
}
|
|
3075
|
+
function typedFunction(node) {
|
|
3076
|
+
switch (node.type) {
|
|
3077
|
+
case import_utils18.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3078
|
+
case import_utils18.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3079
|
+
return node.declaration != null && typedFunction(node.declaration);
|
|
3080
|
+
case import_utils18.AST_NODE_TYPES.FunctionDeclaration:
|
|
3081
|
+
case import_utils18.AST_NODE_TYPES.TSDeclareFunction:
|
|
3082
|
+
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3083
|
+
case import_utils18.AST_NODE_TYPES.VariableDeclaration: {
|
|
3084
|
+
const init = node.declarations[0]?.init;
|
|
3085
|
+
return init != null && (init.type === import_utils18.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils18.AST_NODE_TYPES.FunctionExpression) && init.returnType != null && init.params.every(annotatedParameter);
|
|
3086
|
+
}
|
|
3087
|
+
case import_utils18.AST_NODE_TYPES.MethodDefinition:
|
|
3088
|
+
return node.value.returnType != null && node.value.params.every(annotatedParameter);
|
|
3089
|
+
case import_utils18.AST_NODE_TYPES.TSMethodSignature:
|
|
3090
|
+
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3091
|
+
default:
|
|
3092
|
+
return false;
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
function documentsTypedFunction(sourceCode, comment) {
|
|
3096
|
+
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3097
|
+
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return false;
|
|
3098
|
+
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3099
|
+
while (node != null && node.type !== import_utils18.AST_NODE_TYPES.Program) {
|
|
3100
|
+
if (typedFunction(node)) return true;
|
|
3101
|
+
node = node.parent ?? null;
|
|
3102
|
+
}
|
|
3103
|
+
return false;
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
// src/rules/no-long-comment.ts
|
|
3107
|
+
var no_long_comment_default = createRule({
|
|
3108
|
+
name: "no-long-comment",
|
|
3109
|
+
meta: {
|
|
3110
|
+
type: "suggestion",
|
|
3111
|
+
docs: { description: "Limit in-code prose to two sentences." },
|
|
3112
|
+
schema: [],
|
|
3113
|
+
messages: {
|
|
3114
|
+
tooLong: "Comment exceeds two sentences \u2014 keep one local fact and clarify the code itself."
|
|
3115
|
+
}
|
|
3116
|
+
},
|
|
3117
|
+
defaultOptions: [],
|
|
3118
|
+
create(context) {
|
|
3119
|
+
return {
|
|
3120
|
+
Program() {
|
|
3121
|
+
for (const group of proseGroups(context.filename, context.sourceCode)) {
|
|
3122
|
+
if (!group.hasTypedTags && sentenceUnits(group.text) >= 3) {
|
|
3123
|
+
context.report({ node: group.comment, messageId: "tooLong" });
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
};
|
|
3128
|
+
}
|
|
3129
|
+
});
|
|
3130
|
+
|
|
3131
|
+
// src/rules/no-offset-pagination.ts
|
|
3132
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
2878
3133
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:%s|%\(\w+\)s|\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
2879
3134
|
var OFFSET_GATE = /offset/i;
|
|
2880
3135
|
var no_offset_pagination_default = createRule({
|
|
@@ -2904,15 +3159,15 @@ var no_offset_pagination_default = createRule({
|
|
|
2904
3159
|
});
|
|
2905
3160
|
|
|
2906
3161
|
// src/rules/no-positional-tuple-return.ts
|
|
2907
|
-
var
|
|
3162
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
2908
3163
|
var MIN_ELEMENTS = 2;
|
|
2909
3164
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
2910
3165
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
2911
3166
|
function tupleReturnType(node) {
|
|
2912
|
-
if (node.type ===
|
|
3167
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSTupleType) {
|
|
2913
3168
|
return node;
|
|
2914
3169
|
}
|
|
2915
|
-
if (node.type ===
|
|
3170
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils20.AST_NODE_TYPES.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
2916
3171
|
const argument = node.typeArguments?.params[0];
|
|
2917
3172
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
2918
3173
|
}
|
|
@@ -2926,30 +3181,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
2926
3181
|
if (elements.length < MIN_ELEMENTS) {
|
|
2927
3182
|
return true;
|
|
2928
3183
|
}
|
|
2929
|
-
if (elements.some((element) => element.type ===
|
|
3184
|
+
if (elements.some((element) => element.type === import_utils20.AST_NODE_TYPES.TSRestType)) {
|
|
2930
3185
|
return true;
|
|
2931
3186
|
}
|
|
2932
|
-
if (elements.some((element) => element.type ===
|
|
3187
|
+
if (elements.some((element) => element.type === import_utils20.AST_NODE_TYPES.TSNamedTupleMember)) {
|
|
2933
3188
|
return true;
|
|
2934
3189
|
}
|
|
2935
|
-
if (elements[0]?.type ===
|
|
3190
|
+
if (elements[0]?.type === import_utils20.AST_NODE_TYPES.TSLiteralType) {
|
|
2936
3191
|
return true;
|
|
2937
3192
|
}
|
|
2938
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type ===
|
|
3193
|
+
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === import_utils20.AST_NODE_TYPES.TSFunctionType)) {
|
|
2939
3194
|
return true;
|
|
2940
3195
|
}
|
|
2941
3196
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
2942
3197
|
return texts.size === 1;
|
|
2943
3198
|
}
|
|
2944
3199
|
function functionName(node) {
|
|
2945
|
-
if (node.type ===
|
|
3200
|
+
if (node.type === import_utils20.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2946
3201
|
return node.id?.name ?? null;
|
|
2947
3202
|
}
|
|
2948
3203
|
const parent = node.parent;
|
|
2949
|
-
if (parent?.type ===
|
|
3204
|
+
if (parent?.type === import_utils20.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
2950
3205
|
return parent.id.name;
|
|
2951
3206
|
}
|
|
2952
|
-
if ((parent?.type ===
|
|
3207
|
+
if ((parent?.type === import_utils20.AST_NODE_TYPES.MethodDefinition || parent?.type === import_utils20.AST_NODE_TYPES.PropertyDefinition || parent?.type === import_utils20.AST_NODE_TYPES.Property) && parent.key.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
2953
3208
|
return parent.key.name;
|
|
2954
3209
|
}
|
|
2955
3210
|
return null;
|
|
@@ -2957,7 +3212,7 @@ function functionName(node) {
|
|
|
2957
3212
|
function isInlineExported(node) {
|
|
2958
3213
|
for (let current = node; current != null; current = current.parent) {
|
|
2959
3214
|
const parent = current.parent;
|
|
2960
|
-
if (parent?.type ===
|
|
3215
|
+
if (parent?.type === import_utils20.AST_NODE_TYPES.ExportNamedDeclaration || parent?.type === import_utils20.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
2961
3216
|
return true;
|
|
2962
3217
|
}
|
|
2963
3218
|
}
|
|
@@ -2966,18 +3221,18 @@ function isInlineExported(node) {
|
|
|
2966
3221
|
function moduleScopeBindingName(node) {
|
|
2967
3222
|
let current = node;
|
|
2968
3223
|
let child = node;
|
|
2969
|
-
while (current.parent != null && current.parent.type !==
|
|
3224
|
+
while (current.parent != null && current.parent.type !== import_utils20.AST_NODE_TYPES.Program) {
|
|
2970
3225
|
child = current;
|
|
2971
3226
|
current = current.parent;
|
|
2972
3227
|
}
|
|
2973
|
-
if (current.parent?.type !==
|
|
3228
|
+
if (current.parent?.type !== import_utils20.AST_NODE_TYPES.Program) {
|
|
2974
3229
|
return null;
|
|
2975
3230
|
}
|
|
2976
|
-
if (current.type ===
|
|
3231
|
+
if (current.type === import_utils20.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils20.AST_NODE_TYPES.ClassDeclaration) {
|
|
2977
3232
|
return current.id?.name ?? null;
|
|
2978
3233
|
}
|
|
2979
|
-
if (current.type ===
|
|
2980
|
-
if (child.type !==
|
|
3234
|
+
if (current.type === import_utils20.AST_NODE_TYPES.VariableDeclaration) {
|
|
3235
|
+
if (child.type !== import_utils20.AST_NODE_TYPES.VariableDeclarator || child.id.type !== import_utils20.AST_NODE_TYPES.Identifier) {
|
|
2981
3236
|
return null;
|
|
2982
3237
|
}
|
|
2983
3238
|
return child.id.name;
|
|
@@ -2987,19 +3242,19 @@ function moduleScopeBindingName(node) {
|
|
|
2987
3242
|
function specifierExportedNames(program) {
|
|
2988
3243
|
const names = /* @__PURE__ */ new Set();
|
|
2989
3244
|
for (const statement of program.body) {
|
|
2990
|
-
if (statement.type ===
|
|
3245
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
2991
3246
|
for (const specifier of statement.specifiers) {
|
|
2992
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
3247
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
2993
3248
|
names.add(specifier.local.name);
|
|
2994
3249
|
}
|
|
2995
3250
|
}
|
|
2996
3251
|
continue;
|
|
2997
3252
|
}
|
|
2998
|
-
if (statement.type ===
|
|
3253
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
2999
3254
|
names.add(statement.declaration.name);
|
|
3000
3255
|
continue;
|
|
3001
3256
|
}
|
|
3002
|
-
if (statement.type ===
|
|
3257
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3003
3258
|
names.add(statement.expression.name);
|
|
3004
3259
|
}
|
|
3005
3260
|
}
|
|
@@ -3061,7 +3316,7 @@ var no_positional_tuple_return_default = createRule({
|
|
|
3061
3316
|
});
|
|
3062
3317
|
|
|
3063
3318
|
// src/rules/no-raw-env.ts
|
|
3064
|
-
var
|
|
3319
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
3065
3320
|
var CONFIG_FILE_RE = /(^|[\\/])[\w.-]+\.config\.[cm]?[jt]sx?$/;
|
|
3066
3321
|
var ENV_BOUNDARY_FILE_RE = /(^|[\\/])(?:env|client-env|server-env|client-settings|server-settings)\.[cm]?[jt]sx?$/;
|
|
3067
3322
|
var ENV_VALIDATION_MARKER_RE = /\bcreateEnv\s*\(|\bz\.object\s*\(|\.(?:safeParse|parse)\s*\(/;
|
|
@@ -3111,11 +3366,11 @@ var no_raw_env_default = createRule({
|
|
|
3111
3366
|
meta: {
|
|
3112
3367
|
type: "problem",
|
|
3113
3368
|
docs: {
|
|
3114
|
-
description: "Disallow direct `process.env`
|
|
3369
|
+
description: "Disallow direct `process.env` and `import.meta.env` reads outside validated boundaries."
|
|
3115
3370
|
},
|
|
3116
3371
|
schema: [],
|
|
3117
3372
|
messages: {
|
|
3118
|
-
noRawEnv: "Do not read
|
|
3373
|
+
noRawEnv: "Do not read raw environment values directly. Import the validated env module so values are typed and checked at startup."
|
|
3119
3374
|
}
|
|
3120
3375
|
},
|
|
3121
3376
|
defaultOptions: [],
|
|
@@ -3138,13 +3393,11 @@ var no_raw_env_default = createRule({
|
|
|
3138
3393
|
});
|
|
3139
3394
|
|
|
3140
3395
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
3141
|
-
var
|
|
3396
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
3142
3397
|
var DEFAULT_ALLOW = [
|
|
3143
3398
|
"[\\\\/]clients?[\\\\/]",
|
|
3144
3399
|
"-client\\.[cm]?[jt]sx?$",
|
|
3145
3400
|
"[\\\\/]http-client\\.[cm]?[jt]sx?$",
|
|
3146
|
-
// The `api` spelling of the same client-layer convention: an `api/` directory,
|
|
3147
|
-
// a bare `api.ts`, or a `*-api.ts` / `*.api.ts` module.
|
|
3148
3401
|
"[\\\\/]api[\\\\/]",
|
|
3149
3402
|
"[\\\\/]api\\.[cm]?[jt]sx?$",
|
|
3150
3403
|
"[-.]api\\.[cm]?[jt]sx?$",
|
|
@@ -3182,7 +3435,7 @@ function identifierLikeName(node) {
|
|
|
3182
3435
|
}
|
|
3183
3436
|
function isConstructedArgumentHandoff(node) {
|
|
3184
3437
|
const [first] = node.arguments;
|
|
3185
|
-
return node.arguments.length === 1 && first !== void 0 && first.type ===
|
|
3438
|
+
return node.arguments.length === 1 && first !== void 0 && first.type === import_utils22.AST_NODE_TYPES.NewExpression;
|
|
3186
3439
|
}
|
|
3187
3440
|
function isPresignedUrlTransfer(node) {
|
|
3188
3441
|
const first = node.arguments[0];
|
|
@@ -3251,16 +3504,16 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
3251
3504
|
});
|
|
3252
3505
|
|
|
3253
3506
|
// src/rules/no-repeated-string-literal.ts
|
|
3254
|
-
var
|
|
3507
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
3255
3508
|
var MIN_LENGTH = 40;
|
|
3256
3509
|
var MIN_DISTINCT_SCOPES = 2;
|
|
3257
3510
|
var PREVIEW_LENGTH = 40;
|
|
3258
3511
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
3259
3512
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
3260
3513
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3514
|
+
import_utils23.AST_NODE_TYPES.FunctionDeclaration,
|
|
3515
|
+
import_utils23.AST_NODE_TYPES.FunctionExpression,
|
|
3516
|
+
import_utils23.AST_NODE_TYPES.ArrowFunctionExpression
|
|
3264
3517
|
]);
|
|
3265
3518
|
function isStructured(value) {
|
|
3266
3519
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -3282,7 +3535,8 @@ function isScaffolding(node) {
|
|
|
3282
3535
|
if (parent === void 0) {
|
|
3283
3536
|
return true;
|
|
3284
3537
|
}
|
|
3285
|
-
|
|
3538
|
+
const isRequireSource = parent.type === import_utils23.AST_NODE_TYPES.CallExpression && parent.callee.type === import_utils23.AST_NODE_TYPES.Identifier && parent.callee.name === "require";
|
|
3539
|
+
return parent.type === import_utils23.AST_NODE_TYPES.ImportDeclaration || parent.type === import_utils23.AST_NODE_TYPES.ImportExpression || parent.type === import_utils23.AST_NODE_TYPES.ExportNamedDeclaration || parent.type === import_utils23.AST_NODE_TYPES.ExportAllDeclaration || parent.type === import_utils23.AST_NODE_TYPES.TSImportType || parent.type === import_utils23.AST_NODE_TYPES.JSXAttribute || parent.type === import_utils23.AST_NODE_TYPES.TSLiteralType || isRequireSource;
|
|
3286
3540
|
}
|
|
3287
3541
|
var no_repeated_string_literal_default = createRule({
|
|
3288
3542
|
name: "no-repeated-string-literal",
|
|
@@ -3322,7 +3576,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3322
3576
|
}
|
|
3323
3577
|
},
|
|
3324
3578
|
TemplateLiteral(node) {
|
|
3325
|
-
if (node.parent.type ===
|
|
3579
|
+
if (node.parent.type === import_utils23.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
3326
3580
|
return;
|
|
3327
3581
|
}
|
|
3328
3582
|
const [only] = node.quasis;
|
|
@@ -3356,10 +3610,10 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3356
3610
|
});
|
|
3357
3611
|
|
|
3358
3612
|
// src/rules/no-restated-comment.ts
|
|
3359
|
-
var
|
|
3613
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
3360
3614
|
var MAX_WORDS = 8;
|
|
3361
3615
|
var MIN_CONTENT_TOKENS = 2;
|
|
3362
|
-
var
|
|
3616
|
+
var DIRECTIVE_RE3 = /^(eslint\b|eslint-|sarj-noqa\b|@ts-|prettier-ignore|prettier\b|biome-|c8\b|v8\b|istanbul\b|@type\b|@vite|webpack|<reference|<amd|global\b|noinspection|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
3363
3617
|
var CODEY_RE = /^[\w.$[\]'"]+\s*[:=]\s*\S|^[\w.$]+\s*\(|^(?:return|throw|await|import|export|const|let|var)\b.*[=()[\]{}]/;
|
|
3364
3618
|
var BANNERISH_RE = /[=\-─-╿*#~_.]{3,}|^[A-Z0-9 _:-]+$/;
|
|
3365
3619
|
var MODALITY_RE = /\b(?:can|could|should|shall|may|might|must|will|would|cannot)\b/i;
|
|
@@ -3368,16 +3622,19 @@ var EMPHASIS_RE = /\*\w[^*]*\*|`[^`]+`/;
|
|
|
3368
3622
|
var NEGATION_WORD_RE = /\b(?:no|not|never|neither|nor|without|none|non)\b/i;
|
|
3369
3623
|
var ACTION_STMT_RE = /[\w.$\])]\s*\(|^\s*(?:return|throw|await|yield)\b/;
|
|
3370
3624
|
var NON_ASCII_LETTER_RE = /[^\p{ASCII}\p{N}\p{P}\p{Z}]/u;
|
|
3625
|
+
var WALL_NARRATION_RE2 = /^(?:(?:\d+[.)]|(?:phase|step)\s+\d+\s*:?)\s*)?(?:add|build|call|check|compute|copy|count|create|fetch|filter|find|get|handle|load|map|merge|parse|process|read|remove|return|save|send|set|sort|store|update|validate|write)(?:s|es|d|ed|ing)?\b/i;
|
|
3626
|
+
var WALL_CLUSTER_MAX_LINE_GAP = 8;
|
|
3627
|
+
var WALL_CLUSTER_MIN_COMMENTS = 3;
|
|
3371
3628
|
function areAdjacentLineComments2(a, b) {
|
|
3372
3629
|
return a !== void 0 && b !== void 0 && a.type === "Line" && b.type === "Line" && b.loc.start.line === a.loc.end.line + 1;
|
|
3373
3630
|
}
|
|
3374
3631
|
function headsSiblingRun(node) {
|
|
3375
3632
|
const parent = node.parent;
|
|
3376
3633
|
if (parent === void 0) return false;
|
|
3377
|
-
const
|
|
3378
|
-
if (
|
|
3379
|
-
const index =
|
|
3380
|
-
const next = index >= 0 ?
|
|
3634
|
+
const body2 = "body" in parent && Array.isArray(parent.body) ? parent.body : void 0;
|
|
3635
|
+
if (body2 === void 0) return false;
|
|
3636
|
+
const index = body2.indexOf(node);
|
|
3637
|
+
const next = index >= 0 ? body2[index + 1] : void 0;
|
|
3381
3638
|
return next !== void 0 && next.type === node.type;
|
|
3382
3639
|
}
|
|
3383
3640
|
var no_restated_comment_default = createRule({
|
|
@@ -3406,7 +3663,7 @@ var no_restated_comment_default = createRule({
|
|
|
3406
3663
|
function labelsASiblingRun(comment) {
|
|
3407
3664
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3408
3665
|
if (token === null) return false;
|
|
3409
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
3666
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== import_utils24.AST_NODE_TYPES.Program; node = node.parent) {
|
|
3410
3667
|
if (headsSiblingRun(node)) return true;
|
|
3411
3668
|
}
|
|
3412
3669
|
return false;
|
|
@@ -3414,25 +3671,45 @@ var no_restated_comment_default = createRule({
|
|
|
3414
3671
|
return {
|
|
3415
3672
|
Program() {
|
|
3416
3673
|
const comments = sourceCode.getAllComments();
|
|
3674
|
+
const wallMembers = /* @__PURE__ */ new Set();
|
|
3675
|
+
let cluster = [];
|
|
3676
|
+
for (const candidate of comments) {
|
|
3677
|
+
const body2 = candidate.value.replace(/^\/*/, "").trim();
|
|
3678
|
+
if (candidate.type !== "Line" || !isStandalone(candidate) || isProtected(body2) || !WALL_NARRATION_RE2.test(body2)) {
|
|
3679
|
+
continue;
|
|
3680
|
+
}
|
|
3681
|
+
const previous = cluster.at(-1);
|
|
3682
|
+
if (previous !== void 0 && candidate.loc.start.line - previous.loc.start.line > WALL_CLUSTER_MAX_LINE_GAP) {
|
|
3683
|
+
if (cluster.length >= WALL_CLUSTER_MIN_COMMENTS) {
|
|
3684
|
+
for (const member of cluster) wallMembers.add(member);
|
|
3685
|
+
}
|
|
3686
|
+
cluster = [];
|
|
3687
|
+
}
|
|
3688
|
+
cluster.push(candidate);
|
|
3689
|
+
}
|
|
3690
|
+
if (cluster.length >= WALL_CLUSTER_MIN_COMMENTS) {
|
|
3691
|
+
for (const member of cluster) wallMembers.add(member);
|
|
3692
|
+
}
|
|
3417
3693
|
for (let i = 0; i < comments.length; i++) {
|
|
3418
3694
|
const comment = comments[i];
|
|
3419
3695
|
if (comment === void 0 || comment.type !== "Line") continue;
|
|
3696
|
+
if (wallMembers.has(comment)) continue;
|
|
3420
3697
|
if (!isStandalone(comment)) continue;
|
|
3421
3698
|
if (areAdjacentLineComments2(comments[i - 1], comment) || areAdjacentLineComments2(comment, comments[i + 1])) {
|
|
3422
3699
|
continue;
|
|
3423
3700
|
}
|
|
3424
|
-
const
|
|
3425
|
-
if (
|
|
3426
|
-
if (
|
|
3427
|
-
if (NON_ASCII_LETTER_RE.test(
|
|
3428
|
-
if (MODALITY_RE.test(
|
|
3429
|
-
if (NEGATION_WORD_RE.test(
|
|
3430
|
-
if (
|
|
3431
|
-
const tokens = contentTokens(
|
|
3701
|
+
const body2 = comment.value.replace(/^\/*/, "").trim();
|
|
3702
|
+
if (body2.length === 0 || body2.endsWith("?")) continue;
|
|
3703
|
+
if (DIRECTIVE_RE3.test(body2) || CODEY_RE.test(body2) || BANNERISH_RE.test(body2)) continue;
|
|
3704
|
+
if (NON_ASCII_LETTER_RE.test(body2) || isProtected(body2)) continue;
|
|
3705
|
+
if (MODALITY_RE.test(body2) || LEAD_IN_RE.test(body2) || EMPHASIS_RE.test(body2)) continue;
|
|
3706
|
+
if (NEGATION_WORD_RE.test(body2)) continue;
|
|
3707
|
+
if (body2.split(/\s+/).length > MAX_WORDS) continue;
|
|
3708
|
+
const tokens = contentTokens(body2);
|
|
3432
3709
|
if (tokens.length < MIN_CONTENT_TOKENS) continue;
|
|
3433
3710
|
const statement = restatableStatementBelow(comment, sourceCode);
|
|
3434
3711
|
if (statement === null) continue;
|
|
3435
|
-
if (restatesStatementHead(
|
|
3712
|
+
if (restatesStatementHead(body2, statement)) continue;
|
|
3436
3713
|
const line = lines[comment.loc.start.line] ?? "";
|
|
3437
3714
|
if (!ACTION_STMT_RE.test(line)) continue;
|
|
3438
3715
|
if (labelsASiblingRun(comment)) continue;
|
|
@@ -3446,7 +3723,7 @@ var no_restated_comment_default = createRule({
|
|
|
3446
3723
|
});
|
|
3447
3724
|
|
|
3448
3725
|
// src/rules/no-restated-jsdoc.ts
|
|
3449
|
-
var
|
|
3726
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
3450
3727
|
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
3451
3728
|
"arg",
|
|
3452
3729
|
"argument",
|
|
@@ -3458,7 +3735,7 @@ var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
|
3458
3735
|
]);
|
|
3459
3736
|
var PARAM_TAGS = /* @__PURE__ */ new Set(["arg", "argument", "param"]);
|
|
3460
3737
|
var RETURN_TAGS = /* @__PURE__ */ new Set(["return", "returns"]);
|
|
3461
|
-
var
|
|
3738
|
+
var DIRECTIVE_RE4 = /^\s*(?:eslint\b|eslint-|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|@vite|webpack|@jsx|@jest-environment|@vitest-environment|#__)/i;
|
|
3462
3739
|
var STOPWORDS2 = new Set(
|
|
3463
3740
|
`the a an of to for in on with and or as at by is are was be been being
|
|
3464
3741
|
this that it its if whether when where which what will would can could should
|
|
@@ -3500,30 +3777,30 @@ function declarationNames(node) {
|
|
|
3500
3777
|
switch (node.type) {
|
|
3501
3778
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
3502
3779
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
3503
|
-
case
|
|
3504
|
-
case
|
|
3780
|
+
case import_utils25.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3781
|
+
case import_utils25.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3505
3782
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
3506
|
-
case
|
|
3507
|
-
case
|
|
3783
|
+
case import_utils25.AST_NODE_TYPES.FunctionDeclaration:
|
|
3784
|
+
case import_utils25.AST_NODE_TYPES.TSDeclareFunction:
|
|
3508
3785
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
3509
|
-
case
|
|
3510
|
-
case
|
|
3511
|
-
case
|
|
3512
|
-
case
|
|
3786
|
+
case import_utils25.AST_NODE_TYPES.ClassDeclaration:
|
|
3787
|
+
case import_utils25.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3788
|
+
case import_utils25.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3789
|
+
case import_utils25.AST_NODE_TYPES.TSEnumDeclaration:
|
|
3513
3790
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
3514
|
-
case
|
|
3791
|
+
case import_utils25.AST_NODE_TYPES.VariableDeclaration: {
|
|
3515
3792
|
const declarator = node.declarations[0];
|
|
3516
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
3793
|
+
if (declarator === void 0 || declarator.id.type !== import_utils25.AST_NODE_TYPES.Identifier) return null;
|
|
3517
3794
|
const init = declarator.init;
|
|
3518
|
-
const params = init != null && (init.type ===
|
|
3795
|
+
const params = init != null && (init.type === import_utils25.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils25.AST_NODE_TYPES.FunctionExpression) ? paramNames(init.params) : [];
|
|
3519
3796
|
return { name: declarator.id.name, params };
|
|
3520
3797
|
}
|
|
3521
|
-
case
|
|
3522
|
-
case
|
|
3523
|
-
case
|
|
3524
|
-
case
|
|
3525
|
-
if (node.key.type !==
|
|
3526
|
-
const params = node.type ===
|
|
3798
|
+
case import_utils25.AST_NODE_TYPES.MethodDefinition:
|
|
3799
|
+
case import_utils25.AST_NODE_TYPES.PropertyDefinition:
|
|
3800
|
+
case import_utils25.AST_NODE_TYPES.TSMethodSignature:
|
|
3801
|
+
case import_utils25.AST_NODE_TYPES.TSPropertySignature: {
|
|
3802
|
+
if (node.key.type !== import_utils25.AST_NODE_TYPES.Identifier) return null;
|
|
3803
|
+
const params = node.type === import_utils25.AST_NODE_TYPES.MethodDefinition ? paramNames(node.value.params) : node.type === import_utils25.AST_NODE_TYPES.TSMethodSignature ? paramNames(node.params) : [];
|
|
3527
3804
|
return { name: node.key.name, params };
|
|
3528
3805
|
}
|
|
3529
3806
|
default:
|
|
@@ -3533,9 +3810,9 @@ function declarationNames(node) {
|
|
|
3533
3810
|
function paramNames(params) {
|
|
3534
3811
|
const names = [];
|
|
3535
3812
|
for (const param of params) {
|
|
3536
|
-
const target = param.type ===
|
|
3537
|
-
if (target.type ===
|
|
3538
|
-
else if (target.type ===
|
|
3813
|
+
const target = param.type === import_utils25.AST_NODE_TYPES.AssignmentPattern ? param.left : param;
|
|
3814
|
+
if (target.type === import_utils25.AST_NODE_TYPES.Identifier) names.push(target.name);
|
|
3815
|
+
else if (target.type === import_utils25.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
3539
3816
|
}
|
|
3540
3817
|
return names;
|
|
3541
3818
|
}
|
|
@@ -3569,7 +3846,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3569
3846
|
for (const comment of sourceCode.getAllComments()) {
|
|
3570
3847
|
if (comment.type !== "Block" || !comment.value.startsWith("*")) continue;
|
|
3571
3848
|
const { description, tags } = parseJsDoc(comment.value);
|
|
3572
|
-
if (
|
|
3849
|
+
if (DIRECTIVE_RE4.test(description)) continue;
|
|
3573
3850
|
const tagNames = new Set(tags.map((tag) => tag.name));
|
|
3574
3851
|
if ([...tagNames].some((name) => !MODELLED_TAGS.has(name))) continue;
|
|
3575
3852
|
if (isProtected(description)) continue;
|
|
@@ -3577,7 +3854,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3577
3854
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
3578
3855
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3579
3856
|
let declaration = null;
|
|
3580
|
-
while (node != null && node.type !==
|
|
3857
|
+
while (node != null && node.type !== import_utils25.AST_NODE_TYPES.Program) {
|
|
3581
3858
|
declaration = declarationNames(node);
|
|
3582
3859
|
if (declaration !== null) break;
|
|
3583
3860
|
node = node.parent ?? null;
|
|
@@ -3632,7 +3909,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3632
3909
|
});
|
|
3633
3910
|
|
|
3634
3911
|
// src/rules/no-secret-in-log.ts
|
|
3635
|
-
var
|
|
3912
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
3636
3913
|
|
|
3637
3914
|
// src/rules/_secret-names.ts
|
|
3638
3915
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -3969,7 +4246,7 @@ var no_secret_in_log_default = createRule({
|
|
|
3969
4246
|
});
|
|
3970
4247
|
|
|
3971
4248
|
// src/rules/no-select-star.ts
|
|
3972
|
-
var
|
|
4249
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
3973
4250
|
var QUERY_SHAPE = /\bSELECT\b[\s\S]*?\bFROM\b/i;
|
|
3974
4251
|
var SELECT_KEYWORD = /\bSELECT\b/gi;
|
|
3975
4252
|
var FROM_KEYWORD = /^FROM\b/i;
|
|
@@ -4036,12 +4313,12 @@ var no_select_star_default = createRule({
|
|
|
4036
4313
|
});
|
|
4037
4314
|
|
|
4038
4315
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
4039
|
-
var
|
|
4316
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
4040
4317
|
function sentinelKind(arg) {
|
|
4041
4318
|
if (arg === null) {
|
|
4042
4319
|
return null;
|
|
4043
4320
|
}
|
|
4044
|
-
if (arg.type ===
|
|
4321
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Literal) {
|
|
4045
4322
|
if (arg.value === null) {
|
|
4046
4323
|
return "nullish";
|
|
4047
4324
|
}
|
|
@@ -4053,13 +4330,13 @@ function sentinelKind(arg) {
|
|
|
4053
4330
|
}
|
|
4054
4331
|
return null;
|
|
4055
4332
|
}
|
|
4056
|
-
if (arg.type ===
|
|
4333
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4057
4334
|
return "nullish";
|
|
4058
4335
|
}
|
|
4059
|
-
if (arg.type ===
|
|
4336
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ArrayExpression) {
|
|
4060
4337
|
return "array";
|
|
4061
4338
|
}
|
|
4062
|
-
if (arg.type ===
|
|
4339
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ObjectExpression) {
|
|
4063
4340
|
return "object";
|
|
4064
4341
|
}
|
|
4065
4342
|
return null;
|
|
@@ -4068,25 +4345,25 @@ function isSentinelArgument(arg) {
|
|
|
4068
4345
|
if (arg === null) {
|
|
4069
4346
|
return false;
|
|
4070
4347
|
}
|
|
4071
|
-
if (arg.type ===
|
|
4348
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Literal && arg.value === null) {
|
|
4072
4349
|
return true;
|
|
4073
4350
|
}
|
|
4074
|
-
if (arg.type ===
|
|
4351
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Literal && arg.value === false) {
|
|
4075
4352
|
return true;
|
|
4076
4353
|
}
|
|
4077
|
-
if (arg.type ===
|
|
4354
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4078
4355
|
return true;
|
|
4079
4356
|
}
|
|
4080
|
-
if (arg.type ===
|
|
4357
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ArrayExpression && arg.elements.length === 0) {
|
|
4081
4358
|
return true;
|
|
4082
4359
|
}
|
|
4083
|
-
if (arg.type ===
|
|
4360
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ObjectExpression && arg.properties.length === 0) {
|
|
4084
4361
|
return true;
|
|
4085
4362
|
}
|
|
4086
4363
|
return false;
|
|
4087
4364
|
}
|
|
4088
4365
|
function isFunctionNode(node) {
|
|
4089
|
-
return node.type ===
|
|
4366
|
+
return node.type === import_utils28.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils28.AST_NODE_TYPES.FunctionExpression || node.type === import_utils28.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
4090
4367
|
}
|
|
4091
4368
|
function isNode3(value) {
|
|
4092
4369
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -4126,24 +4403,24 @@ function walkWithinScope(node, visit) {
|
|
|
4126
4403
|
function containsThrow(node) {
|
|
4127
4404
|
return walkWithinScope(
|
|
4128
4405
|
node,
|
|
4129
|
-
(current) => current.type ===
|
|
4406
|
+
(current) => current.type === import_utils28.AST_NODE_TYPES.ThrowStatement
|
|
4130
4407
|
);
|
|
4131
4408
|
}
|
|
4132
4409
|
function bindsName(param, name) {
|
|
4133
4410
|
switch (param.type) {
|
|
4134
|
-
case
|
|
4411
|
+
case import_utils28.AST_NODE_TYPES.Identifier:
|
|
4135
4412
|
return param.name === name;
|
|
4136
|
-
case
|
|
4413
|
+
case import_utils28.AST_NODE_TYPES.AssignmentPattern:
|
|
4137
4414
|
return bindsName(param.left, name);
|
|
4138
|
-
case
|
|
4415
|
+
case import_utils28.AST_NODE_TYPES.RestElement:
|
|
4139
4416
|
return bindsName(param.argument, name);
|
|
4140
|
-
case
|
|
4417
|
+
case import_utils28.AST_NODE_TYPES.ArrayPattern:
|
|
4141
4418
|
return param.elements.some(
|
|
4142
4419
|
(element) => element !== null && bindsName(element, name)
|
|
4143
4420
|
);
|
|
4144
|
-
case
|
|
4421
|
+
case import_utils28.AST_NODE_TYPES.ObjectPattern:
|
|
4145
4422
|
return param.properties.some(
|
|
4146
|
-
(property) => property.type ===
|
|
4423
|
+
(property) => property.type === import_utils28.AST_NODE_TYPES.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
4147
4424
|
);
|
|
4148
4425
|
default:
|
|
4149
4426
|
return false;
|
|
@@ -4158,7 +4435,7 @@ function subtreeReadsName(node, name) {
|
|
|
4158
4435
|
if (found) {
|
|
4159
4436
|
return;
|
|
4160
4437
|
}
|
|
4161
|
-
if (current.type ===
|
|
4438
|
+
if (current.type === import_utils28.AST_NODE_TYPES.Identifier && current.name === name) {
|
|
4162
4439
|
found = true;
|
|
4163
4440
|
return;
|
|
4164
4441
|
}
|
|
@@ -4169,10 +4446,10 @@ function subtreeReadsName(node, name) {
|
|
|
4169
4446
|
if (key === "parent") {
|
|
4170
4447
|
continue;
|
|
4171
4448
|
}
|
|
4172
|
-
if (key === "key" && current.type ===
|
|
4449
|
+
if (key === "key" && current.type === import_utils28.AST_NODE_TYPES.Property && !current.computed) {
|
|
4173
4450
|
continue;
|
|
4174
4451
|
}
|
|
4175
|
-
if (key === "property" && current.type ===
|
|
4452
|
+
if (key === "property" && current.type === import_utils28.AST_NODE_TYPES.MemberExpression && !current.computed) {
|
|
4176
4453
|
continue;
|
|
4177
4454
|
}
|
|
4178
4455
|
const value = current[key];
|
|
@@ -4205,10 +4482,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4205
4482
|
"URLPattern"
|
|
4206
4483
|
]);
|
|
4207
4484
|
function isParseShapedNode(node) {
|
|
4208
|
-
if (node.type ===
|
|
4485
|
+
if (node.type === import_utils28.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils28.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4209
4486
|
return node.callee.property.name === "parse";
|
|
4210
4487
|
}
|
|
4211
|
-
if (node.type ===
|
|
4488
|
+
if (node.type === import_utils28.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4212
4489
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
4213
4490
|
}
|
|
4214
4491
|
return false;
|
|
@@ -4219,10 +4496,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
4219
4496
|
"arrayBuffer"
|
|
4220
4497
|
]);
|
|
4221
4498
|
function isBodyDecodeNode(node) {
|
|
4222
|
-
return node.type ===
|
|
4499
|
+
return node.type === import_utils28.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils28.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils28.AST_NODE_TYPES.Identifier && BODY_DECODE_METHODS.has(node.callee.property.name);
|
|
4223
4500
|
}
|
|
4224
4501
|
function returnsMatching(stmt, predicate) {
|
|
4225
|
-
return stmt.type ===
|
|
4502
|
+
return stmt.type === import_utils28.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
4226
4503
|
}
|
|
4227
4504
|
function enclosingReturnTypeNode(node) {
|
|
4228
4505
|
let current = node.parent;
|
|
@@ -4240,11 +4517,11 @@ function enclosingFunctionName(node) {
|
|
|
4240
4517
|
let current = node.parent;
|
|
4241
4518
|
while (current !== void 0 && current !== null) {
|
|
4242
4519
|
if (isFunctionNode(current)) {
|
|
4243
|
-
if ("id" in current && isNode3(current.id) && current.id.type ===
|
|
4520
|
+
if ("id" in current && isNode3(current.id) && current.id.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4244
4521
|
return current.id.name;
|
|
4245
4522
|
}
|
|
4246
4523
|
const parent = current.parent;
|
|
4247
|
-
if (parent?.type ===
|
|
4524
|
+
if (parent?.type === import_utils28.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4248
4525
|
return parent.id.name;
|
|
4249
4526
|
}
|
|
4250
4527
|
return null;
|
|
@@ -4265,10 +4542,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
4265
4542
|
return false;
|
|
4266
4543
|
}
|
|
4267
4544
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
4268
|
-
if (declared?.type ===
|
|
4545
|
+
if (declared?.type === import_utils28.AST_NODE_TYPES.TSTypeReference && declared.typeName.type === import_utils28.AST_NODE_TYPES.Identifier && declared.typeName.name === "Promise") {
|
|
4269
4546
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
4270
4547
|
}
|
|
4271
|
-
return declared?.type ===
|
|
4548
|
+
return declared?.type === import_utils28.AST_NODE_TYPES.TSBooleanKeyword;
|
|
4272
4549
|
}
|
|
4273
4550
|
function tryReturnsSafeParse(catchNode) {
|
|
4274
4551
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -4284,7 +4561,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
4284
4561
|
function enclosingFunctionBody(node) {
|
|
4285
4562
|
let current = node.parent;
|
|
4286
4563
|
while (current !== void 0 && current !== null) {
|
|
4287
|
-
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type ===
|
|
4564
|
+
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === import_utils28.AST_NODE_TYPES.BlockStatement) {
|
|
4288
4565
|
return current.body;
|
|
4289
4566
|
}
|
|
4290
4567
|
current = current.parent;
|
|
@@ -4297,7 +4574,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
4297
4574
|
return false;
|
|
4298
4575
|
}
|
|
4299
4576
|
return walkWithinScope(functionBody, (current) => {
|
|
4300
|
-
if (current.type !==
|
|
4577
|
+
if (current.type !== import_utils28.AST_NODE_TYPES.ReturnStatement) {
|
|
4301
4578
|
return false;
|
|
4302
4579
|
}
|
|
4303
4580
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -4316,13 +4593,13 @@ function returnedSentinelKinds(arg) {
|
|
|
4316
4593
|
kinds.add(direct);
|
|
4317
4594
|
return kinds;
|
|
4318
4595
|
}
|
|
4319
|
-
if (arg.type ===
|
|
4596
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ConditionalExpression) {
|
|
4320
4597
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
4321
4598
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
4322
4599
|
kinds.add(nested);
|
|
4323
4600
|
}
|
|
4324
4601
|
}
|
|
4325
|
-
} else if (arg.type ===
|
|
4602
|
+
} else if (arg.type === import_utils28.AST_NODE_TYPES.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
4326
4603
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
4327
4604
|
kinds.add(nested);
|
|
4328
4605
|
}
|
|
@@ -4365,7 +4642,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4365
4642
|
const matcher = createLogMatcher(loggingOptions);
|
|
4366
4643
|
function logsOrReportsError(catchBody, caughtName) {
|
|
4367
4644
|
return walkWithinScope(catchBody, (current) => {
|
|
4368
|
-
if (current.type !==
|
|
4645
|
+
if (current.type !== import_utils28.AST_NODE_TYPES.CallExpression) {
|
|
4369
4646
|
return false;
|
|
4370
4647
|
}
|
|
4371
4648
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -4377,12 +4654,12 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4377
4654
|
}
|
|
4378
4655
|
return {
|
|
4379
4656
|
CatchClause(node) {
|
|
4380
|
-
const
|
|
4381
|
-
if (
|
|
4657
|
+
const body2 = node.body.body;
|
|
4658
|
+
if (body2.length === 0) {
|
|
4382
4659
|
return;
|
|
4383
4660
|
}
|
|
4384
|
-
const last =
|
|
4385
|
-
if (last === void 0 || last.type !==
|
|
4661
|
+
const last = body2[body2.length - 1];
|
|
4662
|
+
if (last === void 0 || last.type !== import_utils28.AST_NODE_TYPES.ReturnStatement) {
|
|
4386
4663
|
return;
|
|
4387
4664
|
}
|
|
4388
4665
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -4391,7 +4668,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4391
4668
|
if (containsThrow(node.body)) {
|
|
4392
4669
|
return;
|
|
4393
4670
|
}
|
|
4394
|
-
const caughtName = node.param?.type ===
|
|
4671
|
+
const caughtName = node.param?.type === import_utils28.AST_NODE_TYPES.Identifier ? node.param.name : null;
|
|
4395
4672
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
4396
4673
|
return;
|
|
4397
4674
|
}
|
|
@@ -4418,9 +4695,9 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4418
4695
|
});
|
|
4419
4696
|
|
|
4420
4697
|
// src/rules/no-silent-promise-catch.ts
|
|
4421
|
-
var
|
|
4698
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
4422
4699
|
function isBodyParseCall(node) {
|
|
4423
|
-
return node.type ===
|
|
4700
|
+
return node.type === import_utils29.AST_NODE_TYPES.CallExpression && node.arguments.length === 0 && node.callee.type === import_utils29.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils29.AST_NODE_TYPES.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
4424
4701
|
}
|
|
4425
4702
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
4426
4703
|
"cancel",
|
|
@@ -4435,37 +4712,37 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
4435
4712
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
4436
4713
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
4437
4714
|
function isTeardownCall(node) {
|
|
4438
|
-
return node.type ===
|
|
4715
|
+
return node.type === import_utils29.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils29.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils29.AST_NODE_TYPES.Identifier && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
4439
4716
|
}
|
|
4440
4717
|
function isSilentExpression(node) {
|
|
4441
4718
|
switch (node.type) {
|
|
4442
|
-
case
|
|
4719
|
+
case import_utils29.AST_NODE_TYPES.Literal:
|
|
4443
4720
|
return !("regex" in node);
|
|
4444
|
-
case
|
|
4721
|
+
case import_utils29.AST_NODE_TYPES.Identifier:
|
|
4445
4722
|
return node.name === "undefined";
|
|
4446
|
-
case
|
|
4447
|
-
return node.operator === "void" && node.argument.type ===
|
|
4448
|
-
case
|
|
4723
|
+
case import_utils29.AST_NODE_TYPES.UnaryExpression:
|
|
4724
|
+
return node.operator === "void" && node.argument.type === import_utils29.AST_NODE_TYPES.Literal;
|
|
4725
|
+
case import_utils29.AST_NODE_TYPES.ObjectExpression:
|
|
4449
4726
|
return node.properties.length === 0;
|
|
4450
|
-
case
|
|
4727
|
+
case import_utils29.AST_NODE_TYPES.ArrayExpression:
|
|
4451
4728
|
return node.elements.length === 0;
|
|
4452
|
-
case
|
|
4729
|
+
case import_utils29.AST_NODE_TYPES.TSAsExpression:
|
|
4453
4730
|
return isSilentExpression(node.expression);
|
|
4454
4731
|
default:
|
|
4455
4732
|
return false;
|
|
4456
4733
|
}
|
|
4457
4734
|
}
|
|
4458
4735
|
function isSilentHandler(handler) {
|
|
4459
|
-
const
|
|
4460
|
-
if (
|
|
4461
|
-
return isSilentExpression(
|
|
4736
|
+
const body2 = handler.body;
|
|
4737
|
+
if (body2.type !== import_utils29.AST_NODE_TYPES.BlockStatement) {
|
|
4738
|
+
return isSilentExpression(body2);
|
|
4462
4739
|
}
|
|
4463
|
-
if (
|
|
4740
|
+
if (body2.body.length === 0) {
|
|
4464
4741
|
return true;
|
|
4465
4742
|
}
|
|
4466
|
-
if (
|
|
4467
|
-
const only =
|
|
4468
|
-
if (only !== void 0 && only.type ===
|
|
4743
|
+
if (body2.body.length === 1) {
|
|
4744
|
+
const only = body2.body[0];
|
|
4745
|
+
if (only !== void 0 && only.type === import_utils29.AST_NODE_TYPES.ReturnStatement) {
|
|
4469
4746
|
return only.argument === null || isSilentExpression(only.argument);
|
|
4470
4747
|
}
|
|
4471
4748
|
}
|
|
@@ -4494,7 +4771,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4494
4771
|
return true;
|
|
4495
4772
|
}
|
|
4496
4773
|
let statement = call;
|
|
4497
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
4774
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== import_utils29.AST_NODE_TYPES.VariableDeclaration) {
|
|
4498
4775
|
statement = statement.parent;
|
|
4499
4776
|
}
|
|
4500
4777
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -4506,7 +4783,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4506
4783
|
};
|
|
4507
4784
|
return {
|
|
4508
4785
|
CallExpression(node) {
|
|
4509
|
-
if (node.callee.type !==
|
|
4786
|
+
if (node.callee.type !== import_utils29.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.property.type !== import_utils29.AST_NODE_TYPES.Identifier || node.callee.property.name !== "catch") {
|
|
4510
4787
|
return;
|
|
4511
4788
|
}
|
|
4512
4789
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -4515,14 +4792,14 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4515
4792
|
if (isTeardownCall(node.callee.object)) {
|
|
4516
4793
|
return;
|
|
4517
4794
|
}
|
|
4518
|
-
if (node.parent.type ===
|
|
4795
|
+
if (node.parent.type === import_utils29.AST_NODE_TYPES.MemberExpression && node.parent.object === node) {
|
|
4519
4796
|
return;
|
|
4520
4797
|
}
|
|
4521
4798
|
if (node.arguments.length !== 1) {
|
|
4522
4799
|
return;
|
|
4523
4800
|
}
|
|
4524
4801
|
const handler = node.arguments[0];
|
|
4525
|
-
if (handler === void 0 || handler.type !==
|
|
4802
|
+
if (handler === void 0 || handler.type !== import_utils29.AST_NODE_TYPES.ArrowFunctionExpression && handler.type !== import_utils29.AST_NODE_TYPES.FunctionExpression) {
|
|
4526
4803
|
return;
|
|
4527
4804
|
}
|
|
4528
4805
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -4537,7 +4814,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4537
4814
|
});
|
|
4538
4815
|
|
|
4539
4816
|
// src/rules/no-sleep-in-test-body.ts
|
|
4540
|
-
var
|
|
4817
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
4541
4818
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
4542
4819
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
4543
4820
|
"it",
|
|
@@ -4546,34 +4823,34 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
|
4546
4823
|
"afterEach"
|
|
4547
4824
|
]);
|
|
4548
4825
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4826
|
+
import_utils30.AST_NODE_TYPES.FunctionDeclaration,
|
|
4827
|
+
import_utils30.AST_NODE_TYPES.FunctionExpression,
|
|
4828
|
+
import_utils30.AST_NODE_TYPES.ArrowFunctionExpression
|
|
4552
4829
|
]);
|
|
4553
4830
|
function isNonzeroNumericLiteral(node) {
|
|
4554
|
-
return node?.type ===
|
|
4831
|
+
return node?.type === import_utils30.AST_NODE_TYPES.Literal && typeof node.value === "number" && node.value !== 0;
|
|
4555
4832
|
}
|
|
4556
4833
|
function isTimedSetTimeout(node) {
|
|
4557
|
-
return node.type ===
|
|
4834
|
+
return node.type === import_utils30.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils30.AST_NODE_TYPES.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
4558
4835
|
}
|
|
4559
4836
|
function isPromiseSleep(node) {
|
|
4560
|
-
if (node.callee.type !==
|
|
4837
|
+
if (node.callee.type !== import_utils30.AST_NODE_TYPES.Identifier || node.callee.name !== "Promise") {
|
|
4561
4838
|
return false;
|
|
4562
4839
|
}
|
|
4563
4840
|
const executor = node.arguments[0];
|
|
4564
|
-
if (executor?.type !==
|
|
4841
|
+
if (executor?.type !== import_utils30.AST_NODE_TYPES.ArrowFunctionExpression && executor?.type !== import_utils30.AST_NODE_TYPES.FunctionExpression) {
|
|
4565
4842
|
return false;
|
|
4566
4843
|
}
|
|
4567
|
-
const
|
|
4568
|
-
if (
|
|
4569
|
-
return isTimedSetTimeout(
|
|
4844
|
+
const body2 = executor.body;
|
|
4845
|
+
if (body2.type !== import_utils30.AST_NODE_TYPES.BlockStatement) {
|
|
4846
|
+
return isTimedSetTimeout(body2);
|
|
4570
4847
|
}
|
|
4571
|
-
return
|
|
4572
|
-
(stmt) => stmt.type ===
|
|
4848
|
+
return body2.body.some(
|
|
4849
|
+
(stmt) => stmt.type === import_utils30.AST_NODE_TYPES.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
4573
4850
|
);
|
|
4574
4851
|
}
|
|
4575
4852
|
function isHelperSleep(node) {
|
|
4576
|
-
return node.callee.type ===
|
|
4853
|
+
return node.callee.type === import_utils30.AST_NODE_TYPES.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
4577
4854
|
}
|
|
4578
4855
|
function nearestEnclosingFunction2(node) {
|
|
4579
4856
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -4581,7 +4858,7 @@ function nearestEnclosingFunction2(node) {
|
|
|
4581
4858
|
continue;
|
|
4582
4859
|
}
|
|
4583
4860
|
const grandparent = current.parent;
|
|
4584
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
4861
|
+
const isPromiseExecutor = grandparent?.type === import_utils30.AST_NODE_TYPES.NewExpression && isPromiseSleep(grandparent);
|
|
4585
4862
|
if (!isPromiseExecutor) {
|
|
4586
4863
|
return current;
|
|
4587
4864
|
}
|
|
@@ -4589,23 +4866,23 @@ function nearestEnclosingFunction2(node) {
|
|
|
4589
4866
|
return null;
|
|
4590
4867
|
}
|
|
4591
4868
|
function testCallerName2(callee) {
|
|
4592
|
-
if (callee.type ===
|
|
4869
|
+
if (callee.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4593
4870
|
return callee.name;
|
|
4594
4871
|
}
|
|
4595
|
-
if (callee.type ===
|
|
4872
|
+
if (callee.type === import_utils30.AST_NODE_TYPES.MemberExpression) {
|
|
4596
4873
|
return testCallerName2(callee.object);
|
|
4597
4874
|
}
|
|
4598
|
-
if (callee.type ===
|
|
4875
|
+
if (callee.type === import_utils30.AST_NODE_TYPES.CallExpression) {
|
|
4599
4876
|
return testCallerName2(callee.callee);
|
|
4600
4877
|
}
|
|
4601
|
-
if (callee.type ===
|
|
4878
|
+
if (callee.type === import_utils30.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
4602
4879
|
return testCallerName2(callee.tag);
|
|
4603
4880
|
}
|
|
4604
4881
|
return null;
|
|
4605
4882
|
}
|
|
4606
4883
|
function isTestBody2(fn) {
|
|
4607
4884
|
const call = fn.parent;
|
|
4608
|
-
if (call?.type !==
|
|
4885
|
+
if (call?.type !== import_utils30.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
4609
4886
|
return false;
|
|
4610
4887
|
}
|
|
4611
4888
|
const name = testCallerName2(call.callee);
|
|
@@ -4651,7 +4928,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
4651
4928
|
});
|
|
4652
4929
|
|
|
4653
4930
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
4654
|
-
var
|
|
4931
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
4655
4932
|
var DEFAULT_METHODS2 = [
|
|
4656
4933
|
"prepare",
|
|
4657
4934
|
"put",
|
|
@@ -4670,7 +4947,7 @@ function compile2(patterns) {
|
|
|
4670
4947
|
}
|
|
4671
4948
|
function storageMethodName(node, methods) {
|
|
4672
4949
|
const callee = node.callee;
|
|
4673
|
-
if (callee.type !==
|
|
4950
|
+
if (callee.type !== import_utils31.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils31.AST_NODE_TYPES.Identifier) {
|
|
4674
4951
|
return null;
|
|
4675
4952
|
}
|
|
4676
4953
|
const name = callee.property.name;
|
|
@@ -4738,7 +5015,7 @@ var no_storage_in_stateless_modules_default = createRule({
|
|
|
4738
5015
|
});
|
|
4739
5016
|
|
|
4740
5017
|
// src/rules/no-string-concat-in-loop.ts
|
|
4741
|
-
var
|
|
5018
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
4742
5019
|
var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
4743
5020
|
"ForStatement",
|
|
4744
5021
|
"ForOfStatement",
|
|
@@ -4803,9 +5080,9 @@ function isDeclaredInsideLoop(variable, loop) {
|
|
|
4803
5080
|
if (def === void 0) {
|
|
4804
5081
|
return false;
|
|
4805
5082
|
}
|
|
4806
|
-
const
|
|
5083
|
+
const body2 = loop.body;
|
|
4807
5084
|
const [declStart, declEnd] = def.node.range;
|
|
4808
|
-
const [bodyStart, bodyEnd] =
|
|
5085
|
+
const [bodyStart, bodyEnd] = body2.range;
|
|
4809
5086
|
return declStart >= bodyStart && declEnd <= bodyEnd;
|
|
4810
5087
|
}
|
|
4811
5088
|
function enclosingLoop(node) {
|
|
@@ -4884,7 +5161,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
4884
5161
|
});
|
|
4885
5162
|
|
|
4886
5163
|
// src/rules/no-tautological-expect.ts
|
|
4887
|
-
var
|
|
5164
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
4888
5165
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
4889
5166
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
4890
5167
|
"toBeDefined",
|
|
@@ -4898,17 +5175,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
4898
5175
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
4899
5176
|
function isLiteral(node) {
|
|
4900
5177
|
switch (node.type) {
|
|
4901
|
-
case
|
|
5178
|
+
case import_utils33.AST_NODE_TYPES.Literal:
|
|
4902
5179
|
return true;
|
|
4903
|
-
case
|
|
5180
|
+
case import_utils33.AST_NODE_TYPES.TemplateLiteral:
|
|
4904
5181
|
return node.expressions.length === 0;
|
|
4905
|
-
case
|
|
5182
|
+
case import_utils33.AST_NODE_TYPES.UnaryExpression:
|
|
4906
5183
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
4907
|
-
case
|
|
5184
|
+
case import_utils33.AST_NODE_TYPES.ArrayExpression:
|
|
4908
5185
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
4909
|
-
case
|
|
5186
|
+
case import_utils33.AST_NODE_TYPES.ObjectExpression:
|
|
4910
5187
|
return node.properties.every(
|
|
4911
|
-
(property) => property.type ===
|
|
5188
|
+
(property) => property.type === import_utils33.AST_NODE_TYPES.Property && !property.computed && isLiteral(property.value)
|
|
4912
5189
|
);
|
|
4913
5190
|
default:
|
|
4914
5191
|
return false;
|
|
@@ -4916,7 +5193,7 @@ function isLiteral(node) {
|
|
|
4916
5193
|
}
|
|
4917
5194
|
function expectOperand(callee) {
|
|
4918
5195
|
const receiver = callee.object;
|
|
4919
|
-
if (receiver.type !==
|
|
5196
|
+
if (receiver.type !== import_utils33.AST_NODE_TYPES.CallExpression || receiver.callee.type !== import_utils33.AST_NODE_TYPES.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
4920
5197
|
return null;
|
|
4921
5198
|
}
|
|
4922
5199
|
return receiver.arguments[0] ?? null;
|
|
@@ -4946,10 +5223,10 @@ var no_tautological_expect_default = createRule({
|
|
|
4946
5223
|
return {
|
|
4947
5224
|
CallExpression(node) {
|
|
4948
5225
|
const callee = node.callee;
|
|
4949
|
-
if (callee.type !==
|
|
5226
|
+
if (callee.type !== import_utils33.AST_NODE_TYPES.MemberExpression || callee.computed) {
|
|
4950
5227
|
return;
|
|
4951
5228
|
}
|
|
4952
|
-
if (callee.property.type !==
|
|
5229
|
+
if (callee.property.type !== import_utils33.AST_NODE_TYPES.Identifier) {
|
|
4953
5230
|
return;
|
|
4954
5231
|
}
|
|
4955
5232
|
const matcher = callee.property.name;
|
|
@@ -4982,8 +5259,33 @@ var no_tautological_expect_default = createRule({
|
|
|
4982
5259
|
}
|
|
4983
5260
|
});
|
|
4984
5261
|
|
|
5262
|
+
// src/rules/no-typed-doc-sections.ts
|
|
5263
|
+
var no_typed_doc_sections_default = createRule({
|
|
5264
|
+
name: "no-typed-doc-sections",
|
|
5265
|
+
meta: {
|
|
5266
|
+
type: "suggestion",
|
|
5267
|
+
docs: { description: "Reject typed-signature repetition while preserving behavior that types cannot express." },
|
|
5268
|
+
schema: [],
|
|
5269
|
+
messages: {
|
|
5270
|
+
typedSection: "Typed JSDoc repeats parameters or returns \u2014 delete the tags and improve names or types instead."
|
|
5271
|
+
}
|
|
5272
|
+
},
|
|
5273
|
+
defaultOptions: [],
|
|
5274
|
+
create(context) {
|
|
5275
|
+
return {
|
|
5276
|
+
Program() {
|
|
5277
|
+
for (const group of proseGroups(context.filename, context.sourceCode, true)) {
|
|
5278
|
+
if (group.hasTypedTags && documentsTypedFunction(context.sourceCode, group.comment)) {
|
|
5279
|
+
context.report({ node: group.comment, messageId: "typedSection" });
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
};
|
|
5284
|
+
}
|
|
5285
|
+
});
|
|
5286
|
+
|
|
4985
5287
|
// src/rules/no-trailing-value-narration.ts
|
|
4986
|
-
var
|
|
5288
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
4987
5289
|
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
4988
5290
|
var WORD_RE3 = /[A-Za-z]+(?:'[a-z]+)?|\d+(?:\.\d+)?/g;
|
|
4989
5291
|
var UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -5045,21 +5347,22 @@ var STOPWORDS3 = /* @__PURE__ */ new Set([
|
|
|
5045
5347
|
"we",
|
|
5046
5348
|
"with"
|
|
5047
5349
|
]);
|
|
5048
|
-
var
|
|
5350
|
+
var DIRECTIVE_RE5 = /^\s*(?:eslint\b|eslint-|sarj-noqa\b|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
5049
5351
|
function numbersIn(text) {
|
|
5050
5352
|
return new Set(text.match(NUMBER_RE) ?? []);
|
|
5051
5353
|
}
|
|
5052
|
-
function narratesValue(
|
|
5053
|
-
if (
|
|
5354
|
+
function narratesValue(body2, code) {
|
|
5355
|
+
if (body2.length === 0 || DIRECTIVE_RE5.test(body2) || hasExternalReference(body2)) return false;
|
|
5054
5356
|
const codeNumbers = numbersIn(code);
|
|
5055
5357
|
if (codeNumbers.size === 0) return false;
|
|
5056
|
-
const words = (
|
|
5358
|
+
const words = (body2.match(WORD_RE3) ?? []).map((word) => word.toLowerCase());
|
|
5057
5359
|
if (words.length === 0) return false;
|
|
5058
|
-
const commentNumbers = numbersIn(
|
|
5360
|
+
const commentNumbers = numbersIn(body2);
|
|
5059
5361
|
if (commentNumbers.size === 0) return false;
|
|
5060
5362
|
for (const number of commentNumbers) {
|
|
5061
5363
|
if (!codeNumbers.has(number)) return false;
|
|
5062
5364
|
}
|
|
5365
|
+
if (!words.some((word) => UNIT_WORDS.has(word))) return false;
|
|
5063
5366
|
const identifiers = codeTokens(code);
|
|
5064
5367
|
const stems = /* @__PURE__ */ new Set();
|
|
5065
5368
|
for (const token of identifiers) stems.add(stem(token));
|
|
@@ -5072,7 +5375,7 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5072
5375
|
meta: {
|
|
5073
5376
|
type: "suggestion",
|
|
5074
5377
|
docs: {
|
|
5075
|
-
description: "Flag a trailing comment
|
|
5378
|
+
description: "Flag a trailing comment that repeats the line's numeric value only to name its unit."
|
|
5076
5379
|
},
|
|
5077
5380
|
schema: [],
|
|
5078
5381
|
messages: {
|
|
@@ -5089,14 +5392,25 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5089
5392
|
const before = sourceCode.getTokenBefore(comment, { includeComments: false });
|
|
5090
5393
|
return before !== null && before.loc.end.line === comment.loc.start.line;
|
|
5091
5394
|
}
|
|
5395
|
+
function isInsideBrackets(comment) {
|
|
5396
|
+
let node = sourceCode.getNodeByRangeIndex(comment.range[0]);
|
|
5397
|
+
while (node != null) {
|
|
5398
|
+
if (node.type === "BlockStatement" || node.type === "Program") return false;
|
|
5399
|
+
if (node.type === "ArrayExpression" || node.type === "CallExpression" || node.type === "NewExpression") {
|
|
5400
|
+
return true;
|
|
5401
|
+
}
|
|
5402
|
+
node = node.parent;
|
|
5403
|
+
}
|
|
5404
|
+
return false;
|
|
5405
|
+
}
|
|
5092
5406
|
return {
|
|
5093
5407
|
Program() {
|
|
5094
5408
|
for (const comment of sourceCode.getAllComments()) {
|
|
5095
|
-
if (!isTrailing(comment)) continue;
|
|
5409
|
+
if (!isTrailing(comment) || isInsideBrackets(comment)) continue;
|
|
5096
5410
|
const line = sourceCode.lines[comment.loc.start.line - 1] ?? "";
|
|
5097
5411
|
const code = line.slice(0, comment.loc.start.column);
|
|
5098
|
-
const
|
|
5099
|
-
if (narratesValue(
|
|
5412
|
+
const body2 = comment.value.replace(/^\*+/, "").replace(/\*+$/, "").trim();
|
|
5413
|
+
if (narratesValue(body2, code)) {
|
|
5100
5414
|
context.report({ node: comment, messageId: "narratesValue" });
|
|
5101
5415
|
}
|
|
5102
5416
|
}
|
|
@@ -5106,10 +5420,10 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5106
5420
|
});
|
|
5107
5421
|
|
|
5108
5422
|
// src/rules/no-declaration-comment-wall.ts
|
|
5109
|
-
var
|
|
5423
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5110
5424
|
|
|
5111
5425
|
// src/rules/_comment-wall.ts
|
|
5112
|
-
var
|
|
5426
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
5113
5427
|
var WALL_DEFAULTS = {
|
|
5114
5428
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5115
5429
|
minCommentedMembers: 3,
|
|
@@ -5151,7 +5465,7 @@ var WALL_SCHEMA = {
|
|
|
5151
5465
|
}
|
|
5152
5466
|
}
|
|
5153
5467
|
};
|
|
5154
|
-
var
|
|
5468
|
+
var VALUE_TAG_RE2 = /@(?:deprecated|see|example|throws|remarks|since|default|defaultvalue|link|internal|alpha|beta|experimental|template|typeparam|inheritdoc|todo|fixme|override)\b/i;
|
|
5155
5469
|
var DEFAULT_RE = /^\s*@?default\b|\bdefaults? (?:to|:)/i;
|
|
5156
5470
|
var DIGIT_RE = /\d/;
|
|
5157
5471
|
var UNIT_WORD_RE = /\b(?:ms|milliseconds?|seconds?|minutes?|hours?|days?|weeks?|months?|years?|bytes?|kb|mb|gb|percent|pixels?|px|utc|epoch)\b/i;
|
|
@@ -5171,24 +5485,24 @@ var WALL_STOPWORDS = new Set(
|
|
|
5171
5485
|
);
|
|
5172
5486
|
var WORD_RE4 = /[A-Za-z][A-Za-z0-9]*/g;
|
|
5173
5487
|
var BARE_LABEL_RE = /^[A-Za-z][A-Za-z0-9]*$/;
|
|
5174
|
-
function labelStems(
|
|
5175
|
-
return splitIdentifier(
|
|
5488
|
+
function labelStems(body2) {
|
|
5489
|
+
return splitIdentifier(body2).map(stem).join(" ");
|
|
5176
5490
|
}
|
|
5177
5491
|
function commentBody(comment) {
|
|
5178
5492
|
return comment.value.replace(/^\*+/, "").replace(/^[ \t]*\*[ \t]?/gm, "").trim();
|
|
5179
5493
|
}
|
|
5180
|
-
function carriesValue(
|
|
5181
|
-
return isProtected(
|
|
5494
|
+
function carriesValue(body2) {
|
|
5495
|
+
return isProtected(body2) || VALUE_TAG_RE2.test(body2) || DEFAULT_RE.test(body2) || DIGIT_RE.test(body2) || UNIT_WORD_RE.test(body2) || EXAMPLE_RE.test(body2) || BANNER_RE.test(body2) || NON_ASCII_LETTER_RE2.test(body2);
|
|
5182
5496
|
}
|
|
5183
|
-
function isLabel(
|
|
5497
|
+
function isLabel(body2) {
|
|
5184
5498
|
let content = 0;
|
|
5185
|
-
for (const word of
|
|
5499
|
+
for (const word of body2.match(WORD_RE4) ?? []) {
|
|
5186
5500
|
if (word.length >= 2 && !WALL_STOPWORDS.has(word.toLowerCase())) content += 1;
|
|
5187
5501
|
}
|
|
5188
5502
|
return content <= 1;
|
|
5189
5503
|
}
|
|
5190
|
-
function isTagsOnly(
|
|
5191
|
-
return
|
|
5504
|
+
function isTagsOnly(body2) {
|
|
5505
|
+
return body2.length > 0 && body2.replace(TAG_TOKEN_RE, "").trim().length === 0;
|
|
5192
5506
|
}
|
|
5193
5507
|
function knownTokens(source) {
|
|
5194
5508
|
const tokens = /* @__PURE__ */ new Set();
|
|
@@ -5200,9 +5514,9 @@ function knownTokens(source) {
|
|
|
5200
5514
|
}
|
|
5201
5515
|
return tokens;
|
|
5202
5516
|
}
|
|
5203
|
-
function novelWords(
|
|
5517
|
+
function novelWords(body2, known) {
|
|
5204
5518
|
let novel = 0;
|
|
5205
|
-
for (const word of
|
|
5519
|
+
for (const word of body2.match(WORD_RE4) ?? []) {
|
|
5206
5520
|
const lower = word.toLowerCase();
|
|
5207
5521
|
if (lower.length < 2 || WALL_STOPWORDS.has(lower)) continue;
|
|
5208
5522
|
if (!known.has(lower) && !known.has(stem(lower))) novel += 1;
|
|
@@ -5213,21 +5527,21 @@ function isWall(members, commented, restated, options) {
|
|
|
5213
5527
|
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5214
5528
|
}
|
|
5215
5529
|
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5530
|
+
import_utils35.AST_NODE_TYPES.FunctionExpression,
|
|
5531
|
+
import_utils35.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
5532
|
+
import_utils35.AST_NODE_TYPES.ObjectExpression,
|
|
5533
|
+
import_utils35.AST_NODE_TYPES.ArrayExpression
|
|
5220
5534
|
]);
|
|
5221
5535
|
function declarationRange(member) {
|
|
5222
|
-
const
|
|
5223
|
-
if (
|
|
5224
|
-
return [member.range[0],
|
|
5536
|
+
const body2 = bodyOf(member);
|
|
5537
|
+
if (body2 === void 0) return [member.range[0], member.range[1]];
|
|
5538
|
+
return [member.range[0], body2.range[0]];
|
|
5225
5539
|
}
|
|
5226
5540
|
function bodyOf(member) {
|
|
5227
|
-
if (member.type ===
|
|
5541
|
+
if (member.type === import_utils35.AST_NODE_TYPES.MethodDefinition || member.type === import_utils35.AST_NODE_TYPES.TSAbstractMethodDefinition) {
|
|
5228
5542
|
return member.value.body ?? void 0;
|
|
5229
5543
|
}
|
|
5230
|
-
if (member.type ===
|
|
5544
|
+
if (member.type === import_utils35.AST_NODE_TYPES.Property || member.type === import_utils35.AST_NODE_TYPES.PropertyDefinition) {
|
|
5231
5545
|
const value = member.value;
|
|
5232
5546
|
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5233
5547
|
}
|
|
@@ -5237,12 +5551,12 @@ function bodyOf(member) {
|
|
|
5237
5551
|
// src/rules/no-declaration-comment-wall.ts
|
|
5238
5552
|
function named(node) {
|
|
5239
5553
|
switch (node.type) {
|
|
5240
|
-
case
|
|
5554
|
+
case import_utils36.AST_NODE_TYPES.TSEnumMember:
|
|
5241
5555
|
return { node, key: node.id };
|
|
5242
|
-
case
|
|
5243
|
-
case
|
|
5244
|
-
case
|
|
5245
|
-
case
|
|
5556
|
+
case import_utils36.AST_NODE_TYPES.PropertyDefinition:
|
|
5557
|
+
case import_utils36.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
|
5558
|
+
case import_utils36.AST_NODE_TYPES.MethodDefinition:
|
|
5559
|
+
case import_utils36.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
|
5246
5560
|
return node.computed ? void 0 : { node, key: node.key };
|
|
5247
5561
|
default:
|
|
5248
5562
|
return void 0;
|
|
@@ -5286,9 +5600,9 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5286
5600
|
}
|
|
5287
5601
|
function isGroupLabel(comment, member, headsRun) {
|
|
5288
5602
|
if (comment.loc.end.line >= member.node.loc.start.line) return false;
|
|
5289
|
-
const
|
|
5290
|
-
if (!BARE_LABEL_RE.test(
|
|
5291
|
-
if (labelStems(
|
|
5603
|
+
const body2 = commentBody(comment);
|
|
5604
|
+
if (!BARE_LABEL_RE.test(body2)) return false;
|
|
5605
|
+
if (labelStems(body2) === labelStems(sourceCode.getText(member.key))) return false;
|
|
5292
5606
|
const lineAbove = sourceCode.lines[comment.loc.start.line - 2];
|
|
5293
5607
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5294
5608
|
}
|
|
@@ -5301,19 +5615,21 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5301
5615
|
}));
|
|
5302
5616
|
let commented = 0;
|
|
5303
5617
|
let restated = 0;
|
|
5618
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
5304
5619
|
for (const [index, { member, comment }] of documented.entries()) {
|
|
5305
|
-
if (comment === void 0) continue;
|
|
5620
|
+
if (comment === void 0 || claimed.has(comment)) continue;
|
|
5306
5621
|
const next = documented[index + 1];
|
|
5307
5622
|
if (isGroupLabel(comment, member, next !== void 0 && next.comment === void 0)) {
|
|
5308
5623
|
continue;
|
|
5309
5624
|
}
|
|
5625
|
+
claimed.add(comment);
|
|
5310
5626
|
commented += 1;
|
|
5311
|
-
const
|
|
5312
|
-
if (
|
|
5627
|
+
const body2 = commentBody(comment);
|
|
5628
|
+
if (body2.length === 0 || carriesValue(body2) || isTagsOnly(body2) || isLabel(body2)) {
|
|
5313
5629
|
continue;
|
|
5314
5630
|
}
|
|
5315
5631
|
const [start, end] = declarationRange(member.node);
|
|
5316
|
-
if (novelWords(
|
|
5632
|
+
if (novelWords(body2, knownTokens(sourceCode.text.slice(start, end))) <= options.maxNovelWords) {
|
|
5317
5633
|
restated += 1;
|
|
5318
5634
|
}
|
|
5319
5635
|
}
|
|
@@ -5340,7 +5656,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5340
5656
|
});
|
|
5341
5657
|
|
|
5342
5658
|
// src/rules/no-union-in-comment.ts
|
|
5343
|
-
var
|
|
5659
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5344
5660
|
var MAX_LITERAL_LENGTH = 28;
|
|
5345
5661
|
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5346
5662
|
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
@@ -5359,14 +5675,14 @@ var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
5359
5675
|
function isBareString(node) {
|
|
5360
5676
|
if (node === void 0) return false;
|
|
5361
5677
|
switch (node.type) {
|
|
5362
|
-
case
|
|
5678
|
+
case import_utils37.AST_NODE_TYPES.TSStringKeyword:
|
|
5363
5679
|
return true;
|
|
5364
5680
|
// `string[]` holds members of the same closed set, one element at a time.
|
|
5365
|
-
case
|
|
5681
|
+
case import_utils37.AST_NODE_TYPES.TSArrayType:
|
|
5366
5682
|
return isBareString(node.elementType);
|
|
5367
5683
|
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5368
5684
|
// — the checker collapses that one to `string`.
|
|
5369
|
-
case
|
|
5685
|
+
case import_utils37.AST_NODE_TYPES.TSUnionType:
|
|
5370
5686
|
return node.types.some((member) => isBareString(member));
|
|
5371
5687
|
default:
|
|
5372
5688
|
return false;
|
|
@@ -5376,13 +5692,13 @@ function rootCallee(node) {
|
|
|
5376
5692
|
let current = node;
|
|
5377
5693
|
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5378
5694
|
switch (current.type) {
|
|
5379
|
-
case
|
|
5695
|
+
case import_utils37.AST_NODE_TYPES.CallExpression:
|
|
5380
5696
|
current = current.callee;
|
|
5381
5697
|
break;
|
|
5382
|
-
case
|
|
5698
|
+
case import_utils37.AST_NODE_TYPES.MemberExpression:
|
|
5383
5699
|
current = current.object;
|
|
5384
5700
|
break;
|
|
5385
|
-
case
|
|
5701
|
+
case import_utils37.AST_NODE_TYPES.Identifier:
|
|
5386
5702
|
return current.name;
|
|
5387
5703
|
default:
|
|
5388
5704
|
return null;
|
|
@@ -5391,26 +5707,26 @@ function rootCallee(node) {
|
|
|
5391
5707
|
return null;
|
|
5392
5708
|
}
|
|
5393
5709
|
function nameOf(key) {
|
|
5394
|
-
if (key.type ===
|
|
5395
|
-
if (key.type ===
|
|
5710
|
+
if (key.type === import_utils37.AST_NODE_TYPES.Identifier) return key.name;
|
|
5711
|
+
if (key.type === import_utils37.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
5396
5712
|
return null;
|
|
5397
5713
|
}
|
|
5398
5714
|
function targetOf(node) {
|
|
5399
5715
|
switch (node.type) {
|
|
5400
|
-
case
|
|
5401
|
-
case
|
|
5716
|
+
case import_utils37.AST_NODE_TYPES.TSPropertySignature:
|
|
5717
|
+
case import_utils37.AST_NODE_TYPES.PropertyDefinition: {
|
|
5402
5718
|
const name = node.computed ? null : nameOf(node.key);
|
|
5403
5719
|
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5404
5720
|
return { node, name };
|
|
5405
5721
|
}
|
|
5406
|
-
case
|
|
5722
|
+
case import_utils37.AST_NODE_TYPES.Property: {
|
|
5407
5723
|
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5408
5724
|
const callee = rootCallee(node.value);
|
|
5409
5725
|
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5410
5726
|
return { node, name };
|
|
5411
5727
|
}
|
|
5412
|
-
case
|
|
5413
|
-
if (node.id.type !==
|
|
5728
|
+
case import_utils37.AST_NODE_TYPES.VariableDeclarator: {
|
|
5729
|
+
if (node.id.type !== import_utils37.AST_NODE_TYPES.Identifier) return null;
|
|
5414
5730
|
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5415
5731
|
return { node, name: node.id.name };
|
|
5416
5732
|
}
|
|
@@ -5418,8 +5734,8 @@ function targetOf(node) {
|
|
|
5418
5734
|
return null;
|
|
5419
5735
|
}
|
|
5420
5736
|
}
|
|
5421
|
-
function unionLiterals(
|
|
5422
|
-
const list =
|
|
5737
|
+
function unionLiterals(body2) {
|
|
5738
|
+
const list = body2.replace(LEAD_IN_RE2, "").trim();
|
|
5423
5739
|
if (!UNION_BODY_RE.test(list)) return null;
|
|
5424
5740
|
const literals = (list.match(LITERAL_G) ?? []).map((raw) => raw.slice(1, -1));
|
|
5425
5741
|
if (literals.some((literal) => literal.length === 0 || literal.length > MAX_LITERAL_LENGTH)) {
|
|
@@ -5459,7 +5775,7 @@ var no_union_in_comment_default = createRule({
|
|
|
5459
5775
|
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5460
5776
|
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5461
5777
|
}
|
|
5462
|
-
for (let node = anchor; node != null && node.type !==
|
|
5778
|
+
for (let node = anchor; node != null && node.type !== import_utils37.AST_NODE_TYPES.Program; node = node.parent) {
|
|
5463
5779
|
const target = targetOf(node);
|
|
5464
5780
|
if (target !== null) return target;
|
|
5465
5781
|
}
|
|
@@ -5468,9 +5784,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5468
5784
|
return {
|
|
5469
5785
|
Program() {
|
|
5470
5786
|
for (const comment of sourceCode.getAllComments()) {
|
|
5471
|
-
const
|
|
5472
|
-
if (
|
|
5473
|
-
const literals = unionLiterals(
|
|
5787
|
+
const body2 = comment.value.replace(/^\*+/, "").replace(/\*+$/, "").trim();
|
|
5788
|
+
if (body2.length === 0) continue;
|
|
5789
|
+
const literals = unionLiterals(body2);
|
|
5474
5790
|
if (literals === null) continue;
|
|
5475
5791
|
const target = annotated(comment);
|
|
5476
5792
|
if (target === null) continue;
|
|
@@ -5488,9 +5804,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5488
5804
|
});
|
|
5489
5805
|
|
|
5490
5806
|
// src/rules/no-type-member-comment-wall.ts
|
|
5491
|
-
var
|
|
5807
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5492
5808
|
function isNamedMember(node) {
|
|
5493
|
-
return (node.type ===
|
|
5809
|
+
return (node.type === import_utils38.AST_NODE_TYPES.TSPropertySignature || node.type === import_utils38.AST_NODE_TYPES.TSMethodSignature) && !node.computed;
|
|
5494
5810
|
}
|
|
5495
5811
|
var no_type_member_comment_wall_default = createRule({
|
|
5496
5812
|
name: "no-type-member-comment-wall",
|
|
@@ -5530,14 +5846,14 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5530
5846
|
}
|
|
5531
5847
|
function isGroupLabel(comment, member, headsRun) {
|
|
5532
5848
|
if (comment.loc.end.line >= member.loc.start.line) return false;
|
|
5533
|
-
const
|
|
5534
|
-
if (!BARE_LABEL_RE.test(
|
|
5535
|
-
if (labelStems(
|
|
5849
|
+
const body2 = commentBody(comment);
|
|
5850
|
+
if (!BARE_LABEL_RE.test(body2)) return false;
|
|
5851
|
+
if (labelStems(body2) === labelStems(sourceCode.getText(member.key))) return false;
|
|
5536
5852
|
const lineAbove = sourceCode.lines[comment.loc.start.line - 2];
|
|
5537
5853
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5538
5854
|
}
|
|
5539
5855
|
function check(node) {
|
|
5540
|
-
const members = node.type ===
|
|
5856
|
+
const members = node.type === import_utils38.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
|
5541
5857
|
const named2 = members.filter(isNamedMember);
|
|
5542
5858
|
if (named2.length === 0) return;
|
|
5543
5859
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5552,9 +5868,9 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5552
5868
|
}
|
|
5553
5869
|
claimed.add(comment);
|
|
5554
5870
|
commented += 1;
|
|
5555
|
-
const
|
|
5556
|
-
if (
|
|
5557
|
-
if (novelWords(
|
|
5871
|
+
const body2 = commentBody(comment);
|
|
5872
|
+
if (body2.length === 0 || carriesValue(body2)) continue;
|
|
5873
|
+
if (novelWords(body2, knownTokens(sourceCode.getText(member))) <= options.maxNovelWords) {
|
|
5558
5874
|
restated += 1;
|
|
5559
5875
|
}
|
|
5560
5876
|
}
|
|
@@ -5577,7 +5893,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5577
5893
|
});
|
|
5578
5894
|
|
|
5579
5895
|
// src/rules/no-unnecessary-use-client.ts
|
|
5580
|
-
var
|
|
5896
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
5581
5897
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5582
5898
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5583
5899
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -5603,13 +5919,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
5603
5919
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
5604
5920
|
var jsxRootName = (name) => {
|
|
5605
5921
|
let current = name;
|
|
5606
|
-
while (current.type ===
|
|
5922
|
+
while (current.type === import_utils39.AST_NODE_TYPES.JSXMemberExpression) {
|
|
5607
5923
|
current = current.object;
|
|
5608
5924
|
}
|
|
5609
|
-
return current.type ===
|
|
5925
|
+
return current.type === import_utils39.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
5610
5926
|
};
|
|
5611
5927
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
5612
|
-
if (node.type ===
|
|
5928
|
+
if (node.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
5613
5929
|
return imported.has(node.name);
|
|
5614
5930
|
}
|
|
5615
5931
|
for (const key of Object.keys(node)) {
|
|
@@ -5624,16 +5940,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
5624
5940
|
return false;
|
|
5625
5941
|
};
|
|
5626
5942
|
var isUseClientDirective = (node) => {
|
|
5627
|
-
return node.type ===
|
|
5943
|
+
return node.type === import_utils39.AST_NODE_TYPES.ExpressionStatement && node.expression.type === import_utils39.AST_NODE_TYPES.Literal && node.expression.value === "use client";
|
|
5628
5944
|
};
|
|
5629
5945
|
var isGlobalReference = (node, context) => {
|
|
5630
5946
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
5631
5947
|
const parent = node.parent;
|
|
5632
5948
|
if (parent !== void 0) {
|
|
5633
|
-
if (parent.type ===
|
|
5949
|
+
if (parent.type === import_utils39.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
5634
5950
|
return false;
|
|
5635
5951
|
}
|
|
5636
|
-
if (parent.type ===
|
|
5952
|
+
if (parent.type === import_utils39.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
5637
5953
|
return false;
|
|
5638
5954
|
}
|
|
5639
5955
|
if (parent.type.startsWith("TS")) {
|
|
@@ -5673,13 +5989,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5673
5989
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
5674
5990
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
5675
5991
|
const markIfHookOrContext = (callee) => {
|
|
5676
|
-
if (callee.type ===
|
|
5992
|
+
if (callee.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
5677
5993
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
5678
5994
|
hasClientIndicator = true;
|
|
5679
5995
|
}
|
|
5680
5996
|
return;
|
|
5681
5997
|
}
|
|
5682
|
-
if (callee.type ===
|
|
5998
|
+
if (callee.type === import_utils39.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
5683
5999
|
const name = callee.property.name;
|
|
5684
6000
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
5685
6001
|
hasClientIndicator = true;
|
|
@@ -5689,7 +6005,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5689
6005
|
return {
|
|
5690
6006
|
Program(node) {
|
|
5691
6007
|
for (const stmt of node.body) {
|
|
5692
|
-
if (stmt.type !==
|
|
6008
|
+
if (stmt.type !== import_utils39.AST_NODE_TYPES.ExpressionStatement) break;
|
|
5693
6009
|
if (isUseClientDirective(stmt)) {
|
|
5694
6010
|
directiveNode = stmt;
|
|
5695
6011
|
break;
|
|
@@ -5702,7 +6018,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5702
6018
|
},
|
|
5703
6019
|
JSXAttribute(node) {
|
|
5704
6020
|
if (directiveNode === null) return;
|
|
5705
|
-
if (node.name.type ===
|
|
6021
|
+
if (node.name.type === import_utils39.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
5706
6022
|
hasClientIndicator = true;
|
|
5707
6023
|
}
|
|
5708
6024
|
},
|
|
@@ -5769,18 +6085,18 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5769
6085
|
});
|
|
5770
6086
|
|
|
5771
6087
|
// src/rules/no-unsafe-mock-casting.ts
|
|
5772
|
-
var import_utils39 = require("@typescript-eslint/utils");
|
|
5773
6088
|
var import_utils40 = require("@typescript-eslint/utils");
|
|
6089
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
5774
6090
|
function isMockTypeReference(node) {
|
|
5775
|
-
if (node.type !==
|
|
6091
|
+
if (node.type !== import_utils41.AST_NODE_TYPES.TSTypeReference) {
|
|
5776
6092
|
return false;
|
|
5777
6093
|
}
|
|
5778
6094
|
const typeName = node.typeName;
|
|
5779
|
-
if (typeName.type ===
|
|
6095
|
+
if (typeName.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5780
6096
|
const name = typeName.name;
|
|
5781
6097
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
5782
6098
|
}
|
|
5783
|
-
if (typeName.type ===
|
|
6099
|
+
if (typeName.type === import_utils41.AST_NODE_TYPES.TSQualifiedName) {
|
|
5784
6100
|
const rightName = typeName.right.name;
|
|
5785
6101
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
5786
6102
|
}
|
|
@@ -5816,7 +6132,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
5816
6132
|
});
|
|
5817
6133
|
|
|
5818
6134
|
// src/rules/no-zod-native-enum.ts
|
|
5819
|
-
var
|
|
6135
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
5820
6136
|
var ts = __toESM(require("typescript"), 1);
|
|
5821
6137
|
var IGNORE_PATTERNS = [
|
|
5822
6138
|
/[\\/]generated[\\/]/,
|
|
@@ -5834,7 +6150,7 @@ function isZodModule(source) {
|
|
|
5834
6150
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
5835
6151
|
}
|
|
5836
6152
|
function unwrap2(node) {
|
|
5837
|
-
if (node.type ===
|
|
6153
|
+
if (node.type === import_utils42.AST_NODE_TYPES.TSAsExpression || node.type === import_utils42.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
5838
6154
|
return unwrap2(node.expression);
|
|
5839
6155
|
}
|
|
5840
6156
|
return node;
|
|
@@ -5842,14 +6158,14 @@ function unwrap2(node) {
|
|
|
5842
6158
|
function stringValueTexts(node, sourceCode) {
|
|
5843
6159
|
const texts = [];
|
|
5844
6160
|
for (const prop of node.properties) {
|
|
5845
|
-
if (prop.type !==
|
|
6161
|
+
if (prop.type !== import_utils42.AST_NODE_TYPES.Property) {
|
|
5846
6162
|
return null;
|
|
5847
6163
|
}
|
|
5848
6164
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
5849
6165
|
return null;
|
|
5850
6166
|
}
|
|
5851
6167
|
const value = prop.value;
|
|
5852
|
-
if (value.type !==
|
|
6168
|
+
if (value.type !== import_utils42.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
5853
6169
|
return null;
|
|
5854
6170
|
}
|
|
5855
6171
|
const text = sourceCode.getText(value);
|
|
@@ -5865,7 +6181,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
5865
6181
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
5866
6182
|
if (variable !== void 0) {
|
|
5867
6183
|
return variable.defs.some(
|
|
5868
|
-
(def) => def.node.type ===
|
|
6184
|
+
(def) => def.node.type === import_utils42.AST_NODE_TYPES.TSEnumDeclaration
|
|
5869
6185
|
);
|
|
5870
6186
|
}
|
|
5871
6187
|
current = current.upper;
|
|
@@ -5910,32 +6226,32 @@ var no_zod_native_enum_default = createRule({
|
|
|
5910
6226
|
}
|
|
5911
6227
|
let services;
|
|
5912
6228
|
try {
|
|
5913
|
-
services =
|
|
6229
|
+
services = import_utils42.ESLintUtils.getParserServices(context);
|
|
5914
6230
|
} catch {
|
|
5915
6231
|
services = null;
|
|
5916
6232
|
}
|
|
5917
6233
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
5918
6234
|
function isZodMemberCall(node, api) {
|
|
5919
6235
|
const callee = node.callee;
|
|
5920
|
-
if (callee.type ===
|
|
6236
|
+
if (callee.type === import_utils42.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5921
6237
|
return callee.property.name === api;
|
|
5922
6238
|
}
|
|
5923
|
-
if (callee.type ===
|
|
6239
|
+
if (callee.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5924
6240
|
return zodImportedNames.get(callee.name) === api;
|
|
5925
6241
|
}
|
|
5926
6242
|
return false;
|
|
5927
6243
|
}
|
|
5928
6244
|
function buildFix(node) {
|
|
5929
6245
|
const callee = node.callee;
|
|
5930
|
-
if (callee.type !==
|
|
6246
|
+
if (callee.type !== import_utils42.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5931
6247
|
return null;
|
|
5932
6248
|
}
|
|
5933
6249
|
const arg = node.arguments[0];
|
|
5934
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6250
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === import_utils42.AST_NODE_TYPES.SpreadElement) {
|
|
5935
6251
|
return null;
|
|
5936
6252
|
}
|
|
5937
6253
|
const inner = unwrap2(arg);
|
|
5938
|
-
if (inner.type !==
|
|
6254
|
+
if (inner.type !== import_utils42.AST_NODE_TYPES.ObjectExpression) {
|
|
5939
6255
|
return null;
|
|
5940
6256
|
}
|
|
5941
6257
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -5955,7 +6271,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5955
6271
|
return;
|
|
5956
6272
|
}
|
|
5957
6273
|
for (const spec of node.specifiers) {
|
|
5958
|
-
if (spec.type ===
|
|
6274
|
+
if (spec.type === import_utils42.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5959
6275
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
5960
6276
|
}
|
|
5961
6277
|
}
|
|
@@ -5974,7 +6290,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5974
6290
|
return;
|
|
5975
6291
|
}
|
|
5976
6292
|
const arg = node.arguments[0];
|
|
5977
|
-
if (arg === void 0 || arg.type !==
|
|
6293
|
+
if (arg === void 0 || arg.type !== import_utils42.AST_NODE_TYPES.Identifier) {
|
|
5978
6294
|
return;
|
|
5979
6295
|
}
|
|
5980
6296
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -5991,7 +6307,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5991
6307
|
});
|
|
5992
6308
|
|
|
5993
6309
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
5994
|
-
var
|
|
6310
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
5995
6311
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
5996
6312
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
5997
6313
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6004,36 +6320,36 @@ function isConstantReference(identifier) {
|
|
|
6004
6320
|
}
|
|
6005
6321
|
function isExcludedOperand(node) {
|
|
6006
6322
|
switch (node.type) {
|
|
6007
|
-
case
|
|
6323
|
+
case import_utils43.AST_NODE_TYPES.Literal:
|
|
6008
6324
|
return true;
|
|
6009
|
-
case
|
|
6325
|
+
case import_utils43.AST_NODE_TYPES.TemplateLiteral:
|
|
6010
6326
|
return node.expressions.length === 0;
|
|
6011
|
-
case
|
|
6327
|
+
case import_utils43.AST_NODE_TYPES.Identifier:
|
|
6012
6328
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6013
|
-
case
|
|
6014
|
-
return !node.computed && node.property.type ===
|
|
6329
|
+
case import_utils43.AST_NODE_TYPES.MemberExpression:
|
|
6330
|
+
return !node.computed && node.property.type === import_utils43.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6015
6331
|
default:
|
|
6016
6332
|
return false;
|
|
6017
6333
|
}
|
|
6018
6334
|
}
|
|
6019
6335
|
function operandName(node) {
|
|
6020
|
-
if (node.type ===
|
|
6336
|
+
if (node.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6021
6337
|
return node.name;
|
|
6022
6338
|
}
|
|
6023
|
-
if (node.type ===
|
|
6339
|
+
if (node.type === import_utils43.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6024
6340
|
return node.property.name;
|
|
6025
6341
|
}
|
|
6026
6342
|
return null;
|
|
6027
6343
|
}
|
|
6028
6344
|
function isSecretOperand(node) {
|
|
6029
|
-
if (node.type ===
|
|
6345
|
+
if (node.type === import_utils43.AST_NODE_TYPES.TemplateLiteral) {
|
|
6030
6346
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6031
6347
|
}
|
|
6032
6348
|
const name = operandName(node);
|
|
6033
6349
|
return name !== null && isAuthSecretName(name);
|
|
6034
6350
|
}
|
|
6035
6351
|
function secretNameOf(node) {
|
|
6036
|
-
if (node.type ===
|
|
6352
|
+
if (node.type === import_utils43.AST_NODE_TYPES.TemplateLiteral) {
|
|
6037
6353
|
for (const expression of node.expressions) {
|
|
6038
6354
|
const nested = secretNameOf(expression);
|
|
6039
6355
|
if (nested !== null) {
|
|
@@ -6085,8 +6401,8 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
6085
6401
|
});
|
|
6086
6402
|
|
|
6087
6403
|
// src/rules/prefer-discriminated-union.ts
|
|
6088
|
-
var import_utils43 = require("@typescript-eslint/utils");
|
|
6089
6404
|
var import_utils44 = require("@typescript-eslint/utils");
|
|
6405
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
6090
6406
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
6091
6407
|
"success",
|
|
6092
6408
|
"ok",
|
|
@@ -6096,27 +6412,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6096
6412
|
]);
|
|
6097
6413
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
6098
6414
|
function getMemberName(member) {
|
|
6099
|
-
if (member.type !==
|
|
6415
|
+
if (member.type !== import_utils45.AST_NODE_TYPES.TSPropertySignature) {
|
|
6100
6416
|
return null;
|
|
6101
6417
|
}
|
|
6102
6418
|
const { key } = member;
|
|
6103
|
-
if (key.type ===
|
|
6419
|
+
if (key.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6104
6420
|
return key.name;
|
|
6105
6421
|
}
|
|
6106
|
-
if (key.type ===
|
|
6422
|
+
if (key.type === import_utils45.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
6107
6423
|
return key.value;
|
|
6108
6424
|
}
|
|
6109
6425
|
return null;
|
|
6110
6426
|
}
|
|
6111
6427
|
function isBooleanTyped(member) {
|
|
6112
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6428
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils45.AST_NODE_TYPES.TSBooleanKeyword;
|
|
6113
6429
|
}
|
|
6114
6430
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
6115
6431
|
let hasStatusBoolean = false;
|
|
6116
6432
|
let optionalCount = 0;
|
|
6117
6433
|
let optionalPayloadCount = 0;
|
|
6118
6434
|
for (const member of typeLiteral.members) {
|
|
6119
|
-
if (member.type !==
|
|
6435
|
+
if (member.type !== import_utils45.AST_NODE_TYPES.TSPropertySignature) {
|
|
6120
6436
|
continue;
|
|
6121
6437
|
}
|
|
6122
6438
|
if (member.optional) {
|
|
@@ -6137,7 +6453,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6137
6453
|
meta: {
|
|
6138
6454
|
type: "suggestion",
|
|
6139
6455
|
docs: {
|
|
6140
|
-
description: "Flag object types with a boolean status
|
|
6456
|
+
description: "Flag object types with a boolean status member and at least two optional members, including a non-boolean payload."
|
|
6141
6457
|
},
|
|
6142
6458
|
schema: [],
|
|
6143
6459
|
messages: {
|
|
@@ -6158,7 +6474,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6158
6474
|
TSInterfaceDeclaration(node) {
|
|
6159
6475
|
const synthetic = {
|
|
6160
6476
|
...node.body,
|
|
6161
|
-
type:
|
|
6477
|
+
type: import_utils45.AST_NODE_TYPES.TSTypeLiteral,
|
|
6162
6478
|
members: node.body.body
|
|
6163
6479
|
};
|
|
6164
6480
|
checkTypeLiteral(synthetic, node);
|
|
@@ -6171,7 +6487,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6171
6487
|
});
|
|
6172
6488
|
|
|
6173
6489
|
// src/rules/prefer-module-level-constant.ts
|
|
6174
|
-
var
|
|
6490
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
6175
6491
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6176
6492
|
var MAX_LITERAL_DEPTH = 4;
|
|
6177
6493
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6200,9 +6516,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6200
6516
|
"assign"
|
|
6201
6517
|
]);
|
|
6202
6518
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6519
|
+
import_utils46.AST_NODE_TYPES.FunctionDeclaration,
|
|
6520
|
+
import_utils46.AST_NODE_TYPES.FunctionExpression,
|
|
6521
|
+
import_utils46.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6206
6522
|
]);
|
|
6207
6523
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6208
6524
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6215,14 +6531,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6215
6531
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6216
6532
|
}
|
|
6217
6533
|
function unwrap3(node) {
|
|
6218
|
-
if (node.type ===
|
|
6534
|
+
if (node.type === import_utils46.AST_NODE_TYPES.TSAsExpression || node.type === import_utils46.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils46.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6219
6535
|
return unwrap3(node.expression);
|
|
6220
6536
|
}
|
|
6221
6537
|
return node;
|
|
6222
6538
|
}
|
|
6223
6539
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6224
6540
|
function isRegexLiteral(node) {
|
|
6225
|
-
return node.type ===
|
|
6541
|
+
return node.type === import_utils46.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6226
6542
|
}
|
|
6227
6543
|
function isLiteralOnly(node, depth) {
|
|
6228
6544
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6230,29 +6546,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6230
6546
|
}
|
|
6231
6547
|
const inner = unwrap3(node);
|
|
6232
6548
|
switch (inner.type) {
|
|
6233
|
-
case
|
|
6549
|
+
case import_utils46.AST_NODE_TYPES.Literal: {
|
|
6234
6550
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6235
6551
|
}
|
|
6236
|
-
case
|
|
6552
|
+
case import_utils46.AST_NODE_TYPES.TemplateLiteral: {
|
|
6237
6553
|
return inner.expressions.length === 0;
|
|
6238
6554
|
}
|
|
6239
|
-
case
|
|
6240
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6555
|
+
case import_utils46.AST_NODE_TYPES.UnaryExpression: {
|
|
6556
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils46.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6241
6557
|
}
|
|
6242
|
-
case
|
|
6558
|
+
case import_utils46.AST_NODE_TYPES.ArrayExpression: {
|
|
6243
6559
|
return inner.elements.every(
|
|
6244
|
-
(el) => el !== null && el.type !==
|
|
6560
|
+
(el) => el !== null && el.type !== import_utils46.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6245
6561
|
);
|
|
6246
6562
|
}
|
|
6247
|
-
case
|
|
6563
|
+
case import_utils46.AST_NODE_TYPES.ObjectExpression: {
|
|
6248
6564
|
return inner.properties.every((prop) => {
|
|
6249
|
-
if (prop.type !==
|
|
6565
|
+
if (prop.type !== import_utils46.AST_NODE_TYPES.Property) {
|
|
6250
6566
|
return false;
|
|
6251
6567
|
}
|
|
6252
6568
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6253
6569
|
return false;
|
|
6254
6570
|
}
|
|
6255
|
-
if (prop.computed && prop.key.type !==
|
|
6571
|
+
if (prop.computed && prop.key.type !== import_utils46.AST_NODE_TYPES.Literal) {
|
|
6256
6572
|
return false;
|
|
6257
6573
|
}
|
|
6258
6574
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6265,7 +6581,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6265
6581
|
}
|
|
6266
6582
|
function unwrapObjectFreeze(node) {
|
|
6267
6583
|
const inner = unwrap3(node);
|
|
6268
|
-
if (inner.type ===
|
|
6584
|
+
if (inner.type === import_utils46.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils46.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils46.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils46.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6269
6585
|
return unwrap3(inner.arguments[0]);
|
|
6270
6586
|
}
|
|
6271
6587
|
return inner;
|
|
@@ -6281,19 +6597,19 @@ function classify(init, checkRegex) {
|
|
|
6281
6597
|
}
|
|
6282
6598
|
return { kind: "regex", size: 1 };
|
|
6283
6599
|
}
|
|
6284
|
-
if (node.type ===
|
|
6600
|
+
if (node.type === import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
6285
6601
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6286
6602
|
}
|
|
6287
|
-
if (node.type ===
|
|
6603
|
+
if (node.type === import_utils46.AST_NODE_TYPES.ObjectExpression) {
|
|
6288
6604
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6289
6605
|
}
|
|
6290
|
-
if (node.type ===
|
|
6606
|
+
if (node.type === import_utils46.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils46.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6291
6607
|
const arg = node.arguments[0];
|
|
6292
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6608
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6293
6609
|
return null;
|
|
6294
6610
|
}
|
|
6295
6611
|
const entries = unwrap3(arg);
|
|
6296
|
-
if (entries.type !==
|
|
6612
|
+
if (entries.type !== import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
6297
6613
|
return null;
|
|
6298
6614
|
}
|
|
6299
6615
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6322,10 +6638,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6322
6638
|
);
|
|
6323
6639
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6324
6640
|
const callee = node.callee;
|
|
6325
|
-
if (callee.type ===
|
|
6641
|
+
if (callee.type === import_utils46.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6326
6642
|
return true;
|
|
6327
6643
|
}
|
|
6328
|
-
if (callee.type !==
|
|
6644
|
+
if (callee.type !== import_utils46.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils46.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6329
6645
|
return false;
|
|
6330
6646
|
}
|
|
6331
6647
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6339,38 +6655,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6339
6655
|
}
|
|
6340
6656
|
function isSafeRead(identifier) {
|
|
6341
6657
|
const parent = identifier.parent;
|
|
6342
|
-
if (parent.type ===
|
|
6658
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.MemberExpression) {
|
|
6343
6659
|
if (parent.object !== identifier) {
|
|
6344
6660
|
return true;
|
|
6345
6661
|
}
|
|
6346
6662
|
const grandparent = parent.parent;
|
|
6347
|
-
if (grandparent.type ===
|
|
6663
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6348
6664
|
return false;
|
|
6349
6665
|
}
|
|
6350
|
-
if (grandparent.type ===
|
|
6666
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.UpdateExpression) {
|
|
6351
6667
|
return false;
|
|
6352
6668
|
}
|
|
6353
|
-
if (grandparent.type ===
|
|
6669
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6354
6670
|
return false;
|
|
6355
6671
|
}
|
|
6356
|
-
if (!parent.computed && parent.property.type ===
|
|
6672
|
+
if (!parent.computed && parent.property.type === import_utils46.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils46.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6357
6673
|
return false;
|
|
6358
6674
|
}
|
|
6359
6675
|
return true;
|
|
6360
6676
|
}
|
|
6361
|
-
if (parent.type ===
|
|
6677
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6362
6678
|
return true;
|
|
6363
6679
|
}
|
|
6364
|
-
if (parent.type ===
|
|
6680
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6365
6681
|
return true;
|
|
6366
6682
|
}
|
|
6367
|
-
if (parent.type ===
|
|
6683
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.BinaryExpression) {
|
|
6368
6684
|
return true;
|
|
6369
6685
|
}
|
|
6370
|
-
if (parent.type ===
|
|
6686
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6371
6687
|
return true;
|
|
6372
6688
|
}
|
|
6373
|
-
if (parent.type ===
|
|
6689
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6374
6690
|
return true;
|
|
6375
6691
|
}
|
|
6376
6692
|
return false;
|
|
@@ -6425,7 +6741,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6425
6741
|
if (reference.isWrite()) {
|
|
6426
6742
|
return false;
|
|
6427
6743
|
}
|
|
6428
|
-
if (reference.identifier.type !==
|
|
6744
|
+
if (reference.identifier.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6429
6745
|
return false;
|
|
6430
6746
|
}
|
|
6431
6747
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6437,10 +6753,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6437
6753
|
return {
|
|
6438
6754
|
VariableDeclarator(node) {
|
|
6439
6755
|
const declaration = node.parent;
|
|
6440
|
-
if (declaration.type !==
|
|
6756
|
+
if (declaration.type !== import_utils46.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6441
6757
|
return;
|
|
6442
6758
|
}
|
|
6443
|
-
if (node.id.type !==
|
|
6759
|
+
if (node.id.type !== import_utils46.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6444
6760
|
return;
|
|
6445
6761
|
}
|
|
6446
6762
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6467,7 +6783,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6467
6783
|
});
|
|
6468
6784
|
|
|
6469
6785
|
// src/rules/prefer-module-level-schema.ts
|
|
6470
|
-
var
|
|
6786
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
6471
6787
|
|
|
6472
6788
|
// src/rules/_zod.ts
|
|
6473
6789
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6533,9 +6849,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6533
6849
|
"intl"
|
|
6534
6850
|
]);
|
|
6535
6851
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6852
|
+
import_utils47.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
6853
|
+
import_utils47.AST_NODE_TYPES.FunctionDeclaration,
|
|
6854
|
+
import_utils47.AST_NODE_TYPES.FunctionExpression
|
|
6539
6855
|
]);
|
|
6540
6856
|
function schemaExpression(node) {
|
|
6541
6857
|
let current = node;
|
|
@@ -6544,10 +6860,10 @@ function schemaExpression(node) {
|
|
|
6544
6860
|
if (parent === void 0) {
|
|
6545
6861
|
return current;
|
|
6546
6862
|
}
|
|
6547
|
-
if (parent.type ===
|
|
6863
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils47.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6548
6864
|
return current;
|
|
6549
6865
|
}
|
|
6550
|
-
if (parent.type ===
|
|
6866
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils47.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils47.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils47.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
6551
6867
|
current = parent;
|
|
6552
6868
|
continue;
|
|
6553
6869
|
}
|
|
@@ -6598,22 +6914,22 @@ function subtreeSome(root, predicate) {
|
|
|
6598
6914
|
function readsReceiver(node) {
|
|
6599
6915
|
return subtreeSome(
|
|
6600
6916
|
node,
|
|
6601
|
-
(inner) => inner.type ===
|
|
6917
|
+
(inner) => inner.type === import_utils47.AST_NODE_TYPES.ThisExpression || inner.type === import_utils47.AST_NODE_TYPES.Super || inner.type === import_utils47.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
6602
6918
|
);
|
|
6603
6919
|
}
|
|
6604
6920
|
function buildsLocalizedText(node) {
|
|
6605
6921
|
return subtreeSome(node, (inner) => {
|
|
6606
|
-
if (inner.type ===
|
|
6922
|
+
if (inner.type === import_utils47.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
6607
6923
|
return true;
|
|
6608
6924
|
}
|
|
6609
|
-
if (inner.type !==
|
|
6925
|
+
if (inner.type !== import_utils47.AST_NODE_TYPES.CallExpression) {
|
|
6610
6926
|
return false;
|
|
6611
6927
|
}
|
|
6612
6928
|
const { callee } = inner;
|
|
6613
|
-
if (callee.type ===
|
|
6929
|
+
if (callee.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6614
6930
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6615
6931
|
}
|
|
6616
|
-
return callee.type ===
|
|
6932
|
+
return callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils47.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6617
6933
|
});
|
|
6618
6934
|
}
|
|
6619
6935
|
function collectReferences(scope, out) {
|
|
@@ -6670,15 +6986,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6670
6986
|
}
|
|
6671
6987
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
6672
6988
|
function isZodCall(node) {
|
|
6673
|
-
return node.type ===
|
|
6989
|
+
return node.type === import_utils47.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils47.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
6674
6990
|
}
|
|
6675
6991
|
function isCovered(node) {
|
|
6676
6992
|
let current = node.parent ?? void 0;
|
|
6677
6993
|
while (current !== void 0) {
|
|
6678
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
6994
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
6679
6995
|
return true;
|
|
6680
6996
|
}
|
|
6681
|
-
if (current.type ===
|
|
6997
|
+
if (current.type === import_utils47.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils47.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
6682
6998
|
return true;
|
|
6683
6999
|
}
|
|
6684
7000
|
current = current.parent ?? void 0;
|
|
@@ -6693,11 +7009,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6693
7009
|
if (parent === void 0) {
|
|
6694
7010
|
return confirmed;
|
|
6695
7011
|
}
|
|
6696
|
-
if (parent.type ===
|
|
7012
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils47.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils47.AST_NODE_TYPES.ArrayExpression) {
|
|
6697
7013
|
current = parent;
|
|
6698
7014
|
continue;
|
|
6699
7015
|
}
|
|
6700
|
-
if (parent.type ===
|
|
7016
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
6701
7017
|
current = schemaExpression(parent);
|
|
6702
7018
|
confirmed = current;
|
|
6703
7019
|
continue;
|
|
@@ -6707,7 +7023,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6707
7023
|
}
|
|
6708
7024
|
function isSchemaComposition(node) {
|
|
6709
7025
|
const { callee } = node;
|
|
6710
|
-
const isCombinator = callee.type ===
|
|
7026
|
+
const isCombinator = callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
6711
7027
|
return isCombinator || isZodCall(node);
|
|
6712
7028
|
}
|
|
6713
7029
|
function closesOverNothing(node, enclosing) {
|
|
@@ -6741,13 +7057,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6741
7057
|
}
|
|
6742
7058
|
function ownerName(enclosing) {
|
|
6743
7059
|
const parent = enclosing.parent ?? void 0;
|
|
6744
|
-
if (enclosing.type ===
|
|
7060
|
+
if (enclosing.type === import_utils47.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
6745
7061
|
return enclosing.id.name;
|
|
6746
7062
|
}
|
|
6747
|
-
if (parent !== void 0 && parent.type ===
|
|
7063
|
+
if (parent !== void 0 && parent.type === import_utils47.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6748
7064
|
return parent.id.name;
|
|
6749
7065
|
}
|
|
6750
|
-
if (parent !== void 0 && (parent.type ===
|
|
7066
|
+
if (parent !== void 0 && (parent.type === import_utils47.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils47.AST_NODE_TYPES.Property) && parent.key.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6751
7067
|
return parent.key.name;
|
|
6752
7068
|
}
|
|
6753
7069
|
return "this function";
|
|
@@ -6758,7 +7074,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6758
7074
|
return;
|
|
6759
7075
|
}
|
|
6760
7076
|
for (const specifier of node.specifiers) {
|
|
6761
|
-
if (specifier.type ===
|
|
7077
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils47.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils47.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils47.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
6762
7078
|
zodNamespaces.add(specifier.local.name);
|
|
6763
7079
|
}
|
|
6764
7080
|
}
|
|
@@ -6768,7 +7084,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6768
7084
|
return;
|
|
6769
7085
|
}
|
|
6770
7086
|
const callee = node.callee;
|
|
6771
|
-
if (callee.property.type !==
|
|
7087
|
+
if (callee.property.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6772
7088
|
return;
|
|
6773
7089
|
}
|
|
6774
7090
|
const factory = callee.property.name;
|
|
@@ -6783,7 +7099,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6783
7099
|
return;
|
|
6784
7100
|
}
|
|
6785
7101
|
const shape = node.arguments[0];
|
|
6786
|
-
if (shape !== void 0 && shape.type ===
|
|
7102
|
+
if (shape !== void 0 && shape.type === import_utils47.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
6787
7103
|
return;
|
|
6788
7104
|
}
|
|
6789
7105
|
const expression = schemaExpression(node);
|
|
@@ -6811,20 +7127,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6811
7127
|
});
|
|
6812
7128
|
|
|
6813
7129
|
// src/rules/prefer-non-nullable-collection.ts
|
|
6814
|
-
var
|
|
7130
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6815
7131
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
6816
7132
|
function propertyName(node) {
|
|
6817
7133
|
const key = node.key;
|
|
6818
|
-
if (key.type ===
|
|
6819
|
-
if (key.type ===
|
|
7134
|
+
if (key.type === import_utils48.AST_NODE_TYPES.Identifier) return key.name;
|
|
7135
|
+
if (key.type === import_utils48.AST_NODE_TYPES.Literal) return String(key.value);
|
|
6820
7136
|
return "collection";
|
|
6821
7137
|
}
|
|
6822
7138
|
function isArrayType(node) {
|
|
6823
|
-
if (node.type ===
|
|
6824
|
-
return node.type ===
|
|
7139
|
+
if (node.type === import_utils48.AST_NODE_TYPES.TSArrayType) return true;
|
|
7140
|
+
return node.type === import_utils48.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils48.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
6825
7141
|
}
|
|
6826
7142
|
function isNullishType(node) {
|
|
6827
|
-
return node.type ===
|
|
7143
|
+
return node.type === import_utils48.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils48.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
6828
7144
|
}
|
|
6829
7145
|
function isNullableArrayOnly(node) {
|
|
6830
7146
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -6835,7 +7151,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6835
7151
|
meta: {
|
|
6836
7152
|
type: "suggestion",
|
|
6837
7153
|
docs: {
|
|
6838
|
-
description: "Require
|
|
7154
|
+
description: "Require declared data-shape properties and direct aliases to use non-null arrays instead of explicit nullish unions."
|
|
6839
7155
|
},
|
|
6840
7156
|
schema: [],
|
|
6841
7157
|
messages: {
|
|
@@ -6851,7 +7167,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6851
7167
|
function checkOptionalProperty(node) {
|
|
6852
7168
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
6853
7169
|
if (annotation === void 0) return;
|
|
6854
|
-
if (annotation.type !==
|
|
7170
|
+
if (annotation.type !== import_utils48.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
6855
7171
|
return;
|
|
6856
7172
|
}
|
|
6857
7173
|
context.report({
|
|
@@ -6864,7 +7180,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6864
7180
|
TSPropertySignature: checkOptionalProperty,
|
|
6865
7181
|
PropertyDefinition: checkOptionalProperty,
|
|
6866
7182
|
TSTypeAliasDeclaration(node) {
|
|
6867
|
-
if (node.typeAnnotation.type !==
|
|
7183
|
+
if (node.typeAnnotation.type !== import_utils48.AST_NODE_TYPES.TSUnionType) return;
|
|
6868
7184
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
6869
7185
|
context.report({
|
|
6870
7186
|
node,
|
|
@@ -6877,13 +7193,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6877
7193
|
});
|
|
6878
7194
|
|
|
6879
7195
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
6880
|
-
var
|
|
7196
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
6881
7197
|
var unwrap4 = (node) => {
|
|
6882
7198
|
let current = node;
|
|
6883
7199
|
while (current !== null && current !== void 0) {
|
|
6884
|
-
if (current.type ===
|
|
7200
|
+
if (current.type === import_utils49.AST_NODE_TYPES.TSAsExpression || current.type === import_utils49.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6885
7201
|
current = current.expression;
|
|
6886
|
-
} else if (current.type ===
|
|
7202
|
+
} else if (current.type === import_utils49.AST_NODE_TYPES.ChainExpression) {
|
|
6887
7203
|
current = current.expression;
|
|
6888
7204
|
} else {
|
|
6889
7205
|
break;
|
|
@@ -6898,23 +7214,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
6898
7214
|
]);
|
|
6899
7215
|
var isSchemaParseReference = (node) => {
|
|
6900
7216
|
const inner = unwrap4(node);
|
|
6901
|
-
return inner !== null && inner.type ===
|
|
7217
|
+
return inner !== null && inner.type === import_utils49.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils49.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
6902
7218
|
};
|
|
6903
7219
|
var isRawPayloadSource = (node) => {
|
|
6904
7220
|
let current = unwrap4(node);
|
|
6905
7221
|
if (current === null) return false;
|
|
6906
|
-
if (current.type ===
|
|
7222
|
+
if (current.type === import_utils49.AST_NODE_TYPES.AwaitExpression) {
|
|
6907
7223
|
current = unwrap4(current.argument);
|
|
6908
7224
|
}
|
|
6909
|
-
if (current === null || current.type !==
|
|
7225
|
+
if (current === null || current.type !== import_utils49.AST_NODE_TYPES.CallExpression) {
|
|
6910
7226
|
return false;
|
|
6911
7227
|
}
|
|
6912
7228
|
const callee = unwrap4(current.callee);
|
|
6913
|
-
if (callee === null || callee.type !==
|
|
7229
|
+
if (callee === null || callee.type !== import_utils49.AST_NODE_TYPES.MemberExpression) {
|
|
6914
7230
|
return false;
|
|
6915
7231
|
}
|
|
6916
7232
|
const property = unwrap4(callee.property);
|
|
6917
|
-
if (property === null || property.type !==
|
|
7233
|
+
if (property === null || property.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
6918
7234
|
return false;
|
|
6919
7235
|
}
|
|
6920
7236
|
if (property.name === "json") {
|
|
@@ -6924,17 +7240,16 @@ var isRawPayloadSource = (node) => {
|
|
|
6924
7240
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
6925
7241
|
}
|
|
6926
7242
|
const object = unwrap4(callee.object);
|
|
6927
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
6928
|
-
!isLocalFileRead(current.arguments[0]);
|
|
7243
|
+
return property.name === "parse" && object !== null && object.type === import_utils49.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
6929
7244
|
};
|
|
6930
7245
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
6931
7246
|
var isLocalFileRead = (node) => {
|
|
6932
7247
|
let found = false;
|
|
6933
7248
|
const visit = (current) => {
|
|
6934
7249
|
if (found || current === null || current === void 0) return;
|
|
6935
|
-
if (current.type ===
|
|
7250
|
+
if (current.type === import_utils49.AST_NODE_TYPES.CallExpression) {
|
|
6936
7251
|
const callee = unwrap4(current.callee);
|
|
6937
|
-
const name = callee?.type ===
|
|
7252
|
+
const name = callee?.type === import_utils49.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils49.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils49.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
6938
7253
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
6939
7254
|
found = true;
|
|
6940
7255
|
return;
|
|
@@ -6956,15 +7271,15 @@ var isLocalFileRead = (node) => {
|
|
|
6956
7271
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
6957
7272
|
var isInsideAssertion = (node) => {
|
|
6958
7273
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
6959
|
-
if (current.type !==
|
|
7274
|
+
if (current.type !== import_utils49.AST_NODE_TYPES.CallExpression) continue;
|
|
6960
7275
|
let callee = current.callee;
|
|
6961
|
-
while (callee.type ===
|
|
7276
|
+
while (callee.type === import_utils49.AST_NODE_TYPES.MemberExpression) {
|
|
6962
7277
|
callee = callee.object;
|
|
6963
7278
|
}
|
|
6964
|
-
if (callee.type ===
|
|
7279
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.CallExpression) {
|
|
6965
7280
|
callee = callee.callee;
|
|
6966
7281
|
}
|
|
6967
|
-
if (callee.type ===
|
|
7282
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
6968
7283
|
return true;
|
|
6969
7284
|
}
|
|
6970
7285
|
}
|
|
@@ -6983,39 +7298,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
6983
7298
|
var isValidationRead = (node) => {
|
|
6984
7299
|
let current = node;
|
|
6985
7300
|
let parent = current.parent;
|
|
6986
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7301
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils49.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils49.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils49.AST_NODE_TYPES.ChainExpression)) {
|
|
6987
7302
|
current = parent;
|
|
6988
7303
|
parent = parent.parent;
|
|
6989
7304
|
}
|
|
6990
7305
|
if (parent === null || parent === void 0) return false;
|
|
6991
|
-
if (parent.type ===
|
|
7306
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
6992
7307
|
return true;
|
|
6993
7308
|
}
|
|
6994
|
-
if (parent.type !==
|
|
7309
|
+
if (parent.type !== import_utils49.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
6995
7310
|
return false;
|
|
6996
7311
|
}
|
|
6997
7312
|
const callee = parent.callee;
|
|
6998
|
-
if (callee.type ===
|
|
7313
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
6999
7314
|
return parent.arguments.length === 1;
|
|
7000
7315
|
}
|
|
7001
|
-
return callee.type ===
|
|
7316
|
+
return callee.type === import_utils49.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7002
7317
|
};
|
|
7003
7318
|
var isGuardTestPosition = (node) => {
|
|
7004
7319
|
let current = node;
|
|
7005
7320
|
let parent = current.parent;
|
|
7006
7321
|
while (parent !== void 0 && parent !== null) {
|
|
7007
7322
|
switch (parent.type) {
|
|
7008
|
-
case
|
|
7009
|
-
case
|
|
7010
|
-
case
|
|
7323
|
+
case import_utils49.AST_NODE_TYPES.UnaryExpression:
|
|
7324
|
+
case import_utils49.AST_NODE_TYPES.LogicalExpression:
|
|
7325
|
+
case import_utils49.AST_NODE_TYPES.ChainExpression:
|
|
7011
7326
|
current = parent;
|
|
7012
7327
|
parent = parent.parent;
|
|
7013
7328
|
continue;
|
|
7014
|
-
case
|
|
7015
|
-
case
|
|
7016
|
-
case
|
|
7017
|
-
case
|
|
7018
|
-
case
|
|
7329
|
+
case import_utils49.AST_NODE_TYPES.IfStatement:
|
|
7330
|
+
case import_utils49.AST_NODE_TYPES.ConditionalExpression:
|
|
7331
|
+
case import_utils49.AST_NODE_TYPES.WhileStatement:
|
|
7332
|
+
case import_utils49.AST_NODE_TYPES.DoWhileStatement:
|
|
7333
|
+
case import_utils49.AST_NODE_TYPES.ForStatement:
|
|
7019
7334
|
return parent.test === current;
|
|
7020
7335
|
default:
|
|
7021
7336
|
return false;
|
|
@@ -7025,7 +7340,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7025
7340
|
};
|
|
7026
7341
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7027
7342
|
const unwrapped = unwrap4(node);
|
|
7028
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7343
|
+
if (unwrapped === null || unwrapped.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7029
7344
|
return false;
|
|
7030
7345
|
}
|
|
7031
7346
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7068,11 +7383,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7068
7383
|
return {
|
|
7069
7384
|
VariableDeclarator(node) {
|
|
7070
7385
|
const scope = context.sourceCode.getScope(node);
|
|
7071
|
-
if (node.id.type ===
|
|
7386
|
+
if (node.id.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7072
7387
|
trackInitializer(node);
|
|
7073
7388
|
return;
|
|
7074
7389
|
}
|
|
7075
|
-
if (node.id.type ===
|
|
7390
|
+
if (node.id.type === import_utils49.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils49.AST_NODE_TYPES.ArrayPattern) {
|
|
7076
7391
|
if (isRawPayloadSource(node.init)) {
|
|
7077
7392
|
if (!isFullyNarrowedPattern(node)) {
|
|
7078
7393
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7086,7 +7401,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7086
7401
|
},
|
|
7087
7402
|
AssignmentExpression(node) {
|
|
7088
7403
|
const scope = context.sourceCode.getScope(node);
|
|
7089
|
-
if (node.left.type ===
|
|
7404
|
+
if (node.left.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7090
7405
|
const variable = findVariable2(scope, node.left.name);
|
|
7091
7406
|
if (variable === null) return;
|
|
7092
7407
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7096,7 +7411,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7096
7411
|
}
|
|
7097
7412
|
return;
|
|
7098
7413
|
}
|
|
7099
|
-
if (node.left.type ===
|
|
7414
|
+
if (node.left.type === import_utils49.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils49.AST_NODE_TYPES.ArrayPattern) {
|
|
7100
7415
|
if (isRawPayloadSource(node.right)) {
|
|
7101
7416
|
context.report({
|
|
7102
7417
|
node: node.left,
|
|
@@ -7113,15 +7428,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7113
7428
|
}
|
|
7114
7429
|
},
|
|
7115
7430
|
CallExpression(node) {
|
|
7116
|
-
if (node.callee.type !==
|
|
7431
|
+
if (node.callee.type !== import_utils49.AST_NODE_TYPES.Identifier) return;
|
|
7117
7432
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7118
7433
|
return;
|
|
7119
7434
|
}
|
|
7120
7435
|
const scope = context.sourceCode.getScope(node);
|
|
7121
7436
|
for (const arg of node.arguments) {
|
|
7122
|
-
if (arg.type ===
|
|
7437
|
+
if (arg.type === import_utils49.AST_NODE_TYPES.SpreadElement) continue;
|
|
7123
7438
|
const unwrapped = unwrap4(arg);
|
|
7124
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7439
|
+
if (unwrapped === null || unwrapped.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7125
7440
|
continue;
|
|
7126
7441
|
}
|
|
7127
7442
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7135,13 +7450,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7135
7450
|
const obj = unwrap4(node.object);
|
|
7136
7451
|
if (isRawPayloadSource(obj)) {
|
|
7137
7452
|
const parent = node.parent;
|
|
7138
|
-
if (parent.type ===
|
|
7453
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils49.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7139
7454
|
return;
|
|
7140
7455
|
}
|
|
7141
7456
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7142
7457
|
return;
|
|
7143
7458
|
}
|
|
7144
|
-
if (obj !== null && obj.type ===
|
|
7459
|
+
if (obj !== null && obj.type === import_utils49.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7145
7460
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7146
7461
|
const variable = findVariable2(scope, obj.name);
|
|
7147
7462
|
if (variable !== null) {
|
|
@@ -7154,7 +7469,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7154
7469
|
});
|
|
7155
7470
|
|
|
7156
7471
|
// src/rules/prefer-semantic-colors.ts
|
|
7157
|
-
var
|
|
7472
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7158
7473
|
var import_fs = require("fs");
|
|
7159
7474
|
var import_path = require("path");
|
|
7160
7475
|
|
|
@@ -7254,8 +7569,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7254
7569
|
]);
|
|
7255
7570
|
function jsxElementName(node) {
|
|
7256
7571
|
const name = node.openingElement.name;
|
|
7257
|
-
if (name.type ===
|
|
7258
|
-
if (name.type ===
|
|
7572
|
+
if (name.type === import_utils50.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
7573
|
+
if (name.type === import_utils50.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils50.AST_NODE_TYPES.JSXIdentifier) {
|
|
7259
7574
|
return name.property.name;
|
|
7260
7575
|
}
|
|
7261
7576
|
return null;
|
|
@@ -7277,11 +7592,11 @@ var SVG_SHAPE_PRIMITIVES = /* @__PURE__ */ new Set([
|
|
|
7277
7592
|
"tspan",
|
|
7278
7593
|
"use"
|
|
7279
7594
|
]);
|
|
7280
|
-
var
|
|
7595
|
+
var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
7281
7596
|
var isInsideSvg = (node) => {
|
|
7282
7597
|
let current = node.parent;
|
|
7283
7598
|
while (current !== void 0 && current !== null) {
|
|
7284
|
-
if (current.type ===
|
|
7599
|
+
if (current.type === import_utils50.AST_NODE_TYPES.JSXElement) {
|
|
7285
7600
|
const name = jsxElementName(current);
|
|
7286
7601
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7287
7602
|
}
|
|
@@ -7292,7 +7607,7 @@ var isInsideSvg = (node) => {
|
|
|
7292
7607
|
var isInsideIconFactoryPath = (node) => {
|
|
7293
7608
|
let current = node.parent;
|
|
7294
7609
|
while (current !== void 0 && current !== null) {
|
|
7295
|
-
if (current.type ===
|
|
7610
|
+
if (current.type === import_utils50.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils50.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils50.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils50.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7296
7611
|
return true;
|
|
7297
7612
|
}
|
|
7298
7613
|
current = current.parent;
|
|
@@ -7429,10 +7744,16 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7429
7744
|
return root !== null && workspaceHasMarker(root);
|
|
7430
7745
|
};
|
|
7431
7746
|
var propName = (key) => {
|
|
7432
|
-
if (key.type ===
|
|
7433
|
-
if (key.type ===
|
|
7747
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Identifier) return key.name;
|
|
7748
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
7434
7749
|
return null;
|
|
7435
7750
|
};
|
|
7751
|
+
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7752
|
+
if (statement.type !== import_utils50.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils50.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils50.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
7753
|
+
return false;
|
|
7754
|
+
}
|
|
7755
|
+
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
7756
|
+
});
|
|
7436
7757
|
var prefer_semantic_colors_default = createRule({
|
|
7437
7758
|
name: "prefer-semantic-colors",
|
|
7438
7759
|
meta: {
|
|
@@ -7458,44 +7779,49 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7458
7779
|
defaultOptions: [{}],
|
|
7459
7780
|
create(context, [options]) {
|
|
7460
7781
|
if (STORIES_FILE_RE.test(context.filename)) return {};
|
|
7461
|
-
if (
|
|
7782
|
+
if (staticallyImportsEmailOrPdfRenderer(context.sourceCode.ast)) return {};
|
|
7462
7783
|
if (options?.requireSemanticTokens === true && !hasSemanticTokenSystem(context.filename)) {
|
|
7463
7784
|
return {};
|
|
7464
7785
|
}
|
|
7786
|
+
let importsEmailOrPdfRenderer = false;
|
|
7787
|
+
const pendingReports = [];
|
|
7788
|
+
const report = (node, messageId, data) => {
|
|
7789
|
+
pendingReports.push({ node, messageId, data });
|
|
7790
|
+
};
|
|
7465
7791
|
const reportClasses = (value, node) => {
|
|
7466
7792
|
for (const token of classTokens(value)) {
|
|
7467
7793
|
const base = tailwindBase(token);
|
|
7468
7794
|
if (RAW_PALETTE_RE.test(base)) {
|
|
7469
|
-
|
|
7795
|
+
report(node, "rawPalette", { class: token });
|
|
7470
7796
|
} else if (ARBITRARY_COLOR_RE.test(base) && !CSS_VAR_REFERENCE_RE.test(base)) {
|
|
7471
|
-
|
|
7797
|
+
report(node, "arbitraryColor", { class: token });
|
|
7472
7798
|
}
|
|
7473
7799
|
}
|
|
7474
7800
|
};
|
|
7475
7801
|
const checkClassNode = (node) => {
|
|
7476
7802
|
if (node === null) return;
|
|
7477
7803
|
switch (node.type) {
|
|
7478
|
-
case
|
|
7804
|
+
case import_utils50.AST_NODE_TYPES.Literal:
|
|
7479
7805
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7480
7806
|
break;
|
|
7481
|
-
case
|
|
7807
|
+
case import_utils50.AST_NODE_TYPES.TemplateLiteral:
|
|
7482
7808
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7483
7809
|
break;
|
|
7484
|
-
case
|
|
7810
|
+
case import_utils50.AST_NODE_TYPES.ArrayExpression:
|
|
7485
7811
|
for (const element of node.elements) {
|
|
7486
|
-
if (element !== null && element.type !==
|
|
7812
|
+
if (element !== null && element.type !== import_utils50.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
7487
7813
|
}
|
|
7488
7814
|
break;
|
|
7489
|
-
case
|
|
7815
|
+
case import_utils50.AST_NODE_TYPES.ObjectExpression:
|
|
7490
7816
|
for (const property of node.properties) {
|
|
7491
|
-
if (property.type ===
|
|
7817
|
+
if (property.type === import_utils50.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
7492
7818
|
}
|
|
7493
7819
|
break;
|
|
7494
|
-
case
|
|
7820
|
+
case import_utils50.AST_NODE_TYPES.ConditionalExpression:
|
|
7495
7821
|
checkClassNode(node.consequent);
|
|
7496
7822
|
checkClassNode(node.alternate);
|
|
7497
7823
|
break;
|
|
7498
|
-
case
|
|
7824
|
+
case import_utils50.AST_NODE_TYPES.LogicalExpression:
|
|
7499
7825
|
checkClassNode(node.right);
|
|
7500
7826
|
break;
|
|
7501
7827
|
default:
|
|
@@ -7503,29 +7829,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7503
7829
|
}
|
|
7504
7830
|
};
|
|
7505
7831
|
const checkColorValueNode = (node) => {
|
|
7506
|
-
if (node.type ===
|
|
7507
|
-
|
|
7832
|
+
if (node.type === import_utils50.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
7833
|
+
report(node, "inlineColor", { value: node.value });
|
|
7508
7834
|
}
|
|
7509
7835
|
};
|
|
7510
7836
|
return {
|
|
7511
7837
|
"JSXAttribute[name.name='className']"(node) {
|
|
7512
7838
|
if (node.value === null) return;
|
|
7513
|
-
if (node.value.type ===
|
|
7514
|
-
else if (node.value.type ===
|
|
7515
|
-
if (node.value.expression.type !==
|
|
7839
|
+
if (node.value.type === import_utils50.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
7840
|
+
else if (node.value.type === import_utils50.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
7841
|
+
if (node.value.expression.type !== import_utils50.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
7516
7842
|
checkClassNode(node.value.expression);
|
|
7517
7843
|
}
|
|
7518
7844
|
}
|
|
7519
7845
|
},
|
|
7520
7846
|
CallExpression(node) {
|
|
7521
|
-
if (node.callee.type ===
|
|
7847
|
+
if (node.callee.type === import_utils50.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils50.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
7848
|
+
importsEmailOrPdfRenderer = true;
|
|
7849
|
+
}
|
|
7850
|
+
if (node.callee.type === import_utils50.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7522
7851
|
for (const arg of node.arguments) {
|
|
7523
|
-
if (arg.type !==
|
|
7852
|
+
if (arg.type !== import_utils50.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
7524
7853
|
}
|
|
7525
7854
|
}
|
|
7526
7855
|
},
|
|
7527
7856
|
VariableDeclarator(node) {
|
|
7528
|
-
if (node.id.type ===
|
|
7857
|
+
if (node.id.type === import_utils50.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
7529
7858
|
checkClassNode(node.init);
|
|
7530
7859
|
}
|
|
7531
7860
|
},
|
|
@@ -7533,13 +7862,11 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7533
7862
|
const name = propName(node.key);
|
|
7534
7863
|
if (name !== null && CLASS_NAME_RE.test(name)) checkClassNode(node.value);
|
|
7535
7864
|
},
|
|
7536
|
-
// SVG
|
|
7537
|
-
// Neutral drawing literals and anything inside an SVG defs container are
|
|
7538
|
-
// structural, not UI tokens, so they never fire.
|
|
7865
|
+
// SVG artwork colors are exempt; component presentation colors still report.
|
|
7539
7866
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
7540
|
-
if (node.value?.type !==
|
|
7867
|
+
if (node.value?.type !== import_utils50.AST_NODE_TYPES.Literal) return;
|
|
7541
7868
|
const owner = node.parent.name;
|
|
7542
|
-
if (owner.type ===
|
|
7869
|
+
if (owner.type === import_utils50.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
7543
7870
|
return;
|
|
7544
7871
|
}
|
|
7545
7872
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -7551,13 +7878,22 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7551
7878
|
"JSXAttribute[name.name='style'] ObjectExpression > Property"(node) {
|
|
7552
7879
|
const name = propName(node.key);
|
|
7553
7880
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
7881
|
+
},
|
|
7882
|
+
ImportExpression(node) {
|
|
7883
|
+
if (node.source.type === import_utils50.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
7884
|
+
importsEmailOrPdfRenderer = true;
|
|
7885
|
+
}
|
|
7886
|
+
},
|
|
7887
|
+
"Program:exit"() {
|
|
7888
|
+
if (importsEmailOrPdfRenderer) return;
|
|
7889
|
+
for (const descriptor of pendingReports) context.report(descriptor);
|
|
7554
7890
|
}
|
|
7555
7891
|
};
|
|
7556
7892
|
}
|
|
7557
7893
|
});
|
|
7558
7894
|
|
|
7559
7895
|
// src/rules/prefer-server-actions.ts
|
|
7560
|
-
var
|
|
7896
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7561
7897
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
7562
7898
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
7563
7899
|
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\/)/;
|
|
@@ -7618,6 +7954,22 @@ function isMutationMethod(node, context) {
|
|
|
7618
7954
|
}
|
|
7619
7955
|
return false;
|
|
7620
7956
|
}
|
|
7957
|
+
function isFunctionArgument(node, context) {
|
|
7958
|
+
const resolved = resolveNode(node, context);
|
|
7959
|
+
if (resolved?.type === "ArrowFunctionExpression" || resolved?.type === "FunctionExpression") {
|
|
7960
|
+
return true;
|
|
7961
|
+
}
|
|
7962
|
+
if (node.type !== "Identifier") return false;
|
|
7963
|
+
let scope = getScope(context, node);
|
|
7964
|
+
while (scope) {
|
|
7965
|
+
const variable = scope.set.get(node.name);
|
|
7966
|
+
if (variable?.defs.some((definition) => definition.type === "FunctionName")) {
|
|
7967
|
+
return true;
|
|
7968
|
+
}
|
|
7969
|
+
scope = scope.upper;
|
|
7970
|
+
}
|
|
7971
|
+
return false;
|
|
7972
|
+
}
|
|
7621
7973
|
function getPropertyNode(objNode, propName2) {
|
|
7622
7974
|
if (!objNode || objNode.type !== "ObjectExpression") return null;
|
|
7623
7975
|
for (const prop of objNode.properties) {
|
|
@@ -7655,13 +8007,10 @@ var prefer_server_actions_default = createRule({
|
|
|
7655
8007
|
if (SKIP_FILE_REGEX.test(filename)) {
|
|
7656
8008
|
return {};
|
|
7657
8009
|
}
|
|
7658
|
-
|
|
8010
|
+
const isNonReactFramework = context.sourceCode.ast.body.some(
|
|
8011
|
+
(node) => node.type === "ImportDeclaration" && typeof node.source.value === "string" && NON_REACT_FRAMEWORK_RE.test(node.source.value)
|
|
8012
|
+
);
|
|
7659
8013
|
return {
|
|
7660
|
-
ImportDeclaration(node) {
|
|
7661
|
-
if (typeof node.source.value === "string" && NON_REACT_FRAMEWORK_RE.test(node.source.value)) {
|
|
7662
|
-
isNonReactFramework = true;
|
|
7663
|
-
}
|
|
7664
|
-
},
|
|
7665
8014
|
CallExpression(node) {
|
|
7666
8015
|
if (isNonReactFramework) return;
|
|
7667
8016
|
let isMutation = false;
|
|
@@ -7682,7 +8031,7 @@ var prefer_server_actions_default = createRule({
|
|
|
7682
8031
|
if (AXIOS_MUTATION_METHODS.has(methodName)) {
|
|
7683
8032
|
const urlArg = node.arguments[0];
|
|
7684
8033
|
const hasHandlerArg = node.arguments.some(
|
|
7685
|
-
(arg) => arg.type
|
|
8034
|
+
(arg) => arg.type !== "SpreadElement" && isFunctionArgument(arg, context)
|
|
7686
8035
|
);
|
|
7687
8036
|
if (urlArg && urlArg.type !== "SpreadElement" && !hasHandlerArg && isApiUrl(urlArg, context)) {
|
|
7688
8037
|
isMutation = true;
|
|
@@ -7709,8 +8058,33 @@ var prefer_server_actions_default = createRule({
|
|
|
7709
8058
|
}
|
|
7710
8059
|
});
|
|
7711
8060
|
|
|
8061
|
+
// src/rules/prefer-single-sentence-comment.ts
|
|
8062
|
+
var prefer_single_sentence_comment_default = createRule({
|
|
8063
|
+
name: "prefer-single-sentence-comment",
|
|
8064
|
+
meta: {
|
|
8065
|
+
type: "suggestion",
|
|
8066
|
+
docs: { description: "Prefer one sentence and self-documenting code over a two-sentence comment." },
|
|
8067
|
+
schema: [],
|
|
8068
|
+
messages: {
|
|
8069
|
+
preferOneSentence: "Two-sentence comment \u2014 prefer one sentence and self-documenting code."
|
|
8070
|
+
}
|
|
8071
|
+
},
|
|
8072
|
+
defaultOptions: [],
|
|
8073
|
+
create(context) {
|
|
8074
|
+
return {
|
|
8075
|
+
Program() {
|
|
8076
|
+
for (const group of proseGroups(context.filename, context.sourceCode)) {
|
|
8077
|
+
if (!group.hasTypedTags && sentenceUnits(group.text) === 2) {
|
|
8078
|
+
context.report({ node: group.comment, messageId: "preferOneSentence" });
|
|
8079
|
+
}
|
|
8080
|
+
}
|
|
8081
|
+
}
|
|
8082
|
+
};
|
|
8083
|
+
}
|
|
8084
|
+
});
|
|
8085
|
+
|
|
7712
8086
|
// src/rules/prefer-string-literal-union.ts
|
|
7713
|
-
var
|
|
8087
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7714
8088
|
var ts2 = __toESM(require("typescript"), 1);
|
|
7715
8089
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
7716
8090
|
"status",
|
|
@@ -7753,19 +8127,19 @@ function isChoiceLikeName(name) {
|
|
|
7753
8127
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
7754
8128
|
}
|
|
7755
8129
|
function keyName(key) {
|
|
7756
|
-
if (key.type ===
|
|
8130
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7757
8131
|
return key.name;
|
|
7758
8132
|
}
|
|
7759
|
-
if (key.type ===
|
|
8133
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
7760
8134
|
return key.value;
|
|
7761
8135
|
}
|
|
7762
8136
|
return null;
|
|
7763
8137
|
}
|
|
7764
8138
|
function isStringLiteralMember(t) {
|
|
7765
|
-
return t.type ===
|
|
8139
|
+
return t.type === import_utils52.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils52.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
7766
8140
|
}
|
|
7767
8141
|
function isStringLiteralUnion(node) {
|
|
7768
|
-
if (node?.type !==
|
|
8142
|
+
if (node?.type !== import_utils52.AST_NODE_TYPES.TSUnionType) {
|
|
7769
8143
|
return false;
|
|
7770
8144
|
}
|
|
7771
8145
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -7794,12 +8168,12 @@ function bindingSourceExpression(decl) {
|
|
|
7794
8168
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
7795
8169
|
}
|
|
7796
8170
|
function refKey(node) {
|
|
7797
|
-
if (node.type ===
|
|
8171
|
+
if (node.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7798
8172
|
return node.name;
|
|
7799
8173
|
}
|
|
7800
|
-
if (node.type ===
|
|
8174
|
+
if (node.type === import_utils52.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
7801
8175
|
const inner = refKey(node.object);
|
|
7802
|
-
if (inner === null || node.property.type !==
|
|
8176
|
+
if (inner === null || node.property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7803
8177
|
return null;
|
|
7804
8178
|
}
|
|
7805
8179
|
return `${inner}.${node.property.name}`;
|
|
@@ -7807,7 +8181,7 @@ function refKey(node) {
|
|
|
7807
8181
|
return null;
|
|
7808
8182
|
}
|
|
7809
8183
|
function strLiteral(node) {
|
|
7810
|
-
if (node.type ===
|
|
8184
|
+
if (node.type === import_utils52.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
7811
8185
|
return node.value;
|
|
7812
8186
|
}
|
|
7813
8187
|
return null;
|
|
@@ -7848,7 +8222,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7848
8222
|
);
|
|
7849
8223
|
let services;
|
|
7850
8224
|
try {
|
|
7851
|
-
services =
|
|
8225
|
+
services = import_utils52.ESLintUtils.getParserServices(context);
|
|
7852
8226
|
} catch {
|
|
7853
8227
|
services = null;
|
|
7854
8228
|
}
|
|
@@ -7960,7 +8334,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7960
8334
|
containersWithUnion.add(container);
|
|
7961
8335
|
return;
|
|
7962
8336
|
}
|
|
7963
|
-
if (typeNode?.type !==
|
|
8337
|
+
if (typeNode?.type !== import_utils52.AST_NODE_TYPES.TSStringKeyword) {
|
|
7964
8338
|
return;
|
|
7965
8339
|
}
|
|
7966
8340
|
const name = keyName(key);
|
|
@@ -8048,10 +8422,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8048
8422
|
}
|
|
8049
8423
|
};
|
|
8050
8424
|
function refKeyText(node) {
|
|
8051
|
-
if (node.type ===
|
|
8425
|
+
if (node.type === import_utils52.AST_NODE_TYPES.BinaryExpression) {
|
|
8052
8426
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8053
8427
|
}
|
|
8054
|
-
if (node.type ===
|
|
8428
|
+
if (node.type === import_utils52.AST_NODE_TYPES.SwitchStatement) {
|
|
8055
8429
|
return refKey(node.discriminant) ?? "value";
|
|
8056
8430
|
}
|
|
8057
8431
|
return "value";
|
|
@@ -8060,7 +8434,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8060
8434
|
});
|
|
8061
8435
|
|
|
8062
8436
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8063
|
-
var
|
|
8437
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
8064
8438
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8065
8439
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8066
8440
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8069,11 +8443,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8069
8443
|
var MIN_RUN_LENGTH = 2;
|
|
8070
8444
|
function literalText(node, getText) {
|
|
8071
8445
|
switch (node.type) {
|
|
8072
|
-
case
|
|
8446
|
+
case import_utils53.AST_NODE_TYPES.Literal:
|
|
8073
8447
|
return "regex" in node ? null : getText(node);
|
|
8074
|
-
case
|
|
8448
|
+
case import_utils53.AST_NODE_TYPES.TemplateLiteral:
|
|
8075
8449
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8076
|
-
case
|
|
8450
|
+
case import_utils53.AST_NODE_TYPES.UnaryExpression:
|
|
8077
8451
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8078
8452
|
default:
|
|
8079
8453
|
return null;
|
|
@@ -8081,15 +8455,15 @@ function literalText(node, getText) {
|
|
|
8081
8455
|
}
|
|
8082
8456
|
function isPureReceiver(node) {
|
|
8083
8457
|
switch (node.type) {
|
|
8084
|
-
case
|
|
8085
|
-
case
|
|
8458
|
+
case import_utils53.AST_NODE_TYPES.Identifier:
|
|
8459
|
+
case import_utils53.AST_NODE_TYPES.ThisExpression:
|
|
8086
8460
|
return true;
|
|
8087
|
-
case
|
|
8461
|
+
case import_utils53.AST_NODE_TYPES.MemberExpression:
|
|
8088
8462
|
if (node.optional) {
|
|
8089
8463
|
return false;
|
|
8090
8464
|
}
|
|
8091
8465
|
if (node.computed) {
|
|
8092
|
-
return node.property.type ===
|
|
8466
|
+
return node.property.type === import_utils53.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8093
8467
|
}
|
|
8094
8468
|
return isPureReceiver(node.object);
|
|
8095
8469
|
default:
|
|
@@ -8097,7 +8471,7 @@ function isPureReceiver(node) {
|
|
|
8097
8471
|
}
|
|
8098
8472
|
}
|
|
8099
8473
|
function literalIndex(node) {
|
|
8100
|
-
if (node.type !==
|
|
8474
|
+
if (node.type !== import_utils53.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8101
8475
|
return null;
|
|
8102
8476
|
}
|
|
8103
8477
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8123,24 +8497,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8123
8497
|
}
|
|
8124
8498
|
const { sourceCode } = context;
|
|
8125
8499
|
function parseAssertion(statement) {
|
|
8126
|
-
if (statement.type !==
|
|
8500
|
+
if (statement.type !== import_utils53.AST_NODE_TYPES.ExpressionStatement) {
|
|
8127
8501
|
return null;
|
|
8128
8502
|
}
|
|
8129
8503
|
const call = statement.expression;
|
|
8130
|
-
if (call.type !==
|
|
8504
|
+
if (call.type !== import_utils53.AST_NODE_TYPES.CallExpression) {
|
|
8131
8505
|
return null;
|
|
8132
8506
|
}
|
|
8133
8507
|
const callee = call.callee;
|
|
8134
|
-
if (callee.type !==
|
|
8508
|
+
if (callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
8135
8509
|
return null;
|
|
8136
8510
|
}
|
|
8137
8511
|
const matcher = callee.property.name;
|
|
8138
8512
|
const expectCall = callee.object;
|
|
8139
|
-
if (expectCall.type !==
|
|
8513
|
+
if (expectCall.type !== import_utils53.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils53.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8140
8514
|
return null;
|
|
8141
8515
|
}
|
|
8142
8516
|
const actual = expectCall.arguments[0];
|
|
8143
|
-
if (actual === void 0 || actual.type !==
|
|
8517
|
+
if (actual === void 0 || actual.type !== import_utils53.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8144
8518
|
return null;
|
|
8145
8519
|
}
|
|
8146
8520
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8154,7 +8528,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8154
8528
|
}
|
|
8155
8529
|
key = { kind: "index", index };
|
|
8156
8530
|
} else {
|
|
8157
|
-
if (actual.property.type !==
|
|
8531
|
+
if (actual.property.type !== import_utils53.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8158
8532
|
return null;
|
|
8159
8533
|
}
|
|
8160
8534
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8166,7 +8540,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8166
8540
|
return null;
|
|
8167
8541
|
}
|
|
8168
8542
|
const expected = call.arguments[0];
|
|
8169
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8543
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils53.AST_NODE_TYPES.SpreadElement) {
|
|
8170
8544
|
return null;
|
|
8171
8545
|
}
|
|
8172
8546
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8242,7 +8616,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8242
8616
|
}
|
|
8243
8617
|
});
|
|
8244
8618
|
}
|
|
8245
|
-
function checkBody(
|
|
8619
|
+
function checkBody(body2) {
|
|
8246
8620
|
let run = [];
|
|
8247
8621
|
const flush = () => {
|
|
8248
8622
|
const first = run[0];
|
|
@@ -8255,7 +8629,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8255
8629
|
}
|
|
8256
8630
|
run = [];
|
|
8257
8631
|
};
|
|
8258
|
-
for (const statement of
|
|
8632
|
+
for (const statement of body2) {
|
|
8259
8633
|
const assertion = parseAssertion(statement);
|
|
8260
8634
|
const previous = run.at(-1);
|
|
8261
8635
|
if (assertion !== null && previous !== void 0 && previous.key.kind === assertion.key.kind && sourceCode.getText(previous.receiver) === sourceCode.getText(assertion.receiver)) {
|
|
@@ -8281,7 +8655,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8281
8655
|
});
|
|
8282
8656
|
|
|
8283
8657
|
// src/rules/prefer-zod-enum.ts
|
|
8284
|
-
var
|
|
8658
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
8285
8659
|
var prefer_zod_enum_default = createRule({
|
|
8286
8660
|
name: "prefer-zod-enum",
|
|
8287
8661
|
meta: {
|
|
@@ -8301,33 +8675,39 @@ var prefer_zod_enum_default = createRule({
|
|
|
8301
8675
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8302
8676
|
function enumValues(node) {
|
|
8303
8677
|
const callee = node.callee;
|
|
8304
|
-
if (callee.type !==
|
|
8678
|
+
if (callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils54.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils54.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8305
8679
|
return null;
|
|
8306
8680
|
}
|
|
8307
8681
|
const argument = node.arguments[0];
|
|
8308
|
-
if (argument === void 0 || argument.type !==
|
|
8682
|
+
if (argument === void 0 || argument.type !== import_utils54.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
8309
8683
|
return null;
|
|
8310
8684
|
}
|
|
8311
8685
|
const values = [];
|
|
8686
|
+
let canFix = true;
|
|
8312
8687
|
for (const element of argument.elements) {
|
|
8313
|
-
if (element ===
|
|
8688
|
+
if (element?.type === import_utils54.AST_NODE_TYPES.SpreadElement) {
|
|
8689
|
+
canFix = false;
|
|
8690
|
+
continue;
|
|
8691
|
+
}
|
|
8692
|
+
if (element === null || element.type !== import_utils54.AST_NODE_TYPES.CallExpression || element.callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils54.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils54.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
8314
8693
|
return null;
|
|
8315
8694
|
}
|
|
8316
8695
|
const value = element.arguments[0];
|
|
8317
|
-
if (value === void 0 || value.type !==
|
|
8318
|
-
|
|
8696
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== import_utils54.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
8697
|
+
canFix = false;
|
|
8698
|
+
continue;
|
|
8319
8699
|
}
|
|
8320
8700
|
values.push(value);
|
|
8321
8701
|
}
|
|
8322
|
-
return values;
|
|
8702
|
+
return canFix ? values : void 0;
|
|
8323
8703
|
}
|
|
8324
8704
|
function buildFix(node, values) {
|
|
8325
8705
|
const argument = node.arguments[0];
|
|
8326
|
-
if (argument === void 0 || argument.type !==
|
|
8706
|
+
if (argument === void 0 || argument.type !== import_utils54.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8327
8707
|
return void 0;
|
|
8328
8708
|
}
|
|
8329
8709
|
const callee = node.callee;
|
|
8330
|
-
if (callee.type !==
|
|
8710
|
+
if (callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8331
8711
|
return void 0;
|
|
8332
8712
|
}
|
|
8333
8713
|
return (fixer) => [
|
|
@@ -8344,7 +8724,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8344
8724
|
return;
|
|
8345
8725
|
}
|
|
8346
8726
|
for (const specifier of node.specifiers) {
|
|
8347
|
-
if (specifier.type ===
|
|
8727
|
+
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") {
|
|
8348
8728
|
zodNamespaces.add(specifier.local.name);
|
|
8349
8729
|
}
|
|
8350
8730
|
}
|
|
@@ -8354,7 +8734,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8354
8734
|
if (values === null) {
|
|
8355
8735
|
return;
|
|
8356
8736
|
}
|
|
8357
|
-
const fix = buildFix(node, values);
|
|
8737
|
+
const fix = values === void 0 ? void 0 : buildFix(node, values);
|
|
8358
8738
|
context.report({
|
|
8359
8739
|
node,
|
|
8360
8740
|
messageId: "preferEnum",
|
|
@@ -8366,7 +8746,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8366
8746
|
});
|
|
8367
8747
|
|
|
8368
8748
|
// src/rules/prefer-zod-infer.ts
|
|
8369
|
-
var
|
|
8749
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8370
8750
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8371
8751
|
"describe",
|
|
8372
8752
|
"refine",
|
|
@@ -8403,44 +8783,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8403
8783
|
"Schema"
|
|
8404
8784
|
]);
|
|
8405
8785
|
var LEAF_NODE_TYPES = {
|
|
8406
|
-
string: [
|
|
8407
|
-
email: [
|
|
8408
|
-
url: [
|
|
8409
|
-
uuid: [
|
|
8410
|
-
ulid: [
|
|
8411
|
-
cuid: [
|
|
8412
|
-
cuid2: [
|
|
8413
|
-
nanoid: [
|
|
8414
|
-
iso: [
|
|
8415
|
-
number: [
|
|
8416
|
-
int: [
|
|
8417
|
-
float32: [
|
|
8418
|
-
float64: [
|
|
8419
|
-
boolean: [
|
|
8420
|
-
bigint: [
|
|
8421
|
-
symbol: [
|
|
8422
|
-
any: [
|
|
8423
|
-
unknown: [
|
|
8424
|
-
never: [
|
|
8425
|
-
void: [
|
|
8426
|
-
null: [
|
|
8427
|
-
undefined: [
|
|
8428
|
-
literal: [
|
|
8429
|
-
date: [
|
|
8430
|
-
array: [
|
|
8431
|
-
tuple: [
|
|
8432
|
-
object: [
|
|
8433
|
-
strictObject: [
|
|
8434
|
-
looseObject: [
|
|
8435
|
-
record: [
|
|
8436
|
-
map: [
|
|
8437
|
-
set: [
|
|
8438
|
-
promise: [
|
|
8439
|
-
enum: [
|
|
8440
|
-
nativeEnum: [
|
|
8441
|
-
union: [
|
|
8442
|
-
discriminatedUnion: [
|
|
8443
|
-
intersection: [
|
|
8786
|
+
string: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8787
|
+
email: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8788
|
+
url: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8789
|
+
uuid: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8790
|
+
ulid: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8791
|
+
cuid: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8792
|
+
cuid2: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8793
|
+
nanoid: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8794
|
+
iso: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8795
|
+
number: [import_utils55.AST_NODE_TYPES.TSNumberKeyword],
|
|
8796
|
+
int: [import_utils55.AST_NODE_TYPES.TSNumberKeyword],
|
|
8797
|
+
float32: [import_utils55.AST_NODE_TYPES.TSNumberKeyword],
|
|
8798
|
+
float64: [import_utils55.AST_NODE_TYPES.TSNumberKeyword],
|
|
8799
|
+
boolean: [import_utils55.AST_NODE_TYPES.TSBooleanKeyword],
|
|
8800
|
+
bigint: [import_utils55.AST_NODE_TYPES.TSBigIntKeyword],
|
|
8801
|
+
symbol: [import_utils55.AST_NODE_TYPES.TSSymbolKeyword],
|
|
8802
|
+
any: [import_utils55.AST_NODE_TYPES.TSAnyKeyword],
|
|
8803
|
+
unknown: [import_utils55.AST_NODE_TYPES.TSUnknownKeyword],
|
|
8804
|
+
never: [import_utils55.AST_NODE_TYPES.TSNeverKeyword],
|
|
8805
|
+
void: [import_utils55.AST_NODE_TYPES.TSVoidKeyword],
|
|
8806
|
+
null: [import_utils55.AST_NODE_TYPES.TSNullKeyword],
|
|
8807
|
+
undefined: [import_utils55.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
8808
|
+
literal: [import_utils55.AST_NODE_TYPES.TSLiteralType],
|
|
8809
|
+
date: [import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8810
|
+
array: [import_utils55.AST_NODE_TYPES.TSArrayType, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8811
|
+
tuple: [import_utils55.AST_NODE_TYPES.TSTupleType],
|
|
8812
|
+
object: [import_utils55.AST_NODE_TYPES.TSTypeLiteral, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8813
|
+
strictObject: [import_utils55.AST_NODE_TYPES.TSTypeLiteral, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8814
|
+
looseObject: [import_utils55.AST_NODE_TYPES.TSTypeLiteral, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8815
|
+
record: [import_utils55.AST_NODE_TYPES.TSTypeReference, import_utils55.AST_NODE_TYPES.TSTypeLiteral],
|
|
8816
|
+
map: [import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8817
|
+
set: [import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8818
|
+
promise: [import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8819
|
+
enum: [import_utils55.AST_NODE_TYPES.TSUnionType, import_utils55.AST_NODE_TYPES.TSTypeReference, import_utils55.AST_NODE_TYPES.TSLiteralType],
|
|
8820
|
+
nativeEnum: [import_utils55.AST_NODE_TYPES.TSUnionType, import_utils55.AST_NODE_TYPES.TSTypeReference, import_utils55.AST_NODE_TYPES.TSLiteralType],
|
|
8821
|
+
union: [import_utils55.AST_NODE_TYPES.TSUnionType, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8822
|
+
discriminatedUnion: [import_utils55.AST_NODE_TYPES.TSUnionType, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8823
|
+
intersection: [import_utils55.AST_NODE_TYPES.TSIntersectionType, import_utils55.AST_NODE_TYPES.TSTypeReference]
|
|
8444
8824
|
};
|
|
8445
8825
|
function normalizeSchemaName(name) {
|
|
8446
8826
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8449,20 +8829,20 @@ function normalizeTypeName(name) {
|
|
|
8449
8829
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8450
8830
|
}
|
|
8451
8831
|
function unwrapNullish(annotation) {
|
|
8452
|
-
if (annotation.type !==
|
|
8832
|
+
if (annotation.type !== import_utils55.AST_NODE_TYPES.TSUnionType) {
|
|
8453
8833
|
return {
|
|
8454
8834
|
core: annotation,
|
|
8455
|
-
nullable: annotation.type ===
|
|
8835
|
+
nullable: annotation.type === import_utils55.AST_NODE_TYPES.TSNullKeyword
|
|
8456
8836
|
};
|
|
8457
8837
|
}
|
|
8458
8838
|
const rest = [];
|
|
8459
8839
|
let nullable = false;
|
|
8460
8840
|
for (const member of annotation.types) {
|
|
8461
|
-
if (member.type ===
|
|
8841
|
+
if (member.type === import_utils55.AST_NODE_TYPES.TSNullKeyword) {
|
|
8462
8842
|
nullable = true;
|
|
8463
8843
|
continue;
|
|
8464
8844
|
}
|
|
8465
|
-
if (member.type ===
|
|
8845
|
+
if (member.type === import_utils55.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
8466
8846
|
continue;
|
|
8467
8847
|
}
|
|
8468
8848
|
rest.push(member);
|
|
@@ -8527,14 +8907,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8527
8907
|
function zodCallChain(node) {
|
|
8528
8908
|
const chain = [];
|
|
8529
8909
|
let current = node;
|
|
8530
|
-
while (current.type ===
|
|
8910
|
+
while (current.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
8531
8911
|
const callee = current.callee;
|
|
8532
|
-
if (callee.type !==
|
|
8912
|
+
if (callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8533
8913
|
return null;
|
|
8534
8914
|
}
|
|
8535
8915
|
chain.push(current);
|
|
8536
8916
|
const receiver = callee.object;
|
|
8537
|
-
if (receiver.type ===
|
|
8917
|
+
if (receiver.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8538
8918
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
8539
8919
|
}
|
|
8540
8920
|
current = receiver;
|
|
@@ -8543,19 +8923,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
8543
8923
|
}
|
|
8544
8924
|
function methodName(call) {
|
|
8545
8925
|
const callee = call.callee;
|
|
8546
|
-
return callee.type ===
|
|
8926
|
+
return callee.type === import_utils55.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils55.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
8547
8927
|
}
|
|
8548
8928
|
function schemaField(node) {
|
|
8549
8929
|
const modifiers = [];
|
|
8550
8930
|
let current = node;
|
|
8551
8931
|
let leaf = null;
|
|
8552
|
-
while (current.type ===
|
|
8932
|
+
while (current.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
8553
8933
|
const callee = current.callee;
|
|
8554
|
-
if (callee.type !==
|
|
8934
|
+
if (callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8555
8935
|
break;
|
|
8556
8936
|
}
|
|
8557
8937
|
const receiver = callee.object;
|
|
8558
|
-
if (receiver.type ===
|
|
8938
|
+
if (receiver.type === import_utils55.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
8559
8939
|
leaf = callee.property.name;
|
|
8560
8940
|
break;
|
|
8561
8941
|
}
|
|
@@ -8586,16 +8966,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8586
8966
|
return null;
|
|
8587
8967
|
}
|
|
8588
8968
|
const shape = base.arguments[0];
|
|
8589
|
-
if (shape === void 0 || shape.type !==
|
|
8969
|
+
if (shape === void 0 || shape.type !== import_utils55.AST_NODE_TYPES.ObjectExpression) {
|
|
8590
8970
|
return null;
|
|
8591
8971
|
}
|
|
8592
8972
|
const fields = /* @__PURE__ */ new Map();
|
|
8593
8973
|
for (const property of shape.properties) {
|
|
8594
|
-
if (property.type !==
|
|
8974
|
+
if (property.type !== import_utils55.AST_NODE_TYPES.Property || property.computed) {
|
|
8595
8975
|
return null;
|
|
8596
8976
|
}
|
|
8597
8977
|
const { key } = property;
|
|
8598
|
-
const name = key.type ===
|
|
8978
|
+
const name = key.type === import_utils55.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils55.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8599
8979
|
if (name === null) {
|
|
8600
8980
|
return null;
|
|
8601
8981
|
}
|
|
@@ -8606,11 +8986,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8606
8986
|
function typeMembers(members) {
|
|
8607
8987
|
const result = /* @__PURE__ */ new Map();
|
|
8608
8988
|
for (const member of members) {
|
|
8609
|
-
if (member.type !==
|
|
8989
|
+
if (member.type !== import_utils55.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
8610
8990
|
return null;
|
|
8611
8991
|
}
|
|
8612
8992
|
const { key } = member;
|
|
8613
|
-
const name = key.type ===
|
|
8993
|
+
const name = key.type === import_utils55.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils55.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8614
8994
|
if (name === null) {
|
|
8615
8995
|
return null;
|
|
8616
8996
|
}
|
|
@@ -8624,8 +9004,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
8624
9004
|
return result.size === 0 ? null : result;
|
|
8625
9005
|
}
|
|
8626
9006
|
function collectConstrainedNames(node) {
|
|
8627
|
-
if (node.type ===
|
|
8628
|
-
if (node.typeName.type ===
|
|
9007
|
+
if (node.type === import_utils55.AST_NODE_TYPES.TSTypeReference) {
|
|
9008
|
+
if (node.typeName.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8629
9009
|
constrainedTypeNames.add(node.typeName.name);
|
|
8630
9010
|
}
|
|
8631
9011
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -8633,11 +9013,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8633
9013
|
}
|
|
8634
9014
|
return;
|
|
8635
9015
|
}
|
|
8636
|
-
if (node.type ===
|
|
9016
|
+
if (node.type === import_utils55.AST_NODE_TYPES.TSArrayType) {
|
|
8637
9017
|
collectConstrainedNames(node.elementType);
|
|
8638
9018
|
return;
|
|
8639
9019
|
}
|
|
8640
|
-
if (node.type ===
|
|
9020
|
+
if (node.type === import_utils55.AST_NODE_TYPES.TSUnionType || node.type === import_utils55.AST_NODE_TYPES.TSIntersectionType) {
|
|
8641
9021
|
for (const member of node.types) {
|
|
8642
9022
|
collectConstrainedNames(member);
|
|
8643
9023
|
}
|
|
@@ -8681,13 +9061,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
8681
9061
|
return;
|
|
8682
9062
|
}
|
|
8683
9063
|
for (const specifier of node.specifiers) {
|
|
8684
|
-
if (specifier.type ===
|
|
9064
|
+
if (specifier.type === import_utils55.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils55.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils55.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils55.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8685
9065
|
zodNamespaces.add(specifier.local.name);
|
|
8686
9066
|
}
|
|
8687
9067
|
}
|
|
8688
9068
|
},
|
|
8689
9069
|
VariableDeclarator(node) {
|
|
8690
|
-
if (node.id.type !==
|
|
9070
|
+
if (node.id.type !== import_utils55.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
8691
9071
|
return;
|
|
8692
9072
|
}
|
|
8693
9073
|
const fields = schemaFields(node.init);
|
|
@@ -8695,16 +9075,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8695
9075
|
schemas.push({ name: node.id.name, fields });
|
|
8696
9076
|
}
|
|
8697
9077
|
},
|
|
8698
|
-
/**
|
|
9078
|
+
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
8699
9079
|
"MemberExpression[computed=false]"(node) {
|
|
8700
|
-
if (node.object.type ===
|
|
9080
|
+
if (node.object.type === import_utils55.AST_NODE_TYPES.Identifier && node.property.type === import_utils55.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
8701
9081
|
reshapedSchemaNames.add(node.object.name);
|
|
8702
9082
|
}
|
|
8703
9083
|
},
|
|
8704
|
-
/**
|
|
9084
|
+
/** Records every type argument carried by a Zod constraint. */
|
|
8705
9085
|
TSTypeReference(node) {
|
|
8706
9086
|
const { typeName } = node;
|
|
8707
|
-
const referenced = typeName.type ===
|
|
9087
|
+
const referenced = typeName.type === import_utils55.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils55.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils55.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
8708
9088
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
8709
9089
|
return;
|
|
8710
9090
|
}
|
|
@@ -8722,7 +9102,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
8722
9102
|
}
|
|
8723
9103
|
},
|
|
8724
9104
|
TSTypeAliasDeclaration(node) {
|
|
8725
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9105
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils55.AST_NODE_TYPES.TSTypeLiteral) {
|
|
8726
9106
|
return;
|
|
8727
9107
|
}
|
|
8728
9108
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -8767,10 +9147,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
8767
9147
|
});
|
|
8768
9148
|
|
|
8769
9149
|
// src/rules/require-assert-never.ts
|
|
8770
|
-
var
|
|
9150
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8771
9151
|
var isRuntimeHandlingStatement = (statement) => {
|
|
8772
|
-
if (statement.type ===
|
|
8773
|
-
if (statement.type ===
|
|
9152
|
+
if (statement.type === import_utils56.AST_NODE_TYPES.EmptyStatement) return false;
|
|
9153
|
+
if (statement.type === import_utils56.AST_NODE_TYPES.BlockStatement) {
|
|
8774
9154
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
8775
9155
|
}
|
|
8776
9156
|
return true;
|
|
@@ -8786,7 +9166,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
8786
9166
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
8787
9167
|
}
|
|
8788
9168
|
const only = defaultCase.consequent[0];
|
|
8789
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9169
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils56.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
8790
9170
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
8791
9171
|
}
|
|
8792
9172
|
return false;
|
|
@@ -8826,7 +9206,7 @@ var require_assert_never_default = createRule({
|
|
|
8826
9206
|
});
|
|
8827
9207
|
|
|
8828
9208
|
// src/rules/require-fetch-timeout.ts
|
|
8829
|
-
var
|
|
9209
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8830
9210
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
8831
9211
|
"globalThis",
|
|
8832
9212
|
"window",
|
|
@@ -8842,14 +9222,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
8842
9222
|
return false;
|
|
8843
9223
|
}
|
|
8844
9224
|
function initProvablyLacksSignal(init) {
|
|
8845
|
-
if (init.type !==
|
|
9225
|
+
if (init.type !== import_utils57.AST_NODE_TYPES.ObjectExpression) {
|
|
8846
9226
|
return false;
|
|
8847
9227
|
}
|
|
8848
9228
|
for (const prop of init.properties) {
|
|
8849
|
-
if (prop.type ===
|
|
9229
|
+
if (prop.type === import_utils57.AST_NODE_TYPES.SpreadElement) {
|
|
8850
9230
|
return false;
|
|
8851
9231
|
}
|
|
8852
|
-
if (prop.key.type ===
|
|
9232
|
+
if (prop.key.type === import_utils57.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils57.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
8853
9233
|
return false;
|
|
8854
9234
|
}
|
|
8855
9235
|
if (prop.computed) {
|
|
@@ -8859,7 +9239,7 @@ function initProvablyLacksSignal(init) {
|
|
|
8859
9239
|
return true;
|
|
8860
9240
|
}
|
|
8861
9241
|
function isStringish(node) {
|
|
8862
|
-
return node.type ===
|
|
9242
|
+
return node.type === import_utils57.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils57.AST_NODE_TYPES.TemplateLiteral;
|
|
8863
9243
|
}
|
|
8864
9244
|
var require_fetch_timeout_default = createRule({
|
|
8865
9245
|
name: "require-fetch-timeout",
|
|
@@ -8896,14 +9276,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
8896
9276
|
}
|
|
8897
9277
|
function resolvesToGlobal(identifier) {
|
|
8898
9278
|
const scope = context.sourceCode.getScope(identifier);
|
|
8899
|
-
const variable =
|
|
9279
|
+
const variable = import_utils57.ASTUtils.findVariable(scope, identifier.name);
|
|
8900
9280
|
return variable === null || variable.defs.length === 0;
|
|
8901
9281
|
}
|
|
8902
9282
|
function isGlobalFetchCall2(callee) {
|
|
8903
|
-
if (callee.type ===
|
|
9283
|
+
if (callee.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8904
9284
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
8905
9285
|
}
|
|
8906
|
-
return callee.type ===
|
|
9286
|
+
return callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils57.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils57.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
8907
9287
|
}
|
|
8908
9288
|
return {
|
|
8909
9289
|
CallExpression(node) {
|
|
@@ -8923,7 +9303,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
8923
9303
|
});
|
|
8924
9304
|
|
|
8925
9305
|
// src/rules/require-interface-for-injected-service.ts
|
|
8926
|
-
var
|
|
9306
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8927
9307
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
8928
9308
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
8929
9309
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -8931,20 +9311,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
8931
9311
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
8932
9312
|
var ROUTER_FACTORY_NAME = "Router";
|
|
8933
9313
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
8934
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
8935
|
-
var qualifiedName = (name) => name.type ===
|
|
9314
|
+
var isExportedClass = (node) => node.parent.type === import_utils58.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils58.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
9315
|
+
var qualifiedName = (name) => name.type === import_utils58.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils58.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
8936
9316
|
var readTypeReference = (annotation) => {
|
|
8937
|
-
if (annotation === void 0 || annotation.type !==
|
|
9317
|
+
if (annotation === void 0 || annotation.type !== import_utils58.AST_NODE_TYPES.TSTypeReference) return null;
|
|
8938
9318
|
const { typeName } = annotation;
|
|
8939
|
-
const rightmost = typeName.type ===
|
|
9319
|
+
const rightmost = typeName.type === import_utils58.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils58.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
8940
9320
|
if (rightmost === null) return null;
|
|
8941
9321
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
8942
9322
|
};
|
|
8943
9323
|
var namedParameterCollaborator = (annotated) => {
|
|
8944
9324
|
let target = annotated;
|
|
8945
|
-
if (target.type ===
|
|
8946
|
-
if (target.type ===
|
|
8947
|
-
if (target.type !==
|
|
9325
|
+
if (target.type === import_utils58.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
9326
|
+
if (target.type === import_utils58.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9327
|
+
if (target.type !== import_utils58.AST_NODE_TYPES.Identifier) return null;
|
|
8948
9328
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
8949
9329
|
if (reference === null) return null;
|
|
8950
9330
|
return { name: target.name, ...reference };
|
|
@@ -8952,8 +9332,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
8952
9332
|
var propertySignatureTypes = (members) => {
|
|
8953
9333
|
const types = /* @__PURE__ */ new Map();
|
|
8954
9334
|
for (const member of members) {
|
|
8955
|
-
if (member.type !==
|
|
8956
|
-
if (member.computed || member.key.type !==
|
|
9335
|
+
if (member.type !== import_utils58.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
9336
|
+
if (member.computed || member.key.type !== import_utils58.AST_NODE_TYPES.Identifier) continue;
|
|
8957
9337
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
8958
9338
|
if (reference === null) continue;
|
|
8959
9339
|
types.set(member.key.name, reference);
|
|
@@ -8964,18 +9344,18 @@ var fileTypeIndex = (program) => {
|
|
|
8964
9344
|
const objects = /* @__PURE__ */ new Map();
|
|
8965
9345
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
8966
9346
|
for (const statement of program.body) {
|
|
8967
|
-
const declaration = statement.type ===
|
|
8968
|
-
if (declaration?.type ===
|
|
9347
|
+
const declaration = statement.type === import_utils58.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9348
|
+
if (declaration?.type === import_utils58.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
8969
9349
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
8970
9350
|
continue;
|
|
8971
9351
|
}
|
|
8972
|
-
if (declaration?.type !==
|
|
9352
|
+
if (declaration?.type !== import_utils58.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
8973
9353
|
const aliased = declaration.typeAnnotation;
|
|
8974
|
-
if (aliased.type ===
|
|
9354
|
+
if (aliased.type === import_utils58.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils58.AST_NODE_TYPES.TSConstructorType) {
|
|
8975
9355
|
functionAliases.add(declaration.id.name);
|
|
8976
9356
|
continue;
|
|
8977
9357
|
}
|
|
8978
|
-
const literals = aliased.type ===
|
|
9358
|
+
const literals = aliased.type === import_utils58.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils58.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils58.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
8979
9359
|
if (literals.length === 0) continue;
|
|
8980
9360
|
const merged = /* @__PURE__ */ new Map();
|
|
8981
9361
|
for (const literal of literals) {
|
|
@@ -8988,10 +9368,10 @@ var fileTypeIndex = (program) => {
|
|
|
8988
9368
|
return { objects, functionAliases };
|
|
8989
9369
|
};
|
|
8990
9370
|
var bagMemberTypes = (annotation, declared) => {
|
|
8991
|
-
if (annotation.type ===
|
|
9371
|
+
if (annotation.type === import_utils58.AST_NODE_TYPES.TSTypeLiteral) {
|
|
8992
9372
|
return propertySignatureTypes(annotation.members);
|
|
8993
9373
|
}
|
|
8994
|
-
if (annotation.type !==
|
|
9374
|
+
if (annotation.type !== import_utils58.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8995
9375
|
return null;
|
|
8996
9376
|
}
|
|
8997
9377
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9003,11 +9383,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9003
9383
|
if (members === null) return [];
|
|
9004
9384
|
const collaborators = [];
|
|
9005
9385
|
for (const property of pattern.properties) {
|
|
9006
|
-
if (property.type !==
|
|
9007
|
-
if (property.key.type !==
|
|
9386
|
+
if (property.type !== import_utils58.AST_NODE_TYPES.Property || property.computed) continue;
|
|
9387
|
+
if (property.key.type !== import_utils58.AST_NODE_TYPES.Identifier) continue;
|
|
9008
9388
|
const key = property.key.name;
|
|
9009
|
-
const bound = property.value.type ===
|
|
9010
|
-
if (bound.type !==
|
|
9389
|
+
const bound = property.value.type === import_utils58.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
9390
|
+
if (bound.type !== import_utils58.AST_NODE_TYPES.Identifier) continue;
|
|
9011
9391
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9012
9392
|
const reference = members.get(key);
|
|
9013
9393
|
if (reference === void 0) continue;
|
|
@@ -9017,8 +9397,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9017
9397
|
};
|
|
9018
9398
|
var parameterCollaborators = (parameter, declared) => {
|
|
9019
9399
|
let target = parameter;
|
|
9020
|
-
if (target.type ===
|
|
9021
|
-
if (target.type ===
|
|
9400
|
+
if (target.type === import_utils58.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9401
|
+
if (target.type === import_utils58.AST_NODE_TYPES.ObjectPattern) {
|
|
9022
9402
|
return objectPatternCollaborators(target, declared);
|
|
9023
9403
|
}
|
|
9024
9404
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9032,22 +9412,22 @@ var typeParameterNames = (...declarations) => {
|
|
|
9032
9412
|
return names;
|
|
9033
9413
|
};
|
|
9034
9414
|
var readConstructor = (ctor, declared, typeParameters) => {
|
|
9035
|
-
const
|
|
9415
|
+
const body2 = ctor.value.body;
|
|
9036
9416
|
const storedFrom = /* @__PURE__ */ new Set();
|
|
9037
9417
|
let constructedFields = 0;
|
|
9038
|
-
if (
|
|
9039
|
-
for (const statement of
|
|
9040
|
-
if (statement.type !==
|
|
9418
|
+
if (body2 !== null && body2 !== void 0) {
|
|
9419
|
+
for (const statement of body2.body) {
|
|
9420
|
+
if (statement.type !== import_utils58.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9041
9421
|
const expression = statement.expression;
|
|
9042
|
-
if (expression.type !==
|
|
9422
|
+
if (expression.type !== import_utils58.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils58.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils58.AST_NODE_TYPES.ThisExpression) {
|
|
9043
9423
|
continue;
|
|
9044
9424
|
}
|
|
9045
9425
|
const source = expression.right;
|
|
9046
|
-
if (source.type ===
|
|
9426
|
+
if (source.type === import_utils58.AST_NODE_TYPES.NewExpression) {
|
|
9047
9427
|
constructedFields += 1;
|
|
9048
|
-
} else if (source.type ===
|
|
9428
|
+
} else if (source.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9049
9429
|
storedFrom.add(source.name);
|
|
9050
|
-
} else if (source.type ===
|
|
9430
|
+
} else if (source.type === import_utils58.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9051
9431
|
storedFrom.add(source.object.name);
|
|
9052
9432
|
}
|
|
9053
9433
|
}
|
|
@@ -9055,7 +9435,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9055
9435
|
const collaborators = [];
|
|
9056
9436
|
for (const parameter of ctor.value.params) {
|
|
9057
9437
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9058
|
-
const stored = parameter.type ===
|
|
9438
|
+
const stored = parameter.type === import_utils58.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9059
9439
|
if (!stored) continue;
|
|
9060
9440
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9061
9441
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9088,20 +9468,20 @@ var subtreeHas = (root, found) => {
|
|
|
9088
9468
|
visit(root);
|
|
9089
9469
|
return hit;
|
|
9090
9470
|
};
|
|
9091
|
-
var isFrameworkWiring = (
|
|
9092
|
-
if (node.type ===
|
|
9471
|
+
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9472
|
+
if (node.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
9093
9473
|
const { callee } = node;
|
|
9094
|
-
if (callee.type ===
|
|
9095
|
-
return callee.type ===
|
|
9474
|
+
if (callee.type === import_utils58.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9475
|
+
return callee.type === import_utils58.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils58.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9096
9476
|
}
|
|
9097
|
-
return node.type ===
|
|
9477
|
+
return node.type === import_utils58.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils58.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9098
9478
|
});
|
|
9099
9479
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9100
9480
|
var fileInterfaceNames = (program) => {
|
|
9101
9481
|
const names = [];
|
|
9102
9482
|
for (const statement of program.body) {
|
|
9103
|
-
const declaration = statement.type ===
|
|
9104
|
-
if (declaration?.type ===
|
|
9483
|
+
const declaration = statement.type === import_utils58.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9484
|
+
if (declaration?.type === import_utils58.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9105
9485
|
}
|
|
9106
9486
|
return names;
|
|
9107
9487
|
};
|
|
@@ -9116,14 +9496,14 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9116
9496
|
return target.endsWith(other) || other.endsWith(target);
|
|
9117
9497
|
});
|
|
9118
9498
|
};
|
|
9119
|
-
var publicMethodNames = (
|
|
9499
|
+
var publicMethodNames = (body2) => {
|
|
9120
9500
|
const names = [];
|
|
9121
|
-
for (const member of
|
|
9122
|
-
if (member.type !==
|
|
9501
|
+
for (const member of body2.body) {
|
|
9502
|
+
if (member.type !== import_utils58.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9123
9503
|
if (member.kind !== "method" || member.static) continue;
|
|
9124
9504
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9125
|
-
if (member.key.type ===
|
|
9126
|
-
if (member.key.type ===
|
|
9505
|
+
if (member.key.type === import_utils58.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
9506
|
+
if (member.key.type === import_utils58.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
9127
9507
|
else names.push("\u2026");
|
|
9128
9508
|
}
|
|
9129
9509
|
return names;
|
|
@@ -9156,7 +9536,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9156
9536
|
if (node.implements.length > 0) return;
|
|
9157
9537
|
if (node.decorators.length > 0) return;
|
|
9158
9538
|
const ctor = node.body.body.find(
|
|
9159
|
-
(member) => member.type ===
|
|
9539
|
+
(member) => member.type === import_utils58.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
9160
9540
|
);
|
|
9161
9541
|
if (ctor === void 0) return;
|
|
9162
9542
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9185,18 +9565,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9185
9565
|
});
|
|
9186
9566
|
|
|
9187
9567
|
// src/rules/require-zod-form-validation.ts
|
|
9188
|
-
var
|
|
9568
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
9189
9569
|
var looksLikeZodSchema = (node) => {
|
|
9190
9570
|
let current = node;
|
|
9191
9571
|
while (true) {
|
|
9192
|
-
if (current.type ===
|
|
9572
|
+
if (current.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9193
9573
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9194
9574
|
}
|
|
9195
|
-
if (current.type ===
|
|
9575
|
+
if (current.type === import_utils59.AST_NODE_TYPES.CallExpression) {
|
|
9196
9576
|
current = current.callee;
|
|
9197
9577
|
continue;
|
|
9198
9578
|
}
|
|
9199
|
-
if (current.type ===
|
|
9579
|
+
if (current.type === import_utils59.AST_NODE_TYPES.MemberExpression) {
|
|
9200
9580
|
current = current.object;
|
|
9201
9581
|
continue;
|
|
9202
9582
|
}
|
|
@@ -9204,23 +9584,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9204
9584
|
}
|
|
9205
9585
|
};
|
|
9206
9586
|
var isZodParseCall = (node) => {
|
|
9207
|
-
if (node.type !==
|
|
9587
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.CallExpression) return false;
|
|
9208
9588
|
const callee = node.callee;
|
|
9209
|
-
if (callee.type !==
|
|
9589
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression) return false;
|
|
9210
9590
|
if (callee.computed) return false;
|
|
9211
|
-
if (callee.property.type !==
|
|
9591
|
+
if (callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier) return false;
|
|
9212
9592
|
const method = callee.property.name;
|
|
9213
9593
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9214
9594
|
return looksLikeZodSchema(callee.object);
|
|
9215
9595
|
};
|
|
9216
9596
|
var isFormDataMethodCall = (node) => {
|
|
9217
9597
|
let current = node;
|
|
9218
|
-
if (current.type ===
|
|
9598
|
+
if (current.type === import_utils59.AST_NODE_TYPES.AwaitExpression) {
|
|
9219
9599
|
current = current.argument;
|
|
9220
9600
|
}
|
|
9221
|
-
if (current.type !==
|
|
9601
|
+
if (current.type !== import_utils59.AST_NODE_TYPES.CallExpression) return false;
|
|
9222
9602
|
const callee = current.callee;
|
|
9223
|
-
return callee.type ===
|
|
9603
|
+
return callee.type === import_utils59.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils59.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
9224
9604
|
};
|
|
9225
9605
|
var require_zod_form_validation_default = createRule({
|
|
9226
9606
|
name: "require-zod-form-validation",
|
|
@@ -9240,14 +9620,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9240
9620
|
return {};
|
|
9241
9621
|
}
|
|
9242
9622
|
const isFormSourceIdentifier = (node) => {
|
|
9243
|
-
if (node.type !==
|
|
9623
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.Identifier) return false;
|
|
9244
9624
|
if (/formdata/i.test(node.name)) return true;
|
|
9245
9625
|
let scope = context.sourceCode.getScope(node);
|
|
9246
9626
|
while (scope !== null) {
|
|
9247
9627
|
const variable = scope.set.get(node.name);
|
|
9248
9628
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9249
9629
|
const def = variable.defs[0];
|
|
9250
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
9630
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils59.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
9251
9631
|
return isFormDataMethodCall(def.node.init);
|
|
9252
9632
|
}
|
|
9253
9633
|
return false;
|
|
@@ -9258,8 +9638,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9258
9638
|
};
|
|
9259
9639
|
const isFormDataGetCall = (node) => {
|
|
9260
9640
|
const callee = node.callee;
|
|
9261
|
-
if (callee.type !==
|
|
9262
|
-
if (callee.property.type !==
|
|
9641
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression) return false;
|
|
9642
|
+
if (callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
9263
9643
|
return false;
|
|
9264
9644
|
}
|
|
9265
9645
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9274,11 +9654,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9274
9654
|
};
|
|
9275
9655
|
const isInstanceofNarrowing = (node) => {
|
|
9276
9656
|
const parent = node.parent;
|
|
9277
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9657
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils59.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils59.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9278
9658
|
};
|
|
9279
9659
|
const boundDeclarator = (node) => {
|
|
9280
9660
|
const parent = node.parent;
|
|
9281
|
-
if (parent.type ===
|
|
9661
|
+
if (parent.type === import_utils59.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9282
9662
|
return parent;
|
|
9283
9663
|
}
|
|
9284
9664
|
return null;
|
|
@@ -9306,7 +9686,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
9306
9686
|
});
|
|
9307
9687
|
|
|
9308
9688
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
9309
|
-
var
|
|
9689
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9310
9690
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
9311
9691
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
9312
9692
|
var INSERT_GATE = /insert/i;
|
|
@@ -9337,7 +9717,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9337
9717
|
});
|
|
9338
9718
|
|
|
9339
9719
|
// src/rules/zod-naming-convention.ts
|
|
9340
|
-
var
|
|
9720
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9341
9721
|
var CONVENTIONS = {
|
|
9342
9722
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9343
9723
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9362,15 +9742,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9362
9742
|
"registry",
|
|
9363
9743
|
"implement"
|
|
9364
9744
|
]);
|
|
9365
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
9745
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
9366
9746
|
var calleeChainStartsWithZ = (node) => {
|
|
9367
9747
|
let current = node;
|
|
9368
|
-
while (current.type ===
|
|
9748
|
+
while (current.type === import_utils61.AST_NODE_TYPES.MemberExpression) {
|
|
9369
9749
|
const receiver = current.object;
|
|
9370
|
-
if (receiver.type ===
|
|
9750
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
9371
9751
|
return true;
|
|
9372
9752
|
}
|
|
9373
|
-
if (receiver.type ===
|
|
9753
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9374
9754
|
current = receiver.callee;
|
|
9375
9755
|
continue;
|
|
9376
9756
|
}
|
|
@@ -9415,13 +9795,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9415
9795
|
VariableDeclarator(node) {
|
|
9416
9796
|
const init = node.init;
|
|
9417
9797
|
if (init === null || init === void 0) return;
|
|
9418
|
-
if (init.type !==
|
|
9798
|
+
if (init.type !== import_utils61.AST_NODE_TYPES.CallExpression) return;
|
|
9419
9799
|
const callee = init.callee;
|
|
9420
|
-
if (callee.type !==
|
|
9800
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression) return;
|
|
9421
9801
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9422
9802
|
const terminal = terminalMethodName(callee);
|
|
9423
9803
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9424
|
-
if (node.id.type !==
|
|
9804
|
+
if (node.id.type !== import_utils61.AST_NODE_TYPES.Identifier) return;
|
|
9425
9805
|
if (test.test(node.id.name)) return;
|
|
9426
9806
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9427
9807
|
context.report({
|
|
@@ -9445,47 +9825,47 @@ var renamedRules = {
|
|
|
9445
9825
|
var retiredRules = {
|
|
9446
9826
|
"ban-loose-type-guards-in-tests": {
|
|
9447
9827
|
removedIn: "5.0.0",
|
|
9448
|
-
reason: "
|
|
9828
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9449
9829
|
},
|
|
9450
9830
|
"no-implicit-attribute-access": {
|
|
9451
9831
|
removedIn: "5.0.0",
|
|
9452
|
-
reason: "
|
|
9832
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9453
9833
|
},
|
|
9454
9834
|
"no-sequential-await": {
|
|
9455
9835
|
removedIn: "3.0.0",
|
|
9456
|
-
reason: "
|
|
9836
|
+
reason: "Delete the entry; core `no-await-in-loop` covers it."
|
|
9457
9837
|
},
|
|
9458
9838
|
"no-template-literal-in-log": {
|
|
9459
9839
|
removedIn: "2.3.1",
|
|
9460
|
-
reason: "
|
|
9840
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9461
9841
|
},
|
|
9462
9842
|
"no-unsafe-cast": {
|
|
9463
9843
|
removedIn: "3.0.0",
|
|
9464
|
-
reason:
|
|
9844
|
+
reason: "Delete the entry; keep `@typescript-eslint/consistent-type-assertions` enabled."
|
|
9465
9845
|
},
|
|
9466
9846
|
"prefer-setup-file-mocks": {
|
|
9467
9847
|
removedIn: "5.0.0",
|
|
9468
|
-
reason: "
|
|
9848
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9469
9849
|
},
|
|
9470
9850
|
"prefer-shadcn": {
|
|
9471
9851
|
removedIn: "3.0.0",
|
|
9472
|
-
reason: "
|
|
9852
|
+
reason: "Delete the entry; use `react/forbid-elements` for element restrictions."
|
|
9473
9853
|
},
|
|
9474
9854
|
"primary-export-file-name": {
|
|
9475
9855
|
removedIn: "4.0.0",
|
|
9476
|
-
reason: "
|
|
9856
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9477
9857
|
},
|
|
9478
9858
|
"require-parameterized-tests": {
|
|
9479
9859
|
removedIn: "4.0.0",
|
|
9480
|
-
reason: "
|
|
9860
|
+
reason: "Delete stale references; the rule was never registered."
|
|
9481
9861
|
},
|
|
9482
9862
|
"require-schema-validate-search": {
|
|
9483
9863
|
removedIn: "3.0.0",
|
|
9484
|
-
reason: "
|
|
9864
|
+
reason: "Delete the entry; use `@typescript-eslint/consistent-type-assertions`."
|
|
9485
9865
|
},
|
|
9486
9866
|
"single-public-export": {
|
|
9487
9867
|
removedIn: "3.0.0",
|
|
9488
|
-
reason: "
|
|
9868
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9489
9869
|
}
|
|
9490
9870
|
};
|
|
9491
9871
|
|
|
@@ -9504,6 +9884,7 @@ var rules = {
|
|
|
9504
9884
|
"no-insecure-random-id": no_insecure_random_id_default,
|
|
9505
9885
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
9506
9886
|
"no-log-only-catch": no_log_only_catch_default,
|
|
9887
|
+
"no-long-comment": no_long_comment_default,
|
|
9507
9888
|
"no-offset-pagination": no_offset_pagination_default,
|
|
9508
9889
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
9509
9890
|
"no-raw-env": no_raw_env_default,
|
|
@@ -9519,6 +9900,7 @@ var rules = {
|
|
|
9519
9900
|
"no-storage-in-stateless-modules": no_storage_in_stateless_modules_default,
|
|
9520
9901
|
"no-string-concat-in-loop": no_string_concat_in_loop_default,
|
|
9521
9902
|
"no-tautological-expect": no_tautological_expect_default,
|
|
9903
|
+
"no-typed-doc-sections": no_typed_doc_sections_default,
|
|
9522
9904
|
"no-trailing-value-narration": no_trailing_value_narration_default,
|
|
9523
9905
|
"no-declaration-comment-wall": no_declaration_comment_wall_default,
|
|
9524
9906
|
"no-union-in-comment": no_union_in_comment_default,
|
|
@@ -9534,6 +9916,7 @@ var rules = {
|
|
|
9534
9916
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
9535
9917
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
9536
9918
|
"prefer-server-actions": prefer_server_actions_default,
|
|
9919
|
+
"prefer-single-sentence-comment": prefer_single_sentence_comment_default,
|
|
9537
9920
|
"prefer-string-literal-union": prefer_string_literal_union_default,
|
|
9538
9921
|
"prefer-whole-object-assertion": prefer_whole_object_assertion_default,
|
|
9539
9922
|
"prefer-zod-enum": prefer_zod_enum_default,
|
|
@@ -9547,7 +9930,7 @@ var rules = {
|
|
|
9547
9930
|
};
|
|
9548
9931
|
var meta = {
|
|
9549
9932
|
name: "@sarj/eslint-plugin",
|
|
9550
|
-
version: "9.
|
|
9933
|
+
version: "9.7.0"
|
|
9551
9934
|
};
|
|
9552
9935
|
var recommendedRules = {
|
|
9553
9936
|
"@sarj/enforce-file-structure": "warn",
|
|
@@ -9562,6 +9945,7 @@ var recommendedRules = {
|
|
|
9562
9945
|
"@sarj/no-insecure-random-id": "warn",
|
|
9563
9946
|
"@sarj/no-json-stringify-error": "warn",
|
|
9564
9947
|
"@sarj/no-log-only-catch": "warn",
|
|
9948
|
+
"@sarj/no-long-comment": "warn",
|
|
9565
9949
|
"@sarj/no-offset-pagination": "warn",
|
|
9566
9950
|
"@sarj/no-positional-tuple-return": "warn",
|
|
9567
9951
|
"@sarj/no-repeated-string-literal": "warn",
|
|
@@ -9574,6 +9958,7 @@ var recommendedRules = {
|
|
|
9574
9958
|
"@sarj/no-sleep-in-test-body": "warn",
|
|
9575
9959
|
"@sarj/no-string-concat-in-loop": "warn",
|
|
9576
9960
|
"@sarj/no-tautological-expect": "warn",
|
|
9961
|
+
"@sarj/no-typed-doc-sections": "warn",
|
|
9577
9962
|
"@sarj/no-trailing-value-narration": "warn",
|
|
9578
9963
|
"@sarj/no-declaration-comment-wall": "warn",
|
|
9579
9964
|
"@sarj/no-union-in-comment": "warn",
|
|
@@ -9589,6 +9974,7 @@ var recommendedRules = {
|
|
|
9589
9974
|
"@sarj/prefer-schema-for-api-payload": "warn",
|
|
9590
9975
|
"@sarj/prefer-semantic-colors": ["warn", { requireSemanticTokens: true }],
|
|
9591
9976
|
"@sarj/prefer-server-actions": "warn",
|
|
9977
|
+
"@sarj/prefer-single-sentence-comment": "warn",
|
|
9592
9978
|
"@sarj/prefer-string-literal-union": "warn",
|
|
9593
9979
|
"@sarj/prefer-whole-object-assertion": "warn",
|
|
9594
9980
|
"@sarj/prefer-zod-enum": "warn",
|
|
@@ -9614,6 +10000,7 @@ var strictRules = {
|
|
|
9614
10000
|
"@sarj/no-insecure-random-id": "error",
|
|
9615
10001
|
"@sarj/no-json-stringify-error": "error",
|
|
9616
10002
|
"@sarj/no-log-only-catch": "error",
|
|
10003
|
+
"@sarj/no-long-comment": "error",
|
|
9617
10004
|
"@sarj/no-offset-pagination": "error",
|
|
9618
10005
|
"@sarj/no-positional-tuple-return": "error",
|
|
9619
10006
|
"@sarj/no-raw-env": "error",
|
|
@@ -9629,6 +10016,7 @@ var strictRules = {
|
|
|
9629
10016
|
"@sarj/no-storage-in-stateless-modules": "error",
|
|
9630
10017
|
"@sarj/no-string-concat-in-loop": "error",
|
|
9631
10018
|
"@sarj/no-tautological-expect": "error",
|
|
10019
|
+
"@sarj/no-typed-doc-sections": "error",
|
|
9632
10020
|
"@sarj/no-trailing-value-narration": "error",
|
|
9633
10021
|
"@sarj/no-declaration-comment-wall": "error",
|
|
9634
10022
|
"@sarj/no-union-in-comment": "error",
|
|
@@ -9644,6 +10032,7 @@ var strictRules = {
|
|
|
9644
10032
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
9645
10033
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
9646
10034
|
"@sarj/prefer-server-actions": "error",
|
|
10035
|
+
"@sarj/prefer-single-sentence-comment": "warn",
|
|
9647
10036
|
"@sarj/prefer-string-literal-union": "error",
|
|
9648
10037
|
"@sarj/prefer-whole-object-assertion": "error",
|
|
9649
10038
|
"@sarj/prefer-zod-enum": "error",
|