@sarj/eslint-plugin 15.9.0 → 15.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +833 -731
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +820 -718
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1456,7 +1456,7 @@ var no_comment_cruft_default = createRule({
|
|
|
1456
1456
|
sectionBanner: "Section-banner / region comment \u2014 remove the decoration or replace it with a named code boundary.",
|
|
1457
1457
|
fileHeaderPreamble: "File-header comment preamble \u2014 use a brief doc comment for the why, not a block of `//` lines.",
|
|
1458
1458
|
commentWall: "Statement comment wall ({{count}} narrated steps) \u2014 delete the walkthrough and name the operations in code; keep only constraints or rationale.",
|
|
1459
|
-
redundantNarration: "Comment narrates the code \u2014 delete it or
|
|
1459
|
+
redundantNarration: "Comment narrates the code \u2014 delete it; if the code still needs explanation, use clearer names or extract a named helper. Keep only constraints or rationale.",
|
|
1460
1460
|
placeholderImplementation: "Placeholder implementation comment \u2014 implement the behavior or use an explicit unsupported path.",
|
|
1461
1461
|
untrackedTodo: "Untracked TODO/FIXME marker \u2014 add an issue ticket or context link."
|
|
1462
1462
|
}
|
|
@@ -4212,6 +4212,7 @@ var DIRECTIVE_RE2 = /^(?:!|eslint\b|eslint-|@ts-|prettier|biome-|c8\b|v8\b|istan
|
|
|
4212
4212
|
var LICENSE_RE2 = /\b(?:copyright|spdx-license-identifier|licensed under)\b/i;
|
|
4213
4213
|
var TYPED_TAG_RE = /@(arg|argument|param|return|returns|yield|yields)\b/i;
|
|
4214
4214
|
var VALUE_TAG_RE = /@(example|deprecated|see|remarks|throws|internal|public|alpha|beta|since|template|fileoverview)\b/i;
|
|
4215
|
+
var ANY_TAG_RE = /(?:^|\s)@[A-Za-z][\w-]*\b/u;
|
|
4215
4216
|
var BOUNDARY_RE = /(?<=[.!?])["'`)\]]*\s+(?=[A-Z0-9`])/;
|
|
4216
4217
|
var BULLET_RE = /^\s*(?:[-*+] |\d+[.)] )/;
|
|
4217
4218
|
var HEADING_RE = /^[A-Za-z][A-Za-z ]+:$/;
|
|
@@ -4219,8 +4220,8 @@ var TECHNICAL_ANCHOR_RE = /https?:\/\/|`[^`\n]+`|:[a-z][a-z0-9_-]*:|(["'])[^"'\n
|
|
|
4219
4220
|
function body(comment) {
|
|
4220
4221
|
return comment.value.replace(/^\*/, "").split("\n").map((line) => line.replace(/^\s*\*?\s?/, "")).join("\n").trim();
|
|
4221
4222
|
}
|
|
4222
|
-
function eligible(text, includeValueTags) {
|
|
4223
|
-
return text.length > 0 && !DIRECTIVE_RE2.test(text) && !LICENSE_RE2.test(text) && (includeValueTags || !VALUE_TAG_RE.test(text));
|
|
4223
|
+
function eligible(text, includeValueTags, jsDoc = false) {
|
|
4224
|
+
return text.length > 0 && !DIRECTIVE_RE2.test(text) && !LICENSE_RE2.test(text) && (includeValueTags || !VALUE_TAG_RE.test(text) && (!jsDoc || !ANY_TAG_RE.test(text)));
|
|
4224
4225
|
}
|
|
4225
4226
|
function sentenceUnits(text) {
|
|
4226
4227
|
const cleaned = text.replace(/https?:\/\/\S+/g, "URL").replace(/`[^`\n]+`/g, "CODE").replace(/\b\d+\.\d+\b/g, "NUMBER").replace(/\b(?:e\.g\.|i\.e\.|vs\.|etc\.)/gi, "ABBREVIATION");
|
|
@@ -4260,7 +4261,9 @@ function proseGroups(filename, sourceCode, includeValueTags = false) {
|
|
|
4260
4261
|
const text = body(comment);
|
|
4261
4262
|
if (comment.type === "Block") {
|
|
4262
4263
|
flush();
|
|
4263
|
-
if (eligible(text, includeValueTags
|
|
4264
|
+
if (eligible(text, includeValueTags, comment.value.startsWith("*"))) {
|
|
4265
|
+
groups.push({ comment, text, hasTypedTags: TYPED_TAG_RE.test(text) });
|
|
4266
|
+
}
|
|
4264
4267
|
continue;
|
|
4265
4268
|
}
|
|
4266
4269
|
const ownLine = sourceCode.lines[comment.loc.start.line - 1]?.slice(0, comment.loc.start.column).trim() === "";
|
|
@@ -5956,7 +5959,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
5956
5959
|
},
|
|
5957
5960
|
schema: [],
|
|
5958
5961
|
messages: {
|
|
5959
|
-
restatesSignature: "JSDoc only re-spells the signature \u2014 delete it
|
|
5962
|
+
restatesSignature: "JSDoc only re-spells the signature \u2014 delete it; if the signature still needs explanation, improve its names or types. Keep constraints, failures, and rationale.",
|
|
5960
5963
|
deleteBlock: "Delete the JSDoc block."
|
|
5961
5964
|
}
|
|
5962
5965
|
},
|
|
@@ -7829,7 +7832,7 @@ var no_typed_doc_sections_default = createRule({
|
|
|
7829
7832
|
docs: { description: "Reject typed-signature repetition while preserving behavior that types cannot express." },
|
|
7830
7833
|
schema: [],
|
|
7831
7834
|
messages: {
|
|
7832
|
-
typedSection: "Typed JSDoc repeats parameters or returns \u2014 delete the tags
|
|
7835
|
+
typedSection: "Typed JSDoc repeats parameters or returns \u2014 delete the repeated tags; if the signature still needs explanation, improve its names or types. Keep constraints and rationale."
|
|
7833
7836
|
}
|
|
7834
7837
|
},
|
|
7835
7838
|
defaultOptions: [],
|
|
@@ -8098,6 +8101,9 @@ function labelStems(body2) {
|
|
|
8098
8101
|
function commentBody(comment) {
|
|
8099
8102
|
return comment.value.replace(/^\*+/, "").replace(/^[ \t]*\*[ \t]?/gm, "").trim();
|
|
8100
8103
|
}
|
|
8104
|
+
function hasJsDocTag(comment) {
|
|
8105
|
+
return comment.type === import_utils41.AST_TOKEN_TYPES.Block && comment.value.startsWith("*") && /(?:^|\s)@[A-Za-z][\w-]*\b/u.test(commentBody(comment));
|
|
8106
|
+
}
|
|
8101
8107
|
function carriesValue(body2) {
|
|
8102
8108
|
return isProtected(body2) || VALUE_TAG_RE2.test(body2) || DEFAULT_RE.test(body2) || DIGIT_RE.test(body2) || UNIT_WORD_RE.test(body2) || EXAMPLE_RE.test(body2) || BANNER_RE.test(body2) || NON_ASCII_LETTER_RE2.test(body2);
|
|
8103
8109
|
}
|
|
@@ -8208,7 +8214,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
8208
8214
|
},
|
|
8209
8215
|
schema: [WALL_SCHEMA],
|
|
8210
8216
|
messages: {
|
|
8211
|
-
commentWall: "{{restated}} of this declaration's {{commented}} member comments only re-spell
|
|
8217
|
+
commentWall: "{{restated}} of this declaration's {{commented}} member comments only re-spell member names \u2014 delete them; if a row still needs narration, give the member a clearer name. Keep constraints, lifecycle, and rationale."
|
|
8212
8218
|
}
|
|
8213
8219
|
},
|
|
8214
8220
|
defaultOptions: [WALL_DEFAULTS],
|
|
@@ -8268,7 +8274,7 @@ var no_declaration_comment_wall_default = createRule({
|
|
|
8268
8274
|
claimed.add(comment);
|
|
8269
8275
|
commented += 1;
|
|
8270
8276
|
const body2 = commentBody(comment);
|
|
8271
|
-
if (body2.length === 0 || carriesValue(body2) || isTagsOnly(body2) || isLabel(body2)) {
|
|
8277
|
+
if (body2.length === 0 || hasJsDocTag(comment) || carriesValue(body2) || isTagsOnly(body2) || isLabel(body2)) {
|
|
8272
8278
|
continue;
|
|
8273
8279
|
}
|
|
8274
8280
|
const { end, start } = declarationRange(member.node);
|
|
@@ -8516,7 +8522,7 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
8516
8522
|
},
|
|
8517
8523
|
schema: [WALL_SCHEMA],
|
|
8518
8524
|
messages: {
|
|
8519
|
-
commentWall: "{{restated}} of this type's {{commented}} member comments only re-spell
|
|
8525
|
+
commentWall: "{{restated}} of this type's {{commented}} member comments only re-spell names and types \u2014 delete them; if a row still needs narration, improve its name or type. Keep constraints and rationale."
|
|
8520
8526
|
}
|
|
8521
8527
|
},
|
|
8522
8528
|
defaultOptions: [WALL_DEFAULTS],
|
|
@@ -8574,7 +8580,9 @@ var no_type_member_comment_wall_default = createRule({
|
|
|
8574
8580
|
claimed.add(comment);
|
|
8575
8581
|
commented += 1;
|
|
8576
8582
|
const body2 = commentBody(comment);
|
|
8577
|
-
if (body2.length === 0 || carriesValue(body2) || isTagsOnly(body2))
|
|
8583
|
+
if (body2.length === 0 || hasJsDocTag(comment) || carriesValue(body2) || isTagsOnly(body2)) {
|
|
8584
|
+
continue;
|
|
8585
|
+
}
|
|
8578
8586
|
if (novelWords(body2, knownTokens(sourceCode.getText(member))) <= options.maxNovelWords) {
|
|
8579
8587
|
restated += 1;
|
|
8580
8588
|
}
|
|
@@ -9377,8 +9385,98 @@ function unwrapExpression(node) {
|
|
|
9377
9385
|
return node;
|
|
9378
9386
|
}
|
|
9379
9387
|
|
|
9380
|
-
// src/rules/
|
|
9388
|
+
// src/rules/test-phase-label-comment.ts
|
|
9381
9389
|
var import_utils49 = require("@typescript-eslint/utils");
|
|
9390
|
+
var PHASE_WORD = String.raw`arrange|act|assert(?:ion)?s?|given|when|then|exercise|execute|verif(?:y|ication)|cleanup|prepare|sanity(?:\s+check)?`;
|
|
9391
|
+
var PHASE_RE = new RegExp(
|
|
9392
|
+
String.raw`^[-=~*_#.\s]{0,40}(?:${PHASE_WORD})(?:\s*(?:[/&+,|]|->|and)\s*(?:${PHASE_WORD}))*[-=~*_#.\s:;!–—]{0,40}$`,
|
|
9393
|
+
"iu"
|
|
9394
|
+
);
|
|
9395
|
+
var testPhaseLabelCommentDocumentation = {
|
|
9396
|
+
summary: "Tests must not use bare Arrange, Act, Assert, Given, When, or Then phase comments.",
|
|
9397
|
+
rationale: "Phase labels narrate test structure without explaining behavior and often hide unclear names or oversized tests.",
|
|
9398
|
+
remediation: "Delete the label; if the phases remain hard to follow, extract a named helper or split the test.",
|
|
9399
|
+
category: "testing",
|
|
9400
|
+
autofix: "safe",
|
|
9401
|
+
limitations: [
|
|
9402
|
+
"Only standalone line comments in recognized test files are checked.",
|
|
9403
|
+
"Comments inside bracketed expressions or containing words outside the bounded phase grammar are preserved."
|
|
9404
|
+
],
|
|
9405
|
+
examples: [
|
|
9406
|
+
{
|
|
9407
|
+
id: "behavioral-comment",
|
|
9408
|
+
title: "Behavioral consequence is retained",
|
|
9409
|
+
outcome: "no-match",
|
|
9410
|
+
files: [{ path: "widget.test.ts", source: "// Then the retry loop would spin forever.\nexpect(run()).toBe(true);" }],
|
|
9411
|
+
focusPath: "widget.test.ts",
|
|
9412
|
+
expectedCount: 0,
|
|
9413
|
+
public: true
|
|
9414
|
+
},
|
|
9415
|
+
{
|
|
9416
|
+
id: "bare-phase-label",
|
|
9417
|
+
title: "Bare phase label is removed",
|
|
9418
|
+
outcome: "match",
|
|
9419
|
+
files: [{ path: "widget.test.ts", source: "// Arrange\nconst widget = makeWidget();" }],
|
|
9420
|
+
focusPath: "widget.test.ts",
|
|
9421
|
+
expectedCount: 1,
|
|
9422
|
+
fixedFiles: [{ path: "widget.test.ts", source: "const widget = makeWidget();" }],
|
|
9423
|
+
public: true
|
|
9424
|
+
}
|
|
9425
|
+
]
|
|
9426
|
+
};
|
|
9427
|
+
function insideExpression(sourceCode, comment) {
|
|
9428
|
+
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
9429
|
+
if (token === null) return false;
|
|
9430
|
+
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
9431
|
+
while (node != null && node.type !== import_utils49.AST_NODE_TYPES.Program) {
|
|
9432
|
+
if (node.type === import_utils49.AST_NODE_TYPES.ArrayExpression || node.type === import_utils49.AST_NODE_TYPES.ObjectExpression || node.type === import_utils49.AST_NODE_TYPES.CallExpression || node.type === import_utils49.AST_NODE_TYPES.NewExpression) return node.loc.start.line < comment.loc.start.line;
|
|
9433
|
+
if (/Statement$/u.test(node.type) || /Declaration$/u.test(node.type)) return false;
|
|
9434
|
+
node = node.parent;
|
|
9435
|
+
}
|
|
9436
|
+
return false;
|
|
9437
|
+
}
|
|
9438
|
+
function continuesProseRun(comments, index) {
|
|
9439
|
+
const comment = comments[index];
|
|
9440
|
+
if (comment?.type !== "Line") return false;
|
|
9441
|
+
return [comments[index - 1], comments[index + 1]].some(
|
|
9442
|
+
(neighbor) => neighbor?.type === "Line" && Math.abs(neighbor.loc.start.line - comment.loc.start.line) === 1 && !PHASE_RE.test(neighbor.value.trim())
|
|
9443
|
+
);
|
|
9444
|
+
}
|
|
9445
|
+
var test_phase_label_comment_default = createRule({
|
|
9446
|
+
name: "test-phase-label-comment",
|
|
9447
|
+
documentation: testPhaseLabelCommentDocumentation,
|
|
9448
|
+
meta: {
|
|
9449
|
+
type: "suggestion",
|
|
9450
|
+
fixable: "code",
|
|
9451
|
+
docs: { description: testPhaseLabelCommentDocumentation.summary },
|
|
9452
|
+
schema: [],
|
|
9453
|
+
messages: { removeLabel: "Bare test phase label \u2014 delete it and let the test names and helpers carry the structure." }
|
|
9454
|
+
},
|
|
9455
|
+
defaultOptions: [],
|
|
9456
|
+
create(context) {
|
|
9457
|
+
if (!isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
9458
|
+
return {
|
|
9459
|
+
Program() {
|
|
9460
|
+
const comments = context.sourceCode.getAllComments();
|
|
9461
|
+
for (const [index, comment] of comments.entries()) {
|
|
9462
|
+
if (comment.type !== "Line" || !PHASE_RE.test(comment.value.trim())) continue;
|
|
9463
|
+
const removal = wholeLineRemovalRange(context.sourceCode.text, comment);
|
|
9464
|
+
if (removal === null || insideExpression(context.sourceCode, comment) || continuesProseRun(comments, index)) {
|
|
9465
|
+
continue;
|
|
9466
|
+
}
|
|
9467
|
+
context.report({
|
|
9468
|
+
node: comment,
|
|
9469
|
+
messageId: "removeLabel",
|
|
9470
|
+
fix: (fixer) => fixer.removeRange(removal.range)
|
|
9471
|
+
});
|
|
9472
|
+
}
|
|
9473
|
+
}
|
|
9474
|
+
};
|
|
9475
|
+
}
|
|
9476
|
+
});
|
|
9477
|
+
|
|
9478
|
+
// src/rules/prefer-constant-time-secret-compare.ts
|
|
9479
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
9382
9480
|
var preferConstantTimeSecretCompareDocumentation = {
|
|
9383
9481
|
summary: "Disallow `===`/`!==` on a secret-like value; short-circuiting comparison leaks the secret through timing. Use a constant-time compare.",
|
|
9384
9482
|
rationale: "Ordinary equality stops at the first differing byte, allowing repeated measurements to reveal secret material.",
|
|
@@ -9397,14 +9495,14 @@ var SENTINEL_PREFIX_RE = /^(skip|sentinel|empty|none|missing|unset|placeholder|d
|
|
|
9397
9495
|
var AST_NODE_TYPE_RE = /^(?:TS|JSX)?[A-Z][A-Za-z]*(?:Signature|Keyword|Expression|Declaration|Element|Literal|Identifier)$/;
|
|
9398
9496
|
function isExcludedOperand(node) {
|
|
9399
9497
|
switch (node.type) {
|
|
9400
|
-
case
|
|
9498
|
+
case import_utils50.AST_NODE_TYPES.Literal:
|
|
9401
9499
|
return true;
|
|
9402
|
-
case
|
|
9500
|
+
case import_utils50.AST_NODE_TYPES.TemplateLiteral:
|
|
9403
9501
|
return node.expressions.length === 0;
|
|
9404
|
-
case
|
|
9502
|
+
case import_utils50.AST_NODE_TYPES.Identifier:
|
|
9405
9503
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
9406
|
-
case
|
|
9407
|
-
return !node.computed && node.property.type ===
|
|
9504
|
+
case import_utils50.AST_NODE_TYPES.MemberExpression:
|
|
9505
|
+
return !node.computed && node.property.type === import_utils50.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
9408
9506
|
default:
|
|
9409
9507
|
return false;
|
|
9410
9508
|
}
|
|
@@ -9415,23 +9513,23 @@ function isConstantReference(identifier) {
|
|
|
9415
9513
|
return identifier === identifier.toUpperCase() && /[A-Za-z]/.test(identifier);
|
|
9416
9514
|
}
|
|
9417
9515
|
function operandName(node) {
|
|
9418
|
-
if (node.type ===
|
|
9516
|
+
if (node.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
9419
9517
|
return node.name;
|
|
9420
9518
|
}
|
|
9421
|
-
if (node.type ===
|
|
9519
|
+
if (node.type === import_utils50.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
9422
9520
|
return node.property.name;
|
|
9423
9521
|
}
|
|
9424
9522
|
return null;
|
|
9425
9523
|
}
|
|
9426
9524
|
function isSecretOperand(node) {
|
|
9427
|
-
if (node.type ===
|
|
9525
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TemplateLiteral) {
|
|
9428
9526
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
9429
9527
|
}
|
|
9430
9528
|
const name = operandName(node);
|
|
9431
9529
|
return name !== null && isAuthSecretName(name);
|
|
9432
9530
|
}
|
|
9433
9531
|
function secretNameOf(node) {
|
|
9434
|
-
if (node.type ===
|
|
9532
|
+
if (node.type === import_utils50.AST_NODE_TYPES.TemplateLiteral) {
|
|
9435
9533
|
for (const expression of node.expressions) {
|
|
9436
9534
|
const nested = secretNameOf(expression);
|
|
9437
9535
|
if (nested !== null) {
|
|
@@ -9484,8 +9582,8 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
9484
9582
|
});
|
|
9485
9583
|
|
|
9486
9584
|
// src/rules/prefer-discriminated-union.ts
|
|
9487
|
-
var import_utils50 = require("@typescript-eslint/utils");
|
|
9488
9585
|
var import_utils51 = require("@typescript-eslint/utils");
|
|
9586
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
9489
9587
|
var preferDiscriminatedUnionDocumentation = {
|
|
9490
9588
|
summary: "Flag flat result objects with a required positive boolean status and optional success/failure payloads.",
|
|
9491
9589
|
rationale: "A boolean status plus optional branch data permits contradictory and incomplete states.",
|
|
@@ -9517,13 +9615,13 @@ var SUCCESS_PAYLOAD_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
9517
9615
|
]);
|
|
9518
9616
|
var REQUIRED_STATUS_MEMBER_COUNT = 1;
|
|
9519
9617
|
var FUNCTION_RETURN_OWNER_TYPES = /* @__PURE__ */ new Set([
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9618
|
+
import_utils52.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
9619
|
+
import_utils52.AST_NODE_TYPES.FunctionDeclaration,
|
|
9620
|
+
import_utils52.AST_NODE_TYPES.FunctionExpression,
|
|
9621
|
+
import_utils52.AST_NODE_TYPES.TSDeclareFunction,
|
|
9622
|
+
import_utils52.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
|
|
9623
|
+
import_utils52.AST_NODE_TYPES.TSFunctionType,
|
|
9624
|
+
import_utils52.AST_NODE_TYPES.TSMethodSignature
|
|
9527
9625
|
]);
|
|
9528
9626
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
9529
9627
|
let statusMemberCount = 0;
|
|
@@ -9531,7 +9629,7 @@ function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
|
9531
9629
|
let hasSuccessPayload = false;
|
|
9532
9630
|
let hasUnrecognizedMember = false;
|
|
9533
9631
|
for (const member of typeLiteral.members) {
|
|
9534
|
-
if (member.type !==
|
|
9632
|
+
if (member.type !== import_utils52.AST_NODE_TYPES.TSPropertySignature) {
|
|
9535
9633
|
hasUnrecognizedMember = true;
|
|
9536
9634
|
continue;
|
|
9537
9635
|
}
|
|
@@ -9555,26 +9653,26 @@ function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
|
9555
9653
|
return statusMemberCount === REQUIRED_STATUS_MEMBER_COUNT && hasFailurePayload && (hasSuccessPayload || !hasUnrecognizedMember);
|
|
9556
9654
|
}
|
|
9557
9655
|
function getMemberName(member) {
|
|
9558
|
-
if (member.type !==
|
|
9656
|
+
if (member.type !== import_utils52.AST_NODE_TYPES.TSPropertySignature) {
|
|
9559
9657
|
return null;
|
|
9560
9658
|
}
|
|
9561
9659
|
const { key } = member;
|
|
9562
|
-
if (key.type ===
|
|
9660
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
9563
9661
|
return key.name;
|
|
9564
9662
|
}
|
|
9565
|
-
if (key.type ===
|
|
9663
|
+
if (key.type === import_utils52.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
9566
9664
|
return key.value;
|
|
9567
9665
|
}
|
|
9568
9666
|
return null;
|
|
9569
9667
|
}
|
|
9570
9668
|
function isBooleanTyped(member) {
|
|
9571
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
9669
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils52.AST_NODE_TYPES.TSBooleanKeyword;
|
|
9572
9670
|
}
|
|
9573
9671
|
function inlineReturnTypeLiteral(node) {
|
|
9574
9672
|
let annotation = null;
|
|
9575
|
-
if (node.parent.type ===
|
|
9673
|
+
if (node.parent.type === import_utils52.AST_NODE_TYPES.TSTypeAnnotation) {
|
|
9576
9674
|
annotation = node.parent;
|
|
9577
|
-
} else if (node.parent.type ===
|
|
9675
|
+
} else if (node.parent.type === import_utils52.AST_NODE_TYPES.TSTypeParameterInstantiation && node.parent.params.length === 1 && node.parent.params[0] === node && node.parent.parent.type === import_utils52.AST_NODE_TYPES.TSTypeReference && node.parent.parent.typeName.type === import_utils52.AST_NODE_TYPES.Identifier && node.parent.parent.typeName.name === "Promise" && node.parent.parent.parent.type === import_utils52.AST_NODE_TYPES.TSTypeAnnotation) {
|
|
9578
9676
|
annotation = node.parent.parent.parent;
|
|
9579
9677
|
}
|
|
9580
9678
|
if (annotation === null) return null;
|
|
@@ -9614,7 +9712,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
9614
9712
|
}
|
|
9615
9713
|
const synthetic = {
|
|
9616
9714
|
...node.body,
|
|
9617
|
-
type:
|
|
9715
|
+
type: import_utils52.AST_NODE_TYPES.TSTypeLiteral,
|
|
9618
9716
|
members: node.body.body
|
|
9619
9717
|
};
|
|
9620
9718
|
checkTypeLiteral(synthetic, node);
|
|
@@ -9631,7 +9729,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
9631
9729
|
});
|
|
9632
9730
|
|
|
9633
9731
|
// src/rules/prefer-input-group-search.ts
|
|
9634
|
-
var
|
|
9732
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
9635
9733
|
var preferInputGroupSearchDocumentation = {
|
|
9636
9734
|
summary: "Require search icons and shared Input controls in the same visual wrapper to use InputGroup.",
|
|
9637
9735
|
rationale: "The shared compound control provides consistent spacing, focus behavior, and accessible composition.",
|
|
@@ -9652,15 +9750,15 @@ var MAX_JSX_DISTANCE = 2;
|
|
|
9652
9750
|
var SEARCH_EXPORTS = ["Search", "SearchIcon", "LucideSearch"];
|
|
9653
9751
|
function localNamedImports(node, importedName4) {
|
|
9654
9752
|
return node.specifiers.filter(
|
|
9655
|
-
(specifier) => specifier.type ===
|
|
9753
|
+
(specifier) => specifier.type === import_utils53.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils53.AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value) === importedName4
|
|
9656
9754
|
).map((specifier) => specifier.local.name);
|
|
9657
9755
|
}
|
|
9658
9756
|
function elementName(node) {
|
|
9659
|
-
return node.name.type ===
|
|
9757
|
+
return node.name.type === import_utils53.AST_NODE_TYPES.JSXIdentifier ? node.name.name : null;
|
|
9660
9758
|
}
|
|
9661
9759
|
function jsxAncestors(occurrence) {
|
|
9662
9760
|
return occurrence.ancestors.filter(
|
|
9663
|
-
(ancestor) => ancestor.type ===
|
|
9761
|
+
(ancestor) => ancestor.type === import_utils53.AST_NODE_TYPES.JSXElement
|
|
9664
9762
|
);
|
|
9665
9763
|
}
|
|
9666
9764
|
function isWithinInputGroup(occurrence, inputGroupNames) {
|
|
@@ -9773,7 +9871,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
9773
9871
|
});
|
|
9774
9872
|
|
|
9775
9873
|
// src/rules/prefer-immutable-module-constant.ts
|
|
9776
|
-
var
|
|
9874
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
9777
9875
|
var preferImmutableModuleConstantDocumentation = {
|
|
9778
9876
|
summary: "Require module-level constant collections to expose readonly state.",
|
|
9779
9877
|
rationale: "A const binding prevents reassignment but does not stop callers from mutating its array, object, Set, or Map contents.",
|
|
@@ -9821,59 +9919,59 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
9821
9919
|
"unshift"
|
|
9822
9920
|
]);
|
|
9823
9921
|
function isAsConst(node, sourceText) {
|
|
9824
|
-
if (node.type ===
|
|
9922
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils54.AST_NODE_TYPES.TSNonNullExpression) {
|
|
9825
9923
|
return isAsConst(node.expression, sourceText);
|
|
9826
9924
|
}
|
|
9827
|
-
if (node.type !==
|
|
9925
|
+
if (node.type !== import_utils54.AST_NODE_TYPES.TSAsExpression) return false;
|
|
9828
9926
|
return sourceText(node.typeAnnotation).trim() === "const";
|
|
9829
9927
|
}
|
|
9830
9928
|
function unwrapExpression2(node) {
|
|
9831
|
-
if (node.type ===
|
|
9929
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSAsExpression || node.type === import_utils54.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils54.AST_NODE_TYPES.TSNonNullExpression) {
|
|
9832
9930
|
return unwrapExpression2(node.expression);
|
|
9833
9931
|
}
|
|
9834
9932
|
return node;
|
|
9835
9933
|
}
|
|
9836
9934
|
function isObjectFreeze(node, isUnshadowedGlobal) {
|
|
9837
9935
|
const inner = unwrapExpression2(node);
|
|
9838
|
-
if (inner.type ===
|
|
9936
|
+
if (inner.type === import_utils54.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils54.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils54.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === import_utils54.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1) {
|
|
9839
9937
|
const argument = inner.arguments[0];
|
|
9840
|
-
return argument !== void 0 && argument.type !==
|
|
9938
|
+
return argument !== void 0 && argument.type !== import_utils54.AST_NODE_TYPES.SpreadElement && collectionKind(argument, isUnshadowedGlobal) === "literal";
|
|
9841
9939
|
}
|
|
9842
9940
|
return false;
|
|
9843
9941
|
}
|
|
9844
9942
|
function collectionKind(node, isUnshadowedGlobal) {
|
|
9845
9943
|
const inner = unwrapExpression2(node);
|
|
9846
|
-
if (inner.type ===
|
|
9944
|
+
if (inner.type === import_utils54.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils54.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils54.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === import_utils54.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils54.AST_NODE_TYPES.SpreadElement) {
|
|
9847
9945
|
return collectionKind(inner.arguments[0], isUnshadowedGlobal);
|
|
9848
9946
|
}
|
|
9849
|
-
if (inner.type ===
|
|
9947
|
+
if (inner.type === import_utils54.AST_NODE_TYPES.ArrayExpression || inner.type === import_utils54.AST_NODE_TYPES.ObjectExpression) {
|
|
9850
9948
|
return "literal";
|
|
9851
9949
|
}
|
|
9852
|
-
if (inner.type ===
|
|
9950
|
+
if (inner.type === import_utils54.AST_NODE_TYPES.NewExpression && inner.callee.type === import_utils54.AST_NODE_TYPES.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map") && isUnshadowedGlobal(inner.callee)) {
|
|
9853
9951
|
return inner.callee.name;
|
|
9854
9952
|
}
|
|
9855
9953
|
return null;
|
|
9856
9954
|
}
|
|
9857
9955
|
function declaredReadonlyType(node, kind, aliases) {
|
|
9858
|
-
const annotation = node.id.type ===
|
|
9956
|
+
const annotation = node.id.type === import_utils54.AST_NODE_TYPES.Identifier ? node.id.typeAnnotation : void 0;
|
|
9859
9957
|
if (annotation !== void 0 && isReadonlyTypeResolved(annotation.typeAnnotation, kind, aliases)) {
|
|
9860
9958
|
return true;
|
|
9861
9959
|
}
|
|
9862
|
-
return node.init?.type ===
|
|
9960
|
+
return node.init?.type === import_utils54.AST_NODE_TYPES.TSAsExpression && isReadonlyTypeResolved(node.init.typeAnnotation, kind, aliases);
|
|
9863
9961
|
}
|
|
9864
9962
|
function isReadonlyTypeResolved(node, kind, aliases, seen = /* @__PURE__ */ new Set()) {
|
|
9865
9963
|
if (isReadonlyType(node, kind)) return true;
|
|
9866
|
-
if (node.type !==
|
|
9964
|
+
if (node.type !== import_utils54.AST_NODE_TYPES.TSTypeReference || node.typeName.type !== import_utils54.AST_NODE_TYPES.Identifier) return false;
|
|
9867
9965
|
const name = node.typeName.name;
|
|
9868
9966
|
const target = aliases.get(name);
|
|
9869
9967
|
if (target === void 0 || seen.has(name)) return false;
|
|
9870
9968
|
return isReadonlyTypeResolved(target, kind, aliases, /* @__PURE__ */ new Set([...seen, name]));
|
|
9871
9969
|
}
|
|
9872
9970
|
function isReadonlyType(node, kind) {
|
|
9873
|
-
if (node.type ===
|
|
9971
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeOperator && node.operator === "readonly") {
|
|
9874
9972
|
return true;
|
|
9875
9973
|
}
|
|
9876
|
-
if (node.type !==
|
|
9974
|
+
if (node.type !== import_utils54.AST_NODE_TYPES.TSTypeReference || node.typeName.type !== import_utils54.AST_NODE_TYPES.Identifier) {
|
|
9877
9975
|
return false;
|
|
9878
9976
|
}
|
|
9879
9977
|
if (node.typeName.name === "Readonly") {
|
|
@@ -9882,31 +9980,31 @@ function isReadonlyType(node, kind) {
|
|
|
9882
9980
|
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
9883
9981
|
}
|
|
9884
9982
|
function hasUnknownExplicitType(node, aliases) {
|
|
9885
|
-
const annotation = node.id.type ===
|
|
9983
|
+
const annotation = node.id.type === import_utils54.AST_NODE_TYPES.Identifier ? node.id.typeAnnotation?.typeAnnotation : void 0;
|
|
9886
9984
|
if (annotation === void 0) return false;
|
|
9887
|
-
if (annotation.type ===
|
|
9888
|
-
if (annotation.type !==
|
|
9985
|
+
if (annotation.type === import_utils54.AST_NODE_TYPES.TSArrayType || annotation.type === import_utils54.AST_NODE_TYPES.TSTypeOperator) return false;
|
|
9986
|
+
if (annotation.type !== import_utils54.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils54.AST_NODE_TYPES.Identifier) return true;
|
|
9889
9987
|
return !aliases.has(annotation.typeName.name) && !["Array", "Map", "Readonly", "ReadonlyArray", "ReadonlyMap", "ReadonlySet", "Set"].includes(annotation.typeName.name);
|
|
9890
9988
|
}
|
|
9891
9989
|
function referenceMutates(identifier, isUnshadowedGlobal) {
|
|
9892
9990
|
let member = identifier.parent;
|
|
9893
|
-
if (member?.type !==
|
|
9894
|
-
return member?.type ===
|
|
9991
|
+
if (member?.type !== import_utils54.AST_NODE_TYPES.MemberExpression || member.object !== identifier) {
|
|
9992
|
+
return member?.type === import_utils54.AST_NODE_TYPES.CallExpression && member.arguments[0] === identifier && member.callee.type === import_utils54.AST_NODE_TYPES.MemberExpression && !member.callee.computed && member.callee.object.type === import_utils54.AST_NODE_TYPES.Identifier && member.callee.object.name === "Object" && isUnshadowedGlobal(member.callee.object) && member.callee.property.type === import_utils54.AST_NODE_TYPES.Identifier && member.callee.property.name === "assign";
|
|
9895
9993
|
}
|
|
9896
|
-
while (member.parent.type ===
|
|
9994
|
+
while (member.parent.type === import_utils54.AST_NODE_TYPES.MemberExpression && member.parent.object === member) {
|
|
9897
9995
|
member = member.parent;
|
|
9898
9996
|
}
|
|
9899
9997
|
const parent = member.parent;
|
|
9900
|
-
if (parent?.type ===
|
|
9998
|
+
if (parent?.type === import_utils54.AST_NODE_TYPES.AssignmentExpression && parent.left === member) {
|
|
9901
9999
|
return true;
|
|
9902
10000
|
}
|
|
9903
|
-
if (parent?.type ===
|
|
10001
|
+
if (parent?.type === import_utils54.AST_NODE_TYPES.UpdateExpression && parent.argument === member) {
|
|
9904
10002
|
return true;
|
|
9905
10003
|
}
|
|
9906
|
-
if (parent?.type ===
|
|
10004
|
+
if (parent?.type === import_utils54.AST_NODE_TYPES.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
9907
10005
|
return true;
|
|
9908
10006
|
}
|
|
9909
|
-
return parent?.type ===
|
|
10007
|
+
return parent?.type === import_utils54.AST_NODE_TYPES.CallExpression && parent.callee === member && (member.property.type === import_utils54.AST_NODE_TYPES.Identifier && !member.computed || member.property.type === import_utils54.AST_NODE_TYPES.Literal && typeof member.property.value === "string") && MUTATING_METHODS.has(member.property.type === import_utils54.AST_NODE_TYPES.Identifier ? member.property.name : member.property.value);
|
|
9910
10008
|
}
|
|
9911
10009
|
var prefer_immutable_module_constant_default = createRule({
|
|
9912
10010
|
name: "prefer-immutable-module-constant",
|
|
@@ -9926,7 +10024,7 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
9926
10024
|
create(context) {
|
|
9927
10025
|
const sourceCode = context.sourceCode;
|
|
9928
10026
|
const isUnshadowedGlobal = (identifier) => {
|
|
9929
|
-
const variable =
|
|
10027
|
+
const variable = import_utils54.ASTUtils.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
9930
10028
|
return variable === null || variable.defs.length === 0;
|
|
9931
10029
|
};
|
|
9932
10030
|
if (JAVASCRIPT_FILE_RE.test(context.filename) || isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
@@ -9943,10 +10041,10 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
9943
10041
|
seen.add(variable);
|
|
9944
10042
|
for (const reference of variable.references) {
|
|
9945
10043
|
const identifier = reference.identifier;
|
|
9946
|
-
if (identifier.type !==
|
|
10044
|
+
if (identifier.type !== import_utils54.AST_NODE_TYPES.Identifier) continue;
|
|
9947
10045
|
if (referenceMutates(identifier, isUnshadowedGlobal)) return true;
|
|
9948
10046
|
const declarator = identifier.parent;
|
|
9949
|
-
if (declarator.type !==
|
|
10047
|
+
if (declarator.type !== import_utils54.AST_NODE_TYPES.VariableDeclarator || declarator.init !== identifier || declarator.id.type !== import_utils54.AST_NODE_TYPES.Identifier || declarator.parent.type !== import_utils54.AST_NODE_TYPES.VariableDeclaration || declarator.parent.kind !== "const") {
|
|
9950
10048
|
continue;
|
|
9951
10049
|
}
|
|
9952
10050
|
const alias = sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -9958,32 +10056,32 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
9958
10056
|
return {
|
|
9959
10057
|
Program(node) {
|
|
9960
10058
|
for (const statement of node.body) {
|
|
9961
|
-
const declaration = statement.type ===
|
|
9962
|
-
if (declaration?.type ===
|
|
10059
|
+
const declaration = statement.type === import_utils54.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10060
|
+
if (declaration?.type === import_utils54.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
9963
10061
|
typeAliases2.set(declaration.id.name, declaration.typeAnnotation);
|
|
9964
10062
|
}
|
|
9965
|
-
if (statement.type ===
|
|
10063
|
+
if (statement.type === import_utils54.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
9966
10064
|
if (statement.source !== null || statement.exportKind === "type") continue;
|
|
9967
10065
|
for (const specifier of statement.specifiers) {
|
|
9968
|
-
if (specifier.type ===
|
|
10066
|
+
if (specifier.type === import_utils54.AST_NODE_TYPES.ExportSpecifier && specifier.exportKind !== "type" && specifier.local.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
9969
10067
|
exportedNames2.add(specifier.local.name);
|
|
9970
10068
|
}
|
|
9971
10069
|
}
|
|
9972
|
-
} else if (statement.type ===
|
|
10070
|
+
} else if (statement.type === import_utils54.AST_NODE_TYPES.ExportDefaultDeclaration && unwrapTransparentExport(statement.declaration)?.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
9973
10071
|
exportedNames2.add(unwrapTransparentExport(statement.declaration).name);
|
|
9974
10072
|
}
|
|
9975
10073
|
}
|
|
9976
10074
|
},
|
|
9977
10075
|
VariableDeclarator(node) {
|
|
9978
10076
|
const declaration = node.parent;
|
|
9979
|
-
if (declaration.type !==
|
|
10077
|
+
if (declaration.type !== import_utils54.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || node.id.type !== import_utils54.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
9980
10078
|
return;
|
|
9981
10079
|
}
|
|
9982
10080
|
const container = declaration.parent;
|
|
9983
|
-
if (container.type !==
|
|
10081
|
+
if (container.type !== import_utils54.AST_NODE_TYPES.Program && !(container.type === import_utils54.AST_NODE_TYPES.ExportNamedDeclaration && container.parent.type === import_utils54.AST_NODE_TYPES.Program)) {
|
|
9984
10082
|
return;
|
|
9985
10083
|
}
|
|
9986
|
-
const directlyExported = container.type ===
|
|
10084
|
+
const directlyExported = container.type === import_utils54.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
9987
10085
|
if (!CONSTANT_NAME.test(node.id.name) && !directlyExported && !exportedNames2.has(node.id.name)) {
|
|
9988
10086
|
return;
|
|
9989
10087
|
}
|
|
@@ -10008,14 +10106,14 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
10008
10106
|
}
|
|
10009
10107
|
});
|
|
10010
10108
|
function unwrapTransparentExport(node) {
|
|
10011
|
-
if (node.type ===
|
|
10109
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils54.AST_NODE_TYPES.TSNonNullExpression) {
|
|
10012
10110
|
return unwrapTransparentExport(node.expression);
|
|
10013
10111
|
}
|
|
10014
10112
|
return node;
|
|
10015
10113
|
}
|
|
10016
10114
|
|
|
10017
10115
|
// src/rules/prefer-shadcn-primitives.ts
|
|
10018
|
-
var
|
|
10116
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
10019
10117
|
var preferShadcnPrimitivesDocumentation = {
|
|
10020
10118
|
summary: "Require visible raw JSX controls to use the corresponding shared shadcn primitive.",
|
|
10021
10119
|
rationale: "Shared primitives centralize interaction, accessibility, and visual behavior across the product.",
|
|
@@ -10060,16 +10158,16 @@ var AMBIGUOUS_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
|
10060
10158
|
"submit"
|
|
10061
10159
|
]);
|
|
10062
10160
|
function rawElementName(node) {
|
|
10063
|
-
if (node.name.type !==
|
|
10161
|
+
if (node.name.type !== import_utils55.AST_NODE_TYPES.JSXIdentifier) return null;
|
|
10064
10162
|
const name = node.name.name;
|
|
10065
10163
|
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
10066
10164
|
}
|
|
10067
10165
|
function effectiveAttribute(node, attributeName) {
|
|
10068
10166
|
for (const attribute of node.attributes.toReversed()) {
|
|
10069
|
-
if (attribute.type ===
|
|
10167
|
+
if (attribute.type === import_utils55.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
10070
10168
|
return { kind: "unknown" };
|
|
10071
10169
|
}
|
|
10072
|
-
if (attribute.name.type !==
|
|
10170
|
+
if (attribute.name.type !== import_utils55.AST_NODE_TYPES.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
10073
10171
|
continue;
|
|
10074
10172
|
}
|
|
10075
10173
|
const value = staticString(attribute.value);
|
|
@@ -10078,17 +10176,17 @@ function effectiveAttribute(node, attributeName) {
|
|
|
10078
10176
|
return { kind: "missing" };
|
|
10079
10177
|
}
|
|
10080
10178
|
function staticString(value) {
|
|
10081
|
-
if (value?.type ===
|
|
10179
|
+
if (value?.type === import_utils55.AST_NODE_TYPES.Literal) {
|
|
10082
10180
|
return typeof value.value === "string" ? value.value : null;
|
|
10083
10181
|
}
|
|
10084
|
-
if (value?.type !==
|
|
10182
|
+
if (value?.type !== import_utils55.AST_NODE_TYPES.JSXExpressionContainer) return null;
|
|
10085
10183
|
return staticExpressionString(value.expression);
|
|
10086
10184
|
}
|
|
10087
10185
|
function staticExpressionString(expression) {
|
|
10088
|
-
if (expression.type ===
|
|
10186
|
+
if (expression.type === import_utils55.AST_NODE_TYPES.Literal) {
|
|
10089
10187
|
return typeof expression.value === "string" ? expression.value : null;
|
|
10090
10188
|
}
|
|
10091
|
-
if (expression.type ===
|
|
10189
|
+
if (expression.type === import_utils55.AST_NODE_TYPES.TemplateLiteral) {
|
|
10092
10190
|
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
10093
10191
|
for (const [index, substitution] of expression.expressions.entries()) {
|
|
10094
10192
|
const staticSubstitution = staticExpressionString(substitution);
|
|
@@ -10098,13 +10196,13 @@ function staticExpressionString(expression) {
|
|
|
10098
10196
|
}
|
|
10099
10197
|
return value;
|
|
10100
10198
|
}
|
|
10101
|
-
if (expression.type ===
|
|
10199
|
+
if (expression.type === import_utils55.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils55.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils55.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils55.AST_NODE_TYPES.TSTypeAssertion) {
|
|
10102
10200
|
return staticExpressionString(expression.expression);
|
|
10103
10201
|
}
|
|
10104
10202
|
return null;
|
|
10105
10203
|
}
|
|
10106
10204
|
function isLabelableElement(node) {
|
|
10107
|
-
if (node.openingElement.name.type !==
|
|
10205
|
+
if (node.openingElement.name.type !== import_utils55.AST_NODE_TYPES.JSXIdentifier) {
|
|
10108
10206
|
return false;
|
|
10109
10207
|
}
|
|
10110
10208
|
const name = node.openingElement.name.name;
|
|
@@ -10116,10 +10214,10 @@ function isLabelableElement(node) {
|
|
|
10116
10214
|
}
|
|
10117
10215
|
function containsLabelableElement(node) {
|
|
10118
10216
|
return node.children.some((child) => {
|
|
10119
|
-
if (child.type ===
|
|
10217
|
+
if (child.type === import_utils55.AST_NODE_TYPES.JSXElement) {
|
|
10120
10218
|
return isLabelableElement(child) || containsLabelableElement(child);
|
|
10121
10219
|
}
|
|
10122
|
-
if (child.type ===
|
|
10220
|
+
if (child.type === import_utils55.AST_NODE_TYPES.JSXFragment) {
|
|
10123
10221
|
return containsLabelableElement(child);
|
|
10124
10222
|
}
|
|
10125
10223
|
return false;
|
|
@@ -10128,7 +10226,7 @@ function containsLabelableElement(node) {
|
|
|
10128
10226
|
function isStaticallyAssociatedLabel(node) {
|
|
10129
10227
|
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
10130
10228
|
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
10131
|
-
return node.parent.type ===
|
|
10229
|
+
return node.parent.type === import_utils55.AST_NODE_TYPES.JSXElement && containsLabelableElement(node.parent);
|
|
10132
10230
|
}
|
|
10133
10231
|
function replacementFor(node, element) {
|
|
10134
10232
|
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
@@ -10199,7 +10297,7 @@ var prefer_shadcn_primitives_default = createRule({
|
|
|
10199
10297
|
});
|
|
10200
10298
|
|
|
10201
10299
|
// src/rules/prefer-module-level-constant.ts
|
|
10202
|
-
var
|
|
10300
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
10203
10301
|
var preferModuleLevelConstantDocumentation = {
|
|
10204
10302
|
summary: "Hoist literal-only constant collections and regexes out of function bodies to module scope so they are allocated once.",
|
|
10205
10303
|
rationale: "Recreating immutable lookup data on every call wastes allocations and obscures its constant nature.",
|
|
@@ -10239,9 +10337,9 @@ var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
|
10239
10337
|
"assign"
|
|
10240
10338
|
]);
|
|
10241
10339
|
var FUNCTION_TYPES7 = /* @__PURE__ */ new Set([
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10340
|
+
import_utils56.AST_NODE_TYPES.FunctionDeclaration,
|
|
10341
|
+
import_utils56.AST_NODE_TYPES.FunctionExpression,
|
|
10342
|
+
import_utils56.AST_NODE_TYPES.ArrowFunctionExpression
|
|
10245
10343
|
]);
|
|
10246
10344
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
10247
10345
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -10254,14 +10352,14 @@ function isLocalFixtureFile(filename) {
|
|
|
10254
10352
|
return isTestFile(filename) || isStoryFile(filename);
|
|
10255
10353
|
}
|
|
10256
10354
|
function unwrap3(node) {
|
|
10257
|
-
if (node.type ===
|
|
10355
|
+
if (node.type === import_utils56.AST_NODE_TYPES.TSAsExpression || node.type === import_utils56.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils56.AST_NODE_TYPES.TSNonNullExpression) {
|
|
10258
10356
|
return unwrap3(node.expression);
|
|
10259
10357
|
}
|
|
10260
10358
|
return node;
|
|
10261
10359
|
}
|
|
10262
10360
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
10263
10361
|
function isRegexLiteral(node) {
|
|
10264
|
-
return node.type ===
|
|
10362
|
+
return node.type === import_utils56.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
10265
10363
|
}
|
|
10266
10364
|
function isLiteralOnly(node, depth) {
|
|
10267
10365
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -10269,29 +10367,29 @@ function isLiteralOnly(node, depth) {
|
|
|
10269
10367
|
}
|
|
10270
10368
|
const inner = unwrap3(node);
|
|
10271
10369
|
switch (inner.type) {
|
|
10272
|
-
case
|
|
10370
|
+
case import_utils56.AST_NODE_TYPES.Literal: {
|
|
10273
10371
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
10274
10372
|
}
|
|
10275
|
-
case
|
|
10373
|
+
case import_utils56.AST_NODE_TYPES.TemplateLiteral: {
|
|
10276
10374
|
return inner.expressions.length === 0;
|
|
10277
10375
|
}
|
|
10278
|
-
case
|
|
10279
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
10376
|
+
case import_utils56.AST_NODE_TYPES.UnaryExpression: {
|
|
10377
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils56.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
10280
10378
|
}
|
|
10281
|
-
case
|
|
10379
|
+
case import_utils56.AST_NODE_TYPES.ArrayExpression: {
|
|
10282
10380
|
return inner.elements.every(
|
|
10283
|
-
(el) => el !== null && el.type !==
|
|
10381
|
+
(el) => el !== null && el.type !== import_utils56.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
10284
10382
|
);
|
|
10285
10383
|
}
|
|
10286
|
-
case
|
|
10384
|
+
case import_utils56.AST_NODE_TYPES.ObjectExpression: {
|
|
10287
10385
|
return inner.properties.every((prop) => {
|
|
10288
|
-
if (prop.type !==
|
|
10386
|
+
if (prop.type !== import_utils56.AST_NODE_TYPES.Property) {
|
|
10289
10387
|
return false;
|
|
10290
10388
|
}
|
|
10291
10389
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
10292
10390
|
return false;
|
|
10293
10391
|
}
|
|
10294
|
-
if (prop.computed && prop.key.type !==
|
|
10392
|
+
if (prop.computed && prop.key.type !== import_utils56.AST_NODE_TYPES.Literal) {
|
|
10295
10393
|
return false;
|
|
10296
10394
|
}
|
|
10297
10395
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -10313,19 +10411,19 @@ function classify(init, checkRegex) {
|
|
|
10313
10411
|
}
|
|
10314
10412
|
return { kind: "regex", size: 1 };
|
|
10315
10413
|
}
|
|
10316
|
-
if (node.type ===
|
|
10414
|
+
if (node.type === import_utils56.AST_NODE_TYPES.ArrayExpression) {
|
|
10317
10415
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
10318
10416
|
}
|
|
10319
|
-
if (node.type ===
|
|
10417
|
+
if (node.type === import_utils56.AST_NODE_TYPES.ObjectExpression) {
|
|
10320
10418
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
10321
10419
|
}
|
|
10322
|
-
if (node.type ===
|
|
10420
|
+
if (node.type === import_utils56.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils56.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
10323
10421
|
const arg = node.arguments[0];
|
|
10324
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
10422
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils56.AST_NODE_TYPES.SpreadElement) {
|
|
10325
10423
|
return null;
|
|
10326
10424
|
}
|
|
10327
10425
|
const entries = unwrap3(arg);
|
|
10328
|
-
if (entries.type !==
|
|
10426
|
+
if (entries.type !== import_utils56.AST_NODE_TYPES.ArrayExpression) {
|
|
10329
10427
|
return null;
|
|
10330
10428
|
}
|
|
10331
10429
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -10334,7 +10432,7 @@ function classify(init, checkRegex) {
|
|
|
10334
10432
|
}
|
|
10335
10433
|
function unwrapObjectFreeze(node) {
|
|
10336
10434
|
const inner = unwrap3(node);
|
|
10337
|
-
if (inner.type ===
|
|
10435
|
+
if (inner.type === import_utils56.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils56.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils56.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils56.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils56.AST_NODE_TYPES.SpreadElement) {
|
|
10338
10436
|
return unwrap3(inner.arguments[0]);
|
|
10339
10437
|
}
|
|
10340
10438
|
return inner;
|
|
@@ -10361,48 +10459,48 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
10361
10459
|
);
|
|
10362
10460
|
function isSafeRead(identifier) {
|
|
10363
10461
|
const parent = identifier.parent;
|
|
10364
|
-
if (parent.type ===
|
|
10462
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.MemberExpression) {
|
|
10365
10463
|
if (parent.object !== identifier) {
|
|
10366
10464
|
return true;
|
|
10367
10465
|
}
|
|
10368
10466
|
const grandparent = parent.parent;
|
|
10369
|
-
if (grandparent.type ===
|
|
10467
|
+
if (grandparent.type === import_utils56.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
10370
10468
|
return false;
|
|
10371
10469
|
}
|
|
10372
|
-
if (grandparent.type ===
|
|
10470
|
+
if (grandparent.type === import_utils56.AST_NODE_TYPES.UpdateExpression) {
|
|
10373
10471
|
return false;
|
|
10374
10472
|
}
|
|
10375
|
-
if (grandparent.type ===
|
|
10473
|
+
if (grandparent.type === import_utils56.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
10376
10474
|
return false;
|
|
10377
10475
|
}
|
|
10378
|
-
if (!parent.computed && parent.property.type ===
|
|
10476
|
+
if (!parent.computed && parent.property.type === import_utils56.AST_NODE_TYPES.Identifier && MUTATING_METHODS2.has(parent.property.name) && grandparent.type === import_utils56.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
10379
10477
|
return false;
|
|
10380
10478
|
}
|
|
10381
10479
|
return true;
|
|
10382
10480
|
}
|
|
10383
|
-
if (parent.type ===
|
|
10481
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
10384
10482
|
return true;
|
|
10385
10483
|
}
|
|
10386
|
-
if (parent.type ===
|
|
10484
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.SpreadElement) {
|
|
10387
10485
|
return true;
|
|
10388
10486
|
}
|
|
10389
|
-
if (parent.type ===
|
|
10487
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.BinaryExpression) {
|
|
10390
10488
|
return true;
|
|
10391
10489
|
}
|
|
10392
|
-
if (parent.type ===
|
|
10490
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
10393
10491
|
return true;
|
|
10394
10492
|
}
|
|
10395
|
-
if (parent.type ===
|
|
10493
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
10396
10494
|
return true;
|
|
10397
10495
|
}
|
|
10398
10496
|
return false;
|
|
10399
10497
|
}
|
|
10400
10498
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
10401
10499
|
const callee = node.callee;
|
|
10402
|
-
if (callee.type ===
|
|
10500
|
+
if (callee.type === import_utils56.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
10403
10501
|
return true;
|
|
10404
10502
|
}
|
|
10405
|
-
if (callee.type !==
|
|
10503
|
+
if (callee.type !== import_utils56.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils56.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils56.AST_NODE_TYPES.Identifier) {
|
|
10406
10504
|
return false;
|
|
10407
10505
|
}
|
|
10408
10506
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -10465,7 +10563,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
10465
10563
|
if (reference.isWrite()) {
|
|
10466
10564
|
return false;
|
|
10467
10565
|
}
|
|
10468
|
-
if (reference.identifier.type !==
|
|
10566
|
+
if (reference.identifier.type !== import_utils56.AST_NODE_TYPES.Identifier) {
|
|
10469
10567
|
return false;
|
|
10470
10568
|
}
|
|
10471
10569
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -10477,10 +10575,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
10477
10575
|
return {
|
|
10478
10576
|
VariableDeclarator(node) {
|
|
10479
10577
|
const declaration = node.parent;
|
|
10480
|
-
if (declaration.type !==
|
|
10578
|
+
if (declaration.type !== import_utils56.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
10481
10579
|
return;
|
|
10482
10580
|
}
|
|
10483
|
-
if (node.id.type !==
|
|
10581
|
+
if (node.id.type !== import_utils56.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
10484
10582
|
return;
|
|
10485
10583
|
}
|
|
10486
10584
|
if (enclosingFunction2(node) === null) {
|
|
@@ -10507,7 +10605,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
10507
10605
|
});
|
|
10508
10606
|
|
|
10509
10607
|
// src/rules/prefer-module-level-schema.ts
|
|
10510
|
-
var
|
|
10608
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
10511
10609
|
var preferModuleLevelSchemaDocumentation = {
|
|
10512
10610
|
summary: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function",
|
|
10513
10611
|
rationale: "A closed schema created inside a function is rebuilt on every call and cannot be reused or exported for inference.",
|
|
@@ -10574,9 +10672,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
10574
10672
|
"intl"
|
|
10575
10673
|
]);
|
|
10576
10674
|
var FUNCTION_TYPES8 = /* @__PURE__ */ new Set([
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10675
|
+
import_utils57.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
10676
|
+
import_utils57.AST_NODE_TYPES.FunctionDeclaration,
|
|
10677
|
+
import_utils57.AST_NODE_TYPES.FunctionExpression
|
|
10580
10678
|
]);
|
|
10581
10679
|
function schemaExpression(node) {
|
|
10582
10680
|
let current = node;
|
|
@@ -10585,10 +10683,10 @@ function schemaExpression(node) {
|
|
|
10585
10683
|
if (parent === void 0) {
|
|
10586
10684
|
return current;
|
|
10587
10685
|
}
|
|
10588
|
-
if (parent.type ===
|
|
10686
|
+
if (parent.type === import_utils57.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils57.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
10589
10687
|
return current;
|
|
10590
10688
|
}
|
|
10591
|
-
if (parent.type ===
|
|
10689
|
+
if (parent.type === import_utils57.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils57.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils57.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils57.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
10592
10690
|
current = parent;
|
|
10593
10691
|
continue;
|
|
10594
10692
|
}
|
|
@@ -10639,22 +10737,22 @@ function subtreeSome(root, predicate) {
|
|
|
10639
10737
|
function readsReceiver(node) {
|
|
10640
10738
|
return subtreeSome(
|
|
10641
10739
|
node,
|
|
10642
|
-
(inner) => inner.type ===
|
|
10740
|
+
(inner) => inner.type === import_utils57.AST_NODE_TYPES.ThisExpression || inner.type === import_utils57.AST_NODE_TYPES.Super || inner.type === import_utils57.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
10643
10741
|
);
|
|
10644
10742
|
}
|
|
10645
10743
|
function buildsLocalizedText(node) {
|
|
10646
10744
|
return subtreeSome(node, (inner) => {
|
|
10647
|
-
if (inner.type ===
|
|
10745
|
+
if (inner.type === import_utils57.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
10648
10746
|
return true;
|
|
10649
10747
|
}
|
|
10650
|
-
if (inner.type !==
|
|
10748
|
+
if (inner.type !== import_utils57.AST_NODE_TYPES.CallExpression) {
|
|
10651
10749
|
return false;
|
|
10652
10750
|
}
|
|
10653
10751
|
const { callee } = inner;
|
|
10654
|
-
if (callee.type ===
|
|
10752
|
+
if (callee.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
10655
10753
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
10656
10754
|
}
|
|
10657
|
-
return callee.type ===
|
|
10755
|
+
return callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils57.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
10658
10756
|
});
|
|
10659
10757
|
}
|
|
10660
10758
|
function collectReferences(scope, out) {
|
|
@@ -10718,15 +10816,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10718
10816
|
}
|
|
10719
10817
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
10720
10818
|
function isZodCall(node) {
|
|
10721
|
-
return node.type ===
|
|
10819
|
+
return node.type === import_utils57.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils57.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
10722
10820
|
}
|
|
10723
10821
|
function isCovered(node) {
|
|
10724
10822
|
let current = node.parent ?? void 0;
|
|
10725
10823
|
while (current !== void 0) {
|
|
10726
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
10824
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils57.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
10727
10825
|
return true;
|
|
10728
10826
|
}
|
|
10729
|
-
if (current.type ===
|
|
10827
|
+
if (current.type === import_utils57.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils57.AST_NODE_TYPES.Identifier && memoCallees.has(current.callee.name) || current.callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils57.AST_NODE_TYPES.Identifier && memoCallees.has(current.callee.property.name))) {
|
|
10730
10828
|
return true;
|
|
10731
10829
|
}
|
|
10732
10830
|
current = current.parent ?? void 0;
|
|
@@ -10741,11 +10839,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10741
10839
|
if (parent === void 0) {
|
|
10742
10840
|
return confirmed;
|
|
10743
10841
|
}
|
|
10744
|
-
if (parent.type ===
|
|
10842
|
+
if (parent.type === import_utils57.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils57.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils57.AST_NODE_TYPES.ArrayExpression) {
|
|
10745
10843
|
current = parent;
|
|
10746
10844
|
continue;
|
|
10747
10845
|
}
|
|
10748
|
-
if (parent.type ===
|
|
10846
|
+
if (parent.type === import_utils57.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
10749
10847
|
current = schemaExpression(parent);
|
|
10750
10848
|
confirmed = current;
|
|
10751
10849
|
continue;
|
|
@@ -10755,7 +10853,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10755
10853
|
}
|
|
10756
10854
|
function isSchemaComposition(node) {
|
|
10757
10855
|
const { callee } = node;
|
|
10758
|
-
const isCombinator = callee.type ===
|
|
10856
|
+
const isCombinator = callee.type === import_utils57.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils57.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
10759
10857
|
return isCombinator || isZodCall(node);
|
|
10760
10858
|
}
|
|
10761
10859
|
function closesOverNothing(node, enclosing) {
|
|
@@ -10775,12 +10873,12 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10775
10873
|
for (const definition of resolved.defs) {
|
|
10776
10874
|
if (definition.type === "ImportBinding") {
|
|
10777
10875
|
const parent = reference.identifier.parent;
|
|
10778
|
-
if (parent?.type ===
|
|
10876
|
+
if (parent?.type === import_utils57.AST_NODE_TYPES.CallExpression && parent.callee === reference.identifier && !zodNamespaces.has(reference.identifier.name)) {
|
|
10779
10877
|
return false;
|
|
10780
10878
|
}
|
|
10781
10879
|
continue;
|
|
10782
10880
|
}
|
|
10783
|
-
if (definition.node.type ===
|
|
10881
|
+
if (definition.node.type === import_utils57.AST_NODE_TYPES.VariableDeclarator && definition.node.parent.type === import_utils57.AST_NODE_TYPES.VariableDeclaration && definition.node.parent.kind !== "const") {
|
|
10784
10882
|
return false;
|
|
10785
10883
|
}
|
|
10786
10884
|
const [defStart, defEnd] = definition.node.range;
|
|
@@ -10796,13 +10894,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10796
10894
|
}
|
|
10797
10895
|
function ownerName(enclosing) {
|
|
10798
10896
|
const parent = enclosing.parent ?? void 0;
|
|
10799
|
-
if (enclosing.type ===
|
|
10897
|
+
if (enclosing.type === import_utils57.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
10800
10898
|
return enclosing.id.name;
|
|
10801
10899
|
}
|
|
10802
|
-
if (parent !== void 0 && parent.type ===
|
|
10900
|
+
if (parent !== void 0 && parent.type === import_utils57.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
10803
10901
|
return parent.id.name;
|
|
10804
10902
|
}
|
|
10805
|
-
if (parent !== void 0 && (parent.type ===
|
|
10903
|
+
if (parent !== void 0 && (parent.type === import_utils57.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils57.AST_NODE_TYPES.Property) && parent.key.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
10806
10904
|
return parent.key.name;
|
|
10807
10905
|
}
|
|
10808
10906
|
return "this function";
|
|
@@ -10813,7 +10911,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10813
10911
|
return;
|
|
10814
10912
|
}
|
|
10815
10913
|
for (const specifier of node.specifiers) {
|
|
10816
|
-
if (specifier.type ===
|
|
10914
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils57.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils57.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils57.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
10817
10915
|
zodNamespaces.add(specifier.local.name);
|
|
10818
10916
|
}
|
|
10819
10917
|
}
|
|
@@ -10823,7 +10921,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10823
10921
|
return;
|
|
10824
10922
|
}
|
|
10825
10923
|
const callee = node.callee;
|
|
10826
|
-
if (callee.property.type !==
|
|
10924
|
+
if (callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
10827
10925
|
return;
|
|
10828
10926
|
}
|
|
10829
10927
|
const factory = callee.property.name;
|
|
@@ -10838,7 +10936,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10838
10936
|
return;
|
|
10839
10937
|
}
|
|
10840
10938
|
const shape = node.arguments[0];
|
|
10841
|
-
if (shape !== void 0 && shape.type ===
|
|
10939
|
+
if (shape !== void 0 && shape.type === import_utils57.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
10842
10940
|
return;
|
|
10843
10941
|
}
|
|
10844
10942
|
const expression = schemaExpression(node);
|
|
@@ -10866,7 +10964,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10866
10964
|
});
|
|
10867
10965
|
|
|
10868
10966
|
// src/rules/prefer-native-random-uuid.ts
|
|
10869
|
-
var
|
|
10967
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
10870
10968
|
var preferNativeRandomUuidDocumentation = {
|
|
10871
10969
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
10872
10970
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -10880,7 +10978,7 @@ var preferNativeRandomUuidDocumentation = {
|
|
|
10880
10978
|
]
|
|
10881
10979
|
};
|
|
10882
10980
|
function requireUuid(node) {
|
|
10883
|
-
return node?.type ===
|
|
10981
|
+
return node?.type === import_utils58.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils58.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === import_utils58.AST_NODE_TYPES.Literal && node.arguments[0].value === "uuid";
|
|
10884
10982
|
}
|
|
10885
10983
|
var prefer_native_random_uuid_default = createRule({
|
|
10886
10984
|
name: "prefer-native-random-uuid",
|
|
@@ -10902,7 +11000,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
10902
11000
|
const directBindings = /* @__PURE__ */ new Set();
|
|
10903
11001
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
10904
11002
|
function resolve(identifier) {
|
|
10905
|
-
return
|
|
11003
|
+
return import_utils58.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
10906
11004
|
}
|
|
10907
11005
|
function record(identifier, destination) {
|
|
10908
11006
|
const variable = resolve(identifier);
|
|
@@ -10924,37 +11022,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
10924
11022
|
ImportDeclaration(node) {
|
|
10925
11023
|
if (node.source.value !== "uuid") return;
|
|
10926
11024
|
for (const specifier of node.specifiers) {
|
|
10927
|
-
if (specifier.type ===
|
|
11025
|
+
if (specifier.type === import_utils58.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils58.AST_NODE_TYPES.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
10928
11026
|
record(specifier.local, directBindings);
|
|
10929
|
-
} else if (specifier.type ===
|
|
11027
|
+
} else if (specifier.type === import_utils58.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
10930
11028
|
record(specifier.local, namespaceBindings);
|
|
10931
11029
|
}
|
|
10932
11030
|
}
|
|
10933
11031
|
},
|
|
10934
11032
|
VariableDeclarator(node) {
|
|
10935
11033
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
10936
|
-
if (node.init?.type !==
|
|
11034
|
+
if (node.init?.type !== import_utils58.AST_NODE_TYPES.CallExpression || node.init.callee.type !== import_utils58.AST_NODE_TYPES.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
10937
11035
|
return;
|
|
10938
11036
|
}
|
|
10939
|
-
if (node.id.type ===
|
|
11037
|
+
if (node.id.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
10940
11038
|
record(node.id, namespaceBindings);
|
|
10941
11039
|
return;
|
|
10942
11040
|
}
|
|
10943
|
-
if (node.id.type !==
|
|
11041
|
+
if (node.id.type !== import_utils58.AST_NODE_TYPES.ObjectPattern) return;
|
|
10944
11042
|
for (const property of node.id.properties) {
|
|
10945
|
-
if (property.type ===
|
|
11043
|
+
if (property.type === import_utils58.AST_NODE_TYPES.Property && !property.computed && (property.key.type === import_utils58.AST_NODE_TYPES.Identifier && property.key.name === "v4" || property.key.type === import_utils58.AST_NODE_TYPES.Literal && property.key.value === "v4") && property.value.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
10946
11044
|
record(property.value, directBindings);
|
|
10947
11045
|
}
|
|
10948
11046
|
}
|
|
10949
11047
|
},
|
|
10950
11048
|
"CallExpression:exit"(node) {
|
|
10951
11049
|
if (node.arguments.length !== 0) return;
|
|
10952
|
-
if (node.callee.type ===
|
|
11050
|
+
if (node.callee.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
10953
11051
|
const variable2 = resolve(node.callee);
|
|
10954
11052
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
10955
11053
|
return;
|
|
10956
11054
|
}
|
|
10957
|
-
if (node.callee.type !==
|
|
11055
|
+
if (node.callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.object.type !== import_utils58.AST_NODE_TYPES.Identifier || node.callee.property.type !== import_utils58.AST_NODE_TYPES.Identifier || node.callee.property.name !== "v4") {
|
|
10958
11056
|
return;
|
|
10959
11057
|
}
|
|
10960
11058
|
const variable = resolve(node.callee.object);
|
|
@@ -10965,7 +11063,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
10965
11063
|
});
|
|
10966
11064
|
|
|
10967
11065
|
// src/rules/prefer-non-nullable-collection.ts
|
|
10968
|
-
var
|
|
11066
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
10969
11067
|
var preferNonNullableCollectionDocumentation = {
|
|
10970
11068
|
summary: "Suggest non-null arrays only when local control flow proves the nullish state is equivalent to an empty collection.",
|
|
10971
11069
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
@@ -10981,33 +11079,33 @@ var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
|
10981
11079
|
function propertyName(node) {
|
|
10982
11080
|
const key = node.key;
|
|
10983
11081
|
if (node.computed) return null;
|
|
10984
|
-
if (key.type ===
|
|
10985
|
-
if (key.type ===
|
|
11082
|
+
if (key.type === import_utils59.AST_NODE_TYPES.Identifier) return key.name;
|
|
11083
|
+
if (key.type === import_utils59.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
10986
11084
|
return null;
|
|
10987
11085
|
}
|
|
10988
11086
|
function isArrayType(node) {
|
|
10989
|
-
if (node.type ===
|
|
10990
|
-
return node.type ===
|
|
11087
|
+
if (node.type === import_utils59.AST_NODE_TYPES.TSArrayType) return true;
|
|
11088
|
+
return node.type === import_utils59.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils59.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
10991
11089
|
}
|
|
10992
11090
|
function nullableProperty(node) {
|
|
10993
11091
|
if (node.optional) return null;
|
|
10994
11092
|
const name = propertyName(node);
|
|
10995
11093
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
10996
|
-
if (name === null || annotation?.type !==
|
|
11094
|
+
if (name === null || annotation?.type !== import_utils59.AST_NODE_TYPES.TSUnionType) return null;
|
|
10997
11095
|
const concrete = annotation.types.filter(
|
|
10998
|
-
(member) => member.type !==
|
|
11096
|
+
(member) => member.type !== import_utils59.AST_NODE_TYPES.TSNullKeyword && member.type !== import_utils59.AST_NODE_TYPES.TSUndefinedKeyword
|
|
10999
11097
|
);
|
|
11000
11098
|
if (concrete.length === 0 || !concrete.every(isArrayType)) return null;
|
|
11001
|
-
const acceptsNull = annotation.types.some((member) => member.type ===
|
|
11099
|
+
const acceptsNull = annotation.types.some((member) => member.type === import_utils59.AST_NODE_TYPES.TSNullKeyword);
|
|
11002
11100
|
const acceptsUndefined = annotation.types.some(
|
|
11003
|
-
(member) => member.type ===
|
|
11101
|
+
(member) => member.type === import_utils59.AST_NODE_TYPES.TSUndefinedKeyword
|
|
11004
11102
|
);
|
|
11005
11103
|
if (!acceptsNull && !acceptsUndefined) return null;
|
|
11006
11104
|
return { name, node, acceptsNull, acceptsUndefined };
|
|
11007
11105
|
}
|
|
11008
11106
|
function shapeProperties(members) {
|
|
11009
11107
|
return members.flatMap((member) => {
|
|
11010
|
-
if (member.type !==
|
|
11108
|
+
if (member.type !== import_utils59.AST_NODE_TYPES.TSPropertySignature) return [];
|
|
11011
11109
|
const property = nullableProperty(member);
|
|
11012
11110
|
return property === null ? [] : [property];
|
|
11013
11111
|
});
|
|
@@ -11015,14 +11113,14 @@ function shapeProperties(members) {
|
|
|
11015
11113
|
function typeIndex(program) {
|
|
11016
11114
|
const index = /* @__PURE__ */ new Map();
|
|
11017
11115
|
for (const statement of program.body) {
|
|
11018
|
-
const exported = statement.type ===
|
|
11116
|
+
const exported = statement.type === import_utils59.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
11019
11117
|
const declaration = exported ? statement.declaration : statement;
|
|
11020
|
-
if (declaration?.type ===
|
|
11118
|
+
if (declaration?.type === import_utils59.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
11021
11119
|
index.set(declaration.id.name, {
|
|
11022
11120
|
exported,
|
|
11023
11121
|
properties: shapeProperties(declaration.body.body)
|
|
11024
11122
|
});
|
|
11025
|
-
} else if (declaration?.type ===
|
|
11123
|
+
} else if (declaration?.type === import_utils59.AST_NODE_TYPES.TSTypeAliasDeclaration && declaration.typeAnnotation.type === import_utils59.AST_NODE_TYPES.TSTypeLiteral) {
|
|
11026
11124
|
index.set(declaration.id.name, {
|
|
11027
11125
|
exported,
|
|
11028
11126
|
properties: shapeProperties(declaration.typeAnnotation.members)
|
|
@@ -11032,42 +11130,42 @@ function typeIndex(program) {
|
|
|
11032
11130
|
return index;
|
|
11033
11131
|
}
|
|
11034
11132
|
function emptyArray(node) {
|
|
11035
|
-
return node.type ===
|
|
11133
|
+
return node.type === import_utils59.AST_NODE_TYPES.ArrayExpression && node.elements.length === 0;
|
|
11036
11134
|
}
|
|
11037
11135
|
function sameAccess(node, access) {
|
|
11038
11136
|
if (access.kind === "identifier") {
|
|
11039
|
-
return node.type ===
|
|
11137
|
+
return node.type === import_utils59.AST_NODE_TYPES.Identifier && node.name === access.name;
|
|
11040
11138
|
}
|
|
11041
|
-
return node.type ===
|
|
11139
|
+
return node.type === import_utils59.AST_NODE_TYPES.MemberExpression && !node.computed && node.object.type === import_utils59.AST_NODE_TYPES.Identifier && node.object.name === access.object && node.property.type === import_utils59.AST_NODE_TYPES.Identifier && node.property.name === access.property;
|
|
11042
11140
|
}
|
|
11043
11141
|
function isNullGuard(node, access) {
|
|
11044
|
-
if (node.type ===
|
|
11045
|
-
if (node.type !==
|
|
11142
|
+
if (node.type === import_utils59.AST_NODE_TYPES.UnaryExpression && node.operator === "!" && (sameAccess(node.argument, access) || optionalMemberLengthOf(node.argument, access))) return true;
|
|
11143
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.BinaryExpression || !["==", "==="].includes(node.operator)) {
|
|
11046
11144
|
return false;
|
|
11047
11145
|
}
|
|
11048
|
-
const nullish = (value) => value.type ===
|
|
11146
|
+
const nullish = (value) => value.type === import_utils59.AST_NODE_TYPES.Literal && value.value === null || value.type === import_utils59.AST_NODE_TYPES.Identifier && value.name === "undefined";
|
|
11049
11147
|
return sameAccess(node.left, access) && nullish(node.right) || sameAccess(node.right, access) && nullish(node.left);
|
|
11050
11148
|
}
|
|
11051
11149
|
function isEmptyGuard(node, access) {
|
|
11052
|
-
if (node.type ===
|
|
11053
|
-
if (node.type !==
|
|
11150
|
+
if (node.type === import_utils59.AST_NODE_TYPES.UnaryExpression && node.operator === "!" && memberLengthOf(node.argument, access)) return true;
|
|
11151
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.BinaryExpression || !["==", "===", "<="].includes(node.operator)) {
|
|
11054
11152
|
return false;
|
|
11055
11153
|
}
|
|
11056
|
-
const zero = (value) => value.type ===
|
|
11154
|
+
const zero = (value) => value.type === import_utils59.AST_NODE_TYPES.Literal && value.value === 0;
|
|
11057
11155
|
return memberLengthOf(node.left, access) && zero(node.right) || memberLengthOf(node.right, access) && zero(node.left);
|
|
11058
11156
|
}
|
|
11059
11157
|
function memberLengthOf(node, access) {
|
|
11060
|
-
const target = node.type ===
|
|
11061
|
-
return target.type ===
|
|
11158
|
+
const target = node.type === import_utils59.AST_NODE_TYPES.ChainExpression ? node.expression : node;
|
|
11159
|
+
return target.type === import_utils59.AST_NODE_TYPES.MemberExpression && !target.computed && target.property.type === import_utils59.AST_NODE_TYPES.Identifier && target.property.name === "length" && sameAccess(target.object, access);
|
|
11062
11160
|
}
|
|
11063
11161
|
function optionalMemberLengthOf(node, access) {
|
|
11064
|
-
return node.type ===
|
|
11162
|
+
return node.type === import_utils59.AST_NODE_TYPES.ChainExpression && node.expression.type === import_utils59.AST_NODE_TYPES.MemberExpression && node.expression.optional && memberLengthOf(node, access);
|
|
11065
11163
|
}
|
|
11066
11164
|
function hasEquivalentLeadingGuard(fn, access, visitorKeys) {
|
|
11067
|
-
if (fn.body.type !==
|
|
11165
|
+
if (fn.body.type !== import_utils59.AST_NODE_TYPES.BlockStatement) return false;
|
|
11068
11166
|
const first = fn.body.body[0];
|
|
11069
|
-
if (first?.type !==
|
|
11070
|
-
const terminating = first.consequent.type ===
|
|
11167
|
+
if (first?.type !== import_utils59.AST_NODE_TYPES.IfStatement) return false;
|
|
11168
|
+
const terminating = first.consequent.type === import_utils59.AST_NODE_TYPES.ReturnStatement || first.consequent.type === import_utils59.AST_NODE_TYPES.ThrowStatement || first.consequent.type === import_utils59.AST_NODE_TYPES.BlockStatement && first.consequent.body.length === 1 && (first.consequent.body[0]?.type === import_utils59.AST_NODE_TYPES.ReturnStatement || first.consequent.body[0]?.type === import_utils59.AST_NODE_TYPES.ThrowStatement);
|
|
11071
11169
|
if (!terminating) return false;
|
|
11072
11170
|
if (contains(first.consequent, visitorKeys, (node) => sameAccess(node, access))) return false;
|
|
11073
11171
|
return contains(first.test, visitorKeys, (node) => isNullGuard(node, access)) && contains(first.test, visitorKeys, (node) => isEmptyGuard(node, access));
|
|
@@ -11085,29 +11183,29 @@ function contains(node, visitorKeys, predicate) {
|
|
|
11085
11183
|
function belongsToFunction(node, fn) {
|
|
11086
11184
|
let current = node;
|
|
11087
11185
|
while (current !== void 0 && current !== fn) {
|
|
11088
|
-
if (current !== node && (current.type ===
|
|
11186
|
+
if (current !== node && (current.type === import_utils59.AST_NODE_TYPES.ArrowFunctionExpression || current.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils59.AST_NODE_TYPES.FunctionExpression)) return false;
|
|
11089
11187
|
current = current.parent;
|
|
11090
11188
|
}
|
|
11091
11189
|
return current === fn;
|
|
11092
11190
|
}
|
|
11093
11191
|
function directlyCoalesced(node) {
|
|
11094
11192
|
const parent = node.parent;
|
|
11095
|
-
return parent?.type ===
|
|
11193
|
+
return parent?.type === import_utils59.AST_NODE_TYPES.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
11096
11194
|
}
|
|
11097
11195
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
11098
|
-
const variable =
|
|
11196
|
+
const variable = import_utils59.ASTUtils.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
11099
11197
|
if (variable === null || variable.references.length === 0) return false;
|
|
11100
11198
|
return variable.references.every(
|
|
11101
11199
|
(reference) => belongsToFunction(reference.identifier, fn) && directlyCoalesced(reference.identifier)
|
|
11102
11200
|
);
|
|
11103
11201
|
}
|
|
11104
11202
|
function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
11105
|
-
const variable =
|
|
11203
|
+
const variable = import_utils59.ASTUtils.findVariable(context.sourceCode.getScope(object), object.name);
|
|
11106
11204
|
if (variable === null) return false;
|
|
11107
11205
|
const accesses = variable.references.flatMap((reference) => {
|
|
11108
11206
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
11109
11207
|
const parent = reference.identifier.parent;
|
|
11110
|
-
if (parent?.type ===
|
|
11208
|
+
if (parent?.type === import_utils59.AST_NODE_TYPES.MemberExpression && !parent.computed && parent.object === reference.identifier && parent.property.type === import_utils59.AST_NODE_TYPES.Identifier && parent.property.name === property) return [parent];
|
|
11111
11209
|
return [];
|
|
11112
11210
|
});
|
|
11113
11211
|
return accesses.length > 0 && accesses.every((access) => access !== null && directlyCoalesced(access));
|
|
@@ -11133,8 +11231,8 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
11133
11231
|
let shapes = /* @__PURE__ */ new Map();
|
|
11134
11232
|
const evidence = /* @__PURE__ */ new Map();
|
|
11135
11233
|
function propertiesFor(annotation) {
|
|
11136
|
-
if (annotation?.type ===
|
|
11137
|
-
if (annotation?.type ===
|
|
11234
|
+
if (annotation?.type === import_utils59.AST_NODE_TYPES.TSTypeLiteral) return shapeProperties(annotation.members);
|
|
11235
|
+
if (annotation?.type === import_utils59.AST_NODE_TYPES.TSTypeReference && annotation.typeName.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
11138
11236
|
const shape = shapes.get(annotation.typeName.name);
|
|
11139
11237
|
return shape?.exported === false ? shape.properties : [];
|
|
11140
11238
|
}
|
|
@@ -11147,21 +11245,21 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
11147
11245
|
}
|
|
11148
11246
|
function checkFunction(fn) {
|
|
11149
11247
|
for (const rawParameter of fn.params) {
|
|
11150
|
-
const parameter = rawParameter.type ===
|
|
11151
|
-
if (parameter.type ===
|
|
11248
|
+
const parameter = rawParameter.type === import_utils59.AST_NODE_TYPES.AssignmentPattern ? rawParameter.left : rawParameter;
|
|
11249
|
+
if (parameter.type === import_utils59.AST_NODE_TYPES.ObjectPattern) {
|
|
11152
11250
|
const properties2 = propertiesFor(parameter.typeAnnotation?.typeAnnotation);
|
|
11153
11251
|
for (const property of properties2) {
|
|
11154
11252
|
const bindingProperty = parameter.properties.find(
|
|
11155
|
-
(entry) => entry.type ===
|
|
11253
|
+
(entry) => entry.type === import_utils59.AST_NODE_TYPES.Property && !entry.computed && entry.key.type === import_utils59.AST_NODE_TYPES.Identifier && entry.key.name === property.name
|
|
11156
11254
|
);
|
|
11157
11255
|
if (bindingProperty === void 0) continue;
|
|
11158
11256
|
const value = bindingProperty.value;
|
|
11159
|
-
const binding = value.type ===
|
|
11160
|
-
if (binding.type !==
|
|
11257
|
+
const binding = value.type === import_utils59.AST_NODE_TYPES.AssignmentPattern ? value.left : value;
|
|
11258
|
+
if (binding.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
11161
11259
|
record(property, false);
|
|
11162
11260
|
continue;
|
|
11163
11261
|
}
|
|
11164
|
-
if (value.type ===
|
|
11262
|
+
if (value.type === import_utils59.AST_NODE_TYPES.AssignmentPattern && emptyArray(value.right) && property.acceptsUndefined && !property.acceptsNull) {
|
|
11165
11263
|
record(property, true);
|
|
11166
11264
|
continue;
|
|
11167
11265
|
}
|
|
@@ -11173,7 +11271,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
11173
11271
|
}
|
|
11174
11272
|
continue;
|
|
11175
11273
|
}
|
|
11176
|
-
if (parameter.type !==
|
|
11274
|
+
if (parameter.type !== import_utils59.AST_NODE_TYPES.Identifier) continue;
|
|
11177
11275
|
const properties = propertiesFor(parameter.typeAnnotation?.typeAnnotation);
|
|
11178
11276
|
for (const property of properties) {
|
|
11179
11277
|
const access = {
|
|
@@ -11210,7 +11308,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
11210
11308
|
});
|
|
11211
11309
|
|
|
11212
11310
|
// src/rules/prefer-await-in-async-return.ts
|
|
11213
|
-
var
|
|
11311
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
11214
11312
|
var ts2 = __toESM(require("typescript"), 1);
|
|
11215
11313
|
var preferAwaitInAsyncReturnDocumentation = {
|
|
11216
11314
|
summary: "Prefer explicit `await` when an async function directly returns one typed Promise `.then` transform.",
|
|
@@ -11252,10 +11350,10 @@ var preferAwaitInAsyncReturnDocumentation = {
|
|
|
11252
11350
|
};
|
|
11253
11351
|
function directAsyncReturnOwner(node) {
|
|
11254
11352
|
const parent = node.parent;
|
|
11255
|
-
if (parent.type ===
|
|
11353
|
+
if (parent.type === import_utils60.AST_NODE_TYPES.ArrowFunctionExpression && parent.body === node) {
|
|
11256
11354
|
return parent.async && !parent.generator ? parent : null;
|
|
11257
11355
|
}
|
|
11258
|
-
if (parent.type !==
|
|
11356
|
+
if (parent.type !== import_utils60.AST_NODE_TYPES.ReturnStatement || parent.argument !== node) {
|
|
11259
11357
|
return null;
|
|
11260
11358
|
}
|
|
11261
11359
|
let owner = parent.parent;
|
|
@@ -11265,15 +11363,15 @@ function directAsyncReturnOwner(node) {
|
|
|
11265
11363
|
return owner !== void 0 && owner.async && !owner.generator ? owner : null;
|
|
11266
11364
|
}
|
|
11267
11365
|
function isRuntimeFunction(node) {
|
|
11268
|
-
return node.type ===
|
|
11366
|
+
return node.type === import_utils60.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils60.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils60.AST_NODE_TYPES.FunctionExpression;
|
|
11269
11367
|
}
|
|
11270
11368
|
function promiseThenReceiver(node) {
|
|
11271
11369
|
const callee = node.callee;
|
|
11272
|
-
if (callee.type !==
|
|
11370
|
+
if (callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.property.type !== import_utils60.AST_NODE_TYPES.Identifier || callee.property.name !== "then" || node.optional || node.arguments.length !== 1) {
|
|
11273
11371
|
return null;
|
|
11274
11372
|
}
|
|
11275
11373
|
const callback = node.arguments[0];
|
|
11276
|
-
if (callback === void 0 || callback.type !==
|
|
11374
|
+
if (callback === void 0 || callback.type !== import_utils60.AST_NODE_TYPES.ArrowFunctionExpression && callback.type !== import_utils60.AST_NODE_TYPES.FunctionExpression) {
|
|
11277
11375
|
return null;
|
|
11278
11376
|
}
|
|
11279
11377
|
return callee.object;
|
|
@@ -11314,32 +11412,32 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
11314
11412
|
create(context) {
|
|
11315
11413
|
let services;
|
|
11316
11414
|
try {
|
|
11317
|
-
services =
|
|
11415
|
+
services = import_utils60.ESLintUtils.getParserServices(context);
|
|
11318
11416
|
} catch {
|
|
11319
11417
|
services = null;
|
|
11320
11418
|
}
|
|
11321
11419
|
if (services === null) return {};
|
|
11322
11420
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
11323
11421
|
const rememberFrameworkLoader = (identifier) => {
|
|
11324
|
-
const variable =
|
|
11422
|
+
const variable = import_utils60.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
11325
11423
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
11326
11424
|
};
|
|
11327
11425
|
const isFrameworkLoaderCallback = (owner) => {
|
|
11328
11426
|
const parent = owner.parent;
|
|
11329
|
-
if (parent.type !==
|
|
11330
|
-
const variable =
|
|
11427
|
+
if (parent.type !== import_utils60.AST_NODE_TYPES.CallExpression || parent.arguments[0] !== owner || parent.callee.type !== import_utils60.AST_NODE_TYPES.Identifier) return false;
|
|
11428
|
+
const variable = import_utils60.ASTUtils.findVariable(context.sourceCode.getScope(parent.callee), parent.callee.name);
|
|
11331
11429
|
return variable !== null && frameworkLoaders.has(variable);
|
|
11332
11430
|
};
|
|
11333
11431
|
return {
|
|
11334
11432
|
ImportDeclaration(node) {
|
|
11335
11433
|
if (node.source.value === "react") {
|
|
11336
11434
|
for (const specifier of node.specifiers) {
|
|
11337
|
-
if (specifier.type ===
|
|
11435
|
+
if (specifier.type === import_utils60.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils60.AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value) === "lazy") rememberFrameworkLoader(specifier.local);
|
|
11338
11436
|
}
|
|
11339
11437
|
}
|
|
11340
11438
|
if (node.source.value === "next/dynamic") {
|
|
11341
11439
|
for (const specifier of node.specifiers) {
|
|
11342
|
-
if (specifier.type ===
|
|
11440
|
+
if (specifier.type === import_utils60.AST_NODE_TYPES.ImportDefaultSpecifier) rememberFrameworkLoader(specifier.local);
|
|
11343
11441
|
}
|
|
11344
11442
|
}
|
|
11345
11443
|
},
|
|
@@ -11357,7 +11455,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
11357
11455
|
});
|
|
11358
11456
|
|
|
11359
11457
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
11360
|
-
var
|
|
11458
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
11361
11459
|
var preferSchemaForApiPayloadDocumentation = {
|
|
11362
11460
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
11363
11461
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -11372,9 +11470,9 @@ var preferSchemaForApiPayloadDocumentation = {
|
|
|
11372
11470
|
var unwrap4 = (node) => {
|
|
11373
11471
|
let current = node;
|
|
11374
11472
|
while (current !== null && current !== void 0) {
|
|
11375
|
-
if (current.type ===
|
|
11473
|
+
if (current.type === import_utils61.AST_NODE_TYPES.TSAsExpression || current.type === import_utils61.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils61.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils61.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
11376
11474
|
current = current.expression;
|
|
11377
|
-
} else if (current.type ===
|
|
11475
|
+
} else if (current.type === import_utils61.AST_NODE_TYPES.ChainExpression) {
|
|
11378
11476
|
current = current.expression;
|
|
11379
11477
|
} else {
|
|
11380
11478
|
break;
|
|
@@ -11389,23 +11487,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
11389
11487
|
]);
|
|
11390
11488
|
var isSchemaParseReference = (node) => {
|
|
11391
11489
|
const inner = unwrap4(node);
|
|
11392
|
-
return inner !== null && inner.type ===
|
|
11490
|
+
return inner !== null && inner.type === import_utils61.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils61.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
11393
11491
|
};
|
|
11394
11492
|
var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
11395
11493
|
let current = unwrap4(node);
|
|
11396
11494
|
if (current === null) return false;
|
|
11397
|
-
if (current.type ===
|
|
11495
|
+
if (current.type === import_utils61.AST_NODE_TYPES.AwaitExpression) {
|
|
11398
11496
|
current = unwrap4(current.argument);
|
|
11399
11497
|
}
|
|
11400
|
-
if (current === null || current.type !==
|
|
11498
|
+
if (current === null || current.type !== import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
11401
11499
|
return false;
|
|
11402
11500
|
}
|
|
11403
11501
|
const callee = unwrap4(current.callee);
|
|
11404
|
-
if (callee === null || callee.type !==
|
|
11502
|
+
if (callee === null || callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression) {
|
|
11405
11503
|
return false;
|
|
11406
11504
|
}
|
|
11407
11505
|
const property = unwrap4(callee.property);
|
|
11408
|
-
if (property === null || property.type !==
|
|
11506
|
+
if (property === null || property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
11409
11507
|
return false;
|
|
11410
11508
|
}
|
|
11411
11509
|
if (property.name === "json") {
|
|
@@ -11415,17 +11513,17 @@ var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
|
11415
11513
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
11416
11514
|
}
|
|
11417
11515
|
const object = unwrap4(callee.object);
|
|
11418
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
11516
|
+
return property.name === "parse" && object !== null && object.type === import_utils61.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
11419
11517
|
};
|
|
11420
11518
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
11421
11519
|
var isDirectLocalFileRead = (node) => {
|
|
11422
11520
|
let current = unwrap4(node);
|
|
11423
|
-
if (current?.type ===
|
|
11521
|
+
if (current?.type === import_utils61.AST_NODE_TYPES.AwaitExpression) {
|
|
11424
11522
|
current = unwrap4(current.argument);
|
|
11425
11523
|
}
|
|
11426
|
-
if (current?.type !==
|
|
11524
|
+
if (current?.type !== import_utils61.AST_NODE_TYPES.CallExpression) return false;
|
|
11427
11525
|
const callee = unwrap4(current.callee);
|
|
11428
|
-
const name = callee?.type ===
|
|
11526
|
+
const name = callee?.type === import_utils61.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils61.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
11429
11527
|
return name !== null && FILE_READ_RE.test(name);
|
|
11430
11528
|
};
|
|
11431
11529
|
var isLocalFileRead = (node) => {
|
|
@@ -11452,15 +11550,15 @@ var isLocalFileRead = (node) => {
|
|
|
11452
11550
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
11453
11551
|
var isInsideAssertion = (node) => {
|
|
11454
11552
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11455
|
-
if (current.type !==
|
|
11553
|
+
if (current.type !== import_utils61.AST_NODE_TYPES.CallExpression) continue;
|
|
11456
11554
|
let callee = current.callee;
|
|
11457
|
-
while (callee.type ===
|
|
11555
|
+
while (callee.type === import_utils61.AST_NODE_TYPES.MemberExpression) {
|
|
11458
11556
|
callee = callee.object;
|
|
11459
11557
|
}
|
|
11460
|
-
if (callee.type ===
|
|
11558
|
+
if (callee.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
11461
11559
|
callee = callee.callee;
|
|
11462
11560
|
}
|
|
11463
|
-
if (callee.type ===
|
|
11561
|
+
if (callee.type === import_utils61.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
11464
11562
|
return true;
|
|
11465
11563
|
}
|
|
11466
11564
|
}
|
|
@@ -11479,22 +11577,22 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
11479
11577
|
var isValidationRead = (node) => {
|
|
11480
11578
|
let current = node;
|
|
11481
11579
|
let parent = current.parent;
|
|
11482
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
11580
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils61.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils61.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils61.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils61.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils61.AST_NODE_TYPES.ChainExpression)) {
|
|
11483
11581
|
current = parent;
|
|
11484
11582
|
parent = parent.parent;
|
|
11485
11583
|
}
|
|
11486
11584
|
if (parent === null || parent === void 0) return false;
|
|
11487
|
-
if (parent.type ===
|
|
11585
|
+
if (parent.type === import_utils61.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
11488
11586
|
return true;
|
|
11489
11587
|
}
|
|
11490
|
-
if (parent.type !==
|
|
11588
|
+
if (parent.type !== import_utils61.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
11491
11589
|
return false;
|
|
11492
11590
|
}
|
|
11493
11591
|
const callee = parent.callee;
|
|
11494
|
-
if (callee.type ===
|
|
11592
|
+
if (callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils61.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
11495
11593
|
return parent.arguments.length === 1;
|
|
11496
11594
|
}
|
|
11497
|
-
return callee.type ===
|
|
11595
|
+
return callee.type === import_utils61.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
11498
11596
|
};
|
|
11499
11597
|
var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
11500
11598
|
"bigint",
|
|
@@ -11505,13 +11603,13 @@ var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
|
11505
11603
|
"undefined"
|
|
11506
11604
|
]);
|
|
11507
11605
|
var bindingValidationPolarity = (test, bindingName) => {
|
|
11508
|
-
if (test.type ===
|
|
11606
|
+
if (test.type === import_utils61.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
11509
11607
|
const inner = bindingValidationPolarity(test.argument, bindingName);
|
|
11510
11608
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
11511
11609
|
}
|
|
11512
|
-
if (test.type ===
|
|
11513
|
-
const typeofName = (node) => node.type ===
|
|
11514
|
-
const literalType = (node) => node.type ===
|
|
11610
|
+
if (test.type === import_utils61.AST_NODE_TYPES.BinaryExpression) {
|
|
11611
|
+
const typeofName = (node) => node.type === import_utils61.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && node.argument.type === import_utils61.AST_NODE_TYPES.Identifier ? node.argument.name : null;
|
|
11612
|
+
const literalType = (node) => node.type === import_utils61.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value) ? node.value : null;
|
|
11515
11613
|
const matches = typeofName(test.left) === bindingName && literalType(test.right) !== null || typeofName(test.right) === bindingName && literalType(test.left) !== null;
|
|
11516
11614
|
if (!matches) return null;
|
|
11517
11615
|
if (test.operator === "===" || test.operator === "==") {
|
|
@@ -11519,9 +11617,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
11519
11617
|
}
|
|
11520
11618
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
11521
11619
|
}
|
|
11522
|
-
return test.type ===
|
|
11620
|
+
return test.type === import_utils61.AST_NODE_TYPES.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === import_utils61.AST_NODE_TYPES.Identifier && test.arguments[0].name === bindingName && test.callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && !test.callee.computed && test.callee.object.type === import_utils61.AST_NODE_TYPES.Identifier && test.callee.object.name === "Array" && test.callee.property.type === import_utils61.AST_NODE_TYPES.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
11523
11621
|
};
|
|
11524
|
-
var plainMemberAccess = (node) => node.type ===
|
|
11622
|
+
var plainMemberAccess = (node) => node.type === import_utils61.AST_NODE_TYPES.MemberExpression && !node.computed && node.object.type === import_utils61.AST_NODE_TYPES.Identifier && node.property.type === import_utils61.AST_NODE_TYPES.Identifier ? { object: node.object.name, property: node.property.name } : null;
|
|
11525
11623
|
var isSamePlainMember = (node, access) => {
|
|
11526
11624
|
const candidate = plainMemberAccess(node);
|
|
11527
11625
|
return candidate !== null && candidate.object === access.object && candidate.property === access.property;
|
|
@@ -11529,19 +11627,19 @@ var isSamePlainMember = (node, access) => {
|
|
|
11529
11627
|
var nodeWithin2 = (node, container) => node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
11530
11628
|
var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
11531
11629
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11532
|
-
if (current.type ===
|
|
11630
|
+
if (current.type === import_utils61.AST_NODE_TYPES.ConditionalExpression) {
|
|
11533
11631
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
11534
11632
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
11535
11633
|
return true;
|
|
11536
11634
|
}
|
|
11537
11635
|
}
|
|
11538
|
-
if (current.type ===
|
|
11636
|
+
if (current.type === import_utils61.AST_NODE_TYPES.IfStatement) {
|
|
11539
11637
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
11540
11638
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
11541
11639
|
return true;
|
|
11542
11640
|
}
|
|
11543
11641
|
}
|
|
11544
|
-
if (current.type ===
|
|
11642
|
+
if (current.type === import_utils61.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils61.AST_NODE_TYPES.FunctionExpression || current.type === import_utils61.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
11545
11643
|
return false;
|
|
11546
11644
|
}
|
|
11547
11645
|
}
|
|
@@ -11549,32 +11647,32 @@ var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
|
11549
11647
|
};
|
|
11550
11648
|
var isMemberUseWithinValidatedBranch = (node, access) => {
|
|
11551
11649
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11552
|
-
if (current.type ===
|
|
11650
|
+
if (current.type === import_utils61.AST_NODE_TYPES.ConditionalExpression) {
|
|
11553
11651
|
const polarity = memberValidationPolarity(current.test, access);
|
|
11554
11652
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
11555
11653
|
return true;
|
|
11556
11654
|
}
|
|
11557
11655
|
}
|
|
11558
|
-
if (current.type ===
|
|
11656
|
+
if (current.type === import_utils61.AST_NODE_TYPES.IfStatement) {
|
|
11559
11657
|
const polarity = memberValidationPolarity(current.test, access);
|
|
11560
11658
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
11561
11659
|
return true;
|
|
11562
11660
|
}
|
|
11563
11661
|
}
|
|
11564
|
-
if (current.type ===
|
|
11662
|
+
if (current.type === import_utils61.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils61.AST_NODE_TYPES.FunctionExpression || current.type === import_utils61.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
11565
11663
|
return false;
|
|
11566
11664
|
}
|
|
11567
11665
|
}
|
|
11568
11666
|
return false;
|
|
11569
11667
|
};
|
|
11570
11668
|
var memberValidationPolarity = (test, access) => {
|
|
11571
|
-
if (test.type ===
|
|
11669
|
+
if (test.type === import_utils61.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
11572
11670
|
const inner = memberValidationPolarity(test.argument, access);
|
|
11573
11671
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
11574
11672
|
}
|
|
11575
|
-
if (test.type ===
|
|
11576
|
-
const isMatchingTypeof = (node) => node.type ===
|
|
11577
|
-
const isPrimitiveType = (node) => node.type ===
|
|
11673
|
+
if (test.type === import_utils61.AST_NODE_TYPES.BinaryExpression) {
|
|
11674
|
+
const isMatchingTypeof = (node) => node.type === import_utils61.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && isSamePlainMember(node.argument, access);
|
|
11675
|
+
const isPrimitiveType = (node) => node.type === import_utils61.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value);
|
|
11578
11676
|
if (!(isMatchingTypeof(test.left) && isPrimitiveType(test.right) || isMatchingTypeof(test.right) && isPrimitiveType(test.left))) {
|
|
11579
11677
|
return null;
|
|
11580
11678
|
}
|
|
@@ -11583,15 +11681,15 @@ var memberValidationPolarity = (test, access) => {
|
|
|
11583
11681
|
}
|
|
11584
11682
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
11585
11683
|
}
|
|
11586
|
-
return test.type ===
|
|
11684
|
+
return test.type === import_utils61.AST_NODE_TYPES.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== import_utils61.AST_NODE_TYPES.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && !test.callee.computed && test.callee.object.type === import_utils61.AST_NODE_TYPES.Identifier && test.callee.object.name === "Array" && test.callee.property.type === import_utils61.AST_NODE_TYPES.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
11587
11685
|
};
|
|
11588
11686
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
11589
11687
|
const isValidationReference = (identifier) => {
|
|
11590
11688
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11591
|
-
if ((current.type ===
|
|
11689
|
+
if ((current.type === import_utils61.AST_NODE_TYPES.BinaryExpression || current.type === import_utils61.AST_NODE_TYPES.CallExpression || current.type === import_utils61.AST_NODE_TYPES.UnaryExpression) && bindingValidationPolarity(current, identifier.name) !== null) {
|
|
11592
11690
|
return true;
|
|
11593
11691
|
}
|
|
11594
|
-
if (current.type !==
|
|
11692
|
+
if (current.type !== import_utils61.AST_NODE_TYPES.UnaryExpression && current.type !== import_utils61.AST_NODE_TYPES.MemberExpression && current.type !== import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
11595
11693
|
return false;
|
|
11596
11694
|
}
|
|
11597
11695
|
}
|
|
@@ -11599,7 +11697,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11599
11697
|
};
|
|
11600
11698
|
const isGuardedUse = (identifier) => {
|
|
11601
11699
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11602
|
-
if (current.type ===
|
|
11700
|
+
if (current.type === import_utils61.AST_NODE_TYPES.ConditionalExpression) {
|
|
11603
11701
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
11604
11702
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
11605
11703
|
return true;
|
|
@@ -11608,7 +11706,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11608
11706
|
return true;
|
|
11609
11707
|
}
|
|
11610
11708
|
}
|
|
11611
|
-
if (current.type ===
|
|
11709
|
+
if (current.type === import_utils61.AST_NODE_TYPES.IfStatement) {
|
|
11612
11710
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
11613
11711
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
11614
11712
|
return true;
|
|
@@ -11617,14 +11715,14 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11617
11715
|
return true;
|
|
11618
11716
|
}
|
|
11619
11717
|
}
|
|
11620
|
-
if (current.type ===
|
|
11718
|
+
if (current.type === import_utils61.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils61.AST_NODE_TYPES.FunctionExpression || current.type === import_utils61.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
11621
11719
|
return false;
|
|
11622
11720
|
}
|
|
11623
11721
|
}
|
|
11624
11722
|
return false;
|
|
11625
11723
|
};
|
|
11626
11724
|
const declarator = member.parent;
|
|
11627
|
-
if (declarator.type !==
|
|
11725
|
+
if (declarator.type !== import_utils61.AST_NODE_TYPES.VariableDeclarator || declarator.init !== member || declarator.id.type !== import_utils61.AST_NODE_TYPES.Identifier || declarator.parent.type !== import_utils61.AST_NODE_TYPES.VariableDeclaration || declarator.parent.kind !== "const") {
|
|
11628
11726
|
return false;
|
|
11629
11727
|
}
|
|
11630
11728
|
const extracted = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -11632,7 +11730,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11632
11730
|
let hasValueUse = false;
|
|
11633
11731
|
for (const reference of extracted.references) {
|
|
11634
11732
|
const identifier = reference.identifier;
|
|
11635
|
-
if (identifier.type !==
|
|
11733
|
+
if (identifier.type !== import_utils61.AST_NODE_TYPES.Identifier) return false;
|
|
11636
11734
|
if (nodeWithin2(identifier, declarator)) continue;
|
|
11637
11735
|
if (isValidationReference(identifier)) continue;
|
|
11638
11736
|
hasValueUse = true;
|
|
@@ -11645,17 +11743,17 @@ var isGuardTestPosition = (node) => {
|
|
|
11645
11743
|
let parent = current.parent;
|
|
11646
11744
|
while (parent !== void 0 && parent !== null) {
|
|
11647
11745
|
switch (parent.type) {
|
|
11648
|
-
case
|
|
11649
|
-
case
|
|
11650
|
-
case
|
|
11746
|
+
case import_utils61.AST_NODE_TYPES.UnaryExpression:
|
|
11747
|
+
case import_utils61.AST_NODE_TYPES.LogicalExpression:
|
|
11748
|
+
case import_utils61.AST_NODE_TYPES.ChainExpression:
|
|
11651
11749
|
current = parent;
|
|
11652
11750
|
parent = parent.parent;
|
|
11653
11751
|
continue;
|
|
11654
|
-
case
|
|
11655
|
-
case
|
|
11656
|
-
case
|
|
11657
|
-
case
|
|
11658
|
-
case
|
|
11752
|
+
case import_utils61.AST_NODE_TYPES.IfStatement:
|
|
11753
|
+
case import_utils61.AST_NODE_TYPES.ConditionalExpression:
|
|
11754
|
+
case import_utils61.AST_NODE_TYPES.WhileStatement:
|
|
11755
|
+
case import_utils61.AST_NODE_TYPES.DoWhileStatement:
|
|
11756
|
+
case import_utils61.AST_NODE_TYPES.ForStatement:
|
|
11659
11757
|
return parent.test === current;
|
|
11660
11758
|
default:
|
|
11661
11759
|
return false;
|
|
@@ -11665,7 +11763,7 @@ var isGuardTestPosition = (node) => {
|
|
|
11665
11763
|
};
|
|
11666
11764
|
var unvalidatedVariableRef = (node, scope, tracked) => {
|
|
11667
11765
|
const unwrapped = unwrap4(node);
|
|
11668
|
-
if (unwrapped === null || unwrapped.type !==
|
|
11766
|
+
if (unwrapped === null || unwrapped.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
11669
11767
|
return null;
|
|
11670
11768
|
}
|
|
11671
11769
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -11694,7 +11792,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11694
11792
|
const localFileTextVariables = /* @__PURE__ */ new Set();
|
|
11695
11793
|
const localFileTextRef = (node, scope) => {
|
|
11696
11794
|
const unwrapped = unwrap4(node);
|
|
11697
|
-
if (unwrapped?.type !==
|
|
11795
|
+
if (unwrapped?.type !== import_utils61.AST_NODE_TYPES.Identifier) return null;
|
|
11698
11796
|
const variable = findVariable2(scope, unwrapped.name);
|
|
11699
11797
|
return variable !== null && localFileTextVariables.has(variable) ? variable : null;
|
|
11700
11798
|
};
|
|
@@ -11763,7 +11861,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11763
11861
|
return {
|
|
11764
11862
|
VariableDeclarator(node) {
|
|
11765
11863
|
const scope = context.sourceCode.getScope(node);
|
|
11766
|
-
if (node.id.type ===
|
|
11864
|
+
if (node.id.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
11767
11865
|
const variable = context.sourceCode.getDeclaredVariables(node)[0];
|
|
11768
11866
|
if (variable !== void 0) {
|
|
11769
11867
|
updateLocalFileText(variable, node.init, scope);
|
|
@@ -11771,7 +11869,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11771
11869
|
trackInitializer(node, scope);
|
|
11772
11870
|
return;
|
|
11773
11871
|
}
|
|
11774
|
-
if (node.id.type ===
|
|
11872
|
+
if (node.id.type === import_utils61.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils61.AST_NODE_TYPES.ArrayPattern) {
|
|
11775
11873
|
if (isRawPayloadSource(
|
|
11776
11874
|
node.init,
|
|
11777
11875
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
@@ -11788,7 +11886,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11788
11886
|
},
|
|
11789
11887
|
AssignmentExpression(node) {
|
|
11790
11888
|
const scope = context.sourceCode.getScope(node);
|
|
11791
|
-
if (node.left.type ===
|
|
11889
|
+
if (node.left.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
11792
11890
|
const variable = findVariable2(scope, node.left.name);
|
|
11793
11891
|
if (variable === null) return;
|
|
11794
11892
|
const isLocalText = (candidate) => localFileTextRef(candidate, scope) !== null;
|
|
@@ -11802,7 +11900,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11802
11900
|
}
|
|
11803
11901
|
return;
|
|
11804
11902
|
}
|
|
11805
|
-
if (node.left.type ===
|
|
11903
|
+
if (node.left.type === import_utils61.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils61.AST_NODE_TYPES.ArrayPattern) {
|
|
11806
11904
|
if (isRawPayloadSource(
|
|
11807
11905
|
node.right,
|
|
11808
11906
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
@@ -11822,15 +11920,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11822
11920
|
}
|
|
11823
11921
|
},
|
|
11824
11922
|
CallExpression(node) {
|
|
11825
|
-
if (node.callee.type !==
|
|
11923
|
+
if (node.callee.type !== import_utils61.AST_NODE_TYPES.Identifier) return;
|
|
11826
11924
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
11827
11925
|
return;
|
|
11828
11926
|
}
|
|
11829
11927
|
const scope = context.sourceCode.getScope(node);
|
|
11830
11928
|
for (const arg of node.arguments) {
|
|
11831
|
-
if (arg.type ===
|
|
11929
|
+
if (arg.type === import_utils61.AST_NODE_TYPES.SpreadElement) continue;
|
|
11832
11930
|
const unwrapped = unwrap4(arg);
|
|
11833
|
-
if (unwrapped === null || unwrapped.type !==
|
|
11931
|
+
if (unwrapped === null || unwrapped.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
11834
11932
|
continue;
|
|
11835
11933
|
}
|
|
11836
11934
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -11847,14 +11945,14 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11847
11945
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
11848
11946
|
)) {
|
|
11849
11947
|
const parent = node.parent;
|
|
11850
|
-
if (parent.type ===
|
|
11948
|
+
if (parent.type === import_utils61.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils61.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
11851
11949
|
return;
|
|
11852
11950
|
}
|
|
11853
11951
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
11854
11952
|
return;
|
|
11855
11953
|
}
|
|
11856
|
-
const variable = obj?.type ===
|
|
11857
|
-
if (variable !== null && obj?.type ===
|
|
11954
|
+
const variable = obj?.type === import_utils61.AST_NODE_TYPES.Identifier ? unvalidatedVariableRef(obj, scope, unvalidatedVariables) : null;
|
|
11955
|
+
if (variable !== null && obj?.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
11858
11956
|
if (isUseWithinValidatedBranch(node, obj.name)) {
|
|
11859
11957
|
return;
|
|
11860
11958
|
}
|
|
@@ -11874,7 +11972,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11874
11972
|
});
|
|
11875
11973
|
|
|
11876
11974
|
// src/rules/prefer-semantic-colors.ts
|
|
11877
|
-
var
|
|
11975
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
11878
11976
|
var import_fs = require("fs");
|
|
11879
11977
|
var import_path = require("path");
|
|
11880
11978
|
|
|
@@ -11986,7 +12084,7 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
11986
12084
|
var isInsideSvg = (node) => {
|
|
11987
12085
|
let current = node.parent;
|
|
11988
12086
|
while (current !== void 0 && current !== null) {
|
|
11989
|
-
if (current.type ===
|
|
12087
|
+
if (current.type === import_utils62.AST_NODE_TYPES.JSXElement) {
|
|
11990
12088
|
const name = jsxElementName(current);
|
|
11991
12089
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
11992
12090
|
}
|
|
@@ -11996,8 +12094,8 @@ var isInsideSvg = (node) => {
|
|
|
11996
12094
|
};
|
|
11997
12095
|
function jsxElementName(node) {
|
|
11998
12096
|
const name = node.openingElement.name;
|
|
11999
|
-
if (name.type ===
|
|
12000
|
-
if (name.type ===
|
|
12097
|
+
if (name.type === import_utils62.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
12098
|
+
if (name.type === import_utils62.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils62.AST_NODE_TYPES.JSXIdentifier) {
|
|
12001
12099
|
return name.property.name;
|
|
12002
12100
|
}
|
|
12003
12101
|
return null;
|
|
@@ -12023,7 +12121,7 @@ function isSvgLikeElementName(name) {
|
|
|
12023
12121
|
var isInsideIconFactoryPath = (node) => {
|
|
12024
12122
|
let current = node.parent;
|
|
12025
12123
|
while (current !== void 0 && current !== null) {
|
|
12026
|
-
if (current.type ===
|
|
12124
|
+
if (current.type === import_utils62.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils62.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils62.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils62.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
12027
12125
|
return true;
|
|
12028
12126
|
}
|
|
12029
12127
|
current = current.parent;
|
|
@@ -12157,12 +12255,12 @@ var expandWorkspaceGlob = (root, glob) => {
|
|
|
12157
12255
|
return (0, import_fs.readdirSync)(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => (0, import_path.join)(parent, entry.name));
|
|
12158
12256
|
};
|
|
12159
12257
|
var propName = (key) => {
|
|
12160
|
-
if (key.type ===
|
|
12161
|
-
if (key.type ===
|
|
12258
|
+
if (key.type === import_utils62.AST_NODE_TYPES.Identifier) return key.name;
|
|
12259
|
+
if (key.type === import_utils62.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
12162
12260
|
return null;
|
|
12163
12261
|
};
|
|
12164
12262
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
12165
|
-
if (statement.type !==
|
|
12263
|
+
if (statement.type !== import_utils62.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils62.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils62.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
12166
12264
|
return false;
|
|
12167
12265
|
}
|
|
12168
12266
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -12215,27 +12313,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12215
12313
|
const checkClassNode = (node) => {
|
|
12216
12314
|
if (node === null) return;
|
|
12217
12315
|
switch (node.type) {
|
|
12218
|
-
case
|
|
12316
|
+
case import_utils62.AST_NODE_TYPES.Literal:
|
|
12219
12317
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
12220
12318
|
break;
|
|
12221
|
-
case
|
|
12319
|
+
case import_utils62.AST_NODE_TYPES.TemplateLiteral:
|
|
12222
12320
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
12223
12321
|
break;
|
|
12224
|
-
case
|
|
12322
|
+
case import_utils62.AST_NODE_TYPES.ArrayExpression:
|
|
12225
12323
|
for (const element of node.elements) {
|
|
12226
|
-
if (element !== null && element.type !==
|
|
12324
|
+
if (element !== null && element.type !== import_utils62.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
12227
12325
|
}
|
|
12228
12326
|
break;
|
|
12229
|
-
case
|
|
12327
|
+
case import_utils62.AST_NODE_TYPES.ObjectExpression:
|
|
12230
12328
|
for (const property of node.properties) {
|
|
12231
|
-
if (property.type ===
|
|
12329
|
+
if (property.type === import_utils62.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
12232
12330
|
}
|
|
12233
12331
|
break;
|
|
12234
|
-
case
|
|
12332
|
+
case import_utils62.AST_NODE_TYPES.ConditionalExpression:
|
|
12235
12333
|
checkClassNode(node.consequent);
|
|
12236
12334
|
checkClassNode(node.alternate);
|
|
12237
12335
|
break;
|
|
12238
|
-
case
|
|
12336
|
+
case import_utils62.AST_NODE_TYPES.LogicalExpression:
|
|
12239
12337
|
checkClassNode(node.right);
|
|
12240
12338
|
break;
|
|
12241
12339
|
default:
|
|
@@ -12243,32 +12341,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12243
12341
|
}
|
|
12244
12342
|
};
|
|
12245
12343
|
const checkColorValueNode = (node) => {
|
|
12246
|
-
if (node.type ===
|
|
12344
|
+
if (node.type === import_utils62.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
12247
12345
|
report(node, "inlineColor", { value: node.value });
|
|
12248
12346
|
}
|
|
12249
12347
|
};
|
|
12250
12348
|
return {
|
|
12251
12349
|
"JSXAttribute[name.name='className']"(node) {
|
|
12252
12350
|
if (node.value === null) return;
|
|
12253
|
-
if (node.value.type ===
|
|
12254
|
-
else if (node.value.type ===
|
|
12255
|
-
if (node.value.expression.type !==
|
|
12351
|
+
if (node.value.type === import_utils62.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
12352
|
+
else if (node.value.type === import_utils62.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
12353
|
+
if (node.value.expression.type !== import_utils62.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
12256
12354
|
checkClassNode(node.value.expression);
|
|
12257
12355
|
}
|
|
12258
12356
|
}
|
|
12259
12357
|
},
|
|
12260
12358
|
CallExpression(node) {
|
|
12261
|
-
if (node.callee.type ===
|
|
12359
|
+
if (node.callee.type === import_utils62.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils62.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
12262
12360
|
importsEmailOrPdfRenderer = true;
|
|
12263
12361
|
}
|
|
12264
|
-
if (node.callee.type ===
|
|
12362
|
+
if (node.callee.type === import_utils62.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
12265
12363
|
for (const arg of node.arguments) {
|
|
12266
|
-
if (arg.type !==
|
|
12364
|
+
if (arg.type !== import_utils62.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
12267
12365
|
}
|
|
12268
12366
|
}
|
|
12269
12367
|
},
|
|
12270
12368
|
VariableDeclarator(node) {
|
|
12271
|
-
if (node.id.type ===
|
|
12369
|
+
if (node.id.type === import_utils62.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
12272
12370
|
checkClassNode(node.init);
|
|
12273
12371
|
}
|
|
12274
12372
|
},
|
|
@@ -12278,9 +12376,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12278
12376
|
},
|
|
12279
12377
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
12280
12378
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
12281
|
-
if (node.value?.type !==
|
|
12379
|
+
if (node.value?.type !== import_utils62.AST_NODE_TYPES.Literal) return;
|
|
12282
12380
|
const owner = node.parent.name;
|
|
12283
|
-
if (owner.type ===
|
|
12381
|
+
if (owner.type === import_utils62.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
12284
12382
|
return;
|
|
12285
12383
|
}
|
|
12286
12384
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -12294,7 +12392,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12294
12392
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
12295
12393
|
},
|
|
12296
12394
|
ImportExpression(node) {
|
|
12297
|
-
if (node.source.type ===
|
|
12395
|
+
if (node.source.type === import_utils62.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
12298
12396
|
importsEmailOrPdfRenderer = true;
|
|
12299
12397
|
}
|
|
12300
12398
|
},
|
|
@@ -12307,7 +12405,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12307
12405
|
});
|
|
12308
12406
|
|
|
12309
12407
|
// src/rules/prefer-server-actions.ts
|
|
12310
|
-
var
|
|
12408
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
12311
12409
|
var preferServerActionsDocumentation = {
|
|
12312
12410
|
summary: "Prefer Next.js Server Actions over /api/* mutations.",
|
|
12313
12411
|
rationale: "Server Actions preserve typed application calls and avoid an internal JSON request-response boundary.",
|
|
@@ -12496,7 +12594,7 @@ var prefer_server_actions_default = createRule({
|
|
|
12496
12594
|
});
|
|
12497
12595
|
|
|
12498
12596
|
// src/rules/prefer-whole-object-assertion.ts
|
|
12499
|
-
var
|
|
12597
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
12500
12598
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
12501
12599
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
12502
12600
|
["toBeNull", "null"],
|
|
@@ -12521,11 +12619,11 @@ var preferWholeObjectAssertionDocumentation = {
|
|
|
12521
12619
|
};
|
|
12522
12620
|
function literalText(node, getText) {
|
|
12523
12621
|
switch (node.type) {
|
|
12524
|
-
case
|
|
12622
|
+
case import_utils64.AST_NODE_TYPES.Literal:
|
|
12525
12623
|
return "regex" in node ? null : getText(node);
|
|
12526
|
-
case
|
|
12624
|
+
case import_utils64.AST_NODE_TYPES.TemplateLiteral:
|
|
12527
12625
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
12528
|
-
case
|
|
12626
|
+
case import_utils64.AST_NODE_TYPES.UnaryExpression:
|
|
12529
12627
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
12530
12628
|
default:
|
|
12531
12629
|
return null;
|
|
@@ -12533,15 +12631,15 @@ function literalText(node, getText) {
|
|
|
12533
12631
|
}
|
|
12534
12632
|
function isPureReceiver(node) {
|
|
12535
12633
|
switch (node.type) {
|
|
12536
|
-
case
|
|
12537
|
-
case
|
|
12634
|
+
case import_utils64.AST_NODE_TYPES.Identifier:
|
|
12635
|
+
case import_utils64.AST_NODE_TYPES.ThisExpression:
|
|
12538
12636
|
return true;
|
|
12539
|
-
case
|
|
12637
|
+
case import_utils64.AST_NODE_TYPES.MemberExpression:
|
|
12540
12638
|
if (node.optional) {
|
|
12541
12639
|
return false;
|
|
12542
12640
|
}
|
|
12543
12641
|
if (node.computed) {
|
|
12544
|
-
return node.property.type ===
|
|
12642
|
+
return node.property.type === import_utils64.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
12545
12643
|
}
|
|
12546
12644
|
return isPureReceiver(node.object);
|
|
12547
12645
|
default:
|
|
@@ -12549,7 +12647,7 @@ function isPureReceiver(node) {
|
|
|
12549
12647
|
}
|
|
12550
12648
|
}
|
|
12551
12649
|
function literalIndex(node) {
|
|
12552
|
-
if (node.type !==
|
|
12650
|
+
if (node.type !== import_utils64.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
12553
12651
|
return null;
|
|
12554
12652
|
}
|
|
12555
12653
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -12557,8 +12655,8 @@ function literalIndex(node) {
|
|
|
12557
12655
|
function propertyAccess(node) {
|
|
12558
12656
|
const path = [];
|
|
12559
12657
|
let current = node;
|
|
12560
|
-
while (current.type ===
|
|
12561
|
-
if (current.property.type !==
|
|
12658
|
+
while (current.type === import_utils64.AST_NODE_TYPES.MemberExpression && !current.computed && !current.optional) {
|
|
12659
|
+
if (current.property.type !== import_utils64.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(current.property.name) || LITERAL_KEY_HAZARDS.has(current.property.name)) return null;
|
|
12562
12660
|
path.unshift(current.property.name);
|
|
12563
12661
|
current = current.object;
|
|
12564
12662
|
}
|
|
@@ -12586,24 +12684,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12586
12684
|
}
|
|
12587
12685
|
const { sourceCode } = context;
|
|
12588
12686
|
function parseAssertion(statement) {
|
|
12589
|
-
if (statement.type !==
|
|
12687
|
+
if (statement.type !== import_utils64.AST_NODE_TYPES.ExpressionStatement) {
|
|
12590
12688
|
return null;
|
|
12591
12689
|
}
|
|
12592
12690
|
const call = statement.expression;
|
|
12593
|
-
if (call.type !==
|
|
12691
|
+
if (call.type !== import_utils64.AST_NODE_TYPES.CallExpression) {
|
|
12594
12692
|
return null;
|
|
12595
12693
|
}
|
|
12596
12694
|
const callee = call.callee;
|
|
12597
|
-
if (callee.type !==
|
|
12695
|
+
if (callee.type !== import_utils64.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils64.AST_NODE_TYPES.Identifier) {
|
|
12598
12696
|
return null;
|
|
12599
12697
|
}
|
|
12600
12698
|
const matcher = callee.property.name;
|
|
12601
12699
|
const expectCall = callee.object;
|
|
12602
|
-
if (expectCall.type !==
|
|
12700
|
+
if (expectCall.type !== import_utils64.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils64.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
12603
12701
|
return null;
|
|
12604
12702
|
}
|
|
12605
12703
|
const actual = expectCall.arguments[0];
|
|
12606
|
-
if (actual === void 0 || actual.type !==
|
|
12704
|
+
if (actual === void 0 || actual.type !== import_utils64.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
12607
12705
|
return null;
|
|
12608
12706
|
}
|
|
12609
12707
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -12632,7 +12730,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12632
12730
|
return null;
|
|
12633
12731
|
}
|
|
12634
12732
|
const expected = call.arguments[0];
|
|
12635
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
12733
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils64.AST_NODE_TYPES.SpreadElement) {
|
|
12636
12734
|
return null;
|
|
12637
12735
|
}
|
|
12638
12736
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -12773,7 +12871,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12773
12871
|
});
|
|
12774
12872
|
|
|
12775
12873
|
// src/rules/repeated-static-call-cases.ts
|
|
12776
|
-
var
|
|
12874
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
12777
12875
|
var repeatedStaticCallCasesDocumentation = {
|
|
12778
12876
|
summary: "Report three or more consecutive literal call assertions that should be independently named test cases.",
|
|
12779
12877
|
rationale: "Copy-pasted cases obscure the input table and stop later cases from being reported after the first failure.",
|
|
@@ -12794,67 +12892,67 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
12794
12892
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
12795
12893
|
var MIN_CASES2 = 3;
|
|
12796
12894
|
function staticMemberName5(node) {
|
|
12797
|
-
if (!node.computed && node.property.type ===
|
|
12798
|
-
if (node.computed && node.property.type ===
|
|
12895
|
+
if (!node.computed && node.property.type === import_utils65.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
12896
|
+
if (node.computed && node.property.type === import_utils65.AST_NODE_TYPES.Literal && typeof node.property.value === "string") return node.property.value;
|
|
12799
12897
|
return null;
|
|
12800
12898
|
}
|
|
12801
12899
|
function importedName3(identifier, context, modules) {
|
|
12802
|
-
const variable =
|
|
12900
|
+
const variable = import_utils65.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
12803
12901
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
12804
12902
|
for (const definition of variable.defs) {
|
|
12805
|
-
if (definition.node.type !==
|
|
12903
|
+
if (definition.node.type !== import_utils65.AST_NODE_TYPES.ImportSpecifier) continue;
|
|
12806
12904
|
const declaration = definition.node.parent;
|
|
12807
|
-
if (declaration.type !==
|
|
12905
|
+
if (declaration.type !== import_utils65.AST_NODE_TYPES.ImportDeclaration || typeof declaration.source.value !== "string" || !modules.has(declaration.source.value)) continue;
|
|
12808
12906
|
const imported = definition.node.imported;
|
|
12809
|
-
return imported.type ===
|
|
12907
|
+
return imported.type === import_utils65.AST_NODE_TYPES.Identifier ? imported.name : String(imported.value);
|
|
12810
12908
|
}
|
|
12811
12909
|
return null;
|
|
12812
12910
|
}
|
|
12813
12911
|
function isDirectTestCallback2(node, context) {
|
|
12814
|
-
if (node.type !==
|
|
12912
|
+
if (node.type !== import_utils65.AST_NODE_TYPES.ArrowFunctionExpression && node.type !== import_utils65.AST_NODE_TYPES.FunctionExpression) return false;
|
|
12815
12913
|
const call = node.parent;
|
|
12816
|
-
if (call?.type !==
|
|
12914
|
+
if (call?.type !== import_utils65.AST_NODE_TYPES.CallExpression || !call.arguments.includes(node)) return false;
|
|
12817
12915
|
const root = testRoot2(call.callee);
|
|
12818
12916
|
return root !== null && TEST_NAMES2.has(importedName3(root, context, TEST_MODULES4) ?? "");
|
|
12819
12917
|
}
|
|
12820
12918
|
function testRoot2(callee) {
|
|
12821
|
-
if (callee.type ===
|
|
12822
|
-
if (callee.type !==
|
|
12919
|
+
if (callee.type === import_utils65.AST_NODE_TYPES.Identifier) return callee;
|
|
12920
|
+
if (callee.type !== import_utils65.AST_NODE_TYPES.MemberExpression) return null;
|
|
12823
12921
|
const modifier = staticMemberName5(callee);
|
|
12824
12922
|
return modifier !== null && TEST_MODIFIERS4.has(modifier) ? testRoot2(callee.object) : null;
|
|
12825
12923
|
}
|
|
12826
12924
|
function isStatic(node) {
|
|
12827
|
-
if (node.type ===
|
|
12925
|
+
if (node.type === import_utils65.AST_NODE_TYPES.TSAsExpression || node.type === import_utils65.AST_NODE_TYPES.TSTypeAssertion || node.type === import_utils65.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils65.AST_NODE_TYPES.TSNonNullExpression) return isStatic(node.expression);
|
|
12828
12926
|
switch (node.type) {
|
|
12829
|
-
case
|
|
12927
|
+
case import_utils65.AST_NODE_TYPES.Literal:
|
|
12830
12928
|
return true;
|
|
12831
|
-
case
|
|
12929
|
+
case import_utils65.AST_NODE_TYPES.TemplateLiteral:
|
|
12832
12930
|
return node.expressions.length === 0;
|
|
12833
|
-
case
|
|
12931
|
+
case import_utils65.AST_NODE_TYPES.UnaryExpression:
|
|
12834
12932
|
return (node.operator === "+" || node.operator === "-") && isStatic(node.argument);
|
|
12835
|
-
case
|
|
12836
|
-
return node.elements.every((item) => item !== null && item.type !==
|
|
12837
|
-
case
|
|
12838
|
-
return node.properties.every((property) => property.type ===
|
|
12933
|
+
case import_utils65.AST_NODE_TYPES.ArrayExpression:
|
|
12934
|
+
return node.elements.every((item) => item !== null && item.type !== import_utils65.AST_NODE_TYPES.SpreadElement && isStatic(item));
|
|
12935
|
+
case import_utils65.AST_NODE_TYPES.ObjectExpression:
|
|
12936
|
+
return node.properties.every((property) => property.type === import_utils65.AST_NODE_TYPES.Property && !property.computed && property.kind === "init" && property.value.type !== import_utils65.AST_NODE_TYPES.AssignmentPattern && isStatic(property.value));
|
|
12839
12937
|
default:
|
|
12840
12938
|
return false;
|
|
12841
12939
|
}
|
|
12842
12940
|
}
|
|
12843
12941
|
function staticShape(node) {
|
|
12844
|
-
if (node.type ===
|
|
12942
|
+
if (node.type === import_utils65.AST_NODE_TYPES.TSAsExpression || node.type === import_utils65.AST_NODE_TYPES.TSTypeAssertion || node.type === import_utils65.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils65.AST_NODE_TYPES.TSNonNullExpression) return staticShape(node.expression);
|
|
12845
12943
|
switch (node.type) {
|
|
12846
|
-
case
|
|
12944
|
+
case import_utils65.AST_NODE_TYPES.Literal:
|
|
12847
12945
|
return `literal:${typeof node.value}`;
|
|
12848
|
-
case
|
|
12946
|
+
case import_utils65.AST_NODE_TYPES.TemplateLiteral:
|
|
12849
12947
|
return "template";
|
|
12850
|
-
case
|
|
12948
|
+
case import_utils65.AST_NODE_TYPES.UnaryExpression:
|
|
12851
12949
|
return `unary:${node.operator}:${staticShape(node.argument)}`;
|
|
12852
|
-
case
|
|
12853
|
-
return `array(${node.elements.map((item) => item === null || item.type ===
|
|
12854
|
-
case
|
|
12950
|
+
case import_utils65.AST_NODE_TYPES.ArrayExpression:
|
|
12951
|
+
return `array(${node.elements.map((item) => item === null || item.type === import_utils65.AST_NODE_TYPES.SpreadElement ? "invalid" : staticShape(item)).join(",")})`;
|
|
12952
|
+
case import_utils65.AST_NODE_TYPES.ObjectExpression:
|
|
12855
12953
|
return `object(${node.properties.map((property) => {
|
|
12856
|
-
if (property.type !==
|
|
12857
|
-
const key = property.key.type ===
|
|
12954
|
+
if (property.type !== import_utils65.AST_NODE_TYPES.Property || property.computed || property.value.type === import_utils65.AST_NODE_TYPES.AssignmentPattern) return "invalid";
|
|
12955
|
+
const key = property.key.type === import_utils65.AST_NODE_TYPES.Identifier ? property.key.name : String(property.key.value);
|
|
12858
12956
|
return `${key}:${staticShape(property.value)}`;
|
|
12859
12957
|
}).join(",")})`;
|
|
12860
12958
|
default:
|
|
@@ -12862,16 +12960,16 @@ function staticShape(node) {
|
|
|
12862
12960
|
}
|
|
12863
12961
|
}
|
|
12864
12962
|
function assertionShape(statement, context) {
|
|
12865
|
-
if (statement.type !==
|
|
12963
|
+
if (statement.type !== import_utils65.AST_NODE_TYPES.ExpressionStatement || statement.expression.type !== import_utils65.AST_NODE_TYPES.CallExpression) return null;
|
|
12866
12964
|
const matcherCall = statement.expression;
|
|
12867
|
-
if (matcherCall.callee.type !==
|
|
12965
|
+
if (matcherCall.callee.type !== import_utils65.AST_NODE_TYPES.MemberExpression || matcherCall.callee.computed || matcherCall.callee.property.type !== import_utils65.AST_NODE_TYPES.Identifier || matcherCall.arguments.length !== 1) return null;
|
|
12868
12966
|
const matcher = matcherCall.callee.property.name;
|
|
12869
12967
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
12870
12968
|
const chain = expectCallFromMatcher(matcherCall.callee);
|
|
12871
|
-
if (chain === null || chain.call.callee.type !==
|
|
12969
|
+
if (chain === null || chain.call.callee.type !== import_utils65.AST_NODE_TYPES.Identifier || importedName3(chain.call.callee, context, ASSERTION_MODULES3) !== "expect" || chain.call.arguments.length !== 1) return null;
|
|
12872
12970
|
const observed = chain.call.arguments[0];
|
|
12873
12971
|
const expected = matcherCall.arguments[0];
|
|
12874
|
-
if (observed?.type !==
|
|
12972
|
+
if (observed?.type !== import_utils65.AST_NODE_TYPES.CallExpression || observed.callee.type !== import_utils65.AST_NODE_TYPES.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === import_utils65.AST_NODE_TYPES.SpreadElement || !isStatic(arg)) || expected?.type === import_utils65.AST_NODE_TYPES.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
12875
12973
|
const skeleton = `${observed.callee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
12876
12974
|
const values = [...observed.arguments, expected].map((item) => context.sourceCode.getText(item)).join("\0");
|
|
12877
12975
|
return { statement, skeleton, values };
|
|
@@ -12879,13 +12977,13 @@ function assertionShape(statement, context) {
|
|
|
12879
12977
|
function expectCallFromMatcher(node) {
|
|
12880
12978
|
const modifiers = [];
|
|
12881
12979
|
let receiver = node.object;
|
|
12882
|
-
while (receiver.type ===
|
|
12980
|
+
while (receiver.type === import_utils65.AST_NODE_TYPES.MemberExpression) {
|
|
12883
12981
|
const modifier = staticMemberName5(receiver);
|
|
12884
12982
|
if (modifier === null || !EXPECT_MODIFIERS.has(modifier)) return null;
|
|
12885
12983
|
modifiers.unshift(modifier);
|
|
12886
12984
|
receiver = receiver.object;
|
|
12887
12985
|
}
|
|
12888
|
-
return receiver.type ===
|
|
12986
|
+
return receiver.type === import_utils65.AST_NODE_TYPES.CallExpression ? { call: receiver, modifiers } : null;
|
|
12889
12987
|
}
|
|
12890
12988
|
var repeated_static_call_cases_default = createRule({
|
|
12891
12989
|
name: "repeated-static-call-cases",
|
|
@@ -12905,7 +13003,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
12905
13003
|
return {
|
|
12906
13004
|
"CallExpression > ArrowFunctionExpression, CallExpression > FunctionExpression"(node) {
|
|
12907
13005
|
const call = node.parent;
|
|
12908
|
-
if (call?.type ===
|
|
13006
|
+
if (call?.type === import_utils65.AST_NODE_TYPES.CallExpression) {
|
|
12909
13007
|
const duplicate = duplicateTestBodyCandidate(call, sourceCode);
|
|
12910
13008
|
if (duplicate !== null && duplicate.body === node) {
|
|
12911
13009
|
const groups = duplicateGroups.get(duplicate.container) ?? /* @__PURE__ */ new Map();
|
|
@@ -12915,7 +13013,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
12915
13013
|
duplicateGroups.set(duplicate.container, groups);
|
|
12916
13014
|
}
|
|
12917
13015
|
}
|
|
12918
|
-
if (!isDirectTestCallback2(node, context) || node.body.type !==
|
|
13016
|
+
if (!isDirectTestCallback2(node, context) || node.body.type !== import_utils65.AST_NODE_TYPES.BlockStatement) return;
|
|
12919
13017
|
let run = [];
|
|
12920
13018
|
const flush = () => {
|
|
12921
13019
|
if (run.length >= MIN_CASES2 && new Set(run.map((item) => item.values)).size > 1) {
|
|
@@ -12956,7 +13054,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
12956
13054
|
});
|
|
12957
13055
|
|
|
12958
13056
|
// src/rules/prefer-zod-infer.ts
|
|
12959
|
-
var
|
|
13057
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
12960
13058
|
var preferZodInferDocumentation = {
|
|
12961
13059
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
12962
13060
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -13009,47 +13107,47 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
13009
13107
|
"Schema"
|
|
13010
13108
|
]);
|
|
13011
13109
|
var LEAF_NODE_TYPES = {
|
|
13012
|
-
string: [
|
|
13013
|
-
email: [
|
|
13014
|
-
url: [
|
|
13015
|
-
uuid: [
|
|
13016
|
-
ulid: [
|
|
13017
|
-
cuid: [
|
|
13018
|
-
cuid2: [
|
|
13019
|
-
nanoid: [
|
|
13020
|
-
iso: [
|
|
13021
|
-
number: [
|
|
13022
|
-
int: [
|
|
13023
|
-
float32: [
|
|
13024
|
-
float64: [
|
|
13025
|
-
boolean: [
|
|
13026
|
-
bigint: [
|
|
13027
|
-
symbol: [
|
|
13028
|
-
any: [
|
|
13029
|
-
unknown: [
|
|
13030
|
-
never: [
|
|
13031
|
-
void: [
|
|
13032
|
-
null: [
|
|
13033
|
-
undefined: [
|
|
13034
|
-
literal: [
|
|
13035
|
-
date: [
|
|
13036
|
-
array: [
|
|
13037
|
-
tuple: [
|
|
13038
|
-
object: [
|
|
13039
|
-
strictObject: [
|
|
13040
|
-
looseObject: [
|
|
13041
|
-
record: [
|
|
13042
|
-
map: [
|
|
13043
|
-
set: [
|
|
13044
|
-
promise: [
|
|
13045
|
-
enum: [
|
|
13046
|
-
nativeEnum: [
|
|
13047
|
-
union: [
|
|
13048
|
-
discriminatedUnion: [
|
|
13049
|
-
intersection: [
|
|
13110
|
+
string: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13111
|
+
email: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13112
|
+
url: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13113
|
+
uuid: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13114
|
+
ulid: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13115
|
+
cuid: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13116
|
+
cuid2: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13117
|
+
nanoid: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13118
|
+
iso: [import_utils66.AST_NODE_TYPES.TSStringKeyword],
|
|
13119
|
+
number: [import_utils66.AST_NODE_TYPES.TSNumberKeyword],
|
|
13120
|
+
int: [import_utils66.AST_NODE_TYPES.TSNumberKeyword],
|
|
13121
|
+
float32: [import_utils66.AST_NODE_TYPES.TSNumberKeyword],
|
|
13122
|
+
float64: [import_utils66.AST_NODE_TYPES.TSNumberKeyword],
|
|
13123
|
+
boolean: [import_utils66.AST_NODE_TYPES.TSBooleanKeyword],
|
|
13124
|
+
bigint: [import_utils66.AST_NODE_TYPES.TSBigIntKeyword],
|
|
13125
|
+
symbol: [import_utils66.AST_NODE_TYPES.TSSymbolKeyword],
|
|
13126
|
+
any: [import_utils66.AST_NODE_TYPES.TSAnyKeyword],
|
|
13127
|
+
unknown: [import_utils66.AST_NODE_TYPES.TSUnknownKeyword],
|
|
13128
|
+
never: [import_utils66.AST_NODE_TYPES.TSNeverKeyword],
|
|
13129
|
+
void: [import_utils66.AST_NODE_TYPES.TSVoidKeyword],
|
|
13130
|
+
null: [import_utils66.AST_NODE_TYPES.TSNullKeyword],
|
|
13131
|
+
undefined: [import_utils66.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
13132
|
+
literal: [import_utils66.AST_NODE_TYPES.TSLiteralType],
|
|
13133
|
+
date: [import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13134
|
+
array: [import_utils66.AST_NODE_TYPES.TSArrayType, import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13135
|
+
tuple: [import_utils66.AST_NODE_TYPES.TSTupleType],
|
|
13136
|
+
object: [import_utils66.AST_NODE_TYPES.TSTypeLiteral, import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13137
|
+
strictObject: [import_utils66.AST_NODE_TYPES.TSTypeLiteral, import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13138
|
+
looseObject: [import_utils66.AST_NODE_TYPES.TSTypeLiteral, import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13139
|
+
record: [import_utils66.AST_NODE_TYPES.TSTypeReference, import_utils66.AST_NODE_TYPES.TSTypeLiteral],
|
|
13140
|
+
map: [import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13141
|
+
set: [import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13142
|
+
promise: [import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13143
|
+
enum: [import_utils66.AST_NODE_TYPES.TSUnionType, import_utils66.AST_NODE_TYPES.TSTypeReference, import_utils66.AST_NODE_TYPES.TSLiteralType],
|
|
13144
|
+
nativeEnum: [import_utils66.AST_NODE_TYPES.TSUnionType, import_utils66.AST_NODE_TYPES.TSTypeReference, import_utils66.AST_NODE_TYPES.TSLiteralType],
|
|
13145
|
+
union: [import_utils66.AST_NODE_TYPES.TSUnionType, import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13146
|
+
discriminatedUnion: [import_utils66.AST_NODE_TYPES.TSUnionType, import_utils66.AST_NODE_TYPES.TSTypeReference],
|
|
13147
|
+
intersection: [import_utils66.AST_NODE_TYPES.TSIntersectionType, import_utils66.AST_NODE_TYPES.TSTypeReference]
|
|
13050
13148
|
};
|
|
13051
13149
|
function primitiveLiteralKey(node) {
|
|
13052
|
-
if (node.type !==
|
|
13150
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.Literal) {
|
|
13053
13151
|
return null;
|
|
13054
13152
|
}
|
|
13055
13153
|
if (node.value === null) {
|
|
@@ -13081,13 +13179,13 @@ function staticZodDomain(leaf, call) {
|
|
|
13081
13179
|
}
|
|
13082
13180
|
if (leaf === "literal") {
|
|
13083
13181
|
const [argument] = call.arguments;
|
|
13084
|
-
if (argument === void 0 || argument.type ===
|
|
13182
|
+
if (argument === void 0 || argument.type === import_utils66.AST_NODE_TYPES.SpreadElement) {
|
|
13085
13183
|
return null;
|
|
13086
13184
|
}
|
|
13087
|
-
if (argument.type ===
|
|
13185
|
+
if (argument.type === import_utils66.AST_NODE_TYPES.ArrayExpression) {
|
|
13088
13186
|
return exactDomain(
|
|
13089
13187
|
argument.elements.map(
|
|
13090
|
-
(element) => element === null || element.type ===
|
|
13188
|
+
(element) => element === null || element.type === import_utils66.AST_NODE_TYPES.SpreadElement ? null : primitiveLiteralKey(element)
|
|
13091
13189
|
)
|
|
13092
13190
|
);
|
|
13093
13191
|
}
|
|
@@ -13095,13 +13193,13 @@ function staticZodDomain(leaf, call) {
|
|
|
13095
13193
|
}
|
|
13096
13194
|
if (leaf === "enum") {
|
|
13097
13195
|
const [argument] = call.arguments;
|
|
13098
|
-
if (argument === void 0 || argument.type ===
|
|
13196
|
+
if (argument === void 0 || argument.type === import_utils66.AST_NODE_TYPES.SpreadElement) {
|
|
13099
13197
|
return null;
|
|
13100
13198
|
}
|
|
13101
|
-
if (argument.type ===
|
|
13199
|
+
if (argument.type === import_utils66.AST_NODE_TYPES.ArrayExpression) {
|
|
13102
13200
|
return exactDomain(
|
|
13103
13201
|
argument.elements.map((element) => {
|
|
13104
|
-
if (element === null || element.type ===
|
|
13202
|
+
if (element === null || element.type === import_utils66.AST_NODE_TYPES.SpreadElement) {
|
|
13105
13203
|
return null;
|
|
13106
13204
|
}
|
|
13107
13205
|
const key = primitiveLiteralKey(element);
|
|
@@ -13109,10 +13207,10 @@ function staticZodDomain(leaf, call) {
|
|
|
13109
13207
|
})
|
|
13110
13208
|
);
|
|
13111
13209
|
}
|
|
13112
|
-
if (argument.type ===
|
|
13210
|
+
if (argument.type === import_utils66.AST_NODE_TYPES.ObjectExpression) {
|
|
13113
13211
|
return exactDomain(
|
|
13114
13212
|
argument.properties.map((property) => {
|
|
13115
|
-
if (property.type !==
|
|
13213
|
+
if (property.type !== import_utils66.AST_NODE_TYPES.Property || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
13116
13214
|
return null;
|
|
13117
13215
|
}
|
|
13118
13216
|
const key = primitiveLiteralKey(property.value);
|
|
@@ -13139,15 +13237,15 @@ function sameDomain(left, right) {
|
|
|
13139
13237
|
return true;
|
|
13140
13238
|
}
|
|
13141
13239
|
function isExportedDeclaration(node) {
|
|
13142
|
-
return node.parent?.type ===
|
|
13240
|
+
return node.parent?.type === import_utils66.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
13143
13241
|
}
|
|
13144
13242
|
function isModuleLevelConst(node) {
|
|
13145
13243
|
const declaration = node.parent;
|
|
13146
|
-
if (declaration.type !==
|
|
13244
|
+
if (declaration.type !== import_utils66.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const") {
|
|
13147
13245
|
return false;
|
|
13148
13246
|
}
|
|
13149
13247
|
const container = declaration.parent;
|
|
13150
|
-
return container.type ===
|
|
13248
|
+
return container.type === import_utils66.AST_NODE_TYPES.Program || container.type === import_utils66.AST_NODE_TYPES.ExportNamedDeclaration && container.parent.type === import_utils66.AST_NODE_TYPES.Program;
|
|
13151
13249
|
}
|
|
13152
13250
|
function normalizeSchemaName(name) {
|
|
13153
13251
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -13156,20 +13254,20 @@ function normalizeTypeName(name) {
|
|
|
13156
13254
|
return name.replace(/Type$/, "").toLowerCase();
|
|
13157
13255
|
}
|
|
13158
13256
|
function unwrapNullish(annotation) {
|
|
13159
|
-
if (annotation.type !==
|
|
13257
|
+
if (annotation.type !== import_utils66.AST_NODE_TYPES.TSUnionType) {
|
|
13160
13258
|
return {
|
|
13161
13259
|
core: annotation,
|
|
13162
|
-
nullable: annotation.type ===
|
|
13260
|
+
nullable: annotation.type === import_utils66.AST_NODE_TYPES.TSNullKeyword
|
|
13163
13261
|
};
|
|
13164
13262
|
}
|
|
13165
13263
|
const rest = [];
|
|
13166
13264
|
let nullable = false;
|
|
13167
13265
|
for (const member of annotation.types) {
|
|
13168
|
-
if (member.type ===
|
|
13266
|
+
if (member.type === import_utils66.AST_NODE_TYPES.TSNullKeyword) {
|
|
13169
13267
|
nullable = true;
|
|
13170
13268
|
continue;
|
|
13171
13269
|
}
|
|
13172
|
-
if (member.type ===
|
|
13270
|
+
if (member.type === import_utils66.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
13173
13271
|
continue;
|
|
13174
13272
|
}
|
|
13175
13273
|
rest.push(member);
|
|
@@ -13203,18 +13301,18 @@ function leafAgrees(field, annotation) {
|
|
|
13203
13301
|
return null;
|
|
13204
13302
|
}
|
|
13205
13303
|
if (leaf === "date") {
|
|
13206
|
-
return core.type ===
|
|
13304
|
+
return core.type === import_utils66.AST_NODE_TYPES.TSTypeReference && core.typeName.type === import_utils66.AST_NODE_TYPES.Identifier && core.typeName.name === "Date";
|
|
13207
13305
|
}
|
|
13208
13306
|
return expected.includes(core.type);
|
|
13209
13307
|
}
|
|
13210
13308
|
function typeLiteralDomain(annotation) {
|
|
13211
|
-
const members = annotation.type ===
|
|
13309
|
+
const members = annotation.type === import_utils66.AST_NODE_TYPES.TSUnionType ? annotation.types : [annotation];
|
|
13212
13310
|
const keys = [];
|
|
13213
13311
|
for (const member of members) {
|
|
13214
|
-
if (member.type ===
|
|
13312
|
+
if (member.type === import_utils66.AST_NODE_TYPES.TSNullKeyword) {
|
|
13215
13313
|
continue;
|
|
13216
13314
|
}
|
|
13217
|
-
if (member.type !==
|
|
13315
|
+
if (member.type !== import_utils66.AST_NODE_TYPES.TSLiteralType) {
|
|
13218
13316
|
return null;
|
|
13219
13317
|
}
|
|
13220
13318
|
keys.push(primitiveLiteralKey(member.literal));
|
|
@@ -13222,11 +13320,11 @@ function typeLiteralDomain(annotation) {
|
|
|
13222
13320
|
return exactDomain(keys);
|
|
13223
13321
|
}
|
|
13224
13322
|
function staticStringUnionDomain(node) {
|
|
13225
|
-
if (node.type !==
|
|
13323
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.TSUnionType) {
|
|
13226
13324
|
return null;
|
|
13227
13325
|
}
|
|
13228
13326
|
const keys = node.types.map((member) => {
|
|
13229
|
-
if (member.type !==
|
|
13327
|
+
if (member.type !== import_utils66.AST_NODE_TYPES.TSLiteralType) {
|
|
13230
13328
|
return null;
|
|
13231
13329
|
}
|
|
13232
13330
|
const key = primitiveLiteralKey(member.literal);
|
|
@@ -13294,14 +13392,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
13294
13392
|
function zodCallChain(node) {
|
|
13295
13393
|
const chain = [];
|
|
13296
13394
|
let current = node;
|
|
13297
|
-
while (current.type ===
|
|
13395
|
+
while (current.type === import_utils66.AST_NODE_TYPES.CallExpression) {
|
|
13298
13396
|
const callee = current.callee;
|
|
13299
|
-
if (callee.type !==
|
|
13397
|
+
if (callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils66.AST_NODE_TYPES.Identifier) {
|
|
13300
13398
|
return null;
|
|
13301
13399
|
}
|
|
13302
13400
|
chain.push(current);
|
|
13303
13401
|
const receiver = callee.object;
|
|
13304
|
-
if (receiver.type ===
|
|
13402
|
+
if (receiver.type === import_utils66.AST_NODE_TYPES.Identifier) {
|
|
13305
13403
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
13306
13404
|
}
|
|
13307
13405
|
current = receiver;
|
|
@@ -13310,14 +13408,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
13310
13408
|
}
|
|
13311
13409
|
function methodName2(call) {
|
|
13312
13410
|
const callee = call.callee;
|
|
13313
|
-
return callee.type ===
|
|
13411
|
+
return callee.type === import_utils66.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils66.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
13314
13412
|
}
|
|
13315
13413
|
function recordZodImport(node) {
|
|
13316
13414
|
if (!isZodModule(node.source.value)) {
|
|
13317
13415
|
return;
|
|
13318
13416
|
}
|
|
13319
13417
|
for (const specifier of node.specifiers) {
|
|
13320
|
-
if (specifier.type ===
|
|
13418
|
+
if (specifier.type === import_utils66.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils66.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils66.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils66.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
13321
13419
|
zodNamespaces.add(specifier.local.name);
|
|
13322
13420
|
}
|
|
13323
13421
|
}
|
|
@@ -13327,13 +13425,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
13327
13425
|
let current = node;
|
|
13328
13426
|
let leaf = null;
|
|
13329
13427
|
let leafCall = null;
|
|
13330
|
-
while (current.type ===
|
|
13428
|
+
while (current.type === import_utils66.AST_NODE_TYPES.CallExpression) {
|
|
13331
13429
|
const callee = current.callee;
|
|
13332
|
-
if (callee.type !==
|
|
13430
|
+
if (callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils66.AST_NODE_TYPES.Identifier) {
|
|
13333
13431
|
break;
|
|
13334
13432
|
}
|
|
13335
13433
|
const receiver = callee.object;
|
|
13336
|
-
if (receiver.type ===
|
|
13434
|
+
if (receiver.type === import_utils66.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
13337
13435
|
leaf = callee.property.name;
|
|
13338
13436
|
leafCall = current;
|
|
13339
13437
|
break;
|
|
@@ -13364,20 +13462,20 @@ var prefer_zod_infer_default = createRule({
|
|
|
13364
13462
|
return domain instanceof Set && domain.size >= 2 ? domain : null;
|
|
13365
13463
|
}
|
|
13366
13464
|
function inferredSchemaName(node) {
|
|
13367
|
-
if (node.type !==
|
|
13465
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.TSTypeReference || node.typeName.type !== import_utils66.AST_NODE_TYPES.TSQualifiedName || node.typeName.left.type !== import_utils66.AST_NODE_TYPES.Identifier || !zodNamespaces.has(node.typeName.left.name) || node.typeName.right.name !== "infer") {
|
|
13368
13466
|
return null;
|
|
13369
13467
|
}
|
|
13370
13468
|
const arguments_ = node.typeArguments?.params ?? [];
|
|
13371
13469
|
const [argument] = arguments_;
|
|
13372
|
-
return arguments_.length === 1 && argument?.type ===
|
|
13470
|
+
return arguments_.length === 1 && argument?.type === import_utils66.AST_NODE_TYPES.TSTypeQuery && argument.exprName.type === import_utils66.AST_NODE_TYPES.Identifier ? argument.exprName.name : null;
|
|
13373
13471
|
}
|
|
13374
13472
|
function recordLiteralUnions(members, owner, ownerName, exported) {
|
|
13375
13473
|
for (const member of members) {
|
|
13376
|
-
if (member.type !==
|
|
13474
|
+
if (member.type !== import_utils66.AST_NODE_TYPES.TSPropertySignature || member.computed || member.optional || member.readonly || member.typeAnnotation === void 0) {
|
|
13377
13475
|
continue;
|
|
13378
13476
|
}
|
|
13379
13477
|
const key = member.key;
|
|
13380
|
-
const propertyName3 = key.type ===
|
|
13478
|
+
const propertyName3 = key.type === import_utils66.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils66.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
13381
13479
|
if (propertyName3 === null) {
|
|
13382
13480
|
continue;
|
|
13383
13481
|
}
|
|
@@ -13387,7 +13485,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13387
13485
|
}
|
|
13388
13486
|
const annotation = member.typeAnnotation.typeAnnotation;
|
|
13389
13487
|
const domain = staticStringUnionDomain(annotation);
|
|
13390
|
-
if (domain === null || annotation.type !==
|
|
13488
|
+
if (domain === null || annotation.type !== import_utils66.AST_NODE_TYPES.TSUnionType) {
|
|
13391
13489
|
continue;
|
|
13392
13490
|
}
|
|
13393
13491
|
literalUnionOccurrences.push({
|
|
@@ -13418,16 +13516,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
13418
13516
|
return null;
|
|
13419
13517
|
}
|
|
13420
13518
|
const shape = base.arguments[0];
|
|
13421
|
-
if (shape === void 0 || shape.type !==
|
|
13519
|
+
if (shape === void 0 || shape.type !== import_utils66.AST_NODE_TYPES.ObjectExpression) {
|
|
13422
13520
|
return null;
|
|
13423
13521
|
}
|
|
13424
13522
|
const fields = /* @__PURE__ */ new Map();
|
|
13425
13523
|
for (const property of shape.properties) {
|
|
13426
|
-
if (property.type !==
|
|
13524
|
+
if (property.type !== import_utils66.AST_NODE_TYPES.Property || property.computed) {
|
|
13427
13525
|
return null;
|
|
13428
13526
|
}
|
|
13429
13527
|
const { key } = property;
|
|
13430
|
-
const name = key.type ===
|
|
13528
|
+
const name = key.type === import_utils66.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils66.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
13431
13529
|
if (name === null) {
|
|
13432
13530
|
return null;
|
|
13433
13531
|
}
|
|
@@ -13438,11 +13536,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
13438
13536
|
function typeMembers(members) {
|
|
13439
13537
|
const result = /* @__PURE__ */ new Map();
|
|
13440
13538
|
for (const member of members) {
|
|
13441
|
-
if (member.type !==
|
|
13539
|
+
if (member.type !== import_utils66.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
13442
13540
|
return null;
|
|
13443
13541
|
}
|
|
13444
13542
|
const { key } = member;
|
|
13445
|
-
const name = key.type ===
|
|
13543
|
+
const name = key.type === import_utils66.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils66.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
13446
13544
|
if (name === null) {
|
|
13447
13545
|
return null;
|
|
13448
13546
|
}
|
|
@@ -13457,8 +13555,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
13457
13555
|
return result.size === 0 ? null : result;
|
|
13458
13556
|
}
|
|
13459
13557
|
function collectConstrainedNames(node) {
|
|
13460
|
-
if (node.type ===
|
|
13461
|
-
if (node.typeName.type ===
|
|
13558
|
+
if (node.type === import_utils66.AST_NODE_TYPES.TSTypeReference) {
|
|
13559
|
+
if (node.typeName.type === import_utils66.AST_NODE_TYPES.Identifier) {
|
|
13462
13560
|
constrainedTypeNames.add(node.typeName.name);
|
|
13463
13561
|
}
|
|
13464
13562
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -13466,11 +13564,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
13466
13564
|
}
|
|
13467
13565
|
return;
|
|
13468
13566
|
}
|
|
13469
|
-
if (node.type ===
|
|
13567
|
+
if (node.type === import_utils66.AST_NODE_TYPES.TSArrayType) {
|
|
13470
13568
|
collectConstrainedNames(node.elementType);
|
|
13471
13569
|
return;
|
|
13472
13570
|
}
|
|
13473
|
-
if (node.type ===
|
|
13571
|
+
if (node.type === import_utils66.AST_NODE_TYPES.TSUnionType || node.type === import_utils66.AST_NODE_TYPES.TSIntersectionType) {
|
|
13474
13572
|
for (const member of node.types) {
|
|
13475
13573
|
collectConstrainedNames(member);
|
|
13476
13574
|
}
|
|
@@ -13514,7 +13612,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13514
13612
|
return {
|
|
13515
13613
|
Program(node) {
|
|
13516
13614
|
for (const statement of node.body) {
|
|
13517
|
-
if (statement.type ===
|
|
13615
|
+
if (statement.type === import_utils66.AST_NODE_TYPES.ImportDeclaration) {
|
|
13518
13616
|
recordZodImport(statement);
|
|
13519
13617
|
}
|
|
13520
13618
|
}
|
|
@@ -13523,7 +13621,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13523
13621
|
recordZodImport(node);
|
|
13524
13622
|
},
|
|
13525
13623
|
VariableDeclarator(node) {
|
|
13526
|
-
if (node.id.type !==
|
|
13624
|
+
if (node.id.type !== import_utils66.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
13527
13625
|
return;
|
|
13528
13626
|
}
|
|
13529
13627
|
const fields = schemaFields(node.init);
|
|
@@ -13540,14 +13638,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
13540
13638
|
},
|
|
13541
13639
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
13542
13640
|
"MemberExpression[computed=false]"(node) {
|
|
13543
|
-
if (node.object.type ===
|
|
13641
|
+
if (node.object.type === import_utils66.AST_NODE_TYPES.Identifier && node.property.type === import_utils66.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
13544
13642
|
reshapedSchemaNames.add(node.object.name);
|
|
13545
13643
|
}
|
|
13546
13644
|
},
|
|
13547
13645
|
/** Records every type argument carried by a Zod constraint. */
|
|
13548
13646
|
TSTypeReference(node) {
|
|
13549
13647
|
const { typeName } = node;
|
|
13550
|
-
const referenced = typeName.type ===
|
|
13648
|
+
const referenced = typeName.type === import_utils66.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils66.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils66.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
13551
13649
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
13552
13650
|
return;
|
|
13553
13651
|
}
|
|
@@ -13579,7 +13677,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13579
13677
|
typeName: node.id.name
|
|
13580
13678
|
});
|
|
13581
13679
|
}
|
|
13582
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
13680
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils66.AST_NODE_TYPES.TSTypeLiteral) {
|
|
13583
13681
|
return;
|
|
13584
13682
|
}
|
|
13585
13683
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -13678,7 +13776,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13678
13776
|
});
|
|
13679
13777
|
|
|
13680
13778
|
// src/rules/require-assert-never.ts
|
|
13681
|
-
var
|
|
13779
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
13682
13780
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
13683
13781
|
var requireAssertNeverDocumentation = {
|
|
13684
13782
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
@@ -13691,14 +13789,14 @@ var requireAssertNeverDocumentation = {
|
|
|
13691
13789
|
]
|
|
13692
13790
|
};
|
|
13693
13791
|
var isRuntimeHandlingStatement = (statement) => {
|
|
13694
|
-
if (statement.type ===
|
|
13695
|
-
if (statement.type ===
|
|
13792
|
+
if (statement.type === import_utils67.AST_NODE_TYPES.EmptyStatement) return false;
|
|
13793
|
+
if (statement.type === import_utils67.AST_NODE_TYPES.BreakStatement) {
|
|
13696
13794
|
return statement.label !== null;
|
|
13697
13795
|
}
|
|
13698
|
-
if (statement.type ===
|
|
13796
|
+
if (statement.type === import_utils67.AST_NODE_TYPES.TSTypeAliasDeclaration || statement.type === import_utils67.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
13699
13797
|
return false;
|
|
13700
13798
|
}
|
|
13701
|
-
if (statement.type ===
|
|
13799
|
+
if (statement.type === import_utils67.AST_NODE_TYPES.BlockStatement) {
|
|
13702
13800
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
13703
13801
|
}
|
|
13704
13802
|
return true;
|
|
@@ -13714,7 +13812,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
13714
13812
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
13715
13813
|
}
|
|
13716
13814
|
const only = defaultCase.consequent[0];
|
|
13717
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
13815
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils67.AST_NODE_TYPES.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
13718
13816
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
13719
13817
|
}
|
|
13720
13818
|
return false;
|
|
@@ -13770,7 +13868,7 @@ var require_assert_never_default = createRule({
|
|
|
13770
13868
|
create(context) {
|
|
13771
13869
|
let services;
|
|
13772
13870
|
try {
|
|
13773
|
-
services =
|
|
13871
|
+
services = import_utils67.ESLintUtils.getParserServices(context);
|
|
13774
13872
|
} catch {
|
|
13775
13873
|
services = null;
|
|
13776
13874
|
}
|
|
@@ -13797,7 +13895,7 @@ var require_assert_never_default = createRule({
|
|
|
13797
13895
|
});
|
|
13798
13896
|
|
|
13799
13897
|
// src/rules/require-fetch-timeout.ts
|
|
13800
|
-
var
|
|
13898
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
13801
13899
|
var requireFetchTimeoutDocumentation = {
|
|
13802
13900
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
13803
13901
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -13823,14 +13921,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
13823
13921
|
return false;
|
|
13824
13922
|
}
|
|
13825
13923
|
function initProvablyLacksSignal(init) {
|
|
13826
|
-
if (init.type !==
|
|
13924
|
+
if (init.type !== import_utils68.AST_NODE_TYPES.ObjectExpression) {
|
|
13827
13925
|
return false;
|
|
13828
13926
|
}
|
|
13829
13927
|
for (const prop of init.properties) {
|
|
13830
|
-
if (prop.type ===
|
|
13928
|
+
if (prop.type === import_utils68.AST_NODE_TYPES.SpreadElement) {
|
|
13831
13929
|
return false;
|
|
13832
13930
|
}
|
|
13833
|
-
if (prop.key.type ===
|
|
13931
|
+
if (prop.key.type === import_utils68.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils68.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
13834
13932
|
return false;
|
|
13835
13933
|
}
|
|
13836
13934
|
if (prop.computed) {
|
|
@@ -13840,7 +13938,7 @@ function initProvablyLacksSignal(init) {
|
|
|
13840
13938
|
return true;
|
|
13841
13939
|
}
|
|
13842
13940
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
13843
|
-
return node.type ===
|
|
13941
|
+
return node.type === import_utils68.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils68.AST_NODE_TYPES.TemplateLiteral || node.type === import_utils68.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils68.AST_NODE_TYPES.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
13844
13942
|
}
|
|
13845
13943
|
var require_fetch_timeout_default = createRule({
|
|
13846
13944
|
name: "require-fetch-timeout",
|
|
@@ -13878,30 +13976,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
13878
13976
|
}
|
|
13879
13977
|
function resolvesToGlobal(identifier) {
|
|
13880
13978
|
const scope = context.sourceCode.getScope(identifier);
|
|
13881
|
-
const variable =
|
|
13979
|
+
const variable = import_utils68.ASTUtils.findVariable(scope, identifier.name);
|
|
13882
13980
|
return variable === null || variable.defs.length === 0;
|
|
13883
13981
|
}
|
|
13884
13982
|
function isGlobalFetchCall2(callee) {
|
|
13885
|
-
if (callee.type ===
|
|
13983
|
+
if (callee.type === import_utils68.AST_NODE_TYPES.Identifier) {
|
|
13886
13984
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
13887
13985
|
}
|
|
13888
|
-
return callee.type ===
|
|
13986
|
+
return callee.type === import_utils68.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils68.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils68.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
13889
13987
|
}
|
|
13890
13988
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
13891
|
-
const variable =
|
|
13989
|
+
const variable = import_utils68.ASTUtils.findVariable(
|
|
13892
13990
|
context.sourceCode.getScope(identifier),
|
|
13893
13991
|
identifier.name
|
|
13894
13992
|
);
|
|
13895
13993
|
if (variable?.defs.length !== 1) return false;
|
|
13896
13994
|
const definition = variable.defs[0];
|
|
13897
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
13995
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== import_utils68.AST_NODE_TYPES.ObjectExpression || !initProvablyLacksSignal(definition.node.init)) {
|
|
13898
13996
|
return false;
|
|
13899
13997
|
}
|
|
13900
13998
|
for (const reference of variable.references) {
|
|
13901
13999
|
const ref = reference.identifier;
|
|
13902
14000
|
if (ref === identifier || ref === definition.name) continue;
|
|
13903
14001
|
const member = ref.parent;
|
|
13904
|
-
if (member.type !==
|
|
14002
|
+
if (member.type !== import_utils68.AST_NODE_TYPES.MemberExpression || member.object !== ref || member.computed || member.property.type !== import_utils68.AST_NODE_TYPES.Identifier || member.property.name === "signal" || member.parent.type !== import_utils68.AST_NODE_TYPES.AssignmentExpression || member.parent.left !== member) {
|
|
13905
14003
|
return false;
|
|
13906
14004
|
}
|
|
13907
14005
|
}
|
|
@@ -13916,7 +14014,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
13916
14014
|
if (node.arguments.length === 1 && first !== void 0 && !isInlineUrl(first, resolvesToGlobal)) {
|
|
13917
14015
|
return;
|
|
13918
14016
|
}
|
|
13919
|
-
if (init === void 0 || initProvablyLacksSignal(init) || init.type ===
|
|
14017
|
+
if (init === void 0 || initProvablyLacksSignal(init) || init.type === import_utils68.AST_NODE_TYPES.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
13920
14018
|
context.report({ node, messageId: "missingSignal" });
|
|
13921
14019
|
}
|
|
13922
14020
|
}
|
|
@@ -13925,7 +14023,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
13925
14023
|
});
|
|
13926
14024
|
|
|
13927
14025
|
// src/rules/require-port-for-service.ts
|
|
13928
|
-
var
|
|
14026
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
13929
14027
|
var requirePortForServiceDocumentation = {
|
|
13930
14028
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
13931
14029
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -13950,45 +14048,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
13950
14048
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
13951
14049
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
13952
14050
|
var staticMemberName6 = (member) => {
|
|
13953
|
-
if (member.property.type ===
|
|
13954
|
-
if (!member.computed && member.property.type ===
|
|
13955
|
-
return member.computed && member.property.type ===
|
|
14051
|
+
if (member.property.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier) return `#${member.property.name}`;
|
|
14052
|
+
if (!member.computed && member.property.type === import_utils69.AST_NODE_TYPES.Identifier) return member.property.name;
|
|
14053
|
+
return member.computed && member.property.type === import_utils69.AST_NODE_TYPES.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
13956
14054
|
};
|
|
13957
14055
|
var detachedValueExports = (program) => {
|
|
13958
14056
|
const names = /* @__PURE__ */ new Set();
|
|
13959
14057
|
for (const statement of program.body) {
|
|
13960
|
-
if (statement.type ===
|
|
14058
|
+
if (statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
13961
14059
|
for (const specifier of statement.specifiers) {
|
|
13962
14060
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
13963
14061
|
}
|
|
13964
|
-
} else if (statement.type ===
|
|
14062
|
+
} else if (statement.type === import_utils69.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
13965
14063
|
names.add(statement.declaration.name);
|
|
13966
|
-
} else if (statement.type ===
|
|
14064
|
+
} else if (statement.type === import_utils69.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
13967
14065
|
names.add(statement.expression.name);
|
|
13968
14066
|
}
|
|
13969
14067
|
}
|
|
13970
14068
|
return names;
|
|
13971
14069
|
};
|
|
13972
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
14070
|
+
var isExportedClass2 = (node, detached) => node.parent.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils69.AST_NODE_TYPES.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
13973
14071
|
var readTypeReference = (annotation) => {
|
|
13974
|
-
if (annotation?.type ===
|
|
14072
|
+
if (annotation?.type === import_utils69.AST_NODE_TYPES.TSUnionType) {
|
|
13975
14073
|
const members = annotation.types.filter(
|
|
13976
|
-
(member) => member.type !==
|
|
14074
|
+
(member) => member.type !== import_utils69.AST_NODE_TYPES.TSUndefinedKeyword && member.type !== import_utils69.AST_NODE_TYPES.TSNullKeyword
|
|
13977
14075
|
);
|
|
13978
14076
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
13979
14077
|
}
|
|
13980
|
-
if (annotation === void 0 || annotation.type !==
|
|
14078
|
+
if (annotation === void 0 || annotation.type !== import_utils69.AST_NODE_TYPES.TSTypeReference) return null;
|
|
13981
14079
|
const { typeName } = annotation;
|
|
13982
|
-
const rightmost = typeName.type ===
|
|
14080
|
+
const rightmost = typeName.type === import_utils69.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils69.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
13983
14081
|
if (rightmost === null) return null;
|
|
13984
14082
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
13985
14083
|
};
|
|
13986
|
-
var qualifiedName = (name) => name.type ===
|
|
14084
|
+
var qualifiedName = (name) => name.type === import_utils69.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils69.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
13987
14085
|
var propertySignatureTypes = (members) => {
|
|
13988
14086
|
const types = /* @__PURE__ */ new Map();
|
|
13989
14087
|
for (const member of members) {
|
|
13990
|
-
if (member.type !==
|
|
13991
|
-
if (member.computed || member.key.type !==
|
|
14088
|
+
if (member.type !== import_utils69.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
14089
|
+
if (member.computed || member.key.type !== import_utils69.AST_NODE_TYPES.Identifier) continue;
|
|
13992
14090
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
13993
14091
|
if (reference === null) continue;
|
|
13994
14092
|
types.set(member.key.name, reference);
|
|
@@ -13999,18 +14097,18 @@ var fileTypeIndex = (program) => {
|
|
|
13999
14097
|
const objects = /* @__PURE__ */ new Map();
|
|
14000
14098
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
14001
14099
|
for (const statement of program.body) {
|
|
14002
|
-
const declaration = statement.type ===
|
|
14003
|
-
if (declaration?.type ===
|
|
14100
|
+
const declaration = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14101
|
+
if (declaration?.type === import_utils69.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
14004
14102
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
14005
14103
|
continue;
|
|
14006
14104
|
}
|
|
14007
|
-
if (declaration?.type !==
|
|
14105
|
+
if (declaration?.type !== import_utils69.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
14008
14106
|
const aliased = declaration.typeAnnotation;
|
|
14009
|
-
if (aliased.type ===
|
|
14107
|
+
if (aliased.type === import_utils69.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils69.AST_NODE_TYPES.TSConstructorType) {
|
|
14010
14108
|
functionAliases.add(declaration.id.name);
|
|
14011
14109
|
continue;
|
|
14012
14110
|
}
|
|
14013
|
-
const literals = aliased.type ===
|
|
14111
|
+
const literals = aliased.type === import_utils69.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils69.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils69.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
14014
14112
|
if (literals.length === 0) continue;
|
|
14015
14113
|
const merged = /* @__PURE__ */ new Map();
|
|
14016
14114
|
for (const literal of literals) {
|
|
@@ -14038,10 +14136,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14038
14136
|
while (pending.length > 0) {
|
|
14039
14137
|
const current = pending.pop();
|
|
14040
14138
|
if (current === void 0) break;
|
|
14041
|
-
if (current.type ===
|
|
14042
|
-
const expression = current.type ===
|
|
14043
|
-
const storedField = expression?.type ===
|
|
14044
|
-
if (expression?.type !==
|
|
14139
|
+
if (current.type === import_utils69.AST_NODE_TYPES.ArrowFunctionExpression || current.type === import_utils69.AST_NODE_TYPES.FunctionExpression || current.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils69.AST_NODE_TYPES.ClassExpression || current.type === import_utils69.AST_NODE_TYPES.ClassDeclaration) continue;
|
|
14140
|
+
const expression = current.type === import_utils69.AST_NODE_TYPES.ExpressionStatement ? current.expression : null;
|
|
14141
|
+
const storedField = expression?.type === import_utils69.AST_NODE_TYPES.AssignmentExpression && expression.left.type === import_utils69.AST_NODE_TYPES.MemberExpression && expression.left.object.type === import_utils69.AST_NODE_TYPES.ThisExpression ? staticMemberName6(expression.left) : null;
|
|
14142
|
+
if (expression?.type !== import_utils69.AST_NODE_TYPES.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== import_utils69.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils69.AST_NODE_TYPES.ThisExpression || storedField === null) {
|
|
14045
14143
|
for (const key of Object.keys(current)) {
|
|
14046
14144
|
if (key === "parent") continue;
|
|
14047
14145
|
const value = current[key];
|
|
@@ -14054,14 +14152,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14054
14152
|
continue;
|
|
14055
14153
|
}
|
|
14056
14154
|
let source = expression.right;
|
|
14057
|
-
while (source.type ===
|
|
14058
|
-
if (source.type ===
|
|
14155
|
+
while (source.type === import_utils69.AST_NODE_TYPES.TSNonNullExpression || source.type === import_utils69.AST_NODE_TYPES.TSAsExpression || source.type === import_utils69.AST_NODE_TYPES.TSSatisfiesExpression || source.type === import_utils69.AST_NODE_TYPES.TSTypeAssertion) source = source.expression;
|
|
14156
|
+
if (source.type === import_utils69.AST_NODE_TYPES.NewExpression) {
|
|
14059
14157
|
constructedFields += 1;
|
|
14060
|
-
} else if (source.type ===
|
|
14158
|
+
} else if (source.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14061
14159
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
14062
14160
|
fields.add(storedField);
|
|
14063
14161
|
storedFieldsFrom.set(source.name, fields);
|
|
14064
|
-
} else if (source.type ===
|
|
14162
|
+
} else if (source.type === import_utils69.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14065
14163
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
14066
14164
|
fields.add(storedField);
|
|
14067
14165
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -14071,7 +14169,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14071
14169
|
const collaborators = [];
|
|
14072
14170
|
for (const parameter of ctor.value.params) {
|
|
14073
14171
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
14074
|
-
const fields = parameter.type ===
|
|
14172
|
+
const fields = parameter.type === import_utils69.AST_NODE_TYPES.TSParameterProperty ? [reference.name] : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
14075
14173
|
if (fields.length === 0) continue;
|
|
14076
14174
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
14077
14175
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -14086,8 +14184,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14086
14184
|
};
|
|
14087
14185
|
var parameterCollaborators = (parameter, declared) => {
|
|
14088
14186
|
let target = parameter;
|
|
14089
|
-
if (target.type ===
|
|
14090
|
-
if (target.type ===
|
|
14187
|
+
if (target.type === import_utils69.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
14188
|
+
if (target.type === import_utils69.AST_NODE_TYPES.ObjectPattern) {
|
|
14091
14189
|
return objectPatternCollaborators(target, declared);
|
|
14092
14190
|
}
|
|
14093
14191
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -14095,9 +14193,9 @@ var parameterCollaborators = (parameter, declared) => {
|
|
|
14095
14193
|
};
|
|
14096
14194
|
var namedParameterCollaborator = (annotated) => {
|
|
14097
14195
|
let target = annotated;
|
|
14098
|
-
if (target.type ===
|
|
14099
|
-
if (target.type ===
|
|
14100
|
-
if (target.type !==
|
|
14196
|
+
if (target.type === import_utils69.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
14197
|
+
if (target.type === import_utils69.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
14198
|
+
if (target.type !== import_utils69.AST_NODE_TYPES.Identifier) return null;
|
|
14101
14199
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
14102
14200
|
if (reference === null) return null;
|
|
14103
14201
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -14109,11 +14207,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
14109
14207
|
if (members === null) return [];
|
|
14110
14208
|
const collaborators = [];
|
|
14111
14209
|
for (const property of pattern.properties) {
|
|
14112
|
-
if (property.type !==
|
|
14113
|
-
if (property.key.type !==
|
|
14210
|
+
if (property.type !== import_utils69.AST_NODE_TYPES.Property || property.computed) continue;
|
|
14211
|
+
if (property.key.type !== import_utils69.AST_NODE_TYPES.Identifier) continue;
|
|
14114
14212
|
const key = property.key.name;
|
|
14115
|
-
const bound = property.value.type ===
|
|
14116
|
-
if (bound.type !==
|
|
14213
|
+
const bound = property.value.type === import_utils69.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
14214
|
+
if (bound.type !== import_utils69.AST_NODE_TYPES.Identifier) continue;
|
|
14117
14215
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
14118
14216
|
const reference = members.get(key);
|
|
14119
14217
|
if (reference === void 0) continue;
|
|
@@ -14122,21 +14220,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
14122
14220
|
return collaborators;
|
|
14123
14221
|
};
|
|
14124
14222
|
var bagMemberTypes = (annotation, declared) => {
|
|
14125
|
-
if (annotation.type ===
|
|
14223
|
+
if (annotation.type === import_utils69.AST_NODE_TYPES.TSTypeLiteral) {
|
|
14126
14224
|
return propertySignatureTypes(annotation.members);
|
|
14127
14225
|
}
|
|
14128
|
-
if (annotation.type !==
|
|
14226
|
+
if (annotation.type !== import_utils69.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14129
14227
|
return null;
|
|
14130
14228
|
}
|
|
14131
14229
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
14132
14230
|
};
|
|
14133
14231
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
14134
|
-
if (node.type ===
|
|
14232
|
+
if (node.type === import_utils69.AST_NODE_TYPES.CallExpression) {
|
|
14135
14233
|
const { callee } = node;
|
|
14136
|
-
if (callee.type ===
|
|
14137
|
-
return callee.type ===
|
|
14234
|
+
if (callee.type === import_utils69.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
14235
|
+
return callee.type === import_utils69.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils69.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
14138
14236
|
}
|
|
14139
|
-
return node.type ===
|
|
14237
|
+
return node.type === import_utils69.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils69.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
14140
14238
|
});
|
|
14141
14239
|
var subtreeHas = (root, found) => {
|
|
14142
14240
|
let hit = false;
|
|
@@ -14163,19 +14261,19 @@ var invokedInstanceField = (call) => {
|
|
|
14163
14261
|
const direct = instanceField(call.callee);
|
|
14164
14262
|
if (direct !== null) return direct;
|
|
14165
14263
|
let callee = call.callee;
|
|
14166
|
-
while (callee.type ===
|
|
14167
|
-
return callee.type ===
|
|
14264
|
+
while (callee.type === import_utils69.AST_NODE_TYPES.ChainExpression || callee.type === import_utils69.AST_NODE_TYPES.TSAsExpression || callee.type === import_utils69.AST_NODE_TYPES.TSNonNullExpression || callee.type === import_utils69.AST_NODE_TYPES.TSSatisfiesExpression || callee.type === import_utils69.AST_NODE_TYPES.TSTypeAssertion) callee = callee.expression;
|
|
14265
|
+
return callee.type === import_utils69.AST_NODE_TYPES.MemberExpression ? instanceField(callee.object) : null;
|
|
14168
14266
|
};
|
|
14169
14267
|
var instanceField = (candidate) => {
|
|
14170
14268
|
let node = candidate;
|
|
14171
|
-
while (node.type ===
|
|
14172
|
-
return node.type ===
|
|
14269
|
+
while (node.type === import_utils69.AST_NODE_TYPES.ChainExpression || node.type === import_utils69.AST_NODE_TYPES.TSAsExpression || node.type === import_utils69.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils69.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils69.AST_NODE_TYPES.TSTypeAssertion) node = node.expression;
|
|
14270
|
+
return node.type === import_utils69.AST_NODE_TYPES.MemberExpression && node.object.type === import_utils69.AST_NODE_TYPES.ThisExpression ? staticMemberName6(node) : null;
|
|
14173
14271
|
};
|
|
14174
14272
|
var behaviorallyInvokedFields = (body2) => {
|
|
14175
14273
|
const invoked = /* @__PURE__ */ new Set();
|
|
14176
14274
|
const visit = (current) => {
|
|
14177
|
-
if (current.type ===
|
|
14178
|
-
if (current.type ===
|
|
14275
|
+
if (current.type === import_utils69.AST_NODE_TYPES.ClassDeclaration || current.type === import_utils69.AST_NODE_TYPES.ClassExpression || current.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils69.AST_NODE_TYPES.FunctionExpression) return;
|
|
14276
|
+
if (current.type === import_utils69.AST_NODE_TYPES.CallExpression) {
|
|
14179
14277
|
const field = invokedInstanceField(current);
|
|
14180
14278
|
if (field !== null) invoked.add(field);
|
|
14181
14279
|
}
|
|
@@ -14188,14 +14286,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
14188
14286
|
}
|
|
14189
14287
|
};
|
|
14190
14288
|
for (const member of body2.body) {
|
|
14191
|
-
if (member.type ===
|
|
14192
|
-
if (member.type ===
|
|
14289
|
+
if (member.type === import_utils69.AST_NODE_TYPES.StaticBlock || member.static) continue;
|
|
14290
|
+
if (member.type === import_utils69.AST_NODE_TYPES.MethodDefinition) {
|
|
14193
14291
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
14194
14292
|
continue;
|
|
14195
14293
|
}
|
|
14196
|
-
if (member.type !==
|
|
14294
|
+
if (member.type !== import_utils69.AST_NODE_TYPES.PropertyDefinition || member.value === null) continue;
|
|
14197
14295
|
visit(
|
|
14198
|
-
member.value.type ===
|
|
14296
|
+
member.value.type === import_utils69.AST_NODE_TYPES.ArrowFunctionExpression ? member.value.body : member.value
|
|
14199
14297
|
);
|
|
14200
14298
|
}
|
|
14201
14299
|
return invoked;
|
|
@@ -14215,25 +14313,25 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
14215
14313
|
var fileInterfaceNames = (program) => {
|
|
14216
14314
|
const names = [];
|
|
14217
14315
|
for (const statement of program.body) {
|
|
14218
|
-
const declaration = statement.type ===
|
|
14219
|
-
if (declaration?.type ===
|
|
14316
|
+
const declaration = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14317
|
+
if (declaration?.type === import_utils69.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
14220
14318
|
}
|
|
14221
14319
|
return names;
|
|
14222
14320
|
};
|
|
14223
14321
|
var publicMethodNames = (body2, functionAliases) => {
|
|
14224
14322
|
const names = [];
|
|
14225
14323
|
for (const member of body2.body) {
|
|
14226
|
-
if (member.type ===
|
|
14324
|
+
if (member.type === import_utils69.AST_NODE_TYPES.PropertyDefinition) {
|
|
14227
14325
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
14228
|
-
if (member.value?.type !==
|
|
14229
|
-
names.push(member.key.type ===
|
|
14326
|
+
if (member.value?.type !== import_utils69.AST_NODE_TYPES.ArrowFunctionExpression && member.value?.type !== import_utils69.AST_NODE_TYPES.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== import_utils69.AST_NODE_TYPES.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === import_utils69.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils69.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
14327
|
+
names.push(member.key.type === import_utils69.AST_NODE_TYPES.Identifier ? member.key.name : "\u2026");
|
|
14230
14328
|
continue;
|
|
14231
14329
|
}
|
|
14232
|
-
if (member.type !==
|
|
14330
|
+
if (member.type !== import_utils69.AST_NODE_TYPES.MethodDefinition) continue;
|
|
14233
14331
|
if (member.kind !== "method" || member.static) continue;
|
|
14234
14332
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
14235
|
-
if (member.key.type ===
|
|
14236
|
-
if (member.key.type ===
|
|
14333
|
+
if (member.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
14334
|
+
if (member.key.type === import_utils69.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
14237
14335
|
else names.push("\u2026");
|
|
14238
14336
|
}
|
|
14239
14337
|
return names;
|
|
@@ -14241,13 +14339,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
14241
14339
|
var isFluentConstructionObject = (node, getText) => {
|
|
14242
14340
|
if (node.id === null) return false;
|
|
14243
14341
|
const methods = node.body.body.filter(
|
|
14244
|
-
(member) => member.type ===
|
|
14342
|
+
(member) => member.type === import_utils69.AST_NODE_TYPES.MethodDefinition && member.kind === "method" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.value.body !== null
|
|
14245
14343
|
);
|
|
14246
14344
|
if (methods.length === 0) return false;
|
|
14247
14345
|
return methods.every((member) => {
|
|
14248
14346
|
const result = member.value.returnType?.typeAnnotation;
|
|
14249
14347
|
if (result === void 0) return false;
|
|
14250
|
-
const returnsOwnType = result.type ===
|
|
14348
|
+
const returnsOwnType = result.type === import_utils69.AST_NODE_TYPES.TSTypeReference && result.typeName.type === import_utils69.AST_NODE_TYPES.Identifier && result.typeName.name === node.id?.name;
|
|
14251
14349
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
14252
14350
|
});
|
|
14253
14351
|
};
|
|
@@ -14255,10 +14353,10 @@ function localClassAbstractness(program) {
|
|
|
14255
14353
|
const classes = /* @__PURE__ */ new Map();
|
|
14256
14354
|
const parents = /* @__PURE__ */ new Map();
|
|
14257
14355
|
for (const statement of program.body) {
|
|
14258
|
-
const declaration = statement.type ===
|
|
14259
|
-
if (declaration?.type ===
|
|
14356
|
+
const declaration = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils69.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
14357
|
+
if (declaration?.type === import_utils69.AST_NODE_TYPES.ClassDeclaration && declaration.id !== null) {
|
|
14260
14358
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
14261
|
-
if (declaration.superClass?.type ===
|
|
14359
|
+
if (declaration.superClass?.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14262
14360
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
14263
14361
|
}
|
|
14264
14362
|
}
|
|
@@ -14280,43 +14378,43 @@ function localInterfaceSurfaces(program) {
|
|
|
14280
14378
|
const parents = /* @__PURE__ */ new Map();
|
|
14281
14379
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
14282
14380
|
for (const statement of program.body) {
|
|
14283
|
-
const declaration = statement.type ===
|
|
14284
|
-
if (declaration?.type ===
|
|
14381
|
+
const declaration = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14382
|
+
if (declaration?.type === import_utils69.AST_NODE_TYPES.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === import_utils69.AST_NODE_TYPES.TSFunctionType || declaration.typeAnnotation.type === import_utils69.AST_NODE_TYPES.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
14285
14383
|
}
|
|
14286
14384
|
for (const statement of program.body) {
|
|
14287
|
-
const declaration = statement.type ===
|
|
14288
|
-
if (declaration?.type ===
|
|
14385
|
+
const declaration = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14386
|
+
if (declaration?.type === import_utils69.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
14289
14387
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
14290
|
-
const parts = declaration.typeAnnotation.type ===
|
|
14388
|
+
const parts = declaration.typeAnnotation.type === import_utils69.AST_NODE_TYPES.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
14291
14389
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
14292
14390
|
for (const part of parts) {
|
|
14293
|
-
if (part.type ===
|
|
14391
|
+
if (part.type === import_utils69.AST_NODE_TYPES.TSTypeReference && part.typeName.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14294
14392
|
inherited.push(part.typeName.name);
|
|
14295
14393
|
continue;
|
|
14296
14394
|
}
|
|
14297
|
-
if (part.type !==
|
|
14395
|
+
if (part.type !== import_utils69.AST_NODE_TYPES.TSTypeLiteral) continue;
|
|
14298
14396
|
for (const member of part.members) {
|
|
14299
|
-
if (member.type !==
|
|
14300
|
-
if (member.computed || member.key.type !==
|
|
14301
|
-
if (member.type ===
|
|
14397
|
+
if (member.type !== import_utils69.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils69.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
14398
|
+
if (member.computed || member.key.type !== import_utils69.AST_NODE_TYPES.Identifier) continue;
|
|
14399
|
+
if (member.type === import_utils69.AST_NODE_TYPES.TSMethodSignature) {
|
|
14302
14400
|
callables2.add(member.key.name);
|
|
14303
14401
|
continue;
|
|
14304
14402
|
}
|
|
14305
|
-
if (member.type !==
|
|
14403
|
+
if (member.type !== import_utils69.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
14306
14404
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
14307
|
-
if (annotation?.type ===
|
|
14405
|
+
if (annotation?.type === import_utils69.AST_NODE_TYPES.TSFunctionType || annotation?.type === import_utils69.AST_NODE_TYPES.TSTypeReference && annotation.typeName.type === import_utils69.AST_NODE_TYPES.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(member.key.name);
|
|
14308
14406
|
}
|
|
14309
14407
|
}
|
|
14310
14408
|
interfaces.set(declaration.id.name, callables2);
|
|
14311
14409
|
parents.set(declaration.id.name, inherited);
|
|
14312
14410
|
continue;
|
|
14313
14411
|
}
|
|
14314
|
-
if (declaration?.type !==
|
|
14412
|
+
if (declaration?.type !== import_utils69.AST_NODE_TYPES.TSInterfaceDeclaration) continue;
|
|
14315
14413
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
14316
14414
|
for (const member of declaration.body.body) {
|
|
14317
|
-
if (member.type !==
|
|
14318
|
-
if (member.computed || member.key.type !==
|
|
14319
|
-
if (member.type ===
|
|
14415
|
+
if (member.type !== import_utils69.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils69.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
14416
|
+
if (member.computed || member.key.type !== import_utils69.AST_NODE_TYPES.Identifier) continue;
|
|
14417
|
+
if (member.type === import_utils69.AST_NODE_TYPES.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === import_utils69.AST_NODE_TYPES.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === import_utils69.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils69.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(member.key.name);
|
|
14320
14418
|
}
|
|
14321
14419
|
interfaces.set(declaration.id.name, callables);
|
|
14322
14420
|
parents.set(
|
|
@@ -14324,7 +14422,7 @@ function localInterfaceSurfaces(program) {
|
|
|
14324
14422
|
[
|
|
14325
14423
|
...parents.get(declaration.id.name) ?? [],
|
|
14326
14424
|
...declaration.extends.flatMap(
|
|
14327
|
-
(heritage) => heritage.expression.type ===
|
|
14425
|
+
(heritage) => heritage.expression.type === import_utils69.AST_NODE_TYPES.Identifier ? [heritage.expression.name] : ["*"]
|
|
14328
14426
|
)
|
|
14329
14427
|
]
|
|
14330
14428
|
);
|
|
@@ -14351,7 +14449,7 @@ function localInterfaceSurfaces(program) {
|
|
|
14351
14449
|
}
|
|
14352
14450
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
14353
14451
|
if (node.superClass !== null) {
|
|
14354
|
-
if (node.superClass.type !==
|
|
14452
|
+
if (node.superClass.type !== import_utils69.AST_NODE_TYPES.Identifier) return true;
|
|
14355
14453
|
const localAbstract = classes.get(node.superClass.name);
|
|
14356
14454
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
14357
14455
|
}
|
|
@@ -14363,7 +14461,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
14363
14461
|
if (node.implements.length === 0) return false;
|
|
14364
14462
|
const combined = /* @__PURE__ */ new Set();
|
|
14365
14463
|
for (const implementation of node.implements) {
|
|
14366
|
-
if (implementation.expression.type !==
|
|
14464
|
+
if (implementation.expression.type !== import_utils69.AST_NODE_TYPES.Identifier) return true;
|
|
14367
14465
|
const name = implementation.expression.name;
|
|
14368
14466
|
const localAbstract = classes.get(name);
|
|
14369
14467
|
if (localAbstract === true) return true;
|
|
@@ -14406,7 +14504,7 @@ var require_port_for_service_default = createRule({
|
|
|
14406
14504
|
if (node.abstract === true) return;
|
|
14407
14505
|
if (node.decorators.length > 0) return;
|
|
14408
14506
|
const ctor = node.body.body.find(
|
|
14409
|
-
(member) => member.type ===
|
|
14507
|
+
(member) => member.type === import_utils69.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
14410
14508
|
);
|
|
14411
14509
|
if (ctor === void 0) return;
|
|
14412
14510
|
const constructorFacts = readConstructor(
|
|
@@ -14441,7 +14539,7 @@ var require_port_for_service_default = createRule({
|
|
|
14441
14539
|
});
|
|
14442
14540
|
|
|
14443
14541
|
// src/rules/require-static-next-matcher.ts
|
|
14444
|
-
var
|
|
14542
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
14445
14543
|
var requireStaticNextMatcherDocumentation = {
|
|
14446
14544
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
14447
14545
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -14454,34 +14552,34 @@ var requireStaticNextMatcherDocumentation = {
|
|
|
14454
14552
|
};
|
|
14455
14553
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
14456
14554
|
function unwrapExpression3(node) {
|
|
14457
|
-
if (node.type ===
|
|
14555
|
+
if (node.type === import_utils70.AST_NODE_TYPES.TSAsExpression || node.type === import_utils70.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils70.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils70.AST_NODE_TYPES.TSTypeAssertion) {
|
|
14458
14556
|
return unwrapExpression3(node.expression);
|
|
14459
14557
|
}
|
|
14460
14558
|
return node;
|
|
14461
14559
|
}
|
|
14462
14560
|
function isStaticValue(node) {
|
|
14463
14561
|
const value = unwrapExpression3(node);
|
|
14464
|
-
if (value.type ===
|
|
14562
|
+
if (value.type === import_utils70.AST_NODE_TYPES.Literal) {
|
|
14465
14563
|
return true;
|
|
14466
14564
|
}
|
|
14467
|
-
if (value.type ===
|
|
14565
|
+
if (value.type === import_utils70.AST_NODE_TYPES.TemplateLiteral) {
|
|
14468
14566
|
return value.expressions.length === 0;
|
|
14469
14567
|
}
|
|
14470
|
-
if (value.type ===
|
|
14568
|
+
if (value.type === import_utils70.AST_NODE_TYPES.ArrayExpression) {
|
|
14471
14569
|
return value.elements.every(
|
|
14472
|
-
(element) => element !== null && element.type !==
|
|
14570
|
+
(element) => element !== null && element.type !== import_utils70.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
14473
14571
|
);
|
|
14474
14572
|
}
|
|
14475
|
-
if (value.type ===
|
|
14573
|
+
if (value.type === import_utils70.AST_NODE_TYPES.ObjectExpression) {
|
|
14476
14574
|
return value.properties.every(
|
|
14477
|
-
(property) => property.type ===
|
|
14575
|
+
(property) => property.type === import_utils70.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils70.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
14478
14576
|
);
|
|
14479
14577
|
}
|
|
14480
14578
|
return false;
|
|
14481
14579
|
}
|
|
14482
14580
|
function propertyName2(property) {
|
|
14483
14581
|
if (property.computed) return null;
|
|
14484
|
-
if (property.key.type ===
|
|
14582
|
+
if (property.key.type === import_utils70.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
14485
14583
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
14486
14584
|
}
|
|
14487
14585
|
var require_static_next_matcher_default = createRule({
|
|
@@ -14504,19 +14602,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
14504
14602
|
}
|
|
14505
14603
|
return {
|
|
14506
14604
|
ExportNamedDeclaration(node) {
|
|
14507
|
-
if (node.declaration?.type !==
|
|
14605
|
+
if (node.declaration?.type !== import_utils70.AST_NODE_TYPES.VariableDeclaration) {
|
|
14508
14606
|
return;
|
|
14509
14607
|
}
|
|
14510
14608
|
for (const declaration of node.declaration.declarations) {
|
|
14511
|
-
if (declaration.id.type !==
|
|
14609
|
+
if (declaration.id.type !== import_utils70.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
14512
14610
|
continue;
|
|
14513
14611
|
}
|
|
14514
14612
|
const config = unwrapExpression3(declaration.init);
|
|
14515
|
-
if (config.type !==
|
|
14613
|
+
if (config.type !== import_utils70.AST_NODE_TYPES.ObjectExpression) {
|
|
14516
14614
|
continue;
|
|
14517
14615
|
}
|
|
14518
14616
|
for (const property of config.properties) {
|
|
14519
|
-
if (property.type !==
|
|
14617
|
+
if (property.type !== import_utils70.AST_NODE_TYPES.Property || propertyName2(property) !== "matcher" || property.value.type === import_utils70.AST_NODE_TYPES.AssignmentPattern) {
|
|
14520
14618
|
continue;
|
|
14521
14619
|
}
|
|
14522
14620
|
if (!isStaticValue(property.value)) {
|
|
@@ -14530,7 +14628,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
14530
14628
|
});
|
|
14531
14629
|
|
|
14532
14630
|
// src/rules/require-zod-form-validation.ts
|
|
14533
|
-
var
|
|
14631
|
+
var import_utils71 = require("@typescript-eslint/utils");
|
|
14534
14632
|
var requireZodFormValidationDocumentation = {
|
|
14535
14633
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
14536
14634
|
rationale: "FormData values are untrusted strings or files and need runtime validation before use.",
|
|
@@ -14555,14 +14653,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
14555
14653
|
var zodReceiverRoot = (node) => {
|
|
14556
14654
|
let current = node;
|
|
14557
14655
|
while (true) {
|
|
14558
|
-
if (current.type ===
|
|
14656
|
+
if (current.type === import_utils71.AST_NODE_TYPES.Identifier) {
|
|
14559
14657
|
return current;
|
|
14560
14658
|
}
|
|
14561
|
-
if (current.type ===
|
|
14659
|
+
if (current.type === import_utils71.AST_NODE_TYPES.CallExpression) {
|
|
14562
14660
|
current = current.callee;
|
|
14563
14661
|
continue;
|
|
14564
14662
|
}
|
|
14565
|
-
if (current.type ===
|
|
14663
|
+
if (current.type === import_utils71.AST_NODE_TYPES.MemberExpression) {
|
|
14566
14664
|
current = current.object;
|
|
14567
14665
|
continue;
|
|
14568
14666
|
}
|
|
@@ -14571,12 +14669,12 @@ var zodReceiverRoot = (node) => {
|
|
|
14571
14669
|
};
|
|
14572
14670
|
var isFormDataMethodCall = (node) => {
|
|
14573
14671
|
let current = node;
|
|
14574
|
-
if (current.type ===
|
|
14672
|
+
if (current.type === import_utils71.AST_NODE_TYPES.AwaitExpression) {
|
|
14575
14673
|
current = current.argument;
|
|
14576
14674
|
}
|
|
14577
|
-
if (current.type !==
|
|
14675
|
+
if (current.type !== import_utils71.AST_NODE_TYPES.CallExpression) return false;
|
|
14578
14676
|
const callee = current.callee;
|
|
14579
|
-
return callee.type ===
|
|
14677
|
+
return callee.type === import_utils71.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils71.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
14580
14678
|
};
|
|
14581
14679
|
var require_zod_form_validation_default = createRule({
|
|
14582
14680
|
name: "require-zod-form-validation",
|
|
@@ -14597,7 +14695,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14597
14695
|
return {};
|
|
14598
14696
|
}
|
|
14599
14697
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
14600
|
-
const resolvedBinding = (identifier) =>
|
|
14698
|
+
const resolvedBinding = (identifier) => import_utils71.ASTUtils.findVariable(
|
|
14601
14699
|
context.sourceCode.getScope(identifier),
|
|
14602
14700
|
identifier.name
|
|
14603
14701
|
);
|
|
@@ -14607,16 +14705,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
14607
14705
|
return false;
|
|
14608
14706
|
}
|
|
14609
14707
|
const definition = binding.defs[0];
|
|
14610
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
14708
|
+
if (definition?.type !== "Variable" || definition.node.type !== import_utils71.AST_NODE_TYPES.VariableDeclarator) {
|
|
14611
14709
|
return false;
|
|
14612
14710
|
}
|
|
14613
14711
|
const init = definition.node.init;
|
|
14614
|
-
return init?.type ===
|
|
14712
|
+
return init?.type === import_utils71.AST_NODE_TYPES.ObjectExpression || init?.type === import_utils71.AST_NODE_TYPES.ArrayExpression || init?.type === import_utils71.AST_NODE_TYPES.Literal || init?.type === import_utils71.AST_NODE_TYPES.ArrowFunctionExpression || init?.type === import_utils71.AST_NODE_TYPES.FunctionExpression;
|
|
14615
14713
|
};
|
|
14616
14714
|
const isZodParseCall = (node) => {
|
|
14617
|
-
if (node.type !==
|
|
14715
|
+
if (node.type !== import_utils71.AST_NODE_TYPES.CallExpression) return false;
|
|
14618
14716
|
const callee = node.callee;
|
|
14619
|
-
if (callee.type !==
|
|
14717
|
+
if (callee.type !== import_utils71.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils71.AST_NODE_TYPES.Identifier || !ZOD_PARSE_METHODS.has(callee.property.name)) {
|
|
14620
14718
|
return false;
|
|
14621
14719
|
}
|
|
14622
14720
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -14625,14 +14723,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
14625
14723
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
14626
14724
|
};
|
|
14627
14725
|
const isFormSourceIdentifier = (node) => {
|
|
14628
|
-
if (node.type !==
|
|
14726
|
+
if (node.type !== import_utils71.AST_NODE_TYPES.Identifier) return false;
|
|
14629
14727
|
const conventionalName = /formdata/i.test(node.name);
|
|
14630
14728
|
let scope = context.sourceCode.getScope(node);
|
|
14631
14729
|
while (scope !== null) {
|
|
14632
14730
|
const variable = scope.set.get(node.name);
|
|
14633
14731
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
14634
14732
|
const def = variable.defs[0];
|
|
14635
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
14733
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils71.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
14636
14734
|
return isFormDataMethodCall(def.node.init);
|
|
14637
14735
|
}
|
|
14638
14736
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -14643,8 +14741,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
14643
14741
|
};
|
|
14644
14742
|
const isFormDataGetCall = (node) => {
|
|
14645
14743
|
const callee = node.callee;
|
|
14646
|
-
if (callee.type !==
|
|
14647
|
-
if (callee.property.type !==
|
|
14744
|
+
if (callee.type !== import_utils71.AST_NODE_TYPES.MemberExpression) return false;
|
|
14745
|
+
if (callee.property.type !== import_utils71.AST_NODE_TYPES.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
14648
14746
|
return false;
|
|
14649
14747
|
}
|
|
14650
14748
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -14660,16 +14758,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
14660
14758
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
14661
14759
|
const isInstanceofNarrowing = (node) => {
|
|
14662
14760
|
const parent = node.parent;
|
|
14663
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
14761
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils71.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils71.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
14664
14762
|
};
|
|
14665
14763
|
const boundDeclarator = (node) => {
|
|
14666
14764
|
let current = node;
|
|
14667
14765
|
let parent = current.parent;
|
|
14668
|
-
while ((parent.type ===
|
|
14766
|
+
while ((parent.type === import_utils71.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils71.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils71.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils71.AST_NODE_TYPES.ChainExpression) && parent.expression === current) {
|
|
14669
14767
|
current = parent;
|
|
14670
14768
|
parent = current.parent;
|
|
14671
14769
|
}
|
|
14672
|
-
if (parent.type ===
|
|
14770
|
+
if (parent.type === import_utils71.AST_NODE_TYPES.VariableDeclarator && parent.init === current && parent.id.type === import_utils71.AST_NODE_TYPES.Identifier) {
|
|
14673
14771
|
return parent;
|
|
14674
14772
|
}
|
|
14675
14773
|
return null;
|
|
@@ -14678,7 +14776,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14678
14776
|
let current = node;
|
|
14679
14777
|
while (current.parent !== void 0) {
|
|
14680
14778
|
const parent = current.parent;
|
|
14681
|
-
if (parent.type ===
|
|
14779
|
+
if (parent.type === import_utils71.AST_NODE_TYPES.BlockStatement || parent.type === import_utils71.AST_NODE_TYPES.Program) {
|
|
14682
14780
|
return current;
|
|
14683
14781
|
}
|
|
14684
14782
|
current = parent;
|
|
@@ -14687,12 +14785,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
14687
14785
|
};
|
|
14688
14786
|
const zodParseMethod = (call) => {
|
|
14689
14787
|
const callee = call.callee;
|
|
14690
|
-
return callee.type ===
|
|
14788
|
+
return callee.type === import_utils71.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils71.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
14691
14789
|
};
|
|
14692
14790
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
14693
14791
|
let current = node.parent;
|
|
14694
14792
|
while (current !== void 0 && current !== statement) {
|
|
14695
|
-
if (current.type ===
|
|
14793
|
+
if (current.type === import_utils71.AST_NODE_TYPES.LogicalExpression || current.type === import_utils71.AST_NODE_TYPES.ConditionalExpression) {
|
|
14696
14794
|
return true;
|
|
14697
14795
|
}
|
|
14698
14796
|
current = current.parent;
|
|
@@ -14702,7 +14800,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14702
14800
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
14703
14801
|
let current = node.parent;
|
|
14704
14802
|
while (current !== void 0 && current !== statement) {
|
|
14705
|
-
if (current.type ===
|
|
14803
|
+
if (current.type === import_utils71.AST_NODE_TYPES.AwaitExpression) return true;
|
|
14706
14804
|
current = current.parent;
|
|
14707
14805
|
}
|
|
14708
14806
|
return false;
|
|
@@ -14715,7 +14813,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14715
14813
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
14716
14814
|
return null;
|
|
14717
14815
|
}
|
|
14718
|
-
if (validationStatement.type !==
|
|
14816
|
+
if (validationStatement.type !== import_utils71.AST_NODE_TYPES.VariableDeclaration && validationStatement.type !== import_utils71.AST_NODE_TYPES.ExpressionStatement) {
|
|
14719
14817
|
return null;
|
|
14720
14818
|
}
|
|
14721
14819
|
const method = zodParseMethod(parse2);
|
|
@@ -14727,16 +14825,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
14727
14825
|
};
|
|
14728
14826
|
const isSafePrevalidationInspection = (identifier) => {
|
|
14729
14827
|
const parent = identifier.parent;
|
|
14730
|
-
if (parent.type ===
|
|
14828
|
+
if (parent.type === import_utils71.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof") {
|
|
14731
14829
|
return true;
|
|
14732
14830
|
}
|
|
14733
|
-
if (parent.type !==
|
|
14831
|
+
if (parent.type !== import_utils71.AST_NODE_TYPES.BinaryExpression || parent.left !== identifier) {
|
|
14734
14832
|
return false;
|
|
14735
14833
|
}
|
|
14736
14834
|
if (parent.operator === "instanceof") {
|
|
14737
|
-
return parent.right.type ===
|
|
14835
|
+
return parent.right.type === import_utils71.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
14738
14836
|
}
|
|
14739
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
14837
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === import_utils71.AST_NODE_TYPES.Literal && parent.right.value === null || parent.right.type === import_utils71.AST_NODE_TYPES.Identifier && parent.right.name === "undefined");
|
|
14740
14838
|
};
|
|
14741
14839
|
const isDescendantOf = (node, ancestor) => {
|
|
14742
14840
|
let current = node;
|
|
@@ -14747,23 +14845,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
14747
14845
|
return false;
|
|
14748
14846
|
};
|
|
14749
14847
|
const blockTerminates = (node) => {
|
|
14750
|
-
if (node.type ===
|
|
14848
|
+
if (node.type === import_utils71.AST_NODE_TYPES.ReturnStatement || node.type === import_utils71.AST_NODE_TYPES.ThrowStatement) {
|
|
14751
14849
|
return true;
|
|
14752
14850
|
}
|
|
14753
|
-
if (node.type !==
|
|
14851
|
+
if (node.type !== import_utils71.AST_NODE_TYPES.BlockStatement || node.body.length === 0) return false;
|
|
14754
14852
|
const last = node.body.at(-1);
|
|
14755
14853
|
return last !== void 0 && blockTerminates(last);
|
|
14756
14854
|
};
|
|
14757
14855
|
const narrowingIf = (identifier) => {
|
|
14758
14856
|
const comparison = identifier.parent;
|
|
14759
|
-
if (comparison?.type !==
|
|
14857
|
+
if (comparison?.type !== import_utils71.AST_NODE_TYPES.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== import_utils71.AST_NODE_TYPES.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
14760
14858
|
return null;
|
|
14761
14859
|
}
|
|
14762
14860
|
const maybeNegation = comparison.parent;
|
|
14763
|
-
const negated = maybeNegation?.type ===
|
|
14861
|
+
const negated = maybeNegation?.type === import_utils71.AST_NODE_TYPES.UnaryExpression && maybeNegation.operator === "!";
|
|
14764
14862
|
const test = negated ? maybeNegation : comparison;
|
|
14765
14863
|
const branch = test.parent;
|
|
14766
|
-
return branch?.type ===
|
|
14864
|
+
return branch?.type === import_utils71.AST_NODE_TYPES.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
14767
14865
|
};
|
|
14768
14866
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
14769
14867
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -14783,7 +14881,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14783
14881
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
14784
14882
|
if (variable === void 0) return false;
|
|
14785
14883
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
14786
|
-
(identifier) => identifier.type ===
|
|
14884
|
+
(identifier) => identifier.type === import_utils71.AST_NODE_TYPES.Identifier
|
|
14787
14885
|
);
|
|
14788
14886
|
if (references.length === 0) return false;
|
|
14789
14887
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -14809,7 +14907,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14809
14907
|
ImportDeclaration(node) {
|
|
14810
14908
|
if (!isZodModule(node.source.value)) return;
|
|
14811
14909
|
for (const specifier of node.specifiers) {
|
|
14812
|
-
if (specifier.type ===
|
|
14910
|
+
if (specifier.type === import_utils71.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils71.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils71.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils71.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
14813
14911
|
const binding = resolvedBinding(specifier.local);
|
|
14814
14912
|
if (binding !== null) zodBindings.add(binding);
|
|
14815
14913
|
}
|
|
@@ -14830,7 +14928,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14830
14928
|
});
|
|
14831
14929
|
|
|
14832
14930
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
14833
|
-
var
|
|
14931
|
+
var import_utils72 = require("@typescript-eslint/utils");
|
|
14834
14932
|
var storeInsertRequiresOnConflictDocumentation = {
|
|
14835
14933
|
summary: "Require embedded inserts in explicitly replayable callables to carry conflict handling.",
|
|
14836
14934
|
rationale: "A callable named as an enqueue, seed, migration, schedule, ensure, or upsert promises replay safety.",
|
|
@@ -14894,7 +14992,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
14894
14992
|
});
|
|
14895
14993
|
|
|
14896
14994
|
// src/rules/stepdown.ts
|
|
14897
|
-
var
|
|
14995
|
+
var import_utils73 = require("@typescript-eslint/utils");
|
|
14898
14996
|
var stepdownDocumentation = {
|
|
14899
14997
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
14900
14998
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -14911,7 +15009,7 @@ var stepdownDocumentation = {
|
|
|
14911
15009
|
]
|
|
14912
15010
|
};
|
|
14913
15011
|
function isFunction(node) {
|
|
14914
|
-
return node.type ===
|
|
15012
|
+
return node.type === import_utils73.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils73.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils73.AST_NODE_TYPES.FunctionExpression;
|
|
14915
15013
|
}
|
|
14916
15014
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true) {
|
|
14917
15015
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -15006,8 +15104,8 @@ function moduleScope(context, program) {
|
|
|
15006
15104
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
15007
15105
|
const overloadNames = new Set(
|
|
15008
15106
|
program.body.flatMap((statement) => {
|
|
15009
|
-
const node = statement.type ===
|
|
15010
|
-
return node?.type ===
|
|
15107
|
+
const node = statement.type === import_utils73.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15108
|
+
return node?.type === import_utils73.AST_NODE_TYPES.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
15011
15109
|
})
|
|
15012
15110
|
);
|
|
15013
15111
|
const exported = exportedNames(program);
|
|
@@ -15031,7 +15129,7 @@ function moduleScope(context, program) {
|
|
|
15031
15129
|
const nearestFunction2 = [...ancestors].reverse().find(isFunction);
|
|
15032
15130
|
const parent = identifier.parent;
|
|
15033
15131
|
const callerDefinition = nearestFunction2 === void 0 ? void 0 : byFunction.get(nearestFunction2);
|
|
15034
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
15132
|
+
if (callerDefinition === void 0 || parent.type !== import_utils73.AST_NODE_TYPES.CallExpression || parent.callee !== identifier) {
|
|
15035
15133
|
pinned.add(definition.name);
|
|
15036
15134
|
continue;
|
|
15037
15135
|
}
|
|
@@ -15046,38 +15144,38 @@ function moduleScope(context, program) {
|
|
|
15046
15144
|
function exportedNames(program) {
|
|
15047
15145
|
const names = /* @__PURE__ */ new Set();
|
|
15048
15146
|
for (const statement of program.body) {
|
|
15049
|
-
if (statement.type !==
|
|
15050
|
-
if (statement.declaration?.type ===
|
|
15147
|
+
if (statement.type !== import_utils73.AST_NODE_TYPES.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
15148
|
+
if (statement.declaration?.type === import_utils73.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) {
|
|
15051
15149
|
names.add(statement.declaration.id.name);
|
|
15052
15150
|
}
|
|
15053
|
-
if (statement.declaration?.type ===
|
|
15151
|
+
if (statement.declaration?.type === import_utils73.AST_NODE_TYPES.VariableDeclaration) {
|
|
15054
15152
|
for (const declarator of statement.declaration.declarations) {
|
|
15055
|
-
if (declarator.id.type ===
|
|
15153
|
+
if (declarator.id.type === import_utils73.AST_NODE_TYPES.Identifier) names.add(declarator.id.name);
|
|
15056
15154
|
}
|
|
15057
15155
|
}
|
|
15058
15156
|
for (const specifier of statement.specifiers) {
|
|
15059
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
15157
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils73.AST_NODE_TYPES.Identifier) {
|
|
15060
15158
|
names.add(specifier.local.name);
|
|
15061
15159
|
}
|
|
15062
15160
|
}
|
|
15063
15161
|
}
|
|
15064
15162
|
for (const statement of program.body) {
|
|
15065
|
-
if (statement.type ===
|
|
15066
|
-
if (statement.type ===
|
|
15163
|
+
if (statement.type === import_utils73.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils73.AST_NODE_TYPES.Identifier) names.add(statement.declaration.name);
|
|
15164
|
+
if (statement.type === import_utils73.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils73.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
15067
15165
|
}
|
|
15068
15166
|
return names;
|
|
15069
15167
|
}
|
|
15070
15168
|
function moduleDefinitions(program) {
|
|
15071
15169
|
const definitions = [];
|
|
15072
15170
|
for (const statement of program.body) {
|
|
15073
|
-
const node = statement.type ===
|
|
15074
|
-
if (node?.type ===
|
|
15171
|
+
const node = statement.type === import_utils73.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils73.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
15172
|
+
if (node?.type === import_utils73.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
15075
15173
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
15076
15174
|
continue;
|
|
15077
15175
|
}
|
|
15078
|
-
if (node?.type !==
|
|
15176
|
+
if (node?.type !== import_utils73.AST_NODE_TYPES.VariableDeclaration || node.kind !== "const") continue;
|
|
15079
15177
|
for (const declarator of node.declarations) {
|
|
15080
|
-
if (declarator.id.type ===
|
|
15178
|
+
if (declarator.id.type === import_utils73.AST_NODE_TYPES.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
15081
15179
|
definitions.push({
|
|
15082
15180
|
name: declarator.id.name,
|
|
15083
15181
|
node: declarator,
|
|
@@ -15090,21 +15188,21 @@ function moduleDefinitions(program) {
|
|
|
15090
15188
|
return definitions;
|
|
15091
15189
|
}
|
|
15092
15190
|
function methodName(node) {
|
|
15093
|
-
if (node.key.type ===
|
|
15094
|
-
return !node.computed && node.key.type ===
|
|
15191
|
+
if (node.key.type === import_utils73.AST_NODE_TYPES.PrivateIdentifier) return `#${node.key.name}`;
|
|
15192
|
+
return !node.computed && node.key.type === import_utils73.AST_NODE_TYPES.Identifier ? node.key.name : null;
|
|
15095
15193
|
}
|
|
15096
15194
|
function referencedMethod(context, node, classVariables) {
|
|
15097
|
-
const objectVariable = node.object.type ===
|
|
15195
|
+
const objectVariable = node.object.type === import_utils73.AST_NODE_TYPES.Identifier ? import_utils73.ASTUtils.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
15098
15196
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
15099
|
-
if (node.object.type !==
|
|
15100
|
-
if (node.property.type ===
|
|
15101
|
-
if (!node.computed && node.property.type ===
|
|
15102
|
-
return node.computed && node.property.type ===
|
|
15197
|
+
if (node.object.type !== import_utils73.AST_NODE_TYPES.ThisExpression && !isClassReference) return null;
|
|
15198
|
+
if (node.property.type === import_utils73.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
15199
|
+
if (!node.computed && node.property.type === import_utils73.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
15200
|
+
return node.computed && node.property.type === import_utils73.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
15103
15201
|
}
|
|
15104
15202
|
function referencedPropertyName(node) {
|
|
15105
|
-
if (node.property.type ===
|
|
15106
|
-
if (!node.computed && node.property.type ===
|
|
15107
|
-
return node.computed && node.property.type ===
|
|
15203
|
+
if (node.property.type === import_utils73.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
15204
|
+
if (!node.computed && node.property.type === import_utils73.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
15205
|
+
return node.computed && node.property.type === import_utils73.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
15108
15206
|
}
|
|
15109
15207
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
15110
15208
|
visit(node, nestedFunction);
|
|
@@ -15120,7 +15218,7 @@ function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
15120
15218
|
}
|
|
15121
15219
|
function classScope(context, node, computedReferenceNames) {
|
|
15122
15220
|
const methods = node.body.body.filter(
|
|
15123
|
-
(member) => member.type ===
|
|
15221
|
+
(member) => member.type === import_utils73.AST_NODE_TYPES.MethodDefinition
|
|
15124
15222
|
);
|
|
15125
15223
|
const counts = /* @__PURE__ */ new Map();
|
|
15126
15224
|
for (const method of methods) {
|
|
@@ -15128,8 +15226,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15128
15226
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
15129
15227
|
}
|
|
15130
15228
|
for (const member of node.body.body) {
|
|
15131
|
-
if (member.type !==
|
|
15132
|
-
const name = !member.computed && member.key.type ===
|
|
15229
|
+
if (member.type !== import_utils73.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
15230
|
+
const name = !member.computed && member.key.type === import_utils73.AST_NODE_TYPES.Identifier ? member.key.name : null;
|
|
15133
15231
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
15134
15232
|
}
|
|
15135
15233
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -15138,7 +15236,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15138
15236
|
});
|
|
15139
15237
|
const definitions = methods.flatMap((method) => {
|
|
15140
15238
|
const name = methodName(method);
|
|
15141
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
15239
|
+
const isPrivate = method.accessibility === "private" || method.key.type === import_utils73.AST_NODE_TYPES.PrivateIdentifier;
|
|
15142
15240
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
15143
15241
|
});
|
|
15144
15242
|
if (definitions.length === 0) return;
|
|
@@ -15147,11 +15245,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15147
15245
|
const pinned = /* @__PURE__ */ new Set();
|
|
15148
15246
|
const classVariables = /* @__PURE__ */ new Set();
|
|
15149
15247
|
if (node.id !== null) {
|
|
15150
|
-
const internal =
|
|
15248
|
+
const internal = import_utils73.ASTUtils.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
15151
15249
|
if (internal !== null) classVariables.add(internal);
|
|
15152
15250
|
}
|
|
15153
|
-
if (node.type ===
|
|
15154
|
-
const outer =
|
|
15251
|
+
if (node.type === import_utils73.AST_NODE_TYPES.ClassExpression && node.parent.type === import_utils73.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils73.AST_NODE_TYPES.Identifier) {
|
|
15252
|
+
const outer = import_utils73.ASTUtils.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
15155
15253
|
if (outer !== null) classVariables.add(outer);
|
|
15156
15254
|
}
|
|
15157
15255
|
for (const method of methods) {
|
|
@@ -15167,27 +15265,27 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15167
15265
|
}
|
|
15168
15266
|
const thisValue = (value) => {
|
|
15169
15267
|
let current = value;
|
|
15170
|
-
while (current?.type ===
|
|
15171
|
-
return current?.type ===
|
|
15268
|
+
while (current?.type === import_utils73.AST_NODE_TYPES.TSAsExpression || current?.type === import_utils73.AST_NODE_TYPES.TSSatisfiesExpression || current?.type === import_utils73.AST_NODE_TYPES.TSNonNullExpression) current = current.expression;
|
|
15269
|
+
return current?.type === import_utils73.AST_NODE_TYPES.ThisExpression;
|
|
15172
15270
|
};
|
|
15173
15271
|
const collectAlias = (current, nestedFunction) => {
|
|
15174
|
-
if (nestedFunction || current.type !==
|
|
15175
|
-
if (current.type ===
|
|
15176
|
-
const binding = current.type ===
|
|
15177
|
-
const value = current.type ===
|
|
15272
|
+
if (nestedFunction || current.type !== import_utils73.AST_NODE_TYPES.VariableDeclarator && current.type !== import_utils73.AST_NODE_TYPES.AssignmentPattern) return;
|
|
15273
|
+
if (current.type === import_utils73.AST_NODE_TYPES.VariableDeclarator && (current.parent.type !== import_utils73.AST_NODE_TYPES.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
15274
|
+
const binding = current.type === import_utils73.AST_NODE_TYPES.VariableDeclarator ? current.id : current.left;
|
|
15275
|
+
const value = current.type === import_utils73.AST_NODE_TYPES.VariableDeclarator ? current.init : current.right;
|
|
15178
15276
|
if (!thisValue(value)) return;
|
|
15179
|
-
if (binding.type ===
|
|
15277
|
+
if (binding.type === import_utils73.AST_NODE_TYPES.ObjectPattern) {
|
|
15180
15278
|
for (const property of binding.properties) {
|
|
15181
|
-
if (property.type ===
|
|
15279
|
+
if (property.type === import_utils73.AST_NODE_TYPES.RestElement) {
|
|
15182
15280
|
for (const name of privateNames) pinned.add(name);
|
|
15183
|
-
} else if (property.key.type ===
|
|
15281
|
+
} else if (property.key.type === import_utils73.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) {
|
|
15184
15282
|
pinned.add(property.key.name);
|
|
15185
15283
|
}
|
|
15186
15284
|
}
|
|
15187
15285
|
return;
|
|
15188
15286
|
}
|
|
15189
|
-
if (binding.type !==
|
|
15190
|
-
const variable =
|
|
15287
|
+
if (binding.type !== import_utils73.AST_NODE_TYPES.Identifier) return;
|
|
15288
|
+
const variable = import_utils73.ASTUtils.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
15191
15289
|
if (variable !== null) {
|
|
15192
15290
|
methodClassVariables.add(variable);
|
|
15193
15291
|
methodAliases.add(variable);
|
|
@@ -15200,16 +15298,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15200
15298
|
walk(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
15201
15299
|
}
|
|
15202
15300
|
const visitCall = (current, nestedFunction) => {
|
|
15203
|
-
if (current.type ===
|
|
15301
|
+
if (current.type === import_utils73.AST_NODE_TYPES.VariableDeclarator && current.id.type === import_utils73.AST_NODE_TYPES.ObjectPattern && thisValue(current.init)) {
|
|
15204
15302
|
for (const property of current.id.properties) {
|
|
15205
|
-
if (property.type ===
|
|
15303
|
+
if (property.type === import_utils73.AST_NODE_TYPES.RestElement) {
|
|
15206
15304
|
for (const name of privateNames) pinned.add(name);
|
|
15207
15305
|
continue;
|
|
15208
15306
|
}
|
|
15209
|
-
if (property.type ===
|
|
15307
|
+
if (property.type === import_utils73.AST_NODE_TYPES.Property && property.key.type === import_utils73.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
15210
15308
|
}
|
|
15211
15309
|
}
|
|
15212
|
-
if (current.type !==
|
|
15310
|
+
if (current.type !== import_utils73.AST_NODE_TYPES.MemberExpression) return;
|
|
15213
15311
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
15214
15312
|
if (target === null) {
|
|
15215
15313
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -15217,12 +15315,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15217
15315
|
return;
|
|
15218
15316
|
}
|
|
15219
15317
|
if (!privateNames.has(target)) return;
|
|
15220
|
-
const objectVariable = current.object.type ===
|
|
15318
|
+
const objectVariable = current.object.type === import_utils73.AST_NODE_TYPES.Identifier ? import_utils73.ASTUtils.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
15221
15319
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
15222
15320
|
pinned.add(target);
|
|
15223
15321
|
return;
|
|
15224
15322
|
}
|
|
15225
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
15323
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== import_utils73.AST_NODE_TYPES.CallExpression || current.parent.callee !== current) {
|
|
15226
15324
|
pinned.add(target);
|
|
15227
15325
|
return;
|
|
15228
15326
|
}
|
|
@@ -15242,9 +15340,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15242
15340
|
}
|
|
15243
15341
|
}
|
|
15244
15342
|
for (const member of node.body.body) {
|
|
15245
|
-
if (member.type ===
|
|
15343
|
+
if (member.type === import_utils73.AST_NODE_TYPES.MethodDefinition || member.type === import_utils73.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
15246
15344
|
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
15247
|
-
if (current.type !==
|
|
15345
|
+
if (current.type !== import_utils73.AST_NODE_TYPES.MemberExpression) return;
|
|
15248
15346
|
const target = referencedMethod(context, current, classVariables);
|
|
15249
15347
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
15250
15348
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -15254,14 +15352,14 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15254
15352
|
const accessibility = new Map(
|
|
15255
15353
|
scopeDefinitions.map((definition) => {
|
|
15256
15354
|
const method = definition.node;
|
|
15257
|
-
const accessibility2 = method.key.type ===
|
|
15355
|
+
const accessibility2 = method.key.type === import_utils73.AST_NODE_TYPES.PrivateIdentifier ? "private" : method.accessibility ?? "public";
|
|
15258
15356
|
return [definition.name, accessibility2];
|
|
15259
15357
|
})
|
|
15260
15358
|
);
|
|
15261
15359
|
const methodByName = new Map(scopeDefinitions.map((definition) => [definition.name, definition.node]));
|
|
15262
15360
|
for (const [caller, callees] of calls) {
|
|
15263
15361
|
const callerMethod = methodByName.get(caller);
|
|
15264
|
-
if (accessibility.get(caller) === "private" && callerMethod?.type ===
|
|
15362
|
+
if (accessibility.get(caller) === "private" && callerMethod?.type === import_utils73.AST_NODE_TYPES.MethodDefinition && callerMethod.decorators.length === 0) continue;
|
|
15265
15363
|
for (const callee of callees) pinned.add(callee);
|
|
15266
15364
|
}
|
|
15267
15365
|
const memberIndexes = new Map(node.body.body.map((member, index) => [member, index]));
|
|
@@ -15278,12 +15376,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15278
15376
|
}
|
|
15279
15377
|
function isClassRuntimeBarrier(member) {
|
|
15280
15378
|
switch (member.type) {
|
|
15281
|
-
case
|
|
15379
|
+
case import_utils73.AST_NODE_TYPES.StaticBlock:
|
|
15282
15380
|
return true;
|
|
15283
|
-
case
|
|
15284
|
-
case
|
|
15381
|
+
case import_utils73.AST_NODE_TYPES.PropertyDefinition:
|
|
15382
|
+
case import_utils73.AST_NODE_TYPES.AccessorProperty:
|
|
15285
15383
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
15286
|
-
case
|
|
15384
|
+
case import_utils73.AST_NODE_TYPES.MethodDefinition:
|
|
15287
15385
|
return member.computed || member.decorators.length > 0;
|
|
15288
15386
|
default:
|
|
15289
15387
|
return false;
|
|
@@ -15315,7 +15413,7 @@ var stepdown_default = createRule({
|
|
|
15315
15413
|
moduleScope(context, program);
|
|
15316
15414
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
15317
15415
|
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
15318
|
-
if (node.type ===
|
|
15416
|
+
if (node.type === import_utils73.AST_NODE_TYPES.MemberExpression && node.computed && node.property.type === import_utils73.AST_NODE_TYPES.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
15319
15417
|
});
|
|
15320
15418
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
15321
15419
|
}
|
|
@@ -15324,7 +15422,7 @@ var stepdown_default = createRule({
|
|
|
15324
15422
|
});
|
|
15325
15423
|
|
|
15326
15424
|
// src/rules/source-coupled-test.ts
|
|
15327
|
-
var
|
|
15425
|
+
var import_utils74 = require("@typescript-eslint/utils");
|
|
15328
15426
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|py|[cm]?[jt]s)$/iu;
|
|
15329
15427
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
15330
15428
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -15393,20 +15491,20 @@ var sourceCoupledTestDocumentation = {
|
|
|
15393
15491
|
]
|
|
15394
15492
|
};
|
|
15395
15493
|
function staticMemberName7(node) {
|
|
15396
|
-
if (!node.computed && node.property.type ===
|
|
15397
|
-
if (node.computed && node.property.type ===
|
|
15494
|
+
if (!node.computed && node.property.type === import_utils74.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
15495
|
+
if (node.computed && node.property.type === import_utils74.AST_NODE_TYPES.Literal && typeof node.property.value === "string") return node.property.value;
|
|
15398
15496
|
return null;
|
|
15399
15497
|
}
|
|
15400
15498
|
function unwrap5(node) {
|
|
15401
|
-
if (node.type ===
|
|
15402
|
-
if (node.type ===
|
|
15403
|
-
if (node.type ===
|
|
15499
|
+
if (node.type === import_utils74.AST_NODE_TYPES.AwaitExpression) return unwrap5(node.argument);
|
|
15500
|
+
if (node.type === import_utils74.AST_NODE_TYPES.ChainExpression) return unwrap5(node.expression);
|
|
15501
|
+
if (node.type === import_utils74.AST_NODE_TYPES.TSAsExpression || node.type === import_utils74.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils74.AST_NODE_TYPES.TSTypeAssertion) return unwrap5(node.expression);
|
|
15404
15502
|
return node;
|
|
15405
15503
|
}
|
|
15406
15504
|
function stringValue(node) {
|
|
15407
15505
|
const current = unwrap5(node);
|
|
15408
|
-
if (current.type ===
|
|
15409
|
-
if (current.type ===
|
|
15506
|
+
if (current.type === import_utils74.AST_NODE_TYPES.Literal && typeof current.value === "string") return current.value;
|
|
15507
|
+
if (current.type === import_utils74.AST_NODE_TYPES.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
15410
15508
|
return null;
|
|
15411
15509
|
}
|
|
15412
15510
|
function importSource(node) {
|
|
@@ -15414,7 +15512,7 @@ function importSource(node) {
|
|
|
15414
15512
|
}
|
|
15415
15513
|
function requireSource(node) {
|
|
15416
15514
|
const current = unwrap5(node);
|
|
15417
|
-
if (current.type !==
|
|
15515
|
+
if (current.type !== import_utils74.AST_NODE_TYPES.CallExpression || current.callee.type !== import_utils74.AST_NODE_TYPES.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === import_utils74.AST_NODE_TYPES.SpreadElement) return null;
|
|
15418
15516
|
return stringValue(current.arguments[0]);
|
|
15419
15517
|
}
|
|
15420
15518
|
function newScope() {
|
|
@@ -15454,38 +15552,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15454
15552
|
const current = unwrap5(node);
|
|
15455
15553
|
const value = stringValue(current);
|
|
15456
15554
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
15457
|
-
if (current.type ===
|
|
15458
|
-
if (current.type ===
|
|
15555
|
+
if (current.type === import_utils74.AST_NODE_TYPES.Identifier) return visible("paths", current.name);
|
|
15556
|
+
if (current.type === import_utils74.AST_NODE_TYPES.BinaryExpression && current.operator === "+") {
|
|
15459
15557
|
return sourcePath(current.left) || sourcePath(current.right);
|
|
15460
15558
|
}
|
|
15461
|
-
if (current.type ===
|
|
15462
|
-
if (current.type ===
|
|
15463
|
-
return current.arguments.some((argument) => argument.type !==
|
|
15559
|
+
if (current.type === import_utils74.AST_NODE_TYPES.TemplateLiteral) return current.expressions.some(sourcePath);
|
|
15560
|
+
if (current.type === import_utils74.AST_NODE_TYPES.CallExpression || current.type === import_utils74.AST_NODE_TYPES.NewExpression) {
|
|
15561
|
+
return current.arguments.some((argument) => argument.type !== import_utils74.AST_NODE_TYPES.SpreadElement && sourcePath(argument));
|
|
15464
15562
|
}
|
|
15465
|
-
if (current.type ===
|
|
15563
|
+
if (current.type === import_utils74.AST_NODE_TYPES.MemberExpression) return sourcePath(current.object);
|
|
15466
15564
|
return false;
|
|
15467
15565
|
};
|
|
15468
15566
|
const rawRead = (node) => {
|
|
15469
15567
|
const current = unwrap5(node);
|
|
15470
|
-
if (current.type !==
|
|
15568
|
+
if (current.type !== import_utils74.AST_NODE_TYPES.CallExpression || current.arguments.length === 0) return false;
|
|
15471
15569
|
const callee = unwrap5(current.callee);
|
|
15472
|
-
if (callee.type ===
|
|
15570
|
+
if (callee.type === import_utils74.AST_NODE_TYPES.Identifier) {
|
|
15473
15571
|
return visible("fsReaders", callee.name) && sourcePath(current.arguments[0]);
|
|
15474
15572
|
}
|
|
15475
|
-
if (callee.type !==
|
|
15573
|
+
if (callee.type !== import_utils74.AST_NODE_TYPES.MemberExpression) return false;
|
|
15476
15574
|
const name2 = staticMemberName7(callee);
|
|
15477
15575
|
const object = unwrap5(callee.object);
|
|
15478
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
15576
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === import_utils74.AST_NODE_TYPES.Identifier && visible("fsObjects", object.name) && sourcePath(current.arguments[0]);
|
|
15479
15577
|
};
|
|
15480
15578
|
const rawOrigins = (node) => {
|
|
15481
15579
|
const current = unwrap5(node);
|
|
15482
|
-
if (current.type ===
|
|
15580
|
+
if (current.type === import_utils74.AST_NODE_TYPES.Identifier) return visibleRawOrigins(current.name);
|
|
15483
15581
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
15484
|
-
if (current.type ===
|
|
15485
|
-
if (current.type ===
|
|
15486
|
-
if (current.type !==
|
|
15582
|
+
if (current.type === import_utils74.AST_NODE_TYPES.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
15583
|
+
if (current.type === import_utils74.AST_NODE_TYPES.MemberExpression && staticMemberName7(current) === "length") return rawOrigins(current.object);
|
|
15584
|
+
if (current.type !== import_utils74.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
15487
15585
|
const callee = unwrap5(current.callee);
|
|
15488
|
-
if (callee.type !==
|
|
15586
|
+
if (callee.type !== import_utils74.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
15489
15587
|
const name2 = staticMemberName7(callee);
|
|
15490
15588
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(callee.object) : /* @__PURE__ */ new Set();
|
|
15491
15589
|
};
|
|
@@ -15493,38 +15591,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15493
15591
|
const current = unwrap5(node);
|
|
15494
15592
|
const direct = rawOrigins(current);
|
|
15495
15593
|
if (direct.size > 0) return direct;
|
|
15496
|
-
if (current.type ===
|
|
15497
|
-
if (current.type ===
|
|
15498
|
-
if (current.type !==
|
|
15594
|
+
if (current.type === import_utils74.AST_NODE_TYPES.BinaryExpression || current.type === import_utils74.AST_NODE_TYPES.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
15595
|
+
if (current.type === import_utils74.AST_NODE_TYPES.UnaryExpression) return evidenceOrigins(current.argument);
|
|
15596
|
+
if (current.type !== import_utils74.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
15499
15597
|
const callee = unwrap5(current.callee);
|
|
15500
|
-
if (callee.type !==
|
|
15598
|
+
if (callee.type !== import_utils74.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
15501
15599
|
const name2 = staticMemberName7(callee);
|
|
15502
15600
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(callee.object);
|
|
15503
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
15601
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === import_utils74.AST_NODE_TYPES.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
15504
15602
|
return /* @__PURE__ */ new Set();
|
|
15505
15603
|
};
|
|
15506
15604
|
const rawAssertionOrigins = (node) => {
|
|
15507
15605
|
const callee = unwrap5(node.callee);
|
|
15508
|
-
if (callee.type ===
|
|
15509
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
15606
|
+
if (callee.type === import_utils74.AST_NODE_TYPES.Identifier && callee.name === "assert") {
|
|
15607
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils74.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
15510
15608
|
}
|
|
15511
|
-
if (callee.type !==
|
|
15609
|
+
if (callee.type !== import_utils74.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
15512
15610
|
const matcher = staticMemberName7(callee);
|
|
15513
15611
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
15514
15612
|
let receiver = unwrap5(callee.object);
|
|
15515
|
-
while (receiver.type ===
|
|
15516
|
-
if (receiver.type ===
|
|
15613
|
+
while (receiver.type === import_utils74.AST_NODE_TYPES.MemberExpression && EXPECT_MODIFIERS2.has(staticMemberName7(receiver) ?? "")) receiver = unwrap5(receiver.object);
|
|
15614
|
+
if (receiver.type === import_utils74.AST_NODE_TYPES.CallExpression && receiver.callee.type === import_utils74.AST_NODE_TYPES.Identifier && receiver.callee.name === "expect") {
|
|
15517
15615
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
15518
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
15616
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === import_utils74.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
15519
15617
|
}
|
|
15520
|
-
if (receiver.type !==
|
|
15521
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
15618
|
+
if (receiver.type !== import_utils74.AST_NODE_TYPES.Identifier || receiver.name !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
15619
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils74.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
15522
15620
|
};
|
|
15523
15621
|
const rawRegexExtractionOrigins = (node) => {
|
|
15524
15622
|
const callee = unwrap5(node.callee);
|
|
15525
|
-
if (callee.type !==
|
|
15623
|
+
if (callee.type !== import_utils74.AST_NODE_TYPES.MemberExpression || staticMemberName7(callee) !== "matchAll" || node.arguments.length !== 1) return /* @__PURE__ */ new Set();
|
|
15526
15624
|
const argument = node.arguments[0];
|
|
15527
|
-
if (argument?.type !==
|
|
15625
|
+
if (argument?.type !== import_utils74.AST_NODE_TYPES.Literal || !(argument.value instanceof RegExp)) return /* @__PURE__ */ new Set();
|
|
15528
15626
|
return rawOrigins(callee.object);
|
|
15529
15627
|
};
|
|
15530
15628
|
const declare = (name2, state) => {
|
|
@@ -15545,15 +15643,15 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15545
15643
|
};
|
|
15546
15644
|
const sourceCollection = (node) => {
|
|
15547
15645
|
const current = unwrap5(node);
|
|
15548
|
-
return current.type ===
|
|
15646
|
+
return current.type === import_utils74.AST_NODE_TYPES.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== import_utils74.AST_NODE_TYPES.SpreadElement && sourcePath(element));
|
|
15549
15647
|
};
|
|
15550
15648
|
const declaredNames2 = (node) => {
|
|
15551
15649
|
const current = unwrap5(node);
|
|
15552
|
-
if (current.type ===
|
|
15553
|
-
if (current.type ===
|
|
15554
|
-
if (current.type ===
|
|
15555
|
-
if (current.type ===
|
|
15556
|
-
if (current.type ===
|
|
15650
|
+
if (current.type === import_utils74.AST_NODE_TYPES.Identifier) return [current.name];
|
|
15651
|
+
if (current.type === import_utils74.AST_NODE_TYPES.AssignmentPattern) return declaredNames2(current.left);
|
|
15652
|
+
if (current.type === import_utils74.AST_NODE_TYPES.RestElement) return declaredNames2(current.argument);
|
|
15653
|
+
if (current.type === import_utils74.AST_NODE_TYPES.ArrayPattern) return current.elements.flatMap((element) => element === null ? [] : declaredNames2(element));
|
|
15654
|
+
if (current.type === import_utils74.AST_NODE_TYPES.ObjectPattern) return current.properties.flatMap((property) => property.type === import_utils74.AST_NODE_TYPES.RestElement ? declaredNames2(property.argument) : declaredNames2(property.value));
|
|
15557
15655
|
return [];
|
|
15558
15656
|
};
|
|
15559
15657
|
const enterFunction = (node) => {
|
|
@@ -15568,8 +15666,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15568
15666
|
const source = importSource(node);
|
|
15569
15667
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
15570
15668
|
for (const specifier of node.specifiers) {
|
|
15571
|
-
if (specifier.type ===
|
|
15572
|
-
const imported = specifier.imported.type ===
|
|
15669
|
+
if (specifier.type === import_utils74.AST_NODE_TYPES.ImportSpecifier) {
|
|
15670
|
+
const imported = specifier.imported.type === import_utils74.AST_NODE_TYPES.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
15573
15671
|
if (FS_READERS.has(imported)) declare(specifier.local.name, { fsReader: true });
|
|
15574
15672
|
} else {
|
|
15575
15673
|
declare(specifier.local.name, { fsObject: true });
|
|
@@ -15581,29 +15679,29 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15581
15679
|
VariableDeclarator(node) {
|
|
15582
15680
|
if (node.init === null) return;
|
|
15583
15681
|
const required = requireSource(node.init);
|
|
15584
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
15682
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === import_utils74.AST_NODE_TYPES.Identifier) {
|
|
15585
15683
|
declare(node.id.name, { fsObject: true });
|
|
15586
15684
|
return;
|
|
15587
15685
|
}
|
|
15588
|
-
if (node.id.type ===
|
|
15686
|
+
if (node.id.type === import_utils74.AST_NODE_TYPES.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
15589
15687
|
for (const property of node.id.properties) {
|
|
15590
|
-
if (property.type !==
|
|
15591
|
-
const key = property.key.type ===
|
|
15688
|
+
if (property.type !== import_utils74.AST_NODE_TYPES.Property || property.value.type !== import_utils74.AST_NODE_TYPES.Identifier) continue;
|
|
15689
|
+
const key = property.key.type === import_utils74.AST_NODE_TYPES.Identifier ? property.key.name : property.key.type === import_utils74.AST_NODE_TYPES.Literal ? String(property.key.value) : "";
|
|
15592
15690
|
if (FS_READERS.has(key)) declare(property.value.name, { fsReader: true });
|
|
15593
15691
|
}
|
|
15594
15692
|
return;
|
|
15595
15693
|
}
|
|
15596
|
-
if (node.id.type !==
|
|
15694
|
+
if (node.id.type !== import_utils74.AST_NODE_TYPES.Identifier) return;
|
|
15597
15695
|
declare(node.id.name, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
15598
15696
|
},
|
|
15599
15697
|
AssignmentExpression(node) {
|
|
15600
|
-
if (node.left.type ===
|
|
15698
|
+
if (node.left.type === import_utils74.AST_NODE_TYPES.Identifier) declare(node.left.name, { path: sourcePath(node.right), rawOrigins: rawOrigins(node.right) });
|
|
15601
15699
|
},
|
|
15602
15700
|
ForOfStatement(node) {
|
|
15603
15701
|
const right = unwrap5(node.right);
|
|
15604
|
-
const collection = right.type ===
|
|
15605
|
-
const left = node.left.type ===
|
|
15606
|
-
if (collection && left?.type ===
|
|
15702
|
+
const collection = right.type === import_utils74.AST_NODE_TYPES.Identifier && visible("collections", right.name);
|
|
15703
|
+
const left = node.left.type === import_utils74.AST_NODE_TYPES.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
15704
|
+
if (collection && left?.type === import_utils74.AST_NODE_TYPES.Identifier) declare(left.name, { path: true });
|
|
15607
15705
|
},
|
|
15608
15706
|
CallExpression(node) {
|
|
15609
15707
|
const origins = /* @__PURE__ */ new Set([
|
|
@@ -15663,7 +15761,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
15663
15761
|
);
|
|
15664
15762
|
|
|
15665
15763
|
// src/rules/zod-naming-convention.ts
|
|
15666
|
-
var
|
|
15764
|
+
var import_utils75 = require("@typescript-eslint/utils");
|
|
15667
15765
|
var zodNamingConventionDocumentation = {
|
|
15668
15766
|
summary: "Enforce a consistent Zod schema naming convention \u2014 a `Z` prefix (`ZUser`) or a `Schema` suffix (`userSchema`); both are accepted by default.",
|
|
15669
15767
|
rationale: "A recognizable schema name distinguishes runtime validators from ordinary values at each use site.",
|
|
@@ -15704,18 +15802,18 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
15704
15802
|
"prettifyError",
|
|
15705
15803
|
"treeifyError"
|
|
15706
15804
|
]);
|
|
15707
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
15805
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils75.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
15708
15806
|
var calleeChainRoot = (node) => {
|
|
15709
15807
|
let current = node;
|
|
15710
15808
|
for (; ; ) {
|
|
15711
|
-
if (current.type ===
|
|
15809
|
+
if (current.type === import_utils75.AST_NODE_TYPES.Identifier) {
|
|
15712
15810
|
return current;
|
|
15713
15811
|
}
|
|
15714
|
-
if (current.type ===
|
|
15812
|
+
if (current.type === import_utils75.AST_NODE_TYPES.MemberExpression) {
|
|
15715
15813
|
current = current.object;
|
|
15716
15814
|
continue;
|
|
15717
15815
|
}
|
|
15718
|
-
if (current.type ===
|
|
15816
|
+
if (current.type === import_utils75.AST_NODE_TYPES.CallExpression) {
|
|
15719
15817
|
current = current.callee;
|
|
15720
15818
|
continue;
|
|
15721
15819
|
}
|
|
@@ -15755,7 +15853,7 @@ var zod_naming_convention_default = createRule({
|
|
|
15755
15853
|
const acceptsSchemaWord = convention !== "prefix";
|
|
15756
15854
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
15757
15855
|
function resolvedBinding(identifier) {
|
|
15758
|
-
return
|
|
15856
|
+
return import_utils75.ASTUtils.findVariable(
|
|
15759
15857
|
context.sourceCode.getScope(identifier),
|
|
15760
15858
|
identifier.name
|
|
15761
15859
|
);
|
|
@@ -15777,7 +15875,7 @@ var zod_naming_convention_default = createRule({
|
|
|
15777
15875
|
ImportDeclaration(node) {
|
|
15778
15876
|
if (!isZodModule(node.source.value)) return;
|
|
15779
15877
|
for (const specifier of node.specifiers) {
|
|
15780
|
-
if (specifier.type ===
|
|
15878
|
+
if (specifier.type === import_utils75.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils75.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils75.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils75.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
15781
15879
|
recordZodBinding(specifier.local);
|
|
15782
15880
|
}
|
|
15783
15881
|
}
|
|
@@ -15785,13 +15883,13 @@ var zod_naming_convention_default = createRule({
|
|
|
15785
15883
|
VariableDeclarator(node) {
|
|
15786
15884
|
const init = node.init;
|
|
15787
15885
|
if (init === null || init === void 0) return;
|
|
15788
|
-
if (init.type !==
|
|
15886
|
+
if (init.type !== import_utils75.AST_NODE_TYPES.CallExpression) return;
|
|
15789
15887
|
const callee = init.callee;
|
|
15790
|
-
if (callee.type !==
|
|
15888
|
+
if (callee.type !== import_utils75.AST_NODE_TYPES.MemberExpression) return;
|
|
15791
15889
|
if (!isZodChain(callee)) return;
|
|
15792
15890
|
const terminal = terminalMethodName(callee);
|
|
15793
15891
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
15794
|
-
if (node.id.type !==
|
|
15892
|
+
if (node.id.type !== import_utils75.AST_NODE_TYPES.Identifier) return;
|
|
15795
15893
|
if (test.test(node.id.name)) return;
|
|
15796
15894
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
15797
15895
|
context.report({
|
|
@@ -15929,6 +16027,7 @@ var rules = {
|
|
|
15929
16027
|
"no-unsafe-mock-casting": no_unsafe_mock_casting_default,
|
|
15930
16028
|
"no-zod-native-enum": no_zod_native_enum_default,
|
|
15931
16029
|
"test-loops-over-literal-cases": test_loops_over_literal_cases_default,
|
|
16030
|
+
"test-phase-label-comment": test_phase_label_comment_default,
|
|
15932
16031
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
15933
16032
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
15934
16033
|
"prefer-input-group-search": prefer_input_group_search_default,
|
|
@@ -15957,7 +16056,7 @@ var rules = {
|
|
|
15957
16056
|
};
|
|
15958
16057
|
var meta = {
|
|
15959
16058
|
name: "@sarj/eslint-plugin",
|
|
15960
|
-
version: "15.
|
|
16059
|
+
version: "15.10.1"
|
|
15961
16060
|
};
|
|
15962
16061
|
var applicationOnlyRules = [
|
|
15963
16062
|
"no-restricted-library-load",
|
|
@@ -15968,7 +16067,8 @@ var advisoryRules = [
|
|
|
15968
16067
|
"no-bare-return-from-test-catch",
|
|
15969
16068
|
"iac-source-coupled-test",
|
|
15970
16069
|
"repeated-static-call-cases",
|
|
15971
|
-
"source-coupled-test"
|
|
16070
|
+
"source-coupled-test",
|
|
16071
|
+
"test-phase-label-comment"
|
|
15972
16072
|
];
|
|
15973
16073
|
var recommendedRules = {
|
|
15974
16074
|
"@sarj/iac-source-coupled-test": "warn",
|
|
@@ -16032,6 +16132,7 @@ var recommendedRules = {
|
|
|
16032
16132
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
16033
16133
|
"@sarj/stepdown": "error",
|
|
16034
16134
|
"@sarj/source-coupled-test": "warn",
|
|
16135
|
+
"@sarj/test-phase-label-comment": "warn",
|
|
16035
16136
|
"@sarj/zod-naming-convention": "error"
|
|
16036
16137
|
};
|
|
16037
16138
|
var strictRules = {
|
|
@@ -16100,6 +16201,7 @@ var strictRules = {
|
|
|
16100
16201
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
16101
16202
|
"@sarj/stepdown": "error",
|
|
16102
16203
|
"@sarj/source-coupled-test": "warn",
|
|
16204
|
+
"@sarj/test-phase-label-comment": "warn",
|
|
16103
16205
|
"@sarj/zod-naming-convention": "error"
|
|
16104
16206
|
};
|
|
16105
16207
|
var plugin = {
|