@sarj/eslint-plugin 13.1.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -95
- package/dist/index.cjs +1323 -1218
- package/dist/index.d.cts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +333 -225
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -622,77 +622,8 @@ var duplicate_test_body_default = createRule({
|
|
|
622
622
|
}
|
|
623
623
|
});
|
|
624
624
|
|
|
625
|
-
// src/rules/no-async-callback-in-wait-for.ts
|
|
626
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
|
|
627
|
-
var noAsyncCallbackInWaitForDocumentation = {
|
|
628
|
-
summary: "Disallow async callbacks in `waitFor` to prevent swallowed promise rejections.",
|
|
629
|
-
rationale: "`waitFor` retries synchronous assertions; an async callback changes that contract and can hide a rejected assertion promise.",
|
|
630
|
-
remediation: "Remove `async` and keep the assertions inside `waitFor` synchronous.",
|
|
631
|
-
category: "testing",
|
|
632
|
-
aliases: ["no-async-callback-in-waitfor"],
|
|
633
|
-
limitations: [
|
|
634
|
-
"The rule checks inline first-argument callbacks to bare or non-computed `.waitFor` calls in test files."
|
|
635
|
-
],
|
|
636
|
-
examples: [
|
|
637
|
-
{
|
|
638
|
-
id: "synchronous-wait-for-callback",
|
|
639
|
-
title: "waitFor retries a synchronous assertion",
|
|
640
|
-
outcome: "no-match",
|
|
641
|
-
files: [{ path: "src/component.test.ts", source: "it('works', async () => { await waitFor(() => expect(foo).toBe(true)); });" }],
|
|
642
|
-
focusPath: "src/component.test.ts",
|
|
643
|
-
expectedCount: 0,
|
|
644
|
-
public: true
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
id: "async-wait-for-callback",
|
|
648
|
-
title: "waitFor receives an async callback",
|
|
649
|
-
outcome: "match",
|
|
650
|
-
files: [{ path: "src/component.test.ts", source: "it('fails', async () => { await waitFor(async () => expect(foo).toBe(true)); });" }],
|
|
651
|
-
focusPath: "src/component.test.ts",
|
|
652
|
-
expectedCount: 1,
|
|
653
|
-
public: true
|
|
654
|
-
}
|
|
655
|
-
]
|
|
656
|
-
};
|
|
657
|
-
var isWaitForCallee = (callee) => {
|
|
658
|
-
if (callee.type === AST_NODE_TYPES3.Identifier) return callee.name === "waitFor";
|
|
659
|
-
return callee.type === AST_NODE_TYPES3.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES3.Identifier && callee.property.name === "waitFor";
|
|
660
|
-
};
|
|
661
|
-
var no_async_callback_in_wait_for_default = createRule({
|
|
662
|
-
name: "no-async-callback-in-wait-for",
|
|
663
|
-
documentation: noAsyncCallbackInWaitForDocumentation,
|
|
664
|
-
meta: {
|
|
665
|
-
type: "problem",
|
|
666
|
-
docs: {
|
|
667
|
-
description: "Disallow async callbacks in `waitFor` to prevent swallowed promise rejections."
|
|
668
|
-
},
|
|
669
|
-
schema: [],
|
|
670
|
-
messages: {
|
|
671
|
-
noAsyncCallbackInWaitFor: "The callback to `waitFor` should not be async. It expects synchronous assertions and runs the callback repeatedly."
|
|
672
|
-
}
|
|
673
|
-
},
|
|
674
|
-
defaultOptions: [],
|
|
675
|
-
create(context) {
|
|
676
|
-
if (!isTestFile(context.filename)) {
|
|
677
|
-
return {};
|
|
678
|
-
}
|
|
679
|
-
return {
|
|
680
|
-
CallExpression(node) {
|
|
681
|
-
if (!isWaitForCallee(node.callee)) return;
|
|
682
|
-
const callback = node.arguments[0];
|
|
683
|
-
if (callback && (callback.type === AST_NODE_TYPES3.ArrowFunctionExpression || callback.type === AST_NODE_TYPES3.FunctionExpression) && callback.async) {
|
|
684
|
-
context.report({
|
|
685
|
-
node: callback,
|
|
686
|
-
messageId: "noAsyncCallbackInWaitFor"
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
|
|
694
625
|
// src/rules/no-client-side-data-fetching.ts
|
|
695
|
-
import { AST_NODE_TYPES as
|
|
626
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
|
|
696
627
|
var noClientSideDataFetchingDocumentation = {
|
|
697
628
|
summary: "Disallow direct data fetching inside `useEffect` or `useLayoutEffect`.",
|
|
698
629
|
rationale: "Effect-driven reads begin after rendering and can create request waterfalls, duplicate fetches, and loading-state layout shifts.",
|
|
@@ -745,33 +676,33 @@ var ANALYTICS_SEGMENTS = /* @__PURE__ */ new Set([
|
|
|
745
676
|
]);
|
|
746
677
|
function isEffectHookCall(node) {
|
|
747
678
|
const callee = node.callee;
|
|
748
|
-
if (callee.type ===
|
|
679
|
+
if (callee.type === AST_NODE_TYPES3.Identifier) {
|
|
749
680
|
return callee.name === "useEffect" || callee.name === "useLayoutEffect";
|
|
750
681
|
}
|
|
751
|
-
if (callee.type ===
|
|
682
|
+
if (callee.type === AST_NODE_TYPES3.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES3.Identifier && callee.object.name === "React" && callee.property.type === AST_NODE_TYPES3.Identifier) {
|
|
752
683
|
return callee.property.name === "useEffect" || callee.property.name === "useLayoutEffect";
|
|
753
684
|
}
|
|
754
685
|
return false;
|
|
755
686
|
}
|
|
756
687
|
function isFetchCall(node) {
|
|
757
688
|
const callee = node.callee;
|
|
758
|
-
if (callee.type ===
|
|
689
|
+
if (callee.type === AST_NODE_TYPES3.Identifier && callee.name === "fetch") {
|
|
759
690
|
const method = readMethodProperty(node.arguments[1]);
|
|
760
691
|
if (method !== null && method !== "GET") {
|
|
761
692
|
return false;
|
|
762
693
|
}
|
|
763
694
|
return true;
|
|
764
695
|
}
|
|
765
|
-
if (callee.type ===
|
|
696
|
+
if (callee.type === AST_NODE_TYPES3.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES3.Identifier && FETCH_LIBS.has(callee.object.name) && callee.property.type === AST_NODE_TYPES3.Identifier) {
|
|
766
697
|
return HTTP_METHOD_NAMES.has(callee.property.name);
|
|
767
698
|
}
|
|
768
|
-
if (callee.type ===
|
|
699
|
+
if (callee.type === AST_NODE_TYPES3.Identifier && (callee.name === "axios" || callee.name === "ky")) {
|
|
769
700
|
const firstArg = node.arguments[0];
|
|
770
701
|
const secondArg = node.arguments[1];
|
|
771
702
|
let configArg;
|
|
772
|
-
if (firstArg?.type ===
|
|
703
|
+
if (firstArg?.type === AST_NODE_TYPES3.ObjectExpression) {
|
|
773
704
|
configArg = firstArg;
|
|
774
|
-
} else if (secondArg?.type ===
|
|
705
|
+
} else if (secondArg?.type === AST_NODE_TYPES3.ObjectExpression) {
|
|
775
706
|
configArg = secondArg;
|
|
776
707
|
}
|
|
777
708
|
const method = readMethodProperty(configArg);
|
|
@@ -783,16 +714,16 @@ function isFetchCall(node) {
|
|
|
783
714
|
return false;
|
|
784
715
|
}
|
|
785
716
|
function readMethodProperty(optionsArg) {
|
|
786
|
-
if (!optionsArg || optionsArg.type !==
|
|
717
|
+
if (!optionsArg || optionsArg.type !== AST_NODE_TYPES3.ObjectExpression) {
|
|
787
718
|
return null;
|
|
788
719
|
}
|
|
789
720
|
for (const prop of optionsArg.properties) {
|
|
790
|
-
if (prop.type !==
|
|
721
|
+
if (prop.type !== AST_NODE_TYPES3.Property) continue;
|
|
791
722
|
if (prop.computed) continue;
|
|
792
723
|
const key = prop.key;
|
|
793
|
-
const matchesMethodKey = key.type ===
|
|
724
|
+
const matchesMethodKey = key.type === AST_NODE_TYPES3.Identifier && key.name === "method" || key.type === AST_NODE_TYPES3.Literal && key.value === "method";
|
|
794
725
|
if (!matchesMethodKey) continue;
|
|
795
|
-
if (prop.value.type ===
|
|
726
|
+
if (prop.value.type === AST_NODE_TYPES3.Literal && typeof prop.value.value === "string") {
|
|
796
727
|
return prop.value.value.toUpperCase();
|
|
797
728
|
}
|
|
798
729
|
return null;
|
|
@@ -807,13 +738,13 @@ function isAnalyticsCall(node) {
|
|
|
807
738
|
function extractUrlString(node) {
|
|
808
739
|
const firstArg = node.arguments[0];
|
|
809
740
|
if (!firstArg) return "";
|
|
810
|
-
if (firstArg.type ===
|
|
741
|
+
if (firstArg.type === AST_NODE_TYPES3.Literal && typeof firstArg.value === "string") {
|
|
811
742
|
return firstArg.value;
|
|
812
743
|
}
|
|
813
|
-
if (firstArg.type ===
|
|
744
|
+
if (firstArg.type === AST_NODE_TYPES3.TemplateLiteral) {
|
|
814
745
|
return firstArg.quasis.map((q) => q.value.cooked).join("");
|
|
815
746
|
}
|
|
816
|
-
if (firstArg.type ===
|
|
747
|
+
if (firstArg.type === AST_NODE_TYPES3.Identifier) {
|
|
817
748
|
return firstArg.name;
|
|
818
749
|
}
|
|
819
750
|
return "";
|
|
@@ -855,10 +786,10 @@ var no_client_side_data_fetching_default = createRule({
|
|
|
855
786
|
});
|
|
856
787
|
|
|
857
788
|
// src/rules/no-comment-cruft.ts
|
|
858
|
-
import { AST_NODE_TYPES as
|
|
789
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES5 } from "@typescript-eslint/utils";
|
|
859
790
|
|
|
860
791
|
// src/rules/_comments.ts
|
|
861
|
-
import { AST_NODE_TYPES as
|
|
792
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/utils";
|
|
862
793
|
var REF_RE = /https?:\/\/|\bRFC[- ]?\d+|\bPEP[- ]?\d+|\bCVE-\d{4}|\b(?!UTF-|SHA-|ISO-|AES-|CRC-|MD-|PCM-|EOF-|API-|BASE-)[A-Z][A-Z0-9]{1,9}-\d[A-Z0-9]{0,5}\b|(?<![&\w])#\d{2,6}\b|@[a-z][\w.-]*\.(?:us|com|ai|io|net|org|dev)\b/;
|
|
863
794
|
var VERSION_RE = /(?:>=|<=|==|<|>)\s*v?\d+\.\d+|\bv\d+\.\d+|\b(?:since|until|as of)\s+(?:v?\d+\.\d+|Python\s*\d)/i;
|
|
864
795
|
var UNITS_RE = /[~<>]?\d+(?:\.\d+)?\s?(?:ms|s\b|sec\b|seconds?\b|min\b|minutes?\b|hours?\b|days?\b|KB|MB|MiB|GiB|kHz|Hz|bytes?\b|bit\b|-bit\b|%|px\b|rps\b|qps\b)|\b[1-5]xx\b|\b(?:301|302|304|307|308|400|401|403|404|405|409|410|412|422|425|429|500|501|502|503|504)\b/;
|
|
@@ -944,10 +875,10 @@ var NARRATION_MAX_WORDS = 6;
|
|
|
944
875
|
var NARRATION_MIN_CONTENT = 1;
|
|
945
876
|
var TOKEN_PLURAL_MIN = 4;
|
|
946
877
|
var RESTATABLE_STATEMENTS = /* @__PURE__ */ new Set([
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
878
|
+
AST_NODE_TYPES4.ExpressionStatement,
|
|
879
|
+
AST_NODE_TYPES4.ReturnStatement,
|
|
880
|
+
AST_NODE_TYPES4.ThrowStatement,
|
|
881
|
+
AST_NODE_TYPES4.VariableDeclaration
|
|
951
882
|
]);
|
|
952
883
|
var NARRATION_VERB_RE = /^(?:add|append|assign|build|calculate|call|check|clear|close|compute|convert|copy|count|create|declare|decrement|define|delete|extract|fetch|filter|find|format|generate|get|handle|increment|init|initialise|initialize|insert|iterate|join|load|log|loop|make|map|merge|open|parse|print|process|push|read|remove|render|reset|return|save|send|set|setup|sort|split|start|stop|store|update|validate|wrap|write)(?:s|es|d|ed|ing)?$/i;
|
|
953
884
|
var NARRATION_STOPWORDS = /* @__PURE__ */ new Set([
|
|
@@ -1002,12 +933,12 @@ function normalizeToken(word) {
|
|
|
1002
933
|
function restatableStatementBelow(comment, sourceCode) {
|
|
1003
934
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
1004
935
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) return null;
|
|
1005
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
936
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== AST_NODE_TYPES4.Program; node = node.parent) {
|
|
1006
937
|
if (!RESTATABLE_STATEMENTS.has(node.type)) continue;
|
|
1007
938
|
if (node.loc.start.line !== token.loc.start.line || node.loc.end.line !== node.loc.start.line) {
|
|
1008
939
|
return null;
|
|
1009
940
|
}
|
|
1010
|
-
if (node.type ===
|
|
941
|
+
if (node.type === AST_NODE_TYPES4.VariableDeclaration && isTrivialInitializer(node)) {
|
|
1011
942
|
return null;
|
|
1012
943
|
}
|
|
1013
944
|
return sourceCode.getText(node);
|
|
@@ -1017,8 +948,8 @@ function restatableStatementBelow(comment, sourceCode) {
|
|
|
1017
948
|
function isTrivialInitializer(node) {
|
|
1018
949
|
return node.declarations.every((declarator) => {
|
|
1019
950
|
const init = declarator.init;
|
|
1020
|
-
if (init == null || init.type ===
|
|
1021
|
-
return init.type ===
|
|
951
|
+
if (init == null || init.type === AST_NODE_TYPES4.Literal) return true;
|
|
952
|
+
return init.type === AST_NODE_TYPES4.ArrayExpression && init.elements.length === 0 || init.type === AST_NODE_TYPES4.ObjectExpression && init.properties.length === 0;
|
|
1022
953
|
});
|
|
1023
954
|
}
|
|
1024
955
|
function restatesStatementHead(body2, statement) {
|
|
@@ -1320,13 +1251,13 @@ function restatesWholeStatement(body2, statement) {
|
|
|
1320
1251
|
return statement !== null && restatesStatementHead(body2, statement.replaceAll("(", " "));
|
|
1321
1252
|
}
|
|
1322
1253
|
var STATEMENT_CONTAINERS = /* @__PURE__ */ new Set([
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1254
|
+
AST_NODE_TYPES5.Program,
|
|
1255
|
+
AST_NODE_TYPES5.BlockStatement,
|
|
1256
|
+
AST_NODE_TYPES5.ClassBody,
|
|
1257
|
+
AST_NODE_TYPES5.StaticBlock,
|
|
1258
|
+
AST_NODE_TYPES5.SwitchCase,
|
|
1259
|
+
AST_NODE_TYPES5.TSModuleBlock,
|
|
1260
|
+
AST_NODE_TYPES5.TSInterfaceBody
|
|
1330
1261
|
]);
|
|
1331
1262
|
function statementAttachmentBelow(comment, sourceCode) {
|
|
1332
1263
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
@@ -1344,30 +1275,30 @@ function statementAttachmentBelow(comment, sourceCode) {
|
|
|
1344
1275
|
return null;
|
|
1345
1276
|
}
|
|
1346
1277
|
var WALL_STATEMENTS = /* @__PURE__ */ new Set([
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1278
|
+
AST_NODE_TYPES5.ExpressionStatement,
|
|
1279
|
+
AST_NODE_TYPES5.ReturnStatement,
|
|
1280
|
+
AST_NODE_TYPES5.ThrowStatement,
|
|
1281
|
+
AST_NODE_TYPES5.VariableDeclaration,
|
|
1282
|
+
AST_NODE_TYPES5.IfStatement,
|
|
1283
|
+
AST_NODE_TYPES5.ForStatement,
|
|
1284
|
+
AST_NODE_TYPES5.ForOfStatement,
|
|
1285
|
+
AST_NODE_TYPES5.ForInStatement,
|
|
1286
|
+
AST_NODE_TYPES5.WhileStatement,
|
|
1287
|
+
AST_NODE_TYPES5.DoWhileStatement,
|
|
1288
|
+
AST_NODE_TYPES5.SwitchStatement,
|
|
1289
|
+
AST_NODE_TYPES5.TryStatement
|
|
1359
1290
|
]);
|
|
1360
1291
|
function directStatements(container) {
|
|
1361
1292
|
switch (container.type) {
|
|
1362
|
-
case
|
|
1363
|
-
case
|
|
1364
|
-
case
|
|
1365
|
-
case
|
|
1366
|
-
case
|
|
1293
|
+
case AST_NODE_TYPES5.Program:
|
|
1294
|
+
case AST_NODE_TYPES5.BlockStatement:
|
|
1295
|
+
case AST_NODE_TYPES5.ClassBody:
|
|
1296
|
+
case AST_NODE_TYPES5.StaticBlock:
|
|
1297
|
+
case AST_NODE_TYPES5.TSModuleBlock:
|
|
1367
1298
|
return container.body;
|
|
1368
|
-
case
|
|
1299
|
+
case AST_NODE_TYPES5.SwitchCase:
|
|
1369
1300
|
return container.consequent;
|
|
1370
|
-
case
|
|
1301
|
+
case AST_NODE_TYPES5.TSInterfaceBody:
|
|
1371
1302
|
return container.body;
|
|
1372
1303
|
default:
|
|
1373
1304
|
return [];
|
|
@@ -1386,8 +1317,8 @@ function isWeakWalkthroughComment(body2, statement) {
|
|
|
1386
1317
|
return matched / described.length >= 0.5 && described.length - matched <= WALL_MAX_NOVEL_WORDS;
|
|
1387
1318
|
}
|
|
1388
1319
|
var TYPE_MEMBER_CONTAINERS = /* @__PURE__ */ new Set([
|
|
1389
|
-
|
|
1390
|
-
|
|
1320
|
+
AST_NODE_TYPES5.TSInterfaceBody,
|
|
1321
|
+
AST_NODE_TYPES5.TSTypeLiteral
|
|
1391
1322
|
]);
|
|
1392
1323
|
function runCitesAReference(comments, index) {
|
|
1393
1324
|
for (let i = index; i >= 0; i--) {
|
|
@@ -1481,10 +1412,10 @@ var no_comment_cruft_default = createRule({
|
|
|
1481
1412
|
for (let node = sourceCode.getNodeByRangeIndex(
|
|
1482
1413
|
comment.range[0]
|
|
1483
1414
|
); node != null; node = node.parent) {
|
|
1484
|
-
if (node.type ===
|
|
1485
|
-
return node.expression.type ===
|
|
1415
|
+
if (node.type === AST_NODE_TYPES5.JSXExpressionContainer) {
|
|
1416
|
+
return node.expression.type === AST_NODE_TYPES5.JSXEmptyExpression;
|
|
1486
1417
|
}
|
|
1487
|
-
if (node.type ===
|
|
1418
|
+
if (node.type === AST_NODE_TYPES5.Program) return false;
|
|
1488
1419
|
}
|
|
1489
1420
|
return false;
|
|
1490
1421
|
}
|
|
@@ -1656,7 +1587,7 @@ var no_comment_cruft_default = createRule({
|
|
|
1656
1587
|
});
|
|
1657
1588
|
|
|
1658
1589
|
// src/rules/no-conditional-in-test.ts
|
|
1659
|
-
import { AST_NODE_TYPES as
|
|
1590
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES6 } from "@typescript-eslint/utils";
|
|
1660
1591
|
var noConditionalInTestDocumentation = {
|
|
1661
1592
|
summary: "Disallow test conditionals that can skip a runtime assertion or exit the test before one runs.",
|
|
1662
1593
|
rationale: "A branch can skip the assertion that gives a test its meaning, allowing unexpected inputs to pass silently.",
|
|
@@ -1695,9 +1626,9 @@ var NON_TEST_MEMBERS = /* @__PURE__ */ new Set([
|
|
|
1695
1626
|
"describe"
|
|
1696
1627
|
]);
|
|
1697
1628
|
var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1629
|
+
AST_NODE_TYPES6.FunctionDeclaration,
|
|
1630
|
+
AST_NODE_TYPES6.FunctionExpression,
|
|
1631
|
+
AST_NODE_TYPES6.ArrowFunctionExpression
|
|
1701
1632
|
]);
|
|
1702
1633
|
var ASSERTION_ROOTS = /* @__PURE__ */ new Set([
|
|
1703
1634
|
"expect",
|
|
@@ -1718,38 +1649,38 @@ function nearestEnclosingFunction(node) {
|
|
|
1718
1649
|
return null;
|
|
1719
1650
|
}
|
|
1720
1651
|
function testCallerName(callee) {
|
|
1721
|
-
if (callee.type ===
|
|
1652
|
+
if (callee.type === AST_NODE_TYPES6.Identifier) {
|
|
1722
1653
|
return callee.name;
|
|
1723
1654
|
}
|
|
1724
|
-
if (callee.type ===
|
|
1655
|
+
if (callee.type === AST_NODE_TYPES6.MemberExpression) {
|
|
1725
1656
|
return testCallerName(callee.object);
|
|
1726
1657
|
}
|
|
1727
|
-
if (callee.type ===
|
|
1658
|
+
if (callee.type === AST_NODE_TYPES6.CallExpression) {
|
|
1728
1659
|
return testCallerName(callee.callee);
|
|
1729
1660
|
}
|
|
1730
|
-
if (callee.type ===
|
|
1661
|
+
if (callee.type === AST_NODE_TYPES6.TaggedTemplateExpression) {
|
|
1731
1662
|
return testCallerName(callee.tag);
|
|
1732
1663
|
}
|
|
1733
1664
|
return null;
|
|
1734
1665
|
}
|
|
1735
1666
|
function hasNonTestMember(callee) {
|
|
1736
|
-
if (callee.type ===
|
|
1737
|
-
if (!callee.computed && callee.property.type ===
|
|
1667
|
+
if (callee.type === AST_NODE_TYPES6.MemberExpression) {
|
|
1668
|
+
if (!callee.computed && callee.property.type === AST_NODE_TYPES6.Identifier && NON_TEST_MEMBERS.has(callee.property.name)) {
|
|
1738
1669
|
return true;
|
|
1739
1670
|
}
|
|
1740
1671
|
return hasNonTestMember(callee.object);
|
|
1741
1672
|
}
|
|
1742
|
-
if (callee.type ===
|
|
1673
|
+
if (callee.type === AST_NODE_TYPES6.CallExpression) {
|
|
1743
1674
|
return hasNonTestMember(callee.callee);
|
|
1744
1675
|
}
|
|
1745
|
-
if (callee.type ===
|
|
1676
|
+
if (callee.type === AST_NODE_TYPES6.TaggedTemplateExpression) {
|
|
1746
1677
|
return hasNonTestMember(callee.tag);
|
|
1747
1678
|
}
|
|
1748
1679
|
return false;
|
|
1749
1680
|
}
|
|
1750
1681
|
function isTestBody(fn) {
|
|
1751
1682
|
const call = fn.parent;
|
|
1752
|
-
if (call?.type !==
|
|
1683
|
+
if (call?.type !== AST_NODE_TYPES6.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
1753
1684
|
return false;
|
|
1754
1685
|
}
|
|
1755
1686
|
if (hasNonTestMember(call.callee)) {
|
|
@@ -1795,22 +1726,22 @@ function subtreeMatches(node, predicate, descendIntoFunctions = true) {
|
|
|
1795
1726
|
}
|
|
1796
1727
|
function rootIdentifier2(node) {
|
|
1797
1728
|
switch (node.type) {
|
|
1798
|
-
case
|
|
1729
|
+
case AST_NODE_TYPES6.Identifier:
|
|
1799
1730
|
return node.name;
|
|
1800
|
-
case
|
|
1731
|
+
case AST_NODE_TYPES6.MemberExpression:
|
|
1801
1732
|
return rootIdentifier2(node.object);
|
|
1802
|
-
case
|
|
1733
|
+
case AST_NODE_TYPES6.UnaryExpression:
|
|
1803
1734
|
return rootIdentifier2(node.argument);
|
|
1804
|
-
case
|
|
1735
|
+
case AST_NODE_TYPES6.AwaitExpression:
|
|
1805
1736
|
return rootIdentifier2(node.argument);
|
|
1806
|
-
case
|
|
1807
|
-
case
|
|
1808
|
-
case
|
|
1737
|
+
case AST_NODE_TYPES6.ChainExpression:
|
|
1738
|
+
case AST_NODE_TYPES6.TSNonNullExpression:
|
|
1739
|
+
case AST_NODE_TYPES6.TSAsExpression:
|
|
1809
1740
|
return rootIdentifier2(node.expression);
|
|
1810
|
-
case
|
|
1811
|
-
case
|
|
1741
|
+
case AST_NODE_TYPES6.BinaryExpression:
|
|
1742
|
+
case AST_NODE_TYPES6.LogicalExpression:
|
|
1812
1743
|
return rootIdentifier2(node.left);
|
|
1813
|
-
case
|
|
1744
|
+
case AST_NODE_TYPES6.CallExpression:
|
|
1814
1745
|
return rootIdentifier2(node.callee);
|
|
1815
1746
|
default:
|
|
1816
1747
|
return null;
|
|
@@ -1819,26 +1750,26 @@ function rootIdentifier2(node) {
|
|
|
1819
1750
|
function calleeRootName(call) {
|
|
1820
1751
|
let current = call.callee;
|
|
1821
1752
|
for (; ; ) {
|
|
1822
|
-
if (current.type ===
|
|
1753
|
+
if (current.type === AST_NODE_TYPES6.Identifier) {
|
|
1823
1754
|
return current.name;
|
|
1824
1755
|
}
|
|
1825
|
-
if (current.type ===
|
|
1756
|
+
if (current.type === AST_NODE_TYPES6.MemberExpression) {
|
|
1826
1757
|
current = current.object;
|
|
1827
1758
|
continue;
|
|
1828
1759
|
}
|
|
1829
|
-
if (current.type ===
|
|
1760
|
+
if (current.type === AST_NODE_TYPES6.CallExpression) {
|
|
1830
1761
|
current = current.callee;
|
|
1831
1762
|
continue;
|
|
1832
1763
|
}
|
|
1833
|
-
if (current.type ===
|
|
1764
|
+
if (current.type === AST_NODE_TYPES6.ChainExpression || current.type === AST_NODE_TYPES6.TSNonNullExpression) {
|
|
1834
1765
|
current = current.expression;
|
|
1835
1766
|
continue;
|
|
1836
1767
|
}
|
|
1837
1768
|
return null;
|
|
1838
1769
|
}
|
|
1839
1770
|
}
|
|
1840
|
-
var isAssertionCall = (node) => node.type ===
|
|
1841
|
-
var isTypeAssertionCall = (node) => node.type ===
|
|
1771
|
+
var isAssertionCall = (node) => node.type === AST_NODE_TYPES6.CallExpression && ASSERTION_ROOTS.has(calleeRootName(node) ?? "");
|
|
1772
|
+
var isTypeAssertionCall = (node) => node.type === AST_NODE_TYPES6.CallExpression && TYPE_ASSERTION_ROOTS.has(calleeRootName(node) ?? "");
|
|
1842
1773
|
var containsAssertion = (node) => subtreeMatches(node, isAssertionCall);
|
|
1843
1774
|
var containsRuntimeAssertion = (node) => subtreeMatches(
|
|
1844
1775
|
node,
|
|
@@ -1846,22 +1777,22 @@ var containsRuntimeAssertion = (node) => subtreeMatches(
|
|
|
1846
1777
|
);
|
|
1847
1778
|
var containsSkipCall = (node) => subtreeMatches(
|
|
1848
1779
|
node,
|
|
1849
|
-
(current) => current.type ===
|
|
1780
|
+
(current) => current.type === AST_NODE_TYPES6.CallExpression && current.callee.type === AST_NODE_TYPES6.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES6.Identifier && current.callee.property.name === "skip"
|
|
1850
1781
|
);
|
|
1851
1782
|
var containsEscape = (node) => subtreeMatches(
|
|
1852
1783
|
node,
|
|
1853
|
-
(current) => current.type ===
|
|
1784
|
+
(current) => current.type === AST_NODE_TYPES6.ReturnStatement || current.type === AST_NODE_TYPES6.ContinueStatement || current.type === AST_NODE_TYPES6.BreakStatement || current.type === AST_NODE_TYPES6.ThrowStatement,
|
|
1854
1785
|
false
|
|
1855
1786
|
);
|
|
1856
1787
|
function branchStatements(branch) {
|
|
1857
|
-
return branch.type ===
|
|
1788
|
+
return branch.type === AST_NODE_TYPES6.BlockStatement ? branch.body : [branch];
|
|
1858
1789
|
}
|
|
1859
1790
|
function previousSibling(node) {
|
|
1860
1791
|
const parent = node.parent;
|
|
1861
1792
|
let siblings = null;
|
|
1862
|
-
if (parent.type ===
|
|
1793
|
+
if (parent.type === AST_NODE_TYPES6.BlockStatement || parent.type === AST_NODE_TYPES6.Program || parent.type === AST_NODE_TYPES6.StaticBlock) {
|
|
1863
1794
|
siblings = parent.body;
|
|
1864
|
-
} else if (parent.type ===
|
|
1795
|
+
} else if (parent.type === AST_NODE_TYPES6.SwitchCase) {
|
|
1865
1796
|
siblings = parent.consequent;
|
|
1866
1797
|
}
|
|
1867
1798
|
if (siblings === null) {
|
|
@@ -1876,12 +1807,12 @@ function isPinnedNarrowingGuard(node) {
|
|
|
1876
1807
|
return false;
|
|
1877
1808
|
}
|
|
1878
1809
|
const previous = previousSibling(node);
|
|
1879
|
-
if (previous === null || previous.type !==
|
|
1810
|
+
if (previous === null || previous.type !== AST_NODE_TYPES6.ExpressionStatement) {
|
|
1880
1811
|
return false;
|
|
1881
1812
|
}
|
|
1882
1813
|
let matched = false;
|
|
1883
1814
|
subtreeMatches(previous, (current) => {
|
|
1884
|
-
if (current.type !==
|
|
1815
|
+
if (current.type !== AST_NODE_TYPES6.CallExpression || !ASSERTION_ROOTS.has(calleeRootName(current) ?? "")) {
|
|
1885
1816
|
return false;
|
|
1886
1817
|
}
|
|
1887
1818
|
const subject = current.arguments[0];
|
|
@@ -1901,12 +1832,12 @@ function isThrowingGuard(node) {
|
|
|
1901
1832
|
return false;
|
|
1902
1833
|
}
|
|
1903
1834
|
const statements = branchStatements(node.consequent);
|
|
1904
|
-
return statements.length === 1 && statements[0]?.type ===
|
|
1835
|
+
return statements.length === 1 && statements[0]?.type === AST_NODE_TYPES6.ThrowStatement;
|
|
1905
1836
|
}
|
|
1906
1837
|
function isTypeAssertionBranch(branch) {
|
|
1907
1838
|
const statements = branchStatements(branch);
|
|
1908
1839
|
return statements.length > 0 && statements.every(
|
|
1909
|
-
(statement) => statement.type ===
|
|
1840
|
+
(statement) => statement.type === AST_NODE_TYPES6.ExpressionStatement && isTypeAssertionCall(statement.expression)
|
|
1910
1841
|
);
|
|
1911
1842
|
}
|
|
1912
1843
|
function isTypeLevelNarrowing(node) {
|
|
@@ -1914,17 +1845,17 @@ function isTypeLevelNarrowing(node) {
|
|
|
1914
1845
|
}
|
|
1915
1846
|
var isInertBranch = (branch) => !containsAssertion(branch) && !containsEscape(branch) && !containsSkipCall(branch);
|
|
1916
1847
|
function isNormalizationStatement(statement) {
|
|
1917
|
-
if (statement.type ===
|
|
1848
|
+
if (statement.type === AST_NODE_TYPES6.VariableDeclaration) {
|
|
1918
1849
|
return true;
|
|
1919
1850
|
}
|
|
1920
|
-
if (statement.type ===
|
|
1851
|
+
if (statement.type === AST_NODE_TYPES6.BlockStatement) {
|
|
1921
1852
|
return statement.body.every(isNormalizationStatement);
|
|
1922
1853
|
}
|
|
1923
|
-
if (statement.type !==
|
|
1854
|
+
if (statement.type !== AST_NODE_TYPES6.ExpressionStatement) {
|
|
1924
1855
|
return false;
|
|
1925
1856
|
}
|
|
1926
1857
|
const { expression } = statement;
|
|
1927
|
-
return expression.type ===
|
|
1858
|
+
return expression.type === AST_NODE_TYPES6.AssignmentExpression || expression.type === AST_NODE_TYPES6.UpdateExpression || expression.type === AST_NODE_TYPES6.UnaryExpression && expression.operator === "delete";
|
|
1928
1859
|
}
|
|
1929
1860
|
function isInertNormalization(node) {
|
|
1930
1861
|
const branches = [node.consequent, node.alternate].filter(
|
|
@@ -1962,7 +1893,7 @@ function conditionalSkipsAssertion(node) {
|
|
|
1962
1893
|
return consequent !== alternate;
|
|
1963
1894
|
}
|
|
1964
1895
|
function isShortCircuitedAssertion(node) {
|
|
1965
|
-
return node.operator !== "??" && node.parent.type ===
|
|
1896
|
+
return node.operator !== "??" && node.parent.type === AST_NODE_TYPES6.ExpressionStatement && containsAssertion(node.right);
|
|
1966
1897
|
}
|
|
1967
1898
|
var no_conditional_in_test_default = createRule({
|
|
1968
1899
|
name: "no-conditional-in-test",
|
|
@@ -2013,7 +1944,10 @@ var no_conditional_in_test_default = createRule({
|
|
|
2013
1944
|
});
|
|
2014
1945
|
|
|
2015
1946
|
// src/rules/no-cors-wildcard-with-credentials.ts
|
|
2016
|
-
import
|
|
1947
|
+
import {
|
|
1948
|
+
AST_NODE_TYPES as AST_NODE_TYPES7,
|
|
1949
|
+
ASTUtils as ASTUtils2
|
|
1950
|
+
} from "@typescript-eslint/utils";
|
|
2017
1951
|
var noCorsWildcardWithCredentialsDocumentation = {
|
|
2018
1952
|
summary: "Disallow wildcard CORS origins when credentials are enabled.",
|
|
2019
1953
|
rationale: "Reflecting every origin while allowing credentials can let an untrusted site read authenticated cross-origin responses.",
|
|
@@ -2200,12 +2134,44 @@ var no_cors_wildcard_with_credentials_default = createRule({
|
|
|
2200
2134
|
defaultOptions: [],
|
|
2201
2135
|
create(context) {
|
|
2202
2136
|
const scopeHeaderSets = /* @__PURE__ */ new Map();
|
|
2137
|
+
const variableIds = /* @__PURE__ */ new WeakMap();
|
|
2138
|
+
let nextVariableId = 0;
|
|
2139
|
+
function variableId(variable) {
|
|
2140
|
+
const existing = variableIds.get(variable);
|
|
2141
|
+
if (existing !== void 0) return existing;
|
|
2142
|
+
const value = nextVariableId++;
|
|
2143
|
+
variableIds.set(variable, value);
|
|
2144
|
+
return value;
|
|
2145
|
+
}
|
|
2146
|
+
function receiverIdentity(node) {
|
|
2147
|
+
if (node.type === AST_NODE_TYPES7.Identifier) {
|
|
2148
|
+
const variable = ASTUtils2.findVariable(
|
|
2149
|
+
context.sourceCode.getScope(node),
|
|
2150
|
+
node.name
|
|
2151
|
+
);
|
|
2152
|
+
return variable === null ? `global:${node.name}` : `variable:${variableId(variable)}`;
|
|
2153
|
+
}
|
|
2154
|
+
if (node.type === AST_NODE_TYPES7.ThisExpression) return "this";
|
|
2155
|
+
if (node.type === AST_NODE_TYPES7.MemberExpression && !node.computed && node.property.type === AST_NODE_TYPES7.Identifier) {
|
|
2156
|
+
const owner = receiverIdentity(node.object);
|
|
2157
|
+
return owner === null ? null : `${owner}.${node.property.name}`;
|
|
2158
|
+
}
|
|
2159
|
+
return null;
|
|
2160
|
+
}
|
|
2203
2161
|
function recordHeaderSet(node, kind) {
|
|
2162
|
+
if (node.callee.type !== AST_NODE_TYPES7.MemberExpression) return;
|
|
2163
|
+
const receiver = receiverIdentity(node.callee.object);
|
|
2164
|
+
if (receiver === null) return;
|
|
2204
2165
|
const key = enclosingScope(node) ?? "module";
|
|
2205
|
-
let
|
|
2166
|
+
let receivers = scopeHeaderSets.get(key);
|
|
2167
|
+
if (receivers === void 0) {
|
|
2168
|
+
receivers = /* @__PURE__ */ new Map();
|
|
2169
|
+
scopeHeaderSets.set(key, receivers);
|
|
2170
|
+
}
|
|
2171
|
+
let entry = receivers.get(receiver);
|
|
2206
2172
|
if (entry === void 0) {
|
|
2207
2173
|
entry = { originNodes: [], credentialsNodes: [] };
|
|
2208
|
-
|
|
2174
|
+
receivers.set(receiver, entry);
|
|
2209
2175
|
}
|
|
2210
2176
|
if (kind === "origin") {
|
|
2211
2177
|
entry.originNodes.push(node);
|
|
@@ -2235,13 +2201,15 @@ var no_cors_wildcard_with_credentials_default = createRule({
|
|
|
2235
2201
|
}
|
|
2236
2202
|
},
|
|
2237
2203
|
"Program:exit"() {
|
|
2238
|
-
for (const
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2204
|
+
for (const receivers of scopeHeaderSets.values()) {
|
|
2205
|
+
for (const { originNodes, credentialsNodes } of receivers.values()) {
|
|
2206
|
+
if (originNodes.length > 0 && credentialsNodes.length > 0) {
|
|
2207
|
+
for (const node of originNodes) {
|
|
2208
|
+
context.report({
|
|
2209
|
+
node,
|
|
2210
|
+
messageId: "corsWildcardWithCredentials"
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2245
2213
|
}
|
|
2246
2214
|
}
|
|
2247
2215
|
}
|
|
@@ -3263,7 +3231,7 @@ var noHandRolledSpinnerDocumentation = {
|
|
|
3263
3231
|
};
|
|
3264
3232
|
var DESIGN_SYSTEM_PATH = /(?:^|[/\\])components[/\\]ui[/\\]/u;
|
|
3265
3233
|
var BORDER_WIDTH = /^border(?:-[0-9]+)?$/u;
|
|
3266
|
-
var
|
|
3234
|
+
var CONTRASTING_EDGE = /^border-[trbl]-(?!0$|[0-9]+$).+/u;
|
|
3267
3235
|
function staticClassName(attribute) {
|
|
3268
3236
|
const value = attribute.value;
|
|
3269
3237
|
if (value?.type === AST_NODE_TYPES12.Literal && typeof value.value === "string") {
|
|
@@ -3272,6 +3240,9 @@ function staticClassName(attribute) {
|
|
|
3272
3240
|
if (value?.type === AST_NODE_TYPES12.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES12.Literal && typeof value.expression.value === "string") {
|
|
3273
3241
|
return value.expression.value;
|
|
3274
3242
|
}
|
|
3243
|
+
if (value?.type === AST_NODE_TYPES12.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES12.TemplateLiteral && value.expression.expressions.length === 0) {
|
|
3244
|
+
return value.expression.quasis[0]?.value.cooked ?? null;
|
|
3245
|
+
}
|
|
3275
3246
|
return null;
|
|
3276
3247
|
}
|
|
3277
3248
|
var no_hand_rolled_spinner_default = createRule({
|
|
@@ -3304,7 +3275,7 @@ var no_hand_rolled_spinner_default = createRule({
|
|
|
3304
3275
|
const className = staticClassName(classNameAttribute);
|
|
3305
3276
|
if (className === null) return;
|
|
3306
3277
|
const classes = className.split(/\s+/u);
|
|
3307
|
-
if (classes.includes("animate-spin") && classes.includes("rounded-full") && classes.some((token) => BORDER_WIDTH.test(token)) && classes.some((token) =>
|
|
3278
|
+
if (classes.includes("animate-spin") && classes.includes("rounded-full") && classes.some((token) => BORDER_WIDTH.test(token)) && classes.some((token) => CONTRASTING_EDGE.test(token))) {
|
|
3308
3279
|
context.report({ node, messageId: "handRolledSpinner" });
|
|
3309
3280
|
}
|
|
3310
3281
|
}
|
|
@@ -3326,7 +3297,7 @@ var noInsecureRandomIdDocumentation = {
|
|
|
3326
3297
|
]
|
|
3327
3298
|
};
|
|
3328
3299
|
var STRONG_SECURITY_PATTERN = /token|secret|csrf|password|passwd|apikey|api[-_]?key|nonce|salt|uuid|authid/i;
|
|
3329
|
-
var NON_SECURITY_ID_PATTERN = /temp|tmp|cache|correlation|request|req|trace|execution|dev|hmr|mock|test|perf|marker/i;
|
|
3300
|
+
var NON_SECURITY_ID_PATTERN = /temp|tmp|cache|correlation|request|req|trace|execution|dev|hmr|mock|test|perf|marker|dialog|select|menu|tab|field|input|form|element|dom|aria|component/i;
|
|
3330
3301
|
var PATH_OR_DOM_MARKER = /[\\/#]|\.[A-Za-z0-9]/;
|
|
3331
3302
|
function isMathRandomCall(node) {
|
|
3332
3303
|
if (node.type !== "CallExpression") {
|
|
@@ -4013,7 +3984,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
|
|
|
4013
3984
|
});
|
|
4014
3985
|
|
|
4015
3986
|
// src/rules/no-log-only-catch.ts
|
|
4016
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES14, ASTUtils as
|
|
3987
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14, ASTUtils as ASTUtils3 } from "@typescript-eslint/utils";
|
|
4017
3988
|
|
|
4018
3989
|
// src/rules/_logging.ts
|
|
4019
3990
|
import "@typescript-eslint/utils";
|
|
@@ -4185,7 +4156,7 @@ function seededFallbackHandled(tryStatement, scope) {
|
|
|
4185
4156
|
if (previous.declarations.length !== 1 || declarator === void 0) return false;
|
|
4186
4157
|
if (declarator.id.type !== AST_NODE_TYPES14.Identifier) return false;
|
|
4187
4158
|
if (declarator.init == null || !isSeedValue(declarator.init)) return false;
|
|
4188
|
-
const variable =
|
|
4159
|
+
const variable = ASTUtils3.findVariable(scope, declarator.id.name);
|
|
4189
4160
|
if (variable === null) return false;
|
|
4190
4161
|
const [tryStart, tryEnd] = tryStatement.block.range;
|
|
4191
4162
|
let writtenInTry = false;
|
|
@@ -4453,7 +4424,7 @@ var no_long_comment_default = createRule({
|
|
|
4453
4424
|
});
|
|
4454
4425
|
|
|
4455
4426
|
// src/rules/no-generic-single-export-module.ts
|
|
4456
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES17, ASTUtils as
|
|
4427
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES17, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
|
|
4457
4428
|
var noGenericSingleExportModuleDocumentation = {
|
|
4458
4429
|
summary: "Disallow generic module stems when one runtime export already names the responsibility.",
|
|
4459
4430
|
rationale: "A generic filename hides the sole exported responsibility and makes navigation less descriptive.",
|
|
@@ -4614,7 +4585,7 @@ function kebabCase(name) {
|
|
|
4614
4585
|
return name.replaceAll(/oauth/giu, "Oauth").replaceAll(/graphql/giu, "Graphql").replaceAll(/grpc/giu, "Grpc").replaceAll(/([a-z\d])([A-Z])/gu, "$1-$2").replaceAll(/([A-Z]+)([A-Z][a-z])/gu, "$1-$2").replaceAll(/[_\s]+/gu, "-").replaceAll(/-+/gu, "-").replaceAll(/^-|-$/gu, "").toLowerCase();
|
|
4615
4586
|
}
|
|
4616
4587
|
function isGlobalIdentifier(context, node) {
|
|
4617
|
-
const variable =
|
|
4588
|
+
const variable = ASTUtils4.findVariable(context.sourceCode.getScope(node), node.name);
|
|
4618
4589
|
return variable === null || variable.defs.length === 0;
|
|
4619
4590
|
}
|
|
4620
4591
|
function isConventionalFrameworkUtility(filename, exported) {
|
|
@@ -5142,7 +5113,7 @@ var no_raw_env_default = createRule({
|
|
|
5142
5113
|
});
|
|
5143
5114
|
|
|
5144
5115
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
5145
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES19 } from "@typescript-eslint/utils";
|
|
5116
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES19, ASTUtils as ASTUtils5 } from "@typescript-eslint/utils";
|
|
5146
5117
|
var noRawFetchOutsideClientsDocumentation = {
|
|
5147
5118
|
summary: "Disallow calling the global `fetch` outside the client layer; route outbound HTTP through a client module that owns retry, timeout and status handling.",
|
|
5148
5119
|
rationale: "Scattered fetch calls bypass shared transport policy and are harder to stub and observe consistently.",
|
|
@@ -5174,19 +5145,75 @@ var GLOBAL_RECEIVERS = /* @__PURE__ */ new Set([
|
|
|
5174
5145
|
"self"
|
|
5175
5146
|
]);
|
|
5176
5147
|
var PRESIGNED_URL_NAME_RE = /(?:pre-?signed|signed|upload|download)Url$/i;
|
|
5177
|
-
|
|
5148
|
+
var INTERNAL_MUTATION_METHODS = /* @__PURE__ */ new Set([
|
|
5149
|
+
"POST",
|
|
5150
|
+
"PUT",
|
|
5151
|
+
"DELETE",
|
|
5152
|
+
"PATCH"
|
|
5153
|
+
]);
|
|
5154
|
+
var ANALYTICS_SEGMENTS2 = /* @__PURE__ */ new Set([
|
|
5155
|
+
"analytics",
|
|
5156
|
+
"telemetry",
|
|
5157
|
+
"track",
|
|
5158
|
+
"log",
|
|
5159
|
+
"ping",
|
|
5160
|
+
"beacon",
|
|
5161
|
+
"metrics",
|
|
5162
|
+
"event"
|
|
5163
|
+
]);
|
|
5164
|
+
var SERVER_ACTION_SKIP_FILE_RE = /(?:\.test\.[jt]sx?$|\.spec\.[jt]sx?$|-(?:test|spec)\.[jt]sx?$|\/tests?\/|\/__tests__\/|\/__testfixtures__\/|\/scripts?\/|\/app\/api\/.*\/route\.[jt]sx?$|\/pages\/api\/)/;
|
|
5165
|
+
var NON_REACT_FRAMEWORK_RE = /^(?:@angular\/|@nestjs\/|vue$|vue\/|svelte$|svelte\/|solid-js$|solid-js\/|@ember\/|rxjs$|rxjs\/)/;
|
|
5166
|
+
function isGlobalFetchCall(node, resolvesToGlobal) {
|
|
5178
5167
|
const callee = node.callee;
|
|
5179
5168
|
if (callee.type === "Identifier") {
|
|
5180
|
-
return callee.name === "fetch";
|
|
5169
|
+
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
5181
5170
|
}
|
|
5182
5171
|
if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && callee.property.name === "fetch" && callee.object.type === "Identifier") {
|
|
5183
|
-
return GLOBAL_RECEIVERS.has(callee.object.name);
|
|
5172
|
+
return GLOBAL_RECEIVERS.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
5184
5173
|
}
|
|
5185
5174
|
return false;
|
|
5186
5175
|
}
|
|
5187
|
-
function isConstructedArgumentHandoff(node) {
|
|
5176
|
+
function isConstructedArgumentHandoff(node, resolvesToGlobal) {
|
|
5188
5177
|
const [first] = node.arguments;
|
|
5189
|
-
return node.arguments.length === 1 && first !== void 0 && first.type === AST_NODE_TYPES19.NewExpression;
|
|
5178
|
+
return node.arguments.length === 1 && first !== void 0 && first.type === AST_NODE_TYPES19.NewExpression && first.callee.type === AST_NODE_TYPES19.Identifier && (first.callee.name === "URL" || first.callee.name === "Request") && resolvesToGlobal(first.callee);
|
|
5179
|
+
}
|
|
5180
|
+
function effectOwns(node) {
|
|
5181
|
+
if (node.callee.type !== AST_NODE_TYPES19.Identifier) return false;
|
|
5182
|
+
const method = readDirectMethod(node);
|
|
5183
|
+
if (method !== null && method !== "GET") return false;
|
|
5184
|
+
const first = node.arguments[0];
|
|
5185
|
+
let url = "";
|
|
5186
|
+
if (first?.type === AST_NODE_TYPES19.Literal && typeof first.value === "string") {
|
|
5187
|
+
url = first.value;
|
|
5188
|
+
} else if (first?.type === AST_NODE_TYPES19.TemplateLiteral) {
|
|
5189
|
+
url = first.quasis.map((quasi) => quasi.value.cooked).join("");
|
|
5190
|
+
} else if (first?.type === AST_NODE_TYPES19.Identifier) {
|
|
5191
|
+
url = first.name;
|
|
5192
|
+
}
|
|
5193
|
+
if (url !== "" && url.toLowerCase().split(/[/.]/).some((segment) => ANALYTICS_SEGMENTS2.has(segment))) {
|
|
5194
|
+
return false;
|
|
5195
|
+
}
|
|
5196
|
+
for (let current = node.parent; current != null; current = current.parent) {
|
|
5197
|
+
if (current.type !== AST_NODE_TYPES19.CallExpression) continue;
|
|
5198
|
+
const callee = current.callee;
|
|
5199
|
+
const isEffect = callee.type === AST_NODE_TYPES19.Identifier && (callee.name === "useEffect" || callee.name === "useLayoutEffect") || callee.type === AST_NODE_TYPES19.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES19.Identifier && callee.object.name === "React" && callee.property.type === AST_NODE_TYPES19.Identifier && (callee.property.name === "useEffect" || callee.property.name === "useLayoutEffect");
|
|
5200
|
+
if (!isEffect) continue;
|
|
5201
|
+
const callback = current.arguments[0];
|
|
5202
|
+
return callback !== void 0 && callback.type !== AST_NODE_TYPES19.SpreadElement && node.range[0] >= callback.range[0] && node.range[1] <= callback.range[1];
|
|
5203
|
+
}
|
|
5204
|
+
return false;
|
|
5205
|
+
}
|
|
5206
|
+
function readDirectMethod(node) {
|
|
5207
|
+
const init = node.arguments[1];
|
|
5208
|
+
if (init?.type !== AST_NODE_TYPES19.ObjectExpression) return null;
|
|
5209
|
+
for (const property of init.properties) {
|
|
5210
|
+
if (property.type !== AST_NODE_TYPES19.Property || property.computed) continue;
|
|
5211
|
+
const key = property.key;
|
|
5212
|
+
const isMethod = key.type === AST_NODE_TYPES19.Identifier && key.name === "method" || key.type === AST_NODE_TYPES19.Literal && key.value === "method";
|
|
5213
|
+
if (!isMethod) continue;
|
|
5214
|
+
return property.value.type === AST_NODE_TYPES19.Literal && typeof property.value.value === "string" ? property.value.value.toUpperCase() : null;
|
|
5215
|
+
}
|
|
5216
|
+
return null;
|
|
5190
5217
|
}
|
|
5191
5218
|
function isPresignedUrlTransfer(node) {
|
|
5192
5219
|
const first = node.arguments[0];
|
|
@@ -5248,24 +5275,93 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
5248
5275
|
}
|
|
5249
5276
|
const patterns = options?.allow ?? DEFAULT_ALLOW;
|
|
5250
5277
|
const allowed = compile(patterns);
|
|
5278
|
+
const nonReactFramework = context.sourceCode.ast.body.some(
|
|
5279
|
+
(statement) => statement.type === AST_NODE_TYPES19.ImportDeclaration && typeof statement.source.value === "string" && NON_REACT_FRAMEWORK_RE.test(statement.source.value)
|
|
5280
|
+
);
|
|
5281
|
+
function resolvesToGlobal(identifier) {
|
|
5282
|
+
const variable = ASTUtils5.findVariable(
|
|
5283
|
+
context.sourceCode.getScope(identifier),
|
|
5284
|
+
identifier.name
|
|
5285
|
+
);
|
|
5286
|
+
return variable === null || variable.defs.length === 0;
|
|
5287
|
+
}
|
|
5288
|
+
function resolveNode2(node) {
|
|
5289
|
+
if (node === void 0) return null;
|
|
5290
|
+
if (node.type !== AST_NODE_TYPES19.Identifier) return node;
|
|
5291
|
+
const variable = ASTUtils5.findVariable(
|
|
5292
|
+
context.sourceCode.getScope(node),
|
|
5293
|
+
node.name
|
|
5294
|
+
);
|
|
5295
|
+
if (variable?.defs.length !== 1) return node;
|
|
5296
|
+
const definition = variable.defs[0];
|
|
5297
|
+
return definition?.type === "Variable" && definition.node.init !== null ? definition.node.init : node;
|
|
5298
|
+
}
|
|
5299
|
+
function propertyValue(node, name) {
|
|
5300
|
+
if (node?.type !== AST_NODE_TYPES19.ObjectExpression) return null;
|
|
5301
|
+
for (const property of node.properties) {
|
|
5302
|
+
if (property.type !== AST_NODE_TYPES19.Property || property.computed) continue;
|
|
5303
|
+
const key = property.key;
|
|
5304
|
+
const keyName = key.type === AST_NODE_TYPES19.Identifier ? key.name : key.type === AST_NODE_TYPES19.Literal && typeof key.value === "string" ? key.value : null;
|
|
5305
|
+
if (keyName !== name) continue;
|
|
5306
|
+
return property.value.type === AST_NODE_TYPES19.AssignmentPattern || property.value.type === AST_NODE_TYPES19.ArrayPattern || property.value.type === AST_NODE_TYPES19.ObjectPattern ? null : property.value;
|
|
5307
|
+
}
|
|
5308
|
+
return null;
|
|
5309
|
+
}
|
|
5310
|
+
function isInternalApiUrl(node) {
|
|
5311
|
+
const resolved = resolveNode2(node ?? void 0);
|
|
5312
|
+
if (resolved?.type === AST_NODE_TYPES19.Literal) {
|
|
5313
|
+
return typeof resolved.value === "string" && resolved.value.startsWith("/api/");
|
|
5314
|
+
}
|
|
5315
|
+
if (resolved?.type === AST_NODE_TYPES19.TemplateLiteral) {
|
|
5316
|
+
return resolved.quasis[0]?.value.cooked?.startsWith("/api/") === true;
|
|
5317
|
+
}
|
|
5318
|
+
return resolved?.type === AST_NODE_TYPES19.BinaryExpression && resolved.operator === "+" && isInternalApiUrl(resolved.left);
|
|
5319
|
+
}
|
|
5320
|
+
function isMutationMethod2(node) {
|
|
5321
|
+
const resolved = resolveNode2(node ?? void 0);
|
|
5322
|
+
if (resolved?.type === AST_NODE_TYPES19.Literal) {
|
|
5323
|
+
return typeof resolved.value === "string" && INTERNAL_MUTATION_METHODS.has(resolved.value.toUpperCase());
|
|
5324
|
+
}
|
|
5325
|
+
if (resolved?.type === AST_NODE_TYPES19.TemplateLiteral && resolved.expressions.length === 0) {
|
|
5326
|
+
return INTERNAL_MUTATION_METHODS.has(
|
|
5327
|
+
resolved.quasis.map((quasi) => quasi.value.cooked).join("").toUpperCase()
|
|
5328
|
+
);
|
|
5329
|
+
}
|
|
5330
|
+
if (resolved?.type === AST_NODE_TYPES19.ConditionalExpression) {
|
|
5331
|
+
return isMutationMethod2(resolved.consequent) || isMutationMethod2(resolved.alternate);
|
|
5332
|
+
}
|
|
5333
|
+
return resolved?.type === AST_NODE_TYPES19.LogicalExpression && resolved.operator === "||" && (isMutationMethod2(resolved.left) || isMutationMethod2(resolved.right));
|
|
5334
|
+
}
|
|
5335
|
+
function serverActionOwns(node) {
|
|
5336
|
+
if (node.callee.type !== AST_NODE_TYPES19.Identifier || SERVER_ACTION_SKIP_FILE_RE.test(filename) || nonReactFramework) {
|
|
5337
|
+
return false;
|
|
5338
|
+
}
|
|
5339
|
+
const url = node.arguments[0];
|
|
5340
|
+
const init = node.arguments[1];
|
|
5341
|
+
if (url === void 0 || url.type === AST_NODE_TYPES19.SpreadElement || init === void 0 || init.type === AST_NODE_TYPES19.SpreadElement || !isInternalApiUrl(url)) {
|
|
5342
|
+
return false;
|
|
5343
|
+
}
|
|
5344
|
+
return isMutationMethod2(propertyValue(resolveNode2(init), "method"));
|
|
5345
|
+
}
|
|
5251
5346
|
if (allowed.some((re) => re.test(filename))) {
|
|
5252
5347
|
return {};
|
|
5253
5348
|
}
|
|
5254
5349
|
return {
|
|
5255
5350
|
CallExpression(node) {
|
|
5256
|
-
if (
|
|
5351
|
+
if (!isGlobalFetchCall(node, resolvesToGlobal)) {
|
|
5257
5352
|
return;
|
|
5258
5353
|
}
|
|
5259
|
-
if (
|
|
5260
|
-
|
|
5354
|
+
if (isPresignedUrlTransfer(node) || isConstructedArgumentHandoff(node, resolvesToGlobal) || effectOwns(node) || serverActionOwns(node)) {
|
|
5355
|
+
return;
|
|
5261
5356
|
}
|
|
5357
|
+
context.report({ node, messageId: "rawFetch" });
|
|
5262
5358
|
}
|
|
5263
5359
|
};
|
|
5264
5360
|
}
|
|
5265
5361
|
});
|
|
5266
5362
|
|
|
5267
5363
|
// src/rules/no-restricted-library-load.ts
|
|
5268
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES20, ASTUtils as
|
|
5364
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES20, ASTUtils as ASTUtils6 } from "@typescript-eslint/utils";
|
|
5269
5365
|
var noRestrictedLibraryLoadDocumentation = {
|
|
5270
5366
|
summary: "Apply a configured library-replacement policy to literal dynamic imports, CommonJS loads, and TypeScript import-equals declarations.",
|
|
5271
5367
|
rationale: "Runtime module loads can bypass the replacement policy enforced for static imports.",
|
|
@@ -5338,7 +5434,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
5338
5434
|
});
|
|
5339
5435
|
}
|
|
5340
5436
|
function isUnshadowedRequire(node) {
|
|
5341
|
-
const variable =
|
|
5437
|
+
const variable = ASTUtils6.findVariable(
|
|
5342
5438
|
context.sourceCode.getScope(node),
|
|
5343
5439
|
node.name
|
|
5344
5440
|
);
|
|
@@ -6682,8 +6778,16 @@ var noSilentPromiseCatchDocumentation = {
|
|
|
6682
6778
|
{ id: "silent-rejection", title: "Do not swallow the rejection", outcome: "match", files: [{ path: "src/load.ts", source: "load().catch(() => null);" }], focusPath: "src/load.ts", expectedCount: 1, public: true }
|
|
6683
6779
|
]
|
|
6684
6780
|
};
|
|
6781
|
+
var BODY_PARSE_METHODS = /* @__PURE__ */ new Set([
|
|
6782
|
+
"arrayBuffer",
|
|
6783
|
+
"blob",
|
|
6784
|
+
"bytes",
|
|
6785
|
+
"formData",
|
|
6786
|
+
"json",
|
|
6787
|
+
"text"
|
|
6788
|
+
]);
|
|
6685
6789
|
function isBodyParseCall(node) {
|
|
6686
|
-
return node.type === AST_NODE_TYPES25.CallExpression && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES25.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES25.Identifier && (node.callee.property.name
|
|
6790
|
+
return node.type === AST_NODE_TYPES25.CallExpression && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES25.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES25.Identifier && BODY_PARSE_METHODS.has(node.callee.property.name);
|
|
6687
6791
|
}
|
|
6688
6792
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
6689
6793
|
"cancel",
|
|
@@ -8336,7 +8440,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
8336
8440
|
// src/rules/no-unsafe-mock-casting.ts
|
|
8337
8441
|
import {
|
|
8338
8442
|
AST_NODE_TYPES as AST_NODE_TYPES34,
|
|
8339
|
-
ASTUtils as
|
|
8443
|
+
ASTUtils as ASTUtils7
|
|
8340
8444
|
} from "@typescript-eslint/utils";
|
|
8341
8445
|
var MOCK_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
8342
8446
|
"Mock",
|
|
@@ -8398,7 +8502,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
8398
8502
|
const directBindings = /* @__PURE__ */ new Set();
|
|
8399
8503
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
8400
8504
|
function resolve(identifier) {
|
|
8401
|
-
return
|
|
8505
|
+
return ASTUtils7.findVariable(
|
|
8402
8506
|
context.sourceCode.getScope(identifier),
|
|
8403
8507
|
identifier.name
|
|
8404
8508
|
);
|
|
@@ -8659,7 +8763,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
8659
8763
|
});
|
|
8660
8764
|
|
|
8661
8765
|
// src/rules/test-loops-over-literal-cases.ts
|
|
8662
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES36, ASTUtils as
|
|
8766
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36, ASTUtils as ASTUtils8 } from "@typescript-eslint/utils";
|
|
8663
8767
|
var testLoopsOverLiteralCasesDocumentation = {
|
|
8664
8768
|
summary: "Disallow assertions over an inline literal case loop in a test; parameterization reports and names every case independently.",
|
|
8665
8769
|
rationale: "A loop is reported as one test, so failures hide the individual case name and may stop later cases from running.",
|
|
@@ -8822,7 +8926,7 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
8822
8926
|
return {};
|
|
8823
8927
|
}
|
|
8824
8928
|
const isFrameworkIdentifier = (identifier, modules) => {
|
|
8825
|
-
const variable =
|
|
8929
|
+
const variable = ASTUtils8.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
8826
8930
|
if (variable === null || variable.defs.length === 0) return true;
|
|
8827
8931
|
return variable.defs.some((definition) => {
|
|
8828
8932
|
let current = definition.node;
|
|
@@ -9237,7 +9341,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
9237
9341
|
});
|
|
9238
9342
|
|
|
9239
9343
|
// src/rules/prefer-immutable-module-constant.ts
|
|
9240
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES40, ASTUtils as
|
|
9344
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40, ASTUtils as ASTUtils9 } from "@typescript-eslint/utils";
|
|
9241
9345
|
var preferImmutableModuleConstantDocumentation = {
|
|
9242
9346
|
summary: "Require module-level constant collections to expose readonly state.",
|
|
9243
9347
|
rationale: "A const binding prevents reassignment but does not stop callers from mutating its array, object, Set, or Map contents.",
|
|
@@ -9390,7 +9494,7 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
9390
9494
|
create(context) {
|
|
9391
9495
|
const sourceCode = context.sourceCode;
|
|
9392
9496
|
const isUnshadowedGlobal = (identifier) => {
|
|
9393
|
-
const variable =
|
|
9497
|
+
const variable = ASTUtils9.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
9394
9498
|
return variable === null || variable.defs.length === 0;
|
|
9395
9499
|
};
|
|
9396
9500
|
if (JAVASCRIPT_FILE_RE.test(context.filename) || isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
@@ -10268,7 +10372,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
10268
10372
|
});
|
|
10269
10373
|
|
|
10270
10374
|
// src/rules/prefer-native-random-uuid.ts
|
|
10271
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES44, ASTUtils as
|
|
10375
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44, ASTUtils as ASTUtils10 } from "@typescript-eslint/utils";
|
|
10272
10376
|
var preferNativeRandomUuidDocumentation = {
|
|
10273
10377
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
10274
10378
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -10304,7 +10408,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
10304
10408
|
const directBindings = /* @__PURE__ */ new Set();
|
|
10305
10409
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
10306
10410
|
function resolve(identifier) {
|
|
10307
|
-
return
|
|
10411
|
+
return ASTUtils10.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
10308
10412
|
}
|
|
10309
10413
|
function record(identifier, destination) {
|
|
10310
10414
|
const variable = resolve(identifier);
|
|
@@ -10367,7 +10471,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
10367
10471
|
});
|
|
10368
10472
|
|
|
10369
10473
|
// src/rules/prefer-non-nullable-collection.ts
|
|
10370
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES45, ASTUtils as
|
|
10474
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45, ASTUtils as ASTUtils11 } from "@typescript-eslint/utils";
|
|
10371
10475
|
var preferNonNullableCollectionDocumentation = {
|
|
10372
10476
|
summary: "Suggest non-null arrays only when local control flow proves the nullish state is equivalent to an empty collection.",
|
|
10373
10477
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
@@ -10497,14 +10601,14 @@ function directlyCoalesced(node) {
|
|
|
10497
10601
|
return parent?.type === AST_NODE_TYPES45.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
10498
10602
|
}
|
|
10499
10603
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
10500
|
-
const variable =
|
|
10604
|
+
const variable = ASTUtils11.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
10501
10605
|
if (variable === null || variable.references.length === 0) return false;
|
|
10502
10606
|
return variable.references.every(
|
|
10503
10607
|
(reference) => belongsToFunction(reference.identifier, fn) && directlyCoalesced(reference.identifier)
|
|
10504
10608
|
);
|
|
10505
10609
|
}
|
|
10506
10610
|
function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
10507
|
-
const variable =
|
|
10611
|
+
const variable = ASTUtils11.findVariable(context.sourceCode.getScope(object), object.name);
|
|
10508
10612
|
if (variable === null) return false;
|
|
10509
10613
|
const accesses = variable.references.flatMap((reference) => {
|
|
10510
10614
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
@@ -11510,7 +11614,7 @@ var preferServerActionsDocumentation = {
|
|
|
11510
11614
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
11511
11615
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
11512
11616
|
var SKIP_FILE_REGEX = /(?:\.test\.[jt]sx?$|\.spec\.[jt]sx?$|-(?:test|spec)\.[jt]sx?$|\/tests?\/|\/__tests__\/|\/__testfixtures__\/|\/scripts?\/|\/app\/api\/.*\/route\.[jt]sx?$|\/pages\/api\/)/;
|
|
11513
|
-
var
|
|
11617
|
+
var NON_REACT_FRAMEWORK_RE2 = /^(?:@angular\/|@nestjs\/|vue$|vue\/|svelte$|svelte\/|solid-js$|solid-js\/|@ember\/|rxjs$|rxjs\/)/;
|
|
11514
11618
|
function getScope(context, node) {
|
|
11515
11619
|
return context.sourceCode.getScope(node);
|
|
11516
11620
|
}
|
|
@@ -11622,7 +11726,7 @@ var prefer_server_actions_default = createRule({
|
|
|
11622
11726
|
return {};
|
|
11623
11727
|
}
|
|
11624
11728
|
const isNonReactFramework = context.sourceCode.ast.body.some(
|
|
11625
|
-
(node) => node.type === "ImportDeclaration" && typeof node.source.value === "string" &&
|
|
11729
|
+
(node) => node.type === "ImportDeclaration" && typeof node.source.value === "string" && NON_REACT_FRAMEWORK_RE2.test(node.source.value)
|
|
11626
11730
|
);
|
|
11627
11731
|
return {
|
|
11628
11732
|
CallExpression(node) {
|
|
@@ -12440,7 +12544,7 @@ var require_assert_never_default = createRule({
|
|
|
12440
12544
|
});
|
|
12441
12545
|
|
|
12442
12546
|
// src/rules/require-fetch-timeout.ts
|
|
12443
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES51, ASTUtils as
|
|
12547
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51, ASTUtils as ASTUtils12 } from "@typescript-eslint/utils";
|
|
12444
12548
|
var requireFetchTimeoutDocumentation = {
|
|
12445
12549
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
12446
12550
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -12521,7 +12625,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
12521
12625
|
}
|
|
12522
12626
|
function resolvesToGlobal(identifier) {
|
|
12523
12627
|
const scope = context.sourceCode.getScope(identifier);
|
|
12524
|
-
const variable =
|
|
12628
|
+
const variable = ASTUtils12.findVariable(scope, identifier.name);
|
|
12525
12629
|
return variable === null || variable.defs.length === 0;
|
|
12526
12630
|
}
|
|
12527
12631
|
function isGlobalFetchCall2(callee) {
|
|
@@ -13334,7 +13438,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
13334
13438
|
});
|
|
13335
13439
|
|
|
13336
13440
|
// src/rules/stepdown.ts
|
|
13337
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES55, ASTUtils as
|
|
13441
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES55, ASTUtils as ASTUtils13 } from "@typescript-eslint/utils";
|
|
13338
13442
|
var stepdownDocumentation = {
|
|
13339
13443
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
13340
13444
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -13527,7 +13631,7 @@ function methodName(node) {
|
|
|
13527
13631
|
return !node.computed && node.key.type === AST_NODE_TYPES55.Identifier ? node.key.name : null;
|
|
13528
13632
|
}
|
|
13529
13633
|
function referencedMethod(context, node, classVariables) {
|
|
13530
|
-
const objectVariable = node.object.type === AST_NODE_TYPES55.Identifier ?
|
|
13634
|
+
const objectVariable = node.object.type === AST_NODE_TYPES55.Identifier ? ASTUtils13.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
13531
13635
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
13532
13636
|
if (node.object.type !== AST_NODE_TYPES55.ThisExpression && !isClassReference) return null;
|
|
13533
13637
|
if (node.property.type === AST_NODE_TYPES55.PrivateIdentifier) return `#${node.property.name}`;
|
|
@@ -13580,11 +13684,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
13580
13684
|
const pinned = /* @__PURE__ */ new Set();
|
|
13581
13685
|
const classVariables = /* @__PURE__ */ new Set();
|
|
13582
13686
|
if (node.id !== null) {
|
|
13583
|
-
const internal =
|
|
13687
|
+
const internal = ASTUtils13.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
13584
13688
|
if (internal !== null) classVariables.add(internal);
|
|
13585
13689
|
}
|
|
13586
13690
|
if (node.type === AST_NODE_TYPES55.ClassExpression && node.parent.type === AST_NODE_TYPES55.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES55.Identifier) {
|
|
13587
|
-
const outer =
|
|
13691
|
+
const outer = ASTUtils13.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
13588
13692
|
if (outer !== null) classVariables.add(outer);
|
|
13589
13693
|
}
|
|
13590
13694
|
for (const method of methods) {
|
|
@@ -13620,7 +13724,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
13620
13724
|
return;
|
|
13621
13725
|
}
|
|
13622
13726
|
if (binding.type !== AST_NODE_TYPES55.Identifier) return;
|
|
13623
|
-
const variable =
|
|
13727
|
+
const variable = ASTUtils13.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
13624
13728
|
if (variable !== null) {
|
|
13625
13729
|
methodClassVariables.add(variable);
|
|
13626
13730
|
methodAliases.add(variable);
|
|
@@ -13650,7 +13754,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
13650
13754
|
return;
|
|
13651
13755
|
}
|
|
13652
13756
|
if (!privateNames.has(target)) return;
|
|
13653
|
-
const objectVariable = current.object.type === AST_NODE_TYPES55.Identifier ?
|
|
13757
|
+
const objectVariable = current.object.type === AST_NODE_TYPES55.Identifier ? ASTUtils13.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
13654
13758
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
13655
13759
|
pinned.add(target);
|
|
13656
13760
|
return;
|
|
@@ -13734,7 +13838,7 @@ var stepdown_default = createRule({
|
|
|
13734
13838
|
// src/rules/zod-naming-convention.ts
|
|
13735
13839
|
import {
|
|
13736
13840
|
AST_NODE_TYPES as AST_NODE_TYPES56,
|
|
13737
|
-
ASTUtils as
|
|
13841
|
+
ASTUtils as ASTUtils14
|
|
13738
13842
|
} from "@typescript-eslint/utils";
|
|
13739
13843
|
var zodNamingConventionDocumentation = {
|
|
13740
13844
|
summary: "Enforce a consistent Zod schema naming convention \u2014 a `Z` prefix (`ZUser`) or a `Schema` suffix (`userSchema`); both are accepted by default.",
|
|
@@ -13821,7 +13925,7 @@ var zod_naming_convention_default = createRule({
|
|
|
13821
13925
|
const acceptsSchemaWord = convention !== "prefix";
|
|
13822
13926
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
13823
13927
|
function resolvedBinding(identifier) {
|
|
13824
|
-
return
|
|
13928
|
+
return ASTUtils14.findVariable(
|
|
13825
13929
|
context.sourceCode.getScope(identifier),
|
|
13826
13930
|
identifier.name
|
|
13827
13931
|
);
|
|
@@ -13872,7 +13976,6 @@ var zod_naming_convention_default = createRule({
|
|
|
13872
13976
|
// src/rules/_renames.ts
|
|
13873
13977
|
var renamedRules = {
|
|
13874
13978
|
"jsdoc-restates-signature": "no-restated-jsdoc",
|
|
13875
|
-
"no-async-callback-in-waitfor": "no-async-callback-in-wait-for",
|
|
13876
13979
|
"require-interface-for-injected-service": "require-port-for-service",
|
|
13877
13980
|
"strict-test-assertions": "prefer-whole-object-assertion",
|
|
13878
13981
|
"trailing-value-narration": "no-trailing-value-narration"
|
|
@@ -13888,6 +13991,14 @@ var retiredRules = {
|
|
|
13888
13991
|
removedIn: "5.0.0",
|
|
13889
13992
|
reason: "Delete the config entry and suppressions; there is no replacement."
|
|
13890
13993
|
},
|
|
13994
|
+
"no-async-callback-in-wait-for": {
|
|
13995
|
+
removedIn: "14.0.0",
|
|
13996
|
+
reason: "Delete the entry; Testing Library supports async waitFor callbacks and retries when their promises reject."
|
|
13997
|
+
},
|
|
13998
|
+
"no-async-callback-in-waitfor": {
|
|
13999
|
+
removedIn: "14.0.0",
|
|
14000
|
+
reason: "Delete the stale alias; the replacement was also retired because Testing Library supports async waitFor callbacks."
|
|
14001
|
+
},
|
|
13891
14002
|
"no-sequential-await": {
|
|
13892
14003
|
removedIn: "3.0.0",
|
|
13893
14004
|
reason: "Delete the entry; core `no-await-in-loop` covers it."
|
|
@@ -13942,7 +14053,6 @@ var retiredRules = {
|
|
|
13942
14053
|
var rules = {
|
|
13943
14054
|
"duplicate-test-body": duplicate_test_body_default,
|
|
13944
14055
|
"enforce-file-structure": enforce_file_structure_default,
|
|
13945
|
-
"no-async-callback-in-wait-for": no_async_callback_in_wait_for_default,
|
|
13946
14056
|
"no-client-side-data-fetching": no_client_side_data_fetching_default,
|
|
13947
14057
|
"no-comment-cruft": no_comment_cruft_default,
|
|
13948
14058
|
"no-conditional-in-test": no_conditional_in_test_default,
|
|
@@ -14008,7 +14118,7 @@ var rules = {
|
|
|
14008
14118
|
};
|
|
14009
14119
|
var meta = {
|
|
14010
14120
|
name: "@sarj/eslint-plugin",
|
|
14011
|
-
version: "
|
|
14121
|
+
version: "14.0.0"
|
|
14012
14122
|
};
|
|
14013
14123
|
var applicationOnlyRules = [
|
|
14014
14124
|
"no-restricted-library-load",
|
|
@@ -14018,7 +14128,6 @@ var applicationOnlyRules = [
|
|
|
14018
14128
|
var recommendedRules = {
|
|
14019
14129
|
"@sarj/duplicate-test-body": "error",
|
|
14020
14130
|
"@sarj/enforce-file-structure": "error",
|
|
14021
|
-
"@sarj/no-async-callback-in-wait-for": "error",
|
|
14022
14131
|
"@sarj/no-client-side-data-fetching": "error",
|
|
14023
14132
|
"@sarj/no-comment-cruft": "error",
|
|
14024
14133
|
"@sarj/no-conditional-in-test": "error",
|
|
@@ -14078,7 +14187,6 @@ var recommendedRules = {
|
|
|
14078
14187
|
var strictRules = {
|
|
14079
14188
|
"@sarj/duplicate-test-body": "error",
|
|
14080
14189
|
"@sarj/enforce-file-structure": "error",
|
|
14081
|
-
"@sarj/no-async-callback-in-wait-for": "error",
|
|
14082
14190
|
"@sarj/no-client-side-data-fetching": "error",
|
|
14083
14191
|
"@sarj/no-comment-cruft": "error",
|
|
14084
14192
|
"@sarj/no-conditional-in-test": "error",
|