@sarj/eslint-plugin 16.2.6 → 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 +247 -175
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +391 -318
- 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,14 +14831,15 @@ 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.",
|
|
14835
14838
|
remediation: "Expose literals with `as const` or a readonly type, and expose Set or Map values through ReadonlySet or ReadonlyMap.",
|
|
14836
14839
|
category: "correctness",
|
|
14837
14840
|
limitations: [
|
|
14838
|
-
"Generated, test and JavaScript files are skipped. Private constants with observed direct or alias mutation are excluded; exported mutable collections remain advisory candidates. Reassigned aliases are conservatively followed, not flow-proven."
|
|
14841
|
+
"Generated, test and JavaScript files are skipped. Private constants with observed direct or alias mutation are excluded; exported mutable collections remain advisory candidates. Reassigned aliases are conservatively followed, not flow-proven.",
|
|
14842
|
+
"Local type aliases are resolved before recognizing standard readonly types; imported or otherwise unknown type declarations are not inferred from their names. Readonly types have no runtime enforcement."
|
|
14839
14843
|
],
|
|
14840
14844
|
examples: [
|
|
14841
14845
|
{
|
|
@@ -14855,6 +14859,26 @@ var PREFER_IMMUTABLE_MODULE_CONSTANT_DOCUMENTATION = {
|
|
|
14855
14859
|
focusPath: "src/constants.ts",
|
|
14856
14860
|
expectedCount: 1,
|
|
14857
14861
|
public: true
|
|
14862
|
+
},
|
|
14863
|
+
{
|
|
14864
|
+
id: "shadowed-readonly-alias",
|
|
14865
|
+
scenarioId: "type-binding",
|
|
14866
|
+
title: "A type named Readonly still exposes mutable properties",
|
|
14867
|
+
outcome: "match",
|
|
14868
|
+
files: [{ path: "src/constants.ts", source: "type Readonly = { voice: boolean };\nexport const TOOL_SUPPORT: Readonly = { voice: true };" }],
|
|
14869
|
+
focusPath: "src/constants.ts",
|
|
14870
|
+
expectedCount: 1,
|
|
14871
|
+
public: true
|
|
14872
|
+
},
|
|
14873
|
+
{
|
|
14874
|
+
id: "resolved-readonly-alias",
|
|
14875
|
+
scenarioId: "type-binding",
|
|
14876
|
+
title: "A local alias resolves to readonly properties",
|
|
14877
|
+
outcome: "no-match",
|
|
14878
|
+
files: [{ path: "src/constants.ts", source: "type ToolSupport = Readonly<{ voice: boolean }>;\nexport const TOOL_SUPPORT: ToolSupport = { voice: true };" }],
|
|
14879
|
+
focusPath: "src/constants.ts",
|
|
14880
|
+
expectedCount: 0,
|
|
14881
|
+
public: true
|
|
14858
14882
|
}
|
|
14859
14883
|
]
|
|
14860
14884
|
};
|
|
@@ -14909,39 +14933,84 @@ function collectionKind(node, isUnshadowedGlobal3) {
|
|
|
14909
14933
|
}
|
|
14910
14934
|
return null;
|
|
14911
14935
|
}
|
|
14912
|
-
function declaredReadonlyType(node, kind,
|
|
14936
|
+
function declaredReadonlyType(node, kind, resolveLocalType, isUnshadowedType) {
|
|
14913
14937
|
const annotation = node.id.type === AST_NODE_TYPES72.Identifier ? node.id.typeAnnotation : void 0;
|
|
14914
|
-
if (annotation !== void 0 &&
|
|
14938
|
+
if (annotation !== void 0 && readonlyTypeState(annotation.typeAnnotation, kind, resolveLocalType, isUnshadowedType) === "readonly") {
|
|
14915
14939
|
return true;
|
|
14916
14940
|
}
|
|
14917
|
-
return node.init?.type === AST_NODE_TYPES72.TSAsExpression &&
|
|
14941
|
+
return node.init?.type === AST_NODE_TYPES72.TSAsExpression && readonlyTypeState(node.init.typeAnnotation, kind, resolveLocalType, isUnshadowedType) === "readonly";
|
|
14918
14942
|
}
|
|
14919
|
-
function
|
|
14920
|
-
if (
|
|
14921
|
-
if (node.type !== AST_NODE_TYPES72.TSTypeReference || node.typeName.type !== AST_NODE_TYPES72.Identifier)
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14943
|
+
function readonlyTypeState(node, kind, resolveLocalType, isUnshadowedType, arguments_ = /* @__PURE__ */ new Map(), seen = /* @__PURE__ */ new Set()) {
|
|
14944
|
+
if (seen.has(node)) return "unknown";
|
|
14945
|
+
if (node.type !== AST_NODE_TYPES72.TSTypeReference || node.typeName.type !== AST_NODE_TYPES72.Identifier) {
|
|
14946
|
+
return directReadonlyState(node, kind, isUnshadowedType);
|
|
14947
|
+
}
|
|
14948
|
+
const declaration = resolveLocalType(node.typeName);
|
|
14949
|
+
if (declaration === void 0) return directReadonlyState(node, kind, isUnshadowedType);
|
|
14950
|
+
if (declaration.type === AST_NODE_TYPES72.TSTypeParameter) {
|
|
14951
|
+
const argument = arguments_.get(declaration);
|
|
14952
|
+
return argument === void 0 ? "unknown" : readonlyTypeState(
|
|
14953
|
+
argument.node,
|
|
14954
|
+
kind,
|
|
14955
|
+
resolveLocalType,
|
|
14956
|
+
isUnshadowedType,
|
|
14957
|
+
argument.arguments,
|
|
14958
|
+
argument.seen
|
|
14959
|
+
);
|
|
14960
|
+
}
|
|
14961
|
+
const expanded = /* @__PURE__ */ new Set([...seen, node]);
|
|
14962
|
+
return readonlyTypeState(
|
|
14963
|
+
declaration.typeAnnotation,
|
|
14964
|
+
kind,
|
|
14965
|
+
resolveLocalType,
|
|
14966
|
+
isUnshadowedType,
|
|
14967
|
+
bindTypeArguments(declaration, node, arguments_, expanded),
|
|
14968
|
+
expanded
|
|
14969
|
+
);
|
|
14970
|
+
}
|
|
14971
|
+
function bindTypeArguments(declaration, reference, arguments_, seen) {
|
|
14972
|
+
const bindings = new Map(arguments_);
|
|
14973
|
+
for (const [index, parameter] of (declaration.typeParameters?.params ?? []).entries()) {
|
|
14974
|
+
const argument = reference.typeArguments?.params[index];
|
|
14975
|
+
const node = argument ?? parameter.default;
|
|
14976
|
+
if (node !== void 0) {
|
|
14977
|
+
bindings.set(parameter, { node, arguments: argument === void 0 ? new Map(bindings) : arguments_, seen });
|
|
14978
|
+
}
|
|
14979
|
+
}
|
|
14980
|
+
return bindings;
|
|
14926
14981
|
}
|
|
14927
|
-
function
|
|
14982
|
+
function directReadonlyState(node, kind, isUnshadowedType) {
|
|
14928
14983
|
if (node.type === AST_NODE_TYPES72.TSTypeOperator && node.operator === "readonly") {
|
|
14929
|
-
return
|
|
14984
|
+
return "readonly";
|
|
14930
14985
|
}
|
|
14931
|
-
if (node.type
|
|
14932
|
-
return
|
|
14986
|
+
if (node.type === AST_NODE_TYPES72.TSTypeLiteral) {
|
|
14987
|
+
if (node.members.length === 0) return "unknown";
|
|
14988
|
+
const readonly2 = kind === "literal" && node.members.length > 0 && node.members.every(
|
|
14989
|
+
(member) => (member.type === AST_NODE_TYPES72.TSPropertySignature || member.type === AST_NODE_TYPES72.TSIndexSignature) && member.readonly
|
|
14990
|
+
);
|
|
14991
|
+
return readonly2 ? "readonly" : "mutable";
|
|
14992
|
+
}
|
|
14993
|
+
if (node.type === AST_NODE_TYPES72.TSArrayType || node.type === AST_NODE_TYPES72.TSTupleType) return "mutable";
|
|
14994
|
+
if (node.type !== AST_NODE_TYPES72.TSTypeReference || node.typeName.type !== AST_NODE_TYPES72.Identifier || !isUnshadowedType(node.typeName)) {
|
|
14995
|
+
return "unknown";
|
|
14933
14996
|
}
|
|
14934
14997
|
if (node.typeName.name === "Readonly") {
|
|
14935
|
-
return kind === "literal";
|
|
14998
|
+
return kind === "literal" ? "readonly" : "mutable";
|
|
14936
14999
|
}
|
|
14937
|
-
|
|
15000
|
+
if (["Array", "Map", "Set"].includes(node.typeName.name)) return "mutable";
|
|
15001
|
+
if (!["ReadonlyArray", "ReadonlyMap", "ReadonlySet"].includes(node.typeName.name)) return "unknown";
|
|
15002
|
+
const readonly = kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
15003
|
+
return readonly ? "readonly" : "mutable";
|
|
14938
15004
|
}
|
|
14939
|
-
function hasUnknownExplicitType(node,
|
|
14940
|
-
const annotation = node.id.type === AST_NODE_TYPES72.Identifier ? node.id.typeAnnotation?.typeAnnotation : void 0;
|
|
15005
|
+
function hasUnknownExplicitType(node, kind, resolveLocalType, isUnshadowedType) {
|
|
15006
|
+
const annotation = (node.id.type === AST_NODE_TYPES72.Identifier ? node.id.typeAnnotation?.typeAnnotation : void 0) ?? (node.init?.type === AST_NODE_TYPES72.TSAsExpression ? node.init.typeAnnotation : void 0);
|
|
14941
15007
|
if (annotation === void 0) return false;
|
|
14942
15008
|
if (annotation.type === AST_NODE_TYPES72.TSArrayType || annotation.type === AST_NODE_TYPES72.TSTypeOperator) return false;
|
|
14943
15009
|
if (annotation.type !== AST_NODE_TYPES72.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES72.Identifier) return true;
|
|
14944
|
-
|
|
15010
|
+
if (resolveLocalType(annotation.typeName) !== void 0) {
|
|
15011
|
+
return readonlyTypeState(annotation, kind, resolveLocalType, isUnshadowedType) === "unknown";
|
|
15012
|
+
}
|
|
15013
|
+
return resolveLocalType(annotation.typeName) === void 0 && (!isUnshadowedType(annotation.typeName) || !["Array", "Map", "Readonly", "ReadonlyArray", "ReadonlyMap", "ReadonlySet", "Set"].includes(annotation.typeName.name));
|
|
14945
15014
|
}
|
|
14946
15015
|
function referenceMutates(identifier, isUnshadowedGlobal3) {
|
|
14947
15016
|
let member = identifier.parent;
|
|
@@ -14981,14 +15050,23 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
14981
15050
|
create(context) {
|
|
14982
15051
|
const sourceCode = context.sourceCode;
|
|
14983
15052
|
const isUnshadowedGlobal3 = (identifier) => {
|
|
14984
|
-
const variable =
|
|
15053
|
+
const variable = ASTUtils39.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
14985
15054
|
return variable === null || variable.defs.length === 0;
|
|
14986
15055
|
};
|
|
15056
|
+
const isUnshadowedType = (identifier) => {
|
|
15057
|
+
const variable = ASTUtils39.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
15058
|
+
return variable === null || !variable.defs.some((definition) => definition.isTypeDefinition);
|
|
15059
|
+
};
|
|
15060
|
+
const resolveLocalType = (identifier) => {
|
|
15061
|
+
const variable = ASTUtils39.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
15062
|
+
const definitions = variable?.defs.filter((definition) => definition.isTypeDefinition) ?? [];
|
|
15063
|
+
const declaration = definitions.length === 1 ? definitions[0]?.node : void 0;
|
|
15064
|
+
return declaration?.type === AST_NODE_TYPES72.TSTypeAliasDeclaration || declaration?.type === AST_NODE_TYPES72.TSTypeParameter ? declaration : void 0;
|
|
15065
|
+
};
|
|
14987
15066
|
if (JAVASCRIPT_FILE_RE.test(context.filename) || isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
14988
15067
|
return {};
|
|
14989
15068
|
}
|
|
14990
15069
|
const exportedNames2 = /* @__PURE__ */ new Set();
|
|
14991
|
-
const typeAliases2 = /* @__PURE__ */ new Map();
|
|
14992
15070
|
const mutatesThroughAlias = (root) => {
|
|
14993
15071
|
const pending = [root];
|
|
14994
15072
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -15013,10 +15091,6 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
15013
15091
|
return {
|
|
15014
15092
|
Program(node) {
|
|
15015
15093
|
function collectModuleBindings(statement) {
|
|
15016
|
-
const declaration = statement.type === AST_NODE_TYPES72.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15017
|
-
if (declaration?.type === AST_NODE_TYPES72.TSTypeAliasDeclaration) {
|
|
15018
|
-
typeAliases2.set(declaration.id.name, declaration.typeAnnotation);
|
|
15019
|
-
}
|
|
15020
15094
|
if (statement.type === AST_NODE_TYPES72.ExportNamedDeclaration) {
|
|
15021
15095
|
if (statement.source !== null || statement.exportKind === "type") return;
|
|
15022
15096
|
for (const specifier of statement.specifiers) {
|
|
@@ -15049,7 +15123,7 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
15049
15123
|
return;
|
|
15050
15124
|
}
|
|
15051
15125
|
const kind = collectionKind(node.init, isUnshadowedGlobal3);
|
|
15052
|
-
if (kind === null || declaredReadonlyType(node, kind,
|
|
15126
|
+
if (kind === null || declaredReadonlyType(node, kind, resolveLocalType, isUnshadowedType) || hasUnknownExplicitType(node, kind, resolveLocalType, isUnshadowedType)) {
|
|
15053
15127
|
return;
|
|
15054
15128
|
}
|
|
15055
15129
|
const variable = sourceCode.getDeclaredVariables(node)[0];
|
|
@@ -15800,7 +15874,7 @@ function isSafeMemberRead(identifier, parent) {
|
|
|
15800
15874
|
}
|
|
15801
15875
|
|
|
15802
15876
|
// src/rules/prefer-module-level-schema.ts
|
|
15803
|
-
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";
|
|
15804
15878
|
var PREFER_MODULE_LEVEL_SCHEMA_DOCUMENTATION = {
|
|
15805
15879
|
summary: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function",
|
|
15806
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.",
|
|
@@ -15908,7 +15982,7 @@ function schemaExpression(node) {
|
|
|
15908
15982
|
if (parent === void 0) {
|
|
15909
15983
|
return current;
|
|
15910
15984
|
}
|
|
15911
|
-
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) ?? "")) {
|
|
15912
15986
|
return current;
|
|
15913
15987
|
}
|
|
15914
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) {
|
|
@@ -15978,7 +16052,7 @@ function buildsLocalizedText(node) {
|
|
|
15978
16052
|
if (callee.type === AST_NODE_TYPES75.Identifier) {
|
|
15979
16053
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
15980
16054
|
}
|
|
15981
|
-
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);
|
|
15982
16056
|
});
|
|
15983
16057
|
}
|
|
15984
16058
|
function collectReferences(scope, out) {
|
|
@@ -16042,13 +16116,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16042
16116
|
}
|
|
16043
16117
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
16044
16118
|
function isZodCall(node) {
|
|
16045
|
-
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);
|
|
16046
16120
|
}
|
|
16047
16121
|
function isSchemaConstruction(node) {
|
|
16048
16122
|
const callee = node.callee;
|
|
16049
|
-
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;
|
|
16050
16124
|
if (callee.object.type === AST_NODE_TYPES75.CallExpression) return isSchemaConstruction(callee.object);
|
|
16051
|
-
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(callee
|
|
16125
|
+
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(ASTUtils40.getPropertyName(callee) ?? "");
|
|
16052
16126
|
}
|
|
16053
16127
|
function hasEagerComputation(node) {
|
|
16054
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);
|
|
@@ -16056,10 +16130,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16056
16130
|
function isCovered(node) {
|
|
16057
16131
|
let current = node.parent ?? void 0;
|
|
16058
16132
|
while (current !== void 0) {
|
|
16059
|
-
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) ?? "")) {
|
|
16060
16134
|
return true;
|
|
16061
16135
|
}
|
|
16062
|
-
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) ?? ""))) {
|
|
16063
16137
|
return true;
|
|
16064
16138
|
}
|
|
16065
16139
|
current = current.parent ?? void 0;
|
|
@@ -16088,7 +16162,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16088
16162
|
}
|
|
16089
16163
|
function isSchemaComposition(node) {
|
|
16090
16164
|
const { callee } = node;
|
|
16091
|
-
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) ?? "");
|
|
16092
16166
|
return isCombinator || isZodCall(node);
|
|
16093
16167
|
}
|
|
16094
16168
|
function closesOverNothing(node, enclosing) {
|
|
@@ -16160,10 +16234,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16160
16234
|
return;
|
|
16161
16235
|
}
|
|
16162
16236
|
const callee = node.callee;
|
|
16163
|
-
if (callee
|
|
16237
|
+
if (ASTUtils40.getPropertyName(callee) === null) {
|
|
16164
16238
|
return;
|
|
16165
16239
|
}
|
|
16166
|
-
const factory = callee
|
|
16240
|
+
const factory = ASTUtils40.getPropertyName(callee) ?? "";
|
|
16167
16241
|
if (!factories.has(factory)) {
|
|
16168
16242
|
return;
|
|
16169
16243
|
}
|
|
@@ -16206,7 +16280,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16206
16280
|
// src/rules/prefer-module-level-refined-schema.ts
|
|
16207
16281
|
import {
|
|
16208
16282
|
AST_NODE_TYPES as AST_NODE_TYPES76,
|
|
16209
|
-
ASTUtils as
|
|
16283
|
+
ASTUtils as ASTUtils41
|
|
16210
16284
|
} from "@typescript-eslint/utils";
|
|
16211
16285
|
var BENCHMARK_PATH_RE = /(^|[/\\])(?:benchmarks?|bench)[/\\]/;
|
|
16212
16286
|
var FACTORIES = /* @__PURE__ */ new Set([
|
|
@@ -16407,7 +16481,7 @@ function buildsLocalizedText2(node) {
|
|
|
16407
16481
|
const { callee } = inner;
|
|
16408
16482
|
if (callee.type === AST_NODE_TYPES76.Identifier)
|
|
16409
16483
|
return I18N_CALLEE_NAMES2.has(callee.name);
|
|
16410
|
-
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);
|
|
16411
16485
|
});
|
|
16412
16486
|
}
|
|
16413
16487
|
function calleeChainRoot(node) {
|
|
@@ -16430,9 +16504,9 @@ function chainMemberNames(node) {
|
|
|
16430
16504
|
let current = node;
|
|
16431
16505
|
for (; ; ) {
|
|
16432
16506
|
if (current.type === AST_NODE_TYPES76.MemberExpression) {
|
|
16433
|
-
if (
|
|
16507
|
+
if (ASTUtils41.getPropertyName(current) === null)
|
|
16434
16508
|
return [];
|
|
16435
|
-
names.push(current
|
|
16509
|
+
names.push(ASTUtils41.getPropertyName(current) ?? "");
|
|
16436
16510
|
current = current.object;
|
|
16437
16511
|
continue;
|
|
16438
16512
|
}
|
|
@@ -16449,8 +16523,8 @@ function schemaExpression2(node) {
|
|
|
16449
16523
|
let current = node;
|
|
16450
16524
|
for (; ; ) {
|
|
16451
16525
|
const parent = current.parent ?? void 0;
|
|
16452
|
-
if (parent?.type === AST_NODE_TYPES76.MemberExpression && parent.object === current &&
|
|
16453
|
-
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;
|
|
16454
16528
|
current = parent.parent;
|
|
16455
16529
|
continue;
|
|
16456
16530
|
}
|
|
@@ -16480,7 +16554,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16480
16554
|
return {};
|
|
16481
16555
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
16482
16556
|
function resolvedBinding(identifier) {
|
|
16483
|
-
return
|
|
16557
|
+
return ASTUtils41.findVariable(
|
|
16484
16558
|
context.sourceCode.getScope(identifier),
|
|
16485
16559
|
identifier.name
|
|
16486
16560
|
);
|
|
@@ -16504,7 +16578,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16504
16578
|
}
|
|
16505
16579
|
function isSchemaConstruction(node) {
|
|
16506
16580
|
const callee = node.callee;
|
|
16507
|
-
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;
|
|
16508
16582
|
if (callee.object.type === AST_NODE_TYPES76.CallExpression) return isSchemaConstruction(callee.object);
|
|
16509
16583
|
return factoryName(node, FACTORIES) !== null || factoryName(node, COMPOSITE_FACTORIES) !== null;
|
|
16510
16584
|
}
|
|
@@ -16531,7 +16605,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16531
16605
|
function isMemoized(node) {
|
|
16532
16606
|
let current = node.parent ?? void 0;
|
|
16533
16607
|
while (current !== void 0) {
|
|
16534
|
-
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) ?? "")))
|
|
16535
16609
|
return true;
|
|
16536
16610
|
current = current.parent ?? void 0;
|
|
16537
16611
|
}
|
|
@@ -16594,7 +16668,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16594
16668
|
// src/rules/prefer-multi-value-zod-literal.ts
|
|
16595
16669
|
import {
|
|
16596
16670
|
AST_NODE_TYPES as AST_NODE_TYPES77,
|
|
16597
|
-
ASTUtils as
|
|
16671
|
+
ASTUtils as ASTUtils42
|
|
16598
16672
|
} from "@typescript-eslint/utils";
|
|
16599
16673
|
var PREFER_MULTI_VALUE_ZOD_LITERAL_DOCUMENTATION = {
|
|
16600
16674
|
defaultLevel: "warning",
|
|
@@ -16642,7 +16716,7 @@ function isStaticPrimitive(node, context) {
|
|
|
16642
16716
|
if (node.type === AST_NODE_TYPES77.TemplateLiteral && node.expressions.length === 0)
|
|
16643
16717
|
return true;
|
|
16644
16718
|
if (node.type === AST_NODE_TYPES77.Identifier && node.name === "undefined") {
|
|
16645
|
-
const binding =
|
|
16719
|
+
const binding = ASTUtils42.findVariable(
|
|
16646
16720
|
context.sourceCode.getScope(node),
|
|
16647
16721
|
node.name
|
|
16648
16722
|
);
|
|
@@ -16679,13 +16753,13 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
16679
16753
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
16680
16754
|
const zod4Bindings = /* @__PURE__ */ new Set();
|
|
16681
16755
|
function resolvedBinding(identifier) {
|
|
16682
|
-
return
|
|
16756
|
+
return ASTUtils42.findVariable(
|
|
16683
16757
|
context.sourceCode.getScope(identifier),
|
|
16684
16758
|
identifier.name
|
|
16685
16759
|
);
|
|
16686
16760
|
}
|
|
16687
16761
|
function directMemberCall(node, binding, method) {
|
|
16688
|
-
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)
|
|
16689
16763
|
return false;
|
|
16690
16764
|
return resolvedBinding(node.callee.object) === binding;
|
|
16691
16765
|
}
|
|
@@ -16732,7 +16806,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
16732
16806
|
});
|
|
16733
16807
|
|
|
16734
16808
|
// src/rules/prefer-nominal-id-types.ts
|
|
16735
|
-
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";
|
|
16736
16810
|
var OPERATIONAL_ROLES = /* @__PURE__ */ new Set([
|
|
16737
16811
|
"request",
|
|
16738
16812
|
"trace",
|
|
@@ -16770,7 +16844,7 @@ function isNullish(node) {
|
|
|
16770
16844
|
}
|
|
16771
16845
|
function referenceCarrier(node, context, depth) {
|
|
16772
16846
|
if (node.typeName.type !== AST_NODE_TYPES78.Identifier) return void 0;
|
|
16773
|
-
const variable =
|
|
16847
|
+
const variable = ASTUtils43.findVariable(context.sourceCode.getScope(node), node.typeName.name);
|
|
16774
16848
|
const definitions = variable?.defs ?? [];
|
|
16775
16849
|
const args = node.typeArguments?.params;
|
|
16776
16850
|
if (definitions.length === 0 && ["Array", "ReadonlyArray"].includes(node.typeName.name) && args?.length === 1) {
|
|
@@ -16968,7 +17042,7 @@ var prefer_named_complex_return_type_default = createRule({
|
|
|
16968
17042
|
});
|
|
16969
17043
|
|
|
16970
17044
|
// src/rules/prefer-native-random-uuid.ts
|
|
16971
|
-
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";
|
|
16972
17046
|
var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
|
|
16973
17047
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
16974
17048
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -17004,14 +17078,14 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
17004
17078
|
const directBindings = /* @__PURE__ */ new Set();
|
|
17005
17079
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
17006
17080
|
function resolve2(identifier) {
|
|
17007
|
-
return
|
|
17081
|
+
return ASTUtils44.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
17008
17082
|
}
|
|
17009
17083
|
function record(identifier, destination) {
|
|
17010
17084
|
const variable = resolve2(identifier);
|
|
17011
17085
|
if (variable !== null) destination.add(variable);
|
|
17012
17086
|
}
|
|
17013
17087
|
function report2(node) {
|
|
17014
|
-
const globalBinding =
|
|
17088
|
+
const globalBinding = ASTUtils44.findVariable(context.sourceCode.getScope(node), "globalThis");
|
|
17015
17089
|
const canSuggest = (globalBinding?.defs.length ?? 0) === 0 && context.sourceCode.getCommentsInside(node).length === 0;
|
|
17016
17090
|
context.report({
|
|
17017
17091
|
node,
|
|
@@ -17069,7 +17143,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
17069
17143
|
});
|
|
17070
17144
|
|
|
17071
17145
|
// src/rules/prefer-node-crypto-hash.ts
|
|
17072
|
-
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";
|
|
17073
17147
|
var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
17074
17148
|
defaultLevel: "warning",
|
|
17075
17149
|
summary: "Prefer the modern one-shot node:crypto hash API when streaming state is unnecessary.",
|
|
@@ -17128,7 +17202,7 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
17128
17202
|
const directBindings = /* @__PURE__ */ new Set();
|
|
17129
17203
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
17130
17204
|
function resolve2(identifier) {
|
|
17131
|
-
return
|
|
17205
|
+
return ASTUtils45.findVariable(
|
|
17132
17206
|
context.sourceCode.getScope(identifier),
|
|
17133
17207
|
identifier.name
|
|
17134
17208
|
);
|
|
@@ -17202,7 +17276,7 @@ function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
|
17202
17276
|
}
|
|
17203
17277
|
|
|
17204
17278
|
// src/rules/prefer-node-fs-promises.ts
|
|
17205
|
-
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";
|
|
17206
17280
|
var PREFER_NODE_FS_PROMISES_DOCUMENTATION = {
|
|
17207
17281
|
defaultLevel: "warning",
|
|
17208
17282
|
summary: "Prefer promise-based Node.js filesystem APIs over synchronous calls in production modules.",
|
|
@@ -17264,7 +17338,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
17264
17338
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || normalizedFilename.includes("src/rules/"))
|
|
17265
17339
|
return {};
|
|
17266
17340
|
const namespaces = /* @__PURE__ */ new Set();
|
|
17267
|
-
const bindingOf = (node) =>
|
|
17341
|
+
const bindingOf = (node) => ASTUtils46.findVariable(context.sourceCode.getScope(node), node.name);
|
|
17268
17342
|
const isGlobal = (node) => {
|
|
17269
17343
|
const binding = bindingOf(node);
|
|
17270
17344
|
return binding === null || binding.defs.length === 0;
|
|
@@ -17330,7 +17404,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
17330
17404
|
});
|
|
17331
17405
|
|
|
17332
17406
|
// src/rules/prefer-non-nullable-collection.ts
|
|
17333
|
-
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";
|
|
17334
17408
|
var PREFER_NON_NULLABLE_COLLECTION_DOCUMENTATION = {
|
|
17335
17409
|
summary: "Suggest reviewing nullish arrays that use local empty-array defaults or a shared null-or-empty guard.",
|
|
17336
17410
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
@@ -17455,14 +17529,14 @@ function directlyCoalesced(node) {
|
|
|
17455
17529
|
return parent?.type === AST_NODE_TYPES84.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
17456
17530
|
}
|
|
17457
17531
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
17458
|
-
const variable =
|
|
17532
|
+
const variable = ASTUtils47.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
17459
17533
|
if (variable === null || variable.references.length === 0) return false;
|
|
17460
17534
|
return variable.references.every(
|
|
17461
17535
|
(reference) => belongsToFunction(reference.identifier, fn) && directlyCoalesced(reference.identifier)
|
|
17462
17536
|
);
|
|
17463
17537
|
}
|
|
17464
17538
|
function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
17465
|
-
const variable =
|
|
17539
|
+
const variable = ASTUtils47.findVariable(context.sourceCode.getScope(object), object.name);
|
|
17466
17540
|
if (variable === null) return false;
|
|
17467
17541
|
const accesses = variable.references.flatMap((reference) => {
|
|
17468
17542
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
@@ -17578,7 +17652,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
17578
17652
|
// src/rules/prefer-nullish-filter-predicate.ts
|
|
17579
17653
|
import {
|
|
17580
17654
|
AST_NODE_TYPES as AST_NODE_TYPES85,
|
|
17581
|
-
ASTUtils as
|
|
17655
|
+
ASTUtils as ASTUtils48,
|
|
17582
17656
|
ESLintUtils as ESLintUtils12
|
|
17583
17657
|
} from "@typescript-eslint/utils";
|
|
17584
17658
|
import ts10 from "typescript";
|
|
@@ -17624,7 +17698,7 @@ var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
|
17624
17698
|
]
|
|
17625
17699
|
};
|
|
17626
17700
|
function isUnshadowedBoolean(node, context) {
|
|
17627
|
-
const variable =
|
|
17701
|
+
const variable = ASTUtils48.findVariable(context.sourceCode.getScope(node), node.name);
|
|
17628
17702
|
return variable === null || variable.defs.length === 0;
|
|
17629
17703
|
}
|
|
17630
17704
|
function isBuiltinArrayFilter(node, services) {
|
|
@@ -17683,7 +17757,7 @@ function isProvablyTruthy(type, checker) {
|
|
|
17683
17757
|
}
|
|
17684
17758
|
function availableParameterName(node, context) {
|
|
17685
17759
|
for (const name of ["value", "item", "element", "candidate"]) {
|
|
17686
|
-
if (
|
|
17760
|
+
if (ASTUtils48.findVariable(context.sourceCode.getScope(node), name) === null) return name;
|
|
17687
17761
|
}
|
|
17688
17762
|
return null;
|
|
17689
17763
|
}
|
|
@@ -17714,7 +17788,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
17714
17788
|
CallExpression(node) {
|
|
17715
17789
|
const callee = node.callee;
|
|
17716
17790
|
const callback = node.arguments[0];
|
|
17717
|
-
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;
|
|
17718
17792
|
const elementType = arrayElementType(callee.object, services);
|
|
17719
17793
|
const checker = services.program.getTypeChecker();
|
|
17720
17794
|
if (elementType === null || !isNullishPlusTruthy(elementType, checker)) return;
|
|
@@ -17737,7 +17811,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
17737
17811
|
|
|
17738
17812
|
// src/rules/prefer-await-in-async-return.ts
|
|
17739
17813
|
import {
|
|
17740
|
-
ASTUtils as
|
|
17814
|
+
ASTUtils as ASTUtils49,
|
|
17741
17815
|
ESLintUtils as ESLintUtils13,
|
|
17742
17816
|
AST_NODE_TYPES as AST_NODE_TYPES86
|
|
17743
17817
|
} from "@typescript-eslint/utils";
|
|
@@ -17800,7 +17874,7 @@ function isRuntimeFunction(node) {
|
|
|
17800
17874
|
}
|
|
17801
17875
|
function promiseThenReceiver(node) {
|
|
17802
17876
|
const callee = node.callee;
|
|
17803
|
-
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) {
|
|
17804
17878
|
return null;
|
|
17805
17879
|
}
|
|
17806
17880
|
const callback = node.arguments[0];
|
|
@@ -17869,13 +17943,13 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
17869
17943
|
if (services === null) return {};
|
|
17870
17944
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
17871
17945
|
const rememberFrameworkLoader = (identifier) => {
|
|
17872
|
-
const variable =
|
|
17946
|
+
const variable = ASTUtils49.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
17873
17947
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
17874
17948
|
};
|
|
17875
17949
|
const isFrameworkLoaderCallback = (owner) => {
|
|
17876
17950
|
const parent = owner.parent;
|
|
17877
17951
|
if (parent.type !== AST_NODE_TYPES86.CallExpression || parent.arguments[0] !== owner || parent.callee.type !== AST_NODE_TYPES86.Identifier) return false;
|
|
17878
|
-
const variable =
|
|
17952
|
+
const variable = ASTUtils49.findVariable(context.sourceCode.getScope(parent.callee), parent.callee.name);
|
|
17879
17953
|
return variable !== null && frameworkLoaders.has(variable);
|
|
17880
17954
|
};
|
|
17881
17955
|
return {
|
|
@@ -17912,7 +17986,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
17912
17986
|
});
|
|
17913
17987
|
|
|
17914
17988
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
17915
|
-
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";
|
|
17916
17990
|
var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
17917
17991
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
17918
17992
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -17949,7 +18023,7 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
17949
18023
|
]);
|
|
17950
18024
|
var isSchemaParseReference = (node) => {
|
|
17951
18025
|
const inner = unwrap6(node);
|
|
17952
|
-
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");
|
|
17953
18027
|
};
|
|
17954
18028
|
var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
17955
18029
|
let current = unwrap6(node);
|
|
@@ -17964,31 +18038,31 @@ var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
|
17964
18038
|
if (callee === null || callee.type !== AST_NODE_TYPES87.MemberExpression) {
|
|
17965
18039
|
return false;
|
|
17966
18040
|
}
|
|
17967
|
-
const property =
|
|
17968
|
-
if (property === null
|
|
18041
|
+
const property = ASTUtils50.getPropertyName(callee);
|
|
18042
|
+
if (property === null) {
|
|
17969
18043
|
return false;
|
|
17970
18044
|
}
|
|
17971
|
-
if (property
|
|
17972
|
-
return
|
|
18045
|
+
if (property === "json") {
|
|
18046
|
+
return current.arguments.length === 0 && isResponseSource(callee.object, context);
|
|
17973
18047
|
}
|
|
17974
|
-
if (PROMISE_CHAIN_METHODS.has(property
|
|
18048
|
+
if (PROMISE_CHAIN_METHODS.has(property)) {
|
|
17975
18049
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object, context, isKnownLocalText);
|
|
17976
18050
|
}
|
|
17977
18051
|
const object = unwrap6(callee.object);
|
|
17978
18052
|
const input = unwrap6(current.arguments[0]);
|
|
17979
|
-
if (input?.type === AST_NODE_TYPES87.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES87.MemberExpression &&
|
|
17980
|
-
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;
|
|
17981
18055
|
};
|
|
17982
18056
|
var isResponseSource = (node, context, seen = /* @__PURE__ */ new Set()) => {
|
|
17983
18057
|
let current = unwrap6(node);
|
|
17984
18058
|
if (current?.type === AST_NODE_TYPES87.AwaitExpression) current = unwrap6(current.argument);
|
|
17985
18059
|
if (current === null || seen.has(current)) return false;
|
|
17986
18060
|
seen.add(current);
|
|
17987
|
-
const isGlobal = (identifier) => (
|
|
18061
|
+
const isGlobal = (identifier) => (ASTUtils50.findVariable(context.sourceCode.getScope(identifier), identifier.name)?.defs.length ?? 0) === 0;
|
|
17988
18062
|
if (current.type === AST_NODE_TYPES87.CallExpression) return current.callee.type === AST_NODE_TYPES87.Identifier && current.callee.name === "fetch" && isGlobal(current.callee);
|
|
17989
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);
|
|
17990
18064
|
if (current.type !== AST_NODE_TYPES87.Identifier) return false;
|
|
17991
|
-
const binding =
|
|
18065
|
+
const binding = ASTUtils50.findVariable(context.sourceCode.getScope(current), current.name);
|
|
17992
18066
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
17993
18067
|
const definition = binding.defs[0];
|
|
17994
18068
|
const annotation = definition?.name.type === AST_NODE_TYPES87.Identifier ? definition.name.typeAnnotation?.typeAnnotation : void 0;
|
|
@@ -18003,7 +18077,7 @@ var isDirectLocalFileRead = (node) => {
|
|
|
18003
18077
|
}
|
|
18004
18078
|
if (current?.type !== AST_NODE_TYPES87.CallExpression) return false;
|
|
18005
18079
|
const callee = unwrap6(current.callee);
|
|
18006
|
-
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;
|
|
18007
18081
|
return name !== null && FILE_READ_RE.test(name);
|
|
18008
18082
|
};
|
|
18009
18083
|
var isLocalFileRead = (node) => {
|
|
@@ -18064,7 +18138,7 @@ var isValidationRead = (node) => {
|
|
|
18064
18138
|
return false;
|
|
18065
18139
|
}
|
|
18066
18140
|
const callee = parent.callee;
|
|
18067
|
-
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") {
|
|
18068
18142
|
return parent.arguments.length === 1;
|
|
18069
18143
|
}
|
|
18070
18144
|
return callee.type === AST_NODE_TYPES87.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
@@ -18092,9 +18166,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
18092
18166
|
}
|
|
18093
18167
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
18094
18168
|
}
|
|
18095
|
-
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;
|
|
18096
18170
|
};
|
|
18097
|
-
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;
|
|
18098
18172
|
var isSamePlainMember = (node, access) => {
|
|
18099
18173
|
const candidate2 = plainMemberAccess(node);
|
|
18100
18174
|
return candidate2 !== null && candidate2.object === access.object && candidate2.property === access.property;
|
|
@@ -18156,7 +18230,7 @@ var memberValidationPolarity = (test, access) => {
|
|
|
18156
18230
|
}
|
|
18157
18231
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
18158
18232
|
}
|
|
18159
|
-
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;
|
|
18160
18234
|
};
|
|
18161
18235
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
18162
18236
|
const isValidationReference = (identifier) => {
|
|
@@ -18439,7 +18513,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
18439
18513
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
18440
18514
|
)) {
|
|
18441
18515
|
const parent = node.parent;
|
|
18442
|
-
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) ?? ""))) {
|
|
18443
18517
|
return;
|
|
18444
18518
|
}
|
|
18445
18519
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
@@ -18491,7 +18565,7 @@ function ifGuardDominates(use, branch, positive) {
|
|
|
18491
18565
|
}
|
|
18492
18566
|
|
|
18493
18567
|
// src/rules/prefer-shared-zod-enum.ts
|
|
18494
|
-
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";
|
|
18495
18569
|
var PREFER_SHARED_ZOD_ENUM_DOCUMENTATION = {
|
|
18496
18570
|
defaultLevel: "warning",
|
|
18497
18571
|
summary: "Give repeated literal Zod enum domains one reusable module-level schema.",
|
|
@@ -18541,7 +18615,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
18541
18615
|
create(context) {
|
|
18542
18616
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
18543
18617
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
18544
|
-
const bindingOf = (node) =>
|
|
18618
|
+
const bindingOf = (node) => ASTUtils51.findVariable(context.sourceCode.getScope(node), node.name);
|
|
18545
18619
|
const candidates = /* @__PURE__ */ new Map();
|
|
18546
18620
|
return {
|
|
18547
18621
|
ImportDeclaration(node) {
|
|
@@ -18554,7 +18628,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
18554
18628
|
}
|
|
18555
18629
|
},
|
|
18556
18630
|
CallExpression(node) {
|
|
18557
|
-
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;
|
|
18558
18632
|
const binding = bindingOf(node.callee.object);
|
|
18559
18633
|
if (binding === null || !zodBindings.has(binding)) return;
|
|
18560
18634
|
const domain = literalDomain(node);
|
|
@@ -19172,7 +19246,7 @@ function packageWorkspaceGlobs(parsed) {
|
|
|
19172
19246
|
}
|
|
19173
19247
|
|
|
19174
19248
|
// src/rules/prefer-server-actions.ts
|
|
19175
|
-
import { ASTUtils as
|
|
19249
|
+
import { ASTUtils as ASTUtils52 } from "@typescript-eslint/utils";
|
|
19176
19250
|
var PREFER_SERVER_ACTIONS_DOCUMENTATION = {
|
|
19177
19251
|
summary: "Prefer Next.js Server Actions over same-origin API mutations.",
|
|
19178
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.",
|
|
@@ -19204,7 +19278,7 @@ function resolvesToGlobalFetch(context, identifier) {
|
|
|
19204
19278
|
function resolveNode(node, context) {
|
|
19205
19279
|
if (!node) return null;
|
|
19206
19280
|
if (node.type !== "Identifier") return node;
|
|
19207
|
-
const variable =
|
|
19281
|
+
const variable = ASTUtils52.findVariable(getScope(context, node), node.name);
|
|
19208
19282
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
19209
19283
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return node;
|
|
19210
19284
|
if (definition.node.init.type === "ObjectExpression" && variable?.references.some((reference) => reference.identifier !== node && reference.init !== true)) return node;
|
|
@@ -19213,7 +19287,7 @@ function resolveNode(node, context) {
|
|
|
19213
19287
|
function isAxiosClient(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
19214
19288
|
if (node.type !== "Identifier" || seen.has(node)) return false;
|
|
19215
19289
|
seen.add(node);
|
|
19216
|
-
const variable =
|
|
19290
|
+
const variable = ASTUtils52.findVariable(getScope(context, node), node.name);
|
|
19217
19291
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
19218
19292
|
if (definition === void 0 || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
19219
19293
|
if (variable?.references.some((reference) => {
|
|
@@ -19428,11 +19502,10 @@ var prefer_server_actions_default = createRule({
|
|
|
19428
19502
|
});
|
|
19429
19503
|
|
|
19430
19504
|
// src/rules/prefer-whole-object-assertion.ts
|
|
19431
|
-
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";
|
|
19432
19506
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
19433
19507
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
19434
|
-
["toBeNull", "null"]
|
|
19435
|
-
["toBeUndefined", "undefined"]
|
|
19508
|
+
["toBeNull", "null"]
|
|
19436
19509
|
]);
|
|
19437
19510
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
19438
19511
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -19447,7 +19520,7 @@ var PREFER_WHOLE_OBJECT_ASSERTION_DOCUMENTATION = {
|
|
|
19447
19520
|
category: "testing",
|
|
19448
19521
|
aliases: ["strict-test-assertions"],
|
|
19449
19522
|
autofix: "none",
|
|
19450
|
-
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."],
|
|
19451
19524
|
examples: [
|
|
19452
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 },
|
|
19453
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 }
|
|
@@ -19491,9 +19564,9 @@ function literalIndex(node) {
|
|
|
19491
19564
|
function propertyAccess(node) {
|
|
19492
19565
|
const path = [];
|
|
19493
19566
|
let current = node;
|
|
19494
|
-
while (current.type === AST_NODE_TYPES91.MemberExpression && !current.
|
|
19495
|
-
if (current
|
|
19496
|
-
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) ?? "");
|
|
19497
19570
|
current = current.object;
|
|
19498
19571
|
}
|
|
19499
19572
|
return path.length > 0 && isPureReceiver(current) ? { receiver: current, path } : null;
|
|
@@ -19567,7 +19640,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19567
19640
|
if (first === void 0) {
|
|
19568
19641
|
return;
|
|
19569
19642
|
}
|
|
19570
|
-
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("")}`;
|
|
19571
19644
|
context.report({
|
|
19572
19645
|
node: first.statement,
|
|
19573
19646
|
messageId: "combineAssertions",
|
|
@@ -19636,10 +19709,10 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19636
19709
|
return null;
|
|
19637
19710
|
}
|
|
19638
19711
|
const callee = call.callee;
|
|
19639
|
-
if (callee.type !== AST_NODE_TYPES91.MemberExpression ||
|
|
19712
|
+
if (callee.type !== AST_NODE_TYPES91.MemberExpression || ASTUtils53.getPropertyName(callee) === null) {
|
|
19640
19713
|
return null;
|
|
19641
19714
|
}
|
|
19642
|
-
const matcher = callee
|
|
19715
|
+
const matcher = ASTUtils53.getPropertyName(callee) ?? "";
|
|
19643
19716
|
const expectCall = callee.object;
|
|
19644
19717
|
if (expectCall.type !== AST_NODE_TYPES91.CallExpression || expectCall.callee.type !== AST_NODE_TYPES91.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
19645
19718
|
return null;
|
|
@@ -19654,11 +19727,8 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19654
19727
|
}
|
|
19655
19728
|
let key;
|
|
19656
19729
|
let receiver;
|
|
19657
|
-
|
|
19658
|
-
|
|
19659
|
-
if (index === null) {
|
|
19660
|
-
return null;
|
|
19661
|
-
}
|
|
19730
|
+
const index = actual.computed ? literalIndex(actual.property) : null;
|
|
19731
|
+
if (index !== null) {
|
|
19662
19732
|
key = { kind: "index", index };
|
|
19663
19733
|
receiver = actual.object;
|
|
19664
19734
|
} else {
|
|
@@ -19670,7 +19740,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19670
19740
|
return assertionExpectation(statement, call, receiver, key, matcher);
|
|
19671
19741
|
}
|
|
19672
19742
|
function isTestExpect(callee) {
|
|
19673
|
-
const variable =
|
|
19743
|
+
const variable = ASTUtils53.findVariable(sourceCode.getScope(callee), callee.name);
|
|
19674
19744
|
if (variable !== null && variable.defs.some((definition) => {
|
|
19675
19745
|
if (definition.node.type !== AST_NODE_TYPES91.ImportSpecifier) return true;
|
|
19676
19746
|
const declaration = definition.node.parent;
|
|
@@ -19713,7 +19783,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
19713
19783
|
});
|
|
19714
19784
|
|
|
19715
19785
|
// src/rules/repeated-static-call-cases.ts
|
|
19716
|
-
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";
|
|
19717
19787
|
var REPEATED_STATIC_CALL_CASES_DOCUMENTATION = {
|
|
19718
19788
|
summary: "Review three or more consecutive static-input call assertions as potential named cases.",
|
|
19719
19789
|
rationale: "Copy-pasted cases obscure the input table, and a thrown assertion can stop later cases from being reported.",
|
|
@@ -19734,12 +19804,12 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
19734
19804
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
19735
19805
|
var MIN_CASES2 = 3;
|
|
19736
19806
|
function staticMemberName7(node) {
|
|
19737
|
-
if (
|
|
19807
|
+
if (ASTUtils54.getPropertyName(node) !== null) return ASTUtils54.getPropertyName(node) ?? "";
|
|
19738
19808
|
if (node.computed && node.property.type === AST_NODE_TYPES92.Literal && typeof node.property.value === "string") return node.property.value;
|
|
19739
19809
|
return null;
|
|
19740
19810
|
}
|
|
19741
19811
|
function importedName7(identifier, context, modules) {
|
|
19742
|
-
const variable =
|
|
19812
|
+
const variable = ASTUtils54.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
19743
19813
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
19744
19814
|
for (const definition of variable.defs) {
|
|
19745
19815
|
if (definition.node.type !== AST_NODE_TYPES92.ImportSpecifier) continue;
|
|
@@ -19804,8 +19874,8 @@ function staticShape(node) {
|
|
|
19804
19874
|
function assertionShape(statement, context, callback) {
|
|
19805
19875
|
if (statement.type !== AST_NODE_TYPES92.ExpressionStatement || statement.expression.type !== AST_NODE_TYPES92.CallExpression) return null;
|
|
19806
19876
|
const matcherCall = statement.expression;
|
|
19807
|
-
if (matcherCall.callee.type !== AST_NODE_TYPES92.MemberExpression ||
|
|
19808
|
-
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) ?? "";
|
|
19809
19879
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
19810
19880
|
const chain = expectCallFromMatcher(matcherCall.callee);
|
|
19811
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;
|
|
@@ -19813,7 +19883,7 @@ function assertionShape(statement, context, callback) {
|
|
|
19813
19883
|
const expected = matcherCall.arguments[0];
|
|
19814
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;
|
|
19815
19885
|
const skeleton = `${observed.callee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
19816
|
-
const binding =
|
|
19886
|
+
const binding = ASTUtils54.findVariable(context.sourceCode.getScope(observed.callee), observed.callee.name);
|
|
19817
19887
|
if (binding?.defs.some(
|
|
19818
19888
|
(definition) => definition.node.range[0] >= callback.range[0] && definition.node.range[1] <= callback.range[1]
|
|
19819
19889
|
)) return null;
|
|
@@ -19900,7 +19970,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
19900
19970
|
});
|
|
19901
19971
|
|
|
19902
19972
|
// src/rules/prefer-zod-infer.ts
|
|
19903
|
-
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";
|
|
19904
19974
|
var PREFER_ZOD_INFER_DOCUMENTATION = {
|
|
19905
19975
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
19906
19976
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -20217,7 +20287,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
20217
20287
|
let current = node;
|
|
20218
20288
|
while (current.type === AST_NODE_TYPES93.CallExpression) {
|
|
20219
20289
|
const callee = current.callee;
|
|
20220
|
-
if (callee.type !== AST_NODE_TYPES93.MemberExpression ||
|
|
20290
|
+
if (callee.type !== AST_NODE_TYPES93.MemberExpression || ASTUtils55.getPropertyName(callee) === null) {
|
|
20221
20291
|
return null;
|
|
20222
20292
|
}
|
|
20223
20293
|
chain.push(current);
|
|
@@ -20230,7 +20300,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
20230
20300
|
}
|
|
20231
20301
|
function twinMethodName(call) {
|
|
20232
20302
|
const callee = call.callee;
|
|
20233
|
-
return callee.type === AST_NODE_TYPES93.MemberExpression && callee
|
|
20303
|
+
return callee.type === AST_NODE_TYPES93.MemberExpression && ASTUtils55.getPropertyName(callee) !== null ? ASTUtils55.getPropertyName(callee) ?? "" : "";
|
|
20234
20304
|
}
|
|
20235
20305
|
function twinSchemaFields(initializer, zodNamespaces) {
|
|
20236
20306
|
const chain = twinCallChain(initializer, zodNamespaces);
|
|
@@ -20259,16 +20329,16 @@ function twinSchemaField(node, zodNamespaces) {
|
|
|
20259
20329
|
let leafCall = null;
|
|
20260
20330
|
while (current.type === AST_NODE_TYPES93.CallExpression) {
|
|
20261
20331
|
const callee = current.callee;
|
|
20262
|
-
if (callee.type !== AST_NODE_TYPES93.MemberExpression ||
|
|
20332
|
+
if (callee.type !== AST_NODE_TYPES93.MemberExpression || ASTUtils55.getPropertyName(callee) === null) {
|
|
20263
20333
|
break;
|
|
20264
20334
|
}
|
|
20265
20335
|
const receiver = callee.object;
|
|
20266
20336
|
if (receiver.type === AST_NODE_TYPES93.Identifier && zodNamespaces.has(receiver.name)) {
|
|
20267
|
-
leaf = callee
|
|
20337
|
+
leaf = ASTUtils55.getPropertyName(callee) ?? "";
|
|
20268
20338
|
leafCall = current;
|
|
20269
20339
|
break;
|
|
20270
20340
|
}
|
|
20271
|
-
modifiers.push(callee
|
|
20341
|
+
modifiers.push(ASTUtils55.getPropertyName(callee) ?? "");
|
|
20272
20342
|
current = receiver;
|
|
20273
20343
|
}
|
|
20274
20344
|
return {
|
|
@@ -20470,8 +20540,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
20470
20540
|
}
|
|
20471
20541
|
},
|
|
20472
20542
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
20473
|
-
"MemberExpression
|
|
20474
|
-
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) ?? "")) {
|
|
20475
20545
|
reshapedSchemaNames.add(node.object.name);
|
|
20476
20546
|
}
|
|
20477
20547
|
},
|
|
@@ -20629,6 +20699,7 @@ function staticFieldName(key) {
|
|
|
20629
20699
|
|
|
20630
20700
|
// src/rules/prefer-zod-parse-output-type.ts
|
|
20631
20701
|
import {
|
|
20702
|
+
ASTUtils as ASTUtils56,
|
|
20632
20703
|
AST_NODE_TYPES as AST_NODE_TYPES94,
|
|
20633
20704
|
ESLintUtils as ESLintUtils14
|
|
20634
20705
|
} from "@typescript-eslint/utils";
|
|
@@ -20695,11 +20766,11 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
20695
20766
|
let current = node;
|
|
20696
20767
|
while (current.type === AST_NODE_TYPES94.CallExpression) {
|
|
20697
20768
|
const { callee } = current;
|
|
20698
|
-
if (callee.type !== AST_NODE_TYPES94.MemberExpression ||
|
|
20769
|
+
if (callee.type !== AST_NODE_TYPES94.MemberExpression || ASTUtils56.getPropertyName(callee) === null) {
|
|
20699
20770
|
return false;
|
|
20700
20771
|
}
|
|
20701
20772
|
if (callee.object.type === AST_NODE_TYPES94.Identifier) {
|
|
20702
|
-
return namespaces.has(callee.object.name) && (callee
|
|
20773
|
+
return namespaces.has(callee.object.name) && ((ASTUtils56.getPropertyName(callee) ?? "") === "object" || (ASTUtils56.getPropertyName(callee) ?? "") === "strictObject");
|
|
20703
20774
|
}
|
|
20704
20775
|
current = callee.object;
|
|
20705
20776
|
}
|
|
@@ -20707,12 +20778,14 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
20707
20778
|
}
|
|
20708
20779
|
function zodParseCall(node) {
|
|
20709
20780
|
const { callee } = node;
|
|
20710
|
-
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) {
|
|
20711
20782
|
return null;
|
|
20712
20783
|
}
|
|
20784
|
+
const method = ASTUtils56.getPropertyName(callee);
|
|
20785
|
+
if (method !== "parse" && method !== "safeParse") return null;
|
|
20713
20786
|
return {
|
|
20714
20787
|
call: node,
|
|
20715
|
-
method
|
|
20788
|
+
method,
|
|
20716
20789
|
schema: callee.object
|
|
20717
20790
|
};
|
|
20718
20791
|
}
|
|
@@ -20750,7 +20823,7 @@ function localParseReturnCandidates(node, sourceCode) {
|
|
|
20750
20823
|
for (const reference of variable.references) {
|
|
20751
20824
|
const identifier = reference.identifier;
|
|
20752
20825
|
const parent = identifier.parent;
|
|
20753
|
-
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;
|
|
20754
20827
|
if (output === null) continue;
|
|
20755
20828
|
const candidate2 = returnedOutputCandidate(parsed, output);
|
|
20756
20829
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
@@ -20983,7 +21056,7 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
20983
21056
|
const candidate2 = directParseReturnCandidate(node);
|
|
20984
21057
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
20985
21058
|
},
|
|
20986
|
-
"MemberExpression
|
|
21059
|
+
"MemberExpression"(node) {
|
|
20987
21060
|
if (node.object.type === AST_NODE_TYPES94.Identifier && node.property.type === AST_NODE_TYPES94.Identifier && isPreferZodInferModuleReshaper(node.property.name)) {
|
|
20988
21061
|
reshapedSchemas.add(node.object.name);
|
|
20989
21062
|
}
|
|
@@ -21133,7 +21206,7 @@ var require_assert_never_default = createRule({
|
|
|
21133
21206
|
});
|
|
21134
21207
|
|
|
21135
21208
|
// src/rules/require-fetch-timeout.ts
|
|
21136
|
-
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";
|
|
21137
21210
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
21138
21211
|
summary: "Require an explicit abort signal on locally analyzable global fetch calls.",
|
|
21139
21212
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -21216,7 +21289,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21216
21289
|
}
|
|
21217
21290
|
function resolvesToGlobal(identifier) {
|
|
21218
21291
|
const scope = context.sourceCode.getScope(identifier);
|
|
21219
|
-
const variable =
|
|
21292
|
+
const variable = ASTUtils57.findVariable(scope, identifier.name);
|
|
21220
21293
|
return variable === null || variable.defs.length === 0;
|
|
21221
21294
|
}
|
|
21222
21295
|
function isGlobalFetchCall2(callee) {
|
|
@@ -21226,7 +21299,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21226
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);
|
|
21227
21300
|
}
|
|
21228
21301
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
21229
|
-
const variable =
|
|
21302
|
+
const variable = ASTUtils57.findVariable(
|
|
21230
21303
|
context.sourceCode.getScope(identifier),
|
|
21231
21304
|
identifier.name
|
|
21232
21305
|
);
|
|
@@ -21248,7 +21321,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21248
21321
|
function isForwardedRequest(argument) {
|
|
21249
21322
|
let value = argument;
|
|
21250
21323
|
if (value.type === AST_NODE_TYPES96.Identifier) {
|
|
21251
|
-
const binding =
|
|
21324
|
+
const binding = ASTUtils57.findVariable(context.sourceCode.getScope(value), value.name);
|
|
21252
21325
|
const definition = binding?.defs.length === 1 ? binding.defs[0] : void 0;
|
|
21253
21326
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || binding?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21254
21327
|
value = definition.node.init;
|
|
@@ -21422,7 +21495,7 @@ function exportedClasses(program, classes) {
|
|
|
21422
21495
|
}
|
|
21423
21496
|
|
|
21424
21497
|
// src/rules/require-sql-access-class.ts
|
|
21425
|
-
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";
|
|
21426
21499
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
21427
21500
|
"all",
|
|
21428
21501
|
"batch",
|
|
@@ -21696,12 +21769,12 @@ var require_sql_access_class_default = createRule({
|
|
|
21696
21769
|
if (seen.has(node)) return false;
|
|
21697
21770
|
seen.add(node);
|
|
21698
21771
|
if (node.type === AST_NODE_TYPES98.Identifier) {
|
|
21699
|
-
const binding =
|
|
21772
|
+
const binding = ASTUtils58.findVariable(context.sourceCode.getScope(node), node.name);
|
|
21700
21773
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21701
21774
|
const definition = binding.defs[0];
|
|
21702
21775
|
return definition?.type === "Variable" && definition.node.init !== null && knownNonDatabase(definition.node.init, seen);
|
|
21703
21776
|
}
|
|
21704
|
-
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;
|
|
21705
21778
|
}
|
|
21706
21779
|
return {
|
|
21707
21780
|
CallExpression(node) {
|
|
@@ -21813,7 +21886,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
21813
21886
|
});
|
|
21814
21887
|
|
|
21815
21888
|
// src/rules/require-use-form-default-values.ts
|
|
21816
|
-
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";
|
|
21817
21890
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
21818
21891
|
summary: "Require explicit form-level initialization or a field default for directly bound Controller fields.",
|
|
21819
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.",
|
|
@@ -21868,7 +21941,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
21868
21941
|
const imported = /* @__PURE__ */ new Map();
|
|
21869
21942
|
const uninitializedForms = /* @__PURE__ */ new Set();
|
|
21870
21943
|
const uninitializedControls = /* @__PURE__ */ new Set();
|
|
21871
|
-
const bindingNamed = (node, name) =>
|
|
21944
|
+
const bindingNamed = (node, name) => ASTUtils59.findVariable(context.sourceCode.getScope(node), name);
|
|
21872
21945
|
const bindingOf = (node) => bindingNamed(node, node.name);
|
|
21873
21946
|
const stable = (variable) => !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
21874
21947
|
const importedKind = (node) => {
|
|
@@ -21910,7 +21983,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
21910
21983
|
const variable = bindingOf(node);
|
|
21911
21984
|
return variable !== null && stable(variable) && uninitializedControls.has(variable);
|
|
21912
21985
|
}
|
|
21913
|
-
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);
|
|
21914
21987
|
};
|
|
21915
21988
|
const fieldOptionsNeedDefault = (node) => {
|
|
21916
21989
|
if (node?.type !== AST_NODE_TYPES100.ObjectExpression) return false;
|
|
@@ -21966,7 +22039,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
21966
22039
|
trackDestructuredControl(node.id);
|
|
21967
22040
|
return;
|
|
21968
22041
|
}
|
|
21969
|
-
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)) {
|
|
21970
22043
|
const variable = bindingOf(node.id);
|
|
21971
22044
|
if (variable !== null) uninitializedControls.add(variable);
|
|
21972
22045
|
}
|
|
@@ -22058,7 +22131,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
22058
22131
|
// src/rules/require-zod-form-validation.ts
|
|
22059
22132
|
import {
|
|
22060
22133
|
AST_NODE_TYPES as AST_NODE_TYPES101,
|
|
22061
|
-
ASTUtils as
|
|
22134
|
+
ASTUtils as ASTUtils60
|
|
22062
22135
|
} from "@typescript-eslint/utils";
|
|
22063
22136
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
22064
22137
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
@@ -22106,7 +22179,7 @@ var isFormDataMethodCall = (node) => {
|
|
|
22106
22179
|
}
|
|
22107
22180
|
if (current.type !== AST_NODE_TYPES101.CallExpression) return false;
|
|
22108
22181
|
const callee = current.callee;
|
|
22109
|
-
return callee.type === AST_NODE_TYPES101.MemberExpression &&
|
|
22182
|
+
return callee.type === AST_NODE_TYPES101.MemberExpression && ASTUtils60.getPropertyName(callee) !== null && (ASTUtils60.getPropertyName(callee) ?? "") === "formData";
|
|
22110
22183
|
};
|
|
22111
22184
|
var require_zod_form_validation_default = createRule({
|
|
22112
22185
|
name: "require-zod-form-validation",
|
|
@@ -22127,14 +22200,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
22127
22200
|
return {};
|
|
22128
22201
|
}
|
|
22129
22202
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
22130
|
-
const resolvedBinding = (identifier) =>
|
|
22203
|
+
const resolvedBinding = (identifier) => ASTUtils60.findVariable(
|
|
22131
22204
|
context.sourceCode.getScope(identifier),
|
|
22132
22205
|
identifier.name
|
|
22133
22206
|
);
|
|
22134
22207
|
const isFormDataGetCall = (node) => {
|
|
22135
22208
|
const callee = node.callee;
|
|
22136
22209
|
if (callee.type !== AST_NODE_TYPES101.MemberExpression) return false;
|
|
22137
|
-
if (callee
|
|
22210
|
+
if (ASTUtils60.getPropertyName(callee) === null || !FORM_VALUE_METHODS.has(ASTUtils60.getPropertyName(callee) ?? "")) {
|
|
22138
22211
|
return false;
|
|
22139
22212
|
}
|
|
22140
22213
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -22164,7 +22237,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22164
22237
|
parent = parent.parent;
|
|
22165
22238
|
continue;
|
|
22166
22239
|
}
|
|
22167
|
-
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) {
|
|
22168
22241
|
parent = parent.parent;
|
|
22169
22242
|
continue;
|
|
22170
22243
|
}
|
|
@@ -22176,7 +22249,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22176
22249
|
const isZodParseCall = (node) => {
|
|
22177
22250
|
if (node.type !== AST_NODE_TYPES101.CallExpression) return false;
|
|
22178
22251
|
const callee = node.callee;
|
|
22179
|
-
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) ?? "")) {
|
|
22180
22253
|
return false;
|
|
22181
22254
|
}
|
|
22182
22255
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -22262,7 +22335,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22262
22335
|
};
|
|
22263
22336
|
const zodParseMethod = (call) => {
|
|
22264
22337
|
const callee = call.callee;
|
|
22265
|
-
return callee.type === AST_NODE_TYPES101.MemberExpression &&
|
|
22338
|
+
return callee.type === AST_NODE_TYPES101.MemberExpression && ASTUtils60.getPropertyName(callee) !== null ? ASTUtils60.getPropertyName(callee) ?? "" : null;
|
|
22266
22339
|
};
|
|
22267
22340
|
const isSafePrevalidationInspection = (identifier) => {
|
|
22268
22341
|
const parent = identifier.parent;
|
|
@@ -22437,7 +22510,7 @@ function expressionCallableName(current) {
|
|
|
22437
22510
|
}
|
|
22438
22511
|
|
|
22439
22512
|
// src/rules/stepdown.ts
|
|
22440
|
-
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";
|
|
22441
22514
|
var STEPDOWN_DOCUMENTATION = {
|
|
22442
22515
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
22443
22516
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -22737,7 +22810,7 @@ function receiverOrigin(context, object, receivers) {
|
|
|
22737
22810
|
while (true) {
|
|
22738
22811
|
const unwrapped = unwrapExpression7(current);
|
|
22739
22812
|
if (unwrapped.type !== AST_NODE_TYPES102.Identifier) return unwrapped;
|
|
22740
|
-
const variable =
|
|
22813
|
+
const variable = ASTUtils61.findVariable(context.sourceCode.getScope(unwrapped), unwrapped.name);
|
|
22741
22814
|
if (variable === null) return null;
|
|
22742
22815
|
const known = receivers.get(variable);
|
|
22743
22816
|
if (known !== void 0) return known;
|
|
@@ -22918,11 +22991,11 @@ function classScope(context, node, computedReferences) {
|
|
|
22918
22991
|
function classReceiverBindings(context, node) {
|
|
22919
22992
|
const classReceivers = /* @__PURE__ */ new Map();
|
|
22920
22993
|
if (node.id !== null) {
|
|
22921
|
-
const internal =
|
|
22994
|
+
const internal = ASTUtils61.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
22922
22995
|
if (internal !== null && stableVariable(internal)) classReceivers.set(internal, true);
|
|
22923
22996
|
}
|
|
22924
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") {
|
|
22925
|
-
const outer =
|
|
22998
|
+
const outer = ASTUtils61.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
22926
22999
|
if (outer !== null && stableVariable(outer)) classReceivers.set(outer, true);
|
|
22927
23000
|
}
|
|
22928
23001
|
return classReceivers;
|
|
@@ -23008,7 +23081,7 @@ function classMethodCounts(body2, methods) {
|
|
|
23008
23081
|
}
|
|
23009
23082
|
|
|
23010
23083
|
// src/rules/source-coupled-test.ts
|
|
23011
|
-
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";
|
|
23012
23085
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc?|toml|py|[cm]?[jt]s)$/iu;
|
|
23013
23086
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
23014
23087
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -23128,7 +23201,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23128
23201
|
const scopes = [newScope()];
|
|
23129
23202
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
23130
23203
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
23131
|
-
const bindingOf = (node) =>
|
|
23204
|
+
const bindingOf = (node) => ASTUtils62.findVariable(context.sourceCode.getScope(node), node.name);
|
|
23132
23205
|
const assertionKind = (node) => {
|
|
23133
23206
|
const binding = bindingOf(node);
|
|
23134
23207
|
if (binding === null || binding.defs.length === 0) {
|
|
@@ -23501,7 +23574,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
23501
23574
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
23502
23575
|
import {
|
|
23503
23576
|
AST_NODE_TYPES as AST_NODE_TYPES105,
|
|
23504
|
-
ASTUtils as
|
|
23577
|
+
ASTUtils as ASTUtils63
|
|
23505
23578
|
} from "@typescript-eslint/utils";
|
|
23506
23579
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
23507
23580
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
@@ -23634,7 +23707,7 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
23634
23707
|
"superRefine",
|
|
23635
23708
|
"transform"
|
|
23636
23709
|
]);
|
|
23637
|
-
var terminalMethodName = (callee) =>
|
|
23710
|
+
var terminalMethodName = (callee) => ASTUtils63.getPropertyName(callee) !== null ? ASTUtils63.getPropertyName(callee) ?? "" : null;
|
|
23638
23711
|
var calleeChainRoot2 = (node) => {
|
|
23639
23712
|
let current = node;
|
|
23640
23713
|
for (; ; ) {
|
|
@@ -23657,8 +23730,8 @@ var chainMemberNames2 = (node) => {
|
|
|
23657
23730
|
let current = node;
|
|
23658
23731
|
for (; ; ) {
|
|
23659
23732
|
if (current.type === AST_NODE_TYPES105.MemberExpression) {
|
|
23660
|
-
if (
|
|
23661
|
-
names.push(current
|
|
23733
|
+
if (ASTUtils63.getPropertyName(current) === null) return [];
|
|
23734
|
+
names.push(ASTUtils63.getPropertyName(current) ?? "");
|
|
23662
23735
|
current = current.object;
|
|
23663
23736
|
continue;
|
|
23664
23737
|
}
|
|
@@ -23702,7 +23775,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
23702
23775
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
23703
23776
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
23704
23777
|
function resolvedBinding(identifier) {
|
|
23705
|
-
return
|
|
23778
|
+
return ASTUtils63.findVariable(
|
|
23706
23779
|
context.sourceCode.getScope(identifier),
|
|
23707
23780
|
identifier.name
|
|
23708
23781
|
);
|
|
@@ -23970,7 +24043,7 @@ var RULES = {
|
|
|
23970
24043
|
};
|
|
23971
24044
|
var meta = {
|
|
23972
24045
|
name: "@sarj/eslint-plugin",
|
|
23973
|
-
version: "16.
|
|
24046
|
+
version: "16.3.1"
|
|
23974
24047
|
};
|
|
23975
24048
|
var APPLICATION_ONLY_RULES = [];
|
|
23976
24049
|
var LIBRARY_IMPORT_POLICY = ["error", {
|