@sarj/eslint-plugin 9.6.0 → 9.7.1
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 +9 -12
- package/dist/index.cjs +927 -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 +916 -670
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -45,10 +45,10 @@ var import_utils2 = require("@typescript-eslint/utils");
|
|
|
45
45
|
// src/rules/_docs.ts
|
|
46
46
|
var import_utils = require("@typescript-eslint/utils");
|
|
47
47
|
var REPO_BLOB = "https://github.com/sarj-ai/standards/blob/main";
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var createRule = import_utils.ESLintUtils.RuleCreator(
|
|
48
|
+
var TESTS_DIR = "packages/typescript/tests/rules";
|
|
49
|
+
var examplesPath = (name) => `${TESTS_DIR}/${name}.test.ts`;
|
|
50
|
+
var examplesUrl = (name) => `${REPO_BLOB}/${examplesPath(name)}`;
|
|
51
|
+
var createRule = import_utils.ESLintUtils.RuleCreator(examplesUrl);
|
|
52
52
|
|
|
53
53
|
// src/rules/_paths.ts
|
|
54
54
|
var SCRIPT_FILE_RE = /([\\/]scripts[\\/])|(\.mjs$)/;
|
|
@@ -133,8 +133,8 @@ var enforce_file_structure_default = createRule({
|
|
|
133
133
|
}
|
|
134
134
|
return {
|
|
135
135
|
Program(node) {
|
|
136
|
-
const
|
|
137
|
-
const misplacedUseServer =
|
|
136
|
+
const body2 = node.body;
|
|
137
|
+
const misplacedUseServer = body2.find(
|
|
138
138
|
(statement, index) => index > 0 && isUseServerDirective(statement)
|
|
139
139
|
);
|
|
140
140
|
if (misplacedUseServer !== void 0) {
|
|
@@ -145,7 +145,7 @@ var enforce_file_structure_default = createRule({
|
|
|
145
145
|
}
|
|
146
146
|
let seenBody = false;
|
|
147
147
|
let inMisplacedRun = false;
|
|
148
|
-
for (const statement of
|
|
148
|
+
for (const statement of body2) {
|
|
149
149
|
if (isStringDirective(statement)) continue;
|
|
150
150
|
switch (classifyStatement(statement)) {
|
|
151
151
|
case "reexport":
|
|
@@ -366,11 +366,11 @@ var PROTECTED_SIGNALS = [
|
|
|
366
366
|
SECURITY_RE,
|
|
367
367
|
VENDOR_RE
|
|
368
368
|
];
|
|
369
|
-
function isProtected(
|
|
370
|
-
return PROTECTED_SIGNALS.some((signal) => signal.test(
|
|
369
|
+
function isProtected(body2) {
|
|
370
|
+
return PROTECTED_SIGNALS.some((signal) => signal.test(body2));
|
|
371
371
|
}
|
|
372
|
-
function hasExternalReference(
|
|
373
|
-
return REF_RE.test(
|
|
372
|
+
function hasExternalReference(body2) {
|
|
373
|
+
return REF_RE.test(body2);
|
|
374
374
|
}
|
|
375
375
|
var STOPWORDS = new Set(
|
|
376
376
|
`a an the this that these those it its their his her our your my
|
|
@@ -518,9 +518,9 @@ function restatableStatementBelow(comment, sourceCode) {
|
|
|
518
518
|
}
|
|
519
519
|
return null;
|
|
520
520
|
}
|
|
521
|
-
function restatesStatementHead(
|
|
521
|
+
function restatesStatementHead(body2, statement) {
|
|
522
522
|
if (statement === null) return false;
|
|
523
|
-
const words =
|
|
523
|
+
const words = body2.match(/[A-Za-z][\w$]*/g) ?? [];
|
|
524
524
|
const opener = words[0];
|
|
525
525
|
if (opener === void 0 || words.length > NARRATION_MAX_WORDS) return false;
|
|
526
526
|
if (!NARRATION_VERB_RE.test(opener)) return false;
|
|
@@ -719,11 +719,11 @@ function isProse(text) {
|
|
|
719
719
|
return false;
|
|
720
720
|
}
|
|
721
721
|
var JUSTIFICATION_RE = /\b(?:because|since|until|due to|so that|so we|so it|so the|otherwise|which is why|in order to|to avoid|to work around|to prevent|backwards? compat(?:ibility)?|for compatibility)\b/i;
|
|
722
|
-
function restatesWholeStatement(
|
|
723
|
-
return statement !== null && restatesStatementHead(
|
|
722
|
+
function restatesWholeStatement(body2, statement) {
|
|
723
|
+
return statement !== null && restatesStatementHead(body2, statement.replaceAll("(", " "));
|
|
724
724
|
}
|
|
725
|
-
function isRedundantNarration(
|
|
726
|
-
const t =
|
|
725
|
+
function isRedundantNarration(body2, statementBelow, standalone, isolatedEnumeration, nested) {
|
|
726
|
+
const t = body2.trim();
|
|
727
727
|
if (!t || looksLikeCode(t) || hasPseudocode(t)) return false;
|
|
728
728
|
if (standalone) {
|
|
729
729
|
const justified = JUSTIFICATION_RE.test(t);
|
|
@@ -798,8 +798,8 @@ function statementAttachmentBelow(comment, sourceCode) {
|
|
|
798
798
|
}
|
|
799
799
|
return null;
|
|
800
800
|
}
|
|
801
|
-
function isWeakWalkthroughComment(
|
|
802
|
-
const normalized =
|
|
801
|
+
function isWeakWalkthroughComment(body2, statement) {
|
|
802
|
+
const normalized = body2.replace(WALL_STEP_PREFIX_RE, "");
|
|
803
803
|
if (normalized.length === 0 || normalized.endsWith("?") || normalized.split(/\s+/).length > WALL_MAX_WORDS || isDirective(normalized) || isProtected(normalized) || !WALL_NARRATION_RE.test(normalized)) {
|
|
804
804
|
return false;
|
|
805
805
|
}
|
|
@@ -836,8 +836,8 @@ var LEAD_IN_SCAN_LIMIT = 24;
|
|
|
836
836
|
function hasIllustrationLeadInAbove(comments, index) {
|
|
837
837
|
for (let i = index - 1; i >= 0 && index - i <= LEAD_IN_SCAN_LIMIT; i--) {
|
|
838
838
|
if (!areAdjacentLineComments(comments[i], comments[i + 1])) return false;
|
|
839
|
-
const
|
|
840
|
-
if (
|
|
839
|
+
const body2 = stripCommentMarker(comments[i]?.value ?? "");
|
|
840
|
+
if (body2.length > 0 && body2.endsWith(":")) return true;
|
|
841
841
|
}
|
|
842
842
|
return false;
|
|
843
843
|
}
|
|
@@ -891,12 +891,12 @@ var no_comment_cruft_default = createRule({
|
|
|
891
891
|
if (comment.type !== "Line" || !isStandalone(comment)) continue;
|
|
892
892
|
const attachment = statementAttachmentBelow(comment, sourceCode);
|
|
893
893
|
if (attachment === null) continue;
|
|
894
|
-
const
|
|
894
|
+
const body2 = stripCommentMarker(comment.value);
|
|
895
895
|
const entries = attached.get(attachment.container) ?? [];
|
|
896
896
|
entries.push({
|
|
897
897
|
comment,
|
|
898
898
|
index: attachment.index,
|
|
899
|
-
weak: isWeakWalkthroughComment(
|
|
899
|
+
weak: isWeakWalkthroughComment(body2, attachment.statement)
|
|
900
900
|
});
|
|
901
901
|
attached.set(attachment.container, entries);
|
|
902
902
|
}
|
|
@@ -940,8 +940,8 @@ var no_comment_cruft_default = createRule({
|
|
|
940
940
|
if (comment.type !== "Line") break;
|
|
941
941
|
if (comment.loc.start.line >= firstCodeLine) break;
|
|
942
942
|
if (!isStandalone(comment)) break;
|
|
943
|
-
const
|
|
944
|
-
if (isDirective(
|
|
943
|
+
const body2 = stripCommentMarker(comment.value);
|
|
944
|
+
if (isDirective(body2) || body2.startsWith("!")) continue;
|
|
945
945
|
if (prevLine !== null && comment.loc.start.line !== prevLine + 1) break;
|
|
946
946
|
leading.push(comment);
|
|
947
947
|
prevLine = comment.loc.start.line;
|
|
@@ -949,8 +949,8 @@ var no_comment_cruft_default = createRule({
|
|
|
949
949
|
const first = leading[0];
|
|
950
950
|
if (first === void 0 || leading.length < LEADING_PREAMBLE_MIN) return;
|
|
951
951
|
const bodies = leading.map((c) => stripCommentMarker(c.value));
|
|
952
|
-
if (bodies.some((
|
|
953
|
-
if (bodies.some((
|
|
952
|
+
if (bodies.some((body2) => LICENSE_RE.test(body2))) return;
|
|
953
|
+
if (bodies.some((body2) => isProse(body2))) return;
|
|
954
954
|
if (bodies.filter(isEnumeratedProseItem).length >= ENUMERATED_PREAMBLE_MIN_ITEMS) {
|
|
955
955
|
return;
|
|
956
956
|
}
|
|
@@ -1011,11 +1011,11 @@ var no_comment_cruft_default = createRule({
|
|
|
1011
1011
|
continue;
|
|
1012
1012
|
}
|
|
1013
1013
|
if (comment.type === "Line" && texts.length === 1) {
|
|
1014
|
-
const
|
|
1014
|
+
const body2 = texts[0];
|
|
1015
1015
|
const statement = restatableStatementBelow(comment, sourceCode);
|
|
1016
1016
|
const standalone = !isInsideCommentRun(comments, i);
|
|
1017
1017
|
const nested = container !== null && !STATEMENT_CONTAINERS.has(container.type);
|
|
1018
|
-
if (
|
|
1018
|
+
if (body2 !== void 0 && !runCitesAReference(comments, i) && isRedundantNarration(body2, statement, standalone, enumerated.length === 1, nested)) {
|
|
1019
1019
|
context.report({ node: comment, messageId: "redundantNarration" });
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
@@ -1029,11 +1029,12 @@ var no_comment_cruft_default = createRule({
|
|
|
1029
1029
|
// src/rules/no-conditional-in-test.ts
|
|
1030
1030
|
var import_utils7 = require("@typescript-eslint/utils");
|
|
1031
1031
|
var TEST_CALLERS = /* @__PURE__ */ new Set(["it", "test"]);
|
|
1032
|
-
var
|
|
1032
|
+
var NON_TEST_MEMBERS = /* @__PURE__ */ new Set([
|
|
1033
1033
|
"afterAll",
|
|
1034
1034
|
"afterEach",
|
|
1035
1035
|
"beforeAll",
|
|
1036
|
-
"beforeEach"
|
|
1036
|
+
"beforeEach",
|
|
1037
|
+
"describe"
|
|
1037
1038
|
]);
|
|
1038
1039
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
1039
1040
|
import_utils7.AST_NODE_TYPES.FunctionDeclaration,
|
|
@@ -1073,12 +1074,27 @@ function testCallerName(callee) {
|
|
|
1073
1074
|
}
|
|
1074
1075
|
return null;
|
|
1075
1076
|
}
|
|
1077
|
+
function hasNonTestMember(callee) {
|
|
1078
|
+
if (callee.type === import_utils7.AST_NODE_TYPES.MemberExpression) {
|
|
1079
|
+
if (!callee.computed && callee.property.type === import_utils7.AST_NODE_TYPES.Identifier && NON_TEST_MEMBERS.has(callee.property.name)) {
|
|
1080
|
+
return true;
|
|
1081
|
+
}
|
|
1082
|
+
return hasNonTestMember(callee.object);
|
|
1083
|
+
}
|
|
1084
|
+
if (callee.type === import_utils7.AST_NODE_TYPES.CallExpression) {
|
|
1085
|
+
return hasNonTestMember(callee.callee);
|
|
1086
|
+
}
|
|
1087
|
+
if (callee.type === import_utils7.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
1088
|
+
return hasNonTestMember(callee.tag);
|
|
1089
|
+
}
|
|
1090
|
+
return false;
|
|
1091
|
+
}
|
|
1076
1092
|
function isTestBody(fn) {
|
|
1077
1093
|
const call = fn.parent;
|
|
1078
1094
|
if (call?.type !== import_utils7.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
1079
1095
|
return false;
|
|
1080
1096
|
}
|
|
1081
|
-
if (
|
|
1097
|
+
if (hasNonTestMember(call.callee)) {
|
|
1082
1098
|
return false;
|
|
1083
1099
|
}
|
|
1084
1100
|
const name = testCallerName(call.callee);
|
|
@@ -1804,6 +1820,7 @@ var no_enum_default = createRule({
|
|
|
1804
1820
|
properties: {
|
|
1805
1821
|
ignoreFiles: {
|
|
1806
1822
|
type: "array",
|
|
1823
|
+
description: "Additional generated-file globs to ignore; shared generated paths and header markers are always ignored.",
|
|
1807
1824
|
items: { type: "string" }
|
|
1808
1825
|
}
|
|
1809
1826
|
}
|
|
@@ -2013,8 +2030,8 @@ function handlerRethrows(handler) {
|
|
|
2013
2030
|
if (handler === null) {
|
|
2014
2031
|
return false;
|
|
2015
2032
|
}
|
|
2016
|
-
const
|
|
2017
|
-
const last =
|
|
2033
|
+
const body2 = handler.body.body;
|
|
2034
|
+
const last = body2[body2.length - 1];
|
|
2018
2035
|
return last !== void 0 && last.type === import_utils12.AST_NODE_TYPES.ThrowStatement;
|
|
2019
2036
|
}
|
|
2020
2037
|
var PASS_THROUGH_PARENTS = /* @__PURE__ */ new Set([
|
|
@@ -2048,8 +2065,8 @@ function unwrapAwait(expr) {
|
|
|
2048
2065
|
return inner.type === import_utils12.AST_NODE_TYPES.AwaitExpression ? unwrap(inner.argument) : inner;
|
|
2049
2066
|
}
|
|
2050
2067
|
function handlerEndsByHandingOff(handler) {
|
|
2051
|
-
const
|
|
2052
|
-
const last =
|
|
2068
|
+
const body2 = handler.body.body;
|
|
2069
|
+
const last = body2[body2.length - 1];
|
|
2053
2070
|
if (last === void 0) {
|
|
2054
2071
|
return false;
|
|
2055
2072
|
}
|
|
@@ -2623,8 +2640,8 @@ function negatedInstanceofErrorSubject(test) {
|
|
|
2623
2640
|
return null;
|
|
2624
2641
|
}
|
|
2625
2642
|
function branchTerminates(branch) {
|
|
2626
|
-
const
|
|
2627
|
-
const last =
|
|
2643
|
+
const body2 = branch.type === "BlockStatement" ? branch.body : [branch];
|
|
2644
|
+
const last = body2[body2.length - 1];
|
|
2628
2645
|
return last !== void 0 && (last.type === "ReturnStatement" || last.type === "ThrowStatement");
|
|
2629
2646
|
}
|
|
2630
2647
|
function isNarrowedByEarlyReturn(node, argExpr, sourceCode) {
|
|
@@ -2876,8 +2893,8 @@ function hasFollowingStatement(node) {
|
|
|
2876
2893
|
return false;
|
|
2877
2894
|
}
|
|
2878
2895
|
function fallbackFollowsTry(tryStatement) {
|
|
2879
|
-
const
|
|
2880
|
-
const last =
|
|
2896
|
+
const body2 = tryStatement.block.body;
|
|
2897
|
+
const last = body2.at(-1);
|
|
2881
2898
|
return last?.type === import_utils17.AST_NODE_TYPES.ReturnStatement && hasFollowingStatement(tryStatement);
|
|
2882
2899
|
}
|
|
2883
2900
|
function isSeedValue(node) {
|
|
@@ -2994,8 +3011,125 @@ var no_log_only_catch_default = createRule({
|
|
|
2994
3011
|
}
|
|
2995
3012
|
});
|
|
2996
3013
|
|
|
2997
|
-
// src/rules/
|
|
3014
|
+
// src/rules/_prose-budget.ts
|
|
2998
3015
|
var import_utils18 = require("@typescript-eslint/utils");
|
|
3016
|
+
var DIRECTIVE_RE2 = /^(?:!|eslint\b|eslint-|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|@vite|webpack|@jsx|@jest-environment|@vitest-environment|#__|todo\b|fixme\b|hack\b)/i;
|
|
3017
|
+
var LICENSE_RE2 = /\b(?:copyright|spdx-license-identifier|licensed under)\b/i;
|
|
3018
|
+
var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
|
|
3019
|
+
var VALUE_TAG_RE = /@(example|deprecated|see|remarks|throws|internal|public|alpha|beta|since|template|fileoverview)\b/i;
|
|
3020
|
+
var BOUNDARY_RE = /(?<=[.!?])["'`)\]]*\s+(?=[A-Z0-9`])/;
|
|
3021
|
+
var BULLET_RE = /^\s*(?:[-*+] |\d+[.)] )/;
|
|
3022
|
+
function body(comment) {
|
|
3023
|
+
return comment.value.replace(/^\*/, "").split("\n").map((line) => line.replace(/^\s*\*?\s?/, "")).join("\n").trim();
|
|
3024
|
+
}
|
|
3025
|
+
function eligible(text, includeValueTags) {
|
|
3026
|
+
return text.length > 0 && !DIRECTIVE_RE2.test(text) && !LICENSE_RE2.test(text) && (includeValueTags || !VALUE_TAG_RE.test(text));
|
|
3027
|
+
}
|
|
3028
|
+
function sentenceUnits(text) {
|
|
3029
|
+
const cleaned = text.replace(/https?:\/\/\S+/g, "URL").replace(/`[^`\n]+`/g, "CODE").replace(/\b\d+\.\d+\b/g, "NUMBER").replace(/\b(?:e\.g\.|i\.e\.|vs\.|etc\.)/gi, "ABBREVIATION");
|
|
3030
|
+
let units = 0;
|
|
3031
|
+
const prose = [];
|
|
3032
|
+
for (const raw of cleaned.split("\n")) {
|
|
3033
|
+
const line = raw.trim();
|
|
3034
|
+
if (line.length === 0 || /^[A-Za-z][A-Za-z ]+:$/.test(line)) continue;
|
|
3035
|
+
if (BULLET_RE.test(line)) units += 1;
|
|
3036
|
+
else prose.push(line);
|
|
3037
|
+
}
|
|
3038
|
+
if (prose.length > 0) units += prose.join(" ").split(BOUNDARY_RE).length;
|
|
3039
|
+
return units;
|
|
3040
|
+
}
|
|
3041
|
+
function proseGroups(filename, sourceCode, includeValueTags = false) {
|
|
3042
|
+
if (isGeneratedFile(filename, sourceCode.text) || isStoryFile(filename)) return [];
|
|
3043
|
+
const groups = [];
|
|
3044
|
+
let run = [];
|
|
3045
|
+
const flush = () => {
|
|
3046
|
+
if (run.length === 0) return;
|
|
3047
|
+
const text = run.map(body).join("\n");
|
|
3048
|
+
if (eligible(text, includeValueTags)) groups.push({ comment: run[0], text, hasTypedTags: TYPED_TAG_RE.test(text) });
|
|
3049
|
+
run = [];
|
|
3050
|
+
};
|
|
3051
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
3052
|
+
const text = body(comment);
|
|
3053
|
+
if (comment.type === "Block") {
|
|
3054
|
+
flush();
|
|
3055
|
+
if (eligible(text, includeValueTags)) groups.push({ comment, text, hasTypedTags: TYPED_TAG_RE.test(text) });
|
|
3056
|
+
continue;
|
|
3057
|
+
}
|
|
3058
|
+
const ownLine = sourceCode.lines[comment.loc.start.line - 1]?.slice(0, comment.loc.start.column).trim() === "";
|
|
3059
|
+
if (!ownLine || !eligible(text, includeValueTags)) {
|
|
3060
|
+
flush();
|
|
3061
|
+
continue;
|
|
3062
|
+
}
|
|
3063
|
+
const previous = run.at(-1);
|
|
3064
|
+
if (previous !== void 0 && (comment.loc.start.line !== previous.loc.end.line + 1 || comment.loc.start.column !== previous.loc.start.column)) flush();
|
|
3065
|
+
run.push(comment);
|
|
3066
|
+
}
|
|
3067
|
+
flush();
|
|
3068
|
+
return groups;
|
|
3069
|
+
}
|
|
3070
|
+
function annotatedParameter(parameter) {
|
|
3071
|
+
if (parameter.type === import_utils18.AST_NODE_TYPES.TSParameterProperty) return annotatedParameter(parameter.parameter);
|
|
3072
|
+
const target = parameter.type === import_utils18.AST_NODE_TYPES.AssignmentPattern ? parameter.left : parameter;
|
|
3073
|
+
return "typeAnnotation" in target && target.typeAnnotation != null;
|
|
3074
|
+
}
|
|
3075
|
+
function typedFunction(node) {
|
|
3076
|
+
switch (node.type) {
|
|
3077
|
+
case import_utils18.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3078
|
+
case import_utils18.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3079
|
+
return node.declaration != null && typedFunction(node.declaration);
|
|
3080
|
+
case import_utils18.AST_NODE_TYPES.FunctionDeclaration:
|
|
3081
|
+
case import_utils18.AST_NODE_TYPES.TSDeclareFunction:
|
|
3082
|
+
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3083
|
+
case import_utils18.AST_NODE_TYPES.VariableDeclaration: {
|
|
3084
|
+
const init = node.declarations[0]?.init;
|
|
3085
|
+
return init != null && (init.type === import_utils18.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils18.AST_NODE_TYPES.FunctionExpression) && init.returnType != null && init.params.every(annotatedParameter);
|
|
3086
|
+
}
|
|
3087
|
+
case import_utils18.AST_NODE_TYPES.MethodDefinition:
|
|
3088
|
+
return node.value.returnType != null && node.value.params.every(annotatedParameter);
|
|
3089
|
+
case import_utils18.AST_NODE_TYPES.TSMethodSignature:
|
|
3090
|
+
return node.returnType != null && node.params.every(annotatedParameter);
|
|
3091
|
+
default:
|
|
3092
|
+
return false;
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
function documentsTypedFunction(sourceCode, comment) {
|
|
3096
|
+
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3097
|
+
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return false;
|
|
3098
|
+
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3099
|
+
while (node != null && node.type !== import_utils18.AST_NODE_TYPES.Program) {
|
|
3100
|
+
if (typedFunction(node)) return true;
|
|
3101
|
+
node = node.parent ?? null;
|
|
3102
|
+
}
|
|
3103
|
+
return false;
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
// src/rules/no-long-comment.ts
|
|
3107
|
+
var no_long_comment_default = createRule({
|
|
3108
|
+
name: "no-long-comment",
|
|
3109
|
+
meta: {
|
|
3110
|
+
type: "suggestion",
|
|
3111
|
+
docs: { description: "Limit in-code prose to two sentences." },
|
|
3112
|
+
schema: [],
|
|
3113
|
+
messages: {
|
|
3114
|
+
tooLong: "Comment exceeds two sentences \u2014 keep one local fact and clarify the code itself."
|
|
3115
|
+
}
|
|
3116
|
+
},
|
|
3117
|
+
defaultOptions: [],
|
|
3118
|
+
create(context) {
|
|
3119
|
+
return {
|
|
3120
|
+
Program() {
|
|
3121
|
+
for (const group of proseGroups(context.filename, context.sourceCode)) {
|
|
3122
|
+
if (!group.hasTypedTags && sentenceUnits(group.text) >= 3) {
|
|
3123
|
+
context.report({ node: group.comment, messageId: "tooLong" });
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
};
|
|
3128
|
+
}
|
|
3129
|
+
});
|
|
3130
|
+
|
|
3131
|
+
// src/rules/no-offset-pagination.ts
|
|
3132
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
2999
3133
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:%s|%\(\w+\)s|\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
3000
3134
|
var OFFSET_GATE = /offset/i;
|
|
3001
3135
|
var no_offset_pagination_default = createRule({
|
|
@@ -3025,15 +3159,15 @@ var no_offset_pagination_default = createRule({
|
|
|
3025
3159
|
});
|
|
3026
3160
|
|
|
3027
3161
|
// src/rules/no-positional-tuple-return.ts
|
|
3028
|
-
var
|
|
3162
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
3029
3163
|
var MIN_ELEMENTS = 2;
|
|
3030
3164
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
3031
3165
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
3032
3166
|
function tupleReturnType(node) {
|
|
3033
|
-
if (node.type ===
|
|
3167
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSTupleType) {
|
|
3034
3168
|
return node;
|
|
3035
3169
|
}
|
|
3036
|
-
if (node.type ===
|
|
3170
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils20.AST_NODE_TYPES.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
3037
3171
|
const argument = node.typeArguments?.params[0];
|
|
3038
3172
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
3039
3173
|
}
|
|
@@ -3047,30 +3181,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
3047
3181
|
if (elements.length < MIN_ELEMENTS) {
|
|
3048
3182
|
return true;
|
|
3049
3183
|
}
|
|
3050
|
-
if (elements.some((element) => element.type ===
|
|
3184
|
+
if (elements.some((element) => element.type === import_utils20.AST_NODE_TYPES.TSRestType)) {
|
|
3051
3185
|
return true;
|
|
3052
3186
|
}
|
|
3053
|
-
if (elements.some((element) => element.type ===
|
|
3187
|
+
if (elements.some((element) => element.type === import_utils20.AST_NODE_TYPES.TSNamedTupleMember)) {
|
|
3054
3188
|
return true;
|
|
3055
3189
|
}
|
|
3056
|
-
if (elements[0]?.type ===
|
|
3190
|
+
if (elements[0]?.type === import_utils20.AST_NODE_TYPES.TSLiteralType) {
|
|
3057
3191
|
return true;
|
|
3058
3192
|
}
|
|
3059
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type ===
|
|
3193
|
+
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === import_utils20.AST_NODE_TYPES.TSFunctionType)) {
|
|
3060
3194
|
return true;
|
|
3061
3195
|
}
|
|
3062
3196
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
3063
3197
|
return texts.size === 1;
|
|
3064
3198
|
}
|
|
3065
3199
|
function functionName(node) {
|
|
3066
|
-
if (node.type ===
|
|
3200
|
+
if (node.type === import_utils20.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3067
3201
|
return node.id?.name ?? null;
|
|
3068
3202
|
}
|
|
3069
3203
|
const parent = node.parent;
|
|
3070
|
-
if (parent?.type ===
|
|
3204
|
+
if (parent?.type === import_utils20.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3071
3205
|
return parent.id.name;
|
|
3072
3206
|
}
|
|
3073
|
-
if ((parent?.type ===
|
|
3207
|
+
if ((parent?.type === import_utils20.AST_NODE_TYPES.MethodDefinition || parent?.type === import_utils20.AST_NODE_TYPES.PropertyDefinition || parent?.type === import_utils20.AST_NODE_TYPES.Property) && parent.key.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3074
3208
|
return parent.key.name;
|
|
3075
3209
|
}
|
|
3076
3210
|
return null;
|
|
@@ -3078,7 +3212,7 @@ function functionName(node) {
|
|
|
3078
3212
|
function isInlineExported(node) {
|
|
3079
3213
|
for (let current = node; current != null; current = current.parent) {
|
|
3080
3214
|
const parent = current.parent;
|
|
3081
|
-
if (parent?.type ===
|
|
3215
|
+
if (parent?.type === import_utils20.AST_NODE_TYPES.ExportNamedDeclaration || parent?.type === import_utils20.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
3082
3216
|
return true;
|
|
3083
3217
|
}
|
|
3084
3218
|
}
|
|
@@ -3087,18 +3221,18 @@ function isInlineExported(node) {
|
|
|
3087
3221
|
function moduleScopeBindingName(node) {
|
|
3088
3222
|
let current = node;
|
|
3089
3223
|
let child = node;
|
|
3090
|
-
while (current.parent != null && current.parent.type !==
|
|
3224
|
+
while (current.parent != null && current.parent.type !== import_utils20.AST_NODE_TYPES.Program) {
|
|
3091
3225
|
child = current;
|
|
3092
3226
|
current = current.parent;
|
|
3093
3227
|
}
|
|
3094
|
-
if (current.parent?.type !==
|
|
3228
|
+
if (current.parent?.type !== import_utils20.AST_NODE_TYPES.Program) {
|
|
3095
3229
|
return null;
|
|
3096
3230
|
}
|
|
3097
|
-
if (current.type ===
|
|
3231
|
+
if (current.type === import_utils20.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils20.AST_NODE_TYPES.ClassDeclaration) {
|
|
3098
3232
|
return current.id?.name ?? null;
|
|
3099
3233
|
}
|
|
3100
|
-
if (current.type ===
|
|
3101
|
-
if (child.type !==
|
|
3234
|
+
if (current.type === import_utils20.AST_NODE_TYPES.VariableDeclaration) {
|
|
3235
|
+
if (child.type !== import_utils20.AST_NODE_TYPES.VariableDeclarator || child.id.type !== import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3102
3236
|
return null;
|
|
3103
3237
|
}
|
|
3104
3238
|
return child.id.name;
|
|
@@ -3108,19 +3242,19 @@ function moduleScopeBindingName(node) {
|
|
|
3108
3242
|
function specifierExportedNames(program) {
|
|
3109
3243
|
const names = /* @__PURE__ */ new Set();
|
|
3110
3244
|
for (const statement of program.body) {
|
|
3111
|
-
if (statement.type ===
|
|
3245
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
3112
3246
|
for (const specifier of statement.specifiers) {
|
|
3113
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
3247
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3114
3248
|
names.add(specifier.local.name);
|
|
3115
3249
|
}
|
|
3116
3250
|
}
|
|
3117
3251
|
continue;
|
|
3118
3252
|
}
|
|
3119
|
-
if (statement.type ===
|
|
3253
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3120
3254
|
names.add(statement.declaration.name);
|
|
3121
3255
|
continue;
|
|
3122
3256
|
}
|
|
3123
|
-
if (statement.type ===
|
|
3257
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3124
3258
|
names.add(statement.expression.name);
|
|
3125
3259
|
}
|
|
3126
3260
|
}
|
|
@@ -3182,7 +3316,7 @@ var no_positional_tuple_return_default = createRule({
|
|
|
3182
3316
|
});
|
|
3183
3317
|
|
|
3184
3318
|
// src/rules/no-raw-env.ts
|
|
3185
|
-
var
|
|
3319
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
3186
3320
|
var CONFIG_FILE_RE = /(^|[\\/])[\w.-]+\.config\.[cm]?[jt]sx?$/;
|
|
3187
3321
|
var ENV_BOUNDARY_FILE_RE = /(^|[\\/])(?:env|client-env|server-env|client-settings|server-settings)\.[cm]?[jt]sx?$/;
|
|
3188
3322
|
var ENV_VALIDATION_MARKER_RE = /\bcreateEnv\s*\(|\bz\.object\s*\(|\.(?:safeParse|parse)\s*\(/;
|
|
@@ -3232,11 +3366,11 @@ var no_raw_env_default = createRule({
|
|
|
3232
3366
|
meta: {
|
|
3233
3367
|
type: "problem",
|
|
3234
3368
|
docs: {
|
|
3235
|
-
description: "Disallow direct `process.env`
|
|
3369
|
+
description: "Disallow direct `process.env` and `import.meta.env` reads outside validated boundaries."
|
|
3236
3370
|
},
|
|
3237
3371
|
schema: [],
|
|
3238
3372
|
messages: {
|
|
3239
|
-
noRawEnv: "Do not read
|
|
3373
|
+
noRawEnv: "Do not read raw environment values directly. Import the validated env module so values are typed and checked at startup."
|
|
3240
3374
|
}
|
|
3241
3375
|
},
|
|
3242
3376
|
defaultOptions: [],
|
|
@@ -3259,13 +3393,11 @@ var no_raw_env_default = createRule({
|
|
|
3259
3393
|
});
|
|
3260
3394
|
|
|
3261
3395
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
3262
|
-
var
|
|
3396
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
3263
3397
|
var DEFAULT_ALLOW = [
|
|
3264
3398
|
"[\\\\/]clients?[\\\\/]",
|
|
3265
3399
|
"-client\\.[cm]?[jt]sx?$",
|
|
3266
3400
|
"[\\\\/]http-client\\.[cm]?[jt]sx?$",
|
|
3267
|
-
// The `api` spelling of the same client-layer convention: an `api/` directory,
|
|
3268
|
-
// a bare `api.ts`, or a `*-api.ts` / `*.api.ts` module.
|
|
3269
3401
|
"[\\\\/]api[\\\\/]",
|
|
3270
3402
|
"[\\\\/]api\\.[cm]?[jt]sx?$",
|
|
3271
3403
|
"[-.]api\\.[cm]?[jt]sx?$",
|
|
@@ -3303,7 +3435,7 @@ function identifierLikeName(node) {
|
|
|
3303
3435
|
}
|
|
3304
3436
|
function isConstructedArgumentHandoff(node) {
|
|
3305
3437
|
const [first] = node.arguments;
|
|
3306
|
-
return node.arguments.length === 1 && first !== void 0 && first.type ===
|
|
3438
|
+
return node.arguments.length === 1 && first !== void 0 && first.type === import_utils22.AST_NODE_TYPES.NewExpression;
|
|
3307
3439
|
}
|
|
3308
3440
|
function isPresignedUrlTransfer(node) {
|
|
3309
3441
|
const first = node.arguments[0];
|
|
@@ -3372,16 +3504,16 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
3372
3504
|
});
|
|
3373
3505
|
|
|
3374
3506
|
// src/rules/no-repeated-string-literal.ts
|
|
3375
|
-
var
|
|
3507
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
3376
3508
|
var MIN_LENGTH = 40;
|
|
3377
3509
|
var MIN_DISTINCT_SCOPES = 2;
|
|
3378
3510
|
var PREVIEW_LENGTH = 40;
|
|
3379
3511
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
3380
3512
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
3381
3513
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3514
|
+
import_utils23.AST_NODE_TYPES.FunctionDeclaration,
|
|
3515
|
+
import_utils23.AST_NODE_TYPES.FunctionExpression,
|
|
3516
|
+
import_utils23.AST_NODE_TYPES.ArrowFunctionExpression
|
|
3385
3517
|
]);
|
|
3386
3518
|
function isStructured(value) {
|
|
3387
3519
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -3403,7 +3535,8 @@ function isScaffolding(node) {
|
|
|
3403
3535
|
if (parent === void 0) {
|
|
3404
3536
|
return true;
|
|
3405
3537
|
}
|
|
3406
|
-
|
|
3538
|
+
const isRequireSource = parent.type === import_utils23.AST_NODE_TYPES.CallExpression && parent.callee.type === import_utils23.AST_NODE_TYPES.Identifier && parent.callee.name === "require";
|
|
3539
|
+
return parent.type === import_utils23.AST_NODE_TYPES.ImportDeclaration || parent.type === import_utils23.AST_NODE_TYPES.ImportExpression || parent.type === import_utils23.AST_NODE_TYPES.ExportNamedDeclaration || parent.type === import_utils23.AST_NODE_TYPES.ExportAllDeclaration || parent.type === import_utils23.AST_NODE_TYPES.TSImportType || parent.type === import_utils23.AST_NODE_TYPES.JSXAttribute || parent.type === import_utils23.AST_NODE_TYPES.TSLiteralType || isRequireSource;
|
|
3407
3540
|
}
|
|
3408
3541
|
var no_repeated_string_literal_default = createRule({
|
|
3409
3542
|
name: "no-repeated-string-literal",
|
|
@@ -3443,7 +3576,7 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3443
3576
|
}
|
|
3444
3577
|
},
|
|
3445
3578
|
TemplateLiteral(node) {
|
|
3446
|
-
if (node.parent.type ===
|
|
3579
|
+
if (node.parent.type === import_utils23.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
3447
3580
|
return;
|
|
3448
3581
|
}
|
|
3449
3582
|
const [only] = node.quasis;
|
|
@@ -3477,10 +3610,10 @@ var no_repeated_string_literal_default = createRule({
|
|
|
3477
3610
|
});
|
|
3478
3611
|
|
|
3479
3612
|
// src/rules/no-restated-comment.ts
|
|
3480
|
-
var
|
|
3613
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
3481
3614
|
var MAX_WORDS = 8;
|
|
3482
3615
|
var MIN_CONTENT_TOKENS = 2;
|
|
3483
|
-
var
|
|
3616
|
+
var DIRECTIVE_RE3 = /^(eslint\b|eslint-|sarj-noqa\b|@ts-|prettier-ignore|prettier\b|biome-|c8\b|v8\b|istanbul\b|@type\b|@vite|webpack|<reference|<amd|global\b|noinspection|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
3484
3617
|
var CODEY_RE = /^[\w.$[\]'"]+\s*[:=]\s*\S|^[\w.$]+\s*\(|^(?:return|throw|await|import|export|const|let|var)\b.*[=()[\]{}]/;
|
|
3485
3618
|
var BANNERISH_RE = /[=\-─-╿*#~_.]{3,}|^[A-Z0-9 _:-]+$/;
|
|
3486
3619
|
var MODALITY_RE = /\b(?:can|could|should|shall|may|might|must|will|would|cannot)\b/i;
|
|
@@ -3498,10 +3631,10 @@ function areAdjacentLineComments2(a, b) {
|
|
|
3498
3631
|
function headsSiblingRun(node) {
|
|
3499
3632
|
const parent = node.parent;
|
|
3500
3633
|
if (parent === void 0) return false;
|
|
3501
|
-
const
|
|
3502
|
-
if (
|
|
3503
|
-
const index =
|
|
3504
|
-
const next = index >= 0 ?
|
|
3634
|
+
const body2 = "body" in parent && Array.isArray(parent.body) ? parent.body : void 0;
|
|
3635
|
+
if (body2 === void 0) return false;
|
|
3636
|
+
const index = body2.indexOf(node);
|
|
3637
|
+
const next = index >= 0 ? body2[index + 1] : void 0;
|
|
3505
3638
|
return next !== void 0 && next.type === node.type;
|
|
3506
3639
|
}
|
|
3507
3640
|
var no_restated_comment_default = createRule({
|
|
@@ -3530,7 +3663,7 @@ var no_restated_comment_default = createRule({
|
|
|
3530
3663
|
function labelsASiblingRun(comment) {
|
|
3531
3664
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
3532
3665
|
if (token === null) return false;
|
|
3533
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
3666
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== import_utils24.AST_NODE_TYPES.Program; node = node.parent) {
|
|
3534
3667
|
if (headsSiblingRun(node)) return true;
|
|
3535
3668
|
}
|
|
3536
3669
|
return false;
|
|
@@ -3541,8 +3674,8 @@ var no_restated_comment_default = createRule({
|
|
|
3541
3674
|
const wallMembers = /* @__PURE__ */ new Set();
|
|
3542
3675
|
let cluster = [];
|
|
3543
3676
|
for (const candidate of comments) {
|
|
3544
|
-
const
|
|
3545
|
-
if (candidate.type !== "Line" || !isStandalone(candidate) || isProtected(
|
|
3677
|
+
const body2 = candidate.value.replace(/^\/*/, "").trim();
|
|
3678
|
+
if (candidate.type !== "Line" || !isStandalone(candidate) || isProtected(body2) || !WALL_NARRATION_RE2.test(body2)) {
|
|
3546
3679
|
continue;
|
|
3547
3680
|
}
|
|
3548
3681
|
const previous = cluster.at(-1);
|
|
@@ -3565,18 +3698,18 @@ var no_restated_comment_default = createRule({
|
|
|
3565
3698
|
if (areAdjacentLineComments2(comments[i - 1], comment) || areAdjacentLineComments2(comment, comments[i + 1])) {
|
|
3566
3699
|
continue;
|
|
3567
3700
|
}
|
|
3568
|
-
const
|
|
3569
|
-
if (
|
|
3570
|
-
if (
|
|
3571
|
-
if (NON_ASCII_LETTER_RE.test(
|
|
3572
|
-
if (MODALITY_RE.test(
|
|
3573
|
-
if (NEGATION_WORD_RE.test(
|
|
3574
|
-
if (
|
|
3575
|
-
const tokens = contentTokens(
|
|
3701
|
+
const body2 = comment.value.replace(/^\/*/, "").trim();
|
|
3702
|
+
if (body2.length === 0 || body2.endsWith("?")) continue;
|
|
3703
|
+
if (DIRECTIVE_RE3.test(body2) || CODEY_RE.test(body2) || BANNERISH_RE.test(body2)) continue;
|
|
3704
|
+
if (NON_ASCII_LETTER_RE.test(body2) || isProtected(body2)) continue;
|
|
3705
|
+
if (MODALITY_RE.test(body2) || LEAD_IN_RE.test(body2) || EMPHASIS_RE.test(body2)) continue;
|
|
3706
|
+
if (NEGATION_WORD_RE.test(body2)) continue;
|
|
3707
|
+
if (body2.split(/\s+/).length > MAX_WORDS) continue;
|
|
3708
|
+
const tokens = contentTokens(body2);
|
|
3576
3709
|
if (tokens.length < MIN_CONTENT_TOKENS) continue;
|
|
3577
3710
|
const statement = restatableStatementBelow(comment, sourceCode);
|
|
3578
3711
|
if (statement === null) continue;
|
|
3579
|
-
if (restatesStatementHead(
|
|
3712
|
+
if (restatesStatementHead(body2, statement)) continue;
|
|
3580
3713
|
const line = lines[comment.loc.start.line] ?? "";
|
|
3581
3714
|
if (!ACTION_STMT_RE.test(line)) continue;
|
|
3582
3715
|
if (labelsASiblingRun(comment)) continue;
|
|
@@ -3590,7 +3723,7 @@ var no_restated_comment_default = createRule({
|
|
|
3590
3723
|
});
|
|
3591
3724
|
|
|
3592
3725
|
// src/rules/no-restated-jsdoc.ts
|
|
3593
|
-
var
|
|
3726
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
3594
3727
|
var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
3595
3728
|
"arg",
|
|
3596
3729
|
"argument",
|
|
@@ -3602,7 +3735,7 @@ var MODELLED_TAGS = /* @__PURE__ */ new Set([
|
|
|
3602
3735
|
]);
|
|
3603
3736
|
var PARAM_TAGS = /* @__PURE__ */ new Set(["arg", "argument", "param"]);
|
|
3604
3737
|
var RETURN_TAGS = /* @__PURE__ */ new Set(["return", "returns"]);
|
|
3605
|
-
var
|
|
3738
|
+
var DIRECTIVE_RE4 = /^\s*(?:eslint\b|eslint-|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|@vite|webpack|@jsx|@jest-environment|@vitest-environment|#__)/i;
|
|
3606
3739
|
var STOPWORDS2 = new Set(
|
|
3607
3740
|
`the a an of to for in on with and or as at by is are was be been being
|
|
3608
3741
|
this that it its if whether when where which what will would can could should
|
|
@@ -3644,30 +3777,30 @@ function declarationNames(node) {
|
|
|
3644
3777
|
switch (node.type) {
|
|
3645
3778
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
3646
3779
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
3647
|
-
case
|
|
3648
|
-
case
|
|
3780
|
+
case import_utils25.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
3781
|
+
case import_utils25.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
3649
3782
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
3650
|
-
case
|
|
3651
|
-
case
|
|
3783
|
+
case import_utils25.AST_NODE_TYPES.FunctionDeclaration:
|
|
3784
|
+
case import_utils25.AST_NODE_TYPES.TSDeclareFunction:
|
|
3652
3785
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
3653
|
-
case
|
|
3654
|
-
case
|
|
3655
|
-
case
|
|
3656
|
-
case
|
|
3786
|
+
case import_utils25.AST_NODE_TYPES.ClassDeclaration:
|
|
3787
|
+
case import_utils25.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3788
|
+
case import_utils25.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3789
|
+
case import_utils25.AST_NODE_TYPES.TSEnumDeclaration:
|
|
3657
3790
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
3658
|
-
case
|
|
3791
|
+
case import_utils25.AST_NODE_TYPES.VariableDeclaration: {
|
|
3659
3792
|
const declarator = node.declarations[0];
|
|
3660
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
3793
|
+
if (declarator === void 0 || declarator.id.type !== import_utils25.AST_NODE_TYPES.Identifier) return null;
|
|
3661
3794
|
const init = declarator.init;
|
|
3662
|
-
const params = init != null && (init.type ===
|
|
3795
|
+
const params = init != null && (init.type === import_utils25.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils25.AST_NODE_TYPES.FunctionExpression) ? paramNames(init.params) : [];
|
|
3663
3796
|
return { name: declarator.id.name, params };
|
|
3664
3797
|
}
|
|
3665
|
-
case
|
|
3666
|
-
case
|
|
3667
|
-
case
|
|
3668
|
-
case
|
|
3669
|
-
if (node.key.type !==
|
|
3670
|
-
const params = node.type ===
|
|
3798
|
+
case import_utils25.AST_NODE_TYPES.MethodDefinition:
|
|
3799
|
+
case import_utils25.AST_NODE_TYPES.PropertyDefinition:
|
|
3800
|
+
case import_utils25.AST_NODE_TYPES.TSMethodSignature:
|
|
3801
|
+
case import_utils25.AST_NODE_TYPES.TSPropertySignature: {
|
|
3802
|
+
if (node.key.type !== import_utils25.AST_NODE_TYPES.Identifier) return null;
|
|
3803
|
+
const params = node.type === import_utils25.AST_NODE_TYPES.MethodDefinition ? paramNames(node.value.params) : node.type === import_utils25.AST_NODE_TYPES.TSMethodSignature ? paramNames(node.params) : [];
|
|
3671
3804
|
return { name: node.key.name, params };
|
|
3672
3805
|
}
|
|
3673
3806
|
default:
|
|
@@ -3677,9 +3810,9 @@ function declarationNames(node) {
|
|
|
3677
3810
|
function paramNames(params) {
|
|
3678
3811
|
const names = [];
|
|
3679
3812
|
for (const param of params) {
|
|
3680
|
-
const target = param.type ===
|
|
3681
|
-
if (target.type ===
|
|
3682
|
-
else if (target.type ===
|
|
3813
|
+
const target = param.type === import_utils25.AST_NODE_TYPES.AssignmentPattern ? param.left : param;
|
|
3814
|
+
if (target.type === import_utils25.AST_NODE_TYPES.Identifier) names.push(target.name);
|
|
3815
|
+
else if (target.type === import_utils25.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
3683
3816
|
}
|
|
3684
3817
|
return names;
|
|
3685
3818
|
}
|
|
@@ -3713,7 +3846,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3713
3846
|
for (const comment of sourceCode.getAllComments()) {
|
|
3714
3847
|
if (comment.type !== "Block" || !comment.value.startsWith("*")) continue;
|
|
3715
3848
|
const { description, tags } = parseJsDoc(comment.value);
|
|
3716
|
-
if (
|
|
3849
|
+
if (DIRECTIVE_RE4.test(description)) continue;
|
|
3717
3850
|
const tagNames = new Set(tags.map((tag) => tag.name));
|
|
3718
3851
|
if ([...tagNames].some((name) => !MODELLED_TAGS.has(name))) continue;
|
|
3719
3852
|
if (isProtected(description)) continue;
|
|
@@ -3721,7 +3854,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3721
3854
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
3722
3855
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
3723
3856
|
let declaration = null;
|
|
3724
|
-
while (node != null && node.type !==
|
|
3857
|
+
while (node != null && node.type !== import_utils25.AST_NODE_TYPES.Program) {
|
|
3725
3858
|
declaration = declarationNames(node);
|
|
3726
3859
|
if (declaration !== null) break;
|
|
3727
3860
|
node = node.parent ?? null;
|
|
@@ -3776,7 +3909,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
3776
3909
|
});
|
|
3777
3910
|
|
|
3778
3911
|
// src/rules/no-secret-in-log.ts
|
|
3779
|
-
var
|
|
3912
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
3780
3913
|
|
|
3781
3914
|
// src/rules/_secret-names.ts
|
|
3782
3915
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -4113,7 +4246,7 @@ var no_secret_in_log_default = createRule({
|
|
|
4113
4246
|
});
|
|
4114
4247
|
|
|
4115
4248
|
// src/rules/no-select-star.ts
|
|
4116
|
-
var
|
|
4249
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
4117
4250
|
var QUERY_SHAPE = /\bSELECT\b[\s\S]*?\bFROM\b/i;
|
|
4118
4251
|
var SELECT_KEYWORD = /\bSELECT\b/gi;
|
|
4119
4252
|
var FROM_KEYWORD = /^FROM\b/i;
|
|
@@ -4180,12 +4313,12 @@ var no_select_star_default = createRule({
|
|
|
4180
4313
|
});
|
|
4181
4314
|
|
|
4182
4315
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
4183
|
-
var
|
|
4316
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
4184
4317
|
function sentinelKind(arg) {
|
|
4185
4318
|
if (arg === null) {
|
|
4186
4319
|
return null;
|
|
4187
4320
|
}
|
|
4188
|
-
if (arg.type ===
|
|
4321
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Literal) {
|
|
4189
4322
|
if (arg.value === null) {
|
|
4190
4323
|
return "nullish";
|
|
4191
4324
|
}
|
|
@@ -4197,13 +4330,13 @@ function sentinelKind(arg) {
|
|
|
4197
4330
|
}
|
|
4198
4331
|
return null;
|
|
4199
4332
|
}
|
|
4200
|
-
if (arg.type ===
|
|
4333
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4201
4334
|
return "nullish";
|
|
4202
4335
|
}
|
|
4203
|
-
if (arg.type ===
|
|
4336
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ArrayExpression) {
|
|
4204
4337
|
return "array";
|
|
4205
4338
|
}
|
|
4206
|
-
if (arg.type ===
|
|
4339
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ObjectExpression) {
|
|
4207
4340
|
return "object";
|
|
4208
4341
|
}
|
|
4209
4342
|
return null;
|
|
@@ -4212,25 +4345,25 @@ function isSentinelArgument(arg) {
|
|
|
4212
4345
|
if (arg === null) {
|
|
4213
4346
|
return false;
|
|
4214
4347
|
}
|
|
4215
|
-
if (arg.type ===
|
|
4348
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Literal && arg.value === null) {
|
|
4216
4349
|
return true;
|
|
4217
4350
|
}
|
|
4218
|
-
if (arg.type ===
|
|
4351
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Literal && arg.value === false) {
|
|
4219
4352
|
return true;
|
|
4220
4353
|
}
|
|
4221
|
-
if (arg.type ===
|
|
4354
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.Identifier && arg.name === "undefined") {
|
|
4222
4355
|
return true;
|
|
4223
4356
|
}
|
|
4224
|
-
if (arg.type ===
|
|
4357
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ArrayExpression && arg.elements.length === 0) {
|
|
4225
4358
|
return true;
|
|
4226
4359
|
}
|
|
4227
|
-
if (arg.type ===
|
|
4360
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ObjectExpression && arg.properties.length === 0) {
|
|
4228
4361
|
return true;
|
|
4229
4362
|
}
|
|
4230
4363
|
return false;
|
|
4231
4364
|
}
|
|
4232
4365
|
function isFunctionNode(node) {
|
|
4233
|
-
return node.type ===
|
|
4366
|
+
return node.type === import_utils28.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils28.AST_NODE_TYPES.FunctionExpression || node.type === import_utils28.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
4234
4367
|
}
|
|
4235
4368
|
function isNode3(value) {
|
|
4236
4369
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -4270,24 +4403,24 @@ function walkWithinScope(node, visit) {
|
|
|
4270
4403
|
function containsThrow(node) {
|
|
4271
4404
|
return walkWithinScope(
|
|
4272
4405
|
node,
|
|
4273
|
-
(current) => current.type ===
|
|
4406
|
+
(current) => current.type === import_utils28.AST_NODE_TYPES.ThrowStatement
|
|
4274
4407
|
);
|
|
4275
4408
|
}
|
|
4276
4409
|
function bindsName(param, name) {
|
|
4277
4410
|
switch (param.type) {
|
|
4278
|
-
case
|
|
4411
|
+
case import_utils28.AST_NODE_TYPES.Identifier:
|
|
4279
4412
|
return param.name === name;
|
|
4280
|
-
case
|
|
4413
|
+
case import_utils28.AST_NODE_TYPES.AssignmentPattern:
|
|
4281
4414
|
return bindsName(param.left, name);
|
|
4282
|
-
case
|
|
4415
|
+
case import_utils28.AST_NODE_TYPES.RestElement:
|
|
4283
4416
|
return bindsName(param.argument, name);
|
|
4284
|
-
case
|
|
4417
|
+
case import_utils28.AST_NODE_TYPES.ArrayPattern:
|
|
4285
4418
|
return param.elements.some(
|
|
4286
4419
|
(element) => element !== null && bindsName(element, name)
|
|
4287
4420
|
);
|
|
4288
|
-
case
|
|
4421
|
+
case import_utils28.AST_NODE_TYPES.ObjectPattern:
|
|
4289
4422
|
return param.properties.some(
|
|
4290
|
-
(property) => property.type ===
|
|
4423
|
+
(property) => property.type === import_utils28.AST_NODE_TYPES.RestElement ? bindsName(property.argument, name) : bindsName(property.value, name)
|
|
4291
4424
|
);
|
|
4292
4425
|
default:
|
|
4293
4426
|
return false;
|
|
@@ -4302,7 +4435,7 @@ function subtreeReadsName(node, name) {
|
|
|
4302
4435
|
if (found) {
|
|
4303
4436
|
return;
|
|
4304
4437
|
}
|
|
4305
|
-
if (current.type ===
|
|
4438
|
+
if (current.type === import_utils28.AST_NODE_TYPES.Identifier && current.name === name) {
|
|
4306
4439
|
found = true;
|
|
4307
4440
|
return;
|
|
4308
4441
|
}
|
|
@@ -4313,10 +4446,10 @@ function subtreeReadsName(node, name) {
|
|
|
4313
4446
|
if (key === "parent") {
|
|
4314
4447
|
continue;
|
|
4315
4448
|
}
|
|
4316
|
-
if (key === "key" && current.type ===
|
|
4449
|
+
if (key === "key" && current.type === import_utils28.AST_NODE_TYPES.Property && !current.computed) {
|
|
4317
4450
|
continue;
|
|
4318
4451
|
}
|
|
4319
|
-
if (key === "property" && current.type ===
|
|
4452
|
+
if (key === "property" && current.type === import_utils28.AST_NODE_TYPES.MemberExpression && !current.computed) {
|
|
4320
4453
|
continue;
|
|
4321
4454
|
}
|
|
4322
4455
|
const value = current[key];
|
|
@@ -4349,10 +4482,10 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4349
4482
|
"URLPattern"
|
|
4350
4483
|
]);
|
|
4351
4484
|
function isParseShapedNode(node) {
|
|
4352
|
-
if (node.type ===
|
|
4485
|
+
if (node.type === import_utils28.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils28.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4353
4486
|
return node.callee.property.name === "parse";
|
|
4354
4487
|
}
|
|
4355
|
-
if (node.type ===
|
|
4488
|
+
if (node.type === import_utils28.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4356
4489
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
4357
4490
|
}
|
|
4358
4491
|
return false;
|
|
@@ -4363,10 +4496,10 @@ var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
4363
4496
|
"arrayBuffer"
|
|
4364
4497
|
]);
|
|
4365
4498
|
function isBodyDecodeNode(node) {
|
|
4366
|
-
return node.type ===
|
|
4499
|
+
return node.type === import_utils28.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils28.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils28.AST_NODE_TYPES.Identifier && BODY_DECODE_METHODS.has(node.callee.property.name);
|
|
4367
4500
|
}
|
|
4368
4501
|
function returnsMatching(stmt, predicate) {
|
|
4369
|
-
return stmt.type ===
|
|
4502
|
+
return stmt.type === import_utils28.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && walkWithinScope(stmt.argument, predicate);
|
|
4370
4503
|
}
|
|
4371
4504
|
function enclosingReturnTypeNode(node) {
|
|
4372
4505
|
let current = node.parent;
|
|
@@ -4384,11 +4517,11 @@ function enclosingFunctionName(node) {
|
|
|
4384
4517
|
let current = node.parent;
|
|
4385
4518
|
while (current !== void 0 && current !== null) {
|
|
4386
4519
|
if (isFunctionNode(current)) {
|
|
4387
|
-
if ("id" in current && isNode3(current.id) && current.id.type ===
|
|
4520
|
+
if ("id" in current && isNode3(current.id) && current.id.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4388
4521
|
return current.id.name;
|
|
4389
4522
|
}
|
|
4390
4523
|
const parent = current.parent;
|
|
4391
|
-
if (parent?.type ===
|
|
4524
|
+
if (parent?.type === import_utils28.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4392
4525
|
return parent.id.name;
|
|
4393
4526
|
}
|
|
4394
4527
|
return null;
|
|
@@ -4409,10 +4542,10 @@ function isDeclaredBooleanPredicate(catchNode, kind) {
|
|
|
4409
4542
|
return false;
|
|
4410
4543
|
}
|
|
4411
4544
|
let declared = enclosingReturnTypeNode(catchNode);
|
|
4412
|
-
if (declared?.type ===
|
|
4545
|
+
if (declared?.type === import_utils28.AST_NODE_TYPES.TSTypeReference && declared.typeName.type === import_utils28.AST_NODE_TYPES.Identifier && declared.typeName.name === "Promise") {
|
|
4413
4546
|
declared = declared.typeArguments?.params[0] ?? null;
|
|
4414
4547
|
}
|
|
4415
|
-
return declared?.type ===
|
|
4548
|
+
return declared?.type === import_utils28.AST_NODE_TYPES.TSBooleanKeyword;
|
|
4416
4549
|
}
|
|
4417
4550
|
function tryReturnsSafeParse(catchNode) {
|
|
4418
4551
|
const tryBlock = tryBlockOf(catchNode);
|
|
@@ -4428,7 +4561,7 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
4428
4561
|
function enclosingFunctionBody(node) {
|
|
4429
4562
|
let current = node.parent;
|
|
4430
4563
|
while (current !== void 0 && current !== null) {
|
|
4431
|
-
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type ===
|
|
4564
|
+
if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === import_utils28.AST_NODE_TYPES.BlockStatement) {
|
|
4432
4565
|
return current.body;
|
|
4433
4566
|
}
|
|
4434
4567
|
current = current.parent;
|
|
@@ -4441,7 +4574,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
|
|
|
4441
4574
|
return false;
|
|
4442
4575
|
}
|
|
4443
4576
|
return walkWithinScope(functionBody, (current) => {
|
|
4444
|
-
if (current.type !==
|
|
4577
|
+
if (current.type !== import_utils28.AST_NODE_TYPES.ReturnStatement) {
|
|
4445
4578
|
return false;
|
|
4446
4579
|
}
|
|
4447
4580
|
if (isWithin(current, catchNode.body)) {
|
|
@@ -4460,13 +4593,13 @@ function returnedSentinelKinds(arg) {
|
|
|
4460
4593
|
kinds.add(direct);
|
|
4461
4594
|
return kinds;
|
|
4462
4595
|
}
|
|
4463
|
-
if (arg.type ===
|
|
4596
|
+
if (arg.type === import_utils28.AST_NODE_TYPES.ConditionalExpression) {
|
|
4464
4597
|
for (const branch of [arg.consequent, arg.alternate]) {
|
|
4465
4598
|
for (const nested of returnedSentinelKinds(branch)) {
|
|
4466
4599
|
kinds.add(nested);
|
|
4467
4600
|
}
|
|
4468
4601
|
}
|
|
4469
|
-
} else if (arg.type ===
|
|
4602
|
+
} else if (arg.type === import_utils28.AST_NODE_TYPES.LogicalExpression && (arg.operator === "??" || arg.operator === "||")) {
|
|
4470
4603
|
for (const nested of returnedSentinelKinds(arg.right)) {
|
|
4471
4604
|
kinds.add(nested);
|
|
4472
4605
|
}
|
|
@@ -4509,7 +4642,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4509
4642
|
const matcher = createLogMatcher(loggingOptions);
|
|
4510
4643
|
function logsOrReportsError(catchBody, caughtName) {
|
|
4511
4644
|
return walkWithinScope(catchBody, (current) => {
|
|
4512
|
-
if (current.type !==
|
|
4645
|
+
if (current.type !== import_utils28.AST_NODE_TYPES.CallExpression) {
|
|
4513
4646
|
return false;
|
|
4514
4647
|
}
|
|
4515
4648
|
if (matcher.isLoggingCall(current)) {
|
|
@@ -4521,12 +4654,12 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4521
4654
|
}
|
|
4522
4655
|
return {
|
|
4523
4656
|
CatchClause(node) {
|
|
4524
|
-
const
|
|
4525
|
-
if (
|
|
4657
|
+
const body2 = node.body.body;
|
|
4658
|
+
if (body2.length === 0) {
|
|
4526
4659
|
return;
|
|
4527
4660
|
}
|
|
4528
|
-
const last =
|
|
4529
|
-
if (last === void 0 || last.type !==
|
|
4661
|
+
const last = body2[body2.length - 1];
|
|
4662
|
+
if (last === void 0 || last.type !== import_utils28.AST_NODE_TYPES.ReturnStatement) {
|
|
4530
4663
|
return;
|
|
4531
4664
|
}
|
|
4532
4665
|
if (!isSentinelArgument(last.argument)) {
|
|
@@ -4535,7 +4668,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4535
4668
|
if (containsThrow(node.body)) {
|
|
4536
4669
|
return;
|
|
4537
4670
|
}
|
|
4538
|
-
const caughtName = node.param?.type ===
|
|
4671
|
+
const caughtName = node.param?.type === import_utils28.AST_NODE_TYPES.Identifier ? node.param.name : null;
|
|
4539
4672
|
if (logsOrReportsError(node.body, caughtName)) {
|
|
4540
4673
|
return;
|
|
4541
4674
|
}
|
|
@@ -4562,9 +4695,9 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
4562
4695
|
});
|
|
4563
4696
|
|
|
4564
4697
|
// src/rules/no-silent-promise-catch.ts
|
|
4565
|
-
var
|
|
4698
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
4566
4699
|
function isBodyParseCall(node) {
|
|
4567
|
-
return node.type ===
|
|
4700
|
+
return node.type === import_utils29.AST_NODE_TYPES.CallExpression && node.arguments.length === 0 && node.callee.type === import_utils29.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils29.AST_NODE_TYPES.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
4568
4701
|
}
|
|
4569
4702
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
4570
4703
|
"cancel",
|
|
@@ -4579,37 +4712,37 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
4579
4712
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
4580
4713
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
4581
4714
|
function isTeardownCall(node) {
|
|
4582
|
-
return node.type ===
|
|
4715
|
+
return node.type === import_utils29.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils29.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils29.AST_NODE_TYPES.Identifier && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
4583
4716
|
}
|
|
4584
4717
|
function isSilentExpression(node) {
|
|
4585
4718
|
switch (node.type) {
|
|
4586
|
-
case
|
|
4719
|
+
case import_utils29.AST_NODE_TYPES.Literal:
|
|
4587
4720
|
return !("regex" in node);
|
|
4588
|
-
case
|
|
4721
|
+
case import_utils29.AST_NODE_TYPES.Identifier:
|
|
4589
4722
|
return node.name === "undefined";
|
|
4590
|
-
case
|
|
4591
|
-
return node.operator === "void" && node.argument.type ===
|
|
4592
|
-
case
|
|
4723
|
+
case import_utils29.AST_NODE_TYPES.UnaryExpression:
|
|
4724
|
+
return node.operator === "void" && node.argument.type === import_utils29.AST_NODE_TYPES.Literal;
|
|
4725
|
+
case import_utils29.AST_NODE_TYPES.ObjectExpression:
|
|
4593
4726
|
return node.properties.length === 0;
|
|
4594
|
-
case
|
|
4727
|
+
case import_utils29.AST_NODE_TYPES.ArrayExpression:
|
|
4595
4728
|
return node.elements.length === 0;
|
|
4596
|
-
case
|
|
4729
|
+
case import_utils29.AST_NODE_TYPES.TSAsExpression:
|
|
4597
4730
|
return isSilentExpression(node.expression);
|
|
4598
4731
|
default:
|
|
4599
4732
|
return false;
|
|
4600
4733
|
}
|
|
4601
4734
|
}
|
|
4602
4735
|
function isSilentHandler(handler) {
|
|
4603
|
-
const
|
|
4604
|
-
if (
|
|
4605
|
-
return isSilentExpression(
|
|
4736
|
+
const body2 = handler.body;
|
|
4737
|
+
if (body2.type !== import_utils29.AST_NODE_TYPES.BlockStatement) {
|
|
4738
|
+
return isSilentExpression(body2);
|
|
4606
4739
|
}
|
|
4607
|
-
if (
|
|
4740
|
+
if (body2.body.length === 0) {
|
|
4608
4741
|
return true;
|
|
4609
4742
|
}
|
|
4610
|
-
if (
|
|
4611
|
-
const only =
|
|
4612
|
-
if (only !== void 0 && only.type ===
|
|
4743
|
+
if (body2.body.length === 1) {
|
|
4744
|
+
const only = body2.body[0];
|
|
4745
|
+
if (only !== void 0 && only.type === import_utils29.AST_NODE_TYPES.ReturnStatement) {
|
|
4613
4746
|
return only.argument === null || isSilentExpression(only.argument);
|
|
4614
4747
|
}
|
|
4615
4748
|
}
|
|
@@ -4638,7 +4771,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4638
4771
|
return true;
|
|
4639
4772
|
}
|
|
4640
4773
|
let statement = call;
|
|
4641
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
4774
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== import_utils29.AST_NODE_TYPES.VariableDeclaration) {
|
|
4642
4775
|
statement = statement.parent;
|
|
4643
4776
|
}
|
|
4644
4777
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -4650,7 +4783,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4650
4783
|
};
|
|
4651
4784
|
return {
|
|
4652
4785
|
CallExpression(node) {
|
|
4653
|
-
if (node.callee.type !==
|
|
4786
|
+
if (node.callee.type !== import_utils29.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.property.type !== import_utils29.AST_NODE_TYPES.Identifier || node.callee.property.name !== "catch") {
|
|
4654
4787
|
return;
|
|
4655
4788
|
}
|
|
4656
4789
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -4659,14 +4792,14 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4659
4792
|
if (isTeardownCall(node.callee.object)) {
|
|
4660
4793
|
return;
|
|
4661
4794
|
}
|
|
4662
|
-
if (node.parent.type ===
|
|
4795
|
+
if (node.parent.type === import_utils29.AST_NODE_TYPES.MemberExpression && node.parent.object === node) {
|
|
4663
4796
|
return;
|
|
4664
4797
|
}
|
|
4665
4798
|
if (node.arguments.length !== 1) {
|
|
4666
4799
|
return;
|
|
4667
4800
|
}
|
|
4668
4801
|
const handler = node.arguments[0];
|
|
4669
|
-
if (handler === void 0 || handler.type !==
|
|
4802
|
+
if (handler === void 0 || handler.type !== import_utils29.AST_NODE_TYPES.ArrowFunctionExpression && handler.type !== import_utils29.AST_NODE_TYPES.FunctionExpression) {
|
|
4670
4803
|
return;
|
|
4671
4804
|
}
|
|
4672
4805
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -4681,7 +4814,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
4681
4814
|
});
|
|
4682
4815
|
|
|
4683
4816
|
// src/rules/no-sleep-in-test-body.ts
|
|
4684
|
-
var
|
|
4817
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
4685
4818
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
4686
4819
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
4687
4820
|
"it",
|
|
@@ -4690,34 +4823,34 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
|
|
|
4690
4823
|
"afterEach"
|
|
4691
4824
|
]);
|
|
4692
4825
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4826
|
+
import_utils30.AST_NODE_TYPES.FunctionDeclaration,
|
|
4827
|
+
import_utils30.AST_NODE_TYPES.FunctionExpression,
|
|
4828
|
+
import_utils30.AST_NODE_TYPES.ArrowFunctionExpression
|
|
4696
4829
|
]);
|
|
4697
4830
|
function isNonzeroNumericLiteral(node) {
|
|
4698
|
-
return node?.type ===
|
|
4831
|
+
return node?.type === import_utils30.AST_NODE_TYPES.Literal && typeof node.value === "number" && node.value !== 0;
|
|
4699
4832
|
}
|
|
4700
4833
|
function isTimedSetTimeout(node) {
|
|
4701
|
-
return node.type ===
|
|
4834
|
+
return node.type === import_utils30.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils30.AST_NODE_TYPES.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
4702
4835
|
}
|
|
4703
4836
|
function isPromiseSleep(node) {
|
|
4704
|
-
if (node.callee.type !==
|
|
4837
|
+
if (node.callee.type !== import_utils30.AST_NODE_TYPES.Identifier || node.callee.name !== "Promise") {
|
|
4705
4838
|
return false;
|
|
4706
4839
|
}
|
|
4707
4840
|
const executor = node.arguments[0];
|
|
4708
|
-
if (executor?.type !==
|
|
4841
|
+
if (executor?.type !== import_utils30.AST_NODE_TYPES.ArrowFunctionExpression && executor?.type !== import_utils30.AST_NODE_TYPES.FunctionExpression) {
|
|
4709
4842
|
return false;
|
|
4710
4843
|
}
|
|
4711
|
-
const
|
|
4712
|
-
if (
|
|
4713
|
-
return isTimedSetTimeout(
|
|
4844
|
+
const body2 = executor.body;
|
|
4845
|
+
if (body2.type !== import_utils30.AST_NODE_TYPES.BlockStatement) {
|
|
4846
|
+
return isTimedSetTimeout(body2);
|
|
4714
4847
|
}
|
|
4715
|
-
return
|
|
4716
|
-
(stmt) => stmt.type ===
|
|
4848
|
+
return body2.body.some(
|
|
4849
|
+
(stmt) => stmt.type === import_utils30.AST_NODE_TYPES.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
4717
4850
|
);
|
|
4718
4851
|
}
|
|
4719
4852
|
function isHelperSleep(node) {
|
|
4720
|
-
return node.callee.type ===
|
|
4853
|
+
return node.callee.type === import_utils30.AST_NODE_TYPES.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
4721
4854
|
}
|
|
4722
4855
|
function nearestEnclosingFunction2(node) {
|
|
4723
4856
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -4725,7 +4858,7 @@ function nearestEnclosingFunction2(node) {
|
|
|
4725
4858
|
continue;
|
|
4726
4859
|
}
|
|
4727
4860
|
const grandparent = current.parent;
|
|
4728
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
4861
|
+
const isPromiseExecutor = grandparent?.type === import_utils30.AST_NODE_TYPES.NewExpression && isPromiseSleep(grandparent);
|
|
4729
4862
|
if (!isPromiseExecutor) {
|
|
4730
4863
|
return current;
|
|
4731
4864
|
}
|
|
@@ -4733,23 +4866,23 @@ function nearestEnclosingFunction2(node) {
|
|
|
4733
4866
|
return null;
|
|
4734
4867
|
}
|
|
4735
4868
|
function testCallerName2(callee) {
|
|
4736
|
-
if (callee.type ===
|
|
4869
|
+
if (callee.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4737
4870
|
return callee.name;
|
|
4738
4871
|
}
|
|
4739
|
-
if (callee.type ===
|
|
4872
|
+
if (callee.type === import_utils30.AST_NODE_TYPES.MemberExpression) {
|
|
4740
4873
|
return testCallerName2(callee.object);
|
|
4741
4874
|
}
|
|
4742
|
-
if (callee.type ===
|
|
4875
|
+
if (callee.type === import_utils30.AST_NODE_TYPES.CallExpression) {
|
|
4743
4876
|
return testCallerName2(callee.callee);
|
|
4744
4877
|
}
|
|
4745
|
-
if (callee.type ===
|
|
4878
|
+
if (callee.type === import_utils30.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
4746
4879
|
return testCallerName2(callee.tag);
|
|
4747
4880
|
}
|
|
4748
4881
|
return null;
|
|
4749
4882
|
}
|
|
4750
4883
|
function isTestBody2(fn) {
|
|
4751
4884
|
const call = fn.parent;
|
|
4752
|
-
if (call?.type !==
|
|
4885
|
+
if (call?.type !== import_utils30.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
4753
4886
|
return false;
|
|
4754
4887
|
}
|
|
4755
4888
|
const name = testCallerName2(call.callee);
|
|
@@ -4795,7 +4928,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
4795
4928
|
});
|
|
4796
4929
|
|
|
4797
4930
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
4798
|
-
var
|
|
4931
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
4799
4932
|
var DEFAULT_METHODS2 = [
|
|
4800
4933
|
"prepare",
|
|
4801
4934
|
"put",
|
|
@@ -4814,7 +4947,7 @@ function compile2(patterns) {
|
|
|
4814
4947
|
}
|
|
4815
4948
|
function storageMethodName(node, methods) {
|
|
4816
4949
|
const callee = node.callee;
|
|
4817
|
-
if (callee.type !==
|
|
4950
|
+
if (callee.type !== import_utils31.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils31.AST_NODE_TYPES.Identifier) {
|
|
4818
4951
|
return null;
|
|
4819
4952
|
}
|
|
4820
4953
|
const name = callee.property.name;
|
|
@@ -4882,7 +5015,7 @@ var no_storage_in_stateless_modules_default = createRule({
|
|
|
4882
5015
|
});
|
|
4883
5016
|
|
|
4884
5017
|
// src/rules/no-string-concat-in-loop.ts
|
|
4885
|
-
var
|
|
5018
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
4886
5019
|
var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
4887
5020
|
"ForStatement",
|
|
4888
5021
|
"ForOfStatement",
|
|
@@ -4947,9 +5080,9 @@ function isDeclaredInsideLoop(variable, loop) {
|
|
|
4947
5080
|
if (def === void 0) {
|
|
4948
5081
|
return false;
|
|
4949
5082
|
}
|
|
4950
|
-
const
|
|
5083
|
+
const body2 = loop.body;
|
|
4951
5084
|
const [declStart, declEnd] = def.node.range;
|
|
4952
|
-
const [bodyStart, bodyEnd] =
|
|
5085
|
+
const [bodyStart, bodyEnd] = body2.range;
|
|
4953
5086
|
return declStart >= bodyStart && declEnd <= bodyEnd;
|
|
4954
5087
|
}
|
|
4955
5088
|
function enclosingLoop(node) {
|
|
@@ -5028,7 +5161,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
5028
5161
|
});
|
|
5029
5162
|
|
|
5030
5163
|
// src/rules/no-tautological-expect.ts
|
|
5031
|
-
var
|
|
5164
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
5032
5165
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
5033
5166
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
5034
5167
|
"toBeDefined",
|
|
@@ -5042,17 +5175,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
5042
5175
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
5043
5176
|
function isLiteral(node) {
|
|
5044
5177
|
switch (node.type) {
|
|
5045
|
-
case
|
|
5178
|
+
case import_utils33.AST_NODE_TYPES.Literal:
|
|
5046
5179
|
return true;
|
|
5047
|
-
case
|
|
5180
|
+
case import_utils33.AST_NODE_TYPES.TemplateLiteral:
|
|
5048
5181
|
return node.expressions.length === 0;
|
|
5049
|
-
case
|
|
5182
|
+
case import_utils33.AST_NODE_TYPES.UnaryExpression:
|
|
5050
5183
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
5051
|
-
case
|
|
5184
|
+
case import_utils33.AST_NODE_TYPES.ArrayExpression:
|
|
5052
5185
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
5053
|
-
case
|
|
5186
|
+
case import_utils33.AST_NODE_TYPES.ObjectExpression:
|
|
5054
5187
|
return node.properties.every(
|
|
5055
|
-
(property) => property.type ===
|
|
5188
|
+
(property) => property.type === import_utils33.AST_NODE_TYPES.Property && !property.computed && isLiteral(property.value)
|
|
5056
5189
|
);
|
|
5057
5190
|
default:
|
|
5058
5191
|
return false;
|
|
@@ -5060,7 +5193,7 @@ function isLiteral(node) {
|
|
|
5060
5193
|
}
|
|
5061
5194
|
function expectOperand(callee) {
|
|
5062
5195
|
const receiver = callee.object;
|
|
5063
|
-
if (receiver.type !==
|
|
5196
|
+
if (receiver.type !== import_utils33.AST_NODE_TYPES.CallExpression || receiver.callee.type !== import_utils33.AST_NODE_TYPES.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
5064
5197
|
return null;
|
|
5065
5198
|
}
|
|
5066
5199
|
return receiver.arguments[0] ?? null;
|
|
@@ -5090,10 +5223,10 @@ var no_tautological_expect_default = createRule({
|
|
|
5090
5223
|
return {
|
|
5091
5224
|
CallExpression(node) {
|
|
5092
5225
|
const callee = node.callee;
|
|
5093
|
-
if (callee.type !==
|
|
5226
|
+
if (callee.type !== import_utils33.AST_NODE_TYPES.MemberExpression || callee.computed) {
|
|
5094
5227
|
return;
|
|
5095
5228
|
}
|
|
5096
|
-
if (callee.property.type !==
|
|
5229
|
+
if (callee.property.type !== import_utils33.AST_NODE_TYPES.Identifier) {
|
|
5097
5230
|
return;
|
|
5098
5231
|
}
|
|
5099
5232
|
const matcher = callee.property.name;
|
|
@@ -5126,8 +5259,33 @@ var no_tautological_expect_default = createRule({
|
|
|
5126
5259
|
}
|
|
5127
5260
|
});
|
|
5128
5261
|
|
|
5262
|
+
// src/rules/no-typed-doc-sections.ts
|
|
5263
|
+
var no_typed_doc_sections_default = createRule({
|
|
5264
|
+
name: "no-typed-doc-sections",
|
|
5265
|
+
meta: {
|
|
5266
|
+
type: "suggestion",
|
|
5267
|
+
docs: { description: "Reject typed-signature repetition while preserving behavior that types cannot express." },
|
|
5268
|
+
schema: [],
|
|
5269
|
+
messages: {
|
|
5270
|
+
typedSection: "Typed JSDoc repeats parameters or returns \u2014 delete the tags and improve names or types instead."
|
|
5271
|
+
}
|
|
5272
|
+
},
|
|
5273
|
+
defaultOptions: [],
|
|
5274
|
+
create(context) {
|
|
5275
|
+
return {
|
|
5276
|
+
Program() {
|
|
5277
|
+
for (const group of proseGroups(context.filename, context.sourceCode, true)) {
|
|
5278
|
+
if (group.hasTypedTags && documentsTypedFunction(context.sourceCode, group.comment)) {
|
|
5279
|
+
context.report({ node: group.comment, messageId: "typedSection" });
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
};
|
|
5284
|
+
}
|
|
5285
|
+
});
|
|
5286
|
+
|
|
5129
5287
|
// src/rules/no-trailing-value-narration.ts
|
|
5130
|
-
var
|
|
5288
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
5131
5289
|
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
5132
5290
|
var WORD_RE3 = /[A-Za-z]+(?:'[a-z]+)?|\d+(?:\.\d+)?/g;
|
|
5133
5291
|
var UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -5189,21 +5347,22 @@ var STOPWORDS3 = /* @__PURE__ */ new Set([
|
|
|
5189
5347
|
"we",
|
|
5190
5348
|
"with"
|
|
5191
5349
|
]);
|
|
5192
|
-
var
|
|
5350
|
+
var DIRECTIVE_RE5 = /^\s*(?:eslint\b|eslint-|sarj-noqa\b|@ts-|prettier|biome-|c8\b|v8\b|istanbul\b|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
5193
5351
|
function numbersIn(text) {
|
|
5194
5352
|
return new Set(text.match(NUMBER_RE) ?? []);
|
|
5195
5353
|
}
|
|
5196
|
-
function narratesValue(
|
|
5197
|
-
if (
|
|
5354
|
+
function narratesValue(body2, code) {
|
|
5355
|
+
if (body2.length === 0 || DIRECTIVE_RE5.test(body2) || hasExternalReference(body2)) return false;
|
|
5198
5356
|
const codeNumbers = numbersIn(code);
|
|
5199
5357
|
if (codeNumbers.size === 0) return false;
|
|
5200
|
-
const words = (
|
|
5358
|
+
const words = (body2.match(WORD_RE3) ?? []).map((word) => word.toLowerCase());
|
|
5201
5359
|
if (words.length === 0) return false;
|
|
5202
|
-
const commentNumbers = numbersIn(
|
|
5360
|
+
const commentNumbers = numbersIn(body2);
|
|
5203
5361
|
if (commentNumbers.size === 0) return false;
|
|
5204
5362
|
for (const number of commentNumbers) {
|
|
5205
5363
|
if (!codeNumbers.has(number)) return false;
|
|
5206
5364
|
}
|
|
5365
|
+
if (!words.some((word) => UNIT_WORDS.has(word))) return false;
|
|
5207
5366
|
const identifiers = codeTokens(code);
|
|
5208
5367
|
const stems = /* @__PURE__ */ new Set();
|
|
5209
5368
|
for (const token of identifiers) stems.add(stem(token));
|
|
@@ -5216,7 +5375,7 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5216
5375
|
meta: {
|
|
5217
5376
|
type: "suggestion",
|
|
5218
5377
|
docs: {
|
|
5219
|
-
description: "Flag a trailing comment
|
|
5378
|
+
description: "Flag a trailing comment that repeats the line's numeric value only to name its unit."
|
|
5220
5379
|
},
|
|
5221
5380
|
schema: [],
|
|
5222
5381
|
messages: {
|
|
@@ -5233,14 +5392,25 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5233
5392
|
const before = sourceCode.getTokenBefore(comment, { includeComments: false });
|
|
5234
5393
|
return before !== null && before.loc.end.line === comment.loc.start.line;
|
|
5235
5394
|
}
|
|
5395
|
+
function isInsideBrackets(comment) {
|
|
5396
|
+
let node = sourceCode.getNodeByRangeIndex(comment.range[0]);
|
|
5397
|
+
while (node != null) {
|
|
5398
|
+
if (node.type === "BlockStatement" || node.type === "Program") return false;
|
|
5399
|
+
if (node.type === "ArrayExpression" || node.type === "CallExpression" || node.type === "NewExpression") {
|
|
5400
|
+
return true;
|
|
5401
|
+
}
|
|
5402
|
+
node = node.parent;
|
|
5403
|
+
}
|
|
5404
|
+
return false;
|
|
5405
|
+
}
|
|
5236
5406
|
return {
|
|
5237
5407
|
Program() {
|
|
5238
5408
|
for (const comment of sourceCode.getAllComments()) {
|
|
5239
|
-
if (!isTrailing(comment)) continue;
|
|
5409
|
+
if (!isTrailing(comment) || isInsideBrackets(comment)) continue;
|
|
5240
5410
|
const line = sourceCode.lines[comment.loc.start.line - 1] ?? "";
|
|
5241
5411
|
const code = line.slice(0, comment.loc.start.column);
|
|
5242
|
-
const
|
|
5243
|
-
if (narratesValue(
|
|
5412
|
+
const body2 = comment.value.replace(/^\*+/, "").replace(/\*+$/, "").trim();
|
|
5413
|
+
if (narratesValue(body2, code)) {
|
|
5244
5414
|
context.report({ node: comment, messageId: "narratesValue" });
|
|
5245
5415
|
}
|
|
5246
5416
|
}
|
|
@@ -5250,10 +5420,10 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5250
5420
|
});
|
|
5251
5421
|
|
|
5252
5422
|
// src/rules/no-declaration-comment-wall.ts
|
|
5253
|
-
var
|
|
5423
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5254
5424
|
|
|
5255
5425
|
// src/rules/_comment-wall.ts
|
|
5256
|
-
var
|
|
5426
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
5257
5427
|
var WALL_DEFAULTS = {
|
|
5258
5428
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5259
5429
|
minCommentedMembers: 3,
|
|
@@ -5295,7 +5465,7 @@ var WALL_SCHEMA = {
|
|
|
5295
5465
|
}
|
|
5296
5466
|
}
|
|
5297
5467
|
};
|
|
5298
|
-
var
|
|
5468
|
+
var VALUE_TAG_RE2 = /@(?:deprecated|see|example|throws|remarks|since|default|defaultvalue|link|internal|alpha|beta|experimental|template|typeparam|inheritdoc|todo|fixme|override)\b/i;
|
|
5299
5469
|
var DEFAULT_RE = /^\s*@?default\b|\bdefaults? (?:to|:)/i;
|
|
5300
5470
|
var DIGIT_RE = /\d/;
|
|
5301
5471
|
var UNIT_WORD_RE = /\b(?:ms|milliseconds?|seconds?|minutes?|hours?|days?|weeks?|months?|years?|bytes?|kb|mb|gb|percent|pixels?|px|utc|epoch)\b/i;
|
|
@@ -5315,24 +5485,24 @@ var WALL_STOPWORDS = new Set(
|
|
|
5315
5485
|
);
|
|
5316
5486
|
var WORD_RE4 = /[A-Za-z][A-Za-z0-9]*/g;
|
|
5317
5487
|
var BARE_LABEL_RE = /^[A-Za-z][A-Za-z0-9]*$/;
|
|
5318
|
-
function labelStems(
|
|
5319
|
-
return splitIdentifier(
|
|
5488
|
+
function labelStems(body2) {
|
|
5489
|
+
return splitIdentifier(body2).map(stem).join(" ");
|
|
5320
5490
|
}
|
|
5321
5491
|
function commentBody(comment) {
|
|
5322
5492
|
return comment.value.replace(/^\*+/, "").replace(/^[ \t]*\*[ \t]?/gm, "").trim();
|
|
5323
5493
|
}
|
|
5324
|
-
function carriesValue(
|
|
5325
|
-
return isProtected(
|
|
5494
|
+
function carriesValue(body2) {
|
|
5495
|
+
return isProtected(body2) || VALUE_TAG_RE2.test(body2) || DEFAULT_RE.test(body2) || DIGIT_RE.test(body2) || UNIT_WORD_RE.test(body2) || EXAMPLE_RE.test(body2) || BANNER_RE.test(body2) || NON_ASCII_LETTER_RE2.test(body2);
|
|
5326
5496
|
}
|
|
5327
|
-
function isLabel(
|
|
5497
|
+
function isLabel(body2) {
|
|
5328
5498
|
let content = 0;
|
|
5329
|
-
for (const word of
|
|
5499
|
+
for (const word of body2.match(WORD_RE4) ?? []) {
|
|
5330
5500
|
if (word.length >= 2 && !WALL_STOPWORDS.has(word.toLowerCase())) content += 1;
|
|
5331
5501
|
}
|
|
5332
5502
|
return content <= 1;
|
|
5333
5503
|
}
|
|
5334
|
-
function isTagsOnly(
|
|
5335
|
-
return
|
|
5504
|
+
function isTagsOnly(body2) {
|
|
5505
|
+
return body2.length > 0 && body2.replace(TAG_TOKEN_RE, "").trim().length === 0;
|
|
5336
5506
|
}
|
|
5337
5507
|
function knownTokens(source) {
|
|
5338
5508
|
const tokens = /* @__PURE__ */ new Set();
|
|
@@ -5344,9 +5514,9 @@ function knownTokens(source) {
|
|
|
5344
5514
|
}
|
|
5345
5515
|
return tokens;
|
|
5346
5516
|
}
|
|
5347
|
-
function novelWords(
|
|
5517
|
+
function novelWords(body2, known) {
|
|
5348
5518
|
let novel = 0;
|
|
5349
|
-
for (const word of
|
|
5519
|
+
for (const word of body2.match(WORD_RE4) ?? []) {
|
|
5350
5520
|
const lower = word.toLowerCase();
|
|
5351
5521
|
if (lower.length < 2 || WALL_STOPWORDS.has(lower)) continue;
|
|
5352
5522
|
if (!known.has(lower) && !known.has(stem(lower))) novel += 1;
|
|
@@ -5357,21 +5527,21 @@ function isWall(members, commented, restated, options) {
|
|
|
5357
5527
|
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5358
5528
|
}
|
|
5359
5529
|
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5530
|
+
import_utils35.AST_NODE_TYPES.FunctionExpression,
|
|
5531
|
+
import_utils35.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
5532
|
+
import_utils35.AST_NODE_TYPES.ObjectExpression,
|
|
5533
|
+
import_utils35.AST_NODE_TYPES.ArrayExpression
|
|
5364
5534
|
]);
|
|
5365
5535
|
function declarationRange(member) {
|
|
5366
|
-
const
|
|
5367
|
-
if (
|
|
5368
|
-
return [member.range[0],
|
|
5536
|
+
const body2 = bodyOf(member);
|
|
5537
|
+
if (body2 === void 0) return [member.range[0], member.range[1]];
|
|
5538
|
+
return [member.range[0], body2.range[0]];
|
|
5369
5539
|
}
|
|
5370
5540
|
function bodyOf(member) {
|
|
5371
|
-
if (member.type ===
|
|
5541
|
+
if (member.type === import_utils35.AST_NODE_TYPES.MethodDefinition || member.type === import_utils35.AST_NODE_TYPES.TSAbstractMethodDefinition) {
|
|
5372
5542
|
return member.value.body ?? void 0;
|
|
5373
5543
|
}
|
|
5374
|
-
if (member.type ===
|
|
5544
|
+
if (member.type === import_utils35.AST_NODE_TYPES.Property || member.type === import_utils35.AST_NODE_TYPES.PropertyDefinition) {
|
|
5375
5545
|
const value = member.value;
|
|
5376
5546
|
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5377
5547
|
}
|
|
@@ -5381,12 +5551,12 @@ function bodyOf(member) {
|
|
|
5381
5551
|
// src/rules/no-declaration-comment-wall.ts
|
|
5382
5552
|
function named(node) {
|
|
5383
5553
|
switch (node.type) {
|
|
5384
|
-
case
|
|
5554
|
+
case import_utils36.AST_NODE_TYPES.TSEnumMember:
|
|
5385
5555
|
return { node, key: node.id };
|
|
5386
|
-
case
|
|
5387
|
-
case
|
|
5388
|
-
case
|
|
5389
|
-
case
|
|
5556
|
+
case import_utils36.AST_NODE_TYPES.PropertyDefinition:
|
|
5557
|
+
case import_utils36.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
|
5558
|
+
case import_utils36.AST_NODE_TYPES.MethodDefinition:
|
|
5559
|
+
case import_utils36.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
|
5390
5560
|
return node.computed ? void 0 : { node, key: node.key };
|
|
5391
5561
|
default:
|
|
5392
5562
|
return void 0;
|
|
@@ -5430,9 +5600,9 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5430
5600
|
}
|
|
5431
5601
|
function isGroupLabel(comment, member, headsRun) {
|
|
5432
5602
|
if (comment.loc.end.line >= member.node.loc.start.line) return false;
|
|
5433
|
-
const
|
|
5434
|
-
if (!BARE_LABEL_RE.test(
|
|
5435
|
-
if (labelStems(
|
|
5603
|
+
const body2 = commentBody(comment);
|
|
5604
|
+
if (!BARE_LABEL_RE.test(body2)) return false;
|
|
5605
|
+
if (labelStems(body2) === labelStems(sourceCode.getText(member.key))) return false;
|
|
5436
5606
|
const lineAbove = sourceCode.lines[comment.loc.start.line - 2];
|
|
5437
5607
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5438
5608
|
}
|
|
@@ -5445,19 +5615,21 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5445
5615
|
}));
|
|
5446
5616
|
let commented = 0;
|
|
5447
5617
|
let restated = 0;
|
|
5618
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
5448
5619
|
for (const [index, { member, comment }] of documented.entries()) {
|
|
5449
|
-
if (comment === void 0) continue;
|
|
5620
|
+
if (comment === void 0 || claimed.has(comment)) continue;
|
|
5450
5621
|
const next = documented[index + 1];
|
|
5451
5622
|
if (isGroupLabel(comment, member, next !== void 0 && next.comment === void 0)) {
|
|
5452
5623
|
continue;
|
|
5453
5624
|
}
|
|
5625
|
+
claimed.add(comment);
|
|
5454
5626
|
commented += 1;
|
|
5455
|
-
const
|
|
5456
|
-
if (
|
|
5627
|
+
const body2 = commentBody(comment);
|
|
5628
|
+
if (body2.length === 0 || carriesValue(body2) || isTagsOnly(body2) || isLabel(body2)) {
|
|
5457
5629
|
continue;
|
|
5458
5630
|
}
|
|
5459
5631
|
const [start, end] = declarationRange(member.node);
|
|
5460
|
-
if (novelWords(
|
|
5632
|
+
if (novelWords(body2, knownTokens(sourceCode.text.slice(start, end))) <= options.maxNovelWords) {
|
|
5461
5633
|
restated += 1;
|
|
5462
5634
|
}
|
|
5463
5635
|
}
|
|
@@ -5484,7 +5656,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
5484
5656
|
});
|
|
5485
5657
|
|
|
5486
5658
|
// src/rules/no-union-in-comment.ts
|
|
5487
|
-
var
|
|
5659
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5488
5660
|
var MAX_LITERAL_LENGTH = 28;
|
|
5489
5661
|
var LITERAL = String.raw`(?:'[^'\n]*'|"[^"\n]*"|\`[^\`\n]*\`)`;
|
|
5490
5662
|
var LEAD_IN_RE2 = /^(?:one of|either|values?|allowed(?: values)?|options?|possible(?: values)?)\s*[:=-]?\s*/i;
|
|
@@ -5503,14 +5675,14 @@ var STRING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
5503
5675
|
function isBareString(node) {
|
|
5504
5676
|
if (node === void 0) return false;
|
|
5505
5677
|
switch (node.type) {
|
|
5506
|
-
case
|
|
5678
|
+
case import_utils37.AST_NODE_TYPES.TSStringKeyword:
|
|
5507
5679
|
return true;
|
|
5508
5680
|
// `string[]` holds members of the same closed set, one element at a time.
|
|
5509
|
-
case
|
|
5681
|
+
case import_utils37.AST_NODE_TYPES.TSArrayType:
|
|
5510
5682
|
return isBareString(node.elementType);
|
|
5511
5683
|
// `string | null` is still an unconstrained string, and so is `string | "a"`
|
|
5512
5684
|
// — the checker collapses that one to `string`.
|
|
5513
|
-
case
|
|
5685
|
+
case import_utils37.AST_NODE_TYPES.TSUnionType:
|
|
5514
5686
|
return node.types.some((member) => isBareString(member));
|
|
5515
5687
|
default:
|
|
5516
5688
|
return false;
|
|
@@ -5520,13 +5692,13 @@ function rootCallee(node) {
|
|
|
5520
5692
|
let current = node;
|
|
5521
5693
|
for (let hops = 0; current != null && hops < 12; hops += 1) {
|
|
5522
5694
|
switch (current.type) {
|
|
5523
|
-
case
|
|
5695
|
+
case import_utils37.AST_NODE_TYPES.CallExpression:
|
|
5524
5696
|
current = current.callee;
|
|
5525
5697
|
break;
|
|
5526
|
-
case
|
|
5698
|
+
case import_utils37.AST_NODE_TYPES.MemberExpression:
|
|
5527
5699
|
current = current.object;
|
|
5528
5700
|
break;
|
|
5529
|
-
case
|
|
5701
|
+
case import_utils37.AST_NODE_TYPES.Identifier:
|
|
5530
5702
|
return current.name;
|
|
5531
5703
|
default:
|
|
5532
5704
|
return null;
|
|
@@ -5535,26 +5707,26 @@ function rootCallee(node) {
|
|
|
5535
5707
|
return null;
|
|
5536
5708
|
}
|
|
5537
5709
|
function nameOf(key) {
|
|
5538
|
-
if (key.type ===
|
|
5539
|
-
if (key.type ===
|
|
5710
|
+
if (key.type === import_utils37.AST_NODE_TYPES.Identifier) return key.name;
|
|
5711
|
+
if (key.type === import_utils37.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
5540
5712
|
return null;
|
|
5541
5713
|
}
|
|
5542
5714
|
function targetOf(node) {
|
|
5543
5715
|
switch (node.type) {
|
|
5544
|
-
case
|
|
5545
|
-
case
|
|
5716
|
+
case import_utils37.AST_NODE_TYPES.TSPropertySignature:
|
|
5717
|
+
case import_utils37.AST_NODE_TYPES.PropertyDefinition: {
|
|
5546
5718
|
const name = node.computed ? null : nameOf(node.key);
|
|
5547
5719
|
if (name === null || !isBareString(node.typeAnnotation?.typeAnnotation)) return null;
|
|
5548
5720
|
return { node, name };
|
|
5549
5721
|
}
|
|
5550
|
-
case
|
|
5722
|
+
case import_utils37.AST_NODE_TYPES.Property: {
|
|
5551
5723
|
const name = node.computed || node.shorthand ? null : nameOf(node.key);
|
|
5552
5724
|
const callee = rootCallee(node.value);
|
|
5553
5725
|
if (name === null || callee === null || !STRING_BUILDERS.has(callee)) return null;
|
|
5554
5726
|
return { node, name };
|
|
5555
5727
|
}
|
|
5556
|
-
case
|
|
5557
|
-
if (node.id.type !==
|
|
5728
|
+
case import_utils37.AST_NODE_TYPES.VariableDeclarator: {
|
|
5729
|
+
if (node.id.type !== import_utils37.AST_NODE_TYPES.Identifier) return null;
|
|
5558
5730
|
if (!isBareString(node.id.typeAnnotation?.typeAnnotation)) return null;
|
|
5559
5731
|
return { node, name: node.id.name };
|
|
5560
5732
|
}
|
|
@@ -5562,8 +5734,8 @@ function targetOf(node) {
|
|
|
5562
5734
|
return null;
|
|
5563
5735
|
}
|
|
5564
5736
|
}
|
|
5565
|
-
function unionLiterals(
|
|
5566
|
-
const list =
|
|
5737
|
+
function unionLiterals(body2) {
|
|
5738
|
+
const list = body2.replace(LEAD_IN_RE2, "").trim();
|
|
5567
5739
|
if (!UNION_BODY_RE.test(list)) return null;
|
|
5568
5740
|
const literals = (list.match(LITERAL_G) ?? []).map((raw) => raw.slice(1, -1));
|
|
5569
5741
|
if (literals.some((literal) => literal.length === 0 || literal.length > MAX_LITERAL_LENGTH)) {
|
|
@@ -5603,7 +5775,7 @@ var no_union_in_comment_default = createRule({
|
|
|
5603
5775
|
if (after === null || after.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
5604
5776
|
anchor = sourceCode.getNodeByRangeIndex(after.range[0]);
|
|
5605
5777
|
}
|
|
5606
|
-
for (let node = anchor; node != null && node.type !==
|
|
5778
|
+
for (let node = anchor; node != null && node.type !== import_utils37.AST_NODE_TYPES.Program; node = node.parent) {
|
|
5607
5779
|
const target = targetOf(node);
|
|
5608
5780
|
if (target !== null) return target;
|
|
5609
5781
|
}
|
|
@@ -5612,9 +5784,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5612
5784
|
return {
|
|
5613
5785
|
Program() {
|
|
5614
5786
|
for (const comment of sourceCode.getAllComments()) {
|
|
5615
|
-
const
|
|
5616
|
-
if (
|
|
5617
|
-
const literals = unionLiterals(
|
|
5787
|
+
const body2 = comment.value.replace(/^\*+/, "").replace(/\*+$/, "").trim();
|
|
5788
|
+
if (body2.length === 0) continue;
|
|
5789
|
+
const literals = unionLiterals(body2);
|
|
5618
5790
|
if (literals === null) continue;
|
|
5619
5791
|
const target = annotated(comment);
|
|
5620
5792
|
if (target === null) continue;
|
|
@@ -5632,9 +5804,9 @@ var no_union_in_comment_default = createRule({
|
|
|
5632
5804
|
});
|
|
5633
5805
|
|
|
5634
5806
|
// src/rules/no-type-member-comment-wall.ts
|
|
5635
|
-
var
|
|
5807
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5636
5808
|
function isNamedMember(node) {
|
|
5637
|
-
return (node.type ===
|
|
5809
|
+
return (node.type === import_utils38.AST_NODE_TYPES.TSPropertySignature || node.type === import_utils38.AST_NODE_TYPES.TSMethodSignature) && !node.computed;
|
|
5638
5810
|
}
|
|
5639
5811
|
var no_type_member_comment_wall_default = createRule({
|
|
5640
5812
|
name: "no-type-member-comment-wall",
|
|
@@ -5674,14 +5846,14 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5674
5846
|
}
|
|
5675
5847
|
function isGroupLabel(comment, member, headsRun) {
|
|
5676
5848
|
if (comment.loc.end.line >= member.loc.start.line) return false;
|
|
5677
|
-
const
|
|
5678
|
-
if (!BARE_LABEL_RE.test(
|
|
5679
|
-
if (labelStems(
|
|
5849
|
+
const body2 = commentBody(comment);
|
|
5850
|
+
if (!BARE_LABEL_RE.test(body2)) return false;
|
|
5851
|
+
if (labelStems(body2) === labelStems(sourceCode.getText(member.key))) return false;
|
|
5680
5852
|
const lineAbove = sourceCode.lines[comment.loc.start.line - 2];
|
|
5681
5853
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5682
5854
|
}
|
|
5683
5855
|
function check(node) {
|
|
5684
|
-
const members = node.type ===
|
|
5856
|
+
const members = node.type === import_utils38.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
|
5685
5857
|
const named2 = members.filter(isNamedMember);
|
|
5686
5858
|
if (named2.length === 0) return;
|
|
5687
5859
|
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
@@ -5696,9 +5868,9 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5696
5868
|
}
|
|
5697
5869
|
claimed.add(comment);
|
|
5698
5870
|
commented += 1;
|
|
5699
|
-
const
|
|
5700
|
-
if (
|
|
5701
|
-
if (novelWords(
|
|
5871
|
+
const body2 = commentBody(comment);
|
|
5872
|
+
if (body2.length === 0 || carriesValue(body2)) continue;
|
|
5873
|
+
if (novelWords(body2, knownTokens(sourceCode.getText(member))) <= options.maxNovelWords) {
|
|
5702
5874
|
restated += 1;
|
|
5703
5875
|
}
|
|
5704
5876
|
}
|
|
@@ -5721,7 +5893,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5721
5893
|
});
|
|
5722
5894
|
|
|
5723
5895
|
// src/rules/no-unnecessary-use-client.ts
|
|
5724
|
-
var
|
|
5896
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
5725
5897
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5726
5898
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5727
5899
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -5747,13 +5919,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
5747
5919
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
5748
5920
|
var jsxRootName = (name) => {
|
|
5749
5921
|
let current = name;
|
|
5750
|
-
while (current.type ===
|
|
5922
|
+
while (current.type === import_utils39.AST_NODE_TYPES.JSXMemberExpression) {
|
|
5751
5923
|
current = current.object;
|
|
5752
5924
|
}
|
|
5753
|
-
return current.type ===
|
|
5925
|
+
return current.type === import_utils39.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
5754
5926
|
};
|
|
5755
5927
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
5756
|
-
if (node.type ===
|
|
5928
|
+
if (node.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
5757
5929
|
return imported.has(node.name);
|
|
5758
5930
|
}
|
|
5759
5931
|
for (const key of Object.keys(node)) {
|
|
@@ -5768,16 +5940,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
5768
5940
|
return false;
|
|
5769
5941
|
};
|
|
5770
5942
|
var isUseClientDirective = (node) => {
|
|
5771
|
-
return node.type ===
|
|
5943
|
+
return node.type === import_utils39.AST_NODE_TYPES.ExpressionStatement && node.expression.type === import_utils39.AST_NODE_TYPES.Literal && node.expression.value === "use client";
|
|
5772
5944
|
};
|
|
5773
5945
|
var isGlobalReference = (node, context) => {
|
|
5774
5946
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
5775
5947
|
const parent = node.parent;
|
|
5776
5948
|
if (parent !== void 0) {
|
|
5777
|
-
if (parent.type ===
|
|
5949
|
+
if (parent.type === import_utils39.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
5778
5950
|
return false;
|
|
5779
5951
|
}
|
|
5780
|
-
if (parent.type ===
|
|
5952
|
+
if (parent.type === import_utils39.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
5781
5953
|
return false;
|
|
5782
5954
|
}
|
|
5783
5955
|
if (parent.type.startsWith("TS")) {
|
|
@@ -5817,13 +5989,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5817
5989
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
5818
5990
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
5819
5991
|
const markIfHookOrContext = (callee) => {
|
|
5820
|
-
if (callee.type ===
|
|
5992
|
+
if (callee.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
5821
5993
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
5822
5994
|
hasClientIndicator = true;
|
|
5823
5995
|
}
|
|
5824
5996
|
return;
|
|
5825
5997
|
}
|
|
5826
|
-
if (callee.type ===
|
|
5998
|
+
if (callee.type === import_utils39.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
5827
5999
|
const name = callee.property.name;
|
|
5828
6000
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
5829
6001
|
hasClientIndicator = true;
|
|
@@ -5833,7 +6005,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5833
6005
|
return {
|
|
5834
6006
|
Program(node) {
|
|
5835
6007
|
for (const stmt of node.body) {
|
|
5836
|
-
if (stmt.type !==
|
|
6008
|
+
if (stmt.type !== import_utils39.AST_NODE_TYPES.ExpressionStatement) break;
|
|
5837
6009
|
if (isUseClientDirective(stmt)) {
|
|
5838
6010
|
directiveNode = stmt;
|
|
5839
6011
|
break;
|
|
@@ -5846,7 +6018,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5846
6018
|
},
|
|
5847
6019
|
JSXAttribute(node) {
|
|
5848
6020
|
if (directiveNode === null) return;
|
|
5849
|
-
if (node.name.type ===
|
|
6021
|
+
if (node.name.type === import_utils39.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
5850
6022
|
hasClientIndicator = true;
|
|
5851
6023
|
}
|
|
5852
6024
|
},
|
|
@@ -5913,18 +6085,18 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5913
6085
|
});
|
|
5914
6086
|
|
|
5915
6087
|
// src/rules/no-unsafe-mock-casting.ts
|
|
5916
|
-
var import_utils39 = require("@typescript-eslint/utils");
|
|
5917
6088
|
var import_utils40 = require("@typescript-eslint/utils");
|
|
6089
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
5918
6090
|
function isMockTypeReference(node) {
|
|
5919
|
-
if (node.type !==
|
|
6091
|
+
if (node.type !== import_utils41.AST_NODE_TYPES.TSTypeReference) {
|
|
5920
6092
|
return false;
|
|
5921
6093
|
}
|
|
5922
6094
|
const typeName = node.typeName;
|
|
5923
|
-
if (typeName.type ===
|
|
6095
|
+
if (typeName.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5924
6096
|
const name = typeName.name;
|
|
5925
6097
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
5926
6098
|
}
|
|
5927
|
-
if (typeName.type ===
|
|
6099
|
+
if (typeName.type === import_utils41.AST_NODE_TYPES.TSQualifiedName) {
|
|
5928
6100
|
const rightName = typeName.right.name;
|
|
5929
6101
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
5930
6102
|
}
|
|
@@ -5960,7 +6132,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
5960
6132
|
});
|
|
5961
6133
|
|
|
5962
6134
|
// src/rules/no-zod-native-enum.ts
|
|
5963
|
-
var
|
|
6135
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
5964
6136
|
var ts = __toESM(require("typescript"), 1);
|
|
5965
6137
|
var IGNORE_PATTERNS = [
|
|
5966
6138
|
/[\\/]generated[\\/]/,
|
|
@@ -5978,7 +6150,7 @@ function isZodModule(source) {
|
|
|
5978
6150
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
5979
6151
|
}
|
|
5980
6152
|
function unwrap2(node) {
|
|
5981
|
-
if (node.type ===
|
|
6153
|
+
if (node.type === import_utils42.AST_NODE_TYPES.TSAsExpression || node.type === import_utils42.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
5982
6154
|
return unwrap2(node.expression);
|
|
5983
6155
|
}
|
|
5984
6156
|
return node;
|
|
@@ -5986,14 +6158,14 @@ function unwrap2(node) {
|
|
|
5986
6158
|
function stringValueTexts(node, sourceCode) {
|
|
5987
6159
|
const texts = [];
|
|
5988
6160
|
for (const prop of node.properties) {
|
|
5989
|
-
if (prop.type !==
|
|
6161
|
+
if (prop.type !== import_utils42.AST_NODE_TYPES.Property) {
|
|
5990
6162
|
return null;
|
|
5991
6163
|
}
|
|
5992
6164
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
5993
6165
|
return null;
|
|
5994
6166
|
}
|
|
5995
6167
|
const value = prop.value;
|
|
5996
|
-
if (value.type !==
|
|
6168
|
+
if (value.type !== import_utils42.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
5997
6169
|
return null;
|
|
5998
6170
|
}
|
|
5999
6171
|
const text = sourceCode.getText(value);
|
|
@@ -6009,7 +6181,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6009
6181
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6010
6182
|
if (variable !== void 0) {
|
|
6011
6183
|
return variable.defs.some(
|
|
6012
|
-
(def) => def.node.type ===
|
|
6184
|
+
(def) => def.node.type === import_utils42.AST_NODE_TYPES.TSEnumDeclaration
|
|
6013
6185
|
);
|
|
6014
6186
|
}
|
|
6015
6187
|
current = current.upper;
|
|
@@ -6054,32 +6226,32 @@ var no_zod_native_enum_default = createRule({
|
|
|
6054
6226
|
}
|
|
6055
6227
|
let services;
|
|
6056
6228
|
try {
|
|
6057
|
-
services =
|
|
6229
|
+
services = import_utils42.ESLintUtils.getParserServices(context);
|
|
6058
6230
|
} catch {
|
|
6059
6231
|
services = null;
|
|
6060
6232
|
}
|
|
6061
6233
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6062
6234
|
function isZodMemberCall(node, api) {
|
|
6063
6235
|
const callee = node.callee;
|
|
6064
|
-
if (callee.type ===
|
|
6236
|
+
if (callee.type === import_utils42.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
6065
6237
|
return callee.property.name === api;
|
|
6066
6238
|
}
|
|
6067
|
-
if (callee.type ===
|
|
6239
|
+
if (callee.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
6068
6240
|
return zodImportedNames.get(callee.name) === api;
|
|
6069
6241
|
}
|
|
6070
6242
|
return false;
|
|
6071
6243
|
}
|
|
6072
6244
|
function buildFix(node) {
|
|
6073
6245
|
const callee = node.callee;
|
|
6074
|
-
if (callee.type !==
|
|
6246
|
+
if (callee.type !== import_utils42.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils42.AST_NODE_TYPES.Identifier) {
|
|
6075
6247
|
return null;
|
|
6076
6248
|
}
|
|
6077
6249
|
const arg = node.arguments[0];
|
|
6078
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6250
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === import_utils42.AST_NODE_TYPES.SpreadElement) {
|
|
6079
6251
|
return null;
|
|
6080
6252
|
}
|
|
6081
6253
|
const inner = unwrap2(arg);
|
|
6082
|
-
if (inner.type !==
|
|
6254
|
+
if (inner.type !== import_utils42.AST_NODE_TYPES.ObjectExpression) {
|
|
6083
6255
|
return null;
|
|
6084
6256
|
}
|
|
6085
6257
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6099,7 +6271,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6099
6271
|
return;
|
|
6100
6272
|
}
|
|
6101
6273
|
for (const spec of node.specifiers) {
|
|
6102
|
-
if (spec.type ===
|
|
6274
|
+
if (spec.type === import_utils42.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
6103
6275
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6104
6276
|
}
|
|
6105
6277
|
}
|
|
@@ -6118,7 +6290,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6118
6290
|
return;
|
|
6119
6291
|
}
|
|
6120
6292
|
const arg = node.arguments[0];
|
|
6121
|
-
if (arg === void 0 || arg.type !==
|
|
6293
|
+
if (arg === void 0 || arg.type !== import_utils42.AST_NODE_TYPES.Identifier) {
|
|
6122
6294
|
return;
|
|
6123
6295
|
}
|
|
6124
6296
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6135,7 +6307,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
6135
6307
|
});
|
|
6136
6308
|
|
|
6137
6309
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6138
|
-
var
|
|
6310
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
6139
6311
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6140
6312
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6141
6313
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6148,36 +6320,36 @@ function isConstantReference(identifier) {
|
|
|
6148
6320
|
}
|
|
6149
6321
|
function isExcludedOperand(node) {
|
|
6150
6322
|
switch (node.type) {
|
|
6151
|
-
case
|
|
6323
|
+
case import_utils43.AST_NODE_TYPES.Literal:
|
|
6152
6324
|
return true;
|
|
6153
|
-
case
|
|
6325
|
+
case import_utils43.AST_NODE_TYPES.TemplateLiteral:
|
|
6154
6326
|
return node.expressions.length === 0;
|
|
6155
|
-
case
|
|
6327
|
+
case import_utils43.AST_NODE_TYPES.Identifier:
|
|
6156
6328
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6157
|
-
case
|
|
6158
|
-
return !node.computed && node.property.type ===
|
|
6329
|
+
case import_utils43.AST_NODE_TYPES.MemberExpression:
|
|
6330
|
+
return !node.computed && node.property.type === import_utils43.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6159
6331
|
default:
|
|
6160
6332
|
return false;
|
|
6161
6333
|
}
|
|
6162
6334
|
}
|
|
6163
6335
|
function operandName(node) {
|
|
6164
|
-
if (node.type ===
|
|
6336
|
+
if (node.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6165
6337
|
return node.name;
|
|
6166
6338
|
}
|
|
6167
|
-
if (node.type ===
|
|
6339
|
+
if (node.type === import_utils43.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6168
6340
|
return node.property.name;
|
|
6169
6341
|
}
|
|
6170
6342
|
return null;
|
|
6171
6343
|
}
|
|
6172
6344
|
function isSecretOperand(node) {
|
|
6173
|
-
if (node.type ===
|
|
6345
|
+
if (node.type === import_utils43.AST_NODE_TYPES.TemplateLiteral) {
|
|
6174
6346
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6175
6347
|
}
|
|
6176
6348
|
const name = operandName(node);
|
|
6177
6349
|
return name !== null && isAuthSecretName(name);
|
|
6178
6350
|
}
|
|
6179
6351
|
function secretNameOf(node) {
|
|
6180
|
-
if (node.type ===
|
|
6352
|
+
if (node.type === import_utils43.AST_NODE_TYPES.TemplateLiteral) {
|
|
6181
6353
|
for (const expression of node.expressions) {
|
|
6182
6354
|
const nested = secretNameOf(expression);
|
|
6183
6355
|
if (nested !== null) {
|
|
@@ -6229,8 +6401,8 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
6229
6401
|
});
|
|
6230
6402
|
|
|
6231
6403
|
// src/rules/prefer-discriminated-union.ts
|
|
6232
|
-
var import_utils43 = require("@typescript-eslint/utils");
|
|
6233
6404
|
var import_utils44 = require("@typescript-eslint/utils");
|
|
6405
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
6234
6406
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
6235
6407
|
"success",
|
|
6236
6408
|
"ok",
|
|
@@ -6240,27 +6412,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6240
6412
|
]);
|
|
6241
6413
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
6242
6414
|
function getMemberName(member) {
|
|
6243
|
-
if (member.type !==
|
|
6415
|
+
if (member.type !== import_utils45.AST_NODE_TYPES.TSPropertySignature) {
|
|
6244
6416
|
return null;
|
|
6245
6417
|
}
|
|
6246
6418
|
const { key } = member;
|
|
6247
|
-
if (key.type ===
|
|
6419
|
+
if (key.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6248
6420
|
return key.name;
|
|
6249
6421
|
}
|
|
6250
|
-
if (key.type ===
|
|
6422
|
+
if (key.type === import_utils45.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
6251
6423
|
return key.value;
|
|
6252
6424
|
}
|
|
6253
6425
|
return null;
|
|
6254
6426
|
}
|
|
6255
6427
|
function isBooleanTyped(member) {
|
|
6256
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
6428
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils45.AST_NODE_TYPES.TSBooleanKeyword;
|
|
6257
6429
|
}
|
|
6258
6430
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
6259
6431
|
let hasStatusBoolean = false;
|
|
6260
6432
|
let optionalCount = 0;
|
|
6261
6433
|
let optionalPayloadCount = 0;
|
|
6262
6434
|
for (const member of typeLiteral.members) {
|
|
6263
|
-
if (member.type !==
|
|
6435
|
+
if (member.type !== import_utils45.AST_NODE_TYPES.TSPropertySignature) {
|
|
6264
6436
|
continue;
|
|
6265
6437
|
}
|
|
6266
6438
|
if (member.optional) {
|
|
@@ -6281,7 +6453,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6281
6453
|
meta: {
|
|
6282
6454
|
type: "suggestion",
|
|
6283
6455
|
docs: {
|
|
6284
|
-
description: "Flag object types with a boolean status
|
|
6456
|
+
description: "Flag object types with a boolean status member and at least two optional members, including a non-boolean payload."
|
|
6285
6457
|
},
|
|
6286
6458
|
schema: [],
|
|
6287
6459
|
messages: {
|
|
@@ -6302,7 +6474,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6302
6474
|
TSInterfaceDeclaration(node) {
|
|
6303
6475
|
const synthetic = {
|
|
6304
6476
|
...node.body,
|
|
6305
|
-
type:
|
|
6477
|
+
type: import_utils45.AST_NODE_TYPES.TSTypeLiteral,
|
|
6306
6478
|
members: node.body.body
|
|
6307
6479
|
};
|
|
6308
6480
|
checkTypeLiteral(synthetic, node);
|
|
@@ -6315,7 +6487,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
6315
6487
|
});
|
|
6316
6488
|
|
|
6317
6489
|
// src/rules/prefer-module-level-constant.ts
|
|
6318
|
-
var
|
|
6490
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
6319
6491
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6320
6492
|
var MAX_LITERAL_DEPTH = 4;
|
|
6321
6493
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6344,9 +6516,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6344
6516
|
"assign"
|
|
6345
6517
|
]);
|
|
6346
6518
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6519
|
+
import_utils46.AST_NODE_TYPES.FunctionDeclaration,
|
|
6520
|
+
import_utils46.AST_NODE_TYPES.FunctionExpression,
|
|
6521
|
+
import_utils46.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6350
6522
|
]);
|
|
6351
6523
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6352
6524
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6359,14 +6531,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6359
6531
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6360
6532
|
}
|
|
6361
6533
|
function unwrap3(node) {
|
|
6362
|
-
if (node.type ===
|
|
6534
|
+
if (node.type === import_utils46.AST_NODE_TYPES.TSAsExpression || node.type === import_utils46.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils46.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6363
6535
|
return unwrap3(node.expression);
|
|
6364
6536
|
}
|
|
6365
6537
|
return node;
|
|
6366
6538
|
}
|
|
6367
6539
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6368
6540
|
function isRegexLiteral(node) {
|
|
6369
|
-
return node.type ===
|
|
6541
|
+
return node.type === import_utils46.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6370
6542
|
}
|
|
6371
6543
|
function isLiteralOnly(node, depth) {
|
|
6372
6544
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6374,29 +6546,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6374
6546
|
}
|
|
6375
6547
|
const inner = unwrap3(node);
|
|
6376
6548
|
switch (inner.type) {
|
|
6377
|
-
case
|
|
6549
|
+
case import_utils46.AST_NODE_TYPES.Literal: {
|
|
6378
6550
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6379
6551
|
}
|
|
6380
|
-
case
|
|
6552
|
+
case import_utils46.AST_NODE_TYPES.TemplateLiteral: {
|
|
6381
6553
|
return inner.expressions.length === 0;
|
|
6382
6554
|
}
|
|
6383
|
-
case
|
|
6384
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6555
|
+
case import_utils46.AST_NODE_TYPES.UnaryExpression: {
|
|
6556
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils46.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6385
6557
|
}
|
|
6386
|
-
case
|
|
6558
|
+
case import_utils46.AST_NODE_TYPES.ArrayExpression: {
|
|
6387
6559
|
return inner.elements.every(
|
|
6388
|
-
(el) => el !== null && el.type !==
|
|
6560
|
+
(el) => el !== null && el.type !== import_utils46.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6389
6561
|
);
|
|
6390
6562
|
}
|
|
6391
|
-
case
|
|
6563
|
+
case import_utils46.AST_NODE_TYPES.ObjectExpression: {
|
|
6392
6564
|
return inner.properties.every((prop) => {
|
|
6393
|
-
if (prop.type !==
|
|
6565
|
+
if (prop.type !== import_utils46.AST_NODE_TYPES.Property) {
|
|
6394
6566
|
return false;
|
|
6395
6567
|
}
|
|
6396
6568
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6397
6569
|
return false;
|
|
6398
6570
|
}
|
|
6399
|
-
if (prop.computed && prop.key.type !==
|
|
6571
|
+
if (prop.computed && prop.key.type !== import_utils46.AST_NODE_TYPES.Literal) {
|
|
6400
6572
|
return false;
|
|
6401
6573
|
}
|
|
6402
6574
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6409,7 +6581,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6409
6581
|
}
|
|
6410
6582
|
function unwrapObjectFreeze(node) {
|
|
6411
6583
|
const inner = unwrap3(node);
|
|
6412
|
-
if (inner.type ===
|
|
6584
|
+
if (inner.type === import_utils46.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils46.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils46.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils46.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6413
6585
|
return unwrap3(inner.arguments[0]);
|
|
6414
6586
|
}
|
|
6415
6587
|
return inner;
|
|
@@ -6425,19 +6597,19 @@ function classify(init, checkRegex) {
|
|
|
6425
6597
|
}
|
|
6426
6598
|
return { kind: "regex", size: 1 };
|
|
6427
6599
|
}
|
|
6428
|
-
if (node.type ===
|
|
6600
|
+
if (node.type === import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
6429
6601
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6430
6602
|
}
|
|
6431
|
-
if (node.type ===
|
|
6603
|
+
if (node.type === import_utils46.AST_NODE_TYPES.ObjectExpression) {
|
|
6432
6604
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6433
6605
|
}
|
|
6434
|
-
if (node.type ===
|
|
6606
|
+
if (node.type === import_utils46.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils46.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6435
6607
|
const arg = node.arguments[0];
|
|
6436
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6608
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6437
6609
|
return null;
|
|
6438
6610
|
}
|
|
6439
6611
|
const entries = unwrap3(arg);
|
|
6440
|
-
if (entries.type !==
|
|
6612
|
+
if (entries.type !== import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
6441
6613
|
return null;
|
|
6442
6614
|
}
|
|
6443
6615
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6466,10 +6638,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6466
6638
|
);
|
|
6467
6639
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6468
6640
|
const callee = node.callee;
|
|
6469
|
-
if (callee.type ===
|
|
6641
|
+
if (callee.type === import_utils46.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6470
6642
|
return true;
|
|
6471
6643
|
}
|
|
6472
|
-
if (callee.type !==
|
|
6644
|
+
if (callee.type !== import_utils46.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils46.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6473
6645
|
return false;
|
|
6474
6646
|
}
|
|
6475
6647
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6483,38 +6655,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6483
6655
|
}
|
|
6484
6656
|
function isSafeRead(identifier) {
|
|
6485
6657
|
const parent = identifier.parent;
|
|
6486
|
-
if (parent.type ===
|
|
6658
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.MemberExpression) {
|
|
6487
6659
|
if (parent.object !== identifier) {
|
|
6488
6660
|
return true;
|
|
6489
6661
|
}
|
|
6490
6662
|
const grandparent = parent.parent;
|
|
6491
|
-
if (grandparent.type ===
|
|
6663
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6492
6664
|
return false;
|
|
6493
6665
|
}
|
|
6494
|
-
if (grandparent.type ===
|
|
6666
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.UpdateExpression) {
|
|
6495
6667
|
return false;
|
|
6496
6668
|
}
|
|
6497
|
-
if (grandparent.type ===
|
|
6669
|
+
if (grandparent.type === import_utils46.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6498
6670
|
return false;
|
|
6499
6671
|
}
|
|
6500
|
-
if (!parent.computed && parent.property.type ===
|
|
6672
|
+
if (!parent.computed && parent.property.type === import_utils46.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils46.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6501
6673
|
return false;
|
|
6502
6674
|
}
|
|
6503
6675
|
return true;
|
|
6504
6676
|
}
|
|
6505
|
-
if (parent.type ===
|
|
6677
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6506
6678
|
return true;
|
|
6507
6679
|
}
|
|
6508
|
-
if (parent.type ===
|
|
6680
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
6509
6681
|
return true;
|
|
6510
6682
|
}
|
|
6511
|
-
if (parent.type ===
|
|
6683
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.BinaryExpression) {
|
|
6512
6684
|
return true;
|
|
6513
6685
|
}
|
|
6514
|
-
if (parent.type ===
|
|
6686
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6515
6687
|
return true;
|
|
6516
6688
|
}
|
|
6517
|
-
if (parent.type ===
|
|
6689
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6518
6690
|
return true;
|
|
6519
6691
|
}
|
|
6520
6692
|
return false;
|
|
@@ -6569,7 +6741,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6569
6741
|
if (reference.isWrite()) {
|
|
6570
6742
|
return false;
|
|
6571
6743
|
}
|
|
6572
|
-
if (reference.identifier.type !==
|
|
6744
|
+
if (reference.identifier.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6573
6745
|
return false;
|
|
6574
6746
|
}
|
|
6575
6747
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6581,10 +6753,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6581
6753
|
return {
|
|
6582
6754
|
VariableDeclarator(node) {
|
|
6583
6755
|
const declaration = node.parent;
|
|
6584
|
-
if (declaration.type !==
|
|
6756
|
+
if (declaration.type !== import_utils46.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6585
6757
|
return;
|
|
6586
6758
|
}
|
|
6587
|
-
if (node.id.type !==
|
|
6759
|
+
if (node.id.type !== import_utils46.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6588
6760
|
return;
|
|
6589
6761
|
}
|
|
6590
6762
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6611,7 +6783,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6611
6783
|
});
|
|
6612
6784
|
|
|
6613
6785
|
// src/rules/prefer-module-level-schema.ts
|
|
6614
|
-
var
|
|
6786
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
6615
6787
|
|
|
6616
6788
|
// src/rules/_zod.ts
|
|
6617
6789
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6677,9 +6849,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
6677
6849
|
"intl"
|
|
6678
6850
|
]);
|
|
6679
6851
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6852
|
+
import_utils47.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
6853
|
+
import_utils47.AST_NODE_TYPES.FunctionDeclaration,
|
|
6854
|
+
import_utils47.AST_NODE_TYPES.FunctionExpression
|
|
6683
6855
|
]);
|
|
6684
6856
|
function schemaExpression(node) {
|
|
6685
6857
|
let current = node;
|
|
@@ -6688,10 +6860,10 @@ function schemaExpression(node) {
|
|
|
6688
6860
|
if (parent === void 0) {
|
|
6689
6861
|
return current;
|
|
6690
6862
|
}
|
|
6691
|
-
if (parent.type ===
|
|
6863
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils47.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6692
6864
|
return current;
|
|
6693
6865
|
}
|
|
6694
|
-
if (parent.type ===
|
|
6866
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils47.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils47.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils47.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
6695
6867
|
current = parent;
|
|
6696
6868
|
continue;
|
|
6697
6869
|
}
|
|
@@ -6742,22 +6914,22 @@ function subtreeSome(root, predicate) {
|
|
|
6742
6914
|
function readsReceiver(node) {
|
|
6743
6915
|
return subtreeSome(
|
|
6744
6916
|
node,
|
|
6745
|
-
(inner) => inner.type ===
|
|
6917
|
+
(inner) => inner.type === import_utils47.AST_NODE_TYPES.ThisExpression || inner.type === import_utils47.AST_NODE_TYPES.Super || inner.type === import_utils47.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
6746
6918
|
);
|
|
6747
6919
|
}
|
|
6748
6920
|
function buildsLocalizedText(node) {
|
|
6749
6921
|
return subtreeSome(node, (inner) => {
|
|
6750
|
-
if (inner.type ===
|
|
6922
|
+
if (inner.type === import_utils47.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
6751
6923
|
return true;
|
|
6752
6924
|
}
|
|
6753
|
-
if (inner.type !==
|
|
6925
|
+
if (inner.type !== import_utils47.AST_NODE_TYPES.CallExpression) {
|
|
6754
6926
|
return false;
|
|
6755
6927
|
}
|
|
6756
6928
|
const { callee } = inner;
|
|
6757
|
-
if (callee.type ===
|
|
6929
|
+
if (callee.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6758
6930
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6759
6931
|
}
|
|
6760
|
-
return callee.type ===
|
|
6932
|
+
return callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils47.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6761
6933
|
});
|
|
6762
6934
|
}
|
|
6763
6935
|
function collectReferences(scope, out) {
|
|
@@ -6814,15 +6986,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6814
6986
|
}
|
|
6815
6987
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
6816
6988
|
function isZodCall(node) {
|
|
6817
|
-
return node.type ===
|
|
6989
|
+
return node.type === import_utils47.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils47.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
6818
6990
|
}
|
|
6819
6991
|
function isCovered(node) {
|
|
6820
6992
|
let current = node.parent ?? void 0;
|
|
6821
6993
|
while (current !== void 0) {
|
|
6822
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
6994
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
6823
6995
|
return true;
|
|
6824
6996
|
}
|
|
6825
|
-
if (current.type ===
|
|
6997
|
+
if (current.type === import_utils47.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils47.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
6826
6998
|
return true;
|
|
6827
6999
|
}
|
|
6828
7000
|
current = current.parent ?? void 0;
|
|
@@ -6837,11 +7009,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6837
7009
|
if (parent === void 0) {
|
|
6838
7010
|
return confirmed;
|
|
6839
7011
|
}
|
|
6840
|
-
if (parent.type ===
|
|
7012
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils47.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils47.AST_NODE_TYPES.ArrayExpression) {
|
|
6841
7013
|
current = parent;
|
|
6842
7014
|
continue;
|
|
6843
7015
|
}
|
|
6844
|
-
if (parent.type ===
|
|
7016
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
6845
7017
|
current = schemaExpression(parent);
|
|
6846
7018
|
confirmed = current;
|
|
6847
7019
|
continue;
|
|
@@ -6851,7 +7023,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6851
7023
|
}
|
|
6852
7024
|
function isSchemaComposition(node) {
|
|
6853
7025
|
const { callee } = node;
|
|
6854
|
-
const isCombinator = callee.type ===
|
|
7026
|
+
const isCombinator = callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
6855
7027
|
return isCombinator || isZodCall(node);
|
|
6856
7028
|
}
|
|
6857
7029
|
function closesOverNothing(node, enclosing) {
|
|
@@ -6885,13 +7057,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6885
7057
|
}
|
|
6886
7058
|
function ownerName(enclosing) {
|
|
6887
7059
|
const parent = enclosing.parent ?? void 0;
|
|
6888
|
-
if (enclosing.type ===
|
|
7060
|
+
if (enclosing.type === import_utils47.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
6889
7061
|
return enclosing.id.name;
|
|
6890
7062
|
}
|
|
6891
|
-
if (parent !== void 0 && parent.type ===
|
|
7063
|
+
if (parent !== void 0 && parent.type === import_utils47.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6892
7064
|
return parent.id.name;
|
|
6893
7065
|
}
|
|
6894
|
-
if (parent !== void 0 && (parent.type ===
|
|
7066
|
+
if (parent !== void 0 && (parent.type === import_utils47.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils47.AST_NODE_TYPES.Property) && parent.key.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6895
7067
|
return parent.key.name;
|
|
6896
7068
|
}
|
|
6897
7069
|
return "this function";
|
|
@@ -6902,7 +7074,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6902
7074
|
return;
|
|
6903
7075
|
}
|
|
6904
7076
|
for (const specifier of node.specifiers) {
|
|
6905
|
-
if (specifier.type ===
|
|
7077
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils47.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils47.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils47.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
6906
7078
|
zodNamespaces.add(specifier.local.name);
|
|
6907
7079
|
}
|
|
6908
7080
|
}
|
|
@@ -6912,7 +7084,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6912
7084
|
return;
|
|
6913
7085
|
}
|
|
6914
7086
|
const callee = node.callee;
|
|
6915
|
-
if (callee.property.type !==
|
|
7087
|
+
if (callee.property.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6916
7088
|
return;
|
|
6917
7089
|
}
|
|
6918
7090
|
const factory = callee.property.name;
|
|
@@ -6927,7 +7099,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6927
7099
|
return;
|
|
6928
7100
|
}
|
|
6929
7101
|
const shape = node.arguments[0];
|
|
6930
|
-
if (shape !== void 0 && shape.type ===
|
|
7102
|
+
if (shape !== void 0 && shape.type === import_utils47.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
6931
7103
|
return;
|
|
6932
7104
|
}
|
|
6933
7105
|
const expression = schemaExpression(node);
|
|
@@ -6955,20 +7127,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6955
7127
|
});
|
|
6956
7128
|
|
|
6957
7129
|
// src/rules/prefer-non-nullable-collection.ts
|
|
6958
|
-
var
|
|
7130
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6959
7131
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
6960
7132
|
function propertyName(node) {
|
|
6961
7133
|
const key = node.key;
|
|
6962
|
-
if (key.type ===
|
|
6963
|
-
if (key.type ===
|
|
7134
|
+
if (key.type === import_utils48.AST_NODE_TYPES.Identifier) return key.name;
|
|
7135
|
+
if (key.type === import_utils48.AST_NODE_TYPES.Literal) return String(key.value);
|
|
6964
7136
|
return "collection";
|
|
6965
7137
|
}
|
|
6966
7138
|
function isArrayType(node) {
|
|
6967
|
-
if (node.type ===
|
|
6968
|
-
return node.type ===
|
|
7139
|
+
if (node.type === import_utils48.AST_NODE_TYPES.TSArrayType) return true;
|
|
7140
|
+
return node.type === import_utils48.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils48.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
6969
7141
|
}
|
|
6970
7142
|
function isNullishType(node) {
|
|
6971
|
-
return node.type ===
|
|
7143
|
+
return node.type === import_utils48.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils48.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
6972
7144
|
}
|
|
6973
7145
|
function isNullableArrayOnly(node) {
|
|
6974
7146
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -6979,7 +7151,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6979
7151
|
meta: {
|
|
6980
7152
|
type: "suggestion",
|
|
6981
7153
|
docs: {
|
|
6982
|
-
description: "Require
|
|
7154
|
+
description: "Require declared data-shape properties and direct aliases to use non-null arrays instead of explicit nullish unions."
|
|
6983
7155
|
},
|
|
6984
7156
|
schema: [],
|
|
6985
7157
|
messages: {
|
|
@@ -6993,9 +7165,10 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6993
7165
|
return {};
|
|
6994
7166
|
}
|
|
6995
7167
|
function checkOptionalProperty(node) {
|
|
7168
|
+
if (node.optional) return;
|
|
6996
7169
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
6997
7170
|
if (annotation === void 0) return;
|
|
6998
|
-
if (annotation.type !==
|
|
7171
|
+
if (annotation.type !== import_utils48.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
6999
7172
|
return;
|
|
7000
7173
|
}
|
|
7001
7174
|
context.report({
|
|
@@ -7008,7 +7181,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7008
7181
|
TSPropertySignature: checkOptionalProperty,
|
|
7009
7182
|
PropertyDefinition: checkOptionalProperty,
|
|
7010
7183
|
TSTypeAliasDeclaration(node) {
|
|
7011
|
-
if (node.typeAnnotation.type !==
|
|
7184
|
+
if (node.typeAnnotation.type !== import_utils48.AST_NODE_TYPES.TSUnionType) return;
|
|
7012
7185
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7013
7186
|
context.report({
|
|
7014
7187
|
node,
|
|
@@ -7021,13 +7194,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7021
7194
|
});
|
|
7022
7195
|
|
|
7023
7196
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7024
|
-
var
|
|
7197
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
7025
7198
|
var unwrap4 = (node) => {
|
|
7026
7199
|
let current = node;
|
|
7027
7200
|
while (current !== null && current !== void 0) {
|
|
7028
|
-
if (current.type ===
|
|
7201
|
+
if (current.type === import_utils49.AST_NODE_TYPES.TSAsExpression || current.type === import_utils49.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
7029
7202
|
current = current.expression;
|
|
7030
|
-
} else if (current.type ===
|
|
7203
|
+
} else if (current.type === import_utils49.AST_NODE_TYPES.ChainExpression) {
|
|
7031
7204
|
current = current.expression;
|
|
7032
7205
|
} else {
|
|
7033
7206
|
break;
|
|
@@ -7042,23 +7215,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7042
7215
|
]);
|
|
7043
7216
|
var isSchemaParseReference = (node) => {
|
|
7044
7217
|
const inner = unwrap4(node);
|
|
7045
|
-
return inner !== null && inner.type ===
|
|
7218
|
+
return inner !== null && inner.type === import_utils49.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils49.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7046
7219
|
};
|
|
7047
7220
|
var isRawPayloadSource = (node) => {
|
|
7048
7221
|
let current = unwrap4(node);
|
|
7049
7222
|
if (current === null) return false;
|
|
7050
|
-
if (current.type ===
|
|
7223
|
+
if (current.type === import_utils49.AST_NODE_TYPES.AwaitExpression) {
|
|
7051
7224
|
current = unwrap4(current.argument);
|
|
7052
7225
|
}
|
|
7053
|
-
if (current === null || current.type !==
|
|
7226
|
+
if (current === null || current.type !== import_utils49.AST_NODE_TYPES.CallExpression) {
|
|
7054
7227
|
return false;
|
|
7055
7228
|
}
|
|
7056
7229
|
const callee = unwrap4(current.callee);
|
|
7057
|
-
if (callee === null || callee.type !==
|
|
7230
|
+
if (callee === null || callee.type !== import_utils49.AST_NODE_TYPES.MemberExpression) {
|
|
7058
7231
|
return false;
|
|
7059
7232
|
}
|
|
7060
7233
|
const property = unwrap4(callee.property);
|
|
7061
|
-
if (property === null || property.type !==
|
|
7234
|
+
if (property === null || property.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7062
7235
|
return false;
|
|
7063
7236
|
}
|
|
7064
7237
|
if (property.name === "json") {
|
|
@@ -7068,17 +7241,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7068
7241
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7069
7242
|
}
|
|
7070
7243
|
const object = unwrap4(callee.object);
|
|
7071
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7072
|
-
!isLocalFileRead(current.arguments[0]);
|
|
7244
|
+
return property.name === "parse" && object !== null && object.type === import_utils49.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7073
7245
|
};
|
|
7074
7246
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7075
7247
|
var isLocalFileRead = (node) => {
|
|
7076
7248
|
let found = false;
|
|
7077
7249
|
const visit = (current) => {
|
|
7078
7250
|
if (found || current === null || current === void 0) return;
|
|
7079
|
-
if (current.type ===
|
|
7251
|
+
if (current.type === import_utils49.AST_NODE_TYPES.CallExpression) {
|
|
7080
7252
|
const callee = unwrap4(current.callee);
|
|
7081
|
-
const name = callee?.type ===
|
|
7253
|
+
const name = callee?.type === import_utils49.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils49.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils49.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
7082
7254
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7083
7255
|
found = true;
|
|
7084
7256
|
return;
|
|
@@ -7100,15 +7272,15 @@ var isLocalFileRead = (node) => {
|
|
|
7100
7272
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7101
7273
|
var isInsideAssertion = (node) => {
|
|
7102
7274
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7103
|
-
if (current.type !==
|
|
7275
|
+
if (current.type !== import_utils49.AST_NODE_TYPES.CallExpression) continue;
|
|
7104
7276
|
let callee = current.callee;
|
|
7105
|
-
while (callee.type ===
|
|
7277
|
+
while (callee.type === import_utils49.AST_NODE_TYPES.MemberExpression) {
|
|
7106
7278
|
callee = callee.object;
|
|
7107
7279
|
}
|
|
7108
|
-
if (callee.type ===
|
|
7280
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.CallExpression) {
|
|
7109
7281
|
callee = callee.callee;
|
|
7110
7282
|
}
|
|
7111
|
-
if (callee.type ===
|
|
7283
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7112
7284
|
return true;
|
|
7113
7285
|
}
|
|
7114
7286
|
}
|
|
@@ -7127,39 +7299,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7127
7299
|
var isValidationRead = (node) => {
|
|
7128
7300
|
let current = node;
|
|
7129
7301
|
let parent = current.parent;
|
|
7130
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7302
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils49.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils49.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils49.AST_NODE_TYPES.ChainExpression)) {
|
|
7131
7303
|
current = parent;
|
|
7132
7304
|
parent = parent.parent;
|
|
7133
7305
|
}
|
|
7134
7306
|
if (parent === null || parent === void 0) return false;
|
|
7135
|
-
if (parent.type ===
|
|
7307
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7136
7308
|
return true;
|
|
7137
7309
|
}
|
|
7138
|
-
if (parent.type !==
|
|
7310
|
+
if (parent.type !== import_utils49.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7139
7311
|
return false;
|
|
7140
7312
|
}
|
|
7141
7313
|
const callee = parent.callee;
|
|
7142
|
-
if (callee.type ===
|
|
7314
|
+
if (callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
7143
7315
|
return parent.arguments.length === 1;
|
|
7144
7316
|
}
|
|
7145
|
-
return callee.type ===
|
|
7317
|
+
return callee.type === import_utils49.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7146
7318
|
};
|
|
7147
7319
|
var isGuardTestPosition = (node) => {
|
|
7148
7320
|
let current = node;
|
|
7149
7321
|
let parent = current.parent;
|
|
7150
7322
|
while (parent !== void 0 && parent !== null) {
|
|
7151
7323
|
switch (parent.type) {
|
|
7152
|
-
case
|
|
7153
|
-
case
|
|
7154
|
-
case
|
|
7324
|
+
case import_utils49.AST_NODE_TYPES.UnaryExpression:
|
|
7325
|
+
case import_utils49.AST_NODE_TYPES.LogicalExpression:
|
|
7326
|
+
case import_utils49.AST_NODE_TYPES.ChainExpression:
|
|
7155
7327
|
current = parent;
|
|
7156
7328
|
parent = parent.parent;
|
|
7157
7329
|
continue;
|
|
7158
|
-
case
|
|
7159
|
-
case
|
|
7160
|
-
case
|
|
7161
|
-
case
|
|
7162
|
-
case
|
|
7330
|
+
case import_utils49.AST_NODE_TYPES.IfStatement:
|
|
7331
|
+
case import_utils49.AST_NODE_TYPES.ConditionalExpression:
|
|
7332
|
+
case import_utils49.AST_NODE_TYPES.WhileStatement:
|
|
7333
|
+
case import_utils49.AST_NODE_TYPES.DoWhileStatement:
|
|
7334
|
+
case import_utils49.AST_NODE_TYPES.ForStatement:
|
|
7163
7335
|
return parent.test === current;
|
|
7164
7336
|
default:
|
|
7165
7337
|
return false;
|
|
@@ -7169,7 +7341,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7169
7341
|
};
|
|
7170
7342
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7171
7343
|
const unwrapped = unwrap4(node);
|
|
7172
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7344
|
+
if (unwrapped === null || unwrapped.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7173
7345
|
return false;
|
|
7174
7346
|
}
|
|
7175
7347
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7212,11 +7384,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7212
7384
|
return {
|
|
7213
7385
|
VariableDeclarator(node) {
|
|
7214
7386
|
const scope = context.sourceCode.getScope(node);
|
|
7215
|
-
if (node.id.type ===
|
|
7387
|
+
if (node.id.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7216
7388
|
trackInitializer(node);
|
|
7217
7389
|
return;
|
|
7218
7390
|
}
|
|
7219
|
-
if (node.id.type ===
|
|
7391
|
+
if (node.id.type === import_utils49.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils49.AST_NODE_TYPES.ArrayPattern) {
|
|
7220
7392
|
if (isRawPayloadSource(node.init)) {
|
|
7221
7393
|
if (!isFullyNarrowedPattern(node)) {
|
|
7222
7394
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7230,7 +7402,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7230
7402
|
},
|
|
7231
7403
|
AssignmentExpression(node) {
|
|
7232
7404
|
const scope = context.sourceCode.getScope(node);
|
|
7233
|
-
if (node.left.type ===
|
|
7405
|
+
if (node.left.type === import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7234
7406
|
const variable = findVariable2(scope, node.left.name);
|
|
7235
7407
|
if (variable === null) return;
|
|
7236
7408
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7240,7 +7412,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7240
7412
|
}
|
|
7241
7413
|
return;
|
|
7242
7414
|
}
|
|
7243
|
-
if (node.left.type ===
|
|
7415
|
+
if (node.left.type === import_utils49.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils49.AST_NODE_TYPES.ArrayPattern) {
|
|
7244
7416
|
if (isRawPayloadSource(node.right)) {
|
|
7245
7417
|
context.report({
|
|
7246
7418
|
node: node.left,
|
|
@@ -7257,15 +7429,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7257
7429
|
}
|
|
7258
7430
|
},
|
|
7259
7431
|
CallExpression(node) {
|
|
7260
|
-
if (node.callee.type !==
|
|
7432
|
+
if (node.callee.type !== import_utils49.AST_NODE_TYPES.Identifier) return;
|
|
7261
7433
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7262
7434
|
return;
|
|
7263
7435
|
}
|
|
7264
7436
|
const scope = context.sourceCode.getScope(node);
|
|
7265
7437
|
for (const arg of node.arguments) {
|
|
7266
|
-
if (arg.type ===
|
|
7438
|
+
if (arg.type === import_utils49.AST_NODE_TYPES.SpreadElement) continue;
|
|
7267
7439
|
const unwrapped = unwrap4(arg);
|
|
7268
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7440
|
+
if (unwrapped === null || unwrapped.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7269
7441
|
continue;
|
|
7270
7442
|
}
|
|
7271
7443
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7279,13 +7451,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7279
7451
|
const obj = unwrap4(node.object);
|
|
7280
7452
|
if (isRawPayloadSource(obj)) {
|
|
7281
7453
|
const parent = node.parent;
|
|
7282
|
-
if (parent.type ===
|
|
7454
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils49.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7283
7455
|
return;
|
|
7284
7456
|
}
|
|
7285
7457
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7286
7458
|
return;
|
|
7287
7459
|
}
|
|
7288
|
-
if (obj !== null && obj.type ===
|
|
7460
|
+
if (obj !== null && obj.type === import_utils49.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7289
7461
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7290
7462
|
const variable = findVariable2(scope, obj.name);
|
|
7291
7463
|
if (variable !== null) {
|
|
@@ -7298,7 +7470,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7298
7470
|
});
|
|
7299
7471
|
|
|
7300
7472
|
// src/rules/prefer-semantic-colors.ts
|
|
7301
|
-
var
|
|
7473
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7302
7474
|
var import_fs = require("fs");
|
|
7303
7475
|
var import_path = require("path");
|
|
7304
7476
|
|
|
@@ -7398,8 +7570,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7398
7570
|
]);
|
|
7399
7571
|
function jsxElementName(node) {
|
|
7400
7572
|
const name = node.openingElement.name;
|
|
7401
|
-
if (name.type ===
|
|
7402
|
-
if (name.type ===
|
|
7573
|
+
if (name.type === import_utils50.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
7574
|
+
if (name.type === import_utils50.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils50.AST_NODE_TYPES.JSXIdentifier) {
|
|
7403
7575
|
return name.property.name;
|
|
7404
7576
|
}
|
|
7405
7577
|
return null;
|
|
@@ -7421,11 +7593,11 @@ var SVG_SHAPE_PRIMITIVES = /* @__PURE__ */ new Set([
|
|
|
7421
7593
|
"tspan",
|
|
7422
7594
|
"use"
|
|
7423
7595
|
]);
|
|
7424
|
-
var
|
|
7596
|
+
var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
7425
7597
|
var isInsideSvg = (node) => {
|
|
7426
7598
|
let current = node.parent;
|
|
7427
7599
|
while (current !== void 0 && current !== null) {
|
|
7428
|
-
if (current.type ===
|
|
7600
|
+
if (current.type === import_utils50.AST_NODE_TYPES.JSXElement) {
|
|
7429
7601
|
const name = jsxElementName(current);
|
|
7430
7602
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7431
7603
|
}
|
|
@@ -7436,7 +7608,7 @@ var isInsideSvg = (node) => {
|
|
|
7436
7608
|
var isInsideIconFactoryPath = (node) => {
|
|
7437
7609
|
let current = node.parent;
|
|
7438
7610
|
while (current !== void 0 && current !== null) {
|
|
7439
|
-
if (current.type ===
|
|
7611
|
+
if (current.type === import_utils50.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils50.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils50.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils50.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7440
7612
|
return true;
|
|
7441
7613
|
}
|
|
7442
7614
|
current = current.parent;
|
|
@@ -7573,10 +7745,16 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
7573
7745
|
return root !== null && workspaceHasMarker(root);
|
|
7574
7746
|
};
|
|
7575
7747
|
var propName = (key) => {
|
|
7576
|
-
if (key.type ===
|
|
7577
|
-
if (key.type ===
|
|
7748
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Identifier) return key.name;
|
|
7749
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
7578
7750
|
return null;
|
|
7579
7751
|
};
|
|
7752
|
+
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
7753
|
+
if (statement.type !== import_utils50.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils50.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils50.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
7754
|
+
return false;
|
|
7755
|
+
}
|
|
7756
|
+
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
7757
|
+
});
|
|
7580
7758
|
var prefer_semantic_colors_default = createRule({
|
|
7581
7759
|
name: "prefer-semantic-colors",
|
|
7582
7760
|
meta: {
|
|
@@ -7602,44 +7780,49 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7602
7780
|
defaultOptions: [{}],
|
|
7603
7781
|
create(context, [options]) {
|
|
7604
7782
|
if (STORIES_FILE_RE.test(context.filename)) return {};
|
|
7605
|
-
if (
|
|
7783
|
+
if (staticallyImportsEmailOrPdfRenderer(context.sourceCode.ast)) return {};
|
|
7606
7784
|
if (options?.requireSemanticTokens === true && !hasSemanticTokenSystem(context.filename)) {
|
|
7607
7785
|
return {};
|
|
7608
7786
|
}
|
|
7787
|
+
let importsEmailOrPdfRenderer = false;
|
|
7788
|
+
const pendingReports = [];
|
|
7789
|
+
const report = (node, messageId, data) => {
|
|
7790
|
+
pendingReports.push({ node, messageId, data });
|
|
7791
|
+
};
|
|
7609
7792
|
const reportClasses = (value, node) => {
|
|
7610
7793
|
for (const token of classTokens(value)) {
|
|
7611
7794
|
const base = tailwindBase(token);
|
|
7612
7795
|
if (RAW_PALETTE_RE.test(base)) {
|
|
7613
|
-
|
|
7796
|
+
report(node, "rawPalette", { class: token });
|
|
7614
7797
|
} else if (ARBITRARY_COLOR_RE.test(base) && !CSS_VAR_REFERENCE_RE.test(base)) {
|
|
7615
|
-
|
|
7798
|
+
report(node, "arbitraryColor", { class: token });
|
|
7616
7799
|
}
|
|
7617
7800
|
}
|
|
7618
7801
|
};
|
|
7619
7802
|
const checkClassNode = (node) => {
|
|
7620
7803
|
if (node === null) return;
|
|
7621
7804
|
switch (node.type) {
|
|
7622
|
-
case
|
|
7805
|
+
case import_utils50.AST_NODE_TYPES.Literal:
|
|
7623
7806
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
7624
7807
|
break;
|
|
7625
|
-
case
|
|
7808
|
+
case import_utils50.AST_NODE_TYPES.TemplateLiteral:
|
|
7626
7809
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
7627
7810
|
break;
|
|
7628
|
-
case
|
|
7811
|
+
case import_utils50.AST_NODE_TYPES.ArrayExpression:
|
|
7629
7812
|
for (const element of node.elements) {
|
|
7630
|
-
if (element !== null && element.type !==
|
|
7813
|
+
if (element !== null && element.type !== import_utils50.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
7631
7814
|
}
|
|
7632
7815
|
break;
|
|
7633
|
-
case
|
|
7816
|
+
case import_utils50.AST_NODE_TYPES.ObjectExpression:
|
|
7634
7817
|
for (const property of node.properties) {
|
|
7635
|
-
if (property.type ===
|
|
7818
|
+
if (property.type === import_utils50.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
7636
7819
|
}
|
|
7637
7820
|
break;
|
|
7638
|
-
case
|
|
7821
|
+
case import_utils50.AST_NODE_TYPES.ConditionalExpression:
|
|
7639
7822
|
checkClassNode(node.consequent);
|
|
7640
7823
|
checkClassNode(node.alternate);
|
|
7641
7824
|
break;
|
|
7642
|
-
case
|
|
7825
|
+
case import_utils50.AST_NODE_TYPES.LogicalExpression:
|
|
7643
7826
|
checkClassNode(node.right);
|
|
7644
7827
|
break;
|
|
7645
7828
|
default:
|
|
@@ -7647,29 +7830,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7647
7830
|
}
|
|
7648
7831
|
};
|
|
7649
7832
|
const checkColorValueNode = (node) => {
|
|
7650
|
-
if (node.type ===
|
|
7651
|
-
|
|
7833
|
+
if (node.type === import_utils50.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
7834
|
+
report(node, "inlineColor", { value: node.value });
|
|
7652
7835
|
}
|
|
7653
7836
|
};
|
|
7654
7837
|
return {
|
|
7655
7838
|
"JSXAttribute[name.name='className']"(node) {
|
|
7656
7839
|
if (node.value === null) return;
|
|
7657
|
-
if (node.value.type ===
|
|
7658
|
-
else if (node.value.type ===
|
|
7659
|
-
if (node.value.expression.type !==
|
|
7840
|
+
if (node.value.type === import_utils50.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
7841
|
+
else if (node.value.type === import_utils50.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
7842
|
+
if (node.value.expression.type !== import_utils50.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
7660
7843
|
checkClassNode(node.value.expression);
|
|
7661
7844
|
}
|
|
7662
7845
|
}
|
|
7663
7846
|
},
|
|
7664
7847
|
CallExpression(node) {
|
|
7665
|
-
if (node.callee.type ===
|
|
7848
|
+
if (node.callee.type === import_utils50.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils50.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
7849
|
+
importsEmailOrPdfRenderer = true;
|
|
7850
|
+
}
|
|
7851
|
+
if (node.callee.type === import_utils50.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
7666
7852
|
for (const arg of node.arguments) {
|
|
7667
|
-
if (arg.type !==
|
|
7853
|
+
if (arg.type !== import_utils50.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
7668
7854
|
}
|
|
7669
7855
|
}
|
|
7670
7856
|
},
|
|
7671
7857
|
VariableDeclarator(node) {
|
|
7672
|
-
if (node.id.type ===
|
|
7858
|
+
if (node.id.type === import_utils50.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
7673
7859
|
checkClassNode(node.init);
|
|
7674
7860
|
}
|
|
7675
7861
|
},
|
|
@@ -7677,13 +7863,11 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7677
7863
|
const name = propName(node.key);
|
|
7678
7864
|
if (name !== null && CLASS_NAME_RE.test(name)) checkClassNode(node.value);
|
|
7679
7865
|
},
|
|
7680
|
-
// SVG
|
|
7681
|
-
// Neutral drawing literals and anything inside an SVG defs container are
|
|
7682
|
-
// structural, not UI tokens, so they never fire.
|
|
7866
|
+
// SVG artwork colors are exempt; component presentation colors still report.
|
|
7683
7867
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
7684
|
-
if (node.value?.type !==
|
|
7868
|
+
if (node.value?.type !== import_utils50.AST_NODE_TYPES.Literal) return;
|
|
7685
7869
|
const owner = node.parent.name;
|
|
7686
|
-
if (owner.type ===
|
|
7870
|
+
if (owner.type === import_utils50.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
7687
7871
|
return;
|
|
7688
7872
|
}
|
|
7689
7873
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -7695,13 +7879,22 @@ var prefer_semantic_colors_default = createRule({
|
|
|
7695
7879
|
"JSXAttribute[name.name='style'] ObjectExpression > Property"(node) {
|
|
7696
7880
|
const name = propName(node.key);
|
|
7697
7881
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
7882
|
+
},
|
|
7883
|
+
ImportExpression(node) {
|
|
7884
|
+
if (node.source.type === import_utils50.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
7885
|
+
importsEmailOrPdfRenderer = true;
|
|
7886
|
+
}
|
|
7887
|
+
},
|
|
7888
|
+
"Program:exit"() {
|
|
7889
|
+
if (importsEmailOrPdfRenderer) return;
|
|
7890
|
+
for (const descriptor of pendingReports) context.report(descriptor);
|
|
7698
7891
|
}
|
|
7699
7892
|
};
|
|
7700
7893
|
}
|
|
7701
7894
|
});
|
|
7702
7895
|
|
|
7703
7896
|
// src/rules/prefer-server-actions.ts
|
|
7704
|
-
var
|
|
7897
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7705
7898
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
7706
7899
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
7707
7900
|
var SKIP_FILE_REGEX = /(?:\.test\.[jt]sx?$|\.spec\.[jt]sx?$|-(?:test|spec)\.[jt]sx?$|\/tests?\/|\/__tests__\/|\/__testfixtures__\/|\/scripts?\/|\/app\/api\/.*\/route\.[jt]sx?$|\/pages\/api\/)/;
|
|
@@ -7762,6 +7955,22 @@ function isMutationMethod(node, context) {
|
|
|
7762
7955
|
}
|
|
7763
7956
|
return false;
|
|
7764
7957
|
}
|
|
7958
|
+
function isFunctionArgument(node, context) {
|
|
7959
|
+
const resolved = resolveNode(node, context);
|
|
7960
|
+
if (resolved?.type === "ArrowFunctionExpression" || resolved?.type === "FunctionExpression") {
|
|
7961
|
+
return true;
|
|
7962
|
+
}
|
|
7963
|
+
if (node.type !== "Identifier") return false;
|
|
7964
|
+
let scope = getScope(context, node);
|
|
7965
|
+
while (scope) {
|
|
7966
|
+
const variable = scope.set.get(node.name);
|
|
7967
|
+
if (variable?.defs.some((definition) => definition.type === "FunctionName")) {
|
|
7968
|
+
return true;
|
|
7969
|
+
}
|
|
7970
|
+
scope = scope.upper;
|
|
7971
|
+
}
|
|
7972
|
+
return false;
|
|
7973
|
+
}
|
|
7765
7974
|
function getPropertyNode(objNode, propName2) {
|
|
7766
7975
|
if (!objNode || objNode.type !== "ObjectExpression") return null;
|
|
7767
7976
|
for (const prop of objNode.properties) {
|
|
@@ -7799,13 +8008,10 @@ var prefer_server_actions_default = createRule({
|
|
|
7799
8008
|
if (SKIP_FILE_REGEX.test(filename)) {
|
|
7800
8009
|
return {};
|
|
7801
8010
|
}
|
|
7802
|
-
|
|
8011
|
+
const isNonReactFramework = context.sourceCode.ast.body.some(
|
|
8012
|
+
(node) => node.type === "ImportDeclaration" && typeof node.source.value === "string" && NON_REACT_FRAMEWORK_RE.test(node.source.value)
|
|
8013
|
+
);
|
|
7803
8014
|
return {
|
|
7804
|
-
ImportDeclaration(node) {
|
|
7805
|
-
if (typeof node.source.value === "string" && NON_REACT_FRAMEWORK_RE.test(node.source.value)) {
|
|
7806
|
-
isNonReactFramework = true;
|
|
7807
|
-
}
|
|
7808
|
-
},
|
|
7809
8015
|
CallExpression(node) {
|
|
7810
8016
|
if (isNonReactFramework) return;
|
|
7811
8017
|
let isMutation = false;
|
|
@@ -7826,7 +8032,7 @@ var prefer_server_actions_default = createRule({
|
|
|
7826
8032
|
if (AXIOS_MUTATION_METHODS.has(methodName)) {
|
|
7827
8033
|
const urlArg = node.arguments[0];
|
|
7828
8034
|
const hasHandlerArg = node.arguments.some(
|
|
7829
|
-
(arg) => arg.type
|
|
8035
|
+
(arg) => arg.type !== "SpreadElement" && isFunctionArgument(arg, context)
|
|
7830
8036
|
);
|
|
7831
8037
|
if (urlArg && urlArg.type !== "SpreadElement" && !hasHandlerArg && isApiUrl(urlArg, context)) {
|
|
7832
8038
|
isMutation = true;
|
|
@@ -7853,8 +8059,33 @@ var prefer_server_actions_default = createRule({
|
|
|
7853
8059
|
}
|
|
7854
8060
|
});
|
|
7855
8061
|
|
|
8062
|
+
// src/rules/prefer-single-sentence-comment.ts
|
|
8063
|
+
var prefer_single_sentence_comment_default = createRule({
|
|
8064
|
+
name: "prefer-single-sentence-comment",
|
|
8065
|
+
meta: {
|
|
8066
|
+
type: "suggestion",
|
|
8067
|
+
docs: { description: "Prefer one sentence and self-documenting code over a two-sentence comment." },
|
|
8068
|
+
schema: [],
|
|
8069
|
+
messages: {
|
|
8070
|
+
preferOneSentence: "Two-sentence comment \u2014 prefer one sentence and self-documenting code."
|
|
8071
|
+
}
|
|
8072
|
+
},
|
|
8073
|
+
defaultOptions: [],
|
|
8074
|
+
create(context) {
|
|
8075
|
+
return {
|
|
8076
|
+
Program() {
|
|
8077
|
+
for (const group of proseGroups(context.filename, context.sourceCode)) {
|
|
8078
|
+
if (!group.hasTypedTags && sentenceUnits(group.text) === 2) {
|
|
8079
|
+
context.report({ node: group.comment, messageId: "preferOneSentence" });
|
|
8080
|
+
}
|
|
8081
|
+
}
|
|
8082
|
+
}
|
|
8083
|
+
};
|
|
8084
|
+
}
|
|
8085
|
+
});
|
|
8086
|
+
|
|
7856
8087
|
// src/rules/prefer-string-literal-union.ts
|
|
7857
|
-
var
|
|
8088
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7858
8089
|
var ts2 = __toESM(require("typescript"), 1);
|
|
7859
8090
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
7860
8091
|
"status",
|
|
@@ -7897,19 +8128,19 @@ function isChoiceLikeName(name) {
|
|
|
7897
8128
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
7898
8129
|
}
|
|
7899
8130
|
function keyName(key) {
|
|
7900
|
-
if (key.type ===
|
|
8131
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7901
8132
|
return key.name;
|
|
7902
8133
|
}
|
|
7903
|
-
if (key.type ===
|
|
8134
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
7904
8135
|
return key.value;
|
|
7905
8136
|
}
|
|
7906
8137
|
return null;
|
|
7907
8138
|
}
|
|
7908
8139
|
function isStringLiteralMember(t) {
|
|
7909
|
-
return t.type ===
|
|
8140
|
+
return t.type === import_utils52.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils52.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
7910
8141
|
}
|
|
7911
8142
|
function isStringLiteralUnion(node) {
|
|
7912
|
-
if (node?.type !==
|
|
8143
|
+
if (node?.type !== import_utils52.AST_NODE_TYPES.TSUnionType) {
|
|
7913
8144
|
return false;
|
|
7914
8145
|
}
|
|
7915
8146
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -7938,12 +8169,12 @@ function bindingSourceExpression(decl) {
|
|
|
7938
8169
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
7939
8170
|
}
|
|
7940
8171
|
function refKey(node) {
|
|
7941
|
-
if (node.type ===
|
|
8172
|
+
if (node.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7942
8173
|
return node.name;
|
|
7943
8174
|
}
|
|
7944
|
-
if (node.type ===
|
|
8175
|
+
if (node.type === import_utils52.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
7945
8176
|
const inner = refKey(node.object);
|
|
7946
|
-
if (inner === null || node.property.type !==
|
|
8177
|
+
if (inner === null || node.property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7947
8178
|
return null;
|
|
7948
8179
|
}
|
|
7949
8180
|
return `${inner}.${node.property.name}`;
|
|
@@ -7951,7 +8182,7 @@ function refKey(node) {
|
|
|
7951
8182
|
return null;
|
|
7952
8183
|
}
|
|
7953
8184
|
function strLiteral(node) {
|
|
7954
|
-
if (node.type ===
|
|
8185
|
+
if (node.type === import_utils52.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
7955
8186
|
return node.value;
|
|
7956
8187
|
}
|
|
7957
8188
|
return null;
|
|
@@ -7992,7 +8223,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7992
8223
|
);
|
|
7993
8224
|
let services;
|
|
7994
8225
|
try {
|
|
7995
|
-
services =
|
|
8226
|
+
services = import_utils52.ESLintUtils.getParserServices(context);
|
|
7996
8227
|
} catch {
|
|
7997
8228
|
services = null;
|
|
7998
8229
|
}
|
|
@@ -8104,7 +8335,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8104
8335
|
containersWithUnion.add(container);
|
|
8105
8336
|
return;
|
|
8106
8337
|
}
|
|
8107
|
-
if (typeNode?.type !==
|
|
8338
|
+
if (typeNode?.type !== import_utils52.AST_NODE_TYPES.TSStringKeyword) {
|
|
8108
8339
|
return;
|
|
8109
8340
|
}
|
|
8110
8341
|
const name = keyName(key);
|
|
@@ -8192,10 +8423,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8192
8423
|
}
|
|
8193
8424
|
};
|
|
8194
8425
|
function refKeyText(node) {
|
|
8195
|
-
if (node.type ===
|
|
8426
|
+
if (node.type === import_utils52.AST_NODE_TYPES.BinaryExpression) {
|
|
8196
8427
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8197
8428
|
}
|
|
8198
|
-
if (node.type ===
|
|
8429
|
+
if (node.type === import_utils52.AST_NODE_TYPES.SwitchStatement) {
|
|
8199
8430
|
return refKey(node.discriminant) ?? "value";
|
|
8200
8431
|
}
|
|
8201
8432
|
return "value";
|
|
@@ -8204,7 +8435,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8204
8435
|
});
|
|
8205
8436
|
|
|
8206
8437
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8207
|
-
var
|
|
8438
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
8208
8439
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8209
8440
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8210
8441
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8213,11 +8444,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8213
8444
|
var MIN_RUN_LENGTH = 2;
|
|
8214
8445
|
function literalText(node, getText) {
|
|
8215
8446
|
switch (node.type) {
|
|
8216
|
-
case
|
|
8447
|
+
case import_utils53.AST_NODE_TYPES.Literal:
|
|
8217
8448
|
return "regex" in node ? null : getText(node);
|
|
8218
|
-
case
|
|
8449
|
+
case import_utils53.AST_NODE_TYPES.TemplateLiteral:
|
|
8219
8450
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8220
|
-
case
|
|
8451
|
+
case import_utils53.AST_NODE_TYPES.UnaryExpression:
|
|
8221
8452
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8222
8453
|
default:
|
|
8223
8454
|
return null;
|
|
@@ -8225,15 +8456,15 @@ function literalText(node, getText) {
|
|
|
8225
8456
|
}
|
|
8226
8457
|
function isPureReceiver(node) {
|
|
8227
8458
|
switch (node.type) {
|
|
8228
|
-
case
|
|
8229
|
-
case
|
|
8459
|
+
case import_utils53.AST_NODE_TYPES.Identifier:
|
|
8460
|
+
case import_utils53.AST_NODE_TYPES.ThisExpression:
|
|
8230
8461
|
return true;
|
|
8231
|
-
case
|
|
8462
|
+
case import_utils53.AST_NODE_TYPES.MemberExpression:
|
|
8232
8463
|
if (node.optional) {
|
|
8233
8464
|
return false;
|
|
8234
8465
|
}
|
|
8235
8466
|
if (node.computed) {
|
|
8236
|
-
return node.property.type ===
|
|
8467
|
+
return node.property.type === import_utils53.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8237
8468
|
}
|
|
8238
8469
|
return isPureReceiver(node.object);
|
|
8239
8470
|
default:
|
|
@@ -8241,7 +8472,7 @@ function isPureReceiver(node) {
|
|
|
8241
8472
|
}
|
|
8242
8473
|
}
|
|
8243
8474
|
function literalIndex(node) {
|
|
8244
|
-
if (node.type !==
|
|
8475
|
+
if (node.type !== import_utils53.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8245
8476
|
return null;
|
|
8246
8477
|
}
|
|
8247
8478
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8267,24 +8498,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8267
8498
|
}
|
|
8268
8499
|
const { sourceCode } = context;
|
|
8269
8500
|
function parseAssertion(statement) {
|
|
8270
|
-
if (statement.type !==
|
|
8501
|
+
if (statement.type !== import_utils53.AST_NODE_TYPES.ExpressionStatement) {
|
|
8271
8502
|
return null;
|
|
8272
8503
|
}
|
|
8273
8504
|
const call = statement.expression;
|
|
8274
|
-
if (call.type !==
|
|
8505
|
+
if (call.type !== import_utils53.AST_NODE_TYPES.CallExpression) {
|
|
8275
8506
|
return null;
|
|
8276
8507
|
}
|
|
8277
8508
|
const callee = call.callee;
|
|
8278
|
-
if (callee.type !==
|
|
8509
|
+
if (callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
8279
8510
|
return null;
|
|
8280
8511
|
}
|
|
8281
8512
|
const matcher = callee.property.name;
|
|
8282
8513
|
const expectCall = callee.object;
|
|
8283
|
-
if (expectCall.type !==
|
|
8514
|
+
if (expectCall.type !== import_utils53.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils53.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8284
8515
|
return null;
|
|
8285
8516
|
}
|
|
8286
8517
|
const actual = expectCall.arguments[0];
|
|
8287
|
-
if (actual === void 0 || actual.type !==
|
|
8518
|
+
if (actual === void 0 || actual.type !== import_utils53.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8288
8519
|
return null;
|
|
8289
8520
|
}
|
|
8290
8521
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8298,7 +8529,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8298
8529
|
}
|
|
8299
8530
|
key = { kind: "index", index };
|
|
8300
8531
|
} else {
|
|
8301
|
-
if (actual.property.type !==
|
|
8532
|
+
if (actual.property.type !== import_utils53.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8302
8533
|
return null;
|
|
8303
8534
|
}
|
|
8304
8535
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8310,7 +8541,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8310
8541
|
return null;
|
|
8311
8542
|
}
|
|
8312
8543
|
const expected = call.arguments[0];
|
|
8313
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
8544
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils53.AST_NODE_TYPES.SpreadElement) {
|
|
8314
8545
|
return null;
|
|
8315
8546
|
}
|
|
8316
8547
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8386,7 +8617,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8386
8617
|
}
|
|
8387
8618
|
});
|
|
8388
8619
|
}
|
|
8389
|
-
function checkBody(
|
|
8620
|
+
function checkBody(body2) {
|
|
8390
8621
|
let run = [];
|
|
8391
8622
|
const flush = () => {
|
|
8392
8623
|
const first = run[0];
|
|
@@ -8399,7 +8630,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8399
8630
|
}
|
|
8400
8631
|
run = [];
|
|
8401
8632
|
};
|
|
8402
|
-
for (const statement of
|
|
8633
|
+
for (const statement of body2) {
|
|
8403
8634
|
const assertion = parseAssertion(statement);
|
|
8404
8635
|
const previous = run.at(-1);
|
|
8405
8636
|
if (assertion !== null && previous !== void 0 && previous.key.kind === assertion.key.kind && sourceCode.getText(previous.receiver) === sourceCode.getText(assertion.receiver)) {
|
|
@@ -8425,7 +8656,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8425
8656
|
});
|
|
8426
8657
|
|
|
8427
8658
|
// src/rules/prefer-zod-enum.ts
|
|
8428
|
-
var
|
|
8659
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
8429
8660
|
var prefer_zod_enum_default = createRule({
|
|
8430
8661
|
name: "prefer-zod-enum",
|
|
8431
8662
|
meta: {
|
|
@@ -8445,33 +8676,39 @@ var prefer_zod_enum_default = createRule({
|
|
|
8445
8676
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8446
8677
|
function enumValues(node) {
|
|
8447
8678
|
const callee = node.callee;
|
|
8448
|
-
if (callee.type !==
|
|
8679
|
+
if (callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils54.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils54.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8449
8680
|
return null;
|
|
8450
8681
|
}
|
|
8451
8682
|
const argument = node.arguments[0];
|
|
8452
|
-
if (argument === void 0 || argument.type !==
|
|
8683
|
+
if (argument === void 0 || argument.type !== import_utils54.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
8453
8684
|
return null;
|
|
8454
8685
|
}
|
|
8455
8686
|
const values = [];
|
|
8687
|
+
let canFix = true;
|
|
8456
8688
|
for (const element of argument.elements) {
|
|
8457
|
-
if (element ===
|
|
8689
|
+
if (element?.type === import_utils54.AST_NODE_TYPES.SpreadElement) {
|
|
8690
|
+
canFix = false;
|
|
8691
|
+
continue;
|
|
8692
|
+
}
|
|
8693
|
+
if (element === null || element.type !== import_utils54.AST_NODE_TYPES.CallExpression || element.callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils54.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils54.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
8458
8694
|
return null;
|
|
8459
8695
|
}
|
|
8460
8696
|
const value = element.arguments[0];
|
|
8461
|
-
if (value === void 0 || value.type !==
|
|
8462
|
-
|
|
8697
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== import_utils54.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
8698
|
+
canFix = false;
|
|
8699
|
+
continue;
|
|
8463
8700
|
}
|
|
8464
8701
|
values.push(value);
|
|
8465
8702
|
}
|
|
8466
|
-
return values;
|
|
8703
|
+
return canFix ? values : void 0;
|
|
8467
8704
|
}
|
|
8468
8705
|
function buildFix(node, values) {
|
|
8469
8706
|
const argument = node.arguments[0];
|
|
8470
|
-
if (argument === void 0 || argument.type !==
|
|
8707
|
+
if (argument === void 0 || argument.type !== import_utils54.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
8471
8708
|
return void 0;
|
|
8472
8709
|
}
|
|
8473
8710
|
const callee = node.callee;
|
|
8474
|
-
if (callee.type !==
|
|
8711
|
+
if (callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8475
8712
|
return void 0;
|
|
8476
8713
|
}
|
|
8477
8714
|
return (fixer) => [
|
|
@@ -8488,7 +8725,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8488
8725
|
return;
|
|
8489
8726
|
}
|
|
8490
8727
|
for (const specifier of node.specifiers) {
|
|
8491
|
-
if (specifier.type ===
|
|
8728
|
+
if (specifier.type === import_utils54.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils54.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils54.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils54.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8492
8729
|
zodNamespaces.add(specifier.local.name);
|
|
8493
8730
|
}
|
|
8494
8731
|
}
|
|
@@ -8498,7 +8735,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8498
8735
|
if (values === null) {
|
|
8499
8736
|
return;
|
|
8500
8737
|
}
|
|
8501
|
-
const fix = buildFix(node, values);
|
|
8738
|
+
const fix = values === void 0 ? void 0 : buildFix(node, values);
|
|
8502
8739
|
context.report({
|
|
8503
8740
|
node,
|
|
8504
8741
|
messageId: "preferEnum",
|
|
@@ -8510,7 +8747,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
8510
8747
|
});
|
|
8511
8748
|
|
|
8512
8749
|
// src/rules/prefer-zod-infer.ts
|
|
8513
|
-
var
|
|
8750
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8514
8751
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
8515
8752
|
"describe",
|
|
8516
8753
|
"refine",
|
|
@@ -8547,44 +8784,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
8547
8784
|
"Schema"
|
|
8548
8785
|
]);
|
|
8549
8786
|
var LEAF_NODE_TYPES = {
|
|
8550
|
-
string: [
|
|
8551
|
-
email: [
|
|
8552
|
-
url: [
|
|
8553
|
-
uuid: [
|
|
8554
|
-
ulid: [
|
|
8555
|
-
cuid: [
|
|
8556
|
-
cuid2: [
|
|
8557
|
-
nanoid: [
|
|
8558
|
-
iso: [
|
|
8559
|
-
number: [
|
|
8560
|
-
int: [
|
|
8561
|
-
float32: [
|
|
8562
|
-
float64: [
|
|
8563
|
-
boolean: [
|
|
8564
|
-
bigint: [
|
|
8565
|
-
symbol: [
|
|
8566
|
-
any: [
|
|
8567
|
-
unknown: [
|
|
8568
|
-
never: [
|
|
8569
|
-
void: [
|
|
8570
|
-
null: [
|
|
8571
|
-
undefined: [
|
|
8572
|
-
literal: [
|
|
8573
|
-
date: [
|
|
8574
|
-
array: [
|
|
8575
|
-
tuple: [
|
|
8576
|
-
object: [
|
|
8577
|
-
strictObject: [
|
|
8578
|
-
looseObject: [
|
|
8579
|
-
record: [
|
|
8580
|
-
map: [
|
|
8581
|
-
set: [
|
|
8582
|
-
promise: [
|
|
8583
|
-
enum: [
|
|
8584
|
-
nativeEnum: [
|
|
8585
|
-
union: [
|
|
8586
|
-
discriminatedUnion: [
|
|
8587
|
-
intersection: [
|
|
8787
|
+
string: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8788
|
+
email: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8789
|
+
url: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8790
|
+
uuid: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8791
|
+
ulid: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8792
|
+
cuid: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8793
|
+
cuid2: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8794
|
+
nanoid: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8795
|
+
iso: [import_utils55.AST_NODE_TYPES.TSStringKeyword],
|
|
8796
|
+
number: [import_utils55.AST_NODE_TYPES.TSNumberKeyword],
|
|
8797
|
+
int: [import_utils55.AST_NODE_TYPES.TSNumberKeyword],
|
|
8798
|
+
float32: [import_utils55.AST_NODE_TYPES.TSNumberKeyword],
|
|
8799
|
+
float64: [import_utils55.AST_NODE_TYPES.TSNumberKeyword],
|
|
8800
|
+
boolean: [import_utils55.AST_NODE_TYPES.TSBooleanKeyword],
|
|
8801
|
+
bigint: [import_utils55.AST_NODE_TYPES.TSBigIntKeyword],
|
|
8802
|
+
symbol: [import_utils55.AST_NODE_TYPES.TSSymbolKeyword],
|
|
8803
|
+
any: [import_utils55.AST_NODE_TYPES.TSAnyKeyword],
|
|
8804
|
+
unknown: [import_utils55.AST_NODE_TYPES.TSUnknownKeyword],
|
|
8805
|
+
never: [import_utils55.AST_NODE_TYPES.TSNeverKeyword],
|
|
8806
|
+
void: [import_utils55.AST_NODE_TYPES.TSVoidKeyword],
|
|
8807
|
+
null: [import_utils55.AST_NODE_TYPES.TSNullKeyword],
|
|
8808
|
+
undefined: [import_utils55.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
8809
|
+
literal: [import_utils55.AST_NODE_TYPES.TSLiteralType],
|
|
8810
|
+
date: [import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8811
|
+
array: [import_utils55.AST_NODE_TYPES.TSArrayType, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8812
|
+
tuple: [import_utils55.AST_NODE_TYPES.TSTupleType],
|
|
8813
|
+
object: [import_utils55.AST_NODE_TYPES.TSTypeLiteral, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8814
|
+
strictObject: [import_utils55.AST_NODE_TYPES.TSTypeLiteral, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8815
|
+
looseObject: [import_utils55.AST_NODE_TYPES.TSTypeLiteral, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8816
|
+
record: [import_utils55.AST_NODE_TYPES.TSTypeReference, import_utils55.AST_NODE_TYPES.TSTypeLiteral],
|
|
8817
|
+
map: [import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8818
|
+
set: [import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8819
|
+
promise: [import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8820
|
+
enum: [import_utils55.AST_NODE_TYPES.TSUnionType, import_utils55.AST_NODE_TYPES.TSTypeReference, import_utils55.AST_NODE_TYPES.TSLiteralType],
|
|
8821
|
+
nativeEnum: [import_utils55.AST_NODE_TYPES.TSUnionType, import_utils55.AST_NODE_TYPES.TSTypeReference, import_utils55.AST_NODE_TYPES.TSLiteralType],
|
|
8822
|
+
union: [import_utils55.AST_NODE_TYPES.TSUnionType, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8823
|
+
discriminatedUnion: [import_utils55.AST_NODE_TYPES.TSUnionType, import_utils55.AST_NODE_TYPES.TSTypeReference],
|
|
8824
|
+
intersection: [import_utils55.AST_NODE_TYPES.TSIntersectionType, import_utils55.AST_NODE_TYPES.TSTypeReference]
|
|
8588
8825
|
};
|
|
8589
8826
|
function normalizeSchemaName(name) {
|
|
8590
8827
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -8593,20 +8830,20 @@ function normalizeTypeName(name) {
|
|
|
8593
8830
|
return name.replace(/Type$/, "").toLowerCase();
|
|
8594
8831
|
}
|
|
8595
8832
|
function unwrapNullish(annotation) {
|
|
8596
|
-
if (annotation.type !==
|
|
8833
|
+
if (annotation.type !== import_utils55.AST_NODE_TYPES.TSUnionType) {
|
|
8597
8834
|
return {
|
|
8598
8835
|
core: annotation,
|
|
8599
|
-
nullable: annotation.type ===
|
|
8836
|
+
nullable: annotation.type === import_utils55.AST_NODE_TYPES.TSNullKeyword
|
|
8600
8837
|
};
|
|
8601
8838
|
}
|
|
8602
8839
|
const rest = [];
|
|
8603
8840
|
let nullable = false;
|
|
8604
8841
|
for (const member of annotation.types) {
|
|
8605
|
-
if (member.type ===
|
|
8842
|
+
if (member.type === import_utils55.AST_NODE_TYPES.TSNullKeyword) {
|
|
8606
8843
|
nullable = true;
|
|
8607
8844
|
continue;
|
|
8608
8845
|
}
|
|
8609
|
-
if (member.type ===
|
|
8846
|
+
if (member.type === import_utils55.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
8610
8847
|
continue;
|
|
8611
8848
|
}
|
|
8612
8849
|
rest.push(member);
|
|
@@ -8671,14 +8908,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8671
8908
|
function zodCallChain(node) {
|
|
8672
8909
|
const chain = [];
|
|
8673
8910
|
let current = node;
|
|
8674
|
-
while (current.type ===
|
|
8911
|
+
while (current.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
8675
8912
|
const callee = current.callee;
|
|
8676
|
-
if (callee.type !==
|
|
8913
|
+
if (callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8677
8914
|
return null;
|
|
8678
8915
|
}
|
|
8679
8916
|
chain.push(current);
|
|
8680
8917
|
const receiver = callee.object;
|
|
8681
|
-
if (receiver.type ===
|
|
8918
|
+
if (receiver.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8682
8919
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
8683
8920
|
}
|
|
8684
8921
|
current = receiver;
|
|
@@ -8687,19 +8924,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
8687
8924
|
}
|
|
8688
8925
|
function methodName(call) {
|
|
8689
8926
|
const callee = call.callee;
|
|
8690
|
-
return callee.type ===
|
|
8927
|
+
return callee.type === import_utils55.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils55.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
8691
8928
|
}
|
|
8692
8929
|
function schemaField(node) {
|
|
8693
8930
|
const modifiers = [];
|
|
8694
8931
|
let current = node;
|
|
8695
8932
|
let leaf = null;
|
|
8696
|
-
while (current.type ===
|
|
8933
|
+
while (current.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
8697
8934
|
const callee = current.callee;
|
|
8698
|
-
if (callee.type !==
|
|
8935
|
+
if (callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8699
8936
|
break;
|
|
8700
8937
|
}
|
|
8701
8938
|
const receiver = callee.object;
|
|
8702
|
-
if (receiver.type ===
|
|
8939
|
+
if (receiver.type === import_utils55.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
8703
8940
|
leaf = callee.property.name;
|
|
8704
8941
|
break;
|
|
8705
8942
|
}
|
|
@@ -8730,16 +8967,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8730
8967
|
return null;
|
|
8731
8968
|
}
|
|
8732
8969
|
const shape = base.arguments[0];
|
|
8733
|
-
if (shape === void 0 || shape.type !==
|
|
8970
|
+
if (shape === void 0 || shape.type !== import_utils55.AST_NODE_TYPES.ObjectExpression) {
|
|
8734
8971
|
return null;
|
|
8735
8972
|
}
|
|
8736
8973
|
const fields = /* @__PURE__ */ new Map();
|
|
8737
8974
|
for (const property of shape.properties) {
|
|
8738
|
-
if (property.type !==
|
|
8975
|
+
if (property.type !== import_utils55.AST_NODE_TYPES.Property || property.computed) {
|
|
8739
8976
|
return null;
|
|
8740
8977
|
}
|
|
8741
8978
|
const { key } = property;
|
|
8742
|
-
const name = key.type ===
|
|
8979
|
+
const name = key.type === import_utils55.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils55.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8743
8980
|
if (name === null) {
|
|
8744
8981
|
return null;
|
|
8745
8982
|
}
|
|
@@ -8750,11 +8987,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8750
8987
|
function typeMembers(members) {
|
|
8751
8988
|
const result = /* @__PURE__ */ new Map();
|
|
8752
8989
|
for (const member of members) {
|
|
8753
|
-
if (member.type !==
|
|
8990
|
+
if (member.type !== import_utils55.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
8754
8991
|
return null;
|
|
8755
8992
|
}
|
|
8756
8993
|
const { key } = member;
|
|
8757
|
-
const name = key.type ===
|
|
8994
|
+
const name = key.type === import_utils55.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils55.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8758
8995
|
if (name === null) {
|
|
8759
8996
|
return null;
|
|
8760
8997
|
}
|
|
@@ -8768,8 +9005,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
8768
9005
|
return result.size === 0 ? null : result;
|
|
8769
9006
|
}
|
|
8770
9007
|
function collectConstrainedNames(node) {
|
|
8771
|
-
if (node.type ===
|
|
8772
|
-
if (node.typeName.type ===
|
|
9008
|
+
if (node.type === import_utils55.AST_NODE_TYPES.TSTypeReference) {
|
|
9009
|
+
if (node.typeName.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8773
9010
|
constrainedTypeNames.add(node.typeName.name);
|
|
8774
9011
|
}
|
|
8775
9012
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -8777,11 +9014,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8777
9014
|
}
|
|
8778
9015
|
return;
|
|
8779
9016
|
}
|
|
8780
|
-
if (node.type ===
|
|
9017
|
+
if (node.type === import_utils55.AST_NODE_TYPES.TSArrayType) {
|
|
8781
9018
|
collectConstrainedNames(node.elementType);
|
|
8782
9019
|
return;
|
|
8783
9020
|
}
|
|
8784
|
-
if (node.type ===
|
|
9021
|
+
if (node.type === import_utils55.AST_NODE_TYPES.TSUnionType || node.type === import_utils55.AST_NODE_TYPES.TSIntersectionType) {
|
|
8785
9022
|
for (const member of node.types) {
|
|
8786
9023
|
collectConstrainedNames(member);
|
|
8787
9024
|
}
|
|
@@ -8825,13 +9062,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
8825
9062
|
return;
|
|
8826
9063
|
}
|
|
8827
9064
|
for (const specifier of node.specifiers) {
|
|
8828
|
-
if (specifier.type ===
|
|
9065
|
+
if (specifier.type === import_utils55.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils55.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils55.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils55.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8829
9066
|
zodNamespaces.add(specifier.local.name);
|
|
8830
9067
|
}
|
|
8831
9068
|
}
|
|
8832
9069
|
},
|
|
8833
9070
|
VariableDeclarator(node) {
|
|
8834
|
-
if (node.id.type !==
|
|
9071
|
+
if (node.id.type !== import_utils55.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
8835
9072
|
return;
|
|
8836
9073
|
}
|
|
8837
9074
|
const fields = schemaFields(node.init);
|
|
@@ -8839,16 +9076,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8839
9076
|
schemas.push({ name: node.id.name, fields });
|
|
8840
9077
|
}
|
|
8841
9078
|
},
|
|
8842
|
-
/**
|
|
9079
|
+
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
8843
9080
|
"MemberExpression[computed=false]"(node) {
|
|
8844
|
-
if (node.object.type ===
|
|
9081
|
+
if (node.object.type === import_utils55.AST_NODE_TYPES.Identifier && node.property.type === import_utils55.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
8845
9082
|
reshapedSchemaNames.add(node.object.name);
|
|
8846
9083
|
}
|
|
8847
9084
|
},
|
|
8848
|
-
/**
|
|
9085
|
+
/** Records every type argument carried by a Zod constraint. */
|
|
8849
9086
|
TSTypeReference(node) {
|
|
8850
9087
|
const { typeName } = node;
|
|
8851
|
-
const referenced = typeName.type ===
|
|
9088
|
+
const referenced = typeName.type === import_utils55.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils55.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils55.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
8852
9089
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
8853
9090
|
return;
|
|
8854
9091
|
}
|
|
@@ -8866,7 +9103,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
8866
9103
|
}
|
|
8867
9104
|
},
|
|
8868
9105
|
TSTypeAliasDeclaration(node) {
|
|
8869
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9106
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils55.AST_NODE_TYPES.TSTypeLiteral) {
|
|
8870
9107
|
return;
|
|
8871
9108
|
}
|
|
8872
9109
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -8911,10 +9148,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
8911
9148
|
});
|
|
8912
9149
|
|
|
8913
9150
|
// src/rules/require-assert-never.ts
|
|
8914
|
-
var
|
|
9151
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8915
9152
|
var isRuntimeHandlingStatement = (statement) => {
|
|
8916
|
-
if (statement.type ===
|
|
8917
|
-
if (statement.type ===
|
|
9153
|
+
if (statement.type === import_utils56.AST_NODE_TYPES.EmptyStatement) return false;
|
|
9154
|
+
if (statement.type === import_utils56.AST_NODE_TYPES.BlockStatement) {
|
|
8918
9155
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
8919
9156
|
}
|
|
8920
9157
|
return true;
|
|
@@ -8930,7 +9167,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
8930
9167
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
8931
9168
|
}
|
|
8932
9169
|
const only = defaultCase.consequent[0];
|
|
8933
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9170
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils56.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
8934
9171
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
8935
9172
|
}
|
|
8936
9173
|
return false;
|
|
@@ -8970,7 +9207,7 @@ var require_assert_never_default = createRule({
|
|
|
8970
9207
|
});
|
|
8971
9208
|
|
|
8972
9209
|
// src/rules/require-fetch-timeout.ts
|
|
8973
|
-
var
|
|
9210
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8974
9211
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
8975
9212
|
"globalThis",
|
|
8976
9213
|
"window",
|
|
@@ -8986,14 +9223,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
8986
9223
|
return false;
|
|
8987
9224
|
}
|
|
8988
9225
|
function initProvablyLacksSignal(init) {
|
|
8989
|
-
if (init.type !==
|
|
9226
|
+
if (init.type !== import_utils57.AST_NODE_TYPES.ObjectExpression) {
|
|
8990
9227
|
return false;
|
|
8991
9228
|
}
|
|
8992
9229
|
for (const prop of init.properties) {
|
|
8993
|
-
if (prop.type ===
|
|
9230
|
+
if (prop.type === import_utils57.AST_NODE_TYPES.SpreadElement) {
|
|
8994
9231
|
return false;
|
|
8995
9232
|
}
|
|
8996
|
-
if (prop.key.type ===
|
|
9233
|
+
if (prop.key.type === import_utils57.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils57.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
8997
9234
|
return false;
|
|
8998
9235
|
}
|
|
8999
9236
|
if (prop.computed) {
|
|
@@ -9003,7 +9240,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9003
9240
|
return true;
|
|
9004
9241
|
}
|
|
9005
9242
|
function isStringish(node) {
|
|
9006
|
-
return node.type ===
|
|
9243
|
+
return node.type === import_utils57.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils57.AST_NODE_TYPES.TemplateLiteral;
|
|
9007
9244
|
}
|
|
9008
9245
|
var require_fetch_timeout_default = createRule({
|
|
9009
9246
|
name: "require-fetch-timeout",
|
|
@@ -9040,14 +9277,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9040
9277
|
}
|
|
9041
9278
|
function resolvesToGlobal(identifier) {
|
|
9042
9279
|
const scope = context.sourceCode.getScope(identifier);
|
|
9043
|
-
const variable =
|
|
9280
|
+
const variable = import_utils57.ASTUtils.findVariable(scope, identifier.name);
|
|
9044
9281
|
return variable === null || variable.defs.length === 0;
|
|
9045
9282
|
}
|
|
9046
9283
|
function isGlobalFetchCall2(callee) {
|
|
9047
|
-
if (callee.type ===
|
|
9284
|
+
if (callee.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
9048
9285
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9049
9286
|
}
|
|
9050
|
-
return callee.type ===
|
|
9287
|
+
return callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils57.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils57.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9051
9288
|
}
|
|
9052
9289
|
return {
|
|
9053
9290
|
CallExpression(node) {
|
|
@@ -9067,7 +9304,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9067
9304
|
});
|
|
9068
9305
|
|
|
9069
9306
|
// src/rules/require-interface-for-injected-service.ts
|
|
9070
|
-
var
|
|
9307
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
9071
9308
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9072
9309
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9073
9310
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9075,20 +9312,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9075
9312
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9076
9313
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9077
9314
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9078
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9079
|
-
var qualifiedName = (name) => name.type ===
|
|
9315
|
+
var isExportedClass = (node) => node.parent.type === import_utils58.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils58.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
9316
|
+
var qualifiedName = (name) => name.type === import_utils58.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils58.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9080
9317
|
var readTypeReference = (annotation) => {
|
|
9081
|
-
if (annotation === void 0 || annotation.type !==
|
|
9318
|
+
if (annotation === void 0 || annotation.type !== import_utils58.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9082
9319
|
const { typeName } = annotation;
|
|
9083
|
-
const rightmost = typeName.type ===
|
|
9320
|
+
const rightmost = typeName.type === import_utils58.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils58.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
9084
9321
|
if (rightmost === null) return null;
|
|
9085
9322
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9086
9323
|
};
|
|
9087
9324
|
var namedParameterCollaborator = (annotated) => {
|
|
9088
9325
|
let target = annotated;
|
|
9089
|
-
if (target.type ===
|
|
9090
|
-
if (target.type ===
|
|
9091
|
-
if (target.type !==
|
|
9326
|
+
if (target.type === import_utils58.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
9327
|
+
if (target.type === import_utils58.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9328
|
+
if (target.type !== import_utils58.AST_NODE_TYPES.Identifier) return null;
|
|
9092
9329
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9093
9330
|
if (reference === null) return null;
|
|
9094
9331
|
return { name: target.name, ...reference };
|
|
@@ -9096,8 +9333,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9096
9333
|
var propertySignatureTypes = (members) => {
|
|
9097
9334
|
const types = /* @__PURE__ */ new Map();
|
|
9098
9335
|
for (const member of members) {
|
|
9099
|
-
if (member.type !==
|
|
9100
|
-
if (member.computed || member.key.type !==
|
|
9336
|
+
if (member.type !== import_utils58.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
9337
|
+
if (member.computed || member.key.type !== import_utils58.AST_NODE_TYPES.Identifier) continue;
|
|
9101
9338
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9102
9339
|
if (reference === null) continue;
|
|
9103
9340
|
types.set(member.key.name, reference);
|
|
@@ -9108,18 +9345,18 @@ var fileTypeIndex = (program) => {
|
|
|
9108
9345
|
const objects = /* @__PURE__ */ new Map();
|
|
9109
9346
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9110
9347
|
for (const statement of program.body) {
|
|
9111
|
-
const declaration = statement.type ===
|
|
9112
|
-
if (declaration?.type ===
|
|
9348
|
+
const declaration = statement.type === import_utils58.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9349
|
+
if (declaration?.type === import_utils58.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
9113
9350
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9114
9351
|
continue;
|
|
9115
9352
|
}
|
|
9116
|
-
if (declaration?.type !==
|
|
9353
|
+
if (declaration?.type !== import_utils58.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9117
9354
|
const aliased = declaration.typeAnnotation;
|
|
9118
|
-
if (aliased.type ===
|
|
9355
|
+
if (aliased.type === import_utils58.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils58.AST_NODE_TYPES.TSConstructorType) {
|
|
9119
9356
|
functionAliases.add(declaration.id.name);
|
|
9120
9357
|
continue;
|
|
9121
9358
|
}
|
|
9122
|
-
const literals = aliased.type ===
|
|
9359
|
+
const literals = aliased.type === import_utils58.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils58.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils58.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
9123
9360
|
if (literals.length === 0) continue;
|
|
9124
9361
|
const merged = /* @__PURE__ */ new Map();
|
|
9125
9362
|
for (const literal of literals) {
|
|
@@ -9132,10 +9369,10 @@ var fileTypeIndex = (program) => {
|
|
|
9132
9369
|
return { objects, functionAliases };
|
|
9133
9370
|
};
|
|
9134
9371
|
var bagMemberTypes = (annotation, declared) => {
|
|
9135
|
-
if (annotation.type ===
|
|
9372
|
+
if (annotation.type === import_utils58.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9136
9373
|
return propertySignatureTypes(annotation.members);
|
|
9137
9374
|
}
|
|
9138
|
-
if (annotation.type !==
|
|
9375
|
+
if (annotation.type !== import_utils58.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9139
9376
|
return null;
|
|
9140
9377
|
}
|
|
9141
9378
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9147,11 +9384,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9147
9384
|
if (members === null) return [];
|
|
9148
9385
|
const collaborators = [];
|
|
9149
9386
|
for (const property of pattern.properties) {
|
|
9150
|
-
if (property.type !==
|
|
9151
|
-
if (property.key.type !==
|
|
9387
|
+
if (property.type !== import_utils58.AST_NODE_TYPES.Property || property.computed) continue;
|
|
9388
|
+
if (property.key.type !== import_utils58.AST_NODE_TYPES.Identifier) continue;
|
|
9152
9389
|
const key = property.key.name;
|
|
9153
|
-
const bound = property.value.type ===
|
|
9154
|
-
if (bound.type !==
|
|
9390
|
+
const bound = property.value.type === import_utils58.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
9391
|
+
if (bound.type !== import_utils58.AST_NODE_TYPES.Identifier) continue;
|
|
9155
9392
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9156
9393
|
const reference = members.get(key);
|
|
9157
9394
|
if (reference === void 0) continue;
|
|
@@ -9161,8 +9398,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9161
9398
|
};
|
|
9162
9399
|
var parameterCollaborators = (parameter, declared) => {
|
|
9163
9400
|
let target = parameter;
|
|
9164
|
-
if (target.type ===
|
|
9165
|
-
if (target.type ===
|
|
9401
|
+
if (target.type === import_utils58.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9402
|
+
if (target.type === import_utils58.AST_NODE_TYPES.ObjectPattern) {
|
|
9166
9403
|
return objectPatternCollaborators(target, declared);
|
|
9167
9404
|
}
|
|
9168
9405
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9176,22 +9413,22 @@ var typeParameterNames = (...declarations) => {
|
|
|
9176
9413
|
return names;
|
|
9177
9414
|
};
|
|
9178
9415
|
var readConstructor = (ctor, declared, typeParameters) => {
|
|
9179
|
-
const
|
|
9416
|
+
const body2 = ctor.value.body;
|
|
9180
9417
|
const storedFrom = /* @__PURE__ */ new Set();
|
|
9181
9418
|
let constructedFields = 0;
|
|
9182
|
-
if (
|
|
9183
|
-
for (const statement of
|
|
9184
|
-
if (statement.type !==
|
|
9419
|
+
if (body2 !== null && body2 !== void 0) {
|
|
9420
|
+
for (const statement of body2.body) {
|
|
9421
|
+
if (statement.type !== import_utils58.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9185
9422
|
const expression = statement.expression;
|
|
9186
|
-
if (expression.type !==
|
|
9423
|
+
if (expression.type !== import_utils58.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils58.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils58.AST_NODE_TYPES.ThisExpression) {
|
|
9187
9424
|
continue;
|
|
9188
9425
|
}
|
|
9189
9426
|
const source = expression.right;
|
|
9190
|
-
if (source.type ===
|
|
9427
|
+
if (source.type === import_utils58.AST_NODE_TYPES.NewExpression) {
|
|
9191
9428
|
constructedFields += 1;
|
|
9192
|
-
} else if (source.type ===
|
|
9429
|
+
} else if (source.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9193
9430
|
storedFrom.add(source.name);
|
|
9194
|
-
} else if (source.type ===
|
|
9431
|
+
} else if (source.type === import_utils58.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
9195
9432
|
storedFrom.add(source.object.name);
|
|
9196
9433
|
}
|
|
9197
9434
|
}
|
|
@@ -9199,7 +9436,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9199
9436
|
const collaborators = [];
|
|
9200
9437
|
for (const parameter of ctor.value.params) {
|
|
9201
9438
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9202
|
-
const stored = parameter.type ===
|
|
9439
|
+
const stored = parameter.type === import_utils58.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9203
9440
|
if (!stored) continue;
|
|
9204
9441
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9205
9442
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9232,20 +9469,20 @@ var subtreeHas = (root, found) => {
|
|
|
9232
9469
|
visit(root);
|
|
9233
9470
|
return hit;
|
|
9234
9471
|
};
|
|
9235
|
-
var isFrameworkWiring = (
|
|
9236
|
-
if (node.type ===
|
|
9472
|
+
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9473
|
+
if (node.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
9237
9474
|
const { callee } = node;
|
|
9238
|
-
if (callee.type ===
|
|
9239
|
-
return callee.type ===
|
|
9475
|
+
if (callee.type === import_utils58.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
9476
|
+
return callee.type === import_utils58.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils58.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9240
9477
|
}
|
|
9241
|
-
return node.type ===
|
|
9478
|
+
return node.type === import_utils58.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils58.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9242
9479
|
});
|
|
9243
9480
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9244
9481
|
var fileInterfaceNames = (program) => {
|
|
9245
9482
|
const names = [];
|
|
9246
9483
|
for (const statement of program.body) {
|
|
9247
|
-
const declaration = statement.type ===
|
|
9248
|
-
if (declaration?.type ===
|
|
9484
|
+
const declaration = statement.type === import_utils58.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9485
|
+
if (declaration?.type === import_utils58.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9249
9486
|
}
|
|
9250
9487
|
return names;
|
|
9251
9488
|
};
|
|
@@ -9260,14 +9497,14 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9260
9497
|
return target.endsWith(other) || other.endsWith(target);
|
|
9261
9498
|
});
|
|
9262
9499
|
};
|
|
9263
|
-
var publicMethodNames = (
|
|
9500
|
+
var publicMethodNames = (body2) => {
|
|
9264
9501
|
const names = [];
|
|
9265
|
-
for (const member of
|
|
9266
|
-
if (member.type !==
|
|
9502
|
+
for (const member of body2.body) {
|
|
9503
|
+
if (member.type !== import_utils58.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9267
9504
|
if (member.kind !== "method" || member.static) continue;
|
|
9268
9505
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9269
|
-
if (member.key.type ===
|
|
9270
|
-
if (member.key.type ===
|
|
9506
|
+
if (member.key.type === import_utils58.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
9507
|
+
if (member.key.type === import_utils58.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
9271
9508
|
else names.push("\u2026");
|
|
9272
9509
|
}
|
|
9273
9510
|
return names;
|
|
@@ -9300,7 +9537,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9300
9537
|
if (node.implements.length > 0) return;
|
|
9301
9538
|
if (node.decorators.length > 0) return;
|
|
9302
9539
|
const ctor = node.body.body.find(
|
|
9303
|
-
(member) => member.type ===
|
|
9540
|
+
(member) => member.type === import_utils58.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
9304
9541
|
);
|
|
9305
9542
|
if (ctor === void 0) return;
|
|
9306
9543
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9329,18 +9566,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9329
9566
|
});
|
|
9330
9567
|
|
|
9331
9568
|
// src/rules/require-zod-form-validation.ts
|
|
9332
|
-
var
|
|
9569
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
9333
9570
|
var looksLikeZodSchema = (node) => {
|
|
9334
9571
|
let current = node;
|
|
9335
9572
|
while (true) {
|
|
9336
|
-
if (current.type ===
|
|
9573
|
+
if (current.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9337
9574
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9338
9575
|
}
|
|
9339
|
-
if (current.type ===
|
|
9576
|
+
if (current.type === import_utils59.AST_NODE_TYPES.CallExpression) {
|
|
9340
9577
|
current = current.callee;
|
|
9341
9578
|
continue;
|
|
9342
9579
|
}
|
|
9343
|
-
if (current.type ===
|
|
9580
|
+
if (current.type === import_utils59.AST_NODE_TYPES.MemberExpression) {
|
|
9344
9581
|
current = current.object;
|
|
9345
9582
|
continue;
|
|
9346
9583
|
}
|
|
@@ -9348,23 +9585,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9348
9585
|
}
|
|
9349
9586
|
};
|
|
9350
9587
|
var isZodParseCall = (node) => {
|
|
9351
|
-
if (node.type !==
|
|
9588
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.CallExpression) return false;
|
|
9352
9589
|
const callee = node.callee;
|
|
9353
|
-
if (callee.type !==
|
|
9590
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression) return false;
|
|
9354
9591
|
if (callee.computed) return false;
|
|
9355
|
-
if (callee.property.type !==
|
|
9592
|
+
if (callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier) return false;
|
|
9356
9593
|
const method = callee.property.name;
|
|
9357
9594
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9358
9595
|
return looksLikeZodSchema(callee.object);
|
|
9359
9596
|
};
|
|
9360
9597
|
var isFormDataMethodCall = (node) => {
|
|
9361
9598
|
let current = node;
|
|
9362
|
-
if (current.type ===
|
|
9599
|
+
if (current.type === import_utils59.AST_NODE_TYPES.AwaitExpression) {
|
|
9363
9600
|
current = current.argument;
|
|
9364
9601
|
}
|
|
9365
|
-
if (current.type !==
|
|
9602
|
+
if (current.type !== import_utils59.AST_NODE_TYPES.CallExpression) return false;
|
|
9366
9603
|
const callee = current.callee;
|
|
9367
|
-
return callee.type ===
|
|
9604
|
+
return callee.type === import_utils59.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils59.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
9368
9605
|
};
|
|
9369
9606
|
var require_zod_form_validation_default = createRule({
|
|
9370
9607
|
name: "require-zod-form-validation",
|
|
@@ -9384,14 +9621,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
9384
9621
|
return {};
|
|
9385
9622
|
}
|
|
9386
9623
|
const isFormSourceIdentifier = (node) => {
|
|
9387
|
-
if (node.type !==
|
|
9624
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.Identifier) return false;
|
|
9388
9625
|
if (/formdata/i.test(node.name)) return true;
|
|
9389
9626
|
let scope = context.sourceCode.getScope(node);
|
|
9390
9627
|
while (scope !== null) {
|
|
9391
9628
|
const variable = scope.set.get(node.name);
|
|
9392
9629
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
9393
9630
|
const def = variable.defs[0];
|
|
9394
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
9631
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils59.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
9395
9632
|
return isFormDataMethodCall(def.node.init);
|
|
9396
9633
|
}
|
|
9397
9634
|
return false;
|
|
@@ -9402,8 +9639,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
9402
9639
|
};
|
|
9403
9640
|
const isFormDataGetCall = (node) => {
|
|
9404
9641
|
const callee = node.callee;
|
|
9405
|
-
if (callee.type !==
|
|
9406
|
-
if (callee.property.type !==
|
|
9642
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression) return false;
|
|
9643
|
+
if (callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
9407
9644
|
return false;
|
|
9408
9645
|
}
|
|
9409
9646
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -9418,11 +9655,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
9418
9655
|
};
|
|
9419
9656
|
const isInstanceofNarrowing = (node) => {
|
|
9420
9657
|
const parent = node.parent;
|
|
9421
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9658
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils59.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils59.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
9422
9659
|
};
|
|
9423
9660
|
const boundDeclarator = (node) => {
|
|
9424
9661
|
const parent = node.parent;
|
|
9425
|
-
if (parent.type ===
|
|
9662
|
+
if (parent.type === import_utils59.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
9426
9663
|
return parent;
|
|
9427
9664
|
}
|
|
9428
9665
|
return null;
|
|
@@ -9450,7 +9687,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
9450
9687
|
});
|
|
9451
9688
|
|
|
9452
9689
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
9453
|
-
var
|
|
9690
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9454
9691
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
9455
9692
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
9456
9693
|
var INSERT_GATE = /insert/i;
|
|
@@ -9481,7 +9718,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
9481
9718
|
});
|
|
9482
9719
|
|
|
9483
9720
|
// src/rules/zod-naming-convention.ts
|
|
9484
|
-
var
|
|
9721
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9485
9722
|
var CONVENTIONS = {
|
|
9486
9723
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
9487
9724
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -9506,15 +9743,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
9506
9743
|
"registry",
|
|
9507
9744
|
"implement"
|
|
9508
9745
|
]);
|
|
9509
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
9746
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
9510
9747
|
var calleeChainStartsWithZ = (node) => {
|
|
9511
9748
|
let current = node;
|
|
9512
|
-
while (current.type ===
|
|
9749
|
+
while (current.type === import_utils61.AST_NODE_TYPES.MemberExpression) {
|
|
9513
9750
|
const receiver = current.object;
|
|
9514
|
-
if (receiver.type ===
|
|
9751
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
9515
9752
|
return true;
|
|
9516
9753
|
}
|
|
9517
|
-
if (receiver.type ===
|
|
9754
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9518
9755
|
current = receiver.callee;
|
|
9519
9756
|
continue;
|
|
9520
9757
|
}
|
|
@@ -9559,13 +9796,13 @@ var zod_naming_convention_default = createRule({
|
|
|
9559
9796
|
VariableDeclarator(node) {
|
|
9560
9797
|
const init = node.init;
|
|
9561
9798
|
if (init === null || init === void 0) return;
|
|
9562
|
-
if (init.type !==
|
|
9799
|
+
if (init.type !== import_utils61.AST_NODE_TYPES.CallExpression) return;
|
|
9563
9800
|
const callee = init.callee;
|
|
9564
|
-
if (callee.type !==
|
|
9801
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression) return;
|
|
9565
9802
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
9566
9803
|
const terminal = terminalMethodName(callee);
|
|
9567
9804
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
9568
|
-
if (node.id.type !==
|
|
9805
|
+
if (node.id.type !== import_utils61.AST_NODE_TYPES.Identifier) return;
|
|
9569
9806
|
if (test.test(node.id.name)) return;
|
|
9570
9807
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
9571
9808
|
context.report({
|
|
@@ -9589,47 +9826,47 @@ var renamedRules = {
|
|
|
9589
9826
|
var retiredRules = {
|
|
9590
9827
|
"ban-loose-type-guards-in-tests": {
|
|
9591
9828
|
removedIn: "5.0.0",
|
|
9592
|
-
reason: "
|
|
9829
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9593
9830
|
},
|
|
9594
9831
|
"no-implicit-attribute-access": {
|
|
9595
9832
|
removedIn: "5.0.0",
|
|
9596
|
-
reason: "
|
|
9833
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9597
9834
|
},
|
|
9598
9835
|
"no-sequential-await": {
|
|
9599
9836
|
removedIn: "3.0.0",
|
|
9600
|
-
reason: "
|
|
9837
|
+
reason: "Delete the entry; core `no-await-in-loop` covers it."
|
|
9601
9838
|
},
|
|
9602
9839
|
"no-template-literal-in-log": {
|
|
9603
9840
|
removedIn: "2.3.1",
|
|
9604
|
-
reason: "
|
|
9841
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9605
9842
|
},
|
|
9606
9843
|
"no-unsafe-cast": {
|
|
9607
9844
|
removedIn: "3.0.0",
|
|
9608
|
-
reason:
|
|
9845
|
+
reason: "Delete the entry; keep `@typescript-eslint/consistent-type-assertions` enabled."
|
|
9609
9846
|
},
|
|
9610
9847
|
"prefer-setup-file-mocks": {
|
|
9611
9848
|
removedIn: "5.0.0",
|
|
9612
|
-
reason: "
|
|
9849
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9613
9850
|
},
|
|
9614
9851
|
"prefer-shadcn": {
|
|
9615
9852
|
removedIn: "3.0.0",
|
|
9616
|
-
reason: "
|
|
9853
|
+
reason: "Delete the entry; use `react/forbid-elements` for element restrictions."
|
|
9617
9854
|
},
|
|
9618
9855
|
"primary-export-file-name": {
|
|
9619
9856
|
removedIn: "4.0.0",
|
|
9620
|
-
reason: "
|
|
9857
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9621
9858
|
},
|
|
9622
9859
|
"require-parameterized-tests": {
|
|
9623
9860
|
removedIn: "4.0.0",
|
|
9624
|
-
reason: "
|
|
9861
|
+
reason: "Delete stale references; the rule was never registered."
|
|
9625
9862
|
},
|
|
9626
9863
|
"require-schema-validate-search": {
|
|
9627
9864
|
removedIn: "3.0.0",
|
|
9628
|
-
reason: "
|
|
9865
|
+
reason: "Delete the entry; use `@typescript-eslint/consistent-type-assertions`."
|
|
9629
9866
|
},
|
|
9630
9867
|
"single-public-export": {
|
|
9631
9868
|
removedIn: "3.0.0",
|
|
9632
|
-
reason: "
|
|
9869
|
+
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
9633
9870
|
}
|
|
9634
9871
|
};
|
|
9635
9872
|
|
|
@@ -9648,6 +9885,7 @@ var rules = {
|
|
|
9648
9885
|
"no-insecure-random-id": no_insecure_random_id_default,
|
|
9649
9886
|
"no-json-stringify-error": no_json_stringify_error_default,
|
|
9650
9887
|
"no-log-only-catch": no_log_only_catch_default,
|
|
9888
|
+
"no-long-comment": no_long_comment_default,
|
|
9651
9889
|
"no-offset-pagination": no_offset_pagination_default,
|
|
9652
9890
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
9653
9891
|
"no-raw-env": no_raw_env_default,
|
|
@@ -9663,6 +9901,7 @@ var rules = {
|
|
|
9663
9901
|
"no-storage-in-stateless-modules": no_storage_in_stateless_modules_default,
|
|
9664
9902
|
"no-string-concat-in-loop": no_string_concat_in_loop_default,
|
|
9665
9903
|
"no-tautological-expect": no_tautological_expect_default,
|
|
9904
|
+
"no-typed-doc-sections": no_typed_doc_sections_default,
|
|
9666
9905
|
"no-trailing-value-narration": no_trailing_value_narration_default,
|
|
9667
9906
|
"no-declaration-comment-wall": no_declaration_comment_wall_default,
|
|
9668
9907
|
"no-union-in-comment": no_union_in_comment_default,
|
|
@@ -9678,6 +9917,7 @@ var rules = {
|
|
|
9678
9917
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
9679
9918
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
9680
9919
|
"prefer-server-actions": prefer_server_actions_default,
|
|
9920
|
+
"prefer-single-sentence-comment": prefer_single_sentence_comment_default,
|
|
9681
9921
|
"prefer-string-literal-union": prefer_string_literal_union_default,
|
|
9682
9922
|
"prefer-whole-object-assertion": prefer_whole_object_assertion_default,
|
|
9683
9923
|
"prefer-zod-enum": prefer_zod_enum_default,
|
|
@@ -9691,7 +9931,7 @@ var rules = {
|
|
|
9691
9931
|
};
|
|
9692
9932
|
var meta = {
|
|
9693
9933
|
name: "@sarj/eslint-plugin",
|
|
9694
|
-
version: "9.
|
|
9934
|
+
version: "9.7.1"
|
|
9695
9935
|
};
|
|
9696
9936
|
var recommendedRules = {
|
|
9697
9937
|
"@sarj/enforce-file-structure": "warn",
|
|
@@ -9706,6 +9946,7 @@ var recommendedRules = {
|
|
|
9706
9946
|
"@sarj/no-insecure-random-id": "warn",
|
|
9707
9947
|
"@sarj/no-json-stringify-error": "warn",
|
|
9708
9948
|
"@sarj/no-log-only-catch": "warn",
|
|
9949
|
+
"@sarj/no-long-comment": "warn",
|
|
9709
9950
|
"@sarj/no-offset-pagination": "warn",
|
|
9710
9951
|
"@sarj/no-positional-tuple-return": "warn",
|
|
9711
9952
|
"@sarj/no-repeated-string-literal": "warn",
|
|
@@ -9718,6 +9959,7 @@ var recommendedRules = {
|
|
|
9718
9959
|
"@sarj/no-sleep-in-test-body": "warn",
|
|
9719
9960
|
"@sarj/no-string-concat-in-loop": "warn",
|
|
9720
9961
|
"@sarj/no-tautological-expect": "warn",
|
|
9962
|
+
"@sarj/no-typed-doc-sections": "warn",
|
|
9721
9963
|
"@sarj/no-trailing-value-narration": "warn",
|
|
9722
9964
|
"@sarj/no-declaration-comment-wall": "warn",
|
|
9723
9965
|
"@sarj/no-union-in-comment": "warn",
|
|
@@ -9733,6 +9975,7 @@ var recommendedRules = {
|
|
|
9733
9975
|
"@sarj/prefer-schema-for-api-payload": "warn",
|
|
9734
9976
|
"@sarj/prefer-semantic-colors": ["warn", { requireSemanticTokens: true }],
|
|
9735
9977
|
"@sarj/prefer-server-actions": "warn",
|
|
9978
|
+
"@sarj/prefer-single-sentence-comment": "warn",
|
|
9736
9979
|
"@sarj/prefer-string-literal-union": "warn",
|
|
9737
9980
|
"@sarj/prefer-whole-object-assertion": "warn",
|
|
9738
9981
|
"@sarj/prefer-zod-enum": "warn",
|
|
@@ -9758,6 +10001,7 @@ var strictRules = {
|
|
|
9758
10001
|
"@sarj/no-insecure-random-id": "error",
|
|
9759
10002
|
"@sarj/no-json-stringify-error": "error",
|
|
9760
10003
|
"@sarj/no-log-only-catch": "error",
|
|
10004
|
+
"@sarj/no-long-comment": "error",
|
|
9761
10005
|
"@sarj/no-offset-pagination": "error",
|
|
9762
10006
|
"@sarj/no-positional-tuple-return": "error",
|
|
9763
10007
|
"@sarj/no-raw-env": "error",
|
|
@@ -9773,6 +10017,7 @@ var strictRules = {
|
|
|
9773
10017
|
"@sarj/no-storage-in-stateless-modules": "error",
|
|
9774
10018
|
"@sarj/no-string-concat-in-loop": "error",
|
|
9775
10019
|
"@sarj/no-tautological-expect": "error",
|
|
10020
|
+
"@sarj/no-typed-doc-sections": "error",
|
|
9776
10021
|
"@sarj/no-trailing-value-narration": "error",
|
|
9777
10022
|
"@sarj/no-declaration-comment-wall": "error",
|
|
9778
10023
|
"@sarj/no-union-in-comment": "error",
|
|
@@ -9788,6 +10033,7 @@ var strictRules = {
|
|
|
9788
10033
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
9789
10034
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
9790
10035
|
"@sarj/prefer-server-actions": "error",
|
|
10036
|
+
"@sarj/prefer-single-sentence-comment": "warn",
|
|
9791
10037
|
"@sarj/prefer-string-literal-union": "error",
|
|
9792
10038
|
"@sarj/prefer-whole-object-assertion": "error",
|
|
9793
10039
|
"@sarj/prefer-zod-enum": "error",
|