@sarj/eslint-plugin 7.0.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.cjs +884 -456
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -9
- package/dist/index.d.ts +32 -9
- package/dist/index.js +877 -450
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
default: () => index_default,
|
|
34
34
|
recommendedRules: () => recommendedRules,
|
|
35
35
|
renamedRules: () => renamedRules,
|
|
36
|
+
retiredRules: () => retiredRules,
|
|
36
37
|
rules: () => rules,
|
|
37
38
|
strictRules: () => strictRules
|
|
38
39
|
});
|
|
@@ -52,25 +53,41 @@ var createRule = import_utils.ESLintUtils.RuleCreator(evidenceUrl);
|
|
|
52
53
|
// src/rules/_paths.ts
|
|
53
54
|
var SCRIPT_FILE_RE = /([\\/]scripts[\\/])|(\.mjs$)/;
|
|
54
55
|
var STORY_FILE_RE = /\.stories\.[cm]?[jt]sx?$/i;
|
|
55
|
-
var
|
|
56
|
-
var GENERATED_FILE_RE = /([\\/](?:generated|openapi-gen|graphql[\\/]types|vendor|vendored|
|
|
57
|
-
var
|
|
58
|
-
|
|
56
|
+
var STORY_TREE_RE = /(^|\/)stories(?:[_-][^/]*)?\//i;
|
|
57
|
+
var GENERATED_FILE_RE = /([\\/](?:generated|openapi-gen|graphql[\\/]types|vendor|vendored|third[-_]?party)[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)|(\.types\.[cm]?ts$)/;
|
|
58
|
+
var EXTERNAL_TREE_RE = /[\\/]external[\\/]/;
|
|
59
|
+
var GENERATED_MARKER_RE = /(?:@generated\b|this file (?:is|was|has been)[\w\s,'-]{0,40}?generated|auto-?generated file\b|generated (?:with|by)|generated (?:graphql )?types|do not edit(?: directly| manually)?|do not (?:modify|change) this file)/i;
|
|
60
|
+
var TEST_BASENAME_RE = /[.\-_](test|spec|e2e)\.[cm]?[jt]sx?$/;
|
|
61
|
+
var TEST_INTEGRATION_BASENAME_RE = /\.integration\.[cm]?[jt]sx?$/;
|
|
62
|
+
var TEST_DIR_RE = /(^|\/)(tests?|__tests__|__mocks__|fixtures|__fixtures__|__testfixtures__|e2e|integration)\//;
|
|
63
|
+
var FIXTURE_TREE_RE = /(^|\/)fixture\//;
|
|
64
|
+
function isTestFile(filename, gates = []) {
|
|
59
65
|
const normalized = filename.replaceAll("\\", "/");
|
|
60
66
|
const base = normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
61
|
-
if (
|
|
67
|
+
if (TEST_BASENAME_RE.test(base) || TEST_INTEGRATION_BASENAME_RE.test(base)) {
|
|
62
68
|
return true;
|
|
63
69
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
if (TEST_DIR_RE.test(normalized)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return gates.includes("fixtureTree") && FIXTURE_TREE_RE.test(normalized);
|
|
67
74
|
}
|
|
68
|
-
function isStoryFile(filename) {
|
|
75
|
+
function isStoryFile(filename, gates = []) {
|
|
69
76
|
const normalized = filename.replaceAll("\\", "/");
|
|
70
|
-
|
|
77
|
+
if (STORY_FILE_RE.test(normalized)) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return gates.includes("storyTree") && STORY_TREE_RE.test(normalized);
|
|
71
81
|
}
|
|
72
|
-
function isGeneratedFile(filename, sourceText = "") {
|
|
73
|
-
|
|
82
|
+
function isGeneratedFile(filename, sourceText = "", gates = []) {
|
|
83
|
+
const normalized = filename.replaceAll("\\", "/");
|
|
84
|
+
if (GENERATED_FILE_RE.test(normalized)) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (gates.includes("externalTree") && EXTERNAL_TREE_RE.test(normalized)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
return GENERATED_MARKER_RE.test(sourceText.slice(0, 2048));
|
|
74
91
|
}
|
|
75
92
|
function isScriptFile(filename) {
|
|
76
93
|
return SCRIPT_FILE_RE.test(filename);
|
|
@@ -155,6 +172,10 @@ var enforce_file_structure_default = createRule({
|
|
|
155
172
|
|
|
156
173
|
// src/rules/no-async-callback-in-wait-for.ts
|
|
157
174
|
var import_utils3 = require("@typescript-eslint/utils");
|
|
175
|
+
var isWaitForCallee = (callee) => {
|
|
176
|
+
if (callee.type === import_utils3.AST_NODE_TYPES.Identifier) return callee.name === "waitFor";
|
|
177
|
+
return callee.type === import_utils3.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils3.AST_NODE_TYPES.Identifier && callee.property.name === "waitFor";
|
|
178
|
+
};
|
|
158
179
|
var no_async_callback_in_wait_for_default = createRule({
|
|
159
180
|
name: "no-async-callback-in-wait-for",
|
|
160
181
|
meta: {
|
|
@@ -174,14 +195,13 @@ var no_async_callback_in_wait_for_default = createRule({
|
|
|
174
195
|
}
|
|
175
196
|
return {
|
|
176
197
|
CallExpression(node) {
|
|
177
|
-
if (node.callee
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
198
|
+
if (!isWaitForCallee(node.callee)) return;
|
|
199
|
+
const callback = node.arguments[0];
|
|
200
|
+
if (callback && (callback.type === import_utils3.AST_NODE_TYPES.ArrowFunctionExpression || callback.type === import_utils3.AST_NODE_TYPES.FunctionExpression) && callback.async) {
|
|
201
|
+
context.report({
|
|
202
|
+
node: callback,
|
|
203
|
+
messageId: "noAsyncCallbackInWaitFor"
|
|
204
|
+
});
|
|
185
205
|
}
|
|
186
206
|
}
|
|
187
207
|
};
|
|
@@ -809,6 +829,12 @@ var no_comment_cruft_default = createRule({
|
|
|
809
829
|
// src/rules/no-conditional-in-test.ts
|
|
810
830
|
var import_utils7 = require("@typescript-eslint/utils");
|
|
811
831
|
var TEST_CALLERS = /* @__PURE__ */ new Set(["it", "test"]);
|
|
832
|
+
var HOOK_MEMBERS = /* @__PURE__ */ new Set([
|
|
833
|
+
"afterAll",
|
|
834
|
+
"afterEach",
|
|
835
|
+
"beforeAll",
|
|
836
|
+
"beforeEach"
|
|
837
|
+
]);
|
|
812
838
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
813
839
|
import_utils7.AST_NODE_TYPES.FunctionDeclaration,
|
|
814
840
|
import_utils7.AST_NODE_TYPES.FunctionExpression,
|
|
@@ -852,6 +878,9 @@ function isTestBody(fn) {
|
|
|
852
878
|
if (call?.type !== import_utils7.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
853
879
|
return false;
|
|
854
880
|
}
|
|
881
|
+
if (call.callee.type === import_utils7.AST_NODE_TYPES.MemberExpression && !call.callee.computed && call.callee.property.type === import_utils7.AST_NODE_TYPES.Identifier && HOOK_MEMBERS.has(call.callee.property.name)) {
|
|
882
|
+
return false;
|
|
883
|
+
}
|
|
855
884
|
const name = testCallerName(call.callee);
|
|
856
885
|
return name !== null && TEST_CALLERS.has(name);
|
|
857
886
|
}
|
|
@@ -1006,8 +1035,26 @@ function isTypeLevelNarrowing(node) {
|
|
|
1006
1035
|
return isTypeAssertionBranch(node.consequent) && (node.alternate === null || isTypeAssertionBranch(node.alternate));
|
|
1007
1036
|
}
|
|
1008
1037
|
var isInertBranch = (branch) => !containsAssertion(branch) && !containsEscape(branch) && !containsSkipCall(branch);
|
|
1038
|
+
function isNormalizationStatement(statement) {
|
|
1039
|
+
if (statement.type === import_utils7.AST_NODE_TYPES.VariableDeclaration) {
|
|
1040
|
+
return true;
|
|
1041
|
+
}
|
|
1042
|
+
if (statement.type === import_utils7.AST_NODE_TYPES.BlockStatement) {
|
|
1043
|
+
return statement.body.every(isNormalizationStatement);
|
|
1044
|
+
}
|
|
1045
|
+
if (statement.type !== import_utils7.AST_NODE_TYPES.ExpressionStatement) {
|
|
1046
|
+
return false;
|
|
1047
|
+
}
|
|
1048
|
+
const { expression } = statement;
|
|
1049
|
+
return expression.type === import_utils7.AST_NODE_TYPES.AssignmentExpression || expression.type === import_utils7.AST_NODE_TYPES.UpdateExpression || expression.type === import_utils7.AST_NODE_TYPES.UnaryExpression && expression.operator === "delete";
|
|
1050
|
+
}
|
|
1009
1051
|
function isInertNormalization(node) {
|
|
1010
|
-
|
|
1052
|
+
const branches = [node.consequent, node.alternate].filter(
|
|
1053
|
+
(branch) => branch !== null
|
|
1054
|
+
);
|
|
1055
|
+
return branches.every(
|
|
1056
|
+
(branch) => isInertBranch(branch) && isNormalizationStatement(branch)
|
|
1057
|
+
);
|
|
1011
1058
|
}
|
|
1012
1059
|
function isExemptIfStatement(node) {
|
|
1013
1060
|
return isPinnedNarrowingGuard(node) || isThrowingGuard(node) || isTypeLevelNarrowing(node) || isInertNormalization(node);
|
|
@@ -1615,7 +1662,6 @@ var PURE_METHODS = /* @__PURE__ */ new Set([
|
|
|
1615
1662
|
"forEach",
|
|
1616
1663
|
"reduce",
|
|
1617
1664
|
"reduceRight",
|
|
1618
|
-
"find",
|
|
1619
1665
|
"findIndex",
|
|
1620
1666
|
"findLast",
|
|
1621
1667
|
"findLastIndex",
|
|
@@ -1638,15 +1684,6 @@ var PURE_METHODS = /* @__PURE__ */ new Set([
|
|
|
1638
1684
|
"indexOf",
|
|
1639
1685
|
"lastIndexOf",
|
|
1640
1686
|
"at",
|
|
1641
|
-
"keys",
|
|
1642
|
-
"values",
|
|
1643
|
-
"entries",
|
|
1644
|
-
"has",
|
|
1645
|
-
"get",
|
|
1646
|
-
"set",
|
|
1647
|
-
"add",
|
|
1648
|
-
"delete",
|
|
1649
|
-
"clear",
|
|
1650
1687
|
"toString",
|
|
1651
1688
|
"toLocaleString",
|
|
1652
1689
|
"valueOf",
|
|
@@ -1677,6 +1714,7 @@ var PURE_NAMESPACES = /* @__PURE__ */ new Set([
|
|
|
1677
1714
|
"Boolean",
|
|
1678
1715
|
"console"
|
|
1679
1716
|
]);
|
|
1717
|
+
var IMPURE_NAMESPACE_METHODS = /* @__PURE__ */ new Set(["JSON.parse"]);
|
|
1680
1718
|
var PURE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
1681
1719
|
"Map",
|
|
1682
1720
|
"Set",
|
|
@@ -1713,7 +1751,7 @@ function isPureCall(node) {
|
|
|
1713
1751
|
return false;
|
|
1714
1752
|
}
|
|
1715
1753
|
if (callee.object.type === import_utils12.AST_NODE_TYPES.Identifier && PURE_NAMESPACES.has(callee.object.name)) {
|
|
1716
|
-
return
|
|
1754
|
+
return !IMPURE_NAMESPACE_METHODS.has(`${callee.object.name}.${property.name}`);
|
|
1717
1755
|
}
|
|
1718
1756
|
return PURE_METHODS.has(property.name);
|
|
1719
1757
|
}
|
|
@@ -5032,29 +5070,61 @@ var no_trailing_value_narration_default = createRule({
|
|
|
5032
5070
|
}
|
|
5033
5071
|
});
|
|
5034
5072
|
|
|
5035
|
-
// src/rules/no-
|
|
5073
|
+
// src/rules/no-declaration-comment-wall.ts
|
|
5074
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
5075
|
+
|
|
5076
|
+
// src/rules/_comment-wall.ts
|
|
5036
5077
|
var import_utils34 = require("@typescript-eslint/utils");
|
|
5037
|
-
var
|
|
5078
|
+
var WALL_DEFAULTS = {
|
|
5038
5079
|
// Below three rows "a wall" is not a fair description of what the reader sees.
|
|
5039
5080
|
minCommentedMembers: 3,
|
|
5040
5081
|
// A minority of commented members is a GROUP LABEL, not a wall.
|
|
5041
5082
|
minCommentedRatio: 0.6,
|
|
5042
|
-
// Room for one substantive row in four; a
|
|
5043
|
-
// say something real is
|
|
5083
|
+
// Room for one substantive row in four; a declaration where a quarter of the
|
|
5084
|
+
// comments say something real is one someone was documenting, not decorating.
|
|
5044
5085
|
minRestatedRatio: 0.75,
|
|
5045
|
-
// One word beyond the member's own text. Zero is `no-restated-jsdoc`'s
|
|
5046
|
-
//
|
|
5047
|
-
// beside "Exact match")
|
|
5086
|
+
// One word beyond the member's own text. Zero is `no-restated-jsdoc`'s test
|
|
5087
|
+
// and is already covered there; two admits definitions ("Partial match"
|
|
5088
|
+
// beside "Exact match").
|
|
5048
5089
|
maxNovelWords: 1
|
|
5049
5090
|
};
|
|
5091
|
+
var WALL_SCHEMA = {
|
|
5092
|
+
type: "object",
|
|
5093
|
+
additionalProperties: false,
|
|
5094
|
+
properties: {
|
|
5095
|
+
minCommentedMembers: {
|
|
5096
|
+
type: "integer",
|
|
5097
|
+
minimum: 2,
|
|
5098
|
+
description: "Fewest commented members that can count as a wall."
|
|
5099
|
+
},
|
|
5100
|
+
minCommentedRatio: {
|
|
5101
|
+
type: "number",
|
|
5102
|
+
minimum: 0,
|
|
5103
|
+
maximum: 1,
|
|
5104
|
+
description: "Least share of the members that must be commented; below it the comments are group labels."
|
|
5105
|
+
},
|
|
5106
|
+
minRestatedRatio: {
|
|
5107
|
+
type: "number",
|
|
5108
|
+
minimum: 0,
|
|
5109
|
+
maximum: 1,
|
|
5110
|
+
description: "Least share of the member comments that must be restatements."
|
|
5111
|
+
},
|
|
5112
|
+
maxNovelWords: {
|
|
5113
|
+
type: "integer",
|
|
5114
|
+
minimum: 0,
|
|
5115
|
+
description: "Most content words a comment may add beyond its member's own source and still count as a restatement."
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
};
|
|
5050
5119
|
var VALUE_TAG_RE = /@(?:deprecated|see|example|throws|remarks|since|default|defaultvalue|link|internal|alpha|beta|experimental|template|typeparam|inheritdoc|todo|fixme|override)\b/i;
|
|
5051
5120
|
var DEFAULT_RE = /^\s*@?default\b|\bdefaults? (?:to|:)/i;
|
|
5052
5121
|
var DIGIT_RE = /\d/;
|
|
5053
5122
|
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;
|
|
5054
5123
|
var EXAMPLE_RE = /["'`]|\be\.g\.|\bi\.e\./;
|
|
5124
|
+
var TAG_TOKEN_RE = /@\w+/g;
|
|
5055
5125
|
var BANNER_RE = /[=\-─-╿*#~_.]{3,}/;
|
|
5056
5126
|
var NON_ASCII_LETTER_RE2 = /[^\p{ASCII}\p{N}\p{P}\p{Z}]/u;
|
|
5057
|
-
var
|
|
5127
|
+
var WALL_STOPWORDS = new Set(
|
|
5058
5128
|
`the a an of to for in on with and or as at by is are was be been being
|
|
5059
5129
|
this that it its if whether when where which what will would can could should
|
|
5060
5130
|
must may into from over about not no does do done has have had used use uses
|
|
@@ -5069,15 +5139,22 @@ var BARE_LABEL_RE = /^[A-Za-z][A-Za-z0-9]*$/;
|
|
|
5069
5139
|
function labelStems(body) {
|
|
5070
5140
|
return splitIdentifier(body).map(stem).join(" ");
|
|
5071
5141
|
}
|
|
5072
|
-
function isNamedMember(node) {
|
|
5073
|
-
return (node.type === import_utils34.AST_NODE_TYPES.TSPropertySignature || node.type === import_utils34.AST_NODE_TYPES.TSMethodSignature) && !node.computed;
|
|
5074
|
-
}
|
|
5075
5142
|
function commentBody(comment) {
|
|
5076
5143
|
return comment.value.replace(/^\*+/, "").replace(/^[ \t]*\*[ \t]?/gm, "").trim();
|
|
5077
5144
|
}
|
|
5078
5145
|
function carriesValue(body) {
|
|
5079
5146
|
return isProtected(body) || VALUE_TAG_RE.test(body) || DEFAULT_RE.test(body) || DIGIT_RE.test(body) || UNIT_WORD_RE.test(body) || EXAMPLE_RE.test(body) || BANNER_RE.test(body) || NON_ASCII_LETTER_RE2.test(body);
|
|
5080
5147
|
}
|
|
5148
|
+
function isLabel(body) {
|
|
5149
|
+
let content = 0;
|
|
5150
|
+
for (const word of body.match(WORD_RE4) ?? []) {
|
|
5151
|
+
if (word.length >= 2 && !WALL_STOPWORDS.has(word.toLowerCase())) content += 1;
|
|
5152
|
+
}
|
|
5153
|
+
return content <= 1;
|
|
5154
|
+
}
|
|
5155
|
+
function isTagsOnly(body) {
|
|
5156
|
+
return body.length > 0 && body.replace(TAG_TOKEN_RE, "").trim().length === 0;
|
|
5157
|
+
}
|
|
5081
5158
|
function knownTokens(source) {
|
|
5082
5159
|
const tokens = /* @__PURE__ */ new Set();
|
|
5083
5160
|
for (const identifier of source.match(/[A-Za-z_$][\w$]*/g) ?? []) {
|
|
@@ -5092,11 +5169,146 @@ function novelWords(body, known) {
|
|
|
5092
5169
|
let novel = 0;
|
|
5093
5170
|
for (const word of body.match(WORD_RE4) ?? []) {
|
|
5094
5171
|
const lower = word.toLowerCase();
|
|
5095
|
-
if (lower.length < 2 ||
|
|
5172
|
+
if (lower.length < 2 || WALL_STOPWORDS.has(lower)) continue;
|
|
5096
5173
|
if (!known.has(lower) && !known.has(stem(lower))) novel += 1;
|
|
5097
5174
|
}
|
|
5098
5175
|
return novel;
|
|
5099
5176
|
}
|
|
5177
|
+
function isWall(members, commented, restated, options) {
|
|
5178
|
+
return commented >= options.minCommentedMembers && commented / members >= options.minCommentedRatio && restated / commented >= options.minRestatedRatio;
|
|
5179
|
+
}
|
|
5180
|
+
var OPAQUE_VALUE_TYPES = /* @__PURE__ */ new Set([
|
|
5181
|
+
import_utils34.AST_NODE_TYPES.FunctionExpression,
|
|
5182
|
+
import_utils34.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
5183
|
+
import_utils34.AST_NODE_TYPES.ObjectExpression,
|
|
5184
|
+
import_utils34.AST_NODE_TYPES.ArrayExpression
|
|
5185
|
+
]);
|
|
5186
|
+
function declarationRange(member) {
|
|
5187
|
+
const body = bodyOf(member);
|
|
5188
|
+
if (body === void 0) return [member.range[0], member.range[1]];
|
|
5189
|
+
return [member.range[0], body.range[0]];
|
|
5190
|
+
}
|
|
5191
|
+
function bodyOf(member) {
|
|
5192
|
+
if (member.type === import_utils34.AST_NODE_TYPES.MethodDefinition || member.type === import_utils34.AST_NODE_TYPES.TSAbstractMethodDefinition) {
|
|
5193
|
+
return member.value.body ?? void 0;
|
|
5194
|
+
}
|
|
5195
|
+
if (member.type === import_utils34.AST_NODE_TYPES.Property || member.type === import_utils34.AST_NODE_TYPES.PropertyDefinition) {
|
|
5196
|
+
const value = member.value;
|
|
5197
|
+
if (value !== null && OPAQUE_VALUE_TYPES.has(value.type)) return value;
|
|
5198
|
+
}
|
|
5199
|
+
return void 0;
|
|
5200
|
+
}
|
|
5201
|
+
|
|
5202
|
+
// src/rules/no-declaration-comment-wall.ts
|
|
5203
|
+
function named(node) {
|
|
5204
|
+
switch (node.type) {
|
|
5205
|
+
case import_utils35.AST_NODE_TYPES.TSEnumMember:
|
|
5206
|
+
return { node, key: node.id };
|
|
5207
|
+
case import_utils35.AST_NODE_TYPES.PropertyDefinition:
|
|
5208
|
+
case import_utils35.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
|
5209
|
+
case import_utils35.AST_NODE_TYPES.MethodDefinition:
|
|
5210
|
+
case import_utils35.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
|
5211
|
+
return node.computed ? void 0 : { node, key: node.key };
|
|
5212
|
+
default:
|
|
5213
|
+
return void 0;
|
|
5214
|
+
}
|
|
5215
|
+
}
|
|
5216
|
+
var no_declaration_comment_wall_default = createRule({
|
|
5217
|
+
name: "no-declaration-comment-wall",
|
|
5218
|
+
meta: {
|
|
5219
|
+
type: "suggestion",
|
|
5220
|
+
docs: {
|
|
5221
|
+
description: "Flag an enum body or class body whose member comments mostly re-spell the members' own names."
|
|
5222
|
+
},
|
|
5223
|
+
schema: [WALL_SCHEMA],
|
|
5224
|
+
messages: {
|
|
5225
|
+
commentWall: "{{restated}} of this declaration's {{commented}} member comments only re-spell the member's own name \u2014 delete them, and keep the rows that say what the name cannot."
|
|
5226
|
+
}
|
|
5227
|
+
},
|
|
5228
|
+
defaultOptions: [WALL_DEFAULTS],
|
|
5229
|
+
create(context, [provided]) {
|
|
5230
|
+
const options = { ...WALL_DEFAULTS, ...provided };
|
|
5231
|
+
const sourceCode = context.sourceCode;
|
|
5232
|
+
if (isGeneratedFile(context.filename, sourceCode.text) || isTestFile(context.filename) || isStoryFile(context.filename)) {
|
|
5233
|
+
return {};
|
|
5234
|
+
}
|
|
5235
|
+
const endingOn = /* @__PURE__ */ new Map();
|
|
5236
|
+
const startingOn = /* @__PURE__ */ new Map();
|
|
5237
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
5238
|
+
endingOn.set(comment.loc.end.line, comment);
|
|
5239
|
+
if (!startingOn.has(comment.loc.start.line)) startingOn.set(comment.loc.start.line, comment);
|
|
5240
|
+
}
|
|
5241
|
+
function documentingComment(member) {
|
|
5242
|
+
const beforeMember = sourceCode.getTokenBefore(member, { includeComments: false });
|
|
5243
|
+
const ownsItsLine = beforeMember === null || beforeMember.loc.end.line < member.loc.start.line;
|
|
5244
|
+
const lead = ownsItsLine ? endingOn.get(member.loc.start.line - 1) : void 0;
|
|
5245
|
+
if (lead !== void 0) {
|
|
5246
|
+
const before = sourceCode.getTokenBefore(lead, { includeComments: false });
|
|
5247
|
+
if (before === null || before.loc.end.line < lead.loc.start.line) return lead;
|
|
5248
|
+
}
|
|
5249
|
+
const trail = startingOn.get(member.loc.end.line);
|
|
5250
|
+
return trail !== void 0 && trail.range[0] > member.range[0] ? trail : void 0;
|
|
5251
|
+
}
|
|
5252
|
+
function isGroupLabel(comment, member, headsRun) {
|
|
5253
|
+
if (comment.loc.end.line >= member.node.loc.start.line) return false;
|
|
5254
|
+
const body = commentBody(comment);
|
|
5255
|
+
if (!BARE_LABEL_RE.test(body)) return false;
|
|
5256
|
+
if (labelStems(body) === labelStems(sourceCode.getText(member.key))) return false;
|
|
5257
|
+
const lineAbove = sourceCode.lines[comment.loc.start.line - 2];
|
|
5258
|
+
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5259
|
+
}
|
|
5260
|
+
function check(node, members) {
|
|
5261
|
+
const judged = members.map(named).filter((member) => member !== void 0);
|
|
5262
|
+
if (judged.length === 0) return;
|
|
5263
|
+
const documented = judged.map((member) => ({
|
|
5264
|
+
member,
|
|
5265
|
+
comment: documentingComment(member.node)
|
|
5266
|
+
}));
|
|
5267
|
+
let commented = 0;
|
|
5268
|
+
let restated = 0;
|
|
5269
|
+
for (const [index, { member, comment }] of documented.entries()) {
|
|
5270
|
+
if (comment === void 0) continue;
|
|
5271
|
+
const next = documented[index + 1];
|
|
5272
|
+
if (isGroupLabel(comment, member, next !== void 0 && next.comment === void 0)) {
|
|
5273
|
+
continue;
|
|
5274
|
+
}
|
|
5275
|
+
commented += 1;
|
|
5276
|
+
const body = commentBody(comment);
|
|
5277
|
+
if (body.length === 0 || carriesValue(body) || isTagsOnly(body) || isLabel(body)) {
|
|
5278
|
+
continue;
|
|
5279
|
+
}
|
|
5280
|
+
const [start, end] = declarationRange(member.node);
|
|
5281
|
+
if (novelWords(body, knownTokens(sourceCode.text.slice(start, end))) <= options.maxNovelWords) {
|
|
5282
|
+
restated += 1;
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
if (!isWall(judged.length, commented, restated, options)) return;
|
|
5286
|
+
context.report({
|
|
5287
|
+
node,
|
|
5288
|
+
loc: {
|
|
5289
|
+
start: node.loc.start,
|
|
5290
|
+
end: { line: node.loc.start.line, column: node.loc.start.column + 1 }
|
|
5291
|
+
},
|
|
5292
|
+
messageId: "commentWall",
|
|
5293
|
+
data: { restated: String(restated), commented: String(commented) }
|
|
5294
|
+
});
|
|
5295
|
+
}
|
|
5296
|
+
return {
|
|
5297
|
+
ClassBody: (node) => {
|
|
5298
|
+
check(node, node.body);
|
|
5299
|
+
},
|
|
5300
|
+
TSEnumDeclaration: (node) => {
|
|
5301
|
+
check(node, node.body.members);
|
|
5302
|
+
}
|
|
5303
|
+
};
|
|
5304
|
+
}
|
|
5305
|
+
});
|
|
5306
|
+
|
|
5307
|
+
// src/rules/no-type-member-comment-wall.ts
|
|
5308
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5309
|
+
function isNamedMember(node) {
|
|
5310
|
+
return (node.type === import_utils36.AST_NODE_TYPES.TSPropertySignature || node.type === import_utils36.AST_NODE_TYPES.TSMethodSignature) && !node.computed;
|
|
5311
|
+
}
|
|
5100
5312
|
var no_type_member_comment_wall_default = createRule({
|
|
5101
5313
|
name: "no-type-member-comment-wall",
|
|
5102
5314
|
meta: {
|
|
@@ -5104,45 +5316,16 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5104
5316
|
docs: {
|
|
5105
5317
|
description: "Flag an object type whose member comments mostly re-spell the members' own names and types."
|
|
5106
5318
|
},
|
|
5107
|
-
schema: [
|
|
5108
|
-
{
|
|
5109
|
-
type: "object",
|
|
5110
|
-
additionalProperties: false,
|
|
5111
|
-
properties: {
|
|
5112
|
-
minCommentedMembers: {
|
|
5113
|
-
type: "integer",
|
|
5114
|
-
minimum: 2,
|
|
5115
|
-
description: "Fewest commented members that can count as a wall."
|
|
5116
|
-
},
|
|
5117
|
-
minCommentedRatio: {
|
|
5118
|
-
type: "number",
|
|
5119
|
-
minimum: 0,
|
|
5120
|
-
maximum: 1,
|
|
5121
|
-
description: "Least share of the type's members that must be commented; below it the comments are group labels."
|
|
5122
|
-
},
|
|
5123
|
-
minRestatedRatio: {
|
|
5124
|
-
type: "number",
|
|
5125
|
-
minimum: 0,
|
|
5126
|
-
maximum: 1,
|
|
5127
|
-
description: "Least share of the member comments that must be restatements."
|
|
5128
|
-
},
|
|
5129
|
-
maxNovelWords: {
|
|
5130
|
-
type: "integer",
|
|
5131
|
-
minimum: 0,
|
|
5132
|
-
description: "Most content words a comment may add beyond its member's own source and still count as a restatement."
|
|
5133
|
-
}
|
|
5134
|
-
}
|
|
5135
|
-
}
|
|
5136
|
-
],
|
|
5319
|
+
schema: [WALL_SCHEMA],
|
|
5137
5320
|
messages: {
|
|
5138
5321
|
commentWall: "{{restated}} of this type's {{commented}} member comments only re-spell the member's own name and type \u2014 delete them, and keep the rows that say what the name cannot."
|
|
5139
5322
|
}
|
|
5140
5323
|
},
|
|
5141
|
-
defaultOptions: [
|
|
5324
|
+
defaultOptions: [WALL_DEFAULTS],
|
|
5142
5325
|
create(context, [provided]) {
|
|
5143
|
-
const options = { ...
|
|
5326
|
+
const options = { ...WALL_DEFAULTS, ...provided };
|
|
5144
5327
|
const sourceCode = context.sourceCode;
|
|
5145
|
-
if (isGeneratedFile(context.filename, sourceCode.text) || isTestFile(context.filename) || isStoryFile(context.filename)) {
|
|
5328
|
+
if (isGeneratedFile(context.filename, sourceCode.text, ["externalTree"]) || isTestFile(context.filename, ["fixtureTree"]) || isStoryFile(context.filename, ["storyTree"])) {
|
|
5146
5329
|
return {};
|
|
5147
5330
|
}
|
|
5148
5331
|
const endingOn = /* @__PURE__ */ new Map();
|
|
@@ -5171,10 +5354,10 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5171
5354
|
return headsRun || lineAbove !== void 0 && lineAbove.trim().length === 0;
|
|
5172
5355
|
}
|
|
5173
5356
|
function check(node) {
|
|
5174
|
-
const members = node.type ===
|
|
5175
|
-
const
|
|
5176
|
-
if (
|
|
5177
|
-
const documented =
|
|
5357
|
+
const members = node.type === import_utils36.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
|
5358
|
+
const named2 = members.filter(isNamedMember);
|
|
5359
|
+
if (named2.length === 0) return;
|
|
5360
|
+
const documented = named2.map((member) => ({ member, comment: documentingComment(member) }));
|
|
5178
5361
|
let commented = 0;
|
|
5179
5362
|
let restated = 0;
|
|
5180
5363
|
const claimed = /* @__PURE__ */ new Set();
|
|
@@ -5192,9 +5375,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5192
5375
|
restated += 1;
|
|
5193
5376
|
}
|
|
5194
5377
|
}
|
|
5195
|
-
if (
|
|
5196
|
-
return;
|
|
5197
|
-
}
|
|
5378
|
+
if (!isWall(named2.length, commented, restated, options)) return;
|
|
5198
5379
|
context.report({
|
|
5199
5380
|
node,
|
|
5200
5381
|
loc: {
|
|
@@ -5213,7 +5394,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
5213
5394
|
});
|
|
5214
5395
|
|
|
5215
5396
|
// src/rules/no-unnecessary-use-client.ts
|
|
5216
|
-
var
|
|
5397
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5217
5398
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
5218
5399
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
5219
5400
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -5239,13 +5420,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
5239
5420
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
5240
5421
|
var jsxRootName = (name) => {
|
|
5241
5422
|
let current = name;
|
|
5242
|
-
while (current.type ===
|
|
5423
|
+
while (current.type === import_utils37.AST_NODE_TYPES.JSXMemberExpression) {
|
|
5243
5424
|
current = current.object;
|
|
5244
5425
|
}
|
|
5245
|
-
return current.type ===
|
|
5426
|
+
return current.type === import_utils37.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
5246
5427
|
};
|
|
5247
5428
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
5248
|
-
if (node.type ===
|
|
5429
|
+
if (node.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
5249
5430
|
return imported.has(node.name);
|
|
5250
5431
|
}
|
|
5251
5432
|
for (const key of Object.keys(node)) {
|
|
@@ -5260,16 +5441,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
5260
5441
|
return false;
|
|
5261
5442
|
};
|
|
5262
5443
|
var isUseClientDirective = (node) => {
|
|
5263
|
-
return node.type ===
|
|
5444
|
+
return node.type === import_utils37.AST_NODE_TYPES.ExpressionStatement && node.expression.type === import_utils37.AST_NODE_TYPES.Literal && node.expression.value === "use client";
|
|
5264
5445
|
};
|
|
5265
5446
|
var isGlobalReference = (node, context) => {
|
|
5266
5447
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
5267
5448
|
const parent = node.parent;
|
|
5268
5449
|
if (parent !== void 0) {
|
|
5269
|
-
if (parent.type ===
|
|
5450
|
+
if (parent.type === import_utils37.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
5270
5451
|
return false;
|
|
5271
5452
|
}
|
|
5272
|
-
if (parent.type ===
|
|
5453
|
+
if (parent.type === import_utils37.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
5273
5454
|
return false;
|
|
5274
5455
|
}
|
|
5275
5456
|
if (parent.type.startsWith("TS")) {
|
|
@@ -5309,13 +5490,13 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5309
5490
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
5310
5491
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
5311
5492
|
const markIfHookOrContext = (callee) => {
|
|
5312
|
-
if (callee.type ===
|
|
5493
|
+
if (callee.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
5313
5494
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
5314
5495
|
hasClientIndicator = true;
|
|
5315
5496
|
}
|
|
5316
5497
|
return;
|
|
5317
5498
|
}
|
|
5318
|
-
if (callee.type ===
|
|
5499
|
+
if (callee.type === import_utils37.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
5319
5500
|
const name = callee.property.name;
|
|
5320
5501
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
5321
5502
|
hasClientIndicator = true;
|
|
@@ -5325,7 +5506,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5325
5506
|
return {
|
|
5326
5507
|
Program(node) {
|
|
5327
5508
|
for (const stmt of node.body) {
|
|
5328
|
-
if (stmt.type !==
|
|
5509
|
+
if (stmt.type !== import_utils37.AST_NODE_TYPES.ExpressionStatement) break;
|
|
5329
5510
|
if (isUseClientDirective(stmt)) {
|
|
5330
5511
|
directiveNode = stmt;
|
|
5331
5512
|
break;
|
|
@@ -5338,7 +5519,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5338
5519
|
},
|
|
5339
5520
|
JSXAttribute(node) {
|
|
5340
5521
|
if (directiveNode === null) return;
|
|
5341
|
-
if (node.name.type ===
|
|
5522
|
+
if (node.name.type === import_utils37.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
5342
5523
|
hasClientIndicator = true;
|
|
5343
5524
|
}
|
|
5344
5525
|
},
|
|
@@ -5405,18 +5586,18 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
5405
5586
|
});
|
|
5406
5587
|
|
|
5407
5588
|
// src/rules/no-unsafe-mock-casting.ts
|
|
5408
|
-
var
|
|
5409
|
-
var
|
|
5589
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5590
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
5410
5591
|
function isMockTypeReference(node) {
|
|
5411
|
-
if (node.type !==
|
|
5592
|
+
if (node.type !== import_utils39.AST_NODE_TYPES.TSTypeReference) {
|
|
5412
5593
|
return false;
|
|
5413
5594
|
}
|
|
5414
5595
|
const typeName = node.typeName;
|
|
5415
|
-
if (typeName.type ===
|
|
5596
|
+
if (typeName.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
5416
5597
|
const name = typeName.name;
|
|
5417
5598
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
5418
5599
|
}
|
|
5419
|
-
if (typeName.type ===
|
|
5600
|
+
if (typeName.type === import_utils39.AST_NODE_TYPES.TSQualifiedName) {
|
|
5420
5601
|
const rightName = typeName.right.name;
|
|
5421
5602
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
5422
5603
|
}
|
|
@@ -5452,7 +5633,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
5452
5633
|
});
|
|
5453
5634
|
|
|
5454
5635
|
// src/rules/no-zod-native-enum.ts
|
|
5455
|
-
var
|
|
5636
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
5456
5637
|
var ts = __toESM(require("typescript"), 1);
|
|
5457
5638
|
var IGNORE_PATTERNS = [
|
|
5458
5639
|
/[\\/]generated[\\/]/,
|
|
@@ -5470,7 +5651,7 @@ function isZodModule(source) {
|
|
|
5470
5651
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
5471
5652
|
}
|
|
5472
5653
|
function unwrap2(node) {
|
|
5473
|
-
if (node.type ===
|
|
5654
|
+
if (node.type === import_utils40.AST_NODE_TYPES.TSAsExpression || node.type === import_utils40.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
5474
5655
|
return unwrap2(node.expression);
|
|
5475
5656
|
}
|
|
5476
5657
|
return node;
|
|
@@ -5478,14 +5659,14 @@ function unwrap2(node) {
|
|
|
5478
5659
|
function stringValueTexts(node, sourceCode) {
|
|
5479
5660
|
const texts = [];
|
|
5480
5661
|
for (const prop of node.properties) {
|
|
5481
|
-
if (prop.type !==
|
|
5662
|
+
if (prop.type !== import_utils40.AST_NODE_TYPES.Property) {
|
|
5482
5663
|
return null;
|
|
5483
5664
|
}
|
|
5484
5665
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
5485
5666
|
return null;
|
|
5486
5667
|
}
|
|
5487
5668
|
const value = prop.value;
|
|
5488
|
-
if (value.type !==
|
|
5669
|
+
if (value.type !== import_utils40.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
5489
5670
|
return null;
|
|
5490
5671
|
}
|
|
5491
5672
|
const text = sourceCode.getText(value);
|
|
@@ -5501,7 +5682,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
5501
5682
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
5502
5683
|
if (variable !== void 0) {
|
|
5503
5684
|
return variable.defs.some(
|
|
5504
|
-
(def) => def.node.type ===
|
|
5685
|
+
(def) => def.node.type === import_utils40.AST_NODE_TYPES.TSEnumDeclaration
|
|
5505
5686
|
);
|
|
5506
5687
|
}
|
|
5507
5688
|
current = current.upper;
|
|
@@ -5546,32 +5727,32 @@ var no_zod_native_enum_default = createRule({
|
|
|
5546
5727
|
}
|
|
5547
5728
|
let services;
|
|
5548
5729
|
try {
|
|
5549
|
-
services =
|
|
5730
|
+
services = import_utils40.ESLintUtils.getParserServices(context);
|
|
5550
5731
|
} catch {
|
|
5551
5732
|
services = null;
|
|
5552
5733
|
}
|
|
5553
5734
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
5554
5735
|
function isZodMemberCall(node, api) {
|
|
5555
5736
|
const callee = node.callee;
|
|
5556
|
-
if (callee.type ===
|
|
5737
|
+
if (callee.type === import_utils40.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5557
5738
|
return callee.property.name === api;
|
|
5558
5739
|
}
|
|
5559
|
-
if (callee.type ===
|
|
5740
|
+
if (callee.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5560
5741
|
return zodImportedNames.get(callee.name) === api;
|
|
5561
5742
|
}
|
|
5562
5743
|
return false;
|
|
5563
5744
|
}
|
|
5564
5745
|
function buildFix(node) {
|
|
5565
5746
|
const callee = node.callee;
|
|
5566
|
-
if (callee.type !==
|
|
5747
|
+
if (callee.type !== import_utils40.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5567
5748
|
return null;
|
|
5568
5749
|
}
|
|
5569
5750
|
const arg = node.arguments[0];
|
|
5570
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
5751
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === import_utils40.AST_NODE_TYPES.SpreadElement) {
|
|
5571
5752
|
return null;
|
|
5572
5753
|
}
|
|
5573
5754
|
const inner = unwrap2(arg);
|
|
5574
|
-
if (inner.type !==
|
|
5755
|
+
if (inner.type !== import_utils40.AST_NODE_TYPES.ObjectExpression) {
|
|
5575
5756
|
return null;
|
|
5576
5757
|
}
|
|
5577
5758
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -5591,7 +5772,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5591
5772
|
return;
|
|
5592
5773
|
}
|
|
5593
5774
|
for (const spec of node.specifiers) {
|
|
5594
|
-
if (spec.type ===
|
|
5775
|
+
if (spec.type === import_utils40.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5595
5776
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
5596
5777
|
}
|
|
5597
5778
|
}
|
|
@@ -5610,7 +5791,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5610
5791
|
return;
|
|
5611
5792
|
}
|
|
5612
5793
|
const arg = node.arguments[0];
|
|
5613
|
-
if (arg === void 0 || arg.type !==
|
|
5794
|
+
if (arg === void 0 || arg.type !== import_utils40.AST_NODE_TYPES.Identifier) {
|
|
5614
5795
|
return;
|
|
5615
5796
|
}
|
|
5616
5797
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -5627,7 +5808,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
5627
5808
|
});
|
|
5628
5809
|
|
|
5629
5810
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
5630
|
-
var
|
|
5811
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
5631
5812
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
5632
5813
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
5633
5814
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -5640,36 +5821,36 @@ function isConstantReference(identifier) {
|
|
|
5640
5821
|
}
|
|
5641
5822
|
function isExcludedOperand(node) {
|
|
5642
5823
|
switch (node.type) {
|
|
5643
|
-
case
|
|
5824
|
+
case import_utils41.AST_NODE_TYPES.Literal:
|
|
5644
5825
|
return true;
|
|
5645
|
-
case
|
|
5826
|
+
case import_utils41.AST_NODE_TYPES.TemplateLiteral:
|
|
5646
5827
|
return node.expressions.length === 0;
|
|
5647
|
-
case
|
|
5828
|
+
case import_utils41.AST_NODE_TYPES.Identifier:
|
|
5648
5829
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
5649
|
-
case
|
|
5650
|
-
return !node.computed && node.property.type ===
|
|
5830
|
+
case import_utils41.AST_NODE_TYPES.MemberExpression:
|
|
5831
|
+
return !node.computed && node.property.type === import_utils41.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
5651
5832
|
default:
|
|
5652
5833
|
return false;
|
|
5653
5834
|
}
|
|
5654
5835
|
}
|
|
5655
5836
|
function operandName(node) {
|
|
5656
|
-
if (node.type ===
|
|
5837
|
+
if (node.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5657
5838
|
return node.name;
|
|
5658
5839
|
}
|
|
5659
|
-
if (node.type ===
|
|
5840
|
+
if (node.type === import_utils41.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
5660
5841
|
return node.property.name;
|
|
5661
5842
|
}
|
|
5662
5843
|
return null;
|
|
5663
5844
|
}
|
|
5664
5845
|
function isSecretOperand(node) {
|
|
5665
|
-
if (node.type ===
|
|
5846
|
+
if (node.type === import_utils41.AST_NODE_TYPES.TemplateLiteral) {
|
|
5666
5847
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
5667
5848
|
}
|
|
5668
5849
|
const name = operandName(node);
|
|
5669
5850
|
return name !== null && isAuthSecretName(name);
|
|
5670
5851
|
}
|
|
5671
5852
|
function secretNameOf(node) {
|
|
5672
|
-
if (node.type ===
|
|
5853
|
+
if (node.type === import_utils41.AST_NODE_TYPES.TemplateLiteral) {
|
|
5673
5854
|
for (const expression of node.expressions) {
|
|
5674
5855
|
const nested = secretNameOf(expression);
|
|
5675
5856
|
if (nested !== null) {
|
|
@@ -5721,8 +5902,8 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
5721
5902
|
});
|
|
5722
5903
|
|
|
5723
5904
|
// src/rules/prefer-discriminated-union.ts
|
|
5724
|
-
var
|
|
5725
|
-
var
|
|
5905
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
5906
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
5726
5907
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
5727
5908
|
"success",
|
|
5728
5909
|
"ok",
|
|
@@ -5732,27 +5913,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
5732
5913
|
]);
|
|
5733
5914
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
5734
5915
|
function getMemberName(member) {
|
|
5735
|
-
if (member.type !==
|
|
5916
|
+
if (member.type !== import_utils43.AST_NODE_TYPES.TSPropertySignature) {
|
|
5736
5917
|
return null;
|
|
5737
5918
|
}
|
|
5738
5919
|
const { key } = member;
|
|
5739
|
-
if (key.type ===
|
|
5920
|
+
if (key.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
5740
5921
|
return key.name;
|
|
5741
5922
|
}
|
|
5742
|
-
if (key.type ===
|
|
5923
|
+
if (key.type === import_utils43.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
5743
5924
|
return key.value;
|
|
5744
5925
|
}
|
|
5745
5926
|
return null;
|
|
5746
5927
|
}
|
|
5747
5928
|
function isBooleanTyped(member) {
|
|
5748
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
5929
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils43.AST_NODE_TYPES.TSBooleanKeyword;
|
|
5749
5930
|
}
|
|
5750
5931
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
5751
5932
|
let hasStatusBoolean = false;
|
|
5752
5933
|
let optionalCount = 0;
|
|
5753
5934
|
let optionalPayloadCount = 0;
|
|
5754
5935
|
for (const member of typeLiteral.members) {
|
|
5755
|
-
if (member.type !==
|
|
5936
|
+
if (member.type !== import_utils43.AST_NODE_TYPES.TSPropertySignature) {
|
|
5756
5937
|
continue;
|
|
5757
5938
|
}
|
|
5758
5939
|
if (member.optional) {
|
|
@@ -5794,7 +5975,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
5794
5975
|
TSInterfaceDeclaration(node) {
|
|
5795
5976
|
const synthetic = {
|
|
5796
5977
|
...node.body,
|
|
5797
|
-
type:
|
|
5978
|
+
type: import_utils43.AST_NODE_TYPES.TSTypeLiteral,
|
|
5798
5979
|
members: node.body.body
|
|
5799
5980
|
};
|
|
5800
5981
|
checkTypeLiteral(synthetic, node);
|
|
@@ -5807,7 +5988,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
5807
5988
|
});
|
|
5808
5989
|
|
|
5809
5990
|
// src/rules/prefer-module-level-constant.ts
|
|
5810
|
-
var
|
|
5991
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
5811
5992
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
5812
5993
|
var MAX_LITERAL_DEPTH = 4;
|
|
5813
5994
|
var IGNORE_PATTERNS2 = [
|
|
@@ -5836,9 +6017,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
5836
6017
|
"assign"
|
|
5837
6018
|
]);
|
|
5838
6019
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
6020
|
+
import_utils44.AST_NODE_TYPES.FunctionDeclaration,
|
|
6021
|
+
import_utils44.AST_NODE_TYPES.FunctionExpression,
|
|
6022
|
+
import_utils44.AST_NODE_TYPES.ArrowFunctionExpression
|
|
5842
6023
|
]);
|
|
5843
6024
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
5844
6025
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -5851,14 +6032,14 @@ function isLocalFixtureFile(filename) {
|
|
|
5851
6032
|
return isTestFile(filename) || isStoryFile(filename);
|
|
5852
6033
|
}
|
|
5853
6034
|
function unwrap3(node) {
|
|
5854
|
-
if (node.type ===
|
|
6035
|
+
if (node.type === import_utils44.AST_NODE_TYPES.TSAsExpression || node.type === import_utils44.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils44.AST_NODE_TYPES.TSNonNullExpression) {
|
|
5855
6036
|
return unwrap3(node.expression);
|
|
5856
6037
|
}
|
|
5857
6038
|
return node;
|
|
5858
6039
|
}
|
|
5859
6040
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
5860
6041
|
function isRegexLiteral(node) {
|
|
5861
|
-
return node.type ===
|
|
6042
|
+
return node.type === import_utils44.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
5862
6043
|
}
|
|
5863
6044
|
function isLiteralOnly(node, depth) {
|
|
5864
6045
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -5866,29 +6047,29 @@ function isLiteralOnly(node, depth) {
|
|
|
5866
6047
|
}
|
|
5867
6048
|
const inner = unwrap3(node);
|
|
5868
6049
|
switch (inner.type) {
|
|
5869
|
-
case
|
|
6050
|
+
case import_utils44.AST_NODE_TYPES.Literal: {
|
|
5870
6051
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
5871
6052
|
}
|
|
5872
|
-
case
|
|
6053
|
+
case import_utils44.AST_NODE_TYPES.TemplateLiteral: {
|
|
5873
6054
|
return inner.expressions.length === 0;
|
|
5874
6055
|
}
|
|
5875
|
-
case
|
|
5876
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6056
|
+
case import_utils44.AST_NODE_TYPES.UnaryExpression: {
|
|
6057
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils44.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
5877
6058
|
}
|
|
5878
|
-
case
|
|
6059
|
+
case import_utils44.AST_NODE_TYPES.ArrayExpression: {
|
|
5879
6060
|
return inner.elements.every(
|
|
5880
|
-
(el) => el !== null && el.type !==
|
|
6061
|
+
(el) => el !== null && el.type !== import_utils44.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
5881
6062
|
);
|
|
5882
6063
|
}
|
|
5883
|
-
case
|
|
6064
|
+
case import_utils44.AST_NODE_TYPES.ObjectExpression: {
|
|
5884
6065
|
return inner.properties.every((prop) => {
|
|
5885
|
-
if (prop.type !==
|
|
6066
|
+
if (prop.type !== import_utils44.AST_NODE_TYPES.Property) {
|
|
5886
6067
|
return false;
|
|
5887
6068
|
}
|
|
5888
6069
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
5889
6070
|
return false;
|
|
5890
6071
|
}
|
|
5891
|
-
if (prop.computed && prop.key.type !==
|
|
6072
|
+
if (prop.computed && prop.key.type !== import_utils44.AST_NODE_TYPES.Literal) {
|
|
5892
6073
|
return false;
|
|
5893
6074
|
}
|
|
5894
6075
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -5901,7 +6082,7 @@ function isLiteralOnly(node, depth) {
|
|
|
5901
6082
|
}
|
|
5902
6083
|
function unwrapObjectFreeze(node) {
|
|
5903
6084
|
const inner = unwrap3(node);
|
|
5904
|
-
if (inner.type ===
|
|
6085
|
+
if (inner.type === import_utils44.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils44.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils44.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils44.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils44.AST_NODE_TYPES.SpreadElement) {
|
|
5905
6086
|
return unwrap3(inner.arguments[0]);
|
|
5906
6087
|
}
|
|
5907
6088
|
return inner;
|
|
@@ -5917,19 +6098,19 @@ function classify(init, checkRegex) {
|
|
|
5917
6098
|
}
|
|
5918
6099
|
return { kind: "regex", size: 1 };
|
|
5919
6100
|
}
|
|
5920
|
-
if (node.type ===
|
|
6101
|
+
if (node.type === import_utils44.AST_NODE_TYPES.ArrayExpression) {
|
|
5921
6102
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
5922
6103
|
}
|
|
5923
|
-
if (node.type ===
|
|
6104
|
+
if (node.type === import_utils44.AST_NODE_TYPES.ObjectExpression) {
|
|
5924
6105
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
5925
6106
|
}
|
|
5926
|
-
if (node.type ===
|
|
6107
|
+
if (node.type === import_utils44.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils44.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
5927
6108
|
const arg = node.arguments[0];
|
|
5928
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6109
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils44.AST_NODE_TYPES.SpreadElement) {
|
|
5929
6110
|
return null;
|
|
5930
6111
|
}
|
|
5931
6112
|
const entries = unwrap3(arg);
|
|
5932
|
-
if (entries.type !==
|
|
6113
|
+
if (entries.type !== import_utils44.AST_NODE_TYPES.ArrayExpression) {
|
|
5933
6114
|
return null;
|
|
5934
6115
|
}
|
|
5935
6116
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -5958,10 +6139,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
5958
6139
|
);
|
|
5959
6140
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
5960
6141
|
const callee = node.callee;
|
|
5961
|
-
if (callee.type ===
|
|
6142
|
+
if (callee.type === import_utils44.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
5962
6143
|
return true;
|
|
5963
6144
|
}
|
|
5964
|
-
if (callee.type !==
|
|
6145
|
+
if (callee.type !== import_utils44.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils44.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
5965
6146
|
return false;
|
|
5966
6147
|
}
|
|
5967
6148
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -5975,38 +6156,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
5975
6156
|
}
|
|
5976
6157
|
function isSafeRead(identifier) {
|
|
5977
6158
|
const parent = identifier.parent;
|
|
5978
|
-
if (parent.type ===
|
|
6159
|
+
if (parent.type === import_utils44.AST_NODE_TYPES.MemberExpression) {
|
|
5979
6160
|
if (parent.object !== identifier) {
|
|
5980
6161
|
return true;
|
|
5981
6162
|
}
|
|
5982
6163
|
const grandparent = parent.parent;
|
|
5983
|
-
if (grandparent.type ===
|
|
6164
|
+
if (grandparent.type === import_utils44.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
5984
6165
|
return false;
|
|
5985
6166
|
}
|
|
5986
|
-
if (grandparent.type ===
|
|
6167
|
+
if (grandparent.type === import_utils44.AST_NODE_TYPES.UpdateExpression) {
|
|
5987
6168
|
return false;
|
|
5988
6169
|
}
|
|
5989
|
-
if (grandparent.type ===
|
|
6170
|
+
if (grandparent.type === import_utils44.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
5990
6171
|
return false;
|
|
5991
6172
|
}
|
|
5992
|
-
if (!parent.computed && parent.property.type ===
|
|
6173
|
+
if (!parent.computed && parent.property.type === import_utils44.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils44.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
5993
6174
|
return false;
|
|
5994
6175
|
}
|
|
5995
6176
|
return true;
|
|
5996
6177
|
}
|
|
5997
|
-
if (parent.type ===
|
|
6178
|
+
if (parent.type === import_utils44.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
5998
6179
|
return true;
|
|
5999
6180
|
}
|
|
6000
|
-
if (parent.type ===
|
|
6181
|
+
if (parent.type === import_utils44.AST_NODE_TYPES.SpreadElement) {
|
|
6001
6182
|
return true;
|
|
6002
6183
|
}
|
|
6003
|
-
if (parent.type ===
|
|
6184
|
+
if (parent.type === import_utils44.AST_NODE_TYPES.BinaryExpression) {
|
|
6004
6185
|
return true;
|
|
6005
6186
|
}
|
|
6006
|
-
if (parent.type ===
|
|
6187
|
+
if (parent.type === import_utils44.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6007
6188
|
return true;
|
|
6008
6189
|
}
|
|
6009
|
-
if (parent.type ===
|
|
6190
|
+
if (parent.type === import_utils44.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6010
6191
|
return true;
|
|
6011
6192
|
}
|
|
6012
6193
|
return false;
|
|
@@ -6061,7 +6242,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6061
6242
|
if (reference.isWrite()) {
|
|
6062
6243
|
return false;
|
|
6063
6244
|
}
|
|
6064
|
-
if (reference.identifier.type !==
|
|
6245
|
+
if (reference.identifier.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6065
6246
|
return false;
|
|
6066
6247
|
}
|
|
6067
6248
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6073,10 +6254,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6073
6254
|
return {
|
|
6074
6255
|
VariableDeclarator(node) {
|
|
6075
6256
|
const declaration = node.parent;
|
|
6076
|
-
if (declaration.type !==
|
|
6257
|
+
if (declaration.type !== import_utils44.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6077
6258
|
return;
|
|
6078
6259
|
}
|
|
6079
|
-
if (node.id.type !==
|
|
6260
|
+
if (node.id.type !== import_utils44.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6080
6261
|
return;
|
|
6081
6262
|
}
|
|
6082
6263
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6103,7 +6284,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6103
6284
|
});
|
|
6104
6285
|
|
|
6105
6286
|
// src/rules/prefer-module-level-schema.ts
|
|
6106
|
-
var
|
|
6287
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
6107
6288
|
|
|
6108
6289
|
// src/rules/_zod.ts
|
|
6109
6290
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -6124,7 +6305,7 @@ var DEFAULT_FACTORIES = [
|
|
|
6124
6305
|
"tuple",
|
|
6125
6306
|
"union"
|
|
6126
6307
|
];
|
|
6127
|
-
var DEFAULT_MIN_PROPERTIES =
|
|
6308
|
+
var DEFAULT_MIN_PROPERTIES = 2;
|
|
6128
6309
|
var MEMO_CALLEES = /* @__PURE__ */ new Set([
|
|
6129
6310
|
"lazy",
|
|
6130
6311
|
"memo",
|
|
@@ -6140,10 +6321,38 @@ var TERMINAL_METHODS = /* @__PURE__ */ new Set([
|
|
|
6140
6321
|
"safeParseAsync",
|
|
6141
6322
|
"spa"
|
|
6142
6323
|
]);
|
|
6324
|
+
var ZOD_COMBINATOR_METHODS = /* @__PURE__ */ new Set([
|
|
6325
|
+
"and",
|
|
6326
|
+
"array",
|
|
6327
|
+
"catch",
|
|
6328
|
+
"catchall",
|
|
6329
|
+
"default",
|
|
6330
|
+
"extend",
|
|
6331
|
+
"merge",
|
|
6332
|
+
"or",
|
|
6333
|
+
"pipe",
|
|
6334
|
+
"refine",
|
|
6335
|
+
"superRefine",
|
|
6336
|
+
"transform"
|
|
6337
|
+
]);
|
|
6338
|
+
var I18N_CALLEE_NAMES = /* @__PURE__ */ new Set([
|
|
6339
|
+
"$t",
|
|
6340
|
+
"defineMessage",
|
|
6341
|
+
"gettext",
|
|
6342
|
+
"msg",
|
|
6343
|
+
"ngettext",
|
|
6344
|
+
"t",
|
|
6345
|
+
"translate"
|
|
6346
|
+
]);
|
|
6347
|
+
var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
6348
|
+
"$i18n",
|
|
6349
|
+
"i18n",
|
|
6350
|
+
"intl"
|
|
6351
|
+
]);
|
|
6143
6352
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6353
|
+
import_utils45.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
6354
|
+
import_utils45.AST_NODE_TYPES.FunctionDeclaration,
|
|
6355
|
+
import_utils45.AST_NODE_TYPES.FunctionExpression
|
|
6147
6356
|
]);
|
|
6148
6357
|
function schemaExpression(node) {
|
|
6149
6358
|
let current = node;
|
|
@@ -6152,10 +6361,10 @@ function schemaExpression(node) {
|
|
|
6152
6361
|
if (parent === void 0) {
|
|
6153
6362
|
return current;
|
|
6154
6363
|
}
|
|
6155
|
-
if (parent.type ===
|
|
6364
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils45.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
6156
6365
|
return current;
|
|
6157
6366
|
}
|
|
6158
|
-
if (parent.type ===
|
|
6367
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils45.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils45.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils45.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
6159
6368
|
current = parent;
|
|
6160
6369
|
continue;
|
|
6161
6370
|
}
|
|
@@ -6173,7 +6382,7 @@ function outermostEnclosingFunction(node) {
|
|
|
6173
6382
|
}
|
|
6174
6383
|
return outermost;
|
|
6175
6384
|
}
|
|
6176
|
-
function
|
|
6385
|
+
function subtreeSome(root, predicate) {
|
|
6177
6386
|
let found = false;
|
|
6178
6387
|
const visit = (value) => {
|
|
6179
6388
|
if (found || value === null || typeof value !== "object") {
|
|
@@ -6189,7 +6398,7 @@ function readsReceiver(node) {
|
|
|
6189
6398
|
if (typeof candidate.type !== "string") {
|
|
6190
6399
|
return;
|
|
6191
6400
|
}
|
|
6192
|
-
if (candidate
|
|
6401
|
+
if (predicate(candidate)) {
|
|
6193
6402
|
found = true;
|
|
6194
6403
|
return;
|
|
6195
6404
|
}
|
|
@@ -6200,9 +6409,30 @@ function readsReceiver(node) {
|
|
|
6200
6409
|
visit(candidate[key]);
|
|
6201
6410
|
}
|
|
6202
6411
|
};
|
|
6203
|
-
visit(
|
|
6412
|
+
visit(root);
|
|
6204
6413
|
return found;
|
|
6205
6414
|
}
|
|
6415
|
+
function readsReceiver(node) {
|
|
6416
|
+
return subtreeSome(
|
|
6417
|
+
node,
|
|
6418
|
+
(inner) => inner.type === import_utils45.AST_NODE_TYPES.ThisExpression || inner.type === import_utils45.AST_NODE_TYPES.Super || inner.type === import_utils45.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
6419
|
+
);
|
|
6420
|
+
}
|
|
6421
|
+
function buildsLocalizedText(node) {
|
|
6422
|
+
return subtreeSome(node, (inner) => {
|
|
6423
|
+
if (inner.type === import_utils45.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
6424
|
+
return true;
|
|
6425
|
+
}
|
|
6426
|
+
if (inner.type !== import_utils45.AST_NODE_TYPES.CallExpression) {
|
|
6427
|
+
return false;
|
|
6428
|
+
}
|
|
6429
|
+
const { callee } = inner;
|
|
6430
|
+
if (callee.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6431
|
+
return I18N_CALLEE_NAMES.has(callee.name);
|
|
6432
|
+
}
|
|
6433
|
+
return callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils45.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
6434
|
+
});
|
|
6435
|
+
}
|
|
6206
6436
|
function collectReferences(scope, out) {
|
|
6207
6437
|
out.push(...scope.references);
|
|
6208
6438
|
for (const child of scope.childScopes) {
|
|
@@ -6257,21 +6487,46 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6257
6487
|
}
|
|
6258
6488
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
6259
6489
|
function isZodCall(node) {
|
|
6260
|
-
return node.type ===
|
|
6490
|
+
return node.type === import_utils45.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils45.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
6261
6491
|
}
|
|
6262
6492
|
function isCovered(node) {
|
|
6263
6493
|
let current = node.parent ?? void 0;
|
|
6264
6494
|
while (current !== void 0) {
|
|
6265
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
6495
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils45.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
6266
6496
|
return true;
|
|
6267
6497
|
}
|
|
6268
|
-
if (current.type ===
|
|
6498
|
+
if (current.type === import_utils45.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils45.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils45.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
6269
6499
|
return true;
|
|
6270
6500
|
}
|
|
6271
6501
|
current = current.parent ?? void 0;
|
|
6272
6502
|
}
|
|
6273
6503
|
return false;
|
|
6274
6504
|
}
|
|
6505
|
+
function outermostSchemaExpression(expression) {
|
|
6506
|
+
let confirmed = expression;
|
|
6507
|
+
let current = expression;
|
|
6508
|
+
for (; ; ) {
|
|
6509
|
+
const parent = current.parent ?? void 0;
|
|
6510
|
+
if (parent === void 0) {
|
|
6511
|
+
return confirmed;
|
|
6512
|
+
}
|
|
6513
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils45.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
6514
|
+
current = parent;
|
|
6515
|
+
continue;
|
|
6516
|
+
}
|
|
6517
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
6518
|
+
current = schemaExpression(parent);
|
|
6519
|
+
confirmed = current;
|
|
6520
|
+
continue;
|
|
6521
|
+
}
|
|
6522
|
+
return confirmed;
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
function isSchemaComposition(node) {
|
|
6526
|
+
const { callee } = node;
|
|
6527
|
+
const isCombinator = callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils45.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
6528
|
+
return isCombinator || isZodCall(node);
|
|
6529
|
+
}
|
|
6275
6530
|
function closesOverNothing(node, enclosing) {
|
|
6276
6531
|
const references = [];
|
|
6277
6532
|
collectReferences(sourceCode.getScope(node), references);
|
|
@@ -6291,6 +6546,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6291
6546
|
continue;
|
|
6292
6547
|
}
|
|
6293
6548
|
const [defStart, defEnd] = definition.node.range;
|
|
6549
|
+
if (defStart >= schemaStart && defEnd <= schemaEnd) {
|
|
6550
|
+
continue;
|
|
6551
|
+
}
|
|
6294
6552
|
if (defStart >= functionStart && defEnd <= functionEnd) {
|
|
6295
6553
|
return false;
|
|
6296
6554
|
}
|
|
@@ -6300,13 +6558,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6300
6558
|
}
|
|
6301
6559
|
function ownerName(enclosing) {
|
|
6302
6560
|
const parent = enclosing.parent ?? void 0;
|
|
6303
|
-
if (enclosing.type ===
|
|
6561
|
+
if (enclosing.type === import_utils45.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
6304
6562
|
return enclosing.id.name;
|
|
6305
6563
|
}
|
|
6306
|
-
if (parent !== void 0 && parent.type ===
|
|
6564
|
+
if (parent !== void 0 && parent.type === import_utils45.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6307
6565
|
return parent.id.name;
|
|
6308
6566
|
}
|
|
6309
|
-
if (parent !== void 0 && (parent.type ===
|
|
6567
|
+
if (parent !== void 0 && (parent.type === import_utils45.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils45.AST_NODE_TYPES.Property) && parent.key.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6310
6568
|
return parent.key.name;
|
|
6311
6569
|
}
|
|
6312
6570
|
return "this function";
|
|
@@ -6317,7 +6575,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6317
6575
|
return;
|
|
6318
6576
|
}
|
|
6319
6577
|
for (const specifier of node.specifiers) {
|
|
6320
|
-
if (specifier.type ===
|
|
6578
|
+
if (specifier.type === import_utils45.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils45.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils45.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils45.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
6321
6579
|
zodNamespaces.add(specifier.local.name);
|
|
6322
6580
|
}
|
|
6323
6581
|
}
|
|
@@ -6327,7 +6585,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6327
6585
|
return;
|
|
6328
6586
|
}
|
|
6329
6587
|
const callee = node.callee;
|
|
6330
|
-
if (callee.property.type !==
|
|
6588
|
+
if (callee.property.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6331
6589
|
return;
|
|
6332
6590
|
}
|
|
6333
6591
|
const factory = callee.property.name;
|
|
@@ -6342,13 +6600,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6342
6600
|
return;
|
|
6343
6601
|
}
|
|
6344
6602
|
const shape = node.arguments[0];
|
|
6345
|
-
if (shape !== void 0 && shape.type ===
|
|
6603
|
+
if (shape !== void 0 && shape.type === import_utils45.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
6346
6604
|
return;
|
|
6347
6605
|
}
|
|
6348
6606
|
const expression = schemaExpression(node);
|
|
6349
6607
|
if (readsReceiver(expression)) {
|
|
6350
6608
|
return;
|
|
6351
6609
|
}
|
|
6610
|
+
if (buildsLocalizedText(expression)) {
|
|
6611
|
+
return;
|
|
6612
|
+
}
|
|
6613
|
+
const outermost = outermostSchemaExpression(expression);
|
|
6614
|
+
if (outermost !== expression && (readsReceiver(outermost) || buildsLocalizedText(outermost) || !closesOverNothing(outermost, enclosing))) {
|
|
6615
|
+
return;
|
|
6616
|
+
}
|
|
6352
6617
|
if (!closesOverNothing(expression, enclosing)) {
|
|
6353
6618
|
return;
|
|
6354
6619
|
}
|
|
@@ -6363,20 +6628,20 @@ var prefer_module_level_schema_default = createRule({
|
|
|
6363
6628
|
});
|
|
6364
6629
|
|
|
6365
6630
|
// src/rules/prefer-non-nullable-collection.ts
|
|
6366
|
-
var
|
|
6631
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
6367
6632
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
6368
6633
|
function propertyName(node) {
|
|
6369
6634
|
const key = node.key;
|
|
6370
|
-
if (key.type ===
|
|
6371
|
-
if (key.type ===
|
|
6635
|
+
if (key.type === import_utils46.AST_NODE_TYPES.Identifier) return key.name;
|
|
6636
|
+
if (key.type === import_utils46.AST_NODE_TYPES.Literal) return String(key.value);
|
|
6372
6637
|
return "collection";
|
|
6373
6638
|
}
|
|
6374
6639
|
function isArrayType(node) {
|
|
6375
|
-
if (node.type ===
|
|
6376
|
-
return node.type ===
|
|
6640
|
+
if (node.type === import_utils46.AST_NODE_TYPES.TSArrayType) return true;
|
|
6641
|
+
return node.type === import_utils46.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils46.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
6377
6642
|
}
|
|
6378
6643
|
function isNullishType(node) {
|
|
6379
|
-
return node.type ===
|
|
6644
|
+
return node.type === import_utils46.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils46.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
6380
6645
|
}
|
|
6381
6646
|
function isNullableArrayOnly(node) {
|
|
6382
6647
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -6403,7 +6668,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6403
6668
|
function checkOptionalProperty(node) {
|
|
6404
6669
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
6405
6670
|
if (annotation === void 0) return;
|
|
6406
|
-
if (annotation.type !==
|
|
6671
|
+
if (annotation.type !== import_utils46.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
6407
6672
|
return;
|
|
6408
6673
|
}
|
|
6409
6674
|
context.report({
|
|
@@ -6416,7 +6681,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6416
6681
|
TSPropertySignature: checkOptionalProperty,
|
|
6417
6682
|
PropertyDefinition: checkOptionalProperty,
|
|
6418
6683
|
TSTypeAliasDeclaration(node) {
|
|
6419
|
-
if (node.typeAnnotation.type !==
|
|
6684
|
+
if (node.typeAnnotation.type !== import_utils46.AST_NODE_TYPES.TSUnionType) return;
|
|
6420
6685
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
6421
6686
|
context.report({
|
|
6422
6687
|
node,
|
|
@@ -6429,13 +6694,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
6429
6694
|
});
|
|
6430
6695
|
|
|
6431
6696
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
6432
|
-
var
|
|
6697
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
6433
6698
|
var unwrap4 = (node) => {
|
|
6434
6699
|
let current = node;
|
|
6435
6700
|
while (current !== null && current !== void 0) {
|
|
6436
|
-
if (current.type ===
|
|
6701
|
+
if (current.type === import_utils47.AST_NODE_TYPES.TSAsExpression || current.type === import_utils47.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils47.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils47.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6437
6702
|
current = current.expression;
|
|
6438
|
-
} else if (current.type ===
|
|
6703
|
+
} else if (current.type === import_utils47.AST_NODE_TYPES.ChainExpression) {
|
|
6439
6704
|
current = current.expression;
|
|
6440
6705
|
} else {
|
|
6441
6706
|
break;
|
|
@@ -6450,23 +6715,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
6450
6715
|
]);
|
|
6451
6716
|
var isSchemaParseReference = (node) => {
|
|
6452
6717
|
const inner = unwrap4(node);
|
|
6453
|
-
return inner !== null && inner.type ===
|
|
6718
|
+
return inner !== null && inner.type === import_utils47.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils47.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
6454
6719
|
};
|
|
6455
6720
|
var isRawPayloadSource = (node) => {
|
|
6456
6721
|
let current = unwrap4(node);
|
|
6457
6722
|
if (current === null) return false;
|
|
6458
|
-
if (current.type ===
|
|
6723
|
+
if (current.type === import_utils47.AST_NODE_TYPES.AwaitExpression) {
|
|
6459
6724
|
current = unwrap4(current.argument);
|
|
6460
6725
|
}
|
|
6461
|
-
if (current === null || current.type !==
|
|
6726
|
+
if (current === null || current.type !== import_utils47.AST_NODE_TYPES.CallExpression) {
|
|
6462
6727
|
return false;
|
|
6463
6728
|
}
|
|
6464
6729
|
const callee = unwrap4(current.callee);
|
|
6465
|
-
if (callee === null || callee.type !==
|
|
6730
|
+
if (callee === null || callee.type !== import_utils47.AST_NODE_TYPES.MemberExpression) {
|
|
6466
6731
|
return false;
|
|
6467
6732
|
}
|
|
6468
6733
|
const property = unwrap4(callee.property);
|
|
6469
|
-
if (property === null || property.type !==
|
|
6734
|
+
if (property === null || property.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6470
6735
|
return false;
|
|
6471
6736
|
}
|
|
6472
6737
|
if (property.name === "json") {
|
|
@@ -6476,7 +6741,7 @@ var isRawPayloadSource = (node) => {
|
|
|
6476
6741
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
6477
6742
|
}
|
|
6478
6743
|
const object = unwrap4(callee.object);
|
|
6479
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
6744
|
+
return property.name === "parse" && object !== null && object.type === import_utils47.AST_NODE_TYPES.Identifier && object.name === "JSON" && // ...but not `JSON.parse(readFileSync(p, "utf8"))` — see isLocalFileRead.
|
|
6480
6745
|
!isLocalFileRead(current.arguments[0]);
|
|
6481
6746
|
};
|
|
6482
6747
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
@@ -6484,9 +6749,9 @@ var isLocalFileRead = (node) => {
|
|
|
6484
6749
|
let found = false;
|
|
6485
6750
|
const visit = (current) => {
|
|
6486
6751
|
if (found || current === null || current === void 0) return;
|
|
6487
|
-
if (current.type ===
|
|
6752
|
+
if (current.type === import_utils47.AST_NODE_TYPES.CallExpression) {
|
|
6488
6753
|
const callee = unwrap4(current.callee);
|
|
6489
|
-
const name = callee?.type ===
|
|
6754
|
+
const name = callee?.type === import_utils47.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils47.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils47.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
6490
6755
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
6491
6756
|
found = true;
|
|
6492
6757
|
return;
|
|
@@ -6508,15 +6773,15 @@ var isLocalFileRead = (node) => {
|
|
|
6508
6773
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
6509
6774
|
var isInsideAssertion = (node) => {
|
|
6510
6775
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
6511
|
-
if (current.type !==
|
|
6776
|
+
if (current.type !== import_utils47.AST_NODE_TYPES.CallExpression) continue;
|
|
6512
6777
|
let callee = current.callee;
|
|
6513
|
-
while (callee.type ===
|
|
6778
|
+
while (callee.type === import_utils47.AST_NODE_TYPES.MemberExpression) {
|
|
6514
6779
|
callee = callee.object;
|
|
6515
6780
|
}
|
|
6516
|
-
if (callee.type ===
|
|
6781
|
+
if (callee.type === import_utils47.AST_NODE_TYPES.CallExpression) {
|
|
6517
6782
|
callee = callee.callee;
|
|
6518
6783
|
}
|
|
6519
|
-
if (callee.type ===
|
|
6784
|
+
if (callee.type === import_utils47.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
6520
6785
|
return true;
|
|
6521
6786
|
}
|
|
6522
6787
|
}
|
|
@@ -6535,39 +6800,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
6535
6800
|
var isValidationRead = (node) => {
|
|
6536
6801
|
let current = node;
|
|
6537
6802
|
let parent = current.parent;
|
|
6538
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
6803
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils47.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils47.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils47.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils47.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils47.AST_NODE_TYPES.ChainExpression)) {
|
|
6539
6804
|
current = parent;
|
|
6540
6805
|
parent = parent.parent;
|
|
6541
6806
|
}
|
|
6542
6807
|
if (parent === null || parent === void 0) return false;
|
|
6543
|
-
if (parent.type ===
|
|
6808
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
6544
6809
|
return true;
|
|
6545
6810
|
}
|
|
6546
|
-
if (parent.type !==
|
|
6811
|
+
if (parent.type !== import_utils47.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
6547
6812
|
return false;
|
|
6548
6813
|
}
|
|
6549
6814
|
const callee = parent.callee;
|
|
6550
|
-
if (callee.type ===
|
|
6815
|
+
if (callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils47.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
6551
6816
|
return parent.arguments.length === 1;
|
|
6552
6817
|
}
|
|
6553
|
-
return callee.type ===
|
|
6818
|
+
return callee.type === import_utils47.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
6554
6819
|
};
|
|
6555
6820
|
var isGuardTestPosition = (node) => {
|
|
6556
6821
|
let current = node;
|
|
6557
6822
|
let parent = current.parent;
|
|
6558
6823
|
while (parent !== void 0 && parent !== null) {
|
|
6559
6824
|
switch (parent.type) {
|
|
6560
|
-
case
|
|
6561
|
-
case
|
|
6562
|
-
case
|
|
6825
|
+
case import_utils47.AST_NODE_TYPES.UnaryExpression:
|
|
6826
|
+
case import_utils47.AST_NODE_TYPES.LogicalExpression:
|
|
6827
|
+
case import_utils47.AST_NODE_TYPES.ChainExpression:
|
|
6563
6828
|
current = parent;
|
|
6564
6829
|
parent = parent.parent;
|
|
6565
6830
|
continue;
|
|
6566
|
-
case
|
|
6567
|
-
case
|
|
6568
|
-
case
|
|
6569
|
-
case
|
|
6570
|
-
case
|
|
6831
|
+
case import_utils47.AST_NODE_TYPES.IfStatement:
|
|
6832
|
+
case import_utils47.AST_NODE_TYPES.ConditionalExpression:
|
|
6833
|
+
case import_utils47.AST_NODE_TYPES.WhileStatement:
|
|
6834
|
+
case import_utils47.AST_NODE_TYPES.DoWhileStatement:
|
|
6835
|
+
case import_utils47.AST_NODE_TYPES.ForStatement:
|
|
6571
6836
|
return parent.test === current;
|
|
6572
6837
|
default:
|
|
6573
6838
|
return false;
|
|
@@ -6577,7 +6842,7 @@ var isGuardTestPosition = (node) => {
|
|
|
6577
6842
|
};
|
|
6578
6843
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
6579
6844
|
const unwrapped = unwrap4(node);
|
|
6580
|
-
if (unwrapped === null || unwrapped.type !==
|
|
6845
|
+
if (unwrapped === null || unwrapped.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6581
6846
|
return false;
|
|
6582
6847
|
}
|
|
6583
6848
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -6620,11 +6885,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6620
6885
|
return {
|
|
6621
6886
|
VariableDeclarator(node) {
|
|
6622
6887
|
const scope = context.sourceCode.getScope(node);
|
|
6623
|
-
if (node.id.type ===
|
|
6888
|
+
if (node.id.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6624
6889
|
trackInitializer(node);
|
|
6625
6890
|
return;
|
|
6626
6891
|
}
|
|
6627
|
-
if (node.id.type ===
|
|
6892
|
+
if (node.id.type === import_utils47.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils47.AST_NODE_TYPES.ArrayPattern) {
|
|
6628
6893
|
if (isRawPayloadSource(node.init)) {
|
|
6629
6894
|
if (!isFullyNarrowedPattern(node)) {
|
|
6630
6895
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -6638,7 +6903,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6638
6903
|
},
|
|
6639
6904
|
AssignmentExpression(node) {
|
|
6640
6905
|
const scope = context.sourceCode.getScope(node);
|
|
6641
|
-
if (node.left.type ===
|
|
6906
|
+
if (node.left.type === import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6642
6907
|
const variable = findVariable2(scope, node.left.name);
|
|
6643
6908
|
if (variable === null) return;
|
|
6644
6909
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -6648,7 +6913,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6648
6913
|
}
|
|
6649
6914
|
return;
|
|
6650
6915
|
}
|
|
6651
|
-
if (node.left.type ===
|
|
6916
|
+
if (node.left.type === import_utils47.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils47.AST_NODE_TYPES.ArrayPattern) {
|
|
6652
6917
|
if (isRawPayloadSource(node.right)) {
|
|
6653
6918
|
context.report({
|
|
6654
6919
|
node: node.left,
|
|
@@ -6665,15 +6930,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6665
6930
|
}
|
|
6666
6931
|
},
|
|
6667
6932
|
CallExpression(node) {
|
|
6668
|
-
if (node.callee.type !==
|
|
6933
|
+
if (node.callee.type !== import_utils47.AST_NODE_TYPES.Identifier) return;
|
|
6669
6934
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
6670
6935
|
return;
|
|
6671
6936
|
}
|
|
6672
6937
|
const scope = context.sourceCode.getScope(node);
|
|
6673
6938
|
for (const arg of node.arguments) {
|
|
6674
|
-
if (arg.type ===
|
|
6939
|
+
if (arg.type === import_utils47.AST_NODE_TYPES.SpreadElement) continue;
|
|
6675
6940
|
const unwrapped = unwrap4(arg);
|
|
6676
|
-
if (unwrapped === null || unwrapped.type !==
|
|
6941
|
+
if (unwrapped === null || unwrapped.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
6677
6942
|
continue;
|
|
6678
6943
|
}
|
|
6679
6944
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -6687,13 +6952,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6687
6952
|
const obj = unwrap4(node.object);
|
|
6688
6953
|
if (isRawPayloadSource(obj)) {
|
|
6689
6954
|
const parent = node.parent;
|
|
6690
|
-
if (parent.type ===
|
|
6955
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils47.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
6691
6956
|
return;
|
|
6692
6957
|
}
|
|
6693
6958
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
6694
6959
|
return;
|
|
6695
6960
|
}
|
|
6696
|
-
if (obj !== null && obj.type ===
|
|
6961
|
+
if (obj !== null && obj.type === import_utils47.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
6697
6962
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
6698
6963
|
const variable = findVariable2(scope, obj.name);
|
|
6699
6964
|
if (variable !== null) {
|
|
@@ -6706,7 +6971,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
6706
6971
|
});
|
|
6707
6972
|
|
|
6708
6973
|
// src/rules/prefer-semantic-colors.ts
|
|
6709
|
-
var
|
|
6974
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
6710
6975
|
var import_fs = require("fs");
|
|
6711
6976
|
var import_path = require("path");
|
|
6712
6977
|
|
|
@@ -6748,7 +7013,14 @@ var STYLE_COLOR_PROPS = /* @__PURE__ */ new Set([
|
|
|
6748
7013
|
var RAW_COLOR_VALUE_RE = new RegExp(`#[0-9a-fA-F]{3,8}\\b|\\b(?:${COLOR_FN})\\s*\\(`, "i");
|
|
6749
7014
|
var CSS_VAR_REFERENCE_RE = /var\(\s*--/;
|
|
6750
7015
|
var STORIES_FILE_RE = /\.stories\.[cm]?[jt]sx?$/i;
|
|
6751
|
-
var SEMANTIC_TOKEN_RE =
|
|
7016
|
+
var SEMANTIC_TOKEN_RE = /@theme\b|--(?:background|foreground|primary|secondary|muted|accent|destructive|border|card|popover)\b|(?:bg|text|border)-(?:background|foreground|primary|secondary|muted|accent|destructive|border|card|popover)\b/;
|
|
7017
|
+
var CONFIG_IS_SUFFICIENT = /* @__PURE__ */ new Set([
|
|
7018
|
+
"components.json",
|
|
7019
|
+
"tailwind.config.cjs",
|
|
7020
|
+
"tailwind.config.js",
|
|
7021
|
+
"tailwind.config.mjs",
|
|
7022
|
+
"tailwind.config.ts"
|
|
7023
|
+
]);
|
|
6752
7024
|
var DETECTION_FILES = [
|
|
6753
7025
|
"components.json",
|
|
6754
7026
|
"tailwind.config.js",
|
|
@@ -6761,8 +7033,17 @@ var DETECTION_FILES = [
|
|
|
6761
7033
|
"src/styles/globals.css",
|
|
6762
7034
|
"styles/globals.css"
|
|
6763
7035
|
];
|
|
6764
|
-
var
|
|
6765
|
-
|
|
7036
|
+
var WORKSPACE_ROOT_FILES = [
|
|
7037
|
+
"pnpm-workspace.yaml",
|
|
7038
|
+
"pnpm-workspace.yml",
|
|
7039
|
+
"turbo.json",
|
|
7040
|
+
"lerna.json"
|
|
7041
|
+
];
|
|
7042
|
+
var DEFAULT_WORKSPACE_GLOBS = ["packages/*", "apps/*"];
|
|
7043
|
+
var MAX_WORKSPACE_PACKAGES = 512;
|
|
7044
|
+
var ancestryCache = /* @__PURE__ */ new Map();
|
|
7045
|
+
var workspaceScanCache = /* @__PURE__ */ new Map();
|
|
7046
|
+
var workspaceRootCache = /* @__PURE__ */ new Map();
|
|
6766
7047
|
var SVG_DEFS_CONTAINERS = /* @__PURE__ */ new Set([
|
|
6767
7048
|
"mask",
|
|
6768
7049
|
"clipPath",
|
|
@@ -6783,8 +7064,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
6783
7064
|
]);
|
|
6784
7065
|
function jsxElementName(node) {
|
|
6785
7066
|
const name = node.openingElement.name;
|
|
6786
|
-
if (name.type ===
|
|
6787
|
-
if (name.type ===
|
|
7067
|
+
if (name.type === import_utils48.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
7068
|
+
if (name.type === import_utils48.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils48.AST_NODE_TYPES.JSXIdentifier) {
|
|
6788
7069
|
return name.property.name;
|
|
6789
7070
|
}
|
|
6790
7071
|
return null;
|
|
@@ -6810,7 +7091,7 @@ var EMAIL_OR_PDF_IMPORT_RE = /@react-(?:email|pdf)\//;
|
|
|
6810
7091
|
var isInsideSvg = (node) => {
|
|
6811
7092
|
let current = node.parent;
|
|
6812
7093
|
while (current !== void 0 && current !== null) {
|
|
6813
|
-
if (current.type ===
|
|
7094
|
+
if (current.type === import_utils48.AST_NODE_TYPES.JSXElement) {
|
|
6814
7095
|
const name = jsxElementName(current);
|
|
6815
7096
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
6816
7097
|
}
|
|
@@ -6821,58 +7102,144 @@ var isInsideSvg = (node) => {
|
|
|
6821
7102
|
var isInsideIconFactoryPath = (node) => {
|
|
6822
7103
|
let current = node.parent;
|
|
6823
7104
|
while (current !== void 0 && current !== null) {
|
|
6824
|
-
if (current.type ===
|
|
7105
|
+
if (current.type === import_utils48.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils48.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils48.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils48.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
6825
7106
|
return true;
|
|
6826
7107
|
}
|
|
6827
7108
|
current = current.parent;
|
|
6828
7109
|
}
|
|
6829
7110
|
return false;
|
|
6830
7111
|
};
|
|
6831
|
-
var
|
|
6832
|
-
|
|
7112
|
+
var hasMarkerAt = (dir) => {
|
|
7113
|
+
for (const rel of DETECTION_FILES) {
|
|
7114
|
+
const candidate = (0, import_path.join)(dir, rel);
|
|
7115
|
+
if (!(0, import_fs.existsSync)(candidate)) continue;
|
|
7116
|
+
if (CONFIG_IS_SUFFICIENT.has(rel)) return true;
|
|
7117
|
+
try {
|
|
7118
|
+
if (SEMANTIC_TOKEN_RE.test((0, import_fs.readFileSync)(candidate, "utf8"))) return true;
|
|
7119
|
+
} catch {
|
|
7120
|
+
}
|
|
7121
|
+
}
|
|
7122
|
+
return false;
|
|
7123
|
+
};
|
|
7124
|
+
var hasMarkerAtOrAbove = (startDir) => {
|
|
7125
|
+
let dir = startDir;
|
|
6833
7126
|
const root = (0, import_path.parse)(dir).root;
|
|
6834
7127
|
const visited = [];
|
|
6835
7128
|
let answer;
|
|
6836
|
-
for (
|
|
6837
|
-
const cached =
|
|
7129
|
+
for (; ; ) {
|
|
7130
|
+
const cached = ancestryCache.get(dir);
|
|
6838
7131
|
if (cached !== void 0) {
|
|
6839
7132
|
answer = cached;
|
|
6840
7133
|
break;
|
|
6841
7134
|
}
|
|
6842
7135
|
visited.push(dir);
|
|
6843
|
-
|
|
6844
|
-
for (const rel of DETECTION_FILES) {
|
|
6845
|
-
const candidate = (0, import_path.join)(dir, rel);
|
|
6846
|
-
if (!(0, import_fs.existsSync)(candidate)) continue;
|
|
6847
|
-
if (rel === "components.json") {
|
|
6848
|
-
found = true;
|
|
6849
|
-
break;
|
|
6850
|
-
}
|
|
6851
|
-
try {
|
|
6852
|
-
if (SEMANTIC_TOKEN_RE.test((0, import_fs.readFileSync)(candidate, "utf8"))) {
|
|
6853
|
-
found = true;
|
|
6854
|
-
break;
|
|
6855
|
-
}
|
|
6856
|
-
} catch {
|
|
6857
|
-
}
|
|
6858
|
-
}
|
|
6859
|
-
if (found) {
|
|
7136
|
+
if (hasMarkerAt(dir)) {
|
|
6860
7137
|
answer = true;
|
|
6861
7138
|
break;
|
|
6862
7139
|
}
|
|
6863
|
-
|
|
7140
|
+
const parent = (0, import_path.dirname)(dir);
|
|
7141
|
+
if (dir === root || parent === dir) {
|
|
6864
7142
|
answer = false;
|
|
6865
7143
|
break;
|
|
6866
7144
|
}
|
|
6867
|
-
dir =
|
|
7145
|
+
dir = parent;
|
|
6868
7146
|
}
|
|
6869
|
-
|
|
6870
|
-
for (const seen of visited) semanticTokenCache.set(seen, answer);
|
|
7147
|
+
for (const seen of visited) ancestryCache.set(seen, answer);
|
|
6871
7148
|
return answer;
|
|
6872
7149
|
};
|
|
7150
|
+
var readWorkspaceGlobs = (dir) => {
|
|
7151
|
+
const globs = [];
|
|
7152
|
+
const packageJson = (0, import_path.join)(dir, "package.json");
|
|
7153
|
+
if ((0, import_fs.existsSync)(packageJson)) {
|
|
7154
|
+
try {
|
|
7155
|
+
const parsed = JSON.parse((0, import_fs.readFileSync)(packageJson, "utf8"));
|
|
7156
|
+
const declared = typeof parsed === "object" && parsed !== null && "workspaces" in parsed ? parsed.workspaces : void 0;
|
|
7157
|
+
const list = Array.isArray(declared) ? declared : typeof declared === "object" && declared !== null && Array.isArray(declared.packages) ? declared.packages : [];
|
|
7158
|
+
for (const entry of list) if (typeof entry === "string") globs.push(entry);
|
|
7159
|
+
} catch {
|
|
7160
|
+
}
|
|
7161
|
+
}
|
|
7162
|
+
for (const name of ["pnpm-workspace.yaml", "pnpm-workspace.yml"]) {
|
|
7163
|
+
const yaml = (0, import_path.join)(dir, name);
|
|
7164
|
+
if (!(0, import_fs.existsSync)(yaml)) continue;
|
|
7165
|
+
try {
|
|
7166
|
+
for (const line of (0, import_fs.readFileSync)(yaml, "utf8").split("\n")) {
|
|
7167
|
+
const match = /^\s*-\s*["']?([^"'#\s]+)["']?\s*$/u.exec(line);
|
|
7168
|
+
if (match?.[1] !== void 0) globs.push(match[1]);
|
|
7169
|
+
}
|
|
7170
|
+
} catch {
|
|
7171
|
+
}
|
|
7172
|
+
}
|
|
7173
|
+
return globs;
|
|
7174
|
+
};
|
|
7175
|
+
var expandWorkspaceGlob = (root, glob) => {
|
|
7176
|
+
const star = glob.indexOf("*");
|
|
7177
|
+
if (star === -1) return [(0, import_path.join)(root, glob)];
|
|
7178
|
+
const prefix = glob.slice(0, star).replace(/\/$/u, "");
|
|
7179
|
+
const parent = prefix === "" ? root : (0, import_path.join)(root, prefix);
|
|
7180
|
+
try {
|
|
7181
|
+
return (0, import_fs.readdirSync)(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => (0, import_path.join)(parent, entry.name));
|
|
7182
|
+
} catch {
|
|
7183
|
+
return [];
|
|
7184
|
+
}
|
|
7185
|
+
};
|
|
7186
|
+
var findWorkspaceRoot = (startDir) => {
|
|
7187
|
+
let dir = startDir;
|
|
7188
|
+
const root = (0, import_path.parse)(dir).root;
|
|
7189
|
+
const visited = [];
|
|
7190
|
+
let answer;
|
|
7191
|
+
for (; ; ) {
|
|
7192
|
+
const cached = workspaceRootCache.get(dir);
|
|
7193
|
+
if (cached !== void 0) {
|
|
7194
|
+
answer = cached;
|
|
7195
|
+
break;
|
|
7196
|
+
}
|
|
7197
|
+
visited.push(dir);
|
|
7198
|
+
if (WORKSPACE_ROOT_FILES.some((name) => (0, import_fs.existsSync)((0, import_path.join)(dir, name))) || readWorkspaceGlobs(dir).length > 0) {
|
|
7199
|
+
answer = dir;
|
|
7200
|
+
break;
|
|
7201
|
+
}
|
|
7202
|
+
const parent = (0, import_path.dirname)(dir);
|
|
7203
|
+
if (dir === root || parent === dir) {
|
|
7204
|
+
answer = null;
|
|
7205
|
+
break;
|
|
7206
|
+
}
|
|
7207
|
+
dir = parent;
|
|
7208
|
+
}
|
|
7209
|
+
for (const seen of visited) workspaceRootCache.set(seen, answer);
|
|
7210
|
+
return answer;
|
|
7211
|
+
};
|
|
7212
|
+
var workspaceHasMarker = (root) => {
|
|
7213
|
+
const cached = workspaceScanCache.get(root);
|
|
7214
|
+
if (cached !== void 0) return cached;
|
|
7215
|
+
const globs = readWorkspaceGlobs(root);
|
|
7216
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
7217
|
+
for (const glob of globs.length > 0 ? globs : DEFAULT_WORKSPACE_GLOBS) {
|
|
7218
|
+
for (const dir of expandWorkspaceGlob(root, glob)) {
|
|
7219
|
+
candidates.add(dir);
|
|
7220
|
+
if (candidates.size >= MAX_WORKSPACE_PACKAGES) break;
|
|
7221
|
+
}
|
|
7222
|
+
if (candidates.size >= MAX_WORKSPACE_PACKAGES) break;
|
|
7223
|
+
}
|
|
7224
|
+
let found = false;
|
|
7225
|
+
for (const dir of candidates) {
|
|
7226
|
+
if (hasMarkerAt(dir)) {
|
|
7227
|
+
found = true;
|
|
7228
|
+
break;
|
|
7229
|
+
}
|
|
7230
|
+
}
|
|
7231
|
+
workspaceScanCache.set(root, found);
|
|
7232
|
+
return found;
|
|
7233
|
+
};
|
|
7234
|
+
var hasSemanticTokenSystem = (filename) => {
|
|
7235
|
+
const dir = (0, import_path.dirname)(filename);
|
|
7236
|
+
if (hasMarkerAtOrAbove(dir)) return true;
|
|
7237
|
+
const root = findWorkspaceRoot(dir);
|
|
7238
|
+
return root !== null && workspaceHasMarker(root);
|
|
7239
|
+
};
|
|
6873
7240
|
var propName = (key) => {
|
|
6874
|
-
if (key.type ===
|
|
6875
|
-
if (key.type ===
|
|
7241
|
+
if (key.type === import_utils48.AST_NODE_TYPES.Identifier) return key.name;
|
|
7242
|
+
if (key.type === import_utils48.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
6876
7243
|
return null;
|
|
6877
7244
|
};
|
|
6878
7245
|
var prefer_semantic_colors_default = createRule({
|
|
@@ -6917,27 +7284,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
6917
7284
|
const checkClassNode = (node) => {
|
|
6918
7285
|
if (node === null) return;
|
|
6919
7286
|
switch (node.type) {
|
|
6920
|
-
case
|
|
7287
|
+
case import_utils48.AST_NODE_TYPES.Literal:
|
|
6921
7288
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
6922
7289
|
break;
|
|
6923
|
-
case
|
|
7290
|
+
case import_utils48.AST_NODE_TYPES.TemplateLiteral:
|
|
6924
7291
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
6925
7292
|
break;
|
|
6926
|
-
case
|
|
7293
|
+
case import_utils48.AST_NODE_TYPES.ArrayExpression:
|
|
6927
7294
|
for (const element of node.elements) {
|
|
6928
|
-
if (element !== null && element.type !==
|
|
7295
|
+
if (element !== null && element.type !== import_utils48.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
6929
7296
|
}
|
|
6930
7297
|
break;
|
|
6931
|
-
case
|
|
7298
|
+
case import_utils48.AST_NODE_TYPES.ObjectExpression:
|
|
6932
7299
|
for (const property of node.properties) {
|
|
6933
|
-
if (property.type ===
|
|
7300
|
+
if (property.type === import_utils48.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
6934
7301
|
}
|
|
6935
7302
|
break;
|
|
6936
|
-
case
|
|
7303
|
+
case import_utils48.AST_NODE_TYPES.ConditionalExpression:
|
|
6937
7304
|
checkClassNode(node.consequent);
|
|
6938
7305
|
checkClassNode(node.alternate);
|
|
6939
7306
|
break;
|
|
6940
|
-
case
|
|
7307
|
+
case import_utils48.AST_NODE_TYPES.LogicalExpression:
|
|
6941
7308
|
checkClassNode(node.right);
|
|
6942
7309
|
break;
|
|
6943
7310
|
default:
|
|
@@ -6945,29 +7312,29 @@ var prefer_semantic_colors_default = createRule({
|
|
|
6945
7312
|
}
|
|
6946
7313
|
};
|
|
6947
7314
|
const checkColorValueNode = (node) => {
|
|
6948
|
-
if (node.type ===
|
|
7315
|
+
if (node.type === import_utils48.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
6949
7316
|
context.report({ node, messageId: "inlineColor", data: { value: node.value } });
|
|
6950
7317
|
}
|
|
6951
7318
|
};
|
|
6952
7319
|
return {
|
|
6953
7320
|
"JSXAttribute[name.name='className']"(node) {
|
|
6954
7321
|
if (node.value === null) return;
|
|
6955
|
-
if (node.value.type ===
|
|
6956
|
-
else if (node.value.type ===
|
|
6957
|
-
if (node.value.expression.type !==
|
|
7322
|
+
if (node.value.type === import_utils48.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
7323
|
+
else if (node.value.type === import_utils48.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
7324
|
+
if (node.value.expression.type !== import_utils48.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
6958
7325
|
checkClassNode(node.value.expression);
|
|
6959
7326
|
}
|
|
6960
7327
|
}
|
|
6961
7328
|
},
|
|
6962
7329
|
CallExpression(node) {
|
|
6963
|
-
if (node.callee.type ===
|
|
7330
|
+
if (node.callee.type === import_utils48.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
6964
7331
|
for (const arg of node.arguments) {
|
|
6965
|
-
if (arg.type !==
|
|
7332
|
+
if (arg.type !== import_utils48.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
6966
7333
|
}
|
|
6967
7334
|
}
|
|
6968
7335
|
},
|
|
6969
7336
|
VariableDeclarator(node) {
|
|
6970
|
-
if (node.id.type ===
|
|
7337
|
+
if (node.id.type === import_utils48.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
6971
7338
|
checkClassNode(node.init);
|
|
6972
7339
|
}
|
|
6973
7340
|
},
|
|
@@ -6979,9 +7346,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
6979
7346
|
// Neutral drawing literals and anything inside an SVG defs container are
|
|
6980
7347
|
// structural, not UI tokens, so they never fire.
|
|
6981
7348
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
6982
|
-
if (node.value?.type !==
|
|
7349
|
+
if (node.value?.type !== import_utils48.AST_NODE_TYPES.Literal) return;
|
|
6983
7350
|
const owner = node.parent.name;
|
|
6984
|
-
if (owner.type ===
|
|
7351
|
+
if (owner.type === import_utils48.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
6985
7352
|
return;
|
|
6986
7353
|
}
|
|
6987
7354
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -6999,7 +7366,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
6999
7366
|
});
|
|
7000
7367
|
|
|
7001
7368
|
// src/rules/prefer-server-actions.ts
|
|
7002
|
-
var
|
|
7369
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
7003
7370
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
7004
7371
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
7005
7372
|
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\/)/;
|
|
@@ -7152,7 +7519,7 @@ var prefer_server_actions_default = createRule({
|
|
|
7152
7519
|
});
|
|
7153
7520
|
|
|
7154
7521
|
// src/rules/prefer-string-literal-union.ts
|
|
7155
|
-
var
|
|
7522
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7156
7523
|
var ts2 = __toESM(require("typescript"), 1);
|
|
7157
7524
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
7158
7525
|
"status",
|
|
@@ -7195,19 +7562,19 @@ function isChoiceLikeName(name) {
|
|
|
7195
7562
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
7196
7563
|
}
|
|
7197
7564
|
function keyName(key) {
|
|
7198
|
-
if (key.type ===
|
|
7565
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7199
7566
|
return key.name;
|
|
7200
7567
|
}
|
|
7201
|
-
if (key.type ===
|
|
7568
|
+
if (key.type === import_utils50.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
7202
7569
|
return key.value;
|
|
7203
7570
|
}
|
|
7204
7571
|
return null;
|
|
7205
7572
|
}
|
|
7206
7573
|
function isStringLiteralMember(t) {
|
|
7207
|
-
return t.type ===
|
|
7574
|
+
return t.type === import_utils50.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils50.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
7208
7575
|
}
|
|
7209
7576
|
function isStringLiteralUnion(node) {
|
|
7210
|
-
if (node?.type !==
|
|
7577
|
+
if (node?.type !== import_utils50.AST_NODE_TYPES.TSUnionType) {
|
|
7211
7578
|
return false;
|
|
7212
7579
|
}
|
|
7213
7580
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -7236,12 +7603,12 @@ function bindingSourceExpression(decl) {
|
|
|
7236
7603
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
7237
7604
|
}
|
|
7238
7605
|
function refKey(node) {
|
|
7239
|
-
if (node.type ===
|
|
7606
|
+
if (node.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7240
7607
|
return node.name;
|
|
7241
7608
|
}
|
|
7242
|
-
if (node.type ===
|
|
7609
|
+
if (node.type === import_utils50.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
7243
7610
|
const inner = refKey(node.object);
|
|
7244
|
-
if (inner === null || node.property.type !==
|
|
7611
|
+
if (inner === null || node.property.type !== import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7245
7612
|
return null;
|
|
7246
7613
|
}
|
|
7247
7614
|
return `${inner}.${node.property.name}`;
|
|
@@ -7249,7 +7616,7 @@ function refKey(node) {
|
|
|
7249
7616
|
return null;
|
|
7250
7617
|
}
|
|
7251
7618
|
function strLiteral(node) {
|
|
7252
|
-
if (node.type ===
|
|
7619
|
+
if (node.type === import_utils50.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
7253
7620
|
return node.value;
|
|
7254
7621
|
}
|
|
7255
7622
|
return null;
|
|
@@ -7290,7 +7657,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7290
7657
|
);
|
|
7291
7658
|
let services;
|
|
7292
7659
|
try {
|
|
7293
|
-
services =
|
|
7660
|
+
services = import_utils50.ESLintUtils.getParserServices(context);
|
|
7294
7661
|
} catch {
|
|
7295
7662
|
services = null;
|
|
7296
7663
|
}
|
|
@@ -7402,7 +7769,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7402
7769
|
containersWithUnion.add(container);
|
|
7403
7770
|
return;
|
|
7404
7771
|
}
|
|
7405
|
-
if (typeNode?.type !==
|
|
7772
|
+
if (typeNode?.type !== import_utils50.AST_NODE_TYPES.TSStringKeyword) {
|
|
7406
7773
|
return;
|
|
7407
7774
|
}
|
|
7408
7775
|
const name = keyName(key);
|
|
@@ -7490,10 +7857,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7490
7857
|
}
|
|
7491
7858
|
};
|
|
7492
7859
|
function refKeyText(node) {
|
|
7493
|
-
if (node.type ===
|
|
7860
|
+
if (node.type === import_utils50.AST_NODE_TYPES.BinaryExpression) {
|
|
7494
7861
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
7495
7862
|
}
|
|
7496
|
-
if (node.type ===
|
|
7863
|
+
if (node.type === import_utils50.AST_NODE_TYPES.SwitchStatement) {
|
|
7497
7864
|
return refKey(node.discriminant) ?? "value";
|
|
7498
7865
|
}
|
|
7499
7866
|
return "value";
|
|
@@ -7502,19 +7869,20 @@ var prefer_string_literal_union_default = createRule({
|
|
|
7502
7869
|
});
|
|
7503
7870
|
|
|
7504
7871
|
// src/rules/prefer-whole-object-assertion.ts
|
|
7505
|
-
var
|
|
7872
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7506
7873
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
7507
7874
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
7508
7875
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
7876
|
+
var LITERAL_KEY_HAZARDS = /* @__PURE__ */ new Set(["__proto__"]);
|
|
7509
7877
|
var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
7510
7878
|
var MIN_RUN_LENGTH = 2;
|
|
7511
7879
|
function literalText(node, getText) {
|
|
7512
7880
|
switch (node.type) {
|
|
7513
|
-
case
|
|
7881
|
+
case import_utils51.AST_NODE_TYPES.Literal:
|
|
7514
7882
|
return "regex" in node ? null : getText(node);
|
|
7515
|
-
case
|
|
7883
|
+
case import_utils51.AST_NODE_TYPES.TemplateLiteral:
|
|
7516
7884
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
7517
|
-
case
|
|
7885
|
+
case import_utils51.AST_NODE_TYPES.UnaryExpression:
|
|
7518
7886
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
7519
7887
|
default:
|
|
7520
7888
|
return null;
|
|
@@ -7522,15 +7890,15 @@ function literalText(node, getText) {
|
|
|
7522
7890
|
}
|
|
7523
7891
|
function isPureReceiver(node) {
|
|
7524
7892
|
switch (node.type) {
|
|
7525
|
-
case
|
|
7526
|
-
case
|
|
7893
|
+
case import_utils51.AST_NODE_TYPES.Identifier:
|
|
7894
|
+
case import_utils51.AST_NODE_TYPES.ThisExpression:
|
|
7527
7895
|
return true;
|
|
7528
|
-
case
|
|
7896
|
+
case import_utils51.AST_NODE_TYPES.MemberExpression:
|
|
7529
7897
|
if (node.optional) {
|
|
7530
7898
|
return false;
|
|
7531
7899
|
}
|
|
7532
7900
|
if (node.computed) {
|
|
7533
|
-
return node.property.type ===
|
|
7901
|
+
return node.property.type === import_utils51.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
7534
7902
|
}
|
|
7535
7903
|
return isPureReceiver(node.object);
|
|
7536
7904
|
default:
|
|
@@ -7538,7 +7906,7 @@ function isPureReceiver(node) {
|
|
|
7538
7906
|
}
|
|
7539
7907
|
}
|
|
7540
7908
|
function literalIndex(node) {
|
|
7541
|
-
if (node.type !==
|
|
7909
|
+
if (node.type !== import_utils51.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
7542
7910
|
return null;
|
|
7543
7911
|
}
|
|
7544
7912
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -7564,24 +7932,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7564
7932
|
}
|
|
7565
7933
|
const { sourceCode } = context;
|
|
7566
7934
|
function parseAssertion(statement) {
|
|
7567
|
-
if (statement.type !==
|
|
7935
|
+
if (statement.type !== import_utils51.AST_NODE_TYPES.ExpressionStatement) {
|
|
7568
7936
|
return null;
|
|
7569
7937
|
}
|
|
7570
7938
|
const call = statement.expression;
|
|
7571
|
-
if (call.type !==
|
|
7939
|
+
if (call.type !== import_utils51.AST_NODE_TYPES.CallExpression) {
|
|
7572
7940
|
return null;
|
|
7573
7941
|
}
|
|
7574
7942
|
const callee = call.callee;
|
|
7575
|
-
if (callee.type !==
|
|
7943
|
+
if (callee.type !== import_utils51.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7576
7944
|
return null;
|
|
7577
7945
|
}
|
|
7578
7946
|
const matcher = callee.property.name;
|
|
7579
7947
|
const expectCall = callee.object;
|
|
7580
|
-
if (expectCall.type !==
|
|
7948
|
+
if (expectCall.type !== import_utils51.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils51.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
7581
7949
|
return null;
|
|
7582
7950
|
}
|
|
7583
7951
|
const actual = expectCall.arguments[0];
|
|
7584
|
-
if (actual === void 0 || actual.type !==
|
|
7952
|
+
if (actual === void 0 || actual.type !== import_utils51.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
7585
7953
|
return null;
|
|
7586
7954
|
}
|
|
7587
7955
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -7595,7 +7963,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7595
7963
|
}
|
|
7596
7964
|
key = { kind: "index", index };
|
|
7597
7965
|
} else {
|
|
7598
|
-
if (actual.property.type !==
|
|
7966
|
+
if (actual.property.type !== import_utils51.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
7599
7967
|
return null;
|
|
7600
7968
|
}
|
|
7601
7969
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -7607,7 +7975,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7607
7975
|
return null;
|
|
7608
7976
|
}
|
|
7609
7977
|
const expected = call.arguments[0];
|
|
7610
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
7978
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils51.AST_NODE_TYPES.SpreadElement) {
|
|
7611
7979
|
return null;
|
|
7612
7980
|
}
|
|
7613
7981
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -7620,6 +7988,11 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7620
7988
|
expectedIsLiteral: literal !== null
|
|
7621
7989
|
};
|
|
7622
7990
|
}
|
|
7991
|
+
function hasInterveningComment(run) {
|
|
7992
|
+
return run.some(
|
|
7993
|
+
(assertion, index) => sourceCode.getCommentsInside(assertion.statement).length > 0 || index > 0 && sourceCode.getCommentsBefore(assertion.statement).length > 0
|
|
7994
|
+
);
|
|
7995
|
+
}
|
|
7623
7996
|
function reportPropertyRun(run) {
|
|
7624
7997
|
const names = /* @__PURE__ */ new Set();
|
|
7625
7998
|
for (const assertion of run) {
|
|
@@ -7646,7 +8019,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7646
8019
|
node: first.statement,
|
|
7647
8020
|
messageId: "combineAssertions",
|
|
7648
8021
|
data: { count: String(run.length), receiver: receiverText },
|
|
7649
|
-
fix: (fixer) => [
|
|
8022
|
+
fix: hasInterveningComment(run) ? null : (fixer) => [
|
|
7650
8023
|
fixer.replaceText(first.statement, `expect(${receiverText}).toMatchObject({ ${properties} });`),
|
|
7651
8024
|
...run.slice(1).map((assertion) => fixer.remove(assertion.statement))
|
|
7652
8025
|
]
|
|
@@ -7717,7 +8090,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
7717
8090
|
});
|
|
7718
8091
|
|
|
7719
8092
|
// src/rules/prefer-zod-enum.ts
|
|
7720
|
-
var
|
|
8093
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7721
8094
|
var prefer_zod_enum_default = createRule({
|
|
7722
8095
|
name: "prefer-zod-enum",
|
|
7723
8096
|
meta: {
|
|
@@ -7737,20 +8110,20 @@ var prefer_zod_enum_default = createRule({
|
|
|
7737
8110
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7738
8111
|
function enumValues(node) {
|
|
7739
8112
|
const callee = node.callee;
|
|
7740
|
-
if (callee.type !==
|
|
8113
|
+
if (callee.type !== import_utils52.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils52.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils52.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
7741
8114
|
return null;
|
|
7742
8115
|
}
|
|
7743
8116
|
const argument = node.arguments[0];
|
|
7744
|
-
if (argument === void 0 || argument.type !==
|
|
8117
|
+
if (argument === void 0 || argument.type !== import_utils52.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
7745
8118
|
return null;
|
|
7746
8119
|
}
|
|
7747
8120
|
const values = [];
|
|
7748
8121
|
for (const element of argument.elements) {
|
|
7749
|
-
if (element === null || element.type !==
|
|
8122
|
+
if (element === null || element.type !== import_utils52.AST_NODE_TYPES.CallExpression || element.arguments.length !== 1 || element.callee.type !== import_utils52.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils52.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils52.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
7750
8123
|
return null;
|
|
7751
8124
|
}
|
|
7752
8125
|
const value = element.arguments[0];
|
|
7753
|
-
if (value === void 0 || value.type !==
|
|
8126
|
+
if (value === void 0 || value.type !== import_utils52.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
7754
8127
|
return null;
|
|
7755
8128
|
}
|
|
7756
8129
|
values.push(value);
|
|
@@ -7759,11 +8132,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
7759
8132
|
}
|
|
7760
8133
|
function buildFix(node, values) {
|
|
7761
8134
|
const argument = node.arguments[0];
|
|
7762
|
-
if (argument === void 0 || argument.type !==
|
|
8135
|
+
if (argument === void 0 || argument.type !== import_utils52.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
7763
8136
|
return void 0;
|
|
7764
8137
|
}
|
|
7765
8138
|
const callee = node.callee;
|
|
7766
|
-
if (callee.type !==
|
|
8139
|
+
if (callee.type !== import_utils52.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7767
8140
|
return void 0;
|
|
7768
8141
|
}
|
|
7769
8142
|
return (fixer) => [
|
|
@@ -7780,7 +8153,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
7780
8153
|
return;
|
|
7781
8154
|
}
|
|
7782
8155
|
for (const specifier of node.specifiers) {
|
|
7783
|
-
if (specifier.type ===
|
|
8156
|
+
if (specifier.type === import_utils52.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils52.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils52.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils52.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
7784
8157
|
zodNamespaces.add(specifier.local.name);
|
|
7785
8158
|
}
|
|
7786
8159
|
}
|
|
@@ -7802,7 +8175,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
7802
8175
|
});
|
|
7803
8176
|
|
|
7804
8177
|
// src/rules/prefer-zod-infer.ts
|
|
7805
|
-
var
|
|
8178
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7806
8179
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
7807
8180
|
"describe",
|
|
7808
8181
|
"refine",
|
|
@@ -7839,44 +8212,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
7839
8212
|
"Schema"
|
|
7840
8213
|
]);
|
|
7841
8214
|
var LEAF_NODE_TYPES = {
|
|
7842
|
-
string: [
|
|
7843
|
-
email: [
|
|
7844
|
-
url: [
|
|
7845
|
-
uuid: [
|
|
7846
|
-
ulid: [
|
|
7847
|
-
cuid: [
|
|
7848
|
-
cuid2: [
|
|
7849
|
-
nanoid: [
|
|
7850
|
-
iso: [
|
|
7851
|
-
number: [
|
|
7852
|
-
int: [
|
|
7853
|
-
float32: [
|
|
7854
|
-
float64: [
|
|
7855
|
-
boolean: [
|
|
7856
|
-
bigint: [
|
|
7857
|
-
symbol: [
|
|
7858
|
-
any: [
|
|
7859
|
-
unknown: [
|
|
7860
|
-
never: [
|
|
7861
|
-
void: [
|
|
7862
|
-
null: [
|
|
7863
|
-
undefined: [
|
|
7864
|
-
literal: [
|
|
7865
|
-
date: [
|
|
7866
|
-
array: [
|
|
7867
|
-
tuple: [
|
|
7868
|
-
object: [
|
|
7869
|
-
strictObject: [
|
|
7870
|
-
looseObject: [
|
|
7871
|
-
record: [
|
|
7872
|
-
map: [
|
|
7873
|
-
set: [
|
|
7874
|
-
promise: [
|
|
7875
|
-
enum: [
|
|
7876
|
-
nativeEnum: [
|
|
7877
|
-
union: [
|
|
7878
|
-
discriminatedUnion: [
|
|
7879
|
-
intersection: [
|
|
8215
|
+
string: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8216
|
+
email: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8217
|
+
url: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8218
|
+
uuid: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8219
|
+
ulid: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8220
|
+
cuid: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8221
|
+
cuid2: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8222
|
+
nanoid: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8223
|
+
iso: [import_utils53.AST_NODE_TYPES.TSStringKeyword],
|
|
8224
|
+
number: [import_utils53.AST_NODE_TYPES.TSNumberKeyword],
|
|
8225
|
+
int: [import_utils53.AST_NODE_TYPES.TSNumberKeyword],
|
|
8226
|
+
float32: [import_utils53.AST_NODE_TYPES.TSNumberKeyword],
|
|
8227
|
+
float64: [import_utils53.AST_NODE_TYPES.TSNumberKeyword],
|
|
8228
|
+
boolean: [import_utils53.AST_NODE_TYPES.TSBooleanKeyword],
|
|
8229
|
+
bigint: [import_utils53.AST_NODE_TYPES.TSBigIntKeyword],
|
|
8230
|
+
symbol: [import_utils53.AST_NODE_TYPES.TSSymbolKeyword],
|
|
8231
|
+
any: [import_utils53.AST_NODE_TYPES.TSAnyKeyword],
|
|
8232
|
+
unknown: [import_utils53.AST_NODE_TYPES.TSUnknownKeyword],
|
|
8233
|
+
never: [import_utils53.AST_NODE_TYPES.TSNeverKeyword],
|
|
8234
|
+
void: [import_utils53.AST_NODE_TYPES.TSVoidKeyword],
|
|
8235
|
+
null: [import_utils53.AST_NODE_TYPES.TSNullKeyword],
|
|
8236
|
+
undefined: [import_utils53.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
8237
|
+
literal: [import_utils53.AST_NODE_TYPES.TSLiteralType],
|
|
8238
|
+
date: [import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8239
|
+
array: [import_utils53.AST_NODE_TYPES.TSArrayType, import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8240
|
+
tuple: [import_utils53.AST_NODE_TYPES.TSTupleType],
|
|
8241
|
+
object: [import_utils53.AST_NODE_TYPES.TSTypeLiteral, import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8242
|
+
strictObject: [import_utils53.AST_NODE_TYPES.TSTypeLiteral, import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8243
|
+
looseObject: [import_utils53.AST_NODE_TYPES.TSTypeLiteral, import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8244
|
+
record: [import_utils53.AST_NODE_TYPES.TSTypeReference, import_utils53.AST_NODE_TYPES.TSTypeLiteral],
|
|
8245
|
+
map: [import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8246
|
+
set: [import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8247
|
+
promise: [import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8248
|
+
enum: [import_utils53.AST_NODE_TYPES.TSUnionType, import_utils53.AST_NODE_TYPES.TSTypeReference, import_utils53.AST_NODE_TYPES.TSLiteralType],
|
|
8249
|
+
nativeEnum: [import_utils53.AST_NODE_TYPES.TSUnionType, import_utils53.AST_NODE_TYPES.TSTypeReference, import_utils53.AST_NODE_TYPES.TSLiteralType],
|
|
8250
|
+
union: [import_utils53.AST_NODE_TYPES.TSUnionType, import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8251
|
+
discriminatedUnion: [import_utils53.AST_NODE_TYPES.TSUnionType, import_utils53.AST_NODE_TYPES.TSTypeReference],
|
|
8252
|
+
intersection: [import_utils53.AST_NODE_TYPES.TSIntersectionType, import_utils53.AST_NODE_TYPES.TSTypeReference]
|
|
7880
8253
|
};
|
|
7881
8254
|
function normalizeSchemaName(name) {
|
|
7882
8255
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -7885,20 +8258,20 @@ function normalizeTypeName(name) {
|
|
|
7885
8258
|
return name.replace(/Type$/, "").toLowerCase();
|
|
7886
8259
|
}
|
|
7887
8260
|
function unwrapNullish(annotation) {
|
|
7888
|
-
if (annotation.type !==
|
|
8261
|
+
if (annotation.type !== import_utils53.AST_NODE_TYPES.TSUnionType) {
|
|
7889
8262
|
return {
|
|
7890
8263
|
core: annotation,
|
|
7891
|
-
nullable: annotation.type ===
|
|
8264
|
+
nullable: annotation.type === import_utils53.AST_NODE_TYPES.TSNullKeyword
|
|
7892
8265
|
};
|
|
7893
8266
|
}
|
|
7894
8267
|
const rest = [];
|
|
7895
8268
|
let nullable = false;
|
|
7896
8269
|
for (const member of annotation.types) {
|
|
7897
|
-
if (member.type ===
|
|
8270
|
+
if (member.type === import_utils53.AST_NODE_TYPES.TSNullKeyword) {
|
|
7898
8271
|
nullable = true;
|
|
7899
8272
|
continue;
|
|
7900
8273
|
}
|
|
7901
|
-
if (member.type ===
|
|
8274
|
+
if (member.type === import_utils53.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
7902
8275
|
continue;
|
|
7903
8276
|
}
|
|
7904
8277
|
rest.push(member);
|
|
@@ -7963,14 +8336,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
7963
8336
|
function zodCallChain(node) {
|
|
7964
8337
|
const chain = [];
|
|
7965
8338
|
let current = node;
|
|
7966
|
-
while (current.type ===
|
|
8339
|
+
while (current.type === import_utils53.AST_NODE_TYPES.CallExpression) {
|
|
7967
8340
|
const callee = current.callee;
|
|
7968
|
-
if (callee.type !==
|
|
8341
|
+
if (callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7969
8342
|
return null;
|
|
7970
8343
|
}
|
|
7971
8344
|
chain.push(current);
|
|
7972
8345
|
const receiver = callee.object;
|
|
7973
|
-
if (receiver.type ===
|
|
8346
|
+
if (receiver.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7974
8347
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
7975
8348
|
}
|
|
7976
8349
|
current = receiver;
|
|
@@ -7979,19 +8352,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
7979
8352
|
}
|
|
7980
8353
|
function methodName(call) {
|
|
7981
8354
|
const callee = call.callee;
|
|
7982
|
-
return callee.type ===
|
|
8355
|
+
return callee.type === import_utils53.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils53.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
7983
8356
|
}
|
|
7984
8357
|
function schemaField(node) {
|
|
7985
8358
|
const modifiers = [];
|
|
7986
8359
|
let current = node;
|
|
7987
8360
|
let leaf = null;
|
|
7988
|
-
while (current.type ===
|
|
8361
|
+
while (current.type === import_utils53.AST_NODE_TYPES.CallExpression) {
|
|
7989
8362
|
const callee = current.callee;
|
|
7990
|
-
if (callee.type !==
|
|
8363
|
+
if (callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7991
8364
|
break;
|
|
7992
8365
|
}
|
|
7993
8366
|
const receiver = callee.object;
|
|
7994
|
-
if (receiver.type ===
|
|
8367
|
+
if (receiver.type === import_utils53.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
7995
8368
|
leaf = callee.property.name;
|
|
7996
8369
|
break;
|
|
7997
8370
|
}
|
|
@@ -8022,16 +8395,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
8022
8395
|
return null;
|
|
8023
8396
|
}
|
|
8024
8397
|
const shape = base.arguments[0];
|
|
8025
|
-
if (shape === void 0 || shape.type !==
|
|
8398
|
+
if (shape === void 0 || shape.type !== import_utils53.AST_NODE_TYPES.ObjectExpression) {
|
|
8026
8399
|
return null;
|
|
8027
8400
|
}
|
|
8028
8401
|
const fields = /* @__PURE__ */ new Map();
|
|
8029
8402
|
for (const property of shape.properties) {
|
|
8030
|
-
if (property.type !==
|
|
8403
|
+
if (property.type !== import_utils53.AST_NODE_TYPES.Property || property.computed) {
|
|
8031
8404
|
return null;
|
|
8032
8405
|
}
|
|
8033
8406
|
const { key } = property;
|
|
8034
|
-
const name = key.type ===
|
|
8407
|
+
const name = key.type === import_utils53.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils53.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8035
8408
|
if (name === null) {
|
|
8036
8409
|
return null;
|
|
8037
8410
|
}
|
|
@@ -8042,11 +8415,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8042
8415
|
function typeMembers(members) {
|
|
8043
8416
|
const result = /* @__PURE__ */ new Map();
|
|
8044
8417
|
for (const member of members) {
|
|
8045
|
-
if (member.type !==
|
|
8418
|
+
if (member.type !== import_utils53.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
8046
8419
|
return null;
|
|
8047
8420
|
}
|
|
8048
8421
|
const { key } = member;
|
|
8049
|
-
const name = key.type ===
|
|
8422
|
+
const name = key.type === import_utils53.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils53.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
8050
8423
|
if (name === null) {
|
|
8051
8424
|
return null;
|
|
8052
8425
|
}
|
|
@@ -8060,8 +8433,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
8060
8433
|
return result.size === 0 ? null : result;
|
|
8061
8434
|
}
|
|
8062
8435
|
function collectConstrainedNames(node) {
|
|
8063
|
-
if (node.type ===
|
|
8064
|
-
if (node.typeName.type ===
|
|
8436
|
+
if (node.type === import_utils53.AST_NODE_TYPES.TSTypeReference) {
|
|
8437
|
+
if (node.typeName.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
8065
8438
|
constrainedTypeNames.add(node.typeName.name);
|
|
8066
8439
|
}
|
|
8067
8440
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -8069,11 +8442,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
8069
8442
|
}
|
|
8070
8443
|
return;
|
|
8071
8444
|
}
|
|
8072
|
-
if (node.type ===
|
|
8445
|
+
if (node.type === import_utils53.AST_NODE_TYPES.TSArrayType) {
|
|
8073
8446
|
collectConstrainedNames(node.elementType);
|
|
8074
8447
|
return;
|
|
8075
8448
|
}
|
|
8076
|
-
if (node.type ===
|
|
8449
|
+
if (node.type === import_utils53.AST_NODE_TYPES.TSUnionType || node.type === import_utils53.AST_NODE_TYPES.TSIntersectionType) {
|
|
8077
8450
|
for (const member of node.types) {
|
|
8078
8451
|
collectConstrainedNames(member);
|
|
8079
8452
|
}
|
|
@@ -8117,13 +8490,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
8117
8490
|
return;
|
|
8118
8491
|
}
|
|
8119
8492
|
for (const specifier of node.specifiers) {
|
|
8120
|
-
if (specifier.type ===
|
|
8493
|
+
if (specifier.type === import_utils53.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils53.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils53.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils53.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
8121
8494
|
zodNamespaces.add(specifier.local.name);
|
|
8122
8495
|
}
|
|
8123
8496
|
}
|
|
8124
8497
|
},
|
|
8125
8498
|
VariableDeclarator(node) {
|
|
8126
|
-
if (node.id.type !==
|
|
8499
|
+
if (node.id.type !== import_utils53.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
8127
8500
|
return;
|
|
8128
8501
|
}
|
|
8129
8502
|
const fields = schemaFields(node.init);
|
|
@@ -8133,14 +8506,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
8133
8506
|
},
|
|
8134
8507
|
/** Guard (f): `XSchema.transform(...)` anywhere in the module. */
|
|
8135
8508
|
"MemberExpression[computed=false]"(node) {
|
|
8136
|
-
if (node.object.type ===
|
|
8509
|
+
if (node.object.type === import_utils53.AST_NODE_TYPES.Identifier && node.property.type === import_utils53.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
8137
8510
|
reshapedSchemaNames.add(node.object.name);
|
|
8138
8511
|
}
|
|
8139
8512
|
},
|
|
8140
8513
|
/** Guard (c): `z.ZodType<T>` and every other type argument it carries. */
|
|
8141
8514
|
TSTypeReference(node) {
|
|
8142
8515
|
const { typeName } = node;
|
|
8143
|
-
const referenced = typeName.type ===
|
|
8516
|
+
const referenced = typeName.type === import_utils53.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils53.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils53.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
8144
8517
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
8145
8518
|
return;
|
|
8146
8519
|
}
|
|
@@ -8158,7 +8531,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
8158
8531
|
}
|
|
8159
8532
|
},
|
|
8160
8533
|
TSTypeAliasDeclaration(node) {
|
|
8161
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
8534
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils53.AST_NODE_TYPES.TSTypeLiteral) {
|
|
8162
8535
|
return;
|
|
8163
8536
|
}
|
|
8164
8537
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -8203,36 +8576,36 @@ var prefer_zod_infer_default = createRule({
|
|
|
8203
8576
|
});
|
|
8204
8577
|
|
|
8205
8578
|
// src/rules/require-assert-never.ts
|
|
8206
|
-
var
|
|
8579
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
8207
8580
|
var isAssertNeverCall = (expression) => {
|
|
8208
|
-
if (expression.type !==
|
|
8581
|
+
if (expression.type !== import_utils54.AST_NODE_TYPES.CallExpression) return false;
|
|
8209
8582
|
const callee = expression.callee;
|
|
8210
|
-
if (callee.type ===
|
|
8583
|
+
if (callee.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8211
8584
|
return callee.name === "assertNever";
|
|
8212
8585
|
}
|
|
8213
|
-
if (callee.type ===
|
|
8586
|
+
if (callee.type === import_utils54.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
8214
8587
|
return callee.property.name === "assertNever";
|
|
8215
8588
|
}
|
|
8216
8589
|
return false;
|
|
8217
8590
|
};
|
|
8218
8591
|
var statementContainsAssertNever = (statement) => {
|
|
8219
|
-
if (statement.type ===
|
|
8592
|
+
if (statement.type === import_utils54.AST_NODE_TYPES.ExpressionStatement) {
|
|
8220
8593
|
return isAssertNeverCall(statement.expression);
|
|
8221
8594
|
}
|
|
8222
|
-
if (statement.type ===
|
|
8595
|
+
if (statement.type === import_utils54.AST_NODE_TYPES.ThrowStatement) {
|
|
8223
8596
|
return isAssertNeverCall(statement.argument);
|
|
8224
8597
|
}
|
|
8225
|
-
if (statement.type ===
|
|
8598
|
+
if (statement.type === import_utils54.AST_NODE_TYPES.ReturnStatement) {
|
|
8226
8599
|
return statement.argument !== null && isAssertNeverCall(statement.argument);
|
|
8227
8600
|
}
|
|
8228
|
-
if (statement.type ===
|
|
8601
|
+
if (statement.type === import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
8229
8602
|
return statement.body.some(statementContainsAssertNever);
|
|
8230
8603
|
}
|
|
8231
8604
|
return false;
|
|
8232
8605
|
};
|
|
8233
8606
|
var isRuntimeHandlingStatement = (statement) => {
|
|
8234
|
-
if (statement.type ===
|
|
8235
|
-
if (statement.type ===
|
|
8607
|
+
if (statement.type === import_utils54.AST_NODE_TYPES.EmptyStatement) return false;
|
|
8608
|
+
if (statement.type === import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
8236
8609
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
8237
8610
|
}
|
|
8238
8611
|
return true;
|
|
@@ -8248,7 +8621,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
8248
8621
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
8249
8622
|
}
|
|
8250
8623
|
const only = defaultCase.consequent[0];
|
|
8251
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
8624
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils54.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
8252
8625
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
8253
8626
|
}
|
|
8254
8627
|
return false;
|
|
@@ -8289,7 +8662,7 @@ var require_assert_never_default = createRule({
|
|
|
8289
8662
|
});
|
|
8290
8663
|
|
|
8291
8664
|
// src/rules/require-fetch-timeout.ts
|
|
8292
|
-
var
|
|
8665
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
8293
8666
|
var CODEMOD_FIXTURE_RE = /[\\/]__testfixtures__[\\/]/;
|
|
8294
8667
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
8295
8668
|
"globalThis",
|
|
@@ -8306,14 +8679,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
8306
8679
|
return false;
|
|
8307
8680
|
}
|
|
8308
8681
|
function initProvablyLacksSignal(init) {
|
|
8309
|
-
if (init.type !==
|
|
8682
|
+
if (init.type !== import_utils55.AST_NODE_TYPES.ObjectExpression) {
|
|
8310
8683
|
return false;
|
|
8311
8684
|
}
|
|
8312
8685
|
for (const prop of init.properties) {
|
|
8313
|
-
if (prop.type ===
|
|
8686
|
+
if (prop.type === import_utils55.AST_NODE_TYPES.SpreadElement) {
|
|
8314
8687
|
return false;
|
|
8315
8688
|
}
|
|
8316
|
-
if (prop.key.type ===
|
|
8689
|
+
if (prop.key.type === import_utils55.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils55.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
8317
8690
|
return false;
|
|
8318
8691
|
}
|
|
8319
8692
|
if (prop.computed) {
|
|
@@ -8323,7 +8696,7 @@ function initProvablyLacksSignal(init) {
|
|
|
8323
8696
|
return true;
|
|
8324
8697
|
}
|
|
8325
8698
|
function isStringish(node) {
|
|
8326
|
-
return node.type ===
|
|
8699
|
+
return node.type === import_utils55.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils55.AST_NODE_TYPES.TemplateLiteral;
|
|
8327
8700
|
}
|
|
8328
8701
|
var require_fetch_timeout_default = createRule({
|
|
8329
8702
|
name: "require-fetch-timeout",
|
|
@@ -8360,14 +8733,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
8360
8733
|
}
|
|
8361
8734
|
function resolvesToGlobal(identifier) {
|
|
8362
8735
|
const scope = context.sourceCode.getScope(identifier);
|
|
8363
|
-
const variable =
|
|
8736
|
+
const variable = import_utils55.ASTUtils.findVariable(scope, identifier.name);
|
|
8364
8737
|
return variable === null || variable.defs.length === 0;
|
|
8365
8738
|
}
|
|
8366
8739
|
function isGlobalFetchCall2(callee) {
|
|
8367
|
-
if (callee.type ===
|
|
8740
|
+
if (callee.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
8368
8741
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
8369
8742
|
}
|
|
8370
|
-
return callee.type ===
|
|
8743
|
+
return callee.type === import_utils55.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils55.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils55.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
8371
8744
|
}
|
|
8372
8745
|
return {
|
|
8373
8746
|
CallExpression(node) {
|
|
@@ -8387,26 +8760,26 @@ var require_fetch_timeout_default = createRule({
|
|
|
8387
8760
|
});
|
|
8388
8761
|
|
|
8389
8762
|
// src/rules/require-interface-for-injected-service.ts
|
|
8390
|
-
var
|
|
8763
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
8391
8764
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
8392
8765
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
8393
8766
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
8394
8767
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
8395
8768
|
var ROUTER_FACTORY_NAME = "Router";
|
|
8396
8769
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
8397
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
8398
|
-
var qualifiedName = (name) => name.type ===
|
|
8770
|
+
var isExportedClass = (node) => node.parent.type === import_utils56.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils56.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
8771
|
+
var qualifiedName = (name) => name.type === import_utils56.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils56.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
8399
8772
|
var typeReferenceName = (annotated) => {
|
|
8400
8773
|
let target = annotated;
|
|
8401
|
-
if (target.type ===
|
|
8402
|
-
if (target.type ===
|
|
8403
|
-
if (target.type !==
|
|
8774
|
+
if (target.type === import_utils56.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
8775
|
+
if (target.type === import_utils56.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
8776
|
+
if (target.type !== import_utils56.AST_NODE_TYPES.Identifier) return null;
|
|
8404
8777
|
const annotation = target.typeAnnotation?.typeAnnotation;
|
|
8405
|
-
if (annotation === void 0 || annotation.type !==
|
|
8778
|
+
if (annotation === void 0 || annotation.type !== import_utils56.AST_NODE_TYPES.TSTypeReference) {
|
|
8406
8779
|
return null;
|
|
8407
8780
|
}
|
|
8408
8781
|
const { typeName } = annotation;
|
|
8409
|
-
const rightmost = typeName.type ===
|
|
8782
|
+
const rightmost = typeName.type === import_utils56.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils56.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
8410
8783
|
if (rightmost === null) return null;
|
|
8411
8784
|
return { name: target.name, typeName: rightmost, display: qualifiedName(typeName) };
|
|
8412
8785
|
};
|
|
@@ -8416,17 +8789,17 @@ var readConstructor = (ctor) => {
|
|
|
8416
8789
|
let constructedFields = 0;
|
|
8417
8790
|
if (body !== null && body !== void 0) {
|
|
8418
8791
|
for (const statement of body.body) {
|
|
8419
|
-
if (statement.type !==
|
|
8792
|
+
if (statement.type !== import_utils56.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
8420
8793
|
const expression = statement.expression;
|
|
8421
|
-
if (expression.type !==
|
|
8794
|
+
if (expression.type !== import_utils56.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils56.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils56.AST_NODE_TYPES.ThisExpression) {
|
|
8422
8795
|
continue;
|
|
8423
8796
|
}
|
|
8424
8797
|
const source = expression.right;
|
|
8425
|
-
if (source.type ===
|
|
8798
|
+
if (source.type === import_utils56.AST_NODE_TYPES.NewExpression) {
|
|
8426
8799
|
constructedFields += 1;
|
|
8427
|
-
} else if (source.type ===
|
|
8800
|
+
} else if (source.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8428
8801
|
storedFrom.add(source.name);
|
|
8429
|
-
} else if (source.type ===
|
|
8802
|
+
} else if (source.type === import_utils56.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
8430
8803
|
storedFrom.add(source.object.name);
|
|
8431
8804
|
}
|
|
8432
8805
|
}
|
|
@@ -8435,7 +8808,7 @@ var readConstructor = (ctor) => {
|
|
|
8435
8808
|
for (const parameter of ctor.value.params) {
|
|
8436
8809
|
const reference = typeReferenceName(parameter);
|
|
8437
8810
|
if (reference === null) continue;
|
|
8438
|
-
const stored = parameter.type ===
|
|
8811
|
+
const stored = parameter.type === import_utils56.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
8439
8812
|
if (!stored) continue;
|
|
8440
8813
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
8441
8814
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -8465,19 +8838,19 @@ var subtreeHas = (root, found) => {
|
|
|
8465
8838
|
return hit;
|
|
8466
8839
|
};
|
|
8467
8840
|
var isFrameworkWiring = (body) => subtreeHas(body, (node) => {
|
|
8468
|
-
if (node.type ===
|
|
8841
|
+
if (node.type === import_utils56.AST_NODE_TYPES.CallExpression) {
|
|
8469
8842
|
const { callee } = node;
|
|
8470
|
-
if (callee.type ===
|
|
8471
|
-
return callee.type ===
|
|
8843
|
+
if (callee.type === import_utils56.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
8844
|
+
return callee.type === import_utils56.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils56.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
8472
8845
|
}
|
|
8473
|
-
return node.type ===
|
|
8846
|
+
return node.type === import_utils56.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils56.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
8474
8847
|
});
|
|
8475
8848
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
8476
8849
|
var fileInterfaceNames = (program) => {
|
|
8477
8850
|
const names = [];
|
|
8478
8851
|
for (const statement of program.body) {
|
|
8479
|
-
const declaration = statement.type ===
|
|
8480
|
-
if (declaration?.type ===
|
|
8852
|
+
const declaration = statement.type === import_utils56.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
8853
|
+
if (declaration?.type === import_utils56.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
8481
8854
|
}
|
|
8482
8855
|
return names;
|
|
8483
8856
|
};
|
|
@@ -8495,11 +8868,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
8495
8868
|
var publicMethodNames = (body) => {
|
|
8496
8869
|
const names = [];
|
|
8497
8870
|
for (const member of body.body) {
|
|
8498
|
-
if (member.type !==
|
|
8871
|
+
if (member.type !== import_utils56.AST_NODE_TYPES.MethodDefinition) continue;
|
|
8499
8872
|
if (member.kind !== "method" || member.static) continue;
|
|
8500
8873
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
8501
|
-
if (member.key.type ===
|
|
8502
|
-
if (member.key.type ===
|
|
8874
|
+
if (member.key.type === import_utils56.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
8875
|
+
if (member.key.type === import_utils56.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
8503
8876
|
else names.push("\u2026");
|
|
8504
8877
|
}
|
|
8505
8878
|
return names;
|
|
@@ -8530,7 +8903,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
8530
8903
|
if (node.implements.length > 0) return;
|
|
8531
8904
|
if (node.decorators.length > 0) return;
|
|
8532
8905
|
const ctor = node.body.body.find(
|
|
8533
|
-
(member) => member.type ===
|
|
8906
|
+
(member) => member.type === import_utils56.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
8534
8907
|
);
|
|
8535
8908
|
if (ctor === void 0) return;
|
|
8536
8909
|
const { collaborators, constructedFields } = readConstructor(ctor);
|
|
@@ -8555,18 +8928,18 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
8555
8928
|
});
|
|
8556
8929
|
|
|
8557
8930
|
// src/rules/require-zod-form-validation.ts
|
|
8558
|
-
var
|
|
8931
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8559
8932
|
var looksLikeZodSchema = (node) => {
|
|
8560
8933
|
let current = node;
|
|
8561
8934
|
while (true) {
|
|
8562
|
-
if (current.type ===
|
|
8935
|
+
if (current.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8563
8936
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
8564
8937
|
}
|
|
8565
|
-
if (current.type ===
|
|
8938
|
+
if (current.type === import_utils57.AST_NODE_TYPES.CallExpression) {
|
|
8566
8939
|
current = current.callee;
|
|
8567
8940
|
continue;
|
|
8568
8941
|
}
|
|
8569
|
-
if (current.type ===
|
|
8942
|
+
if (current.type === import_utils57.AST_NODE_TYPES.MemberExpression) {
|
|
8570
8943
|
current = current.object;
|
|
8571
8944
|
continue;
|
|
8572
8945
|
}
|
|
@@ -8574,23 +8947,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
8574
8947
|
}
|
|
8575
8948
|
};
|
|
8576
8949
|
var isZodParseCall = (node) => {
|
|
8577
|
-
if (node.type !==
|
|
8950
|
+
if (node.type !== import_utils57.AST_NODE_TYPES.CallExpression) return false;
|
|
8578
8951
|
const callee = node.callee;
|
|
8579
|
-
if (callee.type !==
|
|
8952
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression) return false;
|
|
8580
8953
|
if (callee.computed) return false;
|
|
8581
|
-
if (callee.property.type !==
|
|
8954
|
+
if (callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) return false;
|
|
8582
8955
|
const method = callee.property.name;
|
|
8583
8956
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
8584
8957
|
return looksLikeZodSchema(callee.object);
|
|
8585
8958
|
};
|
|
8586
8959
|
var isFormDataMethodCall = (node) => {
|
|
8587
8960
|
let current = node;
|
|
8588
|
-
if (current.type ===
|
|
8961
|
+
if (current.type === import_utils57.AST_NODE_TYPES.AwaitExpression) {
|
|
8589
8962
|
current = current.argument;
|
|
8590
8963
|
}
|
|
8591
|
-
if (current.type !==
|
|
8964
|
+
if (current.type !== import_utils57.AST_NODE_TYPES.CallExpression) return false;
|
|
8592
8965
|
const callee = current.callee;
|
|
8593
|
-
return callee.type ===
|
|
8966
|
+
return callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils57.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
8594
8967
|
};
|
|
8595
8968
|
var require_zod_form_validation_default = createRule({
|
|
8596
8969
|
name: "require-zod-form-validation",
|
|
@@ -8610,14 +8983,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
8610
8983
|
return {};
|
|
8611
8984
|
}
|
|
8612
8985
|
const isFormSourceIdentifier = (node) => {
|
|
8613
|
-
if (node.type !==
|
|
8986
|
+
if (node.type !== import_utils57.AST_NODE_TYPES.Identifier) return false;
|
|
8614
8987
|
if (/formdata/i.test(node.name)) return true;
|
|
8615
8988
|
let scope = context.sourceCode.getScope(node);
|
|
8616
8989
|
while (scope !== null) {
|
|
8617
8990
|
const variable = scope.set.get(node.name);
|
|
8618
8991
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
8619
8992
|
const def = variable.defs[0];
|
|
8620
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
8993
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils57.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
8621
8994
|
return isFormDataMethodCall(def.node.init);
|
|
8622
8995
|
}
|
|
8623
8996
|
return false;
|
|
@@ -8628,8 +9001,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
8628
9001
|
};
|
|
8629
9002
|
const isFormDataGetCall = (node) => {
|
|
8630
9003
|
const callee = node.callee;
|
|
8631
|
-
if (callee.type !==
|
|
8632
|
-
if (callee.property.type !==
|
|
9004
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression) return false;
|
|
9005
|
+
if (callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
8633
9006
|
return false;
|
|
8634
9007
|
}
|
|
8635
9008
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -8644,11 +9017,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
8644
9017
|
};
|
|
8645
9018
|
const isInstanceofNarrowing = (node) => {
|
|
8646
9019
|
const parent = node.parent;
|
|
8647
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
9020
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils57.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node;
|
|
8648
9021
|
};
|
|
8649
9022
|
const boundDeclarator = (node) => {
|
|
8650
9023
|
const parent = node.parent;
|
|
8651
|
-
if (parent.type ===
|
|
9024
|
+
if (parent.type === import_utils57.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
8652
9025
|
return parent;
|
|
8653
9026
|
}
|
|
8654
9027
|
return null;
|
|
@@ -8676,7 +9049,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
8676
9049
|
});
|
|
8677
9050
|
|
|
8678
9051
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
8679
|
-
var
|
|
9052
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8680
9053
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
8681
9054
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
8682
9055
|
var INSERT_GATE = /insert/i;
|
|
@@ -8707,7 +9080,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
8707
9080
|
});
|
|
8708
9081
|
|
|
8709
9082
|
// src/rules/zod-naming-convention.ts
|
|
8710
|
-
var
|
|
9083
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
8711
9084
|
var CONVENTIONS = {
|
|
8712
9085
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
8713
9086
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -8732,15 +9105,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
8732
9105
|
"registry",
|
|
8733
9106
|
"implement"
|
|
8734
9107
|
]);
|
|
8735
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
9108
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils59.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
8736
9109
|
var calleeChainStartsWithZ = (node) => {
|
|
8737
9110
|
let current = node;
|
|
8738
|
-
while (current.type ===
|
|
9111
|
+
while (current.type === import_utils59.AST_NODE_TYPES.MemberExpression) {
|
|
8739
9112
|
const receiver = current.object;
|
|
8740
|
-
if (receiver.type ===
|
|
9113
|
+
if (receiver.type === import_utils59.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
8741
9114
|
return true;
|
|
8742
9115
|
}
|
|
8743
|
-
if (receiver.type ===
|
|
9116
|
+
if (receiver.type === import_utils59.AST_NODE_TYPES.CallExpression) {
|
|
8744
9117
|
current = receiver.callee;
|
|
8745
9118
|
continue;
|
|
8746
9119
|
}
|
|
@@ -8785,13 +9158,13 @@ var zod_naming_convention_default = createRule({
|
|
|
8785
9158
|
VariableDeclarator(node) {
|
|
8786
9159
|
const init = node.init;
|
|
8787
9160
|
if (init === null || init === void 0) return;
|
|
8788
|
-
if (init.type !==
|
|
9161
|
+
if (init.type !== import_utils59.AST_NODE_TYPES.CallExpression) return;
|
|
8789
9162
|
const callee = init.callee;
|
|
8790
|
-
if (callee.type !==
|
|
9163
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression) return;
|
|
8791
9164
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
8792
9165
|
const terminal = terminalMethodName(callee);
|
|
8793
9166
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
8794
|
-
if (node.id.type !==
|
|
9167
|
+
if (node.id.type !== import_utils59.AST_NODE_TYPES.Identifier) return;
|
|
8795
9168
|
if (test.test(node.id.name)) return;
|
|
8796
9169
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
8797
9170
|
context.report({
|
|
@@ -8811,6 +9184,54 @@ var renamedRules = {
|
|
|
8811
9184
|
"trailing-value-narration": "no-trailing-value-narration"
|
|
8812
9185
|
};
|
|
8813
9186
|
|
|
9187
|
+
// src/rules/_retired.ts
|
|
9188
|
+
var retiredRules = {
|
|
9189
|
+
"ban-loose-type-guards-in-tests": {
|
|
9190
|
+
removedIn: "5.0.0",
|
|
9191
|
+
reason: "Read at 39 findings with 0 true positives in the #183 corpus audit. Delete the config entry; no replacement."
|
|
9192
|
+
},
|
|
9193
|
+
"no-implicit-attribute-access": {
|
|
9194
|
+
removedIn: "5.0.0",
|
|
9195
|
+
reason: "Read at 50 findings with 0 true positives in the #183 corpus audit. Delete the config entry; no replacement."
|
|
9196
|
+
},
|
|
9197
|
+
"no-sequential-await": {
|
|
9198
|
+
removedIn: "3.0.0",
|
|
9199
|
+
reason: "218 findings, 100% range-contained in core `no-await-in-loop`, which the shipped config already enables. Delete the entry; `no-await-in-loop` covers it."
|
|
9200
|
+
},
|
|
9201
|
+
"no-template-literal-in-log": {
|
|
9202
|
+
removedIn: "2.3.1",
|
|
9203
|
+
reason: "Withdrawn. Delete the config entry; no replacement."
|
|
9204
|
+
},
|
|
9205
|
+
"no-unsafe-cast": {
|
|
9206
|
+
removedIn: "3.0.0",
|
|
9207
|
+
reason: '1,089 findings, matching `@typescript-eslint/consistent-type-assertions` ("never") at the identical line and column with zero residue. Delete the entry; keep that rule enabled.'
|
|
9208
|
+
},
|
|
9209
|
+
"prefer-setup-file-mocks": {
|
|
9210
|
+
removedIn: "5.0.0",
|
|
9211
|
+
reason: "Read at 50 findings with 0 true positives in the #183 corpus audit. Delete the config entry; no replacement."
|
|
9212
|
+
},
|
|
9213
|
+
"prefer-shadcn": {
|
|
9214
|
+
removedIn: "3.0.0",
|
|
9215
|
+
reason: "645 findings, a subset of `react/forbid-elements`; its 24-position residue was all design-system primitives being told not to be the design system. Delete the entry."
|
|
9216
|
+
},
|
|
9217
|
+
"primary-export-file-name": {
|
|
9218
|
+
removedIn: "4.0.0",
|
|
9219
|
+
reason: "Renamed files after one of their exports \u2014 316 findings over 1,966 files sampled 11 harmful / 15 useless / 4 valuable, including telling `next.config.ts` to become `next-config.ts`. Delete the config entry."
|
|
9220
|
+
},
|
|
9221
|
+
"require-parameterized-tests": {
|
|
9222
|
+
removedIn: "4.0.0",
|
|
9223
|
+
reason: "Landed in #153 and never wired up: absent from the `rules` record, every preset, and eslint.strict.mjs. Nothing to migrate."
|
|
9224
|
+
},
|
|
9225
|
+
"require-schema-validate-search": {
|
|
9226
|
+
removedIn: "3.0.0",
|
|
9227
|
+
reason: "14 findings, all matched line-and-column by `@typescript-eslint/consistent-type-assertions`. Delete the entry."
|
|
9228
|
+
},
|
|
9229
|
+
"single-public-export": {
|
|
9230
|
+
removedIn: "3.0.0",
|
|
9231
|
+
reason: "3 findings, all also reported by the then-live `primary-export-file-name` (itself withdrawn in 4.0.0). Delete the entry."
|
|
9232
|
+
}
|
|
9233
|
+
};
|
|
9234
|
+
|
|
8814
9235
|
// src/index.ts
|
|
8815
9236
|
var rules = {
|
|
8816
9237
|
"enforce-file-structure": enforce_file_structure_default,
|
|
@@ -8842,6 +9263,7 @@ var rules = {
|
|
|
8842
9263
|
"no-string-concat-in-loop": no_string_concat_in_loop_default,
|
|
8843
9264
|
"no-tautological-expect": no_tautological_expect_default,
|
|
8844
9265
|
"no-trailing-value-narration": no_trailing_value_narration_default,
|
|
9266
|
+
"no-declaration-comment-wall": no_declaration_comment_wall_default,
|
|
8845
9267
|
"no-type-member-comment-wall": no_type_member_comment_wall_default,
|
|
8846
9268
|
"no-unnecessary-use-client": no_unnecessary_use_client_default,
|
|
8847
9269
|
"no-unsafe-mock-casting": no_unsafe_mock_casting_default,
|
|
@@ -8867,7 +9289,7 @@ var rules = {
|
|
|
8867
9289
|
};
|
|
8868
9290
|
var meta = {
|
|
8869
9291
|
name: "@sarj/eslint-plugin",
|
|
8870
|
-
version: "
|
|
9292
|
+
version: "8.0.0"
|
|
8871
9293
|
};
|
|
8872
9294
|
var renames = renamedRules;
|
|
8873
9295
|
var deprecatedAliases = Object.fromEntries(
|
|
@@ -8916,6 +9338,7 @@ var recommendedRules = {
|
|
|
8916
9338
|
"@sarj/no-string-concat-in-loop": "warn",
|
|
8917
9339
|
"@sarj/no-tautological-expect": "warn",
|
|
8918
9340
|
"@sarj/no-trailing-value-narration": "warn",
|
|
9341
|
+
"@sarj/no-declaration-comment-wall": "warn",
|
|
8919
9342
|
"@sarj/no-type-member-comment-wall": "warn",
|
|
8920
9343
|
"@sarj/no-unnecessary-use-client": "warn",
|
|
8921
9344
|
"@sarj/no-unsafe-mock-casting": "warn",
|
|
@@ -8969,6 +9392,7 @@ var strictRules = {
|
|
|
8969
9392
|
"@sarj/no-string-concat-in-loop": "error",
|
|
8970
9393
|
"@sarj/no-tautological-expect": "error",
|
|
8971
9394
|
"@sarj/no-trailing-value-narration": "error",
|
|
9395
|
+
"@sarj/no-declaration-comment-wall": "error",
|
|
8972
9396
|
"@sarj/no-type-member-comment-wall": "error",
|
|
8973
9397
|
"@sarj/no-unnecessary-use-client": "error",
|
|
8974
9398
|
"@sarj/no-unsafe-mock-casting": "error",
|
|
@@ -8995,6 +9419,9 @@ var strictRules = {
|
|
|
8995
9419
|
var plugin = {
|
|
8996
9420
|
meta,
|
|
8997
9421
|
rules: allRules,
|
|
9422
|
+
// Withdrawn names travel WITH the plugin so a consumer's migration script and
|
|
9423
|
+
// this repo's gates read one map, not two. See src/rules/_retired.ts.
|
|
9424
|
+
retiredRules,
|
|
8998
9425
|
configs: {
|
|
8999
9426
|
recommended: {},
|
|
9000
9427
|
strict: {}
|
|
@@ -9015,6 +9442,7 @@ var index_default = plugin;
|
|
|
9015
9442
|
0 && (module.exports = {
|
|
9016
9443
|
recommendedRules,
|
|
9017
9444
|
renamedRules,
|
|
9445
|
+
retiredRules,
|
|
9018
9446
|
rules,
|
|
9019
9447
|
strictRules
|
|
9020
9448
|
});
|