@sarj/eslint-plugin 16.4.7 → 16.4.8
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 +423 -71
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +702 -350
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,122 @@
|
|
|
1
|
+
// package.json
|
|
2
|
+
var package_default = {
|
|
3
|
+
name: "@sarj/eslint-plugin",
|
|
4
|
+
version: "16.4.8",
|
|
5
|
+
packageManager: "npm@12.1.0",
|
|
6
|
+
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
7
|
+
type: "module",
|
|
8
|
+
main: "./dist/index.cjs",
|
|
9
|
+
module: "./dist/index.js",
|
|
10
|
+
types: "./dist/index.d.ts",
|
|
11
|
+
exports: {
|
|
12
|
+
".": {
|
|
13
|
+
types: "./dist/index.d.ts",
|
|
14
|
+
import: "./dist/index.js",
|
|
15
|
+
require: "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
files: [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
publishConfig: {
|
|
24
|
+
access: "public"
|
|
25
|
+
},
|
|
26
|
+
sideEffects: false,
|
|
27
|
+
repository: {
|
|
28
|
+
type: "git",
|
|
29
|
+
url: "git+https://github.com/sarj-ai/code-standards.git",
|
|
30
|
+
directory: "packages/typescript"
|
|
31
|
+
},
|
|
32
|
+
homepage: "https://code-standards.sarj.ai/rules/eslint/",
|
|
33
|
+
bugs: {
|
|
34
|
+
url: "https://github.com/sarj-ai/code-standards/issues"
|
|
35
|
+
},
|
|
36
|
+
scripts: {
|
|
37
|
+
build: "tsup",
|
|
38
|
+
dogfood: "npm run build && npm run dogfood:built",
|
|
39
|
+
lint: "eslint . ../../.github/scripts ../standards/src ../standards/eslint.config.mjs --max-warnings 0",
|
|
40
|
+
prepack: "npm run build && npm run verify-package",
|
|
41
|
+
test: "vitest run",
|
|
42
|
+
typecheck: "tsc --noEmit",
|
|
43
|
+
"verify-package": `node -e "const fs=require('node:fs'),p=require('./package.json'),walk=x=>typeof x==='string'?[x]:x&&typeof x==='object'?Object.values(x).flatMap(walk):[];for(const file of new Set([p.main,p.module,p.types,...walk(p.exports)].filter(Boolean).map(x=>x.startsWith('./')?x.slice(2):x))){if(!file.startsWith('dist/'))throw new Error('export must live under dist: '+file);const stat=fs.statSync(file);if(!stat.isFile()||stat.size===0)throw new Error('missing or empty export: '+file)}"`,
|
|
44
|
+
"dogfood:built": `eslint --config eslint.dogfood.config.mjs src tests eslint.config.mjs eslint.dogfood.config.mjs module-constant-naming-options.mjs tsup.config.ts vitest.config.ts --max-warnings 0 && node -e "import('./dist/index.js').then(({default:p}) => console.log('dogfood: '+Object.keys(p.rules).length+' TypeScript rules, 0 diagnostics'))"`
|
|
45
|
+
},
|
|
46
|
+
keywords: [
|
|
47
|
+
"eslint",
|
|
48
|
+
"eslintplugin",
|
|
49
|
+
"eslint-plugin",
|
|
50
|
+
"sarj",
|
|
51
|
+
"react",
|
|
52
|
+
"nextjs",
|
|
53
|
+
"zod"
|
|
54
|
+
],
|
|
55
|
+
author: "sarj-ai",
|
|
56
|
+
license: "MIT",
|
|
57
|
+
dependencies: {
|
|
58
|
+
"@typescript-eslint/typescript-estree": "^8.70.1",
|
|
59
|
+
"@typescript-eslint/utils": "^8.70.1",
|
|
60
|
+
"jsonc-parser": "^3.3.1"
|
|
61
|
+
},
|
|
62
|
+
devDependencies: {
|
|
63
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
|
|
64
|
+
"@eslint/compat": "^2.1.1",
|
|
65
|
+
"@eslint/js": "10.0.1",
|
|
66
|
+
"@shadcn/lint": "0.2.0",
|
|
67
|
+
"@types/node": "26.6.2",
|
|
68
|
+
"@typescript-eslint/parser": "8.70.1",
|
|
69
|
+
"@typescript-eslint/rule-tester": "8.70.1",
|
|
70
|
+
"@typescript-eslint/utils": "8.70.1",
|
|
71
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
72
|
+
"@vitest/eslint-plugin": "1.6.27",
|
|
73
|
+
eslint: "10.11.0",
|
|
74
|
+
"eslint-node-test": "0.4.0",
|
|
75
|
+
"eslint-plugin-better-tailwindcss": "^4.7.0",
|
|
76
|
+
"eslint-plugin-jest": "29.16.6",
|
|
77
|
+
"eslint-plugin-jsdoc": "64.5.4",
|
|
78
|
+
"eslint-plugin-n": "^18.3.0",
|
|
79
|
+
"eslint-plugin-perfectionist": "5.12.1",
|
|
80
|
+
"eslint-plugin-playwright": "2.12.0",
|
|
81
|
+
"eslint-plugin-promise": "^7.3.0",
|
|
82
|
+
"eslint-plugin-react": "^7.37.5",
|
|
83
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
84
|
+
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
85
|
+
"eslint-plugin-testing-library": "7.16.2",
|
|
86
|
+
"eslint-plugin-unicorn": "^76.0.0",
|
|
87
|
+
"eslint-plugin-zod": "^4.14.2",
|
|
88
|
+
globals: "15.15.0",
|
|
89
|
+
tsup: "latest",
|
|
90
|
+
typescript: "npm:@typescript/typescript6@6.0.2",
|
|
91
|
+
"typescript-eslint": "^8.70.1",
|
|
92
|
+
vitest: "5.0.1"
|
|
93
|
+
},
|
|
94
|
+
peerDependencies: {
|
|
95
|
+
eslint: ">=9.39.4",
|
|
96
|
+
typescript: ">=5.0.0"
|
|
97
|
+
},
|
|
98
|
+
engines: {
|
|
99
|
+
node: ">=22.22.2"
|
|
100
|
+
},
|
|
101
|
+
allowScripts: {
|
|
102
|
+
"esbuild@0.28.2": true,
|
|
103
|
+
"fsevents@2.3.3": true
|
|
104
|
+
},
|
|
105
|
+
peerDependenciesMeta: {
|
|
106
|
+
typescript: {
|
|
107
|
+
optional: true
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
overrides: {
|
|
111
|
+
"brace-expansion@^5.0.0": "5.0.9",
|
|
112
|
+
esbuild: "0.28.2",
|
|
113
|
+
"nanoid@<3.3.18": "3.3.18",
|
|
114
|
+
"eslint-plugin-react": {
|
|
115
|
+
eslint: "$eslint"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
1
120
|
// src/rules/require-explicit-contract-implementation.ts
|
|
2
121
|
import { AST_NODE_TYPES, ESLintUtils as ESLintUtils2 } from "@typescript-eslint/utils";
|
|
3
122
|
import * as ts from "typescript";
|
|
@@ -4748,16 +4867,51 @@ var no_cors_wildcard_with_credentials_default = createRule({
|
|
|
4748
4867
|
});
|
|
4749
4868
|
|
|
4750
4869
|
// src/rules/no-duplicate-lifecycle-refresh-listeners.ts
|
|
4751
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES28, ASTUtils as
|
|
4870
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES28, ASTUtils as ASTUtils9 } from "@typescript-eslint/utils";
|
|
4752
4871
|
|
|
4753
4872
|
// src/rules/_static-string.ts
|
|
4754
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES27 } from "@typescript-eslint/utils";
|
|
4873
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES27, ASTUtils as ASTUtils8 } from "@typescript-eslint/utils";
|
|
4755
4874
|
function staticString(node) {
|
|
4756
4875
|
if (node === void 0) return null;
|
|
4757
4876
|
const value = unwrapExpression(node);
|
|
4758
4877
|
if (value.type === AST_NODE_TYPES27.Literal && typeof value.value === "string") return value.value;
|
|
4759
4878
|
return value.type === AST_NODE_TYPES27.TemplateLiteral && value.expressions.length === 0 ? value.quasis[0]?.value.cooked ?? null : null;
|
|
4760
4879
|
}
|
|
4880
|
+
var SCOPED_STRING_VALUES = /* @__PURE__ */ new WeakMap();
|
|
4881
|
+
function scopedStaticString(node, sourceCode) {
|
|
4882
|
+
let value = unwrapExpression(node);
|
|
4883
|
+
if (value.type !== AST_NODE_TYPES27.Identifier) return staticString(value);
|
|
4884
|
+
let values = SCOPED_STRING_VALUES.get(sourceCode);
|
|
4885
|
+
if (values === void 0) {
|
|
4886
|
+
values = /* @__PURE__ */ new WeakMap();
|
|
4887
|
+
SCOPED_STRING_VALUES.set(sourceCode, values);
|
|
4888
|
+
}
|
|
4889
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4890
|
+
const pending = [];
|
|
4891
|
+
let result = null;
|
|
4892
|
+
while (value.type === AST_NODE_TYPES27.Identifier) {
|
|
4893
|
+
const binding = ASTUtils8.findVariable(sourceCode.getScope(value), value.name);
|
|
4894
|
+
if (binding === null || seen.has(binding)) break;
|
|
4895
|
+
if (values.has(binding)) {
|
|
4896
|
+
result = values.get(binding) ?? null;
|
|
4897
|
+
break;
|
|
4898
|
+
}
|
|
4899
|
+
seen.add(binding);
|
|
4900
|
+
pending.push(binding);
|
|
4901
|
+
const definition = binding.defs.length === 1 ? binding.defs[0] : void 0;
|
|
4902
|
+
if (definition?.type !== "Variable" || definition.node.id.type !== AST_NODE_TYPES27.Identifier || definition.node.init === null || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) break;
|
|
4903
|
+
value = unwrapExpression(definition.node.init);
|
|
4904
|
+
if (value.type !== AST_NODE_TYPES27.Identifier) result = staticString(value);
|
|
4905
|
+
}
|
|
4906
|
+
for (const binding of pending) values.set(binding, result);
|
|
4907
|
+
return result;
|
|
4908
|
+
}
|
|
4909
|
+
function staticPropertyName(node, sourceCode) {
|
|
4910
|
+
const direct = ASTUtils8.getPropertyName(node);
|
|
4911
|
+
if (direct !== null || !node.computed) return direct;
|
|
4912
|
+
const key = node.type === AST_NODE_TYPES27.MemberExpression ? node.property : node.key;
|
|
4913
|
+
return key.type === AST_NODE_TYPES27.Identifier ? scopedStaticString(key, sourceCode) : null;
|
|
4914
|
+
}
|
|
4761
4915
|
|
|
4762
4916
|
// src/rules/no-duplicate-lifecycle-refresh-listeners.ts
|
|
4763
4917
|
var NO_DUPLICATE_LIFECYCLE_REFRESH_LISTENERS_DOCUMENTATION = {
|
|
@@ -4777,19 +4931,19 @@ function importedName(node) {
|
|
|
4777
4931
|
function registration(sourceCode, node) {
|
|
4778
4932
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
4779
4933
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES28.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
4780
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES28.MemberExpression || receiver.type !== AST_NODE_TYPES28.Identifier || !isUnshadowedGlobal(sourceCode, receiver) ||
|
|
4934
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES28.MemberExpression || receiver.type !== AST_NODE_TYPES28.Identifier || !isUnshadowedGlobal(sourceCode, receiver) || ASTUtils9.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils9.getPropertyName(unwrappedNodeCallee) ?? "") !== "addEventListener" && (ASTUtils9.getPropertyName(unwrappedNodeCallee) ?? "") !== "removeEventListener" || node.arguments.length < 2) return null;
|
|
4781
4935
|
const event = node.arguments[0] === void 0 ? void 0 : unwrapExpression(node.arguments[0]);
|
|
4782
4936
|
const callback = node.arguments[1] === void 0 ? void 0 : unwrapExpression(node.arguments[1]);
|
|
4783
4937
|
if (event === void 0 || callback === void 0) return null;
|
|
4784
4938
|
const eventName = staticString(event);
|
|
4785
4939
|
if (eventName === null || callback.type !== AST_NODE_TYPES28.Identifier) return null;
|
|
4786
|
-
const operation = (
|
|
4940
|
+
const operation = (ASTUtils9.getPropertyName(unwrappedNodeCallee) ?? "") === "addEventListener" ? "add" : "remove";
|
|
4787
4941
|
if (receiver.name === "window" && eventName === "focus") return { operation, event: "focus", callback };
|
|
4788
4942
|
if (receiver.name === "document" && eventName === "visibilitychange") return { operation, event: "visibilitychange", callback };
|
|
4789
4943
|
return null;
|
|
4790
4944
|
}
|
|
4791
4945
|
function isUnshadowedGlobal(sourceCode, node) {
|
|
4792
|
-
const variable =
|
|
4946
|
+
const variable = ASTUtils9.findVariable(sourceCode.getScope(node), node.name);
|
|
4793
4947
|
return variable === null || variable.defs.length === 0;
|
|
4794
4948
|
}
|
|
4795
4949
|
function statementContainer(node) {
|
|
@@ -4828,7 +4982,7 @@ var no_duplicate_lifecycle_refresh_listeners_default = createRule({
|
|
|
4828
4982
|
if (node.source.value !== "next/navigation") return;
|
|
4829
4983
|
for (const specifier of node.specifiers) {
|
|
4830
4984
|
if (specifier.type === AST_NODE_TYPES28.ImportSpecifier && importedName(specifier) === "useRouter") {
|
|
4831
|
-
const variable =
|
|
4985
|
+
const variable = ASTUtils9.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
4832
4986
|
if (variable !== null) routerHooks.add(variable);
|
|
4833
4987
|
}
|
|
4834
4988
|
}
|
|
@@ -4836,7 +4990,7 @@ var no_duplicate_lifecycle_refresh_listeners_default = createRule({
|
|
|
4836
4990
|
VariableDeclarator(node) {
|
|
4837
4991
|
const initializer = node.init === null ? null : unwrapExpression(node.init);
|
|
4838
4992
|
if (node.id.type !== AST_NODE_TYPES28.Identifier) return;
|
|
4839
|
-
const variable =
|
|
4993
|
+
const variable = ASTUtils9.findVariable(context.sourceCode.getScope(node.id), node.id.name);
|
|
4840
4994
|
if (variable === null || variable.references.some((reference) => reference.isWrite() && !reference.init)) return;
|
|
4841
4995
|
if (initializer?.type === AST_NODE_TYPES28.ArrowFunctionExpression || initializer?.type === AST_NODE_TYPES28.FunctionExpression) {
|
|
4842
4996
|
functionCallbacks.set(initializer, variable);
|
|
@@ -4844,19 +4998,19 @@ var no_duplicate_lifecycle_refresh_listeners_default = createRule({
|
|
|
4844
4998
|
if (initializer?.type !== AST_NODE_TYPES28.CallExpression) return;
|
|
4845
4999
|
const hookCallee = unwrapExpression(initializer.callee);
|
|
4846
5000
|
if (hookCallee.type !== AST_NODE_TYPES28.Identifier) return;
|
|
4847
|
-
const hook =
|
|
5001
|
+
const hook = ASTUtils9.findVariable(context.sourceCode.getScope(hookCallee), hookCallee.name);
|
|
4848
5002
|
if (hook !== null && routerHooks.has(hook)) routers.add(variable);
|
|
4849
5003
|
},
|
|
4850
5004
|
FunctionDeclaration(node) {
|
|
4851
5005
|
if (node.id === null) return;
|
|
4852
|
-
const variable =
|
|
5006
|
+
const variable = ASTUtils9.findVariable(context.sourceCode.getScope(node.id), node.id.name);
|
|
4853
5007
|
if (variable !== null && !variable.references.some((reference) => reference.isWrite() && !reference.init)) functionCallbacks.set(node, variable);
|
|
4854
5008
|
},
|
|
4855
5009
|
CallExpression(node) {
|
|
4856
5010
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
4857
5011
|
const item = registration(context.sourceCode, node);
|
|
4858
5012
|
if (item !== null) {
|
|
4859
|
-
const callback2 =
|
|
5013
|
+
const callback2 = ASTUtils9.findVariable(context.sourceCode.getScope(item.callback), item.callback.name);
|
|
4860
5014
|
const container = statementContainer(node);
|
|
4861
5015
|
if (callback2 !== null && container !== null) {
|
|
4862
5016
|
const callbacks = registrations.get(container) ?? /* @__PURE__ */ new Map();
|
|
@@ -4868,8 +5022,8 @@ var no_duplicate_lifecycle_refresh_listeners_default = createRule({
|
|
|
4868
5022
|
}
|
|
4869
5023
|
}
|
|
4870
5024
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES28.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
4871
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES28.MemberExpression || receiver.type !== AST_NODE_TYPES28.Identifier ||
|
|
4872
|
-
const router =
|
|
5025
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES28.MemberExpression || receiver.type !== AST_NODE_TYPES28.Identifier || ASTUtils9.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils9.getPropertyName(unwrappedNodeCallee) ?? "") !== "refresh") return;
|
|
5026
|
+
const router = ASTUtils9.findVariable(context.sourceCode.getScope(receiver), receiver.name);
|
|
4873
5027
|
if (router === null || !routers.has(router)) return;
|
|
4874
5028
|
const fn = enclosingFunction(context.sourceCode, node);
|
|
4875
5029
|
if (fn === null) return;
|
|
@@ -4891,14 +5045,14 @@ var no_duplicate_lifecycle_refresh_listeners_default = createRule({
|
|
|
4891
5045
|
});
|
|
4892
5046
|
|
|
4893
5047
|
// src/rules/_exported-next-config-property.ts
|
|
4894
|
-
import { ASTUtils as
|
|
5048
|
+
import { ASTUtils as ASTUtils10 } from "@typescript-eslint/utils";
|
|
4895
5049
|
function exportedNextConfigProperty(sourceCode, path) {
|
|
4896
5050
|
const resolve2 = (input, seen = /* @__PURE__ */ new Set()) => {
|
|
4897
5051
|
const node = unwrapExpression(input);
|
|
4898
5052
|
if (node.type !== "Identifier") return node;
|
|
4899
5053
|
if (seen.has(node)) return null;
|
|
4900
5054
|
seen.add(node);
|
|
4901
|
-
const binding =
|
|
5055
|
+
const binding = ASTUtils10.findVariable(sourceCode.getScope(node), node.name);
|
|
4902
5056
|
const definition = binding?.defs.length === 1 ? binding.defs[0] : void 0;
|
|
4903
5057
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || binding?.references.some((reference) => reference.identifier !== node && reference.init !== true)) return null;
|
|
4904
5058
|
return resolve2(definition.node.init, seen);
|
|
@@ -4908,7 +5062,7 @@ function exportedNextConfigProperty(sourceCode, path) {
|
|
|
4908
5062
|
let current = resolve2(exported);
|
|
4909
5063
|
let selected = null;
|
|
4910
5064
|
for (const name of path) {
|
|
4911
|
-
if (current?.type !== "ObjectExpression" || current.properties.some((property) => property.type !== "Property" ||
|
|
5065
|
+
if (current?.type !== "ObjectExpression" || current.properties.some((property) => property.type !== "Property" || ASTUtils10.getPropertyName(property) === null || property.kind !== "init")) return null;
|
|
4912
5066
|
selected = objectProperty(current, name);
|
|
4913
5067
|
if (selected === null) return null;
|
|
4914
5068
|
current = resolve2(selected.value);
|
|
@@ -4923,7 +5077,7 @@ function exportedConfig(sourceCode) {
|
|
|
4923
5077
|
const assignment = statement.expression;
|
|
4924
5078
|
const left = assignment.left;
|
|
4925
5079
|
if (left.type !== "MemberExpression" || left.computed || left.object.type !== "Identifier" || left.object.name !== "module" || left.property.type !== "Identifier" || left.property.name !== "exports") continue;
|
|
4926
|
-
const binding =
|
|
5080
|
+
const binding = ASTUtils10.findVariable(sourceCode.getScope(left.object), "module");
|
|
4927
5081
|
if (binding === null || binding.defs.length === 0) exported = assignment.right;
|
|
4928
5082
|
}
|
|
4929
5083
|
return exported;
|
|
@@ -4932,7 +5086,7 @@ function objectProperty(node, name) {
|
|
|
4932
5086
|
let selected = null;
|
|
4933
5087
|
for (const property of node.properties) {
|
|
4934
5088
|
if (property.type !== "Property") continue;
|
|
4935
|
-
const key =
|
|
5089
|
+
const key = ASTUtils10.getPropertyName(property);
|
|
4936
5090
|
if (key === name) selected = property;
|
|
4937
5091
|
}
|
|
4938
5092
|
return selected;
|
|
@@ -5014,7 +5168,7 @@ var no_dangerously_allow_svg_default = createRule({
|
|
|
5014
5168
|
});
|
|
5015
5169
|
|
|
5016
5170
|
// src/rules/no-dynamic-sql.ts
|
|
5017
|
-
import { ASTUtils as
|
|
5171
|
+
import { ASTUtils as ASTUtils11, AST_NODE_TYPES as AST_NODE_TYPES30 } from "@typescript-eslint/utils";
|
|
5018
5172
|
|
|
5019
5173
|
// src/rules/_sql.ts
|
|
5020
5174
|
import { AST_NODE_TYPES as AST_NODE_TYPES29 } from "@typescript-eslint/utils";
|
|
@@ -5253,8 +5407,8 @@ function isStaticFragment(expression) {
|
|
|
5253
5407
|
if (expression.type === AST_NODE_TYPES30.Identifier) {
|
|
5254
5408
|
return CONSTANT_CASE_RE.test(expression.name);
|
|
5255
5409
|
}
|
|
5256
|
-
if (expression.type === AST_NODE_TYPES30.MemberExpression &&
|
|
5257
|
-
return CONSTANT_CASE_RE.test(
|
|
5410
|
+
if (expression.type === AST_NODE_TYPES30.MemberExpression && ASTUtils11.getPropertyName(expression) !== null) {
|
|
5411
|
+
return CONSTANT_CASE_RE.test(ASTUtils11.getPropertyName(expression) ?? "");
|
|
5258
5412
|
}
|
|
5259
5413
|
if (expression.type === AST_NODE_TYPES30.Literal) {
|
|
5260
5414
|
return typeof expression.value === "string";
|
|
@@ -5353,10 +5507,10 @@ function staticStatementText(node) {
|
|
|
5353
5507
|
}
|
|
5354
5508
|
function statementMethodName(node, methods) {
|
|
5355
5509
|
const callee = unwrapExpression(node.callee);
|
|
5356
|
-
if (callee.type !== AST_NODE_TYPES30.MemberExpression ||
|
|
5510
|
+
if (callee.type !== AST_NODE_TYPES30.MemberExpression || ASTUtils11.getPropertyName(callee) === null) {
|
|
5357
5511
|
return null;
|
|
5358
5512
|
}
|
|
5359
|
-
const name =
|
|
5513
|
+
const name = ASTUtils11.getPropertyName(callee) ?? "";
|
|
5360
5514
|
return methods.has(name) ? name : null;
|
|
5361
5515
|
}
|
|
5362
5516
|
var no_dynamic_sql_default = createRule({
|
|
@@ -6074,7 +6228,7 @@ var no_fat_try_blocks_default = createRule({
|
|
|
6074
6228
|
});
|
|
6075
6229
|
|
|
6076
6230
|
// src/rules/no-hand-rolled-sleep.ts
|
|
6077
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES33, ASTUtils as
|
|
6231
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES33, ASTUtils as ASTUtils12 } from "@typescript-eslint/utils";
|
|
6078
6232
|
var NO_HAND_ROLLED_SLEEP_DOCUMENTATION = {
|
|
6079
6233
|
summary: "Disallow uncancellable promisified timers and timeout arms.",
|
|
6080
6234
|
rationale: "A timer that outlives an aborted operation or a lost promise race retains work and can keep the process alive until it fires.",
|
|
@@ -6234,7 +6388,7 @@ var no_hand_rolled_sleep_default = createRule({
|
|
|
6234
6388
|
return {};
|
|
6235
6389
|
}
|
|
6236
6390
|
const checkClientModules = optionsArg?.checkClientModules ?? false;
|
|
6237
|
-
const bindingOf = (identifier) =>
|
|
6391
|
+
const bindingOf = (identifier) => ASTUtils12.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
6238
6392
|
const isGlobal = (identifier) => (bindingOf(identifier)?.defs.length ?? 0) === 0;
|
|
6239
6393
|
const isBuiltinTimer = (callee) => {
|
|
6240
6394
|
callee = unwrapExpression(callee);
|
|
@@ -6401,7 +6555,7 @@ var no_hand_rolled_spinner_default = createRule({
|
|
|
6401
6555
|
});
|
|
6402
6556
|
|
|
6403
6557
|
// src/rules/no-insecure-random-id.ts
|
|
6404
|
-
import { ASTUtils as
|
|
6558
|
+
import { ASTUtils as ASTUtils13 } from "@typescript-eslint/utils";
|
|
6405
6559
|
var NO_INSECURE_RANDOM_ID_DOCUMENTATION = {
|
|
6406
6560
|
summary: "Disallow using `Math.random()` to generate identifiers, tokens, or secrets; use `crypto.randomUUID()` or `crypto.getRandomValues(...)` instead.",
|
|
6407
6561
|
rationale: "Math.random is predictable and lacks the entropy required for security-sensitive values.",
|
|
@@ -6476,7 +6630,7 @@ function isMathRandomCall(node) {
|
|
|
6476
6630
|
return false;
|
|
6477
6631
|
}
|
|
6478
6632
|
const object = unwrapExpression(callee.object);
|
|
6479
|
-
return object.type === "Identifier" && object.name === "Math" &&
|
|
6633
|
+
return object.type === "Identifier" && object.name === "Math" && ASTUtils13.getPropertyName(callee) === "random";
|
|
6480
6634
|
}
|
|
6481
6635
|
function findEnclosingNames(node) {
|
|
6482
6636
|
const names = [];
|
|
@@ -6541,7 +6695,7 @@ function climbValueChain(node) {
|
|
|
6541
6695
|
let current = node;
|
|
6542
6696
|
let parent = current.parent;
|
|
6543
6697
|
while (parent) {
|
|
6544
|
-
if (parent.type === "MemberExpression" && parent.object === current &&
|
|
6698
|
+
if (parent.type === "MemberExpression" && parent.object === current && ASTUtils13.getPropertyName(parent) !== null) {
|
|
6545
6699
|
current = parent;
|
|
6546
6700
|
parent = current.parent;
|
|
6547
6701
|
continue;
|
|
@@ -6594,7 +6748,7 @@ var no_insecure_random_id_default = createRule({
|
|
|
6594
6748
|
if (!isMathRandomCall(node)) {
|
|
6595
6749
|
return;
|
|
6596
6750
|
}
|
|
6597
|
-
if ((
|
|
6751
|
+
if ((ASTUtils13.findVariable(context.sourceCode.getScope(node), "Math")?.defs.length ?? 0) > 0) return;
|
|
6598
6752
|
const names = findEnclosingNames(node);
|
|
6599
6753
|
if (names.some(isStrongSecurityName)) {
|
|
6600
6754
|
context.report({ node, messageId: "insecureRandomId" });
|
|
@@ -6617,8 +6771,8 @@ function appendPropertyName(property, names) {
|
|
|
6617
6771
|
}
|
|
6618
6772
|
function appendAssignedName(assignment, directBinding, names) {
|
|
6619
6773
|
if (directBinding && assignment.left.type === "Identifier") names.push(assignment.left.name);
|
|
6620
|
-
if (directBinding && assignment.left.type === "MemberExpression" &&
|
|
6621
|
-
names.push(
|
|
6774
|
+
if (directBinding && assignment.left.type === "MemberExpression" && ASTUtils13.getPropertyName(assignment.left) !== null) {
|
|
6775
|
+
names.push(ASTUtils13.getPropertyName(assignment.left) ?? "");
|
|
6622
6776
|
}
|
|
6623
6777
|
}
|
|
6624
6778
|
function appendDirectBindingName(id, directBinding, names) {
|
|
@@ -6628,7 +6782,7 @@ function appendDirectBindingName(id, directBinding, names) {
|
|
|
6628
6782
|
// src/rules/no-detached-global-fetch.ts
|
|
6629
6783
|
import {
|
|
6630
6784
|
AST_NODE_TYPES as AST_NODE_TYPES35,
|
|
6631
|
-
ASTUtils as
|
|
6785
|
+
ASTUtils as ASTUtils14
|
|
6632
6786
|
} from "@typescript-eslint/utils";
|
|
6633
6787
|
var NO_DETACHED_GLOBAL_FETCH_DOCUMENTATION = {
|
|
6634
6788
|
summary: "Keep the ambient global fetch receiver-safe when storing or explicitly rebinding it.",
|
|
@@ -6689,7 +6843,7 @@ var no_detached_global_fetch_default = createRule({
|
|
|
6689
6843
|
if (isTestFile(context.filename) || isScriptFile(context.filename) || isGeneratedFile(context.filename, sourceCode.text)) return {};
|
|
6690
6844
|
const aliases = /* @__PURE__ */ new Set();
|
|
6691
6845
|
function bindingOf(identifier) {
|
|
6692
|
-
return
|
|
6846
|
+
return ASTUtils14.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
6693
6847
|
}
|
|
6694
6848
|
function resolvesToGlobal(identifier) {
|
|
6695
6849
|
const variable = bindingOf(identifier);
|
|
@@ -6794,37 +6948,32 @@ var no_detached_global_fetch_default = createRule({
|
|
|
6794
6948
|
});
|
|
6795
6949
|
|
|
6796
6950
|
// src/rules/no-json-stringify-error.ts
|
|
6797
|
-
import { ASTUtils as
|
|
6951
|
+
import { ASTUtils as ASTUtils15 } from "@typescript-eslint/utils";
|
|
6798
6952
|
var NO_JSON_STRINGIFY_ERROR_DOCUMENTATION = {
|
|
6799
6953
|
summary: "Avoid generic JSON serialization that can omit native Error details.",
|
|
6800
6954
|
rationale: "Native Error details are non-enumerable, so generic JSON serialization discards diagnostic information.",
|
|
6801
6955
|
remediation: "Serialize explicit error fields or use an error-aware serializer.",
|
|
6802
6956
|
category: "correctness",
|
|
6803
|
-
limitations: ["The rule uses stable local catch bindings and unshadowed built-in constructors, not runtime type information. Custom replacers are left to their serializer contract; a catch value is not guaranteed to be an Error."],
|
|
6957
|
+
limitations: ["The rule uses stable local catch bindings and unshadowed built-in constructors, not runtime type information. Custom replacers and explicit toJSON hooks are left to their serializer contract; a catch value is not guaranteed to be an Error. Member values, including cause, do not inherit the base Error's provenance; even an Error-valued member requires explicit value/dataflow proof outside this rule. Known literal __proto__ initializer chains preserve native hook inheritance and own toJSON precedence; computed __proto__ keys remain data. Unknown prototype expressions, hook values/spreads and deferred hook writes conservatively lose default serializer proof. Explicit writes invalidate constructor provenance except a later, separate top-level statement; deferred functions, loops, and unknown property keys conservatively lose constructor proof. Statically owned global/property writes and native Reflect.set/Reflect.defineProperty/Object.defineProperty/Object.defineProperties calls are tracked. Mutator aliases, replaced Reflect/Object methods, external calls, and runtime-only property names are not resolved; uncertain ordering conservatively loses proof."],
|
|
6804
6958
|
examples: [
|
|
6805
6959
|
{ id: "explicit-error-message", title: "Narrow an unknown catch value before selecting fields", outcome: "no-match", files: [{ path: "src/report.ts", source: "try { f(); } catch (err) { JSON.stringify({ error: err instanceof Error ? err.message : String(err) }); }" }], focusPath: "src/report.ts", expectedCount: 0, public: true },
|
|
6806
6960
|
{ id: "stringified-error", title: "Do not stringify an Error object", outcome: "match", files: [{ path: "src/report.ts", source: "try { f(); } catch (err) { JSON.stringify({ error: err }); }" }], focusPath: "src/report.ts", expectedCount: 1, public: true },
|
|
6807
6961
|
{ id: "shadowed-error-binding", scenarioId: "binding-provenance", title: "Keep native binding provenance", outcome: "match", files: [{ path: "src/error.ts", source: 'function probe(){try{throw {id:1};}catch(err){if(err instanceof Error)return err.message;{const err=new Error("lost");return JSON.stringify(err);}}}\nconsole.log(probe());' }], focusPath: "src/error.ts", expectedCount: 1, public: true },
|
|
6808
|
-
{ id: "escaped-fallback-binding", scenarioId: "binding-provenance", title: "Keep native binding provenance", outcome: "no-match", files: [{ path: "src/error.ts", source: "function probe(){try{throw {id:1};}catch(err){if(err instanceof Error)return err.message;return JSON.stringify(\\u0065rr);}}\nconsole.log(probe());" }], focusPath: "src/error.ts", expectedCount: 0, public: true }
|
|
6962
|
+
{ id: "escaped-fallback-binding", scenarioId: "binding-provenance", title: "Keep native binding provenance", outcome: "no-match", files: [{ path: "src/error.ts", source: "function probe(){try{throw {id:1};}catch(err){if(err instanceof Error)return err.message;return JSON.stringify(\\u0065rr);}}\nconsole.log(probe());" }], focusPath: "src/error.ts", expectedCount: 0, public: true },
|
|
6963
|
+
{ id: "constructor-before-write", scenarioId: "explicit-constructor-write", title: "A later write does not change an already constructed native Error", outcome: "match", files: [{ path: "src/error.js", source: "const value=new Error('lost');Error=class Other{message='kept'};JSON.stringify(value);" }], focusPath: "src/error.js", expectedCount: 1, public: true },
|
|
6964
|
+
{ id: "constructor-after-write", scenarioId: "explicit-constructor-write", title: "A replaced constructor does not prove a native Error", outcome: "no-match", files: [{ path: "src/error.js", source: "Error=class Other{message='kept'};const value=new Error();JSON.stringify(value);" }], focusPath: "src/error.js", expectedCount: 0, public: true },
|
|
6965
|
+
{ "id": "native-serializer-before-write", "scenarioId": "explicit-serializer-write", "title": "A later write does not change an earlier native serialization", "outcome": "match", "files": [{ "path": "src/error.js", "source": "const result=JSON.stringify(new Error('lost'));JSON.stringify=value=>'kept:'+value.message;" }], "focusPath": "src/error.js", "expectedCount": 1, "public": true },
|
|
6966
|
+
{ "id": "native-serializer-after-write", "scenarioId": "explicit-serializer-write", "title": "A replaced serializer owns its error-field contract", "outcome": "no-match", "files": [{ "path": "src/error.js", "source": "JSON.stringify=value=>'kept:'+value.message;JSON.stringify(new Error('lost'));" }], "focusPath": "src/error.js", "expectedCount": 0, "public": true },
|
|
6967
|
+
{ "id": "static-serializer-key", "scenarioId": "static-property-provenance", "title": "A constant computed serializer still loses native Error details", "outcome": "match", "files": [{ "path": "src/error.js", "source": "const key='stringify';JSON[key](new Error('lost'));" }], "focusPath": "src/error.js", "expectedCount": 1, "public": true },
|
|
6968
|
+
{ "id": "static-error-field", "scenarioId": "static-property-provenance", "title": "A constant message field selects the explicit string escape hatch", "outcome": "no-match", "files": [{ "path": "src/error.js", "source": "const key='message';const error=new Error('lost');JSON.stringify(error[key]);" }], "focusPath": "src/error.js", "expectedCount": 0, "public": true },
|
|
6969
|
+
{ "id": "scalar-cause", "scenarioId": "member-value-provenance", "title": "Native Error cause can be a string value", "outcome": "no-match", "files": [{ "path": "src/error.js", "source": "const error=new Error('lost',{cause:'kept'});JSON.stringify(error.cause);" }], "focusPath": "src/error.js", "expectedCount": 0, "public": true },
|
|
6970
|
+
{ "id": "whole-error-with-cause", "scenarioId": "member-value-provenance", "title": "Serializing the whole Error still loses its native details", "outcome": "match", "files": [{ "path": "src/error.js", "source": "const error=new Error('lost',{cause:'kept'});JSON.stringify(error);" }], "focusPath": "src/error.js", "expectedCount": 1, "public": true },
|
|
6971
|
+
{ "id": "explicit-to-json-hook", "scenarioId": "custom-serializer-contract", "title": "An explicit callable toJSON owns its serialization contract", "outcome": "no-match", "files": [{ "path": "src/error.js", "source": "JSON.stringify({error:new Error('lost'),toJSON(){return {message:'kept'};}});" }], "focusPath": "src/error.js", "expectedCount": 0, "public": true },
|
|
6972
|
+
{ "id": "noncallable-to-json", "scenarioId": "custom-serializer-contract", "title": "A noncallable toJSON does not replace native serialization", "outcome": "match", "files": [{ "path": "src/error.js", "source": "JSON.stringify({error:new Error('lost'),toJSON:42});" }], "focusPath": "src/error.js", "expectedCount": 1, "public": true },
|
|
6973
|
+
{ "id": "literal-prototype-hook", "scenarioId": "native-prototype-serializer", "title": "A literal prototype hook owns the payload serializer contract", "outcome": "no-match", "files": [{ "path": "src/error.js", "source": "JSON.stringify({error:new Error('lost'),__proto__:{toJSON(){return {message:'kept'};}}});" }], "focusPath": "src/error.js", "expectedCount": 0, "public": true },
|
|
6974
|
+
{ "id": "computed-prototype-data", "scenarioId": "native-prototype-serializer", "title": "A computed prototype name remains ordinary serialized data", "outcome": "match", "files": [{ "path": "src/error.js", "source": "JSON.stringify({error:new Error('lost'),['__proto__']:{toJSON(){return {message:'kept'};}}});" }], "focusPath": "src/error.js", "expectedCount": 1, "public": true }
|
|
6809
6975
|
]
|
|
6810
6976
|
};
|
|
6811
|
-
var SAFE_STRING_PROPS = /* @__PURE__ */ new Set(["message", "stack", "name"]);
|
|
6812
|
-
var PAYLOAD_PROPS = /* @__PURE__ */ new Set([
|
|
6813
|
-
"data",
|
|
6814
|
-
"status",
|
|
6815
|
-
"statuscode",
|
|
6816
|
-
"statustext",
|
|
6817
|
-
"code",
|
|
6818
|
-
"issues",
|
|
6819
|
-
"details",
|
|
6820
|
-
"body",
|
|
6821
|
-
"payload",
|
|
6822
|
-
"response",
|
|
6823
|
-
"info",
|
|
6824
|
-
"meta",
|
|
6825
|
-
"metadata",
|
|
6826
|
-
"context"
|
|
6827
|
-
]);
|
|
6828
6977
|
var BUILTIN_ERROR_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
6829
6978
|
"AggregateError",
|
|
6830
6979
|
"Error",
|
|
@@ -6835,17 +6984,203 @@ var BUILTIN_ERROR_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
6835
6984
|
"TypeError",
|
|
6836
6985
|
"URIError"
|
|
6837
6986
|
]);
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
const
|
|
6842
|
-
if (
|
|
6843
|
-
if (
|
|
6844
|
-
|
|
6845
|
-
|
|
6987
|
+
var TRACKED_BUILTINS = /* @__PURE__ */ new Set([...BUILTIN_ERROR_CONSTRUCTORS, "JSON", "JSON.stringify"]);
|
|
6988
|
+
function nativeObjectName(expression, sourceCode) {
|
|
6989
|
+
const value = unwrapExpression(expression);
|
|
6990
|
+
const scope = sourceCode.getScope(value);
|
|
6991
|
+
if (value.type === "Identifier" && (value.name === "globalThis" || value.name === "JSON") && isGlobalIdentifier(value.name, scope)) return value.name;
|
|
6992
|
+
if (value.type === "MemberExpression" && nativeObjectName(value.object, sourceCode) === "globalThis" && staticPropertyName(value, sourceCode) === "JSON") return "JSON";
|
|
6993
|
+
return null;
|
|
6994
|
+
}
|
|
6995
|
+
function globalBuiltinName(expression, sourceCode) {
|
|
6996
|
+
const value = unwrapExpression(expression);
|
|
6997
|
+
const scope = sourceCode.getScope(value);
|
|
6998
|
+
if (value.type === "Identifier") return TRACKED_BUILTINS.has(value.name) && isGlobalIdentifier(value.name, scope) ? value.name : null;
|
|
6999
|
+
if (value.type !== "MemberExpression") return null;
|
|
7000
|
+
const receiver = nativeObjectName(value.object, sourceCode);
|
|
7001
|
+
const name = staticPropertyName(value, sourceCode);
|
|
7002
|
+
if (receiver === "JSON") return name === "stringify" ? "JSON.stringify" : null;
|
|
7003
|
+
return receiver === "globalThis" && name !== null && name !== "JSON.stringify" && TRACKED_BUILTINS.has(name) ? name : null;
|
|
7004
|
+
}
|
|
7005
|
+
function writePreservesBuiltin(target, sourceCode) {
|
|
7006
|
+
const assignment = target.parent;
|
|
7007
|
+
if (assignment?.type !== "AssignmentExpression" || assignment.left !== target) return false;
|
|
7008
|
+
const name = globalBuiltinName(target, sourceCode);
|
|
7009
|
+
if (name === null) return false;
|
|
7010
|
+
if (assignment.operator === "||=" || assignment.operator === "??=") return true;
|
|
7011
|
+
return (assignment.operator === "=" || assignment.operator === "&&=") && globalBuiltinName(assignment.right, sourceCode) === name;
|
|
7012
|
+
}
|
|
7013
|
+
function mayBeCallable(value) {
|
|
7014
|
+
return !["Literal", "TemplateLiteral", "ObjectExpression", "ArrayExpression"].includes(value.type);
|
|
7015
|
+
}
|
|
7016
|
+
var BUILTIN_WRITES = /* @__PURE__ */ new WeakMap();
|
|
7017
|
+
function directProgramStatement(node) {
|
|
7018
|
+
let current = node;
|
|
7019
|
+
while (current.parent !== void 0) {
|
|
7020
|
+
if (current.parent.type === "Program") return current;
|
|
7021
|
+
if (["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression", "ClassBody", "StaticBlock", "ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement"].includes(current.parent.type)) return null;
|
|
7022
|
+
current = current.parent;
|
|
7023
|
+
}
|
|
7024
|
+
return null;
|
|
7025
|
+
}
|
|
7026
|
+
function hasUnchangedBuiltin(name, read, sourceCode) {
|
|
7027
|
+
const summary = builtinWrites(sourceCode).get(name);
|
|
7028
|
+
if (summary === void 0) return true;
|
|
7029
|
+
const statement = directProgramStatement(read);
|
|
7030
|
+
return !summary.unknownOrder && statement !== null && statement.range[1] <= summary.earliestStatementStart;
|
|
7031
|
+
}
|
|
7032
|
+
function builtinWrites(sourceCode) {
|
|
7033
|
+
const cached = BUILTIN_WRITES.get(sourceCode);
|
|
7034
|
+
if (cached !== void 0) return cached;
|
|
7035
|
+
const writes = /* @__PURE__ */ new Map();
|
|
7036
|
+
const record = (name, node) => {
|
|
7037
|
+
const statement = directProgramStatement(node);
|
|
7038
|
+
const existing = writes.get(name);
|
|
7039
|
+
writes.set(name, { earliestStatementStart: Math.min(existing?.earliestStatementStart ?? Infinity, statement?.range[0] ?? Infinity), unknownOrder: (existing?.unknownOrder ?? false) || statement === null });
|
|
7040
|
+
};
|
|
7041
|
+
for (const scope of sourceCode.scopeManager?.scopes ?? []) {
|
|
7042
|
+
for (const reference of scope.references) {
|
|
7043
|
+
const name = reference.identifier.name;
|
|
7044
|
+
if (reference.identifier.type === "Identifier" && reference.isWrite() && TRACKED_BUILTINS.has(name) && (reference.resolved === null || reference.resolved.defs.length === 0) && !writePreservesBuiltin(reference.identifier, sourceCode)) record(name, reference.identifier);
|
|
7045
|
+
}
|
|
7046
|
+
}
|
|
7047
|
+
const propertyReceiver = (expression) => {
|
|
7048
|
+
const native = nativeObjectName(expression, sourceCode);
|
|
7049
|
+
if (native !== null) return native;
|
|
7050
|
+
const value = unwrapExpression(expression);
|
|
7051
|
+
if (value.type === "Identifier") return ASTUtils15.findVariable(sourceCode.getScope(value), value.name);
|
|
7052
|
+
if (value.type === "MemberExpression" && staticPropertyName(value, sourceCode) === "prototype") {
|
|
7053
|
+
const constructor = globalBuiltinName(value.object, sourceCode);
|
|
7054
|
+
if (constructor !== null && BUILTIN_ERROR_CONSTRUCTORS.has(constructor)) return constructor + ".prototype";
|
|
7055
|
+
}
|
|
7056
|
+
return null;
|
|
7057
|
+
};
|
|
7058
|
+
const propertyWrite = (receiver, name, node) => {
|
|
7059
|
+
if (receiver === "JSON") {
|
|
7060
|
+
if (name === null || name === "stringify") record("JSON.stringify", node);
|
|
7061
|
+
} else if (receiver === "globalThis") {
|
|
7062
|
+
if (name === null) {
|
|
7063
|
+
for (const builtin of TRACKED_BUILTINS) record(builtin, node);
|
|
7064
|
+
} else if (name !== "JSON.stringify" && TRACKED_BUILTINS.has(name)) record(name, node);
|
|
7065
|
+
} else if (name === null || name === "toJSON") record(receiver, node);
|
|
7066
|
+
};
|
|
7067
|
+
const visit = (node) => {
|
|
7068
|
+
if (node.type === "AssignmentExpression") propertyTarget(node.left);
|
|
7069
|
+
else if (node.type === "UpdateExpression") propertyTarget(node.argument);
|
|
7070
|
+
else if (node.type === "ForInStatement" || node.type === "ForOfStatement") propertyTarget(node.left);
|
|
7071
|
+
else if (node.type === "UnaryExpression" && node.operator === "delete") propertyTarget(node.argument);
|
|
7072
|
+
else if (node.type === "CallExpression") mutationCall(node);
|
|
7073
|
+
forEachAstChild(node, sourceCode.visitorKeys, visit);
|
|
7074
|
+
};
|
|
7075
|
+
function propertyTarget(target) {
|
|
7076
|
+
if (target.type === "MemberExpression") {
|
|
7077
|
+
memberPropertyWrite(target);
|
|
7078
|
+
return;
|
|
7079
|
+
}
|
|
7080
|
+
switch (target.type) {
|
|
7081
|
+
case "ObjectPattern":
|
|
7082
|
+
for (const property of target.properties) propertyTarget(property.type === "RestElement" ? property.argument : property.value);
|
|
7083
|
+
return;
|
|
7084
|
+
case "ArrayPattern":
|
|
7085
|
+
for (const element of target.elements) if (element !== null) propertyTarget(element);
|
|
7086
|
+
return;
|
|
7087
|
+
case "AssignmentPattern":
|
|
7088
|
+
propertyTarget(target.left);
|
|
7089
|
+
return;
|
|
7090
|
+
case "RestElement":
|
|
7091
|
+
propertyTarget(target.argument);
|
|
7092
|
+
}
|
|
7093
|
+
}
|
|
7094
|
+
function memberPropertyWrite(target) {
|
|
7095
|
+
const receiver = propertyReceiver(target.object);
|
|
7096
|
+
if (receiver === null || writePreservesBuiltin(target, sourceCode)) return;
|
|
7097
|
+
const name = staticPropertyName(target, sourceCode);
|
|
7098
|
+
if (name === "toJSON") {
|
|
7099
|
+
const assignment = target.parent;
|
|
7100
|
+
if (assignment?.type === "UnaryExpression" && assignment.operator === "delete") return;
|
|
7101
|
+
if (assignment?.type === "AssignmentExpression" && assignment.operator === "=" && !mayBeCallable(assignment.right)) return;
|
|
7102
|
+
}
|
|
7103
|
+
propertyWrite(receiver, name, target);
|
|
7104
|
+
}
|
|
7105
|
+
function mutationCall(node) {
|
|
7106
|
+
const callee = unwrapExpression(node.callee);
|
|
7107
|
+
if (callee.type !== "MemberExpression" || callee.object.type !== "Identifier") return;
|
|
7108
|
+
const owner = callee.object.name;
|
|
7109
|
+
if (!["Reflect", "Object"].includes(owner) || !isGlobalIdentifier(owner, sourceCode.getScope(callee))) return;
|
|
7110
|
+
const method = staticPropertyName(callee, sourceCode);
|
|
7111
|
+
const [target, key, value, receiver] = node.arguments;
|
|
7112
|
+
if (target === void 0 || target.type === "SpreadElement" || key === void 0) return;
|
|
7113
|
+
const object = propertyReceiver(target);
|
|
7114
|
+
if (object === null) return;
|
|
7115
|
+
switch (method) {
|
|
7116
|
+
case "set":
|
|
7117
|
+
if (owner === "Reflect") reflectSet(object, scopedStaticString(key, sourceCode), value, receiver, node);
|
|
7118
|
+
return;
|
|
7119
|
+
case "defineProperty":
|
|
7120
|
+
descriptorWrite(object, scopedStaticString(key, sourceCode), value, node);
|
|
7121
|
+
return;
|
|
7122
|
+
case "defineProperties":
|
|
7123
|
+
if (owner === "Object") descriptorBatch(object, key, node);
|
|
7124
|
+
}
|
|
7125
|
+
}
|
|
7126
|
+
function reflectSet(object, name, value, receiver, node) {
|
|
7127
|
+
if (receiver !== void 0 && receiver.type !== "SpreadElement" && ["ObjectExpression", "ArrayExpression", "Literal"].includes(unwrapExpression(receiver).type)) return;
|
|
7128
|
+
const builtin = builtinPropertyName(object, name);
|
|
7129
|
+
if (value !== void 0 && value.type !== "SpreadElement" && builtin !== null && globalBuiltinName(value, sourceCode) === builtin) return;
|
|
7130
|
+
if (name === "toJSON" && value !== void 0 && !mayBeCallable(value)) return;
|
|
7131
|
+
propertyWrite(object, name, node);
|
|
7132
|
+
}
|
|
7133
|
+
function descriptorBatch(object, descriptors, node) {
|
|
7134
|
+
if (descriptors.type !== "ObjectExpression") {
|
|
7135
|
+
propertyWrite(object, null, node);
|
|
7136
|
+
return;
|
|
7137
|
+
}
|
|
7138
|
+
for (const property of descriptors.properties) {
|
|
7139
|
+
if (property.type !== "Property") {
|
|
7140
|
+
propertyWrite(object, null, node);
|
|
7141
|
+
continue;
|
|
7142
|
+
}
|
|
7143
|
+
descriptorWrite(object, staticPropertyName(property, sourceCode), property.value, node);
|
|
7144
|
+
}
|
|
7145
|
+
}
|
|
7146
|
+
function descriptorWrite(object, name, descriptor, node) {
|
|
7147
|
+
if (descriptor !== void 0 && !descriptorChangesValue(descriptor, builtinPropertyName(object, name))) return;
|
|
7148
|
+
propertyWrite(object, name, node);
|
|
7149
|
+
}
|
|
7150
|
+
function descriptorChangesValue(descriptor, name) {
|
|
7151
|
+
if (descriptor.type !== "ObjectExpression") return true;
|
|
7152
|
+
return descriptor.properties.some((property) => {
|
|
7153
|
+
if (property.type !== "Property") return true;
|
|
7154
|
+
const key = staticPropertyName(property, sourceCode);
|
|
7155
|
+
if (key === "value" && name === "toJSON" && !mayBeCallable(property.value)) return false;
|
|
7156
|
+
if (key === "value" && property.value.type !== "AssignmentPattern" && property.value.type !== "ArrayPattern" && property.value.type !== "ObjectPattern" && property.value.type !== "TSEmptyBodyFunctionExpression") return name === null || globalBuiltinName(property.value, sourceCode) !== name;
|
|
7157
|
+
return key === null || key === "get" || key === "set";
|
|
7158
|
+
});
|
|
7159
|
+
}
|
|
7160
|
+
function builtinPropertyName(object, name) {
|
|
7161
|
+
return object === "JSON" && name === "stringify" ? "JSON.stringify" : name;
|
|
7162
|
+
}
|
|
7163
|
+
visit(sourceCode.ast);
|
|
7164
|
+
BUILTIN_WRITES.set(sourceCode, writes);
|
|
7165
|
+
return writes;
|
|
7166
|
+
}
|
|
7167
|
+
function hasDefaultErrorSerialization(expression, call, sourceCode) {
|
|
7168
|
+
let constructor = null;
|
|
7169
|
+
if (expression.type === "Identifier") {
|
|
7170
|
+
const variable = ASTUtils15.findVariable(sourceCode.getScope(expression), expression.name);
|
|
7171
|
+
if (variable !== null && !hasUnchangedBuiltin(variable, call, sourceCode)) return false;
|
|
7172
|
+
const definition = variable?.defs[0];
|
|
7173
|
+
const initializer = definition?.type === "Variable" ? definition.node.init : null;
|
|
7174
|
+
if (initializer?.type === "NewExpression" && initializer.callee.type === "Identifier") constructor = initializer.callee.name;
|
|
7175
|
+
} else if (expression.type === "NewExpression" && expression.callee.type === "Identifier") constructor = expression.callee.name;
|
|
7176
|
+
const families = constructor === null ? BUILTIN_ERROR_CONSTRUCTORS : ["Error", constructor];
|
|
7177
|
+
return [...families].every((name) => hasUnchangedBuiltin(name + ".prototype", call, sourceCode));
|
|
7178
|
+
}
|
|
7179
|
+
function isBuiltinErrorConstructor(identifier, sourceCode) {
|
|
7180
|
+
return sourceCode.scopeManager !== null && BUILTIN_ERROR_CONSTRUCTORS.has(identifier.name) && isGlobalIdentifier(identifier.name, sourceCode.getScope(identifier)) && hasUnchangedBuiltin(identifier.name, identifier, sourceCode);
|
|
6846
7181
|
}
|
|
6847
7182
|
function isGlobalIdentifier(name, scope) {
|
|
6848
|
-
const binding =
|
|
7183
|
+
const binding = ASTUtils15.findVariable(scope, name);
|
|
6849
7184
|
return binding === null || binding.defs.length === 0;
|
|
6850
7185
|
}
|
|
6851
7186
|
function positiveErrorSubject(test, sourceCode) {
|
|
@@ -6853,7 +7188,7 @@ function positiveErrorSubject(test, sourceCode) {
|
|
|
6853
7188
|
}
|
|
6854
7189
|
var TYPE_GUARD_PATTERN = /^(is|has)[A-Z]/;
|
|
6855
7190
|
function instanceofErrorSubject(test, sourceCode) {
|
|
6856
|
-
if (test.type === "BinaryExpression" && test.operator === "instanceof" && test.right.type === "Identifier" && test.right.name === "Error" &&
|
|
7191
|
+
if (test.type === "BinaryExpression" && test.operator === "instanceof" && test.right.type === "Identifier" && test.right.name === "Error" && isBuiltinErrorConstructor(test.right, sourceCode)) {
|
|
6857
7192
|
return test.left;
|
|
6858
7193
|
}
|
|
6859
7194
|
return null;
|
|
@@ -6913,24 +7248,25 @@ function sameSubjectBinding(subject, value, sourceCode) {
|
|
|
6913
7248
|
const left = unwrapExpression(subject);
|
|
6914
7249
|
const right = unwrapExpression(value);
|
|
6915
7250
|
if (left.type === "Identifier" && right.type === "Identifier") {
|
|
6916
|
-
const binding =
|
|
6917
|
-
return binding !== null && binding ===
|
|
7251
|
+
const binding = ASTUtils15.findVariable(sourceCode.getScope(left), left.name);
|
|
7252
|
+
return binding !== null && binding === ASTUtils15.findVariable(sourceCode.getScope(right), right.name);
|
|
6918
7253
|
}
|
|
6919
7254
|
return sourceCode.getText(subject) === sourceCode.getText(value);
|
|
6920
7255
|
}
|
|
6921
7256
|
function nodeWithin(node, container) {
|
|
6922
7257
|
return container !== null && node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
6923
7258
|
}
|
|
6924
|
-
function isJsonStringify(callee) {
|
|
7259
|
+
function isJsonStringify(callee, sourceCode) {
|
|
6925
7260
|
if (callee.type !== "MemberExpression") return false;
|
|
6926
7261
|
const receiver = unwrapExpression(callee.object);
|
|
6927
|
-
return callee.type === "MemberExpression" && receiver.type === "Identifier" && receiver.name === "JSON" &&
|
|
7262
|
+
return callee.type === "MemberExpression" && receiver.type === "Identifier" && receiver.name === "JSON" && staticPropertyName(callee, sourceCode) === "stringify";
|
|
6928
7263
|
}
|
|
6929
|
-
function directLiteralValues(argument) {
|
|
7264
|
+
function directLiteralValues(argument, sourceCode) {
|
|
6930
7265
|
argument = unwrapExpression(argument);
|
|
6931
7266
|
if (argument.type === "ObjectExpression") {
|
|
7267
|
+
if (literalHasSerializer(argument, sourceCode)) return [];
|
|
6932
7268
|
return argument.properties.flatMap((property) => {
|
|
6933
|
-
if (property.type !== "Property" ||
|
|
7269
|
+
if (property.type !== "Property" || staticPropertyName(property, sourceCode) === null) return [];
|
|
6934
7270
|
const value = property.value;
|
|
6935
7271
|
if (value.type === "AssignmentPattern" || value.type === "ArrayPattern" || value.type === "ObjectPattern" || value.type === "TSEmptyBodyFunctionExpression") {
|
|
6936
7272
|
return [];
|
|
@@ -6945,6 +7281,20 @@ function directLiteralValues(argument) {
|
|
|
6945
7281
|
}
|
|
6946
7282
|
return argument.type === "SpreadElement" ? [] : [argument];
|
|
6947
7283
|
}
|
|
7284
|
+
function literalHasSerializer(argument, sourceCode) {
|
|
7285
|
+
for (const property of argument.properties.toReversed()) {
|
|
7286
|
+
if (property.type !== "Property") return true;
|
|
7287
|
+
const key = staticPropertyName(property, sourceCode);
|
|
7288
|
+
if (key === null) return true;
|
|
7289
|
+
if (key === "toJSON") return mayBeCallable(property.value);
|
|
7290
|
+
}
|
|
7291
|
+
for (const property of argument.properties) {
|
|
7292
|
+
if (property.type !== "Property" || property.computed || property.method || property.shorthand || property.kind !== "init" || staticPropertyName(property, sourceCode) !== "__proto__") continue;
|
|
7293
|
+
const prototype = property.value;
|
|
7294
|
+
return prototype.type === "ObjectExpression" ? literalHasSerializer(prototype, sourceCode) : prototype.type !== "Literal" || "regex" in prototype && prototype.regex !== void 0;
|
|
7295
|
+
}
|
|
7296
|
+
return false;
|
|
7297
|
+
}
|
|
6948
7298
|
function expressionSuggestsError(expression, sourceCode) {
|
|
6949
7299
|
expression = unwrapExpression(expression);
|
|
6950
7300
|
const unwrappedExpressionCallee = expression.type === "CallExpression" || expression.type === "NewExpression" ? unwrapExpression(expression.callee) : null;
|
|
@@ -6952,23 +7302,19 @@ function expressionSuggestsError(expression, sourceCode) {
|
|
|
6952
7302
|
return identifierIsProvenError(expression, sourceCode);
|
|
6953
7303
|
}
|
|
6954
7304
|
if (expression.type === "NewExpression" && unwrappedExpressionCallee?.type === "Identifier") {
|
|
6955
|
-
return
|
|
6956
|
-
}
|
|
6957
|
-
return expression.type === "MemberExpression" && memberSuggestsError(expression, sourceCode);
|
|
6958
|
-
}
|
|
6959
|
-
function memberSuggestsError(member, sourceCode) {
|
|
6960
|
-
const propName2 = ASTUtils14.getPropertyName(member);
|
|
6961
|
-
const base = member.object;
|
|
6962
|
-
const baseSuggestsError = base.type === "Identifier" && identifierIsProvenError(base, sourceCode);
|
|
6963
|
-
if (baseSuggestsError) {
|
|
6964
|
-
if (propName2 === null) {
|
|
6965
|
-
return true;
|
|
6966
|
-
}
|
|
6967
|
-
const lowered = propName2.toLowerCase();
|
|
6968
|
-
return !SAFE_STRING_PROPS.has(lowered) && !PAYLOAD_PROPS.has(lowered);
|
|
7305
|
+
return isBuiltinErrorConstructor(unwrappedExpressionCallee, sourceCode);
|
|
6969
7306
|
}
|
|
6970
7307
|
return false;
|
|
6971
7308
|
}
|
|
7309
|
+
function identifierIsProvenError(identifier, sourceCode) {
|
|
7310
|
+
const variable = ASTUtils15.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
7311
|
+
if (variable === null || variable.defs.length !== 1 || variable.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
7312
|
+
const definition = variable.defs[0];
|
|
7313
|
+
if (definition?.type === "CatchClause") return true;
|
|
7314
|
+
if (definition?.type !== "Variable") return false;
|
|
7315
|
+
const initializer = definition.node.init;
|
|
7316
|
+
return initializer?.type === "NewExpression" && initializer.callee.type === "Identifier" && isBuiltinErrorConstructor(initializer.callee, sourceCode);
|
|
7317
|
+
}
|
|
6972
7318
|
var no_json_stringify_error_default = createRule({
|
|
6973
7319
|
name: "no-json-stringify-error",
|
|
6974
7320
|
documentation: NO_JSON_STRINGIFY_ERROR_DOCUMENTATION,
|
|
@@ -6987,7 +7333,7 @@ var no_json_stringify_error_default = createRule({
|
|
|
6987
7333
|
return {
|
|
6988
7334
|
CallExpression(node) {
|
|
6989
7335
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
6990
|
-
if (!isJsonStringify(unwrappedNodeCallee)) {
|
|
7336
|
+
if (!isJsonStringify(unwrappedNodeCallee, context.sourceCode)) {
|
|
6991
7337
|
return;
|
|
6992
7338
|
}
|
|
6993
7339
|
const firstArg = node.arguments[0];
|
|
@@ -6995,11 +7341,11 @@ var no_json_stringify_error_default = createRule({
|
|
|
6995
7341
|
return;
|
|
6996
7342
|
}
|
|
6997
7343
|
const scope = context.sourceCode.getScope(firstArg);
|
|
6998
|
-
if (!isGlobalIdentifier("JSON", scope)) return;
|
|
7344
|
+
if (!isGlobalIdentifier("JSON", scope) || !hasUnchangedBuiltin("JSON", node, context.sourceCode) || !hasUnchangedBuiltin("JSON.stringify", node, context.sourceCode)) return;
|
|
6999
7345
|
const replacer = node.arguments[1] === void 0 ? void 0 : unwrapExpression(node.arguments[1]);
|
|
7000
7346
|
if (replacer !== void 0 && !(replacer.type === "Literal" && replacer.value === null) && !(replacer.type === "Identifier" && replacer.name === "undefined" && isGlobalIdentifier("undefined", scope))) return;
|
|
7001
|
-
const unsafeValue = directLiteralValues(firstArg).find(
|
|
7002
|
-
(value) => expressionSuggestsError(value, context.sourceCode) && !isGuardedByInstanceofError(node, value, context.sourceCode) && !isNarrowedByEarlyReturn(node, value, context.sourceCode)
|
|
7347
|
+
const unsafeValue = directLiteralValues(firstArg, context.sourceCode).find(
|
|
7348
|
+
(value) => expressionSuggestsError(value, context.sourceCode) && hasDefaultErrorSerialization(unwrapExpression(value), node, context.sourceCode) && !isGuardedByInstanceofError(node, value, context.sourceCode) && !isNarrowedByEarlyReturn(node, value, context.sourceCode)
|
|
7003
7349
|
);
|
|
7004
7350
|
if (unsafeValue === void 0) {
|
|
7005
7351
|
return;
|
|
@@ -7035,7 +7381,7 @@ function branchTerminates(branch) {
|
|
|
7035
7381
|
// src/rules/no-json-stringify-object-equality.ts
|
|
7036
7382
|
import {
|
|
7037
7383
|
AST_NODE_TYPES as AST_NODE_TYPES36,
|
|
7038
|
-
ASTUtils as
|
|
7384
|
+
ASTUtils as ASTUtils16,
|
|
7039
7385
|
ESLintUtils as ESLintUtils7
|
|
7040
7386
|
} from "@typescript-eslint/utils";
|
|
7041
7387
|
import ts6 from "typescript";
|
|
@@ -7086,10 +7432,10 @@ function jsonStringifyArgument(node, sourceCode) {
|
|
|
7086
7432
|
if (expression.type !== AST_NODE_TYPES36.CallExpression) return null;
|
|
7087
7433
|
const callee = unwrapExpression(expression.callee);
|
|
7088
7434
|
const calleeReceiver = callee.type === AST_NODE_TYPES36.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
7089
|
-
if (callee.type !== AST_NODE_TYPES36.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES36.Identifier || calleeReceiver.name !== "JSON" ||
|
|
7435
|
+
if (callee.type !== AST_NODE_TYPES36.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES36.Identifier || calleeReceiver.name !== "JSON" || ASTUtils16.getPropertyName(callee) !== "stringify") {
|
|
7090
7436
|
return null;
|
|
7091
7437
|
}
|
|
7092
|
-
const variable =
|
|
7438
|
+
const variable = ASTUtils16.findVariable(sourceCode.getScope(calleeReceiver), "JSON");
|
|
7093
7439
|
if (variable !== null && variable.defs.length > 0) return null;
|
|
7094
7440
|
const argument = expression.arguments[0];
|
|
7095
7441
|
return argument !== void 0 && argument.type !== AST_NODE_TYPES36.SpreadElement ? argument : null;
|
|
@@ -7175,7 +7521,7 @@ var no_json_stringify_object_equality_default = createRule({
|
|
|
7175
7521
|
|
|
7176
7522
|
// src/rules/no-impossible-zod-literal-bounds.ts
|
|
7177
7523
|
import {
|
|
7178
|
-
ASTUtils as
|
|
7524
|
+
ASTUtils as ASTUtils17,
|
|
7179
7525
|
AST_NODE_TYPES as AST_NODE_TYPES37
|
|
7180
7526
|
} from "@typescript-eslint/utils";
|
|
7181
7527
|
|
|
@@ -7327,7 +7673,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
|
|
|
7327
7673
|
if (callee.type !== AST_NODE_TYPES37.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES37.CallExpression) {
|
|
7328
7674
|
return null;
|
|
7329
7675
|
}
|
|
7330
|
-
const method =
|
|
7676
|
+
const method = ASTUtils17.getPropertyName(callee);
|
|
7331
7677
|
if (method === null) return null;
|
|
7332
7678
|
calls.push({ method, node: current });
|
|
7333
7679
|
current = calleeReceiver;
|
|
@@ -7342,7 +7688,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
|
|
|
7342
7688
|
if (callee.type !== AST_NODE_TYPES37.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES37.Identifier || !namespaces.has(calleeReceiver.name) || !resolvesToTrackedImport(calleeReceiver)) {
|
|
7343
7689
|
return null;
|
|
7344
7690
|
}
|
|
7345
|
-
const name =
|
|
7691
|
+
const name = ASTUtils17.getPropertyName(callee);
|
|
7346
7692
|
return name !== null && KINDS.has(name) ? name : null;
|
|
7347
7693
|
}
|
|
7348
7694
|
function isInsideReshapingCall(node) {
|
|
@@ -7352,7 +7698,7 @@ var no_impossible_zod_literal_bounds_default = createRule({
|
|
|
7352
7698
|
if (parent.type === AST_NODE_TYPES37.CallExpression) {
|
|
7353
7699
|
const callee = unwrapExpression(parent.callee);
|
|
7354
7700
|
const calleeReceiver = callee.type === AST_NODE_TYPES37.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
7355
|
-
if (callee.type === AST_NODE_TYPES37.MemberExpression && RESHAPING_METHODS.has(
|
|
7701
|
+
if (callee.type === AST_NODE_TYPES37.MemberExpression && RESHAPING_METHODS.has(ASTUtils17.getPropertyName(callee) ?? "") && (calleeReceiver.type === AST_NODE_TYPES37.CallExpression || calleeReceiver.type === AST_NODE_TYPES37.Identifier && namespaces.has(calleeReceiver.name) && resolvesToTrackedImport(calleeReceiver))) {
|
|
7356
7702
|
return true;
|
|
7357
7703
|
}
|
|
7358
7704
|
if (callee.type === AST_NODE_TYPES37.Identifier && preprocessors.has(callee.name) && resolvesToTrackedImport(callee)) {
|
|
@@ -7563,7 +7909,7 @@ var no_in_operator_on_built_in_collections_default = createRule({
|
|
|
7563
7909
|
|
|
7564
7910
|
// src/rules/no-redundant-optional-array-default.ts
|
|
7565
7911
|
import {
|
|
7566
|
-
ASTUtils as
|
|
7912
|
+
ASTUtils as ASTUtils18,
|
|
7567
7913
|
AST_NODE_TYPES as AST_NODE_TYPES38
|
|
7568
7914
|
} from "@typescript-eslint/utils";
|
|
7569
7915
|
var NO_REDUNDANT_OPTIONAL_ARRAY_DEFAULT_DOCUMENTATION = {
|
|
@@ -7701,7 +8047,7 @@ var no_redundant_optional_array_default_default = createRule({
|
|
|
7701
8047
|
return arrayConstructors.has(callee.name) && resolvesToTrackedImport(callee);
|
|
7702
8048
|
}
|
|
7703
8049
|
if (callee.type !== AST_NODE_TYPES38.MemberExpression) return false;
|
|
7704
|
-
const method =
|
|
8050
|
+
const method = ASTUtils18.getPropertyName(callee);
|
|
7705
8051
|
if (method === "array" && (calleeReceiver.type === AST_NODE_TYPES38.Identifier ? namespaces.has(calleeReceiver.name) && resolvesToTrackedImport(calleeReceiver) : isZodSchemaExpression(calleeReceiver))) {
|
|
7706
8052
|
return true;
|
|
7707
8053
|
}
|
|
@@ -7744,13 +8090,13 @@ var no_redundant_optional_array_default_default = createRule({
|
|
|
7744
8090
|
CallExpression(node) {
|
|
7745
8091
|
const defaultCallee = unwrapExpression(node.callee);
|
|
7746
8092
|
const defaultCalleeReceiver = defaultCallee.type === AST_NODE_TYPES38.MemberExpression ? unwrapExpression(defaultCallee.object) : defaultCallee;
|
|
7747
|
-
if (defaultCallee.type !== AST_NODE_TYPES38.MemberExpression ||
|
|
8093
|
+
if (defaultCallee.type !== AST_NODE_TYPES38.MemberExpression || ASTUtils18.getPropertyName(defaultCallee) !== "default" || !hasArrayFallback(node) || defaultCalleeReceiver.type !== AST_NODE_TYPES38.CallExpression) {
|
|
7748
8094
|
return;
|
|
7749
8095
|
}
|
|
7750
8096
|
const optionalCall = defaultCalleeReceiver;
|
|
7751
8097
|
const optionalCallee = unwrapExpression(optionalCall.callee);
|
|
7752
8098
|
const optionalCalleeReceiver = optionalCallee.type === AST_NODE_TYPES38.MemberExpression ? unwrapExpression(optionalCallee.object) : optionalCallee;
|
|
7753
|
-
if (optionalCallee.type !== AST_NODE_TYPES38.MemberExpression ||
|
|
8099
|
+
if (optionalCallee.type !== AST_NODE_TYPES38.MemberExpression || ASTUtils18.getPropertyName(optionalCallee) !== "optional" || optionalCall.arguments.length !== 0 || !isArraySchemaExpression(optionalCalleeReceiver) || sourceCode.getCommentsInside(optionalCall).length > 0) {
|
|
7754
8100
|
return;
|
|
7755
8101
|
}
|
|
7756
8102
|
context.report({
|
|
@@ -7889,10 +8235,10 @@ var interface_contract_members_private_default = createRule({
|
|
|
7889
8235
|
});
|
|
7890
8236
|
|
|
7891
8237
|
// src/rules/no-log-only-catch.ts
|
|
7892
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES42, ASTUtils as
|
|
8238
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42, ASTUtils as ASTUtils20 } from "@typescript-eslint/utils";
|
|
7893
8239
|
|
|
7894
8240
|
// src/rules/_logging.ts
|
|
7895
|
-
import { ASTUtils as
|
|
8241
|
+
import { ASTUtils as ASTUtils19, AST_NODE_TYPES as AST_NODE_TYPES41 } from "@typescript-eslint/utils";
|
|
7896
8242
|
var LOG_METHODS = /* @__PURE__ */ new Set([
|
|
7897
8243
|
"debug",
|
|
7898
8244
|
"info",
|
|
@@ -7929,7 +8275,7 @@ function calleeName2(callee) {
|
|
|
7929
8275
|
if (callee.type === "Identifier") {
|
|
7930
8276
|
return callee.name;
|
|
7931
8277
|
}
|
|
7932
|
-
return callee.type === "MemberExpression" ?
|
|
8278
|
+
return callee.type === "MemberExpression" ? ASTUtils19.getPropertyName(callee) : null;
|
|
7933
8279
|
}
|
|
7934
8280
|
function createLogMatcher(options = {}) {
|
|
7935
8281
|
const loggerNames = /* @__PURE__ */ new Set([
|
|
@@ -7944,7 +8290,7 @@ function createLogMatcher(options = {}) {
|
|
|
7944
8290
|
return loggerNames.has(expr.name.toLowerCase());
|
|
7945
8291
|
case "MemberExpression": {
|
|
7946
8292
|
const { object } = expr;
|
|
7947
|
-
const property =
|
|
8293
|
+
const property = ASTUtils19.getPropertyName(expr);
|
|
7948
8294
|
if (property !== null) {
|
|
7949
8295
|
const lowered = property.toLowerCase();
|
|
7950
8296
|
if (loggerNames.has(lowered) || LOGGER_FACTORIES.has(lowered)) {
|
|
@@ -7955,7 +8301,7 @@ function createLogMatcher(options = {}) {
|
|
|
7955
8301
|
}
|
|
7956
8302
|
case "CallExpression": {
|
|
7957
8303
|
const callee = unwrapExpression(expr.callee);
|
|
7958
|
-
const name = callee.type === "MemberExpression" ?
|
|
8304
|
+
const name = callee.type === "MemberExpression" ? ASTUtils19.getPropertyName(callee) : null;
|
|
7959
8305
|
if (name !== null && LOGGER_FACTORIES.has(name.toLowerCase())) {
|
|
7960
8306
|
return true;
|
|
7961
8307
|
}
|
|
@@ -7986,7 +8332,7 @@ function createLogMatcher(options = {}) {
|
|
|
7986
8332
|
const callee = unwrapExpression(expr.callee);
|
|
7987
8333
|
const calleeReceiver = callee.type === AST_NODE_TYPES41.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
7988
8334
|
if (callee.type !== "MemberExpression") return false;
|
|
7989
|
-
const name =
|
|
8335
|
+
const name = ASTUtils19.getPropertyName(callee);
|
|
7990
8336
|
return name !== null && LOG_METHODS.has(name.toLowerCase()) && isLoggerReceiver(calleeReceiver);
|
|
7991
8337
|
}
|
|
7992
8338
|
return { isLoggerReceiver, isLogFunctionCall, isLoggingCall };
|
|
@@ -8060,7 +8406,7 @@ function seededFallbackHandled(tryStatement, scope) {
|
|
|
8060
8406
|
if (previous.declarations.length !== 1 || declarator === void 0) return false;
|
|
8061
8407
|
if (declarator.id.type !== AST_NODE_TYPES42.Identifier) return false;
|
|
8062
8408
|
if (declarator.init == null || !isSeedValue(declarator.init)) return false;
|
|
8063
|
-
const variable =
|
|
8409
|
+
const variable = ASTUtils20.findVariable(scope, declarator.id.name);
|
|
8064
8410
|
if (variable === null) return false;
|
|
8065
8411
|
const [tryStart, tryEnd] = tryStatement.block.range;
|
|
8066
8412
|
let writtenInTry = false;
|
|
@@ -8122,9 +8468,9 @@ var no_log_only_catch_default = createRule({
|
|
|
8122
8468
|
if (left.type !== AST_NODE_TYPES42.MemberExpression || left.computed || left.object.type !== AST_NODE_TYPES42.Identifier || right.type !== AST_NODE_TYPES42.CallExpression || right.optional || right.callee.type !== AST_NODE_TYPES42.Identifier || !["String", "Number", "Boolean", "BigInt"].includes(right.callee.name) || right.arguments.length !== 1) return false;
|
|
8123
8469
|
const argument = right.arguments[0];
|
|
8124
8470
|
if (argument === void 0 || sourceCode.getText(left) !== sourceCode.getText(argument)) return false;
|
|
8125
|
-
const global =
|
|
8471
|
+
const global = ASTUtils20.findVariable(sourceCode.getScope(right.callee), right.callee.name);
|
|
8126
8472
|
if (global !== null && global.defs.length > 0) return false;
|
|
8127
|
-
const root =
|
|
8473
|
+
const root = ASTUtils20.findVariable(sourceCode.getScope(left.object), left.object.name);
|
|
8128
8474
|
if (root === null || root.references.some((reference) => reference.isWrite() && !reference.init)) return false;
|
|
8129
8475
|
return hasFollowingCoercionCheck(owner, left, right.callee.name);
|
|
8130
8476
|
}
|
|
@@ -8195,7 +8541,7 @@ var no_log_only_catch_default = createRule({
|
|
|
8195
8541
|
});
|
|
8196
8542
|
|
|
8197
8543
|
// src/rules/no-bare-return-from-test-catch.ts
|
|
8198
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES43, ASTUtils as
|
|
8544
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43, ASTUtils as ASTUtils21 } from "@typescript-eslint/utils";
|
|
8199
8545
|
var NO_BARE_RETURN_FROM_TEST_CATCH_DOCUMENTATION = {
|
|
8200
8546
|
summary: "Disallow a bare return from a test catch block when it skips a later assertion.",
|
|
8201
8547
|
rationale: "An unasserted catch return can swallow a failure and skip later assertions; the complete test result also depends on other assertions and hooks.",
|
|
@@ -8292,7 +8638,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
8292
8638
|
const parameter = catchClause.param;
|
|
8293
8639
|
const returnBlock = node.parent;
|
|
8294
8640
|
if (parameter?.type === AST_NODE_TYPES43.Identifier && returnBlock?.type === AST_NODE_TYPES43.BlockStatement) {
|
|
8295
|
-
const errorBinding =
|
|
8641
|
+
const errorBinding = ASTUtils21.findVariable(context.sourceCode.getScope(parameter), parameter.name);
|
|
8296
8642
|
const assertedError = returnBlock.body.some((statement) => {
|
|
8297
8643
|
if (statement.range[1] >= node.range[0] || statement.type !== AST_NODE_TYPES43.ExpressionStatement) return false;
|
|
8298
8644
|
const expression = statement.expression;
|
|
@@ -8316,7 +8662,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
8316
8662
|
});
|
|
8317
8663
|
|
|
8318
8664
|
// src/rules/no-bespoke-api-case-conversion.ts
|
|
8319
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES44, ASTUtils as
|
|
8665
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44, ASTUtils as ASTUtils22 } from "@typescript-eslint/utils";
|
|
8320
8666
|
var NO_BESPOKE_API_CASE_CONVERSION_DOCUMENTATION = {
|
|
8321
8667
|
defaultLevel: "warning",
|
|
8322
8668
|
summary: "Review direct snake_case/camelCase mirror mappings on explicitly API-typed adapter values.",
|
|
@@ -8369,10 +8715,10 @@ function propertyName(node) {
|
|
|
8369
8715
|
}
|
|
8370
8716
|
function memberName3(node) {
|
|
8371
8717
|
const current = unwrapExpression(node);
|
|
8372
|
-
if (current.type !== AST_NODE_TYPES44.MemberExpression ||
|
|
8718
|
+
if (current.type !== AST_NODE_TYPES44.MemberExpression || ASTUtils22.getPropertyName(current) === null) {
|
|
8373
8719
|
return null;
|
|
8374
8720
|
}
|
|
8375
|
-
return
|
|
8721
|
+
return ASTUtils22.getPropertyName(current) ?? "";
|
|
8376
8722
|
}
|
|
8377
8723
|
function isDirectCaseTranslation(left, right) {
|
|
8378
8724
|
if (SNAKE_CASE_RE2.test(left) && LOWER_CAMEL_CASE_RE.test(right)) {
|
|
@@ -8412,7 +8758,7 @@ var no_bespoke_api_case_conversion_default = createRule({
|
|
|
8412
8758
|
else break;
|
|
8413
8759
|
}
|
|
8414
8760
|
if (current.type !== AST_NODE_TYPES44.Identifier) return false;
|
|
8415
|
-
const binding =
|
|
8761
|
+
const binding = ASTUtils22.findVariable(context.sourceCode.getScope(current), current.name);
|
|
8416
8762
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
8417
8763
|
const identifier = binding.defs[0]?.name;
|
|
8418
8764
|
if (identifier?.type !== AST_NODE_TYPES44.Identifier) return false;
|
|
@@ -8421,7 +8767,7 @@ var no_bespoke_api_case_conversion_default = createRule({
|
|
|
8421
8767
|
let typeName = annotation.typeName;
|
|
8422
8768
|
while (typeName.type === AST_NODE_TYPES44.TSQualifiedName) typeName = typeName.left;
|
|
8423
8769
|
if (typeName.type !== AST_NODE_TYPES44.Identifier) return false;
|
|
8424
|
-
const typeBinding =
|
|
8770
|
+
const typeBinding = ASTUtils22.findVariable(context.sourceCode.getScope(typeName), typeName.name);
|
|
8425
8771
|
return typeBinding?.defs.length === 1 && typeBinding.defs[0]?.type === "ImportBinding" && typeBinding.defs[0].parent.type === AST_NODE_TYPES44.ImportDeclaration && API_BOUNDARY_IMPORT_RE.test(typeBinding.defs[0].parent.source.value);
|
|
8426
8772
|
};
|
|
8427
8773
|
return {
|
|
@@ -8626,7 +8972,7 @@ var no_vague_suppression_description_default = createRule({
|
|
|
8626
8972
|
});
|
|
8627
8973
|
|
|
8628
8974
|
// src/rules/_runtime-exports.ts
|
|
8629
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES46, ASTUtils as
|
|
8975
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46, ASTUtils as ASTUtils23 } from "@typescript-eslint/utils";
|
|
8630
8976
|
var GENERIC_MODULE_STEMS = /* @__PURE__ */ new Set([
|
|
8631
8977
|
"common",
|
|
8632
8978
|
"helper",
|
|
@@ -8748,7 +9094,7 @@ function namespaceEmission(declaration) {
|
|
|
8748
9094
|
}
|
|
8749
9095
|
function isCommonJsExportReference(node, sourceCode) {
|
|
8750
9096
|
function isGlobal(node2) {
|
|
8751
|
-
const variable =
|
|
9097
|
+
const variable = ASTUtils23.findVariable(sourceCode.getScope(node2), node2.name);
|
|
8752
9098
|
return variable === null || variable.defs.length === 0;
|
|
8753
9099
|
}
|
|
8754
9100
|
if (node.type === AST_NODE_TYPES46.MemberExpression) {
|
|
@@ -8871,7 +9217,7 @@ var no_offset_pagination_default = createRule({
|
|
|
8871
9217
|
});
|
|
8872
9218
|
|
|
8873
9219
|
// src/rules/no-positional-tuple-return.ts
|
|
8874
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES47, ASTUtils as
|
|
9220
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47, ASTUtils as ASTUtils24 } from "@typescript-eslint/utils";
|
|
8875
9221
|
var NO_POSITIONAL_TUPLE_RETURN_DOCUMENTATION = {
|
|
8876
9222
|
summary: "Disallow returning a multi-field tuple from a named function; return a named object so call sites cannot mismatch slots.",
|
|
8877
9223
|
rationale: "Tuple fields are identified only by position, so reordering can preserve types while changing meaning.",
|
|
@@ -9005,7 +9351,7 @@ function typeAliases(sourceCode) {
|
|
|
9005
9351
|
get(identifier) {
|
|
9006
9352
|
const declaration = aliases.get(identifier.name);
|
|
9007
9353
|
if (declaration === void 0) return void 0;
|
|
9008
|
-
const binding =
|
|
9354
|
+
const binding = ASTUtils24.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
9009
9355
|
return binding?.defs.length === 1 && binding.defs[0]?.node === declaration ? declaration.typeAnnotation : void 0;
|
|
9010
9356
|
}
|
|
9011
9357
|
};
|
|
@@ -9316,7 +9662,7 @@ var no_production_browser_source_maps_default = createRule({
|
|
|
9316
9662
|
});
|
|
9317
9663
|
|
|
9318
9664
|
// src/rules/no-raw-env.ts
|
|
9319
|
-
import { ASTUtils as
|
|
9665
|
+
import { ASTUtils as ASTUtils25, AST_NODE_TYPES as AST_NODE_TYPES48 } from "@typescript-eslint/utils";
|
|
9320
9666
|
var NO_RAW_ENV_DOCUMENTATION = {
|
|
9321
9667
|
summary: "Disallow direct `process.env` and `import.meta.env` reads outside validated boundaries.",
|
|
9322
9668
|
rationale: "Raw environment reads are untyped and defer invalid configuration failures until use.",
|
|
@@ -9332,15 +9678,15 @@ var CONFIG_FILE_RE = /(^|[\\/])[\w.-]+\.config\.[cm]?[jt]sx?$/;
|
|
|
9332
9678
|
var ENV_BOUNDARY_FILE_RE = /(^|[\\/])(?:env|client-env|server-env|client-settings|server-settings)\.[cm]?[jt]sx?$/;
|
|
9333
9679
|
function isProcessEnv(node, context) {
|
|
9334
9680
|
const receiver = unwrapExpression(node.object);
|
|
9335
|
-
if (receiver.type !== "Identifier" ||
|
|
9336
|
-
const binding =
|
|
9681
|
+
if (receiver.type !== "Identifier" || ASTUtils25.getPropertyName(node) !== "env") return false;
|
|
9682
|
+
const binding = ASTUtils25.findVariable(context.sourceCode.getScope(receiver), receiver.name);
|
|
9337
9683
|
if (binding === null || binding.defs.length === 0) return receiver.name === "process";
|
|
9338
9684
|
return binding.defs.every(
|
|
9339
9685
|
(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)
|
|
9340
9686
|
);
|
|
9341
9687
|
}
|
|
9342
9688
|
function isImportMetaEnv(node) {
|
|
9343
|
-
return
|
|
9689
|
+
return ASTUtils25.getPropertyName(node) === "env" && node.object.type === "MetaProperty" && node.object.meta.name === "import" && node.object.property.name === "meta";
|
|
9344
9690
|
}
|
|
9345
9691
|
var BUILD_TIME_CONSTANTS = /* @__PURE__ */ new Set([
|
|
9346
9692
|
"NODE_ENV",
|
|
@@ -9358,7 +9704,7 @@ var PLATFORM_MARKERS = /* @__PURE__ */ new Set([
|
|
|
9358
9704
|
function isExemptVariableAccess(node) {
|
|
9359
9705
|
const parent = node.parent;
|
|
9360
9706
|
if (parent.type !== "MemberExpression" || parent.object !== node) return false;
|
|
9361
|
-
const name =
|
|
9707
|
+
const name = ASTUtils25.getPropertyName(parent);
|
|
9362
9708
|
return name !== null && (BUILD_TIME_CONSTANTS.has(name) || PLATFORM_MARKERS.has(name));
|
|
9363
9709
|
}
|
|
9364
9710
|
function isWriteTarget(node) {
|
|
@@ -9406,7 +9752,7 @@ var no_raw_env_default = createRule({
|
|
|
9406
9752
|
if (callee.type === "Identifier" && callee.name === "createEnv") {
|
|
9407
9753
|
hasValidationCall = true;
|
|
9408
9754
|
} else if (callee.type === "MemberExpression") {
|
|
9409
|
-
const name =
|
|
9755
|
+
const name = ASTUtils25.getPropertyName(callee);
|
|
9410
9756
|
if (name === "parse" || name === "safeParse" || name === "object" && calleeReceiver.type === "Identifier" && calleeReceiver.name === "z") {
|
|
9411
9757
|
hasValidationCall = true;
|
|
9412
9758
|
}
|
|
@@ -9426,7 +9772,7 @@ var no_raw_env_default = createRule({
|
|
|
9426
9772
|
});
|
|
9427
9773
|
|
|
9428
9774
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
9429
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES49, ASTUtils as
|
|
9775
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49, ASTUtils as ASTUtils26 } from "@typescript-eslint/utils";
|
|
9430
9776
|
var NO_RAW_FETCH_OUTSIDE_CLIENTS_DOCUMENTATION = {
|
|
9431
9777
|
summary: "Disallow calling the global `fetch` outside the client layer; route outbound HTTP through a client module that owns retry, timeout and status handling.",
|
|
9432
9778
|
rationale: "Scattered fetch calls bypass shared transport policy and are harder to stub and observe consistently.",
|
|
@@ -9615,7 +9961,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
9615
9961
|
internalApiPrefixes.push(`${options.basePath}/api`);
|
|
9616
9962
|
}
|
|
9617
9963
|
function resolvesToGlobal(identifier) {
|
|
9618
|
-
const variable =
|
|
9964
|
+
const variable = ASTUtils26.findVariable(
|
|
9619
9965
|
context.sourceCode.getScope(identifier),
|
|
9620
9966
|
identifier.name
|
|
9621
9967
|
);
|
|
@@ -9624,7 +9970,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
9624
9970
|
function resolveNode2(node) {
|
|
9625
9971
|
if (node === void 0) return null;
|
|
9626
9972
|
if (node.type !== AST_NODE_TYPES49.Identifier) return node;
|
|
9627
|
-
const variable =
|
|
9973
|
+
const variable = ASTUtils26.findVariable(
|
|
9628
9974
|
context.sourceCode.getScope(node),
|
|
9629
9975
|
node.name
|
|
9630
9976
|
);
|
|
@@ -9704,7 +10050,7 @@ var no_raw_fetch_outside_clients_default = createRule({
|
|
|
9704
10050
|
});
|
|
9705
10051
|
|
|
9706
10052
|
// src/rules/no-restricted-library-load.ts
|
|
9707
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES50, ASTUtils as
|
|
10053
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50, ASTUtils as ASTUtils27 } from "@typescript-eslint/utils";
|
|
9708
10054
|
var NO_RESTRICTED_LIBRARY_LOAD_DOCUMENTATION = {
|
|
9709
10055
|
summary: "Apply configured library restrictions to literal runtime loads and CommonJS resolution references.",
|
|
9710
10056
|
rationale: "Dynamic imports, CommonJS loads, and package resolution checks can bypass library restrictions enforced for static imports.",
|
|
@@ -9790,7 +10136,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
9790
10136
|
});
|
|
9791
10137
|
}
|
|
9792
10138
|
function isUnshadowedRequire(node) {
|
|
9793
|
-
const variable =
|
|
10139
|
+
const variable = ASTUtils27.findVariable(
|
|
9794
10140
|
context.sourceCode.getScope(node),
|
|
9795
10141
|
node.name
|
|
9796
10142
|
);
|
|
@@ -9824,7 +10170,7 @@ var no_restricted_library_load_default = createRule({
|
|
|
9824
10170
|
});
|
|
9825
10171
|
|
|
9826
10172
|
// src/rules/no-router-refresh-polling.ts
|
|
9827
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES51, ASTUtils as
|
|
10173
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51, ASTUtils as ASTUtils28 } from "@typescript-eslint/utils";
|
|
9828
10174
|
var NO_ROUTER_REFRESH_POLLING_DOCUMENTATION = {
|
|
9829
10175
|
summary: "Do not poll by calling a Next.js router's refresh method from a timer.",
|
|
9830
10176
|
rationale: "A route refresh refetches and rerenders the whole route on every tick instead of loading the named resource that changed.",
|
|
@@ -9852,10 +10198,10 @@ function enclosingIntervalCallback(sourceCode, node) {
|
|
|
9852
10198
|
}
|
|
9853
10199
|
function isIntervalCallee(sourceCode, node) {
|
|
9854
10200
|
node = unwrapExpression(node);
|
|
9855
|
-
return node.type === AST_NODE_TYPES51.Identifier && node.name === "setInterval" && isUnshadowedGlobal2(sourceCode, node) || node.type === AST_NODE_TYPES51.MemberExpression && node.object.type === AST_NODE_TYPES51.Identifier && (node.object.name === "window" || node.object.name === "globalThis") && isUnshadowedGlobal2(sourceCode, node.object) &&
|
|
10201
|
+
return node.type === AST_NODE_TYPES51.Identifier && node.name === "setInterval" && isUnshadowedGlobal2(sourceCode, node) || node.type === AST_NODE_TYPES51.MemberExpression && node.object.type === AST_NODE_TYPES51.Identifier && (node.object.name === "window" || node.object.name === "globalThis") && isUnshadowedGlobal2(sourceCode, node.object) && ASTUtils28.getPropertyName(node) === "setInterval";
|
|
9856
10202
|
}
|
|
9857
10203
|
function isUnshadowedGlobal2(sourceCode, node) {
|
|
9858
|
-
const variable =
|
|
10204
|
+
const variable = ASTUtils28.findVariable(sourceCode.getScope(node), node.name);
|
|
9859
10205
|
return variable === null || variable.defs.length === 0;
|
|
9860
10206
|
}
|
|
9861
10207
|
var no_router_refresh_polling_default = createRule({
|
|
@@ -9878,7 +10224,7 @@ var no_router_refresh_polling_default = createRule({
|
|
|
9878
10224
|
if (node.source.value !== "next/navigation") return;
|
|
9879
10225
|
for (const specifier of node.specifiers) {
|
|
9880
10226
|
if (specifier.type === AST_NODE_TYPES51.ImportSpecifier && importedName4(specifier) === "useRouter") {
|
|
9881
|
-
const variable =
|
|
10227
|
+
const variable = ASTUtils28.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
9882
10228
|
if (variable !== null) routerHooks.add(variable);
|
|
9883
10229
|
}
|
|
9884
10230
|
}
|
|
@@ -9888,16 +10234,16 @@ var no_router_refresh_polling_default = createRule({
|
|
|
9888
10234
|
if (node.id.type === AST_NODE_TYPES51.Identifier && initializer?.type === AST_NODE_TYPES51.CallExpression) {
|
|
9889
10235
|
const hookCallee = unwrapExpression(initializer.callee);
|
|
9890
10236
|
if (hookCallee.type !== AST_NODE_TYPES51.Identifier) return;
|
|
9891
|
-
const hook =
|
|
9892
|
-
const router =
|
|
10237
|
+
const hook = ASTUtils28.findVariable(context.sourceCode.getScope(hookCallee), hookCallee.name);
|
|
10238
|
+
const router = ASTUtils28.findVariable(context.sourceCode.getScope(node.id), node.id.name);
|
|
9893
10239
|
if (hook !== null && router !== null && routerHooks.has(hook)) routers.add(router);
|
|
9894
10240
|
}
|
|
9895
10241
|
},
|
|
9896
10242
|
CallExpression(node) {
|
|
9897
10243
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
9898
10244
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES51.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
9899
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES51.MemberExpression || receiver.type !== AST_NODE_TYPES51.Identifier ||
|
|
9900
|
-
const router =
|
|
10245
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES51.MemberExpression || receiver.type !== AST_NODE_TYPES51.Identifier || ASTUtils28.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils28.getPropertyName(unwrappedNodeCallee) ?? "") !== "refresh") return;
|
|
10246
|
+
const router = ASTUtils28.findVariable(
|
|
9901
10247
|
context.sourceCode.getScope(receiver),
|
|
9902
10248
|
receiver.name
|
|
9903
10249
|
);
|
|
@@ -10460,7 +10806,7 @@ function proseTokens(text) {
|
|
|
10460
10806
|
}
|
|
10461
10807
|
|
|
10462
10808
|
// src/rules/no-secret-in-log.ts
|
|
10463
|
-
import { ASTUtils as
|
|
10809
|
+
import { ASTUtils as ASTUtils29 } from "@typescript-eslint/utils";
|
|
10464
10810
|
|
|
10465
10811
|
// src/rules/_secret-names.ts
|
|
10466
10812
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -10683,7 +11029,7 @@ function hasRedactionMarker(name) {
|
|
|
10683
11029
|
}
|
|
10684
11030
|
function valueName(node) {
|
|
10685
11031
|
if (node.type === "Identifier") return node.name;
|
|
10686
|
-
return node.type === "MemberExpression" ?
|
|
11032
|
+
return node.type === "MemberExpression" ? ASTUtils29.getPropertyName(node) : null;
|
|
10687
11033
|
}
|
|
10688
11034
|
function isRawSecretValue(prop) {
|
|
10689
11035
|
if (prop.shorthand) {
|
|
@@ -10734,11 +11080,11 @@ function rawBlobValueName(value) {
|
|
|
10734
11080
|
return isRawBlobName(value.name) ? value.name : null;
|
|
10735
11081
|
}
|
|
10736
11082
|
if (value.type === "MemberExpression") {
|
|
10737
|
-
const name =
|
|
11083
|
+
const name = ASTUtils29.getPropertyName(value);
|
|
10738
11084
|
return name !== null && isRawBlobName(name) ? name : null;
|
|
10739
11085
|
}
|
|
10740
11086
|
if (value.type === "CallExpression" && value.arguments.length === 0 && unwrappedValueCallee?.type === "MemberExpression" && unwrappedValueCallee.object.type === "Identifier" && /^(?:res|response|\w+Response)$/.test(unwrappedValueCallee.object.name)) {
|
|
10741
|
-
const name =
|
|
11087
|
+
const name = ASTUtils29.getPropertyName(unwrappedValueCallee);
|
|
10742
11088
|
return name === "json" || name === "text" ? `${unwrappedValueCallee.object.name}.${name}()` : null;
|
|
10743
11089
|
}
|
|
10744
11090
|
return null;
|
|
@@ -11046,7 +11392,7 @@ var no_select_star_default = createRule({
|
|
|
11046
11392
|
});
|
|
11047
11393
|
|
|
11048
11394
|
// src/rules/no-sentinel-return-on-catch.ts
|
|
11049
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES55, ASTUtils as
|
|
11395
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES55, ASTUtils as ASTUtils30 } from "@typescript-eslint/utils";
|
|
11050
11396
|
var NO_SENTINEL_RETURN_ON_CATCH_DOCUMENTATION = {
|
|
11051
11397
|
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.",
|
|
11052
11398
|
rationale: "An unreported fallback makes operational failure indistinguishable from a legitimate empty result.",
|
|
@@ -11200,8 +11546,8 @@ function argsIncludeBinding(args, caughtName) {
|
|
|
11200
11546
|
}
|
|
11201
11547
|
function isParseShapedNode(node) {
|
|
11202
11548
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
11203
|
-
if (node.type === AST_NODE_TYPES55.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES55.MemberExpression &&
|
|
11204
|
-
return (
|
|
11549
|
+
if (node.type === AST_NODE_TYPES55.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES55.MemberExpression && ASTUtils30.getPropertyName(unwrappedNodeCallee) !== null) {
|
|
11550
|
+
return (ASTUtils30.getPropertyName(unwrappedNodeCallee) ?? "") === "parse";
|
|
11205
11551
|
}
|
|
11206
11552
|
if (node.type === AST_NODE_TYPES55.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES55.Identifier) {
|
|
11207
11553
|
return SAFE_PARSE_CONSTRUCTORS.has(unwrappedNodeCallee.name);
|
|
@@ -11215,21 +11561,21 @@ var SAFE_PARSE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
11215
11561
|
]);
|
|
11216
11562
|
function isBodyDecodeNode(node) {
|
|
11217
11563
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
11218
|
-
return node.type === AST_NODE_TYPES55.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES55.MemberExpression &&
|
|
11564
|
+
return node.type === AST_NODE_TYPES55.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES55.MemberExpression && ASTUtils30.getPropertyName(unwrappedNodeCallee) !== null && BODY_DECODE_METHODS.has(ASTUtils30.getPropertyName(unwrappedNodeCallee) ?? "");
|
|
11219
11565
|
}
|
|
11220
11566
|
function isSafeParseSupportCall(node) {
|
|
11221
11567
|
const callee = unwrapExpression(node.callee);
|
|
11222
|
-
if (callee.type !== AST_NODE_TYPES55.MemberExpression ||
|
|
11568
|
+
if (callee.type !== AST_NODE_TYPES55.MemberExpression || ASTUtils30.getPropertyName(callee) === null) {
|
|
11223
11569
|
return false;
|
|
11224
11570
|
}
|
|
11225
|
-
if ((
|
|
11571
|
+
if ((ASTUtils30.getPropertyName(callee) ?? "") === "isArray" && callee.object.type === AST_NODE_TYPES55.Identifier && callee.object.name === "Array") {
|
|
11226
11572
|
return true;
|
|
11227
11573
|
}
|
|
11228
|
-
if ((
|
|
11574
|
+
if ((ASTUtils30.getPropertyName(callee) ?? "") !== "getItem") return false;
|
|
11229
11575
|
if (callee.object.type === AST_NODE_TYPES55.Identifier && (callee.object.name === "localStorage" || callee.object.name === "sessionStorage")) {
|
|
11230
11576
|
return true;
|
|
11231
11577
|
}
|
|
11232
|
-
return callee.object.type === AST_NODE_TYPES55.MemberExpression && callee.object.object.type === AST_NODE_TYPES55.Identifier && (callee.object.object.name === "window" || callee.object.object.name === "globalThis") &&
|
|
11578
|
+
return callee.object.type === AST_NODE_TYPES55.MemberExpression && callee.object.object.type === AST_NODE_TYPES55.Identifier && (callee.object.object.name === "window" || callee.object.object.name === "globalThis") && ASTUtils30.getPropertyName(callee.object) !== null && ((ASTUtils30.getPropertyName(callee.object) ?? "") === "localStorage" || (ASTUtils30.getPropertyName(callee.object) ?? "") === "sessionStorage");
|
|
11233
11579
|
}
|
|
11234
11580
|
var BODY_DECODE_METHODS = /* @__PURE__ */ new Set([
|
|
11235
11581
|
"json",
|
|
@@ -11441,7 +11787,7 @@ var no_sentinel_return_on_catch_default = createRule({
|
|
|
11441
11787
|
return;
|
|
11442
11788
|
}
|
|
11443
11789
|
const returned = unwrapSentinelExpression(last.argument);
|
|
11444
|
-
if (returned?.type === AST_NODE_TYPES55.Identifier && returned.name === "undefined" && (
|
|
11790
|
+
if (returned?.type === AST_NODE_TYPES55.Identifier && returned.name === "undefined" && (ASTUtils30.findVariable(context.sourceCode.getScope(returned), returned.name)?.defs.length ?? 0) > 0) return;
|
|
11445
11791
|
if (containsThrow(node.body)) {
|
|
11446
11792
|
return;
|
|
11447
11793
|
}
|
|
@@ -11484,16 +11830,18 @@ function isNonReadingProperty(current, key) {
|
|
|
11484
11830
|
}
|
|
11485
11831
|
|
|
11486
11832
|
// src/rules/no-silent-promise-catch.ts
|
|
11487
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES56, ASTUtils as
|
|
11833
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES56, ASTUtils as ASTUtils31 } from "@typescript-eslint/utils";
|
|
11488
11834
|
var NO_SILENT_PROMISE_CATCH_DOCUMENTATION = {
|
|
11489
11835
|
summary: "Disallow `.catch()` and second-argument `.then()` handlers that silently swallow a rejection; log, rethrow, or handle the error.",
|
|
11490
11836
|
rationale: "A swallowed rejection hides failures and gives callers an indistinguishable fallback value.",
|
|
11491
11837
|
remediation: "Log, rethrow, or explicitly recover from the rejection; explain intentional teardown suppression.",
|
|
11492
11838
|
category: "correctness",
|
|
11493
|
-
limitations: ["Test files, teardown calls, explanatory comments, non-function handlers, and handlers that consume or report the error are excluded.", "Recognized imported Zod construction chains and their stable local aliases are excluded. Other untyped catch-like APIs are not proven to be Promises."],
|
|
11839
|
+
limitations: ["Test files, teardown calls, explanatory comments, non-function handlers, and handlers that consume or report the error are excluded.", "Recognized imported Zod construction chains and their stable local aliases are excluded. Other untyped catch-like APIs are not proven to be Promises.", "Computed methods resolve literal syntax and stable local string aliases in lexical scope. Function-derived, object-derived and mutated computed keys remain unproven."],
|
|
11494
11840
|
examples: [
|
|
11495
11841
|
{ id: "reported-rejection", title: "Report the rejection", outcome: "no-match", files: [{ path: "src/load.ts", source: "load().catch((error) => logger.error({ error }, 'load failed'));" }], focusPath: "src/load.ts", expectedCount: 0, public: true },
|
|
11496
|
-
{ id: "silent-rejection", title: "Do not swallow the rejection", outcome: "match", files: [{ path: "src/load.ts", source: "load().catch(() => null);" }], focusPath: "src/load.ts", expectedCount: 1, public: true }
|
|
11842
|
+
{ id: "silent-rejection", title: "Do not swallow the rejection", outcome: "match", files: [{ path: "src/load.ts", source: "load().catch(() => null);" }], focusPath: "src/load.ts", expectedCount: 1, public: true },
|
|
11843
|
+
{ id: "stable-computed-catch", scenarioId: "computed-method-scope", title: "Report a rejection through a stable computed method", outcome: "match", files: [{ path: "src/load.ts", source: "const method = 'catch'; Promise.reject(new Error('lost'))[method](() => null);" }], focusPath: "src/load.ts", expectedCount: 1, public: true },
|
|
11844
|
+
{ id: "stable-computed-body-parser", scenarioId: "computed-method-scope", title: "Preserve a recognized optional body parse fallback", outcome: "no-match", files: [{ path: "src/load.ts", source: "const method = 'json'; new Response('')[method]().catch(() => null);" }], focusPath: "src/load.ts", expectedCount: 0, public: true }
|
|
11497
11845
|
]
|
|
11498
11846
|
};
|
|
11499
11847
|
var BODY_PARSE_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -11541,9 +11889,11 @@ var ZOD_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
11541
11889
|
"superRefine",
|
|
11542
11890
|
"transform"
|
|
11543
11891
|
]);
|
|
11544
|
-
function isBodyParseCall(node) {
|
|
11892
|
+
function isBodyParseCall(node, sourceCode) {
|
|
11545
11893
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
11546
|
-
|
|
11894
|
+
if (node.type !== AST_NODE_TYPES56.CallExpression || node.arguments.length !== 0 || unwrappedNodeCallee?.type !== AST_NODE_TYPES56.MemberExpression) return false;
|
|
11895
|
+
const method = staticPropertyName(unwrappedNodeCallee, sourceCode);
|
|
11896
|
+
return method !== null && BODY_PARSE_METHODS.has(method);
|
|
11547
11897
|
}
|
|
11548
11898
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
11549
11899
|
"cancel",
|
|
@@ -11557,13 +11907,15 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
11557
11907
|
]);
|
|
11558
11908
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
11559
11909
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
11560
|
-
function isTeardownCall(node) {
|
|
11910
|
+
function isTeardownCall(node, sourceCode) {
|
|
11561
11911
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
11562
|
-
|
|
11912
|
+
if (node.type !== AST_NODE_TYPES56.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES56.MemberExpression) return false;
|
|
11913
|
+
const method = staticPropertyName(unwrappedNodeCallee, sourceCode);
|
|
11914
|
+
return method !== null && TEARDOWN_METHODS.has(method);
|
|
11563
11915
|
}
|
|
11564
|
-
function isCancelledWebShare(node) {
|
|
11916
|
+
function isCancelledWebShare(node, sourceCode) {
|
|
11565
11917
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
11566
|
-
return node.type === AST_NODE_TYPES56.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES56.MemberExpression && unwrappedNodeCallee.object.type === AST_NODE_TYPES56.Identifier && unwrappedNodeCallee.object.name === "navigator" &&
|
|
11918
|
+
return node.type === AST_NODE_TYPES56.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES56.MemberExpression && unwrappedNodeCallee.object.type === AST_NODE_TYPES56.Identifier && unwrappedNodeCallee.object.name === "navigator" && staticPropertyName(unwrappedNodeCallee, sourceCode) === "share";
|
|
11567
11919
|
}
|
|
11568
11920
|
function isSilentHandler(handler) {
|
|
11569
11921
|
const body2 = handler.body;
|
|
@@ -11622,16 +11974,16 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11622
11974
|
if (seen.has(node)) return false;
|
|
11623
11975
|
seen.add(node);
|
|
11624
11976
|
if (node.type === AST_NODE_TYPES56.Identifier) {
|
|
11625
|
-
const binding =
|
|
11977
|
+
const binding = ASTUtils31.findVariable(context.sourceCode.getScope(node), node.name);
|
|
11626
11978
|
if (binding === null || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
11627
11979
|
const [definition] = binding.defs;
|
|
11628
11980
|
return binding.defs.length === 1 && definition?.node.type === AST_NODE_TYPES56.VariableDeclarator && definition.node.init !== null && isZodSchema(definition.node.init, seen);
|
|
11629
11981
|
}
|
|
11630
|
-
if (node.type !== AST_NODE_TYPES56.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES56.MemberExpression
|
|
11982
|
+
if (node.type !== AST_NODE_TYPES56.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES56.MemberExpression) return false;
|
|
11631
11983
|
const { object } = unwrappedNodeCallee;
|
|
11632
|
-
const method =
|
|
11984
|
+
const method = staticPropertyName(unwrappedNodeCallee, context.sourceCode);
|
|
11633
11985
|
if (object.type === AST_NODE_TYPES56.Identifier && method !== null && ZOD_CONSTRUCTORS.has(method)) {
|
|
11634
|
-
const binding =
|
|
11986
|
+
const binding = ASTUtils31.findVariable(context.sourceCode.getScope(object), object.name);
|
|
11635
11987
|
if (binding?.defs.some((definition) => {
|
|
11636
11988
|
const specifier = definition.node;
|
|
11637
11989
|
return (specifier.type === AST_NODE_TYPES56.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES56.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES56.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES56.Identifier && specifier.imported.name === "z") && specifier.parent.type === AST_NODE_TYPES56.ImportDeclaration && isZodModule(String(specifier.parent.source.value));
|
|
@@ -11658,23 +12010,23 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11658
12010
|
return {
|
|
11659
12011
|
CallExpression(node) {
|
|
11660
12012
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
11661
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES56.MemberExpression
|
|
12013
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES56.MemberExpression) {
|
|
11662
12014
|
return;
|
|
11663
12015
|
}
|
|
11664
|
-
const method =
|
|
12016
|
+
const method = staticPropertyName(unwrappedNodeCallee, context.sourceCode);
|
|
11665
12017
|
const handlerIndex = method === "catch" ? 0 : method === "then" ? 1 : null;
|
|
11666
12018
|
if (handlerIndex === null) return;
|
|
11667
12019
|
if (method === "catch" && isZodSchema(unwrappedNodeCallee.object)) return;
|
|
11668
|
-
if (isBodyParseCall(unwrappedNodeCallee.object)) {
|
|
12020
|
+
if (isBodyParseCall(unwrappedNodeCallee.object, context.sourceCode)) {
|
|
11669
12021
|
return;
|
|
11670
12022
|
}
|
|
11671
|
-
if (isTeardownCall(unwrappedNodeCallee.object)) {
|
|
12023
|
+
if (isTeardownCall(unwrappedNodeCallee.object, context.sourceCode)) {
|
|
11672
12024
|
return;
|
|
11673
12025
|
}
|
|
11674
|
-
if (isCancelledWebShare(unwrappedNodeCallee.object)) {
|
|
12026
|
+
if (isCancelledWebShare(unwrappedNodeCallee.object, context.sourceCode)) {
|
|
11675
12027
|
return;
|
|
11676
12028
|
}
|
|
11677
|
-
if (node.parent.type === AST_NODE_TYPES56.MemberExpression && node.parent.object === node &&
|
|
12029
|
+
if (node.parent.type === AST_NODE_TYPES56.MemberExpression && node.parent.object === node && staticPropertyName(node.parent, context.sourceCode) === "then") {
|
|
11678
12030
|
return;
|
|
11679
12031
|
}
|
|
11680
12032
|
const expectedArguments = method === "catch" ? 1 : 2;
|
|
@@ -11699,7 +12051,7 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11699
12051
|
});
|
|
11700
12052
|
|
|
11701
12053
|
// src/rules/no-sleep-in-test-body.ts
|
|
11702
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES57, ASTUtils as
|
|
12054
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES57, ASTUtils as ASTUtils32 } from "@typescript-eslint/utils";
|
|
11703
12055
|
var NO_SLEEP_IN_TEST_BODY_DOCUMENTATION = {
|
|
11704
12056
|
summary: "Avoid fixed timed sleeps directly in test bodies; synchronize on observable behavior or use controlled timers.",
|
|
11705
12057
|
rationale: "Wall-clock delays make test correctness depend on scheduler and machine speed.",
|
|
@@ -11786,7 +12138,7 @@ function testCallerName(callee, source) {
|
|
|
11786
12138
|
return name !== null && TEST_CALLERS2.has(name) ? name : null;
|
|
11787
12139
|
}
|
|
11788
12140
|
if (callee.type === AST_NODE_TYPES57.MemberExpression) {
|
|
11789
|
-
const member =
|
|
12141
|
+
const member = ASTUtils32.getPropertyName(callee);
|
|
11790
12142
|
return member !== null && TEST_MODIFIERS3.has(member) ? testCallerName(callee.object, source) : null;
|
|
11791
12143
|
}
|
|
11792
12144
|
if (callee.type === AST_NODE_TYPES57.CallExpression) return testCallerName(callee.callee, source);
|
|
@@ -11824,8 +12176,8 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
11824
12176
|
return {
|
|
11825
12177
|
NewExpression(node) {
|
|
11826
12178
|
if (isPromiseSleep(node)) {
|
|
11827
|
-
const constructor =
|
|
11828
|
-
const timer =
|
|
12179
|
+
const constructor = ASTUtils32.findVariable(context.sourceCode.getScope(node), "Promise");
|
|
12180
|
+
const timer = ASTUtils32.findVariable(context.sourceCode.getScope(node), "setTimeout");
|
|
11829
12181
|
if ((constructor?.defs.length ?? 0) > 0 || (timer?.defs.length ?? 0) > 0) return;
|
|
11830
12182
|
report2(node);
|
|
11831
12183
|
}
|
|
@@ -11834,7 +12186,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
11834
12186
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
11835
12187
|
if (isHelperSleep(node)) {
|
|
11836
12188
|
if (unwrappedNodeCallee.type !== AST_NODE_TYPES57.Identifier) return;
|
|
11837
|
-
const variable =
|
|
12189
|
+
const variable = ASTUtils32.findVariable(context.sourceCode.getScope(node), unwrappedNodeCallee.name);
|
|
11838
12190
|
if (variable?.defs.some((definition) => definition.type !== "ImportBinding")) return;
|
|
11839
12191
|
report2(node);
|
|
11840
12192
|
}
|
|
@@ -11844,7 +12196,7 @@ var no_sleep_in_test_body_default = createRule({
|
|
|
11844
12196
|
});
|
|
11845
12197
|
|
|
11846
12198
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
11847
|
-
import { ASTUtils as
|
|
12199
|
+
import { ASTUtils as ASTUtils33, AST_NODE_TYPES as AST_NODE_TYPES58 } from "@typescript-eslint/utils";
|
|
11848
12200
|
var DEFAULT_METHODS2 = [
|
|
11849
12201
|
"prepare",
|
|
11850
12202
|
"put",
|
|
@@ -11879,7 +12231,7 @@ function storageMethodName(node, methods) {
|
|
|
11879
12231
|
const callee = unwrapExpression(node.callee);
|
|
11880
12232
|
const calleeReceiver = callee.type === AST_NODE_TYPES58.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
11881
12233
|
if (callee.type !== AST_NODE_TYPES58.MemberExpression) return null;
|
|
11882
|
-
const name =
|
|
12234
|
+
const name = ASTUtils33.getPropertyName(callee);
|
|
11883
12235
|
if (name === null || !methods.has(name)) {
|
|
11884
12236
|
return null;
|
|
11885
12237
|
}
|
|
@@ -11900,7 +12252,7 @@ function isStorageLikeReceiver(node) {
|
|
|
11900
12252
|
if (node.type !== AST_NODE_TYPES58.MemberExpression) {
|
|
11901
12253
|
return false;
|
|
11902
12254
|
}
|
|
11903
|
-
const name =
|
|
12255
|
+
const name = ASTUtils33.getPropertyName(node);
|
|
11904
12256
|
if (name !== null && isStorageIdentifier(name)) {
|
|
11905
12257
|
return true;
|
|
11906
12258
|
}
|
|
@@ -11979,7 +12331,7 @@ function hasSqlPreparationEvidence(node, callee) {
|
|
|
11979
12331
|
if (!/^\s*(?:SELECT|WITH|INSERT|UPDATE|DELETE|REPLACE|CREATE|ALTER|DROP|PRAGMA|EXPLAIN)\b/iu.test(stripSqlNoise(text))) return false;
|
|
11980
12332
|
} else {
|
|
11981
12333
|
const receiver = callee.object;
|
|
11982
|
-
const receiverName = receiver.type === AST_NODE_TYPES58.Identifier ? receiver.name : receiver.type === AST_NODE_TYPES58.MemberExpression ?
|
|
12334
|
+
const receiverName = receiver.type === AST_NODE_TYPES58.Identifier ? receiver.name : receiver.type === AST_NODE_TYPES58.MemberExpression ? ASTUtils33.getPropertyName(receiver) ?? "" : "";
|
|
11983
12335
|
if (!/^(?:db|database|connection)$/iu.test(receiverName)) return false;
|
|
11984
12336
|
}
|
|
11985
12337
|
return true;
|
|
@@ -12242,7 +12594,7 @@ var no_string_concat_in_loop_default = createRule({
|
|
|
12242
12594
|
});
|
|
12243
12595
|
|
|
12244
12596
|
// src/rules/no-duplicate-test-case.ts
|
|
12245
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES59, ASTUtils as
|
|
12597
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES59, ASTUtils as ASTUtils34 } from "@typescript-eslint/utils";
|
|
12246
12598
|
var TEST_MODULES = /* @__PURE__ */ new Set(["vitest", "@jest/globals", "bun:test"]);
|
|
12247
12599
|
var TEST_NAMES2 = /* @__PURE__ */ new Set(["it", "test"]);
|
|
12248
12600
|
var MODIFIERS = /* @__PURE__ */ new Set(["only", "skip", "concurrent", "fails", "failing", "todo"]);
|
|
@@ -12264,15 +12616,15 @@ var NO_DUPLICATE_TEST_CASE_DOCUMENTATION = {
|
|
|
12264
12616
|
};
|
|
12265
12617
|
function frameworkEach(node, sourceCode) {
|
|
12266
12618
|
let callee = unwrapExpression(node.callee);
|
|
12267
|
-
if (callee.type !== AST_NODE_TYPES59.MemberExpression ||
|
|
12619
|
+
if (callee.type !== AST_NODE_TYPES59.MemberExpression || ASTUtils34.getPropertyName(callee) !== "each") return false;
|
|
12268
12620
|
callee = unwrapExpression(callee.object);
|
|
12269
12621
|
while (callee.type === AST_NODE_TYPES59.MemberExpression) {
|
|
12270
|
-
const name =
|
|
12622
|
+
const name = ASTUtils34.getPropertyName(callee);
|
|
12271
12623
|
if (name === null || !MODIFIERS.has(name)) return false;
|
|
12272
12624
|
callee = unwrapExpression(callee.object);
|
|
12273
12625
|
}
|
|
12274
12626
|
if (callee.type !== AST_NODE_TYPES59.Identifier) return false;
|
|
12275
|
-
const variable =
|
|
12627
|
+
const variable = ASTUtils34.findVariable(sourceCode.getScope(callee), callee.name);
|
|
12276
12628
|
if (variable === null || variable.defs.length === 0) return TEST_NAMES2.has(callee.name);
|
|
12277
12629
|
return variable.defs.length === 1 && variable.defs.every((definition) => {
|
|
12278
12630
|
if (definition.node.type !== AST_NODE_TYPES59.ImportSpecifier) return false;
|
|
@@ -12285,7 +12637,7 @@ function table(node, sourceCode) {
|
|
|
12285
12637
|
node = unwrapExpression(node);
|
|
12286
12638
|
if (node.type === AST_NODE_TYPES59.ArrayExpression) return node;
|
|
12287
12639
|
if (node.type !== AST_NODE_TYPES59.Identifier) return null;
|
|
12288
|
-
const variable =
|
|
12640
|
+
const variable = ASTUtils34.findVariable(sourceCode.getScope(node), node.name);
|
|
12289
12641
|
const definition = variable?.defs[0];
|
|
12290
12642
|
if (variable?.defs.length !== 1 || definition?.node.type !== AST_NODE_TYPES59.VariableDeclarator || definition.node.id.type !== AST_NODE_TYPES59.Identifier || definition.node.parent.kind !== "const" || definition.node.init === null || definition.node.init.range[1] > node.range[0]) return null;
|
|
12291
12643
|
if (!variable.references.every((reference) => {
|
|
@@ -12366,7 +12718,7 @@ var no_duplicate_test_case_default = createRule({
|
|
|
12366
12718
|
});
|
|
12367
12719
|
|
|
12368
12720
|
// src/rules/no-tautological-expect.ts
|
|
12369
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES60, ASTUtils as
|
|
12721
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES60, ASTUtils as ASTUtils35 } from "@typescript-eslint/utils";
|
|
12370
12722
|
var NO_TAUTOLOGICAL_EXPECT_DOCUMENTATION = {
|
|
12371
12723
|
summary: "Disallow supported assertions known to pass from literals or immutable scalar setup.",
|
|
12372
12724
|
rationale: "An assertion determined entirely by literals does not observe the code under test and can keep passing after that code is removed.",
|
|
@@ -12433,7 +12785,7 @@ function resolveLiteral(node, sourceCode, seen = /* @__PURE__ */ new Set()) {
|
|
|
12433
12785
|
if (isLiteral(node)) return node;
|
|
12434
12786
|
if (node.type !== AST_NODE_TYPES60.Identifier || seen.has(node)) return null;
|
|
12435
12787
|
seen.add(node);
|
|
12436
|
-
const variable =
|
|
12788
|
+
const variable = ASTUtils35.findVariable(sourceCode.getScope(node), node.name);
|
|
12437
12789
|
if (variable?.defs.length !== 1) return null;
|
|
12438
12790
|
const definition = variable.defs[0];
|
|
12439
12791
|
if (definition?.node.type !== AST_NODE_TYPES60.VariableDeclarator || definition.node.id.type !== AST_NODE_TYPES60.Identifier || definition.node.parent.kind !== "const" || definition.node.init === null || definition.node.init.range[1] > node.range[0] || variable.references.some((reference) => reference.isWrite() && !reference.init)) return null;
|
|
@@ -12533,13 +12885,13 @@ var no_tautological_expect_default = createRule({
|
|
|
12533
12885
|
CallExpression(node) {
|
|
12534
12886
|
const callee = unwrapExpression(node.callee);
|
|
12535
12887
|
if (callee.type !== AST_NODE_TYPES60.MemberExpression) return;
|
|
12536
|
-
const matcher =
|
|
12888
|
+
const matcher = ASTUtils35.getPropertyName(callee);
|
|
12537
12889
|
if (matcher === null) return;
|
|
12538
12890
|
const receiver = unwrapExpression(callee.object);
|
|
12539
12891
|
if (receiver.type !== AST_NODE_TYPES60.CallExpression) return;
|
|
12540
12892
|
const expectIdentifier = unwrapExpression(receiver.callee);
|
|
12541
12893
|
if (expectIdentifier.type !== AST_NODE_TYPES60.Identifier) return;
|
|
12542
|
-
const variable =
|
|
12894
|
+
const variable = ASTUtils35.findVariable(context.sourceCode.getScope(expectIdentifier), expectIdentifier.name);
|
|
12543
12895
|
if (variable !== null && variable.defs.some((definition) => {
|
|
12544
12896
|
if (definition.node.type !== AST_NODE_TYPES60.ImportSpecifier) return true;
|
|
12545
12897
|
const declaration = definition.node.parent;
|
|
@@ -13789,7 +14141,7 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
13789
14141
|
// src/rules/no-unsafe-mock-casting.ts
|
|
13790
14142
|
import {
|
|
13791
14143
|
AST_NODE_TYPES as AST_NODE_TYPES66,
|
|
13792
|
-
ASTUtils as
|
|
14144
|
+
ASTUtils as ASTUtils36
|
|
13793
14145
|
} from "@typescript-eslint/utils";
|
|
13794
14146
|
var MOCK_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
13795
14147
|
"Mock",
|
|
@@ -13856,7 +14208,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
13856
14208
|
const directBindings = /* @__PURE__ */ new Set();
|
|
13857
14209
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
13858
14210
|
function resolve2(identifier) {
|
|
13859
|
-
return
|
|
14211
|
+
return ASTUtils36.findVariable(
|
|
13860
14212
|
context.sourceCode.getScope(identifier),
|
|
13861
14213
|
identifier.name
|
|
13862
14214
|
);
|
|
@@ -13903,7 +14255,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
13903
14255
|
});
|
|
13904
14256
|
|
|
13905
14257
|
// src/rules/no-unsafe-test-double-cast.ts
|
|
13906
|
-
import { ASTUtils as
|
|
14258
|
+
import { ASTUtils as ASTUtils37, AST_NODE_TYPES as AST_NODE_TYPES67 } from "@typescript-eslint/utils";
|
|
13907
14259
|
var NO_UNSAFE_TEST_DOUBLE_CAST_DOCUMENTATION = {
|
|
13908
14260
|
summary: "Disallow mock-backed test doubles that bypass collaborator contracts through double assertions.",
|
|
13909
14261
|
rationale: "Casting a partial object through unknown hides missing or stale collaborator members, so production interface changes can compile while the test double silently drifts.",
|
|
@@ -13933,7 +14285,7 @@ function isMockFactory(node, source) {
|
|
|
13933
14285
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
13934
14286
|
if (node.type !== AST_NODE_TYPES67.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES67.MemberExpression) return false;
|
|
13935
14287
|
const receiver = unwrapExpression(unwrappedNodeCallee.object);
|
|
13936
|
-
return node.type === AST_NODE_TYPES67.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES67.MemberExpression && receiver.type === AST_NODE_TYPES67.Identifier && (importedTestMockNamespace(source, receiver) !== null || isUnshadowedTestMockGlobal(source, receiver)) &&
|
|
14288
|
+
return node.type === AST_NODE_TYPES67.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES67.MemberExpression && receiver.type === AST_NODE_TYPES67.Identifier && (importedTestMockNamespace(source, receiver) !== null || isUnshadowedTestMockGlobal(source, receiver)) && ASTUtils37.getPropertyName(unwrappedNodeCallee) !== null && ["fn", "spyOn"].includes(ASTUtils37.getPropertyName(unwrappedNodeCallee) ?? "");
|
|
13937
14289
|
}
|
|
13938
14290
|
var no_unsafe_test_double_cast_default = createRule({
|
|
13939
14291
|
name: "no-unsafe-test-double-cast",
|
|
@@ -13959,7 +14311,7 @@ var no_unsafe_test_double_cast_default = createRule({
|
|
|
13959
14311
|
});
|
|
13960
14312
|
|
|
13961
14313
|
// src/rules/no-first-party-module-mock.ts
|
|
13962
|
-
import { ASTUtils as
|
|
14314
|
+
import { ASTUtils as ASTUtils38, AST_NODE_TYPES as AST_NODE_TYPES68 } from "@typescript-eslint/utils";
|
|
13963
14315
|
var NO_FIRST_PARTY_MODULE_MOCK_DOCUMENTATION = {
|
|
13964
14316
|
summary: "Prefer injected collaborators over mocking maintained first-party modules in tests.",
|
|
13965
14317
|
rationale: "Replacing an owned module couples tests to its lookup path and can verify mock wiring while bypassing the real implementation contract.",
|
|
@@ -13990,7 +14342,7 @@ var no_first_party_module_mock_default = createRule({
|
|
|
13990
14342
|
CallExpression(node) {
|
|
13991
14343
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
13992
14344
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES68.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
13993
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES68.MemberExpression || receiver.type !== AST_NODE_TYPES68.Identifier ||
|
|
14345
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES68.MemberExpression || receiver.type !== AST_NODE_TYPES68.Identifier || ASTUtils38.getPropertyName(unwrappedNodeCallee) === null || !["mock", "doMock"].includes(ASTUtils38.getPropertyName(unwrappedNodeCallee) ?? "")) return;
|
|
13994
14346
|
const framework = importedTestMockNamespace(context.sourceCode, receiver);
|
|
13995
14347
|
if (framework === null || framework === "jest" && mayBeVirtual(node.arguments[2])) return;
|
|
13996
14348
|
const argument = node.arguments[0] === void 0 ? void 0 : unwrapExpression(node.arguments[0]);
|
|
@@ -14016,7 +14368,7 @@ function mayBeVirtual(options) {
|
|
|
14016
14368
|
import {
|
|
14017
14369
|
ESLintUtils as ESLintUtils10,
|
|
14018
14370
|
AST_NODE_TYPES as AST_NODE_TYPES69,
|
|
14019
|
-
ASTUtils as
|
|
14371
|
+
ASTUtils as ASTUtils39
|
|
14020
14372
|
} from "@typescript-eslint/utils";
|
|
14021
14373
|
import * as ts9 from "typescript";
|
|
14022
14374
|
var NO_ZOD_NATIVE_ENUM_DOCUMENTATION = {
|
|
@@ -14123,7 +14475,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
14123
14475
|
const zodImportedBindings = /* @__PURE__ */ new Map();
|
|
14124
14476
|
const zodNamespaceBindings = /* @__PURE__ */ new Set();
|
|
14125
14477
|
function resolvedBinding(identifier) {
|
|
14126
|
-
return
|
|
14478
|
+
return ASTUtils39.findVariable(
|
|
14127
14479
|
sourceCode.getScope(identifier),
|
|
14128
14480
|
identifier.name
|
|
14129
14481
|
);
|
|
@@ -14131,7 +14483,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
14131
14483
|
function isZodMemberCall(node, api) {
|
|
14132
14484
|
const callee = unwrapExpression(node.callee);
|
|
14133
14485
|
const calleeReceiver = callee.type === AST_NODE_TYPES69.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
14134
|
-
if (callee.type === AST_NODE_TYPES69.MemberExpression && calleeReceiver.type === AST_NODE_TYPES69.Identifier &&
|
|
14486
|
+
if (callee.type === AST_NODE_TYPES69.MemberExpression && calleeReceiver.type === AST_NODE_TYPES69.Identifier && ASTUtils39.getPropertyName(callee) === api) {
|
|
14135
14487
|
const binding = resolvedBinding(calleeReceiver);
|
|
14136
14488
|
return binding !== null && zodNamespaceBindings.has(binding);
|
|
14137
14489
|
}
|
|
@@ -14190,7 +14542,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
14190
14542
|
});
|
|
14191
14543
|
|
|
14192
14544
|
// src/rules/test-loops-over-literal-cases.ts
|
|
14193
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES70, ASTUtils as
|
|
14545
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES70, ASTUtils as ASTUtils40 } from "@typescript-eslint/utils";
|
|
14194
14546
|
var TEST_LOOPS_OVER_LITERAL_CASES_DOCUMENTATION = {
|
|
14195
14547
|
summary: "Disallow assertions over an inline literal case loop in a test; parameterization reports and names every case independently.",
|
|
14196
14548
|
rationale: "A loop is reported as one test, so failures hide the individual case name and may stop later cases from running.",
|
|
@@ -14343,7 +14695,7 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
14343
14695
|
}
|
|
14344
14696
|
const capturesSetup = walkOwnScope2(node.body, (current) => {
|
|
14345
14697
|
if (current.type !== AST_NODE_TYPES70.Identifier) return false;
|
|
14346
|
-
const variable =
|
|
14698
|
+
const variable = ASTUtils40.findVariable(context.sourceCode.getScope(current), current.name);
|
|
14347
14699
|
if (variable === null || !variable.references.some((reference) => reference.identifier === current)) return false;
|
|
14348
14700
|
return variable.defs.some((definition) => {
|
|
14349
14701
|
const declaration = definition.name;
|
|
@@ -14797,7 +15149,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
14797
15149
|
});
|
|
14798
15150
|
|
|
14799
15151
|
// src/rules/prefer-input-group-search.ts
|
|
14800
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES75, ASTUtils as
|
|
15152
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES75, ASTUtils as ASTUtils41 } from "@typescript-eslint/utils";
|
|
14801
15153
|
var PREFER_INPUT_GROUP_SEARCH_DOCUMENTATION = {
|
|
14802
15154
|
summary: "Require search icons and shared Input controls in the same visual wrapper to use InputGroup.",
|
|
14803
15155
|
rationale: "The shared compound control provides consistent spacing, focus behavior, and accessible composition.",
|
|
@@ -14921,7 +15273,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
14921
15273
|
JSXOpeningElement(node) {
|
|
14922
15274
|
const name = elementName(node);
|
|
14923
15275
|
if (name === null) return;
|
|
14924
|
-
const binding =
|
|
15276
|
+
const binding = ASTUtils41.findVariable(context.sourceCode.getScope(node), name);
|
|
14925
15277
|
if (binding?.defs.length !== 1 || binding.defs[0]?.node.type !== AST_NODE_TYPES75.ImportSpecifier || binding.defs[0].node.importKind === "type") return;
|
|
14926
15278
|
const occurrence = {
|
|
14927
15279
|
ancestors: context.sourceCode.getAncestors(node),
|
|
@@ -14961,7 +15313,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
14961
15313
|
|
|
14962
15314
|
// src/rules/prefer-millisecond-control-duration-schema.ts
|
|
14963
15315
|
import {
|
|
14964
|
-
ASTUtils as
|
|
15316
|
+
ASTUtils as ASTUtils42,
|
|
14965
15317
|
AST_NODE_TYPES as AST_NODE_TYPES77
|
|
14966
15318
|
} from "@typescript-eslint/utils";
|
|
14967
15319
|
|
|
@@ -15040,7 +15392,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
15040
15392
|
const objectFactories = /* @__PURE__ */ new Set();
|
|
15041
15393
|
const numberFactories = /* @__PURE__ */ new Set();
|
|
15042
15394
|
function binding(identifier) {
|
|
15043
|
-
return
|
|
15395
|
+
return ASTUtils42.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
15044
15396
|
}
|
|
15045
15397
|
function record(target, identifier) {
|
|
15046
15398
|
const variable = binding(identifier);
|
|
@@ -15053,7 +15405,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
15053
15405
|
const variable2 = binding(callee);
|
|
15054
15406
|
return variable2 !== null && objectFactories.has(variable2);
|
|
15055
15407
|
}
|
|
15056
|
-
if (callee.type !== AST_NODE_TYPES77.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES77.Identifier ||
|
|
15408
|
+
if (callee.type !== AST_NODE_TYPES77.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES77.Identifier || ASTUtils42.getPropertyName(callee) === null || (ASTUtils42.getPropertyName(callee) ?? "") !== "object" && (ASTUtils42.getPropertyName(callee) ?? "") !== "strictObject") {
|
|
15057
15409
|
return false;
|
|
15058
15410
|
}
|
|
15059
15411
|
const variable = binding(calleeReceiver);
|
|
@@ -15068,12 +15420,12 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
15068
15420
|
const variable = binding(callee);
|
|
15069
15421
|
return variable !== null && numberFactories.has(variable);
|
|
15070
15422
|
}
|
|
15071
|
-
if (callee.type !== AST_NODE_TYPES77.MemberExpression ||
|
|
15423
|
+
if (callee.type !== AST_NODE_TYPES77.MemberExpression || ASTUtils42.getPropertyName(callee) === null) return false;
|
|
15072
15424
|
if (calleeReceiver.type === AST_NODE_TYPES77.Identifier) {
|
|
15073
15425
|
const variable = binding(calleeReceiver);
|
|
15074
|
-
return (
|
|
15426
|
+
return (ASTUtils42.getPropertyName(callee) ?? "") === "number" && variable !== null && zodNamespaces.has(variable);
|
|
15075
15427
|
}
|
|
15076
|
-
return ["int", "min", "max", "positive", "nonnegative", "finite", "multipleOf", "optional", "nullable", "nullish", "default", "describe", "brand", "readonly"].includes(
|
|
15428
|
+
return ["int", "min", "max", "positive", "nonnegative", "finite", "multipleOf", "optional", "nullable", "nullish", "default", "describe", "brand", "readonly"].includes(ASTUtils42.getPropertyName(callee) ?? "") && isNumericSchema(calleeReceiver);
|
|
15077
15429
|
}
|
|
15078
15430
|
return {
|
|
15079
15431
|
ImportDeclaration(node) {
|
|
@@ -15106,7 +15458,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
15106
15458
|
});
|
|
15107
15459
|
|
|
15108
15460
|
// src/rules/prefer-immutable-module-constant.ts
|
|
15109
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES78, ASTUtils as
|
|
15461
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES78, ASTUtils as ASTUtils43 } from "@typescript-eslint/utils";
|
|
15110
15462
|
var PREFER_IMMUTABLE_MODULE_CONSTANT_DOCUMENTATION = {
|
|
15111
15463
|
summary: "Require module-level constant collections to expose readonly state.",
|
|
15112
15464
|
rationale: "A const binding prevents reassignment but does not stop callers from mutating its array, object, Set, or Map contents.",
|
|
@@ -15325,15 +15677,15 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
15325
15677
|
create(context) {
|
|
15326
15678
|
const sourceCode = context.sourceCode;
|
|
15327
15679
|
const isUnshadowedGlobal3 = (identifier) => {
|
|
15328
|
-
const variable =
|
|
15680
|
+
const variable = ASTUtils43.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
15329
15681
|
return variable === null || variable.defs.length === 0;
|
|
15330
15682
|
};
|
|
15331
15683
|
const isUnshadowedType = (identifier) => {
|
|
15332
|
-
const variable =
|
|
15684
|
+
const variable = ASTUtils43.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
15333
15685
|
return variable === null || !variable.defs.some((definition) => definition.isTypeDefinition);
|
|
15334
15686
|
};
|
|
15335
15687
|
const resolveLocalType = (identifier) => {
|
|
15336
|
-
const variable =
|
|
15688
|
+
const variable = ASTUtils43.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
15337
15689
|
const definitions = variable?.defs.filter((definition) => definition.isTypeDefinition) ?? [];
|
|
15338
15690
|
const declaration = definitions.length === 1 ? definitions[0]?.node : void 0;
|
|
15339
15691
|
return declaration?.type === AST_NODE_TYPES78.TSTypeAliasDeclaration || declaration?.type === AST_NODE_TYPES78.TSTypeParameter ? declaration : void 0;
|
|
@@ -15827,7 +16179,7 @@ function matchingAliasTargets(paths, alias) {
|
|
|
15827
16179
|
}
|
|
15828
16180
|
|
|
15829
16181
|
// src/rules/prefer-module-level-constant.ts
|
|
15830
|
-
import { ASTUtils as
|
|
16182
|
+
import { ASTUtils as ASTUtils44, AST_NODE_TYPES as AST_NODE_TYPES80 } from "@typescript-eslint/utils";
|
|
15831
16183
|
var PREFER_MODULE_LEVEL_CONSTANT_DOCUMENTATION = {
|
|
15832
16184
|
summary: "Hoist literal-only constant collections and regexes out of function bodies to module scope so they are allocated once.",
|
|
15833
16185
|
rationale: "Recreating immutable lookup data on every call wastes allocations and obscures its constant nature.",
|
|
@@ -15955,7 +16307,7 @@ function classify(init, checkRegex, sourceCode) {
|
|
|
15955
16307
|
function unwrapObjectFreeze(node, sourceCode) {
|
|
15956
16308
|
const inner = unwrap3(node);
|
|
15957
16309
|
const callee = inner.type === AST_NODE_TYPES80.CallExpression ? unwrapExpression(inner.callee) : null;
|
|
15958
|
-
if (inner.type === AST_NODE_TYPES80.CallExpression && callee?.type === AST_NODE_TYPES80.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES80.Identifier && callee.object.name === "Object" && (
|
|
16310
|
+
if (inner.type === AST_NODE_TYPES80.CallExpression && callee?.type === AST_NODE_TYPES80.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES80.Identifier && callee.object.name === "Object" && (ASTUtils44.findVariable(sourceCode.getScope(callee.object), "Object")?.defs.length ?? 0) === 0 && callee.property.type === AST_NODE_TYPES80.Identifier && callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES80.SpreadElement) {
|
|
15959
16311
|
return unwrap3(inner.arguments[0]);
|
|
15960
16312
|
}
|
|
15961
16313
|
return inner;
|
|
@@ -16154,14 +16506,14 @@ function isSafeMemberRead(identifier, parent) {
|
|
|
16154
16506
|
if (grandparent.type === AST_NODE_TYPES80.UnaryExpression && grandparent.operator === "delete") {
|
|
16155
16507
|
return false;
|
|
16156
16508
|
}
|
|
16157
|
-
if (grandparent.type === AST_NODE_TYPES80.CallExpression && grandparent.callee === usage && (
|
|
16509
|
+
if (grandparent.type === AST_NODE_TYPES80.CallExpression && grandparent.callee === usage && (ASTUtils44.getPropertyName(parent) === null || MUTATING_METHODS2.has(ASTUtils44.getPropertyName(parent) ?? ""))) {
|
|
16158
16510
|
return false;
|
|
16159
16511
|
}
|
|
16160
16512
|
return true;
|
|
16161
16513
|
}
|
|
16162
16514
|
|
|
16163
16515
|
// src/rules/prefer-module-level-schema.ts
|
|
16164
|
-
import { ASTUtils as
|
|
16516
|
+
import { ASTUtils as ASTUtils45, AST_NODE_TYPES as AST_NODE_TYPES81 } from "@typescript-eslint/utils";
|
|
16165
16517
|
var PREFER_MODULE_LEVEL_SCHEMA_DOCUMENTATION = {
|
|
16166
16518
|
summary: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function",
|
|
16167
16519
|
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.",
|
|
@@ -16269,7 +16621,7 @@ function schemaExpression(node) {
|
|
|
16269
16621
|
if (parent === void 0) {
|
|
16270
16622
|
return current;
|
|
16271
16623
|
}
|
|
16272
|
-
if (parent.type === AST_NODE_TYPES81.MemberExpression && parent.object === current &&
|
|
16624
|
+
if (parent.type === AST_NODE_TYPES81.MemberExpression && parent.object === current && ASTUtils45.getPropertyName(parent) !== null && TERMINAL_METHODS.has(ASTUtils45.getPropertyName(parent) ?? "")) {
|
|
16273
16625
|
return current;
|
|
16274
16626
|
}
|
|
16275
16627
|
if (parent.type === AST_NODE_TYPES81.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES81.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES81.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES81.TSNonNullExpression && parent.expression === current) {
|
|
@@ -16407,14 +16759,14 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16407
16759
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
16408
16760
|
if (node.type !== AST_NODE_TYPES81.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES81.MemberExpression) return false;
|
|
16409
16761
|
const receiver = unwrapExpression(unwrappedNodeCallee.object);
|
|
16410
|
-
return node.type === AST_NODE_TYPES81.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES81.MemberExpression &&
|
|
16762
|
+
return node.type === AST_NODE_TYPES81.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES81.MemberExpression && ASTUtils45.getPropertyName(unwrappedNodeCallee) !== null && receiver.type === AST_NODE_TYPES81.Identifier && zodNamespaces.has(receiver.name);
|
|
16411
16763
|
}
|
|
16412
16764
|
function isSchemaConstruction(node) {
|
|
16413
16765
|
const callee = unwrapExpression(node.callee);
|
|
16414
16766
|
const calleeReceiver = callee.type === AST_NODE_TYPES81.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
16415
|
-
if (callee.type !== AST_NODE_TYPES81.MemberExpression ||
|
|
16767
|
+
if (callee.type !== AST_NODE_TYPES81.MemberExpression || ASTUtils45.getPropertyName(callee) === null || TERMINAL_METHODS.has(ASTUtils45.getPropertyName(callee) ?? "")) return false;
|
|
16416
16768
|
if (calleeReceiver.type === AST_NODE_TYPES81.CallExpression) return isSchemaConstruction(calleeReceiver);
|
|
16417
|
-
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(
|
|
16769
|
+
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(ASTUtils45.getPropertyName(callee) ?? "");
|
|
16418
16770
|
}
|
|
16419
16771
|
function hasEagerComputation(node) {
|
|
16420
16772
|
return subtreeSome(node, (inner) => inner.type === AST_NODE_TYPES81.NewExpression || inner.type === AST_NODE_TYPES81.TaggedTemplateExpression || inner.type === AST_NODE_TYPES81.CallExpression && !isSchemaConstruction(inner), true);
|
|
@@ -16422,10 +16774,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16422
16774
|
function isCovered(node) {
|
|
16423
16775
|
let current = node.parent ?? void 0;
|
|
16424
16776
|
while (current !== void 0) {
|
|
16425
|
-
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES81.MemberExpression &&
|
|
16777
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES81.MemberExpression && ASTUtils45.getPropertyName(current.callee) !== null && factories.has(ASTUtils45.getPropertyName(current.callee) ?? "")) {
|
|
16426
16778
|
return true;
|
|
16427
16779
|
}
|
|
16428
|
-
if (current.type === AST_NODE_TYPES81.CallExpression && (current.callee.type === AST_NODE_TYPES81.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES81.MemberExpression &&
|
|
16780
|
+
if (current.type === AST_NODE_TYPES81.CallExpression && (current.callee.type === AST_NODE_TYPES81.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES81.MemberExpression && ASTUtils45.getPropertyName(current.callee) !== null && memoCallees.has(ASTUtils45.getPropertyName(current.callee) ?? ""))) {
|
|
16429
16781
|
return true;
|
|
16430
16782
|
}
|
|
16431
16783
|
current = current.parent ?? void 0;
|
|
@@ -16454,7 +16806,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16454
16806
|
}
|
|
16455
16807
|
function isSchemaComposition(node) {
|
|
16456
16808
|
const callee = unwrapExpression(node.callee);
|
|
16457
|
-
const isCombinator = callee.type === AST_NODE_TYPES81.MemberExpression &&
|
|
16809
|
+
const isCombinator = callee.type === AST_NODE_TYPES81.MemberExpression && ASTUtils45.getPropertyName(callee) !== null && ZOD_COMBINATOR_METHODS.has(ASTUtils45.getPropertyName(callee) ?? "");
|
|
16458
16810
|
return isCombinator || isZodCall(node);
|
|
16459
16811
|
}
|
|
16460
16812
|
function closesOverNothing(node, enclosing) {
|
|
@@ -16527,10 +16879,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16527
16879
|
return;
|
|
16528
16880
|
}
|
|
16529
16881
|
const callee = unwrappedNodeCallee;
|
|
16530
|
-
if (
|
|
16882
|
+
if (ASTUtils45.getPropertyName(callee) === null) {
|
|
16531
16883
|
return;
|
|
16532
16884
|
}
|
|
16533
|
-
const factory =
|
|
16885
|
+
const factory = ASTUtils45.getPropertyName(callee) ?? "";
|
|
16534
16886
|
if (!factories.has(factory)) {
|
|
16535
16887
|
return;
|
|
16536
16888
|
}
|
|
@@ -16573,7 +16925,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
16573
16925
|
// src/rules/prefer-module-level-refined-schema.ts
|
|
16574
16926
|
import {
|
|
16575
16927
|
AST_NODE_TYPES as AST_NODE_TYPES82,
|
|
16576
|
-
ASTUtils as
|
|
16928
|
+
ASTUtils as ASTUtils46
|
|
16577
16929
|
} from "@typescript-eslint/utils";
|
|
16578
16930
|
var BENCHMARK_PATH_RE = /(^|[/\\])(?:benchmarks?|bench)[/\\]/;
|
|
16579
16931
|
var FACTORIES = /* @__PURE__ */ new Set([
|
|
@@ -16800,9 +17152,9 @@ function chainMemberNames(node) {
|
|
|
16800
17152
|
for (; ; ) {
|
|
16801
17153
|
current = unwrapExpression(current);
|
|
16802
17154
|
if (current.type === AST_NODE_TYPES82.MemberExpression) {
|
|
16803
|
-
if (
|
|
17155
|
+
if (ASTUtils46.getPropertyName(current) === null)
|
|
16804
17156
|
return [];
|
|
16805
|
-
names.push(
|
|
17157
|
+
names.push(ASTUtils46.getPropertyName(current) ?? "");
|
|
16806
17158
|
current = current.object;
|
|
16807
17159
|
continue;
|
|
16808
17160
|
}
|
|
@@ -16819,8 +17171,8 @@ function schemaExpression2(node) {
|
|
|
16819
17171
|
let current = node;
|
|
16820
17172
|
for (; ; ) {
|
|
16821
17173
|
const parent = current.parent ?? void 0;
|
|
16822
|
-
if (parent?.type === AST_NODE_TYPES82.MemberExpression && parent.object === current &&
|
|
16823
|
-
if (NON_SCHEMA_TERMINALS.has(
|
|
17174
|
+
if (parent?.type === AST_NODE_TYPES82.MemberExpression && parent.object === current && ASTUtils46.getPropertyName(parent) !== null && parent.parent?.type === AST_NODE_TYPES82.CallExpression && parent.parent.callee === parent) {
|
|
17175
|
+
if (NON_SCHEMA_TERMINALS.has(ASTUtils46.getPropertyName(parent) ?? "")) return current;
|
|
16824
17176
|
current = parent.parent;
|
|
16825
17177
|
continue;
|
|
16826
17178
|
}
|
|
@@ -16850,7 +17202,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16850
17202
|
return {};
|
|
16851
17203
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
16852
17204
|
function resolvedBinding(identifier) {
|
|
16853
|
-
return
|
|
17205
|
+
return ASTUtils46.findVariable(
|
|
16854
17206
|
context.sourceCode.getScope(identifier),
|
|
16855
17207
|
identifier.name
|
|
16856
17208
|
);
|
|
@@ -16876,7 +17228,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16876
17228
|
function isSchemaConstruction(node) {
|
|
16877
17229
|
const callee = unwrapExpression(node.callee);
|
|
16878
17230
|
const calleeReceiver = callee.type === AST_NODE_TYPES82.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
16879
|
-
if (callee.type !== AST_NODE_TYPES82.MemberExpression ||
|
|
17231
|
+
if (callee.type !== AST_NODE_TYPES82.MemberExpression || ASTUtils46.getPropertyName(callee) === null || NON_SCHEMA_TERMINALS.has(ASTUtils46.getPropertyName(callee) ?? "")) return false;
|
|
16880
17232
|
if (calleeReceiver.type === AST_NODE_TYPES82.CallExpression) return isSchemaConstruction(calleeReceiver);
|
|
16881
17233
|
return factoryName(node, FACTORIES) !== null || factoryName(node, COMPOSITE_FACTORIES) !== null;
|
|
16882
17234
|
}
|
|
@@ -16903,7 +17255,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16903
17255
|
function isMemoized(node) {
|
|
16904
17256
|
let current = node.parent ?? void 0;
|
|
16905
17257
|
while (current !== void 0) {
|
|
16906
|
-
if (current.type === AST_NODE_TYPES82.CallExpression && (current.callee.type === AST_NODE_TYPES82.Identifier && MEMO_CALLEES2.has(current.callee.name) || current.callee.type === AST_NODE_TYPES82.MemberExpression &&
|
|
17258
|
+
if (current.type === AST_NODE_TYPES82.CallExpression && (current.callee.type === AST_NODE_TYPES82.Identifier && MEMO_CALLEES2.has(current.callee.name) || current.callee.type === AST_NODE_TYPES82.MemberExpression && ASTUtils46.getPropertyName(current.callee) !== null && MEMO_CALLEES2.has(ASTUtils46.getPropertyName(current.callee) ?? "")))
|
|
16907
17259
|
return true;
|
|
16908
17260
|
current = current.parent ?? void 0;
|
|
16909
17261
|
}
|
|
@@ -16966,7 +17318,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
16966
17318
|
// src/rules/prefer-multi-value-zod-literal.ts
|
|
16967
17319
|
import {
|
|
16968
17320
|
AST_NODE_TYPES as AST_NODE_TYPES83,
|
|
16969
|
-
ASTUtils as
|
|
17321
|
+
ASTUtils as ASTUtils47
|
|
16970
17322
|
} from "@typescript-eslint/utils";
|
|
16971
17323
|
var PREFER_MULTI_VALUE_ZOD_LITERAL_DOCUMENTATION = {
|
|
16972
17324
|
defaultLevel: "warning",
|
|
@@ -17015,7 +17367,7 @@ function isStaticPrimitive(node, context) {
|
|
|
17015
17367
|
if (node.type === AST_NODE_TYPES83.TemplateLiteral && node.expressions.length === 0)
|
|
17016
17368
|
return true;
|
|
17017
17369
|
if (node.type === AST_NODE_TYPES83.Identifier && node.name === "undefined") {
|
|
17018
|
-
const binding =
|
|
17370
|
+
const binding = ASTUtils47.findVariable(
|
|
17019
17371
|
context.sourceCode.getScope(node),
|
|
17020
17372
|
node.name
|
|
17021
17373
|
);
|
|
@@ -17053,7 +17405,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
17053
17405
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
17054
17406
|
const zod4Bindings = /* @__PURE__ */ new Set();
|
|
17055
17407
|
function resolvedBinding(identifier) {
|
|
17056
|
-
return
|
|
17408
|
+
return ASTUtils47.findVariable(
|
|
17057
17409
|
context.sourceCode.getScope(identifier),
|
|
17058
17410
|
identifier.name
|
|
17059
17411
|
);
|
|
@@ -17061,7 +17413,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
17061
17413
|
function directMemberCall(node, binding, method) {
|
|
17062
17414
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
17063
17415
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES83.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
17064
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES83.MemberExpression || receiver.type !== AST_NODE_TYPES83.Identifier ||
|
|
17416
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES83.MemberExpression || receiver.type !== AST_NODE_TYPES83.Identifier || ASTUtils47.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils47.getPropertyName(unwrappedNodeCallee) ?? "") !== method)
|
|
17065
17417
|
return false;
|
|
17066
17418
|
return resolvedBinding(receiver) === binding;
|
|
17067
17419
|
}
|
|
@@ -17111,7 +17463,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
17111
17463
|
});
|
|
17112
17464
|
|
|
17113
17465
|
// src/rules/prefer-nominal-id-types.ts
|
|
17114
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES84, ASTUtils as
|
|
17466
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES84, ASTUtils as ASTUtils48 } from "@typescript-eslint/utils";
|
|
17115
17467
|
var OPERATIONAL_ROLES = /* @__PURE__ */ new Set([
|
|
17116
17468
|
"request",
|
|
17117
17469
|
"trace",
|
|
@@ -17149,7 +17501,7 @@ function isNullish(node) {
|
|
|
17149
17501
|
}
|
|
17150
17502
|
function referenceCarrier(node, context, depth) {
|
|
17151
17503
|
if (node.typeName.type !== AST_NODE_TYPES84.Identifier) return void 0;
|
|
17152
|
-
const variable =
|
|
17504
|
+
const variable = ASTUtils48.findVariable(context.sourceCode.getScope(node), node.typeName.name);
|
|
17153
17505
|
const definitions = variable?.defs ?? [];
|
|
17154
17506
|
const args = node.typeArguments?.params;
|
|
17155
17507
|
if (definitions.length === 0 && ["Array", "ReadonlyArray"].includes(node.typeName.name) && args?.length === 1) {
|
|
@@ -17347,7 +17699,7 @@ var prefer_named_complex_return_type_default = createRule({
|
|
|
17347
17699
|
});
|
|
17348
17700
|
|
|
17349
17701
|
// src/rules/prefer-native-random-uuid.ts
|
|
17350
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES87, ASTUtils as
|
|
17702
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES87, ASTUtils as ASTUtils49 } from "@typescript-eslint/utils";
|
|
17351
17703
|
var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
|
|
17352
17704
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
17353
17705
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -17383,14 +17735,14 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
17383
17735
|
const directBindings = /* @__PURE__ */ new Set();
|
|
17384
17736
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
17385
17737
|
function resolve2(identifier) {
|
|
17386
|
-
return
|
|
17738
|
+
return ASTUtils49.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
17387
17739
|
}
|
|
17388
17740
|
function record(identifier, destination) {
|
|
17389
17741
|
const variable = resolve2(identifier);
|
|
17390
17742
|
if (variable !== null) destination.add(variable);
|
|
17391
17743
|
}
|
|
17392
17744
|
function report2(node) {
|
|
17393
|
-
const globalBinding =
|
|
17745
|
+
const globalBinding = ASTUtils49.findVariable(context.sourceCode.getScope(node), "globalThis");
|
|
17394
17746
|
const canSuggest = (globalBinding?.defs.length ?? 0) === 0 && context.sourceCode.getCommentsInside(node).length === 0;
|
|
17395
17747
|
context.report({
|
|
17396
17748
|
node,
|
|
@@ -17449,7 +17801,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
17449
17801
|
});
|
|
17450
17802
|
|
|
17451
17803
|
// src/rules/prefer-node-crypto-hash.ts
|
|
17452
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES88, ASTUtils as
|
|
17804
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES88, ASTUtils as ASTUtils50 } from "@typescript-eslint/utils";
|
|
17453
17805
|
var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
17454
17806
|
defaultLevel: "warning",
|
|
17455
17807
|
summary: "Prefer the modern one-shot node:crypto hash API when streaming state is unnecessary.",
|
|
@@ -17477,7 +17829,7 @@ function isCryptoLoader(node, resolve2) {
|
|
|
17477
17829
|
if (unwrappedNodeCallee?.type === AST_NODE_TYPES88.Identifier) {
|
|
17478
17830
|
return unwrappedNodeCallee.name === "require" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee, resolve2);
|
|
17479
17831
|
}
|
|
17480
|
-
return unwrappedNodeCallee?.type === AST_NODE_TYPES88.MemberExpression && unwrappedNodeCallee.object.type === AST_NODE_TYPES88.Identifier && unwrappedNodeCallee.object.name === "process" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee.object, resolve2) &&
|
|
17832
|
+
return unwrappedNodeCallee?.type === AST_NODE_TYPES88.MemberExpression && unwrappedNodeCallee.object.type === AST_NODE_TYPES88.Identifier && unwrappedNodeCallee.object.name === "process" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee.object, resolve2) && ASTUtils50.getPropertyName(unwrappedNodeCallee) === "getBuiltinModule";
|
|
17481
17833
|
}
|
|
17482
17834
|
function isCryptoSpecifier(node) {
|
|
17483
17835
|
return node.type === AST_NODE_TYPES88.Literal && (node.value === "crypto" || node.value === "node:crypto");
|
|
@@ -17502,7 +17854,7 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
17502
17854
|
const directBindings = /* @__PURE__ */ new Set();
|
|
17503
17855
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
17504
17856
|
function resolve2(identifier) {
|
|
17505
|
-
return
|
|
17857
|
+
return ASTUtils50.findVariable(
|
|
17506
17858
|
context.sourceCode.getScope(identifier),
|
|
17507
17859
|
identifier.name
|
|
17508
17860
|
);
|
|
@@ -17564,7 +17916,7 @@ function importedName5(node) {
|
|
|
17564
17916
|
}
|
|
17565
17917
|
function isMemberCall(node, name) {
|
|
17566
17918
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
17567
|
-
return unwrappedNodeCallee.type === AST_NODE_TYPES88.MemberExpression &&
|
|
17919
|
+
return unwrappedNodeCallee.type === AST_NODE_TYPES88.MemberExpression && ASTUtils50.getPropertyName(unwrappedNodeCallee) === name;
|
|
17568
17920
|
}
|
|
17569
17921
|
function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
17570
17922
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
@@ -17572,7 +17924,7 @@ function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
|
17572
17924
|
const variable2 = resolve2(unwrappedNodeCallee);
|
|
17573
17925
|
return variable2 !== null && directBindings.has(variable2);
|
|
17574
17926
|
}
|
|
17575
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES88.MemberExpression ||
|
|
17927
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES88.MemberExpression || ASTUtils50.getPropertyName(unwrappedNodeCallee) !== "createHash") {
|
|
17576
17928
|
return false;
|
|
17577
17929
|
}
|
|
17578
17930
|
if (isCryptoLoader(unwrappedNodeCallee.object, resolve2)) return true;
|
|
@@ -17582,7 +17934,7 @@ function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
|
17582
17934
|
}
|
|
17583
17935
|
|
|
17584
17936
|
// src/rules/prefer-node-fs-promises.ts
|
|
17585
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES89, ASTUtils as
|
|
17937
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES89, ASTUtils as ASTUtils51 } from "@typescript-eslint/utils";
|
|
17586
17938
|
var PREFER_NODE_FS_PROMISES_DOCUMENTATION = {
|
|
17587
17939
|
defaultLevel: "warning",
|
|
17588
17940
|
summary: "Prefer promise-based Node.js filesystem APIs over synchronous calls in production modules.",
|
|
@@ -17644,7 +17996,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
17644
17996
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || normalizedFilename.includes("src/rules/"))
|
|
17645
17997
|
return {};
|
|
17646
17998
|
const namespaces = /* @__PURE__ */ new Set();
|
|
17647
|
-
const bindingOf = (node) =>
|
|
17999
|
+
const bindingOf = (node) => ASTUtils51.findVariable(context.sourceCode.getScope(node), node.name);
|
|
17648
18000
|
const isGlobal = (node) => {
|
|
17649
18001
|
const binding = bindingOf(node);
|
|
17650
18002
|
return binding === null || binding.defs.length === 0;
|
|
@@ -17710,7 +18062,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
17710
18062
|
});
|
|
17711
18063
|
|
|
17712
18064
|
// src/rules/prefer-non-nullable-collection.ts
|
|
17713
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES90, ASTUtils as
|
|
18065
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES90, ASTUtils as ASTUtils52 } from "@typescript-eslint/utils";
|
|
17714
18066
|
var PREFER_NON_NULLABLE_COLLECTION_DOCUMENTATION = {
|
|
17715
18067
|
summary: "Suggest reviewing nullish arrays that use local empty-array defaults or a shared null-or-empty guard.",
|
|
17716
18068
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
@@ -17835,14 +18187,14 @@ function directlyCoalesced(node) {
|
|
|
17835
18187
|
return parent?.type === AST_NODE_TYPES90.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
17836
18188
|
}
|
|
17837
18189
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
17838
|
-
const variable =
|
|
18190
|
+
const variable = ASTUtils52.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
17839
18191
|
if (variable === null || variable.references.length === 0) return false;
|
|
17840
18192
|
return variable.references.every(
|
|
17841
18193
|
(reference) => belongsToFunction(reference.identifier, fn) && directlyCoalesced(reference.identifier)
|
|
17842
18194
|
);
|
|
17843
18195
|
}
|
|
17844
18196
|
function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
17845
|
-
const variable =
|
|
18197
|
+
const variable = ASTUtils52.findVariable(context.sourceCode.getScope(object), object.name);
|
|
17846
18198
|
if (variable === null) return false;
|
|
17847
18199
|
const accesses = variable.references.flatMap((reference) => {
|
|
17848
18200
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
@@ -17910,7 +18262,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
17910
18262
|
function checkDestructuredProperties(parameter, properties) {
|
|
17911
18263
|
for (const property of properties) {
|
|
17912
18264
|
const bindingProperty = parameter.properties.find(
|
|
17913
|
-
(entry) => entry.type === AST_NODE_TYPES90.Property && !entry.computed &&
|
|
18265
|
+
(entry) => entry.type === AST_NODE_TYPES90.Property && !entry.computed && ASTUtils52.getPropertyName(entry) === property.name
|
|
17914
18266
|
);
|
|
17915
18267
|
if (bindingProperty === void 0) continue;
|
|
17916
18268
|
const value = bindingProperty.value;
|
|
@@ -17958,7 +18310,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
17958
18310
|
// src/rules/prefer-nullish-filter-predicate.ts
|
|
17959
18311
|
import {
|
|
17960
18312
|
AST_NODE_TYPES as AST_NODE_TYPES91,
|
|
17961
|
-
ASTUtils as
|
|
18313
|
+
ASTUtils as ASTUtils53,
|
|
17962
18314
|
ESLintUtils as ESLintUtils12
|
|
17963
18315
|
} from "@typescript-eslint/utils";
|
|
17964
18316
|
import ts10 from "typescript";
|
|
@@ -18004,7 +18356,7 @@ var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
|
18004
18356
|
]
|
|
18005
18357
|
};
|
|
18006
18358
|
function isUnshadowedBoolean(node, context) {
|
|
18007
|
-
const variable =
|
|
18359
|
+
const variable = ASTUtils53.findVariable(context.sourceCode.getScope(node), node.name);
|
|
18008
18360
|
return variable === null || variable.defs.length === 0;
|
|
18009
18361
|
}
|
|
18010
18362
|
function isBuiltinArrayFilter(node, services) {
|
|
@@ -18063,7 +18415,7 @@ function isProvablyTruthy(type, checker) {
|
|
|
18063
18415
|
}
|
|
18064
18416
|
function availableParameterName(node, context) {
|
|
18065
18417
|
for (const name of ["value", "item", "element", "candidate"]) {
|
|
18066
|
-
if (
|
|
18418
|
+
if (ASTUtils53.findVariable(context.sourceCode.getScope(node), name) === null) return name;
|
|
18067
18419
|
}
|
|
18068
18420
|
return null;
|
|
18069
18421
|
}
|
|
@@ -18094,7 +18446,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
18094
18446
|
CallExpression(node) {
|
|
18095
18447
|
const callee = unwrapExpression(node.callee);
|
|
18096
18448
|
const callback = node.arguments[0] === void 0 ? void 0 : unwrapExpression(node.arguments[0]);
|
|
18097
|
-
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES91.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES91.MemberExpression ||
|
|
18449
|
+
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES91.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES91.MemberExpression || ASTUtils53.getPropertyName(callee) === null || (ASTUtils53.getPropertyName(callee) ?? "") !== "filter" || !isUnshadowedBoolean(callback, context) || !isBuiltinArrayFilter(callee, services)) return;
|
|
18098
18450
|
const elementType = arrayElementType(callee.object, services);
|
|
18099
18451
|
const checker = services.program.getTypeChecker();
|
|
18100
18452
|
if (elementType === null || !isNullishPlusTruthy(elementType, checker)) return;
|
|
@@ -18117,7 +18469,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
18117
18469
|
|
|
18118
18470
|
// src/rules/prefer-await-in-async-return.ts
|
|
18119
18471
|
import {
|
|
18120
|
-
ASTUtils as
|
|
18472
|
+
ASTUtils as ASTUtils54,
|
|
18121
18473
|
ESLintUtils as ESLintUtils13,
|
|
18122
18474
|
AST_NODE_TYPES as AST_NODE_TYPES92
|
|
18123
18475
|
} from "@typescript-eslint/utils";
|
|
@@ -18180,7 +18532,7 @@ function isRuntimeFunction(node) {
|
|
|
18180
18532
|
}
|
|
18181
18533
|
function promiseThenReceiver(node) {
|
|
18182
18534
|
const callee = unwrapExpression(node.callee);
|
|
18183
|
-
if (callee.type !== AST_NODE_TYPES92.MemberExpression || callee.optional ||
|
|
18535
|
+
if (callee.type !== AST_NODE_TYPES92.MemberExpression || callee.optional || ASTUtils54.getPropertyName(callee) === null || (ASTUtils54.getPropertyName(callee) ?? "") !== "then" || node.optional || node.arguments.length !== 1) {
|
|
18184
18536
|
return null;
|
|
18185
18537
|
}
|
|
18186
18538
|
const argument = node.arguments[0];
|
|
@@ -18250,7 +18602,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
18250
18602
|
if (services === null) return {};
|
|
18251
18603
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
18252
18604
|
const rememberFrameworkLoader = (identifier) => {
|
|
18253
|
-
const variable =
|
|
18605
|
+
const variable = ASTUtils54.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
18254
18606
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
18255
18607
|
};
|
|
18256
18608
|
const isFrameworkLoaderCallback = (owner) => {
|
|
@@ -18258,7 +18610,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
18258
18610
|
if (parent === null || parent.arguments[0] !== outerExpression(owner)) return false;
|
|
18259
18611
|
const callee = unwrapExpression(parent.callee);
|
|
18260
18612
|
if (callee.type !== AST_NODE_TYPES92.Identifier) return false;
|
|
18261
|
-
const variable =
|
|
18613
|
+
const variable = ASTUtils54.findVariable(context.sourceCode.getScope(callee), callee.name);
|
|
18262
18614
|
return variable !== null && frameworkLoaders.has(variable);
|
|
18263
18615
|
};
|
|
18264
18616
|
return {
|
|
@@ -18295,7 +18647,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
18295
18647
|
});
|
|
18296
18648
|
|
|
18297
18649
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
18298
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES93, ASTUtils as
|
|
18650
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES93, ASTUtils as ASTUtils55 } from "@typescript-eslint/utils";
|
|
18299
18651
|
var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
18300
18652
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
18301
18653
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -18332,7 +18684,7 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
18332
18684
|
]);
|
|
18333
18685
|
var isSchemaParseReference = (node) => {
|
|
18334
18686
|
const inner = unwrap5(node);
|
|
18335
|
-
return inner !== null && inner.type === AST_NODE_TYPES93.MemberExpression &&
|
|
18687
|
+
return inner !== null && inner.type === AST_NODE_TYPES93.MemberExpression && ASTUtils55.getPropertyName(inner) !== null && ((ASTUtils55.getPropertyName(inner) ?? "") === "parse" || (ASTUtils55.getPropertyName(inner) ?? "") === "safeParse");
|
|
18336
18688
|
};
|
|
18337
18689
|
var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
18338
18690
|
let current = unwrap5(node);
|
|
@@ -18347,7 +18699,7 @@ var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
|
18347
18699
|
if (callee === null || callee.type !== AST_NODE_TYPES93.MemberExpression) {
|
|
18348
18700
|
return false;
|
|
18349
18701
|
}
|
|
18350
|
-
const property =
|
|
18702
|
+
const property = ASTUtils55.getPropertyName(callee);
|
|
18351
18703
|
if (property === null) {
|
|
18352
18704
|
return false;
|
|
18353
18705
|
}
|
|
@@ -18359,19 +18711,19 @@ var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
|
18359
18711
|
}
|
|
18360
18712
|
const object = unwrap5(callee.object);
|
|
18361
18713
|
const input = unwrap5(current.arguments[0]);
|
|
18362
|
-
if (input?.type === AST_NODE_TYPES93.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES93.MemberExpression && input.callee.object.type === AST_NODE_TYPES93.Identifier && input.callee.object.name === "JSON" &&
|
|
18363
|
-
return property === "parse" && object !== null && object.type === AST_NODE_TYPES93.Identifier && object.name === "JSON" && (
|
|
18714
|
+
if (input?.type === AST_NODE_TYPES93.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES93.MemberExpression && input.callee.object.type === AST_NODE_TYPES93.Identifier && input.callee.object.name === "JSON" && ASTUtils55.getPropertyName(input.callee) === "stringify" && (ASTUtils55.findVariable(context.sourceCode.getScope(input.callee.object), "JSON")?.defs.length ?? 0) === 0) return false;
|
|
18715
|
+
return property === "parse" && object !== null && object.type === AST_NODE_TYPES93.Identifier && object.name === "JSON" && (ASTUtils55.findVariable(context.sourceCode.getScope(object), "JSON")?.defs.length ?? 0) === 0 && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
18364
18716
|
};
|
|
18365
18717
|
var isResponseSource = (node, context, seen = /* @__PURE__ */ new Set()) => {
|
|
18366
18718
|
let current = unwrap5(node);
|
|
18367
18719
|
if (current?.type === AST_NODE_TYPES93.AwaitExpression) current = unwrap5(current.argument);
|
|
18368
18720
|
if (current === null || seen.has(current)) return false;
|
|
18369
18721
|
seen.add(current);
|
|
18370
|
-
const isGlobal = (identifier) => (
|
|
18722
|
+
const isGlobal = (identifier) => (ASTUtils55.findVariable(context.sourceCode.getScope(identifier), identifier.name)?.defs.length ?? 0) === 0;
|
|
18371
18723
|
if (current.type === AST_NODE_TYPES93.CallExpression) return current.callee.type === AST_NODE_TYPES93.Identifier && current.callee.name === "fetch" && isGlobal(current.callee);
|
|
18372
18724
|
if (current.type === AST_NODE_TYPES93.NewExpression) return current.callee.type === AST_NODE_TYPES93.Identifier && ["Request", "Response"].includes(current.callee.name) && isGlobal(current.callee);
|
|
18373
18725
|
if (current.type !== AST_NODE_TYPES93.Identifier) return false;
|
|
18374
|
-
const binding =
|
|
18726
|
+
const binding = ASTUtils55.findVariable(context.sourceCode.getScope(current), current.name);
|
|
18375
18727
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
18376
18728
|
const definition = binding.defs[0];
|
|
18377
18729
|
const annotation = definition?.name.type === AST_NODE_TYPES93.Identifier ? definition.name.typeAnnotation?.typeAnnotation : void 0;
|
|
@@ -18386,7 +18738,7 @@ var isDirectLocalFileRead = (node) => {
|
|
|
18386
18738
|
}
|
|
18387
18739
|
if (current?.type !== AST_NODE_TYPES93.CallExpression) return false;
|
|
18388
18740
|
const callee = unwrap5(current.callee);
|
|
18389
|
-
const name = callee?.type === AST_NODE_TYPES93.Identifier ? callee.name : callee?.type === AST_NODE_TYPES93.MemberExpression &&
|
|
18741
|
+
const name = callee?.type === AST_NODE_TYPES93.Identifier ? callee.name : callee?.type === AST_NODE_TYPES93.MemberExpression && ASTUtils55.getPropertyName(callee) !== null ? ASTUtils55.getPropertyName(callee) ?? "" : null;
|
|
18390
18742
|
return name !== null && FILE_READ_RE.test(name);
|
|
18391
18743
|
};
|
|
18392
18744
|
var isLocalFileRead = (node) => {
|
|
@@ -18447,7 +18799,7 @@ var isValidationRead = (node) => {
|
|
|
18447
18799
|
return false;
|
|
18448
18800
|
}
|
|
18449
18801
|
const callee = parent.callee;
|
|
18450
|
-
if (callee.type === AST_NODE_TYPES93.MemberExpression && callee.object.type === AST_NODE_TYPES93.Identifier && callee.object.name === "Array" &&
|
|
18802
|
+
if (callee.type === AST_NODE_TYPES93.MemberExpression && callee.object.type === AST_NODE_TYPES93.Identifier && callee.object.name === "Array" && ASTUtils55.getPropertyName(callee) === "isArray") {
|
|
18451
18803
|
return parent.arguments.length === 1;
|
|
18452
18804
|
}
|
|
18453
18805
|
return callee.type === AST_NODE_TYPES93.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
@@ -18475,11 +18827,11 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
18475
18827
|
}
|
|
18476
18828
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
18477
18829
|
}
|
|
18478
|
-
return test.type === AST_NODE_TYPES93.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES93.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES93.MemberExpression && test.callee.object.type === AST_NODE_TYPES93.Identifier && test.callee.object.name === "Array" &&
|
|
18830
|
+
return test.type === AST_NODE_TYPES93.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES93.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES93.MemberExpression && test.callee.object.type === AST_NODE_TYPES93.Identifier && test.callee.object.name === "Array" && ASTUtils55.getPropertyName(test.callee) === "isArray" ? "valid-when-true" : null;
|
|
18479
18831
|
};
|
|
18480
18832
|
var plainMemberAccess = (node) => {
|
|
18481
18833
|
if (node.type !== AST_NODE_TYPES93.MemberExpression || node.object.type !== AST_NODE_TYPES93.Identifier) return null;
|
|
18482
|
-
const property =
|
|
18834
|
+
const property = ASTUtils55.getPropertyName(node);
|
|
18483
18835
|
return property === null ? null : { object: node.object.name, property };
|
|
18484
18836
|
};
|
|
18485
18837
|
var isSamePlainMember = (node, access) => {
|
|
@@ -18543,7 +18895,7 @@ var memberValidationPolarity = (test, access) => {
|
|
|
18543
18895
|
}
|
|
18544
18896
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
18545
18897
|
}
|
|
18546
|
-
return test.type === AST_NODE_TYPES93.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES93.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES93.MemberExpression && test.callee.object.type === AST_NODE_TYPES93.Identifier && test.callee.object.name === "Array" &&
|
|
18898
|
+
return test.type === AST_NODE_TYPES93.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES93.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES93.MemberExpression && test.callee.object.type === AST_NODE_TYPES93.Identifier && test.callee.object.name === "Array" && ASTUtils55.getPropertyName(test.callee) === "isArray" ? "valid-when-true" : null;
|
|
18547
18899
|
};
|
|
18548
18900
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
18549
18901
|
const isValidationReference = (identifier) => {
|
|
@@ -18826,7 +19178,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
18826
19178
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
18827
19179
|
)) {
|
|
18828
19180
|
const parent = node.parent;
|
|
18829
|
-
const method =
|
|
19181
|
+
const method = ASTUtils55.getPropertyName(node);
|
|
18830
19182
|
if (parent.type === AST_NODE_TYPES93.CallExpression && parent.callee === node && method !== null && (method === "parse" || method === "safeParse" || PROMISE_CHAIN_METHODS.has(method))) {
|
|
18831
19183
|
return;
|
|
18832
19184
|
}
|
|
@@ -18879,7 +19231,7 @@ function ifGuardDominates(use, branch, positive) {
|
|
|
18879
19231
|
}
|
|
18880
19232
|
|
|
18881
19233
|
// src/rules/prefer-shared-zod-enum.ts
|
|
18882
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES94, ASTUtils as
|
|
19234
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES94, ASTUtils as ASTUtils56 } from "@typescript-eslint/utils";
|
|
18883
19235
|
var PREFER_SHARED_ZOD_ENUM_DOCUMENTATION = {
|
|
18884
19236
|
defaultLevel: "warning",
|
|
18885
19237
|
summary: "Give repeated literal Zod enum domains one reusable module-level schema.",
|
|
@@ -18929,7 +19281,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
18929
19281
|
create(context) {
|
|
18930
19282
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
18931
19283
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
18932
|
-
const bindingOf = (node) =>
|
|
19284
|
+
const bindingOf = (node) => ASTUtils56.findVariable(context.sourceCode.getScope(node), node.name);
|
|
18933
19285
|
const candidates = /* @__PURE__ */ new Map();
|
|
18934
19286
|
return {
|
|
18935
19287
|
ImportDeclaration(node) {
|
|
@@ -18944,7 +19296,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
18944
19296
|
CallExpression(node) {
|
|
18945
19297
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
18946
19298
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES94.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
18947
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES94.MemberExpression || receiver.type !== AST_NODE_TYPES94.Identifier ||
|
|
19299
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES94.MemberExpression || receiver.type !== AST_NODE_TYPES94.Identifier || ASTUtils56.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils56.getPropertyName(unwrappedNodeCallee) ?? "") !== "enum") return;
|
|
18948
19300
|
const binding = bindingOf(receiver);
|
|
18949
19301
|
if (binding === null || !zodBindings.has(binding)) return;
|
|
18950
19302
|
const domain = literalDomain(node);
|
|
@@ -19566,7 +19918,7 @@ function packageWorkspaceGlobs(parsed) {
|
|
|
19566
19918
|
}
|
|
19567
19919
|
|
|
19568
19920
|
// src/rules/prefer-server-actions.ts
|
|
19569
|
-
import { ASTUtils as
|
|
19921
|
+
import { ASTUtils as ASTUtils57 } from "@typescript-eslint/utils";
|
|
19570
19922
|
var PREFER_SERVER_ACTIONS_DOCUMENTATION = {
|
|
19571
19923
|
summary: "Prefer Next.js Server Actions over same-origin API mutations.",
|
|
19572
19924
|
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.",
|
|
@@ -19599,7 +19951,7 @@ function resolveNode(node, context) {
|
|
|
19599
19951
|
node = node == null ? node : unwrapExpression(node);
|
|
19600
19952
|
if (!node) return null;
|
|
19601
19953
|
if (node.type !== "Identifier") return node;
|
|
19602
|
-
const variable =
|
|
19954
|
+
const variable = ASTUtils57.findVariable(getScope(context, node), node.name);
|
|
19603
19955
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
19604
19956
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return node;
|
|
19605
19957
|
if (definition.node.init.type === "ObjectExpression" && variable?.references.some((reference) => reference.identifier !== node && reference.init !== true)) return node;
|
|
@@ -19608,7 +19960,7 @@ function resolveNode(node, context) {
|
|
|
19608
19960
|
function isAxiosClient(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
19609
19961
|
if (node.type !== "Identifier" || seen.has(node)) return false;
|
|
19610
19962
|
seen.add(node);
|
|
19611
|
-
const variable =
|
|
19963
|
+
const variable = ASTUtils57.findVariable(getScope(context, node), node.name);
|
|
19612
19964
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
19613
19965
|
if (definition === void 0 || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
19614
19966
|
if (variable?.references.some((reference) => {
|
|
@@ -19692,10 +20044,10 @@ function isFunctionArgument(node, context) {
|
|
|
19692
20044
|
}
|
|
19693
20045
|
function getPropertyNode(objNode, propName2) {
|
|
19694
20046
|
if (!objNode || objNode.type !== "ObjectExpression") return null;
|
|
19695
|
-
if (objNode.properties.some((property) => property.type === "SpreadElement" ||
|
|
20047
|
+
if (objNode.properties.some((property) => property.type === "SpreadElement" || ASTUtils57.getPropertyName(property) === null)) return null;
|
|
19696
20048
|
for (const prop of [...objNode.properties].reverse()) {
|
|
19697
20049
|
if (prop.type !== "Property") continue;
|
|
19698
|
-
const keyName =
|
|
20050
|
+
const keyName = ASTUtils57.getPropertyName(prop);
|
|
19699
20051
|
if (keyName === propName2) {
|
|
19700
20052
|
if (prop.value.type === "AssignmentPattern" || prop.value.type === "ArrayPattern" || prop.value.type === "ObjectPattern") {
|
|
19701
20053
|
return null;
|
|
@@ -19819,7 +20171,7 @@ var prefer_server_actions_default = createRule({
|
|
|
19819
20171
|
});
|
|
19820
20172
|
|
|
19821
20173
|
// src/rules/prefer-whole-object-assertion.ts
|
|
19822
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES97, ASTUtils as
|
|
20174
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES97, ASTUtils as ASTUtils58 } from "@typescript-eslint/utils";
|
|
19823
20175
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
19824
20176
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
19825
20177
|
["toBeNull", "null"]
|
|
@@ -19884,7 +20236,7 @@ function propertyAccess(node) {
|
|
|
19884
20236
|
const path = [];
|
|
19885
20237
|
let current = node;
|
|
19886
20238
|
while (current.type === AST_NODE_TYPES97.MemberExpression && !current.optional) {
|
|
19887
|
-
const name =
|
|
20239
|
+
const name = ASTUtils58.getPropertyName(current);
|
|
19888
20240
|
if (name === null || COLLECTION_PROPERTIES.has(name) || LITERAL_KEY_HAZARDS.has(name)) return null;
|
|
19889
20241
|
path.unshift(name);
|
|
19890
20242
|
current = unwrapExpression(current.object);
|
|
@@ -20031,7 +20383,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
20031
20383
|
const callee = unwrapExpression(call.callee);
|
|
20032
20384
|
const calleeReceiver = callee.type === AST_NODE_TYPES97.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
20033
20385
|
if (callee.type !== AST_NODE_TYPES97.MemberExpression) return null;
|
|
20034
|
-
const matcher =
|
|
20386
|
+
const matcher = ASTUtils58.getPropertyName(callee);
|
|
20035
20387
|
if (matcher === null) return null;
|
|
20036
20388
|
const expectCall = calleeReceiver;
|
|
20037
20389
|
const expectCallee = expectCall.type === AST_NODE_TYPES97.CallExpression ? unwrapExpression(expectCall.callee) : null;
|
|
@@ -20061,7 +20413,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
20061
20413
|
return assertionExpectation(statement, call, receiver, key, matcher);
|
|
20062
20414
|
}
|
|
20063
20415
|
function isTestExpect(callee) {
|
|
20064
|
-
const variable =
|
|
20416
|
+
const variable = ASTUtils58.findVariable(sourceCode.getScope(callee), callee.name);
|
|
20065
20417
|
if (variable !== null && variable.defs.some((definition) => {
|
|
20066
20418
|
if (definition.node.type !== AST_NODE_TYPES97.ImportSpecifier) return true;
|
|
20067
20419
|
const declaration = definition.node.parent;
|
|
@@ -20104,7 +20456,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
20104
20456
|
});
|
|
20105
20457
|
|
|
20106
20458
|
// src/rules/repeated-static-call-cases.ts
|
|
20107
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES98, ASTUtils as
|
|
20459
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES98, ASTUtils as ASTUtils59 } from "@typescript-eslint/utils";
|
|
20108
20460
|
var REPEATED_STATIC_CALL_CASES_DOCUMENTATION = {
|
|
20109
20461
|
summary: "Review three or more consecutive static-input call assertions as potential named cases.",
|
|
20110
20462
|
rationale: "Copy-pasted cases obscure the input table, and a thrown assertion can stop later cases from being reported.",
|
|
@@ -20125,7 +20477,7 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
20125
20477
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
20126
20478
|
var MIN_CASES2 = 3;
|
|
20127
20479
|
function importedName6(identifier, context, modules) {
|
|
20128
|
-
const variable =
|
|
20480
|
+
const variable = ASTUtils59.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
20129
20481
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
20130
20482
|
for (const definition of variable.defs) {
|
|
20131
20483
|
if (definition.node.type !== AST_NODE_TYPES98.ImportSpecifier) continue;
|
|
@@ -20147,7 +20499,7 @@ function testRoot2(callee) {
|
|
|
20147
20499
|
callee = unwrapExpression(callee);
|
|
20148
20500
|
if (callee.type === AST_NODE_TYPES98.Identifier) return callee;
|
|
20149
20501
|
if (callee.type !== AST_NODE_TYPES98.MemberExpression) return null;
|
|
20150
|
-
const modifier =
|
|
20502
|
+
const modifier = ASTUtils59.getPropertyName(callee);
|
|
20151
20503
|
return modifier !== null && TEST_MODIFIERS5.has(modifier) ? testRoot2(callee.object) : null;
|
|
20152
20504
|
}
|
|
20153
20505
|
function isStatic(input) {
|
|
@@ -20193,8 +20545,8 @@ function assertionShape(statement, context, callback) {
|
|
|
20193
20545
|
const matcherCall = unwrapExpression(statement.expression);
|
|
20194
20546
|
if (matcherCall.type !== AST_NODE_TYPES98.CallExpression) return null;
|
|
20195
20547
|
const matcherCallee = unwrapExpression(matcherCall.callee);
|
|
20196
|
-
if (matcherCallee.type !== AST_NODE_TYPES98.MemberExpression ||
|
|
20197
|
-
const matcher =
|
|
20548
|
+
if (matcherCallee.type !== AST_NODE_TYPES98.MemberExpression || ASTUtils59.getPropertyName(matcherCallee) === null || matcherCall.arguments.length !== 1) return null;
|
|
20549
|
+
const matcher = ASTUtils59.getPropertyName(matcherCallee) ?? "";
|
|
20198
20550
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
20199
20551
|
const chain = expectCallFromMatcher(matcherCallee);
|
|
20200
20552
|
const expectCallee = chain === null ? null : unwrapExpression(chain.call.callee);
|
|
@@ -20204,7 +20556,7 @@ function assertionShape(statement, context, callback) {
|
|
|
20204
20556
|
const observedCallee = observed?.type === AST_NODE_TYPES98.CallExpression ? unwrapExpression(observed.callee) : null;
|
|
20205
20557
|
if (observed?.type !== AST_NODE_TYPES98.CallExpression || observedCallee?.type !== AST_NODE_TYPES98.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === AST_NODE_TYPES98.SpreadElement || !isStatic(arg)) || expected?.type === AST_NODE_TYPES98.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
20206
20558
|
const skeleton = `${observedCallee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
20207
|
-
const binding =
|
|
20559
|
+
const binding = ASTUtils59.findVariable(context.sourceCode.getScope(observedCallee), observedCallee.name);
|
|
20208
20560
|
if (binding?.defs.some(
|
|
20209
20561
|
(definition) => definition.node.range[0] >= callback.range[0] && definition.node.range[1] <= callback.range[1]
|
|
20210
20562
|
)) return null;
|
|
@@ -20215,7 +20567,7 @@ function expectCallFromMatcher(node) {
|
|
|
20215
20567
|
const modifiers = [];
|
|
20216
20568
|
let receiver = node.object;
|
|
20217
20569
|
while (receiver.type === AST_NODE_TYPES98.MemberExpression) {
|
|
20218
|
-
const modifier =
|
|
20570
|
+
const modifier = ASTUtils59.getPropertyName(receiver);
|
|
20219
20571
|
if (modifier === null || !EXPECT_MODIFIERS.has(modifier)) return null;
|
|
20220
20572
|
modifiers.unshift(modifier);
|
|
20221
20573
|
receiver = receiver.object;
|
|
@@ -20291,7 +20643,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
20291
20643
|
});
|
|
20292
20644
|
|
|
20293
20645
|
// src/rules/prefer-zod-infer.ts
|
|
20294
|
-
import { ASTUtils as
|
|
20646
|
+
import { ASTUtils as ASTUtils60, AST_NODE_TYPES as AST_NODE_TYPES99 } from "@typescript-eslint/utils";
|
|
20295
20647
|
var PREFER_ZOD_INFER_DOCUMENTATION = {
|
|
20296
20648
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
20297
20649
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -20609,7 +20961,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
20609
20961
|
while (current.type === AST_NODE_TYPES99.CallExpression) {
|
|
20610
20962
|
const callee = unwrapExpression(current.callee);
|
|
20611
20963
|
const calleeReceiver = callee.type === AST_NODE_TYPES99.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
20612
|
-
if (callee.type !== AST_NODE_TYPES99.MemberExpression ||
|
|
20964
|
+
if (callee.type !== AST_NODE_TYPES99.MemberExpression || ASTUtils60.getPropertyName(callee) === null) {
|
|
20613
20965
|
return null;
|
|
20614
20966
|
}
|
|
20615
20967
|
chain.push(current);
|
|
@@ -20622,7 +20974,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
20622
20974
|
}
|
|
20623
20975
|
function twinMethodName(call) {
|
|
20624
20976
|
const callee = unwrapExpression(call.callee);
|
|
20625
|
-
return callee.type === AST_NODE_TYPES99.MemberExpression &&
|
|
20977
|
+
return callee.type === AST_NODE_TYPES99.MemberExpression && ASTUtils60.getPropertyName(callee) !== null ? ASTUtils60.getPropertyName(callee) ?? "" : "";
|
|
20626
20978
|
}
|
|
20627
20979
|
function twinSchemaFields(initializer, zodNamespaces) {
|
|
20628
20980
|
const chain = twinCallChain(initializer, zodNamespaces);
|
|
@@ -20637,7 +20989,7 @@ function twinSchemaFields(initializer, zodNamespaces) {
|
|
|
20637
20989
|
const fields = /* @__PURE__ */ new Map();
|
|
20638
20990
|
for (const property of shape.properties) {
|
|
20639
20991
|
if (property.type !== AST_NODE_TYPES99.Property) return null;
|
|
20640
|
-
const name =
|
|
20992
|
+
const name = ASTUtils60.getPropertyName(property);
|
|
20641
20993
|
if (name === null) return null;
|
|
20642
20994
|
fields.set(name, twinSchemaField(property.value, zodNamespaces));
|
|
20643
20995
|
}
|
|
@@ -20651,16 +21003,16 @@ function twinSchemaField(node, zodNamespaces) {
|
|
|
20651
21003
|
while (current.type === AST_NODE_TYPES99.CallExpression) {
|
|
20652
21004
|
const callee = unwrapExpression(current.callee);
|
|
20653
21005
|
const calleeReceiver = callee.type === AST_NODE_TYPES99.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
20654
|
-
if (callee.type !== AST_NODE_TYPES99.MemberExpression ||
|
|
21006
|
+
if (callee.type !== AST_NODE_TYPES99.MemberExpression || ASTUtils60.getPropertyName(callee) === null) {
|
|
20655
21007
|
break;
|
|
20656
21008
|
}
|
|
20657
21009
|
const receiver = calleeReceiver;
|
|
20658
21010
|
if (receiver.type === AST_NODE_TYPES99.Identifier && zodNamespaces.has(receiver.name)) {
|
|
20659
|
-
leaf =
|
|
21011
|
+
leaf = ASTUtils60.getPropertyName(callee) ?? "";
|
|
20660
21012
|
leafCall = current;
|
|
20661
21013
|
break;
|
|
20662
21014
|
}
|
|
20663
|
-
modifiers.push(
|
|
21015
|
+
modifiers.push(ASTUtils60.getPropertyName(callee) ?? "");
|
|
20664
21016
|
current = receiver;
|
|
20665
21017
|
}
|
|
20666
21018
|
return {
|
|
@@ -20863,7 +21215,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
20863
21215
|
},
|
|
20864
21216
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
20865
21217
|
"MemberExpression"(node) {
|
|
20866
|
-
if (node.object.type === AST_NODE_TYPES99.Identifier &&
|
|
21218
|
+
if (node.object.type === AST_NODE_TYPES99.Identifier && ASTUtils60.getPropertyName(node) !== null && isPreferZodInferModuleReshaper(ASTUtils60.getPropertyName(node) ?? "")) {
|
|
20867
21219
|
reshapedSchemaNames.add(node.object.name);
|
|
20868
21220
|
}
|
|
20869
21221
|
},
|
|
@@ -21021,7 +21373,7 @@ function staticFieldName(key) {
|
|
|
21021
21373
|
|
|
21022
21374
|
// src/rules/prefer-zod-parse-output-type.ts
|
|
21023
21375
|
import {
|
|
21024
|
-
ASTUtils as
|
|
21376
|
+
ASTUtils as ASTUtils61,
|
|
21025
21377
|
AST_NODE_TYPES as AST_NODE_TYPES100,
|
|
21026
21378
|
ESLintUtils as ESLintUtils14
|
|
21027
21379
|
} from "@typescript-eslint/utils";
|
|
@@ -21091,11 +21443,11 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
21091
21443
|
while (current.type === AST_NODE_TYPES100.CallExpression) {
|
|
21092
21444
|
const callee = unwrapExpression(current.callee);
|
|
21093
21445
|
const calleeReceiver = callee.type === AST_NODE_TYPES100.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
21094
|
-
if (callee.type !== AST_NODE_TYPES100.MemberExpression ||
|
|
21446
|
+
if (callee.type !== AST_NODE_TYPES100.MemberExpression || ASTUtils61.getPropertyName(callee) === null) {
|
|
21095
21447
|
return false;
|
|
21096
21448
|
}
|
|
21097
21449
|
if (calleeReceiver.type === AST_NODE_TYPES100.Identifier) {
|
|
21098
|
-
return namespaces.has(calleeReceiver.name) && ((
|
|
21450
|
+
return namespaces.has(calleeReceiver.name) && ((ASTUtils61.getPropertyName(callee) ?? "") === "object" || (ASTUtils61.getPropertyName(callee) ?? "") === "strictObject");
|
|
21099
21451
|
}
|
|
21100
21452
|
current = calleeReceiver;
|
|
21101
21453
|
}
|
|
@@ -21104,10 +21456,10 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
21104
21456
|
function zodParseCall(node) {
|
|
21105
21457
|
const callee = unwrapExpression(node.callee);
|
|
21106
21458
|
const calleeReceiver = callee.type === AST_NODE_TYPES100.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
21107
|
-
if (callee.type !== AST_NODE_TYPES100.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES100.Identifier ||
|
|
21459
|
+
if (callee.type !== AST_NODE_TYPES100.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES100.Identifier || ASTUtils61.getPropertyName(callee) === null) {
|
|
21108
21460
|
return null;
|
|
21109
21461
|
}
|
|
21110
|
-
const method =
|
|
21462
|
+
const method = ASTUtils61.getPropertyName(callee);
|
|
21111
21463
|
if (method !== "parse" && method !== "safeParse") return null;
|
|
21112
21464
|
return {
|
|
21113
21465
|
call: node,
|
|
@@ -21149,7 +21501,7 @@ function localParseReturnCandidates(node, sourceCode) {
|
|
|
21149
21501
|
for (const reference of variable.references) {
|
|
21150
21502
|
const identifier = reference.identifier;
|
|
21151
21503
|
const parent = identifier.parent;
|
|
21152
|
-
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES100.MemberExpression && parent.object === identifier &&
|
|
21504
|
+
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES100.MemberExpression && parent.object === identifier && ASTUtils61.getPropertyName(parent) !== null && (ASTUtils61.getPropertyName(parent) ?? "") === "data" ? parent : null;
|
|
21153
21505
|
if (output === null) continue;
|
|
21154
21506
|
const candidate2 = returnedOutputCandidate(parsed, output);
|
|
21155
21507
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
@@ -21532,7 +21884,7 @@ var require_assert_never_default = createRule({
|
|
|
21532
21884
|
});
|
|
21533
21885
|
|
|
21534
21886
|
// src/rules/require-fetch-timeout.ts
|
|
21535
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES102, ASTUtils as
|
|
21887
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES102, ASTUtils as ASTUtils62 } from "@typescript-eslint/utils";
|
|
21536
21888
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
21537
21889
|
summary: "Require an explicit abort signal on locally analyzable global fetch calls.",
|
|
21538
21890
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -21616,7 +21968,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21616
21968
|
}
|
|
21617
21969
|
function resolvesToGlobal(identifier) {
|
|
21618
21970
|
const scope = context.sourceCode.getScope(identifier);
|
|
21619
|
-
const variable =
|
|
21971
|
+
const variable = ASTUtils62.findVariable(scope, identifier.name);
|
|
21620
21972
|
return variable === null || variable.defs.length === 0;
|
|
21621
21973
|
}
|
|
21622
21974
|
function isGlobalFetchCall2(callee) {
|
|
@@ -21626,7 +21978,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21626
21978
|
return callee.type === AST_NODE_TYPES102.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES102.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES102.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
21627
21979
|
}
|
|
21628
21980
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
21629
|
-
const variable =
|
|
21981
|
+
const variable = ASTUtils62.findVariable(
|
|
21630
21982
|
context.sourceCode.getScope(identifier),
|
|
21631
21983
|
identifier.name
|
|
21632
21984
|
);
|
|
@@ -21648,7 +22000,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21648
22000
|
function isForwardedRequest(argument) {
|
|
21649
22001
|
let value = argument;
|
|
21650
22002
|
if (value.type === AST_NODE_TYPES102.Identifier) {
|
|
21651
|
-
const binding =
|
|
22003
|
+
const binding = ASTUtils62.findVariable(context.sourceCode.getScope(value), value.name);
|
|
21652
22004
|
const definition = binding?.defs.length === 1 ? binding.defs[0] : void 0;
|
|
21653
22005
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || binding?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21654
22006
|
value = definition.node.init;
|
|
@@ -21823,7 +22175,7 @@ function exportedClasses(program, classes) {
|
|
|
21823
22175
|
}
|
|
21824
22176
|
|
|
21825
22177
|
// src/rules/require-sql-access-class.ts
|
|
21826
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES104, ASTUtils as
|
|
22178
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES104, ASTUtils as ASTUtils63 } from "@typescript-eslint/utils";
|
|
21827
22179
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
21828
22180
|
"all",
|
|
21829
22181
|
"batch",
|
|
@@ -21930,7 +22282,7 @@ function databaseReceiver(node) {
|
|
|
21930
22282
|
if (node.type === AST_NODE_TYPES104.Identifier)
|
|
21931
22283
|
return DATABASE_NAMES.test(node.name);
|
|
21932
22284
|
if (node.type !== AST_NODE_TYPES104.MemberExpression) return false;
|
|
21933
|
-
const name =
|
|
22285
|
+
const name = ASTUtils63.getPropertyName(node);
|
|
21934
22286
|
return name === "DB" || name !== null && DATABASE_NAMES.test(name);
|
|
21935
22287
|
}
|
|
21936
22288
|
function databaseRootMember(node) {
|
|
@@ -21948,7 +22300,7 @@ function databaseRootMember(node) {
|
|
|
21948
22300
|
}
|
|
21949
22301
|
if (current.type === AST_NODE_TYPES104.MemberExpression) {
|
|
21950
22302
|
if (current.object.type === AST_NODE_TYPES104.ThisExpression)
|
|
21951
|
-
return
|
|
22303
|
+
return ASTUtils63.getPropertyName(current);
|
|
21952
22304
|
current = current.object;
|
|
21953
22305
|
continue;
|
|
21954
22306
|
}
|
|
@@ -21969,7 +22321,7 @@ function expressionHasDatabaseMarker(node) {
|
|
|
21969
22321
|
continue;
|
|
21970
22322
|
}
|
|
21971
22323
|
if (current.type === AST_NODE_TYPES104.MemberExpression) {
|
|
21972
|
-
const name =
|
|
22324
|
+
const name = ASTUtils63.getPropertyName(current);
|
|
21973
22325
|
if (name === "DB" || name !== null && DATABASE_NAMES.test(name))
|
|
21974
22326
|
return true;
|
|
21975
22327
|
current = current.object;
|
|
@@ -21988,7 +22340,7 @@ function expressionCallsBuilder(node) {
|
|
|
21988
22340
|
}
|
|
21989
22341
|
if (current.type === AST_NODE_TYPES104.CallExpression) {
|
|
21990
22342
|
if (current.callee.type !== AST_NODE_TYPES104.MemberExpression) return false;
|
|
21991
|
-
const name =
|
|
22343
|
+
const name = ASTUtils63.getPropertyName(current.callee);
|
|
21992
22344
|
if (name !== null && BUILDER_METHODS.has(name)) return true;
|
|
21993
22345
|
current = current.callee.object;
|
|
21994
22346
|
continue;
|
|
@@ -22039,7 +22391,7 @@ function thisRootMember(node) {
|
|
|
22039
22391
|
let current = node;
|
|
22040
22392
|
let root = null;
|
|
22041
22393
|
while (current.type === AST_NODE_TYPES104.MemberExpression) {
|
|
22042
|
-
const name =
|
|
22394
|
+
const name = ASTUtils63.getPropertyName(current);
|
|
22043
22395
|
if (name === null) return null;
|
|
22044
22396
|
root = name;
|
|
22045
22397
|
current = current.object;
|
|
@@ -22083,19 +22435,19 @@ var require_sql_access_class_default = createRule({
|
|
|
22083
22435
|
if (seen.has(node)) return false;
|
|
22084
22436
|
seen.add(node);
|
|
22085
22437
|
if (node.type === AST_NODE_TYPES104.Identifier) {
|
|
22086
|
-
const binding =
|
|
22438
|
+
const binding = ASTUtils63.findVariable(context.sourceCode.getScope(node), node.name);
|
|
22087
22439
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
22088
22440
|
const definition = binding.defs[0];
|
|
22089
22441
|
return definition?.type === "Variable" && definition.node.init !== null && knownNonDatabase(definition.node.init, seen);
|
|
22090
22442
|
}
|
|
22091
|
-
return node.type === AST_NODE_TYPES104.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES104.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(unwrappedNodeCallee.name) && (
|
|
22443
|
+
return node.type === AST_NODE_TYPES104.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES104.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(unwrappedNodeCallee.name) && (ASTUtils63.findVariable(context.sourceCode.getScope(unwrappedNodeCallee), unwrappedNodeCallee.name)?.defs.length ?? 0) === 0;
|
|
22092
22444
|
}
|
|
22093
22445
|
return {
|
|
22094
22446
|
CallExpression(node) {
|
|
22095
22447
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
22096
22448
|
if (unwrappedNodeCallee.type !== AST_NODE_TYPES104.MemberExpression)
|
|
22097
22449
|
return;
|
|
22098
|
-
const method =
|
|
22450
|
+
const method = ASTUtils63.getPropertyName(unwrappedNodeCallee);
|
|
22099
22451
|
if (knownNonDatabase(unwrappedNodeCallee.object)) return;
|
|
22100
22452
|
if (method === null || !isDatabaseOperation(method, unwrappedNodeCallee.object))
|
|
22101
22453
|
return;
|
|
@@ -22195,7 +22547,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
22195
22547
|
});
|
|
22196
22548
|
|
|
22197
22549
|
// src/rules/require-use-form-default-values.ts
|
|
22198
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES106, ASTUtils as
|
|
22550
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES106, ASTUtils as ASTUtils64 } from "@typescript-eslint/utils";
|
|
22199
22551
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
22200
22552
|
summary: "Require explicit form-level initialization or a field default for directly bound Controller fields.",
|
|
22201
22553
|
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.",
|
|
@@ -22226,7 +22578,7 @@ var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
|
22226
22578
|
}
|
|
22227
22579
|
]
|
|
22228
22580
|
};
|
|
22229
|
-
function
|
|
22581
|
+
function staticPropertyName2(property) {
|
|
22230
22582
|
if (property.computed) return null;
|
|
22231
22583
|
if (property.key.type === AST_NODE_TYPES106.Identifier) return property.key.name;
|
|
22232
22584
|
if (property.key.type === AST_NODE_TYPES106.Literal && typeof property.key.value === "string") return property.key.value;
|
|
@@ -22246,7 +22598,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22246
22598
|
const imported = /* @__PURE__ */ new Map();
|
|
22247
22599
|
const uninitializedForms = /* @__PURE__ */ new Set();
|
|
22248
22600
|
const uninitializedControls = /* @__PURE__ */ new Set();
|
|
22249
|
-
const bindingNamed = (node, name) =>
|
|
22601
|
+
const bindingNamed = (node, name) => ASTUtils64.findVariable(context.sourceCode.getScope(node), name);
|
|
22250
22602
|
const bindingOf = (node) => bindingNamed(node, node.name);
|
|
22251
22603
|
const stable = (variable) => !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
22252
22604
|
const importedKind = (node) => {
|
|
@@ -22275,7 +22627,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22275
22627
|
for (const property of node.properties) {
|
|
22276
22628
|
if (property.type === AST_NODE_TYPES106.SpreadElement || property.computed) return "unknown";
|
|
22277
22629
|
if (property.type !== AST_NODE_TYPES106.Property) continue;
|
|
22278
|
-
const name =
|
|
22630
|
+
const name = staticPropertyName2(property);
|
|
22279
22631
|
if (name === "defaultValues" || name === "values") initialization.set(name, !isDefinitelyUndefined(property.value));
|
|
22280
22632
|
}
|
|
22281
22633
|
return [...initialization.values()].some(Boolean) ? "initialized" : "uninitialized";
|
|
@@ -22292,7 +22644,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22292
22644
|
const variable = bindingOf(node);
|
|
22293
22645
|
return variable !== null && stable(variable) && uninitializedControls.has(variable);
|
|
22294
22646
|
}
|
|
22295
|
-
return node.type === AST_NODE_TYPES106.MemberExpression &&
|
|
22647
|
+
return node.type === AST_NODE_TYPES106.MemberExpression && ASTUtils64.getPropertyName(node) !== null && (ASTUtils64.getPropertyName(node) ?? "") === "control" && isUninitializedForm(node.object);
|
|
22296
22648
|
};
|
|
22297
22649
|
const fieldOptionsNeedDefault = (node) => {
|
|
22298
22650
|
if (node?.type !== AST_NODE_TYPES106.ObjectExpression) return false;
|
|
@@ -22301,7 +22653,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22301
22653
|
for (const property of node.properties) {
|
|
22302
22654
|
if (property.type === AST_NODE_TYPES106.SpreadElement || property.computed) return false;
|
|
22303
22655
|
if (property.type !== AST_NODE_TYPES106.Property) continue;
|
|
22304
|
-
const name =
|
|
22656
|
+
const name = staticPropertyName2(property);
|
|
22305
22657
|
if (name === "control") control = property.value;
|
|
22306
22658
|
if (name === "defaultValue") hasDefault = !isDefinitelyUndefined(property.value);
|
|
22307
22659
|
}
|
|
@@ -22317,7 +22669,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22317
22669
|
};
|
|
22318
22670
|
const trackDestructuredControl = (pattern) => {
|
|
22319
22671
|
for (const property of pattern.properties) {
|
|
22320
|
-
if (property.type !== AST_NODE_TYPES106.Property ||
|
|
22672
|
+
if (property.type !== AST_NODE_TYPES106.Property || staticPropertyName2(property) !== "control" || property.value.type !== AST_NODE_TYPES106.Identifier) continue;
|
|
22321
22673
|
const variable = bindingOf(property.value);
|
|
22322
22674
|
if (variable !== null) uninitializedControls.add(variable);
|
|
22323
22675
|
}
|
|
@@ -22348,7 +22700,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22348
22700
|
trackDestructuredControl(node.id);
|
|
22349
22701
|
return;
|
|
22350
22702
|
}
|
|
22351
|
-
if (node.id.type === AST_NODE_TYPES106.Identifier && node.init.type === AST_NODE_TYPES106.MemberExpression &&
|
|
22703
|
+
if (node.id.type === AST_NODE_TYPES106.Identifier && node.init.type === AST_NODE_TYPES106.MemberExpression && ASTUtils64.getPropertyName(node.init) !== null && (ASTUtils64.getPropertyName(node.init) ?? "") === "control" && isUninitializedForm(node.init.object)) {
|
|
22352
22704
|
const variable = bindingOf(node.id);
|
|
22353
22705
|
if (variable !== null) uninitializedControls.add(variable);
|
|
22354
22706
|
}
|
|
@@ -22441,7 +22793,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
22441
22793
|
// src/rules/require-zod-form-validation.ts
|
|
22442
22794
|
import {
|
|
22443
22795
|
AST_NODE_TYPES as AST_NODE_TYPES107,
|
|
22444
|
-
ASTUtils as
|
|
22796
|
+
ASTUtils as ASTUtils65
|
|
22445
22797
|
} from "@typescript-eslint/utils";
|
|
22446
22798
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
22447
22799
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
@@ -22489,7 +22841,7 @@ var isFormDataMethodCall = (node) => {
|
|
|
22489
22841
|
}
|
|
22490
22842
|
if (current.type !== AST_NODE_TYPES107.CallExpression) return false;
|
|
22491
22843
|
const callee = unwrapExpression(current.callee);
|
|
22492
|
-
return callee.type === AST_NODE_TYPES107.MemberExpression &&
|
|
22844
|
+
return callee.type === AST_NODE_TYPES107.MemberExpression && ASTUtils65.getPropertyName(callee) === "formData";
|
|
22493
22845
|
};
|
|
22494
22846
|
var require_zod_form_validation_default = createRule({
|
|
22495
22847
|
name: "require-zod-form-validation",
|
|
@@ -22510,7 +22862,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22510
22862
|
return {};
|
|
22511
22863
|
}
|
|
22512
22864
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
22513
|
-
const resolvedBinding = (identifier) =>
|
|
22865
|
+
const resolvedBinding = (identifier) => ASTUtils65.findVariable(
|
|
22514
22866
|
context.sourceCode.getScope(identifier),
|
|
22515
22867
|
identifier.name
|
|
22516
22868
|
);
|
|
@@ -22518,7 +22870,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22518
22870
|
const callee = unwrapExpression(node.callee);
|
|
22519
22871
|
const calleeReceiver = callee.type === AST_NODE_TYPES107.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
22520
22872
|
if (callee.type !== AST_NODE_TYPES107.MemberExpression) return false;
|
|
22521
|
-
if (
|
|
22873
|
+
if (ASTUtils65.getPropertyName(callee) === null || !FORM_VALUE_METHODS.has(ASTUtils65.getPropertyName(callee) ?? "")) {
|
|
22522
22874
|
return false;
|
|
22523
22875
|
}
|
|
22524
22876
|
return isFormSourceIdentifier(calleeReceiver);
|
|
@@ -22549,7 +22901,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22549
22901
|
parent = parent.parent;
|
|
22550
22902
|
continue;
|
|
22551
22903
|
}
|
|
22552
|
-
if (parent.type === AST_NODE_TYPES107.CallExpression && parent.callee.type === AST_NODE_TYPES107.MemberExpression && parent.callee.object.type === AST_NODE_TYPES107.Identifier && parent.callee.object.name === "Object" &&
|
|
22904
|
+
if (parent.type === AST_NODE_TYPES107.CallExpression && parent.callee.type === AST_NODE_TYPES107.MemberExpression && parent.callee.object.type === AST_NODE_TYPES107.Identifier && parent.callee.object.name === "Object" && ASTUtils65.getPropertyName(parent.callee) === "fromEntries" && (resolvedBinding(parent.callee.object)?.defs.length ?? 0) === 0) {
|
|
22553
22905
|
parent = parent.parent;
|
|
22554
22906
|
continue;
|
|
22555
22907
|
}
|
|
@@ -22562,7 +22914,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22562
22914
|
if (node.type !== AST_NODE_TYPES107.CallExpression) return false;
|
|
22563
22915
|
const callee = unwrapExpression(node.callee);
|
|
22564
22916
|
const calleeReceiver = callee.type === AST_NODE_TYPES107.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
22565
|
-
if (callee.type !== AST_NODE_TYPES107.MemberExpression ||
|
|
22917
|
+
if (callee.type !== AST_NODE_TYPES107.MemberExpression || ASTUtils65.getPropertyName(callee) === null || !ZOD_PARSE_METHODS.has(ASTUtils65.getPropertyName(callee) ?? "")) {
|
|
22566
22918
|
return false;
|
|
22567
22919
|
}
|
|
22568
22920
|
const root = zodReceiverRoot(calleeReceiver);
|
|
@@ -22648,7 +23000,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22648
23000
|
};
|
|
22649
23001
|
const zodParseMethod = (call) => {
|
|
22650
23002
|
const callee = unwrapExpression(call.callee);
|
|
22651
|
-
return callee.type === AST_NODE_TYPES107.MemberExpression &&
|
|
23003
|
+
return callee.type === AST_NODE_TYPES107.MemberExpression && ASTUtils65.getPropertyName(callee) !== null ? ASTUtils65.getPropertyName(callee) ?? "" : null;
|
|
22652
23004
|
};
|
|
22653
23005
|
const isSafePrevalidationInspection = (identifier) => {
|
|
22654
23006
|
const parent = identifier.parent;
|
|
@@ -22824,7 +23176,7 @@ function expressionCallableName(current) {
|
|
|
22824
23176
|
}
|
|
22825
23177
|
|
|
22826
23178
|
// src/rules/stepdown.ts
|
|
22827
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES108, ASTUtils as
|
|
23179
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES108, ASTUtils as ASTUtils66 } from "@typescript-eslint/utils";
|
|
22828
23180
|
var STEPDOWN_DOCUMENTATION = {
|
|
22829
23181
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
22830
23182
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -23124,7 +23476,7 @@ function receiverOrigin(context, object, receivers) {
|
|
|
23124
23476
|
while (true) {
|
|
23125
23477
|
const unwrapped = unwrapExpression4(current);
|
|
23126
23478
|
if (unwrapped.type !== AST_NODE_TYPES108.Identifier) return unwrapped;
|
|
23127
|
-
const variable =
|
|
23479
|
+
const variable = ASTUtils66.findVariable(context.sourceCode.getScope(unwrapped), unwrapped.name);
|
|
23128
23480
|
if (variable === null) return null;
|
|
23129
23481
|
const known = receivers.get(variable);
|
|
23130
23482
|
if (known !== void 0) return known;
|
|
@@ -23305,11 +23657,11 @@ function classScope(context, node, computedReferences) {
|
|
|
23305
23657
|
function classReceiverBindings(context, node) {
|
|
23306
23658
|
const classReceivers = /* @__PURE__ */ new Map();
|
|
23307
23659
|
if (node.id !== null) {
|
|
23308
|
-
const internal =
|
|
23660
|
+
const internal = ASTUtils66.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
23309
23661
|
if (internal !== null && stableVariable(internal)) classReceivers.set(internal, true);
|
|
23310
23662
|
}
|
|
23311
23663
|
if (node.type === AST_NODE_TYPES108.ClassExpression && node.parent.type === AST_NODE_TYPES108.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES108.Identifier && node.parent.parent.type === AST_NODE_TYPES108.VariableDeclaration && node.parent.parent.kind === "const") {
|
|
23312
|
-
const outer =
|
|
23664
|
+
const outer = ASTUtils66.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
23313
23665
|
if (outer !== null && stableVariable(outer)) classReceivers.set(outer, true);
|
|
23314
23666
|
}
|
|
23315
23667
|
return classReceivers;
|
|
@@ -23395,7 +23747,7 @@ function classMethodCounts(body2, methods) {
|
|
|
23395
23747
|
}
|
|
23396
23748
|
|
|
23397
23749
|
// src/rules/source-coupled-test.ts
|
|
23398
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES109, ASTUtils as
|
|
23750
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES109, ASTUtils as ASTUtils67 } from "@typescript-eslint/utils";
|
|
23399
23751
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc?|toml|py|[cm]?[jt]s)$/iu;
|
|
23400
23752
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
23401
23753
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -23512,7 +23864,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23512
23864
|
const scopes = [newScope()];
|
|
23513
23865
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
23514
23866
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
23515
|
-
const bindingOf = (node) =>
|
|
23867
|
+
const bindingOf = (node) => ASTUtils67.findVariable(context.sourceCode.getScope(node), node.name);
|
|
23516
23868
|
const assertionKind = (node) => {
|
|
23517
23869
|
const binding = bindingOf(node);
|
|
23518
23870
|
if (binding === null || binding.defs.length === 0) {
|
|
@@ -23565,7 +23917,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23565
23917
|
return visible("fsReaders", callee) && sourcePath(current.arguments[0]);
|
|
23566
23918
|
}
|
|
23567
23919
|
if (callee.type !== AST_NODE_TYPES109.MemberExpression) return false;
|
|
23568
|
-
const name2 =
|
|
23920
|
+
const name2 = ASTUtils67.getPropertyName(callee);
|
|
23569
23921
|
const object = unwrap6(calleeReceiver);
|
|
23570
23922
|
return name2 !== null && FS_READERS.has(name2) && object.type === AST_NODE_TYPES109.Identifier && visible("fsObjects", object) && sourcePath(current.arguments[0]);
|
|
23571
23923
|
};
|
|
@@ -23574,12 +23926,12 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23574
23926
|
if (current.type === AST_NODE_TYPES109.Identifier) return visibleRawOrigins(current);
|
|
23575
23927
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
23576
23928
|
if (current.type === AST_NODE_TYPES109.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
23577
|
-
if (current.type === AST_NODE_TYPES109.MemberExpression &&
|
|
23929
|
+
if (current.type === AST_NODE_TYPES109.MemberExpression && ASTUtils67.getPropertyName(current) === "length") return rawOrigins(current.object);
|
|
23578
23930
|
if (current.type !== AST_NODE_TYPES109.CallExpression) return /* @__PURE__ */ new Set();
|
|
23579
23931
|
const callee = unwrap6(current.callee);
|
|
23580
23932
|
const calleeReceiver = callee.type === AST_NODE_TYPES109.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
23581
23933
|
if (callee.type !== AST_NODE_TYPES109.MemberExpression) return /* @__PURE__ */ new Set();
|
|
23582
|
-
const name2 =
|
|
23934
|
+
const name2 = ASTUtils67.getPropertyName(callee);
|
|
23583
23935
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(calleeReceiver) : /* @__PURE__ */ new Set();
|
|
23584
23936
|
};
|
|
23585
23937
|
const evidenceOrigins = (node) => {
|
|
@@ -23592,7 +23944,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23592
23944
|
const callee = unwrap6(current.callee);
|
|
23593
23945
|
const calleeReceiver = callee.type === AST_NODE_TYPES109.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
23594
23946
|
if (callee.type !== AST_NODE_TYPES109.MemberExpression) return /* @__PURE__ */ new Set();
|
|
23595
|
-
const name2 =
|
|
23947
|
+
const name2 = ASTUtils67.getPropertyName(callee);
|
|
23596
23948
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(calleeReceiver);
|
|
23597
23949
|
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES109.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
23598
23950
|
return /* @__PURE__ */ new Set();
|
|
@@ -23604,10 +23956,10 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23604
23956
|
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES109.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
23605
23957
|
}
|
|
23606
23958
|
if (callee.type !== AST_NODE_TYPES109.MemberExpression) return /* @__PURE__ */ new Set();
|
|
23607
|
-
const matcher =
|
|
23959
|
+
const matcher = ASTUtils67.getPropertyName(callee);
|
|
23608
23960
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
23609
23961
|
let receiver = unwrap6(calleeReceiver);
|
|
23610
|
-
while (receiver.type === AST_NODE_TYPES109.MemberExpression && EXPECT_MODIFIERS2.has(
|
|
23962
|
+
while (receiver.type === AST_NODE_TYPES109.MemberExpression && EXPECT_MODIFIERS2.has(ASTUtils67.getPropertyName(receiver) ?? "")) receiver = unwrap6(receiver.object);
|
|
23611
23963
|
const expectCallee = receiver.type === AST_NODE_TYPES109.CallExpression ? unwrapExpression(receiver.callee) : null;
|
|
23612
23964
|
if (receiver.type === AST_NODE_TYPES109.CallExpression && expectCallee?.type === AST_NODE_TYPES109.Identifier && assertionKind(expectCallee) === "expect") {
|
|
23613
23965
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
@@ -23890,7 +24242,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
23890
24242
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
23891
24243
|
import {
|
|
23892
24244
|
AST_NODE_TYPES as AST_NODE_TYPES111,
|
|
23893
|
-
ASTUtils as
|
|
24245
|
+
ASTUtils as ASTUtils68
|
|
23894
24246
|
} from "@typescript-eslint/utils";
|
|
23895
24247
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
23896
24248
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
@@ -24023,7 +24375,7 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
24023
24375
|
"superRefine",
|
|
24024
24376
|
"transform"
|
|
24025
24377
|
]);
|
|
24026
|
-
var terminalMethodName = (callee) =>
|
|
24378
|
+
var terminalMethodName = (callee) => ASTUtils68.getPropertyName(callee) !== null ? ASTUtils68.getPropertyName(callee) ?? "" : null;
|
|
24027
24379
|
var calleeChainRoot2 = (node) => {
|
|
24028
24380
|
let current = node;
|
|
24029
24381
|
for (; ; ) {
|
|
@@ -24048,8 +24400,8 @@ var chainMemberNames2 = (node) => {
|
|
|
24048
24400
|
for (; ; ) {
|
|
24049
24401
|
current = unwrapExpression(current);
|
|
24050
24402
|
if (current.type === AST_NODE_TYPES111.MemberExpression) {
|
|
24051
|
-
if (
|
|
24052
|
-
names.push(
|
|
24403
|
+
if (ASTUtils68.getPropertyName(current) === null) return [];
|
|
24404
|
+
names.push(ASTUtils68.getPropertyName(current) ?? "");
|
|
24053
24405
|
current = current.object;
|
|
24054
24406
|
continue;
|
|
24055
24407
|
}
|
|
@@ -24086,7 +24438,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24086
24438
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
24087
24439
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
24088
24440
|
function resolvedBinding(identifier) {
|
|
24089
|
-
return
|
|
24441
|
+
return ASTUtils68.findVariable(
|
|
24090
24442
|
context.sourceCode.getScope(identifier),
|
|
24091
24443
|
identifier.name
|
|
24092
24444
|
);
|
|
@@ -24357,7 +24709,7 @@ var RULES = {
|
|
|
24357
24709
|
};
|
|
24358
24710
|
var meta = {
|
|
24359
24711
|
name: "@sarj/eslint-plugin",
|
|
24360
|
-
version:
|
|
24712
|
+
version: package_default.version
|
|
24361
24713
|
};
|
|
24362
24714
|
var APPLICATION_ONLY_RULES = [];
|
|
24363
24715
|
var LIBRARY_IMPORT_POLICY = ["error", {
|