@sarj/eslint-plugin 16.22.0 → 16.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +50 -128
- package/dist/index.js +354 -432
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -819,7 +819,7 @@ function isSearchParamReceiver(call, services) {
|
|
|
819
819
|
// package.json
|
|
820
820
|
var package_default = {
|
|
821
821
|
name: "@sarj/eslint-plugin",
|
|
822
|
-
version: "16.22.
|
|
822
|
+
version: "16.22.1",
|
|
823
823
|
packageManager: "npm@12.2.0",
|
|
824
824
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
825
825
|
type: "module",
|
|
@@ -7252,17 +7252,17 @@ var no_dangerously_allow_svg_default = createRule({
|
|
|
7252
7252
|
});
|
|
7253
7253
|
|
|
7254
7254
|
// src/rules/no-dynamic-sql.ts
|
|
7255
|
-
import { ASTUtils as
|
|
7255
|
+
import { ASTUtils as ASTUtils21, AST_NODE_TYPES as AST_NODE_TYPES40 } from "@typescript-eslint/utils";
|
|
7256
7256
|
|
|
7257
7257
|
// src/rules/_sql.ts
|
|
7258
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES39 } from "@typescript-eslint/utils";
|
|
7258
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39, ASTUtils as ASTUtils20 } from "@typescript-eslint/utils";
|
|
7259
7259
|
function stripSqlNoise(text) {
|
|
7260
7260
|
return scanSqlNoise(text);
|
|
7261
7261
|
}
|
|
7262
|
-
function
|
|
7263
|
-
const
|
|
7264
|
-
scanSqlNoise(text, (start, end) =>
|
|
7265
|
-
return
|
|
7262
|
+
function sqlNoiseInfo(text) {
|
|
7263
|
+
const singleQuotedRanges = [];
|
|
7264
|
+
const masked = scanSqlNoise(text, (start, end) => singleQuotedRanges.push([start, end]));
|
|
7265
|
+
return { text: masked, singleQuotedRanges };
|
|
7266
7266
|
}
|
|
7267
7267
|
function scanSqlNoise(text, onSingleQuoted) {
|
|
7268
7268
|
const out = text.split("");
|
|
@@ -7348,6 +7348,7 @@ function maskSqlRange(text, out, start, end) {
|
|
|
7348
7348
|
}
|
|
7349
7349
|
var SUBSTITUTION_MARKER = "?";
|
|
7350
7350
|
function sqlTextOf(node) {
|
|
7351
|
+
node = unwrapExpression(node);
|
|
7351
7352
|
switch (node.type) {
|
|
7352
7353
|
case AST_NODE_TYPES39.Literal:
|
|
7353
7354
|
return typeof node.value === "string" ? node.value : null;
|
|
@@ -7375,7 +7376,7 @@ function fragmentArrayText(node) {
|
|
|
7375
7376
|
if (separator === null) return null;
|
|
7376
7377
|
const parts = [];
|
|
7377
7378
|
for (const element of node.elements) {
|
|
7378
|
-
if (element === null || join4 !== null && element.type === AST_NODE_TYPES39.ArrayExpression) {
|
|
7379
|
+
if (element === null || join4 !== null && unwrapExpression(element).type === AST_NODE_TYPES39.ArrayExpression) {
|
|
7379
7380
|
return null;
|
|
7380
7381
|
}
|
|
7381
7382
|
const part = sqlTextOf(element);
|
|
@@ -7387,8 +7388,10 @@ function fragmentArrayText(node) {
|
|
|
7387
7388
|
return parts.length > 0 ? parts.join(separator) : null;
|
|
7388
7389
|
}
|
|
7389
7390
|
function joinedFragmentCall(node) {
|
|
7390
|
-
const
|
|
7391
|
-
|
|
7391
|
+
const value = outerExpression(node);
|
|
7392
|
+
const parent = value.parent;
|
|
7393
|
+
const callee = parent?.type === AST_NODE_TYPES39.MemberExpression ? outerExpression(parent) : null;
|
|
7394
|
+
return parent?.type === AST_NODE_TYPES39.MemberExpression && parent.object === value && ASTUtils20.getPropertyName(parent) === "join" && callee?.parent?.type === AST_NODE_TYPES39.CallExpression && callee.parent.callee === callee ? callee.parent : null;
|
|
7392
7395
|
}
|
|
7393
7396
|
function markConsumed(node, consumed) {
|
|
7394
7397
|
consumed.add(node);
|
|
@@ -7430,6 +7433,8 @@ function createSqlListener(handler) {
|
|
|
7430
7433
|
markConsumed(node, consumed);
|
|
7431
7434
|
const separator = join4.arguments[0];
|
|
7432
7435
|
if (separator !== void 0 && staticString(separator) !== null) markConsumed(separator, consumed);
|
|
7436
|
+
const member = unwrapExpression(join4.callee);
|
|
7437
|
+
if (member.type === AST_NODE_TYPES39.MemberExpression && member.computed) markConsumed(member.property, consumed);
|
|
7433
7438
|
},
|
|
7434
7439
|
TemplateLiteral: (node) => {
|
|
7435
7440
|
visit(node);
|
|
@@ -7440,11 +7445,11 @@ function createSqlListener(handler) {
|
|
|
7440
7445
|
};
|
|
7441
7446
|
}
|
|
7442
7447
|
function isDiscardedSqlText(node) {
|
|
7443
|
-
let current = node;
|
|
7448
|
+
let current = outerExpression(node);
|
|
7444
7449
|
let parent = current.parent;
|
|
7445
7450
|
while (parent !== void 0 && parent !== null) {
|
|
7446
|
-
if (
|
|
7447
|
-
current = parent;
|
|
7451
|
+
if (parent.type === AST_NODE_TYPES39.BinaryExpression && parent.operator === "+") {
|
|
7452
|
+
current = outerExpression(parent);
|
|
7448
7453
|
parent = current.parent;
|
|
7449
7454
|
continue;
|
|
7450
7455
|
}
|
|
@@ -7512,8 +7517,8 @@ function isStaticFragment(expression) {
|
|
|
7512
7517
|
if (expression.type === AST_NODE_TYPES40.Identifier) {
|
|
7513
7518
|
return CONSTANT_CASE_RE.test(expression.name);
|
|
7514
7519
|
}
|
|
7515
|
-
if (expression.type === AST_NODE_TYPES40.MemberExpression &&
|
|
7516
|
-
return CONSTANT_CASE_RE.test(
|
|
7520
|
+
if (expression.type === AST_NODE_TYPES40.MemberExpression && ASTUtils21.getPropertyName(expression) !== null) {
|
|
7521
|
+
return CONSTANT_CASE_RE.test(ASTUtils21.getPropertyName(expression) ?? "");
|
|
7517
7522
|
}
|
|
7518
7523
|
if (expression.type === AST_NODE_TYPES40.Literal) {
|
|
7519
7524
|
return typeof expression.value === "string";
|
|
@@ -7526,8 +7531,7 @@ function isStaticFragment(expression) {
|
|
|
7526
7531
|
function runtimeInterpolations(template) {
|
|
7527
7532
|
const parts = template.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw);
|
|
7528
7533
|
const statement = parts.join(RUNTIME_MARKER);
|
|
7529
|
-
const ranges =
|
|
7530
|
-
const visible = stripSqlNoise(statement);
|
|
7534
|
+
const { singleQuotedRanges: ranges, text: visible } = sqlNoiseInfo(statement);
|
|
7531
7535
|
let offset = 0;
|
|
7532
7536
|
return template.expressions.flatMap(
|
|
7533
7537
|
(expression, index) => {
|
|
@@ -7548,16 +7552,13 @@ function runtimeConcatOperands(node) {
|
|
|
7548
7552
|
return [];
|
|
7549
7553
|
}
|
|
7550
7554
|
const operands = concatOperands(node);
|
|
7551
|
-
const hasStringLiteral = operands.some(
|
|
7552
|
-
(operand) => operand.type === AST_NODE_TYPES40.Literal && typeof operand.value === "string" || operand.type === AST_NODE_TYPES40.TemplateLiteral && operand.expressions.length === 0
|
|
7553
|
-
);
|
|
7555
|
+
const hasStringLiteral = operands.some((operand) => staticString(operand) !== null);
|
|
7554
7556
|
if (!hasStringLiteral) {
|
|
7555
7557
|
return [];
|
|
7556
7558
|
}
|
|
7557
7559
|
const parts = operands.map((operand) => staticString(operand) ?? RUNTIME_MARKER);
|
|
7558
7560
|
const statement = parts.join("");
|
|
7559
|
-
const ranges =
|
|
7560
|
-
const visible = stripSqlNoise(statement);
|
|
7561
|
+
const { singleQuotedRanges: ranges, text: visible } = sqlNoiseInfo(statement);
|
|
7561
7562
|
let offset = 0;
|
|
7562
7563
|
return operands.flatMap((operand, index) => {
|
|
7563
7564
|
const inValue = ranges.some(([start, end]) => start < offset && offset < end);
|
|
@@ -7571,10 +7572,17 @@ function runtimeConcatOperands(node) {
|
|
|
7571
7572
|
});
|
|
7572
7573
|
}
|
|
7573
7574
|
function concatOperands(node) {
|
|
7574
|
-
|
|
7575
|
-
|
|
7575
|
+
const operands = [];
|
|
7576
|
+
const pending = [node];
|
|
7577
|
+
while (pending.length > 0) {
|
|
7578
|
+
const next = pending.pop();
|
|
7579
|
+
if (next === void 0) continue;
|
|
7580
|
+
const value = unwrapExpression(next);
|
|
7581
|
+
if (value.type === AST_NODE_TYPES40.BinaryExpression && value.operator === "+") {
|
|
7582
|
+
pending.push(value.right, value.left);
|
|
7583
|
+
} else operands.push(value);
|
|
7576
7584
|
}
|
|
7577
|
-
return
|
|
7585
|
+
return operands;
|
|
7578
7586
|
}
|
|
7579
7587
|
var SQL_STATEMENT_RE = /\b(?:select\s|insert\s+into\b|insert\s+or\b|update\s+\w|delete\s+from\b|replace\s+into\b|merge\s+into\b|upsert\s+into\b|create\s+(?:temp(?:orary)?\s+)?(?:table|index|view|trigger|schema|database)\b|alter\s+table\b|drop\s+(?:table|index|view|trigger)\b|truncate\s+table\b|pragma\s+\w|with\s+\w+\s+as\s*\(|from\s+\w+\s+where\b)/i;
|
|
7580
7588
|
var RUNTIME_MARKER = " ? ";
|
|
@@ -7582,6 +7590,7 @@ function looksLikeSql(node) {
|
|
|
7582
7590
|
return SQL_STATEMENT_RE.test(stripSqlNoise(staticStatementText(node)));
|
|
7583
7591
|
}
|
|
7584
7592
|
function staticStatementText(node) {
|
|
7593
|
+
node = unwrapExpression(node);
|
|
7585
7594
|
if (node.type === AST_NODE_TYPES40.TemplateLiteral) {
|
|
7586
7595
|
return node.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join(RUNTIME_MARKER);
|
|
7587
7596
|
}
|
|
@@ -7595,10 +7604,10 @@ function staticStatementText(node) {
|
|
|
7595
7604
|
}
|
|
7596
7605
|
function statementMethodName(node, methods) {
|
|
7597
7606
|
const callee = unwrapExpression(node.callee);
|
|
7598
|
-
if (callee.type !== AST_NODE_TYPES40.MemberExpression ||
|
|
7607
|
+
if (callee.type !== AST_NODE_TYPES40.MemberExpression || ASTUtils21.getPropertyName(callee) === null) {
|
|
7599
7608
|
return null;
|
|
7600
7609
|
}
|
|
7601
|
-
const name =
|
|
7610
|
+
const name = ASTUtils21.getPropertyName(callee) ?? "";
|
|
7602
7611
|
return methods.has(name) ? name : null;
|
|
7603
7612
|
}
|
|
7604
7613
|
var no_dynamic_sql_default = createRule({
|
|
@@ -8307,7 +8316,7 @@ var no_fat_try_blocks_default = createRule({
|
|
|
8307
8316
|
});
|
|
8308
8317
|
|
|
8309
8318
|
// src/rules/no-hand-rolled-sleep.ts
|
|
8310
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES43, ASTUtils as
|
|
8319
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43, ASTUtils as ASTUtils22 } from "@typescript-eslint/utils";
|
|
8311
8320
|
var NO_HAND_ROLLED_SLEEP_DOCUMENTATION = {
|
|
8312
8321
|
summary: "Disallow uncancellable promisified timers and timeout arms.",
|
|
8313
8322
|
rationale: "A timer that outlives an aborted operation or a lost promise race retains work and can keep the process alive until it fires.",
|
|
@@ -8458,7 +8467,7 @@ var no_hand_rolled_sleep_default = createRule({
|
|
|
8458
8467
|
return {};
|
|
8459
8468
|
}
|
|
8460
8469
|
const checkClientModules = optionsArg?.checkClientModules ?? false;
|
|
8461
|
-
const bindingOf = (identifier) =>
|
|
8470
|
+
const bindingOf = (identifier) => ASTUtils22.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
8462
8471
|
const isGlobal = (identifier) => (bindingOf(identifier)?.defs.length ?? 0) === 0;
|
|
8463
8472
|
const isBuiltinTimer = (callee) => {
|
|
8464
8473
|
callee = unwrapExpression(callee);
|
|
@@ -8625,7 +8634,7 @@ var no_hand_rolled_spinner_default = createRule({
|
|
|
8625
8634
|
});
|
|
8626
8635
|
|
|
8627
8636
|
// src/rules/no-insecure-random-id.ts
|
|
8628
|
-
import { ASTUtils as
|
|
8637
|
+
import { ASTUtils as ASTUtils23 } from "@typescript-eslint/utils";
|
|
8629
8638
|
var NO_INSECURE_RANDOM_ID_DOCUMENTATION = {
|
|
8630
8639
|
summary: "Disallow using `Math.random()` to generate identifiers, tokens, or secrets; use `crypto.randomUUID()` or `crypto.getRandomValues(...)` instead.",
|
|
8631
8640
|
rationale: "Math.random is predictable and lacks the entropy required for security-sensitive values.",
|
|
@@ -8651,46 +8660,15 @@ var STRONG_SECURITY_WORDS = /* @__PURE__ */ new Set([
|
|
|
8651
8660
|
"uuid",
|
|
8652
8661
|
"verificationcode"
|
|
8653
8662
|
]);
|
|
8654
|
-
var NON_SECURITY_ID_WORDS = /* @__PURE__ */ new Set([
|
|
8655
|
-
"aria",
|
|
8656
|
-
"cache",
|
|
8657
|
-
"component",
|
|
8658
|
-
"correlation",
|
|
8659
|
-
"dev",
|
|
8660
|
-
"dialog",
|
|
8661
|
-
"dom",
|
|
8662
|
-
"element",
|
|
8663
|
-
"execution",
|
|
8664
|
-
"field",
|
|
8665
|
-
"form",
|
|
8666
|
-
"hmr",
|
|
8667
|
-
"input",
|
|
8668
|
-
"marker",
|
|
8669
|
-
"menu",
|
|
8670
|
-
"mock",
|
|
8671
|
-
"perf",
|
|
8672
|
-
"req",
|
|
8673
|
-
"request",
|
|
8674
|
-
"select",
|
|
8675
|
-
"tab",
|
|
8676
|
-
"temp",
|
|
8677
|
-
"test",
|
|
8678
|
-
"tmp",
|
|
8679
|
-
"trace"
|
|
8680
|
-
]);
|
|
8681
|
-
function nameWords(name) {
|
|
8682
|
-
return name.replaceAll(/([a-z0-9])([A-Z])/gu, "$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map((word) => word.toLowerCase());
|
|
8683
|
-
}
|
|
8684
8663
|
function isStrongSecurityName(name) {
|
|
8685
8664
|
const words2 = nameWords(name);
|
|
8686
8665
|
return words2.some((word) => STRONG_SECURITY_WORDS.has(word)) || words2.some(
|
|
8687
8666
|
(word, index) => word === "api" && words2[index + 1] === "key" || word === "auth" && words2[index + 1] === "id" || word === "verification" && words2[index + 1] === "code"
|
|
8688
8667
|
);
|
|
8689
8668
|
}
|
|
8690
|
-
function
|
|
8691
|
-
return
|
|
8669
|
+
function nameWords(name) {
|
|
8670
|
+
return name.replaceAll(/([a-z0-9])([A-Z])/gu, "$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map((word) => word.toLowerCase());
|
|
8692
8671
|
}
|
|
8693
|
-
var PATH_OR_DOM_MARKER = /[\\/#]|\.[A-Za-z0-9]/;
|
|
8694
8672
|
function isMathRandomCall(node) {
|
|
8695
8673
|
if (node.type !== "CallExpression") {
|
|
8696
8674
|
return false;
|
|
@@ -8700,7 +8678,7 @@ function isMathRandomCall(node) {
|
|
|
8700
8678
|
return false;
|
|
8701
8679
|
}
|
|
8702
8680
|
const object = unwrapExpression(callee.object);
|
|
8703
|
-
return object.type === "Identifier" && object.name === "Math" &&
|
|
8681
|
+
return object.type === "Identifier" && object.name === "Math" && ASTUtils23.getPropertyName(callee) === "random";
|
|
8704
8682
|
}
|
|
8705
8683
|
function findEnclosingNames(node) {
|
|
8706
8684
|
const names = [];
|
|
@@ -8734,67 +8712,6 @@ function findEnclosingNames(node) {
|
|
|
8734
8712
|
}
|
|
8735
8713
|
return names;
|
|
8736
8714
|
}
|
|
8737
|
-
function isConcatenatedIntoPathOrDomId(node) {
|
|
8738
|
-
const valueNode = climbValueChain(node);
|
|
8739
|
-
let current = valueNode;
|
|
8740
|
-
let parent = current.parent;
|
|
8741
|
-
let top;
|
|
8742
|
-
while (parent) {
|
|
8743
|
-
if (parent.type === "BinaryExpression" && parent.operator === "+" && (parent.left === current || parent.right === current)) {
|
|
8744
|
-
top = parent;
|
|
8745
|
-
current = parent;
|
|
8746
|
-
parent = current.parent;
|
|
8747
|
-
continue;
|
|
8748
|
-
}
|
|
8749
|
-
if (parent.type === "TemplateLiteral") {
|
|
8750
|
-
top = parent;
|
|
8751
|
-
current = parent;
|
|
8752
|
-
parent = current.parent;
|
|
8753
|
-
continue;
|
|
8754
|
-
}
|
|
8755
|
-
break;
|
|
8756
|
-
}
|
|
8757
|
-
if (!top) {
|
|
8758
|
-
return false;
|
|
8759
|
-
}
|
|
8760
|
-
const parts = [];
|
|
8761
|
-
collectStaticStringParts(top, parts);
|
|
8762
|
-
return parts.some((part) => PATH_OR_DOM_MARKER.test(part));
|
|
8763
|
-
}
|
|
8764
|
-
function climbValueChain(node) {
|
|
8765
|
-
let current = node;
|
|
8766
|
-
let parent = current.parent;
|
|
8767
|
-
while (parent) {
|
|
8768
|
-
if (parent.type === "MemberExpression" && parent.object === current && ASTUtils22.getPropertyName(parent) !== null) {
|
|
8769
|
-
current = parent;
|
|
8770
|
-
parent = current.parent;
|
|
8771
|
-
continue;
|
|
8772
|
-
}
|
|
8773
|
-
if (parent.type === "CallExpression" && parent.callee === current) {
|
|
8774
|
-
current = parent;
|
|
8775
|
-
parent = current.parent;
|
|
8776
|
-
continue;
|
|
8777
|
-
}
|
|
8778
|
-
break;
|
|
8779
|
-
}
|
|
8780
|
-
return current;
|
|
8781
|
-
}
|
|
8782
|
-
function collectStaticStringParts(node, out) {
|
|
8783
|
-
if (node.type === "Literal" && typeof node.value === "string") {
|
|
8784
|
-
out.push(node.value);
|
|
8785
|
-
return;
|
|
8786
|
-
}
|
|
8787
|
-
if (node.type === "TemplateLiteral") {
|
|
8788
|
-
for (const quasi of node.quasis) {
|
|
8789
|
-
out.push(quasi.value.cooked ?? quasi.value.raw);
|
|
8790
|
-
}
|
|
8791
|
-
return;
|
|
8792
|
-
}
|
|
8793
|
-
if (node.type === "BinaryExpression" && node.operator === "+") {
|
|
8794
|
-
collectStaticStringParts(node.left, out);
|
|
8795
|
-
collectStaticStringParts(node.right, out);
|
|
8796
|
-
}
|
|
8797
|
-
}
|
|
8798
8715
|
var no_insecure_random_id_default = createRule({
|
|
8799
8716
|
name: "no-insecure-random-id",
|
|
8800
8717
|
documentation: NO_INSECURE_RANDOM_ID_DOCUMENTATION,
|
|
@@ -8818,17 +8735,10 @@ var no_insecure_random_id_default = createRule({
|
|
|
8818
8735
|
if (!isMathRandomCall(node)) {
|
|
8819
8736
|
return;
|
|
8820
8737
|
}
|
|
8821
|
-
if ((
|
|
8738
|
+
if ((ASTUtils23.findVariable(context.sourceCode.getScope(node), "Math")?.defs.length ?? 0) > 0) return;
|
|
8822
8739
|
const names = findEnclosingNames(node);
|
|
8823
8740
|
if (names.some(isStrongSecurityName)) {
|
|
8824
8741
|
context.report({ node, messageId: "insecureRandomId" });
|
|
8825
|
-
return;
|
|
8826
|
-
}
|
|
8827
|
-
if (names.some(isNonSecurityName)) {
|
|
8828
|
-
return;
|
|
8829
|
-
}
|
|
8830
|
-
if (isConcatenatedIntoPathOrDomId(node)) {
|
|
8831
|
-
return;
|
|
8832
8742
|
}
|
|
8833
8743
|
}
|
|
8834
8744
|
};
|
|
@@ -8841,8 +8751,8 @@ function appendPropertyName(property, names) {
|
|
|
8841
8751
|
}
|
|
8842
8752
|
function appendAssignedName(assignment, directBinding, names) {
|
|
8843
8753
|
if (directBinding && assignment.left.type === "Identifier") names.push(assignment.left.name);
|
|
8844
|
-
if (directBinding && assignment.left.type === "MemberExpression" &&
|
|
8845
|
-
names.push(
|
|
8754
|
+
if (directBinding && assignment.left.type === "MemberExpression" && ASTUtils23.getPropertyName(assignment.left) !== null) {
|
|
8755
|
+
names.push(ASTUtils23.getPropertyName(assignment.left) ?? "");
|
|
8846
8756
|
}
|
|
8847
8757
|
}
|
|
8848
8758
|
function appendDirectBindingName(id, directBinding, names) {
|
|
@@ -8852,7 +8762,7 @@ function appendDirectBindingName(id, directBinding, names) {
|
|
|
8852
8762
|
// src/rules/no-detached-global-fetch.ts
|
|
8853
8763
|
import {
|
|
8854
8764
|
AST_NODE_TYPES as AST_NODE_TYPES45,
|
|
8855
|
-
ASTUtils as
|
|
8765
|
+
ASTUtils as ASTUtils24
|
|
8856
8766
|
} from "@typescript-eslint/utils";
|
|
8857
8767
|
var NO_DETACHED_GLOBAL_FETCH_DOCUMENTATION = {
|
|
8858
8768
|
summary: "Keep the ambient global fetch receiver-safe when storing or explicitly rebinding it.",
|
|
@@ -8913,7 +8823,7 @@ var no_detached_global_fetch_default = createRule({
|
|
|
8913
8823
|
if (isTestFile(context.filename) || isScriptFile(context.filename) || isGeneratedFile(context.filename, sourceCode.text)) return {};
|
|
8914
8824
|
const aliases = /* @__PURE__ */ new Set();
|
|
8915
8825
|
function bindingOf(identifier) {
|
|
8916
|
-
return
|
|
8826
|
+
return ASTUtils24.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
8917
8827
|
}
|
|
8918
8828
|
function resolvesToGlobal(identifier) {
|
|
8919
8829
|
const variable = bindingOf(identifier);
|
|
@@ -9018,7 +8928,7 @@ var no_detached_global_fetch_default = createRule({
|
|
|
9018
8928
|
});
|
|
9019
8929
|
|
|
9020
8930
|
// src/rules/no-exception-text-in-5xx-response.ts
|
|
9021
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES46, ASTUtils as
|
|
8931
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46, ASTUtils as ASTUtils25 } from "@typescript-eslint/utils";
|
|
9022
8932
|
var NO_EXCEPTION_TEXT_IN_5XX_RESPONSE_DOCUMENTATION = {
|
|
9023
8933
|
summary: "Keep caught exception messages and stacks out of returned 5xx JSON responses.",
|
|
9024
8934
|
rationale: "Exception details can contain database, provider, filesystem or credential information that belongs in server-side diagnostics rather than a client response.",
|
|
@@ -9075,7 +8985,7 @@ var no_exception_text_in_5xx_response_default = createRule({
|
|
|
9075
8985
|
const referenceIdentifiers = new WeakSet(sourceCode.scopeManager?.scopes.flatMap((scope) => scope.references.filter((reference) => reference.isValueReference !== false).map((reference) => reference.identifier)) ?? []);
|
|
9076
8986
|
let uncertainSerialization = false;
|
|
9077
8987
|
function binding(identifier) {
|
|
9078
|
-
return
|
|
8988
|
+
return ASTUtils25.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
9079
8989
|
}
|
|
9080
8990
|
function stable(variable) {
|
|
9081
8991
|
const cached = stableBindings.get(variable);
|
|
@@ -9151,10 +9061,10 @@ var no_exception_text_in_5xx_response_default = createRule({
|
|
|
9151
9061
|
}
|
|
9152
9062
|
function branchValues(value) {
|
|
9153
9063
|
if (value.type === AST_NODE_TYPES46.ConditionalExpression) {
|
|
9154
|
-
const test =
|
|
9064
|
+
const test = ASTUtils25.getStaticValue(unwrapExpression(value.test), sourceCode.getScope(value.test));
|
|
9155
9065
|
return test === null ? [value.consequent, value.alternate] : [test.value ? value.consequent : value.alternate];
|
|
9156
9066
|
}
|
|
9157
|
-
const left =
|
|
9067
|
+
const left = ASTUtils25.getStaticValue(unwrapExpression(value.left), sourceCode.getScope(value.left));
|
|
9158
9068
|
if (left === null) return value.operator === "&&" ? [value.right] : [value.left, value.right];
|
|
9159
9069
|
const useRight = value.operator === "??" ? left.value == null : value.operator === "&&" ? Boolean(left.value) : !left.value;
|
|
9160
9070
|
return useRight ? [value.right] : [];
|
|
@@ -9240,7 +9150,7 @@ var no_exception_text_in_5xx_response_default = createRule({
|
|
|
9240
9150
|
});
|
|
9241
9151
|
|
|
9242
9152
|
// src/rules/no-json-stringify-error.ts
|
|
9243
|
-
import { ASTUtils as
|
|
9153
|
+
import { ASTUtils as ASTUtils26 } from "@typescript-eslint/utils";
|
|
9244
9154
|
var NO_JSON_STRINGIFY_ERROR_DOCUMENTATION = {
|
|
9245
9155
|
summary: "Avoid generic JSON serialization that can omit native Error details.",
|
|
9246
9156
|
rationale: "Native Error details are non-enumerable, so generic JSON serialization discards diagnostic information.",
|
|
@@ -9341,7 +9251,7 @@ function builtinWrites(sourceCode) {
|
|
|
9341
9251
|
const native = nativeObjectName(expression, sourceCode);
|
|
9342
9252
|
if (native !== null) return native;
|
|
9343
9253
|
const value = unwrapExpression(expression);
|
|
9344
|
-
if (value.type === "Identifier") return
|
|
9254
|
+
if (value.type === "Identifier") return ASTUtils26.findVariable(sourceCode.getScope(value), value.name);
|
|
9345
9255
|
if (value.type === "MemberExpression" && staticPropertyName(value, sourceCode) === "prototype") {
|
|
9346
9256
|
const constructor = globalBuiltinName(value.object, sourceCode);
|
|
9347
9257
|
if (constructor !== null && BUILTIN_ERROR_CONSTRUCTORS.has(constructor)) return constructor + ".prototype";
|
|
@@ -9460,7 +9370,7 @@ function builtinWrites(sourceCode) {
|
|
|
9460
9370
|
function hasDefaultErrorSerialization(expression, call, sourceCode) {
|
|
9461
9371
|
let constructor = null;
|
|
9462
9372
|
if (expression.type === "Identifier") {
|
|
9463
|
-
const variable =
|
|
9373
|
+
const variable = ASTUtils26.findVariable(sourceCode.getScope(expression), expression.name);
|
|
9464
9374
|
if (variable !== null && !hasUnchangedBuiltin(variable, call, sourceCode)) return false;
|
|
9465
9375
|
const definition = variable?.defs[0];
|
|
9466
9376
|
const initializer = definition?.type === "Variable" ? definition.node.init : null;
|
|
@@ -9473,7 +9383,7 @@ function isBuiltinErrorConstructor(identifier, sourceCode) {
|
|
|
9473
9383
|
return sourceCode.scopeManager !== null && BUILTIN_ERROR_CONSTRUCTORS.has(identifier.name) && isGlobalIdentifier(identifier.name, sourceCode.getScope(identifier)) && hasUnchangedBuiltin(identifier.name, identifier, sourceCode);
|
|
9474
9384
|
}
|
|
9475
9385
|
function isGlobalIdentifier(name, scope) {
|
|
9476
|
-
const binding =
|
|
9386
|
+
const binding = ASTUtils26.findVariable(scope, name);
|
|
9477
9387
|
return binding === null || binding.defs.length === 0;
|
|
9478
9388
|
}
|
|
9479
9389
|
function positiveErrorSubject(test, sourceCode) {
|
|
@@ -9541,8 +9451,8 @@ function sameSubjectBinding(subject, value, sourceCode) {
|
|
|
9541
9451
|
const left = unwrapExpression(subject);
|
|
9542
9452
|
const right = unwrapExpression(value);
|
|
9543
9453
|
if (left.type === "Identifier" && right.type === "Identifier") {
|
|
9544
|
-
const binding =
|
|
9545
|
-
return binding !== null && binding ===
|
|
9454
|
+
const binding = ASTUtils26.findVariable(sourceCode.getScope(left), left.name);
|
|
9455
|
+
return binding !== null && binding === ASTUtils26.findVariable(sourceCode.getScope(right), right.name);
|
|
9546
9456
|
}
|
|
9547
9457
|
return sourceCode.getText(subject) === sourceCode.getText(value);
|
|
9548
9458
|
}
|
|
@@ -9600,7 +9510,7 @@ function expressionSuggestsError(expression, sourceCode) {
|
|
|
9600
9510
|
return false;
|
|
9601
9511
|
}
|
|
9602
9512
|
function identifierIsProvenError(identifier, sourceCode) {
|
|
9603
|
-
const variable =
|
|
9513
|
+
const variable = ASTUtils26.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
9604
9514
|
if (variable === null || variable.defs.length !== 1 || variable.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
9605
9515
|
const definition = variable.defs[0];
|
|
9606
9516
|
if (definition?.type === "CatchClause") return true;
|
|
@@ -9674,7 +9584,7 @@ function branchTerminates(branch) {
|
|
|
9674
9584
|
// src/rules/no-json-stringify-object-equality.ts
|
|
9675
9585
|
import {
|
|
9676
9586
|
AST_NODE_TYPES as AST_NODE_TYPES47,
|
|
9677
|
-
ASTUtils as
|
|
9587
|
+
ASTUtils as ASTUtils27,
|
|
9678
9588
|
ESLintUtils as ESLintUtils14
|
|
9679
9589
|
} from "@typescript-eslint/utils";
|
|
9680
9590
|
import ts14 from "typescript";
|
|
@@ -9730,19 +9640,19 @@ function jsonStringifyArgument(node, sourceCode) {
|
|
|
9730
9640
|
function isJsonStringify2(node, sourceCode) {
|
|
9731
9641
|
const expression = unwrapComparisonExpression(node);
|
|
9732
9642
|
if (expression.type === AST_NODE_TYPES47.MemberExpression) {
|
|
9733
|
-
return
|
|
9643
|
+
return ASTUtils27.getPropertyName(expression) === "stringify" && expression.object.type !== AST_NODE_TYPES47.Super && isGlobalJson(expression.object, sourceCode);
|
|
9734
9644
|
}
|
|
9735
9645
|
if (expression.type !== AST_NODE_TYPES47.Identifier) return false;
|
|
9736
|
-
const binding =
|
|
9646
|
+
const binding = ASTUtils27.findVariable(sourceCode.getScope(expression), expression.name);
|
|
9737
9647
|
if (binding === null || binding.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
9738
9648
|
const [definition] = binding.defs;
|
|
9739
9649
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.id.type !== AST_NODE_TYPES47.ObjectPattern || definition.node.init === null || !isGlobalJson(definition.node.init, sourceCode)) return false;
|
|
9740
|
-
return definition.node.id.properties.some((property) => property.type === AST_NODE_TYPES47.Property &&
|
|
9650
|
+
return definition.node.id.properties.some((property) => property.type === AST_NODE_TYPES47.Property && ASTUtils27.getPropertyName(property) === "stringify" && property.value.type === AST_NODE_TYPES47.Identifier && ASTUtils27.findVariable(sourceCode.getScope(property.value), property.value.name) === binding);
|
|
9741
9651
|
}
|
|
9742
9652
|
function isGlobalJson(node, sourceCode) {
|
|
9743
9653
|
const expression = unwrapComparisonExpression(node);
|
|
9744
9654
|
if (expression.type !== AST_NODE_TYPES47.Identifier || expression.name !== "JSON") return false;
|
|
9745
|
-
const binding =
|
|
9655
|
+
const binding = ASTUtils27.findVariable(sourceCode.getScope(expression), expression.name);
|
|
9746
9656
|
return binding === null || binding.defs.length === 0;
|
|
9747
9657
|
}
|
|
9748
9658
|
function typeMayContainObject(type, checker) {
|
|
@@ -9767,15 +9677,24 @@ function typeMayContainObject(type, checker) {
|
|
|
9767
9677
|
function syntaxMayContainObject(node) {
|
|
9768
9678
|
const expression = unwrapComparisonExpression(node);
|
|
9769
9679
|
if (expression.type === AST_NODE_TYPES47.ObjectExpression) return true;
|
|
9680
|
+
if (expression.type === AST_NODE_TYPES47.Literal) return "regex" in expression;
|
|
9681
|
+
if (expression.type === AST_NODE_TYPES47.TemplateLiteral || expression.type === AST_NODE_TYPES47.UnaryExpression) return false;
|
|
9770
9682
|
if (expression.type !== AST_NODE_TYPES47.ArrayExpression) return null;
|
|
9683
|
+
let unknown = false;
|
|
9771
9684
|
for (const element of expression.elements) {
|
|
9772
9685
|
if (element === null) continue;
|
|
9773
|
-
|
|
9774
|
-
if (
|
|
9775
|
-
|
|
9776
|
-
}
|
|
9686
|
+
const result = element.type === AST_NODE_TYPES47.SpreadElement ? null : syntaxMayContainObject(element);
|
|
9687
|
+
if (result === true) return true;
|
|
9688
|
+
if (result === null) unknown = true;
|
|
9777
9689
|
}
|
|
9778
|
-
return false;
|
|
9690
|
+
return unknown ? null : false;
|
|
9691
|
+
}
|
|
9692
|
+
function untypedArrayMayContainObject(node) {
|
|
9693
|
+
return node.elements.some((element) => {
|
|
9694
|
+
if (element === null || element.type === AST_NODE_TYPES47.SpreadElement) return false;
|
|
9695
|
+
const value = unwrapComparisonExpression(element);
|
|
9696
|
+
return value.type === AST_NODE_TYPES47.ArrayExpression ? untypedArrayMayContainObject(value) : syntaxMayContainObject(value) !== false;
|
|
9697
|
+
});
|
|
9779
9698
|
}
|
|
9780
9699
|
var no_json_stringify_object_equality_default = createRule({
|
|
9781
9700
|
name: "no-json-stringify-object-equality",
|
|
@@ -9804,7 +9723,10 @@ var no_json_stringify_object_equality_default = createRule({
|
|
|
9804
9723
|
function mayContainObject(node) {
|
|
9805
9724
|
const syntax = syntaxMayContainObject(node);
|
|
9806
9725
|
if (syntax !== null) return syntax;
|
|
9807
|
-
if (services === null || checker === void 0)
|
|
9726
|
+
if (services === null || checker === void 0) {
|
|
9727
|
+
const expression = unwrapComparisonExpression(node);
|
|
9728
|
+
return expression.type === AST_NODE_TYPES47.ArrayExpression && untypedArrayMayContainObject(expression);
|
|
9729
|
+
}
|
|
9808
9730
|
const type = checker.getTypeAtLocation(
|
|
9809
9731
|
services.esTreeNodeToTSNodeMap.get(node)
|
|
9810
9732
|
);
|
|
@@ -9826,7 +9748,7 @@ var no_json_stringify_object_equality_default = createRule({
|
|
|
9826
9748
|
|
|
9827
9749
|
// src/rules/no-impossible-zod-literal-bounds.ts
|
|
9828
9750
|
import {
|
|
9829
|
-
ASTUtils as
|
|
9751
|
+
ASTUtils as ASTUtils28,
|
|
9830
9752
|
AST_NODE_TYPES as AST_NODE_TYPES48
|
|
9831
9753
|
} from "@typescript-eslint/utils";
|
|
9832
9754
|
|
|
@@ -10020,7 +9942,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
|
|
|
10020
9942
|
if (callee.type !== AST_NODE_TYPES48.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES48.CallExpression) {
|
|
10021
9943
|
return null;
|
|
10022
9944
|
}
|
|
10023
|
-
const method =
|
|
9945
|
+
const method = ASTUtils28.getPropertyName(callee);
|
|
10024
9946
|
if (method === null) return null;
|
|
10025
9947
|
calls.push({ method, node: current });
|
|
10026
9948
|
current = calleeReceiver;
|
|
@@ -10035,7 +9957,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
|
|
|
10035
9957
|
if (callee.type !== AST_NODE_TYPES48.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES48.Identifier || !namespaces.has(calleeReceiver.name) || !resolvesToTrackedImport(calleeReceiver)) {
|
|
10036
9958
|
return null;
|
|
10037
9959
|
}
|
|
10038
|
-
const name =
|
|
9960
|
+
const name = ASTUtils28.getPropertyName(callee);
|
|
10039
9961
|
return name === null ? null : KINDS.get(name) ?? null;
|
|
10040
9962
|
}
|
|
10041
9963
|
function isInsideReshapingCall(node) {
|
|
@@ -10045,7 +9967,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
|
|
|
10045
9967
|
if (parent.type === AST_NODE_TYPES48.CallExpression) {
|
|
10046
9968
|
const callee = unwrapExpression(parent.callee);
|
|
10047
9969
|
const calleeReceiver = callee.type === AST_NODE_TYPES48.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
10048
|
-
if (callee.type === AST_NODE_TYPES48.MemberExpression && RESHAPING_METHODS.has(
|
|
9970
|
+
if (callee.type === AST_NODE_TYPES48.MemberExpression && RESHAPING_METHODS.has(ASTUtils28.getPropertyName(callee) ?? "") && (calleeReceiver.type === AST_NODE_TYPES48.CallExpression || calleeReceiver.type === AST_NODE_TYPES48.Identifier && namespaces.has(calleeReceiver.name) && resolvesToTrackedImport(calleeReceiver))) {
|
|
10049
9971
|
return true;
|
|
10050
9972
|
}
|
|
10051
9973
|
if (callee.type === AST_NODE_TYPES48.Identifier && preprocessors.has(callee.name) && resolvesToTrackedImport(callee)) {
|
|
@@ -10287,7 +10209,7 @@ var no_in_operator_on_built_in_collections_default = createRule({
|
|
|
10287
10209
|
|
|
10288
10210
|
// src/rules/no-redundant-optional-array-default.ts
|
|
10289
10211
|
import {
|
|
10290
|
-
ASTUtils as
|
|
10212
|
+
ASTUtils as ASTUtils29,
|
|
10291
10213
|
AST_NODE_TYPES as AST_NODE_TYPES49
|
|
10292
10214
|
} from "@typescript-eslint/utils";
|
|
10293
10215
|
var NO_REDUNDANT_OPTIONAL_ARRAY_DEFAULT_DOCUMENTATION = {
|
|
@@ -10425,7 +10347,7 @@ var no_redundant_optional_array_default_default = createRule({
|
|
|
10425
10347
|
return arrayConstructors.has(callee.name) && resolvesToTrackedImport(callee);
|
|
10426
10348
|
}
|
|
10427
10349
|
if (callee.type !== AST_NODE_TYPES49.MemberExpression) return false;
|
|
10428
|
-
const method =
|
|
10350
|
+
const method = ASTUtils29.getPropertyName(callee);
|
|
10429
10351
|
if (method === "array" && (calleeReceiver.type === AST_NODE_TYPES49.Identifier ? namespaces.has(calleeReceiver.name) && resolvesToTrackedImport(calleeReceiver) : isZodSchemaExpression(calleeReceiver))) {
|
|
10430
10352
|
return true;
|
|
10431
10353
|
}
|
|
@@ -10468,13 +10390,13 @@ var no_redundant_optional_array_default_default = createRule({
|
|
|
10468
10390
|
CallExpression(node) {
|
|
10469
10391
|
const defaultCallee = unwrapExpression(node.callee);
|
|
10470
10392
|
const defaultCalleeReceiver = defaultCallee.type === AST_NODE_TYPES49.MemberExpression ? unwrapExpression(defaultCallee.object) : defaultCallee;
|
|
10471
|
-
if (defaultCallee.type !== AST_NODE_TYPES49.MemberExpression ||
|
|
10393
|
+
if (defaultCallee.type !== AST_NODE_TYPES49.MemberExpression || ASTUtils29.getPropertyName(defaultCallee) !== "default" || !hasArrayFallback(node) || defaultCalleeReceiver.type !== AST_NODE_TYPES49.CallExpression) {
|
|
10472
10394
|
return;
|
|
10473
10395
|
}
|
|
10474
10396
|
const optionalCall = defaultCalleeReceiver;
|
|
10475
10397
|
const optionalCallee = unwrapExpression(optionalCall.callee);
|
|
10476
10398
|
const optionalCalleeReceiver = optionalCallee.type === AST_NODE_TYPES49.MemberExpression ? unwrapExpression(optionalCallee.object) : optionalCallee;
|
|
10477
|
-
if (optionalCallee.type !== AST_NODE_TYPES49.MemberExpression ||
|
|
10399
|
+
if (optionalCallee.type !== AST_NODE_TYPES49.MemberExpression || ASTUtils29.getPropertyName(optionalCallee) !== "optional" || optionalCall.arguments.length !== 0 || !isArraySchemaExpression(optionalCalleeReceiver) || sourceCode.getCommentsInside(optionalCall).length > 0) {
|
|
10478
10400
|
return;
|
|
10479
10401
|
}
|
|
10480
10402
|
context.report({
|
|
@@ -10613,10 +10535,10 @@ var interface_contract_members_private_default = createRule({
|
|
|
10613
10535
|
});
|
|
10614
10536
|
|
|
10615
10537
|
// src/rules/no-log-only-catch.ts
|
|
10616
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES53, ASTUtils as
|
|
10538
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES53, ASTUtils as ASTUtils31 } from "@typescript-eslint/utils";
|
|
10617
10539
|
|
|
10618
10540
|
// src/rules/_logging.ts
|
|
10619
|
-
import { ASTUtils as
|
|
10541
|
+
import { ASTUtils as ASTUtils30, AST_NODE_TYPES as AST_NODE_TYPES52 } from "@typescript-eslint/utils";
|
|
10620
10542
|
var LOG_METHODS = /* @__PURE__ */ new Set([
|
|
10621
10543
|
"debug",
|
|
10622
10544
|
"info",
|
|
@@ -10653,7 +10575,7 @@ function calleeName(callee) {
|
|
|
10653
10575
|
if (callee.type === "Identifier") {
|
|
10654
10576
|
return callee.name;
|
|
10655
10577
|
}
|
|
10656
|
-
return callee.type === "MemberExpression" ?
|
|
10578
|
+
return callee.type === "MemberExpression" ? ASTUtils30.getPropertyName(callee) : null;
|
|
10657
10579
|
}
|
|
10658
10580
|
function createLogMatcher(options = {}) {
|
|
10659
10581
|
const loggerNames = /* @__PURE__ */ new Set([
|
|
@@ -10668,7 +10590,7 @@ function createLogMatcher(options = {}) {
|
|
|
10668
10590
|
return loggerNames.has(expr.name.toLowerCase());
|
|
10669
10591
|
case "MemberExpression": {
|
|
10670
10592
|
const { object } = expr;
|
|
10671
|
-
const property =
|
|
10593
|
+
const property = ASTUtils30.getPropertyName(expr);
|
|
10672
10594
|
if (property !== null) {
|
|
10673
10595
|
const lowered = property.toLowerCase();
|
|
10674
10596
|
if (loggerNames.has(lowered) || LOGGER_FACTORIES.has(lowered)) {
|
|
@@ -10679,7 +10601,7 @@ function createLogMatcher(options = {}) {
|
|
|
10679
10601
|
}
|
|
10680
10602
|
case "CallExpression": {
|
|
10681
10603
|
const callee = unwrapExpression(expr.callee);
|
|
10682
|
-
const name = callee.type === "MemberExpression" ?
|
|
10604
|
+
const name = callee.type === "MemberExpression" ? ASTUtils30.getPropertyName(callee) : null;
|
|
10683
10605
|
if (name !== null && LOGGER_FACTORIES.has(name.toLowerCase())) {
|
|
10684
10606
|
return true;
|
|
10685
10607
|
}
|
|
@@ -10710,7 +10632,7 @@ function createLogMatcher(options = {}) {
|
|
|
10710
10632
|
const callee = unwrapExpression(expr.callee);
|
|
10711
10633
|
const calleeReceiver = callee.type === AST_NODE_TYPES52.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
10712
10634
|
if (callee.type !== "MemberExpression") return false;
|
|
10713
|
-
const name =
|
|
10635
|
+
const name = ASTUtils30.getPropertyName(callee);
|
|
10714
10636
|
return name !== null && LOG_METHODS.has(name.toLowerCase()) && isLoggerReceiver(calleeReceiver);
|
|
10715
10637
|
}
|
|
10716
10638
|
return { isLoggerReceiver, isLogFunctionCall, isLoggingCall };
|
|
@@ -10784,7 +10706,7 @@ function seededFallbackHandled(tryStatement, scope) {
|
|
|
10784
10706
|
if (previous.declarations.length !== 1 || declarator === void 0) return false;
|
|
10785
10707
|
if (declarator.id.type !== AST_NODE_TYPES53.Identifier) return false;
|
|
10786
10708
|
if (declarator.init == null || !isSeedValue(declarator.init)) return false;
|
|
10787
|
-
const variable =
|
|
10709
|
+
const variable = ASTUtils31.findVariable(scope, declarator.id.name);
|
|
10788
10710
|
if (variable === null) return false;
|
|
10789
10711
|
const [tryStart, tryEnd] = tryStatement.block.range;
|
|
10790
10712
|
let writtenInTry = false;
|
|
@@ -10846,9 +10768,9 @@ var no_log_only_catch_default = createRule({
|
|
|
10846
10768
|
if (left.type !== AST_NODE_TYPES53.MemberExpression || left.computed || left.object.type !== AST_NODE_TYPES53.Identifier || right.type !== AST_NODE_TYPES53.CallExpression || right.optional || right.callee.type !== AST_NODE_TYPES53.Identifier || !["String", "Number", "Boolean", "BigInt"].includes(right.callee.name) || right.arguments.length !== 1) return false;
|
|
10847
10769
|
const argument = right.arguments[0];
|
|
10848
10770
|
if (argument === void 0 || sourceCode.getText(left) !== sourceCode.getText(argument)) return false;
|
|
10849
|
-
const global =
|
|
10771
|
+
const global = ASTUtils31.findVariable(sourceCode.getScope(right.callee), right.callee.name);
|
|
10850
10772
|
if (global !== null && global.defs.length > 0) return false;
|
|
10851
|
-
const root =
|
|
10773
|
+
const root = ASTUtils31.findVariable(sourceCode.getScope(left.object), left.object.name);
|
|
10852
10774
|
if (root === null || root.references.some((reference) => reference.isWrite() && !reference.init)) return false;
|
|
10853
10775
|
return hasFollowingCoercionCheck(owner, left, right.callee.name);
|
|
10854
10776
|
}
|
|
@@ -10919,7 +10841,7 @@ var no_log_only_catch_default = createRule({
|
|
|
10919
10841
|
});
|
|
10920
10842
|
|
|
10921
10843
|
// src/rules/no-bare-return-from-test-catch.ts
|
|
10922
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES54, ASTUtils as
|
|
10844
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54, ASTUtils as ASTUtils32 } from "@typescript-eslint/utils";
|
|
10923
10845
|
var NO_BARE_RETURN_FROM_TEST_CATCH_DOCUMENTATION = {
|
|
10924
10846
|
summary: "Disallow a bare return from a test catch block when it skips a later assertion.",
|
|
10925
10847
|
rationale: "An unasserted catch return can swallow a failure and skip later assertions; the complete test result also depends on other assertions and hooks.",
|
|
@@ -11004,14 +10926,14 @@ function isUnconditionalContextSkip(node, owner, context) {
|
|
|
11004
10926
|
return receiver.type === AST_NODE_TYPES54.Identifier && isStableParameterReference(receiver, parameter, context, true);
|
|
11005
10927
|
}
|
|
11006
10928
|
if (parameter?.type !== AST_NODE_TYPES54.ObjectPattern || callee.type !== AST_NODE_TYPES54.Identifier) return false;
|
|
11007
|
-
return parameter.properties.some((property) => property.type === AST_NODE_TYPES54.Property &&
|
|
10929
|
+
return parameter.properties.some((property) => property.type === AST_NODE_TYPES54.Property && ASTUtils32.getPropertyName(property) === "skip" && property.value.type === AST_NODE_TYPES54.Identifier && isStableParameterReference(callee, property.value, context, false));
|
|
11008
10930
|
}
|
|
11009
10931
|
function testContextParameter(owner, context) {
|
|
11010
10932
|
const call = directArgumentCall(owner);
|
|
11011
10933
|
if (call === null) return null;
|
|
11012
10934
|
const root = testRoot(call.callee);
|
|
11013
10935
|
if (root === null) return null;
|
|
11014
|
-
const binding =
|
|
10936
|
+
const binding = ASTUtils32.findVariable(context.sourceCode.getScope(root), root.name);
|
|
11015
10937
|
const definition = binding?.defs[0];
|
|
11016
10938
|
const runnerGlobal = binding === null || binding.defs.length === 0;
|
|
11017
10939
|
const vitestImport = binding?.defs.length === 1 && definition?.node.type === AST_NODE_TYPES54.ImportSpecifier && definition.node.parent.type === AST_NODE_TYPES54.ImportDeclaration && definition.node.parent.source.value === "vitest";
|
|
@@ -11032,8 +10954,8 @@ function contextParameterPosition(callee) {
|
|
|
11032
10954
|
}
|
|
11033
10955
|
function isStableParameterReference(identifier, parameter, context, memberReceiver) {
|
|
11034
10956
|
const source = context.sourceCode;
|
|
11035
|
-
const binding =
|
|
11036
|
-
if (binding === null || binding !==
|
|
10957
|
+
const binding = ASTUtils32.findVariable(source.getScope(parameter), parameter.name);
|
|
10958
|
+
if (binding === null || binding !== ASTUtils32.findVariable(source.getScope(identifier), identifier.name)) return false;
|
|
11037
10959
|
return binding.references.every((reference) => {
|
|
11038
10960
|
if (reference.isWrite() && !reference.init) return false;
|
|
11039
10961
|
if (!memberReceiver) return true;
|
|
@@ -11083,7 +11005,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
11083
11005
|
const parameter = catchClause.param;
|
|
11084
11006
|
const returnBlock = node.parent;
|
|
11085
11007
|
if (parameter?.type === AST_NODE_TYPES54.Identifier && returnBlock?.type === AST_NODE_TYPES54.BlockStatement) {
|
|
11086
|
-
const errorBinding =
|
|
11008
|
+
const errorBinding = ASTUtils32.findVariable(context.sourceCode.getScope(parameter), parameter.name);
|
|
11087
11009
|
const assertedError = returnBlock.body.some((statement) => {
|
|
11088
11010
|
if (statement.range[1] > node.range[0] || statement.type !== AST_NODE_TYPES54.ExpressionStatement) return false;
|
|
11089
11011
|
const expression = statement.expression;
|
|
@@ -11107,7 +11029,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
11107
11029
|
});
|
|
11108
11030
|
|
|
11109
11031
|
// src/rules/no-bespoke-api-case-conversion.ts
|
|
11110
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES55, ASTUtils as
|
|
11032
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES55, ASTUtils as ASTUtils33 } from "@typescript-eslint/utils";
|
|
11111
11033
|
var NO_BESPOKE_API_CASE_CONVERSION_DOCUMENTATION = {
|
|
11112
11034
|
defaultLevel: "warning",
|
|
11113
11035
|
summary: "Review direct snake_case/camelCase mirror mappings on explicitly API-typed adapter values.",
|
|
@@ -11160,10 +11082,10 @@ function propertyName(node) {
|
|
|
11160
11082
|
}
|
|
11161
11083
|
function memberName3(node) {
|
|
11162
11084
|
const current = unwrapExpression(node);
|
|
11163
|
-
if (current.type !== AST_NODE_TYPES55.MemberExpression ||
|
|
11085
|
+
if (current.type !== AST_NODE_TYPES55.MemberExpression || ASTUtils33.getPropertyName(current) === null) {
|
|
11164
11086
|
return null;
|
|
11165
11087
|
}
|
|
11166
|
-
return
|
|
11088
|
+
return ASTUtils33.getPropertyName(current) ?? "";
|
|
11167
11089
|
}
|
|
11168
11090
|
function isDirectCaseTranslation(left, right) {
|
|
11169
11091
|
if (SNAKE_CASE_RE2.test(left) && LOWER_CAMEL_CASE_RE.test(right)) {
|
|
@@ -11203,7 +11125,7 @@ var no_bespoke_api_case_conversion_default = createRule({
|
|
|
11203
11125
|
else break;
|
|
11204
11126
|
}
|
|
11205
11127
|
if (current.type !== AST_NODE_TYPES55.Identifier) return false;
|
|
11206
|
-
const binding =
|
|
11128
|
+
const binding = ASTUtils33.findVariable(context.sourceCode.getScope(current), current.name);
|
|
11207
11129
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
11208
11130
|
const identifier = binding.defs[0]?.name;
|
|
11209
11131
|
if (identifier?.type !== AST_NODE_TYPES55.Identifier) return false;
|
|
@@ -11212,7 +11134,7 @@ var no_bespoke_api_case_conversion_default = createRule({
|
|
|
11212
11134
|
let typeName = annotation.typeName;
|
|
11213
11135
|
while (typeName.type === AST_NODE_TYPES55.TSQualifiedName) typeName = typeName.left;
|
|
11214
11136
|
if (typeName.type !== AST_NODE_TYPES55.Identifier) return false;
|
|
11215
|
-
const typeBinding2 =
|
|
11137
|
+
const typeBinding2 = ASTUtils33.findVariable(context.sourceCode.getScope(typeName), typeName.name);
|
|
11216
11138
|
return typeBinding2?.defs.length === 1 && typeBinding2.defs[0]?.type === "ImportBinding" && typeBinding2.defs[0].parent.type === AST_NODE_TYPES55.ImportDeclaration && API_BOUNDARY_IMPORT_RE.test(typeBinding2.defs[0].parent.source.value);
|
|
11217
11139
|
};
|
|
11218
11140
|
return {
|
|
@@ -11417,7 +11339,7 @@ var no_vague_suppression_description_default = createRule({
|
|
|
11417
11339
|
});
|
|
11418
11340
|
|
|
11419
11341
|
// src/rules/_runtime-exports.ts
|
|
11420
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES57, ASTUtils as
|
|
11342
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES57, ASTUtils as ASTUtils34 } from "@typescript-eslint/utils";
|
|
11421
11343
|
var GENERIC_MODULE_STEMS = /* @__PURE__ */ new Set([
|
|
11422
11344
|
"common",
|
|
11423
11345
|
"helper",
|
|
@@ -11539,7 +11461,7 @@ function namespaceEmission(declaration) {
|
|
|
11539
11461
|
}
|
|
11540
11462
|
function isCommonJsExportReference(node, sourceCode) {
|
|
11541
11463
|
function isGlobal(node2) {
|
|
11542
|
-
const variable =
|
|
11464
|
+
const variable = ASTUtils34.findVariable(sourceCode.getScope(node2), node2.name);
|
|
11543
11465
|
return variable === null || variable.defs.length === 0;
|
|
11544
11466
|
}
|
|
11545
11467
|
if (node.type === AST_NODE_TYPES57.MemberExpression) {
|
|
@@ -11662,7 +11584,7 @@ var no_offset_pagination_default = createRule({
|
|
|
11662
11584
|
});
|
|
11663
11585
|
|
|
11664
11586
|
// src/rules/no-positional-tuple-return.ts
|
|
11665
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES58, ASTUtils as
|
|
11587
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES58, ASTUtils as ASTUtils35 } from "@typescript-eslint/utils";
|
|
11666
11588
|
var NO_POSITIONAL_TUPLE_RETURN_DOCUMENTATION = {
|
|
11667
11589
|
summary: "Disallow returning a multi-field tuple from a named function; return a named object so call sites cannot mismatch slots.",
|
|
11668
11590
|
rationale: "Tuple fields are identified only by position, so reordering can preserve types while changing meaning.",
|
|
@@ -11799,7 +11721,7 @@ function typeAliases(sourceCode) {
|
|
|
11799
11721
|
get(identifier) {
|
|
11800
11722
|
const declaration = aliases.get(identifier.name);
|
|
11801
11723
|
if (declaration === void 0) return void 0;
|
|
11802
|
-
const binding =
|
|
11724
|
+
const binding = ASTUtils35.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
11803
11725
|
return binding?.defs.length === 1 && binding.defs[0]?.node === declaration ? declaration.typeAnnotation : void 0;
|
|
11804
11726
|
}
|
|
11805
11727
|
};
|
|
@@ -12110,7 +12032,7 @@ var no_production_browser_source_maps_default = createRule({
|
|
|
12110
12032
|
});
|
|
12111
12033
|
|
|
12112
12034
|
// src/rules/no-raw-env.ts
|
|
12113
|
-
import { ASTUtils as
|
|
12035
|
+
import { ASTUtils as ASTUtils36, AST_NODE_TYPES as AST_NODE_TYPES59 } from "@typescript-eslint/utils";
|
|
12114
12036
|
var NO_RAW_ENV_DOCUMENTATION = {
|
|
12115
12037
|
summary: "Disallow direct `process.env` and `import.meta.env` reads outside validated boundaries.",
|
|
12116
12038
|
rationale: "Raw environment reads are untyped and defer invalid configuration failures until use.",
|
|
@@ -12126,15 +12048,15 @@ var CONFIG_FILE_RE = /(^|[\\/])[\w.-]+\.config\.[cm]?[jt]sx?$/;
|
|
|
12126
12048
|
var ENV_BOUNDARY_FILE_RE = /(^|[\\/])(?:env|client-env|server-env|client-settings|server-settings)\.[cm]?[jt]sx?$/;
|
|
12127
12049
|
function isProcessEnv(node, context) {
|
|
12128
12050
|
const receiver = unwrapExpression(node.object);
|
|
12129
|
-
if (receiver.type !== "Identifier" ||
|
|
12130
|
-
const binding =
|
|
12051
|
+
if (receiver.type !== "Identifier" || ASTUtils36.getPropertyName(node) !== "env") return false;
|
|
12052
|
+
const binding = ASTUtils36.findVariable(context.sourceCode.getScope(receiver), receiver.name);
|
|
12131
12053
|
if (binding === null || binding.defs.length === 0) return receiver.name === "process";
|
|
12132
12054
|
return binding.defs.every(
|
|
12133
12055
|
(definition) => definition.type === "ImportBinding" && definition.parent.type === "ImportDeclaration" && definition.parent.importKind !== "type" && ["node:process", "process"].includes(definition.parent.source.value) && ["ImportDefaultSpecifier", "ImportNamespaceSpecifier"].includes(definition.node.type)
|
|
12134
12056
|
);
|
|
12135
12057
|
}
|
|
12136
12058
|
function isImportMetaEnv(node) {
|
|
12137
|
-
return
|
|
12059
|
+
return ASTUtils36.getPropertyName(node) === "env" && node.object.type === "MetaProperty" && node.object.meta.name === "import" && node.object.property.name === "meta";
|
|
12138
12060
|
}
|
|
12139
12061
|
var BUILD_TIME_CONSTANTS = /* @__PURE__ */ new Set([
|
|
12140
12062
|
"NODE_ENV",
|
|
@@ -12152,7 +12074,7 @@ var PLATFORM_MARKERS = /* @__PURE__ */ new Set([
|
|
|
12152
12074
|
function isExemptVariableAccess(node) {
|
|
12153
12075
|
const parent = node.parent;
|
|
12154
12076
|
if (parent.type !== "MemberExpression" || parent.object !== node) return false;
|
|
12155
|
-
const name =
|
|
12077
|
+
const name = ASTUtils36.getPropertyName(parent);
|
|
12156
12078
|
return name !== null && (BUILD_TIME_CONSTANTS.has(name) || PLATFORM_MARKERS.has(name));
|
|
12157
12079
|
}
|
|
12158
12080
|
function isWriteTarget(node) {
|
|
@@ -12200,7 +12122,7 @@ var no_raw_env_default = createRule({
|
|
|
12200
12122
|
if (callee.type === "Identifier" && callee.name === "createEnv") {
|
|
12201
12123
|
hasValidationCall = true;
|
|
12202
12124
|
} else if (callee.type === "MemberExpression") {
|
|
12203
|
-
const name =
|
|
12125
|
+
const name = ASTUtils36.getPropertyName(callee);
|
|
12204
12126
|
if (name === "parse" || name === "safeParse" || name === "object" && calleeReceiver.type === "Identifier" && calleeReceiver.name === "z") {
|
|
12205
12127
|
hasValidationCall = true;
|
|
12206
12128
|
}
|
|
@@ -12220,7 +12142,7 @@ var no_raw_env_default = createRule({
|
|
|
12220
12142
|
});
|
|
12221
12143
|
|
|
12222
12144
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
12223
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES60, ASTUtils as
|
|
12145
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES60, ASTUtils as ASTUtils37 } from "@typescript-eslint/utils";
|
|
12224
12146
|
var NO_RAW_FETCH_OUTSIDE_CLIENTS_DOCUMENTATION = {
|
|
12225
12147
|
summary: "Disallow calling the global `fetch` outside the client layer; route outbound HTTP through a client module that owns retry, timeout and status handling.",
|
|
12226
12148
|
rationale: "Scattered fetch calls bypass shared transport policy and are harder to stub and observe consistently.",
|
|
@@ -12409,7 +12331,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
12409
12331
|
internalApiPrefixes.push(`${options.basePath}/api`);
|
|
12410
12332
|
}
|
|
12411
12333
|
function resolvesToGlobal(identifier) {
|
|
12412
|
-
const variable =
|
|
12334
|
+
const variable = ASTUtils37.findVariable(
|
|
12413
12335
|
context.sourceCode.getScope(identifier),
|
|
12414
12336
|
identifier.name
|
|
12415
12337
|
);
|
|
@@ -12418,7 +12340,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
12418
12340
|
function resolveNode2(node) {
|
|
12419
12341
|
if (node === void 0) return null;
|
|
12420
12342
|
if (node.type !== AST_NODE_TYPES60.Identifier) return node;
|
|
12421
|
-
const variable =
|
|
12343
|
+
const variable = ASTUtils37.findVariable(
|
|
12422
12344
|
context.sourceCode.getScope(node),
|
|
12423
12345
|
node.name
|
|
12424
12346
|
);
|
|
@@ -12498,7 +12420,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
12498
12420
|
});
|
|
12499
12421
|
|
|
12500
12422
|
// src/rules/no-restricted-library-load.ts
|
|
12501
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES61, ASTUtils as
|
|
12423
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES61, ASTUtils as ASTUtils38 } from "@typescript-eslint/utils";
|
|
12502
12424
|
var NO_RESTRICTED_LIBRARY_LOAD_DOCUMENTATION = {
|
|
12503
12425
|
summary: "Apply configured library restrictions to literal runtime loads and CommonJS resolution references.",
|
|
12504
12426
|
rationale: "Dynamic imports, CommonJS loads, and package resolution checks can bypass library restrictions enforced for static imports.",
|
|
@@ -12585,7 +12507,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
12585
12507
|
});
|
|
12586
12508
|
}
|
|
12587
12509
|
function isUnshadowedRequire(node) {
|
|
12588
|
-
const variable =
|
|
12510
|
+
const variable = ASTUtils38.findVariable(
|
|
12589
12511
|
context.sourceCode.getScope(node),
|
|
12590
12512
|
node.name
|
|
12591
12513
|
);
|
|
@@ -12619,7 +12541,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
12619
12541
|
});
|
|
12620
12542
|
|
|
12621
12543
|
// src/rules/no-router-refresh-polling.ts
|
|
12622
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES62, ASTUtils as
|
|
12544
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES62, ASTUtils as ASTUtils39 } from "@typescript-eslint/utils";
|
|
12623
12545
|
var NO_ROUTER_REFRESH_POLLING_DOCUMENTATION = {
|
|
12624
12546
|
summary: "Do not poll by calling a Next.js router's refresh method from a timer.",
|
|
12625
12547
|
rationale: "A route refresh refetches and rerenders the whole route on every tick instead of loading the named resource that changed.",
|
|
@@ -12647,10 +12569,10 @@ function enclosingIntervalCallback(sourceCode, node) {
|
|
|
12647
12569
|
}
|
|
12648
12570
|
function isIntervalCallee(sourceCode, node) {
|
|
12649
12571
|
node = unwrapExpression(node);
|
|
12650
|
-
return node.type === AST_NODE_TYPES62.Identifier && node.name === "setInterval" && isUnshadowedGlobal3(sourceCode, node) || node.type === AST_NODE_TYPES62.MemberExpression && node.object.type === AST_NODE_TYPES62.Identifier && (node.object.name === "window" || node.object.name === "globalThis") && isUnshadowedGlobal3(sourceCode, node.object) &&
|
|
12572
|
+
return node.type === AST_NODE_TYPES62.Identifier && node.name === "setInterval" && isUnshadowedGlobal3(sourceCode, node) || node.type === AST_NODE_TYPES62.MemberExpression && node.object.type === AST_NODE_TYPES62.Identifier && (node.object.name === "window" || node.object.name === "globalThis") && isUnshadowedGlobal3(sourceCode, node.object) && ASTUtils39.getPropertyName(node) === "setInterval";
|
|
12651
12573
|
}
|
|
12652
12574
|
function isUnshadowedGlobal3(sourceCode, node) {
|
|
12653
|
-
const variable =
|
|
12575
|
+
const variable = ASTUtils39.findVariable(sourceCode.getScope(node), node.name);
|
|
12654
12576
|
return variable === null || variable.defs.length === 0;
|
|
12655
12577
|
}
|
|
12656
12578
|
var no_router_refresh_polling_default = createRule({
|
|
@@ -12673,7 +12595,7 @@ var no_router_refresh_polling_default = createRule({
|
|
|
12673
12595
|
if (node.source.value !== "next/navigation") return;
|
|
12674
12596
|
for (const specifier of node.specifiers) {
|
|
12675
12597
|
if (specifier.type === AST_NODE_TYPES62.ImportSpecifier && importedName4(specifier) === "useRouter") {
|
|
12676
|
-
const variable =
|
|
12598
|
+
const variable = ASTUtils39.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
12677
12599
|
if (variable !== null) routerHooks.add(variable);
|
|
12678
12600
|
}
|
|
12679
12601
|
}
|
|
@@ -12683,16 +12605,16 @@ var no_router_refresh_polling_default = createRule({
|
|
|
12683
12605
|
if (node.id.type === AST_NODE_TYPES62.Identifier && initializer?.type === AST_NODE_TYPES62.CallExpression) {
|
|
12684
12606
|
const hookCallee = unwrapExpression(initializer.callee);
|
|
12685
12607
|
if (hookCallee.type !== AST_NODE_TYPES62.Identifier) return;
|
|
12686
|
-
const hook =
|
|
12687
|
-
const router =
|
|
12608
|
+
const hook = ASTUtils39.findVariable(context.sourceCode.getScope(hookCallee), hookCallee.name);
|
|
12609
|
+
const router = ASTUtils39.findVariable(context.sourceCode.getScope(node.id), node.id.name);
|
|
12688
12610
|
if (hook !== null && router !== null && routerHooks.has(hook)) routers.add(router);
|
|
12689
12611
|
}
|
|
12690
12612
|
},
|
|
12691
12613
|
CallExpression(node) {
|
|
12692
12614
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
12693
12615
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES62.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
12694
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES62.MemberExpression || receiver.type !== AST_NODE_TYPES62.Identifier ||
|
|
12695
|
-
const router =
|
|
12616
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES62.MemberExpression || receiver.type !== AST_NODE_TYPES62.Identifier || ASTUtils39.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils39.getPropertyName(unwrappedNodeCallee) ?? "") !== "refresh") return;
|
|
12617
|
+
const router = ASTUtils39.findVariable(
|
|
12696
12618
|
context.sourceCode.getScope(receiver),
|
|
12697
12619
|
receiver.name
|
|
12698
12620
|
);
|
|
@@ -13255,7 +13177,7 @@ function proseTokens(text) {
|
|
|
13255
13177
|
}
|
|
13256
13178
|
|
|
13257
13179
|
// src/rules/no-secret-in-log.ts
|
|
13258
|
-
import { ASTUtils as
|
|
13180
|
+
import { ASTUtils as ASTUtils40 } from "@typescript-eslint/utils";
|
|
13259
13181
|
var NO_SECRET_IN_LOG_DOCUMENTATION = {
|
|
13260
13182
|
summary: "Disallow passing a secret-named value or a raw request/response blob to a logging call; both leak to log sinks. Redact or omit.",
|
|
13261
13183
|
rationale: "Logs are widely retained and distributed, so credentials and raw bodies can become durable data leaks.",
|
|
@@ -13334,7 +13256,7 @@ function hasRedactionMarker(name) {
|
|
|
13334
13256
|
}
|
|
13335
13257
|
function valueName(node) {
|
|
13336
13258
|
if (node.type === "Identifier") return node.name;
|
|
13337
|
-
return node.type === "MemberExpression" ?
|
|
13259
|
+
return node.type === "MemberExpression" ? ASTUtils40.getPropertyName(node) : null;
|
|
13338
13260
|
}
|
|
13339
13261
|
function isRawSecretValue(prop) {
|
|
13340
13262
|
if (prop.shorthand) {
|
|
@@ -13385,11 +13307,11 @@ function rawBlobValueName(value) {
|
|
|
13385
13307
|
return isRawBlobName(value.name) ? value.name : null;
|
|
13386
13308
|
}
|
|
13387
13309
|
if (value.type === "MemberExpression") {
|
|
13388
|
-
const name =
|
|
13310
|
+
const name = ASTUtils40.getPropertyName(value);
|
|
13389
13311
|
return name !== null && isRawBlobName(name) ? name : null;
|
|
13390
13312
|
}
|
|
13391
13313
|
if (value.type === "CallExpression" && value.arguments.length === 0 && unwrappedValueCallee?.type === "MemberExpression" && unwrappedValueCallee.object.type === "Identifier" && /^(?:res|response|\w+Response)$/.test(unwrappedValueCallee.object.name)) {
|
|
13392
|
-
const name =
|
|
13314
|
+
const name = ASTUtils40.getPropertyName(unwrappedValueCallee);
|
|
13393
13315
|
return name === "json" || name === "text" ? `${unwrappedValueCallee.object.name}.${name}()` : null;
|
|
13394
13316
|
}
|
|
13395
13317
|
return null;
|
|
@@ -13446,7 +13368,7 @@ var no_secret_in_log_default = createRule({
|
|
|
13446
13368
|
const matcher = createLogMatcher(loggingOptions);
|
|
13447
13369
|
const blobArmApplies = !isTestFile(context.filename);
|
|
13448
13370
|
function resolvesToGlobal(identifier) {
|
|
13449
|
-
const variable =
|
|
13371
|
+
const variable = ASTUtils40.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
13450
13372
|
return variable === null || variable.defs.length === 0;
|
|
13451
13373
|
}
|
|
13452
13374
|
function inspectLoggedValue(value) {
|
|
@@ -13481,7 +13403,7 @@ var no_secret_in_log_default = createRule({
|
|
|
13481
13403
|
const callee = value.type === "CallExpression" ? unwrapExpression(value.callee) : null;
|
|
13482
13404
|
if (value.type !== "CallExpression" || callee?.type !== "MemberExpression" || value.arguments.some((arg) => arg.type === "SpreadElement")) return void 0;
|
|
13483
13405
|
const object = unwrapExpression(callee.object);
|
|
13484
|
-
const method =
|
|
13406
|
+
const method = ASTUtils40.getPropertyName(callee);
|
|
13485
13407
|
if (method === "stringify" && object.type === "Identifier" && object.name === "JSON" && resolvesToGlobal(object) && hasNoReplacer(value.arguments[1])) return value.arguments[0] ?? null;
|
|
13486
13408
|
if (method === "slice" || method === "substring" || method === "substr") {
|
|
13487
13409
|
return isEmptyTruncation(method, value.arguments) ? null : object;
|
|
@@ -13729,7 +13651,7 @@ var no_select_star_default = createRule({
|
|
|
13729
13651
|
});
|
|
13730
13652
|
|
|
13731
13653
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
13732
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES66, ASTUtils as
|
|
13654
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES66, ASTUtils as ASTUtils41 } from "@typescript-eslint/utils";
|
|
13733
13655
|
var NO_SENTINEL_RETURN_ON_CATCH_DOCUMENTATION = {
|
|
13734
13656
|
summary: "Disallow swallowing a caught error by returning an empty sentinel unless the error is handled or the sentinel is part of the function contract.",
|
|
13735
13657
|
rationale: "An unreported fallback makes operational failure indistinguishable from a legitimate empty result.",
|
|
@@ -13883,8 +13805,8 @@ function argsIncludeBinding(args, caughtName) {
|
|
|
13883
13805
|
}
|
|
13884
13806
|
function isParseShapedNode(node) {
|
|
13885
13807
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
13886
|
-
if (node.type === AST_NODE_TYPES66.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES66.MemberExpression &&
|
|
13887
|
-
return (
|
|
13808
|
+
if (node.type === AST_NODE_TYPES66.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES66.MemberExpression && ASTUtils41.getPropertyName(unwrappedNodeCallee) !== null) {
|
|
13809
|
+
return (ASTUtils41.getPropertyName(unwrappedNodeCallee) ?? "") === "parse";
|
|
13888
13810
|
}
|
|
13889
13811
|
if (node.type === AST_NODE_TYPES66.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES66.Identifier) {
|
|
13890
13812
|
return SAFE_PARSE_CONSTRUCTORS.has(unwrappedNodeCallee.name);
|
|
@@ -13898,21 +13820,21 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
13898
13820
|
]);
|
|
13899
13821
|
function isBodyDecodeNode(node) {
|
|
13900
13822
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
13901
|
-
return node.type === AST_NODE_TYPES66.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES66.MemberExpression &&
|
|
13823
|
+
return node.type === AST_NODE_TYPES66.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES66.MemberExpression && ASTUtils41.getPropertyName(unwrappedNodeCallee) !== null && BODY_DECODE_METHODS.has(ASTUtils41.getPropertyName(unwrappedNodeCallee) ?? "");
|
|
13902
13824
|
}
|
|
13903
13825
|
function isSafeParseSupportCall(node) {
|
|
13904
13826
|
const callee = unwrapExpression(node.callee);
|
|
13905
|
-
if (callee.type !== AST_NODE_TYPES66.MemberExpression ||
|
|
13827
|
+
if (callee.type !== AST_NODE_TYPES66.MemberExpression || ASTUtils41.getPropertyName(callee) === null) {
|
|
13906
13828
|
return false;
|
|
13907
13829
|
}
|
|
13908
|
-
if ((
|
|
13830
|
+
if ((ASTUtils41.getPropertyName(callee) ?? "") === "isArray" && callee.object.type === AST_NODE_TYPES66.Identifier && callee.object.name === "Array") {
|
|
13909
13831
|
return true;
|
|
13910
13832
|
}
|
|
13911
|
-
if ((
|
|
13833
|
+
if ((ASTUtils41.getPropertyName(callee) ?? "") !== "getItem") return false;
|
|
13912
13834
|
if (callee.object.type === AST_NODE_TYPES66.Identifier && (callee.object.name === "localStorage" || callee.object.name === "sessionStorage")) {
|
|
13913
13835
|
return true;
|
|
13914
13836
|
}
|
|
13915
|
-
return callee.object.type === AST_NODE_TYPES66.MemberExpression && callee.object.object.type === AST_NODE_TYPES66.Identifier && (callee.object.object.name === "window" || callee.object.object.name === "globalThis") &&
|
|
13837
|
+
return callee.object.type === AST_NODE_TYPES66.MemberExpression && callee.object.object.type === AST_NODE_TYPES66.Identifier && (callee.object.object.name === "window" || callee.object.object.name === "globalThis") && ASTUtils41.getPropertyName(callee.object) !== null && ((ASTUtils41.getPropertyName(callee.object) ?? "") === "localStorage" || (ASTUtils41.getPropertyName(callee.object) ?? "") === "sessionStorage");
|
|
13916
13838
|
}
|
|
13917
13839
|
var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
13918
13840
|
"json",
|
|
@@ -14124,7 +14046,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
14124
14046
|
return;
|
|
14125
14047
|
}
|
|
14126
14048
|
const returned = unwrapSentinelExpression(last.argument);
|
|
14127
|
-
if (returned?.type === AST_NODE_TYPES66.Identifier && returned.name === "undefined" && (
|
|
14049
|
+
if (returned?.type === AST_NODE_TYPES66.Identifier && returned.name === "undefined" && (ASTUtils41.findVariable(context.sourceCode.getScope(returned), returned.name)?.defs.length ?? 0) > 0) return;
|
|
14128
14050
|
if (containsThrow(node.body)) {
|
|
14129
14051
|
return;
|
|
14130
14052
|
}
|
|
@@ -14167,7 +14089,7 @@ function isNonReadingProperty(current, key) {
|
|
|
14167
14089
|
}
|
|
14168
14090
|
|
|
14169
14091
|
// src/rules/no-silent-promise-catch.ts
|
|
14170
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES67, ASTUtils as
|
|
14092
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES67, ASTUtils as ASTUtils42 } from "@typescript-eslint/utils";
|
|
14171
14093
|
var NO_SILENT_PROMISE_CATCH_DOCUMENTATION = {
|
|
14172
14094
|
summary: "Disallow `.catch()` and second-argument `.then()` handlers that silently swallow a rejection; log, rethrow, or handle the error.",
|
|
14173
14095
|
rationale: "A swallowed rejection hides failures and gives callers an indistinguishable fallback value.",
|
|
@@ -14316,8 +14238,8 @@ function isIdentityContinuation(call, sourceCode) {
|
|
|
14316
14238
|
if (returned === null) return false;
|
|
14317
14239
|
const value = unwrapExpression(returned);
|
|
14318
14240
|
if (value.type !== AST_NODE_TYPES67.Identifier) return false;
|
|
14319
|
-
const binding =
|
|
14320
|
-
return binding !== null &&
|
|
14241
|
+
const binding = ASTUtils42.findVariable(sourceCode.getScope(parameter), parameter.name);
|
|
14242
|
+
return binding !== null && ASTUtils42.findVariable(sourceCode.getScope(value), value.name) === binding;
|
|
14321
14243
|
}
|
|
14322
14244
|
var no_silent_promise_catch_default = createRule({
|
|
14323
14245
|
name: "no-silent-promise-catch",
|
|
@@ -14342,7 +14264,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
14342
14264
|
if (seen.has(node)) return false;
|
|
14343
14265
|
seen.add(node);
|
|
14344
14266
|
if (node.type === AST_NODE_TYPES67.Identifier) {
|
|
14345
|
-
const binding =
|
|
14267
|
+
const binding = ASTUtils42.findVariable(context.sourceCode.getScope(node), node.name);
|
|
14346
14268
|
if (binding === null || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
14347
14269
|
const [definition] = binding.defs;
|
|
14348
14270
|
return binding.defs.length === 1 && definition?.node.type === AST_NODE_TYPES67.VariableDeclarator && definition.node.init !== null && isZodSchema(definition.node.init, seen);
|
|
@@ -14352,7 +14274,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
14352
14274
|
const method = staticPropertyName(unwrappedNodeCallee, context.sourceCode);
|
|
14353
14275
|
if (object.type === AST_NODE_TYPES67.MemberExpression && staticPropertyName(object, context.sourceCode) === "coerce" && method !== null && ["bigint", "boolean", "number", "string"].includes(method)) object = object.object;
|
|
14354
14276
|
if (object.type === AST_NODE_TYPES67.Identifier && method !== null && ZOD_CONSTRUCTORS.has(method)) {
|
|
14355
|
-
const binding =
|
|
14277
|
+
const binding = ASTUtils42.findVariable(context.sourceCode.getScope(object), object.name);
|
|
14356
14278
|
if (binding?.defs.some((definition) => {
|
|
14357
14279
|
const specifier = definition.node;
|
|
14358
14280
|
return (specifier.type === AST_NODE_TYPES67.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES67.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES67.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES67.Identifier && specifier.imported.name === "z") && specifier.parent.type === AST_NODE_TYPES67.ImportDeclaration && isZodModule(String(specifier.parent.source.value));
|
|
@@ -14416,7 +14338,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
14416
14338
|
});
|
|
14417
14339
|
|
|
14418
14340
|
// src/rules/no-sleep-in-test-body.ts
|
|
14419
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES68, ASTUtils as
|
|
14341
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES68, ASTUtils as ASTUtils43 } from "@typescript-eslint/utils";
|
|
14420
14342
|
var NO_SLEEP_IN_TEST_BODY_DOCUMENTATION = {
|
|
14421
14343
|
summary: "Avoid fixed timed sleeps directly in test bodies; synchronize on observable behavior or use controlled timers.",
|
|
14422
14344
|
rationale: "Wall-clock delays make test correctness depend on scheduler and machine speed.",
|
|
@@ -14505,7 +14427,7 @@ function testCallerName(callee, source) {
|
|
|
14505
14427
|
return name !== null && TEST_CALLERS2.has(name) ? name : null;
|
|
14506
14428
|
}
|
|
14507
14429
|
if (callee.type === AST_NODE_TYPES68.MemberExpression) {
|
|
14508
|
-
const member =
|
|
14430
|
+
const member = ASTUtils43.getPropertyName(callee);
|
|
14509
14431
|
const receiver = unwrapExpression(callee.object);
|
|
14510
14432
|
if ((member === "beforeEach" || member === "afterEach") && receiver.type === AST_NODE_TYPES68.Identifier && vitestFixtureTestName(source, receiver) !== null) return member;
|
|
14511
14433
|
return member !== null && TEST_MODIFIERS3.has(member) ? testCallerName(callee.object, source) : null;
|
|
@@ -14545,8 +14467,8 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
14545
14467
|
return {
|
|
14546
14468
|
NewExpression(node) {
|
|
14547
14469
|
if (isPromiseSleep(node)) {
|
|
14548
|
-
const constructor =
|
|
14549
|
-
const timer =
|
|
14470
|
+
const constructor = ASTUtils43.findVariable(context.sourceCode.getScope(node), "Promise");
|
|
14471
|
+
const timer = ASTUtils43.findVariable(context.sourceCode.getScope(node), "setTimeout");
|
|
14550
14472
|
if ((constructor?.defs.length ?? 0) > 0 || (timer?.defs.length ?? 0) > 0) return;
|
|
14551
14473
|
report2(node);
|
|
14552
14474
|
}
|
|
@@ -14555,7 +14477,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
14555
14477
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
14556
14478
|
if (isHelperSleep(node)) {
|
|
14557
14479
|
if (unwrappedNodeCallee.type !== AST_NODE_TYPES68.Identifier) return;
|
|
14558
|
-
const variable =
|
|
14480
|
+
const variable = ASTUtils43.findVariable(context.sourceCode.getScope(node), unwrappedNodeCallee.name);
|
|
14559
14481
|
if (variable?.defs.some((definition) => definition.type !== "ImportBinding")) return;
|
|
14560
14482
|
report2(node);
|
|
14561
14483
|
}
|
|
@@ -14565,7 +14487,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
14565
14487
|
});
|
|
14566
14488
|
|
|
14567
14489
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
14568
|
-
import { ASTUtils as
|
|
14490
|
+
import { ASTUtils as ASTUtils44, AST_NODE_TYPES as AST_NODE_TYPES69 } from "@typescript-eslint/utils";
|
|
14569
14491
|
var DEFAULT_METHODS2 = [
|
|
14570
14492
|
"prepare",
|
|
14571
14493
|
"put",
|
|
@@ -14600,7 +14522,7 @@ function storageMethodName(node, methods) {
|
|
|
14600
14522
|
const callee = unwrapExpression(node.callee);
|
|
14601
14523
|
const calleeReceiver = callee.type === AST_NODE_TYPES69.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
14602
14524
|
if (callee.type !== AST_NODE_TYPES69.MemberExpression) return null;
|
|
14603
|
-
const name =
|
|
14525
|
+
const name = ASTUtils44.getPropertyName(callee);
|
|
14604
14526
|
if (name === null || !methods.has(name)) {
|
|
14605
14527
|
return null;
|
|
14606
14528
|
}
|
|
@@ -14621,7 +14543,7 @@ function isStorageLikeReceiver(node) {
|
|
|
14621
14543
|
if (node.type !== AST_NODE_TYPES69.MemberExpression) {
|
|
14622
14544
|
return false;
|
|
14623
14545
|
}
|
|
14624
|
-
const name =
|
|
14546
|
+
const name = ASTUtils44.getPropertyName(node);
|
|
14625
14547
|
if (name !== null && isStorageIdentifier(name)) {
|
|
14626
14548
|
return true;
|
|
14627
14549
|
}
|
|
@@ -14700,7 +14622,7 @@ function hasSqlPreparationEvidence(node, callee) {
|
|
|
14700
14622
|
if (!/^\s*(?:SELECT|WITH|INSERT|UPDATE|DELETE|REPLACE|CREATE|ALTER|DROP|PRAGMA|EXPLAIN)\b/iu.test(stripSqlNoise(text))) return false;
|
|
14701
14623
|
} else {
|
|
14702
14624
|
const receiver = callee.object;
|
|
14703
|
-
const receiverName = receiver.type === AST_NODE_TYPES69.Identifier ? receiver.name : receiver.type === AST_NODE_TYPES69.MemberExpression ?
|
|
14625
|
+
const receiverName = receiver.type === AST_NODE_TYPES69.Identifier ? receiver.name : receiver.type === AST_NODE_TYPES69.MemberExpression ? ASTUtils44.getPropertyName(receiver) ?? "" : "";
|
|
14704
14626
|
if (!/^(?:db|database|connection)$/iu.test(receiverName)) return false;
|
|
14705
14627
|
}
|
|
14706
14628
|
return true;
|
|
@@ -14963,7 +14885,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
14963
14885
|
});
|
|
14964
14886
|
|
|
14965
14887
|
// src/rules/no-duplicate-test-case.ts
|
|
14966
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES70, ASTUtils as
|
|
14888
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES70, ASTUtils as ASTUtils45 } from "@typescript-eslint/utils";
|
|
14967
14889
|
var TEST_MODULES = /* @__PURE__ */ new Set(["vitest", "@jest/globals", "bun:test"]);
|
|
14968
14890
|
var TEST_NAMES2 = /* @__PURE__ */ new Set(["it", "test"]);
|
|
14969
14891
|
var MODIFIERS = /* @__PURE__ */ new Set(["only", "skip", "concurrent", "sequential", "fails", "failing", "todo"]);
|
|
@@ -14990,17 +14912,17 @@ var NO_DUPLICATE_TEST_CASE_DOCUMENTATION = {
|
|
|
14990
14912
|
function frameworkTable(node, sourceCode) {
|
|
14991
14913
|
let callee = unwrapExpression(node.callee);
|
|
14992
14914
|
if (callee.type !== AST_NODE_TYPES70.MemberExpression) return false;
|
|
14993
|
-
const method =
|
|
14915
|
+
const method = ASTUtils45.getPropertyName(callee);
|
|
14994
14916
|
if (method !== "each" && method !== "for") return false;
|
|
14995
14917
|
callee = unwrapExpression(callee.object);
|
|
14996
14918
|
while (callee.type === AST_NODE_TYPES70.MemberExpression) {
|
|
14997
|
-
const name =
|
|
14919
|
+
const name = ASTUtils45.getPropertyName(callee);
|
|
14998
14920
|
if (name === null || !MODIFIERS.has(name)) return false;
|
|
14999
14921
|
callee = unwrapExpression(callee.object);
|
|
15000
14922
|
}
|
|
15001
14923
|
if (callee.type !== AST_NODE_TYPES70.Identifier) return false;
|
|
15002
14924
|
if (vitestFixtureTestName(sourceCode, callee) !== null) return true;
|
|
15003
|
-
const variable =
|
|
14925
|
+
const variable = ASTUtils45.findVariable(sourceCode.getScope(callee), callee.name);
|
|
15004
14926
|
if (variable === null || variable.defs.length === 0) return TEST_NAMES2.has(callee.name) && !variable?.references.some((reference) => reference.isWrite());
|
|
15005
14927
|
return variable.defs.length === 1 && variable.defs.every((definition) => {
|
|
15006
14928
|
if (definition.node.type !== AST_NODE_TYPES70.ImportSpecifier || definition.node.importKind === "type") return false;
|
|
@@ -15013,7 +14935,7 @@ function table(node, sourceCode) {
|
|
|
15013
14935
|
node = unwrapExpression(node);
|
|
15014
14936
|
if (node.type === AST_NODE_TYPES70.ArrayExpression) return node;
|
|
15015
14937
|
if (node.type !== AST_NODE_TYPES70.Identifier) return null;
|
|
15016
|
-
const variable =
|
|
14938
|
+
const variable = ASTUtils45.findVariable(sourceCode.getScope(node), node.name);
|
|
15017
14939
|
const definition = variable?.defs[0];
|
|
15018
14940
|
if (variable?.defs.length !== 1 || definition?.node.type !== AST_NODE_TYPES70.VariableDeclarator || definition.node.id.type !== AST_NODE_TYPES70.Identifier || definition.node.parent.kind !== "const" || definition.node.init === null || definition.node.init.range[1] > node.range[0]) return null;
|
|
15019
14941
|
if (!variable.references.every((reference) => {
|
|
@@ -15050,7 +14972,7 @@ function objectKey(node) {
|
|
|
15050
14972
|
const fields = [];
|
|
15051
14973
|
for (const property of node.properties) {
|
|
15052
14974
|
if (property.type !== AST_NODE_TYPES70.Property || property.computed || property.kind !== "init" || property.method) return null;
|
|
15053
|
-
const key =
|
|
14975
|
+
const key = ASTUtils45.getPropertyName(property);
|
|
15054
14976
|
const value = literalKey(property.value);
|
|
15055
14977
|
if (key === null || value === null) return null;
|
|
15056
14978
|
fields.push(JSON.stringify([key, value]));
|
|
@@ -15094,7 +15016,7 @@ var no_duplicate_test_case_default = createRule({
|
|
|
15094
15016
|
});
|
|
15095
15017
|
|
|
15096
15018
|
// src/rules/no-tautological-expect.ts
|
|
15097
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES71, ASTUtils as
|
|
15019
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES71, ASTUtils as ASTUtils46 } from "@typescript-eslint/utils";
|
|
15098
15020
|
var NO_TAUTOLOGICAL_EXPECT_DOCUMENTATION = {
|
|
15099
15021
|
summary: "Disallow supported assertions fixed by literal setup or immutable self identity.",
|
|
15100
15022
|
rationale: "An assertion fixed by literal setup or one immutable binding's identity cannot distinguish a wrong result from the intended behavior.",
|
|
@@ -15265,7 +15187,7 @@ function resolveLiteral(node, sourceCode, seen = /* @__PURE__ */ new Set()) {
|
|
|
15265
15187
|
if (isLiteral(node)) return node;
|
|
15266
15188
|
if (node.type !== AST_NODE_TYPES71.Identifier || seen.has(node)) return null;
|
|
15267
15189
|
seen.add(node);
|
|
15268
|
-
const variable =
|
|
15190
|
+
const variable = ASTUtils46.findVariable(sourceCode.getScope(node), node.name);
|
|
15269
15191
|
if (variable?.defs.length !== 1) return null;
|
|
15270
15192
|
const definition = variable.defs[0];
|
|
15271
15193
|
if (definition?.node.type !== AST_NODE_TYPES71.VariableDeclarator || definition.node.id.type !== AST_NODE_TYPES71.Identifier || definition.node.parent.kind !== "const" || definition.node.init === null || definition.node.init.range[1] > node.range[0] || variable.references.some((reference) => reference.isWrite() && !reference.init)) return null;
|
|
@@ -15332,7 +15254,7 @@ function passesZeroArgumentMatcher(node, matcher) {
|
|
|
15332
15254
|
}
|
|
15333
15255
|
function expectOperand(callee, sourceCode) {
|
|
15334
15256
|
let receiver = unwrapExpression(callee.object);
|
|
15335
|
-
const negated = receiver.type === AST_NODE_TYPES71.MemberExpression &&
|
|
15257
|
+
const negated = receiver.type === AST_NODE_TYPES71.MemberExpression && ASTUtils46.getPropertyName(receiver) === "not";
|
|
15336
15258
|
if (negated && receiver.type === AST_NODE_TYPES71.MemberExpression) receiver = unwrapExpression(receiver.object);
|
|
15337
15259
|
const expectCallee = receiver.type === AST_NODE_TYPES71.CallExpression ? unwrapExpression(receiver.callee) : null;
|
|
15338
15260
|
if (receiver.type !== AST_NODE_TYPES71.CallExpression || expectCallee?.type !== AST_NODE_TYPES71.Identifier || runtimeTestFrameworkName(sourceCode, expectCallee, "assertion") !== "expect" || receiver.arguments.length !== 1 && !hasStaticMessage(receiver, expectCallee, sourceCode)) {
|
|
@@ -15343,7 +15265,7 @@ function expectOperand(callee, sourceCode) {
|
|
|
15343
15265
|
}
|
|
15344
15266
|
function hasStaticMessage(call, callee, source) {
|
|
15345
15267
|
if (call.arguments.length !== 2) return false;
|
|
15346
|
-
const definition =
|
|
15268
|
+
const definition = ASTUtils46.findVariable(source.getScope(callee), callee.name)?.defs[0];
|
|
15347
15269
|
if (definition?.type !== "ImportBinding" || definition.parent.type !== AST_NODE_TYPES71.ImportDeclaration || !["vitest", "@playwright/test"].includes(definition.parent.source.value)) return false;
|
|
15348
15270
|
const message = call.arguments[1];
|
|
15349
15271
|
const literal2 = message === void 0 ? null : resolveLiteral(message, source);
|
|
@@ -15356,8 +15278,8 @@ function isExceptionContract(node, source) {
|
|
|
15356
15278
|
const call = directArgumentCall(callback);
|
|
15357
15279
|
if (call === null || call.optional) return false;
|
|
15358
15280
|
let member = outerExpression(call).parent;
|
|
15359
|
-
if (member?.type === AST_NODE_TYPES71.MemberExpression &&
|
|
15360
|
-
if (member?.type !== AST_NODE_TYPES71.MemberExpression || member.optional || !THROW_MATCHERS.has(
|
|
15281
|
+
if (member?.type === AST_NODE_TYPES71.MemberExpression && ASTUtils46.getPropertyName(member) === "not") member = outerExpression(member).parent;
|
|
15282
|
+
if (member?.type !== AST_NODE_TYPES71.MemberExpression || member.optional || !THROW_MATCHERS.has(ASTUtils46.getPropertyName(member) ?? "")) return false;
|
|
15361
15283
|
const invocation = outerExpression(member).parent;
|
|
15362
15284
|
return invocation?.type === AST_NODE_TYPES71.CallExpression && !invocation.optional && unwrapExpression(expectOperand(member, source)?.operand ?? member) === callback;
|
|
15363
15285
|
}
|
|
@@ -15380,7 +15302,7 @@ function collectCustomization(node, source, customized) {
|
|
|
15380
15302
|
if (member.type !== AST_NODE_TYPES71.MemberExpression) return;
|
|
15381
15303
|
const receiver = unwrapExpression(member.object);
|
|
15382
15304
|
if (receiver.type !== AST_NODE_TYPES71.Identifier || runtimeTestFrameworkName(source, receiver, "assertion") !== "expect") return;
|
|
15383
|
-
const method =
|
|
15305
|
+
const method = ASTUtils46.getPropertyName(member);
|
|
15384
15306
|
const argument = node.arguments[0] === void 0 ? null : unwrapExpression(node.arguments[0]);
|
|
15385
15307
|
if (method === "addEqualityTesters" && !(argument?.type === AST_NODE_TYPES71.ArrayExpression && argument.elements.length === 0)) {
|
|
15386
15308
|
customized.add("toEqual");
|
|
@@ -15392,7 +15314,7 @@ function collectCustomization(node, source, customized) {
|
|
|
15392
15314
|
return;
|
|
15393
15315
|
}
|
|
15394
15316
|
for (const property of argument.properties) {
|
|
15395
|
-
const name = property.type === AST_NODE_TYPES71.Property ?
|
|
15317
|
+
const name = property.type === AST_NODE_TYPES71.Property ? ASTUtils46.getPropertyName(property) : null;
|
|
15396
15318
|
customized.add(name ?? "*");
|
|
15397
15319
|
}
|
|
15398
15320
|
}
|
|
@@ -15400,8 +15322,8 @@ function hasConstSelfIdentity(actual, expected, source) {
|
|
|
15400
15322
|
actual = unwrapExpression(actual);
|
|
15401
15323
|
expected = unwrapExpression(expected);
|
|
15402
15324
|
if (actual.type !== AST_NODE_TYPES71.Identifier || expected.type !== AST_NODE_TYPES71.Identifier) return false;
|
|
15403
|
-
const variable =
|
|
15404
|
-
if (variable?.defs.length !== 1 ||
|
|
15325
|
+
const variable = ASTUtils46.findVariable(source.getScope(actual), actual.name);
|
|
15326
|
+
if (variable?.defs.length !== 1 || ASTUtils46.findVariable(source.getScope(expected), expected.name) !== variable) return false;
|
|
15405
15327
|
const definition = variable.defs[0];
|
|
15406
15328
|
return definition?.node.type === AST_NODE_TYPES71.VariableDeclarator && definition.node.id.type === AST_NODE_TYPES71.Identifier && definition.node.parent.kind === "const" && definition.node.init !== null && definition.node.init.range[1] <= Math.min(actual.range[0], expected.range[0]) && !variable.references.some((reference) => reference.isWrite() && !reference.init);
|
|
15407
15329
|
}
|
|
@@ -15433,7 +15355,7 @@ var no_tautological_expect_default = createRule({
|
|
|
15433
15355
|
CallExpression(node) {
|
|
15434
15356
|
const callee = unwrapExpression(node.callee);
|
|
15435
15357
|
if (callee.type !== AST_NODE_TYPES71.MemberExpression) return;
|
|
15436
|
-
const matcher =
|
|
15358
|
+
const matcher = ASTUtils46.getPropertyName(callee);
|
|
15437
15359
|
if (matcher === null || !ZERO_ARG_MATCHERS.has(matcher) && !EQUALITY_MATCHERS.has(matcher) || customized.has("*") || customized.has(matcher)) return;
|
|
15438
15360
|
const assertion = expectOperand(callee, context.sourceCode);
|
|
15439
15361
|
if (assertion === null || isExceptionContract(node, context.sourceCode)) return;
|
|
@@ -16815,7 +16737,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
16815
16737
|
});
|
|
16816
16738
|
|
|
16817
16739
|
// src/rules/no-unsafe-test-double-cast.ts
|
|
16818
|
-
import { ASTUtils as
|
|
16740
|
+
import { ASTUtils as ASTUtils47, AST_NODE_TYPES as AST_NODE_TYPES78 } from "@typescript-eslint/utils";
|
|
16819
16741
|
var NO_UNSAFE_TEST_DOUBLE_CAST_DOCUMENTATION = {
|
|
16820
16742
|
summary: "Disallow mock-backed test doubles that bypass collaborator contracts through double assertions.",
|
|
16821
16743
|
rationale: "Casting a partial object through unknown hides missing or stale collaborator members, so production interface changes can compile while the test double silently drifts.",
|
|
@@ -16845,7 +16767,7 @@ function isMockFactory(node, source) {
|
|
|
16845
16767
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
16846
16768
|
if (node.type !== AST_NODE_TYPES78.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES78.MemberExpression) return false;
|
|
16847
16769
|
const receiver = unwrapExpression(unwrappedNodeCallee.object);
|
|
16848
|
-
return node.type === AST_NODE_TYPES78.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES78.MemberExpression && receiver.type === AST_NODE_TYPES78.Identifier && (importedTestMockNamespace(source, receiver) !== null || isUnshadowedTestMockGlobal(source, receiver)) &&
|
|
16770
|
+
return node.type === AST_NODE_TYPES78.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES78.MemberExpression && receiver.type === AST_NODE_TYPES78.Identifier && (importedTestMockNamespace(source, receiver) !== null || isUnshadowedTestMockGlobal(source, receiver)) && ASTUtils47.getPropertyName(unwrappedNodeCallee) !== null && ["fn", "spyOn"].includes(ASTUtils47.getPropertyName(unwrappedNodeCallee) ?? "");
|
|
16849
16771
|
}
|
|
16850
16772
|
var no_unsafe_test_double_cast_default = createRule({
|
|
16851
16773
|
name: "no-unsafe-test-double-cast",
|
|
@@ -16871,7 +16793,7 @@ var no_unsafe_test_double_cast_default = createRule({
|
|
|
16871
16793
|
});
|
|
16872
16794
|
|
|
16873
16795
|
// src/rules/no-first-party-module-mock.ts
|
|
16874
|
-
import { ASTUtils as
|
|
16796
|
+
import { ASTUtils as ASTUtils48, AST_NODE_TYPES as AST_NODE_TYPES79 } from "@typescript-eslint/utils";
|
|
16875
16797
|
var NO_FIRST_PARTY_MODULE_MOCK_DOCUMENTATION = {
|
|
16876
16798
|
summary: "Prefer injected collaborators over mocking maintained first-party modules in tests.",
|
|
16877
16799
|
rationale: "Replacing an owned module couples tests to its lookup path and can verify mock wiring while bypassing the real implementation contract.",
|
|
@@ -16902,7 +16824,7 @@ var no_first_party_module_mock_default = createRule({
|
|
|
16902
16824
|
CallExpression(node) {
|
|
16903
16825
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
16904
16826
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES79.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
16905
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES79.MemberExpression || receiver.type !== AST_NODE_TYPES79.Identifier ||
|
|
16827
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES79.MemberExpression || receiver.type !== AST_NODE_TYPES79.Identifier || ASTUtils48.getPropertyName(unwrappedNodeCallee) === null || !["mock", "doMock"].includes(ASTUtils48.getPropertyName(unwrappedNodeCallee) ?? "")) return;
|
|
16906
16828
|
const framework = importedTestMockNamespace(context.sourceCode, receiver);
|
|
16907
16829
|
if (framework === null || framework === "jest" && mayBeVirtual(node.arguments[2])) return;
|
|
16908
16830
|
const argument = node.arguments[0] === void 0 ? void 0 : unwrapExpression(node.arguments[0]);
|
|
@@ -16928,7 +16850,7 @@ function mayBeVirtual(options) {
|
|
|
16928
16850
|
import {
|
|
16929
16851
|
ESLintUtils as ESLintUtils17,
|
|
16930
16852
|
AST_NODE_TYPES as AST_NODE_TYPES80,
|
|
16931
|
-
ASTUtils as
|
|
16853
|
+
ASTUtils as ASTUtils49
|
|
16932
16854
|
} from "@typescript-eslint/utils";
|
|
16933
16855
|
import * as ts17 from "typescript";
|
|
16934
16856
|
var NO_ZOD_NATIVE_ENUM_DOCUMENTATION = {
|
|
@@ -17048,7 +16970,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
17048
16970
|
const zodImportedBindings = /* @__PURE__ */ new Map();
|
|
17049
16971
|
const zodNamespaceBindings = /* @__PURE__ */ new Set();
|
|
17050
16972
|
function resolvedBinding(identifier) {
|
|
17051
|
-
return
|
|
16973
|
+
return ASTUtils49.findVariable(
|
|
17052
16974
|
sourceCode.getScope(identifier),
|
|
17053
16975
|
identifier.name
|
|
17054
16976
|
);
|
|
@@ -17056,7 +16978,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
17056
16978
|
function isZodMemberCall(node, api) {
|
|
17057
16979
|
const callee = unwrapExpression(node.callee);
|
|
17058
16980
|
const calleeReceiver = callee.type === AST_NODE_TYPES80.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
17059
|
-
if (callee.type === AST_NODE_TYPES80.MemberExpression && calleeReceiver.type === AST_NODE_TYPES80.Identifier &&
|
|
16981
|
+
if (callee.type === AST_NODE_TYPES80.MemberExpression && calleeReceiver.type === AST_NODE_TYPES80.Identifier && ASTUtils49.getPropertyName(callee) === api) {
|
|
17060
16982
|
const binding = resolvedBinding(calleeReceiver);
|
|
17061
16983
|
return binding !== null && zodNamespaceBindings.has(binding);
|
|
17062
16984
|
}
|
|
@@ -17115,7 +17037,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
17115
17037
|
});
|
|
17116
17038
|
|
|
17117
17039
|
// src/rules/test-loops-over-literal-cases.ts
|
|
17118
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES81, ASTUtils as
|
|
17040
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES81, ASTUtils as ASTUtils50 } from "@typescript-eslint/utils";
|
|
17119
17041
|
var TEST_LOOPS_OVER_LITERAL_CASES_DOCUMENTATION = {
|
|
17120
17042
|
summary: "Disallow assertions over an inline literal case loop in a test; parameterization reports and names every case independently.",
|
|
17121
17043
|
rationale: "A loop is reported as one test, so failures hide the individual case name and may stop later cases from running.",
|
|
@@ -17268,7 +17190,7 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
17268
17190
|
}
|
|
17269
17191
|
const capturesSetup = walkOwnScope2(node.body, (current) => {
|
|
17270
17192
|
if (current.type !== AST_NODE_TYPES81.Identifier) return false;
|
|
17271
|
-
const variable =
|
|
17193
|
+
const variable = ASTUtils50.findVariable(context.sourceCode.getScope(current), current.name);
|
|
17272
17194
|
if (variable === null || !variable.references.some((reference) => reference.identifier === current)) return false;
|
|
17273
17195
|
return variable.defs.some((definition) => {
|
|
17274
17196
|
const declaration = definition.name;
|
|
@@ -17377,7 +17299,7 @@ var test_phase_label_comment_default = createRule({
|
|
|
17377
17299
|
});
|
|
17378
17300
|
|
|
17379
17301
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
17380
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES83, ASTUtils as
|
|
17302
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES83, ASTUtils as ASTUtils51 } from "@typescript-eslint/utils";
|
|
17381
17303
|
var PREFER_CONSTANT_TIME_SECRET_COMPARE_DOCUMENTATION = {
|
|
17382
17304
|
summary: "Prefer a supported constant-time comparison primitive for secret-like values.",
|
|
17383
17305
|
rationale: "Ordinary equality offers no constant-time guarantee for comparing secrets.",
|
|
@@ -17463,7 +17385,7 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
17463
17385
|
return {};
|
|
17464
17386
|
}
|
|
17465
17387
|
const sourceCode = context.sourceCode;
|
|
17466
|
-
const variableOf = (node) =>
|
|
17388
|
+
const variableOf = (node) => ASTUtils51.findVariable(sourceCode.getScope(node), node.name);
|
|
17467
17389
|
function credentialSource(node, seen = /* @__PURE__ */ new Set()) {
|
|
17468
17390
|
if (seen.has(node) || seen.size >= 8) return false;
|
|
17469
17391
|
seen.add(node);
|
|
@@ -17477,10 +17399,10 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
17477
17399
|
const definition = binding.defs[0];
|
|
17478
17400
|
return definition?.type === "Variable" && definition.parent.kind === "const" && definition.node.init !== null && credentialSource(definition.node.init, seen);
|
|
17479
17401
|
}
|
|
17480
|
-
if (node.type !== AST_NODE_TYPES83.CallExpression || node.optional || node.arguments.length !== 1 || node.callee.type !== AST_NODE_TYPES83.MemberExpression || node.callee.optional ||
|
|
17402
|
+
if (node.type !== AST_NODE_TYPES83.CallExpression || node.optional || node.arguments.length !== 1 || node.callee.type !== AST_NODE_TYPES83.MemberExpression || node.callee.optional || ASTUtils51.getPropertyName(node.callee) !== "get") return false;
|
|
17481
17403
|
const receiver = node.callee.object;
|
|
17482
17404
|
const key = staticString(node.arguments[0]);
|
|
17483
|
-
if (receiver.type !== AST_NODE_TYPES83.MemberExpression || receiver.optional ||
|
|
17405
|
+
if (receiver.type !== AST_NODE_TYPES83.MemberExpression || receiver.optional || ASTUtils51.getPropertyName(receiver) !== "headers" || key === null || !isAuthSecretName(key) || !isNativeRequest(receiver.object)) return false;
|
|
17484
17406
|
const words2 = tokenize(key);
|
|
17485
17407
|
return !words2.includes("token") || words2.some((word) => AUTH_TOKEN_QUALIFIERS.has(word) || word !== "token" && SECRET_WORDS.has(word));
|
|
17486
17408
|
}
|
|
@@ -17618,7 +17540,7 @@ var prefer_ecmascript_private_members_default = createRule({
|
|
|
17618
17540
|
import "@typescript-eslint/utils";
|
|
17619
17541
|
|
|
17620
17542
|
// src/rules/_discriminated-union-returns.ts
|
|
17621
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES85, ASTUtils as
|
|
17543
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES85, ASTUtils as ASTUtils52 } from "@typescript-eslint/utils";
|
|
17622
17544
|
var MAX_PATH_VISITS = 2048;
|
|
17623
17545
|
var MAX_RETURN_OBJECTS = 256;
|
|
17624
17546
|
var MAX_PATH_DEPTH = 64;
|
|
@@ -17806,11 +17728,11 @@ function broadSwitchInput(statement, sourceCode) {
|
|
|
17806
17728
|
if (body2.type !== AST_NODE_TYPES85.BlockStatement || body2.body.length !== 1) return void 0;
|
|
17807
17729
|
const owner = body2.parent;
|
|
17808
17730
|
if (owner.type !== AST_NODE_TYPES85.FunctionDeclaration || owner.id === null) return void 0;
|
|
17809
|
-
const callable =
|
|
17731
|
+
const callable = ASTUtils52.findVariable(sourceCode.getScope(owner), owner.id.name);
|
|
17810
17732
|
if (callable?.defs.length !== 1 || callable.defs[0]?.type !== "FunctionName" || callable.defs[0].node !== owner) return void 0;
|
|
17811
17733
|
const input = statement.discriminant;
|
|
17812
17734
|
if (input.type !== AST_NODE_TYPES85.Identifier) return void 0;
|
|
17813
|
-
const binding =
|
|
17735
|
+
const binding = ASTUtils52.findVariable(sourceCode.getScope(input), input.name);
|
|
17814
17736
|
const definition = binding?.defs[0];
|
|
17815
17737
|
if (binding?.defs.length !== 1 || definition?.type !== "Parameter" || definition.node !== owner || definition.name.type !== AST_NODE_TYPES85.Identifier || binding.references.some((reference) => reference.isWrite())) return void 0;
|
|
17816
17738
|
const type = definition.name.typeAnnotation?.typeAnnotation.type;
|
|
@@ -18057,7 +17979,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
18057
17979
|
});
|
|
18058
17980
|
|
|
18059
17981
|
// src/rules/prefer-input-group-search.ts
|
|
18060
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES87, ASTUtils as
|
|
17982
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES87, ASTUtils as ASTUtils53 } from "@typescript-eslint/utils";
|
|
18061
17983
|
var PREFER_INPUT_GROUP_SEARCH_DOCUMENTATION = {
|
|
18062
17984
|
summary: "Require search icons and shared Input controls in the same visual wrapper to use InputGroup.",
|
|
18063
17985
|
rationale: "The shared compound control provides consistent spacing, focus behavior, and accessible composition.",
|
|
@@ -18181,7 +18103,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
18181
18103
|
JSXOpeningElement(node) {
|
|
18182
18104
|
const name = elementName(node);
|
|
18183
18105
|
if (name === null) return;
|
|
18184
|
-
const binding =
|
|
18106
|
+
const binding = ASTUtils53.findVariable(context.sourceCode.getScope(node), name);
|
|
18185
18107
|
if (binding?.defs.length !== 1 || binding.defs[0]?.node.type !== AST_NODE_TYPES87.ImportSpecifier || binding.defs[0].node.importKind === "type") return;
|
|
18186
18108
|
const occurrence = {
|
|
18187
18109
|
ancestors: context.sourceCode.getAncestors(node),
|
|
@@ -18221,7 +18143,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
18221
18143
|
|
|
18222
18144
|
// src/rules/prefer-millisecond-control-duration-schema.ts
|
|
18223
18145
|
import {
|
|
18224
|
-
ASTUtils as
|
|
18146
|
+
ASTUtils as ASTUtils54,
|
|
18225
18147
|
AST_NODE_TYPES as AST_NODE_TYPES88
|
|
18226
18148
|
} from "@typescript-eslint/utils";
|
|
18227
18149
|
var PREFER_MILLISECOND_CONTROL_DURATION_SCHEMA_DOCUMENTATION = {
|
|
@@ -18292,7 +18214,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
18292
18214
|
const objectFactories = /* @__PURE__ */ new Set();
|
|
18293
18215
|
const numberFactories = /* @__PURE__ */ new Set();
|
|
18294
18216
|
function binding(identifier) {
|
|
18295
|
-
return
|
|
18217
|
+
return ASTUtils54.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
18296
18218
|
}
|
|
18297
18219
|
function record(target, identifier) {
|
|
18298
18220
|
const variable = binding(identifier);
|
|
@@ -18305,7 +18227,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
18305
18227
|
const variable2 = binding(callee);
|
|
18306
18228
|
return variable2 !== null && objectFactories.has(variable2);
|
|
18307
18229
|
}
|
|
18308
|
-
if (callee.type !== AST_NODE_TYPES88.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES88.Identifier ||
|
|
18230
|
+
if (callee.type !== AST_NODE_TYPES88.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES88.Identifier || ASTUtils54.getPropertyName(callee) === null || (ASTUtils54.getPropertyName(callee) ?? "") !== "object" && (ASTUtils54.getPropertyName(callee) ?? "") !== "strictObject") {
|
|
18309
18231
|
return false;
|
|
18310
18232
|
}
|
|
18311
18233
|
const variable = binding(calleeReceiver);
|
|
@@ -18320,12 +18242,12 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
18320
18242
|
const variable = binding(callee);
|
|
18321
18243
|
return variable !== null && numberFactories.has(variable);
|
|
18322
18244
|
}
|
|
18323
|
-
if (callee.type !== AST_NODE_TYPES88.MemberExpression ||
|
|
18245
|
+
if (callee.type !== AST_NODE_TYPES88.MemberExpression || ASTUtils54.getPropertyName(callee) === null) return false;
|
|
18324
18246
|
if (calleeReceiver.type === AST_NODE_TYPES88.Identifier) {
|
|
18325
18247
|
const variable = binding(calleeReceiver);
|
|
18326
|
-
return (
|
|
18248
|
+
return (ASTUtils54.getPropertyName(callee) ?? "") === "number" && variable !== null && zodNamespaces.has(variable);
|
|
18327
18249
|
}
|
|
18328
|
-
return ["int", "min", "max", "positive", "nonnegative", "finite", "multipleOf", "optional", "nullable", "nullish", "default", "describe", "brand", "readonly"].includes(
|
|
18250
|
+
return ["int", "min", "max", "positive", "nonnegative", "finite", "multipleOf", "optional", "nullable", "nullish", "default", "describe", "brand", "readonly"].includes(ASTUtils54.getPropertyName(callee) ?? "") && isNumericSchema(calleeReceiver);
|
|
18329
18251
|
}
|
|
18330
18252
|
return {
|
|
18331
18253
|
ImportDeclaration(node) {
|
|
@@ -18358,7 +18280,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
18358
18280
|
});
|
|
18359
18281
|
|
|
18360
18282
|
// src/rules/prefer-immutable-module-constant.ts
|
|
18361
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES89, ASTUtils as
|
|
18283
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES89, ASTUtils as ASTUtils55 } from "@typescript-eslint/utils";
|
|
18362
18284
|
var PREFER_IMMUTABLE_MODULE_CONSTANT_DOCUMENTATION = {
|
|
18363
18285
|
summary: "Require module-level constant collections to expose readonly state.",
|
|
18364
18286
|
rationale: "A const binding prevents reassignment but does not stop callers from mutating its array, object, Set, or Map contents.",
|
|
@@ -18577,15 +18499,15 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
18577
18499
|
create(context) {
|
|
18578
18500
|
const sourceCode = context.sourceCode;
|
|
18579
18501
|
const isUnshadowedGlobal4 = (identifier) => {
|
|
18580
|
-
const variable =
|
|
18502
|
+
const variable = ASTUtils55.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
18581
18503
|
return variable === null || variable.defs.length === 0;
|
|
18582
18504
|
};
|
|
18583
18505
|
const isUnshadowedType = (identifier) => {
|
|
18584
|
-
const variable =
|
|
18506
|
+
const variable = ASTUtils55.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
18585
18507
|
return variable === null || !variable.defs.some((definition) => definition.isTypeDefinition);
|
|
18586
18508
|
};
|
|
18587
18509
|
const resolveLocalType = (identifier) => {
|
|
18588
|
-
const variable =
|
|
18510
|
+
const variable = ASTUtils55.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
18589
18511
|
const definitions2 = variable?.defs.filter((definition) => definition.isTypeDefinition) ?? [];
|
|
18590
18512
|
const declaration = definitions2.length === 1 ? definitions2[0]?.node : void 0;
|
|
18591
18513
|
return declaration?.type === AST_NODE_TYPES89.TSTypeAliasDeclaration || declaration?.type === AST_NODE_TYPES89.TSTypeParameter ? declaration : void 0;
|
|
@@ -19079,7 +19001,7 @@ function matchingAliasTargets(paths, alias) {
|
|
|
19079
19001
|
}
|
|
19080
19002
|
|
|
19081
19003
|
// src/rules/prefer-module-level-constant.ts
|
|
19082
|
-
import { ASTUtils as
|
|
19004
|
+
import { ASTUtils as ASTUtils56, AST_NODE_TYPES as AST_NODE_TYPES91 } from "@typescript-eslint/utils";
|
|
19083
19005
|
var PREFER_MODULE_LEVEL_CONSTANT_DOCUMENTATION = {
|
|
19084
19006
|
summary: "Hoist literal-only constant collections and regexes out of function bodies to module scope so they are allocated once.",
|
|
19085
19007
|
rationale: "Recreating immutable lookup data on every call wastes allocations and obscures its constant nature.",
|
|
@@ -19279,7 +19201,7 @@ function isNonRetainingBuiltinCall(node, argument, sourceCode) {
|
|
|
19279
19201
|
return true;
|
|
19280
19202
|
}
|
|
19281
19203
|
function isUnshadowedBuiltin(identifier, sourceCode) {
|
|
19282
|
-
return (
|
|
19204
|
+
return (ASTUtils56.findVariable(sourceCode.getScope(identifier), identifier.name)?.defs.length ?? 0) === 0;
|
|
19283
19205
|
}
|
|
19284
19206
|
var prefer_module_level_constant_default = createRule({
|
|
19285
19207
|
name: "prefer-module-level-constant",
|
|
@@ -19409,14 +19331,14 @@ function isSafeMemberRead(identifier, parent) {
|
|
|
19409
19331
|
if (grandparent.type === AST_NODE_TYPES91.UnaryExpression && grandparent.operator === "delete") {
|
|
19410
19332
|
return false;
|
|
19411
19333
|
}
|
|
19412
|
-
if (grandparent.type === AST_NODE_TYPES91.CallExpression && grandparent.callee === usage && (
|
|
19334
|
+
if (grandparent.type === AST_NODE_TYPES91.CallExpression && grandparent.callee === usage && (ASTUtils56.getPropertyName(parent) === null || MUTATING_METHODS2.has(ASTUtils56.getPropertyName(parent) ?? ""))) {
|
|
19413
19335
|
return false;
|
|
19414
19336
|
}
|
|
19415
19337
|
return true;
|
|
19416
19338
|
}
|
|
19417
19339
|
|
|
19418
19340
|
// src/rules/prefer-module-level-schema.ts
|
|
19419
|
-
import { ASTUtils as
|
|
19341
|
+
import { ASTUtils as ASTUtils57, AST_NODE_TYPES as AST_NODE_TYPES92 } from "@typescript-eslint/utils";
|
|
19420
19342
|
var PREFER_MODULE_LEVEL_SCHEMA_DOCUMENTATION = {
|
|
19421
19343
|
summary: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function",
|
|
19422
19344
|
rationale: "A schema created inside a function is rebuilt on each call. Module scope can enable reuse across callers; local schemas already support local type inference.",
|
|
@@ -19524,7 +19446,7 @@ function schemaExpression(node) {
|
|
|
19524
19446
|
if (parent === void 0) {
|
|
19525
19447
|
return current;
|
|
19526
19448
|
}
|
|
19527
|
-
if (parent.type === AST_NODE_TYPES92.MemberExpression && parent.object === current &&
|
|
19449
|
+
if (parent.type === AST_NODE_TYPES92.MemberExpression && parent.object === current && ASTUtils57.getPropertyName(parent) !== null && TERMINAL_METHODS.has(ASTUtils57.getPropertyName(parent) ?? "")) {
|
|
19528
19450
|
return current;
|
|
19529
19451
|
}
|
|
19530
19452
|
if (parent.type === AST_NODE_TYPES92.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES92.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES92.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES92.TSNonNullExpression && parent.expression === current) {
|
|
@@ -19662,14 +19584,14 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19662
19584
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
19663
19585
|
if (node.type !== AST_NODE_TYPES92.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES92.MemberExpression) return false;
|
|
19664
19586
|
const receiver = unwrapExpression(unwrappedNodeCallee.object);
|
|
19665
|
-
return node.type === AST_NODE_TYPES92.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES92.MemberExpression &&
|
|
19587
|
+
return node.type === AST_NODE_TYPES92.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES92.MemberExpression && ASTUtils57.getPropertyName(unwrappedNodeCallee) !== null && receiver.type === AST_NODE_TYPES92.Identifier && zodNamespaces.has(receiver.name);
|
|
19666
19588
|
}
|
|
19667
19589
|
function isSchemaConstruction(node) {
|
|
19668
19590
|
const callee = unwrapExpression(node.callee);
|
|
19669
19591
|
const calleeReceiver = callee.type === AST_NODE_TYPES92.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
19670
|
-
if (callee.type !== AST_NODE_TYPES92.MemberExpression ||
|
|
19592
|
+
if (callee.type !== AST_NODE_TYPES92.MemberExpression || ASTUtils57.getPropertyName(callee) === null || TERMINAL_METHODS.has(ASTUtils57.getPropertyName(callee) ?? "")) return false;
|
|
19671
19593
|
if (calleeReceiver.type === AST_NODE_TYPES92.CallExpression) return isSchemaConstruction(calleeReceiver);
|
|
19672
|
-
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(
|
|
19594
|
+
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(ASTUtils57.getPropertyName(callee) ?? "");
|
|
19673
19595
|
}
|
|
19674
19596
|
function hasEagerComputation(node) {
|
|
19675
19597
|
return subtreeSome(node, (inner) => inner.type === AST_NODE_TYPES92.NewExpression || inner.type === AST_NODE_TYPES92.TaggedTemplateExpression || inner.type === AST_NODE_TYPES92.CallExpression && !isSchemaConstruction(inner), true);
|
|
@@ -19677,10 +19599,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19677
19599
|
function isCovered(node) {
|
|
19678
19600
|
let current = node.parent ?? void 0;
|
|
19679
19601
|
while (current !== void 0) {
|
|
19680
|
-
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES92.MemberExpression &&
|
|
19602
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES92.MemberExpression && ASTUtils57.getPropertyName(current.callee) !== null && factories.has(ASTUtils57.getPropertyName(current.callee) ?? "")) {
|
|
19681
19603
|
return true;
|
|
19682
19604
|
}
|
|
19683
|
-
if (current.type === AST_NODE_TYPES92.CallExpression && (current.callee.type === AST_NODE_TYPES92.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES92.MemberExpression &&
|
|
19605
|
+
if (current.type === AST_NODE_TYPES92.CallExpression && (current.callee.type === AST_NODE_TYPES92.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES92.MemberExpression && ASTUtils57.getPropertyName(current.callee) !== null && memoCallees.has(ASTUtils57.getPropertyName(current.callee) ?? ""))) {
|
|
19684
19606
|
return true;
|
|
19685
19607
|
}
|
|
19686
19608
|
current = current.parent ?? void 0;
|
|
@@ -19709,7 +19631,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19709
19631
|
}
|
|
19710
19632
|
function isSchemaComposition(node) {
|
|
19711
19633
|
const callee = unwrapExpression(node.callee);
|
|
19712
|
-
const isCombinator = callee.type === AST_NODE_TYPES92.MemberExpression &&
|
|
19634
|
+
const isCombinator = callee.type === AST_NODE_TYPES92.MemberExpression && ASTUtils57.getPropertyName(callee) !== null && ZOD_COMBINATOR_METHODS.has(ASTUtils57.getPropertyName(callee) ?? "");
|
|
19713
19635
|
return isCombinator || isZodCall(node);
|
|
19714
19636
|
}
|
|
19715
19637
|
function closesOverNothing(node, enclosing) {
|
|
@@ -19782,10 +19704,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19782
19704
|
return;
|
|
19783
19705
|
}
|
|
19784
19706
|
const callee = unwrappedNodeCallee;
|
|
19785
|
-
if (
|
|
19707
|
+
if (ASTUtils57.getPropertyName(callee) === null) {
|
|
19786
19708
|
return;
|
|
19787
19709
|
}
|
|
19788
|
-
const factory =
|
|
19710
|
+
const factory = ASTUtils57.getPropertyName(callee) ?? "";
|
|
19789
19711
|
if (!factories.has(factory)) {
|
|
19790
19712
|
return;
|
|
19791
19713
|
}
|
|
@@ -19828,7 +19750,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19828
19750
|
// src/rules/prefer-module-level-refined-schema.ts
|
|
19829
19751
|
import {
|
|
19830
19752
|
AST_NODE_TYPES as AST_NODE_TYPES93,
|
|
19831
|
-
ASTUtils as
|
|
19753
|
+
ASTUtils as ASTUtils58
|
|
19832
19754
|
} from "@typescript-eslint/utils";
|
|
19833
19755
|
var BENCHMARK_PATH_RE = /(^|[/\\])(?:benchmarks?|bench)[/\\]/;
|
|
19834
19756
|
var FACTORIES = /* @__PURE__ */ new Set([
|
|
@@ -20055,9 +19977,9 @@ function chainMemberNames(node) {
|
|
|
20055
19977
|
for (; ; ) {
|
|
20056
19978
|
current = unwrapExpression(current);
|
|
20057
19979
|
if (current.type === AST_NODE_TYPES93.MemberExpression) {
|
|
20058
|
-
if (
|
|
19980
|
+
if (ASTUtils58.getPropertyName(current) === null)
|
|
20059
19981
|
return [];
|
|
20060
|
-
names.push(
|
|
19982
|
+
names.push(ASTUtils58.getPropertyName(current) ?? "");
|
|
20061
19983
|
current = current.object;
|
|
20062
19984
|
continue;
|
|
20063
19985
|
}
|
|
@@ -20074,8 +19996,8 @@ function schemaExpression2(node) {
|
|
|
20074
19996
|
let current = node;
|
|
20075
19997
|
for (; ; ) {
|
|
20076
19998
|
const parent = current.parent ?? void 0;
|
|
20077
|
-
if (parent?.type === AST_NODE_TYPES93.MemberExpression && parent.object === current &&
|
|
20078
|
-
if (NON_SCHEMA_TERMINALS.has(
|
|
19999
|
+
if (parent?.type === AST_NODE_TYPES93.MemberExpression && parent.object === current && ASTUtils58.getPropertyName(parent) !== null && parent.parent?.type === AST_NODE_TYPES93.CallExpression && parent.parent.callee === parent) {
|
|
20000
|
+
if (NON_SCHEMA_TERMINALS.has(ASTUtils58.getPropertyName(parent) ?? "")) return current;
|
|
20079
20001
|
current = parent.parent;
|
|
20080
20002
|
continue;
|
|
20081
20003
|
}
|
|
@@ -20105,7 +20027,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
20105
20027
|
return {};
|
|
20106
20028
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
20107
20029
|
function resolvedBinding(identifier) {
|
|
20108
|
-
return
|
|
20030
|
+
return ASTUtils58.findVariable(
|
|
20109
20031
|
context.sourceCode.getScope(identifier),
|
|
20110
20032
|
identifier.name
|
|
20111
20033
|
);
|
|
@@ -20131,7 +20053,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
20131
20053
|
function isSchemaConstruction(node) {
|
|
20132
20054
|
const callee = unwrapExpression(node.callee);
|
|
20133
20055
|
const calleeReceiver = callee.type === AST_NODE_TYPES93.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
20134
|
-
if (callee.type !== AST_NODE_TYPES93.MemberExpression ||
|
|
20056
|
+
if (callee.type !== AST_NODE_TYPES93.MemberExpression || ASTUtils58.getPropertyName(callee) === null || NON_SCHEMA_TERMINALS.has(ASTUtils58.getPropertyName(callee) ?? "")) return false;
|
|
20135
20057
|
if (calleeReceiver.type === AST_NODE_TYPES93.CallExpression) return isSchemaConstruction(calleeReceiver);
|
|
20136
20058
|
return factoryName(node, FACTORIES) !== null || factoryName(node, COMPOSITE_FACTORIES) !== null;
|
|
20137
20059
|
}
|
|
@@ -20158,7 +20080,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
20158
20080
|
function isMemoized(node) {
|
|
20159
20081
|
let current = node.parent ?? void 0;
|
|
20160
20082
|
while (current !== void 0) {
|
|
20161
|
-
if (current.type === AST_NODE_TYPES93.CallExpression && (current.callee.type === AST_NODE_TYPES93.Identifier && MEMO_CALLEES2.has(current.callee.name) || current.callee.type === AST_NODE_TYPES93.MemberExpression &&
|
|
20083
|
+
if (current.type === AST_NODE_TYPES93.CallExpression && (current.callee.type === AST_NODE_TYPES93.Identifier && MEMO_CALLEES2.has(current.callee.name) || current.callee.type === AST_NODE_TYPES93.MemberExpression && ASTUtils58.getPropertyName(current.callee) !== null && MEMO_CALLEES2.has(ASTUtils58.getPropertyName(current.callee) ?? "")))
|
|
20162
20084
|
return true;
|
|
20163
20085
|
current = current.parent ?? void 0;
|
|
20164
20086
|
}
|
|
@@ -20221,7 +20143,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
20221
20143
|
// src/rules/prefer-multi-value-zod-literal.ts
|
|
20222
20144
|
import {
|
|
20223
20145
|
AST_NODE_TYPES as AST_NODE_TYPES94,
|
|
20224
|
-
ASTUtils as
|
|
20146
|
+
ASTUtils as ASTUtils59
|
|
20225
20147
|
} from "@typescript-eslint/utils";
|
|
20226
20148
|
var PREFER_MULTI_VALUE_ZOD_LITERAL_DOCUMENTATION = {
|
|
20227
20149
|
defaultLevel: "error",
|
|
@@ -20270,7 +20192,7 @@ function isStaticPrimitive(node, context) {
|
|
|
20270
20192
|
if (node.type === AST_NODE_TYPES94.TemplateLiteral && node.expressions.length === 0)
|
|
20271
20193
|
return true;
|
|
20272
20194
|
if (node.type === AST_NODE_TYPES94.Identifier && node.name === "undefined") {
|
|
20273
|
-
const binding =
|
|
20195
|
+
const binding = ASTUtils59.findVariable(
|
|
20274
20196
|
context.sourceCode.getScope(node),
|
|
20275
20197
|
node.name
|
|
20276
20198
|
);
|
|
@@ -20308,7 +20230,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
20308
20230
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
20309
20231
|
const zod4Bindings = /* @__PURE__ */ new Set();
|
|
20310
20232
|
function resolvedBinding(identifier) {
|
|
20311
|
-
return
|
|
20233
|
+
return ASTUtils59.findVariable(
|
|
20312
20234
|
context.sourceCode.getScope(identifier),
|
|
20313
20235
|
identifier.name
|
|
20314
20236
|
);
|
|
@@ -20316,7 +20238,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
20316
20238
|
function directMemberCall(node, binding, method) {
|
|
20317
20239
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
20318
20240
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES94.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
20319
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES94.MemberExpression || receiver.type !== AST_NODE_TYPES94.Identifier ||
|
|
20241
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES94.MemberExpression || receiver.type !== AST_NODE_TYPES94.Identifier || ASTUtils59.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils59.getPropertyName(unwrappedNodeCallee) ?? "") !== method)
|
|
20320
20242
|
return false;
|
|
20321
20243
|
return resolvedBinding(receiver) === binding;
|
|
20322
20244
|
}
|
|
@@ -20618,7 +20540,7 @@ var prefer_named_complex_return_type_default = createRule({
|
|
|
20618
20540
|
});
|
|
20619
20541
|
|
|
20620
20542
|
// src/rules/prefer-native-random-uuid.ts
|
|
20621
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES98, ASTUtils as
|
|
20543
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES98, ASTUtils as ASTUtils60 } from "@typescript-eslint/utils";
|
|
20622
20544
|
var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
|
|
20623
20545
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
20624
20546
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -20654,14 +20576,14 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
20654
20576
|
const directBindings = /* @__PURE__ */ new Set();
|
|
20655
20577
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
20656
20578
|
function resolve2(identifier) {
|
|
20657
|
-
return
|
|
20579
|
+
return ASTUtils60.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
20658
20580
|
}
|
|
20659
20581
|
function record(identifier, destination) {
|
|
20660
20582
|
const variable = resolve2(identifier);
|
|
20661
20583
|
if (variable !== null) destination.add(variable);
|
|
20662
20584
|
}
|
|
20663
20585
|
function report2(node) {
|
|
20664
|
-
const globalBinding =
|
|
20586
|
+
const globalBinding = ASTUtils60.findVariable(context.sourceCode.getScope(node), "globalThis");
|
|
20665
20587
|
const canSuggest = (globalBinding?.defs.length ?? 0) === 0 && context.sourceCode.getCommentsInside(node).length === 0;
|
|
20666
20588
|
context.report({
|
|
20667
20589
|
node,
|
|
@@ -20720,7 +20642,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
20720
20642
|
});
|
|
20721
20643
|
|
|
20722
20644
|
// src/rules/prefer-node-crypto-hash.ts
|
|
20723
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES99, ASTUtils as
|
|
20645
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES99, ASTUtils as ASTUtils61 } from "@typescript-eslint/utils";
|
|
20724
20646
|
var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
20725
20647
|
defaultLevel: "warning",
|
|
20726
20648
|
summary: "Prefer the modern one-shot node:crypto hash API when streaming state is unnecessary.",
|
|
@@ -20748,7 +20670,7 @@ function isCryptoLoader(node, resolve2) {
|
|
|
20748
20670
|
if (unwrappedNodeCallee?.type === AST_NODE_TYPES99.Identifier) {
|
|
20749
20671
|
return unwrappedNodeCallee.name === "require" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee, resolve2);
|
|
20750
20672
|
}
|
|
20751
|
-
return unwrappedNodeCallee?.type === AST_NODE_TYPES99.MemberExpression && unwrappedNodeCallee.object.type === AST_NODE_TYPES99.Identifier && unwrappedNodeCallee.object.name === "process" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee.object, resolve2) &&
|
|
20673
|
+
return unwrappedNodeCallee?.type === AST_NODE_TYPES99.MemberExpression && unwrappedNodeCallee.object.type === AST_NODE_TYPES99.Identifier && unwrappedNodeCallee.object.name === "process" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee.object, resolve2) && ASTUtils61.getPropertyName(unwrappedNodeCallee) === "getBuiltinModule";
|
|
20752
20674
|
}
|
|
20753
20675
|
function isCryptoSpecifier(node) {
|
|
20754
20676
|
return node.type === AST_NODE_TYPES99.Literal && (node.value === "crypto" || node.value === "node:crypto");
|
|
@@ -20773,7 +20695,7 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
20773
20695
|
const directBindings = /* @__PURE__ */ new Set();
|
|
20774
20696
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
20775
20697
|
function resolve2(identifier) {
|
|
20776
|
-
return
|
|
20698
|
+
return ASTUtils61.findVariable(
|
|
20777
20699
|
context.sourceCode.getScope(identifier),
|
|
20778
20700
|
identifier.name
|
|
20779
20701
|
);
|
|
@@ -20835,7 +20757,7 @@ function importedName5(node) {
|
|
|
20835
20757
|
}
|
|
20836
20758
|
function isMemberCall(node, name) {
|
|
20837
20759
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
20838
|
-
return unwrappedNodeCallee.type === AST_NODE_TYPES99.MemberExpression &&
|
|
20760
|
+
return unwrappedNodeCallee.type === AST_NODE_TYPES99.MemberExpression && ASTUtils61.getPropertyName(unwrappedNodeCallee) === name;
|
|
20839
20761
|
}
|
|
20840
20762
|
function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
20841
20763
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
@@ -20843,7 +20765,7 @@ function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
|
20843
20765
|
const variable2 = resolve2(unwrappedNodeCallee);
|
|
20844
20766
|
return variable2 !== null && directBindings.has(variable2);
|
|
20845
20767
|
}
|
|
20846
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES99.MemberExpression ||
|
|
20768
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES99.MemberExpression || ASTUtils61.getPropertyName(unwrappedNodeCallee) !== "createHash") {
|
|
20847
20769
|
return false;
|
|
20848
20770
|
}
|
|
20849
20771
|
if (isCryptoLoader(unwrappedNodeCallee.object, resolve2)) return true;
|
|
@@ -20853,7 +20775,7 @@ function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
|
20853
20775
|
}
|
|
20854
20776
|
|
|
20855
20777
|
// src/rules/prefer-node-fs-promises.ts
|
|
20856
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES100, ASTUtils as
|
|
20778
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES100, ASTUtils as ASTUtils62 } from "@typescript-eslint/utils";
|
|
20857
20779
|
var PREFER_NODE_FS_PROMISES_DOCUMENTATION = {
|
|
20858
20780
|
defaultLevel: "warning",
|
|
20859
20781
|
summary: "Prefer promise-based Node.js filesystem APIs over synchronous calls in production modules.",
|
|
@@ -20915,7 +20837,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
20915
20837
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || normalizedFilename.includes("src/rules/"))
|
|
20916
20838
|
return {};
|
|
20917
20839
|
const namespaces = /* @__PURE__ */ new Set();
|
|
20918
|
-
const bindingOf = (node) =>
|
|
20840
|
+
const bindingOf = (node) => ASTUtils62.findVariable(context.sourceCode.getScope(node), node.name);
|
|
20919
20841
|
const isGlobal = (node) => {
|
|
20920
20842
|
const binding = bindingOf(node);
|
|
20921
20843
|
return binding === null || binding.defs.length === 0;
|
|
@@ -20981,7 +20903,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
20981
20903
|
});
|
|
20982
20904
|
|
|
20983
20905
|
// src/rules/prefer-non-nullable-collection.ts
|
|
20984
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES101, ASTUtils as
|
|
20906
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES101, ASTUtils as ASTUtils63 } from "@typescript-eslint/utils";
|
|
20985
20907
|
var PREFER_NON_NULLABLE_COLLECTION_DOCUMENTATION = {
|
|
20986
20908
|
summary: "Suggest reviewing nullish arrays that use local empty-array defaults or a shared null-or-empty guard.",
|
|
20987
20909
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
@@ -21301,14 +21223,14 @@ function directlyCoalesced(node) {
|
|
|
21301
21223
|
return parent?.type === AST_NODE_TYPES101.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
21302
21224
|
}
|
|
21303
21225
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
21304
|
-
const variable =
|
|
21226
|
+
const variable = ASTUtils63.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
21305
21227
|
if (variable === null || variable.references.length === 0) return false;
|
|
21306
21228
|
return variable.references.every(
|
|
21307
21229
|
(reference) => belongsToFunction(reference.identifier, fn) && directlyCoalesced(reference.identifier)
|
|
21308
21230
|
);
|
|
21309
21231
|
}
|
|
21310
21232
|
function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
21311
|
-
const variable =
|
|
21233
|
+
const variable = ASTUtils63.findVariable(context.sourceCode.getScope(object), object.name);
|
|
21312
21234
|
if (variable === null) return false;
|
|
21313
21235
|
const accesses = variable.references.flatMap((reference) => {
|
|
21314
21236
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
@@ -21381,7 +21303,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
21381
21303
|
function checkDestructuredProperties(parameter, properties) {
|
|
21382
21304
|
for (const property of properties) {
|
|
21383
21305
|
const bindingProperty = parameter.properties.find(
|
|
21384
|
-
(entry) => entry.type === AST_NODE_TYPES101.Property && !entry.computed &&
|
|
21306
|
+
(entry) => entry.type === AST_NODE_TYPES101.Property && !entry.computed && ASTUtils63.getPropertyName(entry) === property.name
|
|
21385
21307
|
);
|
|
21386
21308
|
if (bindingProperty === void 0) continue;
|
|
21387
21309
|
const value = bindingProperty.value;
|
|
@@ -21431,7 +21353,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
21431
21353
|
// src/rules/prefer-nullish-filter-predicate.ts
|
|
21432
21354
|
import {
|
|
21433
21355
|
AST_NODE_TYPES as AST_NODE_TYPES102,
|
|
21434
|
-
ASTUtils as
|
|
21356
|
+
ASTUtils as ASTUtils64,
|
|
21435
21357
|
ESLintUtils as ESLintUtils19
|
|
21436
21358
|
} from "@typescript-eslint/utils";
|
|
21437
21359
|
import ts18 from "typescript";
|
|
@@ -21477,7 +21399,7 @@ var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
|
21477
21399
|
]
|
|
21478
21400
|
};
|
|
21479
21401
|
function isUnshadowedBoolean(node, context) {
|
|
21480
|
-
const variable =
|
|
21402
|
+
const variable = ASTUtils64.findVariable(context.sourceCode.getScope(node), node.name);
|
|
21481
21403
|
return variable === null || variable.defs.length === 0;
|
|
21482
21404
|
}
|
|
21483
21405
|
function isBuiltinArrayFilter(node, services) {
|
|
@@ -21536,7 +21458,7 @@ function isProvablyTruthy(type, checker) {
|
|
|
21536
21458
|
}
|
|
21537
21459
|
function availableParameterName(node, context) {
|
|
21538
21460
|
for (const name of ["value", "item", "element", "candidate"]) {
|
|
21539
|
-
if (
|
|
21461
|
+
if (ASTUtils64.findVariable(context.sourceCode.getScope(node), name) === null) return name;
|
|
21540
21462
|
}
|
|
21541
21463
|
return null;
|
|
21542
21464
|
}
|
|
@@ -21567,7 +21489,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
21567
21489
|
CallExpression(node) {
|
|
21568
21490
|
const callee = unwrapExpression(node.callee);
|
|
21569
21491
|
const callback = node.arguments[0] === void 0 ? void 0 : unwrapExpression(node.arguments[0]);
|
|
21570
|
-
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES102.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES102.MemberExpression ||
|
|
21492
|
+
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES102.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES102.MemberExpression || ASTUtils64.getPropertyName(callee) === null || (ASTUtils64.getPropertyName(callee) ?? "") !== "filter" || !isUnshadowedBoolean(callback, context) || !isBuiltinArrayFilter(callee, services)) return;
|
|
21571
21493
|
const elementType = arrayElementType(callee.object, services);
|
|
21572
21494
|
const checker = services.program.getTypeChecker();
|
|
21573
21495
|
if (elementType === null || !isNullishPlusTruthy(elementType, checker)) return;
|
|
@@ -21590,7 +21512,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
21590
21512
|
|
|
21591
21513
|
// src/rules/prefer-await-in-async-return.ts
|
|
21592
21514
|
import {
|
|
21593
|
-
ASTUtils as
|
|
21515
|
+
ASTUtils as ASTUtils65,
|
|
21594
21516
|
ESLintUtils as ESLintUtils20,
|
|
21595
21517
|
AST_NODE_TYPES as AST_NODE_TYPES103
|
|
21596
21518
|
} from "@typescript-eslint/utils";
|
|
@@ -21653,7 +21575,7 @@ function isRuntimeFunction(node) {
|
|
|
21653
21575
|
}
|
|
21654
21576
|
function promiseThenReceiver(node) {
|
|
21655
21577
|
const callee = unwrapExpression(node.callee);
|
|
21656
|
-
if (callee.type !== AST_NODE_TYPES103.MemberExpression || callee.optional ||
|
|
21578
|
+
if (callee.type !== AST_NODE_TYPES103.MemberExpression || callee.optional || ASTUtils65.getPropertyName(callee) === null || (ASTUtils65.getPropertyName(callee) ?? "") !== "then" || node.optional || node.arguments.length !== 1) {
|
|
21657
21579
|
return null;
|
|
21658
21580
|
}
|
|
21659
21581
|
const argument = node.arguments[0];
|
|
@@ -21723,7 +21645,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
21723
21645
|
if (services === null) return {};
|
|
21724
21646
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
21725
21647
|
const rememberFrameworkLoader = (identifier) => {
|
|
21726
|
-
const variable =
|
|
21648
|
+
const variable = ASTUtils65.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
21727
21649
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
21728
21650
|
};
|
|
21729
21651
|
const isFrameworkLoaderCallback = (owner) => {
|
|
@@ -21731,7 +21653,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
21731
21653
|
if (parent === null || parent.arguments[0] !== outerExpression(owner)) return false;
|
|
21732
21654
|
const callee = unwrapExpression(parent.callee);
|
|
21733
21655
|
if (callee.type !== AST_NODE_TYPES103.Identifier) return false;
|
|
21734
|
-
const variable =
|
|
21656
|
+
const variable = ASTUtils65.findVariable(context.sourceCode.getScope(callee), callee.name);
|
|
21735
21657
|
return variable !== null && frameworkLoaders.has(variable);
|
|
21736
21658
|
};
|
|
21737
21659
|
return {
|
|
@@ -21768,18 +21690,18 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
21768
21690
|
});
|
|
21769
21691
|
|
|
21770
21692
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
21771
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES105, ASTUtils as
|
|
21693
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES105, ASTUtils as ASTUtils67 } from "@typescript-eslint/utils";
|
|
21772
21694
|
|
|
21773
21695
|
// src/rules/_native-fetch-reference.ts
|
|
21774
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES104, ASTUtils as
|
|
21696
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES104, ASTUtils as ASTUtils66 } from "@typescript-eslint/utils";
|
|
21775
21697
|
var GLOBAL_RECEIVERS3 = /* @__PURE__ */ new Set(["globalThis", "self", "window"]);
|
|
21776
21698
|
function nativeFetchReference(node, sourceCode, seen = /* @__PURE__ */ new Set()) {
|
|
21777
21699
|
const expression = unwrapExpression(node);
|
|
21778
21700
|
if (expression.type === AST_NODE_TYPES104.MemberExpression) {
|
|
21779
|
-
return
|
|
21701
|
+
return ASTUtils66.getPropertyName(expression) === "fetch" && globalReceiver(expression.object, sourceCode);
|
|
21780
21702
|
}
|
|
21781
21703
|
if (expression.type !== AST_NODE_TYPES104.Identifier) return false;
|
|
21782
|
-
const binding =
|
|
21704
|
+
const binding = ASTUtils66.findVariable(sourceCode.getScope(expression), expression.name);
|
|
21783
21705
|
if (binding === null || binding.defs.length === 0) return expression.name === "fetch";
|
|
21784
21706
|
if (seen.has(binding) || seen.size >= 8 || binding.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21785
21707
|
seen.add(binding);
|
|
@@ -21788,11 +21710,11 @@ function nativeFetchReference(node, sourceCode, seen = /* @__PURE__ */ new Set()
|
|
|
21788
21710
|
if (definition.node.id.type === AST_NODE_TYPES104.Identifier) {
|
|
21789
21711
|
return nativeFetchReference(definition.node.init, sourceCode, seen);
|
|
21790
21712
|
}
|
|
21791
|
-
return definition.node.id.type === AST_NODE_TYPES104.ObjectPattern && globalReceiver(definition.node.init, sourceCode) && definition.node.id.properties.some((property) => property.type === AST_NODE_TYPES104.Property &&
|
|
21713
|
+
return definition.node.id.type === AST_NODE_TYPES104.ObjectPattern && globalReceiver(definition.node.init, sourceCode) && definition.node.id.properties.some((property) => property.type === AST_NODE_TYPES104.Property && ASTUtils66.getPropertyName(property) === "fetch" && property.value.type === AST_NODE_TYPES104.Identifier && ASTUtils66.findVariable(sourceCode.getScope(property.value), property.value.name) === binding);
|
|
21792
21714
|
}
|
|
21793
21715
|
function globalReceiver(node, sourceCode) {
|
|
21794
21716
|
const receiver = unwrapExpression(node);
|
|
21795
|
-
return receiver.type === AST_NODE_TYPES104.Identifier && GLOBAL_RECEIVERS3.has(receiver.name) && !
|
|
21717
|
+
return receiver.type === AST_NODE_TYPES104.Identifier && GLOBAL_RECEIVERS3.has(receiver.name) && !ASTUtils66.findVariable(sourceCode.getScope(receiver), receiver.name)?.defs.length;
|
|
21796
21718
|
}
|
|
21797
21719
|
|
|
21798
21720
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
@@ -21832,7 +21754,7 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
21832
21754
|
]);
|
|
21833
21755
|
var isSchemaParseReference = (node) => {
|
|
21834
21756
|
const inner = unwrap5(node);
|
|
21835
|
-
return inner !== null && inner.type === AST_NODE_TYPES105.MemberExpression &&
|
|
21757
|
+
return inner !== null && inner.type === AST_NODE_TYPES105.MemberExpression && ASTUtils67.getPropertyName(inner) !== null && ((ASTUtils67.getPropertyName(inner) ?? "") === "parse" || (ASTUtils67.getPropertyName(inner) ?? "") === "safeParse");
|
|
21836
21758
|
};
|
|
21837
21759
|
var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
21838
21760
|
let current = unwrap5(node);
|
|
@@ -21847,7 +21769,7 @@ var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
|
21847
21769
|
if (callee === null || callee.type !== AST_NODE_TYPES105.MemberExpression) {
|
|
21848
21770
|
return false;
|
|
21849
21771
|
}
|
|
21850
|
-
const property =
|
|
21772
|
+
const property = ASTUtils67.getPropertyName(callee);
|
|
21851
21773
|
if (property === null) {
|
|
21852
21774
|
return false;
|
|
21853
21775
|
}
|
|
@@ -21859,19 +21781,19 @@ var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
|
21859
21781
|
}
|
|
21860
21782
|
const object = unwrap5(callee.object);
|
|
21861
21783
|
const input = unwrap5(current.arguments[0]);
|
|
21862
|
-
if (input?.type === AST_NODE_TYPES105.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES105.MemberExpression && input.callee.object.type === AST_NODE_TYPES105.Identifier && input.callee.object.name === "JSON" &&
|
|
21863
|
-
return property === "parse" && object !== null && object.type === AST_NODE_TYPES105.Identifier && object.name === "JSON" && (
|
|
21784
|
+
if (input?.type === AST_NODE_TYPES105.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES105.MemberExpression && input.callee.object.type === AST_NODE_TYPES105.Identifier && input.callee.object.name === "JSON" && ASTUtils67.getPropertyName(input.callee) === "stringify" && (ASTUtils67.findVariable(context.sourceCode.getScope(input.callee.object), "JSON")?.defs.length ?? 0) === 0) return false;
|
|
21785
|
+
return property === "parse" && object !== null && object.type === AST_NODE_TYPES105.Identifier && object.name === "JSON" && (ASTUtils67.findVariable(context.sourceCode.getScope(object), "JSON")?.defs.length ?? 0) === 0 && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
21864
21786
|
};
|
|
21865
21787
|
var isResponseSource = (node, context, seen = /* @__PURE__ */ new Set()) => {
|
|
21866
21788
|
let current = unwrap5(node);
|
|
21867
21789
|
if (current?.type === AST_NODE_TYPES105.AwaitExpression) current = unwrap5(current.argument);
|
|
21868
21790
|
if (current === null || seen.has(current)) return false;
|
|
21869
21791
|
seen.add(current);
|
|
21870
|
-
const isGlobal = (identifier) => (
|
|
21792
|
+
const isGlobal = (identifier) => (ASTUtils67.findVariable(context.sourceCode.getScope(identifier), identifier.name)?.defs.length ?? 0) === 0;
|
|
21871
21793
|
if (current.type === AST_NODE_TYPES105.CallExpression) return nativeFetchReference(current.callee, context.sourceCode);
|
|
21872
21794
|
if (current.type === AST_NODE_TYPES105.NewExpression) return current.callee.type === AST_NODE_TYPES105.Identifier && ["Request", "Response"].includes(current.callee.name) && isGlobal(current.callee);
|
|
21873
21795
|
if (current.type !== AST_NODE_TYPES105.Identifier) return false;
|
|
21874
|
-
const binding =
|
|
21796
|
+
const binding = ASTUtils67.findVariable(context.sourceCode.getScope(current), current.name);
|
|
21875
21797
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21876
21798
|
const definition = binding.defs[0];
|
|
21877
21799
|
const annotation = definition?.name.type === AST_NODE_TYPES105.Identifier ? definition.name.typeAnnotation?.typeAnnotation : void 0;
|
|
@@ -21886,7 +21808,7 @@ var isDirectLocalFileRead = (node) => {
|
|
|
21886
21808
|
}
|
|
21887
21809
|
if (current?.type !== AST_NODE_TYPES105.CallExpression) return false;
|
|
21888
21810
|
const callee = unwrap5(current.callee);
|
|
21889
|
-
const name = callee?.type === AST_NODE_TYPES105.Identifier ? callee.name : callee?.type === AST_NODE_TYPES105.MemberExpression &&
|
|
21811
|
+
const name = callee?.type === AST_NODE_TYPES105.Identifier ? callee.name : callee?.type === AST_NODE_TYPES105.MemberExpression && ASTUtils67.getPropertyName(callee) !== null ? ASTUtils67.getPropertyName(callee) ?? "" : null;
|
|
21890
21812
|
return name !== null && FILE_READ_RE.test(name);
|
|
21891
21813
|
};
|
|
21892
21814
|
var isLocalFileRead = (node) => {
|
|
@@ -21947,7 +21869,7 @@ var isValidationRead = (node) => {
|
|
|
21947
21869
|
return false;
|
|
21948
21870
|
}
|
|
21949
21871
|
const callee = parent.callee;
|
|
21950
|
-
if (callee.type === AST_NODE_TYPES105.MemberExpression && callee.object.type === AST_NODE_TYPES105.Identifier && callee.object.name === "Array" &&
|
|
21872
|
+
if (callee.type === AST_NODE_TYPES105.MemberExpression && callee.object.type === AST_NODE_TYPES105.Identifier && callee.object.name === "Array" && ASTUtils67.getPropertyName(callee) === "isArray") {
|
|
21951
21873
|
return parent.arguments.length === 1;
|
|
21952
21874
|
}
|
|
21953
21875
|
return callee.type === AST_NODE_TYPES105.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
@@ -21975,11 +21897,11 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
21975
21897
|
}
|
|
21976
21898
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
21977
21899
|
}
|
|
21978
|
-
return test.type === AST_NODE_TYPES105.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES105.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES105.MemberExpression && test.callee.object.type === AST_NODE_TYPES105.Identifier && test.callee.object.name === "Array" &&
|
|
21900
|
+
return test.type === AST_NODE_TYPES105.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES105.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES105.MemberExpression && test.callee.object.type === AST_NODE_TYPES105.Identifier && test.callee.object.name === "Array" && ASTUtils67.getPropertyName(test.callee) === "isArray" ? "valid-when-true" : null;
|
|
21979
21901
|
};
|
|
21980
21902
|
var plainMemberAccess = (node) => {
|
|
21981
21903
|
if (node.type !== AST_NODE_TYPES105.MemberExpression || node.object.type !== AST_NODE_TYPES105.Identifier) return null;
|
|
21982
|
-
const property =
|
|
21904
|
+
const property = ASTUtils67.getPropertyName(node);
|
|
21983
21905
|
return property === null ? null : { object: node.object.name, property };
|
|
21984
21906
|
};
|
|
21985
21907
|
var isSamePlainMember = (node, access) => {
|
|
@@ -22043,7 +21965,7 @@ var memberValidationPolarity = (test, access) => {
|
|
|
22043
21965
|
}
|
|
22044
21966
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
22045
21967
|
}
|
|
22046
|
-
return test.type === AST_NODE_TYPES105.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES105.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES105.MemberExpression && test.callee.object.type === AST_NODE_TYPES105.Identifier && test.callee.object.name === "Array" &&
|
|
21968
|
+
return test.type === AST_NODE_TYPES105.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES105.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES105.MemberExpression && test.callee.object.type === AST_NODE_TYPES105.Identifier && test.callee.object.name === "Array" && ASTUtils67.getPropertyName(test.callee) === "isArray" ? "valid-when-true" : null;
|
|
22047
21969
|
};
|
|
22048
21970
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
22049
21971
|
const isValidationReference = (identifier) => {
|
|
@@ -22326,7 +22248,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
22326
22248
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
22327
22249
|
)) {
|
|
22328
22250
|
const parent = node.parent;
|
|
22329
|
-
const method =
|
|
22251
|
+
const method = ASTUtils67.getPropertyName(node);
|
|
22330
22252
|
if (parent.type === AST_NODE_TYPES105.CallExpression && parent.callee === node && method !== null && (method === "parse" || method === "safeParse" || PROMISE_CHAIN_METHODS.has(method))) {
|
|
22331
22253
|
return;
|
|
22332
22254
|
}
|
|
@@ -22379,7 +22301,7 @@ function ifGuardDominates(use, branch, positive) {
|
|
|
22379
22301
|
}
|
|
22380
22302
|
|
|
22381
22303
|
// src/rules/prefer-shared-zod-enum.ts
|
|
22382
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES106, ASTUtils as
|
|
22304
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES106, ASTUtils as ASTUtils68 } from "@typescript-eslint/utils";
|
|
22383
22305
|
var PREFER_SHARED_ZOD_ENUM_DOCUMENTATION = {
|
|
22384
22306
|
defaultLevel: "warning",
|
|
22385
22307
|
summary: "Give repeated literal Zod enum domains one reusable module-level schema.",
|
|
@@ -22430,7 +22352,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
22430
22352
|
create(context) {
|
|
22431
22353
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
22432
22354
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
22433
|
-
const bindingOf = (node) =>
|
|
22355
|
+
const bindingOf = (node) => ASTUtils68.findVariable(context.sourceCode.getScope(node), node.name);
|
|
22434
22356
|
const candidates = /* @__PURE__ */ new Map();
|
|
22435
22357
|
return {
|
|
22436
22358
|
ImportDeclaration(node) {
|
|
@@ -22445,7 +22367,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
22445
22367
|
CallExpression(node) {
|
|
22446
22368
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
22447
22369
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES106.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
22448
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES106.MemberExpression || receiver.type !== AST_NODE_TYPES106.Identifier ||
|
|
22370
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES106.MemberExpression || receiver.type !== AST_NODE_TYPES106.Identifier || ASTUtils68.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils68.getPropertyName(unwrappedNodeCallee) ?? "") !== "enum") return;
|
|
22449
22371
|
const binding = bindingOf(receiver);
|
|
22450
22372
|
if (binding === null || !zodBindings.has(binding)) return;
|
|
22451
22373
|
const domain = literalDomain(node);
|
|
@@ -22470,7 +22392,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
22470
22392
|
});
|
|
22471
22393
|
|
|
22472
22394
|
// src/rules/prefer-switch-for-repeated-equality.ts
|
|
22473
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES107, ASTUtils as
|
|
22395
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES107, ASTUtils as ASTUtils69 } from "@typescript-eslint/utils";
|
|
22474
22396
|
var PREFER_SWITCH_FOR_REPEATED_EQUALITY_DOCUMENTATION = {
|
|
22475
22397
|
defaultLevel: "error",
|
|
22476
22398
|
summary: "Prefer switch over long if/else-if chains that compare one value for strict equality.",
|
|
@@ -22522,7 +22444,7 @@ var prefer_switch_for_repeated_equality_default = createRule({
|
|
|
22522
22444
|
if (node.parent.type === AST_NODE_TYPES107.IfStatement && node.parent.alternate === node) return;
|
|
22523
22445
|
const first = discriminantName(node.test);
|
|
22524
22446
|
if (first === null) return;
|
|
22525
|
-
const binding =
|
|
22447
|
+
const binding = ASTUtils69.findVariable(context.sourceCode.getScope(node), first);
|
|
22526
22448
|
if (binding === null || binding.defs.length !== 1 || binding.scope.type === "global") return;
|
|
22527
22449
|
const [definition] = binding.defs;
|
|
22528
22450
|
if (definition?.type !== "Parameter" && definition?.type !== "Variable") return;
|
|
@@ -23069,7 +22991,7 @@ function packageWorkspaceGlobs(parsed) {
|
|
|
23069
22991
|
}
|
|
23070
22992
|
|
|
23071
22993
|
// src/rules/prefer-server-actions.ts
|
|
23072
|
-
import { ASTUtils as
|
|
22994
|
+
import { ASTUtils as ASTUtils70 } from "@typescript-eslint/utils";
|
|
23073
22995
|
var PREFER_SERVER_ACTIONS_DOCUMENTATION = {
|
|
23074
22996
|
summary: "Prefer Next.js Server Actions over same-origin API mutations.",
|
|
23075
22997
|
rationale: "Server Actions can remove a hand-written internal API wrapper while retaining typed application calls. Client invocations still cross a network and serialization boundary.",
|
|
@@ -23102,7 +23024,7 @@ function resolveNode(node, context) {
|
|
|
23102
23024
|
node = node == null ? node : unwrapExpression(node);
|
|
23103
23025
|
if (!node) return null;
|
|
23104
23026
|
if (node.type !== "Identifier") return node;
|
|
23105
|
-
const variable =
|
|
23027
|
+
const variable = ASTUtils70.findVariable(getScope(context, node), node.name);
|
|
23106
23028
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
23107
23029
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return node;
|
|
23108
23030
|
if (definition.node.init.type === "ObjectExpression" && variable?.references.some((reference) => reference.identifier !== node && reference.init !== true)) return node;
|
|
@@ -23111,7 +23033,7 @@ function resolveNode(node, context) {
|
|
|
23111
23033
|
function isAxiosClient(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
23112
23034
|
if (node.type !== "Identifier" || seen.has(node)) return false;
|
|
23113
23035
|
seen.add(node);
|
|
23114
|
-
const variable =
|
|
23036
|
+
const variable = ASTUtils70.findVariable(getScope(context, node), node.name);
|
|
23115
23037
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
23116
23038
|
if (definition === void 0 || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
23117
23039
|
if (variable?.references.some((reference) => {
|
|
@@ -23195,10 +23117,10 @@ function isFunctionArgument(node, context) {
|
|
|
23195
23117
|
}
|
|
23196
23118
|
function getPropertyNode(objNode, propName2) {
|
|
23197
23119
|
if (!objNode || objNode.type !== "ObjectExpression") return null;
|
|
23198
|
-
if (objNode.properties.some((property) => property.type === "SpreadElement" ||
|
|
23120
|
+
if (objNode.properties.some((property) => property.type === "SpreadElement" || ASTUtils70.getPropertyName(property) === null)) return null;
|
|
23199
23121
|
for (const prop of [...objNode.properties].reverse()) {
|
|
23200
23122
|
if (prop.type !== "Property") continue;
|
|
23201
|
-
const keyName =
|
|
23123
|
+
const keyName = ASTUtils70.getPropertyName(prop);
|
|
23202
23124
|
if (keyName === propName2) {
|
|
23203
23125
|
if (prop.value.type === "AssignmentPattern" || prop.value.type === "ArrayPattern" || prop.value.type === "ObjectPattern") {
|
|
23204
23126
|
return null;
|
|
@@ -23322,7 +23244,7 @@ var prefer_server_actions_default = createRule({
|
|
|
23322
23244
|
});
|
|
23323
23245
|
|
|
23324
23246
|
// src/rules/prefer-whole-object-assertion.ts
|
|
23325
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES109, ASTUtils as
|
|
23247
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES109, ASTUtils as ASTUtils71 } from "@typescript-eslint/utils";
|
|
23326
23248
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
23327
23249
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
23328
23250
|
["toBeNull", "null"]
|
|
@@ -23389,7 +23311,7 @@ function propertyAccess(node) {
|
|
|
23389
23311
|
const path = [];
|
|
23390
23312
|
let current = node;
|
|
23391
23313
|
while (current.type === AST_NODE_TYPES109.MemberExpression && !current.optional) {
|
|
23392
|
-
const name =
|
|
23314
|
+
const name = ASTUtils71.getPropertyName(current);
|
|
23393
23315
|
if (name === null || COLLECTION_PROPERTIES.has(name) || LITERAL_KEY_HAZARDS.has(name)) return null;
|
|
23394
23316
|
path.unshift(name);
|
|
23395
23317
|
current = unwrapExpression(current.object);
|
|
@@ -23539,7 +23461,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
23539
23461
|
const callee = unwrapExpression(call.callee);
|
|
23540
23462
|
const calleeReceiver = callee.type === AST_NODE_TYPES109.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
23541
23463
|
if (callee.type !== AST_NODE_TYPES109.MemberExpression) return null;
|
|
23542
|
-
const matcher =
|
|
23464
|
+
const matcher = ASTUtils71.getPropertyName(callee);
|
|
23543
23465
|
if (matcher === null) return null;
|
|
23544
23466
|
const expectCall = calleeReceiver;
|
|
23545
23467
|
const expectCallee = expectCall.type === AST_NODE_TYPES109.CallExpression ? unwrapExpression(expectCall.callee) : null;
|
|
@@ -23576,7 +23498,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
23576
23498
|
const call = statement.expression;
|
|
23577
23499
|
const callee = unwrapExpression(call.callee);
|
|
23578
23500
|
if (callee.type !== AST_NODE_TYPES109.MemberExpression || call.arguments.length !== 1) return false;
|
|
23579
|
-
const matcher =
|
|
23501
|
+
const matcher = ASTUtils71.getPropertyName(callee);
|
|
23580
23502
|
const assertion = unwrapExpression(callee.object);
|
|
23581
23503
|
if (assertion.type !== AST_NODE_TYPES109.CallExpression || assertion.arguments.length !== 1) return false;
|
|
23582
23504
|
const expect = unwrapExpression(assertion.callee);
|
|
@@ -23585,7 +23507,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
23585
23507
|
if (expected?.type !== AST_NODE_TYPES109.Literal || typeof expected.value !== "number" || !Number.isInteger(expected.value) || expected.value < 0) return false;
|
|
23586
23508
|
let actual = assertion.arguments[0] === void 0 ? void 0 : unwrapExpression(assertion.arguments[0]);
|
|
23587
23509
|
if (matcher !== "toHaveLength") {
|
|
23588
|
-
if (matcher === null || !MERGEABLE_MATCHERS.has(matcher) || actual?.type !== AST_NODE_TYPES109.MemberExpression || actual.optional ||
|
|
23510
|
+
if (matcher === null || !MERGEABLE_MATCHERS.has(matcher) || actual?.type !== AST_NODE_TYPES109.MemberExpression || actual.optional || ASTUtils71.getPropertyName(actual) !== "length") return false;
|
|
23589
23511
|
actual = unwrapExpression(actual.object);
|
|
23590
23512
|
}
|
|
23591
23513
|
return actual !== void 0 && sourceCode.getText(actual) === sourceCode.getText(receiver);
|
|
@@ -23624,7 +23546,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
23624
23546
|
});
|
|
23625
23547
|
|
|
23626
23548
|
// src/rules/repeated-static-call-cases.ts
|
|
23627
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES110, ASTUtils as
|
|
23549
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES110, ASTUtils as ASTUtils72 } from "@typescript-eslint/utils";
|
|
23628
23550
|
var REPEATED_STATIC_CALL_CASES_DOCUMENTATION = {
|
|
23629
23551
|
summary: "Review three or more consecutive static-input call assertions as potential named cases.",
|
|
23630
23552
|
rationale: "Copy-pasted cases obscure the input table, and a thrown assertion can stop later cases from being reported.",
|
|
@@ -23645,7 +23567,7 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
23645
23567
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
23646
23568
|
var MIN_CASES2 = 3;
|
|
23647
23569
|
function importedName6(identifier, context, modules) {
|
|
23648
|
-
const variable =
|
|
23570
|
+
const variable = ASTUtils72.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
23649
23571
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
23650
23572
|
for (const definition of variable.defs) {
|
|
23651
23573
|
if (definition.node.type !== AST_NODE_TYPES110.ImportSpecifier) continue;
|
|
@@ -23667,7 +23589,7 @@ function testRoot2(callee) {
|
|
|
23667
23589
|
callee = unwrapExpression(callee);
|
|
23668
23590
|
if (callee.type === AST_NODE_TYPES110.Identifier) return callee;
|
|
23669
23591
|
if (callee.type !== AST_NODE_TYPES110.MemberExpression) return null;
|
|
23670
|
-
const modifier =
|
|
23592
|
+
const modifier = ASTUtils72.getPropertyName(callee);
|
|
23671
23593
|
return modifier !== null && TEST_MODIFIERS5.has(modifier) ? testRoot2(callee.object) : null;
|
|
23672
23594
|
}
|
|
23673
23595
|
function isStatic(input) {
|
|
@@ -23713,8 +23635,8 @@ function assertionShape(statement, context, callback) {
|
|
|
23713
23635
|
const matcherCall = unwrapExpression(statement.expression);
|
|
23714
23636
|
if (matcherCall.type !== AST_NODE_TYPES110.CallExpression) return null;
|
|
23715
23637
|
const matcherCallee = unwrapExpression(matcherCall.callee);
|
|
23716
|
-
if (matcherCallee.type !== AST_NODE_TYPES110.MemberExpression ||
|
|
23717
|
-
const matcher =
|
|
23638
|
+
if (matcherCallee.type !== AST_NODE_TYPES110.MemberExpression || ASTUtils72.getPropertyName(matcherCallee) === null || matcherCall.arguments.length !== 1) return null;
|
|
23639
|
+
const matcher = ASTUtils72.getPropertyName(matcherCallee) ?? "";
|
|
23718
23640
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
23719
23641
|
const chain = expectCallFromMatcher(matcherCallee);
|
|
23720
23642
|
const expectCallee = chain === null ? null : unwrapExpression(chain.call.callee);
|
|
@@ -23724,7 +23646,7 @@ function assertionShape(statement, context, callback) {
|
|
|
23724
23646
|
const observedCallee = observed?.type === AST_NODE_TYPES110.CallExpression ? unwrapExpression(observed.callee) : null;
|
|
23725
23647
|
if (observed?.type !== AST_NODE_TYPES110.CallExpression || observedCallee?.type !== AST_NODE_TYPES110.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === AST_NODE_TYPES110.SpreadElement || !isStatic(arg)) || expected?.type === AST_NODE_TYPES110.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
23726
23648
|
const skeleton = `${observedCallee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
23727
|
-
const binding =
|
|
23649
|
+
const binding = ASTUtils72.findVariable(context.sourceCode.getScope(observedCallee), observedCallee.name);
|
|
23728
23650
|
if (binding?.defs.some(
|
|
23729
23651
|
(definition) => definition.node.range[0] >= callback.range[0] && definition.node.range[1] <= callback.range[1]
|
|
23730
23652
|
)) return null;
|
|
@@ -23735,7 +23657,7 @@ function expectCallFromMatcher(node) {
|
|
|
23735
23657
|
const modifiers = [];
|
|
23736
23658
|
let receiver = node.object;
|
|
23737
23659
|
while (receiver.type === AST_NODE_TYPES110.MemberExpression) {
|
|
23738
|
-
const modifier =
|
|
23660
|
+
const modifier = ASTUtils72.getPropertyName(receiver);
|
|
23739
23661
|
if (modifier === null || !EXPECT_MODIFIERS.has(modifier)) return null;
|
|
23740
23662
|
modifiers.unshift(modifier);
|
|
23741
23663
|
receiver = receiver.object;
|
|
@@ -23811,7 +23733,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
23811
23733
|
});
|
|
23812
23734
|
|
|
23813
23735
|
// src/rules/prefer-zod-infer.ts
|
|
23814
|
-
import { ASTUtils as
|
|
23736
|
+
import { ASTUtils as ASTUtils73, AST_NODE_TYPES as AST_NODE_TYPES111 } from "@typescript-eslint/utils";
|
|
23815
23737
|
var PREFER_ZOD_INFER_DOCUMENTATION = {
|
|
23816
23738
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
23817
23739
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -24129,7 +24051,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
24129
24051
|
while (current.type === AST_NODE_TYPES111.CallExpression) {
|
|
24130
24052
|
const callee = unwrapExpression(current.callee);
|
|
24131
24053
|
const calleeReceiver = callee.type === AST_NODE_TYPES111.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24132
|
-
if (callee.type !== AST_NODE_TYPES111.MemberExpression ||
|
|
24054
|
+
if (callee.type !== AST_NODE_TYPES111.MemberExpression || ASTUtils73.getPropertyName(callee) === null) {
|
|
24133
24055
|
return null;
|
|
24134
24056
|
}
|
|
24135
24057
|
chain.push(current);
|
|
@@ -24142,7 +24064,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
24142
24064
|
}
|
|
24143
24065
|
function twinMethodName(call) {
|
|
24144
24066
|
const callee = unwrapExpression(call.callee);
|
|
24145
|
-
return callee.type === AST_NODE_TYPES111.MemberExpression &&
|
|
24067
|
+
return callee.type === AST_NODE_TYPES111.MemberExpression && ASTUtils73.getPropertyName(callee) !== null ? ASTUtils73.getPropertyName(callee) ?? "" : "";
|
|
24146
24068
|
}
|
|
24147
24069
|
function twinSchemaFields(initializer, zodNamespaces) {
|
|
24148
24070
|
const chain = twinCallChain(initializer, zodNamespaces);
|
|
@@ -24157,7 +24079,7 @@ function twinSchemaFields(initializer, zodNamespaces) {
|
|
|
24157
24079
|
const fields = /* @__PURE__ */ new Map();
|
|
24158
24080
|
for (const property of shape.properties) {
|
|
24159
24081
|
if (property.type !== AST_NODE_TYPES111.Property) return null;
|
|
24160
|
-
const name =
|
|
24082
|
+
const name = ASTUtils73.getPropertyName(property);
|
|
24161
24083
|
if (name === null) return null;
|
|
24162
24084
|
fields.set(name, twinSchemaField(property.value, zodNamespaces));
|
|
24163
24085
|
}
|
|
@@ -24171,16 +24093,16 @@ function twinSchemaField(node, zodNamespaces) {
|
|
|
24171
24093
|
while (current.type === AST_NODE_TYPES111.CallExpression) {
|
|
24172
24094
|
const callee = unwrapExpression(current.callee);
|
|
24173
24095
|
const calleeReceiver = callee.type === AST_NODE_TYPES111.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24174
|
-
if (callee.type !== AST_NODE_TYPES111.MemberExpression ||
|
|
24096
|
+
if (callee.type !== AST_NODE_TYPES111.MemberExpression || ASTUtils73.getPropertyName(callee) === null) {
|
|
24175
24097
|
break;
|
|
24176
24098
|
}
|
|
24177
24099
|
const receiver = calleeReceiver;
|
|
24178
24100
|
if (receiver.type === AST_NODE_TYPES111.Identifier && zodNamespaces.has(receiver.name)) {
|
|
24179
|
-
leaf =
|
|
24101
|
+
leaf = ASTUtils73.getPropertyName(callee) ?? "";
|
|
24180
24102
|
leafCall = current;
|
|
24181
24103
|
break;
|
|
24182
24104
|
}
|
|
24183
|
-
modifiers.push(
|
|
24105
|
+
modifiers.push(ASTUtils73.getPropertyName(callee) ?? "");
|
|
24184
24106
|
current = receiver;
|
|
24185
24107
|
}
|
|
24186
24108
|
return {
|
|
@@ -24383,7 +24305,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
24383
24305
|
},
|
|
24384
24306
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
24385
24307
|
"MemberExpression"(node) {
|
|
24386
|
-
if (node.object.type === AST_NODE_TYPES111.Identifier &&
|
|
24308
|
+
if (node.object.type === AST_NODE_TYPES111.Identifier && ASTUtils73.getPropertyName(node) !== null && isPreferZodInferModuleReshaper(ASTUtils73.getPropertyName(node) ?? "")) {
|
|
24387
24309
|
reshapedSchemaNames.add(node.object.name);
|
|
24388
24310
|
}
|
|
24389
24311
|
},
|
|
@@ -24540,7 +24462,7 @@ function staticFieldName(key) {
|
|
|
24540
24462
|
}
|
|
24541
24463
|
|
|
24542
24464
|
// src/rules/named-child-schema-type.ts
|
|
24543
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES112, ASTUtils as
|
|
24465
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES112, ASTUtils as ASTUtils74 } from "@typescript-eslint/utils";
|
|
24544
24466
|
var UNRESOLVED_TYPE_NODES = /* @__PURE__ */ new Set([
|
|
24545
24467
|
AST_NODE_TYPES112.TSTypeQuery,
|
|
24546
24468
|
AST_NODE_TYPES112.TSImportType,
|
|
@@ -24585,7 +24507,7 @@ var named_child_schema_type_default = createRule({
|
|
|
24585
24507
|
const source = context.sourceCode;
|
|
24586
24508
|
if (isGeneratedFile(context.filename, source.text)) return {};
|
|
24587
24509
|
const namespaces = /* @__PURE__ */ new Set();
|
|
24588
|
-
const bindingOf = (node) =>
|
|
24510
|
+
const bindingOf = (node) => ASTUtils74.findVariable(source.getScope(node), node.name);
|
|
24589
24511
|
function namespaceOf(type) {
|
|
24590
24512
|
if (type.typeName.type !== AST_NODE_TYPES112.TSQualifiedName || type.typeName.left.type !== AST_NODE_TYPES112.Identifier) return null;
|
|
24591
24513
|
const binding = bindingOf(type.typeName.left);
|
|
@@ -24629,7 +24551,7 @@ var named_child_schema_type_default = createRule({
|
|
|
24629
24551
|
VariableDeclarator(node) {
|
|
24630
24552
|
if (!isModuleConst(node) || node.id.type !== AST_NODE_TYPES112.Identifier || node.init?.type !== AST_NODE_TYPES112.CallExpression) return;
|
|
24631
24553
|
const call = node.init;
|
|
24632
|
-
if (call.arguments.length !== 2 || call.callee.type !== AST_NODE_TYPES112.MemberExpression || call.callee.object.type !== AST_NODE_TYPES112.Identifier ||
|
|
24554
|
+
if (call.arguments.length !== 2 || call.callee.type !== AST_NODE_TYPES112.MemberExpression || call.callee.object.type !== AST_NODE_TYPES112.Identifier || ASTUtils74.getPropertyName(call.callee) !== "record") return;
|
|
24633
24555
|
const annotation = node.id.typeAnnotation?.typeAnnotation;
|
|
24634
24556
|
if (annotation?.type !== AST_NODE_TYPES112.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES112.TSQualifiedName || annotation.typeName.right.name !== "ZodRecord") return;
|
|
24635
24557
|
const namespace = namespaceOf(annotation);
|
|
@@ -24645,7 +24567,7 @@ var named_child_schema_type_default = createRule({
|
|
|
24645
24567
|
|
|
24646
24568
|
// src/rules/prefer-zod-parse-output-type.ts
|
|
24647
24569
|
import {
|
|
24648
|
-
ASTUtils as
|
|
24570
|
+
ASTUtils as ASTUtils75,
|
|
24649
24571
|
AST_NODE_TYPES as AST_NODE_TYPES113,
|
|
24650
24572
|
ESLintUtils as ESLintUtils21
|
|
24651
24573
|
} from "@typescript-eslint/utils";
|
|
@@ -24892,11 +24814,11 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
24892
24814
|
while (current.type === AST_NODE_TYPES113.CallExpression) {
|
|
24893
24815
|
const callee = unwrapExpression(current.callee);
|
|
24894
24816
|
const calleeReceiver = callee.type === AST_NODE_TYPES113.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24895
|
-
if (callee.type !== AST_NODE_TYPES113.MemberExpression ||
|
|
24817
|
+
if (callee.type !== AST_NODE_TYPES113.MemberExpression || ASTUtils75.getPropertyName(callee) === null) {
|
|
24896
24818
|
return false;
|
|
24897
24819
|
}
|
|
24898
24820
|
if (calleeReceiver.type === AST_NODE_TYPES113.Identifier) {
|
|
24899
|
-
return namespaces.has(calleeReceiver.name) && ((
|
|
24821
|
+
return namespaces.has(calleeReceiver.name) && ((ASTUtils75.getPropertyName(callee) ?? "") === "object" || (ASTUtils75.getPropertyName(callee) ?? "") === "strictObject");
|
|
24900
24822
|
}
|
|
24901
24823
|
current = calleeReceiver;
|
|
24902
24824
|
}
|
|
@@ -24905,10 +24827,10 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
24905
24827
|
function zodParseCall(node) {
|
|
24906
24828
|
const callee = unwrapExpression(node.callee);
|
|
24907
24829
|
const calleeReceiver = callee.type === AST_NODE_TYPES113.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24908
|
-
if (callee.type !== AST_NODE_TYPES113.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES113.Identifier ||
|
|
24830
|
+
if (callee.type !== AST_NODE_TYPES113.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES113.Identifier || ASTUtils75.getPropertyName(callee) === null) {
|
|
24909
24831
|
return null;
|
|
24910
24832
|
}
|
|
24911
|
-
const method =
|
|
24833
|
+
const method = ASTUtils75.getPropertyName(callee);
|
|
24912
24834
|
if (method !== "parse" && method !== "safeParse") return null;
|
|
24913
24835
|
return {
|
|
24914
24836
|
call: node,
|
|
@@ -24950,7 +24872,7 @@ function localParseReturnCandidates(node, sourceCode) {
|
|
|
24950
24872
|
for (const reference of variable.references) {
|
|
24951
24873
|
const identifier = reference.identifier;
|
|
24952
24874
|
const parent = identifier.parent;
|
|
24953
|
-
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES113.MemberExpression && parent.object === identifier &&
|
|
24875
|
+
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES113.MemberExpression && parent.object === identifier && ASTUtils75.getPropertyName(parent) !== null && (ASTUtils75.getPropertyName(parent) ?? "") === "data" ? parent : null;
|
|
24954
24876
|
if (output === null) continue;
|
|
24955
24877
|
const candidate2 = returnedOutputCandidate(parsed, output);
|
|
24956
24878
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
@@ -25325,7 +25247,7 @@ var require_assert_never_default = createRule({
|
|
|
25325
25247
|
// src/rules/require-fetch-timeout.ts
|
|
25326
25248
|
import {
|
|
25327
25249
|
AST_NODE_TYPES as AST_NODE_TYPES115,
|
|
25328
|
-
ASTUtils as
|
|
25250
|
+
ASTUtils as ASTUtils76
|
|
25329
25251
|
} from "@typescript-eslint/utils";
|
|
25330
25252
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
25331
25253
|
summary: "Require an explicit abort signal on locally analyzable global fetch calls.",
|
|
@@ -25394,7 +25316,7 @@ function initSignalState(init, resolvesToGlobal) {
|
|
|
25394
25316
|
const isSignal = !prop.computed && prop.key.type === AST_NODE_TYPES115.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES115.Literal && prop.key.value === "signal";
|
|
25395
25317
|
if (isSignal) {
|
|
25396
25318
|
state = !prop.method ? emptySignal(prop.value, resolvesToGlobal) ?? "unknown" : "unknown";
|
|
25397
|
-
} else if (!prop.computed &&
|
|
25319
|
+
} else if (!prop.computed && ASTUtils76.getPropertyName(prop) === "__proto__" && state === "absent") {
|
|
25398
25320
|
state = "unknown";
|
|
25399
25321
|
} else if (prop.computed && prop.key.type !== AST_NODE_TYPES115.Literal) {
|
|
25400
25322
|
state = "unknown";
|
|
@@ -25403,14 +25325,14 @@ function initSignalState(init, resolvesToGlobal) {
|
|
|
25403
25325
|
return state;
|
|
25404
25326
|
}
|
|
25405
25327
|
function hasUnprovedPrototype(property) {
|
|
25406
|
-
if (property.computed || property.method || property.shorthand ||
|
|
25328
|
+
if (property.computed || property.method || property.shorthand || ASTUtils76.getPropertyName(property) !== "__proto__")
|
|
25407
25329
|
return false;
|
|
25408
25330
|
const prototype = unwrapExpression(property.value);
|
|
25409
25331
|
if (prototype.type === AST_NODE_TYPES115.Literal && prototype.value === null)
|
|
25410
25332
|
return false;
|
|
25411
25333
|
if (prototype.type !== AST_NODE_TYPES115.ObjectExpression) return true;
|
|
25412
25334
|
return prototype.properties.some(
|
|
25413
|
-
(member) => member.type === AST_NODE_TYPES115.SpreadElement || member.kind !== "init" || !member.computed &&
|
|
25335
|
+
(member) => member.type === AST_NODE_TYPES115.SpreadElement || member.kind !== "init" || !member.computed && ASTUtils76.getPropertyName(member) === "__proto__" || member.computed && member.key.type !== AST_NODE_TYPES115.Literal
|
|
25414
25336
|
);
|
|
25415
25337
|
}
|
|
25416
25338
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
@@ -25453,11 +25375,11 @@ var require_fetch_timeout_default = createRule({
|
|
|
25453
25375
|
}
|
|
25454
25376
|
function resolvesToGlobal(identifier) {
|
|
25455
25377
|
const scope = context.sourceCode.getScope(identifier);
|
|
25456
|
-
const variable =
|
|
25378
|
+
const variable = ASTUtils76.findVariable(scope, identifier.name);
|
|
25457
25379
|
return variable === null || variable.defs.length === 0;
|
|
25458
25380
|
}
|
|
25459
25381
|
function localConstInitSignalState(identifier) {
|
|
25460
|
-
const variable =
|
|
25382
|
+
const variable = ASTUtils76.findVariable(
|
|
25461
25383
|
context.sourceCode.getScope(identifier),
|
|
25462
25384
|
identifier.name
|
|
25463
25385
|
);
|
|
@@ -25479,7 +25401,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
25479
25401
|
function isForwardedRequest(argument) {
|
|
25480
25402
|
let value = unwrapExpression(argument);
|
|
25481
25403
|
if (value.type === AST_NODE_TYPES115.Identifier) {
|
|
25482
|
-
const binding =
|
|
25404
|
+
const binding = ASTUtils76.findVariable(
|
|
25483
25405
|
context.sourceCode.getScope(value),
|
|
25484
25406
|
value.name
|
|
25485
25407
|
);
|
|
@@ -25664,7 +25586,7 @@ function exportedClasses(program, classes) {
|
|
|
25664
25586
|
}
|
|
25665
25587
|
|
|
25666
25588
|
// src/rules/require-sql-access-class.ts
|
|
25667
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES117, ASTUtils as
|
|
25589
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES117, ASTUtils as ASTUtils77 } from "@typescript-eslint/utils";
|
|
25668
25590
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
25669
25591
|
"all",
|
|
25670
25592
|
"batch",
|
|
@@ -25771,7 +25693,7 @@ function databaseReceiver(node) {
|
|
|
25771
25693
|
if (node.type === AST_NODE_TYPES117.Identifier)
|
|
25772
25694
|
return DATABASE_NAMES.test(node.name);
|
|
25773
25695
|
if (node.type !== AST_NODE_TYPES117.MemberExpression) return false;
|
|
25774
|
-
const name =
|
|
25696
|
+
const name = ASTUtils77.getPropertyName(node);
|
|
25775
25697
|
return name === "DB" || name !== null && DATABASE_NAMES.test(name);
|
|
25776
25698
|
}
|
|
25777
25699
|
function databaseRootMember(node) {
|
|
@@ -25789,7 +25711,7 @@ function databaseRootMember(node) {
|
|
|
25789
25711
|
}
|
|
25790
25712
|
if (current.type === AST_NODE_TYPES117.MemberExpression) {
|
|
25791
25713
|
if (current.object.type === AST_NODE_TYPES117.ThisExpression)
|
|
25792
|
-
return
|
|
25714
|
+
return ASTUtils77.getPropertyName(current);
|
|
25793
25715
|
current = current.object;
|
|
25794
25716
|
continue;
|
|
25795
25717
|
}
|
|
@@ -25810,7 +25732,7 @@ function expressionHasDatabaseMarker(node) {
|
|
|
25810
25732
|
continue;
|
|
25811
25733
|
}
|
|
25812
25734
|
if (current.type === AST_NODE_TYPES117.MemberExpression) {
|
|
25813
|
-
const name =
|
|
25735
|
+
const name = ASTUtils77.getPropertyName(current);
|
|
25814
25736
|
if (name === "DB" || name !== null && DATABASE_NAMES.test(name))
|
|
25815
25737
|
return true;
|
|
25816
25738
|
current = current.object;
|
|
@@ -25829,7 +25751,7 @@ function expressionCallsBuilder(node) {
|
|
|
25829
25751
|
}
|
|
25830
25752
|
if (current.type === AST_NODE_TYPES117.CallExpression) {
|
|
25831
25753
|
if (current.callee.type !== AST_NODE_TYPES117.MemberExpression) return false;
|
|
25832
|
-
const name =
|
|
25754
|
+
const name = ASTUtils77.getPropertyName(current.callee);
|
|
25833
25755
|
if (name !== null && BUILDER_METHODS.has(name)) return true;
|
|
25834
25756
|
current = current.callee.object;
|
|
25835
25757
|
continue;
|
|
@@ -25880,7 +25802,7 @@ function thisRootMember(node) {
|
|
|
25880
25802
|
let current = node;
|
|
25881
25803
|
let root = null;
|
|
25882
25804
|
while (current.type === AST_NODE_TYPES117.MemberExpression) {
|
|
25883
|
-
const name =
|
|
25805
|
+
const name = ASTUtils77.getPropertyName(current);
|
|
25884
25806
|
if (name === null) return null;
|
|
25885
25807
|
root = name;
|
|
25886
25808
|
current = current.object;
|
|
@@ -25924,19 +25846,19 @@ var require_sql_access_class_default = createRule({
|
|
|
25924
25846
|
if (seen.has(node)) return false;
|
|
25925
25847
|
seen.add(node);
|
|
25926
25848
|
if (node.type === AST_NODE_TYPES117.Identifier) {
|
|
25927
|
-
const binding =
|
|
25849
|
+
const binding = ASTUtils77.findVariable(context.sourceCode.getScope(node), node.name);
|
|
25928
25850
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
25929
25851
|
const definition = binding.defs[0];
|
|
25930
25852
|
return definition?.type === "Variable" && definition.node.init !== null && knownNonDatabase(definition.node.init, seen);
|
|
25931
25853
|
}
|
|
25932
|
-
return node.type === AST_NODE_TYPES117.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES117.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(unwrappedNodeCallee.name) && (
|
|
25854
|
+
return node.type === AST_NODE_TYPES117.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES117.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(unwrappedNodeCallee.name) && (ASTUtils77.findVariable(context.sourceCode.getScope(unwrappedNodeCallee), unwrappedNodeCallee.name)?.defs.length ?? 0) === 0;
|
|
25933
25855
|
}
|
|
25934
25856
|
return {
|
|
25935
25857
|
CallExpression(node) {
|
|
25936
25858
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
25937
25859
|
if (unwrappedNodeCallee.type !== AST_NODE_TYPES117.MemberExpression)
|
|
25938
25860
|
return;
|
|
25939
|
-
const method =
|
|
25861
|
+
const method = ASTUtils77.getPropertyName(unwrappedNodeCallee);
|
|
25940
25862
|
if (knownNonDatabase(unwrappedNodeCallee.object)) return;
|
|
25941
25863
|
if (method === null || !isDatabaseOperation(method, unwrappedNodeCallee.object))
|
|
25942
25864
|
return;
|
|
@@ -26036,7 +25958,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
26036
25958
|
});
|
|
26037
25959
|
|
|
26038
25960
|
// src/rules/require-use-form-default-values.ts
|
|
26039
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES119, ASTUtils as
|
|
25961
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES119, ASTUtils as ASTUtils78 } from "@typescript-eslint/utils";
|
|
26040
25962
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
26041
25963
|
summary: "Require explicit form-level initialization or a field default for directly bound Controller fields.",
|
|
26042
25964
|
rationale: "React Hook Form exposes form-level defaultValues/values and field-level defaultValue as its explicit initialization mechanisms. A directly bound controlled field should not omit both mechanisms.",
|
|
@@ -26087,7 +26009,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
26087
26009
|
const imported = /* @__PURE__ */ new Map();
|
|
26088
26010
|
const uninitializedForms = /* @__PURE__ */ new Set();
|
|
26089
26011
|
const uninitializedControls = /* @__PURE__ */ new Set();
|
|
26090
|
-
const bindingNamed = (node, name) =>
|
|
26012
|
+
const bindingNamed = (node, name) => ASTUtils78.findVariable(context.sourceCode.getScope(node), name);
|
|
26091
26013
|
const bindingOf = (node) => bindingNamed(node, node.name);
|
|
26092
26014
|
const stable = (variable) => !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
26093
26015
|
const importedKind = (node) => {
|
|
@@ -26133,7 +26055,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
26133
26055
|
const variable = bindingOf(node);
|
|
26134
26056
|
return variable !== null && stable(variable) && uninitializedControls.has(variable);
|
|
26135
26057
|
}
|
|
26136
|
-
return node.type === AST_NODE_TYPES119.MemberExpression &&
|
|
26058
|
+
return node.type === AST_NODE_TYPES119.MemberExpression && ASTUtils78.getPropertyName(node) !== null && (ASTUtils78.getPropertyName(node) ?? "") === "control" && isUninitializedForm(node.object);
|
|
26137
26059
|
};
|
|
26138
26060
|
const fieldOptionsNeedDefault = (node) => {
|
|
26139
26061
|
if (node?.type !== AST_NODE_TYPES119.ObjectExpression) return false;
|
|
@@ -26189,7 +26111,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
26189
26111
|
trackDestructuredControl(node.id);
|
|
26190
26112
|
return;
|
|
26191
26113
|
}
|
|
26192
|
-
if (node.id.type === AST_NODE_TYPES119.Identifier && node.init.type === AST_NODE_TYPES119.MemberExpression &&
|
|
26114
|
+
if (node.id.type === AST_NODE_TYPES119.Identifier && node.init.type === AST_NODE_TYPES119.MemberExpression && ASTUtils78.getPropertyName(node.init) !== null && (ASTUtils78.getPropertyName(node.init) ?? "") === "control" && isUninitializedForm(node.init.object)) {
|
|
26193
26115
|
const variable = bindingOf(node.id);
|
|
26194
26116
|
if (variable !== null) uninitializedControls.add(variable);
|
|
26195
26117
|
}
|
|
@@ -26282,7 +26204,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
26282
26204
|
// src/rules/require-zod-form-validation.ts
|
|
26283
26205
|
import {
|
|
26284
26206
|
AST_NODE_TYPES as AST_NODE_TYPES120,
|
|
26285
|
-
ASTUtils as
|
|
26207
|
+
ASTUtils as ASTUtils79
|
|
26286
26208
|
} from "@typescript-eslint/utils";
|
|
26287
26209
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
26288
26210
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
@@ -26330,7 +26252,7 @@ var isFormDataMethodCall = (node) => {
|
|
|
26330
26252
|
}
|
|
26331
26253
|
if (current.type !== AST_NODE_TYPES120.CallExpression) return false;
|
|
26332
26254
|
const callee = unwrapExpression(current.callee);
|
|
26333
|
-
return callee.type === AST_NODE_TYPES120.MemberExpression &&
|
|
26255
|
+
return callee.type === AST_NODE_TYPES120.MemberExpression && ASTUtils79.getPropertyName(callee) === "formData";
|
|
26334
26256
|
};
|
|
26335
26257
|
var require_zod_form_validation_default = createRule({
|
|
26336
26258
|
name: "require-zod-form-validation",
|
|
@@ -26351,7 +26273,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
26351
26273
|
return {};
|
|
26352
26274
|
}
|
|
26353
26275
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
26354
|
-
const resolvedBinding = (identifier) =>
|
|
26276
|
+
const resolvedBinding = (identifier) => ASTUtils79.findVariable(
|
|
26355
26277
|
context.sourceCode.getScope(identifier),
|
|
26356
26278
|
identifier.name
|
|
26357
26279
|
);
|
|
@@ -26359,7 +26281,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
26359
26281
|
const callee = unwrapExpression(node.callee);
|
|
26360
26282
|
const calleeReceiver = callee.type === AST_NODE_TYPES120.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
26361
26283
|
if (callee.type !== AST_NODE_TYPES120.MemberExpression) return false;
|
|
26362
|
-
if (
|
|
26284
|
+
if (ASTUtils79.getPropertyName(callee) === null || !FORM_VALUE_METHODS.has(ASTUtils79.getPropertyName(callee) ?? "")) {
|
|
26363
26285
|
return false;
|
|
26364
26286
|
}
|
|
26365
26287
|
return isFormSourceIdentifier(calleeReceiver);
|
|
@@ -26390,7 +26312,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
26390
26312
|
parent = parent.parent;
|
|
26391
26313
|
continue;
|
|
26392
26314
|
}
|
|
26393
|
-
if (parent.type === AST_NODE_TYPES120.CallExpression && parent.callee.type === AST_NODE_TYPES120.MemberExpression && parent.callee.object.type === AST_NODE_TYPES120.Identifier && parent.callee.object.name === "Object" &&
|
|
26315
|
+
if (parent.type === AST_NODE_TYPES120.CallExpression && parent.callee.type === AST_NODE_TYPES120.MemberExpression && parent.callee.object.type === AST_NODE_TYPES120.Identifier && parent.callee.object.name === "Object" && ASTUtils79.getPropertyName(parent.callee) === "fromEntries" && (resolvedBinding(parent.callee.object)?.defs.length ?? 0) === 0) {
|
|
26394
26316
|
parent = parent.parent;
|
|
26395
26317
|
continue;
|
|
26396
26318
|
}
|
|
@@ -26403,7 +26325,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
26403
26325
|
if (node.type !== AST_NODE_TYPES120.CallExpression) return false;
|
|
26404
26326
|
const callee = unwrapExpression(node.callee);
|
|
26405
26327
|
const calleeReceiver = callee.type === AST_NODE_TYPES120.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
26406
|
-
if (callee.type !== AST_NODE_TYPES120.MemberExpression ||
|
|
26328
|
+
if (callee.type !== AST_NODE_TYPES120.MemberExpression || ASTUtils79.getPropertyName(callee) === null || !ZOD_PARSE_METHODS.has(ASTUtils79.getPropertyName(callee) ?? "")) {
|
|
26407
26329
|
return false;
|
|
26408
26330
|
}
|
|
26409
26331
|
const root = zodReceiverRoot(calleeReceiver);
|
|
@@ -26489,7 +26411,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
26489
26411
|
};
|
|
26490
26412
|
const zodParseMethod = (call) => {
|
|
26491
26413
|
const callee = unwrapExpression(call.callee);
|
|
26492
|
-
return callee.type === AST_NODE_TYPES120.MemberExpression &&
|
|
26414
|
+
return callee.type === AST_NODE_TYPES120.MemberExpression && ASTUtils79.getPropertyName(callee) !== null ? ASTUtils79.getPropertyName(callee) ?? "" : null;
|
|
26493
26415
|
};
|
|
26494
26416
|
const isSafePrevalidationInspection = (identifier) => {
|
|
26495
26417
|
const parent = identifier.parent;
|
|
@@ -26665,7 +26587,7 @@ function expressionCallableName(current) {
|
|
|
26665
26587
|
}
|
|
26666
26588
|
|
|
26667
26589
|
// src/rules/stepdown.ts
|
|
26668
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES121, ASTUtils as
|
|
26590
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES121, ASTUtils as ASTUtils80 } from "@typescript-eslint/utils";
|
|
26669
26591
|
var STEPDOWN_DOCUMENTATION = {
|
|
26670
26592
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
26671
26593
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -26965,7 +26887,7 @@ function receiverOrigin(context, object, receivers) {
|
|
|
26965
26887
|
while (true) {
|
|
26966
26888
|
const unwrapped = unwrapExpression4(current);
|
|
26967
26889
|
if (unwrapped.type !== AST_NODE_TYPES121.Identifier) return unwrapped;
|
|
26968
|
-
const variable =
|
|
26890
|
+
const variable = ASTUtils80.findVariable(context.sourceCode.getScope(unwrapped), unwrapped.name);
|
|
26969
26891
|
if (variable === null) return null;
|
|
26970
26892
|
const known = receivers.get(variable);
|
|
26971
26893
|
if (known !== void 0) return known;
|
|
@@ -27146,11 +27068,11 @@ function classScope(context, node, computedReferences) {
|
|
|
27146
27068
|
function classReceiverBindings(context, node) {
|
|
27147
27069
|
const classReceivers = /* @__PURE__ */ new Map();
|
|
27148
27070
|
if (node.id !== null) {
|
|
27149
|
-
const internal =
|
|
27071
|
+
const internal = ASTUtils80.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
27150
27072
|
if (internal !== null && stableVariable(internal)) classReceivers.set(internal, true);
|
|
27151
27073
|
}
|
|
27152
27074
|
if (node.type === AST_NODE_TYPES121.ClassExpression && node.parent.type === AST_NODE_TYPES121.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES121.Identifier && node.parent.parent.type === AST_NODE_TYPES121.VariableDeclaration && node.parent.parent.kind === "const") {
|
|
27153
|
-
const outer =
|
|
27075
|
+
const outer = ASTUtils80.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
27154
27076
|
if (outer !== null && stableVariable(outer)) classReceivers.set(outer, true);
|
|
27155
27077
|
}
|
|
27156
27078
|
return classReceivers;
|
|
@@ -27236,7 +27158,7 @@ function classMethodCounts(body2, methods) {
|
|
|
27236
27158
|
}
|
|
27237
27159
|
|
|
27238
27160
|
// src/rules/source-coupled-test.ts
|
|
27239
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES122, ASTUtils as
|
|
27161
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES122, ASTUtils as ASTUtils81 } from "@typescript-eslint/utils";
|
|
27240
27162
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|toml|py|[cm]?[jt]s)$|(?<!\.(?:tf|tftest))\.json$/iu;
|
|
27241
27163
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
27242
27164
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -27353,7 +27275,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27353
27275
|
const scopes = [newScope()];
|
|
27354
27276
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
27355
27277
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
27356
|
-
const bindingOf = (node) =>
|
|
27278
|
+
const bindingOf = (node) => ASTUtils81.findVariable(context.sourceCode.getScope(node), node.name);
|
|
27357
27279
|
const assertionKind = (node) => {
|
|
27358
27280
|
const binding = bindingOf(node);
|
|
27359
27281
|
if (binding === null || binding.defs.length === 0) {
|
|
@@ -27406,7 +27328,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27406
27328
|
return visible("fsReaders", callee) && sourcePath(current.arguments[0]);
|
|
27407
27329
|
}
|
|
27408
27330
|
if (callee.type !== AST_NODE_TYPES122.MemberExpression) return false;
|
|
27409
|
-
const name2 =
|
|
27331
|
+
const name2 = ASTUtils81.getPropertyName(callee);
|
|
27410
27332
|
const object = unwrap6(calleeReceiver);
|
|
27411
27333
|
return name2 !== null && FS_READERS.has(name2) && object.type === AST_NODE_TYPES122.Identifier && visible("fsObjects", object) && sourcePath(current.arguments[0]);
|
|
27412
27334
|
};
|
|
@@ -27415,12 +27337,12 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27415
27337
|
if (current.type === AST_NODE_TYPES122.Identifier) return visibleRawOrigins(current);
|
|
27416
27338
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
27417
27339
|
if (current.type === AST_NODE_TYPES122.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
27418
|
-
if (current.type === AST_NODE_TYPES122.MemberExpression &&
|
|
27340
|
+
if (current.type === AST_NODE_TYPES122.MemberExpression && ASTUtils81.getPropertyName(current) === "length") return rawOrigins(current.object);
|
|
27419
27341
|
if (current.type !== AST_NODE_TYPES122.CallExpression) return /* @__PURE__ */ new Set();
|
|
27420
27342
|
const callee = unwrap6(current.callee);
|
|
27421
27343
|
const calleeReceiver = callee.type === AST_NODE_TYPES122.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
27422
27344
|
if (callee.type !== AST_NODE_TYPES122.MemberExpression) return /* @__PURE__ */ new Set();
|
|
27423
|
-
const name2 =
|
|
27345
|
+
const name2 = ASTUtils81.getPropertyName(callee);
|
|
27424
27346
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(calleeReceiver) : /* @__PURE__ */ new Set();
|
|
27425
27347
|
};
|
|
27426
27348
|
const evidenceOrigins = (node) => {
|
|
@@ -27433,7 +27355,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27433
27355
|
const callee = unwrap6(current.callee);
|
|
27434
27356
|
const calleeReceiver = callee.type === AST_NODE_TYPES122.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
27435
27357
|
if (callee.type !== AST_NODE_TYPES122.MemberExpression) return /* @__PURE__ */ new Set();
|
|
27436
|
-
const name2 =
|
|
27358
|
+
const name2 = ASTUtils81.getPropertyName(callee);
|
|
27437
27359
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(calleeReceiver);
|
|
27438
27360
|
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES122.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
27439
27361
|
return /* @__PURE__ */ new Set();
|
|
@@ -27445,10 +27367,10 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27445
27367
|
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES122.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
27446
27368
|
}
|
|
27447
27369
|
if (callee.type !== AST_NODE_TYPES122.MemberExpression) return /* @__PURE__ */ new Set();
|
|
27448
|
-
const matcher =
|
|
27370
|
+
const matcher = ASTUtils81.getPropertyName(callee);
|
|
27449
27371
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
27450
27372
|
let receiver = unwrap6(calleeReceiver);
|
|
27451
|
-
while (receiver.type === AST_NODE_TYPES122.MemberExpression && EXPECT_MODIFIERS2.has(
|
|
27373
|
+
while (receiver.type === AST_NODE_TYPES122.MemberExpression && EXPECT_MODIFIERS2.has(ASTUtils81.getPropertyName(receiver) ?? "")) receiver = unwrap6(receiver.object);
|
|
27452
27374
|
const expectCallee = receiver.type === AST_NODE_TYPES122.CallExpression ? unwrapExpression(receiver.callee) : null;
|
|
27453
27375
|
if (receiver.type === AST_NODE_TYPES122.CallExpression && expectCallee?.type === AST_NODE_TYPES122.Identifier && assertionKind(expectCallee) === "expect") {
|
|
27454
27376
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
@@ -27731,7 +27653,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
27731
27653
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
27732
27654
|
import {
|
|
27733
27655
|
AST_NODE_TYPES as AST_NODE_TYPES124,
|
|
27734
|
-
ASTUtils as
|
|
27656
|
+
ASTUtils as ASTUtils82
|
|
27735
27657
|
} from "@typescript-eslint/utils";
|
|
27736
27658
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
27737
27659
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
@@ -27864,7 +27786,7 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
27864
27786
|
"superRefine",
|
|
27865
27787
|
"transform"
|
|
27866
27788
|
]);
|
|
27867
|
-
var terminalMethodName = (callee) =>
|
|
27789
|
+
var terminalMethodName = (callee) => ASTUtils82.getPropertyName(callee) !== null ? ASTUtils82.getPropertyName(callee) ?? "" : null;
|
|
27868
27790
|
var calleeChainRoot2 = (node) => {
|
|
27869
27791
|
let current = node;
|
|
27870
27792
|
for (; ; ) {
|
|
@@ -27889,8 +27811,8 @@ var chainMemberNames2 = (node) => {
|
|
|
27889
27811
|
for (; ; ) {
|
|
27890
27812
|
current = unwrapExpression(current);
|
|
27891
27813
|
if (current.type === AST_NODE_TYPES124.MemberExpression) {
|
|
27892
|
-
if (
|
|
27893
|
-
names.push(
|
|
27814
|
+
if (ASTUtils82.getPropertyName(current) === null) return [];
|
|
27815
|
+
names.push(ASTUtils82.getPropertyName(current) ?? "");
|
|
27894
27816
|
current = current.object;
|
|
27895
27817
|
continue;
|
|
27896
27818
|
}
|
|
@@ -27927,7 +27849,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
27927
27849
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
27928
27850
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
27929
27851
|
function resolvedBinding(identifier) {
|
|
27930
|
-
return
|
|
27852
|
+
return ASTUtils82.findVariable(
|
|
27931
27853
|
context.sourceCode.getScope(identifier),
|
|
27932
27854
|
identifier.name
|
|
27933
27855
|
);
|