@sarj/eslint-plugin 15.9.0 → 15.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +815 -721
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +797 -703
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9345,8 +9345,98 @@ function unwrapExpression(node) {
|
|
|
9345
9345
|
return node;
|
|
9346
9346
|
}
|
|
9347
9347
|
|
|
9348
|
-
// src/rules/
|
|
9348
|
+
// src/rules/test-phase-label-comment.ts
|
|
9349
9349
|
import { AST_NODE_TYPES as AST_NODE_TYPES37 } from "@typescript-eslint/utils";
|
|
9350
|
+
var PHASE_WORD = String.raw`arrange|act|assert(?:ion)?s?|given|when|then|exercise|execute|verif(?:y|ication)|cleanup|prepare|sanity(?:\s+check)?`;
|
|
9351
|
+
var PHASE_RE = new RegExp(
|
|
9352
|
+
String.raw`^[-=~*_#.\s]{0,40}(?:${PHASE_WORD})(?:\s*(?:[/&+,|]|->|and)\s*(?:${PHASE_WORD}))*[-=~*_#.\s:;!–—]{0,40}$`,
|
|
9353
|
+
"iu"
|
|
9354
|
+
);
|
|
9355
|
+
var testPhaseLabelCommentDocumentation = {
|
|
9356
|
+
summary: "Tests must not use bare Arrange, Act, Assert, Given, When, or Then phase comments.",
|
|
9357
|
+
rationale: "Phase labels narrate test structure without explaining behavior and often hide unclear names or oversized tests.",
|
|
9358
|
+
remediation: "Delete the label; if the phases remain hard to follow, extract a named helper or split the test.",
|
|
9359
|
+
category: "testing",
|
|
9360
|
+
autofix: "safe",
|
|
9361
|
+
limitations: [
|
|
9362
|
+
"Only standalone line comments in recognized test files are checked.",
|
|
9363
|
+
"Comments inside bracketed expressions or containing words outside the bounded phase grammar are preserved."
|
|
9364
|
+
],
|
|
9365
|
+
examples: [
|
|
9366
|
+
{
|
|
9367
|
+
id: "behavioral-comment",
|
|
9368
|
+
title: "Behavioral consequence is retained",
|
|
9369
|
+
outcome: "no-match",
|
|
9370
|
+
files: [{ path: "widget.test.ts", source: "// Then the retry loop would spin forever.\nexpect(run()).toBe(true);" }],
|
|
9371
|
+
focusPath: "widget.test.ts",
|
|
9372
|
+
expectedCount: 0,
|
|
9373
|
+
public: true
|
|
9374
|
+
},
|
|
9375
|
+
{
|
|
9376
|
+
id: "bare-phase-label",
|
|
9377
|
+
title: "Bare phase label is removed",
|
|
9378
|
+
outcome: "match",
|
|
9379
|
+
files: [{ path: "widget.test.ts", source: "// Arrange\nconst widget = makeWidget();" }],
|
|
9380
|
+
focusPath: "widget.test.ts",
|
|
9381
|
+
expectedCount: 1,
|
|
9382
|
+
fixedFiles: [{ path: "widget.test.ts", source: "const widget = makeWidget();" }],
|
|
9383
|
+
public: true
|
|
9384
|
+
}
|
|
9385
|
+
]
|
|
9386
|
+
};
|
|
9387
|
+
function insideExpression(sourceCode, comment) {
|
|
9388
|
+
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
9389
|
+
if (token === null) return false;
|
|
9390
|
+
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
9391
|
+
while (node != null && node.type !== AST_NODE_TYPES37.Program) {
|
|
9392
|
+
if (node.type === AST_NODE_TYPES37.ArrayExpression || node.type === AST_NODE_TYPES37.ObjectExpression || node.type === AST_NODE_TYPES37.CallExpression || node.type === AST_NODE_TYPES37.NewExpression) return node.loc.start.line < comment.loc.start.line;
|
|
9393
|
+
if (/Statement$/u.test(node.type) || /Declaration$/u.test(node.type)) return false;
|
|
9394
|
+
node = node.parent;
|
|
9395
|
+
}
|
|
9396
|
+
return false;
|
|
9397
|
+
}
|
|
9398
|
+
function continuesProseRun(comments, index) {
|
|
9399
|
+
const comment = comments[index];
|
|
9400
|
+
if (comment?.type !== "Line") return false;
|
|
9401
|
+
return [comments[index - 1], comments[index + 1]].some(
|
|
9402
|
+
(neighbor) => neighbor?.type === "Line" && Math.abs(neighbor.loc.start.line - comment.loc.start.line) === 1 && !PHASE_RE.test(neighbor.value.trim())
|
|
9403
|
+
);
|
|
9404
|
+
}
|
|
9405
|
+
var test_phase_label_comment_default = createRule({
|
|
9406
|
+
name: "test-phase-label-comment",
|
|
9407
|
+
documentation: testPhaseLabelCommentDocumentation,
|
|
9408
|
+
meta: {
|
|
9409
|
+
type: "suggestion",
|
|
9410
|
+
fixable: "code",
|
|
9411
|
+
docs: { description: testPhaseLabelCommentDocumentation.summary },
|
|
9412
|
+
schema: [],
|
|
9413
|
+
messages: { removeLabel: "Bare test phase label \u2014 delete it and let the test names and helpers carry the structure." }
|
|
9414
|
+
},
|
|
9415
|
+
defaultOptions: [],
|
|
9416
|
+
create(context) {
|
|
9417
|
+
if (!isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
9418
|
+
return {
|
|
9419
|
+
Program() {
|
|
9420
|
+
const comments = context.sourceCode.getAllComments();
|
|
9421
|
+
for (const [index, comment] of comments.entries()) {
|
|
9422
|
+
if (comment.type !== "Line" || !PHASE_RE.test(comment.value.trim())) continue;
|
|
9423
|
+
const removal = wholeLineRemovalRange(context.sourceCode.text, comment);
|
|
9424
|
+
if (removal === null || insideExpression(context.sourceCode, comment) || continuesProseRun(comments, index)) {
|
|
9425
|
+
continue;
|
|
9426
|
+
}
|
|
9427
|
+
context.report({
|
|
9428
|
+
node: comment,
|
|
9429
|
+
messageId: "removeLabel",
|
|
9430
|
+
fix: (fixer) => fixer.removeRange(removal.range)
|
|
9431
|
+
});
|
|
9432
|
+
}
|
|
9433
|
+
}
|
|
9434
|
+
};
|
|
9435
|
+
}
|
|
9436
|
+
});
|
|
9437
|
+
|
|
9438
|
+
// src/rules/prefer-constant-time-secret-compare.ts
|
|
9439
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
9350
9440
|
var preferConstantTimeSecretCompareDocumentation = {
|
|
9351
9441
|
summary: "Disallow `===`/`!==` on a secret-like value; short-circuiting comparison leaks the secret through timing. Use a constant-time compare.",
|
|
9352
9442
|
rationale: "Ordinary equality stops at the first differing byte, allowing repeated measurements to reveal secret material.",
|
|
@@ -9365,14 +9455,14 @@ var SENTINEL_PREFIX_RE = /^(skip|sentinel|empty|none|missing|unset|placeholder|d
|
|
|
9365
9455
|
var AST_NODE_TYPE_RE = /^(?:TS|JSX)?[A-Z][A-Za-z]*(?:Signature|Keyword|Expression|Declaration|Element|Literal|Identifier)$/;
|
|
9366
9456
|
function isExcludedOperand(node) {
|
|
9367
9457
|
switch (node.type) {
|
|
9368
|
-
case
|
|
9458
|
+
case AST_NODE_TYPES38.Literal:
|
|
9369
9459
|
return true;
|
|
9370
|
-
case
|
|
9460
|
+
case AST_NODE_TYPES38.TemplateLiteral:
|
|
9371
9461
|
return node.expressions.length === 0;
|
|
9372
|
-
case
|
|
9462
|
+
case AST_NODE_TYPES38.Identifier:
|
|
9373
9463
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
9374
|
-
case
|
|
9375
|
-
return !node.computed && node.property.type ===
|
|
9464
|
+
case AST_NODE_TYPES38.MemberExpression:
|
|
9465
|
+
return !node.computed && node.property.type === AST_NODE_TYPES38.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
9376
9466
|
default:
|
|
9377
9467
|
return false;
|
|
9378
9468
|
}
|
|
@@ -9383,23 +9473,23 @@ function isConstantReference(identifier) {
|
|
|
9383
9473
|
return identifier === identifier.toUpperCase() && /[A-Za-z]/.test(identifier);
|
|
9384
9474
|
}
|
|
9385
9475
|
function operandName(node) {
|
|
9386
|
-
if (node.type ===
|
|
9476
|
+
if (node.type === AST_NODE_TYPES38.Identifier) {
|
|
9387
9477
|
return node.name;
|
|
9388
9478
|
}
|
|
9389
|
-
if (node.type ===
|
|
9479
|
+
if (node.type === AST_NODE_TYPES38.MemberExpression && !node.computed && node.property.type === AST_NODE_TYPES38.Identifier) {
|
|
9390
9480
|
return node.property.name;
|
|
9391
9481
|
}
|
|
9392
9482
|
return null;
|
|
9393
9483
|
}
|
|
9394
9484
|
function isSecretOperand(node) {
|
|
9395
|
-
if (node.type ===
|
|
9485
|
+
if (node.type === AST_NODE_TYPES38.TemplateLiteral) {
|
|
9396
9486
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
9397
9487
|
}
|
|
9398
9488
|
const name = operandName(node);
|
|
9399
9489
|
return name !== null && isAuthSecretName(name);
|
|
9400
9490
|
}
|
|
9401
9491
|
function secretNameOf(node) {
|
|
9402
|
-
if (node.type ===
|
|
9492
|
+
if (node.type === AST_NODE_TYPES38.TemplateLiteral) {
|
|
9403
9493
|
for (const expression of node.expressions) {
|
|
9404
9494
|
const nested = secretNameOf(expression);
|
|
9405
9495
|
if (nested !== null) {
|
|
@@ -9453,7 +9543,7 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
9453
9543
|
|
|
9454
9544
|
// src/rules/prefer-discriminated-union.ts
|
|
9455
9545
|
import "@typescript-eslint/utils";
|
|
9456
|
-
import { AST_NODE_TYPES as
|
|
9546
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39 } from "@typescript-eslint/utils";
|
|
9457
9547
|
var preferDiscriminatedUnionDocumentation = {
|
|
9458
9548
|
summary: "Flag flat result objects with a required positive boolean status and optional success/failure payloads.",
|
|
9459
9549
|
rationale: "A boolean status plus optional branch data permits contradictory and incomplete states.",
|
|
@@ -9485,13 +9575,13 @@ var SUCCESS_PAYLOAD_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
9485
9575
|
]);
|
|
9486
9576
|
var REQUIRED_STATUS_MEMBER_COUNT = 1;
|
|
9487
9577
|
var FUNCTION_RETURN_OWNER_TYPES = /* @__PURE__ */ new Set([
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9578
|
+
AST_NODE_TYPES39.ArrowFunctionExpression,
|
|
9579
|
+
AST_NODE_TYPES39.FunctionDeclaration,
|
|
9580
|
+
AST_NODE_TYPES39.FunctionExpression,
|
|
9581
|
+
AST_NODE_TYPES39.TSDeclareFunction,
|
|
9582
|
+
AST_NODE_TYPES39.TSEmptyBodyFunctionExpression,
|
|
9583
|
+
AST_NODE_TYPES39.TSFunctionType,
|
|
9584
|
+
AST_NODE_TYPES39.TSMethodSignature
|
|
9495
9585
|
]);
|
|
9496
9586
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
9497
9587
|
let statusMemberCount = 0;
|
|
@@ -9499,7 +9589,7 @@ function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
|
9499
9589
|
let hasSuccessPayload = false;
|
|
9500
9590
|
let hasUnrecognizedMember = false;
|
|
9501
9591
|
for (const member of typeLiteral.members) {
|
|
9502
|
-
if (member.type !==
|
|
9592
|
+
if (member.type !== AST_NODE_TYPES39.TSPropertySignature) {
|
|
9503
9593
|
hasUnrecognizedMember = true;
|
|
9504
9594
|
continue;
|
|
9505
9595
|
}
|
|
@@ -9523,26 +9613,26 @@ function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
|
9523
9613
|
return statusMemberCount === REQUIRED_STATUS_MEMBER_COUNT && hasFailurePayload && (hasSuccessPayload || !hasUnrecognizedMember);
|
|
9524
9614
|
}
|
|
9525
9615
|
function getMemberName(member) {
|
|
9526
|
-
if (member.type !==
|
|
9616
|
+
if (member.type !== AST_NODE_TYPES39.TSPropertySignature) {
|
|
9527
9617
|
return null;
|
|
9528
9618
|
}
|
|
9529
9619
|
const { key } = member;
|
|
9530
|
-
if (key.type ===
|
|
9620
|
+
if (key.type === AST_NODE_TYPES39.Identifier) {
|
|
9531
9621
|
return key.name;
|
|
9532
9622
|
}
|
|
9533
|
-
if (key.type ===
|
|
9623
|
+
if (key.type === AST_NODE_TYPES39.Literal && typeof key.value === "string") {
|
|
9534
9624
|
return key.value;
|
|
9535
9625
|
}
|
|
9536
9626
|
return null;
|
|
9537
9627
|
}
|
|
9538
9628
|
function isBooleanTyped(member) {
|
|
9539
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
9629
|
+
return member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES39.TSBooleanKeyword;
|
|
9540
9630
|
}
|
|
9541
9631
|
function inlineReturnTypeLiteral(node) {
|
|
9542
9632
|
let annotation = null;
|
|
9543
|
-
if (node.parent.type ===
|
|
9633
|
+
if (node.parent.type === AST_NODE_TYPES39.TSTypeAnnotation) {
|
|
9544
9634
|
annotation = node.parent;
|
|
9545
|
-
} else if (node.parent.type ===
|
|
9635
|
+
} else if (node.parent.type === AST_NODE_TYPES39.TSTypeParameterInstantiation && node.parent.params.length === 1 && node.parent.params[0] === node && node.parent.parent.type === AST_NODE_TYPES39.TSTypeReference && node.parent.parent.typeName.type === AST_NODE_TYPES39.Identifier && node.parent.parent.typeName.name === "Promise" && node.parent.parent.parent.type === AST_NODE_TYPES39.TSTypeAnnotation) {
|
|
9546
9636
|
annotation = node.parent.parent.parent;
|
|
9547
9637
|
}
|
|
9548
9638
|
if (annotation === null) return null;
|
|
@@ -9582,7 +9672,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
9582
9672
|
}
|
|
9583
9673
|
const synthetic = {
|
|
9584
9674
|
...node.body,
|
|
9585
|
-
type:
|
|
9675
|
+
type: AST_NODE_TYPES39.TSTypeLiteral,
|
|
9586
9676
|
members: node.body.body
|
|
9587
9677
|
};
|
|
9588
9678
|
checkTypeLiteral(synthetic, node);
|
|
@@ -9599,7 +9689,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
9599
9689
|
});
|
|
9600
9690
|
|
|
9601
9691
|
// src/rules/prefer-input-group-search.ts
|
|
9602
|
-
import { AST_NODE_TYPES as
|
|
9692
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40 } from "@typescript-eslint/utils";
|
|
9603
9693
|
var preferInputGroupSearchDocumentation = {
|
|
9604
9694
|
summary: "Require search icons and shared Input controls in the same visual wrapper to use InputGroup.",
|
|
9605
9695
|
rationale: "The shared compound control provides consistent spacing, focus behavior, and accessible composition.",
|
|
@@ -9620,15 +9710,15 @@ var MAX_JSX_DISTANCE = 2;
|
|
|
9620
9710
|
var SEARCH_EXPORTS = ["Search", "SearchIcon", "LucideSearch"];
|
|
9621
9711
|
function localNamedImports(node, importedName4) {
|
|
9622
9712
|
return node.specifiers.filter(
|
|
9623
|
-
(specifier) => specifier.type ===
|
|
9713
|
+
(specifier) => specifier.type === AST_NODE_TYPES40.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES40.Identifier ? specifier.imported.name : specifier.imported.value) === importedName4
|
|
9624
9714
|
).map((specifier) => specifier.local.name);
|
|
9625
9715
|
}
|
|
9626
9716
|
function elementName(node) {
|
|
9627
|
-
return node.name.type ===
|
|
9717
|
+
return node.name.type === AST_NODE_TYPES40.JSXIdentifier ? node.name.name : null;
|
|
9628
9718
|
}
|
|
9629
9719
|
function jsxAncestors(occurrence) {
|
|
9630
9720
|
return occurrence.ancestors.filter(
|
|
9631
|
-
(ancestor) => ancestor.type ===
|
|
9721
|
+
(ancestor) => ancestor.type === AST_NODE_TYPES40.JSXElement
|
|
9632
9722
|
);
|
|
9633
9723
|
}
|
|
9634
9724
|
function isWithinInputGroup(occurrence, inputGroupNames) {
|
|
@@ -9741,7 +9831,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
9741
9831
|
});
|
|
9742
9832
|
|
|
9743
9833
|
// src/rules/prefer-immutable-module-constant.ts
|
|
9744
|
-
import { AST_NODE_TYPES as
|
|
9834
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41, ASTUtils as ASTUtils11 } from "@typescript-eslint/utils";
|
|
9745
9835
|
var preferImmutableModuleConstantDocumentation = {
|
|
9746
9836
|
summary: "Require module-level constant collections to expose readonly state.",
|
|
9747
9837
|
rationale: "A const binding prevents reassignment but does not stop callers from mutating its array, object, Set, or Map contents.",
|
|
@@ -9789,59 +9879,59 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
9789
9879
|
"unshift"
|
|
9790
9880
|
]);
|
|
9791
9881
|
function isAsConst(node, sourceText) {
|
|
9792
|
-
if (node.type ===
|
|
9882
|
+
if (node.type === AST_NODE_TYPES41.TSSatisfiesExpression || node.type === AST_NODE_TYPES41.TSNonNullExpression) {
|
|
9793
9883
|
return isAsConst(node.expression, sourceText);
|
|
9794
9884
|
}
|
|
9795
|
-
if (node.type !==
|
|
9885
|
+
if (node.type !== AST_NODE_TYPES41.TSAsExpression) return false;
|
|
9796
9886
|
return sourceText(node.typeAnnotation).trim() === "const";
|
|
9797
9887
|
}
|
|
9798
9888
|
function unwrapExpression2(node) {
|
|
9799
|
-
if (node.type ===
|
|
9889
|
+
if (node.type === AST_NODE_TYPES41.TSAsExpression || node.type === AST_NODE_TYPES41.TSSatisfiesExpression || node.type === AST_NODE_TYPES41.TSNonNullExpression) {
|
|
9800
9890
|
return unwrapExpression2(node.expression);
|
|
9801
9891
|
}
|
|
9802
9892
|
return node;
|
|
9803
9893
|
}
|
|
9804
9894
|
function isObjectFreeze(node, isUnshadowedGlobal) {
|
|
9805
9895
|
const inner = unwrapExpression2(node);
|
|
9806
|
-
if (inner.type ===
|
|
9896
|
+
if (inner.type === AST_NODE_TYPES41.CallExpression && inner.callee.type === AST_NODE_TYPES41.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES41.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === AST_NODE_TYPES41.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1) {
|
|
9807
9897
|
const argument = inner.arguments[0];
|
|
9808
|
-
return argument !== void 0 && argument.type !==
|
|
9898
|
+
return argument !== void 0 && argument.type !== AST_NODE_TYPES41.SpreadElement && collectionKind(argument, isUnshadowedGlobal) === "literal";
|
|
9809
9899
|
}
|
|
9810
9900
|
return false;
|
|
9811
9901
|
}
|
|
9812
9902
|
function collectionKind(node, isUnshadowedGlobal) {
|
|
9813
9903
|
const inner = unwrapExpression2(node);
|
|
9814
|
-
if (inner.type ===
|
|
9904
|
+
if (inner.type === AST_NODE_TYPES41.CallExpression && inner.callee.type === AST_NODE_TYPES41.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES41.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === AST_NODE_TYPES41.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES41.SpreadElement) {
|
|
9815
9905
|
return collectionKind(inner.arguments[0], isUnshadowedGlobal);
|
|
9816
9906
|
}
|
|
9817
|
-
if (inner.type ===
|
|
9907
|
+
if (inner.type === AST_NODE_TYPES41.ArrayExpression || inner.type === AST_NODE_TYPES41.ObjectExpression) {
|
|
9818
9908
|
return "literal";
|
|
9819
9909
|
}
|
|
9820
|
-
if (inner.type ===
|
|
9910
|
+
if (inner.type === AST_NODE_TYPES41.NewExpression && inner.callee.type === AST_NODE_TYPES41.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map") && isUnshadowedGlobal(inner.callee)) {
|
|
9821
9911
|
return inner.callee.name;
|
|
9822
9912
|
}
|
|
9823
9913
|
return null;
|
|
9824
9914
|
}
|
|
9825
9915
|
function declaredReadonlyType(node, kind, aliases) {
|
|
9826
|
-
const annotation = node.id.type ===
|
|
9916
|
+
const annotation = node.id.type === AST_NODE_TYPES41.Identifier ? node.id.typeAnnotation : void 0;
|
|
9827
9917
|
if (annotation !== void 0 && isReadonlyTypeResolved(annotation.typeAnnotation, kind, aliases)) {
|
|
9828
9918
|
return true;
|
|
9829
9919
|
}
|
|
9830
|
-
return node.init?.type ===
|
|
9920
|
+
return node.init?.type === AST_NODE_TYPES41.TSAsExpression && isReadonlyTypeResolved(node.init.typeAnnotation, kind, aliases);
|
|
9831
9921
|
}
|
|
9832
9922
|
function isReadonlyTypeResolved(node, kind, aliases, seen = /* @__PURE__ */ new Set()) {
|
|
9833
9923
|
if (isReadonlyType(node, kind)) return true;
|
|
9834
|
-
if (node.type !==
|
|
9924
|
+
if (node.type !== AST_NODE_TYPES41.TSTypeReference || node.typeName.type !== AST_NODE_TYPES41.Identifier) return false;
|
|
9835
9925
|
const name = node.typeName.name;
|
|
9836
9926
|
const target = aliases.get(name);
|
|
9837
9927
|
if (target === void 0 || seen.has(name)) return false;
|
|
9838
9928
|
return isReadonlyTypeResolved(target, kind, aliases, /* @__PURE__ */ new Set([...seen, name]));
|
|
9839
9929
|
}
|
|
9840
9930
|
function isReadonlyType(node, kind) {
|
|
9841
|
-
if (node.type ===
|
|
9931
|
+
if (node.type === AST_NODE_TYPES41.TSTypeOperator && node.operator === "readonly") {
|
|
9842
9932
|
return true;
|
|
9843
9933
|
}
|
|
9844
|
-
if (node.type !==
|
|
9934
|
+
if (node.type !== AST_NODE_TYPES41.TSTypeReference || node.typeName.type !== AST_NODE_TYPES41.Identifier) {
|
|
9845
9935
|
return false;
|
|
9846
9936
|
}
|
|
9847
9937
|
if (node.typeName.name === "Readonly") {
|
|
@@ -9850,31 +9940,31 @@ function isReadonlyType(node, kind) {
|
|
|
9850
9940
|
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
9851
9941
|
}
|
|
9852
9942
|
function hasUnknownExplicitType(node, aliases) {
|
|
9853
|
-
const annotation = node.id.type ===
|
|
9943
|
+
const annotation = node.id.type === AST_NODE_TYPES41.Identifier ? node.id.typeAnnotation?.typeAnnotation : void 0;
|
|
9854
9944
|
if (annotation === void 0) return false;
|
|
9855
|
-
if (annotation.type ===
|
|
9856
|
-
if (annotation.type !==
|
|
9945
|
+
if (annotation.type === AST_NODE_TYPES41.TSArrayType || annotation.type === AST_NODE_TYPES41.TSTypeOperator) return false;
|
|
9946
|
+
if (annotation.type !== AST_NODE_TYPES41.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES41.Identifier) return true;
|
|
9857
9947
|
return !aliases.has(annotation.typeName.name) && !["Array", "Map", "Readonly", "ReadonlyArray", "ReadonlyMap", "ReadonlySet", "Set"].includes(annotation.typeName.name);
|
|
9858
9948
|
}
|
|
9859
9949
|
function referenceMutates(identifier, isUnshadowedGlobal) {
|
|
9860
9950
|
let member = identifier.parent;
|
|
9861
|
-
if (member?.type !==
|
|
9862
|
-
return member?.type ===
|
|
9951
|
+
if (member?.type !== AST_NODE_TYPES41.MemberExpression || member.object !== identifier) {
|
|
9952
|
+
return member?.type === AST_NODE_TYPES41.CallExpression && member.arguments[0] === identifier && member.callee.type === AST_NODE_TYPES41.MemberExpression && !member.callee.computed && member.callee.object.type === AST_NODE_TYPES41.Identifier && member.callee.object.name === "Object" && isUnshadowedGlobal(member.callee.object) && member.callee.property.type === AST_NODE_TYPES41.Identifier && member.callee.property.name === "assign";
|
|
9863
9953
|
}
|
|
9864
|
-
while (member.parent.type ===
|
|
9954
|
+
while (member.parent.type === AST_NODE_TYPES41.MemberExpression && member.parent.object === member) {
|
|
9865
9955
|
member = member.parent;
|
|
9866
9956
|
}
|
|
9867
9957
|
const parent = member.parent;
|
|
9868
|
-
if (parent?.type ===
|
|
9958
|
+
if (parent?.type === AST_NODE_TYPES41.AssignmentExpression && parent.left === member) {
|
|
9869
9959
|
return true;
|
|
9870
9960
|
}
|
|
9871
|
-
if (parent?.type ===
|
|
9961
|
+
if (parent?.type === AST_NODE_TYPES41.UpdateExpression && parent.argument === member) {
|
|
9872
9962
|
return true;
|
|
9873
9963
|
}
|
|
9874
|
-
if (parent?.type ===
|
|
9964
|
+
if (parent?.type === AST_NODE_TYPES41.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
9875
9965
|
return true;
|
|
9876
9966
|
}
|
|
9877
|
-
return parent?.type ===
|
|
9967
|
+
return parent?.type === AST_NODE_TYPES41.CallExpression && parent.callee === member && (member.property.type === AST_NODE_TYPES41.Identifier && !member.computed || member.property.type === AST_NODE_TYPES41.Literal && typeof member.property.value === "string") && MUTATING_METHODS.has(member.property.type === AST_NODE_TYPES41.Identifier ? member.property.name : member.property.value);
|
|
9878
9968
|
}
|
|
9879
9969
|
var prefer_immutable_module_constant_default = createRule({
|
|
9880
9970
|
name: "prefer-immutable-module-constant",
|
|
@@ -9911,10 +10001,10 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
9911
10001
|
seen.add(variable);
|
|
9912
10002
|
for (const reference of variable.references) {
|
|
9913
10003
|
const identifier = reference.identifier;
|
|
9914
|
-
if (identifier.type !==
|
|
10004
|
+
if (identifier.type !== AST_NODE_TYPES41.Identifier) continue;
|
|
9915
10005
|
if (referenceMutates(identifier, isUnshadowedGlobal)) return true;
|
|
9916
10006
|
const declarator = identifier.parent;
|
|
9917
|
-
if (declarator.type !==
|
|
10007
|
+
if (declarator.type !== AST_NODE_TYPES41.VariableDeclarator || declarator.init !== identifier || declarator.id.type !== AST_NODE_TYPES41.Identifier || declarator.parent.type !== AST_NODE_TYPES41.VariableDeclaration || declarator.parent.kind !== "const") {
|
|
9918
10008
|
continue;
|
|
9919
10009
|
}
|
|
9920
10010
|
const alias = sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -9926,32 +10016,32 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
9926
10016
|
return {
|
|
9927
10017
|
Program(node) {
|
|
9928
10018
|
for (const statement of node.body) {
|
|
9929
|
-
const declaration = statement.type ===
|
|
9930
|
-
if (declaration?.type ===
|
|
10019
|
+
const declaration = statement.type === AST_NODE_TYPES41.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10020
|
+
if (declaration?.type === AST_NODE_TYPES41.TSTypeAliasDeclaration) {
|
|
9931
10021
|
typeAliases2.set(declaration.id.name, declaration.typeAnnotation);
|
|
9932
10022
|
}
|
|
9933
|
-
if (statement.type ===
|
|
10023
|
+
if (statement.type === AST_NODE_TYPES41.ExportNamedDeclaration) {
|
|
9934
10024
|
if (statement.source !== null || statement.exportKind === "type") continue;
|
|
9935
10025
|
for (const specifier of statement.specifiers) {
|
|
9936
|
-
if (specifier.type ===
|
|
10026
|
+
if (specifier.type === AST_NODE_TYPES41.ExportSpecifier && specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES41.Identifier) {
|
|
9937
10027
|
exportedNames2.add(specifier.local.name);
|
|
9938
10028
|
}
|
|
9939
10029
|
}
|
|
9940
|
-
} else if (statement.type ===
|
|
10030
|
+
} else if (statement.type === AST_NODE_TYPES41.ExportDefaultDeclaration && unwrapTransparentExport(statement.declaration)?.type === AST_NODE_TYPES41.Identifier) {
|
|
9941
10031
|
exportedNames2.add(unwrapTransparentExport(statement.declaration).name);
|
|
9942
10032
|
}
|
|
9943
10033
|
}
|
|
9944
10034
|
},
|
|
9945
10035
|
VariableDeclarator(node) {
|
|
9946
10036
|
const declaration = node.parent;
|
|
9947
|
-
if (declaration.type !==
|
|
10037
|
+
if (declaration.type !== AST_NODE_TYPES41.VariableDeclaration || declaration.kind !== "const" || node.id.type !== AST_NODE_TYPES41.Identifier || node.init === null) {
|
|
9948
10038
|
return;
|
|
9949
10039
|
}
|
|
9950
10040
|
const container = declaration.parent;
|
|
9951
|
-
if (container.type !==
|
|
10041
|
+
if (container.type !== AST_NODE_TYPES41.Program && !(container.type === AST_NODE_TYPES41.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES41.Program)) {
|
|
9952
10042
|
return;
|
|
9953
10043
|
}
|
|
9954
|
-
const directlyExported = container.type ===
|
|
10044
|
+
const directlyExported = container.type === AST_NODE_TYPES41.ExportNamedDeclaration;
|
|
9955
10045
|
if (!CONSTANT_NAME.test(node.id.name) && !directlyExported && !exportedNames2.has(node.id.name)) {
|
|
9956
10046
|
return;
|
|
9957
10047
|
}
|
|
@@ -9976,14 +10066,14 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
9976
10066
|
}
|
|
9977
10067
|
});
|
|
9978
10068
|
function unwrapTransparentExport(node) {
|
|
9979
|
-
if (node.type ===
|
|
10069
|
+
if (node.type === AST_NODE_TYPES41.TSSatisfiesExpression || node.type === AST_NODE_TYPES41.TSNonNullExpression) {
|
|
9980
10070
|
return unwrapTransparentExport(node.expression);
|
|
9981
10071
|
}
|
|
9982
10072
|
return node;
|
|
9983
10073
|
}
|
|
9984
10074
|
|
|
9985
10075
|
// src/rules/prefer-shadcn-primitives.ts
|
|
9986
|
-
import { AST_NODE_TYPES as
|
|
10076
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42 } from "@typescript-eslint/utils";
|
|
9987
10077
|
var preferShadcnPrimitivesDocumentation = {
|
|
9988
10078
|
summary: "Require visible raw JSX controls to use the corresponding shared shadcn primitive.",
|
|
9989
10079
|
rationale: "Shared primitives centralize interaction, accessibility, and visual behavior across the product.",
|
|
@@ -10028,16 +10118,16 @@ var AMBIGUOUS_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
|
10028
10118
|
"submit"
|
|
10029
10119
|
]);
|
|
10030
10120
|
function rawElementName(node) {
|
|
10031
|
-
if (node.name.type !==
|
|
10121
|
+
if (node.name.type !== AST_NODE_TYPES42.JSXIdentifier) return null;
|
|
10032
10122
|
const name = node.name.name;
|
|
10033
10123
|
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
10034
10124
|
}
|
|
10035
10125
|
function effectiveAttribute(node, attributeName) {
|
|
10036
10126
|
for (const attribute of node.attributes.toReversed()) {
|
|
10037
|
-
if (attribute.type ===
|
|
10127
|
+
if (attribute.type === AST_NODE_TYPES42.JSXSpreadAttribute) {
|
|
10038
10128
|
return { kind: "unknown" };
|
|
10039
10129
|
}
|
|
10040
|
-
if (attribute.name.type !==
|
|
10130
|
+
if (attribute.name.type !== AST_NODE_TYPES42.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
10041
10131
|
continue;
|
|
10042
10132
|
}
|
|
10043
10133
|
const value = staticString(attribute.value);
|
|
@@ -10046,17 +10136,17 @@ function effectiveAttribute(node, attributeName) {
|
|
|
10046
10136
|
return { kind: "missing" };
|
|
10047
10137
|
}
|
|
10048
10138
|
function staticString(value) {
|
|
10049
|
-
if (value?.type ===
|
|
10139
|
+
if (value?.type === AST_NODE_TYPES42.Literal) {
|
|
10050
10140
|
return typeof value.value === "string" ? value.value : null;
|
|
10051
10141
|
}
|
|
10052
|
-
if (value?.type !==
|
|
10142
|
+
if (value?.type !== AST_NODE_TYPES42.JSXExpressionContainer) return null;
|
|
10053
10143
|
return staticExpressionString(value.expression);
|
|
10054
10144
|
}
|
|
10055
10145
|
function staticExpressionString(expression) {
|
|
10056
|
-
if (expression.type ===
|
|
10146
|
+
if (expression.type === AST_NODE_TYPES42.Literal) {
|
|
10057
10147
|
return typeof expression.value === "string" ? expression.value : null;
|
|
10058
10148
|
}
|
|
10059
|
-
if (expression.type ===
|
|
10149
|
+
if (expression.type === AST_NODE_TYPES42.TemplateLiteral) {
|
|
10060
10150
|
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
10061
10151
|
for (const [index, substitution] of expression.expressions.entries()) {
|
|
10062
10152
|
const staticSubstitution = staticExpressionString(substitution);
|
|
@@ -10066,13 +10156,13 @@ function staticExpressionString(expression) {
|
|
|
10066
10156
|
}
|
|
10067
10157
|
return value;
|
|
10068
10158
|
}
|
|
10069
|
-
if (expression.type ===
|
|
10159
|
+
if (expression.type === AST_NODE_TYPES42.TSAsExpression || expression.type === AST_NODE_TYPES42.TSNonNullExpression || expression.type === AST_NODE_TYPES42.TSSatisfiesExpression || expression.type === AST_NODE_TYPES42.TSTypeAssertion) {
|
|
10070
10160
|
return staticExpressionString(expression.expression);
|
|
10071
10161
|
}
|
|
10072
10162
|
return null;
|
|
10073
10163
|
}
|
|
10074
10164
|
function isLabelableElement(node) {
|
|
10075
|
-
if (node.openingElement.name.type !==
|
|
10165
|
+
if (node.openingElement.name.type !== AST_NODE_TYPES42.JSXIdentifier) {
|
|
10076
10166
|
return false;
|
|
10077
10167
|
}
|
|
10078
10168
|
const name = node.openingElement.name.name;
|
|
@@ -10084,10 +10174,10 @@ function isLabelableElement(node) {
|
|
|
10084
10174
|
}
|
|
10085
10175
|
function containsLabelableElement(node) {
|
|
10086
10176
|
return node.children.some((child) => {
|
|
10087
|
-
if (child.type ===
|
|
10177
|
+
if (child.type === AST_NODE_TYPES42.JSXElement) {
|
|
10088
10178
|
return isLabelableElement(child) || containsLabelableElement(child);
|
|
10089
10179
|
}
|
|
10090
|
-
if (child.type ===
|
|
10180
|
+
if (child.type === AST_NODE_TYPES42.JSXFragment) {
|
|
10091
10181
|
return containsLabelableElement(child);
|
|
10092
10182
|
}
|
|
10093
10183
|
return false;
|
|
@@ -10096,7 +10186,7 @@ function containsLabelableElement(node) {
|
|
|
10096
10186
|
function isStaticallyAssociatedLabel(node) {
|
|
10097
10187
|
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
10098
10188
|
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
10099
|
-
return node.parent.type ===
|
|
10189
|
+
return node.parent.type === AST_NODE_TYPES42.JSXElement && containsLabelableElement(node.parent);
|
|
10100
10190
|
}
|
|
10101
10191
|
function replacementFor(node, element) {
|
|
10102
10192
|
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
@@ -10167,7 +10257,7 @@ var prefer_shadcn_primitives_default = createRule({
|
|
|
10167
10257
|
});
|
|
10168
10258
|
|
|
10169
10259
|
// src/rules/prefer-module-level-constant.ts
|
|
10170
|
-
import { AST_NODE_TYPES as
|
|
10260
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43 } from "@typescript-eslint/utils";
|
|
10171
10261
|
var preferModuleLevelConstantDocumentation = {
|
|
10172
10262
|
summary: "Hoist literal-only constant collections and regexes out of function bodies to module scope so they are allocated once.",
|
|
10173
10263
|
rationale: "Recreating immutable lookup data on every call wastes allocations and obscures its constant nature.",
|
|
@@ -10207,9 +10297,9 @@ var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
|
10207
10297
|
"assign"
|
|
10208
10298
|
]);
|
|
10209
10299
|
var FUNCTION_TYPES7 = /* @__PURE__ */ new Set([
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10300
|
+
AST_NODE_TYPES43.FunctionDeclaration,
|
|
10301
|
+
AST_NODE_TYPES43.FunctionExpression,
|
|
10302
|
+
AST_NODE_TYPES43.ArrowFunctionExpression
|
|
10213
10303
|
]);
|
|
10214
10304
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
10215
10305
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -10222,14 +10312,14 @@ function isLocalFixtureFile(filename) {
|
|
|
10222
10312
|
return isTestFile(filename) || isStoryFile(filename);
|
|
10223
10313
|
}
|
|
10224
10314
|
function unwrap3(node) {
|
|
10225
|
-
if (node.type ===
|
|
10315
|
+
if (node.type === AST_NODE_TYPES43.TSAsExpression || node.type === AST_NODE_TYPES43.TSSatisfiesExpression || node.type === AST_NODE_TYPES43.TSNonNullExpression) {
|
|
10226
10316
|
return unwrap3(node.expression);
|
|
10227
10317
|
}
|
|
10228
10318
|
return node;
|
|
10229
10319
|
}
|
|
10230
10320
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
10231
10321
|
function isRegexLiteral(node) {
|
|
10232
|
-
return node.type ===
|
|
10322
|
+
return node.type === AST_NODE_TYPES43.Literal && "regex" in node && node.regex !== void 0;
|
|
10233
10323
|
}
|
|
10234
10324
|
function isLiteralOnly(node, depth) {
|
|
10235
10325
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -10237,29 +10327,29 @@ function isLiteralOnly(node, depth) {
|
|
|
10237
10327
|
}
|
|
10238
10328
|
const inner = unwrap3(node);
|
|
10239
10329
|
switch (inner.type) {
|
|
10240
|
-
case
|
|
10330
|
+
case AST_NODE_TYPES43.Literal: {
|
|
10241
10331
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
10242
10332
|
}
|
|
10243
|
-
case
|
|
10333
|
+
case AST_NODE_TYPES43.TemplateLiteral: {
|
|
10244
10334
|
return inner.expressions.length === 0;
|
|
10245
10335
|
}
|
|
10246
|
-
case
|
|
10247
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
10336
|
+
case AST_NODE_TYPES43.UnaryExpression: {
|
|
10337
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES43.Literal && typeof inner.argument.value === "number";
|
|
10248
10338
|
}
|
|
10249
|
-
case
|
|
10339
|
+
case AST_NODE_TYPES43.ArrayExpression: {
|
|
10250
10340
|
return inner.elements.every(
|
|
10251
|
-
(el) => el !== null && el.type !==
|
|
10341
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES43.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
10252
10342
|
);
|
|
10253
10343
|
}
|
|
10254
|
-
case
|
|
10344
|
+
case AST_NODE_TYPES43.ObjectExpression: {
|
|
10255
10345
|
return inner.properties.every((prop) => {
|
|
10256
|
-
if (prop.type !==
|
|
10346
|
+
if (prop.type !== AST_NODE_TYPES43.Property) {
|
|
10257
10347
|
return false;
|
|
10258
10348
|
}
|
|
10259
10349
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
10260
10350
|
return false;
|
|
10261
10351
|
}
|
|
10262
|
-
if (prop.computed && prop.key.type !==
|
|
10352
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES43.Literal) {
|
|
10263
10353
|
return false;
|
|
10264
10354
|
}
|
|
10265
10355
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -10281,19 +10371,19 @@ function classify(init, checkRegex) {
|
|
|
10281
10371
|
}
|
|
10282
10372
|
return { kind: "regex", size: 1 };
|
|
10283
10373
|
}
|
|
10284
|
-
if (node.type ===
|
|
10374
|
+
if (node.type === AST_NODE_TYPES43.ArrayExpression) {
|
|
10285
10375
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
10286
10376
|
}
|
|
10287
|
-
if (node.type ===
|
|
10377
|
+
if (node.type === AST_NODE_TYPES43.ObjectExpression) {
|
|
10288
10378
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
10289
10379
|
}
|
|
10290
|
-
if (node.type ===
|
|
10380
|
+
if (node.type === AST_NODE_TYPES43.NewExpression && node.callee.type === AST_NODE_TYPES43.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
10291
10381
|
const arg = node.arguments[0];
|
|
10292
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
10382
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES43.SpreadElement) {
|
|
10293
10383
|
return null;
|
|
10294
10384
|
}
|
|
10295
10385
|
const entries = unwrap3(arg);
|
|
10296
|
-
if (entries.type !==
|
|
10386
|
+
if (entries.type !== AST_NODE_TYPES43.ArrayExpression) {
|
|
10297
10387
|
return null;
|
|
10298
10388
|
}
|
|
10299
10389
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -10302,7 +10392,7 @@ function classify(init, checkRegex) {
|
|
|
10302
10392
|
}
|
|
10303
10393
|
function unwrapObjectFreeze(node) {
|
|
10304
10394
|
const inner = unwrap3(node);
|
|
10305
|
-
if (inner.type ===
|
|
10395
|
+
if (inner.type === AST_NODE_TYPES43.CallExpression && inner.callee.type === AST_NODE_TYPES43.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES43.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES43.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES43.SpreadElement) {
|
|
10306
10396
|
return unwrap3(inner.arguments[0]);
|
|
10307
10397
|
}
|
|
10308
10398
|
return inner;
|
|
@@ -10329,48 +10419,48 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
10329
10419
|
);
|
|
10330
10420
|
function isSafeRead(identifier) {
|
|
10331
10421
|
const parent = identifier.parent;
|
|
10332
|
-
if (parent.type ===
|
|
10422
|
+
if (parent.type === AST_NODE_TYPES43.MemberExpression) {
|
|
10333
10423
|
if (parent.object !== identifier) {
|
|
10334
10424
|
return true;
|
|
10335
10425
|
}
|
|
10336
10426
|
const grandparent = parent.parent;
|
|
10337
|
-
if (grandparent.type ===
|
|
10427
|
+
if (grandparent.type === AST_NODE_TYPES43.AssignmentExpression && grandparent.left === parent) {
|
|
10338
10428
|
return false;
|
|
10339
10429
|
}
|
|
10340
|
-
if (grandparent.type ===
|
|
10430
|
+
if (grandparent.type === AST_NODE_TYPES43.UpdateExpression) {
|
|
10341
10431
|
return false;
|
|
10342
10432
|
}
|
|
10343
|
-
if (grandparent.type ===
|
|
10433
|
+
if (grandparent.type === AST_NODE_TYPES43.UnaryExpression && grandparent.operator === "delete") {
|
|
10344
10434
|
return false;
|
|
10345
10435
|
}
|
|
10346
|
-
if (!parent.computed && parent.property.type ===
|
|
10436
|
+
if (!parent.computed && parent.property.type === AST_NODE_TYPES43.Identifier && MUTATING_METHODS2.has(parent.property.name) && grandparent.type === AST_NODE_TYPES43.CallExpression && grandparent.callee === parent) {
|
|
10347
10437
|
return false;
|
|
10348
10438
|
}
|
|
10349
10439
|
return true;
|
|
10350
10440
|
}
|
|
10351
|
-
if (parent.type ===
|
|
10441
|
+
if (parent.type === AST_NODE_TYPES43.ForOfStatement && parent.right === identifier) {
|
|
10352
10442
|
return true;
|
|
10353
10443
|
}
|
|
10354
|
-
if (parent.type ===
|
|
10444
|
+
if (parent.type === AST_NODE_TYPES43.SpreadElement) {
|
|
10355
10445
|
return true;
|
|
10356
10446
|
}
|
|
10357
|
-
if (parent.type ===
|
|
10447
|
+
if (parent.type === AST_NODE_TYPES43.BinaryExpression) {
|
|
10358
10448
|
return true;
|
|
10359
10449
|
}
|
|
10360
|
-
if (parent.type ===
|
|
10450
|
+
if (parent.type === AST_NODE_TYPES43.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
10361
10451
|
return true;
|
|
10362
10452
|
}
|
|
10363
|
-
if (parent.type ===
|
|
10453
|
+
if (parent.type === AST_NODE_TYPES43.UnaryExpression && parent.operator !== "delete") {
|
|
10364
10454
|
return true;
|
|
10365
10455
|
}
|
|
10366
10456
|
return false;
|
|
10367
10457
|
}
|
|
10368
10458
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
10369
10459
|
const callee = node.callee;
|
|
10370
|
-
if (callee.type ===
|
|
10460
|
+
if (callee.type === AST_NODE_TYPES43.Identifier && callee.name === "structuredClone") {
|
|
10371
10461
|
return true;
|
|
10372
10462
|
}
|
|
10373
|
-
if (callee.type !==
|
|
10463
|
+
if (callee.type !== AST_NODE_TYPES43.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES43.Identifier || callee.property.type !== AST_NODE_TYPES43.Identifier) {
|
|
10374
10464
|
return false;
|
|
10375
10465
|
}
|
|
10376
10466
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -10433,7 +10523,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
10433
10523
|
if (reference.isWrite()) {
|
|
10434
10524
|
return false;
|
|
10435
10525
|
}
|
|
10436
|
-
if (reference.identifier.type !==
|
|
10526
|
+
if (reference.identifier.type !== AST_NODE_TYPES43.Identifier) {
|
|
10437
10527
|
return false;
|
|
10438
10528
|
}
|
|
10439
10529
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -10445,10 +10535,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
10445
10535
|
return {
|
|
10446
10536
|
VariableDeclarator(node) {
|
|
10447
10537
|
const declaration = node.parent;
|
|
10448
|
-
if (declaration.type !==
|
|
10538
|
+
if (declaration.type !== AST_NODE_TYPES43.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
10449
10539
|
return;
|
|
10450
10540
|
}
|
|
10451
|
-
if (node.id.type !==
|
|
10541
|
+
if (node.id.type !== AST_NODE_TYPES43.Identifier || node.init === null) {
|
|
10452
10542
|
return;
|
|
10453
10543
|
}
|
|
10454
10544
|
if (enclosingFunction2(node) === null) {
|
|
@@ -10475,7 +10565,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
10475
10565
|
});
|
|
10476
10566
|
|
|
10477
10567
|
// src/rules/prefer-module-level-schema.ts
|
|
10478
|
-
import { AST_NODE_TYPES as
|
|
10568
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44 } from "@typescript-eslint/utils";
|
|
10479
10569
|
var preferModuleLevelSchemaDocumentation = {
|
|
10480
10570
|
summary: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function",
|
|
10481
10571
|
rationale: "A closed schema created inside a function is rebuilt on every call and cannot be reused or exported for inference.",
|
|
@@ -10542,9 +10632,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
10542
10632
|
"intl"
|
|
10543
10633
|
]);
|
|
10544
10634
|
var FUNCTION_TYPES8 = /* @__PURE__ */ new Set([
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10635
|
+
AST_NODE_TYPES44.ArrowFunctionExpression,
|
|
10636
|
+
AST_NODE_TYPES44.FunctionDeclaration,
|
|
10637
|
+
AST_NODE_TYPES44.FunctionExpression
|
|
10548
10638
|
]);
|
|
10549
10639
|
function schemaExpression(node) {
|
|
10550
10640
|
let current = node;
|
|
@@ -10553,10 +10643,10 @@ function schemaExpression(node) {
|
|
|
10553
10643
|
if (parent === void 0) {
|
|
10554
10644
|
return current;
|
|
10555
10645
|
}
|
|
10556
|
-
if (parent.type ===
|
|
10646
|
+
if (parent.type === AST_NODE_TYPES44.MemberExpression && parent.object === current && !parent.computed && parent.property.type === AST_NODE_TYPES44.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
10557
10647
|
return current;
|
|
10558
10648
|
}
|
|
10559
|
-
if (parent.type ===
|
|
10649
|
+
if (parent.type === AST_NODE_TYPES44.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES44.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES44.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES44.TSNonNullExpression && parent.expression === current) {
|
|
10560
10650
|
current = parent;
|
|
10561
10651
|
continue;
|
|
10562
10652
|
}
|
|
@@ -10607,22 +10697,22 @@ function subtreeSome(root, predicate) {
|
|
|
10607
10697
|
function readsReceiver(node) {
|
|
10608
10698
|
return subtreeSome(
|
|
10609
10699
|
node,
|
|
10610
|
-
(inner) => inner.type ===
|
|
10700
|
+
(inner) => inner.type === AST_NODE_TYPES44.ThisExpression || inner.type === AST_NODE_TYPES44.Super || inner.type === AST_NODE_TYPES44.Identifier && inner.name === "arguments"
|
|
10611
10701
|
);
|
|
10612
10702
|
}
|
|
10613
10703
|
function buildsLocalizedText(node) {
|
|
10614
10704
|
return subtreeSome(node, (inner) => {
|
|
10615
|
-
if (inner.type ===
|
|
10705
|
+
if (inner.type === AST_NODE_TYPES44.TaggedTemplateExpression) {
|
|
10616
10706
|
return true;
|
|
10617
10707
|
}
|
|
10618
|
-
if (inner.type !==
|
|
10708
|
+
if (inner.type !== AST_NODE_TYPES44.CallExpression) {
|
|
10619
10709
|
return false;
|
|
10620
10710
|
}
|
|
10621
10711
|
const { callee } = inner;
|
|
10622
|
-
if (callee.type ===
|
|
10712
|
+
if (callee.type === AST_NODE_TYPES44.Identifier) {
|
|
10623
10713
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
10624
10714
|
}
|
|
10625
|
-
return callee.type ===
|
|
10715
|
+
return callee.type === AST_NODE_TYPES44.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES44.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
10626
10716
|
});
|
|
10627
10717
|
}
|
|
10628
10718
|
function collectReferences(scope, out) {
|
|
@@ -10686,15 +10776,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10686
10776
|
}
|
|
10687
10777
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
10688
10778
|
function isZodCall(node) {
|
|
10689
|
-
return node.type ===
|
|
10779
|
+
return node.type === AST_NODE_TYPES44.CallExpression && node.callee.type === AST_NODE_TYPES44.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES44.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
10690
10780
|
}
|
|
10691
10781
|
function isCovered(node) {
|
|
10692
10782
|
let current = node.parent ?? void 0;
|
|
10693
10783
|
while (current !== void 0) {
|
|
10694
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
10784
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES44.MemberExpression && current.callee.property.type === AST_NODE_TYPES44.Identifier && factories.has(current.callee.property.name)) {
|
|
10695
10785
|
return true;
|
|
10696
10786
|
}
|
|
10697
|
-
if (current.type ===
|
|
10787
|
+
if (current.type === AST_NODE_TYPES44.CallExpression && (current.callee.type === AST_NODE_TYPES44.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES44.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES44.Identifier && memoCallees.has(current.callee.property.name))) {
|
|
10698
10788
|
return true;
|
|
10699
10789
|
}
|
|
10700
10790
|
current = current.parent ?? void 0;
|
|
@@ -10709,11 +10799,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10709
10799
|
if (parent === void 0) {
|
|
10710
10800
|
return confirmed;
|
|
10711
10801
|
}
|
|
10712
|
-
if (parent.type ===
|
|
10802
|
+
if (parent.type === AST_NODE_TYPES44.Property && parent.value === current || parent.type === AST_NODE_TYPES44.ObjectExpression || parent.type === AST_NODE_TYPES44.ArrayExpression) {
|
|
10713
10803
|
current = parent;
|
|
10714
10804
|
continue;
|
|
10715
10805
|
}
|
|
10716
|
-
if (parent.type ===
|
|
10806
|
+
if (parent.type === AST_NODE_TYPES44.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
10717
10807
|
current = schemaExpression(parent);
|
|
10718
10808
|
confirmed = current;
|
|
10719
10809
|
continue;
|
|
@@ -10723,7 +10813,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10723
10813
|
}
|
|
10724
10814
|
function isSchemaComposition(node) {
|
|
10725
10815
|
const { callee } = node;
|
|
10726
|
-
const isCombinator = callee.type ===
|
|
10816
|
+
const isCombinator = callee.type === AST_NODE_TYPES44.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES44.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
10727
10817
|
return isCombinator || isZodCall(node);
|
|
10728
10818
|
}
|
|
10729
10819
|
function closesOverNothing(node, enclosing) {
|
|
@@ -10743,12 +10833,12 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10743
10833
|
for (const definition of resolved.defs) {
|
|
10744
10834
|
if (definition.type === "ImportBinding") {
|
|
10745
10835
|
const parent = reference.identifier.parent;
|
|
10746
|
-
if (parent?.type ===
|
|
10836
|
+
if (parent?.type === AST_NODE_TYPES44.CallExpression && parent.callee === reference.identifier && !zodNamespaces.has(reference.identifier.name)) {
|
|
10747
10837
|
return false;
|
|
10748
10838
|
}
|
|
10749
10839
|
continue;
|
|
10750
10840
|
}
|
|
10751
|
-
if (definition.node.type ===
|
|
10841
|
+
if (definition.node.type === AST_NODE_TYPES44.VariableDeclarator && definition.node.parent.type === AST_NODE_TYPES44.VariableDeclaration && definition.node.parent.kind !== "const") {
|
|
10752
10842
|
return false;
|
|
10753
10843
|
}
|
|
10754
10844
|
const [defStart, defEnd] = definition.node.range;
|
|
@@ -10764,13 +10854,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10764
10854
|
}
|
|
10765
10855
|
function ownerName(enclosing) {
|
|
10766
10856
|
const parent = enclosing.parent ?? void 0;
|
|
10767
|
-
if (enclosing.type ===
|
|
10857
|
+
if (enclosing.type === AST_NODE_TYPES44.FunctionDeclaration && enclosing.id !== null) {
|
|
10768
10858
|
return enclosing.id.name;
|
|
10769
10859
|
}
|
|
10770
|
-
if (parent !== void 0 && parent.type ===
|
|
10860
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES44.VariableDeclarator && parent.id.type === AST_NODE_TYPES44.Identifier) {
|
|
10771
10861
|
return parent.id.name;
|
|
10772
10862
|
}
|
|
10773
|
-
if (parent !== void 0 && (parent.type ===
|
|
10863
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES44.MethodDefinition || parent.type === AST_NODE_TYPES44.Property) && parent.key.type === AST_NODE_TYPES44.Identifier) {
|
|
10774
10864
|
return parent.key.name;
|
|
10775
10865
|
}
|
|
10776
10866
|
return "this function";
|
|
@@ -10781,7 +10871,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10781
10871
|
return;
|
|
10782
10872
|
}
|
|
10783
10873
|
for (const specifier of node.specifiers) {
|
|
10784
|
-
if (specifier.type ===
|
|
10874
|
+
if (specifier.type === AST_NODE_TYPES44.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES44.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES44.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES44.Identifier && specifier.imported.name === "z") {
|
|
10785
10875
|
zodNamespaces.add(specifier.local.name);
|
|
10786
10876
|
}
|
|
10787
10877
|
}
|
|
@@ -10791,7 +10881,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10791
10881
|
return;
|
|
10792
10882
|
}
|
|
10793
10883
|
const callee = node.callee;
|
|
10794
|
-
if (callee.property.type !==
|
|
10884
|
+
if (callee.property.type !== AST_NODE_TYPES44.Identifier) {
|
|
10795
10885
|
return;
|
|
10796
10886
|
}
|
|
10797
10887
|
const factory = callee.property.name;
|
|
@@ -10806,7 +10896,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10806
10896
|
return;
|
|
10807
10897
|
}
|
|
10808
10898
|
const shape = node.arguments[0];
|
|
10809
|
-
if (shape !== void 0 && shape.type ===
|
|
10899
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES44.ObjectExpression && shape.properties.length < minProperties) {
|
|
10810
10900
|
return;
|
|
10811
10901
|
}
|
|
10812
10902
|
const expression = schemaExpression(node);
|
|
@@ -10834,7 +10924,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10834
10924
|
});
|
|
10835
10925
|
|
|
10836
10926
|
// src/rules/prefer-native-random-uuid.ts
|
|
10837
|
-
import { AST_NODE_TYPES as
|
|
10927
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45, ASTUtils as ASTUtils12 } from "@typescript-eslint/utils";
|
|
10838
10928
|
var preferNativeRandomUuidDocumentation = {
|
|
10839
10929
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
10840
10930
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -10848,7 +10938,7 @@ var preferNativeRandomUuidDocumentation = {
|
|
|
10848
10938
|
]
|
|
10849
10939
|
};
|
|
10850
10940
|
function requireUuid(node) {
|
|
10851
|
-
return node?.type ===
|
|
10941
|
+
return node?.type === AST_NODE_TYPES45.CallExpression && node.callee.type === AST_NODE_TYPES45.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === AST_NODE_TYPES45.Literal && node.arguments[0].value === "uuid";
|
|
10852
10942
|
}
|
|
10853
10943
|
var prefer_native_random_uuid_default = createRule({
|
|
10854
10944
|
name: "prefer-native-random-uuid",
|
|
@@ -10892,37 +10982,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
10892
10982
|
ImportDeclaration(node) {
|
|
10893
10983
|
if (node.source.value !== "uuid") return;
|
|
10894
10984
|
for (const specifier of node.specifiers) {
|
|
10895
|
-
if (specifier.type ===
|
|
10985
|
+
if (specifier.type === AST_NODE_TYPES45.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES45.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
10896
10986
|
record(specifier.local, directBindings);
|
|
10897
|
-
} else if (specifier.type ===
|
|
10987
|
+
} else if (specifier.type === AST_NODE_TYPES45.ImportNamespaceSpecifier) {
|
|
10898
10988
|
record(specifier.local, namespaceBindings);
|
|
10899
10989
|
}
|
|
10900
10990
|
}
|
|
10901
10991
|
},
|
|
10902
10992
|
VariableDeclarator(node) {
|
|
10903
10993
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
10904
|
-
if (node.init?.type !==
|
|
10994
|
+
if (node.init?.type !== AST_NODE_TYPES45.CallExpression || node.init.callee.type !== AST_NODE_TYPES45.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
10905
10995
|
return;
|
|
10906
10996
|
}
|
|
10907
|
-
if (node.id.type ===
|
|
10997
|
+
if (node.id.type === AST_NODE_TYPES45.Identifier) {
|
|
10908
10998
|
record(node.id, namespaceBindings);
|
|
10909
10999
|
return;
|
|
10910
11000
|
}
|
|
10911
|
-
if (node.id.type !==
|
|
11001
|
+
if (node.id.type !== AST_NODE_TYPES45.ObjectPattern) return;
|
|
10912
11002
|
for (const property of node.id.properties) {
|
|
10913
|
-
if (property.type ===
|
|
11003
|
+
if (property.type === AST_NODE_TYPES45.Property && !property.computed && (property.key.type === AST_NODE_TYPES45.Identifier && property.key.name === "v4" || property.key.type === AST_NODE_TYPES45.Literal && property.key.value === "v4") && property.value.type === AST_NODE_TYPES45.Identifier) {
|
|
10914
11004
|
record(property.value, directBindings);
|
|
10915
11005
|
}
|
|
10916
11006
|
}
|
|
10917
11007
|
},
|
|
10918
11008
|
"CallExpression:exit"(node) {
|
|
10919
11009
|
if (node.arguments.length !== 0) return;
|
|
10920
|
-
if (node.callee.type ===
|
|
11010
|
+
if (node.callee.type === AST_NODE_TYPES45.Identifier) {
|
|
10921
11011
|
const variable2 = resolve(node.callee);
|
|
10922
11012
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
10923
11013
|
return;
|
|
10924
11014
|
}
|
|
10925
|
-
if (node.callee.type !==
|
|
11015
|
+
if (node.callee.type !== AST_NODE_TYPES45.MemberExpression || node.callee.computed || node.callee.object.type !== AST_NODE_TYPES45.Identifier || node.callee.property.type !== AST_NODE_TYPES45.Identifier || node.callee.property.name !== "v4") {
|
|
10926
11016
|
return;
|
|
10927
11017
|
}
|
|
10928
11018
|
const variable = resolve(node.callee.object);
|
|
@@ -10933,7 +11023,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
10933
11023
|
});
|
|
10934
11024
|
|
|
10935
11025
|
// src/rules/prefer-non-nullable-collection.ts
|
|
10936
|
-
import { AST_NODE_TYPES as
|
|
11026
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46, ASTUtils as ASTUtils13 } from "@typescript-eslint/utils";
|
|
10937
11027
|
var preferNonNullableCollectionDocumentation = {
|
|
10938
11028
|
summary: "Suggest non-null arrays only when local control flow proves the nullish state is equivalent to an empty collection.",
|
|
10939
11029
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
@@ -10949,33 +11039,33 @@ var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
|
10949
11039
|
function propertyName(node) {
|
|
10950
11040
|
const key = node.key;
|
|
10951
11041
|
if (node.computed) return null;
|
|
10952
|
-
if (key.type ===
|
|
10953
|
-
if (key.type ===
|
|
11042
|
+
if (key.type === AST_NODE_TYPES46.Identifier) return key.name;
|
|
11043
|
+
if (key.type === AST_NODE_TYPES46.Literal && typeof key.value === "string") return key.value;
|
|
10954
11044
|
return null;
|
|
10955
11045
|
}
|
|
10956
11046
|
function isArrayType(node) {
|
|
10957
|
-
if (node.type ===
|
|
10958
|
-
return node.type ===
|
|
11047
|
+
if (node.type === AST_NODE_TYPES46.TSArrayType) return true;
|
|
11048
|
+
return node.type === AST_NODE_TYPES46.TSTypeReference && node.typeName.type === AST_NODE_TYPES46.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
10959
11049
|
}
|
|
10960
11050
|
function nullableProperty(node) {
|
|
10961
11051
|
if (node.optional) return null;
|
|
10962
11052
|
const name = propertyName(node);
|
|
10963
11053
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
10964
|
-
if (name === null || annotation?.type !==
|
|
11054
|
+
if (name === null || annotation?.type !== AST_NODE_TYPES46.TSUnionType) return null;
|
|
10965
11055
|
const concrete = annotation.types.filter(
|
|
10966
|
-
(member) => member.type !==
|
|
11056
|
+
(member) => member.type !== AST_NODE_TYPES46.TSNullKeyword && member.type !== AST_NODE_TYPES46.TSUndefinedKeyword
|
|
10967
11057
|
);
|
|
10968
11058
|
if (concrete.length === 0 || !concrete.every(isArrayType)) return null;
|
|
10969
|
-
const acceptsNull = annotation.types.some((member) => member.type ===
|
|
11059
|
+
const acceptsNull = annotation.types.some((member) => member.type === AST_NODE_TYPES46.TSNullKeyword);
|
|
10970
11060
|
const acceptsUndefined = annotation.types.some(
|
|
10971
|
-
(member) => member.type ===
|
|
11061
|
+
(member) => member.type === AST_NODE_TYPES46.TSUndefinedKeyword
|
|
10972
11062
|
);
|
|
10973
11063
|
if (!acceptsNull && !acceptsUndefined) return null;
|
|
10974
11064
|
return { name, node, acceptsNull, acceptsUndefined };
|
|
10975
11065
|
}
|
|
10976
11066
|
function shapeProperties(members) {
|
|
10977
11067
|
return members.flatMap((member) => {
|
|
10978
|
-
if (member.type !==
|
|
11068
|
+
if (member.type !== AST_NODE_TYPES46.TSPropertySignature) return [];
|
|
10979
11069
|
const property = nullableProperty(member);
|
|
10980
11070
|
return property === null ? [] : [property];
|
|
10981
11071
|
});
|
|
@@ -10983,14 +11073,14 @@ function shapeProperties(members) {
|
|
|
10983
11073
|
function typeIndex(program) {
|
|
10984
11074
|
const index = /* @__PURE__ */ new Map();
|
|
10985
11075
|
for (const statement of program.body) {
|
|
10986
|
-
const exported = statement.type ===
|
|
11076
|
+
const exported = statement.type === AST_NODE_TYPES46.ExportNamedDeclaration;
|
|
10987
11077
|
const declaration = exported ? statement.declaration : statement;
|
|
10988
|
-
if (declaration?.type ===
|
|
11078
|
+
if (declaration?.type === AST_NODE_TYPES46.TSInterfaceDeclaration) {
|
|
10989
11079
|
index.set(declaration.id.name, {
|
|
10990
11080
|
exported,
|
|
10991
11081
|
properties: shapeProperties(declaration.body.body)
|
|
10992
11082
|
});
|
|
10993
|
-
} else if (declaration?.type ===
|
|
11083
|
+
} else if (declaration?.type === AST_NODE_TYPES46.TSTypeAliasDeclaration && declaration.typeAnnotation.type === AST_NODE_TYPES46.TSTypeLiteral) {
|
|
10994
11084
|
index.set(declaration.id.name, {
|
|
10995
11085
|
exported,
|
|
10996
11086
|
properties: shapeProperties(declaration.typeAnnotation.members)
|
|
@@ -11000,42 +11090,42 @@ function typeIndex(program) {
|
|
|
11000
11090
|
return index;
|
|
11001
11091
|
}
|
|
11002
11092
|
function emptyArray(node) {
|
|
11003
|
-
return node.type ===
|
|
11093
|
+
return node.type === AST_NODE_TYPES46.ArrayExpression && node.elements.length === 0;
|
|
11004
11094
|
}
|
|
11005
11095
|
function sameAccess(node, access) {
|
|
11006
11096
|
if (access.kind === "identifier") {
|
|
11007
|
-
return node.type ===
|
|
11097
|
+
return node.type === AST_NODE_TYPES46.Identifier && node.name === access.name;
|
|
11008
11098
|
}
|
|
11009
|
-
return node.type ===
|
|
11099
|
+
return node.type === AST_NODE_TYPES46.MemberExpression && !node.computed && node.object.type === AST_NODE_TYPES46.Identifier && node.object.name === access.object && node.property.type === AST_NODE_TYPES46.Identifier && node.property.name === access.property;
|
|
11010
11100
|
}
|
|
11011
11101
|
function isNullGuard(node, access) {
|
|
11012
|
-
if (node.type ===
|
|
11013
|
-
if (node.type !==
|
|
11102
|
+
if (node.type === AST_NODE_TYPES46.UnaryExpression && node.operator === "!" && (sameAccess(node.argument, access) || optionalMemberLengthOf(node.argument, access))) return true;
|
|
11103
|
+
if (node.type !== AST_NODE_TYPES46.BinaryExpression || !["==", "==="].includes(node.operator)) {
|
|
11014
11104
|
return false;
|
|
11015
11105
|
}
|
|
11016
|
-
const nullish = (value) => value.type ===
|
|
11106
|
+
const nullish = (value) => value.type === AST_NODE_TYPES46.Literal && value.value === null || value.type === AST_NODE_TYPES46.Identifier && value.name === "undefined";
|
|
11017
11107
|
return sameAccess(node.left, access) && nullish(node.right) || sameAccess(node.right, access) && nullish(node.left);
|
|
11018
11108
|
}
|
|
11019
11109
|
function isEmptyGuard(node, access) {
|
|
11020
|
-
if (node.type ===
|
|
11021
|
-
if (node.type !==
|
|
11110
|
+
if (node.type === AST_NODE_TYPES46.UnaryExpression && node.operator === "!" && memberLengthOf(node.argument, access)) return true;
|
|
11111
|
+
if (node.type !== AST_NODE_TYPES46.BinaryExpression || !["==", "===", "<="].includes(node.operator)) {
|
|
11022
11112
|
return false;
|
|
11023
11113
|
}
|
|
11024
|
-
const zero = (value) => value.type ===
|
|
11114
|
+
const zero = (value) => value.type === AST_NODE_TYPES46.Literal && value.value === 0;
|
|
11025
11115
|
return memberLengthOf(node.left, access) && zero(node.right) || memberLengthOf(node.right, access) && zero(node.left);
|
|
11026
11116
|
}
|
|
11027
11117
|
function memberLengthOf(node, access) {
|
|
11028
|
-
const target = node.type ===
|
|
11029
|
-
return target.type ===
|
|
11118
|
+
const target = node.type === AST_NODE_TYPES46.ChainExpression ? node.expression : node;
|
|
11119
|
+
return target.type === AST_NODE_TYPES46.MemberExpression && !target.computed && target.property.type === AST_NODE_TYPES46.Identifier && target.property.name === "length" && sameAccess(target.object, access);
|
|
11030
11120
|
}
|
|
11031
11121
|
function optionalMemberLengthOf(node, access) {
|
|
11032
|
-
return node.type ===
|
|
11122
|
+
return node.type === AST_NODE_TYPES46.ChainExpression && node.expression.type === AST_NODE_TYPES46.MemberExpression && node.expression.optional && memberLengthOf(node, access);
|
|
11033
11123
|
}
|
|
11034
11124
|
function hasEquivalentLeadingGuard(fn, access, visitorKeys) {
|
|
11035
|
-
if (fn.body.type !==
|
|
11125
|
+
if (fn.body.type !== AST_NODE_TYPES46.BlockStatement) return false;
|
|
11036
11126
|
const first = fn.body.body[0];
|
|
11037
|
-
if (first?.type !==
|
|
11038
|
-
const terminating = first.consequent.type ===
|
|
11127
|
+
if (first?.type !== AST_NODE_TYPES46.IfStatement) return false;
|
|
11128
|
+
const terminating = first.consequent.type === AST_NODE_TYPES46.ReturnStatement || first.consequent.type === AST_NODE_TYPES46.ThrowStatement || first.consequent.type === AST_NODE_TYPES46.BlockStatement && first.consequent.body.length === 1 && (first.consequent.body[0]?.type === AST_NODE_TYPES46.ReturnStatement || first.consequent.body[0]?.type === AST_NODE_TYPES46.ThrowStatement);
|
|
11039
11129
|
if (!terminating) return false;
|
|
11040
11130
|
if (contains(first.consequent, visitorKeys, (node) => sameAccess(node, access))) return false;
|
|
11041
11131
|
return contains(first.test, visitorKeys, (node) => isNullGuard(node, access)) && contains(first.test, visitorKeys, (node) => isEmptyGuard(node, access));
|
|
@@ -11053,14 +11143,14 @@ function contains(node, visitorKeys, predicate) {
|
|
|
11053
11143
|
function belongsToFunction(node, fn) {
|
|
11054
11144
|
let current = node;
|
|
11055
11145
|
while (current !== void 0 && current !== fn) {
|
|
11056
|
-
if (current !== node && (current.type ===
|
|
11146
|
+
if (current !== node && (current.type === AST_NODE_TYPES46.ArrowFunctionExpression || current.type === AST_NODE_TYPES46.FunctionDeclaration || current.type === AST_NODE_TYPES46.FunctionExpression)) return false;
|
|
11057
11147
|
current = current.parent;
|
|
11058
11148
|
}
|
|
11059
11149
|
return current === fn;
|
|
11060
11150
|
}
|
|
11061
11151
|
function directlyCoalesced(node) {
|
|
11062
11152
|
const parent = node.parent;
|
|
11063
|
-
return parent?.type ===
|
|
11153
|
+
return parent?.type === AST_NODE_TYPES46.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
11064
11154
|
}
|
|
11065
11155
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
11066
11156
|
const variable = ASTUtils13.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
@@ -11075,7 +11165,7 @@ function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
|
11075
11165
|
const accesses = variable.references.flatMap((reference) => {
|
|
11076
11166
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
11077
11167
|
const parent = reference.identifier.parent;
|
|
11078
|
-
if (parent?.type ===
|
|
11168
|
+
if (parent?.type === AST_NODE_TYPES46.MemberExpression && !parent.computed && parent.object === reference.identifier && parent.property.type === AST_NODE_TYPES46.Identifier && parent.property.name === property) return [parent];
|
|
11079
11169
|
return [];
|
|
11080
11170
|
});
|
|
11081
11171
|
return accesses.length > 0 && accesses.every((access) => access !== null && directlyCoalesced(access));
|
|
@@ -11101,8 +11191,8 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
11101
11191
|
let shapes = /* @__PURE__ */ new Map();
|
|
11102
11192
|
const evidence = /* @__PURE__ */ new Map();
|
|
11103
11193
|
function propertiesFor(annotation) {
|
|
11104
|
-
if (annotation?.type ===
|
|
11105
|
-
if (annotation?.type ===
|
|
11194
|
+
if (annotation?.type === AST_NODE_TYPES46.TSTypeLiteral) return shapeProperties(annotation.members);
|
|
11195
|
+
if (annotation?.type === AST_NODE_TYPES46.TSTypeReference && annotation.typeName.type === AST_NODE_TYPES46.Identifier) {
|
|
11106
11196
|
const shape = shapes.get(annotation.typeName.name);
|
|
11107
11197
|
return shape?.exported === false ? shape.properties : [];
|
|
11108
11198
|
}
|
|
@@ -11115,21 +11205,21 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
11115
11205
|
}
|
|
11116
11206
|
function checkFunction(fn) {
|
|
11117
11207
|
for (const rawParameter of fn.params) {
|
|
11118
|
-
const parameter = rawParameter.type ===
|
|
11119
|
-
if (parameter.type ===
|
|
11208
|
+
const parameter = rawParameter.type === AST_NODE_TYPES46.AssignmentPattern ? rawParameter.left : rawParameter;
|
|
11209
|
+
if (parameter.type === AST_NODE_TYPES46.ObjectPattern) {
|
|
11120
11210
|
const properties2 = propertiesFor(parameter.typeAnnotation?.typeAnnotation);
|
|
11121
11211
|
for (const property of properties2) {
|
|
11122
11212
|
const bindingProperty = parameter.properties.find(
|
|
11123
|
-
(entry) => entry.type ===
|
|
11213
|
+
(entry) => entry.type === AST_NODE_TYPES46.Property && !entry.computed && entry.key.type === AST_NODE_TYPES46.Identifier && entry.key.name === property.name
|
|
11124
11214
|
);
|
|
11125
11215
|
if (bindingProperty === void 0) continue;
|
|
11126
11216
|
const value = bindingProperty.value;
|
|
11127
|
-
const binding = value.type ===
|
|
11128
|
-
if (binding.type !==
|
|
11217
|
+
const binding = value.type === AST_NODE_TYPES46.AssignmentPattern ? value.left : value;
|
|
11218
|
+
if (binding.type !== AST_NODE_TYPES46.Identifier) {
|
|
11129
11219
|
record(property, false);
|
|
11130
11220
|
continue;
|
|
11131
11221
|
}
|
|
11132
|
-
if (value.type ===
|
|
11222
|
+
if (value.type === AST_NODE_TYPES46.AssignmentPattern && emptyArray(value.right) && property.acceptsUndefined && !property.acceptsNull) {
|
|
11133
11223
|
record(property, true);
|
|
11134
11224
|
continue;
|
|
11135
11225
|
}
|
|
@@ -11141,7 +11231,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
11141
11231
|
}
|
|
11142
11232
|
continue;
|
|
11143
11233
|
}
|
|
11144
|
-
if (parameter.type !==
|
|
11234
|
+
if (parameter.type !== AST_NODE_TYPES46.Identifier) continue;
|
|
11145
11235
|
const properties = propertiesFor(parameter.typeAnnotation?.typeAnnotation);
|
|
11146
11236
|
for (const property of properties) {
|
|
11147
11237
|
const access = {
|
|
@@ -11181,7 +11271,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
11181
11271
|
import {
|
|
11182
11272
|
ASTUtils as ASTUtils14,
|
|
11183
11273
|
ESLintUtils as ESLintUtils3,
|
|
11184
|
-
AST_NODE_TYPES as
|
|
11274
|
+
AST_NODE_TYPES as AST_NODE_TYPES47
|
|
11185
11275
|
} from "@typescript-eslint/utils";
|
|
11186
11276
|
import * as ts2 from "typescript";
|
|
11187
11277
|
var preferAwaitInAsyncReturnDocumentation = {
|
|
@@ -11224,10 +11314,10 @@ var preferAwaitInAsyncReturnDocumentation = {
|
|
|
11224
11314
|
};
|
|
11225
11315
|
function directAsyncReturnOwner(node) {
|
|
11226
11316
|
const parent = node.parent;
|
|
11227
|
-
if (parent.type ===
|
|
11317
|
+
if (parent.type === AST_NODE_TYPES47.ArrowFunctionExpression && parent.body === node) {
|
|
11228
11318
|
return parent.async && !parent.generator ? parent : null;
|
|
11229
11319
|
}
|
|
11230
|
-
if (parent.type !==
|
|
11320
|
+
if (parent.type !== AST_NODE_TYPES47.ReturnStatement || parent.argument !== node) {
|
|
11231
11321
|
return null;
|
|
11232
11322
|
}
|
|
11233
11323
|
let owner = parent.parent;
|
|
@@ -11237,15 +11327,15 @@ function directAsyncReturnOwner(node) {
|
|
|
11237
11327
|
return owner !== void 0 && owner.async && !owner.generator ? owner : null;
|
|
11238
11328
|
}
|
|
11239
11329
|
function isRuntimeFunction(node) {
|
|
11240
|
-
return node.type ===
|
|
11330
|
+
return node.type === AST_NODE_TYPES47.ArrowFunctionExpression || node.type === AST_NODE_TYPES47.FunctionDeclaration || node.type === AST_NODE_TYPES47.FunctionExpression;
|
|
11241
11331
|
}
|
|
11242
11332
|
function promiseThenReceiver(node) {
|
|
11243
11333
|
const callee = node.callee;
|
|
11244
|
-
if (callee.type !==
|
|
11334
|
+
if (callee.type !== AST_NODE_TYPES47.MemberExpression || callee.computed || callee.optional || callee.property.type !== AST_NODE_TYPES47.Identifier || callee.property.name !== "then" || node.optional || node.arguments.length !== 1) {
|
|
11245
11335
|
return null;
|
|
11246
11336
|
}
|
|
11247
11337
|
const callback = node.arguments[0];
|
|
11248
|
-
if (callback === void 0 || callback.type !==
|
|
11338
|
+
if (callback === void 0 || callback.type !== AST_NODE_TYPES47.ArrowFunctionExpression && callback.type !== AST_NODE_TYPES47.FunctionExpression) {
|
|
11249
11339
|
return null;
|
|
11250
11340
|
}
|
|
11251
11341
|
return callee.object;
|
|
@@ -11298,7 +11388,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
11298
11388
|
};
|
|
11299
11389
|
const isFrameworkLoaderCallback = (owner) => {
|
|
11300
11390
|
const parent = owner.parent;
|
|
11301
|
-
if (parent.type !==
|
|
11391
|
+
if (parent.type !== AST_NODE_TYPES47.CallExpression || parent.arguments[0] !== owner || parent.callee.type !== AST_NODE_TYPES47.Identifier) return false;
|
|
11302
11392
|
const variable = ASTUtils14.findVariable(context.sourceCode.getScope(parent.callee), parent.callee.name);
|
|
11303
11393
|
return variable !== null && frameworkLoaders.has(variable);
|
|
11304
11394
|
};
|
|
@@ -11306,12 +11396,12 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
11306
11396
|
ImportDeclaration(node) {
|
|
11307
11397
|
if (node.source.value === "react") {
|
|
11308
11398
|
for (const specifier of node.specifiers) {
|
|
11309
|
-
if (specifier.type ===
|
|
11399
|
+
if (specifier.type === AST_NODE_TYPES47.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES47.Identifier ? specifier.imported.name : specifier.imported.value) === "lazy") rememberFrameworkLoader(specifier.local);
|
|
11310
11400
|
}
|
|
11311
11401
|
}
|
|
11312
11402
|
if (node.source.value === "next/dynamic") {
|
|
11313
11403
|
for (const specifier of node.specifiers) {
|
|
11314
|
-
if (specifier.type ===
|
|
11404
|
+
if (specifier.type === AST_NODE_TYPES47.ImportDefaultSpecifier) rememberFrameworkLoader(specifier.local);
|
|
11315
11405
|
}
|
|
11316
11406
|
}
|
|
11317
11407
|
},
|
|
@@ -11329,7 +11419,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
11329
11419
|
});
|
|
11330
11420
|
|
|
11331
11421
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
11332
|
-
import { AST_NODE_TYPES as
|
|
11422
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48 } from "@typescript-eslint/utils";
|
|
11333
11423
|
var preferSchemaForApiPayloadDocumentation = {
|
|
11334
11424
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
11335
11425
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -11344,9 +11434,9 @@ var preferSchemaForApiPayloadDocumentation = {
|
|
|
11344
11434
|
var unwrap4 = (node) => {
|
|
11345
11435
|
let current = node;
|
|
11346
11436
|
while (current !== null && current !== void 0) {
|
|
11347
|
-
if (current.type ===
|
|
11437
|
+
if (current.type === AST_NODE_TYPES48.TSAsExpression || current.type === AST_NODE_TYPES48.TSTypeAssertion || current.type === AST_NODE_TYPES48.TSNonNullExpression || current.type === AST_NODE_TYPES48.TSSatisfiesExpression) {
|
|
11348
11438
|
current = current.expression;
|
|
11349
|
-
} else if (current.type ===
|
|
11439
|
+
} else if (current.type === AST_NODE_TYPES48.ChainExpression) {
|
|
11350
11440
|
current = current.expression;
|
|
11351
11441
|
} else {
|
|
11352
11442
|
break;
|
|
@@ -11361,23 +11451,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
11361
11451
|
]);
|
|
11362
11452
|
var isSchemaParseReference = (node) => {
|
|
11363
11453
|
const inner = unwrap4(node);
|
|
11364
|
-
return inner !== null && inner.type ===
|
|
11454
|
+
return inner !== null && inner.type === AST_NODE_TYPES48.MemberExpression && !inner.computed && inner.property.type === AST_NODE_TYPES48.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
11365
11455
|
};
|
|
11366
11456
|
var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
11367
11457
|
let current = unwrap4(node);
|
|
11368
11458
|
if (current === null) return false;
|
|
11369
|
-
if (current.type ===
|
|
11459
|
+
if (current.type === AST_NODE_TYPES48.AwaitExpression) {
|
|
11370
11460
|
current = unwrap4(current.argument);
|
|
11371
11461
|
}
|
|
11372
|
-
if (current === null || current.type !==
|
|
11462
|
+
if (current === null || current.type !== AST_NODE_TYPES48.CallExpression) {
|
|
11373
11463
|
return false;
|
|
11374
11464
|
}
|
|
11375
11465
|
const callee = unwrap4(current.callee);
|
|
11376
|
-
if (callee === null || callee.type !==
|
|
11466
|
+
if (callee === null || callee.type !== AST_NODE_TYPES48.MemberExpression) {
|
|
11377
11467
|
return false;
|
|
11378
11468
|
}
|
|
11379
11469
|
const property = unwrap4(callee.property);
|
|
11380
|
-
if (property === null || property.type !==
|
|
11470
|
+
if (property === null || property.type !== AST_NODE_TYPES48.Identifier) {
|
|
11381
11471
|
return false;
|
|
11382
11472
|
}
|
|
11383
11473
|
if (property.name === "json") {
|
|
@@ -11387,17 +11477,17 @@ var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
|
11387
11477
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
11388
11478
|
}
|
|
11389
11479
|
const object = unwrap4(callee.object);
|
|
11390
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
11480
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES48.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
11391
11481
|
};
|
|
11392
11482
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
11393
11483
|
var isDirectLocalFileRead = (node) => {
|
|
11394
11484
|
let current = unwrap4(node);
|
|
11395
|
-
if (current?.type ===
|
|
11485
|
+
if (current?.type === AST_NODE_TYPES48.AwaitExpression) {
|
|
11396
11486
|
current = unwrap4(current.argument);
|
|
11397
11487
|
}
|
|
11398
|
-
if (current?.type !==
|
|
11488
|
+
if (current?.type !== AST_NODE_TYPES48.CallExpression) return false;
|
|
11399
11489
|
const callee = unwrap4(current.callee);
|
|
11400
|
-
const name = callee?.type ===
|
|
11490
|
+
const name = callee?.type === AST_NODE_TYPES48.Identifier ? callee.name : callee?.type === AST_NODE_TYPES48.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES48.Identifier ? callee.property.name : null;
|
|
11401
11491
|
return name !== null && FILE_READ_RE.test(name);
|
|
11402
11492
|
};
|
|
11403
11493
|
var isLocalFileRead = (node) => {
|
|
@@ -11424,15 +11514,15 @@ var isLocalFileRead = (node) => {
|
|
|
11424
11514
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
11425
11515
|
var isInsideAssertion = (node) => {
|
|
11426
11516
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11427
|
-
if (current.type !==
|
|
11517
|
+
if (current.type !== AST_NODE_TYPES48.CallExpression) continue;
|
|
11428
11518
|
let callee = current.callee;
|
|
11429
|
-
while (callee.type ===
|
|
11519
|
+
while (callee.type === AST_NODE_TYPES48.MemberExpression) {
|
|
11430
11520
|
callee = callee.object;
|
|
11431
11521
|
}
|
|
11432
|
-
if (callee.type ===
|
|
11522
|
+
if (callee.type === AST_NODE_TYPES48.CallExpression) {
|
|
11433
11523
|
callee = callee.callee;
|
|
11434
11524
|
}
|
|
11435
|
-
if (callee.type ===
|
|
11525
|
+
if (callee.type === AST_NODE_TYPES48.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
11436
11526
|
return true;
|
|
11437
11527
|
}
|
|
11438
11528
|
}
|
|
@@ -11451,22 +11541,22 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
11451
11541
|
var isValidationRead = (node) => {
|
|
11452
11542
|
let current = node;
|
|
11453
11543
|
let parent = current.parent;
|
|
11454
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
11544
|
+
while (parent !== null && parent !== void 0 && (parent.type === AST_NODE_TYPES48.TSAsExpression || parent.type === AST_NODE_TYPES48.TSTypeAssertion || parent.type === AST_NODE_TYPES48.TSNonNullExpression || parent.type === AST_NODE_TYPES48.TSSatisfiesExpression || parent.type === AST_NODE_TYPES48.ChainExpression)) {
|
|
11455
11545
|
current = parent;
|
|
11456
11546
|
parent = parent.parent;
|
|
11457
11547
|
}
|
|
11458
11548
|
if (parent === null || parent === void 0) return false;
|
|
11459
|
-
if (parent.type ===
|
|
11549
|
+
if (parent.type === AST_NODE_TYPES48.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
11460
11550
|
return true;
|
|
11461
11551
|
}
|
|
11462
|
-
if (parent.type !==
|
|
11552
|
+
if (parent.type !== AST_NODE_TYPES48.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
11463
11553
|
return false;
|
|
11464
11554
|
}
|
|
11465
11555
|
const callee = parent.callee;
|
|
11466
|
-
if (callee.type ===
|
|
11556
|
+
if (callee.type === AST_NODE_TYPES48.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES48.Identifier && callee.object.name === "Array" && callee.property.type === AST_NODE_TYPES48.Identifier && callee.property.name === "isArray") {
|
|
11467
11557
|
return parent.arguments.length === 1;
|
|
11468
11558
|
}
|
|
11469
|
-
return callee.type ===
|
|
11559
|
+
return callee.type === AST_NODE_TYPES48.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
11470
11560
|
};
|
|
11471
11561
|
var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
11472
11562
|
"bigint",
|
|
@@ -11477,13 +11567,13 @@ var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
|
11477
11567
|
"undefined"
|
|
11478
11568
|
]);
|
|
11479
11569
|
var bindingValidationPolarity = (test, bindingName) => {
|
|
11480
|
-
if (test.type ===
|
|
11570
|
+
if (test.type === AST_NODE_TYPES48.UnaryExpression && test.operator === "!") {
|
|
11481
11571
|
const inner = bindingValidationPolarity(test.argument, bindingName);
|
|
11482
11572
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
11483
11573
|
}
|
|
11484
|
-
if (test.type ===
|
|
11485
|
-
const typeofName = (node) => node.type ===
|
|
11486
|
-
const literalType = (node) => node.type ===
|
|
11574
|
+
if (test.type === AST_NODE_TYPES48.BinaryExpression) {
|
|
11575
|
+
const typeofName = (node) => node.type === AST_NODE_TYPES48.UnaryExpression && node.operator === "typeof" && node.argument.type === AST_NODE_TYPES48.Identifier ? node.argument.name : null;
|
|
11576
|
+
const literalType = (node) => node.type === AST_NODE_TYPES48.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value) ? node.value : null;
|
|
11487
11577
|
const matches = typeofName(test.left) === bindingName && literalType(test.right) !== null || typeofName(test.right) === bindingName && literalType(test.left) !== null;
|
|
11488
11578
|
if (!matches) return null;
|
|
11489
11579
|
if (test.operator === "===" || test.operator === "==") {
|
|
@@ -11491,9 +11581,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
11491
11581
|
}
|
|
11492
11582
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
11493
11583
|
}
|
|
11494
|
-
return test.type ===
|
|
11584
|
+
return test.type === AST_NODE_TYPES48.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES48.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES48.MemberExpression && !test.callee.computed && test.callee.object.type === AST_NODE_TYPES48.Identifier && test.callee.object.name === "Array" && test.callee.property.type === AST_NODE_TYPES48.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
11495
11585
|
};
|
|
11496
|
-
var plainMemberAccess = (node) => node.type ===
|
|
11586
|
+
var plainMemberAccess = (node) => node.type === AST_NODE_TYPES48.MemberExpression && !node.computed && node.object.type === AST_NODE_TYPES48.Identifier && node.property.type === AST_NODE_TYPES48.Identifier ? { object: node.object.name, property: node.property.name } : null;
|
|
11497
11587
|
var isSamePlainMember = (node, access) => {
|
|
11498
11588
|
const candidate = plainMemberAccess(node);
|
|
11499
11589
|
return candidate !== null && candidate.object === access.object && candidate.property === access.property;
|
|
@@ -11501,19 +11591,19 @@ var isSamePlainMember = (node, access) => {
|
|
|
11501
11591
|
var nodeWithin2 = (node, container) => node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
11502
11592
|
var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
11503
11593
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11504
|
-
if (current.type ===
|
|
11594
|
+
if (current.type === AST_NODE_TYPES48.ConditionalExpression) {
|
|
11505
11595
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
11506
11596
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
11507
11597
|
return true;
|
|
11508
11598
|
}
|
|
11509
11599
|
}
|
|
11510
|
-
if (current.type ===
|
|
11600
|
+
if (current.type === AST_NODE_TYPES48.IfStatement) {
|
|
11511
11601
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
11512
11602
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
11513
11603
|
return true;
|
|
11514
11604
|
}
|
|
11515
11605
|
}
|
|
11516
|
-
if (current.type ===
|
|
11606
|
+
if (current.type === AST_NODE_TYPES48.FunctionDeclaration || current.type === AST_NODE_TYPES48.FunctionExpression || current.type === AST_NODE_TYPES48.ArrowFunctionExpression) {
|
|
11517
11607
|
return false;
|
|
11518
11608
|
}
|
|
11519
11609
|
}
|
|
@@ -11521,32 +11611,32 @@ var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
|
11521
11611
|
};
|
|
11522
11612
|
var isMemberUseWithinValidatedBranch = (node, access) => {
|
|
11523
11613
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11524
|
-
if (current.type ===
|
|
11614
|
+
if (current.type === AST_NODE_TYPES48.ConditionalExpression) {
|
|
11525
11615
|
const polarity = memberValidationPolarity(current.test, access);
|
|
11526
11616
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
11527
11617
|
return true;
|
|
11528
11618
|
}
|
|
11529
11619
|
}
|
|
11530
|
-
if (current.type ===
|
|
11620
|
+
if (current.type === AST_NODE_TYPES48.IfStatement) {
|
|
11531
11621
|
const polarity = memberValidationPolarity(current.test, access);
|
|
11532
11622
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
11533
11623
|
return true;
|
|
11534
11624
|
}
|
|
11535
11625
|
}
|
|
11536
|
-
if (current.type ===
|
|
11626
|
+
if (current.type === AST_NODE_TYPES48.FunctionDeclaration || current.type === AST_NODE_TYPES48.FunctionExpression || current.type === AST_NODE_TYPES48.ArrowFunctionExpression) {
|
|
11537
11627
|
return false;
|
|
11538
11628
|
}
|
|
11539
11629
|
}
|
|
11540
11630
|
return false;
|
|
11541
11631
|
};
|
|
11542
11632
|
var memberValidationPolarity = (test, access) => {
|
|
11543
|
-
if (test.type ===
|
|
11633
|
+
if (test.type === AST_NODE_TYPES48.UnaryExpression && test.operator === "!") {
|
|
11544
11634
|
const inner = memberValidationPolarity(test.argument, access);
|
|
11545
11635
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
11546
11636
|
}
|
|
11547
|
-
if (test.type ===
|
|
11548
|
-
const isMatchingTypeof = (node) => node.type ===
|
|
11549
|
-
const isPrimitiveType = (node) => node.type ===
|
|
11637
|
+
if (test.type === AST_NODE_TYPES48.BinaryExpression) {
|
|
11638
|
+
const isMatchingTypeof = (node) => node.type === AST_NODE_TYPES48.UnaryExpression && node.operator === "typeof" && isSamePlainMember(node.argument, access);
|
|
11639
|
+
const isPrimitiveType = (node) => node.type === AST_NODE_TYPES48.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value);
|
|
11550
11640
|
if (!(isMatchingTypeof(test.left) && isPrimitiveType(test.right) || isMatchingTypeof(test.right) && isPrimitiveType(test.left))) {
|
|
11551
11641
|
return null;
|
|
11552
11642
|
}
|
|
@@ -11555,15 +11645,15 @@ var memberValidationPolarity = (test, access) => {
|
|
|
11555
11645
|
}
|
|
11556
11646
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
11557
11647
|
}
|
|
11558
|
-
return test.type ===
|
|
11648
|
+
return test.type === AST_NODE_TYPES48.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES48.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES48.MemberExpression && !test.callee.computed && test.callee.object.type === AST_NODE_TYPES48.Identifier && test.callee.object.name === "Array" && test.callee.property.type === AST_NODE_TYPES48.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
11559
11649
|
};
|
|
11560
11650
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
11561
11651
|
const isValidationReference = (identifier) => {
|
|
11562
11652
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11563
|
-
if ((current.type ===
|
|
11653
|
+
if ((current.type === AST_NODE_TYPES48.BinaryExpression || current.type === AST_NODE_TYPES48.CallExpression || current.type === AST_NODE_TYPES48.UnaryExpression) && bindingValidationPolarity(current, identifier.name) !== null) {
|
|
11564
11654
|
return true;
|
|
11565
11655
|
}
|
|
11566
|
-
if (current.type !==
|
|
11656
|
+
if (current.type !== AST_NODE_TYPES48.UnaryExpression && current.type !== AST_NODE_TYPES48.MemberExpression && current.type !== AST_NODE_TYPES48.CallExpression) {
|
|
11567
11657
|
return false;
|
|
11568
11658
|
}
|
|
11569
11659
|
}
|
|
@@ -11571,7 +11661,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11571
11661
|
};
|
|
11572
11662
|
const isGuardedUse = (identifier) => {
|
|
11573
11663
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11574
|
-
if (current.type ===
|
|
11664
|
+
if (current.type === AST_NODE_TYPES48.ConditionalExpression) {
|
|
11575
11665
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
11576
11666
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
11577
11667
|
return true;
|
|
@@ -11580,7 +11670,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11580
11670
|
return true;
|
|
11581
11671
|
}
|
|
11582
11672
|
}
|
|
11583
|
-
if (current.type ===
|
|
11673
|
+
if (current.type === AST_NODE_TYPES48.IfStatement) {
|
|
11584
11674
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
11585
11675
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
11586
11676
|
return true;
|
|
@@ -11589,14 +11679,14 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11589
11679
|
return true;
|
|
11590
11680
|
}
|
|
11591
11681
|
}
|
|
11592
|
-
if (current.type ===
|
|
11682
|
+
if (current.type === AST_NODE_TYPES48.FunctionDeclaration || current.type === AST_NODE_TYPES48.FunctionExpression || current.type === AST_NODE_TYPES48.ArrowFunctionExpression) {
|
|
11593
11683
|
return false;
|
|
11594
11684
|
}
|
|
11595
11685
|
}
|
|
11596
11686
|
return false;
|
|
11597
11687
|
};
|
|
11598
11688
|
const declarator = member.parent;
|
|
11599
|
-
if (declarator.type !==
|
|
11689
|
+
if (declarator.type !== AST_NODE_TYPES48.VariableDeclarator || declarator.init !== member || declarator.id.type !== AST_NODE_TYPES48.Identifier || declarator.parent.type !== AST_NODE_TYPES48.VariableDeclaration || declarator.parent.kind !== "const") {
|
|
11600
11690
|
return false;
|
|
11601
11691
|
}
|
|
11602
11692
|
const extracted = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -11604,7 +11694,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11604
11694
|
let hasValueUse = false;
|
|
11605
11695
|
for (const reference of extracted.references) {
|
|
11606
11696
|
const identifier = reference.identifier;
|
|
11607
|
-
if (identifier.type !==
|
|
11697
|
+
if (identifier.type !== AST_NODE_TYPES48.Identifier) return false;
|
|
11608
11698
|
if (nodeWithin2(identifier, declarator)) continue;
|
|
11609
11699
|
if (isValidationReference(identifier)) continue;
|
|
11610
11700
|
hasValueUse = true;
|
|
@@ -11617,17 +11707,17 @@ var isGuardTestPosition = (node) => {
|
|
|
11617
11707
|
let parent = current.parent;
|
|
11618
11708
|
while (parent !== void 0 && parent !== null) {
|
|
11619
11709
|
switch (parent.type) {
|
|
11620
|
-
case
|
|
11621
|
-
case
|
|
11622
|
-
case
|
|
11710
|
+
case AST_NODE_TYPES48.UnaryExpression:
|
|
11711
|
+
case AST_NODE_TYPES48.LogicalExpression:
|
|
11712
|
+
case AST_NODE_TYPES48.ChainExpression:
|
|
11623
11713
|
current = parent;
|
|
11624
11714
|
parent = parent.parent;
|
|
11625
11715
|
continue;
|
|
11626
|
-
case
|
|
11627
|
-
case
|
|
11628
|
-
case
|
|
11629
|
-
case
|
|
11630
|
-
case
|
|
11716
|
+
case AST_NODE_TYPES48.IfStatement:
|
|
11717
|
+
case AST_NODE_TYPES48.ConditionalExpression:
|
|
11718
|
+
case AST_NODE_TYPES48.WhileStatement:
|
|
11719
|
+
case AST_NODE_TYPES48.DoWhileStatement:
|
|
11720
|
+
case AST_NODE_TYPES48.ForStatement:
|
|
11631
11721
|
return parent.test === current;
|
|
11632
11722
|
default:
|
|
11633
11723
|
return false;
|
|
@@ -11637,7 +11727,7 @@ var isGuardTestPosition = (node) => {
|
|
|
11637
11727
|
};
|
|
11638
11728
|
var unvalidatedVariableRef = (node, scope, tracked) => {
|
|
11639
11729
|
const unwrapped = unwrap4(node);
|
|
11640
|
-
if (unwrapped === null || unwrapped.type !==
|
|
11730
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES48.Identifier) {
|
|
11641
11731
|
return null;
|
|
11642
11732
|
}
|
|
11643
11733
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -11666,7 +11756,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11666
11756
|
const localFileTextVariables = /* @__PURE__ */ new Set();
|
|
11667
11757
|
const localFileTextRef = (node, scope) => {
|
|
11668
11758
|
const unwrapped = unwrap4(node);
|
|
11669
|
-
if (unwrapped?.type !==
|
|
11759
|
+
if (unwrapped?.type !== AST_NODE_TYPES48.Identifier) return null;
|
|
11670
11760
|
const variable = findVariable2(scope, unwrapped.name);
|
|
11671
11761
|
return variable !== null && localFileTextVariables.has(variable) ? variable : null;
|
|
11672
11762
|
};
|
|
@@ -11735,7 +11825,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11735
11825
|
return {
|
|
11736
11826
|
VariableDeclarator(node) {
|
|
11737
11827
|
const scope = context.sourceCode.getScope(node);
|
|
11738
|
-
if (node.id.type ===
|
|
11828
|
+
if (node.id.type === AST_NODE_TYPES48.Identifier) {
|
|
11739
11829
|
const variable = context.sourceCode.getDeclaredVariables(node)[0];
|
|
11740
11830
|
if (variable !== void 0) {
|
|
11741
11831
|
updateLocalFileText(variable, node.init, scope);
|
|
@@ -11743,7 +11833,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11743
11833
|
trackInitializer(node, scope);
|
|
11744
11834
|
return;
|
|
11745
11835
|
}
|
|
11746
|
-
if (node.id.type ===
|
|
11836
|
+
if (node.id.type === AST_NODE_TYPES48.ObjectPattern || node.id.type === AST_NODE_TYPES48.ArrayPattern) {
|
|
11747
11837
|
if (isRawPayloadSource(
|
|
11748
11838
|
node.init,
|
|
11749
11839
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
@@ -11760,7 +11850,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11760
11850
|
},
|
|
11761
11851
|
AssignmentExpression(node) {
|
|
11762
11852
|
const scope = context.sourceCode.getScope(node);
|
|
11763
|
-
if (node.left.type ===
|
|
11853
|
+
if (node.left.type === AST_NODE_TYPES48.Identifier) {
|
|
11764
11854
|
const variable = findVariable2(scope, node.left.name);
|
|
11765
11855
|
if (variable === null) return;
|
|
11766
11856
|
const isLocalText = (candidate) => localFileTextRef(candidate, scope) !== null;
|
|
@@ -11774,7 +11864,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11774
11864
|
}
|
|
11775
11865
|
return;
|
|
11776
11866
|
}
|
|
11777
|
-
if (node.left.type ===
|
|
11867
|
+
if (node.left.type === AST_NODE_TYPES48.ObjectPattern || node.left.type === AST_NODE_TYPES48.ArrayPattern) {
|
|
11778
11868
|
if (isRawPayloadSource(
|
|
11779
11869
|
node.right,
|
|
11780
11870
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
@@ -11794,15 +11884,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11794
11884
|
}
|
|
11795
11885
|
},
|
|
11796
11886
|
CallExpression(node) {
|
|
11797
|
-
if (node.callee.type !==
|
|
11887
|
+
if (node.callee.type !== AST_NODE_TYPES48.Identifier) return;
|
|
11798
11888
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
11799
11889
|
return;
|
|
11800
11890
|
}
|
|
11801
11891
|
const scope = context.sourceCode.getScope(node);
|
|
11802
11892
|
for (const arg of node.arguments) {
|
|
11803
|
-
if (arg.type ===
|
|
11893
|
+
if (arg.type === AST_NODE_TYPES48.SpreadElement) continue;
|
|
11804
11894
|
const unwrapped = unwrap4(arg);
|
|
11805
|
-
if (unwrapped === null || unwrapped.type !==
|
|
11895
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES48.Identifier) {
|
|
11806
11896
|
continue;
|
|
11807
11897
|
}
|
|
11808
11898
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -11819,14 +11909,14 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11819
11909
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
11820
11910
|
)) {
|
|
11821
11911
|
const parent = node.parent;
|
|
11822
|
-
if (parent.type ===
|
|
11912
|
+
if (parent.type === AST_NODE_TYPES48.CallExpression && parent.callee === node && node.property.type === AST_NODE_TYPES48.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
11823
11913
|
return;
|
|
11824
11914
|
}
|
|
11825
11915
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
11826
11916
|
return;
|
|
11827
11917
|
}
|
|
11828
|
-
const variable = obj?.type ===
|
|
11829
|
-
if (variable !== null && obj?.type ===
|
|
11918
|
+
const variable = obj?.type === AST_NODE_TYPES48.Identifier ? unvalidatedVariableRef(obj, scope, unvalidatedVariables) : null;
|
|
11919
|
+
if (variable !== null && obj?.type === AST_NODE_TYPES48.Identifier) {
|
|
11830
11920
|
if (isUseWithinValidatedBranch(node, obj.name)) {
|
|
11831
11921
|
return;
|
|
11832
11922
|
}
|
|
@@ -11846,7 +11936,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11846
11936
|
});
|
|
11847
11937
|
|
|
11848
11938
|
// src/rules/prefer-semantic-colors.ts
|
|
11849
|
-
import { AST_NODE_TYPES as
|
|
11939
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49 } from "@typescript-eslint/utils";
|
|
11850
11940
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
11851
11941
|
import { dirname, join, parse } from "path";
|
|
11852
11942
|
|
|
@@ -11958,7 +12048,7 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
11958
12048
|
var isInsideSvg = (node) => {
|
|
11959
12049
|
let current = node.parent;
|
|
11960
12050
|
while (current !== void 0 && current !== null) {
|
|
11961
|
-
if (current.type ===
|
|
12051
|
+
if (current.type === AST_NODE_TYPES49.JSXElement) {
|
|
11962
12052
|
const name = jsxElementName(current);
|
|
11963
12053
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
11964
12054
|
}
|
|
@@ -11968,8 +12058,8 @@ var isInsideSvg = (node) => {
|
|
|
11968
12058
|
};
|
|
11969
12059
|
function jsxElementName(node) {
|
|
11970
12060
|
const name = node.openingElement.name;
|
|
11971
|
-
if (name.type ===
|
|
11972
|
-
if (name.type ===
|
|
12061
|
+
if (name.type === AST_NODE_TYPES49.JSXIdentifier) return name.name;
|
|
12062
|
+
if (name.type === AST_NODE_TYPES49.JSXMemberExpression && name.property.type === AST_NODE_TYPES49.JSXIdentifier) {
|
|
11973
12063
|
return name.property.name;
|
|
11974
12064
|
}
|
|
11975
12065
|
return null;
|
|
@@ -11995,7 +12085,7 @@ function isSvgLikeElementName(name) {
|
|
|
11995
12085
|
var isInsideIconFactoryPath = (node) => {
|
|
11996
12086
|
let current = node.parent;
|
|
11997
12087
|
while (current !== void 0 && current !== null) {
|
|
11998
|
-
if (current.type ===
|
|
12088
|
+
if (current.type === AST_NODE_TYPES49.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES49.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES49.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES49.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
11999
12089
|
return true;
|
|
12000
12090
|
}
|
|
12001
12091
|
current = current.parent;
|
|
@@ -12129,12 +12219,12 @@ var expandWorkspaceGlob = (root, glob) => {
|
|
|
12129
12219
|
return readdirSync(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => join(parent, entry.name));
|
|
12130
12220
|
};
|
|
12131
12221
|
var propName = (key) => {
|
|
12132
|
-
if (key.type ===
|
|
12133
|
-
if (key.type ===
|
|
12222
|
+
if (key.type === AST_NODE_TYPES49.Identifier) return key.name;
|
|
12223
|
+
if (key.type === AST_NODE_TYPES49.Literal && typeof key.value === "string") return key.value;
|
|
12134
12224
|
return null;
|
|
12135
12225
|
};
|
|
12136
12226
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
12137
|
-
if (statement.type !==
|
|
12227
|
+
if (statement.type !== AST_NODE_TYPES49.ImportDeclaration && statement.type !== AST_NODE_TYPES49.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES49.ExportAllDeclaration) {
|
|
12138
12228
|
return false;
|
|
12139
12229
|
}
|
|
12140
12230
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -12187,27 +12277,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12187
12277
|
const checkClassNode = (node) => {
|
|
12188
12278
|
if (node === null) return;
|
|
12189
12279
|
switch (node.type) {
|
|
12190
|
-
case
|
|
12280
|
+
case AST_NODE_TYPES49.Literal:
|
|
12191
12281
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
12192
12282
|
break;
|
|
12193
|
-
case
|
|
12283
|
+
case AST_NODE_TYPES49.TemplateLiteral:
|
|
12194
12284
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
12195
12285
|
break;
|
|
12196
|
-
case
|
|
12286
|
+
case AST_NODE_TYPES49.ArrayExpression:
|
|
12197
12287
|
for (const element of node.elements) {
|
|
12198
|
-
if (element !== null && element.type !==
|
|
12288
|
+
if (element !== null && element.type !== AST_NODE_TYPES49.SpreadElement) checkClassNode(element);
|
|
12199
12289
|
}
|
|
12200
12290
|
break;
|
|
12201
|
-
case
|
|
12291
|
+
case AST_NODE_TYPES49.ObjectExpression:
|
|
12202
12292
|
for (const property of node.properties) {
|
|
12203
|
-
if (property.type ===
|
|
12293
|
+
if (property.type === AST_NODE_TYPES49.Property) checkClassNode(property.value);
|
|
12204
12294
|
}
|
|
12205
12295
|
break;
|
|
12206
|
-
case
|
|
12296
|
+
case AST_NODE_TYPES49.ConditionalExpression:
|
|
12207
12297
|
checkClassNode(node.consequent);
|
|
12208
12298
|
checkClassNode(node.alternate);
|
|
12209
12299
|
break;
|
|
12210
|
-
case
|
|
12300
|
+
case AST_NODE_TYPES49.LogicalExpression:
|
|
12211
12301
|
checkClassNode(node.right);
|
|
12212
12302
|
break;
|
|
12213
12303
|
default:
|
|
@@ -12215,32 +12305,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12215
12305
|
}
|
|
12216
12306
|
};
|
|
12217
12307
|
const checkColorValueNode = (node) => {
|
|
12218
|
-
if (node.type ===
|
|
12308
|
+
if (node.type === AST_NODE_TYPES49.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
12219
12309
|
report(node, "inlineColor", { value: node.value });
|
|
12220
12310
|
}
|
|
12221
12311
|
};
|
|
12222
12312
|
return {
|
|
12223
12313
|
"JSXAttribute[name.name='className']"(node) {
|
|
12224
12314
|
if (node.value === null) return;
|
|
12225
|
-
if (node.value.type ===
|
|
12226
|
-
else if (node.value.type ===
|
|
12227
|
-
if (node.value.expression.type !==
|
|
12315
|
+
if (node.value.type === AST_NODE_TYPES49.Literal) checkClassNode(node.value);
|
|
12316
|
+
else if (node.value.type === AST_NODE_TYPES49.JSXExpressionContainer) {
|
|
12317
|
+
if (node.value.expression.type !== AST_NODE_TYPES49.JSXEmptyExpression) {
|
|
12228
12318
|
checkClassNode(node.value.expression);
|
|
12229
12319
|
}
|
|
12230
12320
|
}
|
|
12231
12321
|
},
|
|
12232
12322
|
CallExpression(node) {
|
|
12233
|
-
if (node.callee.type ===
|
|
12323
|
+
if (node.callee.type === AST_NODE_TYPES49.Identifier && node.callee.name === "require" && node.arguments[0]?.type === AST_NODE_TYPES49.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
12234
12324
|
importsEmailOrPdfRenderer = true;
|
|
12235
12325
|
}
|
|
12236
|
-
if (node.callee.type ===
|
|
12326
|
+
if (node.callee.type === AST_NODE_TYPES49.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
12237
12327
|
for (const arg of node.arguments) {
|
|
12238
|
-
if (arg.type !==
|
|
12328
|
+
if (arg.type !== AST_NODE_TYPES49.SpreadElement) checkClassNode(arg);
|
|
12239
12329
|
}
|
|
12240
12330
|
}
|
|
12241
12331
|
},
|
|
12242
12332
|
VariableDeclarator(node) {
|
|
12243
|
-
if (node.id.type ===
|
|
12333
|
+
if (node.id.type === AST_NODE_TYPES49.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
12244
12334
|
checkClassNode(node.init);
|
|
12245
12335
|
}
|
|
12246
12336
|
},
|
|
@@ -12250,9 +12340,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12250
12340
|
},
|
|
12251
12341
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
12252
12342
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
12253
|
-
if (node.value?.type !==
|
|
12343
|
+
if (node.value?.type !== AST_NODE_TYPES49.Literal) return;
|
|
12254
12344
|
const owner = node.parent.name;
|
|
12255
|
-
if (owner.type ===
|
|
12345
|
+
if (owner.type === AST_NODE_TYPES49.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
12256
12346
|
return;
|
|
12257
12347
|
}
|
|
12258
12348
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -12266,7 +12356,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
12266
12356
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
12267
12357
|
},
|
|
12268
12358
|
ImportExpression(node) {
|
|
12269
|
-
if (node.source.type ===
|
|
12359
|
+
if (node.source.type === AST_NODE_TYPES49.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
12270
12360
|
importsEmailOrPdfRenderer = true;
|
|
12271
12361
|
}
|
|
12272
12362
|
},
|
|
@@ -12468,7 +12558,7 @@ var prefer_server_actions_default = createRule({
|
|
|
12468
12558
|
});
|
|
12469
12559
|
|
|
12470
12560
|
// src/rules/prefer-whole-object-assertion.ts
|
|
12471
|
-
import { AST_NODE_TYPES as
|
|
12561
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50 } from "@typescript-eslint/utils";
|
|
12472
12562
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
12473
12563
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
12474
12564
|
["toBeNull", "null"],
|
|
@@ -12493,11 +12583,11 @@ var preferWholeObjectAssertionDocumentation = {
|
|
|
12493
12583
|
};
|
|
12494
12584
|
function literalText(node, getText) {
|
|
12495
12585
|
switch (node.type) {
|
|
12496
|
-
case
|
|
12586
|
+
case AST_NODE_TYPES50.Literal:
|
|
12497
12587
|
return "regex" in node ? null : getText(node);
|
|
12498
|
-
case
|
|
12588
|
+
case AST_NODE_TYPES50.TemplateLiteral:
|
|
12499
12589
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
12500
|
-
case
|
|
12590
|
+
case AST_NODE_TYPES50.UnaryExpression:
|
|
12501
12591
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
12502
12592
|
default:
|
|
12503
12593
|
return null;
|
|
@@ -12505,15 +12595,15 @@ function literalText(node, getText) {
|
|
|
12505
12595
|
}
|
|
12506
12596
|
function isPureReceiver(node) {
|
|
12507
12597
|
switch (node.type) {
|
|
12508
|
-
case
|
|
12509
|
-
case
|
|
12598
|
+
case AST_NODE_TYPES50.Identifier:
|
|
12599
|
+
case AST_NODE_TYPES50.ThisExpression:
|
|
12510
12600
|
return true;
|
|
12511
|
-
case
|
|
12601
|
+
case AST_NODE_TYPES50.MemberExpression:
|
|
12512
12602
|
if (node.optional) {
|
|
12513
12603
|
return false;
|
|
12514
12604
|
}
|
|
12515
12605
|
if (node.computed) {
|
|
12516
|
-
return node.property.type ===
|
|
12606
|
+
return node.property.type === AST_NODE_TYPES50.Literal && isPureReceiver(node.object);
|
|
12517
12607
|
}
|
|
12518
12608
|
return isPureReceiver(node.object);
|
|
12519
12609
|
default:
|
|
@@ -12521,7 +12611,7 @@ function isPureReceiver(node) {
|
|
|
12521
12611
|
}
|
|
12522
12612
|
}
|
|
12523
12613
|
function literalIndex(node) {
|
|
12524
|
-
if (node.type !==
|
|
12614
|
+
if (node.type !== AST_NODE_TYPES50.Literal || typeof node.value !== "number") {
|
|
12525
12615
|
return null;
|
|
12526
12616
|
}
|
|
12527
12617
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -12529,8 +12619,8 @@ function literalIndex(node) {
|
|
|
12529
12619
|
function propertyAccess(node) {
|
|
12530
12620
|
const path = [];
|
|
12531
12621
|
let current = node;
|
|
12532
|
-
while (current.type ===
|
|
12533
|
-
if (current.property.type !==
|
|
12622
|
+
while (current.type === AST_NODE_TYPES50.MemberExpression && !current.computed && !current.optional) {
|
|
12623
|
+
if (current.property.type !== AST_NODE_TYPES50.Identifier || COLLECTION_PROPERTIES.has(current.property.name) || LITERAL_KEY_HAZARDS.has(current.property.name)) return null;
|
|
12534
12624
|
path.unshift(current.property.name);
|
|
12535
12625
|
current = current.object;
|
|
12536
12626
|
}
|
|
@@ -12558,24 +12648,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12558
12648
|
}
|
|
12559
12649
|
const { sourceCode } = context;
|
|
12560
12650
|
function parseAssertion(statement) {
|
|
12561
|
-
if (statement.type !==
|
|
12651
|
+
if (statement.type !== AST_NODE_TYPES50.ExpressionStatement) {
|
|
12562
12652
|
return null;
|
|
12563
12653
|
}
|
|
12564
12654
|
const call = statement.expression;
|
|
12565
|
-
if (call.type !==
|
|
12655
|
+
if (call.type !== AST_NODE_TYPES50.CallExpression) {
|
|
12566
12656
|
return null;
|
|
12567
12657
|
}
|
|
12568
12658
|
const callee = call.callee;
|
|
12569
|
-
if (callee.type !==
|
|
12659
|
+
if (callee.type !== AST_NODE_TYPES50.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES50.Identifier) {
|
|
12570
12660
|
return null;
|
|
12571
12661
|
}
|
|
12572
12662
|
const matcher = callee.property.name;
|
|
12573
12663
|
const expectCall = callee.object;
|
|
12574
|
-
if (expectCall.type !==
|
|
12664
|
+
if (expectCall.type !== AST_NODE_TYPES50.CallExpression || expectCall.callee.type !== AST_NODE_TYPES50.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
12575
12665
|
return null;
|
|
12576
12666
|
}
|
|
12577
12667
|
const actual = expectCall.arguments[0];
|
|
12578
|
-
if (actual === void 0 || actual.type !==
|
|
12668
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES50.MemberExpression || actual.optional) {
|
|
12579
12669
|
return null;
|
|
12580
12670
|
}
|
|
12581
12671
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -12604,7 +12694,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12604
12694
|
return null;
|
|
12605
12695
|
}
|
|
12606
12696
|
const expected = call.arguments[0];
|
|
12607
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
12697
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES50.SpreadElement) {
|
|
12608
12698
|
return null;
|
|
12609
12699
|
}
|
|
12610
12700
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -12745,7 +12835,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12745
12835
|
});
|
|
12746
12836
|
|
|
12747
12837
|
// src/rules/repeated-static-call-cases.ts
|
|
12748
|
-
import { AST_NODE_TYPES as
|
|
12838
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51, ASTUtils as ASTUtils15 } from "@typescript-eslint/utils";
|
|
12749
12839
|
var repeatedStaticCallCasesDocumentation = {
|
|
12750
12840
|
summary: "Report three or more consecutive literal call assertions that should be independently named test cases.",
|
|
12751
12841
|
rationale: "Copy-pasted cases obscure the input table and stop later cases from being reported after the first failure.",
|
|
@@ -12766,67 +12856,67 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
12766
12856
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
12767
12857
|
var MIN_CASES2 = 3;
|
|
12768
12858
|
function staticMemberName5(node) {
|
|
12769
|
-
if (!node.computed && node.property.type ===
|
|
12770
|
-
if (node.computed && node.property.type ===
|
|
12859
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES51.Identifier) return node.property.name;
|
|
12860
|
+
if (node.computed && node.property.type === AST_NODE_TYPES51.Literal && typeof node.property.value === "string") return node.property.value;
|
|
12771
12861
|
return null;
|
|
12772
12862
|
}
|
|
12773
12863
|
function importedName3(identifier, context, modules) {
|
|
12774
12864
|
const variable = ASTUtils15.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
12775
12865
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
12776
12866
|
for (const definition of variable.defs) {
|
|
12777
|
-
if (definition.node.type !==
|
|
12867
|
+
if (definition.node.type !== AST_NODE_TYPES51.ImportSpecifier) continue;
|
|
12778
12868
|
const declaration = definition.node.parent;
|
|
12779
|
-
if (declaration.type !==
|
|
12869
|
+
if (declaration.type !== AST_NODE_TYPES51.ImportDeclaration || typeof declaration.source.value !== "string" || !modules.has(declaration.source.value)) continue;
|
|
12780
12870
|
const imported = definition.node.imported;
|
|
12781
|
-
return imported.type ===
|
|
12871
|
+
return imported.type === AST_NODE_TYPES51.Identifier ? imported.name : String(imported.value);
|
|
12782
12872
|
}
|
|
12783
12873
|
return null;
|
|
12784
12874
|
}
|
|
12785
12875
|
function isDirectTestCallback2(node, context) {
|
|
12786
|
-
if (node.type !==
|
|
12876
|
+
if (node.type !== AST_NODE_TYPES51.ArrowFunctionExpression && node.type !== AST_NODE_TYPES51.FunctionExpression) return false;
|
|
12787
12877
|
const call = node.parent;
|
|
12788
|
-
if (call?.type !==
|
|
12878
|
+
if (call?.type !== AST_NODE_TYPES51.CallExpression || !call.arguments.includes(node)) return false;
|
|
12789
12879
|
const root = testRoot2(call.callee);
|
|
12790
12880
|
return root !== null && TEST_NAMES2.has(importedName3(root, context, TEST_MODULES4) ?? "");
|
|
12791
12881
|
}
|
|
12792
12882
|
function testRoot2(callee) {
|
|
12793
|
-
if (callee.type ===
|
|
12794
|
-
if (callee.type !==
|
|
12883
|
+
if (callee.type === AST_NODE_TYPES51.Identifier) return callee;
|
|
12884
|
+
if (callee.type !== AST_NODE_TYPES51.MemberExpression) return null;
|
|
12795
12885
|
const modifier = staticMemberName5(callee);
|
|
12796
12886
|
return modifier !== null && TEST_MODIFIERS4.has(modifier) ? testRoot2(callee.object) : null;
|
|
12797
12887
|
}
|
|
12798
12888
|
function isStatic(node) {
|
|
12799
|
-
if (node.type ===
|
|
12889
|
+
if (node.type === AST_NODE_TYPES51.TSAsExpression || node.type === AST_NODE_TYPES51.TSTypeAssertion || node.type === AST_NODE_TYPES51.TSSatisfiesExpression || node.type === AST_NODE_TYPES51.TSNonNullExpression) return isStatic(node.expression);
|
|
12800
12890
|
switch (node.type) {
|
|
12801
|
-
case
|
|
12891
|
+
case AST_NODE_TYPES51.Literal:
|
|
12802
12892
|
return true;
|
|
12803
|
-
case
|
|
12893
|
+
case AST_NODE_TYPES51.TemplateLiteral:
|
|
12804
12894
|
return node.expressions.length === 0;
|
|
12805
|
-
case
|
|
12895
|
+
case AST_NODE_TYPES51.UnaryExpression:
|
|
12806
12896
|
return (node.operator === "+" || node.operator === "-") && isStatic(node.argument);
|
|
12807
|
-
case
|
|
12808
|
-
return node.elements.every((item) => item !== null && item.type !==
|
|
12809
|
-
case
|
|
12810
|
-
return node.properties.every((property) => property.type ===
|
|
12897
|
+
case AST_NODE_TYPES51.ArrayExpression:
|
|
12898
|
+
return node.elements.every((item) => item !== null && item.type !== AST_NODE_TYPES51.SpreadElement && isStatic(item));
|
|
12899
|
+
case AST_NODE_TYPES51.ObjectExpression:
|
|
12900
|
+
return node.properties.every((property) => property.type === AST_NODE_TYPES51.Property && !property.computed && property.kind === "init" && property.value.type !== AST_NODE_TYPES51.AssignmentPattern && isStatic(property.value));
|
|
12811
12901
|
default:
|
|
12812
12902
|
return false;
|
|
12813
12903
|
}
|
|
12814
12904
|
}
|
|
12815
12905
|
function staticShape(node) {
|
|
12816
|
-
if (node.type ===
|
|
12906
|
+
if (node.type === AST_NODE_TYPES51.TSAsExpression || node.type === AST_NODE_TYPES51.TSTypeAssertion || node.type === AST_NODE_TYPES51.TSSatisfiesExpression || node.type === AST_NODE_TYPES51.TSNonNullExpression) return staticShape(node.expression);
|
|
12817
12907
|
switch (node.type) {
|
|
12818
|
-
case
|
|
12908
|
+
case AST_NODE_TYPES51.Literal:
|
|
12819
12909
|
return `literal:${typeof node.value}`;
|
|
12820
|
-
case
|
|
12910
|
+
case AST_NODE_TYPES51.TemplateLiteral:
|
|
12821
12911
|
return "template";
|
|
12822
|
-
case
|
|
12912
|
+
case AST_NODE_TYPES51.UnaryExpression:
|
|
12823
12913
|
return `unary:${node.operator}:${staticShape(node.argument)}`;
|
|
12824
|
-
case
|
|
12825
|
-
return `array(${node.elements.map((item) => item === null || item.type ===
|
|
12826
|
-
case
|
|
12914
|
+
case AST_NODE_TYPES51.ArrayExpression:
|
|
12915
|
+
return `array(${node.elements.map((item) => item === null || item.type === AST_NODE_TYPES51.SpreadElement ? "invalid" : staticShape(item)).join(",")})`;
|
|
12916
|
+
case AST_NODE_TYPES51.ObjectExpression:
|
|
12827
12917
|
return `object(${node.properties.map((property) => {
|
|
12828
|
-
if (property.type !==
|
|
12829
|
-
const key = property.key.type ===
|
|
12918
|
+
if (property.type !== AST_NODE_TYPES51.Property || property.computed || property.value.type === AST_NODE_TYPES51.AssignmentPattern) return "invalid";
|
|
12919
|
+
const key = property.key.type === AST_NODE_TYPES51.Identifier ? property.key.name : String(property.key.value);
|
|
12830
12920
|
return `${key}:${staticShape(property.value)}`;
|
|
12831
12921
|
}).join(",")})`;
|
|
12832
12922
|
default:
|
|
@@ -12834,16 +12924,16 @@ function staticShape(node) {
|
|
|
12834
12924
|
}
|
|
12835
12925
|
}
|
|
12836
12926
|
function assertionShape(statement, context) {
|
|
12837
|
-
if (statement.type !==
|
|
12927
|
+
if (statement.type !== AST_NODE_TYPES51.ExpressionStatement || statement.expression.type !== AST_NODE_TYPES51.CallExpression) return null;
|
|
12838
12928
|
const matcherCall = statement.expression;
|
|
12839
|
-
if (matcherCall.callee.type !==
|
|
12929
|
+
if (matcherCall.callee.type !== AST_NODE_TYPES51.MemberExpression || matcherCall.callee.computed || matcherCall.callee.property.type !== AST_NODE_TYPES51.Identifier || matcherCall.arguments.length !== 1) return null;
|
|
12840
12930
|
const matcher = matcherCall.callee.property.name;
|
|
12841
12931
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
12842
12932
|
const chain = expectCallFromMatcher(matcherCall.callee);
|
|
12843
|
-
if (chain === null || chain.call.callee.type !==
|
|
12933
|
+
if (chain === null || chain.call.callee.type !== AST_NODE_TYPES51.Identifier || importedName3(chain.call.callee, context, ASSERTION_MODULES3) !== "expect" || chain.call.arguments.length !== 1) return null;
|
|
12844
12934
|
const observed = chain.call.arguments[0];
|
|
12845
12935
|
const expected = matcherCall.arguments[0];
|
|
12846
|
-
if (observed?.type !==
|
|
12936
|
+
if (observed?.type !== AST_NODE_TYPES51.CallExpression || observed.callee.type !== AST_NODE_TYPES51.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === AST_NODE_TYPES51.SpreadElement || !isStatic(arg)) || expected?.type === AST_NODE_TYPES51.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
12847
12937
|
const skeleton = `${observed.callee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
12848
12938
|
const values = [...observed.arguments, expected].map((item) => context.sourceCode.getText(item)).join("\0");
|
|
12849
12939
|
return { statement, skeleton, values };
|
|
@@ -12851,13 +12941,13 @@ function assertionShape(statement, context) {
|
|
|
12851
12941
|
function expectCallFromMatcher(node) {
|
|
12852
12942
|
const modifiers = [];
|
|
12853
12943
|
let receiver = node.object;
|
|
12854
|
-
while (receiver.type ===
|
|
12944
|
+
while (receiver.type === AST_NODE_TYPES51.MemberExpression) {
|
|
12855
12945
|
const modifier = staticMemberName5(receiver);
|
|
12856
12946
|
if (modifier === null || !EXPECT_MODIFIERS.has(modifier)) return null;
|
|
12857
12947
|
modifiers.unshift(modifier);
|
|
12858
12948
|
receiver = receiver.object;
|
|
12859
12949
|
}
|
|
12860
|
-
return receiver.type ===
|
|
12950
|
+
return receiver.type === AST_NODE_TYPES51.CallExpression ? { call: receiver, modifiers } : null;
|
|
12861
12951
|
}
|
|
12862
12952
|
var repeated_static_call_cases_default = createRule({
|
|
12863
12953
|
name: "repeated-static-call-cases",
|
|
@@ -12877,7 +12967,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
12877
12967
|
return {
|
|
12878
12968
|
"CallExpression > ArrowFunctionExpression, CallExpression > FunctionExpression"(node) {
|
|
12879
12969
|
const call = node.parent;
|
|
12880
|
-
if (call?.type ===
|
|
12970
|
+
if (call?.type === AST_NODE_TYPES51.CallExpression) {
|
|
12881
12971
|
const duplicate = duplicateTestBodyCandidate(call, sourceCode);
|
|
12882
12972
|
if (duplicate !== null && duplicate.body === node) {
|
|
12883
12973
|
const groups = duplicateGroups.get(duplicate.container) ?? /* @__PURE__ */ new Map();
|
|
@@ -12887,7 +12977,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
12887
12977
|
duplicateGroups.set(duplicate.container, groups);
|
|
12888
12978
|
}
|
|
12889
12979
|
}
|
|
12890
|
-
if (!isDirectTestCallback2(node, context) || node.body.type !==
|
|
12980
|
+
if (!isDirectTestCallback2(node, context) || node.body.type !== AST_NODE_TYPES51.BlockStatement) return;
|
|
12891
12981
|
let run = [];
|
|
12892
12982
|
const flush = () => {
|
|
12893
12983
|
if (run.length >= MIN_CASES2 && new Set(run.map((item) => item.values)).size > 1) {
|
|
@@ -12928,7 +13018,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
12928
13018
|
});
|
|
12929
13019
|
|
|
12930
13020
|
// src/rules/prefer-zod-infer.ts
|
|
12931
|
-
import { AST_NODE_TYPES as
|
|
13021
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52 } from "@typescript-eslint/utils";
|
|
12932
13022
|
var preferZodInferDocumentation = {
|
|
12933
13023
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
12934
13024
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -12981,47 +13071,47 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
12981
13071
|
"Schema"
|
|
12982
13072
|
]);
|
|
12983
13073
|
var LEAF_NODE_TYPES = {
|
|
12984
|
-
string: [
|
|
12985
|
-
email: [
|
|
12986
|
-
url: [
|
|
12987
|
-
uuid: [
|
|
12988
|
-
ulid: [
|
|
12989
|
-
cuid: [
|
|
12990
|
-
cuid2: [
|
|
12991
|
-
nanoid: [
|
|
12992
|
-
iso: [
|
|
12993
|
-
number: [
|
|
12994
|
-
int: [
|
|
12995
|
-
float32: [
|
|
12996
|
-
float64: [
|
|
12997
|
-
boolean: [
|
|
12998
|
-
bigint: [
|
|
12999
|
-
symbol: [
|
|
13000
|
-
any: [
|
|
13001
|
-
unknown: [
|
|
13002
|
-
never: [
|
|
13003
|
-
void: [
|
|
13004
|
-
null: [
|
|
13005
|
-
undefined: [
|
|
13006
|
-
literal: [
|
|
13007
|
-
date: [
|
|
13008
|
-
array: [
|
|
13009
|
-
tuple: [
|
|
13010
|
-
object: [
|
|
13011
|
-
strictObject: [
|
|
13012
|
-
looseObject: [
|
|
13013
|
-
record: [
|
|
13014
|
-
map: [
|
|
13015
|
-
set: [
|
|
13016
|
-
promise: [
|
|
13017
|
-
enum: [
|
|
13018
|
-
nativeEnum: [
|
|
13019
|
-
union: [
|
|
13020
|
-
discriminatedUnion: [
|
|
13021
|
-
intersection: [
|
|
13074
|
+
string: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13075
|
+
email: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13076
|
+
url: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13077
|
+
uuid: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13078
|
+
ulid: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13079
|
+
cuid: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13080
|
+
cuid2: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13081
|
+
nanoid: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13082
|
+
iso: [AST_NODE_TYPES52.TSStringKeyword],
|
|
13083
|
+
number: [AST_NODE_TYPES52.TSNumberKeyword],
|
|
13084
|
+
int: [AST_NODE_TYPES52.TSNumberKeyword],
|
|
13085
|
+
float32: [AST_NODE_TYPES52.TSNumberKeyword],
|
|
13086
|
+
float64: [AST_NODE_TYPES52.TSNumberKeyword],
|
|
13087
|
+
boolean: [AST_NODE_TYPES52.TSBooleanKeyword],
|
|
13088
|
+
bigint: [AST_NODE_TYPES52.TSBigIntKeyword],
|
|
13089
|
+
symbol: [AST_NODE_TYPES52.TSSymbolKeyword],
|
|
13090
|
+
any: [AST_NODE_TYPES52.TSAnyKeyword],
|
|
13091
|
+
unknown: [AST_NODE_TYPES52.TSUnknownKeyword],
|
|
13092
|
+
never: [AST_NODE_TYPES52.TSNeverKeyword],
|
|
13093
|
+
void: [AST_NODE_TYPES52.TSVoidKeyword],
|
|
13094
|
+
null: [AST_NODE_TYPES52.TSNullKeyword],
|
|
13095
|
+
undefined: [AST_NODE_TYPES52.TSUndefinedKeyword],
|
|
13096
|
+
literal: [AST_NODE_TYPES52.TSLiteralType],
|
|
13097
|
+
date: [AST_NODE_TYPES52.TSTypeReference],
|
|
13098
|
+
array: [AST_NODE_TYPES52.TSArrayType, AST_NODE_TYPES52.TSTypeReference],
|
|
13099
|
+
tuple: [AST_NODE_TYPES52.TSTupleType],
|
|
13100
|
+
object: [AST_NODE_TYPES52.TSTypeLiteral, AST_NODE_TYPES52.TSTypeReference],
|
|
13101
|
+
strictObject: [AST_NODE_TYPES52.TSTypeLiteral, AST_NODE_TYPES52.TSTypeReference],
|
|
13102
|
+
looseObject: [AST_NODE_TYPES52.TSTypeLiteral, AST_NODE_TYPES52.TSTypeReference],
|
|
13103
|
+
record: [AST_NODE_TYPES52.TSTypeReference, AST_NODE_TYPES52.TSTypeLiteral],
|
|
13104
|
+
map: [AST_NODE_TYPES52.TSTypeReference],
|
|
13105
|
+
set: [AST_NODE_TYPES52.TSTypeReference],
|
|
13106
|
+
promise: [AST_NODE_TYPES52.TSTypeReference],
|
|
13107
|
+
enum: [AST_NODE_TYPES52.TSUnionType, AST_NODE_TYPES52.TSTypeReference, AST_NODE_TYPES52.TSLiteralType],
|
|
13108
|
+
nativeEnum: [AST_NODE_TYPES52.TSUnionType, AST_NODE_TYPES52.TSTypeReference, AST_NODE_TYPES52.TSLiteralType],
|
|
13109
|
+
union: [AST_NODE_TYPES52.TSUnionType, AST_NODE_TYPES52.TSTypeReference],
|
|
13110
|
+
discriminatedUnion: [AST_NODE_TYPES52.TSUnionType, AST_NODE_TYPES52.TSTypeReference],
|
|
13111
|
+
intersection: [AST_NODE_TYPES52.TSIntersectionType, AST_NODE_TYPES52.TSTypeReference]
|
|
13022
13112
|
};
|
|
13023
13113
|
function primitiveLiteralKey(node) {
|
|
13024
|
-
if (node.type !==
|
|
13114
|
+
if (node.type !== AST_NODE_TYPES52.Literal) {
|
|
13025
13115
|
return null;
|
|
13026
13116
|
}
|
|
13027
13117
|
if (node.value === null) {
|
|
@@ -13053,13 +13143,13 @@ function staticZodDomain(leaf, call) {
|
|
|
13053
13143
|
}
|
|
13054
13144
|
if (leaf === "literal") {
|
|
13055
13145
|
const [argument] = call.arguments;
|
|
13056
|
-
if (argument === void 0 || argument.type ===
|
|
13146
|
+
if (argument === void 0 || argument.type === AST_NODE_TYPES52.SpreadElement) {
|
|
13057
13147
|
return null;
|
|
13058
13148
|
}
|
|
13059
|
-
if (argument.type ===
|
|
13149
|
+
if (argument.type === AST_NODE_TYPES52.ArrayExpression) {
|
|
13060
13150
|
return exactDomain(
|
|
13061
13151
|
argument.elements.map(
|
|
13062
|
-
(element) => element === null || element.type ===
|
|
13152
|
+
(element) => element === null || element.type === AST_NODE_TYPES52.SpreadElement ? null : primitiveLiteralKey(element)
|
|
13063
13153
|
)
|
|
13064
13154
|
);
|
|
13065
13155
|
}
|
|
@@ -13067,13 +13157,13 @@ function staticZodDomain(leaf, call) {
|
|
|
13067
13157
|
}
|
|
13068
13158
|
if (leaf === "enum") {
|
|
13069
13159
|
const [argument] = call.arguments;
|
|
13070
|
-
if (argument === void 0 || argument.type ===
|
|
13160
|
+
if (argument === void 0 || argument.type === AST_NODE_TYPES52.SpreadElement) {
|
|
13071
13161
|
return null;
|
|
13072
13162
|
}
|
|
13073
|
-
if (argument.type ===
|
|
13163
|
+
if (argument.type === AST_NODE_TYPES52.ArrayExpression) {
|
|
13074
13164
|
return exactDomain(
|
|
13075
13165
|
argument.elements.map((element) => {
|
|
13076
|
-
if (element === null || element.type ===
|
|
13166
|
+
if (element === null || element.type === AST_NODE_TYPES52.SpreadElement) {
|
|
13077
13167
|
return null;
|
|
13078
13168
|
}
|
|
13079
13169
|
const key = primitiveLiteralKey(element);
|
|
@@ -13081,10 +13171,10 @@ function staticZodDomain(leaf, call) {
|
|
|
13081
13171
|
})
|
|
13082
13172
|
);
|
|
13083
13173
|
}
|
|
13084
|
-
if (argument.type ===
|
|
13174
|
+
if (argument.type === AST_NODE_TYPES52.ObjectExpression) {
|
|
13085
13175
|
return exactDomain(
|
|
13086
13176
|
argument.properties.map((property) => {
|
|
13087
|
-
if (property.type !==
|
|
13177
|
+
if (property.type !== AST_NODE_TYPES52.Property || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
13088
13178
|
return null;
|
|
13089
13179
|
}
|
|
13090
13180
|
const key = primitiveLiteralKey(property.value);
|
|
@@ -13111,15 +13201,15 @@ function sameDomain(left, right) {
|
|
|
13111
13201
|
return true;
|
|
13112
13202
|
}
|
|
13113
13203
|
function isExportedDeclaration(node) {
|
|
13114
|
-
return node.parent?.type ===
|
|
13204
|
+
return node.parent?.type === AST_NODE_TYPES52.ExportNamedDeclaration;
|
|
13115
13205
|
}
|
|
13116
13206
|
function isModuleLevelConst(node) {
|
|
13117
13207
|
const declaration = node.parent;
|
|
13118
|
-
if (declaration.type !==
|
|
13208
|
+
if (declaration.type !== AST_NODE_TYPES52.VariableDeclaration || declaration.kind !== "const") {
|
|
13119
13209
|
return false;
|
|
13120
13210
|
}
|
|
13121
13211
|
const container = declaration.parent;
|
|
13122
|
-
return container.type ===
|
|
13212
|
+
return container.type === AST_NODE_TYPES52.Program || container.type === AST_NODE_TYPES52.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES52.Program;
|
|
13123
13213
|
}
|
|
13124
13214
|
function normalizeSchemaName(name) {
|
|
13125
13215
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -13128,20 +13218,20 @@ function normalizeTypeName(name) {
|
|
|
13128
13218
|
return name.replace(/Type$/, "").toLowerCase();
|
|
13129
13219
|
}
|
|
13130
13220
|
function unwrapNullish(annotation) {
|
|
13131
|
-
if (annotation.type !==
|
|
13221
|
+
if (annotation.type !== AST_NODE_TYPES52.TSUnionType) {
|
|
13132
13222
|
return {
|
|
13133
13223
|
core: annotation,
|
|
13134
|
-
nullable: annotation.type ===
|
|
13224
|
+
nullable: annotation.type === AST_NODE_TYPES52.TSNullKeyword
|
|
13135
13225
|
};
|
|
13136
13226
|
}
|
|
13137
13227
|
const rest = [];
|
|
13138
13228
|
let nullable = false;
|
|
13139
13229
|
for (const member of annotation.types) {
|
|
13140
|
-
if (member.type ===
|
|
13230
|
+
if (member.type === AST_NODE_TYPES52.TSNullKeyword) {
|
|
13141
13231
|
nullable = true;
|
|
13142
13232
|
continue;
|
|
13143
13233
|
}
|
|
13144
|
-
if (member.type ===
|
|
13234
|
+
if (member.type === AST_NODE_TYPES52.TSUndefinedKeyword) {
|
|
13145
13235
|
continue;
|
|
13146
13236
|
}
|
|
13147
13237
|
rest.push(member);
|
|
@@ -13175,18 +13265,18 @@ function leafAgrees(field, annotation) {
|
|
|
13175
13265
|
return null;
|
|
13176
13266
|
}
|
|
13177
13267
|
if (leaf === "date") {
|
|
13178
|
-
return core.type ===
|
|
13268
|
+
return core.type === AST_NODE_TYPES52.TSTypeReference && core.typeName.type === AST_NODE_TYPES52.Identifier && core.typeName.name === "Date";
|
|
13179
13269
|
}
|
|
13180
13270
|
return expected.includes(core.type);
|
|
13181
13271
|
}
|
|
13182
13272
|
function typeLiteralDomain(annotation) {
|
|
13183
|
-
const members = annotation.type ===
|
|
13273
|
+
const members = annotation.type === AST_NODE_TYPES52.TSUnionType ? annotation.types : [annotation];
|
|
13184
13274
|
const keys = [];
|
|
13185
13275
|
for (const member of members) {
|
|
13186
|
-
if (member.type ===
|
|
13276
|
+
if (member.type === AST_NODE_TYPES52.TSNullKeyword) {
|
|
13187
13277
|
continue;
|
|
13188
13278
|
}
|
|
13189
|
-
if (member.type !==
|
|
13279
|
+
if (member.type !== AST_NODE_TYPES52.TSLiteralType) {
|
|
13190
13280
|
return null;
|
|
13191
13281
|
}
|
|
13192
13282
|
keys.push(primitiveLiteralKey(member.literal));
|
|
@@ -13194,11 +13284,11 @@ function typeLiteralDomain(annotation) {
|
|
|
13194
13284
|
return exactDomain(keys);
|
|
13195
13285
|
}
|
|
13196
13286
|
function staticStringUnionDomain(node) {
|
|
13197
|
-
if (node.type !==
|
|
13287
|
+
if (node.type !== AST_NODE_TYPES52.TSUnionType) {
|
|
13198
13288
|
return null;
|
|
13199
13289
|
}
|
|
13200
13290
|
const keys = node.types.map((member) => {
|
|
13201
|
-
if (member.type !==
|
|
13291
|
+
if (member.type !== AST_NODE_TYPES52.TSLiteralType) {
|
|
13202
13292
|
return null;
|
|
13203
13293
|
}
|
|
13204
13294
|
const key = primitiveLiteralKey(member.literal);
|
|
@@ -13266,14 +13356,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
13266
13356
|
function zodCallChain(node) {
|
|
13267
13357
|
const chain = [];
|
|
13268
13358
|
let current = node;
|
|
13269
|
-
while (current.type ===
|
|
13359
|
+
while (current.type === AST_NODE_TYPES52.CallExpression) {
|
|
13270
13360
|
const callee = current.callee;
|
|
13271
|
-
if (callee.type !==
|
|
13361
|
+
if (callee.type !== AST_NODE_TYPES52.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES52.Identifier) {
|
|
13272
13362
|
return null;
|
|
13273
13363
|
}
|
|
13274
13364
|
chain.push(current);
|
|
13275
13365
|
const receiver = callee.object;
|
|
13276
|
-
if (receiver.type ===
|
|
13366
|
+
if (receiver.type === AST_NODE_TYPES52.Identifier) {
|
|
13277
13367
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
13278
13368
|
}
|
|
13279
13369
|
current = receiver;
|
|
@@ -13282,14 +13372,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
13282
13372
|
}
|
|
13283
13373
|
function methodName2(call) {
|
|
13284
13374
|
const callee = call.callee;
|
|
13285
|
-
return callee.type ===
|
|
13375
|
+
return callee.type === AST_NODE_TYPES52.MemberExpression && callee.property.type === AST_NODE_TYPES52.Identifier ? callee.property.name : "";
|
|
13286
13376
|
}
|
|
13287
13377
|
function recordZodImport(node) {
|
|
13288
13378
|
if (!isZodModule(node.source.value)) {
|
|
13289
13379
|
return;
|
|
13290
13380
|
}
|
|
13291
13381
|
for (const specifier of node.specifiers) {
|
|
13292
|
-
if (specifier.type ===
|
|
13382
|
+
if (specifier.type === AST_NODE_TYPES52.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES52.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES52.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES52.Identifier && specifier.imported.name === "z") {
|
|
13293
13383
|
zodNamespaces.add(specifier.local.name);
|
|
13294
13384
|
}
|
|
13295
13385
|
}
|
|
@@ -13299,13 +13389,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
13299
13389
|
let current = node;
|
|
13300
13390
|
let leaf = null;
|
|
13301
13391
|
let leafCall = null;
|
|
13302
|
-
while (current.type ===
|
|
13392
|
+
while (current.type === AST_NODE_TYPES52.CallExpression) {
|
|
13303
13393
|
const callee = current.callee;
|
|
13304
|
-
if (callee.type !==
|
|
13394
|
+
if (callee.type !== AST_NODE_TYPES52.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES52.Identifier) {
|
|
13305
13395
|
break;
|
|
13306
13396
|
}
|
|
13307
13397
|
const receiver = callee.object;
|
|
13308
|
-
if (receiver.type ===
|
|
13398
|
+
if (receiver.type === AST_NODE_TYPES52.Identifier && zodNamespaces.has(receiver.name)) {
|
|
13309
13399
|
leaf = callee.property.name;
|
|
13310
13400
|
leafCall = current;
|
|
13311
13401
|
break;
|
|
@@ -13336,20 +13426,20 @@ var prefer_zod_infer_default = createRule({
|
|
|
13336
13426
|
return domain instanceof Set && domain.size >= 2 ? domain : null;
|
|
13337
13427
|
}
|
|
13338
13428
|
function inferredSchemaName(node) {
|
|
13339
|
-
if (node.type !==
|
|
13429
|
+
if (node.type !== AST_NODE_TYPES52.TSTypeReference || node.typeName.type !== AST_NODE_TYPES52.TSQualifiedName || node.typeName.left.type !== AST_NODE_TYPES52.Identifier || !zodNamespaces.has(node.typeName.left.name) || node.typeName.right.name !== "infer") {
|
|
13340
13430
|
return null;
|
|
13341
13431
|
}
|
|
13342
13432
|
const arguments_ = node.typeArguments?.params ?? [];
|
|
13343
13433
|
const [argument] = arguments_;
|
|
13344
|
-
return arguments_.length === 1 && argument?.type ===
|
|
13434
|
+
return arguments_.length === 1 && argument?.type === AST_NODE_TYPES52.TSTypeQuery && argument.exprName.type === AST_NODE_TYPES52.Identifier ? argument.exprName.name : null;
|
|
13345
13435
|
}
|
|
13346
13436
|
function recordLiteralUnions(members, owner, ownerName, exported) {
|
|
13347
13437
|
for (const member of members) {
|
|
13348
|
-
if (member.type !==
|
|
13438
|
+
if (member.type !== AST_NODE_TYPES52.TSPropertySignature || member.computed || member.optional || member.readonly || member.typeAnnotation === void 0) {
|
|
13349
13439
|
continue;
|
|
13350
13440
|
}
|
|
13351
13441
|
const key = member.key;
|
|
13352
|
-
const propertyName3 = key.type ===
|
|
13442
|
+
const propertyName3 = key.type === AST_NODE_TYPES52.Identifier ? key.name : key.type === AST_NODE_TYPES52.Literal && typeof key.value === "string" ? key.value : null;
|
|
13353
13443
|
if (propertyName3 === null) {
|
|
13354
13444
|
continue;
|
|
13355
13445
|
}
|
|
@@ -13359,7 +13449,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13359
13449
|
}
|
|
13360
13450
|
const annotation = member.typeAnnotation.typeAnnotation;
|
|
13361
13451
|
const domain = staticStringUnionDomain(annotation);
|
|
13362
|
-
if (domain === null || annotation.type !==
|
|
13452
|
+
if (domain === null || annotation.type !== AST_NODE_TYPES52.TSUnionType) {
|
|
13363
13453
|
continue;
|
|
13364
13454
|
}
|
|
13365
13455
|
literalUnionOccurrences.push({
|
|
@@ -13390,16 +13480,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
13390
13480
|
return null;
|
|
13391
13481
|
}
|
|
13392
13482
|
const shape = base.arguments[0];
|
|
13393
|
-
if (shape === void 0 || shape.type !==
|
|
13483
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES52.ObjectExpression) {
|
|
13394
13484
|
return null;
|
|
13395
13485
|
}
|
|
13396
13486
|
const fields = /* @__PURE__ */ new Map();
|
|
13397
13487
|
for (const property of shape.properties) {
|
|
13398
|
-
if (property.type !==
|
|
13488
|
+
if (property.type !== AST_NODE_TYPES52.Property || property.computed) {
|
|
13399
13489
|
return null;
|
|
13400
13490
|
}
|
|
13401
13491
|
const { key } = property;
|
|
13402
|
-
const name = key.type ===
|
|
13492
|
+
const name = key.type === AST_NODE_TYPES52.Identifier ? key.name : key.type === AST_NODE_TYPES52.Literal && typeof key.value === "string" ? key.value : null;
|
|
13403
13493
|
if (name === null) {
|
|
13404
13494
|
return null;
|
|
13405
13495
|
}
|
|
@@ -13410,11 +13500,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
13410
13500
|
function typeMembers(members) {
|
|
13411
13501
|
const result = /* @__PURE__ */ new Map();
|
|
13412
13502
|
for (const member of members) {
|
|
13413
|
-
if (member.type !==
|
|
13503
|
+
if (member.type !== AST_NODE_TYPES52.TSPropertySignature || member.computed) {
|
|
13414
13504
|
return null;
|
|
13415
13505
|
}
|
|
13416
13506
|
const { key } = member;
|
|
13417
|
-
const name = key.type ===
|
|
13507
|
+
const name = key.type === AST_NODE_TYPES52.Identifier ? key.name : key.type === AST_NODE_TYPES52.Literal && typeof key.value === "string" ? key.value : null;
|
|
13418
13508
|
if (name === null) {
|
|
13419
13509
|
return null;
|
|
13420
13510
|
}
|
|
@@ -13429,8 +13519,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
13429
13519
|
return result.size === 0 ? null : result;
|
|
13430
13520
|
}
|
|
13431
13521
|
function collectConstrainedNames(node) {
|
|
13432
|
-
if (node.type ===
|
|
13433
|
-
if (node.typeName.type ===
|
|
13522
|
+
if (node.type === AST_NODE_TYPES52.TSTypeReference) {
|
|
13523
|
+
if (node.typeName.type === AST_NODE_TYPES52.Identifier) {
|
|
13434
13524
|
constrainedTypeNames.add(node.typeName.name);
|
|
13435
13525
|
}
|
|
13436
13526
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -13438,11 +13528,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
13438
13528
|
}
|
|
13439
13529
|
return;
|
|
13440
13530
|
}
|
|
13441
|
-
if (node.type ===
|
|
13531
|
+
if (node.type === AST_NODE_TYPES52.TSArrayType) {
|
|
13442
13532
|
collectConstrainedNames(node.elementType);
|
|
13443
13533
|
return;
|
|
13444
13534
|
}
|
|
13445
|
-
if (node.type ===
|
|
13535
|
+
if (node.type === AST_NODE_TYPES52.TSUnionType || node.type === AST_NODE_TYPES52.TSIntersectionType) {
|
|
13446
13536
|
for (const member of node.types) {
|
|
13447
13537
|
collectConstrainedNames(member);
|
|
13448
13538
|
}
|
|
@@ -13486,7 +13576,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13486
13576
|
return {
|
|
13487
13577
|
Program(node) {
|
|
13488
13578
|
for (const statement of node.body) {
|
|
13489
|
-
if (statement.type ===
|
|
13579
|
+
if (statement.type === AST_NODE_TYPES52.ImportDeclaration) {
|
|
13490
13580
|
recordZodImport(statement);
|
|
13491
13581
|
}
|
|
13492
13582
|
}
|
|
@@ -13495,7 +13585,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13495
13585
|
recordZodImport(node);
|
|
13496
13586
|
},
|
|
13497
13587
|
VariableDeclarator(node) {
|
|
13498
|
-
if (node.id.type !==
|
|
13588
|
+
if (node.id.type !== AST_NODE_TYPES52.Identifier || node.init == null) {
|
|
13499
13589
|
return;
|
|
13500
13590
|
}
|
|
13501
13591
|
const fields = schemaFields(node.init);
|
|
@@ -13512,14 +13602,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
13512
13602
|
},
|
|
13513
13603
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
13514
13604
|
"MemberExpression[computed=false]"(node) {
|
|
13515
|
-
if (node.object.type ===
|
|
13605
|
+
if (node.object.type === AST_NODE_TYPES52.Identifier && node.property.type === AST_NODE_TYPES52.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
13516
13606
|
reshapedSchemaNames.add(node.object.name);
|
|
13517
13607
|
}
|
|
13518
13608
|
},
|
|
13519
13609
|
/** Records every type argument carried by a Zod constraint. */
|
|
13520
13610
|
TSTypeReference(node) {
|
|
13521
13611
|
const { typeName } = node;
|
|
13522
|
-
const referenced = typeName.type ===
|
|
13612
|
+
const referenced = typeName.type === AST_NODE_TYPES52.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES52.TSQualifiedName && typeName.right.type === AST_NODE_TYPES52.Identifier ? typeName.right.name : null;
|
|
13523
13613
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
13524
13614
|
return;
|
|
13525
13615
|
}
|
|
@@ -13551,7 +13641,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13551
13641
|
typeName: node.id.name
|
|
13552
13642
|
});
|
|
13553
13643
|
}
|
|
13554
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
13644
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES52.TSTypeLiteral) {
|
|
13555
13645
|
return;
|
|
13556
13646
|
}
|
|
13557
13647
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -13652,7 +13742,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
13652
13742
|
// src/rules/require-assert-never.ts
|
|
13653
13743
|
import {
|
|
13654
13744
|
ESLintUtils as ESLintUtils4,
|
|
13655
|
-
AST_NODE_TYPES as
|
|
13745
|
+
AST_NODE_TYPES as AST_NODE_TYPES53
|
|
13656
13746
|
} from "@typescript-eslint/utils";
|
|
13657
13747
|
import ts3 from "typescript";
|
|
13658
13748
|
var requireAssertNeverDocumentation = {
|
|
@@ -13666,14 +13756,14 @@ var requireAssertNeverDocumentation = {
|
|
|
13666
13756
|
]
|
|
13667
13757
|
};
|
|
13668
13758
|
var isRuntimeHandlingStatement = (statement) => {
|
|
13669
|
-
if (statement.type ===
|
|
13670
|
-
if (statement.type ===
|
|
13759
|
+
if (statement.type === AST_NODE_TYPES53.EmptyStatement) return false;
|
|
13760
|
+
if (statement.type === AST_NODE_TYPES53.BreakStatement) {
|
|
13671
13761
|
return statement.label !== null;
|
|
13672
13762
|
}
|
|
13673
|
-
if (statement.type ===
|
|
13763
|
+
if (statement.type === AST_NODE_TYPES53.TSTypeAliasDeclaration || statement.type === AST_NODE_TYPES53.TSInterfaceDeclaration) {
|
|
13674
13764
|
return false;
|
|
13675
13765
|
}
|
|
13676
|
-
if (statement.type ===
|
|
13766
|
+
if (statement.type === AST_NODE_TYPES53.BlockStatement) {
|
|
13677
13767
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
13678
13768
|
}
|
|
13679
13769
|
return true;
|
|
@@ -13689,7 +13779,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
13689
13779
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
13690
13780
|
}
|
|
13691
13781
|
const only = defaultCase.consequent[0];
|
|
13692
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
13782
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES53.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
13693
13783
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
13694
13784
|
}
|
|
13695
13785
|
return false;
|
|
@@ -13772,7 +13862,7 @@ var require_assert_never_default = createRule({
|
|
|
13772
13862
|
});
|
|
13773
13863
|
|
|
13774
13864
|
// src/rules/require-fetch-timeout.ts
|
|
13775
|
-
import { AST_NODE_TYPES as
|
|
13865
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54, ASTUtils as ASTUtils16 } from "@typescript-eslint/utils";
|
|
13776
13866
|
var requireFetchTimeoutDocumentation = {
|
|
13777
13867
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
13778
13868
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -13798,14 +13888,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
13798
13888
|
return false;
|
|
13799
13889
|
}
|
|
13800
13890
|
function initProvablyLacksSignal(init) {
|
|
13801
|
-
if (init.type !==
|
|
13891
|
+
if (init.type !== AST_NODE_TYPES54.ObjectExpression) {
|
|
13802
13892
|
return false;
|
|
13803
13893
|
}
|
|
13804
13894
|
for (const prop of init.properties) {
|
|
13805
|
-
if (prop.type ===
|
|
13895
|
+
if (prop.type === AST_NODE_TYPES54.SpreadElement) {
|
|
13806
13896
|
return false;
|
|
13807
13897
|
}
|
|
13808
|
-
if (prop.key.type ===
|
|
13898
|
+
if (prop.key.type === AST_NODE_TYPES54.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES54.Literal && prop.key.value === "signal") {
|
|
13809
13899
|
return false;
|
|
13810
13900
|
}
|
|
13811
13901
|
if (prop.computed) {
|
|
@@ -13815,7 +13905,7 @@ function initProvablyLacksSignal(init) {
|
|
|
13815
13905
|
return true;
|
|
13816
13906
|
}
|
|
13817
13907
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
13818
|
-
return node.type ===
|
|
13908
|
+
return node.type === AST_NODE_TYPES54.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES54.TemplateLiteral || node.type === AST_NODE_TYPES54.NewExpression && node.callee.type === AST_NODE_TYPES54.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
13819
13909
|
}
|
|
13820
13910
|
var require_fetch_timeout_default = createRule({
|
|
13821
13911
|
name: "require-fetch-timeout",
|
|
@@ -13857,10 +13947,10 @@ var require_fetch_timeout_default = createRule({
|
|
|
13857
13947
|
return variable === null || variable.defs.length === 0;
|
|
13858
13948
|
}
|
|
13859
13949
|
function isGlobalFetchCall2(callee) {
|
|
13860
|
-
if (callee.type ===
|
|
13950
|
+
if (callee.type === AST_NODE_TYPES54.Identifier) {
|
|
13861
13951
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
13862
13952
|
}
|
|
13863
|
-
return callee.type ===
|
|
13953
|
+
return callee.type === AST_NODE_TYPES54.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES54.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES54.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
13864
13954
|
}
|
|
13865
13955
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
13866
13956
|
const variable = ASTUtils16.findVariable(
|
|
@@ -13869,14 +13959,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
13869
13959
|
);
|
|
13870
13960
|
if (variable?.defs.length !== 1) return false;
|
|
13871
13961
|
const definition = variable.defs[0];
|
|
13872
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
13962
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== AST_NODE_TYPES54.ObjectExpression || !initProvablyLacksSignal(definition.node.init)) {
|
|
13873
13963
|
return false;
|
|
13874
13964
|
}
|
|
13875
13965
|
for (const reference of variable.references) {
|
|
13876
13966
|
const ref = reference.identifier;
|
|
13877
13967
|
if (ref === identifier || ref === definition.name) continue;
|
|
13878
13968
|
const member = ref.parent;
|
|
13879
|
-
if (member.type !==
|
|
13969
|
+
if (member.type !== AST_NODE_TYPES54.MemberExpression || member.object !== ref || member.computed || member.property.type !== AST_NODE_TYPES54.Identifier || member.property.name === "signal" || member.parent.type !== AST_NODE_TYPES54.AssignmentExpression || member.parent.left !== member) {
|
|
13880
13970
|
return false;
|
|
13881
13971
|
}
|
|
13882
13972
|
}
|
|
@@ -13891,7 +13981,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
13891
13981
|
if (node.arguments.length === 1 && first !== void 0 && !isInlineUrl(first, resolvesToGlobal)) {
|
|
13892
13982
|
return;
|
|
13893
13983
|
}
|
|
13894
|
-
if (init === void 0 || initProvablyLacksSignal(init) || init.type ===
|
|
13984
|
+
if (init === void 0 || initProvablyLacksSignal(init) || init.type === AST_NODE_TYPES54.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
13895
13985
|
context.report({ node, messageId: "missingSignal" });
|
|
13896
13986
|
}
|
|
13897
13987
|
}
|
|
@@ -13900,7 +13990,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
13900
13990
|
});
|
|
13901
13991
|
|
|
13902
13992
|
// src/rules/require-port-for-service.ts
|
|
13903
|
-
import { AST_NODE_TYPES as
|
|
13993
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES55 } from "@typescript-eslint/utils";
|
|
13904
13994
|
var requirePortForServiceDocumentation = {
|
|
13905
13995
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
13906
13996
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -13925,45 +14015,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
13925
14015
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
13926
14016
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
13927
14017
|
var staticMemberName6 = (member) => {
|
|
13928
|
-
if (member.property.type ===
|
|
13929
|
-
if (!member.computed && member.property.type ===
|
|
13930
|
-
return member.computed && member.property.type ===
|
|
14018
|
+
if (member.property.type === AST_NODE_TYPES55.PrivateIdentifier) return `#${member.property.name}`;
|
|
14019
|
+
if (!member.computed && member.property.type === AST_NODE_TYPES55.Identifier) return member.property.name;
|
|
14020
|
+
return member.computed && member.property.type === AST_NODE_TYPES55.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
13931
14021
|
};
|
|
13932
14022
|
var detachedValueExports = (program) => {
|
|
13933
14023
|
const names = /* @__PURE__ */ new Set();
|
|
13934
14024
|
for (const statement of program.body) {
|
|
13935
|
-
if (statement.type ===
|
|
14025
|
+
if (statement.type === AST_NODE_TYPES55.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
13936
14026
|
for (const specifier of statement.specifiers) {
|
|
13937
14027
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
13938
14028
|
}
|
|
13939
|
-
} else if (statement.type ===
|
|
14029
|
+
} else if (statement.type === AST_NODE_TYPES55.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES55.Identifier) {
|
|
13940
14030
|
names.add(statement.declaration.name);
|
|
13941
|
-
} else if (statement.type ===
|
|
14031
|
+
} else if (statement.type === AST_NODE_TYPES55.TSExportAssignment && statement.expression.type === AST_NODE_TYPES55.Identifier) {
|
|
13942
14032
|
names.add(statement.expression.name);
|
|
13943
14033
|
}
|
|
13944
14034
|
}
|
|
13945
14035
|
return names;
|
|
13946
14036
|
};
|
|
13947
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
14037
|
+
var isExportedClass2 = (node, detached) => node.parent.type === AST_NODE_TYPES55.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES55.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
13948
14038
|
var readTypeReference = (annotation) => {
|
|
13949
|
-
if (annotation?.type ===
|
|
14039
|
+
if (annotation?.type === AST_NODE_TYPES55.TSUnionType) {
|
|
13950
14040
|
const members = annotation.types.filter(
|
|
13951
|
-
(member) => member.type !==
|
|
14041
|
+
(member) => member.type !== AST_NODE_TYPES55.TSUndefinedKeyword && member.type !== AST_NODE_TYPES55.TSNullKeyword
|
|
13952
14042
|
);
|
|
13953
14043
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
13954
14044
|
}
|
|
13955
|
-
if (annotation === void 0 || annotation.type !==
|
|
14045
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES55.TSTypeReference) return null;
|
|
13956
14046
|
const { typeName } = annotation;
|
|
13957
|
-
const rightmost = typeName.type ===
|
|
14047
|
+
const rightmost = typeName.type === AST_NODE_TYPES55.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES55.TSQualifiedName ? typeName.right.name : null;
|
|
13958
14048
|
if (rightmost === null) return null;
|
|
13959
14049
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
13960
14050
|
};
|
|
13961
|
-
var qualifiedName = (name) => name.type ===
|
|
14051
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES55.Identifier ? name.name : name.type === AST_NODE_TYPES55.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
13962
14052
|
var propertySignatureTypes = (members) => {
|
|
13963
14053
|
const types = /* @__PURE__ */ new Map();
|
|
13964
14054
|
for (const member of members) {
|
|
13965
|
-
if (member.type !==
|
|
13966
|
-
if (member.computed || member.key.type !==
|
|
14055
|
+
if (member.type !== AST_NODE_TYPES55.TSPropertySignature) continue;
|
|
14056
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES55.Identifier) continue;
|
|
13967
14057
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
13968
14058
|
if (reference === null) continue;
|
|
13969
14059
|
types.set(member.key.name, reference);
|
|
@@ -13974,18 +14064,18 @@ var fileTypeIndex = (program) => {
|
|
|
13974
14064
|
const objects = /* @__PURE__ */ new Map();
|
|
13975
14065
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
13976
14066
|
for (const statement of program.body) {
|
|
13977
|
-
const declaration = statement.type ===
|
|
13978
|
-
if (declaration?.type ===
|
|
14067
|
+
const declaration = statement.type === AST_NODE_TYPES55.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14068
|
+
if (declaration?.type === AST_NODE_TYPES55.TSInterfaceDeclaration) {
|
|
13979
14069
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
13980
14070
|
continue;
|
|
13981
14071
|
}
|
|
13982
|
-
if (declaration?.type !==
|
|
14072
|
+
if (declaration?.type !== AST_NODE_TYPES55.TSTypeAliasDeclaration) continue;
|
|
13983
14073
|
const aliased = declaration.typeAnnotation;
|
|
13984
|
-
if (aliased.type ===
|
|
14074
|
+
if (aliased.type === AST_NODE_TYPES55.TSFunctionType || aliased.type === AST_NODE_TYPES55.TSConstructorType) {
|
|
13985
14075
|
functionAliases.add(declaration.id.name);
|
|
13986
14076
|
continue;
|
|
13987
14077
|
}
|
|
13988
|
-
const literals = aliased.type ===
|
|
14078
|
+
const literals = aliased.type === AST_NODE_TYPES55.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES55.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES55.TSTypeLiteral) : [];
|
|
13989
14079
|
if (literals.length === 0) continue;
|
|
13990
14080
|
const merged = /* @__PURE__ */ new Map();
|
|
13991
14081
|
for (const literal of literals) {
|
|
@@ -14013,10 +14103,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14013
14103
|
while (pending.length > 0) {
|
|
14014
14104
|
const current = pending.pop();
|
|
14015
14105
|
if (current === void 0) break;
|
|
14016
|
-
if (current.type ===
|
|
14017
|
-
const expression = current.type ===
|
|
14018
|
-
const storedField = expression?.type ===
|
|
14019
|
-
if (expression?.type !==
|
|
14106
|
+
if (current.type === AST_NODE_TYPES55.ArrowFunctionExpression || current.type === AST_NODE_TYPES55.FunctionExpression || current.type === AST_NODE_TYPES55.FunctionDeclaration || current.type === AST_NODE_TYPES55.ClassExpression || current.type === AST_NODE_TYPES55.ClassDeclaration) continue;
|
|
14107
|
+
const expression = current.type === AST_NODE_TYPES55.ExpressionStatement ? current.expression : null;
|
|
14108
|
+
const storedField = expression?.type === AST_NODE_TYPES55.AssignmentExpression && expression.left.type === AST_NODE_TYPES55.MemberExpression && expression.left.object.type === AST_NODE_TYPES55.ThisExpression ? staticMemberName6(expression.left) : null;
|
|
14109
|
+
if (expression?.type !== AST_NODE_TYPES55.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== AST_NODE_TYPES55.MemberExpression || expression.left.object.type !== AST_NODE_TYPES55.ThisExpression || storedField === null) {
|
|
14020
14110
|
for (const key of Object.keys(current)) {
|
|
14021
14111
|
if (key === "parent") continue;
|
|
14022
14112
|
const value = current[key];
|
|
@@ -14029,14 +14119,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14029
14119
|
continue;
|
|
14030
14120
|
}
|
|
14031
14121
|
let source = expression.right;
|
|
14032
|
-
while (source.type ===
|
|
14033
|
-
if (source.type ===
|
|
14122
|
+
while (source.type === AST_NODE_TYPES55.TSNonNullExpression || source.type === AST_NODE_TYPES55.TSAsExpression || source.type === AST_NODE_TYPES55.TSSatisfiesExpression || source.type === AST_NODE_TYPES55.TSTypeAssertion) source = source.expression;
|
|
14123
|
+
if (source.type === AST_NODE_TYPES55.NewExpression) {
|
|
14034
14124
|
constructedFields += 1;
|
|
14035
|
-
} else if (source.type ===
|
|
14125
|
+
} else if (source.type === AST_NODE_TYPES55.Identifier) {
|
|
14036
14126
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
14037
14127
|
fields.add(storedField);
|
|
14038
14128
|
storedFieldsFrom.set(source.name, fields);
|
|
14039
|
-
} else if (source.type ===
|
|
14129
|
+
} else if (source.type === AST_NODE_TYPES55.MemberExpression && source.object.type === AST_NODE_TYPES55.Identifier) {
|
|
14040
14130
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
14041
14131
|
fields.add(storedField);
|
|
14042
14132
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -14046,7 +14136,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14046
14136
|
const collaborators = [];
|
|
14047
14137
|
for (const parameter of ctor.value.params) {
|
|
14048
14138
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
14049
|
-
const fields = parameter.type ===
|
|
14139
|
+
const fields = parameter.type === AST_NODE_TYPES55.TSParameterProperty ? [reference.name] : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
14050
14140
|
if (fields.length === 0) continue;
|
|
14051
14141
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
14052
14142
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -14061,8 +14151,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14061
14151
|
};
|
|
14062
14152
|
var parameterCollaborators = (parameter, declared) => {
|
|
14063
14153
|
let target = parameter;
|
|
14064
|
-
if (target.type ===
|
|
14065
|
-
if (target.type ===
|
|
14154
|
+
if (target.type === AST_NODE_TYPES55.AssignmentPattern) target = target.left;
|
|
14155
|
+
if (target.type === AST_NODE_TYPES55.ObjectPattern) {
|
|
14066
14156
|
return objectPatternCollaborators(target, declared);
|
|
14067
14157
|
}
|
|
14068
14158
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -14070,9 +14160,9 @@ var parameterCollaborators = (parameter, declared) => {
|
|
|
14070
14160
|
};
|
|
14071
14161
|
var namedParameterCollaborator = (annotated) => {
|
|
14072
14162
|
let target = annotated;
|
|
14073
|
-
if (target.type ===
|
|
14074
|
-
if (target.type ===
|
|
14075
|
-
if (target.type !==
|
|
14163
|
+
if (target.type === AST_NODE_TYPES55.TSParameterProperty) target = target.parameter;
|
|
14164
|
+
if (target.type === AST_NODE_TYPES55.AssignmentPattern) target = target.left;
|
|
14165
|
+
if (target.type !== AST_NODE_TYPES55.Identifier) return null;
|
|
14076
14166
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
14077
14167
|
if (reference === null) return null;
|
|
14078
14168
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -14084,11 +14174,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
14084
14174
|
if (members === null) return [];
|
|
14085
14175
|
const collaborators = [];
|
|
14086
14176
|
for (const property of pattern.properties) {
|
|
14087
|
-
if (property.type !==
|
|
14088
|
-
if (property.key.type !==
|
|
14177
|
+
if (property.type !== AST_NODE_TYPES55.Property || property.computed) continue;
|
|
14178
|
+
if (property.key.type !== AST_NODE_TYPES55.Identifier) continue;
|
|
14089
14179
|
const key = property.key.name;
|
|
14090
|
-
const bound = property.value.type ===
|
|
14091
|
-
if (bound.type !==
|
|
14180
|
+
const bound = property.value.type === AST_NODE_TYPES55.AssignmentPattern ? property.value.left : property.value;
|
|
14181
|
+
if (bound.type !== AST_NODE_TYPES55.Identifier) continue;
|
|
14092
14182
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
14093
14183
|
const reference = members.get(key);
|
|
14094
14184
|
if (reference === void 0) continue;
|
|
@@ -14097,21 +14187,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
14097
14187
|
return collaborators;
|
|
14098
14188
|
};
|
|
14099
14189
|
var bagMemberTypes = (annotation, declared) => {
|
|
14100
|
-
if (annotation.type ===
|
|
14190
|
+
if (annotation.type === AST_NODE_TYPES55.TSTypeLiteral) {
|
|
14101
14191
|
return propertySignatureTypes(annotation.members);
|
|
14102
14192
|
}
|
|
14103
|
-
if (annotation.type !==
|
|
14193
|
+
if (annotation.type !== AST_NODE_TYPES55.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES55.Identifier) {
|
|
14104
14194
|
return null;
|
|
14105
14195
|
}
|
|
14106
14196
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
14107
14197
|
};
|
|
14108
14198
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
14109
|
-
if (node.type ===
|
|
14199
|
+
if (node.type === AST_NODE_TYPES55.CallExpression) {
|
|
14110
14200
|
const { callee } = node;
|
|
14111
|
-
if (callee.type ===
|
|
14112
|
-
return callee.type ===
|
|
14201
|
+
if (callee.type === AST_NODE_TYPES55.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
14202
|
+
return callee.type === AST_NODE_TYPES55.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES55.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
14113
14203
|
}
|
|
14114
|
-
return node.type ===
|
|
14204
|
+
return node.type === AST_NODE_TYPES55.TSTypeReference && node.typeName.type === AST_NODE_TYPES55.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
14115
14205
|
});
|
|
14116
14206
|
var subtreeHas = (root, found) => {
|
|
14117
14207
|
let hit = false;
|
|
@@ -14138,19 +14228,19 @@ var invokedInstanceField = (call) => {
|
|
|
14138
14228
|
const direct = instanceField(call.callee);
|
|
14139
14229
|
if (direct !== null) return direct;
|
|
14140
14230
|
let callee = call.callee;
|
|
14141
|
-
while (callee.type ===
|
|
14142
|
-
return callee.type ===
|
|
14231
|
+
while (callee.type === AST_NODE_TYPES55.ChainExpression || callee.type === AST_NODE_TYPES55.TSAsExpression || callee.type === AST_NODE_TYPES55.TSNonNullExpression || callee.type === AST_NODE_TYPES55.TSSatisfiesExpression || callee.type === AST_NODE_TYPES55.TSTypeAssertion) callee = callee.expression;
|
|
14232
|
+
return callee.type === AST_NODE_TYPES55.MemberExpression ? instanceField(callee.object) : null;
|
|
14143
14233
|
};
|
|
14144
14234
|
var instanceField = (candidate) => {
|
|
14145
14235
|
let node = candidate;
|
|
14146
|
-
while (node.type ===
|
|
14147
|
-
return node.type ===
|
|
14236
|
+
while (node.type === AST_NODE_TYPES55.ChainExpression || node.type === AST_NODE_TYPES55.TSAsExpression || node.type === AST_NODE_TYPES55.TSNonNullExpression || node.type === AST_NODE_TYPES55.TSSatisfiesExpression || node.type === AST_NODE_TYPES55.TSTypeAssertion) node = node.expression;
|
|
14237
|
+
return node.type === AST_NODE_TYPES55.MemberExpression && node.object.type === AST_NODE_TYPES55.ThisExpression ? staticMemberName6(node) : null;
|
|
14148
14238
|
};
|
|
14149
14239
|
var behaviorallyInvokedFields = (body2) => {
|
|
14150
14240
|
const invoked = /* @__PURE__ */ new Set();
|
|
14151
14241
|
const visit = (current) => {
|
|
14152
|
-
if (current.type ===
|
|
14153
|
-
if (current.type ===
|
|
14242
|
+
if (current.type === AST_NODE_TYPES55.ClassDeclaration || current.type === AST_NODE_TYPES55.ClassExpression || current.type === AST_NODE_TYPES55.FunctionDeclaration || current.type === AST_NODE_TYPES55.FunctionExpression) return;
|
|
14243
|
+
if (current.type === AST_NODE_TYPES55.CallExpression) {
|
|
14154
14244
|
const field = invokedInstanceField(current);
|
|
14155
14245
|
if (field !== null) invoked.add(field);
|
|
14156
14246
|
}
|
|
@@ -14163,14 +14253,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
14163
14253
|
}
|
|
14164
14254
|
};
|
|
14165
14255
|
for (const member of body2.body) {
|
|
14166
|
-
if (member.type ===
|
|
14167
|
-
if (member.type ===
|
|
14256
|
+
if (member.type === AST_NODE_TYPES55.StaticBlock || member.static) continue;
|
|
14257
|
+
if (member.type === AST_NODE_TYPES55.MethodDefinition) {
|
|
14168
14258
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
14169
14259
|
continue;
|
|
14170
14260
|
}
|
|
14171
|
-
if (member.type !==
|
|
14261
|
+
if (member.type !== AST_NODE_TYPES55.PropertyDefinition || member.value === null) continue;
|
|
14172
14262
|
visit(
|
|
14173
|
-
member.value.type ===
|
|
14263
|
+
member.value.type === AST_NODE_TYPES55.ArrowFunctionExpression ? member.value.body : member.value
|
|
14174
14264
|
);
|
|
14175
14265
|
}
|
|
14176
14266
|
return invoked;
|
|
@@ -14190,25 +14280,25 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
14190
14280
|
var fileInterfaceNames = (program) => {
|
|
14191
14281
|
const names = [];
|
|
14192
14282
|
for (const statement of program.body) {
|
|
14193
|
-
const declaration = statement.type ===
|
|
14194
|
-
if (declaration?.type ===
|
|
14283
|
+
const declaration = statement.type === AST_NODE_TYPES55.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14284
|
+
if (declaration?.type === AST_NODE_TYPES55.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
14195
14285
|
}
|
|
14196
14286
|
return names;
|
|
14197
14287
|
};
|
|
14198
14288
|
var publicMethodNames = (body2, functionAliases) => {
|
|
14199
14289
|
const names = [];
|
|
14200
14290
|
for (const member of body2.body) {
|
|
14201
|
-
if (member.type ===
|
|
14291
|
+
if (member.type === AST_NODE_TYPES55.PropertyDefinition) {
|
|
14202
14292
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
14203
|
-
if (member.value?.type !==
|
|
14204
|
-
names.push(member.key.type ===
|
|
14293
|
+
if (member.value?.type !== AST_NODE_TYPES55.ArrowFunctionExpression && member.value?.type !== AST_NODE_TYPES55.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES55.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES55.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === AST_NODE_TYPES55.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
14294
|
+
names.push(member.key.type === AST_NODE_TYPES55.Identifier ? member.key.name : "\u2026");
|
|
14205
14295
|
continue;
|
|
14206
14296
|
}
|
|
14207
|
-
if (member.type !==
|
|
14297
|
+
if (member.type !== AST_NODE_TYPES55.MethodDefinition) continue;
|
|
14208
14298
|
if (member.kind !== "method" || member.static) continue;
|
|
14209
14299
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
14210
|
-
if (member.key.type ===
|
|
14211
|
-
if (member.key.type ===
|
|
14300
|
+
if (member.key.type === AST_NODE_TYPES55.PrivateIdentifier) continue;
|
|
14301
|
+
if (member.key.type === AST_NODE_TYPES55.Identifier) names.push(member.key.name);
|
|
14212
14302
|
else names.push("\u2026");
|
|
14213
14303
|
}
|
|
14214
14304
|
return names;
|
|
@@ -14216,13 +14306,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
14216
14306
|
var isFluentConstructionObject = (node, getText) => {
|
|
14217
14307
|
if (node.id === null) return false;
|
|
14218
14308
|
const methods = node.body.body.filter(
|
|
14219
|
-
(member) => member.type ===
|
|
14309
|
+
(member) => member.type === AST_NODE_TYPES55.MethodDefinition && member.kind === "method" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.value.body !== null
|
|
14220
14310
|
);
|
|
14221
14311
|
if (methods.length === 0) return false;
|
|
14222
14312
|
return methods.every((member) => {
|
|
14223
14313
|
const result = member.value.returnType?.typeAnnotation;
|
|
14224
14314
|
if (result === void 0) return false;
|
|
14225
|
-
const returnsOwnType = result.type ===
|
|
14315
|
+
const returnsOwnType = result.type === AST_NODE_TYPES55.TSTypeReference && result.typeName.type === AST_NODE_TYPES55.Identifier && result.typeName.name === node.id?.name;
|
|
14226
14316
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
14227
14317
|
});
|
|
14228
14318
|
};
|
|
@@ -14230,10 +14320,10 @@ function localClassAbstractness(program) {
|
|
|
14230
14320
|
const classes = /* @__PURE__ */ new Map();
|
|
14231
14321
|
const parents = /* @__PURE__ */ new Map();
|
|
14232
14322
|
for (const statement of program.body) {
|
|
14233
|
-
const declaration = statement.type ===
|
|
14234
|
-
if (declaration?.type ===
|
|
14323
|
+
const declaration = statement.type === AST_NODE_TYPES55.ExportNamedDeclaration || statement.type === AST_NODE_TYPES55.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
14324
|
+
if (declaration?.type === AST_NODE_TYPES55.ClassDeclaration && declaration.id !== null) {
|
|
14235
14325
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
14236
|
-
if (declaration.superClass?.type ===
|
|
14326
|
+
if (declaration.superClass?.type === AST_NODE_TYPES55.Identifier) {
|
|
14237
14327
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
14238
14328
|
}
|
|
14239
14329
|
}
|
|
@@ -14255,43 +14345,43 @@ function localInterfaceSurfaces(program) {
|
|
|
14255
14345
|
const parents = /* @__PURE__ */ new Map();
|
|
14256
14346
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
14257
14347
|
for (const statement of program.body) {
|
|
14258
|
-
const declaration = statement.type ===
|
|
14259
|
-
if (declaration?.type ===
|
|
14348
|
+
const declaration = statement.type === AST_NODE_TYPES55.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14349
|
+
if (declaration?.type === AST_NODE_TYPES55.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === AST_NODE_TYPES55.TSFunctionType || declaration.typeAnnotation.type === AST_NODE_TYPES55.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
14260
14350
|
}
|
|
14261
14351
|
for (const statement of program.body) {
|
|
14262
|
-
const declaration = statement.type ===
|
|
14263
|
-
if (declaration?.type ===
|
|
14352
|
+
const declaration = statement.type === AST_NODE_TYPES55.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14353
|
+
if (declaration?.type === AST_NODE_TYPES55.TSTypeAliasDeclaration) {
|
|
14264
14354
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
14265
|
-
const parts = declaration.typeAnnotation.type ===
|
|
14355
|
+
const parts = declaration.typeAnnotation.type === AST_NODE_TYPES55.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
14266
14356
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
14267
14357
|
for (const part of parts) {
|
|
14268
|
-
if (part.type ===
|
|
14358
|
+
if (part.type === AST_NODE_TYPES55.TSTypeReference && part.typeName.type === AST_NODE_TYPES55.Identifier) {
|
|
14269
14359
|
inherited.push(part.typeName.name);
|
|
14270
14360
|
continue;
|
|
14271
14361
|
}
|
|
14272
|
-
if (part.type !==
|
|
14362
|
+
if (part.type !== AST_NODE_TYPES55.TSTypeLiteral) continue;
|
|
14273
14363
|
for (const member of part.members) {
|
|
14274
|
-
if (member.type !==
|
|
14275
|
-
if (member.computed || member.key.type !==
|
|
14276
|
-
if (member.type ===
|
|
14364
|
+
if (member.type !== AST_NODE_TYPES55.TSMethodSignature && member.type !== AST_NODE_TYPES55.TSPropertySignature) continue;
|
|
14365
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES55.Identifier) continue;
|
|
14366
|
+
if (member.type === AST_NODE_TYPES55.TSMethodSignature) {
|
|
14277
14367
|
callables2.add(member.key.name);
|
|
14278
14368
|
continue;
|
|
14279
14369
|
}
|
|
14280
|
-
if (member.type !==
|
|
14370
|
+
if (member.type !== AST_NODE_TYPES55.TSPropertySignature) continue;
|
|
14281
14371
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
14282
|
-
if (annotation?.type ===
|
|
14372
|
+
if (annotation?.type === AST_NODE_TYPES55.TSFunctionType || annotation?.type === AST_NODE_TYPES55.TSTypeReference && annotation.typeName.type === AST_NODE_TYPES55.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(member.key.name);
|
|
14283
14373
|
}
|
|
14284
14374
|
}
|
|
14285
14375
|
interfaces.set(declaration.id.name, callables2);
|
|
14286
14376
|
parents.set(declaration.id.name, inherited);
|
|
14287
14377
|
continue;
|
|
14288
14378
|
}
|
|
14289
|
-
if (declaration?.type !==
|
|
14379
|
+
if (declaration?.type !== AST_NODE_TYPES55.TSInterfaceDeclaration) continue;
|
|
14290
14380
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
14291
14381
|
for (const member of declaration.body.body) {
|
|
14292
|
-
if (member.type !==
|
|
14293
|
-
if (member.computed || member.key.type !==
|
|
14294
|
-
if (member.type ===
|
|
14382
|
+
if (member.type !== AST_NODE_TYPES55.TSMethodSignature && member.type !== AST_NODE_TYPES55.TSPropertySignature) continue;
|
|
14383
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES55.Identifier) continue;
|
|
14384
|
+
if (member.type === AST_NODE_TYPES55.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES55.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES55.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === AST_NODE_TYPES55.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(member.key.name);
|
|
14295
14385
|
}
|
|
14296
14386
|
interfaces.set(declaration.id.name, callables);
|
|
14297
14387
|
parents.set(
|
|
@@ -14299,7 +14389,7 @@ function localInterfaceSurfaces(program) {
|
|
|
14299
14389
|
[
|
|
14300
14390
|
...parents.get(declaration.id.name) ?? [],
|
|
14301
14391
|
...declaration.extends.flatMap(
|
|
14302
|
-
(heritage) => heritage.expression.type ===
|
|
14392
|
+
(heritage) => heritage.expression.type === AST_NODE_TYPES55.Identifier ? [heritage.expression.name] : ["*"]
|
|
14303
14393
|
)
|
|
14304
14394
|
]
|
|
14305
14395
|
);
|
|
@@ -14326,7 +14416,7 @@ function localInterfaceSurfaces(program) {
|
|
|
14326
14416
|
}
|
|
14327
14417
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
14328
14418
|
if (node.superClass !== null) {
|
|
14329
|
-
if (node.superClass.type !==
|
|
14419
|
+
if (node.superClass.type !== AST_NODE_TYPES55.Identifier) return true;
|
|
14330
14420
|
const localAbstract = classes.get(node.superClass.name);
|
|
14331
14421
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
14332
14422
|
}
|
|
@@ -14338,7 +14428,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
14338
14428
|
if (node.implements.length === 0) return false;
|
|
14339
14429
|
const combined = /* @__PURE__ */ new Set();
|
|
14340
14430
|
for (const implementation of node.implements) {
|
|
14341
|
-
if (implementation.expression.type !==
|
|
14431
|
+
if (implementation.expression.type !== AST_NODE_TYPES55.Identifier) return true;
|
|
14342
14432
|
const name = implementation.expression.name;
|
|
14343
14433
|
const localAbstract = classes.get(name);
|
|
14344
14434
|
if (localAbstract === true) return true;
|
|
@@ -14381,7 +14471,7 @@ var require_port_for_service_default = createRule({
|
|
|
14381
14471
|
if (node.abstract === true) return;
|
|
14382
14472
|
if (node.decorators.length > 0) return;
|
|
14383
14473
|
const ctor = node.body.body.find(
|
|
14384
|
-
(member) => member.type ===
|
|
14474
|
+
(member) => member.type === AST_NODE_TYPES55.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
14385
14475
|
);
|
|
14386
14476
|
if (ctor === void 0) return;
|
|
14387
14477
|
const constructorFacts = readConstructor(
|
|
@@ -14416,7 +14506,7 @@ var require_port_for_service_default = createRule({
|
|
|
14416
14506
|
});
|
|
14417
14507
|
|
|
14418
14508
|
// src/rules/require-static-next-matcher.ts
|
|
14419
|
-
import { AST_NODE_TYPES as
|
|
14509
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES56 } from "@typescript-eslint/utils";
|
|
14420
14510
|
var requireStaticNextMatcherDocumentation = {
|
|
14421
14511
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
14422
14512
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -14429,34 +14519,34 @@ var requireStaticNextMatcherDocumentation = {
|
|
|
14429
14519
|
};
|
|
14430
14520
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
14431
14521
|
function unwrapExpression3(node) {
|
|
14432
|
-
if (node.type ===
|
|
14522
|
+
if (node.type === AST_NODE_TYPES56.TSAsExpression || node.type === AST_NODE_TYPES56.TSSatisfiesExpression || node.type === AST_NODE_TYPES56.TSNonNullExpression || node.type === AST_NODE_TYPES56.TSTypeAssertion) {
|
|
14433
14523
|
return unwrapExpression3(node.expression);
|
|
14434
14524
|
}
|
|
14435
14525
|
return node;
|
|
14436
14526
|
}
|
|
14437
14527
|
function isStaticValue(node) {
|
|
14438
14528
|
const value = unwrapExpression3(node);
|
|
14439
|
-
if (value.type ===
|
|
14529
|
+
if (value.type === AST_NODE_TYPES56.Literal) {
|
|
14440
14530
|
return true;
|
|
14441
14531
|
}
|
|
14442
|
-
if (value.type ===
|
|
14532
|
+
if (value.type === AST_NODE_TYPES56.TemplateLiteral) {
|
|
14443
14533
|
return value.expressions.length === 0;
|
|
14444
14534
|
}
|
|
14445
|
-
if (value.type ===
|
|
14535
|
+
if (value.type === AST_NODE_TYPES56.ArrayExpression) {
|
|
14446
14536
|
return value.elements.every(
|
|
14447
|
-
(element) => element !== null && element.type !==
|
|
14537
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES56.SpreadElement && isStaticValue(element)
|
|
14448
14538
|
);
|
|
14449
14539
|
}
|
|
14450
|
-
if (value.type ===
|
|
14540
|
+
if (value.type === AST_NODE_TYPES56.ObjectExpression) {
|
|
14451
14541
|
return value.properties.every(
|
|
14452
|
-
(property) => property.type ===
|
|
14542
|
+
(property) => property.type === AST_NODE_TYPES56.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES56.AssignmentPattern && isStaticValue(property.value)
|
|
14453
14543
|
);
|
|
14454
14544
|
}
|
|
14455
14545
|
return false;
|
|
14456
14546
|
}
|
|
14457
14547
|
function propertyName2(property) {
|
|
14458
14548
|
if (property.computed) return null;
|
|
14459
|
-
if (property.key.type ===
|
|
14549
|
+
if (property.key.type === AST_NODE_TYPES56.Identifier) return property.key.name;
|
|
14460
14550
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
14461
14551
|
}
|
|
14462
14552
|
var require_static_next_matcher_default = createRule({
|
|
@@ -14479,19 +14569,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
14479
14569
|
}
|
|
14480
14570
|
return {
|
|
14481
14571
|
ExportNamedDeclaration(node) {
|
|
14482
|
-
if (node.declaration?.type !==
|
|
14572
|
+
if (node.declaration?.type !== AST_NODE_TYPES56.VariableDeclaration) {
|
|
14483
14573
|
return;
|
|
14484
14574
|
}
|
|
14485
14575
|
for (const declaration of node.declaration.declarations) {
|
|
14486
|
-
if (declaration.id.type !==
|
|
14576
|
+
if (declaration.id.type !== AST_NODE_TYPES56.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
14487
14577
|
continue;
|
|
14488
14578
|
}
|
|
14489
14579
|
const config = unwrapExpression3(declaration.init);
|
|
14490
|
-
if (config.type !==
|
|
14580
|
+
if (config.type !== AST_NODE_TYPES56.ObjectExpression) {
|
|
14491
14581
|
continue;
|
|
14492
14582
|
}
|
|
14493
14583
|
for (const property of config.properties) {
|
|
14494
|
-
if (property.type !==
|
|
14584
|
+
if (property.type !== AST_NODE_TYPES56.Property || propertyName2(property) !== "matcher" || property.value.type === AST_NODE_TYPES56.AssignmentPattern) {
|
|
14495
14585
|
continue;
|
|
14496
14586
|
}
|
|
14497
14587
|
if (!isStaticValue(property.value)) {
|
|
@@ -14506,7 +14596,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
14506
14596
|
|
|
14507
14597
|
// src/rules/require-zod-form-validation.ts
|
|
14508
14598
|
import {
|
|
14509
|
-
AST_NODE_TYPES as
|
|
14599
|
+
AST_NODE_TYPES as AST_NODE_TYPES57,
|
|
14510
14600
|
ASTUtils as ASTUtils17
|
|
14511
14601
|
} from "@typescript-eslint/utils";
|
|
14512
14602
|
var requireZodFormValidationDocumentation = {
|
|
@@ -14533,14 +14623,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
14533
14623
|
var zodReceiverRoot = (node) => {
|
|
14534
14624
|
let current = node;
|
|
14535
14625
|
while (true) {
|
|
14536
|
-
if (current.type ===
|
|
14626
|
+
if (current.type === AST_NODE_TYPES57.Identifier) {
|
|
14537
14627
|
return current;
|
|
14538
14628
|
}
|
|
14539
|
-
if (current.type ===
|
|
14629
|
+
if (current.type === AST_NODE_TYPES57.CallExpression) {
|
|
14540
14630
|
current = current.callee;
|
|
14541
14631
|
continue;
|
|
14542
14632
|
}
|
|
14543
|
-
if (current.type ===
|
|
14633
|
+
if (current.type === AST_NODE_TYPES57.MemberExpression) {
|
|
14544
14634
|
current = current.object;
|
|
14545
14635
|
continue;
|
|
14546
14636
|
}
|
|
@@ -14549,12 +14639,12 @@ var zodReceiverRoot = (node) => {
|
|
|
14549
14639
|
};
|
|
14550
14640
|
var isFormDataMethodCall = (node) => {
|
|
14551
14641
|
let current = node;
|
|
14552
|
-
if (current.type ===
|
|
14642
|
+
if (current.type === AST_NODE_TYPES57.AwaitExpression) {
|
|
14553
14643
|
current = current.argument;
|
|
14554
14644
|
}
|
|
14555
|
-
if (current.type !==
|
|
14645
|
+
if (current.type !== AST_NODE_TYPES57.CallExpression) return false;
|
|
14556
14646
|
const callee = current.callee;
|
|
14557
|
-
return callee.type ===
|
|
14647
|
+
return callee.type === AST_NODE_TYPES57.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES57.Identifier && callee.property.name === "formData";
|
|
14558
14648
|
};
|
|
14559
14649
|
var require_zod_form_validation_default = createRule({
|
|
14560
14650
|
name: "require-zod-form-validation",
|
|
@@ -14585,16 +14675,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
14585
14675
|
return false;
|
|
14586
14676
|
}
|
|
14587
14677
|
const definition = binding.defs[0];
|
|
14588
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
14678
|
+
if (definition?.type !== "Variable" || definition.node.type !== AST_NODE_TYPES57.VariableDeclarator) {
|
|
14589
14679
|
return false;
|
|
14590
14680
|
}
|
|
14591
14681
|
const init = definition.node.init;
|
|
14592
|
-
return init?.type ===
|
|
14682
|
+
return init?.type === AST_NODE_TYPES57.ObjectExpression || init?.type === AST_NODE_TYPES57.ArrayExpression || init?.type === AST_NODE_TYPES57.Literal || init?.type === AST_NODE_TYPES57.ArrowFunctionExpression || init?.type === AST_NODE_TYPES57.FunctionExpression;
|
|
14593
14683
|
};
|
|
14594
14684
|
const isZodParseCall = (node) => {
|
|
14595
|
-
if (node.type !==
|
|
14685
|
+
if (node.type !== AST_NODE_TYPES57.CallExpression) return false;
|
|
14596
14686
|
const callee = node.callee;
|
|
14597
|
-
if (callee.type !==
|
|
14687
|
+
if (callee.type !== AST_NODE_TYPES57.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES57.Identifier || !ZOD_PARSE_METHODS.has(callee.property.name)) {
|
|
14598
14688
|
return false;
|
|
14599
14689
|
}
|
|
14600
14690
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -14603,14 +14693,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
14603
14693
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
14604
14694
|
};
|
|
14605
14695
|
const isFormSourceIdentifier = (node) => {
|
|
14606
|
-
if (node.type !==
|
|
14696
|
+
if (node.type !== AST_NODE_TYPES57.Identifier) return false;
|
|
14607
14697
|
const conventionalName = /formdata/i.test(node.name);
|
|
14608
14698
|
let scope = context.sourceCode.getScope(node);
|
|
14609
14699
|
while (scope !== null) {
|
|
14610
14700
|
const variable = scope.set.get(node.name);
|
|
14611
14701
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
14612
14702
|
const def = variable.defs[0];
|
|
14613
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
14703
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES57.VariableDeclarator && def.node.init !== null) {
|
|
14614
14704
|
return isFormDataMethodCall(def.node.init);
|
|
14615
14705
|
}
|
|
14616
14706
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -14621,8 +14711,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
14621
14711
|
};
|
|
14622
14712
|
const isFormDataGetCall = (node) => {
|
|
14623
14713
|
const callee = node.callee;
|
|
14624
|
-
if (callee.type !==
|
|
14625
|
-
if (callee.property.type !==
|
|
14714
|
+
if (callee.type !== AST_NODE_TYPES57.MemberExpression) return false;
|
|
14715
|
+
if (callee.property.type !== AST_NODE_TYPES57.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
14626
14716
|
return false;
|
|
14627
14717
|
}
|
|
14628
14718
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -14638,16 +14728,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
14638
14728
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
14639
14729
|
const isInstanceofNarrowing = (node) => {
|
|
14640
14730
|
const parent = node.parent;
|
|
14641
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
14731
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES57.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES57.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
14642
14732
|
};
|
|
14643
14733
|
const boundDeclarator = (node) => {
|
|
14644
14734
|
let current = node;
|
|
14645
14735
|
let parent = current.parent;
|
|
14646
|
-
while ((parent.type ===
|
|
14736
|
+
while ((parent.type === AST_NODE_TYPES57.TSAsExpression || parent.type === AST_NODE_TYPES57.TSSatisfiesExpression || parent.type === AST_NODE_TYPES57.TSNonNullExpression || parent.type === AST_NODE_TYPES57.ChainExpression) && parent.expression === current) {
|
|
14647
14737
|
current = parent;
|
|
14648
14738
|
parent = current.parent;
|
|
14649
14739
|
}
|
|
14650
|
-
if (parent.type ===
|
|
14740
|
+
if (parent.type === AST_NODE_TYPES57.VariableDeclarator && parent.init === current && parent.id.type === AST_NODE_TYPES57.Identifier) {
|
|
14651
14741
|
return parent;
|
|
14652
14742
|
}
|
|
14653
14743
|
return null;
|
|
@@ -14656,7 +14746,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14656
14746
|
let current = node;
|
|
14657
14747
|
while (current.parent !== void 0) {
|
|
14658
14748
|
const parent = current.parent;
|
|
14659
|
-
if (parent.type ===
|
|
14749
|
+
if (parent.type === AST_NODE_TYPES57.BlockStatement || parent.type === AST_NODE_TYPES57.Program) {
|
|
14660
14750
|
return current;
|
|
14661
14751
|
}
|
|
14662
14752
|
current = parent;
|
|
@@ -14665,12 +14755,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
14665
14755
|
};
|
|
14666
14756
|
const zodParseMethod = (call) => {
|
|
14667
14757
|
const callee = call.callee;
|
|
14668
|
-
return callee.type ===
|
|
14758
|
+
return callee.type === AST_NODE_TYPES57.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES57.Identifier ? callee.property.name : null;
|
|
14669
14759
|
};
|
|
14670
14760
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
14671
14761
|
let current = node.parent;
|
|
14672
14762
|
while (current !== void 0 && current !== statement) {
|
|
14673
|
-
if (current.type ===
|
|
14763
|
+
if (current.type === AST_NODE_TYPES57.LogicalExpression || current.type === AST_NODE_TYPES57.ConditionalExpression) {
|
|
14674
14764
|
return true;
|
|
14675
14765
|
}
|
|
14676
14766
|
current = current.parent;
|
|
@@ -14680,7 +14770,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14680
14770
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
14681
14771
|
let current = node.parent;
|
|
14682
14772
|
while (current !== void 0 && current !== statement) {
|
|
14683
|
-
if (current.type ===
|
|
14773
|
+
if (current.type === AST_NODE_TYPES57.AwaitExpression) return true;
|
|
14684
14774
|
current = current.parent;
|
|
14685
14775
|
}
|
|
14686
14776
|
return false;
|
|
@@ -14693,7 +14783,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14693
14783
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
14694
14784
|
return null;
|
|
14695
14785
|
}
|
|
14696
|
-
if (validationStatement.type !==
|
|
14786
|
+
if (validationStatement.type !== AST_NODE_TYPES57.VariableDeclaration && validationStatement.type !== AST_NODE_TYPES57.ExpressionStatement) {
|
|
14697
14787
|
return null;
|
|
14698
14788
|
}
|
|
14699
14789
|
const method = zodParseMethod(parse2);
|
|
@@ -14705,16 +14795,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
14705
14795
|
};
|
|
14706
14796
|
const isSafePrevalidationInspection = (identifier) => {
|
|
14707
14797
|
const parent = identifier.parent;
|
|
14708
|
-
if (parent.type ===
|
|
14798
|
+
if (parent.type === AST_NODE_TYPES57.UnaryExpression && parent.operator === "typeof") {
|
|
14709
14799
|
return true;
|
|
14710
14800
|
}
|
|
14711
|
-
if (parent.type !==
|
|
14801
|
+
if (parent.type !== AST_NODE_TYPES57.BinaryExpression || parent.left !== identifier) {
|
|
14712
14802
|
return false;
|
|
14713
14803
|
}
|
|
14714
14804
|
if (parent.operator === "instanceof") {
|
|
14715
|
-
return parent.right.type ===
|
|
14805
|
+
return parent.right.type === AST_NODE_TYPES57.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
14716
14806
|
}
|
|
14717
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
14807
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === AST_NODE_TYPES57.Literal && parent.right.value === null || parent.right.type === AST_NODE_TYPES57.Identifier && parent.right.name === "undefined");
|
|
14718
14808
|
};
|
|
14719
14809
|
const isDescendantOf = (node, ancestor) => {
|
|
14720
14810
|
let current = node;
|
|
@@ -14725,23 +14815,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
14725
14815
|
return false;
|
|
14726
14816
|
};
|
|
14727
14817
|
const blockTerminates = (node) => {
|
|
14728
|
-
if (node.type ===
|
|
14818
|
+
if (node.type === AST_NODE_TYPES57.ReturnStatement || node.type === AST_NODE_TYPES57.ThrowStatement) {
|
|
14729
14819
|
return true;
|
|
14730
14820
|
}
|
|
14731
|
-
if (node.type !==
|
|
14821
|
+
if (node.type !== AST_NODE_TYPES57.BlockStatement || node.body.length === 0) return false;
|
|
14732
14822
|
const last = node.body.at(-1);
|
|
14733
14823
|
return last !== void 0 && blockTerminates(last);
|
|
14734
14824
|
};
|
|
14735
14825
|
const narrowingIf = (identifier) => {
|
|
14736
14826
|
const comparison = identifier.parent;
|
|
14737
|
-
if (comparison?.type !==
|
|
14827
|
+
if (comparison?.type !== AST_NODE_TYPES57.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== AST_NODE_TYPES57.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
14738
14828
|
return null;
|
|
14739
14829
|
}
|
|
14740
14830
|
const maybeNegation = comparison.parent;
|
|
14741
|
-
const negated = maybeNegation?.type ===
|
|
14831
|
+
const negated = maybeNegation?.type === AST_NODE_TYPES57.UnaryExpression && maybeNegation.operator === "!";
|
|
14742
14832
|
const test = negated ? maybeNegation : comparison;
|
|
14743
14833
|
const branch = test.parent;
|
|
14744
|
-
return branch?.type ===
|
|
14834
|
+
return branch?.type === AST_NODE_TYPES57.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
14745
14835
|
};
|
|
14746
14836
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
14747
14837
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -14761,7 +14851,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14761
14851
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
14762
14852
|
if (variable === void 0) return false;
|
|
14763
14853
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
14764
|
-
(identifier) => identifier.type ===
|
|
14854
|
+
(identifier) => identifier.type === AST_NODE_TYPES57.Identifier
|
|
14765
14855
|
);
|
|
14766
14856
|
if (references.length === 0) return false;
|
|
14767
14857
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -14787,7 +14877,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14787
14877
|
ImportDeclaration(node) {
|
|
14788
14878
|
if (!isZodModule(node.source.value)) return;
|
|
14789
14879
|
for (const specifier of node.specifiers) {
|
|
14790
|
-
if (specifier.type ===
|
|
14880
|
+
if (specifier.type === AST_NODE_TYPES57.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES57.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES57.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES57.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
14791
14881
|
const binding = resolvedBinding(specifier.local);
|
|
14792
14882
|
if (binding !== null) zodBindings.add(binding);
|
|
14793
14883
|
}
|
|
@@ -14872,7 +14962,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
14872
14962
|
});
|
|
14873
14963
|
|
|
14874
14964
|
// src/rules/stepdown.ts
|
|
14875
|
-
import { AST_NODE_TYPES as
|
|
14965
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES58, ASTUtils as ASTUtils18 } from "@typescript-eslint/utils";
|
|
14876
14966
|
var stepdownDocumentation = {
|
|
14877
14967
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
14878
14968
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -14889,7 +14979,7 @@ var stepdownDocumentation = {
|
|
|
14889
14979
|
]
|
|
14890
14980
|
};
|
|
14891
14981
|
function isFunction(node) {
|
|
14892
|
-
return node.type ===
|
|
14982
|
+
return node.type === AST_NODE_TYPES58.ArrowFunctionExpression || node.type === AST_NODE_TYPES58.FunctionDeclaration || node.type === AST_NODE_TYPES58.FunctionExpression;
|
|
14893
14983
|
}
|
|
14894
14984
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true) {
|
|
14895
14985
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -14984,8 +15074,8 @@ function moduleScope(context, program) {
|
|
|
14984
15074
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
14985
15075
|
const overloadNames = new Set(
|
|
14986
15076
|
program.body.flatMap((statement) => {
|
|
14987
|
-
const node = statement.type ===
|
|
14988
|
-
return node?.type ===
|
|
15077
|
+
const node = statement.type === AST_NODE_TYPES58.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15078
|
+
return node?.type === AST_NODE_TYPES58.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
14989
15079
|
})
|
|
14990
15080
|
);
|
|
14991
15081
|
const exported = exportedNames(program);
|
|
@@ -15009,7 +15099,7 @@ function moduleScope(context, program) {
|
|
|
15009
15099
|
const nearestFunction2 = [...ancestors].reverse().find(isFunction);
|
|
15010
15100
|
const parent = identifier.parent;
|
|
15011
15101
|
const callerDefinition = nearestFunction2 === void 0 ? void 0 : byFunction.get(nearestFunction2);
|
|
15012
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
15102
|
+
if (callerDefinition === void 0 || parent.type !== AST_NODE_TYPES58.CallExpression || parent.callee !== identifier) {
|
|
15013
15103
|
pinned.add(definition.name);
|
|
15014
15104
|
continue;
|
|
15015
15105
|
}
|
|
@@ -15024,38 +15114,38 @@ function moduleScope(context, program) {
|
|
|
15024
15114
|
function exportedNames(program) {
|
|
15025
15115
|
const names = /* @__PURE__ */ new Set();
|
|
15026
15116
|
for (const statement of program.body) {
|
|
15027
|
-
if (statement.type !==
|
|
15028
|
-
if (statement.declaration?.type ===
|
|
15117
|
+
if (statement.type !== AST_NODE_TYPES58.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
15118
|
+
if (statement.declaration?.type === AST_NODE_TYPES58.FunctionDeclaration && statement.declaration.id !== null) {
|
|
15029
15119
|
names.add(statement.declaration.id.name);
|
|
15030
15120
|
}
|
|
15031
|
-
if (statement.declaration?.type ===
|
|
15121
|
+
if (statement.declaration?.type === AST_NODE_TYPES58.VariableDeclaration) {
|
|
15032
15122
|
for (const declarator of statement.declaration.declarations) {
|
|
15033
|
-
if (declarator.id.type ===
|
|
15123
|
+
if (declarator.id.type === AST_NODE_TYPES58.Identifier) names.add(declarator.id.name);
|
|
15034
15124
|
}
|
|
15035
15125
|
}
|
|
15036
15126
|
for (const specifier of statement.specifiers) {
|
|
15037
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
15127
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES58.Identifier) {
|
|
15038
15128
|
names.add(specifier.local.name);
|
|
15039
15129
|
}
|
|
15040
15130
|
}
|
|
15041
15131
|
}
|
|
15042
15132
|
for (const statement of program.body) {
|
|
15043
|
-
if (statement.type ===
|
|
15044
|
-
if (statement.type ===
|
|
15133
|
+
if (statement.type === AST_NODE_TYPES58.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES58.Identifier) names.add(statement.declaration.name);
|
|
15134
|
+
if (statement.type === AST_NODE_TYPES58.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES58.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
15045
15135
|
}
|
|
15046
15136
|
return names;
|
|
15047
15137
|
}
|
|
15048
15138
|
function moduleDefinitions(program) {
|
|
15049
15139
|
const definitions = [];
|
|
15050
15140
|
for (const statement of program.body) {
|
|
15051
|
-
const node = statement.type ===
|
|
15052
|
-
if (node?.type ===
|
|
15141
|
+
const node = statement.type === AST_NODE_TYPES58.ExportNamedDeclaration || statement.type === AST_NODE_TYPES58.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
15142
|
+
if (node?.type === AST_NODE_TYPES58.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
15053
15143
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
15054
15144
|
continue;
|
|
15055
15145
|
}
|
|
15056
|
-
if (node?.type !==
|
|
15146
|
+
if (node?.type !== AST_NODE_TYPES58.VariableDeclaration || node.kind !== "const") continue;
|
|
15057
15147
|
for (const declarator of node.declarations) {
|
|
15058
|
-
if (declarator.id.type ===
|
|
15148
|
+
if (declarator.id.type === AST_NODE_TYPES58.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
15059
15149
|
definitions.push({
|
|
15060
15150
|
name: declarator.id.name,
|
|
15061
15151
|
node: declarator,
|
|
@@ -15068,21 +15158,21 @@ function moduleDefinitions(program) {
|
|
|
15068
15158
|
return definitions;
|
|
15069
15159
|
}
|
|
15070
15160
|
function methodName(node) {
|
|
15071
|
-
if (node.key.type ===
|
|
15072
|
-
return !node.computed && node.key.type ===
|
|
15161
|
+
if (node.key.type === AST_NODE_TYPES58.PrivateIdentifier) return `#${node.key.name}`;
|
|
15162
|
+
return !node.computed && node.key.type === AST_NODE_TYPES58.Identifier ? node.key.name : null;
|
|
15073
15163
|
}
|
|
15074
15164
|
function referencedMethod(context, node, classVariables) {
|
|
15075
|
-
const objectVariable = node.object.type ===
|
|
15165
|
+
const objectVariable = node.object.type === AST_NODE_TYPES58.Identifier ? ASTUtils18.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
15076
15166
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
15077
|
-
if (node.object.type !==
|
|
15078
|
-
if (node.property.type ===
|
|
15079
|
-
if (!node.computed && node.property.type ===
|
|
15080
|
-
return node.computed && node.property.type ===
|
|
15167
|
+
if (node.object.type !== AST_NODE_TYPES58.ThisExpression && !isClassReference) return null;
|
|
15168
|
+
if (node.property.type === AST_NODE_TYPES58.PrivateIdentifier) return `#${node.property.name}`;
|
|
15169
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES58.Identifier) return node.property.name;
|
|
15170
|
+
return node.computed && node.property.type === AST_NODE_TYPES58.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
15081
15171
|
}
|
|
15082
15172
|
function referencedPropertyName(node) {
|
|
15083
|
-
if (node.property.type ===
|
|
15084
|
-
if (!node.computed && node.property.type ===
|
|
15085
|
-
return node.computed && node.property.type ===
|
|
15173
|
+
if (node.property.type === AST_NODE_TYPES58.PrivateIdentifier) return `#${node.property.name}`;
|
|
15174
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES58.Identifier) return node.property.name;
|
|
15175
|
+
return node.computed && node.property.type === AST_NODE_TYPES58.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
15086
15176
|
}
|
|
15087
15177
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
15088
15178
|
visit(node, nestedFunction);
|
|
@@ -15098,7 +15188,7 @@ function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
15098
15188
|
}
|
|
15099
15189
|
function classScope(context, node, computedReferenceNames) {
|
|
15100
15190
|
const methods = node.body.body.filter(
|
|
15101
|
-
(member) => member.type ===
|
|
15191
|
+
(member) => member.type === AST_NODE_TYPES58.MethodDefinition
|
|
15102
15192
|
);
|
|
15103
15193
|
const counts = /* @__PURE__ */ new Map();
|
|
15104
15194
|
for (const method of methods) {
|
|
@@ -15106,8 +15196,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15106
15196
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
15107
15197
|
}
|
|
15108
15198
|
for (const member of node.body.body) {
|
|
15109
|
-
if (member.type !==
|
|
15110
|
-
const name = !member.computed && member.key.type ===
|
|
15199
|
+
if (member.type !== AST_NODE_TYPES58.TSAbstractMethodDefinition) continue;
|
|
15200
|
+
const name = !member.computed && member.key.type === AST_NODE_TYPES58.Identifier ? member.key.name : null;
|
|
15111
15201
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
15112
15202
|
}
|
|
15113
15203
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -15116,7 +15206,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15116
15206
|
});
|
|
15117
15207
|
const definitions = methods.flatMap((method) => {
|
|
15118
15208
|
const name = methodName(method);
|
|
15119
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
15209
|
+
const isPrivate = method.accessibility === "private" || method.key.type === AST_NODE_TYPES58.PrivateIdentifier;
|
|
15120
15210
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
15121
15211
|
});
|
|
15122
15212
|
if (definitions.length === 0) return;
|
|
@@ -15128,7 +15218,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15128
15218
|
const internal = ASTUtils18.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
15129
15219
|
if (internal !== null) classVariables.add(internal);
|
|
15130
15220
|
}
|
|
15131
|
-
if (node.type ===
|
|
15221
|
+
if (node.type === AST_NODE_TYPES58.ClassExpression && node.parent.type === AST_NODE_TYPES58.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES58.Identifier) {
|
|
15132
15222
|
const outer = ASTUtils18.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
15133
15223
|
if (outer !== null) classVariables.add(outer);
|
|
15134
15224
|
}
|
|
@@ -15145,26 +15235,26 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15145
15235
|
}
|
|
15146
15236
|
const thisValue = (value) => {
|
|
15147
15237
|
let current = value;
|
|
15148
|
-
while (current?.type ===
|
|
15149
|
-
return current?.type ===
|
|
15238
|
+
while (current?.type === AST_NODE_TYPES58.TSAsExpression || current?.type === AST_NODE_TYPES58.TSSatisfiesExpression || current?.type === AST_NODE_TYPES58.TSNonNullExpression) current = current.expression;
|
|
15239
|
+
return current?.type === AST_NODE_TYPES58.ThisExpression;
|
|
15150
15240
|
};
|
|
15151
15241
|
const collectAlias = (current, nestedFunction) => {
|
|
15152
|
-
if (nestedFunction || current.type !==
|
|
15153
|
-
if (current.type ===
|
|
15154
|
-
const binding = current.type ===
|
|
15155
|
-
const value = current.type ===
|
|
15242
|
+
if (nestedFunction || current.type !== AST_NODE_TYPES58.VariableDeclarator && current.type !== AST_NODE_TYPES58.AssignmentPattern) return;
|
|
15243
|
+
if (current.type === AST_NODE_TYPES58.VariableDeclarator && (current.parent.type !== AST_NODE_TYPES58.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
15244
|
+
const binding = current.type === AST_NODE_TYPES58.VariableDeclarator ? current.id : current.left;
|
|
15245
|
+
const value = current.type === AST_NODE_TYPES58.VariableDeclarator ? current.init : current.right;
|
|
15156
15246
|
if (!thisValue(value)) return;
|
|
15157
|
-
if (binding.type ===
|
|
15247
|
+
if (binding.type === AST_NODE_TYPES58.ObjectPattern) {
|
|
15158
15248
|
for (const property of binding.properties) {
|
|
15159
|
-
if (property.type ===
|
|
15249
|
+
if (property.type === AST_NODE_TYPES58.RestElement) {
|
|
15160
15250
|
for (const name of privateNames) pinned.add(name);
|
|
15161
|
-
} else if (property.key.type ===
|
|
15251
|
+
} else if (property.key.type === AST_NODE_TYPES58.Identifier && privateNames.has(property.key.name)) {
|
|
15162
15252
|
pinned.add(property.key.name);
|
|
15163
15253
|
}
|
|
15164
15254
|
}
|
|
15165
15255
|
return;
|
|
15166
15256
|
}
|
|
15167
|
-
if (binding.type !==
|
|
15257
|
+
if (binding.type !== AST_NODE_TYPES58.Identifier) return;
|
|
15168
15258
|
const variable = ASTUtils18.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
15169
15259
|
if (variable !== null) {
|
|
15170
15260
|
methodClassVariables.add(variable);
|
|
@@ -15178,16 +15268,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15178
15268
|
walk(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
15179
15269
|
}
|
|
15180
15270
|
const visitCall = (current, nestedFunction) => {
|
|
15181
|
-
if (current.type ===
|
|
15271
|
+
if (current.type === AST_NODE_TYPES58.VariableDeclarator && current.id.type === AST_NODE_TYPES58.ObjectPattern && thisValue(current.init)) {
|
|
15182
15272
|
for (const property of current.id.properties) {
|
|
15183
|
-
if (property.type ===
|
|
15273
|
+
if (property.type === AST_NODE_TYPES58.RestElement) {
|
|
15184
15274
|
for (const name of privateNames) pinned.add(name);
|
|
15185
15275
|
continue;
|
|
15186
15276
|
}
|
|
15187
|
-
if (property.type ===
|
|
15277
|
+
if (property.type === AST_NODE_TYPES58.Property && property.key.type === AST_NODE_TYPES58.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
15188
15278
|
}
|
|
15189
15279
|
}
|
|
15190
|
-
if (current.type !==
|
|
15280
|
+
if (current.type !== AST_NODE_TYPES58.MemberExpression) return;
|
|
15191
15281
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
15192
15282
|
if (target === null) {
|
|
15193
15283
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -15195,12 +15285,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15195
15285
|
return;
|
|
15196
15286
|
}
|
|
15197
15287
|
if (!privateNames.has(target)) return;
|
|
15198
|
-
const objectVariable = current.object.type ===
|
|
15288
|
+
const objectVariable = current.object.type === AST_NODE_TYPES58.Identifier ? ASTUtils18.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
15199
15289
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
15200
15290
|
pinned.add(target);
|
|
15201
15291
|
return;
|
|
15202
15292
|
}
|
|
15203
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
15293
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== AST_NODE_TYPES58.CallExpression || current.parent.callee !== current) {
|
|
15204
15294
|
pinned.add(target);
|
|
15205
15295
|
return;
|
|
15206
15296
|
}
|
|
@@ -15220,9 +15310,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15220
15310
|
}
|
|
15221
15311
|
}
|
|
15222
15312
|
for (const member of node.body.body) {
|
|
15223
|
-
if (member.type ===
|
|
15313
|
+
if (member.type === AST_NODE_TYPES58.MethodDefinition || member.type === AST_NODE_TYPES58.TSAbstractMethodDefinition) continue;
|
|
15224
15314
|
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
15225
|
-
if (current.type !==
|
|
15315
|
+
if (current.type !== AST_NODE_TYPES58.MemberExpression) return;
|
|
15226
15316
|
const target = referencedMethod(context, current, classVariables);
|
|
15227
15317
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
15228
15318
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -15232,14 +15322,14 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15232
15322
|
const accessibility = new Map(
|
|
15233
15323
|
scopeDefinitions.map((definition) => {
|
|
15234
15324
|
const method = definition.node;
|
|
15235
|
-
const accessibility2 = method.key.type ===
|
|
15325
|
+
const accessibility2 = method.key.type === AST_NODE_TYPES58.PrivateIdentifier ? "private" : method.accessibility ?? "public";
|
|
15236
15326
|
return [definition.name, accessibility2];
|
|
15237
15327
|
})
|
|
15238
15328
|
);
|
|
15239
15329
|
const methodByName = new Map(scopeDefinitions.map((definition) => [definition.name, definition.node]));
|
|
15240
15330
|
for (const [caller, callees] of calls) {
|
|
15241
15331
|
const callerMethod = methodByName.get(caller);
|
|
15242
|
-
if (accessibility.get(caller) === "private" && callerMethod?.type ===
|
|
15332
|
+
if (accessibility.get(caller) === "private" && callerMethod?.type === AST_NODE_TYPES58.MethodDefinition && callerMethod.decorators.length === 0) continue;
|
|
15243
15333
|
for (const callee of callees) pinned.add(callee);
|
|
15244
15334
|
}
|
|
15245
15335
|
const memberIndexes = new Map(node.body.body.map((member, index) => [member, index]));
|
|
@@ -15256,12 +15346,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
15256
15346
|
}
|
|
15257
15347
|
function isClassRuntimeBarrier(member) {
|
|
15258
15348
|
switch (member.type) {
|
|
15259
|
-
case
|
|
15349
|
+
case AST_NODE_TYPES58.StaticBlock:
|
|
15260
15350
|
return true;
|
|
15261
|
-
case
|
|
15262
|
-
case
|
|
15351
|
+
case AST_NODE_TYPES58.PropertyDefinition:
|
|
15352
|
+
case AST_NODE_TYPES58.AccessorProperty:
|
|
15263
15353
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
15264
|
-
case
|
|
15354
|
+
case AST_NODE_TYPES58.MethodDefinition:
|
|
15265
15355
|
return member.computed || member.decorators.length > 0;
|
|
15266
15356
|
default:
|
|
15267
15357
|
return false;
|
|
@@ -15293,7 +15383,7 @@ var stepdown_default = createRule({
|
|
|
15293
15383
|
moduleScope(context, program);
|
|
15294
15384
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
15295
15385
|
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
15296
|
-
if (node.type ===
|
|
15386
|
+
if (node.type === AST_NODE_TYPES58.MemberExpression && node.computed && node.property.type === AST_NODE_TYPES58.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
15297
15387
|
});
|
|
15298
15388
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
15299
15389
|
}
|
|
@@ -15302,7 +15392,7 @@ var stepdown_default = createRule({
|
|
|
15302
15392
|
});
|
|
15303
15393
|
|
|
15304
15394
|
// src/rules/source-coupled-test.ts
|
|
15305
|
-
import { AST_NODE_TYPES as
|
|
15395
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES59 } from "@typescript-eslint/utils";
|
|
15306
15396
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|py|[cm]?[jt]s)$/iu;
|
|
15307
15397
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
15308
15398
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -15371,20 +15461,20 @@ var sourceCoupledTestDocumentation = {
|
|
|
15371
15461
|
]
|
|
15372
15462
|
};
|
|
15373
15463
|
function staticMemberName7(node) {
|
|
15374
|
-
if (!node.computed && node.property.type ===
|
|
15375
|
-
if (node.computed && node.property.type ===
|
|
15464
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES59.Identifier) return node.property.name;
|
|
15465
|
+
if (node.computed && node.property.type === AST_NODE_TYPES59.Literal && typeof node.property.value === "string") return node.property.value;
|
|
15376
15466
|
return null;
|
|
15377
15467
|
}
|
|
15378
15468
|
function unwrap5(node) {
|
|
15379
|
-
if (node.type ===
|
|
15380
|
-
if (node.type ===
|
|
15381
|
-
if (node.type ===
|
|
15469
|
+
if (node.type === AST_NODE_TYPES59.AwaitExpression) return unwrap5(node.argument);
|
|
15470
|
+
if (node.type === AST_NODE_TYPES59.ChainExpression) return unwrap5(node.expression);
|
|
15471
|
+
if (node.type === AST_NODE_TYPES59.TSAsExpression || node.type === AST_NODE_TYPES59.TSNonNullExpression || node.type === AST_NODE_TYPES59.TSTypeAssertion) return unwrap5(node.expression);
|
|
15382
15472
|
return node;
|
|
15383
15473
|
}
|
|
15384
15474
|
function stringValue(node) {
|
|
15385
15475
|
const current = unwrap5(node);
|
|
15386
|
-
if (current.type ===
|
|
15387
|
-
if (current.type ===
|
|
15476
|
+
if (current.type === AST_NODE_TYPES59.Literal && typeof current.value === "string") return current.value;
|
|
15477
|
+
if (current.type === AST_NODE_TYPES59.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
15388
15478
|
return null;
|
|
15389
15479
|
}
|
|
15390
15480
|
function importSource(node) {
|
|
@@ -15392,7 +15482,7 @@ function importSource(node) {
|
|
|
15392
15482
|
}
|
|
15393
15483
|
function requireSource(node) {
|
|
15394
15484
|
const current = unwrap5(node);
|
|
15395
|
-
if (current.type !==
|
|
15485
|
+
if (current.type !== AST_NODE_TYPES59.CallExpression || current.callee.type !== AST_NODE_TYPES59.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === AST_NODE_TYPES59.SpreadElement) return null;
|
|
15396
15486
|
return stringValue(current.arguments[0]);
|
|
15397
15487
|
}
|
|
15398
15488
|
function newScope() {
|
|
@@ -15432,38 +15522,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15432
15522
|
const current = unwrap5(node);
|
|
15433
15523
|
const value = stringValue(current);
|
|
15434
15524
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
15435
|
-
if (current.type ===
|
|
15436
|
-
if (current.type ===
|
|
15525
|
+
if (current.type === AST_NODE_TYPES59.Identifier) return visible("paths", current.name);
|
|
15526
|
+
if (current.type === AST_NODE_TYPES59.BinaryExpression && current.operator === "+") {
|
|
15437
15527
|
return sourcePath(current.left) || sourcePath(current.right);
|
|
15438
15528
|
}
|
|
15439
|
-
if (current.type ===
|
|
15440
|
-
if (current.type ===
|
|
15441
|
-
return current.arguments.some((argument) => argument.type !==
|
|
15529
|
+
if (current.type === AST_NODE_TYPES59.TemplateLiteral) return current.expressions.some(sourcePath);
|
|
15530
|
+
if (current.type === AST_NODE_TYPES59.CallExpression || current.type === AST_NODE_TYPES59.NewExpression) {
|
|
15531
|
+
return current.arguments.some((argument) => argument.type !== AST_NODE_TYPES59.SpreadElement && sourcePath(argument));
|
|
15442
15532
|
}
|
|
15443
|
-
if (current.type ===
|
|
15533
|
+
if (current.type === AST_NODE_TYPES59.MemberExpression) return sourcePath(current.object);
|
|
15444
15534
|
return false;
|
|
15445
15535
|
};
|
|
15446
15536
|
const rawRead = (node) => {
|
|
15447
15537
|
const current = unwrap5(node);
|
|
15448
|
-
if (current.type !==
|
|
15538
|
+
if (current.type !== AST_NODE_TYPES59.CallExpression || current.arguments.length === 0) return false;
|
|
15449
15539
|
const callee = unwrap5(current.callee);
|
|
15450
|
-
if (callee.type ===
|
|
15540
|
+
if (callee.type === AST_NODE_TYPES59.Identifier) {
|
|
15451
15541
|
return visible("fsReaders", callee.name) && sourcePath(current.arguments[0]);
|
|
15452
15542
|
}
|
|
15453
|
-
if (callee.type !==
|
|
15543
|
+
if (callee.type !== AST_NODE_TYPES59.MemberExpression) return false;
|
|
15454
15544
|
const name2 = staticMemberName7(callee);
|
|
15455
15545
|
const object = unwrap5(callee.object);
|
|
15456
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
15546
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === AST_NODE_TYPES59.Identifier && visible("fsObjects", object.name) && sourcePath(current.arguments[0]);
|
|
15457
15547
|
};
|
|
15458
15548
|
const rawOrigins = (node) => {
|
|
15459
15549
|
const current = unwrap5(node);
|
|
15460
|
-
if (current.type ===
|
|
15550
|
+
if (current.type === AST_NODE_TYPES59.Identifier) return visibleRawOrigins(current.name);
|
|
15461
15551
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
15462
|
-
if (current.type ===
|
|
15463
|
-
if (current.type ===
|
|
15464
|
-
if (current.type !==
|
|
15552
|
+
if (current.type === AST_NODE_TYPES59.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
15553
|
+
if (current.type === AST_NODE_TYPES59.MemberExpression && staticMemberName7(current) === "length") return rawOrigins(current.object);
|
|
15554
|
+
if (current.type !== AST_NODE_TYPES59.CallExpression) return /* @__PURE__ */ new Set();
|
|
15465
15555
|
const callee = unwrap5(current.callee);
|
|
15466
|
-
if (callee.type !==
|
|
15556
|
+
if (callee.type !== AST_NODE_TYPES59.MemberExpression) return /* @__PURE__ */ new Set();
|
|
15467
15557
|
const name2 = staticMemberName7(callee);
|
|
15468
15558
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(callee.object) : /* @__PURE__ */ new Set();
|
|
15469
15559
|
};
|
|
@@ -15471,38 +15561,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15471
15561
|
const current = unwrap5(node);
|
|
15472
15562
|
const direct = rawOrigins(current);
|
|
15473
15563
|
if (direct.size > 0) return direct;
|
|
15474
|
-
if (current.type ===
|
|
15475
|
-
if (current.type ===
|
|
15476
|
-
if (current.type !==
|
|
15564
|
+
if (current.type === AST_NODE_TYPES59.BinaryExpression || current.type === AST_NODE_TYPES59.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
15565
|
+
if (current.type === AST_NODE_TYPES59.UnaryExpression) return evidenceOrigins(current.argument);
|
|
15566
|
+
if (current.type !== AST_NODE_TYPES59.CallExpression) return /* @__PURE__ */ new Set();
|
|
15477
15567
|
const callee = unwrap5(current.callee);
|
|
15478
|
-
if (callee.type !==
|
|
15568
|
+
if (callee.type !== AST_NODE_TYPES59.MemberExpression) return /* @__PURE__ */ new Set();
|
|
15479
15569
|
const name2 = staticMemberName7(callee);
|
|
15480
15570
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(callee.object);
|
|
15481
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
15571
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES59.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
15482
15572
|
return /* @__PURE__ */ new Set();
|
|
15483
15573
|
};
|
|
15484
15574
|
const rawAssertionOrigins = (node) => {
|
|
15485
15575
|
const callee = unwrap5(node.callee);
|
|
15486
|
-
if (callee.type ===
|
|
15487
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
15576
|
+
if (callee.type === AST_NODE_TYPES59.Identifier && callee.name === "assert") {
|
|
15577
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES59.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
15488
15578
|
}
|
|
15489
|
-
if (callee.type !==
|
|
15579
|
+
if (callee.type !== AST_NODE_TYPES59.MemberExpression) return /* @__PURE__ */ new Set();
|
|
15490
15580
|
const matcher = staticMemberName7(callee);
|
|
15491
15581
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
15492
15582
|
let receiver = unwrap5(callee.object);
|
|
15493
|
-
while (receiver.type ===
|
|
15494
|
-
if (receiver.type ===
|
|
15583
|
+
while (receiver.type === AST_NODE_TYPES59.MemberExpression && EXPECT_MODIFIERS2.has(staticMemberName7(receiver) ?? "")) receiver = unwrap5(receiver.object);
|
|
15584
|
+
if (receiver.type === AST_NODE_TYPES59.CallExpression && receiver.callee.type === AST_NODE_TYPES59.Identifier && receiver.callee.name === "expect") {
|
|
15495
15585
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
15496
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
15586
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === AST_NODE_TYPES59.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
15497
15587
|
}
|
|
15498
|
-
if (receiver.type !==
|
|
15499
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
15588
|
+
if (receiver.type !== AST_NODE_TYPES59.Identifier || receiver.name !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
15589
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES59.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
15500
15590
|
};
|
|
15501
15591
|
const rawRegexExtractionOrigins = (node) => {
|
|
15502
15592
|
const callee = unwrap5(node.callee);
|
|
15503
|
-
if (callee.type !==
|
|
15593
|
+
if (callee.type !== AST_NODE_TYPES59.MemberExpression || staticMemberName7(callee) !== "matchAll" || node.arguments.length !== 1) return /* @__PURE__ */ new Set();
|
|
15504
15594
|
const argument = node.arguments[0];
|
|
15505
|
-
if (argument?.type !==
|
|
15595
|
+
if (argument?.type !== AST_NODE_TYPES59.Literal || !(argument.value instanceof RegExp)) return /* @__PURE__ */ new Set();
|
|
15506
15596
|
return rawOrigins(callee.object);
|
|
15507
15597
|
};
|
|
15508
15598
|
const declare = (name2, state) => {
|
|
@@ -15523,15 +15613,15 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15523
15613
|
};
|
|
15524
15614
|
const sourceCollection = (node) => {
|
|
15525
15615
|
const current = unwrap5(node);
|
|
15526
|
-
return current.type ===
|
|
15616
|
+
return current.type === AST_NODE_TYPES59.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== AST_NODE_TYPES59.SpreadElement && sourcePath(element));
|
|
15527
15617
|
};
|
|
15528
15618
|
const declaredNames2 = (node) => {
|
|
15529
15619
|
const current = unwrap5(node);
|
|
15530
|
-
if (current.type ===
|
|
15531
|
-
if (current.type ===
|
|
15532
|
-
if (current.type ===
|
|
15533
|
-
if (current.type ===
|
|
15534
|
-
if (current.type ===
|
|
15620
|
+
if (current.type === AST_NODE_TYPES59.Identifier) return [current.name];
|
|
15621
|
+
if (current.type === AST_NODE_TYPES59.AssignmentPattern) return declaredNames2(current.left);
|
|
15622
|
+
if (current.type === AST_NODE_TYPES59.RestElement) return declaredNames2(current.argument);
|
|
15623
|
+
if (current.type === AST_NODE_TYPES59.ArrayPattern) return current.elements.flatMap((element) => element === null ? [] : declaredNames2(element));
|
|
15624
|
+
if (current.type === AST_NODE_TYPES59.ObjectPattern) return current.properties.flatMap((property) => property.type === AST_NODE_TYPES59.RestElement ? declaredNames2(property.argument) : declaredNames2(property.value));
|
|
15535
15625
|
return [];
|
|
15536
15626
|
};
|
|
15537
15627
|
const enterFunction = (node) => {
|
|
@@ -15546,8 +15636,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15546
15636
|
const source = importSource(node);
|
|
15547
15637
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
15548
15638
|
for (const specifier of node.specifiers) {
|
|
15549
|
-
if (specifier.type ===
|
|
15550
|
-
const imported = specifier.imported.type ===
|
|
15639
|
+
if (specifier.type === AST_NODE_TYPES59.ImportSpecifier) {
|
|
15640
|
+
const imported = specifier.imported.type === AST_NODE_TYPES59.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
15551
15641
|
if (FS_READERS.has(imported)) declare(specifier.local.name, { fsReader: true });
|
|
15552
15642
|
} else {
|
|
15553
15643
|
declare(specifier.local.name, { fsObject: true });
|
|
@@ -15559,29 +15649,29 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
15559
15649
|
VariableDeclarator(node) {
|
|
15560
15650
|
if (node.init === null) return;
|
|
15561
15651
|
const required = requireSource(node.init);
|
|
15562
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
15652
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === AST_NODE_TYPES59.Identifier) {
|
|
15563
15653
|
declare(node.id.name, { fsObject: true });
|
|
15564
15654
|
return;
|
|
15565
15655
|
}
|
|
15566
|
-
if (node.id.type ===
|
|
15656
|
+
if (node.id.type === AST_NODE_TYPES59.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
15567
15657
|
for (const property of node.id.properties) {
|
|
15568
|
-
if (property.type !==
|
|
15569
|
-
const key = property.key.type ===
|
|
15658
|
+
if (property.type !== AST_NODE_TYPES59.Property || property.value.type !== AST_NODE_TYPES59.Identifier) continue;
|
|
15659
|
+
const key = property.key.type === AST_NODE_TYPES59.Identifier ? property.key.name : property.key.type === AST_NODE_TYPES59.Literal ? String(property.key.value) : "";
|
|
15570
15660
|
if (FS_READERS.has(key)) declare(property.value.name, { fsReader: true });
|
|
15571
15661
|
}
|
|
15572
15662
|
return;
|
|
15573
15663
|
}
|
|
15574
|
-
if (node.id.type !==
|
|
15664
|
+
if (node.id.type !== AST_NODE_TYPES59.Identifier) return;
|
|
15575
15665
|
declare(node.id.name, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
15576
15666
|
},
|
|
15577
15667
|
AssignmentExpression(node) {
|
|
15578
|
-
if (node.left.type ===
|
|
15668
|
+
if (node.left.type === AST_NODE_TYPES59.Identifier) declare(node.left.name, { path: sourcePath(node.right), rawOrigins: rawOrigins(node.right) });
|
|
15579
15669
|
},
|
|
15580
15670
|
ForOfStatement(node) {
|
|
15581
15671
|
const right = unwrap5(node.right);
|
|
15582
|
-
const collection = right.type ===
|
|
15583
|
-
const left = node.left.type ===
|
|
15584
|
-
if (collection && left?.type ===
|
|
15672
|
+
const collection = right.type === AST_NODE_TYPES59.Identifier && visible("collections", right.name);
|
|
15673
|
+
const left = node.left.type === AST_NODE_TYPES59.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
15674
|
+
if (collection && left?.type === AST_NODE_TYPES59.Identifier) declare(left.name, { path: true });
|
|
15585
15675
|
},
|
|
15586
15676
|
CallExpression(node) {
|
|
15587
15677
|
const origins = /* @__PURE__ */ new Set([
|
|
@@ -15642,7 +15732,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
15642
15732
|
|
|
15643
15733
|
// src/rules/zod-naming-convention.ts
|
|
15644
15734
|
import {
|
|
15645
|
-
AST_NODE_TYPES as
|
|
15735
|
+
AST_NODE_TYPES as AST_NODE_TYPES60,
|
|
15646
15736
|
ASTUtils as ASTUtils19
|
|
15647
15737
|
} from "@typescript-eslint/utils";
|
|
15648
15738
|
var zodNamingConventionDocumentation = {
|
|
@@ -15685,18 +15775,18 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
15685
15775
|
"prettifyError",
|
|
15686
15776
|
"treeifyError"
|
|
15687
15777
|
]);
|
|
15688
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
15778
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES60.Identifier ? callee.property.name : null;
|
|
15689
15779
|
var calleeChainRoot = (node) => {
|
|
15690
15780
|
let current = node;
|
|
15691
15781
|
for (; ; ) {
|
|
15692
|
-
if (current.type ===
|
|
15782
|
+
if (current.type === AST_NODE_TYPES60.Identifier) {
|
|
15693
15783
|
return current;
|
|
15694
15784
|
}
|
|
15695
|
-
if (current.type ===
|
|
15785
|
+
if (current.type === AST_NODE_TYPES60.MemberExpression) {
|
|
15696
15786
|
current = current.object;
|
|
15697
15787
|
continue;
|
|
15698
15788
|
}
|
|
15699
|
-
if (current.type ===
|
|
15789
|
+
if (current.type === AST_NODE_TYPES60.CallExpression) {
|
|
15700
15790
|
current = current.callee;
|
|
15701
15791
|
continue;
|
|
15702
15792
|
}
|
|
@@ -15758,7 +15848,7 @@ var zod_naming_convention_default = createRule({
|
|
|
15758
15848
|
ImportDeclaration(node) {
|
|
15759
15849
|
if (!isZodModule(node.source.value)) return;
|
|
15760
15850
|
for (const specifier of node.specifiers) {
|
|
15761
|
-
if (specifier.type ===
|
|
15851
|
+
if (specifier.type === AST_NODE_TYPES60.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES60.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES60.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES60.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
15762
15852
|
recordZodBinding(specifier.local);
|
|
15763
15853
|
}
|
|
15764
15854
|
}
|
|
@@ -15766,13 +15856,13 @@ var zod_naming_convention_default = createRule({
|
|
|
15766
15856
|
VariableDeclarator(node) {
|
|
15767
15857
|
const init = node.init;
|
|
15768
15858
|
if (init === null || init === void 0) return;
|
|
15769
|
-
if (init.type !==
|
|
15859
|
+
if (init.type !== AST_NODE_TYPES60.CallExpression) return;
|
|
15770
15860
|
const callee = init.callee;
|
|
15771
|
-
if (callee.type !==
|
|
15861
|
+
if (callee.type !== AST_NODE_TYPES60.MemberExpression) return;
|
|
15772
15862
|
if (!isZodChain(callee)) return;
|
|
15773
15863
|
const terminal = terminalMethodName(callee);
|
|
15774
15864
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
15775
|
-
if (node.id.type !==
|
|
15865
|
+
if (node.id.type !== AST_NODE_TYPES60.Identifier) return;
|
|
15776
15866
|
if (test.test(node.id.name)) return;
|
|
15777
15867
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
15778
15868
|
context.report({
|
|
@@ -15910,6 +16000,7 @@ var rules = {
|
|
|
15910
16000
|
"no-unsafe-mock-casting": no_unsafe_mock_casting_default,
|
|
15911
16001
|
"no-zod-native-enum": no_zod_native_enum_default,
|
|
15912
16002
|
"test-loops-over-literal-cases": test_loops_over_literal_cases_default,
|
|
16003
|
+
"test-phase-label-comment": test_phase_label_comment_default,
|
|
15913
16004
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
15914
16005
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
15915
16006
|
"prefer-input-group-search": prefer_input_group_search_default,
|
|
@@ -15938,7 +16029,7 @@ var rules = {
|
|
|
15938
16029
|
};
|
|
15939
16030
|
var meta = {
|
|
15940
16031
|
name: "@sarj/eslint-plugin",
|
|
15941
|
-
version: "15.
|
|
16032
|
+
version: "15.10.0"
|
|
15942
16033
|
};
|
|
15943
16034
|
var applicationOnlyRules = [
|
|
15944
16035
|
"no-restricted-library-load",
|
|
@@ -15949,7 +16040,8 @@ var advisoryRules = [
|
|
|
15949
16040
|
"no-bare-return-from-test-catch",
|
|
15950
16041
|
"iac-source-coupled-test",
|
|
15951
16042
|
"repeated-static-call-cases",
|
|
15952
|
-
"source-coupled-test"
|
|
16043
|
+
"source-coupled-test",
|
|
16044
|
+
"test-phase-label-comment"
|
|
15953
16045
|
];
|
|
15954
16046
|
var recommendedRules = {
|
|
15955
16047
|
"@sarj/iac-source-coupled-test": "warn",
|
|
@@ -16013,6 +16105,7 @@ var recommendedRules = {
|
|
|
16013
16105
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
16014
16106
|
"@sarj/stepdown": "error",
|
|
16015
16107
|
"@sarj/source-coupled-test": "warn",
|
|
16108
|
+
"@sarj/test-phase-label-comment": "warn",
|
|
16016
16109
|
"@sarj/zod-naming-convention": "error"
|
|
16017
16110
|
};
|
|
16018
16111
|
var strictRules = {
|
|
@@ -16081,6 +16174,7 @@ var strictRules = {
|
|
|
16081
16174
|
"@sarj/store-insert-requires-on-conflict": "error",
|
|
16082
16175
|
"@sarj/stepdown": "error",
|
|
16083
16176
|
"@sarj/source-coupled-test": "warn",
|
|
16177
|
+
"@sarj/test-phase-label-comment": "warn",
|
|
16084
16178
|
"@sarj/zod-naming-convention": "error"
|
|
16085
16179
|
};
|
|
16086
16180
|
var plugin = {
|