@sarj/eslint-plugin 9.6.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 +926 -681
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -14
- package/dist/index.d.ts +27 -14
- package/dist/index.js +915 -670
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
|
4
4
|
// src/rules/_docs.ts
|
|
5
5
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
6
6
|
var REPO_BLOB = "https://github.com/sarj-ai/standards/blob/main";
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var createRule = ESLintUtils.RuleCreator(
|
|
7
|
+
var TESTS_DIR = "packages/typescript/tests/rules";
|
|
8
|
+
var examplesPath = (name) => `${TESTS_DIR}/${name}.test.ts`;
|
|
9
|
+
var examplesUrl = (name) => `${REPO_BLOB}/${examplesPath(name)}`;
|
|
10
|
+
var createRule = ESLintUtils.RuleCreator(examplesUrl);
|
|
11
11
|
|
|
12
12
|
// src/rules/_paths.ts
|
|
13
13
|
var SCRIPT_FILE_RE = /([\\/]scripts[\\/])|(\.mjs$)/;
|
|
@@ -92,8 +92,8 @@ var enforce_file_structure_default = createRule({
|
|
|
92
92
|
}
|
|
93
93
|
return {
|
|
94
94
|
Program(node) {
|
|
95
|
-
const
|
|
96
|
-
const misplacedUseServer =
|
|
95
|
+
const body2 = node.body;
|
|
96
|
+
const misplacedUseServer = body2.find(
|
|
97
97
|
(statement, index) => index > 0 && isUseServerDirective(statement)
|
|
98
98
|
);
|
|
99
99
|
if (misplacedUseServer !== void 0) {
|
|
@@ -104,7 +104,7 @@ var enforce_file_structure_default = createRule({
|
|
|
104
104
|
}
|
|
105
105
|
let seenBody = false;
|
|
106
106
|
let inMisplacedRun = false;
|
|
107
|
-
for (const statement of
|
|
107
|
+
for (const statement of body2) {
|
|
108
108
|
if (isStringDirective(statement)) continue;
|
|
109
109
|
switch (classifyStatement(statement)) {
|
|
110
110
|
case "reexport":
|
|
@@ -325,11 +325,11 @@ var PROTECTED_SIGNALS = [
|
|
|
325
325
|
SECURITY_RE,
|
|
326
326
|
VENDOR_RE
|
|
327
327
|
];
|
|
328
|
-
function isProtected(
|
|
329
|
-
return PROTECTED_SIGNALS.some((signal) => signal.test(
|
|
328
|
+
function isProtected(body2) {
|
|
329
|
+
return PROTECTED_SIGNALS.some((signal) => signal.test(body2));
|
|
330
330
|
}
|
|
331
|
-
function hasExternalReference(
|
|
332
|
-
return REF_RE.test(
|
|
331
|
+
function hasExternalReference(body2) {
|
|
332
|
+
return REF_RE.test(body2);
|
|
333
333
|
}
|
|
334
334
|
var STOPWORDS = new Set(
|
|
335
335
|
`a an the this that these those it its their his her our your my
|
|
@@ -477,9 +477,9 @@ function restatableStatementBelow(comment, sourceCode) {
|
|
|
477
477
|
}
|
|
478
478
|
return null;
|
|
479
479
|
}
|
|
480
|
-
function restatesStatementHead(
|
|
480
|
+
function restatesStatementHead(body2, statement) {
|
|
481
481
|
if (statement === null) return false;
|
|
482
|
-
const words =
|
|
482
|
+
const words = body2.match(/[A-Za-z][\w$]*/g) ?? [];
|
|
483
483
|
const opener = words[0];
|
|
484
484
|
if (opener === void 0 || words.length > NARRATION_MAX_WORDS) return false;
|
|
485
485
|
if (!NARRATION_VERB_RE.test(opener)) return false;
|
|
@@ -678,11 +678,11 @@ function isProse(text) {
|
|
|
678
678
|
return false;
|
|
679
679
|
}
|
|
680
680
|
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;
|
|
681
|
-
function restatesWholeStatement(
|
|
682
|
-
return statement !== null && restatesStatementHead(
|
|
681
|
+
function restatesWholeStatement(body2, statement) {
|
|
682
|
+
return statement !== null && restatesStatementHead(body2, statement.replaceAll("(", " "));
|
|
683
683
|
}
|
|
684
|
-
function isRedundantNarration(
|
|
685
|
-
const t =
|
|
684
|
+
function isRedundantNarration(body2, statementBelow, standalone, isolatedEnumeration, nested) {
|
|
685
|
+
const t = body2.trim();
|
|
686
686
|
if (!t || looksLikeCode(t) || hasPseudocode(t)) return false;
|
|
687
687
|
if (standalone) {
|
|
688
688
|
const justified = JUSTIFICATION_RE.test(t);
|
|
@@ -757,8 +757,8 @@ function statementAttachmentBelow(comment, sourceCode) {
|
|
|
757
757
|
}
|
|
758
758
|
return null;
|
|
759
759
|
}
|
|
760
|
-
function isWeakWalkthroughComment(
|
|
761
|
-
const normalized =
|
|
760
|
+
function isWeakWalkthroughComment(body2, statement) {
|
|
761
|
+
const normalized = body2.replace(WALL_STEP_PREFIX_RE, "");
|
|
762
762
|
if (normalized.length === 0 || normalized.endsWith("?") || normalized.split(/\s+/).length > WALL_MAX_WORDS || isDirective(normalized) || isProtected(normalized) || !WALL_NARRATION_RE.test(normalized)) {
|
|
763
763
|
return false;
|
|
764
764
|
}
|
|
@@ -795,8 +795,8 @@ var LEAD_IN_SCAN_LIMIT = 24;
|
|
|
795
795
|
function hasIllustrationLeadInAbove(comments, index) {
|
|
796
796
|
for (let i = index - 1; i >= 0 && index - i <= LEAD_IN_SCAN_LIMIT; i--) {
|
|
797
797
|
if (!areAdjacentLineComments(comments[i], comments[i + 1])) return false;
|
|
798
|
-
const
|
|
799
|
-
if (
|
|
798
|
+
const body2 = stripCommentMarker(comments[i]?.value ?? "");
|
|
799
|
+
if (body2.length > 0 && body2.endsWith(":")) return true;
|
|
800
800
|
}
|
|
801
801
|
return false;
|
|
802
802
|
}
|
|
@@ -850,12 +850,12 @@ var no_comment_cruft_default = createRule({
|
|
|
850
850
|
if (comment.type !== "Line" || !isStandalone(comment)) continue;
|
|
851
851
|
const attachment = statementAttachmentBelow(comment, sourceCode);
|
|
852
852
|
if (attachment === null) continue;
|
|
853
|
-
const
|
|
853
|
+
const body2 = stripCommentMarker(comment.value);
|
|
854
854
|
const entries = attached.get(attachment.container) ?? [];
|
|
855
855
|
entries.push({
|
|
856
856
|
comment,
|
|
857
857
|
index: attachment.index,
|
|
858
|
-
weak: isWeakWalkthroughComment(
|
|
858
|
+
weak: isWeakWalkthroughComment(body2, attachment.statement)
|
|
859
859
|
});
|
|
860
860
|
attached.set(attachment.container, entries);
|
|
861
861
|
}
|
|
@@ -899,8 +899,8 @@ var no_comment_cruft_default = createRule({
|
|
|
899
899
|
if (comment.type !== "Line") break;
|
|
900
900
|
if (comment.loc.start.line >= firstCodeLine) break;
|
|
901
901
|
if (!isStandalone(comment)) break;
|
|
902
|
-
const
|
|
903
|
-
if (isDirective(
|
|
902
|
+
const body2 = stripCommentMarker(comment.value);
|
|
903
|
+
if (isDirective(body2) || body2.startsWith("!")) continue;
|
|
904
904
|
if (prevLine !== null && comment.loc.start.line !== prevLine + 1) break;
|
|
905
905
|
leading.push(comment);
|
|
906
906
|
prevLine = comment.loc.start.line;
|
|
@@ -908,8 +908,8 @@ var no_comment_cruft_default = createRule({
|
|
|
908
908
|
const first = leading[0];
|
|
909
909
|
if (first === void 0 || leading.length < LEADING_PREAMBLE_MIN) return;
|
|
910
910
|
const bodies = leading.map((c) => stripCommentMarker(c.value));
|
|
911
|
-
if (bodies.some((
|
|
912
|
-
if (bodies.some((
|
|
911
|
+
if (bodies.some((body2) => LICENSE_RE.test(body2))) return;
|
|
912
|
+
if (bodies.some((body2) => isProse(body2))) return;
|
|
913
913
|
if (bodies.filter(isEnumeratedProseItem).length >= ENUMERATED_PREAMBLE_MIN_ITEMS) {
|
|
914
914
|
return;
|
|
915
915
|
}
|
|
@@ -970,11 +970,11 @@ var no_comment_cruft_default = createRule({
|
|
|
970
970
|
continue;
|
|
971
971
|
}
|
|
972
972
|
if (comment.type === "Line" && texts.length === 1) {
|
|
973
|
-
const
|
|
973
|
+
const body2 = texts[0];
|
|
974
974
|
const statement = restatableStatementBelow(comment, sourceCode);
|
|
975
975
|
const standalone = !isInsideCommentRun(comments, i);
|
|
976
976
|
const nested = container !== null && !STATEMENT_CONTAINERS.has(container.type);
|
|
977
|
-
if (
|
|
977
|
+
if (body2 !== void 0 && !runCitesAReference(comments, i) && isRedundantNarration(body2, statement, standalone, enumerated.length === 1, nested)) {
|
|
978
978
|
context.report({ node: comment, messageId: "redundantNarration" });
|
|
979
979
|
}
|
|
980
980
|
}
|
|
@@ -988,11 +988,12 @@ var no_comment_cruft_default = createRule({
|
|
|
988
988
|
// src/rules/no-conditional-in-test.ts
|
|
989
989
|
import { AST_NODE_TYPES as AST_NODE_TYPES6 } from "@typescript-eslint/utils";
|
|
990
990
|
var TEST_CALLERS = /* @__PURE__ */ new Set(["it", "test"]);
|
|
991
|
-
var
|
|
991
|
+
var NON_TEST_MEMBERS = /* @__PURE__ */ new Set([
|
|
992
992
|
"afterAll",
|
|
993
993
|
"afterEach",
|
|
994
994
|
"beforeAll",
|
|
995
|
-
"beforeEach"
|
|
995
|
+
"beforeEach",
|
|
996
|
+
"describe"
|
|
996
997
|
]);
|
|
997
998
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
998
999
|
AST_NODE_TYPES6.FunctionDeclaration,
|
|
@@ -1032,12 +1033,27 @@ function testCallerName(callee) {
|
|
|
1032
1033
|
}
|
|
1033
1034
|
return null;
|
|
1034
1035
|
}
|
|
1036
|
+
function hasNonTestMember(callee) {
|
|
1037
|
+
if (callee.type === AST_NODE_TYPES6.MemberExpression) {
|
|
1038
|
+
if (!callee.computed && callee.property.type === AST_NODE_TYPES6.Identifier && NON_TEST_MEMBERS.has(callee.property.name)) {
|
|
1039
|
+
return true;
|
|
1040
|
+
}
|
|
1041
|
+
return hasNonTestMember(callee.object);
|
|
1042
|
+
}
|
|
1043
|
+
if (callee.type === AST_NODE_TYPES6.CallExpression) {
|
|
1044
|
+
return hasNonTestMember(callee.callee);
|
|
1045
|
+
}
|
|
1046
|
+
if (callee.type === AST_NODE_TYPES6.TaggedTemplateExpression) {
|
|
1047
|
+
return hasNonTestMember(callee.tag);
|
|
1048
|
+
}
|
|
1049
|
+
return false;
|
|
1050
|
+
}
|
|
1035
1051
|
function isTestBody(fn) {
|
|
1036
1052
|
const call = fn.parent;
|
|
1037
1053
|
if (call?.type !== AST_NODE_TYPES6.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
1038
1054
|
return false;
|
|
1039
1055
|
}
|
|
1040
|
-
if (
|
|
1056
|
+
if (hasNonTestMember(call.callee)) {
|
|
1041
1057
|
return false;
|
|
1042
1058
|
}
|
|
1043
1059
|
const name = testCallerName(call.callee);
|
|
@@ -1763,6 +1779,7 @@ var no_enum_default = createRule({
|
|
|
1763
1779
|
properties: {
|
|
1764
1780
|
ignoreFiles: {
|
|
1765
1781
|
type: "array",
|
|
1782
|
+
description: "Additional generated-file globs to ignore; shared generated paths and header markers are always ignored.",
|
|
1766
1783
|
items: { type: "string" }
|
|
1767
1784
|
}
|
|
1768
1785
|
}
|
|
@@ -1972,8 +1989,8 @@ function handlerRethrows(handler) {
|
|
|
1972
1989
|
if (handler === null) {
|
|
1973
1990
|
return false;
|
|
1974
1991
|
}
|
|
1975
|
-
const
|
|
1976
|
-
const last =
|
|
1992
|
+
const body2 = handler.body.body;
|
|
1993
|
+
const last = body2[body2.length - 1];
|
|
1977
1994
|
return last !== void 0 && last.type === AST_NODE_TYPES9.ThrowStatement;
|
|
1978
1995
|
}
|
|
1979
1996
|
var PASS_THROUGH_PARENTS = /* @__PURE__ */ new Set([
|
|
@@ -2007,8 +2024,8 @@ function unwrapAwait(expr) {
|
|
|
2007
2024
|
return inner.type === AST_NODE_TYPES9.AwaitExpression ? unwrap(inner.argument) : inner;
|
|
2008
2025
|
}
|
|
2009
2026
|
function handlerEndsByHandingOff(handler) {
|
|
2010
|
-
const
|
|
2011
|
-
const last =
|
|
2027
|
+
const body2 = handler.body.body;
|
|
2028
|
+
const last = body2[body2.length - 1];
|
|
2012
2029
|
if (last === void 0) {
|
|
2013
2030
|
return false;
|
|
2014
2031
|
}
|
|
@@ -2582,8 +2599,8 @@ function negatedInstanceofErrorSubject(test) {
|
|
|
2582
2599
|
return null;
|
|
2583
2600
|
}
|
|
2584
2601
|
function branchTerminates(branch) {
|
|
2585
|
-
const
|
|
2586
|
-
const last =
|
|
2602
|
+
const body2 = branch.type === "BlockStatement" ? branch.body : [branch];
|
|
2603
|
+
const last = body2[body2.length - 1];
|
|
2587
2604
|
return last !== void 0 && (last.type === "ReturnStatement" || last.type === "ThrowStatement");
|
|
2588
2605
|
}
|
|
2589
2606
|
function isNarrowedByEarlyReturn(node, argExpr, sourceCode) {
|
|
@@ -2835,8 +2852,8 @@ function hasFollowingStatement(node) {
|
|
|
2835
2852
|
return false;
|
|
2836
2853
|
}
|
|
2837
2854
|
function fallbackFollowsTry(tryStatement) {
|
|
2838
|
-
const
|
|
2839
|
-
const last =
|
|
2855
|
+
const body2 = tryStatement.block.body;
|
|
2856
|
+
const last = body2.at(-1);
|
|
2840
2857
|
return last?.type === AST_NODE_TYPES11.ReturnStatement && hasFollowingStatement(tryStatement);
|
|
2841
2858
|
}
|
|
2842
2859
|
function isSeedValue(node) {
|
|
@@ -2953,6 +2970,123 @@ var no_log_only_catch_default = createRule({
|
|
|
2953
2970
|
}
|
|
2954
2971
|
});
|
|
2955
2972
|
|
|
2973
|
+
// src/rules/_prose-budget.ts
|
|
2974
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES12 } from "@typescript-eslint/utils";
|
|
2975
|
+
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;
|
|
2976
|
+
var LICENSE_RE2 = /\b(?:copyright|spdx-license-identifier|licensed under)\b/i;
|
|
2977
|
+
var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
|
|
2978
|
+
var VALUE_TAG_RE = /@(example|deprecated|see|remarks|throws|internal|public|alpha|beta|since|template|fileoverview)\b/i;
|
|
2979
|
+
var BOUNDARY_RE = /(?<=[.!?])["'`)\]]*\s+(?=[A-Z0-9`])/;
|
|
2980
|
+
var BULLET_RE = /^\s*(?:[-*+] |\d+[.)] )/;
|
|
2981
|
+
function body(comment) {
|
|
2982
|
+
return comment.value.replace(/^\*/, "").split("\n").map((line) => line.replace(/^\s*\*?\s?/, "")).join("\n").trim();
|
|
2983
|
+
}
|
|
2984
|
+
function eligible(text, includeValueTags) {
|
|
2985
|
+
return text.length > 0 && !DIRECTIVE_RE2.test(text) && !LICENSE_RE2.test(text) && (includeValueTags || !VALUE_TAG_RE.test(text));
|
|
2986
|
+
}
|
|
2987
|
+
function sentenceUnits(text) {
|
|
2988
|
+
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");
|
|
2989
|
+
let units = 0;
|
|
2990
|
+
const prose = [];
|
|
2991
|
+
for (const raw of cleaned.split("\n")) {
|
|
2992
|
+
const line = raw.trim();
|
|
2993
|
+
if (line.length === 0 || /^[A-Za-z][A-Za-z ]+:$/.test(line)) continue;
|
|
2994
|
+
if (BULLET_RE.test(line)) units += 1;
|
|
2995
|
+
else prose.push(line);
|
|
2996
|
+
}
|
|
2997
|
+
if (prose.length > 0) units += prose.join(" ").split(BOUNDARY_RE).length;
|
|
2998
|
+
return units;
|
|
2999
|
+
}
|
|
3000
|
+
function proseGroups(filename, sourceCode, includeValueTags = false) {
|
|
3001
|
+
if (isGeneratedFile(filename, sourceCode.text) || isStoryFile(filename)) return [];
|
|
3002
|
+
const groups = [];
|
|
3003
|
+
let run = [];
|
|
3004
|
+
const flush = () => {
|
|
3005
|
+
if (run.length === 0) return;
|
|
3006
|
+
const text = run.map(body).join("\n");
|
|
3007
|
+
if (eligible(text, includeValueTags)) groups.push({ comment: run[0], text, hasTypedTags: TYPED_TAG_RE.test(text) });
|
|
3008
|
+
run = [];
|
|
3009
|
+
};
|
|
3010
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
3011
|
+
const text = body(comment);
|
|
3012
|
+
if (comment.type === "Block") {
|
|
3013
|
+
flush();
|
|
3014
|
+
if (eligible(text, includeValueTags)) groups.push({ comment, text, hasTypedTags: TYPED_TAG_RE.test(text) });
|
|
3015
|
+
continue;
|
|
3016
|
+
}
|
|
3017
|
+
const ownLine = sourceCode.lines[comment.loc.start.line - 1]?.slice(0, comment.loc.start.column).trim() === "";
|
|
3018
|
+
if (!ownLine || !eligible(text, includeValueTags)) {
|
|
3019
|
+
flush();
|
|
3020
|
+
continue;
|
|
3021
|
+
}
|
|
3022
|
+
const previous = run.at(-1);
|
|
3023
|
+
if (previous !== void 0 && (comment.loc.start.line !== previous.loc.end.line + 1 || comment.loc.start.column !== previous.loc.start.column)) flush();
|
|
3024
|
+
run.push(comment);
|
|
3025
|
+
}
|
|
3026
|
+
flush();
|
|
3027
|
+
return groups;
|
|
3028
|
+
}
|
|
3029
|
+
function annotatedParameter(parameter) {
|
|
3030
|
+
if (parameter.type === AST_NODE_TYPES12.TSParameterProperty) return annotatedParameter(parameter.parameter);
|
|
3031
|
+
const target = parameter.type === AST_NODE_TYPES12.AssignmentPattern ? parameter.left : parameter;
|
|
3032
|
+
return "typeAnnotation" in target && target.typeAnnotation != null;
|
|
3033
|
+
}
|
|
3034
|
+
function typedFunction(node) {
|
|
3035
|
+
switch (node.type) {
|
|
3036
|
+
case AST_NODE_TYPES12.ExportNamedDeclaration:
|
|
3037
|
+
case AST_NODE_TYPES12.ExportDefaultDeclaration:
|
|
3038
|
+
return node.declaration != null && typedFunction(node.declaration);
|
|
3039
|
+
case AST_NODE_TYPES12.FunctionDeclaration:
|
|
3040
|
+
case AST_NODE_TYPES12.TSDeclareFunction:
|
|
3041
|
+
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3042
|
+
case AST_NODE_TYPES12.VariableDeclaration: {
|
|
3043
|
+
const init = node.declarations[0]?.init;
|
|
3044
|
+
return init != null && (init.type === AST_NODE_TYPES12.ArrowFunctionExpression || init.type === AST_NODE_TYPES12.FunctionExpression) && init.returnType != null && init.params.every(annotatedParameter);
|
|
3045
|
+
}
|
|
3046
|
+
case AST_NODE_TYPES12.MethodDefinition:
|
|
3047
|
+
return node.value.returnType != null && node.value.params.every(annotatedParameter);
|
|
3048
|
+
case AST_NODE_TYPES12.TSMethodSignature:
|
|
3049
|
+
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3050
|
+
default:
|
|
3051
|
+
return false;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
function documentsTypedFunction(sourceCode, comment) {
|
|
3055
|
+
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3056
|
+
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return false;
|
|
3057
|
+
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3058
|
+
while (node != null && node.type !== AST_NODE_TYPES12.Program) {
|
|
3059
|
+
if (typedFunction(node)) return true;
|
|
3060
|
+
node = node.parent ?? null;
|
|
3061
|
+
}
|
|
3062
|
+
return false;
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
// src/rules/no-long-comment.ts
|
|
3066
|
+
var no_long_comment_default = createRule({
|
|
3067
|
+
name: "no-long-comment",
|
|
3068
|
+
meta: {
|
|
3069
|
+
type: "suggestion",
|
|
3070
|
+
docs: { description: "Limit in-code prose to two sentences." },
|
|
3071
|
+
schema: [],
|
|
3072
|
+
messages: {
|
|
3073
|
+
tooLong: "Comment exceeds two sentences \u2014 keep one local fact and clarify the code itself."
|
|
3074
|
+
}
|
|
3075
|
+
},
|
|
3076
|
+
defaultOptions: [],
|
|
3077
|
+
create(context) {
|
|
3078
|
+
return {
|
|
3079
|
+
Program() {
|
|
3080
|
+
for (const group of proseGroups(context.filename, context.sourceCode)) {
|
|
3081
|
+
if (!group.hasTypedTags && sentenceUnits(group.text) >= 3) {
|
|
3082
|
+
context.report({ node: group.comment, messageId: "tooLong" });
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
};
|
|
3087
|
+
}
|
|
3088
|
+
});
|
|
3089
|
+
|
|
2956
3090
|
// src/rules/no-offset-pagination.ts
|
|
2957
3091
|
import "@typescript-eslint/utils";
|
|
2958
3092
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:%s|%\(\w+\)s|\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
@@ -2984,15 +3118,15 @@ var no_offset_pagination_default = createRule({
|
|
|
2984
3118
|
});
|
|
2985
3119
|
|
|
2986
3120
|
// src/rules/no-positional-tuple-return.ts
|
|
2987
|
-
import { AST_NODE_TYPES as
|
|
3121
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES13 } from "@typescript-eslint/utils";
|
|
2988
3122
|
var MIN_ELEMENTS = 2;
|
|
2989
3123
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
2990
3124
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
2991
3125
|
function tupleReturnType(node) {
|
|
2992
|
-
if (node.type ===
|
|
3126
|
+
if (node.type === AST_NODE_TYPES13.TSTupleType) {
|
|
2993
3127
|
return node;
|
|
2994
3128
|
}
|
|
2995
|
-
if (node.type ===
|
|
3129
|
+
if (node.type === AST_NODE_TYPES13.TSTypeReference && node.typeName.type === AST_NODE_TYPES13.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
2996
3130
|
const argument = node.typeArguments?.params[0];
|
|
2997
3131
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
2998
3132
|
}
|
|
@@ -3006,30 +3140,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
3006
3140
|
if (elements.length < MIN_ELEMENTS) {
|
|
3007
3141
|
return true;
|
|
3008
3142
|
}
|
|
3009
|
-
if (elements.some((element) => element.type ===
|
|
3143
|
+
if (elements.some((element) => element.type === AST_NODE_TYPES13.TSRestType)) {
|
|
3010
3144
|
return true;
|
|
3011
3145
|
}
|
|
3012
|
-
if (elements.some((element) => element.type ===
|
|
3146
|
+
if (elements.some((element) => element.type === AST_NODE_TYPES13.TSNamedTupleMember)) {
|
|
3013
3147
|
return true;
|
|
3014
3148
|
}
|
|
3015
|
-
if (elements[0]?.type ===
|
|
3149
|
+
if (elements[0]?.type === AST_NODE_TYPES13.TSLiteralType) {
|
|
3016
3150
|
return true;
|
|
3017
3151
|
}
|
|
3018
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type ===
|
|
3152
|
+
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === AST_NODE_TYPES13.TSFunctionType)) {
|
|
3019
3153
|
return true;
|
|
3020
3154
|
}
|
|
3021
3155
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
3022
3156
|
return texts.size === 1;
|
|
3023
3157
|
}
|
|
3024
3158
|
function functionName(node) {
|
|
3025
|
-
if (node.type ===
|
|
3159
|
+
if (node.type === AST_NODE_TYPES13.FunctionDeclaration) {
|
|
3026
3160
|
return node.id?.name ?? null;
|
|
3027
3161
|
}
|
|
3028
3162
|
const parent = node.parent;
|
|
3029
|
-
if (parent?.type ===
|
|
3163
|
+
if (parent?.type === AST_NODE_TYPES13.VariableDeclarator && parent.id.type === AST_NODE_TYPES13.Identifier) {
|
|
3030
3164
|
return parent.id.name;
|
|
3031
3165
|
}
|
|
3032
|
-
if ((parent?.type ===
|
|
3166
|
+
if ((parent?.type === AST_NODE_TYPES13.MethodDefinition || parent?.type === AST_NODE_TYPES13.PropertyDefinition || parent?.type === AST_NODE_TYPES13.Property) && parent.key.type === AST_NODE_TYPES13.Identifier) {
|
|
3033
3167
|
return parent.key.name;
|
|
3034
3168
|
}
|
|
3035
3169
|
return null;
|
|
@@ -3037,7 +3171,7 @@ function functionName(node) {
|
|
|
3037
3171
|
function isInlineExported(node) {
|
|
3038
3172
|
for (let current = node; current != null; current = current.parent) {
|
|
3039
3173
|
const parent = current.parent;
|
|
3040
|
-
if (parent?.type ===
|
|
3174
|
+
if (parent?.type === AST_NODE_TYPES13.ExportNamedDeclaration || parent?.type === AST_NODE_TYPES13.ExportDefaultDeclaration) {
|
|
3041
3175
|
return true;
|
|
3042
3176
|
}
|
|
3043
3177
|
}
|
|
@@ -3046,18 +3180,18 @@ function isInlineExported(node) {
|
|
|
3046
3180
|
function moduleScopeBindingName(node) {
|
|
3047
3181
|
let current = node;
|
|
3048
3182
|
let child = node;
|
|
3049
|
-
while (current.parent != null && current.parent.type !==
|
|
3183
|
+
while (current.parent != null && current.parent.type !== AST_NODE_TYPES13.Program) {
|
|
3050
3184
|
child = current;
|
|
3051
3185
|
current = current.parent;
|
|
3052
3186
|
}
|
|
3053
|
-
if (current.parent?.type !==
|
|
3187
|
+
if (current.parent?.type !== AST_NODE_TYPES13.Program) {
|
|
3054
3188
|
return null;
|
|
3055
3189
|
}
|
|
3056
|
-
if (current.type ===
|
|
3190
|
+
if (current.type === AST_NODE_TYPES13.FunctionDeclaration || current.type === AST_NODE_TYPES13.ClassDeclaration) {
|
|
3057
3191
|
return current.id?.name ?? null;
|
|
3058
3192
|
}
|
|
3059
|
-
if (current.type ===
|
|
3060
|
-
if (child.type !==
|
|
3193
|
+
if (current.type === AST_NODE_TYPES13.VariableDeclaration) {
|
|
3194
|
+
if (child.type !== AST_NODE_TYPES13.VariableDeclarator || child.id.type !== AST_NODE_TYPES13.Identifier) {
|
|
3061
3195
|
return null;
|
|
3062
3196
|
}
|
|
3063
3197
|
return child.id.name;
|
|
@@ -3067,19 +3201,19 @@ function moduleScopeBindingName(node) {
|
|
|
3067
3201
|
function specifierExportedNames(program) {
|
|
3068
3202
|
const names = /* @__PURE__ */ new Set();
|
|
3069
3203
|
for (const statement of program.body) {
|
|
3070
|
-
if (statement.type ===
|
|
3204
|
+
if (statement.type === AST_NODE_TYPES13.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
3071
3205
|
for (const specifier of statement.specifiers) {
|
|
3072
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
3206
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES13.Identifier) {
|
|
3073
3207
|
names.add(specifier.local.name);
|
|
3074
3208
|
}
|
|
3075
3209
|
}
|
|
3076
3210
|
continue;
|
|
3077
3211
|
}
|
|
3078
|
-
if (statement.type ===
|
|
3212
|
+
if (statement.type === AST_NODE_TYPES13.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES13.Identifier) {
|
|
3079
3213
|
names.add(statement.declaration.name);
|
|
3080
3214
|
continue;
|
|
3081
3215
|
}
|
|
3082
|
-
if (statement.type ===
|
|
3216
|
+
if (statement.type === AST_NODE_TYPES13.TSExportAssignment && statement.expression.type === AST_NODE_TYPES13.Identifier) {
|
|
3083
3217
|
names.add(statement.expression.name);
|
|
3084
3218
|
}
|
|
3085
3219
|
}
|
|
@@ -3191,11 +3325,11 @@ var no_raw_env_default = createRule({
|
|
|
3191
3325
|
meta: {
|
|
3192
3326
|
type: "problem",
|
|
3193
3327
|
docs: {
|
|
3194
|
-
description: "Disallow direct `process.env`
|
|
3328
|
+
description: "Disallow direct `process.env` and `import.meta.env` reads outside validated boundaries."
|
|
3195
3329
|
},
|
|
3196
3330
|
schema: [],
|
|
3197
3331
|
messages: {
|
|
3198
|
-
noRawEnv: "Do not read
|
|
3332
|
+
noRawEnv: "Do not read raw environment values directly. Import the validated env module so values are typed and checked at startup."
|
|
3199
3333
|
}
|
|
3200
3334
|
},
|
|
3201
3335
|
defaultOptions: [],
|
|
@@ -3218,13 +3352,11 @@ var no_raw_env_default = createRule({
|
|
|
3218
3352
|
});
|
|
3219
3353
|
|
|
3220
3354
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
3221
|
-
import { AST_NODE_TYPES as
|
|
3355
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14 } from "@typescript-eslint/utils";
|
|
3222
3356
|
var DEFAULT_ALLOW = [
|
|
3223
3357
|
"[\\\\/]clients?[\\\\/]",
|
|
3224
3358
|
"-client\\.[cm]?[jt]sx?$",
|
|
3225
3359
|
"[\\\\/]http-client\\.[cm]?[jt]sx?$",
|
|
3226
|
-
// The `api` spelling of the same client-layer convention: an `api/` directory,
|
|
3227
|
-
// a bare `api.ts`, or a `*-api.ts` / `*.api.ts` module.
|
|
3228
3360
|
"[\\\\/]api[\\\\/]",
|
|
3229
3361
|
"[\\\\/]api\\.[cm]?[jt]sx?$",
|
|
3230
3362
|
"[-.]api\\.[cm]?[jt]sx?$",
|
|
@@ -3262,7 +3394,7 @@ function identifierLikeName(node) {
|
|
|
3262
3394
|
}
|
|
3263
3395
|
function isConstructedArgumentHandoff(node) {
|
|
3264
3396
|
const [first] = node.arguments;
|
|
3265
|
-
return node.arguments.length === 1 && first !== void 0 && first.type ===
|
|
3397
|
+
return node.arguments.length === 1 && first !== void 0 && first.type === AST_NODE_TYPES14.NewExpression;
|
|
3266
3398
|
}
|
|
3267
3399
|
function isPresignedUrlTransfer(node) {
|
|
3268
3400
|
const first = node.arguments[0];
|
|
@@ -3331,16 +3463,16 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
3331
3463
|
});
|
|
3332
3464
|
|
|
3333
3465
|
// src/rules/no-repeated-string-literal.ts
|
|
3334
|
-
import { AST_NODE_TYPES as
|
|
3466
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15 } from "@typescript-eslint/utils";
|
|
3335
3467
|
var MIN_LENGTH = 40;
|
|
3336
3468
|
var MIN_DISTINCT_SCOPES = 2;
|
|
3337
3469
|
var PREVIEW_LENGTH = 40;
|
|
3338
3470
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
3339
3471
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
3340
3472
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3473
|
+
AST_NODE_TYPES15.FunctionDeclaration,
|
|
3474
|
+
AST_NODE_TYPES15.FunctionExpression,
|
|
3475
|
+
AST_NODE_TYPES15.ArrowFunctionExpression
|
|
3344
3476
|
]);
|
|
3345
3477
|
function isStructured(value) {
|
|
3346
3478
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -3362,7 +3494,8 @@ function isScaffolding(node) {
|
|
|
3362
3494
|
if (parent === void 0) {
|
|
3363
3495
|
return true;
|
|
3364
3496
|
}
|
|
3365
|
-
|
|
3497
|
+
const isRequireSource = parent.type === AST_NODE_TYPES15.CallExpression && parent.callee.type === AST_NODE_TYPES15.Identifier && parent.callee.name === "require";
|
|
3498
|
+
return parent.type === AST_NODE_TYPES15.ImportDeclaration || parent.type === AST_NODE_TYPES15.ImportExpression || parent.type === AST_NODE_TYPES15.ExportNamedDeclaration || parent.type === AST_NODE_TYPES15.ExportAllDeclaration || parent.type === AST_NODE_TYPES15.TSImportType || parent.type === AST_NODE_TYPES15.JSXAttribute || parent.type === AST_NODE_TYPES15.TSLiteralType || isRequireSource;
|
|
3366
3499
|
}
|
|
3367
3500
|
var no_repeated_string_literal_default = createRule({
|
|
3368
3501
|
name: "no-repeated-string-literal",
|
|
@@ -3402,7 +3535,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3402
3535
|
}
|
|
3403
3536
|
},
|
|
3404
3537
|
TemplateLiteral(node) {
|
|
3405
|
-
if (node.parent.type ===
|
|
3538
|
+
if (node.parent.type === AST_NODE_TYPES15.TaggedTemplateExpression) {
|
|
3406
3539
|
return;
|
|
3407
3540
|
}
|
|
3408
3541
|
const [only] = node.quasis;
|
|
@@ -3436,10 +3569,10 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3436
3569
|
});
|
|
3437
3570
|
|
|
3438
3571
|
// src/rules/no-restated-comment.ts
|
|
3439
|
-
import { AST_NODE_TYPES as
|
|
3572
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES16 } from "@typescript-eslint/utils";
|
|
3440
3573
|
var MAX_WORDS = 8;
|
|
3441
3574
|
var MIN_CONTENT_TOKENS = 2;
|
|
3442
|
-
var
|
|
3575
|
+
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;
|
|
3443
3576
|
var CODEY_RE = /^[\w.$[\]'"]+\s*[:=]\s*\S|^[\w.$]+\s*\(|^(?:return|throw|await|import|export|const|let|var)\b.*[=()[\]{}]/;
|
|
3444
3577
|
var BANNERISH_RE = /[=\-─-╿*#~_.]{3,}|^[A-Z0-9 _:-]+$/;
|
|
3445
3578
|
var MODALITY_RE = /\b(?:can|could|should|shall|may|might|must|will|would|cannot)\b/i;
|
|
@@ -3457,10 +3590,10 @@ function areAdjacentLineComments2(a, b) {
|
|
|
3457
3590
|
function headsSiblingRun(node) {
|
|
3458
3591
|
const parent = node.parent;
|
|
3459
3592
|
if (parent === void 0) return false;
|
|
3460
|
-
const
|
|
3461
|
-
if (
|
|
3462
|
-
const index =
|
|
3463
|
-
const next = index >= 0 ?
|
|
3593
|
+
const body2 = "body" in parent && Array.isArray(parent.body) ? parent.body : void 0;
|
|
3594
|
+
if (body2 === void 0) return false;
|
|
3595
|
+
const index = body2.indexOf(node);
|
|
3596
|
+
const next = index >= 0 ? body2[index + 1] : void 0;
|
|
3464
3597
|
return next !== void 0 && next.type === node.type;
|
|
3465
3598
|
}
|
|
3466
3599
|
var no_restated_comment_default = createRule({
|
|
@@ -3489,7 +3622,7 @@ var no_restated_comment_default = createRule({
|
|
|
3489
3622
|
function labelsASiblingRun(comment) {
|
|
3490
3623
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3491
3624
|
if (token === null) return false;
|
|
3492
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
3625
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== AST_NODE_TYPES16.Program; node = node.parent) {
|
|
3493
3626
|
if (headsSiblingRun(node)) return true;
|
|
3494
3627
|
}
|
|
3495
3628
|
return false;
|
|
@@ -3500,8 +3633,8 @@ var no_restated_comment_default = createRule({
|
|
|
3500
3633
|
const wallMembers = /* @__PURE__ */ new Set();
|
|
3501
3634
|
let cluster = [];
|
|
3502
3635
|
for (const candidate of comments) {
|
|
3503
|
-
const
|
|
3504
|
-
if (candidate.type !== "Line" || !isStandalone(candidate) || isProtected(
|
|
3636
|
+
const body2 = candidate.value.replace(/^\/*/, "").trim();
|
|
3637
|
+
if (candidate.type !== "Line" || !isStandalone(candidate) || isProtected(body2) || !WALL_NARRATION_RE2.test(body2)) {
|
|
3505
3638
|
continue;
|
|
3506
3639
|
}
|
|
3507
3640
|
const previous = cluster.at(-1);
|
|
@@ -3524,18 +3657,18 @@ var no_restated_comment_default = createRule({
|
|
|
3524
3657
|
if (areAdjacentLineComments2(comments[i - 1], comment) || areAdjacentLineComments2(comment, comments[i + 1])) {
|
|
3525
3658
|
continue;
|
|
3526
3659
|
}
|
|
3527
|
-
const
|
|
3528
|
-
if (
|
|
3529
|
-
if (
|
|
3530
|
-
if (NON_ASCII_LETTER_RE.test(
|
|
3531
|
-
if (MODALITY_RE.test(
|
|
3532
|
-
if (NEGATION_WORD_RE.test(
|
|
3533
|
-
if (
|
|
3534
|
-
const tokens = contentTokens(
|
|
3660
|
+
const body2 = comment.value.replace(/^\/*/, "").trim();
|
|
3661
|
+
if (body2.length === 0 || body2.endsWith("?")) continue;
|
|
3662
|
+
if (DIRECTIVE_RE3.test(body2) || CODEY_RE.test(body2) || BANNERISH_RE.test(body2)) continue;
|
|
3663
|
+
if (NON_ASCII_LETTER_RE.test(body2) || isProtected(body2)) continue;
|
|
3664
|
+
if (MODALITY_RE.test(body2) || LEAD_IN_RE.test(body2) || EMPHASIS_RE.test(body2)) continue;
|
|
3665
|
+
if (NEGATION_WORD_RE.test(body2)) continue;
|
|
3666
|
+
if (body2.split(/\s+/).length > MAX_WORDS) continue;
|
|
3667
|
+
const tokens = contentTokens(body2);
|
|
3535
3668
|
if (tokens.length < MIN_CONTENT_TOKENS) continue;
|
|
3536
3669
|
const statement = restatableStatementBelow(comment, sourceCode);
|
|
3537
3670
|
if (statement === null) continue;
|
|
3538
|
-
if (restatesStatementHead(
|
|
3671
|
+
if (restatesStatementHead(body2, statement)) continue;
|
|
3539
3672
|
const line = lines[comment.loc.start.line] ?? "";
|
|
3540
3673
|
if (!ACTION_STMT_RE.test(line)) continue;
|
|
3541
3674
|
if (labelsASiblingRun(comment)) continue;
|
|
@@ -3549,7 +3682,7 @@ var no_restated_comment_default = createRule({
|
|
|
3549
3682
|
});
|
|
3550
3683
|
|
|
3551
3684
|
// src/rules/no-restated-jsdoc.ts
|
|
3552
|
-
import { AST_NODE_TYPES as
|
|
3685
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES17 } from "@typescript-eslint/utils";
|
|
3553
3686
|
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
3554
3687
|
"arg",
|
|
3555
3688
|
"argument",
|
|
@@ -3561,7 +3694,7 @@ var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
|
3561
3694
|
]);
|
|
3562
3695
|
var PARAM_TAGS = /* @__PURE__ */ new Set(["arg", "argument", "param"]);
|
|
3563
3696
|
var RETURN_TAGS = /* @__PURE__ */ new Set(["return", "returns"]);
|
|
3564
|
-
var
|
|
3697
|
+
var DIRECTIVE_RE4 = /^\s*(?:eslint\b|eslint-|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|@vite|webpack|@jsx|@jest-environment|@vitest-environment|#__)/i;
|
|
3565
3698
|
var STOPWORDS2 = new Set(
|
|
3566
3699
|
`the a an of to for in on with and or as at by is are was be been being
|
|
3567
3700
|
this that it its if whether when where which what will would can could should
|
|
@@ -3603,30 +3736,30 @@ function declarationNames(node) {
|
|
|
3603
3736
|
switch (node.type) {
|
|
3604
3737
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
3605
3738
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
3606
|
-
case
|
|
3607
|
-
case
|
|
3739
|
+
case AST_NODE_TYPES17.ExportNamedDeclaration:
|
|
3740
|
+
case AST_NODE_TYPES17.ExportDefaultDeclaration:
|
|
3608
3741
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
3609
|
-
case
|
|
3610
|
-
case
|
|
3742
|
+
case AST_NODE_TYPES17.FunctionDeclaration:
|
|
3743
|
+
case AST_NODE_TYPES17.TSDeclareFunction:
|
|
3611
3744
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
3612
|
-
case
|
|
3613
|
-
case
|
|
3614
|
-
case
|
|
3615
|
-
case
|
|
3745
|
+
case AST_NODE_TYPES17.ClassDeclaration:
|
|
3746
|
+
case AST_NODE_TYPES17.TSInterfaceDeclaration:
|
|
3747
|
+
case AST_NODE_TYPES17.TSTypeAliasDeclaration:
|
|
3748
|
+
case AST_NODE_TYPES17.TSEnumDeclaration:
|
|
3616
3749
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
3617
|
-
case
|
|
3750
|
+
case AST_NODE_TYPES17.VariableDeclaration: {
|
|
3618
3751
|
const declarator = node.declarations[0];
|
|
3619
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
3752
|
+
if (declarator === void 0 || declarator.id.type !== AST_NODE_TYPES17.Identifier) return null;
|
|
3620
3753
|
const init = declarator.init;
|
|
3621
|
-
const params = init != null && (init.type ===
|
|
3754
|
+
const params = init != null && (init.type === AST_NODE_TYPES17.ArrowFunctionExpression || init.type === AST_NODE_TYPES17.FunctionExpression) ? paramNames(init.params) : [];
|
|
3622
3755
|
return { name: declarator.id.name, params };
|
|
3623
3756
|
}
|
|
3624
|
-
case
|
|
3625
|
-
case
|
|
3626
|
-
case
|
|
3627
|
-
case
|
|
3628
|
-
if (node.key.type !==
|
|
3629
|
-
const params = node.type ===
|
|
3757
|
+
case AST_NODE_TYPES17.MethodDefinition:
|
|
3758
|
+
case AST_NODE_TYPES17.PropertyDefinition:
|
|
3759
|
+
case AST_NODE_TYPES17.TSMethodSignature:
|
|
3760
|
+
case AST_NODE_TYPES17.TSPropertySignature: {
|
|
3761
|
+
if (node.key.type !== AST_NODE_TYPES17.Identifier) return null;
|
|
3762
|
+
const params = node.type === AST_NODE_TYPES17.MethodDefinition ? paramNames(node.value.params) : node.type === AST_NODE_TYPES17.TSMethodSignature ? paramNames(node.params) : [];
|
|
3630
3763
|
return { name: node.key.name, params };
|
|
3631
3764
|
}
|
|
3632
3765
|
default:
|
|
@@ -3636,9 +3769,9 @@ function declarationNames(node) {
|
|
|
3636
3769
|
function paramNames(params) {
|
|
3637
3770
|
const names = [];
|
|
3638
3771
|
for (const param of params) {
|
|
3639
|
-
const target = param.type ===
|
|
3640
|
-
if (target.type ===
|
|
3641
|
-
else if (target.type ===
|
|
3772
|
+
const target = param.type === AST_NODE_TYPES17.AssignmentPattern ? param.left : param;
|
|
3773
|
+
if (target.type === AST_NODE_TYPES17.Identifier) names.push(target.name);
|
|
3774
|
+
else if (target.type === AST_NODE_TYPES17.TSParameterProperty) continue;
|
|
3642
3775
|
}
|
|
3643
3776
|
return names;
|
|
3644
3777
|
}
|
|
@@ -3672,7 +3805,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3672
3805
|
for (const comment of sourceCode.getAllComments()) {
|
|
3673
3806
|
if (comment.type !== "Block" || !comment.value.startsWith("*")) continue;
|
|
3674
3807
|
const { description, tags } = parseJsDoc(comment.value);
|
|
3675
|
-
if (
|
|
3808
|
+
if (DIRECTIVE_RE4.test(description)) continue;
|
|
3676
3809
|
const tagNames = new Set(tags.map((tag) => tag.name));
|
|
3677
3810
|
if ([...tagNames].some((name) => !MODELLED_TAGS.has(name))) continue;
|
|
3678
3811
|
if (isProtected(description)) continue;
|
|
@@ -3680,7 +3813,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3680
3813
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
3681
3814
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3682
3815
|
let declaration = null;
|
|
3683
|
-
while (node != null && node.type !==
|
|
3816
|
+
while (node != null && node.type !== AST_NODE_TYPES17.Program) {
|
|
3684
3817
|
declaration = declarationNames(node);
|
|
3685
3818
|
if (declaration !== null) break;
|
|
3686
3819
|
node = node.parent ?? null;
|
|
@@ -4139,12 +4272,12 @@ var no_select_star_default = createRule({
|
|
|
4139
4272
|
});
|
|
4140
4273
|
|
|
4141
4274
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
4142
|
-
import { AST_NODE_TYPES as
|
|
4275
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES18 } from "@typescript-eslint/utils";
|
|
4143
4276
|
function sentinelKind(arg) {
|
|
4144
4277
|
if (arg === null) {
|
|
4145
4278
|
return null;
|
|
4146
4279
|
}
|
|
4147
|
-
if (arg.type ===
|
|
4280
|
+
if (arg.type === AST_NODE_TYPES18.Literal) {
|
|
4148
4281
|
if (arg.value === null) {
|
|
4149
4282
|
return "nullish";
|
|
4150
4283
|
}
|
|
@@ -4156,13 +4289,13 @@ function sentinelKind(arg) {
|
|
|
4156
4289
|
}
|
|
4157
4290
|
return null;
|
|
4158
4291
|
}
|
|
4159
|
-
if (arg.type ===
|
|
4292
|
+
if (arg.type === AST_NODE_TYPES18.Identifier && arg.name === "undefined") {
|
|
4160
4293
|
return "nullish";
|
|
4161
4294
|
}
|
|
4162
|
-
if (arg.type ===
|
|
4295
|
+
if (arg.type === AST_NODE_TYPES18.ArrayExpression) {
|
|
4163
4296
|
return "array";
|
|
4164
4297
|
}
|
|
4165
|
-
if (arg.type ===
|
|
4298
|
+
if (arg.type === AST_NODE_TYPES18.ObjectExpression) {
|
|
4166
4299
|
return "object";
|
|
4167
4300
|
}
|
|
4168
4301
|
return null;
|
|
@@ -4171,25 +4304,25 @@ function isSentinelArgument(arg) {
|
|
|
4171
4304
|
if (arg === null) {
|
|
4172
4305
|
return false;
|
|
4173
4306
|
}
|
|
4174
|
-
if (arg.type ===
|
|
4307
|
+
if (arg.type === AST_NODE_TYPES18.Literal && arg.value === null) {
|
|
4175
4308
|
return true;
|
|
4176
4309
|
}
|
|
4177
|
-
if (arg.type ===
|
|
4310
|
+
if (arg.type === AST_NODE_TYPES18.Literal && arg.value === false) {
|
|
4178
4311
|
return true;
|
|
4179
4312
|
}
|
|
4180
|
-
if (arg.type ===
|
|
4313
|
+
if (arg.type === AST_NODE_TYPES18.Identifier && arg.name === "undefined") {
|
|
4181
4314
|
return true;
|
|
4182
4315
|
}
|
|
4183
|
-
if (arg.type ===
|
|
4316
|
+
if (arg.type === AST_NODE_TYPES18.ArrayExpression && arg.elements.length === 0) {
|
|
4184
4317
|
return true;
|
|
4185
4318
|
}
|
|
4186
|
-
if (arg.type ===
|
|
4319
|
+
if (arg.type === AST_NODE_TYPES18.ObjectExpression && arg.properties.length === 0) {
|
|
4187
4320
|
return true;
|
|
4188
4321
|
}
|
|
4189
4322
|
return false;
|
|
4190
4323
|
}
|
|
4191
4324
|
function isFunctionNode(node) {
|
|
4192
|
-
return node.type ===
|
|
4325
|
+
return node.type === AST_NODE_TYPES18.FunctionDeclaration || node.type === AST_NODE_TYPES18.FunctionExpression || node.type === AST_NODE_TYPES18.ArrowFunctionExpression;
|
|
4193
4326
|
}
|
|
4194
4327
|
function isNode3(value) {
|
|
4195
4328
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -4229,24 +4362,24 @@ function walkWithinScope(node, visit) {
|
|
|
4229
4362
|
function containsThrow(node) {
|
|
4230
4363
|
return walkWithinScope(
|
|
4231
4364
|
node,
|
|
4232
|
-
(current) => current.type ===
|
|
4365
|
+
(current) => current.type === AST_NODE_TYPES18.ThrowStatement
|
|
4233
4366
|
);
|
|
4234
4367
|
}
|
|
4235
4368
|
function bindsName(param, name) {
|
|
4236
4369
|
switch (param.type) {
|
|
4237
|
-
case
|
|
4370
|
+
case AST_NODE_TYPES18.Identifier:
|
|
4238
4371
|
return param.name === name;
|
|
4239
|
-
case
|
|
4372
|
+
case AST_NODE_TYPES18.AssignmentPattern:
|
|
4240
4373
|
return bindsName(param.left, name);
|
|
4241
|
-
case
|
|
4374
|
+
case AST_NODE_TYPES18.RestElement:
|
|
4242
4375
|
return bindsName(param.argument, name);
|
|
4243
|
-
case
|
|
4376
|
+
case AST_NODE_TYPES18.ArrayPattern:
|
|
4244
4377
|
return param.elements.some(
|
|
4245
4378
|
(element) => element !== null && bindsName(element, name)
|
|
4246
4379
|
);
|
|
4247
|
-
case
|
|
4380
|
+
case AST_NODE_TYPES18.ObjectPattern:
|
|
4248
4381
|
return param.properties.some(
|
|
4249
|
-
(property) => property.type ===
|
|
4382
|
+
(property) => property.type === AST_NODE_TYPES18.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
4250
4383
|
);
|
|
4251
4384
|
default:
|
|
4252
4385
|
return false;
|
|
@@ -4261,7 +4394,7 @@ function subtreeReadsName(node, name) {
|
|
|
4261
4394
|
if (found) {
|
|
4262
4395
|
return;
|
|
4263
4396
|
}
|
|
4264
|
-
if (current.type ===
|
|
4397
|
+
if (current.type === AST_NODE_TYPES18.Identifier && current.name === name) {
|
|
4265
4398
|
found = true;
|
|
4266
4399
|
return;
|
|
4267
4400
|
}
|
|
@@ -4272,10 +4405,10 @@ function subtreeReadsName(node, name) {
|
|
|
4272
4405
|
if (key === "parent") {
|
|
4273
4406
|
continue;
|
|
4274
4407
|
}
|
|
4275
|
-
if (key === "key" && current.type ===
|
|
4408
|
+
if (key === "key" && current.type === AST_NODE_TYPES18.Property && !current.computed) {
|
|
4276
4409
|
continue;
|
|
4277
4410
|
}
|
|
4278
|
-
if (key === "property" && current.type ===
|
|
4411
|
+
if (key === "property" && current.type === AST_NODE_TYPES18.MemberExpression && !current.computed) {
|
|
4279
4412
|
continue;
|
|
4280
4413
|
}
|
|
4281
4414
|
const value = current[key];
|
|
@@ -4308,10 +4441,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4308
4441
|
"URLPattern"
|
|
4309
4442
|
]);
|
|
4310
4443
|
function isParseShapedNode(node) {
|
|
4311
|
-
if (node.type ===
|
|
4444
|
+
if (node.type === AST_NODE_TYPES18.CallExpression && node.callee.type === AST_NODE_TYPES18.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES18.Identifier) {
|
|
4312
4445
|
return node.callee.property.name === "parse";
|
|
4313
4446
|
}
|
|
4314
|
-
if (node.type ===
|
|
4447
|
+
if (node.type === AST_NODE_TYPES18.NewExpression && node.callee.type === AST_NODE_TYPES18.Identifier) {
|
|
4315
4448
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
4316
4449
|
}
|
|
4317
4450
|
return false;
|
|
@@ -4322,10 +4455,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
4322
4455
|
"arrayBuffer"
|
|
4323
4456
|
]);
|
|
4324
4457
|
function isBodyDecodeNode(node) {
|
|
4325
|
-
return node.type ===
|
|
4458
|
+
return node.type === AST_NODE_TYPES18.CallExpression && node.callee.type === AST_NODE_TYPES18.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES18.Identifier && BODY_DECODE_METHODS.has(node.callee.property.name);
|
|
4326
4459
|
}
|
|
4327
4460
|
function returnsMatching(stmt, predicate) {
|
|
4328
|
-
return stmt.type ===
|
|
4461
|
+
return stmt.type === AST_NODE_TYPES18.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
4329
4462
|
}
|
|
4330
4463
|
function enclosingReturnTypeNode(node) {
|
|
4331
4464
|
let current = node.parent;
|
|
@@ -4343,11 +4476,11 @@ function enclosingFunctionName(node) {
|
|
|
4343
4476
|
let current = node.parent;
|
|
4344
4477
|
while (current !== void 0 && current !== null) {
|
|
4345
4478
|
if (isFunctionNode(current)) {
|
|
4346
|
-
if ("id" in current && isNode3(current.id) && current.id.type ===
|
|
4479
|
+
if ("id" in current && isNode3(current.id) && current.id.type === AST_NODE_TYPES18.Identifier) {
|
|
4347
4480
|
return current.id.name;
|
|
4348
4481
|
}
|
|
4349
4482
|
const parent = current.parent;
|
|
4350
|
-
if (parent?.type ===
|
|
4483
|
+
if (parent?.type === AST_NODE_TYPES18.VariableDeclarator && parent.id.type === AST_NODE_TYPES18.Identifier) {
|
|
4351
4484
|
return parent.id.name;
|
|
4352
4485
|
}
|
|
4353
4486
|
return null;
|
|
@@ -4368,10 +4501,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
4368
4501
|
return false;
|
|
4369
4502
|
}
|
|
4370
4503
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
4371
|
-
if (declared?.type ===
|
|
4504
|
+
if (declared?.type === AST_NODE_TYPES18.TSTypeReference && declared.typeName.type === AST_NODE_TYPES18.Identifier && declared.typeName.name === "Promise") {
|
|
4372
4505
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
4373
4506
|
}
|
|
4374
|
-
return declared?.type ===
|
|
4507
|
+
return declared?.type === AST_NODE_TYPES18.TSBooleanKeyword;
|
|
4375
4508
|
}
|
|
4376
4509
|
function tryReturnsSafeParse(catchNode) {
|
|
4377
4510
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -4387,7 +4520,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
4387
4520
|
function enclosingFunctionBody(node) {
|
|
4388
4521
|
let current = node.parent;
|
|
4389
4522
|
while (current !== void 0 && current !== null) {
|
|
4390
|
-
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type ===
|
|
4523
|
+
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === AST_NODE_TYPES18.BlockStatement) {
|
|
4391
4524
|
return current.body;
|
|
4392
4525
|
}
|
|
4393
4526
|
current = current.parent;
|
|
@@ -4400,7 +4533,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
4400
4533
|
return false;
|
|
4401
4534
|
}
|
|
4402
4535
|
return walkWithinScope(functionBody, (current) => {
|
|
4403
|
-
if (current.type !==
|
|
4536
|
+
if (current.type !== AST_NODE_TYPES18.ReturnStatement) {
|
|
4404
4537
|
return false;
|
|
4405
4538
|
}
|
|
4406
4539
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -4419,13 +4552,13 @@ function returnedSentinelKinds(arg) {
|
|
|
4419
4552
|
kinds.add(direct);
|
|
4420
4553
|
return kinds;
|
|
4421
4554
|
}
|
|
4422
|
-
if (arg.type ===
|
|
4555
|
+
if (arg.type === AST_NODE_TYPES18.ConditionalExpression) {
|
|
4423
4556
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
4424
4557
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
4425
4558
|
kinds.add(nested);
|
|
4426
4559
|
}
|
|
4427
4560
|
}
|
|
4428
|
-
} else if (arg.type ===
|
|
4561
|
+
} else if (arg.type === AST_NODE_TYPES18.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
4429
4562
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
4430
4563
|
kinds.add(nested);
|
|
4431
4564
|
}
|
|
@@ -4468,7 +4601,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4468
4601
|
const matcher = createLogMatcher(loggingOptions);
|
|
4469
4602
|
function logsOrReportsError(catchBody, caughtName) {
|
|
4470
4603
|
return walkWithinScope(catchBody, (current) => {
|
|
4471
|
-
if (current.type !==
|
|
4604
|
+
if (current.type !== AST_NODE_TYPES18.CallExpression) {
|
|
4472
4605
|
return false;
|
|
4473
4606
|
}
|
|
4474
4607
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -4480,12 +4613,12 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4480
4613
|
}
|
|
4481
4614
|
return {
|
|
4482
4615
|
CatchClause(node) {
|
|
4483
|
-
const
|
|
4484
|
-
if (
|
|
4616
|
+
const body2 = node.body.body;
|
|
4617
|
+
if (body2.length === 0) {
|
|
4485
4618
|
return;
|
|
4486
4619
|
}
|
|
4487
|
-
const last =
|
|
4488
|
-
if (last === void 0 || last.type !==
|
|
4620
|
+
const last = body2[body2.length - 1];
|
|
4621
|
+
if (last === void 0 || last.type !== AST_NODE_TYPES18.ReturnStatement) {
|
|
4489
4622
|
return;
|
|
4490
4623
|
}
|
|
4491
4624
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -4494,7 +4627,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4494
4627
|
if (containsThrow(node.body)) {
|
|
4495
4628
|
return;
|
|
4496
4629
|
}
|
|
4497
|
-
const caughtName = node.param?.type ===
|
|
4630
|
+
const caughtName = node.param?.type === AST_NODE_TYPES18.Identifier ? node.param.name : null;
|
|
4498
4631
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
4499
4632
|
return;
|
|
4500
4633
|
}
|
|
@@ -4521,9 +4654,9 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4521
4654
|
});
|
|
4522
4655
|
|
|
4523
4656
|
// src/rules/no-silent-promise-catch.ts
|
|
4524
|
-
import { AST_NODE_TYPES as
|
|
4657
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES19 } from "@typescript-eslint/utils";
|
|
4525
4658
|
function isBodyParseCall(node) {
|
|
4526
|
-
return node.type ===
|
|
4659
|
+
return node.type === AST_NODE_TYPES19.CallExpression && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES19.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES19.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
4527
4660
|
}
|
|
4528
4661
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
4529
4662
|
"cancel",
|
|
@@ -4538,37 +4671,37 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
4538
4671
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
4539
4672
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
4540
4673
|
function isTeardownCall(node) {
|
|
4541
|
-
return node.type ===
|
|
4674
|
+
return node.type === AST_NODE_TYPES19.CallExpression && node.callee.type === AST_NODE_TYPES19.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES19.Identifier && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
4542
4675
|
}
|
|
4543
4676
|
function isSilentExpression(node) {
|
|
4544
4677
|
switch (node.type) {
|
|
4545
|
-
case
|
|
4678
|
+
case AST_NODE_TYPES19.Literal:
|
|
4546
4679
|
return !("regex" in node);
|
|
4547
|
-
case
|
|
4680
|
+
case AST_NODE_TYPES19.Identifier:
|
|
4548
4681
|
return node.name === "undefined";
|
|
4549
|
-
case
|
|
4550
|
-
return node.operator === "void" && node.argument.type ===
|
|
4551
|
-
case
|
|
4682
|
+
case AST_NODE_TYPES19.UnaryExpression:
|
|
4683
|
+
return node.operator === "void" && node.argument.type === AST_NODE_TYPES19.Literal;
|
|
4684
|
+
case AST_NODE_TYPES19.ObjectExpression:
|
|
4552
4685
|
return node.properties.length === 0;
|
|
4553
|
-
case
|
|
4686
|
+
case AST_NODE_TYPES19.ArrayExpression:
|
|
4554
4687
|
return node.elements.length === 0;
|
|
4555
|
-
case
|
|
4688
|
+
case AST_NODE_TYPES19.TSAsExpression:
|
|
4556
4689
|
return isSilentExpression(node.expression);
|
|
4557
4690
|
default:
|
|
4558
4691
|
return false;
|
|
4559
4692
|
}
|
|
4560
4693
|
}
|
|
4561
4694
|
function isSilentHandler(handler) {
|
|
4562
|
-
const
|
|
4563
|
-
if (
|
|
4564
|
-
return isSilentExpression(
|
|
4695
|
+
const body2 = handler.body;
|
|
4696
|
+
if (body2.type !== AST_NODE_TYPES19.BlockStatement) {
|
|
4697
|
+
return isSilentExpression(body2);
|
|
4565
4698
|
}
|
|
4566
|
-
if (
|
|
4699
|
+
if (body2.body.length === 0) {
|
|
4567
4700
|
return true;
|
|
4568
4701
|
}
|
|
4569
|
-
if (
|
|
4570
|
-
const only =
|
|
4571
|
-
if (only !== void 0 && only.type ===
|
|
4702
|
+
if (body2.body.length === 1) {
|
|
4703
|
+
const only = body2.body[0];
|
|
4704
|
+
if (only !== void 0 && only.type === AST_NODE_TYPES19.ReturnStatement) {
|
|
4572
4705
|
return only.argument === null || isSilentExpression(only.argument);
|
|
4573
4706
|
}
|
|
4574
4707
|
}
|
|
@@ -4597,7 +4730,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4597
4730
|
return true;
|
|
4598
4731
|
}
|
|
4599
4732
|
let statement = call;
|
|
4600
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
4733
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== AST_NODE_TYPES19.VariableDeclaration) {
|
|
4601
4734
|
statement = statement.parent;
|
|
4602
4735
|
}
|
|
4603
4736
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -4609,7 +4742,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4609
4742
|
};
|
|
4610
4743
|
return {
|
|
4611
4744
|
CallExpression(node) {
|
|
4612
|
-
if (node.callee.type !==
|
|
4745
|
+
if (node.callee.type !== AST_NODE_TYPES19.MemberExpression || node.callee.computed || node.callee.property.type !== AST_NODE_TYPES19.Identifier || node.callee.property.name !== "catch") {
|
|
4613
4746
|
return;
|
|
4614
4747
|
}
|
|
4615
4748
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -4618,14 +4751,14 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4618
4751
|
if (isTeardownCall(node.callee.object)) {
|
|
4619
4752
|
return;
|
|
4620
4753
|
}
|
|
4621
|
-
if (node.parent.type ===
|
|
4754
|
+
if (node.parent.type === AST_NODE_TYPES19.MemberExpression && node.parent.object === node) {
|
|
4622
4755
|
return;
|
|
4623
4756
|
}
|
|
4624
4757
|
if (node.arguments.length !== 1) {
|
|
4625
4758
|
return;
|
|
4626
4759
|
}
|
|
4627
4760
|
const handler = node.arguments[0];
|
|
4628
|
-
if (handler === void 0 || handler.type !==
|
|
4761
|
+
if (handler === void 0 || handler.type !== AST_NODE_TYPES19.ArrowFunctionExpression && handler.type !== AST_NODE_TYPES19.FunctionExpression) {
|
|
4629
4762
|
return;
|
|
4630
4763
|
}
|
|
4631
4764
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -4640,7 +4773,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4640
4773
|
});
|
|
4641
4774
|
|
|
4642
4775
|
// src/rules/no-sleep-in-test-body.ts
|
|
4643
|
-
import { AST_NODE_TYPES as
|
|
4776
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES20 } from "@typescript-eslint/utils";
|
|
4644
4777
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
4645
4778
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
4646
4779
|
"it",
|
|
@@ -4649,34 +4782,34 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
|
4649
4782
|
"afterEach"
|
|
4650
4783
|
]);
|
|
4651
4784
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4785
|
+
AST_NODE_TYPES20.FunctionDeclaration,
|
|
4786
|
+
AST_NODE_TYPES20.FunctionExpression,
|
|
4787
|
+
AST_NODE_TYPES20.ArrowFunctionExpression
|
|
4655
4788
|
]);
|
|
4656
4789
|
function isNonzeroNumericLiteral(node) {
|
|
4657
|
-
return node?.type ===
|
|
4790
|
+
return node?.type === AST_NODE_TYPES20.Literal && typeof node.value === "number" && node.value !== 0;
|
|
4658
4791
|
}
|
|
4659
4792
|
function isTimedSetTimeout(node) {
|
|
4660
|
-
return node.type ===
|
|
4793
|
+
return node.type === AST_NODE_TYPES20.CallExpression && node.callee.type === AST_NODE_TYPES20.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
4661
4794
|
}
|
|
4662
4795
|
function isPromiseSleep(node) {
|
|
4663
|
-
if (node.callee.type !==
|
|
4796
|
+
if (node.callee.type !== AST_NODE_TYPES20.Identifier || node.callee.name !== "Promise") {
|
|
4664
4797
|
return false;
|
|
4665
4798
|
}
|
|
4666
4799
|
const executor = node.arguments[0];
|
|
4667
|
-
if (executor?.type !==
|
|
4800
|
+
if (executor?.type !== AST_NODE_TYPES20.ArrowFunctionExpression && executor?.type !== AST_NODE_TYPES20.FunctionExpression) {
|
|
4668
4801
|
return false;
|
|
4669
4802
|
}
|
|
4670
|
-
const
|
|
4671
|
-
if (
|
|
4672
|
-
return isTimedSetTimeout(
|
|
4803
|
+
const body2 = executor.body;
|
|
4804
|
+
if (body2.type !== AST_NODE_TYPES20.BlockStatement) {
|
|
4805
|
+
return isTimedSetTimeout(body2);
|
|
4673
4806
|
}
|
|
4674
|
-
return
|
|
4675
|
-
(stmt) => stmt.type ===
|
|
4807
|
+
return body2.body.some(
|
|
4808
|
+
(stmt) => stmt.type === AST_NODE_TYPES20.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
4676
4809
|
);
|
|
4677
4810
|
}
|
|
4678
4811
|
function isHelperSleep(node) {
|
|
4679
|
-
return node.callee.type ===
|
|
4812
|
+
return node.callee.type === AST_NODE_TYPES20.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
4680
4813
|
}
|
|
4681
4814
|
function nearestEnclosingFunction2(node) {
|
|
4682
4815
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -4684,7 +4817,7 @@ function nearestEnclosingFunction2(node) {
|
|
|
4684
4817
|
continue;
|
|
4685
4818
|
}
|
|
4686
4819
|
const grandparent = current.parent;
|
|
4687
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
4820
|
+
const isPromiseExecutor = grandparent?.type === AST_NODE_TYPES20.NewExpression && isPromiseSleep(grandparent);
|
|
4688
4821
|
if (!isPromiseExecutor) {
|
|
4689
4822
|
return current;
|
|
4690
4823
|
}
|
|
@@ -4692,23 +4825,23 @@ function nearestEnclosingFunction2(node) {
|
|
|
4692
4825
|
return null;
|
|
4693
4826
|
}
|
|
4694
4827
|
function testCallerName2(callee) {
|
|
4695
|
-
if (callee.type ===
|
|
4828
|
+
if (callee.type === AST_NODE_TYPES20.Identifier) {
|
|
4696
4829
|
return callee.name;
|
|
4697
4830
|
}
|
|
4698
|
-
if (callee.type ===
|
|
4831
|
+
if (callee.type === AST_NODE_TYPES20.MemberExpression) {
|
|
4699
4832
|
return testCallerName2(callee.object);
|
|
4700
4833
|
}
|
|
4701
|
-
if (callee.type ===
|
|
4834
|
+
if (callee.type === AST_NODE_TYPES20.CallExpression) {
|
|
4702
4835
|
return testCallerName2(callee.callee);
|
|
4703
4836
|
}
|
|
4704
|
-
if (callee.type ===
|
|
4837
|
+
if (callee.type === AST_NODE_TYPES20.TaggedTemplateExpression) {
|
|
4705
4838
|
return testCallerName2(callee.tag);
|
|
4706
4839
|
}
|
|
4707
4840
|
return null;
|
|
4708
4841
|
}
|
|
4709
4842
|
function isTestBody2(fn) {
|
|
4710
4843
|
const call = fn.parent;
|
|
4711
|
-
if (call?.type !==
|
|
4844
|
+
if (call?.type !== AST_NODE_TYPES20.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
4712
4845
|
return false;
|
|
4713
4846
|
}
|
|
4714
4847
|
const name = testCallerName2(call.callee);
|
|
@@ -4754,7 +4887,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
4754
4887
|
});
|
|
4755
4888
|
|
|
4756
4889
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
4757
|
-
import { AST_NODE_TYPES as
|
|
4890
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES21 } from "@typescript-eslint/utils";
|
|
4758
4891
|
var DEFAULT_METHODS2 = [
|
|
4759
4892
|
"prepare",
|
|
4760
4893
|
"put",
|
|
@@ -4773,7 +4906,7 @@ function compile2(patterns) {
|
|
|
4773
4906
|
}
|
|
4774
4907
|
function storageMethodName(node, methods) {
|
|
4775
4908
|
const callee = node.callee;
|
|
4776
|
-
if (callee.type !==
|
|
4909
|
+
if (callee.type !== AST_NODE_TYPES21.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES21.Identifier) {
|
|
4777
4910
|
return null;
|
|
4778
4911
|
}
|
|
4779
4912
|
const name = callee.property.name;
|
|
@@ -4906,9 +5039,9 @@ function isDeclaredInsideLoop(variable, loop) {
|
|
|
4906
5039
|
if (def === void 0) {
|
|
4907
5040
|
return false;
|
|
4908
5041
|
}
|
|
4909
|
-
const
|
|
5042
|
+
const body2 = loop.body;
|
|
4910
5043
|
const [declStart, declEnd] = def.node.range;
|
|
4911
|
-
const [bodyStart, bodyEnd] =
|
|
5044
|
+
const [bodyStart, bodyEnd] = body2.range;
|
|
4912
5045
|
return declStart >= bodyStart && declEnd <= bodyEnd;
|
|
4913
5046
|
}
|
|
4914
5047
|
function enclosingLoop(node) {
|
|
@@ -4987,7 +5120,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
4987
5120
|
});
|
|
4988
5121
|
|
|
4989
5122
|
// src/rules/no-tautological-expect.ts
|
|
4990
|
-
import { AST_NODE_TYPES as
|
|
5123
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES22 } from "@typescript-eslint/utils";
|
|
4991
5124
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
4992
5125
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
4993
5126
|
"toBeDefined",
|
|
@@ -5001,17 +5134,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
5001
5134
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
5002
5135
|
function isLiteral(node) {
|
|
5003
5136
|
switch (node.type) {
|
|
5004
|
-
case
|
|
5137
|
+
case AST_NODE_TYPES22.Literal:
|
|
5005
5138
|
return true;
|
|
5006
|
-
case
|
|
5139
|
+
case AST_NODE_TYPES22.TemplateLiteral:
|
|
5007
5140
|
return node.expressions.length === 0;
|
|
5008
|
-
case
|
|
5141
|
+
case AST_NODE_TYPES22.UnaryExpression:
|
|
5009
5142
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
5010
|
-
case
|
|
5143
|
+
case AST_NODE_TYPES22.ArrayExpression:
|
|
5011
5144
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
5012
|
-
case
|
|
5145
|
+
case AST_NODE_TYPES22.ObjectExpression:
|
|
5013
5146
|
return node.properties.every(
|
|
5014
|
-
(property) => property.type ===
|
|
5147
|
+
(property) => property.type === AST_NODE_TYPES22.Property && !property.computed && isLiteral(property.value)
|
|
5015
5148
|
);
|
|
5016
5149
|
default:
|
|
5017
5150
|
return false;
|
|
@@ -5019,7 +5152,7 @@ function isLiteral(node) {
|
|
|
5019
5152
|
}
|
|
5020
5153
|
function expectOperand(callee) {
|
|
5021
5154
|
const receiver = callee.object;
|
|
5022
|
-
if (receiver.type !==
|
|
5155
|
+
if (receiver.type !== AST_NODE_TYPES22.CallExpression || receiver.callee.type !== AST_NODE_TYPES22.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
5023
5156
|
return null;
|
|
5024
5157
|
}
|
|
5025
5158
|
return receiver.arguments[0] ?? null;
|
|
@@ -5049,10 +5182,10 @@ var no_tautological_expect_default = createRule({
|
|
|
5049
5182
|
return {
|
|
5050
5183
|
CallExpression(node) {
|
|
5051
5184
|
const callee = node.callee;
|
|
5052
|
-
if (callee.type !==
|
|
5185
|
+
if (callee.type !== AST_NODE_TYPES22.MemberExpression || callee.computed) {
|
|
5053
5186
|
return;
|
|
5054
5187
|
}
|
|
5055
|
-
if (callee.property.type !==
|
|
5188
|
+
if (callee.property.type !== AST_NODE_TYPES22.Identifier) {
|
|
5056
5189
|
return;
|
|
5057
5190
|
}
|
|
5058
5191
|
const matcher = callee.property.name;
|
|
@@ -5085,6 +5218,31 @@ var no_tautological_expect_default = createRule({
|
|
|
5085
5218
|
}
|
|
5086
5219
|
});
|
|
5087
5220
|
|
|
5221
|
+
// src/rules/no-typed-doc-sections.ts
|
|
5222
|
+
var no_typed_doc_sections_default = createRule({
|
|
5223
|
+
name: "no-typed-doc-sections",
|
|
5224
|
+
meta: {
|
|
5225
|
+
type: "suggestion",
|
|
5226
|
+
docs: { description: "Reject typed-signature repetition while preserving behavior that types cannot express." },
|
|
5227
|
+
schema: [],
|
|
5228
|
+
messages: {
|
|
5229
|
+
typedSection: "Typed JSDoc repeats parameters or returns \u2014 delete the tags and improve names or types instead."
|
|
5230
|
+
}
|
|
5231
|
+
},
|
|
5232
|
+
defaultOptions: [],
|
|
5233
|
+
create(context) {
|
|
5234
|
+
return {
|
|
5235
|
+
Program() {
|
|
5236
|
+
for (const group of proseGroups(context.filename, context.sourceCode, true)) {
|
|
5237
|
+
if (group.hasTypedTags && documentsTypedFunction(context.sourceCode, group.comment)) {
|
|
5238
|
+
context.report({ node: group.comment, messageId: "typedSection" });
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5242
|
+
};
|
|
5243
|
+
}
|
|
5244
|
+
});
|
|
5245
|
+
|
|
5088
5246
|
// src/rules/no-trailing-value-narration.ts
|
|
5089
5247
|
import "@typescript-eslint/utils";
|
|
5090
5248
|
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
@@ -5148,21 +5306,22 @@ var STOPWORDS3 = /* @__PURE__ */ new Set([
|
|
|
5148
5306
|
"we",
|
|
5149
5307
|
"with"
|
|
5150
5308
|
]);
|
|
5151
|
-
var
|
|
5309
|
+
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;
|
|
5152
5310
|
function numbersIn(text) {
|
|
5153
5311
|
return new Set(text.match(NUMBER_RE) ?? []);
|
|
5154
5312
|
}
|
|
5155
|
-
function narratesValue(
|
|
5156
|
-
if (
|
|
5313
|
+
function narratesValue(body2, code) {
|
|
5314
|
+
if (body2.length === 0 || DIRECTIVE_RE5.test(body2) || hasExternalReference(body2)) return false;
|
|
5157
5315
|
const codeNumbers = numbersIn(code);
|
|
5158
5316
|
if (codeNumbers.size === 0) return false;
|
|
5159
|
-
const words = (
|
|
5317
|
+
const words = (body2.match(WORD_RE3) ?? []).map((word) => word.toLowerCase());
|
|
5160
5318
|
if (words.length === 0) return false;
|
|
5161
|
-
const commentNumbers = numbersIn(
|
|
5319
|
+
const commentNumbers = numbersIn(body2);
|
|
5162
5320
|
if (commentNumbers.size === 0) return false;
|
|
5163
5321
|
for (const number of commentNumbers) {
|
|
5164
5322
|
if (!codeNumbers.has(number)) return false;
|
|
5165
5323
|
}
|
|
5324
|
+
if (!words.some((word) => UNIT_WORDS.has(word))) return false;
|
|
5166
5325
|
const identifiers = codeTokens(code);
|
|
5167
5326
|
const stems = /* @__PURE__ */ new Set();
|
|
5168
5327
|
for (const token of identifiers) stems.add(stem(token));
|
|
@@ -5175,7 +5334,7 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5175
5334
|
meta: {
|
|
5176
5335
|
type: "suggestion",
|
|
5177
5336
|
docs: {
|
|
5178
|
-
description: "Flag a trailing comment
|
|
5337
|
+
description: "Flag a trailing comment that repeats the line's numeric value only to name its unit."
|
|
5179
5338
|
},
|
|
5180
5339
|
schema: [],
|
|
5181
5340
|
messages: {
|
|
@@ -5192,14 +5351,25 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5192
5351
|
const before = sourceCode.getTokenBefore(comment, { includeComments: false });
|
|
5193
5352
|
return before !== null && before.loc.end.line === comment.loc.start.line;
|
|
5194
5353
|
}
|
|
5354
|
+
function isInsideBrackets(comment) {
|
|
5355
|
+
let node = sourceCode.getNodeByRangeIndex(comment.range[0]);
|
|
5356
|
+
while (node != null) {
|
|
5357
|
+
if (node.type === "BlockStatement" || node.type === "Program") return false;
|
|
5358
|
+
if (node.type === "ArrayExpression" || node.type === "CallExpression" || node.type === "NewExpression") {
|
|
5359
|
+
return true;
|
|
5360
|
+
}
|
|
5361
|
+
node = node.parent;
|
|
5362
|
+
}
|
|
5363
|
+
return false;
|
|
5364
|
+
}
|
|
5195
5365
|
return {
|
|
5196
5366
|
Program() {
|
|
5197
5367
|
for (const comment of sourceCode.getAllComments()) {
|
|
5198
|
-
if (!isTrailing(comment)) continue;
|
|
5368
|
+
if (!isTrailing(comment) || isInsideBrackets(comment)) continue;
|
|
5199
5369
|
const line = sourceCode.lines[comment.loc.start.line - 1] ?? "";
|
|
5200
5370
|
const code = line.slice(0, comment.loc.start.column);
|
|
5201
|
-
const
|
|
5202
|
-
if (narratesValue(
|
|
5371
|
+
const body2 = comment.value.replace(/^\*+/, "").replace(/\*+$/, "").trim();
|
|
5372
|
+
if (narratesValue(body2, code)) {
|
|
5203
5373
|
context.report({ node: comment, messageId: "narratesValue" });
|
|
5204
5374
|
}
|
|
5205
5375
|
}
|
|
@@ -5209,10 +5379,10 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5209
5379
|
});
|
|
5210
5380
|
|
|
5211
5381
|
// src/rules/no-declaration-comment-wall.ts
|
|
5212
|
-
import { AST_NODE_TYPES as
|
|
5382
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES24 } from "@typescript-eslint/utils";
|
|
5213
5383
|
|
|
5214
5384
|
// src/rules/_comment-wall.ts
|
|
5215
|
-
import { AST_NODE_TYPES as
|
|
5385
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES23 } from "@typescript-eslint/utils";
|
|
5216
5386
|
var WALL_DEFAULTS = {
|
|
5217
5387
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5218
5388
|
minCommentedMembers: 3,
|
|
@@ -5254,7 +5424,7 @@ var WALL_SCHEMA = {
|
|
|
5254
5424
|
}
|
|
5255
5425
|
}
|
|
5256
5426
|
};
|
|
5257
|
-
var
|
|
5427
|
+
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;
|
|
5258
5428
|
var DEFAULT_RE = /^\s*@?default\b|\bdefaults? (?:to|:)/i;
|
|
5259
5429
|
var DIGIT_RE = /\d/;
|
|
5260
5430
|
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;
|
|
@@ -5274,24 +5444,24 @@ var WALL_STOPWORDS = new Set(
|
|
|
5274
5444
|
);
|
|
5275
5445
|
var WORD_RE4 = /[A-Za-z][A-Za-z0-9]*/g;
|
|
5276
5446
|
var BARE_LABEL_RE = /^[A-Za-z][A-Za-z0-9]*$/;
|
|
5277
|
-
function labelStems(
|
|
5278
|
-
return splitIdentifier(
|
|
5447
|
+
function labelStems(body2) {
|
|
5448
|
+
return splitIdentifier(body2).map(stem).join(" ");
|
|
5279
5449
|
}
|
|
5280
5450
|
function commentBody(comment) {
|
|
5281
5451
|
return comment.value.replace(/^\*+/, "").replace(/^[ \t]*\*[ \t]?/gm, "").trim();
|
|
5282
5452
|
}
|
|
5283
|
-
function carriesValue(
|
|
5284
|
-
return isProtected(
|
|
5453
|
+
function carriesValue(body2) {
|
|
5454
|
+
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);
|
|
5285
5455
|
}
|
|
5286
|
-
function isLabel(
|
|
5456
|
+
function isLabel(body2) {
|
|
5287
5457
|
let content = 0;
|
|
5288
|
-
for (const word of
|
|
5458
|
+
for (const word of body2.match(WORD_RE4) ?? []) {
|
|
5289
5459
|
if (word.length >= 2 && !WALL_STOPWORDS.has(word.toLowerCase())) content += 1;
|
|
5290
5460
|
}
|
|
5291
5461
|
return content <= 1;
|
|
5292
5462
|
}
|
|
5293
|
-
function isTagsOnly(
|
|
5294
|
-
return
|
|
5463
|
+
function isTagsOnly(body2) {
|
|
5464
|
+
return body2.length > 0 && body2.replace(TAG_TOKEN_RE, "").trim().length === 0;
|
|
5295
5465
|
}
|
|
5296
5466
|
function knownTokens(source) {
|
|
5297
5467
|
const tokens = /* @__PURE__ */ new Set();
|
|
@@ -5303,9 +5473,9 @@ function knownTokens(source) {
|
|
|
5303
5473
|
}
|
|
5304
5474
|
return tokens;
|
|
5305
5475
|
}
|
|
5306
|
-
function novelWords(
|
|
5476
|
+
function novelWords(body2, known) {
|
|
5307
5477
|
let novel = 0;
|
|
5308
|
-
for (const word of
|
|
5478
|
+
for (const word of body2.match(WORD_RE4) ?? []) {
|
|
5309
5479
|
const lower = word.toLowerCase();
|
|
5310
5480
|
if (lower.length < 2 || WALL_STOPWORDS.has(lower)) continue;
|
|
5311
5481
|
if (!known.has(lower) && !known.has(stem(lower))) novel += 1;
|
|
@@ -5316,21 +5486,21 @@ function isWall(members, commented, restated, options) {
|
|
|
5316
5486
|
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5317
5487
|
}
|
|
5318
5488
|
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5489
|
+
AST_NODE_TYPES23.FunctionExpression,
|
|
5490
|
+
AST_NODE_TYPES23.ArrowFunctionExpression,
|
|
5491
|
+
AST_NODE_TYPES23.ObjectExpression,
|
|
5492
|
+
AST_NODE_TYPES23.ArrayExpression
|
|
5323
5493
|
]);
|
|
5324
5494
|
function declarationRange(member) {
|
|
5325
|
-
const
|
|
5326
|
-
if (
|
|
5327
|
-
return [member.range[0],
|
|
5495
|
+
const body2 = bodyOf(member);
|
|
5496
|
+
if (body2 === void 0) return [member.range[0], member.range[1]];
|
|
5497
|
+
return [member.range[0], body2.range[0]];
|
|
5328
5498
|
}
|
|
5329
5499
|
function bodyOf(member) {
|
|
5330
|
-
if (member.type ===
|
|
5500
|
+
if (member.type === AST_NODE_TYPES23.MethodDefinition || member.type === AST_NODE_TYPES23.TSAbstractMethodDefinition) {
|
|
5331
5501
|
return member.value.body ?? void 0;
|
|
5332
5502
|
}
|
|
5333
|
-
if (member.type ===
|
|
5503
|
+
if (member.type === AST_NODE_TYPES23.Property || member.type === AST_NODE_TYPES23.PropertyDefinition) {
|
|
5334
5504
|
const value = member.value;
|
|
5335
5505
|
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5336
5506
|
}
|
|
@@ -5340,12 +5510,12 @@ function bodyOf(member) {
|
|
|
5340
5510
|
// src/rules/no-declaration-comment-wall.ts
|
|
5341
5511
|
function named(node) {
|
|
5342
5512
|
switch (node.type) {
|
|
5343
|
-
case
|
|
5513
|
+
case AST_NODE_TYPES24.TSEnumMember:
|
|
5344
5514
|
return { node, key: node.id };
|
|
5345
|
-
case
|
|
5346
|
-
case
|
|
5347
|
-
case
|
|
5348
|
-
case
|
|
5515
|
+
case AST_NODE_TYPES24.PropertyDefinition:
|
|
5516
|
+
case AST_NODE_TYPES24.TSAbstractPropertyDefinition:
|
|
5517
|
+
case AST_NODE_TYPES24.MethodDefinition:
|
|
5518
|
+
case AST_NODE_TYPES24.TSAbstractMethodDefinition:
|
|
5349
5519
|
return node.computed ? void 0 : { node, key: node.key };
|
|
5350
5520
|
default:
|
|
5351
5521
|
return void 0;
|
|
@@ -5389,9 +5559,9 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5389
5559
|
}
|
|
5390
5560
|
function isGroupLabel(comment, member, headsRun) {
|
|
5391
5561
|
if (comment.loc.end.line >= member.node.loc.start.line) return false;
|
|
5392
|
-
const
|
|
5393
|
-
if (!BARE_LABEL_RE.test(
|
|
5394
|
-
if (labelStems(
|
|
5562
|
+
const body2 = commentBody(comment);
|
|
5563
|
+
if (!BARE_LABEL_RE.test(body2)) return false;
|
|
5564
|
+
if (labelStems(body2) === labelStems(sourceCode.getText(member.key))) return false;
|
|
5395
5565
|
const lineAbove = sourceCode.lines[comment.loc.start.line - 2];
|
|
5396
5566
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5397
5567
|
}
|
|
@@ -5404,19 +5574,21 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5404
5574
|
}));
|
|
5405
5575
|
let commented = 0;
|
|
5406
5576
|
let restated = 0;
|
|
5577
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
5407
5578
|
for (const [index, { member, comment }] of documented.entries()) {
|
|
5408
|
-
if (comment === void 0) continue;
|
|
5579
|
+
if (comment === void 0 || claimed.has(comment)) continue;
|
|
5409
5580
|
const next = documented[index + 1];
|
|
5410
5581
|
if (isGroupLabel(comment, member, next !== void 0 && next.comment === void 0)) {
|
|
5411
5582
|
continue;
|
|
5412
5583
|
}
|
|
5584
|
+
claimed.add(comment);
|
|
5413
5585
|
commented += 1;
|
|
5414
|
-
const
|
|
5415
|
-
if (
|
|
5586
|
+
const body2 = commentBody(comment);
|
|
5587
|
+
if (body2.length === 0 || carriesValue(body2) || isTagsOnly(body2) || isLabel(body2)) {
|
|
5416
5588
|
continue;
|
|
5417
5589
|
}
|
|
5418
5590
|
const [start, end] = declarationRange(member.node);
|
|
5419
|
-
if (novelWords(
|
|
5591
|
+
if (novelWords(body2, knownTokens(sourceCode.text.slice(start, end))) <= options.maxNovelWords) {
|
|
5420
5592
|
restated += 1;
|
|
5421
5593
|
}
|
|
5422
5594
|
}
|
|
@@ -5443,7 +5615,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5443
5615
|
});
|
|
5444
5616
|
|
|
5445
5617
|
// src/rules/no-union-in-comment.ts
|
|
5446
|
-
import { AST_NODE_TYPES as
|
|
5618
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES25 } from "@typescript-eslint/utils";
|
|
5447
5619
|
var MAX_LITERAL_LENGTH = 28;
|
|
5448
5620
|
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5449
5621
|
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
@@ -5462,14 +5634,14 @@ var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
5462
5634
|
function isBareString(node) {
|
|
5463
5635
|
if (node === void 0) return false;
|
|
5464
5636
|
switch (node.type) {
|
|
5465
|
-
case
|
|
5637
|
+
case AST_NODE_TYPES25.TSStringKeyword:
|
|
5466
5638
|
return true;
|
|
5467
5639
|
// `string[]` holds members of the same closed set, one element at a time.
|
|
5468
|
-
case
|
|
5640
|
+
case AST_NODE_TYPES25.TSArrayType:
|
|
5469
5641
|
return isBareString(node.elementType);
|
|
5470
5642
|
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5471
5643
|
// — the checker collapses that one to `string`.
|
|
5472
|
-
case
|
|
5644
|
+
case AST_NODE_TYPES25.TSUnionType:
|
|
5473
5645
|
return node.types.some((member) => isBareString(member));
|
|
5474
5646
|
default:
|
|
5475
5647
|
return false;
|
|
@@ -5479,13 +5651,13 @@ function rootCallee(node) {
|
|
|
5479
5651
|
let current = node;
|
|
5480
5652
|
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5481
5653
|
switch (current.type) {
|
|
5482
|
-
case
|
|
5654
|
+
case AST_NODE_TYPES25.CallExpression:
|
|
5483
5655
|
current = current.callee;
|
|
5484
5656
|
break;
|
|
5485
|
-
case
|
|
5657
|
+
case AST_NODE_TYPES25.MemberExpression:
|
|
5486
5658
|
current = current.object;
|
|
5487
5659
|
break;
|
|
5488
|
-
case
|
|
5660
|
+
case AST_NODE_TYPES25.Identifier:
|
|
5489
5661
|
return current.name;
|
|
5490
5662
|
default:
|
|
5491
5663
|
return null;
|
|
@@ -5494,26 +5666,26 @@ function rootCallee(node) {
|
|
|
5494
5666
|
return null;
|
|
5495
5667
|
}
|
|
5496
5668
|
function nameOf(key) {
|
|
5497
|
-
if (key.type ===
|
|
5498
|
-
if (key.type ===
|
|
5669
|
+
if (key.type === AST_NODE_TYPES25.Identifier) return key.name;
|
|
5670
|
+
if (key.type === AST_NODE_TYPES25.Literal && typeof key.value === "string") return key.value;
|
|
5499
5671
|
return null;
|
|
5500
5672
|
}
|
|
5501
5673
|
function targetOf(node) {
|
|
5502
5674
|
switch (node.type) {
|
|
5503
|
-
case
|
|
5504
|
-
case
|
|
5675
|
+
case AST_NODE_TYPES25.TSPropertySignature:
|
|
5676
|
+
case AST_NODE_TYPES25.PropertyDefinition: {
|
|
5505
5677
|
const name = node.computed ? null : nameOf(node.key);
|
|
5506
5678
|
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5507
5679
|
return { node, name };
|
|
5508
5680
|
}
|
|
5509
|
-
case
|
|
5681
|
+
case AST_NODE_TYPES25.Property: {
|
|
5510
5682
|
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5511
5683
|
const callee = rootCallee(node.value);
|
|
5512
5684
|
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5513
5685
|
return { node, name };
|
|
5514
5686
|
}
|
|
5515
|
-
case
|
|
5516
|
-
if (node.id.type !==
|
|
5687
|
+
case AST_NODE_TYPES25.VariableDeclarator: {
|
|
5688
|
+
if (node.id.type !== AST_NODE_TYPES25.Identifier) return null;
|
|
5517
5689
|
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5518
5690
|
return { node, name: node.id.name };
|
|
5519
5691
|
}
|
|
@@ -5521,8 +5693,8 @@ function targetOf(node) {
|
|
|
5521
5693
|
return null;
|
|
5522
5694
|
}
|
|
5523
5695
|
}
|
|
5524
|
-
function unionLiterals(
|
|
5525
|
-
const list =
|
|
5696
|
+
function unionLiterals(body2) {
|
|
5697
|
+
const list = body2.replace(LEAD_IN_RE2, "").trim();
|
|
5526
5698
|
if (!UNION_BODY_RE.test(list)) return null;
|
|
5527
5699
|
const literals = (list.match(LITERAL_G) ?? []).map((raw) => raw.slice(1, -1));
|
|
5528
5700
|
if (literals.some((literal) => literal.length === 0 || literal.length > MAX_LITERAL_LENGTH)) {
|
|
@@ -5562,7 +5734,7 @@ var no_union_in_comment_default = createRule({
|
|
|
5562
5734
|
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5563
5735
|
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5564
5736
|
}
|
|
5565
|
-
for (let node = anchor; node != null && node.type !==
|
|
5737
|
+
for (let node = anchor; node != null && node.type !== AST_NODE_TYPES25.Program; node = node.parent) {
|
|
5566
5738
|
const target = targetOf(node);
|
|
5567
5739
|
if (target !== null) return target;
|
|
5568
5740
|
}
|
|
@@ -5571,9 +5743,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5571
5743
|
return {
|
|
5572
5744
|
Program() {
|
|
5573
5745
|
for (const comment of sourceCode.getAllComments()) {
|
|
5574
|
-
const
|
|
5575
|
-
if (
|
|
5576
|
-
const literals = unionLiterals(
|
|
5746
|
+
const body2 = comment.value.replace(/^\*+/, "").replace(/\*+$/, "").trim();
|
|
5747
|
+
if (body2.length === 0) continue;
|
|
5748
|
+
const literals = unionLiterals(body2);
|
|
5577
5749
|
if (literals === null) continue;
|
|
5578
5750
|
const target = annotated(comment);
|
|
5579
5751
|
if (target === null) continue;
|
|
@@ -5591,9 +5763,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5591
5763
|
});
|
|
5592
5764
|
|
|
5593
5765
|
// src/rules/no-type-member-comment-wall.ts
|
|
5594
|
-
import { AST_NODE_TYPES as
|
|
5766
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES26 } from "@typescript-eslint/utils";
|
|
5595
5767
|
function isNamedMember(node) {
|
|
5596
|
-
return (node.type ===
|
|
5768
|
+
return (node.type === AST_NODE_TYPES26.TSPropertySignature || node.type === AST_NODE_TYPES26.TSMethodSignature) && !node.computed;
|
|
5597
5769
|
}
|
|
5598
5770
|
var no_type_member_comment_wall_default = createRule({
|
|
5599
5771
|
name: "no-type-member-comment-wall",
|
|
@@ -5633,14 +5805,14 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5633
5805
|
}
|
|
5634
5806
|
function isGroupLabel(comment, member, headsRun) {
|
|
5635
5807
|
if (comment.loc.end.line >= member.loc.start.line) return false;
|
|
5636
|
-
const
|
|
5637
|
-
if (!BARE_LABEL_RE.test(
|
|
5638
|
-
if (labelStems(
|
|
5808
|
+
const body2 = commentBody(comment);
|
|
5809
|
+
if (!BARE_LABEL_RE.test(body2)) return false;
|
|
5810
|
+
if (labelStems(body2) === labelStems(sourceCode.getText(member.key))) return false;
|
|
5639
5811
|
const lineAbove = sourceCode.lines[comment.loc.start.line - 2];
|
|
5640
5812
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5641
5813
|
}
|
|
5642
5814
|
function check(node) {
|
|
5643
|
-
const members = node.type ===
|
|
5815
|
+
const members = node.type === AST_NODE_TYPES26.TSInterfaceBody ? node.body : node.members;
|
|
5644
5816
|
const named2 = members.filter(isNamedMember);
|
|
5645
5817
|
if (named2.length === 0) return;
|
|
5646
5818
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5655,9 +5827,9 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5655
5827
|
}
|
|
5656
5828
|
claimed.add(comment);
|
|
5657
5829
|
commented += 1;
|
|
5658
|
-
const
|
|
5659
|
-
if (
|
|
5660
|
-
if (novelWords(
|
|
5830
|
+
const body2 = commentBody(comment);
|
|
5831
|
+
if (body2.length === 0 || carriesValue(body2)) continue;
|
|
5832
|
+
if (novelWords(body2, knownTokens(sourceCode.getText(member))) <= options.maxNovelWords) {
|
|
5661
5833
|
restated += 1;
|
|
5662
5834
|
}
|
|
5663
5835
|
}
|
|
@@ -5680,7 +5852,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5680
5852
|
});
|
|
5681
5853
|
|
|
5682
5854
|
// src/rules/no-unnecessary-use-client.ts
|
|
5683
|
-
import { AST_NODE_TYPES as
|
|
5855
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES27 } from "@typescript-eslint/utils";
|
|
5684
5856
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5685
5857
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5686
5858
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -5706,13 +5878,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
5706
5878
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
5707
5879
|
var jsxRootName = (name) => {
|
|
5708
5880
|
let current = name;
|
|
5709
|
-
while (current.type ===
|
|
5881
|
+
while (current.type === AST_NODE_TYPES27.JSXMemberExpression) {
|
|
5710
5882
|
current = current.object;
|
|
5711
5883
|
}
|
|
5712
|
-
return current.type ===
|
|
5884
|
+
return current.type === AST_NODE_TYPES27.JSXIdentifier ? current.name : "";
|
|
5713
5885
|
};
|
|
5714
5886
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
5715
|
-
if (node.type ===
|
|
5887
|
+
if (node.type === AST_NODE_TYPES27.Identifier) {
|
|
5716
5888
|
return imported.has(node.name);
|
|
5717
5889
|
}
|
|
5718
5890
|
for (const key of Object.keys(node)) {
|
|
@@ -5727,16 +5899,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
5727
5899
|
return false;
|
|
5728
5900
|
};
|
|
5729
5901
|
var isUseClientDirective = (node) => {
|
|
5730
|
-
return node.type ===
|
|
5902
|
+
return node.type === AST_NODE_TYPES27.ExpressionStatement && node.expression.type === AST_NODE_TYPES27.Literal && node.expression.value === "use client";
|
|
5731
5903
|
};
|
|
5732
5904
|
var isGlobalReference = (node, context) => {
|
|
5733
5905
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
5734
5906
|
const parent = node.parent;
|
|
5735
5907
|
if (parent !== void 0) {
|
|
5736
|
-
if (parent.type ===
|
|
5908
|
+
if (parent.type === AST_NODE_TYPES27.MemberExpression && parent.property === node && !parent.computed) {
|
|
5737
5909
|
return false;
|
|
5738
5910
|
}
|
|
5739
|
-
if (parent.type ===
|
|
5911
|
+
if (parent.type === AST_NODE_TYPES27.Property && parent.key === node && !parent.computed) {
|
|
5740
5912
|
return false;
|
|
5741
5913
|
}
|
|
5742
5914
|
if (parent.type.startsWith("TS")) {
|
|
@@ -5776,13 +5948,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5776
5948
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
5777
5949
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
5778
5950
|
const markIfHookOrContext = (callee) => {
|
|
5779
|
-
if (callee.type ===
|
|
5951
|
+
if (callee.type === AST_NODE_TYPES27.Identifier) {
|
|
5780
5952
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
5781
5953
|
hasClientIndicator = true;
|
|
5782
5954
|
}
|
|
5783
5955
|
return;
|
|
5784
5956
|
}
|
|
5785
|
-
if (callee.type ===
|
|
5957
|
+
if (callee.type === AST_NODE_TYPES27.MemberExpression && callee.property.type === AST_NODE_TYPES27.Identifier) {
|
|
5786
5958
|
const name = callee.property.name;
|
|
5787
5959
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
5788
5960
|
hasClientIndicator = true;
|
|
@@ -5792,7 +5964,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5792
5964
|
return {
|
|
5793
5965
|
Program(node) {
|
|
5794
5966
|
for (const stmt of node.body) {
|
|
5795
|
-
if (stmt.type !==
|
|
5967
|
+
if (stmt.type !== AST_NODE_TYPES27.ExpressionStatement) break;
|
|
5796
5968
|
if (isUseClientDirective(stmt)) {
|
|
5797
5969
|
directiveNode = stmt;
|
|
5798
5970
|
break;
|
|
@@ -5805,7 +5977,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5805
5977
|
},
|
|
5806
5978
|
JSXAttribute(node) {
|
|
5807
5979
|
if (directiveNode === null) return;
|
|
5808
|
-
if (node.name.type ===
|
|
5980
|
+
if (node.name.type === AST_NODE_TYPES27.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
5809
5981
|
hasClientIndicator = true;
|
|
5810
5982
|
}
|
|
5811
5983
|
},
|
|
@@ -5873,17 +6045,17 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5873
6045
|
|
|
5874
6046
|
// src/rules/no-unsafe-mock-casting.ts
|
|
5875
6047
|
import "@typescript-eslint/utils";
|
|
5876
|
-
import { AST_NODE_TYPES as
|
|
6048
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES28 } from "@typescript-eslint/utils";
|
|
5877
6049
|
function isMockTypeReference(node) {
|
|
5878
|
-
if (node.type !==
|
|
6050
|
+
if (node.type !== AST_NODE_TYPES28.TSTypeReference) {
|
|
5879
6051
|
return false;
|
|
5880
6052
|
}
|
|
5881
6053
|
const typeName = node.typeName;
|
|
5882
|
-
if (typeName.type ===
|
|
6054
|
+
if (typeName.type === AST_NODE_TYPES28.Identifier) {
|
|
5883
6055
|
const name = typeName.name;
|
|
5884
6056
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
5885
6057
|
}
|
|
5886
|
-
if (typeName.type ===
|
|
6058
|
+
if (typeName.type === AST_NODE_TYPES28.TSQualifiedName) {
|
|
5887
6059
|
const rightName = typeName.right.name;
|
|
5888
6060
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
5889
6061
|
}
|
|
@@ -5921,7 +6093,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
5921
6093
|
// src/rules/no-zod-native-enum.ts
|
|
5922
6094
|
import {
|
|
5923
6095
|
ESLintUtils as ESLintUtils2,
|
|
5924
|
-
AST_NODE_TYPES as
|
|
6096
|
+
AST_NODE_TYPES as AST_NODE_TYPES29
|
|
5925
6097
|
} from "@typescript-eslint/utils";
|
|
5926
6098
|
import * as ts from "typescript";
|
|
5927
6099
|
var IGNORE_PATTERNS = [
|
|
@@ -5940,7 +6112,7 @@ function isZodModule(source) {
|
|
|
5940
6112
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
5941
6113
|
}
|
|
5942
6114
|
function unwrap2(node) {
|
|
5943
|
-
if (node.type ===
|
|
6115
|
+
if (node.type === AST_NODE_TYPES29.TSAsExpression || node.type === AST_NODE_TYPES29.TSSatisfiesExpression) {
|
|
5944
6116
|
return unwrap2(node.expression);
|
|
5945
6117
|
}
|
|
5946
6118
|
return node;
|
|
@@ -5948,14 +6120,14 @@ function unwrap2(node) {
|
|
|
5948
6120
|
function stringValueTexts(node, sourceCode) {
|
|
5949
6121
|
const texts = [];
|
|
5950
6122
|
for (const prop of node.properties) {
|
|
5951
|
-
if (prop.type !==
|
|
6123
|
+
if (prop.type !== AST_NODE_TYPES29.Property) {
|
|
5952
6124
|
return null;
|
|
5953
6125
|
}
|
|
5954
6126
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
5955
6127
|
return null;
|
|
5956
6128
|
}
|
|
5957
6129
|
const value = prop.value;
|
|
5958
|
-
if (value.type !==
|
|
6130
|
+
if (value.type !== AST_NODE_TYPES29.Literal || typeof value.value !== "string") {
|
|
5959
6131
|
return null;
|
|
5960
6132
|
}
|
|
5961
6133
|
const text = sourceCode.getText(value);
|
|
@@ -5971,7 +6143,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
5971
6143
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
5972
6144
|
if (variable !== void 0) {
|
|
5973
6145
|
return variable.defs.some(
|
|
5974
|
-
(def) => def.node.type ===
|
|
6146
|
+
(def) => def.node.type === AST_NODE_TYPES29.TSEnumDeclaration
|
|
5975
6147
|
);
|
|
5976
6148
|
}
|
|
5977
6149
|
current = current.upper;
|
|
@@ -6023,25 +6195,25 @@ var no_zod_native_enum_default = createRule({
|
|
|
6023
6195
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6024
6196
|
function isZodMemberCall(node, api) {
|
|
6025
6197
|
const callee = node.callee;
|
|
6026
|
-
if (callee.type ===
|
|
6198
|
+
if (callee.type === AST_NODE_TYPES29.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES29.Identifier) {
|
|
6027
6199
|
return callee.property.name === api;
|
|
6028
6200
|
}
|
|
6029
|
-
if (callee.type ===
|
|
6201
|
+
if (callee.type === AST_NODE_TYPES29.Identifier) {
|
|
6030
6202
|
return zodImportedNames.get(callee.name) === api;
|
|
6031
6203
|
}
|
|
6032
6204
|
return false;
|
|
6033
6205
|
}
|
|
6034
6206
|
function buildFix(node) {
|
|
6035
6207
|
const callee = node.callee;
|
|
6036
|
-
if (callee.type !==
|
|
6208
|
+
if (callee.type !== AST_NODE_TYPES29.MemberExpression || callee.property.type !== AST_NODE_TYPES29.Identifier) {
|
|
6037
6209
|
return null;
|
|
6038
6210
|
}
|
|
6039
6211
|
const arg = node.arguments[0];
|
|
6040
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6212
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === AST_NODE_TYPES29.SpreadElement) {
|
|
6041
6213
|
return null;
|
|
6042
6214
|
}
|
|
6043
6215
|
const inner = unwrap2(arg);
|
|
6044
|
-
if (inner.type !==
|
|
6216
|
+
if (inner.type !== AST_NODE_TYPES29.ObjectExpression) {
|
|
6045
6217
|
return null;
|
|
6046
6218
|
}
|
|
6047
6219
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6061,7 +6233,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6061
6233
|
return;
|
|
6062
6234
|
}
|
|
6063
6235
|
for (const spec of node.specifiers) {
|
|
6064
|
-
if (spec.type ===
|
|
6236
|
+
if (spec.type === AST_NODE_TYPES29.ImportSpecifier && spec.imported.type === AST_NODE_TYPES29.Identifier) {
|
|
6065
6237
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6066
6238
|
}
|
|
6067
6239
|
}
|
|
@@ -6080,7 +6252,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6080
6252
|
return;
|
|
6081
6253
|
}
|
|
6082
6254
|
const arg = node.arguments[0];
|
|
6083
|
-
if (arg === void 0 || arg.type !==
|
|
6255
|
+
if (arg === void 0 || arg.type !== AST_NODE_TYPES29.Identifier) {
|
|
6084
6256
|
return;
|
|
6085
6257
|
}
|
|
6086
6258
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6097,7 +6269,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6097
6269
|
});
|
|
6098
6270
|
|
|
6099
6271
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6100
|
-
import { AST_NODE_TYPES as
|
|
6272
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES30 } from "@typescript-eslint/utils";
|
|
6101
6273
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6102
6274
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6103
6275
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6110,36 +6282,36 @@ function isConstantReference(identifier) {
|
|
|
6110
6282
|
}
|
|
6111
6283
|
function isExcludedOperand(node) {
|
|
6112
6284
|
switch (node.type) {
|
|
6113
|
-
case
|
|
6285
|
+
case AST_NODE_TYPES30.Literal:
|
|
6114
6286
|
return true;
|
|
6115
|
-
case
|
|
6287
|
+
case AST_NODE_TYPES30.TemplateLiteral:
|
|
6116
6288
|
return node.expressions.length === 0;
|
|
6117
|
-
case
|
|
6289
|
+
case AST_NODE_TYPES30.Identifier:
|
|
6118
6290
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6119
|
-
case
|
|
6120
|
-
return !node.computed && node.property.type ===
|
|
6291
|
+
case AST_NODE_TYPES30.MemberExpression:
|
|
6292
|
+
return !node.computed && node.property.type === AST_NODE_TYPES30.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6121
6293
|
default:
|
|
6122
6294
|
return false;
|
|
6123
6295
|
}
|
|
6124
6296
|
}
|
|
6125
6297
|
function operandName(node) {
|
|
6126
|
-
if (node.type ===
|
|
6298
|
+
if (node.type === AST_NODE_TYPES30.Identifier) {
|
|
6127
6299
|
return node.name;
|
|
6128
6300
|
}
|
|
6129
|
-
if (node.type ===
|
|
6301
|
+
if (node.type === AST_NODE_TYPES30.MemberExpression && !node.computed && node.property.type === AST_NODE_TYPES30.Identifier) {
|
|
6130
6302
|
return node.property.name;
|
|
6131
6303
|
}
|
|
6132
6304
|
return null;
|
|
6133
6305
|
}
|
|
6134
6306
|
function isSecretOperand(node) {
|
|
6135
|
-
if (node.type ===
|
|
6307
|
+
if (node.type === AST_NODE_TYPES30.TemplateLiteral) {
|
|
6136
6308
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6137
6309
|
}
|
|
6138
6310
|
const name = operandName(node);
|
|
6139
6311
|
return name !== null && isAuthSecretName(name);
|
|
6140
6312
|
}
|
|
6141
6313
|
function secretNameOf(node) {
|
|
6142
|
-
if (node.type ===
|
|
6314
|
+
if (node.type === AST_NODE_TYPES30.TemplateLiteral) {
|
|
6143
6315
|
for (const expression of node.expressions) {
|
|
6144
6316
|
const nested = secretNameOf(expression);
|
|
6145
6317
|
if (nested !== null) {
|
|
@@ -6192,7 +6364,7 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
6192
6364
|
|
|
6193
6365
|
// src/rules/prefer-discriminated-union.ts
|
|
6194
6366
|
import "@typescript-eslint/utils";
|
|
6195
|
-
import { AST_NODE_TYPES as
|
|
6367
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES31 } from "@typescript-eslint/utils";
|
|
6196
6368
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
6197
6369
|
"success",
|
|
6198
6370
|
"ok",
|
|
@@ -6202,27 +6374,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6202
6374
|
]);
|
|
6203
6375
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
6204
6376
|
function getMemberName(member) {
|
|
6205
|
-
if (member.type !==
|
|
6377
|
+
if (member.type !== AST_NODE_TYPES31.TSPropertySignature) {
|
|
6206
6378
|
return null;
|
|
6207
6379
|
}
|
|
6208
6380
|
const { key } = member;
|
|
6209
|
-
if (key.type ===
|
|
6381
|
+
if (key.type === AST_NODE_TYPES31.Identifier) {
|
|
6210
6382
|
return key.name;
|
|
6211
6383
|
}
|
|
6212
|
-
if (key.type ===
|
|
6384
|
+
if (key.type === AST_NODE_TYPES31.Literal && typeof key.value === "string") {
|
|
6213
6385
|
return key.value;
|
|
6214
6386
|
}
|
|
6215
6387
|
return null;
|
|
6216
6388
|
}
|
|
6217
6389
|
function isBooleanTyped(member) {
|
|
6218
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6390
|
+
return member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES31.TSBooleanKeyword;
|
|
6219
6391
|
}
|
|
6220
6392
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
6221
6393
|
let hasStatusBoolean = false;
|
|
6222
6394
|
let optionalCount = 0;
|
|
6223
6395
|
let optionalPayloadCount = 0;
|
|
6224
6396
|
for (const member of typeLiteral.members) {
|
|
6225
|
-
if (member.type !==
|
|
6397
|
+
if (member.type !== AST_NODE_TYPES31.TSPropertySignature) {
|
|
6226
6398
|
continue;
|
|
6227
6399
|
}
|
|
6228
6400
|
if (member.optional) {
|
|
@@ -6243,7 +6415,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6243
6415
|
meta: {
|
|
6244
6416
|
type: "suggestion",
|
|
6245
6417
|
docs: {
|
|
6246
|
-
description: "Flag object types with a boolean status
|
|
6418
|
+
description: "Flag object types with a boolean status member and at least two optional members, including a non-boolean payload."
|
|
6247
6419
|
},
|
|
6248
6420
|
schema: [],
|
|
6249
6421
|
messages: {
|
|
@@ -6264,7 +6436,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6264
6436
|
TSInterfaceDeclaration(node) {
|
|
6265
6437
|
const synthetic = {
|
|
6266
6438
|
...node.body,
|
|
6267
|
-
type:
|
|
6439
|
+
type: AST_NODE_TYPES31.TSTypeLiteral,
|
|
6268
6440
|
members: node.body.body
|
|
6269
6441
|
};
|
|
6270
6442
|
checkTypeLiteral(synthetic, node);
|
|
@@ -6277,7 +6449,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6277
6449
|
});
|
|
6278
6450
|
|
|
6279
6451
|
// src/rules/prefer-module-level-constant.ts
|
|
6280
|
-
import { AST_NODE_TYPES as
|
|
6452
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES32 } from "@typescript-eslint/utils";
|
|
6281
6453
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6282
6454
|
var MAX_LITERAL_DEPTH = 4;
|
|
6283
6455
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6306,9 +6478,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6306
6478
|
"assign"
|
|
6307
6479
|
]);
|
|
6308
6480
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6481
|
+
AST_NODE_TYPES32.FunctionDeclaration,
|
|
6482
|
+
AST_NODE_TYPES32.FunctionExpression,
|
|
6483
|
+
AST_NODE_TYPES32.ArrowFunctionExpression
|
|
6312
6484
|
]);
|
|
6313
6485
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6314
6486
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6321,14 +6493,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6321
6493
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6322
6494
|
}
|
|
6323
6495
|
function unwrap3(node) {
|
|
6324
|
-
if (node.type ===
|
|
6496
|
+
if (node.type === AST_NODE_TYPES32.TSAsExpression || node.type === AST_NODE_TYPES32.TSSatisfiesExpression || node.type === AST_NODE_TYPES32.TSNonNullExpression) {
|
|
6325
6497
|
return unwrap3(node.expression);
|
|
6326
6498
|
}
|
|
6327
6499
|
return node;
|
|
6328
6500
|
}
|
|
6329
6501
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6330
6502
|
function isRegexLiteral(node) {
|
|
6331
|
-
return node.type ===
|
|
6503
|
+
return node.type === AST_NODE_TYPES32.Literal && "regex" in node && node.regex !== void 0;
|
|
6332
6504
|
}
|
|
6333
6505
|
function isLiteralOnly(node, depth) {
|
|
6334
6506
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6336,29 +6508,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6336
6508
|
}
|
|
6337
6509
|
const inner = unwrap3(node);
|
|
6338
6510
|
switch (inner.type) {
|
|
6339
|
-
case
|
|
6511
|
+
case AST_NODE_TYPES32.Literal: {
|
|
6340
6512
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6341
6513
|
}
|
|
6342
|
-
case
|
|
6514
|
+
case AST_NODE_TYPES32.TemplateLiteral: {
|
|
6343
6515
|
return inner.expressions.length === 0;
|
|
6344
6516
|
}
|
|
6345
|
-
case
|
|
6346
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6517
|
+
case AST_NODE_TYPES32.UnaryExpression: {
|
|
6518
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES32.Literal && typeof inner.argument.value === "number";
|
|
6347
6519
|
}
|
|
6348
|
-
case
|
|
6520
|
+
case AST_NODE_TYPES32.ArrayExpression: {
|
|
6349
6521
|
return inner.elements.every(
|
|
6350
|
-
(el) => el !== null && el.type !==
|
|
6522
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES32.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6351
6523
|
);
|
|
6352
6524
|
}
|
|
6353
|
-
case
|
|
6525
|
+
case AST_NODE_TYPES32.ObjectExpression: {
|
|
6354
6526
|
return inner.properties.every((prop) => {
|
|
6355
|
-
if (prop.type !==
|
|
6527
|
+
if (prop.type !== AST_NODE_TYPES32.Property) {
|
|
6356
6528
|
return false;
|
|
6357
6529
|
}
|
|
6358
6530
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6359
6531
|
return false;
|
|
6360
6532
|
}
|
|
6361
|
-
if (prop.computed && prop.key.type !==
|
|
6533
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES32.Literal) {
|
|
6362
6534
|
return false;
|
|
6363
6535
|
}
|
|
6364
6536
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6371,7 +6543,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6371
6543
|
}
|
|
6372
6544
|
function unwrapObjectFreeze(node) {
|
|
6373
6545
|
const inner = unwrap3(node);
|
|
6374
|
-
if (inner.type ===
|
|
6546
|
+
if (inner.type === AST_NODE_TYPES32.CallExpression && inner.callee.type === AST_NODE_TYPES32.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES32.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES32.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES32.SpreadElement) {
|
|
6375
6547
|
return unwrap3(inner.arguments[0]);
|
|
6376
6548
|
}
|
|
6377
6549
|
return inner;
|
|
@@ -6387,19 +6559,19 @@ function classify(init, checkRegex) {
|
|
|
6387
6559
|
}
|
|
6388
6560
|
return { kind: "regex", size: 1 };
|
|
6389
6561
|
}
|
|
6390
|
-
if (node.type ===
|
|
6562
|
+
if (node.type === AST_NODE_TYPES32.ArrayExpression) {
|
|
6391
6563
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6392
6564
|
}
|
|
6393
|
-
if (node.type ===
|
|
6565
|
+
if (node.type === AST_NODE_TYPES32.ObjectExpression) {
|
|
6394
6566
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6395
6567
|
}
|
|
6396
|
-
if (node.type ===
|
|
6568
|
+
if (node.type === AST_NODE_TYPES32.NewExpression && node.callee.type === AST_NODE_TYPES32.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6397
6569
|
const arg = node.arguments[0];
|
|
6398
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6570
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES32.SpreadElement) {
|
|
6399
6571
|
return null;
|
|
6400
6572
|
}
|
|
6401
6573
|
const entries = unwrap3(arg);
|
|
6402
|
-
if (entries.type !==
|
|
6574
|
+
if (entries.type !== AST_NODE_TYPES32.ArrayExpression) {
|
|
6403
6575
|
return null;
|
|
6404
6576
|
}
|
|
6405
6577
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6428,10 +6600,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6428
6600
|
);
|
|
6429
6601
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6430
6602
|
const callee = node.callee;
|
|
6431
|
-
if (callee.type ===
|
|
6603
|
+
if (callee.type === AST_NODE_TYPES32.Identifier && callee.name === "structuredClone") {
|
|
6432
6604
|
return true;
|
|
6433
6605
|
}
|
|
6434
|
-
if (callee.type !==
|
|
6606
|
+
if (callee.type !== AST_NODE_TYPES32.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES32.Identifier || callee.property.type !== AST_NODE_TYPES32.Identifier) {
|
|
6435
6607
|
return false;
|
|
6436
6608
|
}
|
|
6437
6609
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6445,38 +6617,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6445
6617
|
}
|
|
6446
6618
|
function isSafeRead(identifier) {
|
|
6447
6619
|
const parent = identifier.parent;
|
|
6448
|
-
if (parent.type ===
|
|
6620
|
+
if (parent.type === AST_NODE_TYPES32.MemberExpression) {
|
|
6449
6621
|
if (parent.object !== identifier) {
|
|
6450
6622
|
return true;
|
|
6451
6623
|
}
|
|
6452
6624
|
const grandparent = parent.parent;
|
|
6453
|
-
if (grandparent.type ===
|
|
6625
|
+
if (grandparent.type === AST_NODE_TYPES32.AssignmentExpression && grandparent.left === parent) {
|
|
6454
6626
|
return false;
|
|
6455
6627
|
}
|
|
6456
|
-
if (grandparent.type ===
|
|
6628
|
+
if (grandparent.type === AST_NODE_TYPES32.UpdateExpression) {
|
|
6457
6629
|
return false;
|
|
6458
6630
|
}
|
|
6459
|
-
if (grandparent.type ===
|
|
6631
|
+
if (grandparent.type === AST_NODE_TYPES32.UnaryExpression && grandparent.operator === "delete") {
|
|
6460
6632
|
return false;
|
|
6461
6633
|
}
|
|
6462
|
-
if (!parent.computed && parent.property.type ===
|
|
6634
|
+
if (!parent.computed && parent.property.type === AST_NODE_TYPES32.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === AST_NODE_TYPES32.CallExpression && grandparent.callee === parent) {
|
|
6463
6635
|
return false;
|
|
6464
6636
|
}
|
|
6465
6637
|
return true;
|
|
6466
6638
|
}
|
|
6467
|
-
if (parent.type ===
|
|
6639
|
+
if (parent.type === AST_NODE_TYPES32.ForOfStatement && parent.right === identifier) {
|
|
6468
6640
|
return true;
|
|
6469
6641
|
}
|
|
6470
|
-
if (parent.type ===
|
|
6642
|
+
if (parent.type === AST_NODE_TYPES32.SpreadElement) {
|
|
6471
6643
|
return true;
|
|
6472
6644
|
}
|
|
6473
|
-
if (parent.type ===
|
|
6645
|
+
if (parent.type === AST_NODE_TYPES32.BinaryExpression) {
|
|
6474
6646
|
return true;
|
|
6475
6647
|
}
|
|
6476
|
-
if (parent.type ===
|
|
6648
|
+
if (parent.type === AST_NODE_TYPES32.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6477
6649
|
return true;
|
|
6478
6650
|
}
|
|
6479
|
-
if (parent.type ===
|
|
6651
|
+
if (parent.type === AST_NODE_TYPES32.UnaryExpression && parent.operator !== "delete") {
|
|
6480
6652
|
return true;
|
|
6481
6653
|
}
|
|
6482
6654
|
return false;
|
|
@@ -6531,7 +6703,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6531
6703
|
if (reference.isWrite()) {
|
|
6532
6704
|
return false;
|
|
6533
6705
|
}
|
|
6534
|
-
if (reference.identifier.type !==
|
|
6706
|
+
if (reference.identifier.type !== AST_NODE_TYPES32.Identifier) {
|
|
6535
6707
|
return false;
|
|
6536
6708
|
}
|
|
6537
6709
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6543,10 +6715,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6543
6715
|
return {
|
|
6544
6716
|
VariableDeclarator(node) {
|
|
6545
6717
|
const declaration = node.parent;
|
|
6546
|
-
if (declaration.type !==
|
|
6718
|
+
if (declaration.type !== AST_NODE_TYPES32.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6547
6719
|
return;
|
|
6548
6720
|
}
|
|
6549
|
-
if (node.id.type !==
|
|
6721
|
+
if (node.id.type !== AST_NODE_TYPES32.Identifier || node.init === null) {
|
|
6550
6722
|
return;
|
|
6551
6723
|
}
|
|
6552
6724
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6573,7 +6745,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6573
6745
|
});
|
|
6574
6746
|
|
|
6575
6747
|
// src/rules/prefer-module-level-schema.ts
|
|
6576
|
-
import { AST_NODE_TYPES as
|
|
6748
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES33 } from "@typescript-eslint/utils";
|
|
6577
6749
|
|
|
6578
6750
|
// src/rules/_zod.ts
|
|
6579
6751
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6639,9 +6811,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6639
6811
|
"intl"
|
|
6640
6812
|
]);
|
|
6641
6813
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6814
|
+
AST_NODE_TYPES33.ArrowFunctionExpression,
|
|
6815
|
+
AST_NODE_TYPES33.FunctionDeclaration,
|
|
6816
|
+
AST_NODE_TYPES33.FunctionExpression
|
|
6645
6817
|
]);
|
|
6646
6818
|
function schemaExpression(node) {
|
|
6647
6819
|
let current = node;
|
|
@@ -6650,10 +6822,10 @@ function schemaExpression(node) {
|
|
|
6650
6822
|
if (parent === void 0) {
|
|
6651
6823
|
return current;
|
|
6652
6824
|
}
|
|
6653
|
-
if (parent.type ===
|
|
6825
|
+
if (parent.type === AST_NODE_TYPES33.MemberExpression && parent.object === current && !parent.computed && parent.property.type === AST_NODE_TYPES33.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6654
6826
|
return current;
|
|
6655
6827
|
}
|
|
6656
|
-
if (parent.type ===
|
|
6828
|
+
if (parent.type === AST_NODE_TYPES33.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES33.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES33.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES33.TSNonNullExpression && parent.expression === current) {
|
|
6657
6829
|
current = parent;
|
|
6658
6830
|
continue;
|
|
6659
6831
|
}
|
|
@@ -6704,22 +6876,22 @@ function subtreeSome(root, predicate) {
|
|
|
6704
6876
|
function readsReceiver(node) {
|
|
6705
6877
|
return subtreeSome(
|
|
6706
6878
|
node,
|
|
6707
|
-
(inner) => inner.type ===
|
|
6879
|
+
(inner) => inner.type === AST_NODE_TYPES33.ThisExpression || inner.type === AST_NODE_TYPES33.Super || inner.type === AST_NODE_TYPES33.Identifier && inner.name === "arguments"
|
|
6708
6880
|
);
|
|
6709
6881
|
}
|
|
6710
6882
|
function buildsLocalizedText(node) {
|
|
6711
6883
|
return subtreeSome(node, (inner) => {
|
|
6712
|
-
if (inner.type ===
|
|
6884
|
+
if (inner.type === AST_NODE_TYPES33.TaggedTemplateExpression) {
|
|
6713
6885
|
return true;
|
|
6714
6886
|
}
|
|
6715
|
-
if (inner.type !==
|
|
6887
|
+
if (inner.type !== AST_NODE_TYPES33.CallExpression) {
|
|
6716
6888
|
return false;
|
|
6717
6889
|
}
|
|
6718
6890
|
const { callee } = inner;
|
|
6719
|
-
if (callee.type ===
|
|
6891
|
+
if (callee.type === AST_NODE_TYPES33.Identifier) {
|
|
6720
6892
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6721
6893
|
}
|
|
6722
|
-
return callee.type ===
|
|
6894
|
+
return callee.type === AST_NODE_TYPES33.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES33.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6723
6895
|
});
|
|
6724
6896
|
}
|
|
6725
6897
|
function collectReferences(scope, out) {
|
|
@@ -6776,15 +6948,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6776
6948
|
}
|
|
6777
6949
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
6778
6950
|
function isZodCall(node) {
|
|
6779
|
-
return node.type ===
|
|
6951
|
+
return node.type === AST_NODE_TYPES33.CallExpression && node.callee.type === AST_NODE_TYPES33.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES33.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
6780
6952
|
}
|
|
6781
6953
|
function isCovered(node) {
|
|
6782
6954
|
let current = node.parent ?? void 0;
|
|
6783
6955
|
while (current !== void 0) {
|
|
6784
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
6956
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES33.MemberExpression && current.callee.property.type === AST_NODE_TYPES33.Identifier && factories.has(current.callee.property.name)) {
|
|
6785
6957
|
return true;
|
|
6786
6958
|
}
|
|
6787
|
-
if (current.type ===
|
|
6959
|
+
if (current.type === AST_NODE_TYPES33.CallExpression && (current.callee.type === AST_NODE_TYPES33.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === AST_NODE_TYPES33.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES33.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
6788
6960
|
return true;
|
|
6789
6961
|
}
|
|
6790
6962
|
current = current.parent ?? void 0;
|
|
@@ -6799,11 +6971,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6799
6971
|
if (parent === void 0) {
|
|
6800
6972
|
return confirmed;
|
|
6801
6973
|
}
|
|
6802
|
-
if (parent.type ===
|
|
6974
|
+
if (parent.type === AST_NODE_TYPES33.Property && parent.value === current || parent.type === AST_NODE_TYPES33.ObjectExpression || parent.type === AST_NODE_TYPES33.ArrayExpression) {
|
|
6803
6975
|
current = parent;
|
|
6804
6976
|
continue;
|
|
6805
6977
|
}
|
|
6806
|
-
if (parent.type ===
|
|
6978
|
+
if (parent.type === AST_NODE_TYPES33.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
6807
6979
|
current = schemaExpression(parent);
|
|
6808
6980
|
confirmed = current;
|
|
6809
6981
|
continue;
|
|
@@ -6813,7 +6985,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6813
6985
|
}
|
|
6814
6986
|
function isSchemaComposition(node) {
|
|
6815
6987
|
const { callee } = node;
|
|
6816
|
-
const isCombinator = callee.type ===
|
|
6988
|
+
const isCombinator = callee.type === AST_NODE_TYPES33.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES33.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
6817
6989
|
return isCombinator || isZodCall(node);
|
|
6818
6990
|
}
|
|
6819
6991
|
function closesOverNothing(node, enclosing) {
|
|
@@ -6847,13 +7019,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6847
7019
|
}
|
|
6848
7020
|
function ownerName(enclosing) {
|
|
6849
7021
|
const parent = enclosing.parent ?? void 0;
|
|
6850
|
-
if (enclosing.type ===
|
|
7022
|
+
if (enclosing.type === AST_NODE_TYPES33.FunctionDeclaration && enclosing.id !== null) {
|
|
6851
7023
|
return enclosing.id.name;
|
|
6852
7024
|
}
|
|
6853
|
-
if (parent !== void 0 && parent.type ===
|
|
7025
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES33.VariableDeclarator && parent.id.type === AST_NODE_TYPES33.Identifier) {
|
|
6854
7026
|
return parent.id.name;
|
|
6855
7027
|
}
|
|
6856
|
-
if (parent !== void 0 && (parent.type ===
|
|
7028
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES33.MethodDefinition || parent.type === AST_NODE_TYPES33.Property) && parent.key.type === AST_NODE_TYPES33.Identifier) {
|
|
6857
7029
|
return parent.key.name;
|
|
6858
7030
|
}
|
|
6859
7031
|
return "this function";
|
|
@@ -6864,7 +7036,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6864
7036
|
return;
|
|
6865
7037
|
}
|
|
6866
7038
|
for (const specifier of node.specifiers) {
|
|
6867
|
-
if (specifier.type ===
|
|
7039
|
+
if (specifier.type === AST_NODE_TYPES33.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES33.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES33.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES33.Identifier && specifier.imported.name === "z") {
|
|
6868
7040
|
zodNamespaces.add(specifier.local.name);
|
|
6869
7041
|
}
|
|
6870
7042
|
}
|
|
@@ -6874,7 +7046,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6874
7046
|
return;
|
|
6875
7047
|
}
|
|
6876
7048
|
const callee = node.callee;
|
|
6877
|
-
if (callee.property.type !==
|
|
7049
|
+
if (callee.property.type !== AST_NODE_TYPES33.Identifier) {
|
|
6878
7050
|
return;
|
|
6879
7051
|
}
|
|
6880
7052
|
const factory = callee.property.name;
|
|
@@ -6889,7 +7061,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6889
7061
|
return;
|
|
6890
7062
|
}
|
|
6891
7063
|
const shape = node.arguments[0];
|
|
6892
|
-
if (shape !== void 0 && shape.type ===
|
|
7064
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES33.ObjectExpression && shape.properties.length < minProperties) {
|
|
6893
7065
|
return;
|
|
6894
7066
|
}
|
|
6895
7067
|
const expression = schemaExpression(node);
|
|
@@ -6917,20 +7089,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6917
7089
|
});
|
|
6918
7090
|
|
|
6919
7091
|
// src/rules/prefer-non-nullable-collection.ts
|
|
6920
|
-
import { AST_NODE_TYPES as
|
|
7092
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES34 } from "@typescript-eslint/utils";
|
|
6921
7093
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
6922
7094
|
function propertyName(node) {
|
|
6923
7095
|
const key = node.key;
|
|
6924
|
-
if (key.type ===
|
|
6925
|
-
if (key.type ===
|
|
7096
|
+
if (key.type === AST_NODE_TYPES34.Identifier) return key.name;
|
|
7097
|
+
if (key.type === AST_NODE_TYPES34.Literal) return String(key.value);
|
|
6926
7098
|
return "collection";
|
|
6927
7099
|
}
|
|
6928
7100
|
function isArrayType(node) {
|
|
6929
|
-
if (node.type ===
|
|
6930
|
-
return node.type ===
|
|
7101
|
+
if (node.type === AST_NODE_TYPES34.TSArrayType) return true;
|
|
7102
|
+
return node.type === AST_NODE_TYPES34.TSTypeReference && node.typeName.type === AST_NODE_TYPES34.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
6931
7103
|
}
|
|
6932
7104
|
function isNullishType(node) {
|
|
6933
|
-
return node.type ===
|
|
7105
|
+
return node.type === AST_NODE_TYPES34.TSNullKeyword || node.type === AST_NODE_TYPES34.TSUndefinedKeyword;
|
|
6934
7106
|
}
|
|
6935
7107
|
function isNullableArrayOnly(node) {
|
|
6936
7108
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -6941,7 +7113,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6941
7113
|
meta: {
|
|
6942
7114
|
type: "suggestion",
|
|
6943
7115
|
docs: {
|
|
6944
|
-
description: "Require
|
|
7116
|
+
description: "Require declared data-shape properties and direct aliases to use non-null arrays instead of explicit nullish unions."
|
|
6945
7117
|
},
|
|
6946
7118
|
schema: [],
|
|
6947
7119
|
messages: {
|
|
@@ -6957,7 +7129,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6957
7129
|
function checkOptionalProperty(node) {
|
|
6958
7130
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
6959
7131
|
if (annotation === void 0) return;
|
|
6960
|
-
if (annotation.type !==
|
|
7132
|
+
if (annotation.type !== AST_NODE_TYPES34.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
6961
7133
|
return;
|
|
6962
7134
|
}
|
|
6963
7135
|
context.report({
|
|
@@ -6970,7 +7142,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6970
7142
|
TSPropertySignature: checkOptionalProperty,
|
|
6971
7143
|
PropertyDefinition: checkOptionalProperty,
|
|
6972
7144
|
TSTypeAliasDeclaration(node) {
|
|
6973
|
-
if (node.typeAnnotation.type !==
|
|
7145
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES34.TSUnionType) return;
|
|
6974
7146
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
6975
7147
|
context.report({
|
|
6976
7148
|
node,
|
|
@@ -6983,13 +7155,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6983
7155
|
});
|
|
6984
7156
|
|
|
6985
7157
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
6986
|
-
import { AST_NODE_TYPES as
|
|
7158
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35 } from "@typescript-eslint/utils";
|
|
6987
7159
|
var unwrap4 = (node) => {
|
|
6988
7160
|
let current = node;
|
|
6989
7161
|
while (current !== null && current !== void 0) {
|
|
6990
|
-
if (current.type ===
|
|
7162
|
+
if (current.type === AST_NODE_TYPES35.TSAsExpression || current.type === AST_NODE_TYPES35.TSTypeAssertion || current.type === AST_NODE_TYPES35.TSNonNullExpression || current.type === AST_NODE_TYPES35.TSSatisfiesExpression) {
|
|
6991
7163
|
current = current.expression;
|
|
6992
|
-
} else if (current.type ===
|
|
7164
|
+
} else if (current.type === AST_NODE_TYPES35.ChainExpression) {
|
|
6993
7165
|
current = current.expression;
|
|
6994
7166
|
} else {
|
|
6995
7167
|
break;
|
|
@@ -7004,23 +7176,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7004
7176
|
]);
|
|
7005
7177
|
var isSchemaParseReference = (node) => {
|
|
7006
7178
|
const inner = unwrap4(node);
|
|
7007
|
-
return inner !== null && inner.type ===
|
|
7179
|
+
return inner !== null && inner.type === AST_NODE_TYPES35.MemberExpression && !inner.computed && inner.property.type === AST_NODE_TYPES35.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7008
7180
|
};
|
|
7009
7181
|
var isRawPayloadSource = (node) => {
|
|
7010
7182
|
let current = unwrap4(node);
|
|
7011
7183
|
if (current === null) return false;
|
|
7012
|
-
if (current.type ===
|
|
7184
|
+
if (current.type === AST_NODE_TYPES35.AwaitExpression) {
|
|
7013
7185
|
current = unwrap4(current.argument);
|
|
7014
7186
|
}
|
|
7015
|
-
if (current === null || current.type !==
|
|
7187
|
+
if (current === null || current.type !== AST_NODE_TYPES35.CallExpression) {
|
|
7016
7188
|
return false;
|
|
7017
7189
|
}
|
|
7018
7190
|
const callee = unwrap4(current.callee);
|
|
7019
|
-
if (callee === null || callee.type !==
|
|
7191
|
+
if (callee === null || callee.type !== AST_NODE_TYPES35.MemberExpression) {
|
|
7020
7192
|
return false;
|
|
7021
7193
|
}
|
|
7022
7194
|
const property = unwrap4(callee.property);
|
|
7023
|
-
if (property === null || property.type !==
|
|
7195
|
+
if (property === null || property.type !== AST_NODE_TYPES35.Identifier) {
|
|
7024
7196
|
return false;
|
|
7025
7197
|
}
|
|
7026
7198
|
if (property.name === "json") {
|
|
@@ -7030,17 +7202,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7030
7202
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7031
7203
|
}
|
|
7032
7204
|
const object = unwrap4(callee.object);
|
|
7033
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7034
|
-
!isLocalFileRead(current.arguments[0]);
|
|
7205
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES35.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7035
7206
|
};
|
|
7036
7207
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7037
7208
|
var isLocalFileRead = (node) => {
|
|
7038
7209
|
let found = false;
|
|
7039
7210
|
const visit = (current) => {
|
|
7040
7211
|
if (found || current === null || current === void 0) return;
|
|
7041
|
-
if (current.type ===
|
|
7212
|
+
if (current.type === AST_NODE_TYPES35.CallExpression) {
|
|
7042
7213
|
const callee = unwrap4(current.callee);
|
|
7043
|
-
const name = callee?.type ===
|
|
7214
|
+
const name = callee?.type === AST_NODE_TYPES35.Identifier ? callee.name : callee?.type === AST_NODE_TYPES35.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES35.Identifier ? callee.property.name : null;
|
|
7044
7215
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7045
7216
|
found = true;
|
|
7046
7217
|
return;
|
|
@@ -7062,15 +7233,15 @@ var isLocalFileRead = (node) => {
|
|
|
7062
7233
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7063
7234
|
var isInsideAssertion = (node) => {
|
|
7064
7235
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7065
|
-
if (current.type !==
|
|
7236
|
+
if (current.type !== AST_NODE_TYPES35.CallExpression) continue;
|
|
7066
7237
|
let callee = current.callee;
|
|
7067
|
-
while (callee.type ===
|
|
7238
|
+
while (callee.type === AST_NODE_TYPES35.MemberExpression) {
|
|
7068
7239
|
callee = callee.object;
|
|
7069
7240
|
}
|
|
7070
|
-
if (callee.type ===
|
|
7241
|
+
if (callee.type === AST_NODE_TYPES35.CallExpression) {
|
|
7071
7242
|
callee = callee.callee;
|
|
7072
7243
|
}
|
|
7073
|
-
if (callee.type ===
|
|
7244
|
+
if (callee.type === AST_NODE_TYPES35.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7074
7245
|
return true;
|
|
7075
7246
|
}
|
|
7076
7247
|
}
|
|
@@ -7089,39 +7260,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7089
7260
|
var isValidationRead = (node) => {
|
|
7090
7261
|
let current = node;
|
|
7091
7262
|
let parent = current.parent;
|
|
7092
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7263
|
+
while (parent !== null && parent !== void 0 && (parent.type === AST_NODE_TYPES35.TSAsExpression || parent.type === AST_NODE_TYPES35.TSTypeAssertion || parent.type === AST_NODE_TYPES35.TSNonNullExpression || parent.type === AST_NODE_TYPES35.TSSatisfiesExpression || parent.type === AST_NODE_TYPES35.ChainExpression)) {
|
|
7093
7264
|
current = parent;
|
|
7094
7265
|
parent = parent.parent;
|
|
7095
7266
|
}
|
|
7096
7267
|
if (parent === null || parent === void 0) return false;
|
|
7097
|
-
if (parent.type ===
|
|
7268
|
+
if (parent.type === AST_NODE_TYPES35.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7098
7269
|
return true;
|
|
7099
7270
|
}
|
|
7100
|
-
if (parent.type !==
|
|
7271
|
+
if (parent.type !== AST_NODE_TYPES35.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7101
7272
|
return false;
|
|
7102
7273
|
}
|
|
7103
7274
|
const callee = parent.callee;
|
|
7104
|
-
if (callee.type ===
|
|
7275
|
+
if (callee.type === AST_NODE_TYPES35.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES35.Identifier && callee.object.name === "Array" && callee.property.type === AST_NODE_TYPES35.Identifier && callee.property.name === "isArray") {
|
|
7105
7276
|
return parent.arguments.length === 1;
|
|
7106
7277
|
}
|
|
7107
|
-
return callee.type ===
|
|
7278
|
+
return callee.type === AST_NODE_TYPES35.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7108
7279
|
};
|
|
7109
7280
|
var isGuardTestPosition = (node) => {
|
|
7110
7281
|
let current = node;
|
|
7111
7282
|
let parent = current.parent;
|
|
7112
7283
|
while (parent !== void 0 && parent !== null) {
|
|
7113
7284
|
switch (parent.type) {
|
|
7114
|
-
case
|
|
7115
|
-
case
|
|
7116
|
-
case
|
|
7285
|
+
case AST_NODE_TYPES35.UnaryExpression:
|
|
7286
|
+
case AST_NODE_TYPES35.LogicalExpression:
|
|
7287
|
+
case AST_NODE_TYPES35.ChainExpression:
|
|
7117
7288
|
current = parent;
|
|
7118
7289
|
parent = parent.parent;
|
|
7119
7290
|
continue;
|
|
7120
|
-
case
|
|
7121
|
-
case
|
|
7122
|
-
case
|
|
7123
|
-
case
|
|
7124
|
-
case
|
|
7291
|
+
case AST_NODE_TYPES35.IfStatement:
|
|
7292
|
+
case AST_NODE_TYPES35.ConditionalExpression:
|
|
7293
|
+
case AST_NODE_TYPES35.WhileStatement:
|
|
7294
|
+
case AST_NODE_TYPES35.DoWhileStatement:
|
|
7295
|
+
case AST_NODE_TYPES35.ForStatement:
|
|
7125
7296
|
return parent.test === current;
|
|
7126
7297
|
default:
|
|
7127
7298
|
return false;
|
|
@@ -7131,7 +7302,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7131
7302
|
};
|
|
7132
7303
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7133
7304
|
const unwrapped = unwrap4(node);
|
|
7134
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7305
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES35.Identifier) {
|
|
7135
7306
|
return false;
|
|
7136
7307
|
}
|
|
7137
7308
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7174,11 +7345,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7174
7345
|
return {
|
|
7175
7346
|
VariableDeclarator(node) {
|
|
7176
7347
|
const scope = context.sourceCode.getScope(node);
|
|
7177
|
-
if (node.id.type ===
|
|
7348
|
+
if (node.id.type === AST_NODE_TYPES35.Identifier) {
|
|
7178
7349
|
trackInitializer(node);
|
|
7179
7350
|
return;
|
|
7180
7351
|
}
|
|
7181
|
-
if (node.id.type ===
|
|
7352
|
+
if (node.id.type === AST_NODE_TYPES35.ObjectPattern || node.id.type === AST_NODE_TYPES35.ArrayPattern) {
|
|
7182
7353
|
if (isRawPayloadSource(node.init)) {
|
|
7183
7354
|
if (!isFullyNarrowedPattern(node)) {
|
|
7184
7355
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7192,7 +7363,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7192
7363
|
},
|
|
7193
7364
|
AssignmentExpression(node) {
|
|
7194
7365
|
const scope = context.sourceCode.getScope(node);
|
|
7195
|
-
if (node.left.type ===
|
|
7366
|
+
if (node.left.type === AST_NODE_TYPES35.Identifier) {
|
|
7196
7367
|
const variable = findVariable2(scope, node.left.name);
|
|
7197
7368
|
if (variable === null) return;
|
|
7198
7369
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7202,7 +7373,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7202
7373
|
}
|
|
7203
7374
|
return;
|
|
7204
7375
|
}
|
|
7205
|
-
if (node.left.type ===
|
|
7376
|
+
if (node.left.type === AST_NODE_TYPES35.ObjectPattern || node.left.type === AST_NODE_TYPES35.ArrayPattern) {
|
|
7206
7377
|
if (isRawPayloadSource(node.right)) {
|
|
7207
7378
|
context.report({
|
|
7208
7379
|
node: node.left,
|
|
@@ -7219,15 +7390,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7219
7390
|
}
|
|
7220
7391
|
},
|
|
7221
7392
|
CallExpression(node) {
|
|
7222
|
-
if (node.callee.type !==
|
|
7393
|
+
if (node.callee.type !== AST_NODE_TYPES35.Identifier) return;
|
|
7223
7394
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7224
7395
|
return;
|
|
7225
7396
|
}
|
|
7226
7397
|
const scope = context.sourceCode.getScope(node);
|
|
7227
7398
|
for (const arg of node.arguments) {
|
|
7228
|
-
if (arg.type ===
|
|
7399
|
+
if (arg.type === AST_NODE_TYPES35.SpreadElement) continue;
|
|
7229
7400
|
const unwrapped = unwrap4(arg);
|
|
7230
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7401
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES35.Identifier) {
|
|
7231
7402
|
continue;
|
|
7232
7403
|
}
|
|
7233
7404
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7241,13 +7412,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7241
7412
|
const obj = unwrap4(node.object);
|
|
7242
7413
|
if (isRawPayloadSource(obj)) {
|
|
7243
7414
|
const parent = node.parent;
|
|
7244
|
-
if (parent.type ===
|
|
7415
|
+
if (parent.type === AST_NODE_TYPES35.CallExpression && parent.callee === node && node.property.type === AST_NODE_TYPES35.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7245
7416
|
return;
|
|
7246
7417
|
}
|
|
7247
7418
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7248
7419
|
return;
|
|
7249
7420
|
}
|
|
7250
|
-
if (obj !== null && obj.type ===
|
|
7421
|
+
if (obj !== null && obj.type === AST_NODE_TYPES35.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7251
7422
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7252
7423
|
const variable = findVariable2(scope, obj.name);
|
|
7253
7424
|
if (variable !== null) {
|
|
@@ -7260,7 +7431,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7260
7431
|
});
|
|
7261
7432
|
|
|
7262
7433
|
// src/rules/prefer-semantic-colors.ts
|
|
7263
|
-
import { AST_NODE_TYPES as
|
|
7434
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36 } from "@typescript-eslint/utils";
|
|
7264
7435
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
7265
7436
|
import { dirname, join, parse } from "path";
|
|
7266
7437
|
|
|
@@ -7360,8 +7531,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7360
7531
|
]);
|
|
7361
7532
|
function jsxElementName(node) {
|
|
7362
7533
|
const name = node.openingElement.name;
|
|
7363
|
-
if (name.type ===
|
|
7364
|
-
if (name.type ===
|
|
7534
|
+
if (name.type === AST_NODE_TYPES36.JSXIdentifier) return name.name;
|
|
7535
|
+
if (name.type === AST_NODE_TYPES36.JSXMemberExpression && name.property.type === AST_NODE_TYPES36.JSXIdentifier) {
|
|
7365
7536
|
return name.property.name;
|
|
7366
7537
|
}
|
|
7367
7538
|
return null;
|
|
@@ -7383,11 +7554,11 @@ var SVG_SHAPE_PRIMITIVES = /* @__PURE__ */ new Set([
|
|
|
7383
7554
|
"tspan",
|
|
7384
7555
|
"use"
|
|
7385
7556
|
]);
|
|
7386
|
-
var
|
|
7557
|
+
var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
7387
7558
|
var isInsideSvg = (node) => {
|
|
7388
7559
|
let current = node.parent;
|
|
7389
7560
|
while (current !== void 0 && current !== null) {
|
|
7390
|
-
if (current.type ===
|
|
7561
|
+
if (current.type === AST_NODE_TYPES36.JSXElement) {
|
|
7391
7562
|
const name = jsxElementName(current);
|
|
7392
7563
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7393
7564
|
}
|
|
@@ -7398,7 +7569,7 @@ var isInsideSvg = (node) => {
|
|
|
7398
7569
|
var isInsideIconFactoryPath = (node) => {
|
|
7399
7570
|
let current = node.parent;
|
|
7400
7571
|
while (current !== void 0 && current !== null) {
|
|
7401
|
-
if (current.type ===
|
|
7572
|
+
if (current.type === AST_NODE_TYPES36.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES36.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES36.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES36.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7402
7573
|
return true;
|
|
7403
7574
|
}
|
|
7404
7575
|
current = current.parent;
|
|
@@ -7535,10 +7706,16 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7535
7706
|
return root !== null && workspaceHasMarker(root);
|
|
7536
7707
|
};
|
|
7537
7708
|
var propName = (key) => {
|
|
7538
|
-
if (key.type ===
|
|
7539
|
-
if (key.type ===
|
|
7709
|
+
if (key.type === AST_NODE_TYPES36.Identifier) return key.name;
|
|
7710
|
+
if (key.type === AST_NODE_TYPES36.Literal && typeof key.value === "string") return key.value;
|
|
7540
7711
|
return null;
|
|
7541
7712
|
};
|
|
7713
|
+
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7714
|
+
if (statement.type !== AST_NODE_TYPES36.ImportDeclaration && statement.type !== AST_NODE_TYPES36.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES36.ExportAllDeclaration) {
|
|
7715
|
+
return false;
|
|
7716
|
+
}
|
|
7717
|
+
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
7718
|
+
});
|
|
7542
7719
|
var prefer_semantic_colors_default = createRule({
|
|
7543
7720
|
name: "prefer-semantic-colors",
|
|
7544
7721
|
meta: {
|
|
@@ -7564,44 +7741,49 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7564
7741
|
defaultOptions: [{}],
|
|
7565
7742
|
create(context, [options]) {
|
|
7566
7743
|
if (STORIES_FILE_RE.test(context.filename)) return {};
|
|
7567
|
-
if (
|
|
7744
|
+
if (staticallyImportsEmailOrPdfRenderer(context.sourceCode.ast)) return {};
|
|
7568
7745
|
if (options?.requireSemanticTokens === true && !hasSemanticTokenSystem(context.filename)) {
|
|
7569
7746
|
return {};
|
|
7570
7747
|
}
|
|
7748
|
+
let importsEmailOrPdfRenderer = false;
|
|
7749
|
+
const pendingReports = [];
|
|
7750
|
+
const report = (node, messageId, data) => {
|
|
7751
|
+
pendingReports.push({ node, messageId, data });
|
|
7752
|
+
};
|
|
7571
7753
|
const reportClasses = (value, node) => {
|
|
7572
7754
|
for (const token of classTokens(value)) {
|
|
7573
7755
|
const base = tailwindBase(token);
|
|
7574
7756
|
if (RAW_PALETTE_RE.test(base)) {
|
|
7575
|
-
|
|
7757
|
+
report(node, "rawPalette", { class: token });
|
|
7576
7758
|
} else if (ARBITRARY_COLOR_RE.test(base) && !CSS_VAR_REFERENCE_RE.test(base)) {
|
|
7577
|
-
|
|
7759
|
+
report(node, "arbitraryColor", { class: token });
|
|
7578
7760
|
}
|
|
7579
7761
|
}
|
|
7580
7762
|
};
|
|
7581
7763
|
const checkClassNode = (node) => {
|
|
7582
7764
|
if (node === null) return;
|
|
7583
7765
|
switch (node.type) {
|
|
7584
|
-
case
|
|
7766
|
+
case AST_NODE_TYPES36.Literal:
|
|
7585
7767
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7586
7768
|
break;
|
|
7587
|
-
case
|
|
7769
|
+
case AST_NODE_TYPES36.TemplateLiteral:
|
|
7588
7770
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7589
7771
|
break;
|
|
7590
|
-
case
|
|
7772
|
+
case AST_NODE_TYPES36.ArrayExpression:
|
|
7591
7773
|
for (const element of node.elements) {
|
|
7592
|
-
if (element !== null && element.type !==
|
|
7774
|
+
if (element !== null && element.type !== AST_NODE_TYPES36.SpreadElement) checkClassNode(element);
|
|
7593
7775
|
}
|
|
7594
7776
|
break;
|
|
7595
|
-
case
|
|
7777
|
+
case AST_NODE_TYPES36.ObjectExpression:
|
|
7596
7778
|
for (const property of node.properties) {
|
|
7597
|
-
if (property.type ===
|
|
7779
|
+
if (property.type === AST_NODE_TYPES36.Property) checkClassNode(property.value);
|
|
7598
7780
|
}
|
|
7599
7781
|
break;
|
|
7600
|
-
case
|
|
7782
|
+
case AST_NODE_TYPES36.ConditionalExpression:
|
|
7601
7783
|
checkClassNode(node.consequent);
|
|
7602
7784
|
checkClassNode(node.alternate);
|
|
7603
7785
|
break;
|
|
7604
|
-
case
|
|
7786
|
+
case AST_NODE_TYPES36.LogicalExpression:
|
|
7605
7787
|
checkClassNode(node.right);
|
|
7606
7788
|
break;
|
|
7607
7789
|
default:
|
|
@@ -7609,29 +7791,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7609
7791
|
}
|
|
7610
7792
|
};
|
|
7611
7793
|
const checkColorValueNode = (node) => {
|
|
7612
|
-
if (node.type ===
|
|
7613
|
-
|
|
7794
|
+
if (node.type === AST_NODE_TYPES36.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
7795
|
+
report(node, "inlineColor", { value: node.value });
|
|
7614
7796
|
}
|
|
7615
7797
|
};
|
|
7616
7798
|
return {
|
|
7617
7799
|
"JSXAttribute[name.name='className']"(node) {
|
|
7618
7800
|
if (node.value === null) return;
|
|
7619
|
-
if (node.value.type ===
|
|
7620
|
-
else if (node.value.type ===
|
|
7621
|
-
if (node.value.expression.type !==
|
|
7801
|
+
if (node.value.type === AST_NODE_TYPES36.Literal) checkClassNode(node.value);
|
|
7802
|
+
else if (node.value.type === AST_NODE_TYPES36.JSXExpressionContainer) {
|
|
7803
|
+
if (node.value.expression.type !== AST_NODE_TYPES36.JSXEmptyExpression) {
|
|
7622
7804
|
checkClassNode(node.value.expression);
|
|
7623
7805
|
}
|
|
7624
7806
|
}
|
|
7625
7807
|
},
|
|
7626
7808
|
CallExpression(node) {
|
|
7627
|
-
if (node.callee.type ===
|
|
7809
|
+
if (node.callee.type === AST_NODE_TYPES36.Identifier && node.callee.name === "require" && node.arguments[0]?.type === AST_NODE_TYPES36.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
7810
|
+
importsEmailOrPdfRenderer = true;
|
|
7811
|
+
}
|
|
7812
|
+
if (node.callee.type === AST_NODE_TYPES36.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7628
7813
|
for (const arg of node.arguments) {
|
|
7629
|
-
if (arg.type !==
|
|
7814
|
+
if (arg.type !== AST_NODE_TYPES36.SpreadElement) checkClassNode(arg);
|
|
7630
7815
|
}
|
|
7631
7816
|
}
|
|
7632
7817
|
},
|
|
7633
7818
|
VariableDeclarator(node) {
|
|
7634
|
-
if (node.id.type ===
|
|
7819
|
+
if (node.id.type === AST_NODE_TYPES36.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
7635
7820
|
checkClassNode(node.init);
|
|
7636
7821
|
}
|
|
7637
7822
|
},
|
|
@@ -7639,13 +7824,11 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7639
7824
|
const name = propName(node.key);
|
|
7640
7825
|
if (name !== null && CLASS_NAME_RE.test(name)) checkClassNode(node.value);
|
|
7641
7826
|
},
|
|
7642
|
-
// SVG
|
|
7643
|
-
// Neutral drawing literals and anything inside an SVG defs container are
|
|
7644
|
-
// structural, not UI tokens, so they never fire.
|
|
7827
|
+
// SVG artwork colors are exempt; component presentation colors still report.
|
|
7645
7828
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
7646
|
-
if (node.value?.type !==
|
|
7829
|
+
if (node.value?.type !== AST_NODE_TYPES36.Literal) return;
|
|
7647
7830
|
const owner = node.parent.name;
|
|
7648
|
-
if (owner.type ===
|
|
7831
|
+
if (owner.type === AST_NODE_TYPES36.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
7649
7832
|
return;
|
|
7650
7833
|
}
|
|
7651
7834
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -7657,6 +7840,15 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7657
7840
|
"JSXAttribute[name.name='style'] ObjectExpression > Property"(node) {
|
|
7658
7841
|
const name = propName(node.key);
|
|
7659
7842
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
7843
|
+
},
|
|
7844
|
+
ImportExpression(node) {
|
|
7845
|
+
if (node.source.type === AST_NODE_TYPES36.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
7846
|
+
importsEmailOrPdfRenderer = true;
|
|
7847
|
+
}
|
|
7848
|
+
},
|
|
7849
|
+
"Program:exit"() {
|
|
7850
|
+
if (importsEmailOrPdfRenderer) return;
|
|
7851
|
+
for (const descriptor of pendingReports) context.report(descriptor);
|
|
7660
7852
|
}
|
|
7661
7853
|
};
|
|
7662
7854
|
}
|
|
@@ -7724,6 +7916,22 @@ function isMutationMethod(node, context) {
|
|
|
7724
7916
|
}
|
|
7725
7917
|
return false;
|
|
7726
7918
|
}
|
|
7919
|
+
function isFunctionArgument(node, context) {
|
|
7920
|
+
const resolved = resolveNode(node, context);
|
|
7921
|
+
if (resolved?.type === "ArrowFunctionExpression" || resolved?.type === "FunctionExpression") {
|
|
7922
|
+
return true;
|
|
7923
|
+
}
|
|
7924
|
+
if (node.type !== "Identifier") return false;
|
|
7925
|
+
let scope = getScope(context, node);
|
|
7926
|
+
while (scope) {
|
|
7927
|
+
const variable = scope.set.get(node.name);
|
|
7928
|
+
if (variable?.defs.some((definition) => definition.type === "FunctionName")) {
|
|
7929
|
+
return true;
|
|
7930
|
+
}
|
|
7931
|
+
scope = scope.upper;
|
|
7932
|
+
}
|
|
7933
|
+
return false;
|
|
7934
|
+
}
|
|
7727
7935
|
function getPropertyNode(objNode, propName2) {
|
|
7728
7936
|
if (!objNode || objNode.type !== "ObjectExpression") return null;
|
|
7729
7937
|
for (const prop of objNode.properties) {
|
|
@@ -7761,13 +7969,10 @@ var prefer_server_actions_default = createRule({
|
|
|
7761
7969
|
if (SKIP_FILE_REGEX.test(filename)) {
|
|
7762
7970
|
return {};
|
|
7763
7971
|
}
|
|
7764
|
-
|
|
7972
|
+
const isNonReactFramework = context.sourceCode.ast.body.some(
|
|
7973
|
+
(node) => node.type === "ImportDeclaration" && typeof node.source.value === "string" && NON_REACT_FRAMEWORK_RE.test(node.source.value)
|
|
7974
|
+
);
|
|
7765
7975
|
return {
|
|
7766
|
-
ImportDeclaration(node) {
|
|
7767
|
-
if (typeof node.source.value === "string" && NON_REACT_FRAMEWORK_RE.test(node.source.value)) {
|
|
7768
|
-
isNonReactFramework = true;
|
|
7769
|
-
}
|
|
7770
|
-
},
|
|
7771
7976
|
CallExpression(node) {
|
|
7772
7977
|
if (isNonReactFramework) return;
|
|
7773
7978
|
let isMutation = false;
|
|
@@ -7788,7 +7993,7 @@ var prefer_server_actions_default = createRule({
|
|
|
7788
7993
|
if (AXIOS_MUTATION_METHODS.has(methodName)) {
|
|
7789
7994
|
const urlArg = node.arguments[0];
|
|
7790
7995
|
const hasHandlerArg = node.arguments.some(
|
|
7791
|
-
(arg) => arg.type
|
|
7996
|
+
(arg) => arg.type !== "SpreadElement" && isFunctionArgument(arg, context)
|
|
7792
7997
|
);
|
|
7793
7998
|
if (urlArg && urlArg.type !== "SpreadElement" && !hasHandlerArg && isApiUrl(urlArg, context)) {
|
|
7794
7999
|
isMutation = true;
|
|
@@ -7815,10 +8020,35 @@ var prefer_server_actions_default = createRule({
|
|
|
7815
8020
|
}
|
|
7816
8021
|
});
|
|
7817
8022
|
|
|
8023
|
+
// src/rules/prefer-single-sentence-comment.ts
|
|
8024
|
+
var prefer_single_sentence_comment_default = createRule({
|
|
8025
|
+
name: "prefer-single-sentence-comment",
|
|
8026
|
+
meta: {
|
|
8027
|
+
type: "suggestion",
|
|
8028
|
+
docs: { description: "Prefer one sentence and self-documenting code over a two-sentence comment." },
|
|
8029
|
+
schema: [],
|
|
8030
|
+
messages: {
|
|
8031
|
+
preferOneSentence: "Two-sentence comment \u2014 prefer one sentence and self-documenting code."
|
|
8032
|
+
}
|
|
8033
|
+
},
|
|
8034
|
+
defaultOptions: [],
|
|
8035
|
+
create(context) {
|
|
8036
|
+
return {
|
|
8037
|
+
Program() {
|
|
8038
|
+
for (const group of proseGroups(context.filename, context.sourceCode)) {
|
|
8039
|
+
if (!group.hasTypedTags && sentenceUnits(group.text) === 2) {
|
|
8040
|
+
context.report({ node: group.comment, messageId: "preferOneSentence" });
|
|
8041
|
+
}
|
|
8042
|
+
}
|
|
8043
|
+
}
|
|
8044
|
+
};
|
|
8045
|
+
}
|
|
8046
|
+
});
|
|
8047
|
+
|
|
7818
8048
|
// src/rules/prefer-string-literal-union.ts
|
|
7819
8049
|
import {
|
|
7820
8050
|
ESLintUtils as ESLintUtils3,
|
|
7821
|
-
AST_NODE_TYPES as
|
|
8051
|
+
AST_NODE_TYPES as AST_NODE_TYPES37
|
|
7822
8052
|
} from "@typescript-eslint/utils";
|
|
7823
8053
|
import * as ts2 from "typescript";
|
|
7824
8054
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -7862,19 +8092,19 @@ function isChoiceLikeName(name) {
|
|
|
7862
8092
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
7863
8093
|
}
|
|
7864
8094
|
function keyName(key) {
|
|
7865
|
-
if (key.type ===
|
|
8095
|
+
if (key.type === AST_NODE_TYPES37.Identifier) {
|
|
7866
8096
|
return key.name;
|
|
7867
8097
|
}
|
|
7868
|
-
if (key.type ===
|
|
8098
|
+
if (key.type === AST_NODE_TYPES37.Literal && typeof key.value === "string") {
|
|
7869
8099
|
return key.value;
|
|
7870
8100
|
}
|
|
7871
8101
|
return null;
|
|
7872
8102
|
}
|
|
7873
8103
|
function isStringLiteralMember(t) {
|
|
7874
|
-
return t.type ===
|
|
8104
|
+
return t.type === AST_NODE_TYPES37.TSLiteralType && t.literal.type === AST_NODE_TYPES37.Literal && typeof t.literal.value === "string";
|
|
7875
8105
|
}
|
|
7876
8106
|
function isStringLiteralUnion(node) {
|
|
7877
|
-
if (node?.type !==
|
|
8107
|
+
if (node?.type !== AST_NODE_TYPES37.TSUnionType) {
|
|
7878
8108
|
return false;
|
|
7879
8109
|
}
|
|
7880
8110
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -7903,12 +8133,12 @@ function bindingSourceExpression(decl) {
|
|
|
7903
8133
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
7904
8134
|
}
|
|
7905
8135
|
function refKey(node) {
|
|
7906
|
-
if (node.type ===
|
|
8136
|
+
if (node.type === AST_NODE_TYPES37.Identifier) {
|
|
7907
8137
|
return node.name;
|
|
7908
8138
|
}
|
|
7909
|
-
if (node.type ===
|
|
8139
|
+
if (node.type === AST_NODE_TYPES37.MemberExpression && !node.computed) {
|
|
7910
8140
|
const inner = refKey(node.object);
|
|
7911
|
-
if (inner === null || node.property.type !==
|
|
8141
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES37.Identifier) {
|
|
7912
8142
|
return null;
|
|
7913
8143
|
}
|
|
7914
8144
|
return `${inner}.${node.property.name}`;
|
|
@@ -7916,7 +8146,7 @@ function refKey(node) {
|
|
|
7916
8146
|
return null;
|
|
7917
8147
|
}
|
|
7918
8148
|
function strLiteral(node) {
|
|
7919
|
-
if (node.type ===
|
|
8149
|
+
if (node.type === AST_NODE_TYPES37.Literal && typeof node.value === "string") {
|
|
7920
8150
|
return node.value;
|
|
7921
8151
|
}
|
|
7922
8152
|
return null;
|
|
@@ -8069,7 +8299,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8069
8299
|
containersWithUnion.add(container);
|
|
8070
8300
|
return;
|
|
8071
8301
|
}
|
|
8072
|
-
if (typeNode?.type !==
|
|
8302
|
+
if (typeNode?.type !== AST_NODE_TYPES37.TSStringKeyword) {
|
|
8073
8303
|
return;
|
|
8074
8304
|
}
|
|
8075
8305
|
const name = keyName(key);
|
|
@@ -8157,10 +8387,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8157
8387
|
}
|
|
8158
8388
|
};
|
|
8159
8389
|
function refKeyText(node) {
|
|
8160
|
-
if (node.type ===
|
|
8390
|
+
if (node.type === AST_NODE_TYPES37.BinaryExpression) {
|
|
8161
8391
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8162
8392
|
}
|
|
8163
|
-
if (node.type ===
|
|
8393
|
+
if (node.type === AST_NODE_TYPES37.SwitchStatement) {
|
|
8164
8394
|
return refKey(node.discriminant) ?? "value";
|
|
8165
8395
|
}
|
|
8166
8396
|
return "value";
|
|
@@ -8169,7 +8399,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8169
8399
|
});
|
|
8170
8400
|
|
|
8171
8401
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8172
|
-
import { AST_NODE_TYPES as
|
|
8402
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
8173
8403
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8174
8404
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8175
8405
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8178,11 +8408,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8178
8408
|
var MIN_RUN_LENGTH = 2;
|
|
8179
8409
|
function literalText(node, getText) {
|
|
8180
8410
|
switch (node.type) {
|
|
8181
|
-
case
|
|
8411
|
+
case AST_NODE_TYPES38.Literal:
|
|
8182
8412
|
return "regex" in node ? null : getText(node);
|
|
8183
|
-
case
|
|
8413
|
+
case AST_NODE_TYPES38.TemplateLiteral:
|
|
8184
8414
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8185
|
-
case
|
|
8415
|
+
case AST_NODE_TYPES38.UnaryExpression:
|
|
8186
8416
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8187
8417
|
default:
|
|
8188
8418
|
return null;
|
|
@@ -8190,15 +8420,15 @@ function literalText(node, getText) {
|
|
|
8190
8420
|
}
|
|
8191
8421
|
function isPureReceiver(node) {
|
|
8192
8422
|
switch (node.type) {
|
|
8193
|
-
case
|
|
8194
|
-
case
|
|
8423
|
+
case AST_NODE_TYPES38.Identifier:
|
|
8424
|
+
case AST_NODE_TYPES38.ThisExpression:
|
|
8195
8425
|
return true;
|
|
8196
|
-
case
|
|
8426
|
+
case AST_NODE_TYPES38.MemberExpression:
|
|
8197
8427
|
if (node.optional) {
|
|
8198
8428
|
return false;
|
|
8199
8429
|
}
|
|
8200
8430
|
if (node.computed) {
|
|
8201
|
-
return node.property.type ===
|
|
8431
|
+
return node.property.type === AST_NODE_TYPES38.Literal && isPureReceiver(node.object);
|
|
8202
8432
|
}
|
|
8203
8433
|
return isPureReceiver(node.object);
|
|
8204
8434
|
default:
|
|
@@ -8206,7 +8436,7 @@ function isPureReceiver(node) {
|
|
|
8206
8436
|
}
|
|
8207
8437
|
}
|
|
8208
8438
|
function literalIndex(node) {
|
|
8209
|
-
if (node.type !==
|
|
8439
|
+
if (node.type !== AST_NODE_TYPES38.Literal || typeof node.value !== "number") {
|
|
8210
8440
|
return null;
|
|
8211
8441
|
}
|
|
8212
8442
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8232,24 +8462,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8232
8462
|
}
|
|
8233
8463
|
const { sourceCode } = context;
|
|
8234
8464
|
function parseAssertion(statement) {
|
|
8235
|
-
if (statement.type !==
|
|
8465
|
+
if (statement.type !== AST_NODE_TYPES38.ExpressionStatement) {
|
|
8236
8466
|
return null;
|
|
8237
8467
|
}
|
|
8238
8468
|
const call = statement.expression;
|
|
8239
|
-
if (call.type !==
|
|
8469
|
+
if (call.type !== AST_NODE_TYPES38.CallExpression) {
|
|
8240
8470
|
return null;
|
|
8241
8471
|
}
|
|
8242
8472
|
const callee = call.callee;
|
|
8243
|
-
if (callee.type !==
|
|
8473
|
+
if (callee.type !== AST_NODE_TYPES38.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES38.Identifier) {
|
|
8244
8474
|
return null;
|
|
8245
8475
|
}
|
|
8246
8476
|
const matcher = callee.property.name;
|
|
8247
8477
|
const expectCall = callee.object;
|
|
8248
|
-
if (expectCall.type !==
|
|
8478
|
+
if (expectCall.type !== AST_NODE_TYPES38.CallExpression || expectCall.callee.type !== AST_NODE_TYPES38.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8249
8479
|
return null;
|
|
8250
8480
|
}
|
|
8251
8481
|
const actual = expectCall.arguments[0];
|
|
8252
|
-
if (actual === void 0 || actual.type !==
|
|
8482
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES38.MemberExpression || actual.optional) {
|
|
8253
8483
|
return null;
|
|
8254
8484
|
}
|
|
8255
8485
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8263,7 +8493,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8263
8493
|
}
|
|
8264
8494
|
key = { kind: "index", index };
|
|
8265
8495
|
} else {
|
|
8266
|
-
if (actual.property.type !==
|
|
8496
|
+
if (actual.property.type !== AST_NODE_TYPES38.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8267
8497
|
return null;
|
|
8268
8498
|
}
|
|
8269
8499
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8275,7 +8505,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8275
8505
|
return null;
|
|
8276
8506
|
}
|
|
8277
8507
|
const expected = call.arguments[0];
|
|
8278
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8508
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES38.SpreadElement) {
|
|
8279
8509
|
return null;
|
|
8280
8510
|
}
|
|
8281
8511
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8351,7 +8581,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8351
8581
|
}
|
|
8352
8582
|
});
|
|
8353
8583
|
}
|
|
8354
|
-
function checkBody(
|
|
8584
|
+
function checkBody(body2) {
|
|
8355
8585
|
let run = [];
|
|
8356
8586
|
const flush = () => {
|
|
8357
8587
|
const first = run[0];
|
|
@@ -8364,7 +8594,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8364
8594
|
}
|
|
8365
8595
|
run = [];
|
|
8366
8596
|
};
|
|
8367
|
-
for (const statement of
|
|
8597
|
+
for (const statement of body2) {
|
|
8368
8598
|
const assertion = parseAssertion(statement);
|
|
8369
8599
|
const previous = run.at(-1);
|
|
8370
8600
|
if (assertion !== null && previous !== void 0 && previous.key.kind === assertion.key.kind && sourceCode.getText(previous.receiver) === sourceCode.getText(assertion.receiver)) {
|
|
@@ -8390,7 +8620,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8390
8620
|
});
|
|
8391
8621
|
|
|
8392
8622
|
// src/rules/prefer-zod-enum.ts
|
|
8393
|
-
import { AST_NODE_TYPES as
|
|
8623
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39 } from "@typescript-eslint/utils";
|
|
8394
8624
|
var prefer_zod_enum_default = createRule({
|
|
8395
8625
|
name: "prefer-zod-enum",
|
|
8396
8626
|
meta: {
|
|
@@ -8410,33 +8640,39 @@ var prefer_zod_enum_default = createRule({
|
|
|
8410
8640
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8411
8641
|
function enumValues(node) {
|
|
8412
8642
|
const callee = node.callee;
|
|
8413
|
-
if (callee.type !==
|
|
8643
|
+
if (callee.type !== AST_NODE_TYPES39.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES39.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== AST_NODE_TYPES39.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8414
8644
|
return null;
|
|
8415
8645
|
}
|
|
8416
8646
|
const argument = node.arguments[0];
|
|
8417
|
-
if (argument === void 0 || argument.type !==
|
|
8647
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES39.ArrayExpression || argument.elements.length === 0) {
|
|
8418
8648
|
return null;
|
|
8419
8649
|
}
|
|
8420
8650
|
const values = [];
|
|
8651
|
+
let canFix = true;
|
|
8421
8652
|
for (const element of argument.elements) {
|
|
8422
|
-
if (element ===
|
|
8653
|
+
if (element?.type === AST_NODE_TYPES39.SpreadElement) {
|
|
8654
|
+
canFix = false;
|
|
8655
|
+
continue;
|
|
8656
|
+
}
|
|
8657
|
+
if (element === null || element.type !== AST_NODE_TYPES39.CallExpression || element.callee.type !== AST_NODE_TYPES39.MemberExpression || element.callee.computed || element.callee.object.type !== AST_NODE_TYPES39.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== AST_NODE_TYPES39.Identifier || element.callee.property.name !== "literal") {
|
|
8423
8658
|
return null;
|
|
8424
8659
|
}
|
|
8425
8660
|
const value = element.arguments[0];
|
|
8426
|
-
if (value === void 0 || value.type !==
|
|
8427
|
-
|
|
8661
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== AST_NODE_TYPES39.Literal || typeof value.value !== "string") {
|
|
8662
|
+
canFix = false;
|
|
8663
|
+
continue;
|
|
8428
8664
|
}
|
|
8429
8665
|
values.push(value);
|
|
8430
8666
|
}
|
|
8431
|
-
return values;
|
|
8667
|
+
return canFix ? values : void 0;
|
|
8432
8668
|
}
|
|
8433
8669
|
function buildFix(node, values) {
|
|
8434
8670
|
const argument = node.arguments[0];
|
|
8435
|
-
if (argument === void 0 || argument.type !==
|
|
8671
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES39.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8436
8672
|
return void 0;
|
|
8437
8673
|
}
|
|
8438
8674
|
const callee = node.callee;
|
|
8439
|
-
if (callee.type !==
|
|
8675
|
+
if (callee.type !== AST_NODE_TYPES39.MemberExpression || callee.property.type !== AST_NODE_TYPES39.Identifier) {
|
|
8440
8676
|
return void 0;
|
|
8441
8677
|
}
|
|
8442
8678
|
return (fixer) => [
|
|
@@ -8453,7 +8689,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8453
8689
|
return;
|
|
8454
8690
|
}
|
|
8455
8691
|
for (const specifier of node.specifiers) {
|
|
8456
|
-
if (specifier.type ===
|
|
8692
|
+
if (specifier.type === AST_NODE_TYPES39.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES39.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES39.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES39.Identifier && specifier.imported.name === "z") {
|
|
8457
8693
|
zodNamespaces.add(specifier.local.name);
|
|
8458
8694
|
}
|
|
8459
8695
|
}
|
|
@@ -8463,7 +8699,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8463
8699
|
if (values === null) {
|
|
8464
8700
|
return;
|
|
8465
8701
|
}
|
|
8466
|
-
const fix = buildFix(node, values);
|
|
8702
|
+
const fix = values === void 0 ? void 0 : buildFix(node, values);
|
|
8467
8703
|
context.report({
|
|
8468
8704
|
node,
|
|
8469
8705
|
messageId: "preferEnum",
|
|
@@ -8475,7 +8711,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8475
8711
|
});
|
|
8476
8712
|
|
|
8477
8713
|
// src/rules/prefer-zod-infer.ts
|
|
8478
|
-
import { AST_NODE_TYPES as
|
|
8714
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40 } from "@typescript-eslint/utils";
|
|
8479
8715
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8480
8716
|
"describe",
|
|
8481
8717
|
"refine",
|
|
@@ -8512,44 +8748,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8512
8748
|
"Schema"
|
|
8513
8749
|
]);
|
|
8514
8750
|
var LEAF_NODE_TYPES = {
|
|
8515
|
-
string: [
|
|
8516
|
-
email: [
|
|
8517
|
-
url: [
|
|
8518
|
-
uuid: [
|
|
8519
|
-
ulid: [
|
|
8520
|
-
cuid: [
|
|
8521
|
-
cuid2: [
|
|
8522
|
-
nanoid: [
|
|
8523
|
-
iso: [
|
|
8524
|
-
number: [
|
|
8525
|
-
int: [
|
|
8526
|
-
float32: [
|
|
8527
|
-
float64: [
|
|
8528
|
-
boolean: [
|
|
8529
|
-
bigint: [
|
|
8530
|
-
symbol: [
|
|
8531
|
-
any: [
|
|
8532
|
-
unknown: [
|
|
8533
|
-
never: [
|
|
8534
|
-
void: [
|
|
8535
|
-
null: [
|
|
8536
|
-
undefined: [
|
|
8537
|
-
literal: [
|
|
8538
|
-
date: [
|
|
8539
|
-
array: [
|
|
8540
|
-
tuple: [
|
|
8541
|
-
object: [
|
|
8542
|
-
strictObject: [
|
|
8543
|
-
looseObject: [
|
|
8544
|
-
record: [
|
|
8545
|
-
map: [
|
|
8546
|
-
set: [
|
|
8547
|
-
promise: [
|
|
8548
|
-
enum: [
|
|
8549
|
-
nativeEnum: [
|
|
8550
|
-
union: [
|
|
8551
|
-
discriminatedUnion: [
|
|
8552
|
-
intersection: [
|
|
8751
|
+
string: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8752
|
+
email: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8753
|
+
url: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8754
|
+
uuid: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8755
|
+
ulid: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8756
|
+
cuid: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8757
|
+
cuid2: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8758
|
+
nanoid: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8759
|
+
iso: [AST_NODE_TYPES40.TSStringKeyword],
|
|
8760
|
+
number: [AST_NODE_TYPES40.TSNumberKeyword],
|
|
8761
|
+
int: [AST_NODE_TYPES40.TSNumberKeyword],
|
|
8762
|
+
float32: [AST_NODE_TYPES40.TSNumberKeyword],
|
|
8763
|
+
float64: [AST_NODE_TYPES40.TSNumberKeyword],
|
|
8764
|
+
boolean: [AST_NODE_TYPES40.TSBooleanKeyword],
|
|
8765
|
+
bigint: [AST_NODE_TYPES40.TSBigIntKeyword],
|
|
8766
|
+
symbol: [AST_NODE_TYPES40.TSSymbolKeyword],
|
|
8767
|
+
any: [AST_NODE_TYPES40.TSAnyKeyword],
|
|
8768
|
+
unknown: [AST_NODE_TYPES40.TSUnknownKeyword],
|
|
8769
|
+
never: [AST_NODE_TYPES40.TSNeverKeyword],
|
|
8770
|
+
void: [AST_NODE_TYPES40.TSVoidKeyword],
|
|
8771
|
+
null: [AST_NODE_TYPES40.TSNullKeyword],
|
|
8772
|
+
undefined: [AST_NODE_TYPES40.TSUndefinedKeyword],
|
|
8773
|
+
literal: [AST_NODE_TYPES40.TSLiteralType],
|
|
8774
|
+
date: [AST_NODE_TYPES40.TSTypeReference],
|
|
8775
|
+
array: [AST_NODE_TYPES40.TSArrayType, AST_NODE_TYPES40.TSTypeReference],
|
|
8776
|
+
tuple: [AST_NODE_TYPES40.TSTupleType],
|
|
8777
|
+
object: [AST_NODE_TYPES40.TSTypeLiteral, AST_NODE_TYPES40.TSTypeReference],
|
|
8778
|
+
strictObject: [AST_NODE_TYPES40.TSTypeLiteral, AST_NODE_TYPES40.TSTypeReference],
|
|
8779
|
+
looseObject: [AST_NODE_TYPES40.TSTypeLiteral, AST_NODE_TYPES40.TSTypeReference],
|
|
8780
|
+
record: [AST_NODE_TYPES40.TSTypeReference, AST_NODE_TYPES40.TSTypeLiteral],
|
|
8781
|
+
map: [AST_NODE_TYPES40.TSTypeReference],
|
|
8782
|
+
set: [AST_NODE_TYPES40.TSTypeReference],
|
|
8783
|
+
promise: [AST_NODE_TYPES40.TSTypeReference],
|
|
8784
|
+
enum: [AST_NODE_TYPES40.TSUnionType, AST_NODE_TYPES40.TSTypeReference, AST_NODE_TYPES40.TSLiteralType],
|
|
8785
|
+
nativeEnum: [AST_NODE_TYPES40.TSUnionType, AST_NODE_TYPES40.TSTypeReference, AST_NODE_TYPES40.TSLiteralType],
|
|
8786
|
+
union: [AST_NODE_TYPES40.TSUnionType, AST_NODE_TYPES40.TSTypeReference],
|
|
8787
|
+
discriminatedUnion: [AST_NODE_TYPES40.TSUnionType, AST_NODE_TYPES40.TSTypeReference],
|
|
8788
|
+
intersection: [AST_NODE_TYPES40.TSIntersectionType, AST_NODE_TYPES40.TSTypeReference]
|
|
8553
8789
|
};
|
|
8554
8790
|
function normalizeSchemaName(name) {
|
|
8555
8791
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8558,20 +8794,20 @@ function normalizeTypeName(name) {
|
|
|
8558
8794
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8559
8795
|
}
|
|
8560
8796
|
function unwrapNullish(annotation) {
|
|
8561
|
-
if (annotation.type !==
|
|
8797
|
+
if (annotation.type !== AST_NODE_TYPES40.TSUnionType) {
|
|
8562
8798
|
return {
|
|
8563
8799
|
core: annotation,
|
|
8564
|
-
nullable: annotation.type ===
|
|
8800
|
+
nullable: annotation.type === AST_NODE_TYPES40.TSNullKeyword
|
|
8565
8801
|
};
|
|
8566
8802
|
}
|
|
8567
8803
|
const rest = [];
|
|
8568
8804
|
let nullable = false;
|
|
8569
8805
|
for (const member of annotation.types) {
|
|
8570
|
-
if (member.type ===
|
|
8806
|
+
if (member.type === AST_NODE_TYPES40.TSNullKeyword) {
|
|
8571
8807
|
nullable = true;
|
|
8572
8808
|
continue;
|
|
8573
8809
|
}
|
|
8574
|
-
if (member.type ===
|
|
8810
|
+
if (member.type === AST_NODE_TYPES40.TSUndefinedKeyword) {
|
|
8575
8811
|
continue;
|
|
8576
8812
|
}
|
|
8577
8813
|
rest.push(member);
|
|
@@ -8636,14 +8872,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8636
8872
|
function zodCallChain(node) {
|
|
8637
8873
|
const chain = [];
|
|
8638
8874
|
let current = node;
|
|
8639
|
-
while (current.type ===
|
|
8875
|
+
while (current.type === AST_NODE_TYPES40.CallExpression) {
|
|
8640
8876
|
const callee = current.callee;
|
|
8641
|
-
if (callee.type !==
|
|
8877
|
+
if (callee.type !== AST_NODE_TYPES40.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES40.Identifier) {
|
|
8642
8878
|
return null;
|
|
8643
8879
|
}
|
|
8644
8880
|
chain.push(current);
|
|
8645
8881
|
const receiver = callee.object;
|
|
8646
|
-
if (receiver.type ===
|
|
8882
|
+
if (receiver.type === AST_NODE_TYPES40.Identifier) {
|
|
8647
8883
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
8648
8884
|
}
|
|
8649
8885
|
current = receiver;
|
|
@@ -8652,19 +8888,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
8652
8888
|
}
|
|
8653
8889
|
function methodName(call) {
|
|
8654
8890
|
const callee = call.callee;
|
|
8655
|
-
return callee.type ===
|
|
8891
|
+
return callee.type === AST_NODE_TYPES40.MemberExpression && callee.property.type === AST_NODE_TYPES40.Identifier ? callee.property.name : "";
|
|
8656
8892
|
}
|
|
8657
8893
|
function schemaField(node) {
|
|
8658
8894
|
const modifiers = [];
|
|
8659
8895
|
let current = node;
|
|
8660
8896
|
let leaf = null;
|
|
8661
|
-
while (current.type ===
|
|
8897
|
+
while (current.type === AST_NODE_TYPES40.CallExpression) {
|
|
8662
8898
|
const callee = current.callee;
|
|
8663
|
-
if (callee.type !==
|
|
8899
|
+
if (callee.type !== AST_NODE_TYPES40.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES40.Identifier) {
|
|
8664
8900
|
break;
|
|
8665
8901
|
}
|
|
8666
8902
|
const receiver = callee.object;
|
|
8667
|
-
if (receiver.type ===
|
|
8903
|
+
if (receiver.type === AST_NODE_TYPES40.Identifier && zodNamespaces.has(receiver.name)) {
|
|
8668
8904
|
leaf = callee.property.name;
|
|
8669
8905
|
break;
|
|
8670
8906
|
}
|
|
@@ -8695,16 +8931,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8695
8931
|
return null;
|
|
8696
8932
|
}
|
|
8697
8933
|
const shape = base.arguments[0];
|
|
8698
|
-
if (shape === void 0 || shape.type !==
|
|
8934
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES40.ObjectExpression) {
|
|
8699
8935
|
return null;
|
|
8700
8936
|
}
|
|
8701
8937
|
const fields = /* @__PURE__ */ new Map();
|
|
8702
8938
|
for (const property of shape.properties) {
|
|
8703
|
-
if (property.type !==
|
|
8939
|
+
if (property.type !== AST_NODE_TYPES40.Property || property.computed) {
|
|
8704
8940
|
return null;
|
|
8705
8941
|
}
|
|
8706
8942
|
const { key } = property;
|
|
8707
|
-
const name = key.type ===
|
|
8943
|
+
const name = key.type === AST_NODE_TYPES40.Identifier ? key.name : key.type === AST_NODE_TYPES40.Literal && typeof key.value === "string" ? key.value : null;
|
|
8708
8944
|
if (name === null) {
|
|
8709
8945
|
return null;
|
|
8710
8946
|
}
|
|
@@ -8715,11 +8951,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8715
8951
|
function typeMembers(members) {
|
|
8716
8952
|
const result = /* @__PURE__ */ new Map();
|
|
8717
8953
|
for (const member of members) {
|
|
8718
|
-
if (member.type !==
|
|
8954
|
+
if (member.type !== AST_NODE_TYPES40.TSPropertySignature || member.computed) {
|
|
8719
8955
|
return null;
|
|
8720
8956
|
}
|
|
8721
8957
|
const { key } = member;
|
|
8722
|
-
const name = key.type ===
|
|
8958
|
+
const name = key.type === AST_NODE_TYPES40.Identifier ? key.name : key.type === AST_NODE_TYPES40.Literal && typeof key.value === "string" ? key.value : null;
|
|
8723
8959
|
if (name === null) {
|
|
8724
8960
|
return null;
|
|
8725
8961
|
}
|
|
@@ -8733,8 +8969,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
8733
8969
|
return result.size === 0 ? null : result;
|
|
8734
8970
|
}
|
|
8735
8971
|
function collectConstrainedNames(node) {
|
|
8736
|
-
if (node.type ===
|
|
8737
|
-
if (node.typeName.type ===
|
|
8972
|
+
if (node.type === AST_NODE_TYPES40.TSTypeReference) {
|
|
8973
|
+
if (node.typeName.type === AST_NODE_TYPES40.Identifier) {
|
|
8738
8974
|
constrainedTypeNames.add(node.typeName.name);
|
|
8739
8975
|
}
|
|
8740
8976
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -8742,11 +8978,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8742
8978
|
}
|
|
8743
8979
|
return;
|
|
8744
8980
|
}
|
|
8745
|
-
if (node.type ===
|
|
8981
|
+
if (node.type === AST_NODE_TYPES40.TSArrayType) {
|
|
8746
8982
|
collectConstrainedNames(node.elementType);
|
|
8747
8983
|
return;
|
|
8748
8984
|
}
|
|
8749
|
-
if (node.type ===
|
|
8985
|
+
if (node.type === AST_NODE_TYPES40.TSUnionType || node.type === AST_NODE_TYPES40.TSIntersectionType) {
|
|
8750
8986
|
for (const member of node.types) {
|
|
8751
8987
|
collectConstrainedNames(member);
|
|
8752
8988
|
}
|
|
@@ -8790,13 +9026,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
8790
9026
|
return;
|
|
8791
9027
|
}
|
|
8792
9028
|
for (const specifier of node.specifiers) {
|
|
8793
|
-
if (specifier.type ===
|
|
9029
|
+
if (specifier.type === AST_NODE_TYPES40.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES40.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES40.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES40.Identifier && specifier.imported.name === "z") {
|
|
8794
9030
|
zodNamespaces.add(specifier.local.name);
|
|
8795
9031
|
}
|
|
8796
9032
|
}
|
|
8797
9033
|
},
|
|
8798
9034
|
VariableDeclarator(node) {
|
|
8799
|
-
if (node.id.type !==
|
|
9035
|
+
if (node.id.type !== AST_NODE_TYPES40.Identifier || node.init == null) {
|
|
8800
9036
|
return;
|
|
8801
9037
|
}
|
|
8802
9038
|
const fields = schemaFields(node.init);
|
|
@@ -8804,16 +9040,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8804
9040
|
schemas.push({ name: node.id.name, fields });
|
|
8805
9041
|
}
|
|
8806
9042
|
},
|
|
8807
|
-
/**
|
|
9043
|
+
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
8808
9044
|
"MemberExpression[computed=false]"(node) {
|
|
8809
|
-
if (node.object.type ===
|
|
9045
|
+
if (node.object.type === AST_NODE_TYPES40.Identifier && node.property.type === AST_NODE_TYPES40.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
8810
9046
|
reshapedSchemaNames.add(node.object.name);
|
|
8811
9047
|
}
|
|
8812
9048
|
},
|
|
8813
|
-
/**
|
|
9049
|
+
/** Records every type argument carried by a Zod constraint. */
|
|
8814
9050
|
TSTypeReference(node) {
|
|
8815
9051
|
const { typeName } = node;
|
|
8816
|
-
const referenced = typeName.type ===
|
|
9052
|
+
const referenced = typeName.type === AST_NODE_TYPES40.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES40.TSQualifiedName && typeName.right.type === AST_NODE_TYPES40.Identifier ? typeName.right.name : null;
|
|
8817
9053
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
8818
9054
|
return;
|
|
8819
9055
|
}
|
|
@@ -8831,7 +9067,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
8831
9067
|
}
|
|
8832
9068
|
},
|
|
8833
9069
|
TSTypeAliasDeclaration(node) {
|
|
8834
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9070
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES40.TSTypeLiteral) {
|
|
8835
9071
|
return;
|
|
8836
9072
|
}
|
|
8837
9073
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -8876,10 +9112,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
8876
9112
|
});
|
|
8877
9113
|
|
|
8878
9114
|
// src/rules/require-assert-never.ts
|
|
8879
|
-
import { AST_NODE_TYPES as
|
|
9115
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41 } from "@typescript-eslint/utils";
|
|
8880
9116
|
var isRuntimeHandlingStatement = (statement) => {
|
|
8881
|
-
if (statement.type ===
|
|
8882
|
-
if (statement.type ===
|
|
9117
|
+
if (statement.type === AST_NODE_TYPES41.EmptyStatement) return false;
|
|
9118
|
+
if (statement.type === AST_NODE_TYPES41.BlockStatement) {
|
|
8883
9119
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
8884
9120
|
}
|
|
8885
9121
|
return true;
|
|
@@ -8895,7 +9131,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
8895
9131
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
8896
9132
|
}
|
|
8897
9133
|
const only = defaultCase.consequent[0];
|
|
8898
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9134
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES41.BlockStatement && only.body.length === 0) {
|
|
8899
9135
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
8900
9136
|
}
|
|
8901
9137
|
return false;
|
|
@@ -8935,7 +9171,7 @@ var require_assert_never_default = createRule({
|
|
|
8935
9171
|
});
|
|
8936
9172
|
|
|
8937
9173
|
// src/rules/require-fetch-timeout.ts
|
|
8938
|
-
import { AST_NODE_TYPES as
|
|
9174
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42, ASTUtils as ASTUtils2 } from "@typescript-eslint/utils";
|
|
8939
9175
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
8940
9176
|
"globalThis",
|
|
8941
9177
|
"window",
|
|
@@ -8951,14 +9187,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
8951
9187
|
return false;
|
|
8952
9188
|
}
|
|
8953
9189
|
function initProvablyLacksSignal(init) {
|
|
8954
|
-
if (init.type !==
|
|
9190
|
+
if (init.type !== AST_NODE_TYPES42.ObjectExpression) {
|
|
8955
9191
|
return false;
|
|
8956
9192
|
}
|
|
8957
9193
|
for (const prop of init.properties) {
|
|
8958
|
-
if (prop.type ===
|
|
9194
|
+
if (prop.type === AST_NODE_TYPES42.SpreadElement) {
|
|
8959
9195
|
return false;
|
|
8960
9196
|
}
|
|
8961
|
-
if (prop.key.type ===
|
|
9197
|
+
if (prop.key.type === AST_NODE_TYPES42.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES42.Literal && prop.key.value === "signal") {
|
|
8962
9198
|
return false;
|
|
8963
9199
|
}
|
|
8964
9200
|
if (prop.computed) {
|
|
@@ -8968,7 +9204,7 @@ function initProvablyLacksSignal(init) {
|
|
|
8968
9204
|
return true;
|
|
8969
9205
|
}
|
|
8970
9206
|
function isStringish(node) {
|
|
8971
|
-
return node.type ===
|
|
9207
|
+
return node.type === AST_NODE_TYPES42.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES42.TemplateLiteral;
|
|
8972
9208
|
}
|
|
8973
9209
|
var require_fetch_timeout_default = createRule({
|
|
8974
9210
|
name: "require-fetch-timeout",
|
|
@@ -9009,10 +9245,10 @@ var require_fetch_timeout_default = createRule({
|
|
|
9009
9245
|
return variable === null || variable.defs.length === 0;
|
|
9010
9246
|
}
|
|
9011
9247
|
function isGlobalFetchCall2(callee) {
|
|
9012
|
-
if (callee.type ===
|
|
9248
|
+
if (callee.type === AST_NODE_TYPES42.Identifier) {
|
|
9013
9249
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9014
9250
|
}
|
|
9015
|
-
return callee.type ===
|
|
9251
|
+
return callee.type === AST_NODE_TYPES42.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES42.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES42.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9016
9252
|
}
|
|
9017
9253
|
return {
|
|
9018
9254
|
CallExpression(node) {
|
|
@@ -9032,7 +9268,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9032
9268
|
});
|
|
9033
9269
|
|
|
9034
9270
|
// src/rules/require-interface-for-injected-service.ts
|
|
9035
|
-
import { AST_NODE_TYPES as
|
|
9271
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43 } from "@typescript-eslint/utils";
|
|
9036
9272
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9037
9273
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9038
9274
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9040,20 +9276,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9040
9276
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9041
9277
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9042
9278
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9043
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9044
|
-
var qualifiedName = (name) => name.type ===
|
|
9279
|
+
var isExportedClass = (node) => node.parent.type === AST_NODE_TYPES43.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES43.ExportDefaultDeclaration;
|
|
9280
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES43.Identifier ? name.name : name.type === AST_NODE_TYPES43.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9045
9281
|
var readTypeReference = (annotation) => {
|
|
9046
|
-
if (annotation === void 0 || annotation.type !==
|
|
9282
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES43.TSTypeReference) return null;
|
|
9047
9283
|
const { typeName } = annotation;
|
|
9048
|
-
const rightmost = typeName.type ===
|
|
9284
|
+
const rightmost = typeName.type === AST_NODE_TYPES43.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES43.TSQualifiedName ? typeName.right.name : null;
|
|
9049
9285
|
if (rightmost === null) return null;
|
|
9050
9286
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9051
9287
|
};
|
|
9052
9288
|
var namedParameterCollaborator = (annotated) => {
|
|
9053
9289
|
let target = annotated;
|
|
9054
|
-
if (target.type ===
|
|
9055
|
-
if (target.type ===
|
|
9056
|
-
if (target.type !==
|
|
9290
|
+
if (target.type === AST_NODE_TYPES43.TSParameterProperty) target = target.parameter;
|
|
9291
|
+
if (target.type === AST_NODE_TYPES43.AssignmentPattern) target = target.left;
|
|
9292
|
+
if (target.type !== AST_NODE_TYPES43.Identifier) return null;
|
|
9057
9293
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9058
9294
|
if (reference === null) return null;
|
|
9059
9295
|
return { name: target.name, ...reference };
|
|
@@ -9061,8 +9297,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9061
9297
|
var propertySignatureTypes = (members) => {
|
|
9062
9298
|
const types = /* @__PURE__ */ new Map();
|
|
9063
9299
|
for (const member of members) {
|
|
9064
|
-
if (member.type !==
|
|
9065
|
-
if (member.computed || member.key.type !==
|
|
9300
|
+
if (member.type !== AST_NODE_TYPES43.TSPropertySignature) continue;
|
|
9301
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES43.Identifier) continue;
|
|
9066
9302
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9067
9303
|
if (reference === null) continue;
|
|
9068
9304
|
types.set(member.key.name, reference);
|
|
@@ -9073,18 +9309,18 @@ var fileTypeIndex = (program) => {
|
|
|
9073
9309
|
const objects = /* @__PURE__ */ new Map();
|
|
9074
9310
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9075
9311
|
for (const statement of program.body) {
|
|
9076
|
-
const declaration = statement.type ===
|
|
9077
|
-
if (declaration?.type ===
|
|
9312
|
+
const declaration = statement.type === AST_NODE_TYPES43.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9313
|
+
if (declaration?.type === AST_NODE_TYPES43.TSInterfaceDeclaration) {
|
|
9078
9314
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9079
9315
|
continue;
|
|
9080
9316
|
}
|
|
9081
|
-
if (declaration?.type !==
|
|
9317
|
+
if (declaration?.type !== AST_NODE_TYPES43.TSTypeAliasDeclaration) continue;
|
|
9082
9318
|
const aliased = declaration.typeAnnotation;
|
|
9083
|
-
if (aliased.type ===
|
|
9319
|
+
if (aliased.type === AST_NODE_TYPES43.TSFunctionType || aliased.type === AST_NODE_TYPES43.TSConstructorType) {
|
|
9084
9320
|
functionAliases.add(declaration.id.name);
|
|
9085
9321
|
continue;
|
|
9086
9322
|
}
|
|
9087
|
-
const literals = aliased.type ===
|
|
9323
|
+
const literals = aliased.type === AST_NODE_TYPES43.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES43.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES43.TSTypeLiteral) : [];
|
|
9088
9324
|
if (literals.length === 0) continue;
|
|
9089
9325
|
const merged = /* @__PURE__ */ new Map();
|
|
9090
9326
|
for (const literal of literals) {
|
|
@@ -9097,10 +9333,10 @@ var fileTypeIndex = (program) => {
|
|
|
9097
9333
|
return { objects, functionAliases };
|
|
9098
9334
|
};
|
|
9099
9335
|
var bagMemberTypes = (annotation, declared) => {
|
|
9100
|
-
if (annotation.type ===
|
|
9336
|
+
if (annotation.type === AST_NODE_TYPES43.TSTypeLiteral) {
|
|
9101
9337
|
return propertySignatureTypes(annotation.members);
|
|
9102
9338
|
}
|
|
9103
|
-
if (annotation.type !==
|
|
9339
|
+
if (annotation.type !== AST_NODE_TYPES43.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES43.Identifier) {
|
|
9104
9340
|
return null;
|
|
9105
9341
|
}
|
|
9106
9342
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9112,11 +9348,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9112
9348
|
if (members === null) return [];
|
|
9113
9349
|
const collaborators = [];
|
|
9114
9350
|
for (const property of pattern.properties) {
|
|
9115
|
-
if (property.type !==
|
|
9116
|
-
if (property.key.type !==
|
|
9351
|
+
if (property.type !== AST_NODE_TYPES43.Property || property.computed) continue;
|
|
9352
|
+
if (property.key.type !== AST_NODE_TYPES43.Identifier) continue;
|
|
9117
9353
|
const key = property.key.name;
|
|
9118
|
-
const bound = property.value.type ===
|
|
9119
|
-
if (bound.type !==
|
|
9354
|
+
const bound = property.value.type === AST_NODE_TYPES43.AssignmentPattern ? property.value.left : property.value;
|
|
9355
|
+
if (bound.type !== AST_NODE_TYPES43.Identifier) continue;
|
|
9120
9356
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9121
9357
|
const reference = members.get(key);
|
|
9122
9358
|
if (reference === void 0) continue;
|
|
@@ -9126,8 +9362,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9126
9362
|
};
|
|
9127
9363
|
var parameterCollaborators = (parameter, declared) => {
|
|
9128
9364
|
let target = parameter;
|
|
9129
|
-
if (target.type ===
|
|
9130
|
-
if (target.type ===
|
|
9365
|
+
if (target.type === AST_NODE_TYPES43.AssignmentPattern) target = target.left;
|
|
9366
|
+
if (target.type === AST_NODE_TYPES43.ObjectPattern) {
|
|
9131
9367
|
return objectPatternCollaborators(target, declared);
|
|
9132
9368
|
}
|
|
9133
9369
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9141,22 +9377,22 @@ var typeParameterNames = (...declarations) => {
|
|
|
9141
9377
|
return names;
|
|
9142
9378
|
};
|
|
9143
9379
|
var readConstructor = (ctor, declared, typeParameters) => {
|
|
9144
|
-
const
|
|
9380
|
+
const body2 = ctor.value.body;
|
|
9145
9381
|
const storedFrom = /* @__PURE__ */ new Set();
|
|
9146
9382
|
let constructedFields = 0;
|
|
9147
|
-
if (
|
|
9148
|
-
for (const statement of
|
|
9149
|
-
if (statement.type !==
|
|
9383
|
+
if (body2 !== null && body2 !== void 0) {
|
|
9384
|
+
for (const statement of body2.body) {
|
|
9385
|
+
if (statement.type !== AST_NODE_TYPES43.ExpressionStatement) continue;
|
|
9150
9386
|
const expression = statement.expression;
|
|
9151
|
-
if (expression.type !==
|
|
9387
|
+
if (expression.type !== AST_NODE_TYPES43.AssignmentExpression || expression.operator !== "=" || expression.left.type !== AST_NODE_TYPES43.MemberExpression || expression.left.object.type !== AST_NODE_TYPES43.ThisExpression) {
|
|
9152
9388
|
continue;
|
|
9153
9389
|
}
|
|
9154
9390
|
const source = expression.right;
|
|
9155
|
-
if (source.type ===
|
|
9391
|
+
if (source.type === AST_NODE_TYPES43.NewExpression) {
|
|
9156
9392
|
constructedFields += 1;
|
|
9157
|
-
} else if (source.type ===
|
|
9393
|
+
} else if (source.type === AST_NODE_TYPES43.Identifier) {
|
|
9158
9394
|
storedFrom.add(source.name);
|
|
9159
|
-
} else if (source.type ===
|
|
9395
|
+
} else if (source.type === AST_NODE_TYPES43.MemberExpression && source.object.type === AST_NODE_TYPES43.Identifier) {
|
|
9160
9396
|
storedFrom.add(source.object.name);
|
|
9161
9397
|
}
|
|
9162
9398
|
}
|
|
@@ -9164,7 +9400,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9164
9400
|
const collaborators = [];
|
|
9165
9401
|
for (const parameter of ctor.value.params) {
|
|
9166
9402
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9167
|
-
const stored = parameter.type ===
|
|
9403
|
+
const stored = parameter.type === AST_NODE_TYPES43.TSParameterProperty || storedFrom.has(reference.name);
|
|
9168
9404
|
if (!stored) continue;
|
|
9169
9405
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9170
9406
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9197,20 +9433,20 @@ var subtreeHas = (root, found) => {
|
|
|
9197
9433
|
visit(root);
|
|
9198
9434
|
return hit;
|
|
9199
9435
|
};
|
|
9200
|
-
var isFrameworkWiring = (
|
|
9201
|
-
if (node.type ===
|
|
9436
|
+
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9437
|
+
if (node.type === AST_NODE_TYPES43.CallExpression) {
|
|
9202
9438
|
const { callee } = node;
|
|
9203
|
-
if (callee.type ===
|
|
9204
|
-
return callee.type ===
|
|
9439
|
+
if (callee.type === AST_NODE_TYPES43.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9440
|
+
return callee.type === AST_NODE_TYPES43.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES43.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9205
9441
|
}
|
|
9206
|
-
return node.type ===
|
|
9442
|
+
return node.type === AST_NODE_TYPES43.TSTypeReference && node.typeName.type === AST_NODE_TYPES43.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9207
9443
|
});
|
|
9208
9444
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9209
9445
|
var fileInterfaceNames = (program) => {
|
|
9210
9446
|
const names = [];
|
|
9211
9447
|
for (const statement of program.body) {
|
|
9212
|
-
const declaration = statement.type ===
|
|
9213
|
-
if (declaration?.type ===
|
|
9448
|
+
const declaration = statement.type === AST_NODE_TYPES43.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9449
|
+
if (declaration?.type === AST_NODE_TYPES43.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9214
9450
|
}
|
|
9215
9451
|
return names;
|
|
9216
9452
|
};
|
|
@@ -9225,14 +9461,14 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9225
9461
|
return target.endsWith(other) || other.endsWith(target);
|
|
9226
9462
|
});
|
|
9227
9463
|
};
|
|
9228
|
-
var publicMethodNames = (
|
|
9464
|
+
var publicMethodNames = (body2) => {
|
|
9229
9465
|
const names = [];
|
|
9230
|
-
for (const member of
|
|
9231
|
-
if (member.type !==
|
|
9466
|
+
for (const member of body2.body) {
|
|
9467
|
+
if (member.type !== AST_NODE_TYPES43.MethodDefinition) continue;
|
|
9232
9468
|
if (member.kind !== "method" || member.static) continue;
|
|
9233
9469
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9234
|
-
if (member.key.type ===
|
|
9235
|
-
if (member.key.type ===
|
|
9470
|
+
if (member.key.type === AST_NODE_TYPES43.PrivateIdentifier) continue;
|
|
9471
|
+
if (member.key.type === AST_NODE_TYPES43.Identifier) names.push(member.key.name);
|
|
9236
9472
|
else names.push("\u2026");
|
|
9237
9473
|
}
|
|
9238
9474
|
return names;
|
|
@@ -9265,7 +9501,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9265
9501
|
if (node.implements.length > 0) return;
|
|
9266
9502
|
if (node.decorators.length > 0) return;
|
|
9267
9503
|
const ctor = node.body.body.find(
|
|
9268
|
-
(member) => member.type ===
|
|
9504
|
+
(member) => member.type === AST_NODE_TYPES43.MethodDefinition && member.kind === "constructor"
|
|
9269
9505
|
);
|
|
9270
9506
|
if (ctor === void 0) return;
|
|
9271
9507
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9294,18 +9530,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9294
9530
|
});
|
|
9295
9531
|
|
|
9296
9532
|
// src/rules/require-zod-form-validation.ts
|
|
9297
|
-
import { AST_NODE_TYPES as
|
|
9533
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44 } from "@typescript-eslint/utils";
|
|
9298
9534
|
var looksLikeZodSchema = (node) => {
|
|
9299
9535
|
let current = node;
|
|
9300
9536
|
while (true) {
|
|
9301
|
-
if (current.type ===
|
|
9537
|
+
if (current.type === AST_NODE_TYPES44.Identifier) {
|
|
9302
9538
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9303
9539
|
}
|
|
9304
|
-
if (current.type ===
|
|
9540
|
+
if (current.type === AST_NODE_TYPES44.CallExpression) {
|
|
9305
9541
|
current = current.callee;
|
|
9306
9542
|
continue;
|
|
9307
9543
|
}
|
|
9308
|
-
if (current.type ===
|
|
9544
|
+
if (current.type === AST_NODE_TYPES44.MemberExpression) {
|
|
9309
9545
|
current = current.object;
|
|
9310
9546
|
continue;
|
|
9311
9547
|
}
|
|
@@ -9313,23 +9549,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9313
9549
|
}
|
|
9314
9550
|
};
|
|
9315
9551
|
var isZodParseCall = (node) => {
|
|
9316
|
-
if (node.type !==
|
|
9552
|
+
if (node.type !== AST_NODE_TYPES44.CallExpression) return false;
|
|
9317
9553
|
const callee = node.callee;
|
|
9318
|
-
if (callee.type !==
|
|
9554
|
+
if (callee.type !== AST_NODE_TYPES44.MemberExpression) return false;
|
|
9319
9555
|
if (callee.computed) return false;
|
|
9320
|
-
if (callee.property.type !==
|
|
9556
|
+
if (callee.property.type !== AST_NODE_TYPES44.Identifier) return false;
|
|
9321
9557
|
const method = callee.property.name;
|
|
9322
9558
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9323
9559
|
return looksLikeZodSchema(callee.object);
|
|
9324
9560
|
};
|
|
9325
9561
|
var isFormDataMethodCall = (node) => {
|
|
9326
9562
|
let current = node;
|
|
9327
|
-
if (current.type ===
|
|
9563
|
+
if (current.type === AST_NODE_TYPES44.AwaitExpression) {
|
|
9328
9564
|
current = current.argument;
|
|
9329
9565
|
}
|
|
9330
|
-
if (current.type !==
|
|
9566
|
+
if (current.type !== AST_NODE_TYPES44.CallExpression) return false;
|
|
9331
9567
|
const callee = current.callee;
|
|
9332
|
-
return callee.type ===
|
|
9568
|
+
return callee.type === AST_NODE_TYPES44.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES44.Identifier && callee.property.name === "formData";
|
|
9333
9569
|
};
|
|
9334
9570
|
var require_zod_form_validation_default = createRule({
|
|
9335
9571
|
name: "require-zod-form-validation",
|
|
@@ -9349,14 +9585,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9349
9585
|
return {};
|
|
9350
9586
|
}
|
|
9351
9587
|
const isFormSourceIdentifier = (node) => {
|
|
9352
|
-
if (node.type !==
|
|
9588
|
+
if (node.type !== AST_NODE_TYPES44.Identifier) return false;
|
|
9353
9589
|
if (/formdata/i.test(node.name)) return true;
|
|
9354
9590
|
let scope = context.sourceCode.getScope(node);
|
|
9355
9591
|
while (scope !== null) {
|
|
9356
9592
|
const variable = scope.set.get(node.name);
|
|
9357
9593
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9358
9594
|
const def = variable.defs[0];
|
|
9359
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
9595
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES44.VariableDeclarator && def.node.init !== null) {
|
|
9360
9596
|
return isFormDataMethodCall(def.node.init);
|
|
9361
9597
|
}
|
|
9362
9598
|
return false;
|
|
@@ -9367,8 +9603,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9367
9603
|
};
|
|
9368
9604
|
const isFormDataGetCall = (node) => {
|
|
9369
9605
|
const callee = node.callee;
|
|
9370
|
-
if (callee.type !==
|
|
9371
|
-
if (callee.property.type !==
|
|
9606
|
+
if (callee.type !== AST_NODE_TYPES44.MemberExpression) return false;
|
|
9607
|
+
if (callee.property.type !== AST_NODE_TYPES44.Identifier || callee.property.name !== "get") {
|
|
9372
9608
|
return false;
|
|
9373
9609
|
}
|
|
9374
9610
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9383,11 +9619,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9383
9619
|
};
|
|
9384
9620
|
const isInstanceofNarrowing = (node) => {
|
|
9385
9621
|
const parent = node.parent;
|
|
9386
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9622
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES44.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES44.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9387
9623
|
};
|
|
9388
9624
|
const boundDeclarator = (node) => {
|
|
9389
9625
|
const parent = node.parent;
|
|
9390
|
-
if (parent.type ===
|
|
9626
|
+
if (parent.type === AST_NODE_TYPES44.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES44.Identifier) {
|
|
9391
9627
|
return parent;
|
|
9392
9628
|
}
|
|
9393
9629
|
return null;
|
|
@@ -9446,7 +9682,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9446
9682
|
});
|
|
9447
9683
|
|
|
9448
9684
|
// src/rules/zod-naming-convention.ts
|
|
9449
|
-
import { AST_NODE_TYPES as
|
|
9685
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45 } from "@typescript-eslint/utils";
|
|
9450
9686
|
var CONVENTIONS = {
|
|
9451
9687
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9452
9688
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9471,15 +9707,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9471
9707
|
"registry",
|
|
9472
9708
|
"implement"
|
|
9473
9709
|
]);
|
|
9474
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
9710
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES45.Identifier ? callee.property.name : null;
|
|
9475
9711
|
var calleeChainStartsWithZ = (node) => {
|
|
9476
9712
|
let current = node;
|
|
9477
|
-
while (current.type ===
|
|
9713
|
+
while (current.type === AST_NODE_TYPES45.MemberExpression) {
|
|
9478
9714
|
const receiver = current.object;
|
|
9479
|
-
if (receiver.type ===
|
|
9715
|
+
if (receiver.type === AST_NODE_TYPES45.Identifier && receiver.name === "z") {
|
|
9480
9716
|
return true;
|
|
9481
9717
|
}
|
|
9482
|
-
if (receiver.type ===
|
|
9718
|
+
if (receiver.type === AST_NODE_TYPES45.CallExpression) {
|
|
9483
9719
|
current = receiver.callee;
|
|
9484
9720
|
continue;
|
|
9485
9721
|
}
|
|
@@ -9524,13 +9760,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9524
9760
|
VariableDeclarator(node) {
|
|
9525
9761
|
const init = node.init;
|
|
9526
9762
|
if (init === null || init === void 0) return;
|
|
9527
|
-
if (init.type !==
|
|
9763
|
+
if (init.type !== AST_NODE_TYPES45.CallExpression) return;
|
|
9528
9764
|
const callee = init.callee;
|
|
9529
|
-
if (callee.type !==
|
|
9765
|
+
if (callee.type !== AST_NODE_TYPES45.MemberExpression) return;
|
|
9530
9766
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9531
9767
|
const terminal = terminalMethodName(callee);
|
|
9532
9768
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9533
|
-
if (node.id.type !==
|
|
9769
|
+
if (node.id.type !== AST_NODE_TYPES45.Identifier) return;
|
|
9534
9770
|
if (test.test(node.id.name)) return;
|
|
9535
9771
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9536
9772
|
context.report({
|
|
@@ -9554,47 +9790,47 @@ var renamedRules = {
|
|
|
9554
9790
|
var retiredRules = {
|
|
9555
9791
|
"ban-loose-type-guards-in-tests": {
|
|
9556
9792
|
removedIn: "5.0.0",
|
|
9557
|
-
reason: "
|
|
9793
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9558
9794
|
},
|
|
9559
9795
|
"no-implicit-attribute-access": {
|
|
9560
9796
|
removedIn: "5.0.0",
|
|
9561
|
-
reason: "
|
|
9797
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9562
9798
|
},
|
|
9563
9799
|
"no-sequential-await": {
|
|
9564
9800
|
removedIn: "3.0.0",
|
|
9565
|
-
reason: "
|
|
9801
|
+
reason: "Delete the entry; core `no-await-in-loop` covers it."
|
|
9566
9802
|
},
|
|
9567
9803
|
"no-template-literal-in-log": {
|
|
9568
9804
|
removedIn: "2.3.1",
|
|
9569
|
-
reason: "
|
|
9805
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9570
9806
|
},
|
|
9571
9807
|
"no-unsafe-cast": {
|
|
9572
9808
|
removedIn: "3.0.0",
|
|
9573
|
-
reason:
|
|
9809
|
+
reason: "Delete the entry; keep `@typescript-eslint/consistent-type-assertions` enabled."
|
|
9574
9810
|
},
|
|
9575
9811
|
"prefer-setup-file-mocks": {
|
|
9576
9812
|
removedIn: "5.0.0",
|
|
9577
|
-
reason: "
|
|
9813
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9578
9814
|
},
|
|
9579
9815
|
"prefer-shadcn": {
|
|
9580
9816
|
removedIn: "3.0.0",
|
|
9581
|
-
reason: "
|
|
9817
|
+
reason: "Delete the entry; use `react/forbid-elements` for element restrictions."
|
|
9582
9818
|
},
|
|
9583
9819
|
"primary-export-file-name": {
|
|
9584
9820
|
removedIn: "4.0.0",
|
|
9585
|
-
reason: "
|
|
9821
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9586
9822
|
},
|
|
9587
9823
|
"require-parameterized-tests": {
|
|
9588
9824
|
removedIn: "4.0.0",
|
|
9589
|
-
reason: "
|
|
9825
|
+
reason: "Delete stale references; the rule was never registered."
|
|
9590
9826
|
},
|
|
9591
9827
|
"require-schema-validate-search": {
|
|
9592
9828
|
removedIn: "3.0.0",
|
|
9593
|
-
reason: "
|
|
9829
|
+
reason: "Delete the entry; use `@typescript-eslint/consistent-type-assertions`."
|
|
9594
9830
|
},
|
|
9595
9831
|
"single-public-export": {
|
|
9596
9832
|
removedIn: "3.0.0",
|
|
9597
|
-
reason: "
|
|
9833
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9598
9834
|
}
|
|
9599
9835
|
};
|
|
9600
9836
|
|
|
@@ -9613,6 +9849,7 @@ var rules = {
|
|
|
9613
9849
|
"no-insecure-random-id": no_insecure_random_id_default,
|
|
9614
9850
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
9615
9851
|
"no-log-only-catch": no_log_only_catch_default,
|
|
9852
|
+
"no-long-comment": no_long_comment_default,
|
|
9616
9853
|
"no-offset-pagination": no_offset_pagination_default,
|
|
9617
9854
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
9618
9855
|
"no-raw-env": no_raw_env_default,
|
|
@@ -9628,6 +9865,7 @@ var rules = {
|
|
|
9628
9865
|
"no-storage-in-stateless-modules": no_storage_in_stateless_modules_default,
|
|
9629
9866
|
"no-string-concat-in-loop": no_string_concat_in_loop_default,
|
|
9630
9867
|
"no-tautological-expect": no_tautological_expect_default,
|
|
9868
|
+
"no-typed-doc-sections": no_typed_doc_sections_default,
|
|
9631
9869
|
"no-trailing-value-narration": no_trailing_value_narration_default,
|
|
9632
9870
|
"no-declaration-comment-wall": no_declaration_comment_wall_default,
|
|
9633
9871
|
"no-union-in-comment": no_union_in_comment_default,
|
|
@@ -9643,6 +9881,7 @@ var rules = {
|
|
|
9643
9881
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
9644
9882
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
9645
9883
|
"prefer-server-actions": prefer_server_actions_default,
|
|
9884
|
+
"prefer-single-sentence-comment": prefer_single_sentence_comment_default,
|
|
9646
9885
|
"prefer-string-literal-union": prefer_string_literal_union_default,
|
|
9647
9886
|
"prefer-whole-object-assertion": prefer_whole_object_assertion_default,
|
|
9648
9887
|
"prefer-zod-enum": prefer_zod_enum_default,
|
|
@@ -9656,7 +9895,7 @@ var rules = {
|
|
|
9656
9895
|
};
|
|
9657
9896
|
var meta = {
|
|
9658
9897
|
name: "@sarj/eslint-plugin",
|
|
9659
|
-
version: "9.
|
|
9898
|
+
version: "9.7.0"
|
|
9660
9899
|
};
|
|
9661
9900
|
var recommendedRules = {
|
|
9662
9901
|
"@sarj/enforce-file-structure": "warn",
|
|
@@ -9671,6 +9910,7 @@ var recommendedRules = {
|
|
|
9671
9910
|
"@sarj/no-insecure-random-id": "warn",
|
|
9672
9911
|
"@sarj/no-json-stringify-error": "warn",
|
|
9673
9912
|
"@sarj/no-log-only-catch": "warn",
|
|
9913
|
+
"@sarj/no-long-comment": "warn",
|
|
9674
9914
|
"@sarj/no-offset-pagination": "warn",
|
|
9675
9915
|
"@sarj/no-positional-tuple-return": "warn",
|
|
9676
9916
|
"@sarj/no-repeated-string-literal": "warn",
|
|
@@ -9683,6 +9923,7 @@ var recommendedRules = {
|
|
|
9683
9923
|
"@sarj/no-sleep-in-test-body": "warn",
|
|
9684
9924
|
"@sarj/no-string-concat-in-loop": "warn",
|
|
9685
9925
|
"@sarj/no-tautological-expect": "warn",
|
|
9926
|
+
"@sarj/no-typed-doc-sections": "warn",
|
|
9686
9927
|
"@sarj/no-trailing-value-narration": "warn",
|
|
9687
9928
|
"@sarj/no-declaration-comment-wall": "warn",
|
|
9688
9929
|
"@sarj/no-union-in-comment": "warn",
|
|
@@ -9698,6 +9939,7 @@ var recommendedRules = {
|
|
|
9698
9939
|
"@sarj/prefer-schema-for-api-payload": "warn",
|
|
9699
9940
|
"@sarj/prefer-semantic-colors": ["warn", { requireSemanticTokens: true }],
|
|
9700
9941
|
"@sarj/prefer-server-actions": "warn",
|
|
9942
|
+
"@sarj/prefer-single-sentence-comment": "warn",
|
|
9701
9943
|
"@sarj/prefer-string-literal-union": "warn",
|
|
9702
9944
|
"@sarj/prefer-whole-object-assertion": "warn",
|
|
9703
9945
|
"@sarj/prefer-zod-enum": "warn",
|
|
@@ -9723,6 +9965,7 @@ var strictRules = {
|
|
|
9723
9965
|
"@sarj/no-insecure-random-id": "error",
|
|
9724
9966
|
"@sarj/no-json-stringify-error": "error",
|
|
9725
9967
|
"@sarj/no-log-only-catch": "error",
|
|
9968
|
+
"@sarj/no-long-comment": "error",
|
|
9726
9969
|
"@sarj/no-offset-pagination": "error",
|
|
9727
9970
|
"@sarj/no-positional-tuple-return": "error",
|
|
9728
9971
|
"@sarj/no-raw-env": "error",
|
|
@@ -9738,6 +9981,7 @@ var strictRules = {
|
|
|
9738
9981
|
"@sarj/no-storage-in-stateless-modules": "error",
|
|
9739
9982
|
"@sarj/no-string-concat-in-loop": "error",
|
|
9740
9983
|
"@sarj/no-tautological-expect": "error",
|
|
9984
|
+
"@sarj/no-typed-doc-sections": "error",
|
|
9741
9985
|
"@sarj/no-trailing-value-narration": "error",
|
|
9742
9986
|
"@sarj/no-declaration-comment-wall": "error",
|
|
9743
9987
|
"@sarj/no-union-in-comment": "error",
|
|
@@ -9753,6 +9997,7 @@ var strictRules = {
|
|
|
9753
9997
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
9754
9998
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
9755
9999
|
"@sarj/prefer-server-actions": "error",
|
|
10000
|
+
"@sarj/prefer-single-sentence-comment": "warn",
|
|
9756
10001
|
"@sarj/prefer-string-literal-union": "error",
|
|
9757
10002
|
"@sarj/prefer-whole-object-assertion": "error",
|
|
9758
10003
|
"@sarj/prefer-zod-enum": "error",
|