@sarj/eslint-plugin 16.3.0 → 16.3.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 +150 -149
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +296 -294
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2338,7 +2338,7 @@ var prefer_logical_tailwind_utilities_default = createRule({
|
|
|
2338
2338
|
});
|
|
2339
2339
|
|
|
2340
2340
|
// src/rules/no-unlocalized-toast.ts
|
|
2341
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES14 } from "@typescript-eslint/utils";
|
|
2341
|
+
import { ASTUtils as ASTUtils4, AST_NODE_TYPES as AST_NODE_TYPES14 } from "@typescript-eslint/utils";
|
|
2342
2342
|
|
|
2343
2343
|
// src/rules/_localization.ts
|
|
2344
2344
|
import {
|
|
@@ -2467,7 +2467,7 @@ var no_unlocalized_toast_default = createRule({
|
|
|
2467
2467
|
return {
|
|
2468
2468
|
CallExpression(node) {
|
|
2469
2469
|
const callee = node.callee;
|
|
2470
|
-
const receiver = callee.type === AST_NODE_TYPES14.Identifier ? callee : callee.type === AST_NODE_TYPES14.MemberExpression &&
|
|
2470
|
+
const receiver = callee.type === AST_NODE_TYPES14.Identifier ? callee : callee.type === AST_NODE_TYPES14.MemberExpression && callee.object.type === AST_NODE_TYPES14.Identifier && ASTUtils4.getPropertyName(callee) !== null && methods.includes(ASTUtils4.getPropertyName(callee) ?? "") ? callee.object : null;
|
|
2471
2471
|
if (receiver === null) return;
|
|
2472
2472
|
const imported = importedComponent(receiver, context.sourceCode);
|
|
2473
2473
|
if (!functions.some(
|
|
@@ -2974,7 +2974,7 @@ var enforce_file_structure_default = createRule({
|
|
|
2974
2974
|
});
|
|
2975
2975
|
|
|
2976
2976
|
// src/rules/duplicate-test-body.ts
|
|
2977
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES18, ASTUtils as
|
|
2977
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES18, ASTUtils as ASTUtils5 } from "@typescript-eslint/utils";
|
|
2978
2978
|
var TEST_CALLERS = /* @__PURE__ */ new Set(["it", "test"]);
|
|
2979
2979
|
var TEST_MODIFIERS = /* @__PURE__ */ new Set(["concurrent", "fails", "only", "sequential", "skip"]);
|
|
2980
2980
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -3181,7 +3181,7 @@ function containsInlineSnapshot(node) {
|
|
|
3181
3181
|
return false;
|
|
3182
3182
|
}
|
|
3183
3183
|
function isDuplicateTestFrameworkIdentifier(identifier, sourceCode) {
|
|
3184
|
-
const variable =
|
|
3184
|
+
const variable = ASTUtils5.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
3185
3185
|
if (variable === null || variable.defs.length === 0) return true;
|
|
3186
3186
|
return variable.defs.some((definition) => {
|
|
3187
3187
|
if (definition.node.type === AST_NODE_TYPES18.ImportDefaultSpecifier) return definition.node.parent.source.value === "node:test";
|
|
@@ -4442,7 +4442,7 @@ var no_comment_cruft_default = createRule({
|
|
|
4442
4442
|
// src/rules/no-cors-wildcard-with-credentials.ts
|
|
4443
4443
|
import {
|
|
4444
4444
|
AST_NODE_TYPES as AST_NODE_TYPES24,
|
|
4445
|
-
ASTUtils as
|
|
4445
|
+
ASTUtils as ASTUtils6
|
|
4446
4446
|
} from "@typescript-eslint/utils";
|
|
4447
4447
|
var NO_CORS_WILDCARD_WITH_CREDENTIALS_DOCUMENTATION = {
|
|
4448
4448
|
summary: "Disallow wildcard CORS origins when credentials are enabled.",
|
|
@@ -4641,7 +4641,7 @@ var no_cors_wildcard_with_credentials_default = createRule({
|
|
|
4641
4641
|
}
|
|
4642
4642
|
function receiverIdentity(node) {
|
|
4643
4643
|
if (node.type === AST_NODE_TYPES24.Identifier) {
|
|
4644
|
-
const variable =
|
|
4644
|
+
const variable = ASTUtils6.findVariable(
|
|
4645
4645
|
context.sourceCode.getScope(node),
|
|
4646
4646
|
node.name
|
|
4647
4647
|
);
|
|
@@ -4701,7 +4701,7 @@ var no_cors_wildcard_with_credentials_default = createRule({
|
|
|
4701
4701
|
});
|
|
4702
4702
|
|
|
4703
4703
|
// src/rules/no-duplicate-lifecycle-refresh-listeners.ts
|
|
4704
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES25, ASTUtils as
|
|
4704
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES25, ASTUtils as ASTUtils7 } from "@typescript-eslint/utils";
|
|
4705
4705
|
var NO_DUPLICATE_LIFECYCLE_REFRESH_LISTENERS_DOCUMENTATION = {
|
|
4706
4706
|
summary: "Do not register one Next.js route-refresh callback for both focus and visibilitychange.",
|
|
4707
4707
|
rationale: "A browser tab activation can emit both lifecycle signals and invoke the same route-wide refresh twice.",
|
|
@@ -4717,18 +4717,18 @@ function importedName(node) {
|
|
|
4717
4717
|
return node.imported.type === AST_NODE_TYPES25.Identifier ? node.imported.name : String(node.imported.value);
|
|
4718
4718
|
}
|
|
4719
4719
|
function registration(sourceCode, node) {
|
|
4720
|
-
if (node.callee.type !== AST_NODE_TYPES25.MemberExpression || node.callee.
|
|
4720
|
+
if (node.callee.type !== AST_NODE_TYPES25.MemberExpression || node.callee.object.type !== AST_NODE_TYPES25.Identifier || !isUnshadowedGlobal(sourceCode, node.callee.object) || ASTUtils7.getPropertyName(node.callee) === null || (ASTUtils7.getPropertyName(node.callee) ?? "") !== "addEventListener" && (ASTUtils7.getPropertyName(node.callee) ?? "") !== "removeEventListener" || node.arguments.length < 2) return null;
|
|
4721
4721
|
const event = node.arguments[0];
|
|
4722
4722
|
const callback = node.arguments[1];
|
|
4723
4723
|
if (event === void 0 || callback === void 0) return null;
|
|
4724
4724
|
if (event.type !== AST_NODE_TYPES25.Literal || typeof event.value !== "string" || callback.type !== AST_NODE_TYPES25.Identifier) return null;
|
|
4725
|
-
const operation = node.callee
|
|
4725
|
+
const operation = (ASTUtils7.getPropertyName(node.callee) ?? "") === "addEventListener" ? "add" : "remove";
|
|
4726
4726
|
if (node.callee.object.name === "window" && event.value === "focus") return { operation, event: "focus", callback };
|
|
4727
4727
|
if (node.callee.object.name === "document" && event.value === "visibilitychange") return { operation, event: "visibilitychange", callback };
|
|
4728
4728
|
return null;
|
|
4729
4729
|
}
|
|
4730
4730
|
function isUnshadowedGlobal(sourceCode, node) {
|
|
4731
|
-
const variable =
|
|
4731
|
+
const variable = ASTUtils7.findVariable(sourceCode.getScope(node), node.name);
|
|
4732
4732
|
return variable === null || variable.defs.length === 0;
|
|
4733
4733
|
}
|
|
4734
4734
|
function statementContainer(node) {
|
|
@@ -4767,31 +4767,31 @@ var no_duplicate_lifecycle_refresh_listeners_default = createRule({
|
|
|
4767
4767
|
if (node.source.value !== "next/navigation") return;
|
|
4768
4768
|
for (const specifier of node.specifiers) {
|
|
4769
4769
|
if (specifier.type === AST_NODE_TYPES25.ImportSpecifier && importedName(specifier) === "useRouter") {
|
|
4770
|
-
const variable =
|
|
4770
|
+
const variable = ASTUtils7.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
4771
4771
|
if (variable !== null) routerHooks.add(variable);
|
|
4772
4772
|
}
|
|
4773
4773
|
}
|
|
4774
4774
|
},
|
|
4775
4775
|
VariableDeclarator(node) {
|
|
4776
4776
|
if (node.id.type !== AST_NODE_TYPES25.Identifier) return;
|
|
4777
|
-
const variable =
|
|
4777
|
+
const variable = ASTUtils7.findVariable(context.sourceCode.getScope(node.id), node.id.name);
|
|
4778
4778
|
if (variable === null || variable.references.some((reference) => reference.isWrite() && !reference.init)) return;
|
|
4779
4779
|
if (node.init?.type === AST_NODE_TYPES25.ArrowFunctionExpression || node.init?.type === AST_NODE_TYPES25.FunctionExpression) {
|
|
4780
4780
|
functionCallbacks.set(node.init, variable);
|
|
4781
4781
|
}
|
|
4782
4782
|
if (node.init?.type !== AST_NODE_TYPES25.CallExpression || node.init.callee.type !== AST_NODE_TYPES25.Identifier) return;
|
|
4783
|
-
const hook =
|
|
4783
|
+
const hook = ASTUtils7.findVariable(context.sourceCode.getScope(node.init.callee), node.init.callee.name);
|
|
4784
4784
|
if (hook !== null && routerHooks.has(hook)) routers.add(variable);
|
|
4785
4785
|
},
|
|
4786
4786
|
FunctionDeclaration(node) {
|
|
4787
4787
|
if (node.id === null) return;
|
|
4788
|
-
const variable =
|
|
4788
|
+
const variable = ASTUtils7.findVariable(context.sourceCode.getScope(node.id), node.id.name);
|
|
4789
4789
|
if (variable !== null && !variable.references.some((reference) => reference.isWrite() && !reference.init)) functionCallbacks.set(node, variable);
|
|
4790
4790
|
},
|
|
4791
4791
|
CallExpression(node) {
|
|
4792
4792
|
const item = registration(context.sourceCode, node);
|
|
4793
4793
|
if (item !== null) {
|
|
4794
|
-
const callback2 =
|
|
4794
|
+
const callback2 = ASTUtils7.findVariable(context.sourceCode.getScope(item.callback), item.callback.name);
|
|
4795
4795
|
const container = statementContainer(node);
|
|
4796
4796
|
if (callback2 !== null && container !== null) {
|
|
4797
4797
|
const callbacks = registrations.get(container) ?? /* @__PURE__ */ new Map();
|
|
@@ -4802,8 +4802,8 @@ var no_duplicate_lifecycle_refresh_listeners_default = createRule({
|
|
|
4802
4802
|
registrations.set(container, callbacks);
|
|
4803
4803
|
}
|
|
4804
4804
|
}
|
|
4805
|
-
if (node.callee.type !== AST_NODE_TYPES25.MemberExpression || node.callee.
|
|
4806
|
-
const router =
|
|
4805
|
+
if (node.callee.type !== AST_NODE_TYPES25.MemberExpression || node.callee.object.type !== AST_NODE_TYPES25.Identifier || ASTUtils7.getPropertyName(node.callee) === null || (ASTUtils7.getPropertyName(node.callee) ?? "") !== "refresh") return;
|
|
4806
|
+
const router = ASTUtils7.findVariable(context.sourceCode.getScope(node.callee.object), node.callee.object.name);
|
|
4807
4807
|
if (router === null || !routers.has(router)) return;
|
|
4808
4808
|
const fn = enclosingFunction(context.sourceCode, node);
|
|
4809
4809
|
if (fn === null) return;
|
|
@@ -4825,7 +4825,7 @@ var no_duplicate_lifecycle_refresh_listeners_default = createRule({
|
|
|
4825
4825
|
});
|
|
4826
4826
|
|
|
4827
4827
|
// src/rules/_exported-next-config-property.ts
|
|
4828
|
-
import { ASTUtils as
|
|
4828
|
+
import { ASTUtils as ASTUtils8 } from "@typescript-eslint/utils";
|
|
4829
4829
|
function unwrap(node) {
|
|
4830
4830
|
while (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSTypeAssertion" || node.type === "TSNonNullExpression") node = node.expression;
|
|
4831
4831
|
return node;
|
|
@@ -4836,7 +4836,7 @@ function exportedNextConfigProperty(sourceCode, path) {
|
|
|
4836
4836
|
if (node.type !== "Identifier") return node;
|
|
4837
4837
|
if (seen.has(node)) return null;
|
|
4838
4838
|
seen.add(node);
|
|
4839
|
-
const binding =
|
|
4839
|
+
const binding = ASTUtils8.findVariable(sourceCode.getScope(node), node.name);
|
|
4840
4840
|
const definition = binding?.defs.length === 1 ? binding.defs[0] : void 0;
|
|
4841
4841
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || binding?.references.some((reference) => reference.identifier !== node && reference.init !== true)) return null;
|
|
4842
4842
|
return resolve2(definition.node.init, seen);
|
|
@@ -4861,7 +4861,7 @@ function exportedConfig(sourceCode) {
|
|
|
4861
4861
|
const assignment = statement.expression;
|
|
4862
4862
|
const left = assignment.left;
|
|
4863
4863
|
if (left.type !== "MemberExpression" || left.computed || left.object.type !== "Identifier" || left.object.name !== "module" || left.property.type !== "Identifier" || left.property.name !== "exports") continue;
|
|
4864
|
-
const binding =
|
|
4864
|
+
const binding = ASTUtils8.findVariable(sourceCode.getScope(left.object), "module");
|
|
4865
4865
|
if (binding === null || binding.defs.length === 0) exported = assignment.right;
|
|
4866
4866
|
}
|
|
4867
4867
|
return exported;
|
|
@@ -4952,7 +4952,7 @@ var no_dangerously_allow_svg_default = createRule({
|
|
|
4952
4952
|
});
|
|
4953
4953
|
|
|
4954
4954
|
// src/rules/no-dynamic-sql.ts
|
|
4955
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES27 } from "@typescript-eslint/utils";
|
|
4955
|
+
import { ASTUtils as ASTUtils9, AST_NODE_TYPES as AST_NODE_TYPES27 } from "@typescript-eslint/utils";
|
|
4956
4956
|
|
|
4957
4957
|
// src/rules/_sql.ts
|
|
4958
4958
|
import { AST_NODE_TYPES as AST_NODE_TYPES26 } from "@typescript-eslint/utils";
|
|
@@ -5178,8 +5178,8 @@ function isStaticFragment(expression) {
|
|
|
5178
5178
|
if (expression.type === AST_NODE_TYPES27.Identifier) {
|
|
5179
5179
|
return CONSTANT_CASE_RE.test(expression.name);
|
|
5180
5180
|
}
|
|
5181
|
-
if (expression.type === AST_NODE_TYPES27.MemberExpression &&
|
|
5182
|
-
return CONSTANT_CASE_RE.test(expression
|
|
5181
|
+
if (expression.type === AST_NODE_TYPES27.MemberExpression && ASTUtils9.getPropertyName(expression) !== null) {
|
|
5182
|
+
return CONSTANT_CASE_RE.test(ASTUtils9.getPropertyName(expression) ?? "");
|
|
5183
5183
|
}
|
|
5184
5184
|
if (expression.type === AST_NODE_TYPES27.Literal) {
|
|
5185
5185
|
return typeof expression.value === "string";
|
|
@@ -5278,10 +5278,10 @@ function staticStatementText(node) {
|
|
|
5278
5278
|
}
|
|
5279
5279
|
function statementMethodName(node, methods) {
|
|
5280
5280
|
const callee = node.callee;
|
|
5281
|
-
if (callee.type !== AST_NODE_TYPES27.MemberExpression ||
|
|
5281
|
+
if (callee.type !== AST_NODE_TYPES27.MemberExpression || ASTUtils9.getPropertyName(callee) === null) {
|
|
5282
5282
|
return null;
|
|
5283
5283
|
}
|
|
5284
|
-
const name = callee
|
|
5284
|
+
const name = ASTUtils9.getPropertyName(callee) ?? "";
|
|
5285
5285
|
return methods.has(name) ? name : null;
|
|
5286
5286
|
}
|
|
5287
5287
|
var no_dynamic_sql_default = createRule({
|
|
@@ -5997,7 +5997,7 @@ var no_fat_try_blocks_default = createRule({
|
|
|
5997
5997
|
});
|
|
5998
5998
|
|
|
5999
5999
|
// src/rules/no-hand-rolled-sleep.ts
|
|
6000
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES30, ASTUtils as
|
|
6000
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES30, ASTUtils as ASTUtils10 } from "@typescript-eslint/utils";
|
|
6001
6001
|
var NO_HAND_ROLLED_SLEEP_DOCUMENTATION = {
|
|
6002
6002
|
summary: "Disallow uncancellable promisified timers and timeout arms.",
|
|
6003
6003
|
rationale: "A timer that outlives an aborted operation or a lost promise race retains work and can keep the process alive until it fires.",
|
|
@@ -6149,7 +6149,7 @@ var no_hand_rolled_sleep_default = createRule({
|
|
|
6149
6149
|
return {};
|
|
6150
6150
|
}
|
|
6151
6151
|
const checkClientModules = optionsArg?.checkClientModules ?? false;
|
|
6152
|
-
const bindingOf = (identifier) =>
|
|
6152
|
+
const bindingOf = (identifier) => ASTUtils10.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
6153
6153
|
const isGlobal = (identifier) => (bindingOf(identifier)?.defs.length ?? 0) === 0;
|
|
6154
6154
|
const isBuiltinTimer = (callee) => {
|
|
6155
6155
|
if (!isSetTimeoutCallee(callee)) return false;
|
|
@@ -6313,7 +6313,7 @@ var no_hand_rolled_spinner_default = createRule({
|
|
|
6313
6313
|
});
|
|
6314
6314
|
|
|
6315
6315
|
// src/rules/no-insecure-random-id.ts
|
|
6316
|
-
import { ASTUtils as
|
|
6316
|
+
import { ASTUtils as ASTUtils11 } from "@typescript-eslint/utils";
|
|
6317
6317
|
var NO_INSECURE_RANDOM_ID_DOCUMENTATION = {
|
|
6318
6318
|
summary: "Disallow using `Math.random()` to generate identifiers, tokens, or secrets; use `crypto.randomUUID()` or `crypto.getRandomValues(...)` instead.",
|
|
6319
6319
|
rationale: "Math.random is predictable and lacks the entropy required for security-sensitive values.",
|
|
@@ -6384,11 +6384,11 @@ function isMathRandomCall(node) {
|
|
|
6384
6384
|
return false;
|
|
6385
6385
|
}
|
|
6386
6386
|
const callee = node.callee;
|
|
6387
|
-
if (callee.type !== "MemberExpression"
|
|
6387
|
+
if (callee.type !== "MemberExpression") {
|
|
6388
6388
|
return false;
|
|
6389
6389
|
}
|
|
6390
|
-
const { object
|
|
6391
|
-
return object.type === "Identifier" && object.name === "Math" &&
|
|
6390
|
+
const { object } = callee;
|
|
6391
|
+
return object.type === "Identifier" && object.name === "Math" && ASTUtils11.getPropertyName(callee) === "random";
|
|
6392
6392
|
}
|
|
6393
6393
|
function findEnclosingNames(node) {
|
|
6394
6394
|
const names = [];
|
|
@@ -6453,7 +6453,7 @@ function climbValueChain(node) {
|
|
|
6453
6453
|
let current = node;
|
|
6454
6454
|
let parent = current.parent;
|
|
6455
6455
|
while (parent) {
|
|
6456
|
-
if (parent.type === "MemberExpression" && parent.object === current &&
|
|
6456
|
+
if (parent.type === "MemberExpression" && parent.object === current && ASTUtils11.getPropertyName(parent) !== null) {
|
|
6457
6457
|
current = parent;
|
|
6458
6458
|
parent = current.parent;
|
|
6459
6459
|
continue;
|
|
@@ -6506,7 +6506,7 @@ var no_insecure_random_id_default = createRule({
|
|
|
6506
6506
|
if (!isMathRandomCall(node)) {
|
|
6507
6507
|
return;
|
|
6508
6508
|
}
|
|
6509
|
-
if ((
|
|
6509
|
+
if ((ASTUtils11.findVariable(context.sourceCode.getScope(node), "Math")?.defs.length ?? 0) > 0) return;
|
|
6510
6510
|
const names = findEnclosingNames(node);
|
|
6511
6511
|
if (names.some(isStrongSecurityName)) {
|
|
6512
6512
|
context.report({ node, messageId: "insecureRandomId" });
|
|
@@ -6529,8 +6529,8 @@ function appendPropertyName(property, names) {
|
|
|
6529
6529
|
}
|
|
6530
6530
|
function appendAssignedName(assignment, directBinding, names) {
|
|
6531
6531
|
if (directBinding && assignment.left.type === "Identifier") names.push(assignment.left.name);
|
|
6532
|
-
if (directBinding && assignment.left.type === "MemberExpression" &&
|
|
6533
|
-
names.push(assignment.left
|
|
6532
|
+
if (directBinding && assignment.left.type === "MemberExpression" && ASTUtils11.getPropertyName(assignment.left) !== null) {
|
|
6533
|
+
names.push(ASTUtils11.getPropertyName(assignment.left) ?? "");
|
|
6534
6534
|
}
|
|
6535
6535
|
}
|
|
6536
6536
|
function appendDirectBindingName(id, directBinding, names) {
|
|
@@ -6540,7 +6540,7 @@ function appendDirectBindingName(id, directBinding, names) {
|
|
|
6540
6540
|
// src/rules/no-detached-global-fetch.ts
|
|
6541
6541
|
import {
|
|
6542
6542
|
AST_NODE_TYPES as AST_NODE_TYPES32,
|
|
6543
|
-
ASTUtils as
|
|
6543
|
+
ASTUtils as ASTUtils12
|
|
6544
6544
|
} from "@typescript-eslint/utils";
|
|
6545
6545
|
var NO_DETACHED_GLOBAL_FETCH_DOCUMENTATION = {
|
|
6546
6546
|
summary: "Keep the ambient global fetch receiver-safe when storing or explicitly rebinding it.",
|
|
@@ -6601,7 +6601,7 @@ var no_detached_global_fetch_default = createRule({
|
|
|
6601
6601
|
if (isTestFile(context.filename) || isScriptFile(context.filename) || isGeneratedFile(context.filename, sourceCode.text)) return {};
|
|
6602
6602
|
const aliases = /* @__PURE__ */ new Set();
|
|
6603
6603
|
function bindingOf(identifier) {
|
|
6604
|
-
return
|
|
6604
|
+
return ASTUtils12.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
6605
6605
|
}
|
|
6606
6606
|
function resolvesToGlobal(identifier) {
|
|
6607
6607
|
const variable = bindingOf(identifier);
|
|
@@ -6706,7 +6706,7 @@ var no_detached_global_fetch_default = createRule({
|
|
|
6706
6706
|
});
|
|
6707
6707
|
|
|
6708
6708
|
// src/rules/no-json-stringify-error.ts
|
|
6709
|
-
import { ASTUtils as
|
|
6709
|
+
import { ASTUtils as ASTUtils13 } from "@typescript-eslint/utils";
|
|
6710
6710
|
var NO_JSON_STRINGIFY_ERROR_DOCUMENTATION = {
|
|
6711
6711
|
summary: "Avoid generic JSON serialization that can omit native Error details.",
|
|
6712
6712
|
rationale: "Native Error details are non-enumerable, so generic JSON serialization discards diagnostic information.",
|
|
@@ -6746,7 +6746,7 @@ var BUILTIN_ERROR_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
6746
6746
|
"URIError"
|
|
6747
6747
|
]);
|
|
6748
6748
|
function identifierIsProvenError(identifier, scope) {
|
|
6749
|
-
const variable =
|
|
6749
|
+
const variable = ASTUtils13.findVariable(scope, identifier.name);
|
|
6750
6750
|
if (variable === null || variable.defs.length !== 1 || variable.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
6751
6751
|
const definition = variable.defs[0];
|
|
6752
6752
|
if (definition?.type === "CatchClause") return true;
|
|
@@ -6755,7 +6755,7 @@ function identifierIsProvenError(identifier, scope) {
|
|
|
6755
6755
|
return initializer?.type === "NewExpression" && initializer.callee.type === "Identifier" && BUILTIN_ERROR_CONSTRUCTORS.has(initializer.callee.name) && isGlobalIdentifier(initializer.callee.name, scope);
|
|
6756
6756
|
}
|
|
6757
6757
|
function isGlobalIdentifier(name, scope) {
|
|
6758
|
-
const binding =
|
|
6758
|
+
const binding = ASTUtils13.findVariable(scope, name);
|
|
6759
6759
|
return binding === null || binding.defs.length === 0;
|
|
6760
6760
|
}
|
|
6761
6761
|
function positiveErrorSubject(test) {
|
|
@@ -6824,7 +6824,7 @@ function nodeWithin(node, container) {
|
|
|
6824
6824
|
return container !== null && node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
6825
6825
|
}
|
|
6826
6826
|
function isJsonStringify(callee) {
|
|
6827
|
-
return callee.type === "MemberExpression" &&
|
|
6827
|
+
return callee.type === "MemberExpression" && callee.object.type === "Identifier" && callee.object.name === "JSON" && ASTUtils13.getPropertyName(callee) !== null && (ASTUtils13.getPropertyName(callee) ?? "") === "stringify";
|
|
6828
6828
|
}
|
|
6829
6829
|
function directLiteralValues(argument) {
|
|
6830
6830
|
if (argument.type === "ObjectExpression") {
|
|
@@ -6854,7 +6854,7 @@ function expressionSuggestsError(expression, scope) {
|
|
|
6854
6854
|
return expression.type === "MemberExpression" && memberSuggestsError(expression, scope);
|
|
6855
6855
|
}
|
|
6856
6856
|
function memberSuggestsError(member, scope) {
|
|
6857
|
-
const propName2 =
|
|
6857
|
+
const propName2 = ASTUtils13.getPropertyName(member) !== null ? ASTUtils13.getPropertyName(member) ?? "" : null;
|
|
6858
6858
|
const base = member.object;
|
|
6859
6859
|
const baseSuggestsError = base.type === "Identifier" && identifierIsProvenError(base, scope);
|
|
6860
6860
|
if (baseSuggestsError) {
|
|
@@ -6931,7 +6931,7 @@ function branchTerminates(branch) {
|
|
|
6931
6931
|
// src/rules/no-json-stringify-object-equality.ts
|
|
6932
6932
|
import {
|
|
6933
6933
|
AST_NODE_TYPES as AST_NODE_TYPES33,
|
|
6934
|
-
ASTUtils as
|
|
6934
|
+
ASTUtils as ASTUtils14,
|
|
6935
6935
|
ESLintUtils as ESLintUtils7
|
|
6936
6936
|
} from "@typescript-eslint/utils";
|
|
6937
6937
|
import ts6 from "typescript";
|
|
@@ -6984,7 +6984,7 @@ function jsonStringifyArgument(node, sourceCode) {
|
|
|
6984
6984
|
if (callee.type !== AST_NODE_TYPES33.MemberExpression || callee.object.type !== AST_NODE_TYPES33.Identifier || callee.object.name !== "JSON" || (!callee.computed ? callee.property.type !== AST_NODE_TYPES33.Identifier || callee.property.name !== "stringify" : callee.property.type !== AST_NODE_TYPES33.Literal || callee.property.value !== "stringify")) {
|
|
6985
6985
|
return null;
|
|
6986
6986
|
}
|
|
6987
|
-
const variable =
|
|
6987
|
+
const variable = ASTUtils14.findVariable(sourceCode.getScope(callee.object), "JSON");
|
|
6988
6988
|
if (variable !== null && variable.defs.length > 0) return null;
|
|
6989
6989
|
const argument = expression.arguments[0];
|
|
6990
6990
|
return argument !== void 0 && argument.type !== AST_NODE_TYPES33.SpreadElement ? argument : null;
|
|
@@ -7754,10 +7754,10 @@ var interface_contract_members_private_default = createRule({
|
|
|
7754
7754
|
});
|
|
7755
7755
|
|
|
7756
7756
|
// src/rules/no-log-only-catch.ts
|
|
7757
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES38, ASTUtils as
|
|
7757
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38, ASTUtils as ASTUtils16 } from "@typescript-eslint/utils";
|
|
7758
7758
|
|
|
7759
7759
|
// src/rules/_logging.ts
|
|
7760
|
-
import "@typescript-eslint/utils";
|
|
7760
|
+
import { ASTUtils as ASTUtils15 } from "@typescript-eslint/utils";
|
|
7761
7761
|
var LOG_METHODS = /* @__PURE__ */ new Set([
|
|
7762
7762
|
"debug",
|
|
7763
7763
|
"info",
|
|
@@ -7793,8 +7793,8 @@ function calleeName2(callee) {
|
|
|
7793
7793
|
if (callee.type === "Identifier") {
|
|
7794
7794
|
return callee.name;
|
|
7795
7795
|
}
|
|
7796
|
-
if (callee.type === "MemberExpression" &&
|
|
7797
|
-
return callee
|
|
7796
|
+
if (callee.type === "MemberExpression" && ASTUtils15.getPropertyName(callee) !== null) {
|
|
7797
|
+
return ASTUtils15.getPropertyName(callee) ?? "";
|
|
7798
7798
|
}
|
|
7799
7799
|
return null;
|
|
7800
7800
|
}
|
|
@@ -7809,9 +7809,10 @@ function createLogMatcher(options = {}) {
|
|
|
7809
7809
|
case "Identifier":
|
|
7810
7810
|
return loggerNames.has(expr.name.toLowerCase());
|
|
7811
7811
|
case "MemberExpression": {
|
|
7812
|
-
const {
|
|
7813
|
-
|
|
7814
|
-
|
|
7812
|
+
const { object } = expr;
|
|
7813
|
+
const property = ASTUtils15.getPropertyName(expr);
|
|
7814
|
+
if (property !== null) {
|
|
7815
|
+
const lowered = property.toLowerCase();
|
|
7815
7816
|
if (loggerNames.has(lowered) || LOGGER_FACTORIES.has(lowered)) {
|
|
7816
7817
|
return true;
|
|
7817
7818
|
}
|
|
@@ -7820,7 +7821,7 @@ function createLogMatcher(options = {}) {
|
|
|
7820
7821
|
}
|
|
7821
7822
|
case "CallExpression": {
|
|
7822
7823
|
const callee = expr.callee;
|
|
7823
|
-
if (callee.type === "MemberExpression" &&
|
|
7824
|
+
if (callee.type === "MemberExpression" && ASTUtils15.getPropertyName(callee) !== null && LOGGER_FACTORIES.has((ASTUtils15.getPropertyName(callee) ?? "").toLowerCase())) {
|
|
7824
7825
|
return true;
|
|
7825
7826
|
}
|
|
7826
7827
|
if (callee.type !== "Super") {
|
|
@@ -7847,10 +7848,10 @@ function createLogMatcher(options = {}) {
|
|
|
7847
7848
|
return true;
|
|
7848
7849
|
}
|
|
7849
7850
|
const callee = expr.callee;
|
|
7850
|
-
if (callee.type !== "MemberExpression" ||
|
|
7851
|
+
if (callee.type !== "MemberExpression" || ASTUtils15.getPropertyName(callee) === null) {
|
|
7851
7852
|
return false;
|
|
7852
7853
|
}
|
|
7853
|
-
if (!LOG_METHODS.has(callee.
|
|
7854
|
+
if (!LOG_METHODS.has((ASTUtils15.getPropertyName(callee) ?? "").toLowerCase())) {
|
|
7854
7855
|
return false;
|
|
7855
7856
|
}
|
|
7856
7857
|
return isLoggerReceiver(callee.object);
|
|
@@ -7926,7 +7927,7 @@ function seededFallbackHandled(tryStatement, scope) {
|
|
|
7926
7927
|
if (previous.declarations.length !== 1 || declarator === void 0) return false;
|
|
7927
7928
|
if (declarator.id.type !== AST_NODE_TYPES38.Identifier) return false;
|
|
7928
7929
|
if (declarator.init == null || !isSeedValue(declarator.init)) return false;
|
|
7929
|
-
const variable =
|
|
7930
|
+
const variable = ASTUtils16.findVariable(scope, declarator.id.name);
|
|
7930
7931
|
if (variable === null) return false;
|
|
7931
7932
|
const [tryStart, tryEnd] = tryStatement.block.range;
|
|
7932
7933
|
let writtenInTry = false;
|
|
@@ -7988,9 +7989,9 @@ var no_log_only_catch_default = createRule({
|
|
|
7988
7989
|
if (left.type !== AST_NODE_TYPES38.MemberExpression || left.computed || left.object.type !== AST_NODE_TYPES38.Identifier || right.type !== AST_NODE_TYPES38.CallExpression || right.optional || right.callee.type !== AST_NODE_TYPES38.Identifier || !["String", "Number", "Boolean", "BigInt"].includes(right.callee.name) || right.arguments.length !== 1) return false;
|
|
7989
7990
|
const argument = right.arguments[0];
|
|
7990
7991
|
if (argument === void 0 || sourceCode.getText(left) !== sourceCode.getText(argument)) return false;
|
|
7991
|
-
const global =
|
|
7992
|
+
const global = ASTUtils16.findVariable(sourceCode.getScope(right.callee), right.callee.name);
|
|
7992
7993
|
if (global !== null && global.defs.length > 0) return false;
|
|
7993
|
-
const root =
|
|
7994
|
+
const root = ASTUtils16.findVariable(sourceCode.getScope(left.object), left.object.name);
|
|
7994
7995
|
if (root === null || root.references.some((reference) => reference.isWrite() && !reference.init)) return false;
|
|
7995
7996
|
return hasFollowingCoercionCheck(owner, left, right.callee.name);
|
|
7996
7997
|
}
|
|
@@ -8061,7 +8062,7 @@ var no_log_only_catch_default = createRule({
|
|
|
8061
8062
|
});
|
|
8062
8063
|
|
|
8063
8064
|
// src/rules/no-bare-return-from-test-catch.ts
|
|
8064
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES39, ASTUtils as
|
|
8065
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39, ASTUtils as ASTUtils17 } from "@typescript-eslint/utils";
|
|
8065
8066
|
var NO_BARE_RETURN_FROM_TEST_CATCH_DOCUMENTATION = {
|
|
8066
8067
|
summary: "Disallow a bare return from a test catch block when it skips a later assertion.",
|
|
8067
8068
|
rationale: "An unasserted catch return can swallow a failure and skip later assertions; the complete test result also depends on other assertions and hooks.",
|
|
@@ -8086,7 +8087,7 @@ function staticMemberName3(node) {
|
|
|
8086
8087
|
return null;
|
|
8087
8088
|
}
|
|
8088
8089
|
function importedName4(identifier, context, modules) {
|
|
8089
|
-
const variable =
|
|
8090
|
+
const variable = ASTUtils17.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
8090
8091
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
8091
8092
|
for (const definition of variable.defs) {
|
|
8092
8093
|
if (definition.node.type !== AST_NODE_TYPES39.ImportSpecifier && definition.node.type !== AST_NODE_TYPES39.ImportDefaultSpecifier && definition.node.type !== AST_NODE_TYPES39.ImportNamespaceSpecifier) continue;
|
|
@@ -8171,7 +8172,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
8171
8172
|
const parameter = catchClause.param;
|
|
8172
8173
|
const returnBlock = node.parent;
|
|
8173
8174
|
if (parameter?.type === AST_NODE_TYPES39.Identifier && returnBlock?.type === AST_NODE_TYPES39.BlockStatement) {
|
|
8174
|
-
const errorBinding =
|
|
8175
|
+
const errorBinding = ASTUtils17.findVariable(context.sourceCode.getScope(parameter), parameter.name);
|
|
8175
8176
|
const assertedError = returnBlock.body.some((statement) => {
|
|
8176
8177
|
if (statement.range[1] >= node.range[0] || statement.type !== AST_NODE_TYPES39.ExpressionStatement) return false;
|
|
8177
8178
|
const expression = statement.expression;
|
|
@@ -8195,7 +8196,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
8195
8196
|
});
|
|
8196
8197
|
|
|
8197
8198
|
// src/rules/no-bespoke-api-case-conversion.ts
|
|
8198
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES40, ASTUtils as
|
|
8199
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40, ASTUtils as ASTUtils18 } from "@typescript-eslint/utils";
|
|
8199
8200
|
var NO_BESPOKE_API_CASE_CONVERSION_DOCUMENTATION = {
|
|
8200
8201
|
defaultLevel: "warning",
|
|
8201
8202
|
summary: "Review direct snake_case/camelCase mirror mappings on explicitly API-typed adapter values.",
|
|
@@ -8251,10 +8252,10 @@ function memberName5(node) {
|
|
|
8251
8252
|
while (current.type === AST_NODE_TYPES40.TSAsExpression || current.type === AST_NODE_TYPES40.TSNonNullExpression || current.type === AST_NODE_TYPES40.TSTypeAssertion) {
|
|
8252
8253
|
current = current.expression;
|
|
8253
8254
|
}
|
|
8254
|
-
if (current.type !== AST_NODE_TYPES40.MemberExpression ||
|
|
8255
|
+
if (current.type !== AST_NODE_TYPES40.MemberExpression || ASTUtils18.getPropertyName(current) === null) {
|
|
8255
8256
|
return null;
|
|
8256
8257
|
}
|
|
8257
|
-
return current
|
|
8258
|
+
return ASTUtils18.getPropertyName(current) ?? "";
|
|
8258
8259
|
}
|
|
8259
8260
|
function isDirectCaseTranslation(left, right) {
|
|
8260
8261
|
if (SNAKE_CASE_RE2.test(left) && LOWER_CAMEL_CASE_RE.test(right)) {
|
|
@@ -8294,7 +8295,7 @@ var no_bespoke_api_case_conversion_default = createRule({
|
|
|
8294
8295
|
else break;
|
|
8295
8296
|
}
|
|
8296
8297
|
if (current.type !== AST_NODE_TYPES40.Identifier) return false;
|
|
8297
|
-
const binding =
|
|
8298
|
+
const binding = ASTUtils18.findVariable(context.sourceCode.getScope(current), current.name);
|
|
8298
8299
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
8299
8300
|
const identifier = binding.defs[0]?.name;
|
|
8300
8301
|
if (identifier?.type !== AST_NODE_TYPES40.Identifier) return false;
|
|
@@ -8303,7 +8304,7 @@ var no_bespoke_api_case_conversion_default = createRule({
|
|
|
8303
8304
|
let typeName = annotation.typeName;
|
|
8304
8305
|
while (typeName.type === AST_NODE_TYPES40.TSQualifiedName) typeName = typeName.left;
|
|
8305
8306
|
if (typeName.type !== AST_NODE_TYPES40.Identifier) return false;
|
|
8306
|
-
const typeBinding =
|
|
8307
|
+
const typeBinding = ASTUtils18.findVariable(context.sourceCode.getScope(typeName), typeName.name);
|
|
8307
8308
|
return typeBinding?.defs.length === 1 && typeBinding.defs[0]?.type === "ImportBinding" && typeBinding.defs[0].parent.type === AST_NODE_TYPES40.ImportDeclaration && API_BOUNDARY_IMPORT_RE.test(typeBinding.defs[0].parent.source.value);
|
|
8308
8309
|
};
|
|
8309
8310
|
return {
|
|
@@ -8508,7 +8509,7 @@ var no_vague_suppression_description_default = createRule({
|
|
|
8508
8509
|
});
|
|
8509
8510
|
|
|
8510
8511
|
// src/rules/_runtime-exports.ts
|
|
8511
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES42, ASTUtils as
|
|
8512
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42, ASTUtils as ASTUtils19 } from "@typescript-eslint/utils";
|
|
8512
8513
|
var GENERIC_MODULE_STEMS = /* @__PURE__ */ new Set([
|
|
8513
8514
|
"common",
|
|
8514
8515
|
"helper",
|
|
@@ -8630,7 +8631,7 @@ function namespaceEmission(declaration) {
|
|
|
8630
8631
|
}
|
|
8631
8632
|
function isCommonJsExportReference(node, sourceCode) {
|
|
8632
8633
|
function isGlobal(node2) {
|
|
8633
|
-
const variable =
|
|
8634
|
+
const variable = ASTUtils19.findVariable(sourceCode.getScope(node2), node2.name);
|
|
8634
8635
|
return variable === null || variable.defs.length === 0;
|
|
8635
8636
|
}
|
|
8636
8637
|
if (node.type === AST_NODE_TYPES42.MemberExpression) {
|
|
@@ -8752,7 +8753,7 @@ var no_offset_pagination_default = createRule({
|
|
|
8752
8753
|
});
|
|
8753
8754
|
|
|
8754
8755
|
// src/rules/no-positional-tuple-return.ts
|
|
8755
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES43, ASTUtils as
|
|
8756
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43, ASTUtils as ASTUtils20 } from "@typescript-eslint/utils";
|
|
8756
8757
|
var NO_POSITIONAL_TUPLE_RETURN_DOCUMENTATION = {
|
|
8757
8758
|
summary: "Disallow returning a multi-field tuple from a named function; return a named object so call sites cannot mismatch slots.",
|
|
8758
8759
|
rationale: "Tuple fields are identified only by position, so reordering can preserve types while changing meaning.",
|
|
@@ -8886,7 +8887,7 @@ function typeAliases(sourceCode) {
|
|
|
8886
8887
|
get(identifier) {
|
|
8887
8888
|
const declaration = aliases.get(identifier.name);
|
|
8888
8889
|
if (declaration === void 0) return void 0;
|
|
8889
|
-
const binding =
|
|
8890
|
+
const binding = ASTUtils20.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
8890
8891
|
return binding?.defs.length === 1 && binding.defs[0]?.node === declaration ? declaration.typeAnnotation : void 0;
|
|
8891
8892
|
}
|
|
8892
8893
|
};
|
|
@@ -9197,7 +9198,7 @@ var no_production_browser_source_maps_default = createRule({
|
|
|
9197
9198
|
});
|
|
9198
9199
|
|
|
9199
9200
|
// src/rules/no-raw-env.ts
|
|
9200
|
-
import { ASTUtils as
|
|
9201
|
+
import { ASTUtils as ASTUtils21 } from "@typescript-eslint/utils";
|
|
9201
9202
|
var NO_RAW_ENV_DOCUMENTATION = {
|
|
9202
9203
|
summary: "Disallow direct `process.env` and `import.meta.env` reads outside validated boundaries.",
|
|
9203
9204
|
rationale: "Raw environment reads are untyped and defer invalid configuration failures until use.",
|
|
@@ -9211,11 +9212,16 @@ var NO_RAW_ENV_DOCUMENTATION = {
|
|
|
9211
9212
|
};
|
|
9212
9213
|
var CONFIG_FILE_RE = /(^|[\\/])[\w.-]+\.config\.[cm]?[jt]sx?$/;
|
|
9213
9214
|
var ENV_BOUNDARY_FILE_RE = /(^|[\\/])(?:env|client-env|server-env|client-settings|server-settings)\.[cm]?[jt]sx?$/;
|
|
9214
|
-
function isProcessEnv(node) {
|
|
9215
|
-
|
|
9215
|
+
function isProcessEnv(node, context) {
|
|
9216
|
+
if (node.object.type !== "Identifier" || ASTUtils21.getPropertyName(node) !== "env") return false;
|
|
9217
|
+
const binding = ASTUtils21.findVariable(context.sourceCode.getScope(node.object), node.object.name);
|
|
9218
|
+
if (binding === null || binding.defs.length === 0) return node.object.name === "process";
|
|
9219
|
+
return binding.defs.every(
|
|
9220
|
+
(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)
|
|
9221
|
+
);
|
|
9216
9222
|
}
|
|
9217
9223
|
function isImportMetaEnv(node) {
|
|
9218
|
-
return
|
|
9224
|
+
return ASTUtils21.getPropertyName(node) !== null && (ASTUtils21.getPropertyName(node) ?? "") === "env" && node.object.type === "MetaProperty" && node.object.meta.name === "import" && node.object.property.name === "meta";
|
|
9219
9225
|
}
|
|
9220
9226
|
var BUILD_TIME_CONSTANTS = /* @__PURE__ */ new Set([
|
|
9221
9227
|
"NODE_ENV",
|
|
@@ -9232,7 +9238,7 @@ var PLATFORM_MARKERS = /* @__PURE__ */ new Set([
|
|
|
9232
9238
|
]);
|
|
9233
9239
|
function isExemptVariableAccess(node) {
|
|
9234
9240
|
const parent = node.parent;
|
|
9235
|
-
return parent.type === "MemberExpression" && parent.object === node &&
|
|
9241
|
+
return parent.type === "MemberExpression" && parent.object === node && ASTUtils21.getPropertyName(parent) !== null && (BUILD_TIME_CONSTANTS.has(ASTUtils21.getPropertyName(parent) ?? "") || PLATFORM_MARKERS.has(ASTUtils21.getPropertyName(parent) ?? ""));
|
|
9236
9242
|
}
|
|
9237
9243
|
function isWriteTarget(node) {
|
|
9238
9244
|
const access = node.parent.type === "MemberExpression" && node.parent.object === node ? node.parent : node;
|
|
@@ -9275,14 +9281,10 @@ var no_raw_env_default = createRule({
|
|
|
9275
9281
|
CallExpression(node) {
|
|
9276
9282
|
if (!boundaryFile) return;
|
|
9277
9283
|
const callee = node.callee;
|
|
9278
|
-
if (callee.type === "Identifier" && callee.name === "createEnv" || callee.type === "MemberExpression" &&
|
|
9284
|
+
if (callee.type === "Identifier" && callee.name === "createEnv" || callee.type === "MemberExpression" && ASTUtils21.getPropertyName(callee) !== null && (["parse", "safeParse"].includes(ASTUtils21.getPropertyName(callee) ?? "") || (ASTUtils21.getPropertyName(callee) ?? "") === "object" && callee.object.type === "Identifier" && callee.object.name === "z")) hasValidationCall = true;
|
|
9279
9285
|
},
|
|
9280
9286
|
MemberExpression(node) {
|
|
9281
|
-
if (isProcessEnv(node) && node
|
|
9282
|
-
const binding = ASTUtils18.findVariable(context.sourceCode.getScope(node), node.object.name);
|
|
9283
|
-
if (binding !== null && binding.defs.length > 0 && !binding.defs.every((definition) => definition.type === "ImportBinding" && definition.parent.type === "ImportDeclaration" && ["node:process", "process"].includes(definition.parent.source.value) && ["ImportDefaultSpecifier", "ImportNamespaceSpecifier"].includes(definition.node.type))) return;
|
|
9284
|
-
}
|
|
9285
|
-
if ((isProcessEnv(node) || isImportMetaEnv(node)) && !isExemptVariableAccess(node) && !isWriteTarget(node) && !isWholeEnvSpread(node)) {
|
|
9287
|
+
if ((isProcessEnv(node, context) || isImportMetaEnv(node)) && !isExemptVariableAccess(node) && !isWriteTarget(node) && !isWholeEnvSpread(node)) {
|
|
9286
9288
|
reads.push(node);
|
|
9287
9289
|
}
|
|
9288
9290
|
},
|
|
@@ -9295,7 +9297,7 @@ var no_raw_env_default = createRule({
|
|
|
9295
9297
|
});
|
|
9296
9298
|
|
|
9297
9299
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
9298
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES44, ASTUtils as
|
|
9300
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44, ASTUtils as ASTUtils22 } from "@typescript-eslint/utils";
|
|
9299
9301
|
var NO_RAW_FETCH_OUTSIDE_CLIENTS_DOCUMENTATION = {
|
|
9300
9302
|
summary: "Disallow calling the global `fetch` outside the client layer; route outbound HTTP through a client module that owns retry, timeout and status handling.",
|
|
9301
9303
|
rationale: "Scattered fetch calls bypass shared transport policy and are harder to stub and observe consistently.",
|
|
@@ -9483,7 +9485,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
9483
9485
|
internalApiPrefixes.push(`${options.basePath}/api`);
|
|
9484
9486
|
}
|
|
9485
9487
|
function resolvesToGlobal(identifier) {
|
|
9486
|
-
const variable =
|
|
9488
|
+
const variable = ASTUtils22.findVariable(
|
|
9487
9489
|
context.sourceCode.getScope(identifier),
|
|
9488
9490
|
identifier.name
|
|
9489
9491
|
);
|
|
@@ -9492,7 +9494,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
9492
9494
|
function resolveNode2(node) {
|
|
9493
9495
|
if (node === void 0) return null;
|
|
9494
9496
|
if (node.type !== AST_NODE_TYPES44.Identifier) return node;
|
|
9495
|
-
const variable =
|
|
9497
|
+
const variable = ASTUtils22.findVariable(
|
|
9496
9498
|
context.sourceCode.getScope(node),
|
|
9497
9499
|
node.name
|
|
9498
9500
|
);
|
|
@@ -9571,7 +9573,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
9571
9573
|
});
|
|
9572
9574
|
|
|
9573
9575
|
// src/rules/no-restricted-library-load.ts
|
|
9574
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES45, ASTUtils as
|
|
9576
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45, ASTUtils as ASTUtils23 } from "@typescript-eslint/utils";
|
|
9575
9577
|
var NO_RESTRICTED_LIBRARY_LOAD_DOCUMENTATION = {
|
|
9576
9578
|
summary: "Apply configured library restrictions to literal runtime loads and CommonJS resolution references.",
|
|
9577
9579
|
rationale: "Dynamic imports, CommonJS loads, and package resolution checks can bypass library restrictions enforced for static imports.",
|
|
@@ -9656,7 +9658,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
9656
9658
|
});
|
|
9657
9659
|
}
|
|
9658
9660
|
function isUnshadowedRequire(node) {
|
|
9659
|
-
const variable =
|
|
9661
|
+
const variable = ASTUtils23.findVariable(
|
|
9660
9662
|
context.sourceCode.getScope(node),
|
|
9661
9663
|
node.name
|
|
9662
9664
|
);
|
|
@@ -9689,7 +9691,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
9689
9691
|
});
|
|
9690
9692
|
|
|
9691
9693
|
// src/rules/no-router-refresh-polling.ts
|
|
9692
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES46, ASTUtils as
|
|
9694
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46, ASTUtils as ASTUtils24 } from "@typescript-eslint/utils";
|
|
9693
9695
|
var NO_ROUTER_REFRESH_POLLING_DOCUMENTATION = {
|
|
9694
9696
|
summary: "Do not poll by calling a Next.js router's refresh method from a timer.",
|
|
9695
9697
|
rationale: "A route refresh refetches and rerenders the whole route on every tick instead of loading the named resource that changed.",
|
|
@@ -9716,10 +9718,10 @@ function enclosingIntervalCallback(sourceCode, node) {
|
|
|
9716
9718
|
return null;
|
|
9717
9719
|
}
|
|
9718
9720
|
function isIntervalCallee(sourceCode, node) {
|
|
9719
|
-
return node.type === AST_NODE_TYPES46.Identifier && node.name === "setInterval" && isUnshadowedGlobal2(sourceCode, node) || node.type === AST_NODE_TYPES46.MemberExpression &&
|
|
9721
|
+
return node.type === AST_NODE_TYPES46.Identifier && node.name === "setInterval" && isUnshadowedGlobal2(sourceCode, node) || node.type === AST_NODE_TYPES46.MemberExpression && node.object.type === AST_NODE_TYPES46.Identifier && (node.object.name === "window" || node.object.name === "globalThis") && isUnshadowedGlobal2(sourceCode, node.object) && ASTUtils24.getPropertyName(node) !== null && (ASTUtils24.getPropertyName(node) ?? "") === "setInterval";
|
|
9720
9722
|
}
|
|
9721
9723
|
function isUnshadowedGlobal2(sourceCode, node) {
|
|
9722
|
-
const variable =
|
|
9724
|
+
const variable = ASTUtils24.findVariable(sourceCode.getScope(node), node.name);
|
|
9723
9725
|
return variable === null || variable.defs.length === 0;
|
|
9724
9726
|
}
|
|
9725
9727
|
var no_router_refresh_polling_default = createRule({
|
|
@@ -9742,21 +9744,21 @@ var no_router_refresh_polling_default = createRule({
|
|
|
9742
9744
|
if (node.source.value !== "next/navigation") return;
|
|
9743
9745
|
for (const specifier of node.specifiers) {
|
|
9744
9746
|
if (specifier.type === AST_NODE_TYPES46.ImportSpecifier && importedName5(specifier) === "useRouter") {
|
|
9745
|
-
const variable =
|
|
9747
|
+
const variable = ASTUtils24.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
9746
9748
|
if (variable !== null) routerHooks.add(variable);
|
|
9747
9749
|
}
|
|
9748
9750
|
}
|
|
9749
9751
|
},
|
|
9750
9752
|
VariableDeclarator(node) {
|
|
9751
9753
|
if (node.id.type === AST_NODE_TYPES46.Identifier && node.init?.type === AST_NODE_TYPES46.CallExpression && node.init.callee.type === AST_NODE_TYPES46.Identifier) {
|
|
9752
|
-
const hook =
|
|
9753
|
-
const router =
|
|
9754
|
+
const hook = ASTUtils24.findVariable(context.sourceCode.getScope(node.init.callee), node.init.callee.name);
|
|
9755
|
+
const router = ASTUtils24.findVariable(context.sourceCode.getScope(node.id), node.id.name);
|
|
9754
9756
|
if (hook !== null && router !== null && routerHooks.has(hook)) routers.add(router);
|
|
9755
9757
|
}
|
|
9756
9758
|
},
|
|
9757
9759
|
CallExpression(node) {
|
|
9758
|
-
if (node.callee.type !== AST_NODE_TYPES46.MemberExpression || node.callee.
|
|
9759
|
-
const router =
|
|
9760
|
+
if (node.callee.type !== AST_NODE_TYPES46.MemberExpression || node.callee.object.type !== AST_NODE_TYPES46.Identifier || ASTUtils24.getPropertyName(node.callee) === null || (ASTUtils24.getPropertyName(node.callee) ?? "") !== "refresh") return;
|
|
9761
|
+
const router = ASTUtils24.findVariable(
|
|
9760
9762
|
context.sourceCode.getScope(node.callee.object),
|
|
9761
9763
|
node.callee.object.name
|
|
9762
9764
|
);
|
|
@@ -10319,7 +10321,7 @@ function proseTokens(text) {
|
|
|
10319
10321
|
}
|
|
10320
10322
|
|
|
10321
10323
|
// src/rules/no-secret-in-log.ts
|
|
10322
|
-
import "@typescript-eslint/utils";
|
|
10324
|
+
import { ASTUtils as ASTUtils25 } from "@typescript-eslint/utils";
|
|
10323
10325
|
|
|
10324
10326
|
// src/rules/_secret-names.ts
|
|
10325
10327
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -10542,7 +10544,7 @@ function hasRedactionMarker(name) {
|
|
|
10542
10544
|
}
|
|
10543
10545
|
function valueName(node) {
|
|
10544
10546
|
if (node.type === "Identifier") return node.name;
|
|
10545
|
-
return node.type === "MemberExpression" &&
|
|
10547
|
+
return node.type === "MemberExpression" && ASTUtils25.getPropertyName(node) !== null ? ASTUtils25.getPropertyName(node) ?? "" : null;
|
|
10546
10548
|
}
|
|
10547
10549
|
function isRawSecretValue(prop) {
|
|
10548
10550
|
if (prop.shorthand) {
|
|
@@ -10591,11 +10593,11 @@ function rawBlobValueName(value) {
|
|
|
10591
10593
|
if (value.type === "Identifier") {
|
|
10592
10594
|
return isRawBlobName(value.name) ? value.name : null;
|
|
10593
10595
|
}
|
|
10594
|
-
if (value.type === "MemberExpression" &&
|
|
10595
|
-
return isRawBlobName(value
|
|
10596
|
+
if (value.type === "MemberExpression" && ASTUtils25.getPropertyName(value) !== null) {
|
|
10597
|
+
return isRawBlobName(ASTUtils25.getPropertyName(value) ?? "") ? ASTUtils25.getPropertyName(value) ?? "" : null;
|
|
10596
10598
|
}
|
|
10597
|
-
if (value.type === "CallExpression" && value.arguments.length === 0 && value.callee.type === "MemberExpression" &&
|
|
10598
|
-
return `${value.callee.object.name}.${value.callee
|
|
10599
|
+
if (value.type === "CallExpression" && value.arguments.length === 0 && value.callee.type === "MemberExpression" && value.callee.object.type === "Identifier" && /^(?:res|response|\w+Response)$/.test(value.callee.object.name) && ASTUtils25.getPropertyName(value.callee) !== null && ((ASTUtils25.getPropertyName(value.callee) ?? "") === "json" || (ASTUtils25.getPropertyName(value.callee) ?? "") === "text")) {
|
|
10600
|
+
return `${value.callee.object.name}.${ASTUtils25.getPropertyName(value.callee) ?? ""}()`;
|
|
10599
10601
|
}
|
|
10600
10602
|
return null;
|
|
10601
10603
|
}
|
|
@@ -10900,7 +10902,7 @@ var no_select_star_default = createRule({
|
|
|
10900
10902
|
});
|
|
10901
10903
|
|
|
10902
10904
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
10903
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES50, ASTUtils as
|
|
10905
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50, ASTUtils as ASTUtils26 } from "@typescript-eslint/utils";
|
|
10904
10906
|
var NO_SENTINEL_RETURN_ON_CATCH_DOCUMENTATION = {
|
|
10905
10907
|
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.",
|
|
10906
10908
|
rationale: "An unreported fallback makes operational failure indistinguishable from a legitimate empty result.",
|
|
@@ -11053,8 +11055,8 @@ function argsIncludeBinding(args, caughtName) {
|
|
|
11053
11055
|
return args.some((arg) => subtreeReadsName(arg, caughtName));
|
|
11054
11056
|
}
|
|
11055
11057
|
function isParseShapedNode(node) {
|
|
11056
|
-
if (node.type === AST_NODE_TYPES50.CallExpression && node.callee.type === AST_NODE_TYPES50.MemberExpression &&
|
|
11057
|
-
return node.callee
|
|
11058
|
+
if (node.type === AST_NODE_TYPES50.CallExpression && node.callee.type === AST_NODE_TYPES50.MemberExpression && ASTUtils26.getPropertyName(node.callee) !== null) {
|
|
11059
|
+
return (ASTUtils26.getPropertyName(node.callee) ?? "") === "parse";
|
|
11058
11060
|
}
|
|
11059
11061
|
if (node.type === AST_NODE_TYPES50.NewExpression && node.callee.type === AST_NODE_TYPES50.Identifier) {
|
|
11060
11062
|
return SAFE_PARSE_CONSTRUCTORS.has(node.callee.name);
|
|
@@ -11067,21 +11069,21 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
11067
11069
|
"URLPattern"
|
|
11068
11070
|
]);
|
|
11069
11071
|
function isBodyDecodeNode(node) {
|
|
11070
|
-
return node.type === AST_NODE_TYPES50.CallExpression && node.callee.type === AST_NODE_TYPES50.MemberExpression &&
|
|
11072
|
+
return node.type === AST_NODE_TYPES50.CallExpression && node.callee.type === AST_NODE_TYPES50.MemberExpression && ASTUtils26.getPropertyName(node.callee) !== null && BODY_DECODE_METHODS.has(ASTUtils26.getPropertyName(node.callee) ?? "");
|
|
11071
11073
|
}
|
|
11072
11074
|
function isSafeParseSupportCall(node) {
|
|
11073
11075
|
const callee = node.callee;
|
|
11074
|
-
if (callee.type !== AST_NODE_TYPES50.MemberExpression ||
|
|
11076
|
+
if (callee.type !== AST_NODE_TYPES50.MemberExpression || ASTUtils26.getPropertyName(callee) === null) {
|
|
11075
11077
|
return false;
|
|
11076
11078
|
}
|
|
11077
|
-
if (callee
|
|
11079
|
+
if ((ASTUtils26.getPropertyName(callee) ?? "") === "isArray" && callee.object.type === AST_NODE_TYPES50.Identifier && callee.object.name === "Array") {
|
|
11078
11080
|
return true;
|
|
11079
11081
|
}
|
|
11080
|
-
if (callee
|
|
11082
|
+
if ((ASTUtils26.getPropertyName(callee) ?? "") !== "getItem") return false;
|
|
11081
11083
|
if (callee.object.type === AST_NODE_TYPES50.Identifier && (callee.object.name === "localStorage" || callee.object.name === "sessionStorage")) {
|
|
11082
11084
|
return true;
|
|
11083
11085
|
}
|
|
11084
|
-
return callee.object.type === AST_NODE_TYPES50.MemberExpression &&
|
|
11086
|
+
return callee.object.type === AST_NODE_TYPES50.MemberExpression && callee.object.object.type === AST_NODE_TYPES50.Identifier && (callee.object.object.name === "window" || callee.object.object.name === "globalThis") && ASTUtils26.getPropertyName(callee.object) !== null && ((ASTUtils26.getPropertyName(callee.object) ?? "") === "localStorage" || (ASTUtils26.getPropertyName(callee.object) ?? "") === "sessionStorage");
|
|
11085
11087
|
}
|
|
11086
11088
|
var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
11087
11089
|
"json",
|
|
@@ -11293,7 +11295,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
11293
11295
|
return;
|
|
11294
11296
|
}
|
|
11295
11297
|
const returned = unwrapSentinelExpression(last.argument);
|
|
11296
|
-
if (returned?.type === AST_NODE_TYPES50.Identifier && returned.name === "undefined" && (
|
|
11298
|
+
if (returned?.type === AST_NODE_TYPES50.Identifier && returned.name === "undefined" && (ASTUtils26.findVariable(context.sourceCode.getScope(returned), returned.name)?.defs.length ?? 0) > 0) return;
|
|
11297
11299
|
if (containsThrow(node.body)) {
|
|
11298
11300
|
return;
|
|
11299
11301
|
}
|
|
@@ -11336,7 +11338,7 @@ function isNonReadingProperty(current, key) {
|
|
|
11336
11338
|
}
|
|
11337
11339
|
|
|
11338
11340
|
// src/rules/no-silent-promise-catch.ts
|
|
11339
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES51, ASTUtils as
|
|
11341
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51, ASTUtils as ASTUtils27 } from "@typescript-eslint/utils";
|
|
11340
11342
|
var NO_SILENT_PROMISE_CATCH_DOCUMENTATION = {
|
|
11341
11343
|
summary: "Disallow `.catch()` and second-argument `.then()` handlers that silently swallow a rejection; log, rethrow, or handle the error.",
|
|
11342
11344
|
rationale: "A swallowed rejection hides failures and gives callers an indistinguishable fallback value.",
|
|
@@ -11394,7 +11396,7 @@ var ZOD_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
11394
11396
|
"transform"
|
|
11395
11397
|
]);
|
|
11396
11398
|
function isBodyParseCall(node) {
|
|
11397
|
-
return node.type === AST_NODE_TYPES51.CallExpression && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES51.MemberExpression &&
|
|
11399
|
+
return node.type === AST_NODE_TYPES51.CallExpression && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES51.MemberExpression && ASTUtils27.getPropertyName(node.callee) !== null && BODY_PARSE_METHODS.has(ASTUtils27.getPropertyName(node.callee) ?? "");
|
|
11398
11400
|
}
|
|
11399
11401
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
11400
11402
|
"cancel",
|
|
@@ -11409,10 +11411,10 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
11409
11411
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
11410
11412
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
11411
11413
|
function isTeardownCall(node) {
|
|
11412
|
-
return node.type === AST_NODE_TYPES51.CallExpression && node.callee.type === AST_NODE_TYPES51.MemberExpression &&
|
|
11414
|
+
return node.type === AST_NODE_TYPES51.CallExpression && node.callee.type === AST_NODE_TYPES51.MemberExpression && ASTUtils27.getPropertyName(node.callee) !== null && TEARDOWN_METHODS.has(ASTUtils27.getPropertyName(node.callee) ?? "");
|
|
11413
11415
|
}
|
|
11414
11416
|
function isCancelledWebShare(node) {
|
|
11415
|
-
return node.type === AST_NODE_TYPES51.CallExpression && node.callee.type === AST_NODE_TYPES51.MemberExpression &&
|
|
11417
|
+
return node.type === AST_NODE_TYPES51.CallExpression && node.callee.type === AST_NODE_TYPES51.MemberExpression && node.callee.object.type === AST_NODE_TYPES51.Identifier && node.callee.object.name === "navigator" && ASTUtils27.getPropertyName(node.callee) !== null && (ASTUtils27.getPropertyName(node.callee) ?? "") === "share";
|
|
11416
11418
|
}
|
|
11417
11419
|
function isSilentHandler(handler) {
|
|
11418
11420
|
const body2 = handler.body;
|
|
@@ -11470,21 +11472,22 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11470
11472
|
if (seen.has(node)) return false;
|
|
11471
11473
|
seen.add(node);
|
|
11472
11474
|
if (node.type === AST_NODE_TYPES51.Identifier) {
|
|
11473
|
-
const binding =
|
|
11475
|
+
const binding = ASTUtils27.findVariable(context.sourceCode.getScope(node), node.name);
|
|
11474
11476
|
if (binding === null || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
11475
11477
|
const [definition] = binding.defs;
|
|
11476
11478
|
return binding.defs.length === 1 && definition?.node.type === AST_NODE_TYPES51.VariableDeclarator && definition.node.init !== null && isZodSchema(definition.node.init, seen);
|
|
11477
11479
|
}
|
|
11478
|
-
if (node.type !== AST_NODE_TYPES51.CallExpression || node.callee.type !== AST_NODE_TYPES51.MemberExpression ||
|
|
11479
|
-
const { object
|
|
11480
|
-
|
|
11481
|
-
|
|
11480
|
+
if (node.type !== AST_NODE_TYPES51.CallExpression || node.callee.type !== AST_NODE_TYPES51.MemberExpression || ASTUtils27.getPropertyName(node.callee) === null) return false;
|
|
11481
|
+
const { object } = node.callee;
|
|
11482
|
+
const method = ASTUtils27.getPropertyName(node.callee);
|
|
11483
|
+
if (object.type === AST_NODE_TYPES51.Identifier && method !== null && ZOD_CONSTRUCTORS.has(method)) {
|
|
11484
|
+
const binding = ASTUtils27.findVariable(context.sourceCode.getScope(object), object.name);
|
|
11482
11485
|
if (binding?.defs.some((definition) => {
|
|
11483
11486
|
const specifier = definition.node;
|
|
11484
11487
|
return (specifier.type === AST_NODE_TYPES51.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES51.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES51.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES51.Identifier && specifier.imported.name === "z") && specifier.parent.type === AST_NODE_TYPES51.ImportDeclaration && isZodModule(String(specifier.parent.source.value));
|
|
11485
11488
|
})) return true;
|
|
11486
11489
|
}
|
|
11487
|
-
return ZOD_CHAIN_METHODS.has(
|
|
11490
|
+
return method !== null && ZOD_CHAIN_METHODS.has(method) && isZodSchema(object, seen);
|
|
11488
11491
|
}
|
|
11489
11492
|
const hasExplanatoryComment = (call, handler) => {
|
|
11490
11493
|
const sourceCode = context.sourceCode;
|
|
@@ -11504,10 +11507,10 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11504
11507
|
};
|
|
11505
11508
|
return {
|
|
11506
11509
|
CallExpression(node) {
|
|
11507
|
-
if (node.callee.type !== AST_NODE_TYPES51.MemberExpression ||
|
|
11510
|
+
if (node.callee.type !== AST_NODE_TYPES51.MemberExpression || ASTUtils27.getPropertyName(node.callee) === null) {
|
|
11508
11511
|
return;
|
|
11509
11512
|
}
|
|
11510
|
-
const method = node.callee
|
|
11513
|
+
const method = ASTUtils27.getPropertyName(node.callee) ?? "";
|
|
11511
11514
|
const handlerIndex = method === "catch" ? 0 : method === "then" ? 1 : null;
|
|
11512
11515
|
if (handlerIndex === null) return;
|
|
11513
11516
|
if (method === "catch" && isZodSchema(node.callee.object)) return;
|
|
@@ -11520,7 +11523,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11520
11523
|
if (isCancelledWebShare(node.callee.object)) {
|
|
11521
11524
|
return;
|
|
11522
11525
|
}
|
|
11523
|
-
if (node.parent.type === AST_NODE_TYPES51.MemberExpression && node.parent.object === node &&
|
|
11526
|
+
if (node.parent.type === AST_NODE_TYPES51.MemberExpression && node.parent.object === node && ASTUtils27.getPropertyName(node.parent) !== null && (ASTUtils27.getPropertyName(node.parent) ?? "") === "then") {
|
|
11524
11527
|
return;
|
|
11525
11528
|
}
|
|
11526
11529
|
const expectedArguments = method === "catch" ? 1 : 2;
|
|
@@ -11543,7 +11546,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11543
11546
|
});
|
|
11544
11547
|
|
|
11545
11548
|
// src/rules/no-sleep-in-test-body.ts
|
|
11546
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES52, ASTUtils as
|
|
11549
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52, ASTUtils as ASTUtils28 } from "@typescript-eslint/utils";
|
|
11547
11550
|
var NO_SLEEP_IN_TEST_BODY_DOCUMENTATION = {
|
|
11548
11551
|
summary: "Avoid fixed timed sleeps directly in test bodies; synchronize on observable behavior or use controlled timers.",
|
|
11549
11552
|
rationale: "Wall-clock delays make test correctness depend on scheduler and machine speed.",
|
|
@@ -11666,8 +11669,8 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
11666
11669
|
return {
|
|
11667
11670
|
NewExpression(node) {
|
|
11668
11671
|
if (isPromiseSleep(node)) {
|
|
11669
|
-
const constructor =
|
|
11670
|
-
const timer =
|
|
11672
|
+
const constructor = ASTUtils28.findVariable(context.sourceCode.getScope(node), "Promise");
|
|
11673
|
+
const timer = ASTUtils28.findVariable(context.sourceCode.getScope(node), "setTimeout");
|
|
11671
11674
|
if ((constructor?.defs.length ?? 0) > 0 || (timer?.defs.length ?? 0) > 0) return;
|
|
11672
11675
|
report2(node);
|
|
11673
11676
|
}
|
|
@@ -11675,7 +11678,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
11675
11678
|
CallExpression(node) {
|
|
11676
11679
|
if (isHelperSleep(node)) {
|
|
11677
11680
|
if (node.callee.type !== AST_NODE_TYPES52.Identifier) return;
|
|
11678
|
-
const variable =
|
|
11681
|
+
const variable = ASTUtils28.findVariable(context.sourceCode.getScope(node), node.callee.name);
|
|
11679
11682
|
if (variable?.defs.some((definition) => definition.type !== "ImportBinding")) return;
|
|
11680
11683
|
report2(node);
|
|
11681
11684
|
}
|
|
@@ -11685,7 +11688,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
11685
11688
|
});
|
|
11686
11689
|
|
|
11687
11690
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
11688
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES53 } from "@typescript-eslint/utils";
|
|
11691
|
+
import { ASTUtils as ASTUtils29, AST_NODE_TYPES as AST_NODE_TYPES53 } from "@typescript-eslint/utils";
|
|
11689
11692
|
var DEFAULT_METHODS2 = [
|
|
11690
11693
|
"prepare",
|
|
11691
11694
|
"put",
|
|
@@ -11718,10 +11721,10 @@ var STORAGE_RECEIVER_WORDS = /* @__PURE__ */ new Set([
|
|
|
11718
11721
|
]);
|
|
11719
11722
|
function storageMethodName(node, methods) {
|
|
11720
11723
|
const callee = node.callee;
|
|
11721
|
-
if (callee.type !== AST_NODE_TYPES53.MemberExpression ||
|
|
11724
|
+
if (callee.type !== AST_NODE_TYPES53.MemberExpression || ASTUtils29.getPropertyName(callee) === null) {
|
|
11722
11725
|
return null;
|
|
11723
11726
|
}
|
|
11724
|
-
const name = callee
|
|
11727
|
+
const name = ASTUtils29.getPropertyName(callee) ?? "";
|
|
11725
11728
|
if (!methods.has(name)) {
|
|
11726
11729
|
return null;
|
|
11727
11730
|
}
|
|
@@ -11741,7 +11744,7 @@ function isStorageLikeReceiver(node) {
|
|
|
11741
11744
|
if (node.type !== AST_NODE_TYPES53.MemberExpression) {
|
|
11742
11745
|
return false;
|
|
11743
11746
|
}
|
|
11744
|
-
if (
|
|
11747
|
+
if (ASTUtils29.getPropertyName(node) !== null && isStorageIdentifier(ASTUtils29.getPropertyName(node) ?? "")) {
|
|
11745
11748
|
return true;
|
|
11746
11749
|
}
|
|
11747
11750
|
return isStorageLikeReceiver(node.object);
|
|
@@ -11819,7 +11822,7 @@ function hasSqlPreparationEvidence(node, callee) {
|
|
|
11819
11822
|
if (!/^\s*(?:SELECT|WITH|INSERT|UPDATE|DELETE|REPLACE|CREATE|ALTER|DROP|PRAGMA|EXPLAIN)\b/iu.test(stripSqlNoise(text))) return false;
|
|
11820
11823
|
} else {
|
|
11821
11824
|
const receiver = callee.object;
|
|
11822
|
-
const receiverName = receiver.type === AST_NODE_TYPES53.Identifier ? receiver.name : receiver.type === AST_NODE_TYPES53.MemberExpression &&
|
|
11825
|
+
const receiverName = receiver.type === AST_NODE_TYPES53.Identifier ? receiver.name : receiver.type === AST_NODE_TYPES53.MemberExpression && ASTUtils29.getPropertyName(receiver) !== null ? ASTUtils29.getPropertyName(receiver) ?? "" : "";
|
|
11823
11826
|
if (!/^(?:db|database|connection)$/iu.test(receiverName)) return false;
|
|
11824
11827
|
}
|
|
11825
11828
|
return true;
|
|
@@ -12081,7 +12084,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
12081
12084
|
});
|
|
12082
12085
|
|
|
12083
12086
|
// src/rules/no-tautological-expect.ts
|
|
12084
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES54, ASTUtils as
|
|
12087
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54, ASTUtils as ASTUtils30 } from "@typescript-eslint/utils";
|
|
12085
12088
|
var NO_TAUTOLOGICAL_EXPECT_DOCUMENTATION = {
|
|
12086
12089
|
summary: "Disallow supported literal-only assertions that are statically known to pass.",
|
|
12087
12090
|
rationale: "An assertion determined entirely by literals does not observe the code under test and can keep passing after that code is removed.",
|
|
@@ -12213,16 +12216,16 @@ var no_tautological_expect_default = createRule({
|
|
|
12213
12216
|
return {
|
|
12214
12217
|
CallExpression(node) {
|
|
12215
12218
|
const callee = node.callee;
|
|
12216
|
-
if (callee.type !== AST_NODE_TYPES54.MemberExpression || callee
|
|
12219
|
+
if (callee.type !== AST_NODE_TYPES54.MemberExpression || ASTUtils30.getPropertyName(callee) === null) {
|
|
12217
12220
|
return;
|
|
12218
12221
|
}
|
|
12219
|
-
if (callee
|
|
12222
|
+
if (ASTUtils30.getPropertyName(callee) === null) {
|
|
12220
12223
|
return;
|
|
12221
12224
|
}
|
|
12222
|
-
const matcher = callee
|
|
12225
|
+
const matcher = ASTUtils30.getPropertyName(callee) ?? "";
|
|
12223
12226
|
if (callee.object.type !== AST_NODE_TYPES54.CallExpression || callee.object.callee.type !== AST_NODE_TYPES54.Identifier) return;
|
|
12224
12227
|
const expectIdentifier = callee.object.callee;
|
|
12225
|
-
const variable =
|
|
12228
|
+
const variable = ASTUtils30.findVariable(context.sourceCode.getScope(expectIdentifier), expectIdentifier.name);
|
|
12226
12229
|
if (variable !== null && variable.defs.some((definition) => {
|
|
12227
12230
|
if (definition.node.type !== AST_NODE_TYPES54.ImportSpecifier) return true;
|
|
12228
12231
|
const declaration = definition.node.parent;
|
|
@@ -13470,7 +13473,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
13470
13473
|
// src/rules/no-unsafe-mock-casting.ts
|
|
13471
13474
|
import {
|
|
13472
13475
|
AST_NODE_TYPES as AST_NODE_TYPES60,
|
|
13473
|
-
ASTUtils as
|
|
13476
|
+
ASTUtils as ASTUtils31
|
|
13474
13477
|
} from "@typescript-eslint/utils";
|
|
13475
13478
|
var MOCK_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
13476
13479
|
"Mock",
|
|
@@ -13537,7 +13540,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
13537
13540
|
const directBindings = /* @__PURE__ */ new Set();
|
|
13538
13541
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
13539
13542
|
function resolve2(identifier) {
|
|
13540
|
-
return
|
|
13543
|
+
return ASTUtils31.findVariable(
|
|
13541
13544
|
context.sourceCode.getScope(identifier),
|
|
13542
13545
|
identifier.name
|
|
13543
13546
|
);
|
|
@@ -13584,12 +13587,12 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
13584
13587
|
});
|
|
13585
13588
|
|
|
13586
13589
|
// src/rules/no-unsafe-test-double-cast.ts
|
|
13587
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES62 } from "@typescript-eslint/utils";
|
|
13590
|
+
import { ASTUtils as ASTUtils33, AST_NODE_TYPES as AST_NODE_TYPES62 } from "@typescript-eslint/utils";
|
|
13588
13591
|
|
|
13589
13592
|
// src/rules/_test-mock-provenance.ts
|
|
13590
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES61, ASTUtils as
|
|
13593
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES61, ASTUtils as ASTUtils32 } from "@typescript-eslint/utils";
|
|
13591
13594
|
function importedTestMockNamespace(source, identifier) {
|
|
13592
|
-
const binding =
|
|
13595
|
+
const binding = ASTUtils32.findVariable(source.getScope(identifier), identifier.name);
|
|
13593
13596
|
if (binding?.defs.length !== 1) return null;
|
|
13594
13597
|
const definition = binding.defs[0];
|
|
13595
13598
|
if (definition?.type !== "ImportBinding" || definition.parent.type !== AST_NODE_TYPES61.ImportDeclaration || definition.parent.importKind === "type") return null;
|
|
@@ -13603,7 +13606,7 @@ function importedTestMockNamespace(source, identifier) {
|
|
|
13603
13606
|
}
|
|
13604
13607
|
function isUnshadowedTestMockGlobal(source, identifier) {
|
|
13605
13608
|
if (identifier.name !== "vi" && identifier.name !== "jest") return false;
|
|
13606
|
-
const binding =
|
|
13609
|
+
const binding = ASTUtils32.findVariable(source.getScope(identifier), identifier.name);
|
|
13607
13610
|
return binding === null || binding.defs.length === 0 && !binding.references.some((reference) => reference.isWrite());
|
|
13608
13611
|
}
|
|
13609
13612
|
|
|
@@ -13636,7 +13639,7 @@ function containsMockFactory(node, source) {
|
|
|
13636
13639
|
return false;
|
|
13637
13640
|
}
|
|
13638
13641
|
function isMockFactory(node, source) {
|
|
13639
|
-
return node.type === AST_NODE_TYPES62.CallExpression && node.callee.type === AST_NODE_TYPES62.MemberExpression &&
|
|
13642
|
+
return node.type === AST_NODE_TYPES62.CallExpression && node.callee.type === AST_NODE_TYPES62.MemberExpression && node.callee.object.type === AST_NODE_TYPES62.Identifier && (importedTestMockNamespace(source, node.callee.object) !== null || isUnshadowedTestMockGlobal(source, node.callee.object)) && ASTUtils33.getPropertyName(node.callee) !== null && ["fn", "spyOn"].includes(ASTUtils33.getPropertyName(node.callee) ?? "");
|
|
13640
13643
|
}
|
|
13641
13644
|
var no_unsafe_test_double_cast_default = createRule({
|
|
13642
13645
|
name: "no-unsafe-test-double-cast",
|
|
@@ -13662,7 +13665,7 @@ var no_unsafe_test_double_cast_default = createRule({
|
|
|
13662
13665
|
});
|
|
13663
13666
|
|
|
13664
13667
|
// src/rules/no-first-party-module-mock.ts
|
|
13665
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES63 } from "@typescript-eslint/utils";
|
|
13668
|
+
import { ASTUtils as ASTUtils34, AST_NODE_TYPES as AST_NODE_TYPES63 } from "@typescript-eslint/utils";
|
|
13666
13669
|
var NO_FIRST_PARTY_MODULE_MOCK_DOCUMENTATION = {
|
|
13667
13670
|
summary: "Prefer injected collaborators over mocking maintained first-party modules in tests.",
|
|
13668
13671
|
rationale: "Replacing an owned module couples tests to its lookup path and can verify mock wiring while bypassing the real implementation contract.",
|
|
@@ -13691,7 +13694,7 @@ var no_first_party_module_mock_default = createRule({
|
|
|
13691
13694
|
if (!isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
13692
13695
|
return {
|
|
13693
13696
|
CallExpression(node) {
|
|
13694
|
-
if (node.callee.type !== AST_NODE_TYPES63.MemberExpression || node.callee.
|
|
13697
|
+
if (node.callee.type !== AST_NODE_TYPES63.MemberExpression || node.callee.object.type !== AST_NODE_TYPES63.Identifier || ASTUtils34.getPropertyName(node.callee) === null || !["mock", "doMock"].includes(ASTUtils34.getPropertyName(node.callee) ?? "")) return;
|
|
13695
13698
|
const framework = importedTestMockNamespace(context.sourceCode, node.callee.object);
|
|
13696
13699
|
if (framework === null || framework === "jest" && mayBeVirtual(node.arguments[2])) return;
|
|
13697
13700
|
const argument = node.arguments[0];
|
|
@@ -13716,7 +13719,7 @@ function mayBeVirtual(options) {
|
|
|
13716
13719
|
import {
|
|
13717
13720
|
ESLintUtils as ESLintUtils10,
|
|
13718
13721
|
AST_NODE_TYPES as AST_NODE_TYPES64,
|
|
13719
|
-
ASTUtils as
|
|
13722
|
+
ASTUtils as ASTUtils35
|
|
13720
13723
|
} from "@typescript-eslint/utils";
|
|
13721
13724
|
import * as ts9 from "typescript";
|
|
13722
13725
|
var NO_ZOD_NATIVE_ENUM_DOCUMENTATION = {
|
|
@@ -13826,7 +13829,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
13826
13829
|
const zodImportedBindings = /* @__PURE__ */ new Map();
|
|
13827
13830
|
const zodNamespaceBindings = /* @__PURE__ */ new Set();
|
|
13828
13831
|
function resolvedBinding(identifier) {
|
|
13829
|
-
return
|
|
13832
|
+
return ASTUtils35.findVariable(
|
|
13830
13833
|
sourceCode.getScope(identifier),
|
|
13831
13834
|
identifier.name
|
|
13832
13835
|
);
|
|
@@ -13892,7 +13895,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
13892
13895
|
});
|
|
13893
13896
|
|
|
13894
13897
|
// src/rules/test-loops-over-literal-cases.ts
|
|
13895
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES65, ASTUtils as
|
|
13898
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES65, ASTUtils as ASTUtils36 } from "@typescript-eslint/utils";
|
|
13896
13899
|
var TEST_LOOPS_OVER_LITERAL_CASES_DOCUMENTATION = {
|
|
13897
13900
|
summary: "Disallow assertions over an inline literal case loop in a test; parameterization reports and names every case independently.",
|
|
13898
13901
|
rationale: "A loop is reported as one test, so failures hide the individual case name and may stop later cases from running.",
|
|
@@ -14039,7 +14042,7 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
14039
14042
|
return {};
|
|
14040
14043
|
}
|
|
14041
14044
|
const isFrameworkIdentifier = (identifier, modules) => {
|
|
14042
|
-
const variable =
|
|
14045
|
+
const variable = ASTUtils36.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
14043
14046
|
if (variable === null || variable.defs.length === 0) return true;
|
|
14044
14047
|
return variable.defs.some((definition) => {
|
|
14045
14048
|
let current = definition.node;
|
|
@@ -14069,7 +14072,7 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
14069
14072
|
}
|
|
14070
14073
|
const capturesSetup = walkOwnScope2(node.body, (current) => {
|
|
14071
14074
|
if (current.type !== AST_NODE_TYPES65.Identifier) return false;
|
|
14072
|
-
const variable =
|
|
14075
|
+
const variable = ASTUtils36.findVariable(context.sourceCode.getScope(current), current.name);
|
|
14073
14076
|
if (variable === null || !variable.references.some((reference) => reference.identifier === current)) return false;
|
|
14074
14077
|
return variable.defs.some((definition) => {
|
|
14075
14078
|
const declaration = definition.name;
|
|
@@ -14529,7 +14532,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
14529
14532
|
});
|
|
14530
14533
|
|
|
14531
14534
|
// src/rules/prefer-input-group-search.ts
|
|
14532
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES70, ASTUtils as
|
|
14535
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES70, ASTUtils as ASTUtils37 } from "@typescript-eslint/utils";
|
|
14533
14536
|
var PREFER_INPUT_GROUP_SEARCH_DOCUMENTATION = {
|
|
14534
14537
|
summary: "Require search icons and shared Input controls in the same visual wrapper to use InputGroup.",
|
|
14535
14538
|
rationale: "The shared compound control provides consistent spacing, focus behavior, and accessible composition.",
|
|
@@ -14653,7 +14656,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
14653
14656
|
JSXOpeningElement(node) {
|
|
14654
14657
|
const name = elementName(node);
|
|
14655
14658
|
if (name === null) return;
|
|
14656
|
-
const binding =
|
|
14659
|
+
const binding = ASTUtils37.findVariable(context.sourceCode.getScope(node), name);
|
|
14657
14660
|
if (binding?.defs.length !== 1 || binding.defs[0]?.node.type !== AST_NODE_TYPES70.ImportSpecifier || binding.defs[0].node.importKind === "type") return;
|
|
14658
14661
|
const occurrence = {
|
|
14659
14662
|
ancestors: context.sourceCode.getAncestors(node),
|
|
@@ -14693,7 +14696,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
14693
14696
|
|
|
14694
14697
|
// src/rules/prefer-millisecond-control-duration-schema.ts
|
|
14695
14698
|
import {
|
|
14696
|
-
ASTUtils as
|
|
14699
|
+
ASTUtils as ASTUtils38,
|
|
14697
14700
|
AST_NODE_TYPES as AST_NODE_TYPES71
|
|
14698
14701
|
} from "@typescript-eslint/utils";
|
|
14699
14702
|
var PREFER_MILLISECOND_CONTROL_DURATION_SCHEMA_DOCUMENTATION = {
|
|
@@ -14764,7 +14767,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
14764
14767
|
const objectFactories = /* @__PURE__ */ new Set();
|
|
14765
14768
|
const numberFactories = /* @__PURE__ */ new Set();
|
|
14766
14769
|
function binding(identifier) {
|
|
14767
|
-
return
|
|
14770
|
+
return ASTUtils38.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
14768
14771
|
}
|
|
14769
14772
|
function record(target, identifier) {
|
|
14770
14773
|
const variable = binding(identifier);
|
|
@@ -14776,7 +14779,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
14776
14779
|
const variable2 = binding(callee);
|
|
14777
14780
|
return variable2 !== null && objectFactories.has(variable2);
|
|
14778
14781
|
}
|
|
14779
|
-
if (callee.type !== AST_NODE_TYPES71.MemberExpression || callee.
|
|
14782
|
+
if (callee.type !== AST_NODE_TYPES71.MemberExpression || callee.object.type !== AST_NODE_TYPES71.Identifier || ASTUtils38.getPropertyName(callee) === null || (ASTUtils38.getPropertyName(callee) ?? "") !== "object" && (ASTUtils38.getPropertyName(callee) ?? "") !== "strictObject") {
|
|
14780
14783
|
return false;
|
|
14781
14784
|
}
|
|
14782
14785
|
const variable = binding(callee.object);
|
|
@@ -14789,12 +14792,12 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
14789
14792
|
const variable = binding(callee);
|
|
14790
14793
|
return variable !== null && numberFactories.has(variable);
|
|
14791
14794
|
}
|
|
14792
|
-
if (callee.type !== AST_NODE_TYPES71.MemberExpression ||
|
|
14795
|
+
if (callee.type !== AST_NODE_TYPES71.MemberExpression || ASTUtils38.getPropertyName(callee) === null) return false;
|
|
14793
14796
|
if (callee.object.type === AST_NODE_TYPES71.Identifier) {
|
|
14794
14797
|
const variable = binding(callee.object);
|
|
14795
|
-
return callee
|
|
14798
|
+
return (ASTUtils38.getPropertyName(callee) ?? "") === "number" && variable !== null && zodNamespaces.has(variable);
|
|
14796
14799
|
}
|
|
14797
|
-
return ["int", "min", "max", "positive", "nonnegative", "finite", "multipleOf", "optional", "nullable", "nullish", "default", "describe", "brand", "readonly"].includes(callee
|
|
14800
|
+
return ["int", "min", "max", "positive", "nonnegative", "finite", "multipleOf", "optional", "nullable", "nullish", "default", "describe", "brand", "readonly"].includes(ASTUtils38.getPropertyName(callee) ?? "") && isNumericSchema(callee.object);
|
|
14798
14801
|
}
|
|
14799
14802
|
return {
|
|
14800
14803
|
ImportDeclaration(node) {
|
|
@@ -14828,7 +14831,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
14828
14831
|
});
|
|
14829
14832
|
|
|
14830
14833
|
// src/rules/prefer-immutable-module-constant.ts
|
|
14831
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES72, ASTUtils as
|
|
14834
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES72, ASTUtils as ASTUtils39 } from "@typescript-eslint/utils";
|
|
14832
14835
|
var PREFER_IMMUTABLE_MODULE_CONSTANT_DOCUMENTATION = {
|
|
14833
14836
|
summary: "Require module-level constant collections to expose readonly state.",
|
|
14834
14837
|
rationale: "A const binding prevents reassignment but does not stop callers from mutating its array, object, Set, or Map contents.",
|
|
@@ -15047,15 +15050,15 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
15047
15050
|
create(context) {
|
|
15048
15051
|
const sourceCode = context.sourceCode;
|
|
15049
15052
|
const isUnshadowedGlobal3 = (identifier) => {
|
|
15050
|
-
const variable =
|
|
15053
|
+
const variable = ASTUtils39.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
15051
15054
|
return variable === null || variable.defs.length === 0;
|
|
15052
15055
|
};
|
|
15053
15056
|
const isUnshadowedType = (identifier) => {
|
|
15054
|
-
const variable =
|
|
15057
|
+
const variable = ASTUtils39.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
15055
15058
|
return variable === null || !variable.defs.some((definition) => definition.isTypeDefinition);
|
|
15056
15059
|
};
|
|
15057
15060
|
const resolveLocalType = (identifier) => {
|
|
15058
|
-
const variable =
|
|
15061
|
+
const variable = ASTUtils39.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
15059
15062
|
const definitions = variable?.defs.filter((definition) => definition.isTypeDefinition) ?? [];
|
|
15060
15063
|
const declaration = definitions.length === 1 ? definitions[0]?.node : void 0;
|
|
15061
15064
|
return declaration?.type === AST_NODE_TYPES72.TSTypeAliasDeclaration || declaration?.type === AST_NODE_TYPES72.TSTypeParameter ? declaration : void 0;
|
|
@@ -15871,7 +15874,7 @@ function isSafeMemberRead(identifier, parent) {
|
|
|
15871
15874
|
}
|
|
15872
15875
|
|
|
15873
15876
|
// src/rules/prefer-module-level-schema.ts
|
|
15874
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES75 } from "@typescript-eslint/utils";
|
|
15877
|
+
import { ASTUtils as ASTUtils40, AST_NODE_TYPES as AST_NODE_TYPES75 } from "@typescript-eslint/utils";
|
|
15875
15878
|
var PREFER_MODULE_LEVEL_SCHEMA_DOCUMENTATION = {
|
|
15876
15879
|
summary: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function",
|
|
15877
15880
|
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.",
|
|
@@ -15979,7 +15982,7 @@ function schemaExpression(node) {
|
|
|
15979
15982
|
if (parent === void 0) {
|
|
15980
15983
|
return current;
|
|
15981
15984
|
}
|
|
15982
|
-
if (parent.type === AST_NODE_TYPES75.MemberExpression && parent.object === current &&
|
|
15985
|
+
if (parent.type === AST_NODE_TYPES75.MemberExpression && parent.object === current && ASTUtils40.getPropertyName(parent) !== null && TERMINAL_METHODS.has(ASTUtils40.getPropertyName(parent) ?? "")) {
|
|
15983
15986
|
return current;
|
|
15984
15987
|
}
|
|
15985
15988
|
if (parent.type === AST_NODE_TYPES75.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES75.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES75.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES75.TSNonNullExpression && parent.expression === current) {
|
|
@@ -16049,7 +16052,7 @@ function buildsLocalizedText(node) {
|
|
|
16049
16052
|
if (callee.type === AST_NODE_TYPES75.Identifier) {
|
|
16050
16053
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
16051
16054
|
}
|
|
16052
|
-
return callee.type === AST_NODE_TYPES75.MemberExpression &&
|
|
16055
|
+
return callee.type === AST_NODE_TYPES75.MemberExpression && callee.object.type === AST_NODE_TYPES75.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
16053
16056
|
});
|
|
16054
16057
|
}
|
|
16055
16058
|
function collectReferences(scope, out) {
|
|
@@ -16113,13 +16116,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16113
16116
|
}
|
|
16114
16117
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
16115
16118
|
function isZodCall(node) {
|
|
16116
|
-
return node.type === AST_NODE_TYPES75.CallExpression && node.callee.type === AST_NODE_TYPES75.MemberExpression &&
|
|
16119
|
+
return node.type === AST_NODE_TYPES75.CallExpression && node.callee.type === AST_NODE_TYPES75.MemberExpression && ASTUtils40.getPropertyName(node.callee) !== null && node.callee.object.type === AST_NODE_TYPES75.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
16117
16120
|
}
|
|
16118
16121
|
function isSchemaConstruction(node) {
|
|
16119
16122
|
const callee = node.callee;
|
|
16120
|
-
if (callee.type !== AST_NODE_TYPES75.MemberExpression ||
|
|
16123
|
+
if (callee.type !== AST_NODE_TYPES75.MemberExpression || ASTUtils40.getPropertyName(callee) === null || TERMINAL_METHODS.has(ASTUtils40.getPropertyName(callee) ?? "")) return false;
|
|
16121
16124
|
if (callee.object.type === AST_NODE_TYPES75.CallExpression) return isSchemaConstruction(callee.object);
|
|
16122
|
-
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(callee
|
|
16125
|
+
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(ASTUtils40.getPropertyName(callee) ?? "");
|
|
16123
16126
|
}
|
|
16124
16127
|
function hasEagerComputation(node) {
|
|
16125
16128
|
return subtreeSome(node, (inner) => inner.type === AST_NODE_TYPES75.NewExpression || inner.type === AST_NODE_TYPES75.TaggedTemplateExpression || inner.type === AST_NODE_TYPES75.CallExpression && !isSchemaConstruction(inner), true);
|
|
@@ -16127,10 +16130,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16127
16130
|
function isCovered(node) {
|
|
16128
16131
|
let current = node.parent ?? void 0;
|
|
16129
16132
|
while (current !== void 0) {
|
|
16130
|
-
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES75.MemberExpression && current.callee
|
|
16133
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES75.MemberExpression && ASTUtils40.getPropertyName(current.callee) !== null && factories.has(ASTUtils40.getPropertyName(current.callee) ?? "")) {
|
|
16131
16134
|
return true;
|
|
16132
16135
|
}
|
|
16133
|
-
if (current.type === AST_NODE_TYPES75.CallExpression && (current.callee.type === AST_NODE_TYPES75.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES75.MemberExpression &&
|
|
16136
|
+
if (current.type === AST_NODE_TYPES75.CallExpression && (current.callee.type === AST_NODE_TYPES75.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES75.MemberExpression && ASTUtils40.getPropertyName(current.callee) !== null && memoCallees.has(ASTUtils40.getPropertyName(current.callee) ?? ""))) {
|
|
16134
16137
|
return true;
|
|
16135
16138
|
}
|
|
16136
16139
|
current = current.parent ?? void 0;
|
|
@@ -16159,7 +16162,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16159
16162
|
}
|
|
16160
16163
|
function isSchemaComposition(node) {
|
|
16161
16164
|
const { callee } = node;
|
|
16162
|
-
const isCombinator = callee.type === AST_NODE_TYPES75.MemberExpression &&
|
|
16165
|
+
const isCombinator = callee.type === AST_NODE_TYPES75.MemberExpression && ASTUtils40.getPropertyName(callee) !== null && ZOD_COMBINATOR_METHODS.has(ASTUtils40.getPropertyName(callee) ?? "");
|
|
16163
16166
|
return isCombinator || isZodCall(node);
|
|
16164
16167
|
}
|
|
16165
16168
|
function closesOverNothing(node, enclosing) {
|
|
@@ -16231,10 +16234,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16231
16234
|
return;
|
|
16232
16235
|
}
|
|
16233
16236
|
const callee = node.callee;
|
|
16234
|
-
if (callee
|
|
16237
|
+
if (ASTUtils40.getPropertyName(callee) === null) {
|
|
16235
16238
|
return;
|
|
16236
16239
|
}
|
|
16237
|
-
const factory = callee
|
|
16240
|
+
const factory = ASTUtils40.getPropertyName(callee) ?? "";
|
|
16238
16241
|
if (!factories.has(factory)) {
|
|
16239
16242
|
return;
|
|
16240
16243
|
}
|
|
@@ -16277,7 +16280,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16277
16280
|
// src/rules/prefer-module-level-refined-schema.ts
|
|
16278
16281
|
import {
|
|
16279
16282
|
AST_NODE_TYPES as AST_NODE_TYPES76,
|
|
16280
|
-
ASTUtils as
|
|
16283
|
+
ASTUtils as ASTUtils41
|
|
16281
16284
|
} from "@typescript-eslint/utils";
|
|
16282
16285
|
var BENCHMARK_PATH_RE = /(^|[/\\])(?:benchmarks?|bench)[/\\]/;
|
|
16283
16286
|
var FACTORIES = /* @__PURE__ */ new Set([
|
|
@@ -16478,7 +16481,7 @@ function buildsLocalizedText2(node) {
|
|
|
16478
16481
|
const { callee } = inner;
|
|
16479
16482
|
if (callee.type === AST_NODE_TYPES76.Identifier)
|
|
16480
16483
|
return I18N_CALLEE_NAMES2.has(callee.name);
|
|
16481
|
-
return callee.type === AST_NODE_TYPES76.MemberExpression &&
|
|
16484
|
+
return callee.type === AST_NODE_TYPES76.MemberExpression && callee.object.type === AST_NODE_TYPES76.Identifier && I18N_RECEIVER_NAMES2.has(callee.object.name);
|
|
16482
16485
|
});
|
|
16483
16486
|
}
|
|
16484
16487
|
function calleeChainRoot(node) {
|
|
@@ -16501,9 +16504,9 @@ function chainMemberNames(node) {
|
|
|
16501
16504
|
let current = node;
|
|
16502
16505
|
for (; ; ) {
|
|
16503
16506
|
if (current.type === AST_NODE_TYPES76.MemberExpression) {
|
|
16504
|
-
if (
|
|
16507
|
+
if (ASTUtils41.getPropertyName(current) === null)
|
|
16505
16508
|
return [];
|
|
16506
|
-
names.push(current
|
|
16509
|
+
names.push(ASTUtils41.getPropertyName(current) ?? "");
|
|
16507
16510
|
current = current.object;
|
|
16508
16511
|
continue;
|
|
16509
16512
|
}
|
|
@@ -16520,8 +16523,8 @@ function schemaExpression2(node) {
|
|
|
16520
16523
|
let current = node;
|
|
16521
16524
|
for (; ; ) {
|
|
16522
16525
|
const parent = current.parent ?? void 0;
|
|
16523
|
-
if (parent?.type === AST_NODE_TYPES76.MemberExpression && parent.object === current &&
|
|
16524
|
-
if (NON_SCHEMA_TERMINALS.has(parent
|
|
16526
|
+
if (parent?.type === AST_NODE_TYPES76.MemberExpression && parent.object === current && ASTUtils41.getPropertyName(parent) !== null && parent.parent?.type === AST_NODE_TYPES76.CallExpression && parent.parent.callee === parent) {
|
|
16527
|
+
if (NON_SCHEMA_TERMINALS.has(ASTUtils41.getPropertyName(parent) ?? "")) return current;
|
|
16525
16528
|
current = parent.parent;
|
|
16526
16529
|
continue;
|
|
16527
16530
|
}
|
|
@@ -16551,7 +16554,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16551
16554
|
return {};
|
|
16552
16555
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
16553
16556
|
function resolvedBinding(identifier) {
|
|
16554
|
-
return
|
|
16557
|
+
return ASTUtils41.findVariable(
|
|
16555
16558
|
context.sourceCode.getScope(identifier),
|
|
16556
16559
|
identifier.name
|
|
16557
16560
|
);
|
|
@@ -16575,7 +16578,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16575
16578
|
}
|
|
16576
16579
|
function isSchemaConstruction(node) {
|
|
16577
16580
|
const callee = node.callee;
|
|
16578
|
-
if (callee.type !== AST_NODE_TYPES76.MemberExpression ||
|
|
16581
|
+
if (callee.type !== AST_NODE_TYPES76.MemberExpression || ASTUtils41.getPropertyName(callee) === null || NON_SCHEMA_TERMINALS.has(ASTUtils41.getPropertyName(callee) ?? "")) return false;
|
|
16579
16582
|
if (callee.object.type === AST_NODE_TYPES76.CallExpression) return isSchemaConstruction(callee.object);
|
|
16580
16583
|
return factoryName(node, FACTORIES) !== null || factoryName(node, COMPOSITE_FACTORIES) !== null;
|
|
16581
16584
|
}
|
|
@@ -16602,7 +16605,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16602
16605
|
function isMemoized(node) {
|
|
16603
16606
|
let current = node.parent ?? void 0;
|
|
16604
16607
|
while (current !== void 0) {
|
|
16605
|
-
if (current.type === AST_NODE_TYPES76.CallExpression && (current.callee.type === AST_NODE_TYPES76.Identifier && MEMO_CALLEES2.has(current.callee.name) || current.callee.type === AST_NODE_TYPES76.MemberExpression &&
|
|
16608
|
+
if (current.type === AST_NODE_TYPES76.CallExpression && (current.callee.type === AST_NODE_TYPES76.Identifier && MEMO_CALLEES2.has(current.callee.name) || current.callee.type === AST_NODE_TYPES76.MemberExpression && ASTUtils41.getPropertyName(current.callee) !== null && MEMO_CALLEES2.has(ASTUtils41.getPropertyName(current.callee) ?? "")))
|
|
16606
16609
|
return true;
|
|
16607
16610
|
current = current.parent ?? void 0;
|
|
16608
16611
|
}
|
|
@@ -16665,7 +16668,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16665
16668
|
// src/rules/prefer-multi-value-zod-literal.ts
|
|
16666
16669
|
import {
|
|
16667
16670
|
AST_NODE_TYPES as AST_NODE_TYPES77,
|
|
16668
|
-
ASTUtils as
|
|
16671
|
+
ASTUtils as ASTUtils42
|
|
16669
16672
|
} from "@typescript-eslint/utils";
|
|
16670
16673
|
var PREFER_MULTI_VALUE_ZOD_LITERAL_DOCUMENTATION = {
|
|
16671
16674
|
defaultLevel: "warning",
|
|
@@ -16713,7 +16716,7 @@ function isStaticPrimitive(node, context) {
|
|
|
16713
16716
|
if (node.type === AST_NODE_TYPES77.TemplateLiteral && node.expressions.length === 0)
|
|
16714
16717
|
return true;
|
|
16715
16718
|
if (node.type === AST_NODE_TYPES77.Identifier && node.name === "undefined") {
|
|
16716
|
-
const binding =
|
|
16719
|
+
const binding = ASTUtils42.findVariable(
|
|
16717
16720
|
context.sourceCode.getScope(node),
|
|
16718
16721
|
node.name
|
|
16719
16722
|
);
|
|
@@ -16750,13 +16753,13 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
16750
16753
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
16751
16754
|
const zod4Bindings = /* @__PURE__ */ new Set();
|
|
16752
16755
|
function resolvedBinding(identifier) {
|
|
16753
|
-
return
|
|
16756
|
+
return ASTUtils42.findVariable(
|
|
16754
16757
|
context.sourceCode.getScope(identifier),
|
|
16755
16758
|
identifier.name
|
|
16756
16759
|
);
|
|
16757
16760
|
}
|
|
16758
16761
|
function directMemberCall(node, binding, method) {
|
|
16759
|
-
if (node.callee.type !== AST_NODE_TYPES77.MemberExpression || node.callee.
|
|
16762
|
+
if (node.callee.type !== AST_NODE_TYPES77.MemberExpression || node.callee.object.type !== AST_NODE_TYPES77.Identifier || ASTUtils42.getPropertyName(node.callee) === null || (ASTUtils42.getPropertyName(node.callee) ?? "") !== method)
|
|
16760
16763
|
return false;
|
|
16761
16764
|
return resolvedBinding(node.callee.object) === binding;
|
|
16762
16765
|
}
|
|
@@ -16803,7 +16806,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
16803
16806
|
});
|
|
16804
16807
|
|
|
16805
16808
|
// src/rules/prefer-nominal-id-types.ts
|
|
16806
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES78, ASTUtils as
|
|
16809
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES78, ASTUtils as ASTUtils43 } from "@typescript-eslint/utils";
|
|
16807
16810
|
var OPERATIONAL_ROLES = /* @__PURE__ */ new Set([
|
|
16808
16811
|
"request",
|
|
16809
16812
|
"trace",
|
|
@@ -16841,7 +16844,7 @@ function isNullish(node) {
|
|
|
16841
16844
|
}
|
|
16842
16845
|
function referenceCarrier(node, context, depth) {
|
|
16843
16846
|
if (node.typeName.type !== AST_NODE_TYPES78.Identifier) return void 0;
|
|
16844
|
-
const variable =
|
|
16847
|
+
const variable = ASTUtils43.findVariable(context.sourceCode.getScope(node), node.typeName.name);
|
|
16845
16848
|
const definitions = variable?.defs ?? [];
|
|
16846
16849
|
const args = node.typeArguments?.params;
|
|
16847
16850
|
if (definitions.length === 0 && ["Array", "ReadonlyArray"].includes(node.typeName.name) && args?.length === 1) {
|
|
@@ -17039,7 +17042,7 @@ var prefer_named_complex_return_type_default = createRule({
|
|
|
17039
17042
|
});
|
|
17040
17043
|
|
|
17041
17044
|
// src/rules/prefer-native-random-uuid.ts
|
|
17042
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES81, ASTUtils as
|
|
17045
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES81, ASTUtils as ASTUtils44 } from "@typescript-eslint/utils";
|
|
17043
17046
|
var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
|
|
17044
17047
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
17045
17048
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -17075,14 +17078,14 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
17075
17078
|
const directBindings = /* @__PURE__ */ new Set();
|
|
17076
17079
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
17077
17080
|
function resolve2(identifier) {
|
|
17078
|
-
return
|
|
17081
|
+
return ASTUtils44.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
17079
17082
|
}
|
|
17080
17083
|
function record(identifier, destination) {
|
|
17081
17084
|
const variable = resolve2(identifier);
|
|
17082
17085
|
if (variable !== null) destination.add(variable);
|
|
17083
17086
|
}
|
|
17084
17087
|
function report2(node) {
|
|
17085
|
-
const globalBinding =
|
|
17088
|
+
const globalBinding = ASTUtils44.findVariable(context.sourceCode.getScope(node), "globalThis");
|
|
17086
17089
|
const canSuggest = (globalBinding?.defs.length ?? 0) === 0 && context.sourceCode.getCommentsInside(node).length === 0;
|
|
17087
17090
|
context.report({
|
|
17088
17091
|
node,
|
|
@@ -17140,7 +17143,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
17140
17143
|
});
|
|
17141
17144
|
|
|
17142
17145
|
// src/rules/prefer-node-crypto-hash.ts
|
|
17143
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES82, ASTUtils as
|
|
17146
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES82, ASTUtils as ASTUtils45 } from "@typescript-eslint/utils";
|
|
17144
17147
|
var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
17145
17148
|
defaultLevel: "warning",
|
|
17146
17149
|
summary: "Prefer the modern one-shot node:crypto hash API when streaming state is unnecessary.",
|
|
@@ -17199,7 +17202,7 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
17199
17202
|
const directBindings = /* @__PURE__ */ new Set();
|
|
17200
17203
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
17201
17204
|
function resolve2(identifier) {
|
|
17202
|
-
return
|
|
17205
|
+
return ASTUtils45.findVariable(
|
|
17203
17206
|
context.sourceCode.getScope(identifier),
|
|
17204
17207
|
identifier.name
|
|
17205
17208
|
);
|
|
@@ -17273,7 +17276,7 @@ function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
|
17273
17276
|
}
|
|
17274
17277
|
|
|
17275
17278
|
// src/rules/prefer-node-fs-promises.ts
|
|
17276
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES83, ASTUtils as
|
|
17279
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES83, ASTUtils as ASTUtils46 } from "@typescript-eslint/utils";
|
|
17277
17280
|
var PREFER_NODE_FS_PROMISES_DOCUMENTATION = {
|
|
17278
17281
|
defaultLevel: "warning",
|
|
17279
17282
|
summary: "Prefer promise-based Node.js filesystem APIs over synchronous calls in production modules.",
|
|
@@ -17335,7 +17338,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
17335
17338
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || normalizedFilename.includes("src/rules/"))
|
|
17336
17339
|
return {};
|
|
17337
17340
|
const namespaces = /* @__PURE__ */ new Set();
|
|
17338
|
-
const bindingOf = (node) =>
|
|
17341
|
+
const bindingOf = (node) => ASTUtils46.findVariable(context.sourceCode.getScope(node), node.name);
|
|
17339
17342
|
const isGlobal = (node) => {
|
|
17340
17343
|
const binding = bindingOf(node);
|
|
17341
17344
|
return binding === null || binding.defs.length === 0;
|
|
@@ -17401,7 +17404,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
17401
17404
|
});
|
|
17402
17405
|
|
|
17403
17406
|
// src/rules/prefer-non-nullable-collection.ts
|
|
17404
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES84, ASTUtils as
|
|
17407
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES84, ASTUtils as ASTUtils47 } from "@typescript-eslint/utils";
|
|
17405
17408
|
var PREFER_NON_NULLABLE_COLLECTION_DOCUMENTATION = {
|
|
17406
17409
|
summary: "Suggest reviewing nullish arrays that use local empty-array defaults or a shared null-or-empty guard.",
|
|
17407
17410
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
@@ -17526,14 +17529,14 @@ function directlyCoalesced(node) {
|
|
|
17526
17529
|
return parent?.type === AST_NODE_TYPES84.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
17527
17530
|
}
|
|
17528
17531
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
17529
|
-
const variable =
|
|
17532
|
+
const variable = ASTUtils47.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
17530
17533
|
if (variable === null || variable.references.length === 0) return false;
|
|
17531
17534
|
return variable.references.every(
|
|
17532
17535
|
(reference) => belongsToFunction(reference.identifier, fn) && directlyCoalesced(reference.identifier)
|
|
17533
17536
|
);
|
|
17534
17537
|
}
|
|
17535
17538
|
function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
17536
|
-
const variable =
|
|
17539
|
+
const variable = ASTUtils47.findVariable(context.sourceCode.getScope(object), object.name);
|
|
17537
17540
|
if (variable === null) return false;
|
|
17538
17541
|
const accesses = variable.references.flatMap((reference) => {
|
|
17539
17542
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
@@ -17649,7 +17652,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
17649
17652
|
// src/rules/prefer-nullish-filter-predicate.ts
|
|
17650
17653
|
import {
|
|
17651
17654
|
AST_NODE_TYPES as AST_NODE_TYPES85,
|
|
17652
|
-
ASTUtils as
|
|
17655
|
+
ASTUtils as ASTUtils48,
|
|
17653
17656
|
ESLintUtils as ESLintUtils12
|
|
17654
17657
|
} from "@typescript-eslint/utils";
|
|
17655
17658
|
import ts10 from "typescript";
|
|
@@ -17695,7 +17698,7 @@ var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
|
17695
17698
|
]
|
|
17696
17699
|
};
|
|
17697
17700
|
function isUnshadowedBoolean(node, context) {
|
|
17698
|
-
const variable =
|
|
17701
|
+
const variable = ASTUtils48.findVariable(context.sourceCode.getScope(node), node.name);
|
|
17699
17702
|
return variable === null || variable.defs.length === 0;
|
|
17700
17703
|
}
|
|
17701
17704
|
function isBuiltinArrayFilter(node, services) {
|
|
@@ -17754,7 +17757,7 @@ function isProvablyTruthy(type, checker) {
|
|
|
17754
17757
|
}
|
|
17755
17758
|
function availableParameterName(node, context) {
|
|
17756
17759
|
for (const name of ["value", "item", "element", "candidate"]) {
|
|
17757
|
-
if (
|
|
17760
|
+
if (ASTUtils48.findVariable(context.sourceCode.getScope(node), name) === null) return name;
|
|
17758
17761
|
}
|
|
17759
17762
|
return null;
|
|
17760
17763
|
}
|
|
@@ -17785,7 +17788,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
17785
17788
|
CallExpression(node) {
|
|
17786
17789
|
const callee = node.callee;
|
|
17787
17790
|
const callback = node.arguments[0];
|
|
17788
|
-
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES85.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES85.MemberExpression ||
|
|
17791
|
+
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES85.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES85.MemberExpression || ASTUtils48.getPropertyName(callee) === null || (ASTUtils48.getPropertyName(callee) ?? "") !== "filter" || !isUnshadowedBoolean(callback, context) || !isBuiltinArrayFilter(callee, services)) return;
|
|
17789
17792
|
const elementType = arrayElementType(callee.object, services);
|
|
17790
17793
|
const checker = services.program.getTypeChecker();
|
|
17791
17794
|
if (elementType === null || !isNullishPlusTruthy(elementType, checker)) return;
|
|
@@ -17808,7 +17811,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
17808
17811
|
|
|
17809
17812
|
// src/rules/prefer-await-in-async-return.ts
|
|
17810
17813
|
import {
|
|
17811
|
-
ASTUtils as
|
|
17814
|
+
ASTUtils as ASTUtils49,
|
|
17812
17815
|
ESLintUtils as ESLintUtils13,
|
|
17813
17816
|
AST_NODE_TYPES as AST_NODE_TYPES86
|
|
17814
17817
|
} from "@typescript-eslint/utils";
|
|
@@ -17871,7 +17874,7 @@ function isRuntimeFunction(node) {
|
|
|
17871
17874
|
}
|
|
17872
17875
|
function promiseThenReceiver(node) {
|
|
17873
17876
|
const callee = node.callee;
|
|
17874
|
-
if (callee.type !== AST_NODE_TYPES86.MemberExpression || callee.
|
|
17877
|
+
if (callee.type !== AST_NODE_TYPES86.MemberExpression || callee.optional || ASTUtils49.getPropertyName(callee) === null || (ASTUtils49.getPropertyName(callee) ?? "") !== "then" || node.optional || node.arguments.length !== 1) {
|
|
17875
17878
|
return null;
|
|
17876
17879
|
}
|
|
17877
17880
|
const callback = node.arguments[0];
|
|
@@ -17940,13 +17943,13 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
17940
17943
|
if (services === null) return {};
|
|
17941
17944
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
17942
17945
|
const rememberFrameworkLoader = (identifier) => {
|
|
17943
|
-
const variable =
|
|
17946
|
+
const variable = ASTUtils49.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
17944
17947
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
17945
17948
|
};
|
|
17946
17949
|
const isFrameworkLoaderCallback = (owner) => {
|
|
17947
17950
|
const parent = owner.parent;
|
|
17948
17951
|
if (parent.type !== AST_NODE_TYPES86.CallExpression || parent.arguments[0] !== owner || parent.callee.type !== AST_NODE_TYPES86.Identifier) return false;
|
|
17949
|
-
const variable =
|
|
17952
|
+
const variable = ASTUtils49.findVariable(context.sourceCode.getScope(parent.callee), parent.callee.name);
|
|
17950
17953
|
return variable !== null && frameworkLoaders.has(variable);
|
|
17951
17954
|
};
|
|
17952
17955
|
return {
|
|
@@ -17983,7 +17986,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
17983
17986
|
});
|
|
17984
17987
|
|
|
17985
17988
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
17986
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES87, ASTUtils as
|
|
17989
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES87, ASTUtils as ASTUtils50 } from "@typescript-eslint/utils";
|
|
17987
17990
|
var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
17988
17991
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
17989
17992
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -18020,7 +18023,7 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
18020
18023
|
]);
|
|
18021
18024
|
var isSchemaParseReference = (node) => {
|
|
18022
18025
|
const inner = unwrap6(node);
|
|
18023
|
-
return inner !== null && inner.type === AST_NODE_TYPES87.MemberExpression &&
|
|
18026
|
+
return inner !== null && inner.type === AST_NODE_TYPES87.MemberExpression && ASTUtils50.getPropertyName(inner) !== null && ((ASTUtils50.getPropertyName(inner) ?? "") === "parse" || (ASTUtils50.getPropertyName(inner) ?? "") === "safeParse");
|
|
18024
18027
|
};
|
|
18025
18028
|
var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
18026
18029
|
let current = unwrap6(node);
|
|
@@ -18035,31 +18038,31 @@ var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
|
18035
18038
|
if (callee === null || callee.type !== AST_NODE_TYPES87.MemberExpression) {
|
|
18036
18039
|
return false;
|
|
18037
18040
|
}
|
|
18038
|
-
const property =
|
|
18039
|
-
if (property === null
|
|
18041
|
+
const property = ASTUtils50.getPropertyName(callee);
|
|
18042
|
+
if (property === null) {
|
|
18040
18043
|
return false;
|
|
18041
18044
|
}
|
|
18042
|
-
if (property
|
|
18043
|
-
return
|
|
18045
|
+
if (property === "json") {
|
|
18046
|
+
return current.arguments.length === 0 && isResponseSource(callee.object, context);
|
|
18044
18047
|
}
|
|
18045
|
-
if (PROMISE_CHAIN_METHODS.has(property
|
|
18048
|
+
if (PROMISE_CHAIN_METHODS.has(property)) {
|
|
18046
18049
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object, context, isKnownLocalText);
|
|
18047
18050
|
}
|
|
18048
18051
|
const object = unwrap6(callee.object);
|
|
18049
18052
|
const input = unwrap6(current.arguments[0]);
|
|
18050
|
-
if (input?.type === AST_NODE_TYPES87.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES87.MemberExpression &&
|
|
18051
|
-
return property
|
|
18053
|
+
if (input?.type === AST_NODE_TYPES87.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES87.MemberExpression && input.callee.object.type === AST_NODE_TYPES87.Identifier && input.callee.object.name === "JSON" && ASTUtils50.getPropertyName(input.callee) !== null && (ASTUtils50.getPropertyName(input.callee) ?? "") === "stringify" && (ASTUtils50.findVariable(context.sourceCode.getScope(input.callee.object), "JSON")?.defs.length ?? 0) === 0) return false;
|
|
18054
|
+
return property === "parse" && object !== null && object.type === AST_NODE_TYPES87.Identifier && object.name === "JSON" && (ASTUtils50.findVariable(context.sourceCode.getScope(object), "JSON")?.defs.length ?? 0) === 0 && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
18052
18055
|
};
|
|
18053
18056
|
var isResponseSource = (node, context, seen = /* @__PURE__ */ new Set()) => {
|
|
18054
18057
|
let current = unwrap6(node);
|
|
18055
18058
|
if (current?.type === AST_NODE_TYPES87.AwaitExpression) current = unwrap6(current.argument);
|
|
18056
18059
|
if (current === null || seen.has(current)) return false;
|
|
18057
18060
|
seen.add(current);
|
|
18058
|
-
const isGlobal = (identifier) => (
|
|
18061
|
+
const isGlobal = (identifier) => (ASTUtils50.findVariable(context.sourceCode.getScope(identifier), identifier.name)?.defs.length ?? 0) === 0;
|
|
18059
18062
|
if (current.type === AST_NODE_TYPES87.CallExpression) return current.callee.type === AST_NODE_TYPES87.Identifier && current.callee.name === "fetch" && isGlobal(current.callee);
|
|
18060
18063
|
if (current.type === AST_NODE_TYPES87.NewExpression) return current.callee.type === AST_NODE_TYPES87.Identifier && ["Request", "Response"].includes(current.callee.name) && isGlobal(current.callee);
|
|
18061
18064
|
if (current.type !== AST_NODE_TYPES87.Identifier) return false;
|
|
18062
|
-
const binding =
|
|
18065
|
+
const binding = ASTUtils50.findVariable(context.sourceCode.getScope(current), current.name);
|
|
18063
18066
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
18064
18067
|
const definition = binding.defs[0];
|
|
18065
18068
|
const annotation = definition?.name.type === AST_NODE_TYPES87.Identifier ? definition.name.typeAnnotation?.typeAnnotation : void 0;
|
|
@@ -18074,7 +18077,7 @@ var isDirectLocalFileRead = (node) => {
|
|
|
18074
18077
|
}
|
|
18075
18078
|
if (current?.type !== AST_NODE_TYPES87.CallExpression) return false;
|
|
18076
18079
|
const callee = unwrap6(current.callee);
|
|
18077
|
-
const name = callee?.type === AST_NODE_TYPES87.Identifier ? callee.name : callee?.type === AST_NODE_TYPES87.MemberExpression &&
|
|
18080
|
+
const name = callee?.type === AST_NODE_TYPES87.Identifier ? callee.name : callee?.type === AST_NODE_TYPES87.MemberExpression && ASTUtils50.getPropertyName(callee) !== null ? ASTUtils50.getPropertyName(callee) ?? "" : null;
|
|
18078
18081
|
return name !== null && FILE_READ_RE.test(name);
|
|
18079
18082
|
};
|
|
18080
18083
|
var isLocalFileRead = (node) => {
|
|
@@ -18135,7 +18138,7 @@ var isValidationRead = (node) => {
|
|
|
18135
18138
|
return false;
|
|
18136
18139
|
}
|
|
18137
18140
|
const callee = parent.callee;
|
|
18138
|
-
if (callee.type === AST_NODE_TYPES87.MemberExpression &&
|
|
18141
|
+
if (callee.type === AST_NODE_TYPES87.MemberExpression && callee.object.type === AST_NODE_TYPES87.Identifier && callee.object.name === "Array" && ASTUtils50.getPropertyName(callee) !== null && (ASTUtils50.getPropertyName(callee) ?? "") === "isArray") {
|
|
18139
18142
|
return parent.arguments.length === 1;
|
|
18140
18143
|
}
|
|
18141
18144
|
return callee.type === AST_NODE_TYPES87.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
@@ -18163,9 +18166,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
18163
18166
|
}
|
|
18164
18167
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
18165
18168
|
}
|
|
18166
|
-
return test.type === AST_NODE_TYPES87.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES87.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES87.MemberExpression &&
|
|
18169
|
+
return test.type === AST_NODE_TYPES87.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES87.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES87.MemberExpression && test.callee.object.type === AST_NODE_TYPES87.Identifier && test.callee.object.name === "Array" && ASTUtils50.getPropertyName(test.callee) !== null && (ASTUtils50.getPropertyName(test.callee) ?? "") === "isArray" ? "valid-when-true" : null;
|
|
18167
18170
|
};
|
|
18168
|
-
var plainMemberAccess = (node) => node.type === AST_NODE_TYPES87.MemberExpression &&
|
|
18171
|
+
var plainMemberAccess = (node) => node.type === AST_NODE_TYPES87.MemberExpression && node.object.type === AST_NODE_TYPES87.Identifier && ASTUtils50.getPropertyName(node) !== null ? { object: node.object.name, property: ASTUtils50.getPropertyName(node) ?? "" } : null;
|
|
18169
18172
|
var isSamePlainMember = (node, access) => {
|
|
18170
18173
|
const candidate2 = plainMemberAccess(node);
|
|
18171
18174
|
return candidate2 !== null && candidate2.object === access.object && candidate2.property === access.property;
|
|
@@ -18227,7 +18230,7 @@ var memberValidationPolarity = (test, access) => {
|
|
|
18227
18230
|
}
|
|
18228
18231
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
18229
18232
|
}
|
|
18230
|
-
return test.type === AST_NODE_TYPES87.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES87.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES87.MemberExpression &&
|
|
18233
|
+
return test.type === AST_NODE_TYPES87.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES87.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES87.MemberExpression && test.callee.object.type === AST_NODE_TYPES87.Identifier && test.callee.object.name === "Array" && ASTUtils50.getPropertyName(test.callee) !== null && (ASTUtils50.getPropertyName(test.callee) ?? "") === "isArray" ? "valid-when-true" : null;
|
|
18231
18234
|
};
|
|
18232
18235
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
18233
18236
|
const isValidationReference = (identifier) => {
|
|
@@ -18510,7 +18513,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
18510
18513
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
18511
18514
|
)) {
|
|
18512
18515
|
const parent = node.parent;
|
|
18513
|
-
if (parent.type === AST_NODE_TYPES87.CallExpression && parent.callee === node && node
|
|
18516
|
+
if (parent.type === AST_NODE_TYPES87.CallExpression && parent.callee === node && ASTUtils50.getPropertyName(node) !== null && ((ASTUtils50.getPropertyName(node) ?? "") === "parse" || (ASTUtils50.getPropertyName(node) ?? "") === "safeParse" || PROMISE_CHAIN_METHODS.has(ASTUtils50.getPropertyName(node) ?? ""))) {
|
|
18514
18517
|
return;
|
|
18515
18518
|
}
|
|
18516
18519
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
@@ -18562,7 +18565,7 @@ function ifGuardDominates(use, branch, positive) {
|
|
|
18562
18565
|
}
|
|
18563
18566
|
|
|
18564
18567
|
// src/rules/prefer-shared-zod-enum.ts
|
|
18565
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES88, ASTUtils as
|
|
18568
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES88, ASTUtils as ASTUtils51 } from "@typescript-eslint/utils";
|
|
18566
18569
|
var PREFER_SHARED_ZOD_ENUM_DOCUMENTATION = {
|
|
18567
18570
|
defaultLevel: "warning",
|
|
18568
18571
|
summary: "Give repeated literal Zod enum domains one reusable module-level schema.",
|
|
@@ -18612,7 +18615,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
18612
18615
|
create(context) {
|
|
18613
18616
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
18614
18617
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
18615
|
-
const bindingOf = (node) =>
|
|
18618
|
+
const bindingOf = (node) => ASTUtils51.findVariable(context.sourceCode.getScope(node), node.name);
|
|
18616
18619
|
const candidates = /* @__PURE__ */ new Map();
|
|
18617
18620
|
return {
|
|
18618
18621
|
ImportDeclaration(node) {
|
|
@@ -18625,7 +18628,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
18625
18628
|
}
|
|
18626
18629
|
},
|
|
18627
18630
|
CallExpression(node) {
|
|
18628
|
-
if (node.callee.type !== AST_NODE_TYPES88.MemberExpression || node.callee.
|
|
18631
|
+
if (node.callee.type !== AST_NODE_TYPES88.MemberExpression || node.callee.object.type !== AST_NODE_TYPES88.Identifier || ASTUtils51.getPropertyName(node.callee) === null || (ASTUtils51.getPropertyName(node.callee) ?? "") !== "enum") return;
|
|
18629
18632
|
const binding = bindingOf(node.callee.object);
|
|
18630
18633
|
if (binding === null || !zodBindings.has(binding)) return;
|
|
18631
18634
|
const domain = literalDomain(node);
|
|
@@ -19243,7 +19246,7 @@ function packageWorkspaceGlobs(parsed) {
|
|
|
19243
19246
|
}
|
|
19244
19247
|
|
|
19245
19248
|
// src/rules/prefer-server-actions.ts
|
|
19246
|
-
import { ASTUtils as
|
|
19249
|
+
import { ASTUtils as ASTUtils52 } from "@typescript-eslint/utils";
|
|
19247
19250
|
var PREFER_SERVER_ACTIONS_DOCUMENTATION = {
|
|
19248
19251
|
summary: "Prefer Next.js Server Actions over same-origin API mutations.",
|
|
19249
19252
|
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.",
|
|
@@ -19275,7 +19278,7 @@ function resolvesToGlobalFetch(context, identifier) {
|
|
|
19275
19278
|
function resolveNode(node, context) {
|
|
19276
19279
|
if (!node) return null;
|
|
19277
19280
|
if (node.type !== "Identifier") return node;
|
|
19278
|
-
const variable =
|
|
19281
|
+
const variable = ASTUtils52.findVariable(getScope(context, node), node.name);
|
|
19279
19282
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
19280
19283
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return node;
|
|
19281
19284
|
if (definition.node.init.type === "ObjectExpression" && variable?.references.some((reference) => reference.identifier !== node && reference.init !== true)) return node;
|
|
@@ -19284,7 +19287,7 @@ function resolveNode(node, context) {
|
|
|
19284
19287
|
function isAxiosClient(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
19285
19288
|
if (node.type !== "Identifier" || seen.has(node)) return false;
|
|
19286
19289
|
seen.add(node);
|
|
19287
|
-
const variable =
|
|
19290
|
+
const variable = ASTUtils52.findVariable(getScope(context, node), node.name);
|
|
19288
19291
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
19289
19292
|
if (definition === void 0 || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
19290
19293
|
if (variable?.references.some((reference) => {
|
|
@@ -19499,11 +19502,10 @@ var prefer_server_actions_default = createRule({
|
|
|
19499
19502
|
});
|
|
19500
19503
|
|
|
19501
19504
|
// src/rules/prefer-whole-object-assertion.ts
|
|
19502
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES91, ASTUtils as
|
|
19505
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES91, ASTUtils as ASTUtils53 } from "@typescript-eslint/utils";
|
|
19503
19506
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
19504
19507
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
19505
|
-
["toBeNull", "null"]
|
|
19506
|
-
["toBeUndefined", "undefined"]
|
|
19508
|
+
["toBeNull", "null"]
|
|
19507
19509
|
]);
|
|
19508
19510
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
19509
19511
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -19518,7 +19520,7 @@ var PREFER_WHOLE_OBJECT_ASSERTION_DOCUMENTATION = {
|
|
|
19518
19520
|
category: "testing",
|
|
19519
19521
|
aliases: ["strict-test-assertions"],
|
|
19520
19522
|
autofix: "none",
|
|
19521
|
-
limitations: ["
|
|
19523
|
+
limitations: ["Undefined-property assertions are excluded because whole-object matching can require previously absent properties. No automatic rewrite: grouping can change observable getter or proxy reads."],
|
|
19522
19524
|
examples: [
|
|
19523
19525
|
{ id: "whole-object", title: "Assert the object once", outcome: "no-match", files: [{ path: "src/user.test.ts", source: "expect(user).toMatchObject({ id: 1, name: 'Ada' });" }], focusPath: "src/user.test.ts", expectedCount: 0, public: true },
|
|
19524
19526
|
{ id: "member-run", title: "Consider grouping related data properties", outcome: "match", files: [{ path: "src/user.test.ts", source: "expect(user.id).toBe(1);\nexpect(user.name).toBe('Ada');" }], focusPath: "src/user.test.ts", expectedCount: 1, public: true }
|
|
@@ -19562,9 +19564,9 @@ function literalIndex(node) {
|
|
|
19562
19564
|
function propertyAccess(node) {
|
|
19563
19565
|
const path = [];
|
|
19564
19566
|
let current = node;
|
|
19565
|
-
while (current.type === AST_NODE_TYPES91.MemberExpression && !current.
|
|
19566
|
-
if (current
|
|
19567
|
-
path.unshift(current
|
|
19567
|
+
while (current.type === AST_NODE_TYPES91.MemberExpression && !current.optional) {
|
|
19568
|
+
if (ASTUtils53.getPropertyName(current) === null || COLLECTION_PROPERTIES.has(ASTUtils53.getPropertyName(current) ?? "") || LITERAL_KEY_HAZARDS.has(ASTUtils53.getPropertyName(current) ?? "")) return null;
|
|
19569
|
+
path.unshift(ASTUtils53.getPropertyName(current) ?? "");
|
|
19568
19570
|
current = current.object;
|
|
19569
19571
|
}
|
|
19570
19572
|
return path.length > 0 && isPureReceiver(current) ? { receiver: current, path } : null;
|
|
@@ -19638,7 +19640,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19638
19640
|
if (first === void 0) {
|
|
19639
19641
|
return;
|
|
19640
19642
|
}
|
|
19641
|
-
const receiverText = `${sourceCode.getText(first.receiver)}${commonPrefix.map((name) => `.${name}`).join("")}`;
|
|
19643
|
+
const receiverText = `${sourceCode.getText(first.receiver)}${commonPrefix.map((name) => /^[A-Za-z_$][\w$]*$/u.test(name) ? `.${name}` : `[${JSON.stringify(name)}]`).join("")}`;
|
|
19642
19644
|
context.report({
|
|
19643
19645
|
node: first.statement,
|
|
19644
19646
|
messageId: "combineAssertions",
|
|
@@ -19707,10 +19709,10 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19707
19709
|
return null;
|
|
19708
19710
|
}
|
|
19709
19711
|
const callee = call.callee;
|
|
19710
|
-
if (callee.type !== AST_NODE_TYPES91.MemberExpression ||
|
|
19712
|
+
if (callee.type !== AST_NODE_TYPES91.MemberExpression || ASTUtils53.getPropertyName(callee) === null) {
|
|
19711
19713
|
return null;
|
|
19712
19714
|
}
|
|
19713
|
-
const matcher = callee
|
|
19715
|
+
const matcher = ASTUtils53.getPropertyName(callee) ?? "";
|
|
19714
19716
|
const expectCall = callee.object;
|
|
19715
19717
|
if (expectCall.type !== AST_NODE_TYPES91.CallExpression || expectCall.callee.type !== AST_NODE_TYPES91.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
19716
19718
|
return null;
|
|
@@ -19725,11 +19727,8 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19725
19727
|
}
|
|
19726
19728
|
let key;
|
|
19727
19729
|
let receiver;
|
|
19728
|
-
|
|
19729
|
-
|
|
19730
|
-
if (index === null) {
|
|
19731
|
-
return null;
|
|
19732
|
-
}
|
|
19730
|
+
const index = actual.computed ? literalIndex(actual.property) : null;
|
|
19731
|
+
if (index !== null) {
|
|
19733
19732
|
key = { kind: "index", index };
|
|
19734
19733
|
receiver = actual.object;
|
|
19735
19734
|
} else {
|
|
@@ -19741,7 +19740,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19741
19740
|
return assertionExpectation(statement, call, receiver, key, matcher);
|
|
19742
19741
|
}
|
|
19743
19742
|
function isTestExpect(callee) {
|
|
19744
|
-
const variable =
|
|
19743
|
+
const variable = ASTUtils53.findVariable(sourceCode.getScope(callee), callee.name);
|
|
19745
19744
|
if (variable !== null && variable.defs.some((definition) => {
|
|
19746
19745
|
if (definition.node.type !== AST_NODE_TYPES91.ImportSpecifier) return true;
|
|
19747
19746
|
const declaration = definition.node.parent;
|
|
@@ -19784,7 +19783,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19784
19783
|
});
|
|
19785
19784
|
|
|
19786
19785
|
// src/rules/repeated-static-call-cases.ts
|
|
19787
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES92, ASTUtils as
|
|
19786
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES92, ASTUtils as ASTUtils54 } from "@typescript-eslint/utils";
|
|
19788
19787
|
var REPEATED_STATIC_CALL_CASES_DOCUMENTATION = {
|
|
19789
19788
|
summary: "Review three or more consecutive static-input call assertions as potential named cases.",
|
|
19790
19789
|
rationale: "Copy-pasted cases obscure the input table, and a thrown assertion can stop later cases from being reported.",
|
|
@@ -19805,12 +19804,12 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
19805
19804
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
19806
19805
|
var MIN_CASES2 = 3;
|
|
19807
19806
|
function staticMemberName7(node) {
|
|
19808
|
-
if (
|
|
19807
|
+
if (ASTUtils54.getPropertyName(node) !== null) return ASTUtils54.getPropertyName(node) ?? "";
|
|
19809
19808
|
if (node.computed && node.property.type === AST_NODE_TYPES92.Literal && typeof node.property.value === "string") return node.property.value;
|
|
19810
19809
|
return null;
|
|
19811
19810
|
}
|
|
19812
19811
|
function importedName7(identifier, context, modules) {
|
|
19813
|
-
const variable =
|
|
19812
|
+
const variable = ASTUtils54.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
19814
19813
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
19815
19814
|
for (const definition of variable.defs) {
|
|
19816
19815
|
if (definition.node.type !== AST_NODE_TYPES92.ImportSpecifier) continue;
|
|
@@ -19875,8 +19874,8 @@ function staticShape(node) {
|
|
|
19875
19874
|
function assertionShape(statement, context, callback) {
|
|
19876
19875
|
if (statement.type !== AST_NODE_TYPES92.ExpressionStatement || statement.expression.type !== AST_NODE_TYPES92.CallExpression) return null;
|
|
19877
19876
|
const matcherCall = statement.expression;
|
|
19878
|
-
if (matcherCall.callee.type !== AST_NODE_TYPES92.MemberExpression ||
|
|
19879
|
-
const matcher = matcherCall.callee
|
|
19877
|
+
if (matcherCall.callee.type !== AST_NODE_TYPES92.MemberExpression || ASTUtils54.getPropertyName(matcherCall.callee) === null || matcherCall.arguments.length !== 1) return null;
|
|
19878
|
+
const matcher = ASTUtils54.getPropertyName(matcherCall.callee) ?? "";
|
|
19880
19879
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
19881
19880
|
const chain = expectCallFromMatcher(matcherCall.callee);
|
|
19882
19881
|
if (chain === null || chain.call.callee.type !== AST_NODE_TYPES92.Identifier || importedName7(chain.call.callee, context, ASSERTION_MODULES3) !== "expect" || chain.call.arguments.length !== 1) return null;
|
|
@@ -19884,7 +19883,7 @@ function assertionShape(statement, context, callback) {
|
|
|
19884
19883
|
const expected = matcherCall.arguments[0];
|
|
19885
19884
|
if (observed?.type !== AST_NODE_TYPES92.CallExpression || observed.callee.type !== AST_NODE_TYPES92.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === AST_NODE_TYPES92.SpreadElement || !isStatic(arg)) || expected?.type === AST_NODE_TYPES92.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
19886
19885
|
const skeleton = `${observed.callee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
19887
|
-
const binding =
|
|
19886
|
+
const binding = ASTUtils54.findVariable(context.sourceCode.getScope(observed.callee), observed.callee.name);
|
|
19888
19887
|
if (binding?.defs.some(
|
|
19889
19888
|
(definition) => definition.node.range[0] >= callback.range[0] && definition.node.range[1] <= callback.range[1]
|
|
19890
19889
|
)) return null;
|
|
@@ -19971,7 +19970,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
19971
19970
|
});
|
|
19972
19971
|
|
|
19973
19972
|
// src/rules/prefer-zod-infer.ts
|
|
19974
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES93 } from "@typescript-eslint/utils";
|
|
19973
|
+
import { ASTUtils as ASTUtils55, AST_NODE_TYPES as AST_NODE_TYPES93 } from "@typescript-eslint/utils";
|
|
19975
19974
|
var PREFER_ZOD_INFER_DOCUMENTATION = {
|
|
19976
19975
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
19977
19976
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -20288,7 +20287,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
20288
20287
|
let current = node;
|
|
20289
20288
|
while (current.type === AST_NODE_TYPES93.CallExpression) {
|
|
20290
20289
|
const callee = current.callee;
|
|
20291
|
-
if (callee.type !== AST_NODE_TYPES93.MemberExpression ||
|
|
20290
|
+
if (callee.type !== AST_NODE_TYPES93.MemberExpression || ASTUtils55.getPropertyName(callee) === null) {
|
|
20292
20291
|
return null;
|
|
20293
20292
|
}
|
|
20294
20293
|
chain.push(current);
|
|
@@ -20301,7 +20300,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
20301
20300
|
}
|
|
20302
20301
|
function twinMethodName(call) {
|
|
20303
20302
|
const callee = call.callee;
|
|
20304
|
-
return callee.type === AST_NODE_TYPES93.MemberExpression && callee
|
|
20303
|
+
return callee.type === AST_NODE_TYPES93.MemberExpression && ASTUtils55.getPropertyName(callee) !== null ? ASTUtils55.getPropertyName(callee) ?? "" : "";
|
|
20305
20304
|
}
|
|
20306
20305
|
function twinSchemaFields(initializer, zodNamespaces) {
|
|
20307
20306
|
const chain = twinCallChain(initializer, zodNamespaces);
|
|
@@ -20330,16 +20329,16 @@ function twinSchemaField(node, zodNamespaces) {
|
|
|
20330
20329
|
let leafCall = null;
|
|
20331
20330
|
while (current.type === AST_NODE_TYPES93.CallExpression) {
|
|
20332
20331
|
const callee = current.callee;
|
|
20333
|
-
if (callee.type !== AST_NODE_TYPES93.MemberExpression ||
|
|
20332
|
+
if (callee.type !== AST_NODE_TYPES93.MemberExpression || ASTUtils55.getPropertyName(callee) === null) {
|
|
20334
20333
|
break;
|
|
20335
20334
|
}
|
|
20336
20335
|
const receiver = callee.object;
|
|
20337
20336
|
if (receiver.type === AST_NODE_TYPES93.Identifier && zodNamespaces.has(receiver.name)) {
|
|
20338
|
-
leaf = callee
|
|
20337
|
+
leaf = ASTUtils55.getPropertyName(callee) ?? "";
|
|
20339
20338
|
leafCall = current;
|
|
20340
20339
|
break;
|
|
20341
20340
|
}
|
|
20342
|
-
modifiers.push(callee
|
|
20341
|
+
modifiers.push(ASTUtils55.getPropertyName(callee) ?? "");
|
|
20343
20342
|
current = receiver;
|
|
20344
20343
|
}
|
|
20345
20344
|
return {
|
|
@@ -20541,8 +20540,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
20541
20540
|
}
|
|
20542
20541
|
},
|
|
20543
20542
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
20544
|
-
"MemberExpression
|
|
20545
|
-
if (node.object.type === AST_NODE_TYPES93.Identifier && node
|
|
20543
|
+
"MemberExpression"(node) {
|
|
20544
|
+
if (node.object.type === AST_NODE_TYPES93.Identifier && ASTUtils55.getPropertyName(node) !== null && isPreferZodInferModuleReshaper(ASTUtils55.getPropertyName(node) ?? "")) {
|
|
20546
20545
|
reshapedSchemaNames.add(node.object.name);
|
|
20547
20546
|
}
|
|
20548
20547
|
},
|
|
@@ -20700,6 +20699,7 @@ function staticFieldName(key) {
|
|
|
20700
20699
|
|
|
20701
20700
|
// src/rules/prefer-zod-parse-output-type.ts
|
|
20702
20701
|
import {
|
|
20702
|
+
ASTUtils as ASTUtils56,
|
|
20703
20703
|
AST_NODE_TYPES as AST_NODE_TYPES94,
|
|
20704
20704
|
ESLintUtils as ESLintUtils14
|
|
20705
20705
|
} from "@typescript-eslint/utils";
|
|
@@ -20766,11 +20766,11 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
20766
20766
|
let current = node;
|
|
20767
20767
|
while (current.type === AST_NODE_TYPES94.CallExpression) {
|
|
20768
20768
|
const { callee } = current;
|
|
20769
|
-
if (callee.type !== AST_NODE_TYPES94.MemberExpression ||
|
|
20769
|
+
if (callee.type !== AST_NODE_TYPES94.MemberExpression || ASTUtils56.getPropertyName(callee) === null) {
|
|
20770
20770
|
return false;
|
|
20771
20771
|
}
|
|
20772
20772
|
if (callee.object.type === AST_NODE_TYPES94.Identifier) {
|
|
20773
|
-
return namespaces.has(callee.object.name) && (callee
|
|
20773
|
+
return namespaces.has(callee.object.name) && ((ASTUtils56.getPropertyName(callee) ?? "") === "object" || (ASTUtils56.getPropertyName(callee) ?? "") === "strictObject");
|
|
20774
20774
|
}
|
|
20775
20775
|
current = callee.object;
|
|
20776
20776
|
}
|
|
@@ -20778,12 +20778,14 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
20778
20778
|
}
|
|
20779
20779
|
function zodParseCall(node) {
|
|
20780
20780
|
const { callee } = node;
|
|
20781
|
-
if (callee.type !== AST_NODE_TYPES94.MemberExpression || callee.
|
|
20781
|
+
if (callee.type !== AST_NODE_TYPES94.MemberExpression || callee.object.type !== AST_NODE_TYPES94.Identifier || ASTUtils56.getPropertyName(callee) === null) {
|
|
20782
20782
|
return null;
|
|
20783
20783
|
}
|
|
20784
|
+
const method = ASTUtils56.getPropertyName(callee);
|
|
20785
|
+
if (method !== "parse" && method !== "safeParse") return null;
|
|
20784
20786
|
return {
|
|
20785
20787
|
call: node,
|
|
20786
|
-
method
|
|
20788
|
+
method,
|
|
20787
20789
|
schema: callee.object
|
|
20788
20790
|
};
|
|
20789
20791
|
}
|
|
@@ -20821,7 +20823,7 @@ function localParseReturnCandidates(node, sourceCode) {
|
|
|
20821
20823
|
for (const reference of variable.references) {
|
|
20822
20824
|
const identifier = reference.identifier;
|
|
20823
20825
|
const parent = identifier.parent;
|
|
20824
|
-
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES94.MemberExpression && parent.object === identifier &&
|
|
20826
|
+
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES94.MemberExpression && parent.object === identifier && ASTUtils56.getPropertyName(parent) !== null && (ASTUtils56.getPropertyName(parent) ?? "") === "data" ? parent : null;
|
|
20825
20827
|
if (output === null) continue;
|
|
20826
20828
|
const candidate2 = returnedOutputCandidate(parsed, output);
|
|
20827
20829
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
@@ -21054,7 +21056,7 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
21054
21056
|
const candidate2 = directParseReturnCandidate(node);
|
|
21055
21057
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
21056
21058
|
},
|
|
21057
|
-
"MemberExpression
|
|
21059
|
+
"MemberExpression"(node) {
|
|
21058
21060
|
if (node.object.type === AST_NODE_TYPES94.Identifier && node.property.type === AST_NODE_TYPES94.Identifier && isPreferZodInferModuleReshaper(node.property.name)) {
|
|
21059
21061
|
reshapedSchemas.add(node.object.name);
|
|
21060
21062
|
}
|
|
@@ -21204,7 +21206,7 @@ var require_assert_never_default = createRule({
|
|
|
21204
21206
|
});
|
|
21205
21207
|
|
|
21206
21208
|
// src/rules/require-fetch-timeout.ts
|
|
21207
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES96, ASTUtils as
|
|
21209
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES96, ASTUtils as ASTUtils57 } from "@typescript-eslint/utils";
|
|
21208
21210
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
21209
21211
|
summary: "Require an explicit abort signal on locally analyzable global fetch calls.",
|
|
21210
21212
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -21287,7 +21289,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21287
21289
|
}
|
|
21288
21290
|
function resolvesToGlobal(identifier) {
|
|
21289
21291
|
const scope = context.sourceCode.getScope(identifier);
|
|
21290
|
-
const variable =
|
|
21292
|
+
const variable = ASTUtils57.findVariable(scope, identifier.name);
|
|
21291
21293
|
return variable === null || variable.defs.length === 0;
|
|
21292
21294
|
}
|
|
21293
21295
|
function isGlobalFetchCall2(callee) {
|
|
@@ -21297,7 +21299,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21297
21299
|
return callee.type === AST_NODE_TYPES96.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES96.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES96.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
21298
21300
|
}
|
|
21299
21301
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
21300
|
-
const variable =
|
|
21302
|
+
const variable = ASTUtils57.findVariable(
|
|
21301
21303
|
context.sourceCode.getScope(identifier),
|
|
21302
21304
|
identifier.name
|
|
21303
21305
|
);
|
|
@@ -21319,7 +21321,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21319
21321
|
function isForwardedRequest(argument) {
|
|
21320
21322
|
let value = argument;
|
|
21321
21323
|
if (value.type === AST_NODE_TYPES96.Identifier) {
|
|
21322
|
-
const binding =
|
|
21324
|
+
const binding = ASTUtils57.findVariable(context.sourceCode.getScope(value), value.name);
|
|
21323
21325
|
const definition = binding?.defs.length === 1 ? binding.defs[0] : void 0;
|
|
21324
21326
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || binding?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21325
21327
|
value = definition.node.init;
|
|
@@ -21493,7 +21495,7 @@ function exportedClasses(program, classes) {
|
|
|
21493
21495
|
}
|
|
21494
21496
|
|
|
21495
21497
|
// src/rules/require-sql-access-class.ts
|
|
21496
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES98, ASTUtils as
|
|
21498
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES98, ASTUtils as ASTUtils58 } from "@typescript-eslint/utils";
|
|
21497
21499
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
21498
21500
|
"all",
|
|
21499
21501
|
"batch",
|
|
@@ -21767,12 +21769,12 @@ var require_sql_access_class_default = createRule({
|
|
|
21767
21769
|
if (seen.has(node)) return false;
|
|
21768
21770
|
seen.add(node);
|
|
21769
21771
|
if (node.type === AST_NODE_TYPES98.Identifier) {
|
|
21770
|
-
const binding =
|
|
21772
|
+
const binding = ASTUtils58.findVariable(context.sourceCode.getScope(node), node.name);
|
|
21771
21773
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21772
21774
|
const definition = binding.defs[0];
|
|
21773
21775
|
return definition?.type === "Variable" && definition.node.init !== null && knownNonDatabase(definition.node.init, seen);
|
|
21774
21776
|
}
|
|
21775
|
-
return node.type === AST_NODE_TYPES98.NewExpression && node.callee.type === AST_NODE_TYPES98.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(node.callee.name) && (
|
|
21777
|
+
return node.type === AST_NODE_TYPES98.NewExpression && node.callee.type === AST_NODE_TYPES98.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(node.callee.name) && (ASTUtils58.findVariable(context.sourceCode.getScope(node.callee), node.callee.name)?.defs.length ?? 0) === 0;
|
|
21776
21778
|
}
|
|
21777
21779
|
return {
|
|
21778
21780
|
CallExpression(node) {
|
|
@@ -21884,7 +21886,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
21884
21886
|
});
|
|
21885
21887
|
|
|
21886
21888
|
// src/rules/require-use-form-default-values.ts
|
|
21887
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES100, ASTUtils as
|
|
21889
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES100, ASTUtils as ASTUtils59 } from "@typescript-eslint/utils";
|
|
21888
21890
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
21889
21891
|
summary: "Require explicit form-level initialization or a field default for directly bound Controller fields.",
|
|
21890
21892
|
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.",
|
|
@@ -21939,7 +21941,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
21939
21941
|
const imported = /* @__PURE__ */ new Map();
|
|
21940
21942
|
const uninitializedForms = /* @__PURE__ */ new Set();
|
|
21941
21943
|
const uninitializedControls = /* @__PURE__ */ new Set();
|
|
21942
|
-
const bindingNamed = (node, name) =>
|
|
21944
|
+
const bindingNamed = (node, name) => ASTUtils59.findVariable(context.sourceCode.getScope(node), name);
|
|
21943
21945
|
const bindingOf = (node) => bindingNamed(node, node.name);
|
|
21944
21946
|
const stable = (variable) => !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
21945
21947
|
const importedKind = (node) => {
|
|
@@ -21981,7 +21983,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
21981
21983
|
const variable = bindingOf(node);
|
|
21982
21984
|
return variable !== null && stable(variable) && uninitializedControls.has(variable);
|
|
21983
21985
|
}
|
|
21984
|
-
return node.type === AST_NODE_TYPES100.MemberExpression &&
|
|
21986
|
+
return node.type === AST_NODE_TYPES100.MemberExpression && ASTUtils59.getPropertyName(node) !== null && (ASTUtils59.getPropertyName(node) ?? "") === "control" && isUninitializedForm(node.object);
|
|
21985
21987
|
};
|
|
21986
21988
|
const fieldOptionsNeedDefault = (node) => {
|
|
21987
21989
|
if (node?.type !== AST_NODE_TYPES100.ObjectExpression) return false;
|
|
@@ -22037,7 +22039,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22037
22039
|
trackDestructuredControl(node.id);
|
|
22038
22040
|
return;
|
|
22039
22041
|
}
|
|
22040
|
-
if (node.id.type === AST_NODE_TYPES100.Identifier && node.init.type === AST_NODE_TYPES100.MemberExpression &&
|
|
22042
|
+
if (node.id.type === AST_NODE_TYPES100.Identifier && node.init.type === AST_NODE_TYPES100.MemberExpression && ASTUtils59.getPropertyName(node.init) !== null && (ASTUtils59.getPropertyName(node.init) ?? "") === "control" && isUninitializedForm(node.init.object)) {
|
|
22041
22043
|
const variable = bindingOf(node.id);
|
|
22042
22044
|
if (variable !== null) uninitializedControls.add(variable);
|
|
22043
22045
|
}
|
|
@@ -22129,7 +22131,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
22129
22131
|
// src/rules/require-zod-form-validation.ts
|
|
22130
22132
|
import {
|
|
22131
22133
|
AST_NODE_TYPES as AST_NODE_TYPES101,
|
|
22132
|
-
ASTUtils as
|
|
22134
|
+
ASTUtils as ASTUtils60
|
|
22133
22135
|
} from "@typescript-eslint/utils";
|
|
22134
22136
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
22135
22137
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
@@ -22177,7 +22179,7 @@ var isFormDataMethodCall = (node) => {
|
|
|
22177
22179
|
}
|
|
22178
22180
|
if (current.type !== AST_NODE_TYPES101.CallExpression) return false;
|
|
22179
22181
|
const callee = current.callee;
|
|
22180
|
-
return callee.type === AST_NODE_TYPES101.MemberExpression &&
|
|
22182
|
+
return callee.type === AST_NODE_TYPES101.MemberExpression && ASTUtils60.getPropertyName(callee) !== null && (ASTUtils60.getPropertyName(callee) ?? "") === "formData";
|
|
22181
22183
|
};
|
|
22182
22184
|
var require_zod_form_validation_default = createRule({
|
|
22183
22185
|
name: "require-zod-form-validation",
|
|
@@ -22198,14 +22200,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
22198
22200
|
return {};
|
|
22199
22201
|
}
|
|
22200
22202
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
22201
|
-
const resolvedBinding = (identifier) =>
|
|
22203
|
+
const resolvedBinding = (identifier) => ASTUtils60.findVariable(
|
|
22202
22204
|
context.sourceCode.getScope(identifier),
|
|
22203
22205
|
identifier.name
|
|
22204
22206
|
);
|
|
22205
22207
|
const isFormDataGetCall = (node) => {
|
|
22206
22208
|
const callee = node.callee;
|
|
22207
22209
|
if (callee.type !== AST_NODE_TYPES101.MemberExpression) return false;
|
|
22208
|
-
if (callee
|
|
22210
|
+
if (ASTUtils60.getPropertyName(callee) === null || !FORM_VALUE_METHODS.has(ASTUtils60.getPropertyName(callee) ?? "")) {
|
|
22209
22211
|
return false;
|
|
22210
22212
|
}
|
|
22211
22213
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -22235,7 +22237,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22235
22237
|
parent = parent.parent;
|
|
22236
22238
|
continue;
|
|
22237
22239
|
}
|
|
22238
|
-
if (parent.type === AST_NODE_TYPES101.CallExpression && parent.callee.type === AST_NODE_TYPES101.MemberExpression &&
|
|
22240
|
+
if (parent.type === AST_NODE_TYPES101.CallExpression && parent.callee.type === AST_NODE_TYPES101.MemberExpression && parent.callee.object.type === AST_NODE_TYPES101.Identifier && parent.callee.object.name === "Object" && ASTUtils60.getPropertyName(parent.callee) !== null && (ASTUtils60.getPropertyName(parent.callee) ?? "") === "fromEntries" && (resolvedBinding(parent.callee.object)?.defs.length ?? 0) === 0) {
|
|
22239
22241
|
parent = parent.parent;
|
|
22240
22242
|
continue;
|
|
22241
22243
|
}
|
|
@@ -22247,7 +22249,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22247
22249
|
const isZodParseCall = (node) => {
|
|
22248
22250
|
if (node.type !== AST_NODE_TYPES101.CallExpression) return false;
|
|
22249
22251
|
const callee = node.callee;
|
|
22250
|
-
if (callee.type !== AST_NODE_TYPES101.MemberExpression ||
|
|
22252
|
+
if (callee.type !== AST_NODE_TYPES101.MemberExpression || ASTUtils60.getPropertyName(callee) === null || !ZOD_PARSE_METHODS.has(ASTUtils60.getPropertyName(callee) ?? "")) {
|
|
22251
22253
|
return false;
|
|
22252
22254
|
}
|
|
22253
22255
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -22333,7 +22335,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22333
22335
|
};
|
|
22334
22336
|
const zodParseMethod = (call) => {
|
|
22335
22337
|
const callee = call.callee;
|
|
22336
|
-
return callee.type === AST_NODE_TYPES101.MemberExpression &&
|
|
22338
|
+
return callee.type === AST_NODE_TYPES101.MemberExpression && ASTUtils60.getPropertyName(callee) !== null ? ASTUtils60.getPropertyName(callee) ?? "" : null;
|
|
22337
22339
|
};
|
|
22338
22340
|
const isSafePrevalidationInspection = (identifier) => {
|
|
22339
22341
|
const parent = identifier.parent;
|
|
@@ -22508,7 +22510,7 @@ function expressionCallableName(current) {
|
|
|
22508
22510
|
}
|
|
22509
22511
|
|
|
22510
22512
|
// src/rules/stepdown.ts
|
|
22511
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES102, ASTUtils as
|
|
22513
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES102, ASTUtils as ASTUtils61 } from "@typescript-eslint/utils";
|
|
22512
22514
|
var STEPDOWN_DOCUMENTATION = {
|
|
22513
22515
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
22514
22516
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -22808,7 +22810,7 @@ function receiverOrigin(context, object, receivers) {
|
|
|
22808
22810
|
while (true) {
|
|
22809
22811
|
const unwrapped = unwrapExpression7(current);
|
|
22810
22812
|
if (unwrapped.type !== AST_NODE_TYPES102.Identifier) return unwrapped;
|
|
22811
|
-
const variable =
|
|
22813
|
+
const variable = ASTUtils61.findVariable(context.sourceCode.getScope(unwrapped), unwrapped.name);
|
|
22812
22814
|
if (variable === null) return null;
|
|
22813
22815
|
const known = receivers.get(variable);
|
|
22814
22816
|
if (known !== void 0) return known;
|
|
@@ -22989,11 +22991,11 @@ function classScope(context, node, computedReferences) {
|
|
|
22989
22991
|
function classReceiverBindings(context, node) {
|
|
22990
22992
|
const classReceivers = /* @__PURE__ */ new Map();
|
|
22991
22993
|
if (node.id !== null) {
|
|
22992
|
-
const internal =
|
|
22994
|
+
const internal = ASTUtils61.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
22993
22995
|
if (internal !== null && stableVariable(internal)) classReceivers.set(internal, true);
|
|
22994
22996
|
}
|
|
22995
22997
|
if (node.type === AST_NODE_TYPES102.ClassExpression && node.parent.type === AST_NODE_TYPES102.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES102.Identifier && node.parent.parent.type === AST_NODE_TYPES102.VariableDeclaration && node.parent.parent.kind === "const") {
|
|
22996
|
-
const outer =
|
|
22998
|
+
const outer = ASTUtils61.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
22997
22999
|
if (outer !== null && stableVariable(outer)) classReceivers.set(outer, true);
|
|
22998
23000
|
}
|
|
22999
23001
|
return classReceivers;
|
|
@@ -23079,7 +23081,7 @@ function classMethodCounts(body2, methods) {
|
|
|
23079
23081
|
}
|
|
23080
23082
|
|
|
23081
23083
|
// src/rules/source-coupled-test.ts
|
|
23082
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES103, ASTUtils as
|
|
23084
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES103, ASTUtils as ASTUtils62 } from "@typescript-eslint/utils";
|
|
23083
23085
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc?|toml|py|[cm]?[jt]s)$/iu;
|
|
23084
23086
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
23085
23087
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -23199,7 +23201,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23199
23201
|
const scopes = [newScope()];
|
|
23200
23202
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
23201
23203
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
23202
|
-
const bindingOf = (node) =>
|
|
23204
|
+
const bindingOf = (node) => ASTUtils62.findVariable(context.sourceCode.getScope(node), node.name);
|
|
23203
23205
|
const assertionKind = (node) => {
|
|
23204
23206
|
const binding = bindingOf(node);
|
|
23205
23207
|
if (binding === null || binding.defs.length === 0) {
|
|
@@ -23572,7 +23574,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
23572
23574
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
23573
23575
|
import {
|
|
23574
23576
|
AST_NODE_TYPES as AST_NODE_TYPES105,
|
|
23575
|
-
ASTUtils as
|
|
23577
|
+
ASTUtils as ASTUtils63
|
|
23576
23578
|
} from "@typescript-eslint/utils";
|
|
23577
23579
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
23578
23580
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
@@ -23705,7 +23707,7 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
23705
23707
|
"superRefine",
|
|
23706
23708
|
"transform"
|
|
23707
23709
|
]);
|
|
23708
|
-
var terminalMethodName = (callee) =>
|
|
23710
|
+
var terminalMethodName = (callee) => ASTUtils63.getPropertyName(callee) !== null ? ASTUtils63.getPropertyName(callee) ?? "" : null;
|
|
23709
23711
|
var calleeChainRoot2 = (node) => {
|
|
23710
23712
|
let current = node;
|
|
23711
23713
|
for (; ; ) {
|
|
@@ -23728,8 +23730,8 @@ var chainMemberNames2 = (node) => {
|
|
|
23728
23730
|
let current = node;
|
|
23729
23731
|
for (; ; ) {
|
|
23730
23732
|
if (current.type === AST_NODE_TYPES105.MemberExpression) {
|
|
23731
|
-
if (
|
|
23732
|
-
names.push(current
|
|
23733
|
+
if (ASTUtils63.getPropertyName(current) === null) return [];
|
|
23734
|
+
names.push(ASTUtils63.getPropertyName(current) ?? "");
|
|
23733
23735
|
current = current.object;
|
|
23734
23736
|
continue;
|
|
23735
23737
|
}
|
|
@@ -23773,7 +23775,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
23773
23775
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
23774
23776
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
23775
23777
|
function resolvedBinding(identifier) {
|
|
23776
|
-
return
|
|
23778
|
+
return ASTUtils63.findVariable(
|
|
23777
23779
|
context.sourceCode.getScope(identifier),
|
|
23778
23780
|
identifier.name
|
|
23779
23781
|
);
|
|
@@ -24041,7 +24043,7 @@ var RULES = {
|
|
|
24041
24043
|
};
|
|
24042
24044
|
var meta = {
|
|
24043
24045
|
name: "@sarj/eslint-plugin",
|
|
24044
|
-
version: "16.3.
|
|
24046
|
+
version: "16.3.1"
|
|
24045
24047
|
};
|
|
24046
24048
|
var APPLICATION_ONLY_RULES = [];
|
|
24047
24049
|
var LIBRARY_IMPORT_POLICY = ["error", {
|