@sarj/eslint-plugin 16.4.7 → 16.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +880 -420
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +1111 -651
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -49,6 +49,125 @@ __export(src_exports, {
|
|
|
49
49
|
});
|
|
50
50
|
module.exports = __toCommonJS(src_exports);
|
|
51
51
|
|
|
52
|
+
// package.json
|
|
53
|
+
var package_default = {
|
|
54
|
+
name: "@sarj/eslint-plugin",
|
|
55
|
+
version: "16.5.0",
|
|
56
|
+
packageManager: "npm@12.1.0",
|
|
57
|
+
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
58
|
+
type: "module",
|
|
59
|
+
main: "./dist/index.cjs",
|
|
60
|
+
module: "./dist/index.js",
|
|
61
|
+
types: "./dist/index.d.ts",
|
|
62
|
+
exports: {
|
|
63
|
+
".": {
|
|
64
|
+
types: "./dist/index.d.ts",
|
|
65
|
+
import: "./dist/index.js",
|
|
66
|
+
require: "./dist/index.cjs"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
files: [
|
|
70
|
+
"dist",
|
|
71
|
+
"README.md",
|
|
72
|
+
"LICENSE"
|
|
73
|
+
],
|
|
74
|
+
publishConfig: {
|
|
75
|
+
access: "public"
|
|
76
|
+
},
|
|
77
|
+
sideEffects: false,
|
|
78
|
+
repository: {
|
|
79
|
+
type: "git",
|
|
80
|
+
url: "git+https://github.com/sarj-ai/code-standards.git",
|
|
81
|
+
directory: "packages/typescript"
|
|
82
|
+
},
|
|
83
|
+
homepage: "https://code-standards.sarj.ai/rules/eslint/",
|
|
84
|
+
bugs: {
|
|
85
|
+
url: "https://github.com/sarj-ai/code-standards/issues"
|
|
86
|
+
},
|
|
87
|
+
scripts: {
|
|
88
|
+
build: "tsup",
|
|
89
|
+
dogfood: "npm run build && npm run dogfood:built",
|
|
90
|
+
lint: "eslint . ../../.github/scripts ../standards/src ../standards/eslint.config.mjs --max-warnings 0",
|
|
91
|
+
prepack: "npm run build && npm run verify-package",
|
|
92
|
+
test: "vitest run",
|
|
93
|
+
typecheck: "tsc --noEmit",
|
|
94
|
+
"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)}"`,
|
|
95
|
+
"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'))"`
|
|
96
|
+
},
|
|
97
|
+
keywords: [
|
|
98
|
+
"eslint",
|
|
99
|
+
"eslintplugin",
|
|
100
|
+
"eslint-plugin",
|
|
101
|
+
"sarj",
|
|
102
|
+
"react",
|
|
103
|
+
"nextjs",
|
|
104
|
+
"zod"
|
|
105
|
+
],
|
|
106
|
+
author: "sarj-ai",
|
|
107
|
+
license: "MIT",
|
|
108
|
+
dependencies: {
|
|
109
|
+
"@typescript-eslint/typescript-estree": "^8.70.1",
|
|
110
|
+
"@typescript-eslint/utils": "^8.70.1",
|
|
111
|
+
"jsonc-parser": "^3.3.1"
|
|
112
|
+
},
|
|
113
|
+
devDependencies: {
|
|
114
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
|
|
115
|
+
"@eslint/compat": "^2.1.1",
|
|
116
|
+
"@eslint/js": "10.0.1",
|
|
117
|
+
"@shadcn/lint": "0.2.0",
|
|
118
|
+
"@types/node": "26.6.2",
|
|
119
|
+
"@typescript-eslint/parser": "8.70.1",
|
|
120
|
+
"@typescript-eslint/rule-tester": "8.70.1",
|
|
121
|
+
"@typescript-eslint/utils": "8.70.1",
|
|
122
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
123
|
+
"@vitest/eslint-plugin": "1.6.27",
|
|
124
|
+
eslint: "10.11.0",
|
|
125
|
+
"eslint-node-test": "0.4.0",
|
|
126
|
+
"eslint-plugin-better-tailwindcss": "^4.7.0",
|
|
127
|
+
"eslint-plugin-jest": "29.16.6",
|
|
128
|
+
"eslint-plugin-jsdoc": "64.5.4",
|
|
129
|
+
"eslint-plugin-n": "^18.3.0",
|
|
130
|
+
"eslint-plugin-perfectionist": "5.12.1",
|
|
131
|
+
"eslint-plugin-playwright": "2.12.0",
|
|
132
|
+
"eslint-plugin-promise": "^7.3.0",
|
|
133
|
+
"eslint-plugin-react": "^7.37.5",
|
|
134
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
135
|
+
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
136
|
+
"eslint-plugin-testing-library": "7.16.2",
|
|
137
|
+
"eslint-plugin-unicorn": "^76.0.0",
|
|
138
|
+
"eslint-plugin-zod": "^4.14.2",
|
|
139
|
+
globals: "15.15.0",
|
|
140
|
+
tsup: "latest",
|
|
141
|
+
typescript: "npm:@typescript/typescript6@6.0.2",
|
|
142
|
+
"typescript-eslint": "^8.70.1",
|
|
143
|
+
vitest: "5.0.1"
|
|
144
|
+
},
|
|
145
|
+
peerDependencies: {
|
|
146
|
+
eslint: ">=9.39.4",
|
|
147
|
+
typescript: ">=5.0.0"
|
|
148
|
+
},
|
|
149
|
+
engines: {
|
|
150
|
+
node: ">=22.22.2"
|
|
151
|
+
},
|
|
152
|
+
allowScripts: {
|
|
153
|
+
"esbuild@0.28.2": true,
|
|
154
|
+
"fsevents@2.3.3": true
|
|
155
|
+
},
|
|
156
|
+
peerDependenciesMeta: {
|
|
157
|
+
typescript: {
|
|
158
|
+
optional: true
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
overrides: {
|
|
162
|
+
"brace-expansion@^5.0.0": "5.0.9",
|
|
163
|
+
esbuild: "0.28.2",
|
|
164
|
+
"nanoid@<3.3.18": "3.3.18",
|
|
165
|
+
"eslint-plugin-react": {
|
|
166
|
+
eslint: "$eslint"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
52
171
|
// src/rules/require-explicit-contract-implementation.ts
|
|
53
172
|
var import_utils2 = require("@typescript-eslint/utils");
|
|
54
173
|
var ts = __toESM(require("typescript"), 1);
|
|
@@ -4794,6 +4913,41 @@ function staticString(node) {
|
|
|
4794
4913
|
if (value.type === import_utils29.AST_NODE_TYPES.Literal && typeof value.value === "string") return value.value;
|
|
4795
4914
|
return value.type === import_utils29.AST_NODE_TYPES.TemplateLiteral && value.expressions.length === 0 ? value.quasis[0]?.value.cooked ?? null : null;
|
|
4796
4915
|
}
|
|
4916
|
+
var SCOPED_STRING_VALUES = /* @__PURE__ */ new WeakMap();
|
|
4917
|
+
function scopedStaticString(node, sourceCode) {
|
|
4918
|
+
let value = unwrapExpression(node);
|
|
4919
|
+
if (value.type !== import_utils29.AST_NODE_TYPES.Identifier) return staticString(value);
|
|
4920
|
+
let values = SCOPED_STRING_VALUES.get(sourceCode);
|
|
4921
|
+
if (values === void 0) {
|
|
4922
|
+
values = /* @__PURE__ */ new WeakMap();
|
|
4923
|
+
SCOPED_STRING_VALUES.set(sourceCode, values);
|
|
4924
|
+
}
|
|
4925
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4926
|
+
const pending = [];
|
|
4927
|
+
let result = null;
|
|
4928
|
+
while (value.type === import_utils29.AST_NODE_TYPES.Identifier) {
|
|
4929
|
+
const binding = import_utils29.ASTUtils.findVariable(sourceCode.getScope(value), value.name);
|
|
4930
|
+
if (binding === null || seen.has(binding)) break;
|
|
4931
|
+
if (values.has(binding)) {
|
|
4932
|
+
result = values.get(binding) ?? null;
|
|
4933
|
+
break;
|
|
4934
|
+
}
|
|
4935
|
+
seen.add(binding);
|
|
4936
|
+
pending.push(binding);
|
|
4937
|
+
const definition = binding.defs.length === 1 ? binding.defs[0] : void 0;
|
|
4938
|
+
if (definition?.type !== "Variable" || definition.node.id.type !== import_utils29.AST_NODE_TYPES.Identifier || definition.node.init === null || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) break;
|
|
4939
|
+
value = unwrapExpression(definition.node.init);
|
|
4940
|
+
if (value.type !== import_utils29.AST_NODE_TYPES.Identifier) result = staticString(value);
|
|
4941
|
+
}
|
|
4942
|
+
for (const binding of pending) values.set(binding, result);
|
|
4943
|
+
return result;
|
|
4944
|
+
}
|
|
4945
|
+
function staticPropertyName(node, sourceCode) {
|
|
4946
|
+
const direct = import_utils29.ASTUtils.getPropertyName(node);
|
|
4947
|
+
if (direct !== null || !node.computed) return direct;
|
|
4948
|
+
const key = node.type === import_utils29.AST_NODE_TYPES.MemberExpression ? node.property : node.key;
|
|
4949
|
+
return key.type === import_utils29.AST_NODE_TYPES.Identifier ? scopedStaticString(key, sourceCode) : null;
|
|
4950
|
+
}
|
|
4797
4951
|
|
|
4798
4952
|
// src/rules/no-duplicate-lifecycle-refresh-listeners.ts
|
|
4799
4953
|
var NO_DUPLICATE_LIFECYCLE_REFRESH_LISTENERS_DOCUMENTATION = {
|
|
@@ -6833,31 +6987,26 @@ var NO_JSON_STRINGIFY_ERROR_DOCUMENTATION = {
|
|
|
6833
6987
|
rationale: "Native Error details are non-enumerable, so generic JSON serialization discards diagnostic information.",
|
|
6834
6988
|
remediation: "Serialize explicit error fields or use an error-aware serializer.",
|
|
6835
6989
|
category: "correctness",
|
|
6836
|
-
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."],
|
|
6990
|
+
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."],
|
|
6837
6991
|
examples: [
|
|
6838
6992
|
{ 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 },
|
|
6839
6993
|
{ 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 },
|
|
6840
6994
|
{ 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 },
|
|
6841
|
-
{ 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 }
|
|
6995
|
+
{ 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 },
|
|
6996
|
+
{ 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 },
|
|
6997
|
+
{ 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 },
|
|
6998
|
+
{ "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 },
|
|
6999
|
+
{ "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 },
|
|
7000
|
+
{ "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 },
|
|
7001
|
+
{ "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 },
|
|
7002
|
+
{ "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 },
|
|
7003
|
+
{ "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 },
|
|
7004
|
+
{ "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 },
|
|
7005
|
+
{ "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 },
|
|
7006
|
+
{ "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 },
|
|
7007
|
+
{ "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 }
|
|
6842
7008
|
]
|
|
6843
7009
|
};
|
|
6844
|
-
var SAFE_STRING_PROPS = /* @__PURE__ */ new Set(["message", "stack", "name"]);
|
|
6845
|
-
var PAYLOAD_PROPS = /* @__PURE__ */ new Set([
|
|
6846
|
-
"data",
|
|
6847
|
-
"status",
|
|
6848
|
-
"statuscode",
|
|
6849
|
-
"statustext",
|
|
6850
|
-
"code",
|
|
6851
|
-
"issues",
|
|
6852
|
-
"details",
|
|
6853
|
-
"body",
|
|
6854
|
-
"payload",
|
|
6855
|
-
"response",
|
|
6856
|
-
"info",
|
|
6857
|
-
"meta",
|
|
6858
|
-
"metadata",
|
|
6859
|
-
"context"
|
|
6860
|
-
]);
|
|
6861
7010
|
var BUILTIN_ERROR_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
6862
7011
|
"AggregateError",
|
|
6863
7012
|
"Error",
|
|
@@ -6868,14 +7017,200 @@ var BUILTIN_ERROR_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
6868
7017
|
"TypeError",
|
|
6869
7018
|
"URIError"
|
|
6870
7019
|
]);
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
const
|
|
6875
|
-
if (
|
|
6876
|
-
if (
|
|
6877
|
-
|
|
6878
|
-
|
|
7020
|
+
var TRACKED_BUILTINS = /* @__PURE__ */ new Set([...BUILTIN_ERROR_CONSTRUCTORS, "JSON", "JSON.stringify"]);
|
|
7021
|
+
function nativeObjectName(expression, sourceCode) {
|
|
7022
|
+
const value = unwrapExpression(expression);
|
|
7023
|
+
const scope = sourceCode.getScope(value);
|
|
7024
|
+
if (value.type === "Identifier" && (value.name === "globalThis" || value.name === "JSON") && isGlobalIdentifier(value.name, scope)) return value.name;
|
|
7025
|
+
if (value.type === "MemberExpression" && nativeObjectName(value.object, sourceCode) === "globalThis" && staticPropertyName(value, sourceCode) === "JSON") return "JSON";
|
|
7026
|
+
return null;
|
|
7027
|
+
}
|
|
7028
|
+
function globalBuiltinName(expression, sourceCode) {
|
|
7029
|
+
const value = unwrapExpression(expression);
|
|
7030
|
+
const scope = sourceCode.getScope(value);
|
|
7031
|
+
if (value.type === "Identifier") return TRACKED_BUILTINS.has(value.name) && isGlobalIdentifier(value.name, scope) ? value.name : null;
|
|
7032
|
+
if (value.type !== "MemberExpression") return null;
|
|
7033
|
+
const receiver = nativeObjectName(value.object, sourceCode);
|
|
7034
|
+
const name = staticPropertyName(value, sourceCode);
|
|
7035
|
+
if (receiver === "JSON") return name === "stringify" ? "JSON.stringify" : null;
|
|
7036
|
+
return receiver === "globalThis" && name !== null && name !== "JSON.stringify" && TRACKED_BUILTINS.has(name) ? name : null;
|
|
7037
|
+
}
|
|
7038
|
+
function writePreservesBuiltin(target, sourceCode) {
|
|
7039
|
+
const assignment = target.parent;
|
|
7040
|
+
if (assignment?.type !== "AssignmentExpression" || assignment.left !== target) return false;
|
|
7041
|
+
const name = globalBuiltinName(target, sourceCode);
|
|
7042
|
+
if (name === null) return false;
|
|
7043
|
+
if (assignment.operator === "||=" || assignment.operator === "??=") return true;
|
|
7044
|
+
return (assignment.operator === "=" || assignment.operator === "&&=") && globalBuiltinName(assignment.right, sourceCode) === name;
|
|
7045
|
+
}
|
|
7046
|
+
function mayBeCallable(value) {
|
|
7047
|
+
return !["Literal", "TemplateLiteral", "ObjectExpression", "ArrayExpression"].includes(value.type);
|
|
7048
|
+
}
|
|
7049
|
+
var BUILTIN_WRITES = /* @__PURE__ */ new WeakMap();
|
|
7050
|
+
function directProgramStatement(node) {
|
|
7051
|
+
let current = node;
|
|
7052
|
+
while (current.parent !== void 0) {
|
|
7053
|
+
if (current.parent.type === "Program") return current;
|
|
7054
|
+
if (["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression", "ClassBody", "StaticBlock", "ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement"].includes(current.parent.type)) return null;
|
|
7055
|
+
current = current.parent;
|
|
7056
|
+
}
|
|
7057
|
+
return null;
|
|
7058
|
+
}
|
|
7059
|
+
function hasUnchangedBuiltin(name, read, sourceCode) {
|
|
7060
|
+
const summary = builtinWrites(sourceCode).get(name);
|
|
7061
|
+
if (summary === void 0) return true;
|
|
7062
|
+
const statement = directProgramStatement(read);
|
|
7063
|
+
return !summary.unknownOrder && statement !== null && statement.range[1] <= summary.earliestStatementStart;
|
|
7064
|
+
}
|
|
7065
|
+
function builtinWrites(sourceCode) {
|
|
7066
|
+
const cached = BUILTIN_WRITES.get(sourceCode);
|
|
7067
|
+
if (cached !== void 0) return cached;
|
|
7068
|
+
const writes = /* @__PURE__ */ new Map();
|
|
7069
|
+
const record = (name, node) => {
|
|
7070
|
+
const statement = directProgramStatement(node);
|
|
7071
|
+
const existing = writes.get(name);
|
|
7072
|
+
writes.set(name, { earliestStatementStart: Math.min(existing?.earliestStatementStart ?? Infinity, statement?.range[0] ?? Infinity), unknownOrder: (existing?.unknownOrder ?? false) || statement === null });
|
|
7073
|
+
};
|
|
7074
|
+
for (const scope of sourceCode.scopeManager?.scopes ?? []) {
|
|
7075
|
+
for (const reference of scope.references) {
|
|
7076
|
+
const name = reference.identifier.name;
|
|
7077
|
+
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);
|
|
7078
|
+
}
|
|
7079
|
+
}
|
|
7080
|
+
const propertyReceiver = (expression) => {
|
|
7081
|
+
const native = nativeObjectName(expression, sourceCode);
|
|
7082
|
+
if (native !== null) return native;
|
|
7083
|
+
const value = unwrapExpression(expression);
|
|
7084
|
+
if (value.type === "Identifier") return import_utils41.ASTUtils.findVariable(sourceCode.getScope(value), value.name);
|
|
7085
|
+
if (value.type === "MemberExpression" && staticPropertyName(value, sourceCode) === "prototype") {
|
|
7086
|
+
const constructor = globalBuiltinName(value.object, sourceCode);
|
|
7087
|
+
if (constructor !== null && BUILTIN_ERROR_CONSTRUCTORS.has(constructor)) return constructor + ".prototype";
|
|
7088
|
+
}
|
|
7089
|
+
return null;
|
|
7090
|
+
};
|
|
7091
|
+
const propertyWrite = (receiver, name, node) => {
|
|
7092
|
+
if (receiver === "JSON") {
|
|
7093
|
+
if (name === null || name === "stringify") record("JSON.stringify", node);
|
|
7094
|
+
} else if (receiver === "globalThis") {
|
|
7095
|
+
if (name === null) {
|
|
7096
|
+
for (const builtin of TRACKED_BUILTINS) record(builtin, node);
|
|
7097
|
+
} else if (name !== "JSON.stringify" && TRACKED_BUILTINS.has(name)) record(name, node);
|
|
7098
|
+
} else if (name === null || name === "toJSON") record(receiver, node);
|
|
7099
|
+
};
|
|
7100
|
+
const visit = (node) => {
|
|
7101
|
+
if (node.type === "AssignmentExpression") propertyTarget(node.left);
|
|
7102
|
+
else if (node.type === "UpdateExpression") propertyTarget(node.argument);
|
|
7103
|
+
else if (node.type === "ForInStatement" || node.type === "ForOfStatement") propertyTarget(node.left);
|
|
7104
|
+
else if (node.type === "UnaryExpression" && node.operator === "delete") propertyTarget(node.argument);
|
|
7105
|
+
else if (node.type === "CallExpression") mutationCall(node);
|
|
7106
|
+
forEachAstChild(node, sourceCode.visitorKeys, visit);
|
|
7107
|
+
};
|
|
7108
|
+
function propertyTarget(target) {
|
|
7109
|
+
if (target.type === "MemberExpression") {
|
|
7110
|
+
memberPropertyWrite(target);
|
|
7111
|
+
return;
|
|
7112
|
+
}
|
|
7113
|
+
switch (target.type) {
|
|
7114
|
+
case "ObjectPattern":
|
|
7115
|
+
for (const property of target.properties) propertyTarget(property.type === "RestElement" ? property.argument : property.value);
|
|
7116
|
+
return;
|
|
7117
|
+
case "ArrayPattern":
|
|
7118
|
+
for (const element of target.elements) if (element !== null) propertyTarget(element);
|
|
7119
|
+
return;
|
|
7120
|
+
case "AssignmentPattern":
|
|
7121
|
+
propertyTarget(target.left);
|
|
7122
|
+
return;
|
|
7123
|
+
case "RestElement":
|
|
7124
|
+
propertyTarget(target.argument);
|
|
7125
|
+
}
|
|
7126
|
+
}
|
|
7127
|
+
function memberPropertyWrite(target) {
|
|
7128
|
+
const receiver = propertyReceiver(target.object);
|
|
7129
|
+
if (receiver === null || writePreservesBuiltin(target, sourceCode)) return;
|
|
7130
|
+
const name = staticPropertyName(target, sourceCode);
|
|
7131
|
+
if (name === "toJSON") {
|
|
7132
|
+
const assignment = target.parent;
|
|
7133
|
+
if (assignment?.type === "UnaryExpression" && assignment.operator === "delete") return;
|
|
7134
|
+
if (assignment?.type === "AssignmentExpression" && assignment.operator === "=" && !mayBeCallable(assignment.right)) return;
|
|
7135
|
+
}
|
|
7136
|
+
propertyWrite(receiver, name, target);
|
|
7137
|
+
}
|
|
7138
|
+
function mutationCall(node) {
|
|
7139
|
+
const callee = unwrapExpression(node.callee);
|
|
7140
|
+
if (callee.type !== "MemberExpression" || callee.object.type !== "Identifier") return;
|
|
7141
|
+
const owner = callee.object.name;
|
|
7142
|
+
if (!["Reflect", "Object"].includes(owner) || !isGlobalIdentifier(owner, sourceCode.getScope(callee))) return;
|
|
7143
|
+
const method = staticPropertyName(callee, sourceCode);
|
|
7144
|
+
const [target, key, value, receiver] = node.arguments;
|
|
7145
|
+
if (target === void 0 || target.type === "SpreadElement" || key === void 0) return;
|
|
7146
|
+
const object = propertyReceiver(target);
|
|
7147
|
+
if (object === null) return;
|
|
7148
|
+
switch (method) {
|
|
7149
|
+
case "set":
|
|
7150
|
+
if (owner === "Reflect") reflectSet(object, scopedStaticString(key, sourceCode), value, receiver, node);
|
|
7151
|
+
return;
|
|
7152
|
+
case "defineProperty":
|
|
7153
|
+
descriptorWrite(object, scopedStaticString(key, sourceCode), value, node);
|
|
7154
|
+
return;
|
|
7155
|
+
case "defineProperties":
|
|
7156
|
+
if (owner === "Object") descriptorBatch(object, key, node);
|
|
7157
|
+
}
|
|
7158
|
+
}
|
|
7159
|
+
function reflectSet(object, name, value, receiver, node) {
|
|
7160
|
+
if (receiver !== void 0 && receiver.type !== "SpreadElement" && ["ObjectExpression", "ArrayExpression", "Literal"].includes(unwrapExpression(receiver).type)) return;
|
|
7161
|
+
const builtin = builtinPropertyName(object, name);
|
|
7162
|
+
if (value !== void 0 && value.type !== "SpreadElement" && builtin !== null && globalBuiltinName(value, sourceCode) === builtin) return;
|
|
7163
|
+
if (name === "toJSON" && value !== void 0 && !mayBeCallable(value)) return;
|
|
7164
|
+
propertyWrite(object, name, node);
|
|
7165
|
+
}
|
|
7166
|
+
function descriptorBatch(object, descriptors, node) {
|
|
7167
|
+
if (descriptors.type !== "ObjectExpression") {
|
|
7168
|
+
propertyWrite(object, null, node);
|
|
7169
|
+
return;
|
|
7170
|
+
}
|
|
7171
|
+
for (const property of descriptors.properties) {
|
|
7172
|
+
if (property.type !== "Property") {
|
|
7173
|
+
propertyWrite(object, null, node);
|
|
7174
|
+
continue;
|
|
7175
|
+
}
|
|
7176
|
+
descriptorWrite(object, staticPropertyName(property, sourceCode), property.value, node);
|
|
7177
|
+
}
|
|
7178
|
+
}
|
|
7179
|
+
function descriptorWrite(object, name, descriptor, node) {
|
|
7180
|
+
if (descriptor !== void 0 && !descriptorChangesValue(descriptor, builtinPropertyName(object, name))) return;
|
|
7181
|
+
propertyWrite(object, name, node);
|
|
7182
|
+
}
|
|
7183
|
+
function descriptorChangesValue(descriptor, name) {
|
|
7184
|
+
if (descriptor.type !== "ObjectExpression") return true;
|
|
7185
|
+
return descriptor.properties.some((property) => {
|
|
7186
|
+
if (property.type !== "Property") return true;
|
|
7187
|
+
const key = staticPropertyName(property, sourceCode);
|
|
7188
|
+
if (key === "value" && name === "toJSON" && !mayBeCallable(property.value)) return false;
|
|
7189
|
+
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;
|
|
7190
|
+
return key === null || key === "get" || key === "set";
|
|
7191
|
+
});
|
|
7192
|
+
}
|
|
7193
|
+
function builtinPropertyName(object, name) {
|
|
7194
|
+
return object === "JSON" && name === "stringify" ? "JSON.stringify" : name;
|
|
7195
|
+
}
|
|
7196
|
+
visit(sourceCode.ast);
|
|
7197
|
+
BUILTIN_WRITES.set(sourceCode, writes);
|
|
7198
|
+
return writes;
|
|
7199
|
+
}
|
|
7200
|
+
function hasDefaultErrorSerialization(expression, call, sourceCode) {
|
|
7201
|
+
let constructor = null;
|
|
7202
|
+
if (expression.type === "Identifier") {
|
|
7203
|
+
const variable = import_utils41.ASTUtils.findVariable(sourceCode.getScope(expression), expression.name);
|
|
7204
|
+
if (variable !== null && !hasUnchangedBuiltin(variable, call, sourceCode)) return false;
|
|
7205
|
+
const definition = variable?.defs[0];
|
|
7206
|
+
const initializer = definition?.type === "Variable" ? definition.node.init : null;
|
|
7207
|
+
if (initializer?.type === "NewExpression" && initializer.callee.type === "Identifier") constructor = initializer.callee.name;
|
|
7208
|
+
} else if (expression.type === "NewExpression" && expression.callee.type === "Identifier") constructor = expression.callee.name;
|
|
7209
|
+
const families = constructor === null ? BUILTIN_ERROR_CONSTRUCTORS : ["Error", constructor];
|
|
7210
|
+
return [...families].every((name) => hasUnchangedBuiltin(name + ".prototype", call, sourceCode));
|
|
7211
|
+
}
|
|
7212
|
+
function isBuiltinErrorConstructor(identifier, sourceCode) {
|
|
7213
|
+
return sourceCode.scopeManager !== null && BUILTIN_ERROR_CONSTRUCTORS.has(identifier.name) && isGlobalIdentifier(identifier.name, sourceCode.getScope(identifier)) && hasUnchangedBuiltin(identifier.name, identifier, sourceCode);
|
|
6879
7214
|
}
|
|
6880
7215
|
function isGlobalIdentifier(name, scope) {
|
|
6881
7216
|
const binding = import_utils41.ASTUtils.findVariable(scope, name);
|
|
@@ -6886,7 +7221,7 @@ function positiveErrorSubject(test, sourceCode) {
|
|
|
6886
7221
|
}
|
|
6887
7222
|
var TYPE_GUARD_PATTERN = /^(is|has)[A-Z]/;
|
|
6888
7223
|
function instanceofErrorSubject(test, sourceCode) {
|
|
6889
|
-
if (test.type === "BinaryExpression" && test.operator === "instanceof" && test.right.type === "Identifier" && test.right.name === "Error" &&
|
|
7224
|
+
if (test.type === "BinaryExpression" && test.operator === "instanceof" && test.right.type === "Identifier" && test.right.name === "Error" && isBuiltinErrorConstructor(test.right, sourceCode)) {
|
|
6890
7225
|
return test.left;
|
|
6891
7226
|
}
|
|
6892
7227
|
return null;
|
|
@@ -6954,16 +7289,17 @@ function sameSubjectBinding(subject, value, sourceCode) {
|
|
|
6954
7289
|
function nodeWithin(node, container) {
|
|
6955
7290
|
return container !== null && node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
6956
7291
|
}
|
|
6957
|
-
function isJsonStringify(callee) {
|
|
7292
|
+
function isJsonStringify(callee, sourceCode) {
|
|
6958
7293
|
if (callee.type !== "MemberExpression") return false;
|
|
6959
7294
|
const receiver = unwrapExpression(callee.object);
|
|
6960
|
-
return callee.type === "MemberExpression" && receiver.type === "Identifier" && receiver.name === "JSON" &&
|
|
7295
|
+
return callee.type === "MemberExpression" && receiver.type === "Identifier" && receiver.name === "JSON" && staticPropertyName(callee, sourceCode) === "stringify";
|
|
6961
7296
|
}
|
|
6962
|
-
function directLiteralValues(argument) {
|
|
7297
|
+
function directLiteralValues(argument, sourceCode) {
|
|
6963
7298
|
argument = unwrapExpression(argument);
|
|
6964
7299
|
if (argument.type === "ObjectExpression") {
|
|
7300
|
+
if (literalHasSerializer(argument, sourceCode)) return [];
|
|
6965
7301
|
return argument.properties.flatMap((property) => {
|
|
6966
|
-
if (property.type !== "Property" ||
|
|
7302
|
+
if (property.type !== "Property" || staticPropertyName(property, sourceCode) === null) return [];
|
|
6967
7303
|
const value = property.value;
|
|
6968
7304
|
if (value.type === "AssignmentPattern" || value.type === "ArrayPattern" || value.type === "ObjectPattern" || value.type === "TSEmptyBodyFunctionExpression") {
|
|
6969
7305
|
return [];
|
|
@@ -6978,6 +7314,20 @@ function directLiteralValues(argument) {
|
|
|
6978
7314
|
}
|
|
6979
7315
|
return argument.type === "SpreadElement" ? [] : [argument];
|
|
6980
7316
|
}
|
|
7317
|
+
function literalHasSerializer(argument, sourceCode) {
|
|
7318
|
+
for (const property of argument.properties.toReversed()) {
|
|
7319
|
+
if (property.type !== "Property") return true;
|
|
7320
|
+
const key = staticPropertyName(property, sourceCode);
|
|
7321
|
+
if (key === null) return true;
|
|
7322
|
+
if (key === "toJSON") return mayBeCallable(property.value);
|
|
7323
|
+
}
|
|
7324
|
+
for (const property of argument.properties) {
|
|
7325
|
+
if (property.type !== "Property" || property.computed || property.method || property.shorthand || property.kind !== "init" || staticPropertyName(property, sourceCode) !== "__proto__") continue;
|
|
7326
|
+
const prototype = property.value;
|
|
7327
|
+
return prototype.type === "ObjectExpression" ? literalHasSerializer(prototype, sourceCode) : prototype.type !== "Literal" || "regex" in prototype && prototype.regex !== void 0;
|
|
7328
|
+
}
|
|
7329
|
+
return false;
|
|
7330
|
+
}
|
|
6981
7331
|
function expressionSuggestsError(expression, sourceCode) {
|
|
6982
7332
|
expression = unwrapExpression(expression);
|
|
6983
7333
|
const unwrappedExpressionCallee = expression.type === "CallExpression" || expression.type === "NewExpression" ? unwrapExpression(expression.callee) : null;
|
|
@@ -6985,23 +7335,19 @@ function expressionSuggestsError(expression, sourceCode) {
|
|
|
6985
7335
|
return identifierIsProvenError(expression, sourceCode);
|
|
6986
7336
|
}
|
|
6987
7337
|
if (expression.type === "NewExpression" && unwrappedExpressionCallee?.type === "Identifier") {
|
|
6988
|
-
return
|
|
6989
|
-
}
|
|
6990
|
-
return expression.type === "MemberExpression" && memberSuggestsError(expression, sourceCode);
|
|
6991
|
-
}
|
|
6992
|
-
function memberSuggestsError(member, sourceCode) {
|
|
6993
|
-
const propName2 = import_utils41.ASTUtils.getPropertyName(member);
|
|
6994
|
-
const base = member.object;
|
|
6995
|
-
const baseSuggestsError = base.type === "Identifier" && identifierIsProvenError(base, sourceCode);
|
|
6996
|
-
if (baseSuggestsError) {
|
|
6997
|
-
if (propName2 === null) {
|
|
6998
|
-
return true;
|
|
6999
|
-
}
|
|
7000
|
-
const lowered = propName2.toLowerCase();
|
|
7001
|
-
return !SAFE_STRING_PROPS.has(lowered) && !PAYLOAD_PROPS.has(lowered);
|
|
7338
|
+
return isBuiltinErrorConstructor(unwrappedExpressionCallee, sourceCode);
|
|
7002
7339
|
}
|
|
7003
7340
|
return false;
|
|
7004
7341
|
}
|
|
7342
|
+
function identifierIsProvenError(identifier, sourceCode) {
|
|
7343
|
+
const variable = import_utils41.ASTUtils.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
7344
|
+
if (variable === null || variable.defs.length !== 1 || variable.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
7345
|
+
const definition = variable.defs[0];
|
|
7346
|
+
if (definition?.type === "CatchClause") return true;
|
|
7347
|
+
if (definition?.type !== "Variable") return false;
|
|
7348
|
+
const initializer = definition.node.init;
|
|
7349
|
+
return initializer?.type === "NewExpression" && initializer.callee.type === "Identifier" && isBuiltinErrorConstructor(initializer.callee, sourceCode);
|
|
7350
|
+
}
|
|
7005
7351
|
var no_json_stringify_error_default = createRule({
|
|
7006
7352
|
name: "no-json-stringify-error",
|
|
7007
7353
|
documentation: NO_JSON_STRINGIFY_ERROR_DOCUMENTATION,
|
|
@@ -7020,7 +7366,7 @@ var no_json_stringify_error_default = createRule({
|
|
|
7020
7366
|
return {
|
|
7021
7367
|
CallExpression(node) {
|
|
7022
7368
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
7023
|
-
if (!isJsonStringify(unwrappedNodeCallee)) {
|
|
7369
|
+
if (!isJsonStringify(unwrappedNodeCallee, context.sourceCode)) {
|
|
7024
7370
|
return;
|
|
7025
7371
|
}
|
|
7026
7372
|
const firstArg = node.arguments[0];
|
|
@@ -7028,11 +7374,11 @@ var no_json_stringify_error_default = createRule({
|
|
|
7028
7374
|
return;
|
|
7029
7375
|
}
|
|
7030
7376
|
const scope = context.sourceCode.getScope(firstArg);
|
|
7031
|
-
if (!isGlobalIdentifier("JSON", scope)) return;
|
|
7377
|
+
if (!isGlobalIdentifier("JSON", scope) || !hasUnchangedBuiltin("JSON", node, context.sourceCode) || !hasUnchangedBuiltin("JSON.stringify", node, context.sourceCode)) return;
|
|
7032
7378
|
const replacer = node.arguments[1] === void 0 ? void 0 : unwrapExpression(node.arguments[1]);
|
|
7033
7379
|
if (replacer !== void 0 && !(replacer.type === "Literal" && replacer.value === null) && !(replacer.type === "Identifier" && replacer.name === "undefined" && isGlobalIdentifier("undefined", scope))) return;
|
|
7034
|
-
const unsafeValue = directLiteralValues(firstArg).find(
|
|
7035
|
-
(value) => expressionSuggestsError(value, context.sourceCode) && !isGuardedByInstanceofError(node, value, context.sourceCode) && !isNarrowedByEarlyReturn(node, value, context.sourceCode)
|
|
7380
|
+
const unsafeValue = directLiteralValues(firstArg, context.sourceCode).find(
|
|
7381
|
+
(value) => expressionSuggestsError(value, context.sourceCode) && hasDefaultErrorSerialization(unwrapExpression(value), node, context.sourceCode) && !isGuardedByInstanceofError(node, value, context.sourceCode) && !isNarrowedByEarlyReturn(node, value, context.sourceCode)
|
|
7036
7382
|
);
|
|
7037
7383
|
if (unsafeValue === void 0) {
|
|
7038
7384
|
return;
|
|
@@ -11506,10 +11852,12 @@ var NO_SILENT_PROMISE_CATCH_DOCUMENTATION = {
|
|
|
11506
11852
|
rationale: "A swallowed rejection hides failures and gives callers an indistinguishable fallback value.",
|
|
11507
11853
|
remediation: "Log, rethrow, or explicitly recover from the rejection; explain intentional teardown suppression.",
|
|
11508
11854
|
category: "correctness",
|
|
11509
|
-
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."],
|
|
11855
|
+
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."],
|
|
11510
11856
|
examples: [
|
|
11511
11857
|
{ 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 },
|
|
11512
|
-
{ 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 }
|
|
11858
|
+
{ 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 },
|
|
11859
|
+
{ 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 },
|
|
11860
|
+
{ 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 }
|
|
11513
11861
|
]
|
|
11514
11862
|
};
|
|
11515
11863
|
var BODY_PARSE_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -11557,9 +11905,11 @@ var ZOD_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
11557
11905
|
"superRefine",
|
|
11558
11906
|
"transform"
|
|
11559
11907
|
]);
|
|
11560
|
-
function isBodyParseCall(node) {
|
|
11908
|
+
function isBodyParseCall(node, sourceCode) {
|
|
11561
11909
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
11562
|
-
|
|
11910
|
+
if (node.type !== import_utils68.AST_NODE_TYPES.CallExpression || node.arguments.length !== 0 || unwrappedNodeCallee?.type !== import_utils68.AST_NODE_TYPES.MemberExpression) return false;
|
|
11911
|
+
const method = staticPropertyName(unwrappedNodeCallee, sourceCode);
|
|
11912
|
+
return method !== null && BODY_PARSE_METHODS.has(method);
|
|
11563
11913
|
}
|
|
11564
11914
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
11565
11915
|
"cancel",
|
|
@@ -11573,13 +11923,15 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
11573
11923
|
]);
|
|
11574
11924
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
11575
11925
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
11576
|
-
function isTeardownCall(node) {
|
|
11926
|
+
function isTeardownCall(node, sourceCode) {
|
|
11577
11927
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
11578
|
-
|
|
11928
|
+
if (node.type !== import_utils68.AST_NODE_TYPES.CallExpression || unwrappedNodeCallee?.type !== import_utils68.AST_NODE_TYPES.MemberExpression) return false;
|
|
11929
|
+
const method = staticPropertyName(unwrappedNodeCallee, sourceCode);
|
|
11930
|
+
return method !== null && TEARDOWN_METHODS.has(method);
|
|
11579
11931
|
}
|
|
11580
|
-
function isCancelledWebShare(node) {
|
|
11932
|
+
function isCancelledWebShare(node, sourceCode) {
|
|
11581
11933
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
11582
|
-
return node.type === import_utils68.AST_NODE_TYPES.CallExpression && unwrappedNodeCallee?.type === import_utils68.AST_NODE_TYPES.MemberExpression && unwrappedNodeCallee.object.type === import_utils68.AST_NODE_TYPES.Identifier && unwrappedNodeCallee.object.name === "navigator" &&
|
|
11934
|
+
return node.type === import_utils68.AST_NODE_TYPES.CallExpression && unwrappedNodeCallee?.type === import_utils68.AST_NODE_TYPES.MemberExpression && unwrappedNodeCallee.object.type === import_utils68.AST_NODE_TYPES.Identifier && unwrappedNodeCallee.object.name === "navigator" && staticPropertyName(unwrappedNodeCallee, sourceCode) === "share";
|
|
11583
11935
|
}
|
|
11584
11936
|
function isSilentHandler(handler) {
|
|
11585
11937
|
const body2 = handler.body;
|
|
@@ -11643,9 +11995,9 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11643
11995
|
const [definition] = binding.defs;
|
|
11644
11996
|
return binding.defs.length === 1 && definition?.node.type === import_utils68.AST_NODE_TYPES.VariableDeclarator && definition.node.init !== null && isZodSchema(definition.node.init, seen);
|
|
11645
11997
|
}
|
|
11646
|
-
if (node.type !== import_utils68.AST_NODE_TYPES.CallExpression || unwrappedNodeCallee?.type !== import_utils68.AST_NODE_TYPES.MemberExpression
|
|
11998
|
+
if (node.type !== import_utils68.AST_NODE_TYPES.CallExpression || unwrappedNodeCallee?.type !== import_utils68.AST_NODE_TYPES.MemberExpression) return false;
|
|
11647
11999
|
const { object } = unwrappedNodeCallee;
|
|
11648
|
-
const method =
|
|
12000
|
+
const method = staticPropertyName(unwrappedNodeCallee, context.sourceCode);
|
|
11649
12001
|
if (object.type === import_utils68.AST_NODE_TYPES.Identifier && method !== null && ZOD_CONSTRUCTORS.has(method)) {
|
|
11650
12002
|
const binding = import_utils68.ASTUtils.findVariable(context.sourceCode.getScope(object), object.name);
|
|
11651
12003
|
if (binding?.defs.some((definition) => {
|
|
@@ -11674,23 +12026,23 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11674
12026
|
return {
|
|
11675
12027
|
CallExpression(node) {
|
|
11676
12028
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
11677
|
-
if (unwrappedNodeCallee.type !== import_utils68.AST_NODE_TYPES.MemberExpression
|
|
12029
|
+
if (unwrappedNodeCallee.type !== import_utils68.AST_NODE_TYPES.MemberExpression) {
|
|
11678
12030
|
return;
|
|
11679
12031
|
}
|
|
11680
|
-
const method =
|
|
12032
|
+
const method = staticPropertyName(unwrappedNodeCallee, context.sourceCode);
|
|
11681
12033
|
const handlerIndex = method === "catch" ? 0 : method === "then" ? 1 : null;
|
|
11682
12034
|
if (handlerIndex === null) return;
|
|
11683
12035
|
if (method === "catch" && isZodSchema(unwrappedNodeCallee.object)) return;
|
|
11684
|
-
if (isBodyParseCall(unwrappedNodeCallee.object)) {
|
|
12036
|
+
if (isBodyParseCall(unwrappedNodeCallee.object, context.sourceCode)) {
|
|
11685
12037
|
return;
|
|
11686
12038
|
}
|
|
11687
|
-
if (isTeardownCall(unwrappedNodeCallee.object)) {
|
|
12039
|
+
if (isTeardownCall(unwrappedNodeCallee.object, context.sourceCode)) {
|
|
11688
12040
|
return;
|
|
11689
12041
|
}
|
|
11690
|
-
if (isCancelledWebShare(unwrappedNodeCallee.object)) {
|
|
12042
|
+
if (isCancelledWebShare(unwrappedNodeCallee.object, context.sourceCode)) {
|
|
11691
12043
|
return;
|
|
11692
12044
|
}
|
|
11693
|
-
if (node.parent.type === import_utils68.AST_NODE_TYPES.MemberExpression && node.parent.object === node &&
|
|
12045
|
+
if (node.parent.type === import_utils68.AST_NODE_TYPES.MemberExpression && node.parent.object === node && staticPropertyName(node.parent, context.sourceCode) === "then") {
|
|
11694
12046
|
return;
|
|
11695
12047
|
}
|
|
11696
12048
|
const expectedArguments = method === "catch" ? 1 : 2;
|
|
@@ -21008,8 +21360,112 @@ function staticFieldName(key) {
|
|
|
21008
21360
|
return key.type === import_utils115.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils115.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
21009
21361
|
}
|
|
21010
21362
|
|
|
21011
|
-
// src/rules/
|
|
21363
|
+
// src/rules/named-child-schema-type.ts
|
|
21012
21364
|
var import_utils116 = require("@typescript-eslint/utils");
|
|
21365
|
+
var UNRESOLVED_TYPE_NODES = /* @__PURE__ */ new Set([
|
|
21366
|
+
import_utils116.AST_NODE_TYPES.TSTypeQuery,
|
|
21367
|
+
import_utils116.AST_NODE_TYPES.TSImportType,
|
|
21368
|
+
import_utils116.AST_NODE_TYPES.TSTypeParameter,
|
|
21369
|
+
import_utils116.AST_NODE_TYPES.TSAnyKeyword,
|
|
21370
|
+
import_utils116.AST_NODE_TYPES.TSUnknownKeyword
|
|
21371
|
+
]);
|
|
21372
|
+
var NAMED_CHILD_SCHEMA_TYPE_DOCUMENTATION = {
|
|
21373
|
+
defaultLevel: "warning",
|
|
21374
|
+
summary: "Reference a named Zod record child's complete schema type instead of repeating its explicit annotation.",
|
|
21375
|
+
rationale: "Repeating a child schema's generic contract creates a second maintained declaration even though the record already uses that child at runtime.",
|
|
21376
|
+
remediation: "Replace only the matching record type argument with `typeof ChildSchema`; retain the outer annotation required by isolatedDeclarations and every runtime schema operation.",
|
|
21377
|
+
category: "maintainability",
|
|
21378
|
+
autofix: "none",
|
|
21379
|
+
limitations: [
|
|
21380
|
+
"Only direct module-level const z.record calls with two arguments, a ZodRecord annotation, and an earlier local const child with a complete explicit Zod type are inspected.",
|
|
21381
|
+
"The entire generic child annotation must match token for token; input/output, defaults, transforms, readonly modifiers and brands are never compared by output shape alone.",
|
|
21382
|
+
"Bare leaf types, broad ZodType constraints, type queries, imported or unqualified type references, annotation cycles, comments on the repeated argument, mutable bindings and generated files are excluded.",
|
|
21383
|
+
"Import aliases and namespace imports resolve through scope bindings. Independent public contract pins require review; this warning does not remove annotations or change runtime validation."
|
|
21384
|
+
],
|
|
21385
|
+
examples: [
|
|
21386
|
+
{ id: "named-child", title: "Reference the named child contract", outcome: "no-match", files: [{ path: "src/record.ts", source: 'import { z } from "zod"; const KeySchema: z.ZodEnum<{ a: "a"; b: "b" }> = z.enum(["a", "b"]); export const RecordSchema: z.ZodRecord<typeof KeySchema, z.ZodString> = z.record(KeySchema, z.string());' }], focusPath: "src/record.ts", expectedCount: 0, public: true },
|
|
21387
|
+
{ id: "copied-child", title: "Do not repeat the complete child annotation", outcome: "match", files: [{ path: "src/record.ts", source: 'import { z } from "zod"; const KeySchema: z.ZodEnum<{ a: "a"; b: "b" }> = z.enum(["a", "b"]); export const RecordSchema: z.ZodRecord<z.ZodEnum<{ a: "a"; b: "b" }>, z.ZodString> = z.record(KeySchema, z.string());' }], focusPath: "src/record.ts", expectedCount: 1, public: true }
|
|
21388
|
+
]
|
|
21389
|
+
};
|
|
21390
|
+
function isModuleConst(node) {
|
|
21391
|
+
if (node.parent.kind !== "const" || node.id.type !== import_utils116.AST_NODE_TYPES.Identifier) return false;
|
|
21392
|
+
const parent = node.parent.parent;
|
|
21393
|
+
return parent.type === import_utils116.AST_NODE_TYPES.Program || parent.type === import_utils116.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent.type === import_utils116.AST_NODE_TYPES.Program;
|
|
21394
|
+
}
|
|
21395
|
+
var named_child_schema_type_default = createRule({
|
|
21396
|
+
name: "named-child-schema-type",
|
|
21397
|
+
documentation: NAMED_CHILD_SCHEMA_TYPE_DOCUMENTATION,
|
|
21398
|
+
meta: {
|
|
21399
|
+
type: "suggestion",
|
|
21400
|
+
docs: { description: NAMED_CHILD_SCHEMA_TYPE_DOCUMENTATION.summary },
|
|
21401
|
+
schema: [],
|
|
21402
|
+
messages: { namedChildType: "Use `typeof {{name}}` for this exact child contract; keep the outer schema annotation and runtime operations." }
|
|
21403
|
+
},
|
|
21404
|
+
defaultOptions: [],
|
|
21405
|
+
create(context) {
|
|
21406
|
+
const source = context.sourceCode;
|
|
21407
|
+
if (isGeneratedFile(context.filename, source.text)) return {};
|
|
21408
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
21409
|
+
const bindingOf = (node) => import_utils116.ASTUtils.findVariable(source.getScope(node), node.name);
|
|
21410
|
+
function namespaceOf(type) {
|
|
21411
|
+
if (type.typeName.type !== import_utils116.AST_NODE_TYPES.TSQualifiedName || type.typeName.left.type !== import_utils116.AST_NODE_TYPES.Identifier) return null;
|
|
21412
|
+
const binding = bindingOf(type.typeName.left);
|
|
21413
|
+
return binding !== null && namespaces.has(binding) ? binding : null;
|
|
21414
|
+
}
|
|
21415
|
+
function closedType(node, namespace) {
|
|
21416
|
+
if (UNRESOLVED_TYPE_NODES.has(node.type)) return false;
|
|
21417
|
+
if (node.type === import_utils116.AST_NODE_TYPES.TSTypeReference && namespaceOf(node) !== namespace) return false;
|
|
21418
|
+
return !forEachOwnAstChild(node, (child) => !closedType(child, namespace));
|
|
21419
|
+
}
|
|
21420
|
+
function inspectChild(argument, repeated, namespace, parent) {
|
|
21421
|
+
if (argument.type !== import_utils116.AST_NODE_TYPES.Identifier || repeated.type !== import_utils116.AST_NODE_TYPES.TSTypeReference || repeated.typeArguments === void 0) return;
|
|
21422
|
+
if (repeated.typeName.type !== import_utils116.AST_NODE_TYPES.TSQualifiedName || /^(?:ZodType|ZodSchema|ZodTypeAny)$/u.test(repeated.typeName.right.name)) return;
|
|
21423
|
+
const variable = bindingOf(argument);
|
|
21424
|
+
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
21425
|
+
if (definition?.type !== "Variable" || !isModuleConst(definition.node)) return;
|
|
21426
|
+
const child = definition.node;
|
|
21427
|
+
if (child.id.type !== import_utils116.AST_NODE_TYPES.Identifier || child.init === null || child.range[0] >= parent.range[0]) return;
|
|
21428
|
+
const annotation = child.id.typeAnnotation?.typeAnnotation;
|
|
21429
|
+
if (annotation === void 0 || factoryNamespace(child.init) !== namespace || !closedType(annotation, namespace)) return;
|
|
21430
|
+
if (source.getCommentsInside(repeated).length > 0 || source.getCommentsBefore(repeated).length > 0) return;
|
|
21431
|
+
const expected = source.getTokens(annotation);
|
|
21432
|
+
const actual = source.getTokens(repeated);
|
|
21433
|
+
if (expected.length !== actual.length || expected.some((token, index) => token.type !== actual[index]?.type || token.value !== actual[index]?.value)) return;
|
|
21434
|
+
context.report({ node: repeated, messageId: "namedChildType", data: { name: argument.name } });
|
|
21435
|
+
}
|
|
21436
|
+
function factoryNamespace(expression) {
|
|
21437
|
+
if (expression.type !== import_utils116.AST_NODE_TYPES.CallExpression || expression.callee.type !== import_utils116.AST_NODE_TYPES.MemberExpression) return null;
|
|
21438
|
+
const object = expression.callee.object;
|
|
21439
|
+
return object.type === import_utils116.AST_NODE_TYPES.Identifier ? bindingOf(object) : factoryNamespace(object);
|
|
21440
|
+
}
|
|
21441
|
+
return {
|
|
21442
|
+
ImportDeclaration(node) {
|
|
21443
|
+
if (node.importKind === "type" || !isZodModule(node.source.value)) return;
|
|
21444
|
+
for (const specifier of node.specifiers) {
|
|
21445
|
+
if (specifier.type !== import_utils116.AST_NODE_TYPES.ImportNamespaceSpecifier && (specifier.type !== import_utils116.AST_NODE_TYPES.ImportSpecifier || specifier.importKind === "type" || importSpecifierName(specifier) !== "z")) continue;
|
|
21446
|
+
const binding = bindingOf(specifier.local);
|
|
21447
|
+
if (binding !== null) namespaces.add(binding);
|
|
21448
|
+
}
|
|
21449
|
+
},
|
|
21450
|
+
VariableDeclarator(node) {
|
|
21451
|
+
if (!isModuleConst(node) || node.id.type !== import_utils116.AST_NODE_TYPES.Identifier || node.init?.type !== import_utils116.AST_NODE_TYPES.CallExpression) return;
|
|
21452
|
+
const call = node.init;
|
|
21453
|
+
if (call.arguments.length !== 2 || call.callee.type !== import_utils116.AST_NODE_TYPES.MemberExpression || call.callee.object.type !== import_utils116.AST_NODE_TYPES.Identifier || import_utils116.ASTUtils.getPropertyName(call.callee) !== "record") return;
|
|
21454
|
+
const annotation = node.id.typeAnnotation?.typeAnnotation;
|
|
21455
|
+
if (annotation?.type !== import_utils116.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils116.AST_NODE_TYPES.TSQualifiedName || annotation.typeName.right.name !== "ZodRecord") return;
|
|
21456
|
+
const namespace = namespaceOf(annotation);
|
|
21457
|
+
if (namespace === null || bindingOf(call.callee.object) !== namespace || annotation.typeArguments?.params.length !== 2) return;
|
|
21458
|
+
for (const [index, argument] of call.arguments.entries()) {
|
|
21459
|
+
const repeated = annotation.typeArguments.params[index];
|
|
21460
|
+
if (repeated !== void 0) inspectChild(argument, repeated, namespace, node);
|
|
21461
|
+
}
|
|
21462
|
+
}
|
|
21463
|
+
};
|
|
21464
|
+
}
|
|
21465
|
+
});
|
|
21466
|
+
|
|
21467
|
+
// src/rules/prefer-zod-parse-output-type.ts
|
|
21468
|
+
var import_utils117 = require("@typescript-eslint/utils");
|
|
21013
21469
|
var import_typescript7 = __toESM(require("typescript"), 1);
|
|
21014
21470
|
var PREFER_ZOD_PARSE_OUTPUT_TYPE_DOCUMENTATION = {
|
|
21015
21471
|
summary: "Derive a function's return contract from the local Zod schema whose parsed output it returns.",
|
|
@@ -21065,22 +21521,22 @@ var PREFER_ZOD_PARSE_OUTPUT_TYPE_DOCUMENTATION = {
|
|
|
21065
21521
|
};
|
|
21066
21522
|
function isModuleLevelConst2(node) {
|
|
21067
21523
|
const declaration = node.parent;
|
|
21068
|
-
if (declaration.type !==
|
|
21524
|
+
if (declaration.type !== import_utils117.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const") {
|
|
21069
21525
|
return false;
|
|
21070
21526
|
}
|
|
21071
21527
|
const container = declaration.parent;
|
|
21072
|
-
return container.type ===
|
|
21528
|
+
return container.type === import_utils117.AST_NODE_TYPES.Program || container.type === import_utils117.AST_NODE_TYPES.ExportNamedDeclaration && container.parent.type === import_utils117.AST_NODE_TYPES.Program;
|
|
21073
21529
|
}
|
|
21074
21530
|
function isLocalZodObjectSchema(node, namespaces) {
|
|
21075
21531
|
let current = node;
|
|
21076
|
-
while (current.type ===
|
|
21532
|
+
while (current.type === import_utils117.AST_NODE_TYPES.CallExpression) {
|
|
21077
21533
|
const callee = unwrapExpression(current.callee);
|
|
21078
|
-
const calleeReceiver = callee.type ===
|
|
21079
|
-
if (callee.type !==
|
|
21534
|
+
const calleeReceiver = callee.type === import_utils117.AST_NODE_TYPES.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
21535
|
+
if (callee.type !== import_utils117.AST_NODE_TYPES.MemberExpression || import_utils117.ASTUtils.getPropertyName(callee) === null) {
|
|
21080
21536
|
return false;
|
|
21081
21537
|
}
|
|
21082
|
-
if (calleeReceiver.type ===
|
|
21083
|
-
return namespaces.has(calleeReceiver.name) && ((
|
|
21538
|
+
if (calleeReceiver.type === import_utils117.AST_NODE_TYPES.Identifier) {
|
|
21539
|
+
return namespaces.has(calleeReceiver.name) && ((import_utils117.ASTUtils.getPropertyName(callee) ?? "") === "object" || (import_utils117.ASTUtils.getPropertyName(callee) ?? "") === "strictObject");
|
|
21084
21540
|
}
|
|
21085
21541
|
current = calleeReceiver;
|
|
21086
21542
|
}
|
|
@@ -21088,11 +21544,11 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
21088
21544
|
}
|
|
21089
21545
|
function zodParseCall(node) {
|
|
21090
21546
|
const callee = unwrapExpression(node.callee);
|
|
21091
|
-
const calleeReceiver = callee.type ===
|
|
21092
|
-
if (callee.type !==
|
|
21547
|
+
const calleeReceiver = callee.type === import_utils117.AST_NODE_TYPES.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
21548
|
+
if (callee.type !== import_utils117.AST_NODE_TYPES.MemberExpression || calleeReceiver.type !== import_utils117.AST_NODE_TYPES.Identifier || import_utils117.ASTUtils.getPropertyName(callee) === null) {
|
|
21093
21549
|
return null;
|
|
21094
21550
|
}
|
|
21095
|
-
const method =
|
|
21551
|
+
const method = import_utils117.ASTUtils.getPropertyName(callee);
|
|
21096
21552
|
if (method !== "parse" && method !== "safeParse") return null;
|
|
21097
21553
|
return {
|
|
21098
21554
|
call: node,
|
|
@@ -21106,7 +21562,7 @@ function returnedOutputCandidate(parsed, output) {
|
|
|
21106
21562
|
const annotation = owner?.returnType?.typeAnnotation;
|
|
21107
21563
|
if (annotation === void 0) return null;
|
|
21108
21564
|
const typeReference = returnContractReference(annotation);
|
|
21109
|
-
if (typeReference === null || typeReference.typeName.type !==
|
|
21565
|
+
if (typeReference === null || typeReference.typeName.type !== import_utils117.AST_NODE_TYPES.Identifier) {
|
|
21110
21566
|
return null;
|
|
21111
21567
|
}
|
|
21112
21568
|
return {
|
|
@@ -21123,7 +21579,7 @@ function directParseReturnCandidate(node) {
|
|
|
21123
21579
|
return parsed?.method === "parse" ? returnedOutputCandidate(parsed, node) : null;
|
|
21124
21580
|
}
|
|
21125
21581
|
function localParseReturnCandidates(node, sourceCode) {
|
|
21126
|
-
if (node.id.type !==
|
|
21582
|
+
if (node.id.type !== import_utils117.AST_NODE_TYPES.Identifier || node.init?.type !== import_utils117.AST_NODE_TYPES.CallExpression || node.parent.type !== import_utils117.AST_NODE_TYPES.VariableDeclaration || node.parent.kind !== "const" || enclosingFunction4(node.init) === null) {
|
|
21127
21583
|
return [];
|
|
21128
21584
|
}
|
|
21129
21585
|
const parsed = zodParseCall(node.init);
|
|
@@ -21134,7 +21590,7 @@ function localParseReturnCandidates(node, sourceCode) {
|
|
|
21134
21590
|
for (const reference of variable.references) {
|
|
21135
21591
|
const identifier = reference.identifier;
|
|
21136
21592
|
const parent = identifier.parent;
|
|
21137
|
-
const output = parsed.method === "parse" ? identifier : parent.type ===
|
|
21593
|
+
const output = parsed.method === "parse" ? identifier : parent.type === import_utils117.AST_NODE_TYPES.MemberExpression && parent.object === identifier && import_utils117.ASTUtils.getPropertyName(parent) !== null && (import_utils117.ASTUtils.getPropertyName(parent) ?? "") === "data" ? parent : null;
|
|
21138
21594
|
if (output === null) continue;
|
|
21139
21595
|
const candidate2 = returnedOutputCandidate(parsed, output);
|
|
21140
21596
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
@@ -21145,17 +21601,17 @@ function directReturnOwner(node) {
|
|
|
21145
21601
|
let current = node;
|
|
21146
21602
|
while (current.parent !== void 0) {
|
|
21147
21603
|
const parent = current.parent;
|
|
21148
|
-
if (parent.type ===
|
|
21604
|
+
if (parent.type === import_utils117.AST_NODE_TYPES.ReturnStatement) {
|
|
21149
21605
|
return parent.argument === current ? enclosingFunction4(parent) : null;
|
|
21150
21606
|
}
|
|
21151
|
-
if (parent.type ===
|
|
21607
|
+
if (parent.type === import_utils117.AST_NODE_TYPES.ArrowFunctionExpression && parent.expression && parent.body === current) {
|
|
21152
21608
|
return parent;
|
|
21153
21609
|
}
|
|
21154
|
-
if (parent.type ===
|
|
21610
|
+
if (parent.type === import_utils117.AST_NODE_TYPES.AwaitExpression && parent.argument === current) {
|
|
21155
21611
|
current = parent;
|
|
21156
21612
|
continue;
|
|
21157
21613
|
}
|
|
21158
|
-
if (parent.type ===
|
|
21614
|
+
if (parent.type === import_utils117.AST_NODE_TYPES.ConditionalExpression) {
|
|
21159
21615
|
const parsedWhenTrue = parent.consequent === current && isNullishExpression(parent.alternate);
|
|
21160
21616
|
const parsedWhenFalse = parent.alternate === current && isNullishExpression(parent.consequent);
|
|
21161
21617
|
if (parsedWhenTrue || parsedWhenFalse) {
|
|
@@ -21168,12 +21624,12 @@ function directReturnOwner(node) {
|
|
|
21168
21624
|
return null;
|
|
21169
21625
|
}
|
|
21170
21626
|
function isNullishExpression(node) {
|
|
21171
|
-
return node.type ===
|
|
21627
|
+
return node.type === import_utils117.AST_NODE_TYPES.Literal && node.value === null || node.type === import_utils117.AST_NODE_TYPES.Identifier && node.name === "undefined";
|
|
21172
21628
|
}
|
|
21173
21629
|
function enclosingFunction4(node) {
|
|
21174
21630
|
let current = node.parent;
|
|
21175
21631
|
while (current != null) {
|
|
21176
|
-
if (current.type ===
|
|
21632
|
+
if (current.type === import_utils117.AST_NODE_TYPES.ArrowFunctionExpression || current.type === import_utils117.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils117.AST_NODE_TYPES.FunctionExpression) {
|
|
21177
21633
|
return current;
|
|
21178
21634
|
}
|
|
21179
21635
|
current = current.parent;
|
|
@@ -21181,45 +21637,45 @@ function enclosingFunction4(node) {
|
|
|
21181
21637
|
return null;
|
|
21182
21638
|
}
|
|
21183
21639
|
function returnContractReference(node) {
|
|
21184
|
-
if (node.type ===
|
|
21640
|
+
if (node.type === import_utils117.AST_NODE_TYPES.TSUnionType) {
|
|
21185
21641
|
const substantive = node.types.filter(
|
|
21186
|
-
(member) => member.type !==
|
|
21642
|
+
(member) => member.type !== import_utils117.AST_NODE_TYPES.TSNullKeyword && member.type !== import_utils117.AST_NODE_TYPES.TSUndefinedKeyword
|
|
21187
21643
|
);
|
|
21188
21644
|
const [only] = substantive;
|
|
21189
21645
|
return substantive.length === 1 && only !== void 0 ? returnContractReference(only) : null;
|
|
21190
21646
|
}
|
|
21191
|
-
if (node.type ===
|
|
21647
|
+
if (node.type === import_utils117.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils117.AST_NODE_TYPES.Identifier && node.typeName.name === "Promise") {
|
|
21192
21648
|
const parameters = node.typeArguments?.params ?? [];
|
|
21193
21649
|
const [only] = parameters;
|
|
21194
21650
|
return parameters.length === 1 && only !== void 0 ? returnContractReference(only) : null;
|
|
21195
21651
|
}
|
|
21196
|
-
return node.type ===
|
|
21652
|
+
return node.type === import_utils117.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils117.AST_NODE_TYPES.Identifier && (node.typeArguments?.params.length ?? 0) === 0 ? node : null;
|
|
21197
21653
|
}
|
|
21198
21654
|
function recordZodNamespaces(node, namespaces) {
|
|
21199
21655
|
for (const statement of node.body) {
|
|
21200
|
-
if (statement.type !==
|
|
21656
|
+
if (statement.type !== import_utils117.AST_NODE_TYPES.ImportDeclaration || !isZodModule(statement.source.value)) {
|
|
21201
21657
|
continue;
|
|
21202
21658
|
}
|
|
21203
21659
|
for (const specifier of statement.specifiers) {
|
|
21204
|
-
if (specifier.type ===
|
|
21660
|
+
if (specifier.type === import_utils117.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils117.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils117.AST_NODE_TYPES.ImportSpecifier && importSpecifierName(specifier) === "z") {
|
|
21205
21661
|
namespaces.add(specifier.local.name);
|
|
21206
21662
|
}
|
|
21207
21663
|
}
|
|
21208
21664
|
}
|
|
21209
21665
|
}
|
|
21210
21666
|
function collectConstrainedNames(node, names) {
|
|
21211
|
-
if (node.type ===
|
|
21212
|
-
if (node.typeName.type ===
|
|
21667
|
+
if (node.type === import_utils117.AST_NODE_TYPES.TSTypeReference) {
|
|
21668
|
+
if (node.typeName.type === import_utils117.AST_NODE_TYPES.Identifier) names.add(node.typeName.name);
|
|
21213
21669
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
21214
21670
|
collectConstrainedNames(argument, names);
|
|
21215
21671
|
}
|
|
21216
21672
|
return;
|
|
21217
21673
|
}
|
|
21218
|
-
if (node.type ===
|
|
21674
|
+
if (node.type === import_utils117.AST_NODE_TYPES.TSArrayType) {
|
|
21219
21675
|
collectConstrainedNames(node.elementType, names);
|
|
21220
21676
|
return;
|
|
21221
21677
|
}
|
|
21222
|
-
if (node.type ===
|
|
21678
|
+
if (node.type === import_utils117.AST_NODE_TYPES.TSUnionType || node.type === import_utils117.AST_NODE_TYPES.TSIntersectionType) {
|
|
21223
21679
|
for (const member of node.types) collectConstrainedNames(member, names);
|
|
21224
21680
|
}
|
|
21225
21681
|
}
|
|
@@ -21253,7 +21709,7 @@ function reportCandidates(context, services, schemas, candidates, zodNamespaces,
|
|
|
21253
21709
|
if (constrained) return;
|
|
21254
21710
|
if (declaration.getSourceFile() === tsSchema.getSourceFile()) {
|
|
21255
21711
|
const estreeDeclaration = services.tsNodeToESTreeNodeMap.get(declaration);
|
|
21256
|
-
if ((estreeDeclaration.type ===
|
|
21712
|
+
if ((estreeDeclaration.type === import_utils117.AST_NODE_TYPES.TSInterfaceDeclaration || estreeDeclaration.type === import_utils117.AST_NODE_TYPES.TSTypeAliasDeclaration) && preferZodInferOwnsDefaultTwin({
|
|
21257
21713
|
constrained,
|
|
21258
21714
|
declaration: estreeDeclaration,
|
|
21259
21715
|
initializer: schema.initializer,
|
|
@@ -21343,7 +21799,7 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
21343
21799
|
}
|
|
21344
21800
|
let services;
|
|
21345
21801
|
try {
|
|
21346
|
-
services =
|
|
21802
|
+
services = import_utils117.ESLintUtils.getParserServices(context);
|
|
21347
21803
|
} catch {
|
|
21348
21804
|
services = null;
|
|
21349
21805
|
}
|
|
@@ -21358,7 +21814,7 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
21358
21814
|
recordZodNamespaces(node, namespaces);
|
|
21359
21815
|
},
|
|
21360
21816
|
VariableDeclarator(node) {
|
|
21361
|
-
if (node.id.type ===
|
|
21817
|
+
if (node.id.type === import_utils117.AST_NODE_TYPES.Identifier && node.init !== null && isModuleLevelConst2(node) && isLocalZodObjectSchema(node.init, namespaces)) {
|
|
21362
21818
|
schemas.push({ identifier: node.id, initializer: node.init, name: node.id.name });
|
|
21363
21819
|
}
|
|
21364
21820
|
candidates.push(...localParseReturnCandidates(node, context.sourceCode));
|
|
@@ -21368,13 +21824,13 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
21368
21824
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
21369
21825
|
},
|
|
21370
21826
|
"MemberExpression"(node) {
|
|
21371
|
-
if (node.object.type ===
|
|
21827
|
+
if (node.object.type === import_utils117.AST_NODE_TYPES.Identifier && node.property.type === import_utils117.AST_NODE_TYPES.Identifier && isPreferZodInferModuleReshaper(node.property.name)) {
|
|
21372
21828
|
reshapedSchemas.add(node.object.name);
|
|
21373
21829
|
}
|
|
21374
21830
|
},
|
|
21375
21831
|
TSTypeReference(node) {
|
|
21376
21832
|
const { typeName } = node;
|
|
21377
|
-
const name = typeName.type ===
|
|
21833
|
+
const name = typeName.type === import_utils117.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils117.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils117.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
21378
21834
|
if (name === null || !isPreferZodInferTypeConstraintName(name)) return;
|
|
21379
21835
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
21380
21836
|
collectConstrainedNames(argument, constrainedTypeNames);
|
|
@@ -21396,7 +21852,7 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
21396
21852
|
});
|
|
21397
21853
|
|
|
21398
21854
|
// src/rules/require-assert-never.ts
|
|
21399
|
-
var
|
|
21855
|
+
var import_utils118 = require("@typescript-eslint/utils");
|
|
21400
21856
|
var import_typescript8 = __toESM(require("typescript"), 1);
|
|
21401
21857
|
var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
21402
21858
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
@@ -21410,14 +21866,14 @@ var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
|
21410
21866
|
]
|
|
21411
21867
|
};
|
|
21412
21868
|
var isRuntimeHandlingStatement = (statement) => {
|
|
21413
|
-
if (statement.type ===
|
|
21414
|
-
if (statement.type ===
|
|
21869
|
+
if (statement.type === import_utils118.AST_NODE_TYPES.EmptyStatement) return false;
|
|
21870
|
+
if (statement.type === import_utils118.AST_NODE_TYPES.BreakStatement) {
|
|
21415
21871
|
return statement.label !== null;
|
|
21416
21872
|
}
|
|
21417
|
-
if (statement.type ===
|
|
21873
|
+
if (statement.type === import_utils118.AST_NODE_TYPES.TSTypeAliasDeclaration || statement.type === import_utils118.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
21418
21874
|
return false;
|
|
21419
21875
|
}
|
|
21420
|
-
if (statement.type ===
|
|
21876
|
+
if (statement.type === import_utils118.AST_NODE_TYPES.BlockStatement) {
|
|
21421
21877
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
21422
21878
|
}
|
|
21423
21879
|
return true;
|
|
@@ -21433,7 +21889,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
21433
21889
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
21434
21890
|
}
|
|
21435
21891
|
const only = defaultCase.consequent[0];
|
|
21436
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
21892
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils118.AST_NODE_TYPES.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
21437
21893
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
21438
21894
|
}
|
|
21439
21895
|
return false;
|
|
@@ -21487,7 +21943,7 @@ var require_assert_never_default = createRule({
|
|
|
21487
21943
|
create(context) {
|
|
21488
21944
|
let services;
|
|
21489
21945
|
try {
|
|
21490
|
-
services =
|
|
21946
|
+
services = import_utils118.ESLintUtils.getParserServices(context);
|
|
21491
21947
|
} catch {
|
|
21492
21948
|
services = null;
|
|
21493
21949
|
}
|
|
@@ -21514,7 +21970,7 @@ var require_assert_never_default = createRule({
|
|
|
21514
21970
|
});
|
|
21515
21971
|
|
|
21516
21972
|
// src/rules/require-fetch-timeout.ts
|
|
21517
|
-
var
|
|
21973
|
+
var import_utils119 = require("@typescript-eslint/utils");
|
|
21518
21974
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
21519
21975
|
summary: "Require an explicit abort signal on locally analyzable global fetch calls.",
|
|
21520
21976
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -21541,18 +21997,18 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
21541
21997
|
return false;
|
|
21542
21998
|
}
|
|
21543
21999
|
function initProvablyLacksSignal(init, resolvesToGlobal) {
|
|
21544
|
-
if (init.type !==
|
|
22000
|
+
if (init.type !== import_utils119.AST_NODE_TYPES.ObjectExpression) return false;
|
|
21545
22001
|
let lacksSignal = true;
|
|
21546
22002
|
for (const prop of init.properties) {
|
|
21547
|
-
if (prop.type ===
|
|
22003
|
+
if (prop.type === import_utils119.AST_NODE_TYPES.SpreadElement) {
|
|
21548
22004
|
lacksSignal = false;
|
|
21549
22005
|
continue;
|
|
21550
22006
|
}
|
|
21551
|
-
const isSignal = !prop.computed && prop.key.type ===
|
|
22007
|
+
const isSignal = !prop.computed && prop.key.type === import_utils119.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils119.AST_NODE_TYPES.Literal && prop.key.value === "signal";
|
|
21552
22008
|
if (isSignal) {
|
|
21553
22009
|
const value = prop.value;
|
|
21554
|
-
lacksSignal = prop.kind === "init" && !prop.method && (value.type ===
|
|
21555
|
-
} else if (prop.computed && prop.key.type !==
|
|
22010
|
+
lacksSignal = prop.kind === "init" && !prop.method && (value.type === import_utils119.AST_NODE_TYPES.Literal && value.value === null || value.type === import_utils119.AST_NODE_TYPES.Identifier && value.name === "undefined" && resolvesToGlobal(value) || value.type === import_utils119.AST_NODE_TYPES.UnaryExpression && value.operator === "void" && value.argument.type === import_utils119.AST_NODE_TYPES.Literal && value.argument.value === 0);
|
|
22011
|
+
} else if (prop.computed && prop.key.type !== import_utils119.AST_NODE_TYPES.Literal) {
|
|
21556
22012
|
lacksSignal = false;
|
|
21557
22013
|
}
|
|
21558
22014
|
}
|
|
@@ -21560,7 +22016,7 @@ function initProvablyLacksSignal(init, resolvesToGlobal) {
|
|
|
21560
22016
|
}
|
|
21561
22017
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
21562
22018
|
node = unwrapExpression(node);
|
|
21563
|
-
return node.type ===
|
|
22019
|
+
return node.type === import_utils119.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils119.AST_NODE_TYPES.TemplateLiteral || node.type === import_utils119.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils119.AST_NODE_TYPES.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
21564
22020
|
}
|
|
21565
22021
|
var require_fetch_timeout_default = createRule({
|
|
21566
22022
|
name: "require-fetch-timeout",
|
|
@@ -21598,30 +22054,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
21598
22054
|
}
|
|
21599
22055
|
function resolvesToGlobal(identifier) {
|
|
21600
22056
|
const scope = context.sourceCode.getScope(identifier);
|
|
21601
|
-
const variable =
|
|
22057
|
+
const variable = import_utils119.ASTUtils.findVariable(scope, identifier.name);
|
|
21602
22058
|
return variable === null || variable.defs.length === 0;
|
|
21603
22059
|
}
|
|
21604
22060
|
function isGlobalFetchCall2(callee) {
|
|
21605
|
-
if (callee.type ===
|
|
22061
|
+
if (callee.type === import_utils119.AST_NODE_TYPES.Identifier) {
|
|
21606
22062
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
21607
22063
|
}
|
|
21608
|
-
return callee.type ===
|
|
22064
|
+
return callee.type === import_utils119.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils119.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils119.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
21609
22065
|
}
|
|
21610
22066
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
21611
|
-
const variable =
|
|
22067
|
+
const variable = import_utils119.ASTUtils.findVariable(
|
|
21612
22068
|
context.sourceCode.getScope(identifier),
|
|
21613
22069
|
identifier.name
|
|
21614
22070
|
);
|
|
21615
22071
|
if (variable?.defs.length !== 1) return false;
|
|
21616
22072
|
const definition = variable.defs[0];
|
|
21617
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
22073
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== import_utils119.AST_NODE_TYPES.ObjectExpression || !initProvablyLacksSignal(definition.node.init, resolvesToGlobal)) {
|
|
21618
22074
|
return false;
|
|
21619
22075
|
}
|
|
21620
22076
|
for (const reference of variable.references) {
|
|
21621
22077
|
const ref = reference.identifier;
|
|
21622
22078
|
if (ref === identifier || ref === definition.name) continue;
|
|
21623
22079
|
const member = ref.parent;
|
|
21624
|
-
if (member.type !==
|
|
22080
|
+
if (member.type !== import_utils119.AST_NODE_TYPES.MemberExpression || member.object !== ref || member.computed || member.property.type !== import_utils119.AST_NODE_TYPES.Identifier || member.property.name === "signal" || member.parent.type !== import_utils119.AST_NODE_TYPES.AssignmentExpression || member.parent.left !== member) {
|
|
21625
22081
|
return false;
|
|
21626
22082
|
}
|
|
21627
22083
|
}
|
|
@@ -21629,13 +22085,13 @@ var require_fetch_timeout_default = createRule({
|
|
|
21629
22085
|
}
|
|
21630
22086
|
function isForwardedRequest(argument) {
|
|
21631
22087
|
let value = argument;
|
|
21632
|
-
if (value.type ===
|
|
21633
|
-
const binding =
|
|
22088
|
+
if (value.type === import_utils119.AST_NODE_TYPES.Identifier) {
|
|
22089
|
+
const binding = import_utils119.ASTUtils.findVariable(context.sourceCode.getScope(value), value.name);
|
|
21634
22090
|
const definition = binding?.defs.length === 1 ? binding.defs[0] : void 0;
|
|
21635
22091
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || binding?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21636
22092
|
value = definition.node.init;
|
|
21637
22093
|
}
|
|
21638
|
-
return value.type ===
|
|
22094
|
+
return value.type === import_utils119.AST_NODE_TYPES.NewExpression && value.callee.type === import_utils119.AST_NODE_TYPES.Identifier && value.callee.name === "Request" && resolvesToGlobal(value.callee);
|
|
21639
22095
|
}
|
|
21640
22096
|
return {
|
|
21641
22097
|
CallExpression(node) {
|
|
@@ -21647,7 +22103,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21647
22103
|
if (first !== void 0 && (node.arguments.length === 1 && !isInlineUrl(first, resolvesToGlobal) || isForwardedRequest(first))) {
|
|
21648
22104
|
return;
|
|
21649
22105
|
}
|
|
21650
|
-
if (init === void 0 || initProvablyLacksSignal(init, resolvesToGlobal) || init.type ===
|
|
22106
|
+
if (init === void 0 || initProvablyLacksSignal(init, resolvesToGlobal) || init.type === import_utils119.AST_NODE_TYPES.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
21651
22107
|
context.report({ node, messageId: "missingSignal" });
|
|
21652
22108
|
}
|
|
21653
22109
|
}
|
|
@@ -21656,7 +22112,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
21656
22112
|
});
|
|
21657
22113
|
|
|
21658
22114
|
// src/rules/require-interface-for-exported-class.ts
|
|
21659
|
-
var
|
|
22115
|
+
var import_utils120 = require("@typescript-eslint/utils");
|
|
21660
22116
|
var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
21661
22117
|
defaultLevel: "warning",
|
|
21662
22118
|
summary: "Require exported concrete classes with public behavior to declare a contract.",
|
|
@@ -21703,23 +22159,23 @@ var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
|
21703
22159
|
};
|
|
21704
22160
|
function hasPublicInstanceBehavior(node) {
|
|
21705
22161
|
return node.body.body.some((member) => {
|
|
21706
|
-
if (member.type ===
|
|
21707
|
-
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !==
|
|
22162
|
+
if (member.type === import_utils120.AST_NODE_TYPES.MethodDefinition) {
|
|
22163
|
+
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !== import_utils120.AST_NODE_TYPES.PrivateIdentifier;
|
|
21708
22164
|
}
|
|
21709
|
-
if (member.type !==
|
|
22165
|
+
if (member.type !== import_utils120.AST_NODE_TYPES.PropertyDefinition || member.static)
|
|
21710
22166
|
return false;
|
|
21711
|
-
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type ===
|
|
21712
|
-
return member.value?.type ===
|
|
22167
|
+
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type === import_utils120.AST_NODE_TYPES.PrivateIdentifier) return false;
|
|
22168
|
+
return member.value?.type === import_utils120.AST_NODE_TYPES.ArrowFunctionExpression || member.value?.type === import_utils120.AST_NODE_TYPES.FunctionExpression || member.typeAnnotation?.typeAnnotation.type === import_utils120.AST_NODE_TYPES.TSFunctionType;
|
|
21713
22169
|
});
|
|
21714
22170
|
}
|
|
21715
22171
|
function classBindings(statement) {
|
|
21716
|
-
const declaration = statement.type ===
|
|
21717
|
-
if (declaration?.type ===
|
|
22172
|
+
const declaration = statement.type === import_utils120.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
22173
|
+
if (declaration?.type === import_utils120.AST_NODE_TYPES.ClassDeclaration) {
|
|
21718
22174
|
return declaration.id === null ? [] : [{ declaration, name: declaration.id.name }];
|
|
21719
22175
|
}
|
|
21720
|
-
if (declaration?.type !==
|
|
22176
|
+
if (declaration?.type !== import_utils120.AST_NODE_TYPES.VariableDeclaration) return [];
|
|
21721
22177
|
return declaration.declarations.flatMap(
|
|
21722
|
-
(item) => item.id.type ===
|
|
22178
|
+
(item) => item.id.type === import_utils120.AST_NODE_TYPES.Identifier && item.init?.type === import_utils120.AST_NODE_TYPES.ClassExpression ? [{ declaration: item.init, name: item.id.name }] : []
|
|
21723
22179
|
);
|
|
21724
22180
|
}
|
|
21725
22181
|
var require_interface_for_exported_class_default = createRule({
|
|
@@ -21753,7 +22209,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
21753
22209
|
}
|
|
21754
22210
|
const exported = exportedClasses(program, classes);
|
|
21755
22211
|
for (const [declaration, exportedName] of exported) {
|
|
21756
|
-
const extendsLocalAbstractBase = declaration.superClass?.type ===
|
|
22212
|
+
const extendsLocalAbstractBase = declaration.superClass?.type === import_utils120.AST_NODE_TYPES.Identifier && abstractBases.has(declaration.superClass.name);
|
|
21757
22213
|
if (declaration.abstract || declaration.implements.length > 0 || extendsLocalAbstractBase || !hasPublicInstanceBehavior(declaration)) continue;
|
|
21758
22214
|
context.report({
|
|
21759
22215
|
node: declaration.id ?? declaration,
|
|
@@ -21768,7 +22224,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
21768
22224
|
function exportedClasses(program, classes) {
|
|
21769
22225
|
const exported = /* @__PURE__ */ new Map();
|
|
21770
22226
|
function collectExportedClass(statement) {
|
|
21771
|
-
if (statement.type ===
|
|
22227
|
+
if (statement.type === import_utils120.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
21772
22228
|
for (const binding of classBindings(statement)) {
|
|
21773
22229
|
exported.set(binding.declaration, binding.name);
|
|
21774
22230
|
}
|
|
@@ -21776,13 +22232,13 @@ function exportedClasses(program, classes) {
|
|
|
21776
22232
|
collectClassSpecifiers(statement);
|
|
21777
22233
|
return;
|
|
21778
22234
|
}
|
|
21779
|
-
if (statement.type !==
|
|
21780
|
-
if (statement.declaration.type ===
|
|
22235
|
+
if (statement.type !== import_utils120.AST_NODE_TYPES.ExportDefaultDeclaration) return;
|
|
22236
|
+
if (statement.declaration.type === import_utils120.AST_NODE_TYPES.ClassDeclaration || statement.declaration.type === import_utils120.AST_NODE_TYPES.ClassExpression) {
|
|
21781
22237
|
exported.set(
|
|
21782
22238
|
statement.declaration,
|
|
21783
22239
|
statement.declaration.id?.name ?? "default"
|
|
21784
22240
|
);
|
|
21785
|
-
} else if (statement.declaration.type ===
|
|
22241
|
+
} else if (statement.declaration.type === import_utils120.AST_NODE_TYPES.Identifier) {
|
|
21786
22242
|
const candidate2 = classes.get(statement.declaration.name);
|
|
21787
22243
|
if (candidate2 !== void 0) {
|
|
21788
22244
|
exported.set(candidate2, statement.declaration.name);
|
|
@@ -21794,7 +22250,7 @@ function exportedClasses(program, classes) {
|
|
|
21794
22250
|
if (specifier.exportKind === "type") continue;
|
|
21795
22251
|
const candidate2 = classes.get(specifier.local.name);
|
|
21796
22252
|
if (candidate2 === void 0) continue;
|
|
21797
|
-
const exportedName = specifier.exported.type ===
|
|
22253
|
+
const exportedName = specifier.exported.type === import_utils120.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
21798
22254
|
exported.set(candidate2, exportedName);
|
|
21799
22255
|
}
|
|
21800
22256
|
}
|
|
@@ -21805,7 +22261,7 @@ function exportedClasses(program, classes) {
|
|
|
21805
22261
|
}
|
|
21806
22262
|
|
|
21807
22263
|
// src/rules/require-sql-access-class.ts
|
|
21808
|
-
var
|
|
22264
|
+
var import_utils121 = require("@typescript-eslint/utils");
|
|
21809
22265
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
21810
22266
|
"all",
|
|
21811
22267
|
"batch",
|
|
@@ -21909,80 +22365,80 @@ function isDatabaseOperation(method, receiver) {
|
|
|
21909
22365
|
}
|
|
21910
22366
|
function databaseReceiver(node) {
|
|
21911
22367
|
node = unwrapExpression(node);
|
|
21912
|
-
if (node.type ===
|
|
22368
|
+
if (node.type === import_utils121.AST_NODE_TYPES.Identifier)
|
|
21913
22369
|
return DATABASE_NAMES.test(node.name);
|
|
21914
|
-
if (node.type !==
|
|
21915
|
-
const name =
|
|
22370
|
+
if (node.type !== import_utils121.AST_NODE_TYPES.MemberExpression) return false;
|
|
22371
|
+
const name = import_utils121.ASTUtils.getPropertyName(node);
|
|
21916
22372
|
return name === "DB" || name !== null && DATABASE_NAMES.test(name);
|
|
21917
22373
|
}
|
|
21918
22374
|
function databaseRootMember(node) {
|
|
21919
22375
|
let current = node;
|
|
21920
22376
|
for (; ; ) {
|
|
21921
22377
|
current = unwrapExpression(current);
|
|
21922
|
-
if (current.type ===
|
|
22378
|
+
if (current.type === import_utils121.AST_NODE_TYPES.ChainExpression) {
|
|
21923
22379
|
current = current.expression;
|
|
21924
22380
|
continue;
|
|
21925
22381
|
}
|
|
21926
|
-
if (current.type ===
|
|
21927
|
-
if (current.callee.type !==
|
|
22382
|
+
if (current.type === import_utils121.AST_NODE_TYPES.CallExpression) {
|
|
22383
|
+
if (current.callee.type !== import_utils121.AST_NODE_TYPES.MemberExpression) return null;
|
|
21928
22384
|
current = current.callee.object;
|
|
21929
22385
|
continue;
|
|
21930
22386
|
}
|
|
21931
|
-
if (current.type ===
|
|
21932
|
-
if (current.object.type ===
|
|
21933
|
-
return
|
|
22387
|
+
if (current.type === import_utils121.AST_NODE_TYPES.MemberExpression) {
|
|
22388
|
+
if (current.object.type === import_utils121.AST_NODE_TYPES.ThisExpression)
|
|
22389
|
+
return import_utils121.ASTUtils.getPropertyName(current);
|
|
21934
22390
|
current = current.object;
|
|
21935
22391
|
continue;
|
|
21936
22392
|
}
|
|
21937
|
-
return current.type ===
|
|
22393
|
+
return current.type === import_utils121.AST_NODE_TYPES.Identifier ? current.name : null;
|
|
21938
22394
|
}
|
|
21939
22395
|
}
|
|
21940
22396
|
function expressionHasDatabaseMarker(node) {
|
|
21941
22397
|
let current = node;
|
|
21942
22398
|
for (; ; ) {
|
|
21943
22399
|
current = unwrapExpression(current);
|
|
21944
|
-
if (current.type ===
|
|
22400
|
+
if (current.type === import_utils121.AST_NODE_TYPES.ChainExpression) {
|
|
21945
22401
|
current = current.expression;
|
|
21946
22402
|
continue;
|
|
21947
22403
|
}
|
|
21948
|
-
if (current.type ===
|
|
21949
|
-
if (current.callee.type !==
|
|
22404
|
+
if (current.type === import_utils121.AST_NODE_TYPES.CallExpression) {
|
|
22405
|
+
if (current.callee.type !== import_utils121.AST_NODE_TYPES.MemberExpression) return false;
|
|
21950
22406
|
current = current.callee.object;
|
|
21951
22407
|
continue;
|
|
21952
22408
|
}
|
|
21953
|
-
if (current.type ===
|
|
21954
|
-
const name =
|
|
22409
|
+
if (current.type === import_utils121.AST_NODE_TYPES.MemberExpression) {
|
|
22410
|
+
const name = import_utils121.ASTUtils.getPropertyName(current);
|
|
21955
22411
|
if (name === "DB" || name !== null && DATABASE_NAMES.test(name))
|
|
21956
22412
|
return true;
|
|
21957
22413
|
current = current.object;
|
|
21958
22414
|
continue;
|
|
21959
22415
|
}
|
|
21960
|
-
return current.type ===
|
|
22416
|
+
return current.type === import_utils121.AST_NODE_TYPES.Identifier && DATABASE_NAMES.test(current.name);
|
|
21961
22417
|
}
|
|
21962
22418
|
}
|
|
21963
22419
|
function expressionCallsBuilder(node) {
|
|
21964
22420
|
let current = node;
|
|
21965
22421
|
for (; ; ) {
|
|
21966
22422
|
current = unwrapExpression(current);
|
|
21967
|
-
if (current.type ===
|
|
22423
|
+
if (current.type === import_utils121.AST_NODE_TYPES.ChainExpression) {
|
|
21968
22424
|
current = current.expression;
|
|
21969
22425
|
continue;
|
|
21970
22426
|
}
|
|
21971
|
-
if (current.type ===
|
|
21972
|
-
if (current.callee.type !==
|
|
21973
|
-
const name =
|
|
22427
|
+
if (current.type === import_utils121.AST_NODE_TYPES.CallExpression) {
|
|
22428
|
+
if (current.callee.type !== import_utils121.AST_NODE_TYPES.MemberExpression) return false;
|
|
22429
|
+
const name = import_utils121.ASTUtils.getPropertyName(current.callee);
|
|
21974
22430
|
if (name !== null && BUILDER_METHODS.has(name)) return true;
|
|
21975
22431
|
current = current.callee.object;
|
|
21976
22432
|
continue;
|
|
21977
22433
|
}
|
|
21978
|
-
if (current.type !==
|
|
22434
|
+
if (current.type !== import_utils121.AST_NODE_TYPES.MemberExpression) return false;
|
|
21979
22435
|
current = current.object;
|
|
21980
22436
|
}
|
|
21981
22437
|
}
|
|
21982
22438
|
function owningClass2(node) {
|
|
21983
22439
|
let current = node.parent;
|
|
21984
22440
|
while (current != null) {
|
|
21985
|
-
if (current.type ===
|
|
22441
|
+
if (current.type === import_utils121.AST_NODE_TYPES.ClassDeclaration || current.type === import_utils121.AST_NODE_TYPES.ClassExpression)
|
|
21986
22442
|
return current;
|
|
21987
22443
|
current = current.parent;
|
|
21988
22444
|
}
|
|
@@ -21991,25 +22447,25 @@ function owningClass2(node) {
|
|
|
21991
22447
|
function injectedMembers(owner) {
|
|
21992
22448
|
const injected = /* @__PURE__ */ new Set();
|
|
21993
22449
|
const constructor = owner.body.body.find(
|
|
21994
|
-
(member) => member.type ===
|
|
22450
|
+
(member) => member.type === import_utils121.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
21995
22451
|
);
|
|
21996
22452
|
if (constructor === void 0) return injected;
|
|
21997
22453
|
const parameters = /* @__PURE__ */ new Set();
|
|
21998
22454
|
for (const parameter of constructor.value.params) {
|
|
21999
22455
|
for (const name of parameterNames(parameter)) parameters.add(name);
|
|
22000
|
-
if (parameter.type !==
|
|
22001
|
-
const value = parameter.parameter.type ===
|
|
22002
|
-
if (value.type ===
|
|
22456
|
+
if (parameter.type !== import_utils121.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
22457
|
+
const value = parameter.parameter.type === import_utils121.AST_NODE_TYPES.AssignmentPattern ? parameter.parameter.left : parameter.parameter;
|
|
22458
|
+
if (value.type === import_utils121.AST_NODE_TYPES.Identifier) injected.add(value.name);
|
|
22003
22459
|
}
|
|
22004
22460
|
const body2 = constructor.value.body;
|
|
22005
22461
|
if (body2 === null) return injected;
|
|
22006
22462
|
function collectInjectedMember(statement) {
|
|
22007
|
-
if (statement.type !==
|
|
22463
|
+
if (statement.type !== import_utils121.AST_NODE_TYPES.ExpressionStatement || statement.expression.type !== import_utils121.AST_NODE_TYPES.AssignmentExpression || statement.expression.operator !== "=") return;
|
|
22008
22464
|
const { left, right } = statement.expression;
|
|
22009
|
-
if (left.type !==
|
|
22465
|
+
if (left.type !== import_utils121.AST_NODE_TYPES.MemberExpression) return;
|
|
22010
22466
|
const target = thisRootMember(left);
|
|
22011
22467
|
if (target === null) return;
|
|
22012
|
-
const source = right.type ===
|
|
22468
|
+
const source = right.type === import_utils121.AST_NODE_TYPES.Identifier ? right.name : right.type === import_utils121.AST_NODE_TYPES.MemberExpression && right.object.type === import_utils121.AST_NODE_TYPES.Identifier ? right.object.name : null;
|
|
22013
22469
|
if (source !== null && parameters.has(source)) injected.add(target);
|
|
22014
22470
|
}
|
|
22015
22471
|
for (const statement of body2.body) {
|
|
@@ -22020,26 +22476,26 @@ function injectedMembers(owner) {
|
|
|
22020
22476
|
function thisRootMember(node) {
|
|
22021
22477
|
let current = node;
|
|
22022
22478
|
let root = null;
|
|
22023
|
-
while (current.type ===
|
|
22024
|
-
const name =
|
|
22479
|
+
while (current.type === import_utils121.AST_NODE_TYPES.MemberExpression) {
|
|
22480
|
+
const name = import_utils121.ASTUtils.getPropertyName(current);
|
|
22025
22481
|
if (name === null) return null;
|
|
22026
22482
|
root = name;
|
|
22027
22483
|
current = current.object;
|
|
22028
22484
|
}
|
|
22029
|
-
return current.type ===
|
|
22485
|
+
return current.type === import_utils121.AST_NODE_TYPES.ThisExpression ? root : null;
|
|
22030
22486
|
}
|
|
22031
22487
|
function parameterNames(parameter) {
|
|
22032
22488
|
let value = parameter;
|
|
22033
|
-
if (value.type ===
|
|
22034
|
-
if (value.type ===
|
|
22035
|
-
if (value.type ===
|
|
22036
|
-
if (value.type !==
|
|
22489
|
+
if (value.type === import_utils121.AST_NODE_TYPES.TSParameterProperty) value = value.parameter;
|
|
22490
|
+
if (value.type === import_utils121.AST_NODE_TYPES.AssignmentPattern) value = value.left;
|
|
22491
|
+
if (value.type === import_utils121.AST_NODE_TYPES.Identifier) return /* @__PURE__ */ new Set([value.name]);
|
|
22492
|
+
if (value.type !== import_utils121.AST_NODE_TYPES.ObjectPattern) return /* @__PURE__ */ new Set();
|
|
22037
22493
|
return new Set(
|
|
22038
22494
|
value.properties.flatMap((property) => {
|
|
22039
|
-
if (property.type ===
|
|
22040
|
-
return property.argument.type ===
|
|
22041
|
-
const target = property.value.type ===
|
|
22042
|
-
return target.type ===
|
|
22495
|
+
if (property.type === import_utils121.AST_NODE_TYPES.RestElement)
|
|
22496
|
+
return property.argument.type === import_utils121.AST_NODE_TYPES.Identifier ? [property.argument.name] : [];
|
|
22497
|
+
const target = property.value.type === import_utils121.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
22498
|
+
return target.type === import_utils121.AST_NODE_TYPES.Identifier ? [target.name] : [];
|
|
22043
22499
|
})
|
|
22044
22500
|
);
|
|
22045
22501
|
}
|
|
@@ -22064,20 +22520,20 @@ var require_sql_access_class_default = createRule({
|
|
|
22064
22520
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
22065
22521
|
if (seen.has(node)) return false;
|
|
22066
22522
|
seen.add(node);
|
|
22067
|
-
if (node.type ===
|
|
22068
|
-
const binding =
|
|
22523
|
+
if (node.type === import_utils121.AST_NODE_TYPES.Identifier) {
|
|
22524
|
+
const binding = import_utils121.ASTUtils.findVariable(context.sourceCode.getScope(node), node.name);
|
|
22069
22525
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
22070
22526
|
const definition = binding.defs[0];
|
|
22071
22527
|
return definition?.type === "Variable" && definition.node.init !== null && knownNonDatabase(definition.node.init, seen);
|
|
22072
22528
|
}
|
|
22073
|
-
return node.type ===
|
|
22529
|
+
return node.type === import_utils121.AST_NODE_TYPES.NewExpression && unwrappedNodeCallee?.type === import_utils121.AST_NODE_TYPES.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(unwrappedNodeCallee.name) && (import_utils121.ASTUtils.findVariable(context.sourceCode.getScope(unwrappedNodeCallee), unwrappedNodeCallee.name)?.defs.length ?? 0) === 0;
|
|
22074
22530
|
}
|
|
22075
22531
|
return {
|
|
22076
22532
|
CallExpression(node) {
|
|
22077
22533
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
22078
|
-
if (unwrappedNodeCallee.type !==
|
|
22534
|
+
if (unwrappedNodeCallee.type !== import_utils121.AST_NODE_TYPES.MemberExpression)
|
|
22079
22535
|
return;
|
|
22080
|
-
const method =
|
|
22536
|
+
const method = import_utils121.ASTUtils.getPropertyName(unwrappedNodeCallee);
|
|
22081
22537
|
if (knownNonDatabase(unwrappedNodeCallee.object)) return;
|
|
22082
22538
|
if (method === null || !isDatabaseOperation(method, unwrappedNodeCallee.object))
|
|
22083
22539
|
return;
|
|
@@ -22093,7 +22549,7 @@ var require_sql_access_class_default = createRule({
|
|
|
22093
22549
|
});
|
|
22094
22550
|
|
|
22095
22551
|
// src/rules/require-static-next-matcher.ts
|
|
22096
|
-
var
|
|
22552
|
+
var import_utils122 = require("@typescript-eslint/utils");
|
|
22097
22553
|
var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
22098
22554
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
22099
22555
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -22109,27 +22565,27 @@ var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
|
22109
22565
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
22110
22566
|
function isStaticValue(node) {
|
|
22111
22567
|
const value = unwrapExpression(node);
|
|
22112
|
-
if (value.type ===
|
|
22568
|
+
if (value.type === import_utils122.AST_NODE_TYPES.Literal) {
|
|
22113
22569
|
return true;
|
|
22114
22570
|
}
|
|
22115
|
-
if (value.type ===
|
|
22571
|
+
if (value.type === import_utils122.AST_NODE_TYPES.TemplateLiteral) {
|
|
22116
22572
|
return value.expressions.length === 0;
|
|
22117
22573
|
}
|
|
22118
|
-
if (value.type ===
|
|
22574
|
+
if (value.type === import_utils122.AST_NODE_TYPES.ArrayExpression) {
|
|
22119
22575
|
return value.elements.every(
|
|
22120
|
-
(element) => element !== null && element.type !==
|
|
22576
|
+
(element) => element !== null && element.type !== import_utils122.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
22121
22577
|
);
|
|
22122
22578
|
}
|
|
22123
|
-
if (value.type ===
|
|
22579
|
+
if (value.type === import_utils122.AST_NODE_TYPES.ObjectExpression) {
|
|
22124
22580
|
return value.properties.every(
|
|
22125
|
-
(property) => property.type ===
|
|
22581
|
+
(property) => property.type === import_utils122.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils122.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
22126
22582
|
);
|
|
22127
22583
|
}
|
|
22128
22584
|
return false;
|
|
22129
22585
|
}
|
|
22130
22586
|
function propertyName5(property) {
|
|
22131
|
-
if (!property.computed && property.key.type ===
|
|
22132
|
-
return property.key.type ===
|
|
22587
|
+
if (!property.computed && property.key.type === import_utils122.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
22588
|
+
return property.key.type === import_utils122.AST_NODE_TYPES.Literal && typeof property.key.value === "string" ? property.key.value : null;
|
|
22133
22589
|
}
|
|
22134
22590
|
var require_static_next_matcher_default = createRule({
|
|
22135
22591
|
name: "require-static-next-matcher",
|
|
@@ -22151,19 +22607,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
22151
22607
|
}
|
|
22152
22608
|
return {
|
|
22153
22609
|
ExportNamedDeclaration(node) {
|
|
22154
|
-
if (node.declaration?.type !==
|
|
22610
|
+
if (node.declaration?.type !== import_utils122.AST_NODE_TYPES.VariableDeclaration) {
|
|
22155
22611
|
return;
|
|
22156
22612
|
}
|
|
22157
22613
|
for (const declaration of node.declaration.declarations) {
|
|
22158
|
-
if (declaration.id.type !==
|
|
22614
|
+
if (declaration.id.type !== import_utils122.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
22159
22615
|
continue;
|
|
22160
22616
|
}
|
|
22161
22617
|
const config = unwrapExpression(declaration.init);
|
|
22162
|
-
if (config.type !==
|
|
22618
|
+
if (config.type !== import_utils122.AST_NODE_TYPES.ObjectExpression) {
|
|
22163
22619
|
continue;
|
|
22164
22620
|
}
|
|
22165
22621
|
for (const property of config.properties) {
|
|
22166
|
-
if (property.type !==
|
|
22622
|
+
if (property.type !== import_utils122.AST_NODE_TYPES.Property || propertyName5(property) !== "matcher" || property.value.type === import_utils122.AST_NODE_TYPES.AssignmentPattern) {
|
|
22167
22623
|
continue;
|
|
22168
22624
|
}
|
|
22169
22625
|
if (!isStaticValue(property.value)) {
|
|
@@ -22177,7 +22633,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
22177
22633
|
});
|
|
22178
22634
|
|
|
22179
22635
|
// src/rules/require-use-form-default-values.ts
|
|
22180
|
-
var
|
|
22636
|
+
var import_utils123 = require("@typescript-eslint/utils");
|
|
22181
22637
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
22182
22638
|
summary: "Require explicit form-level initialization or a field default for directly bound Controller fields.",
|
|
22183
22639
|
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.",
|
|
@@ -22208,10 +22664,10 @@ var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
|
22208
22664
|
}
|
|
22209
22665
|
]
|
|
22210
22666
|
};
|
|
22211
|
-
function
|
|
22667
|
+
function staticPropertyName2(property) {
|
|
22212
22668
|
if (property.computed) return null;
|
|
22213
|
-
if (property.key.type ===
|
|
22214
|
-
if (property.key.type ===
|
|
22669
|
+
if (property.key.type === import_utils123.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
22670
|
+
if (property.key.type === import_utils123.AST_NODE_TYPES.Literal && typeof property.key.value === "string") return property.key.value;
|
|
22215
22671
|
return null;
|
|
22216
22672
|
}
|
|
22217
22673
|
var require_use_form_default_values_default = createRule({
|
|
@@ -22228,7 +22684,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22228
22684
|
const imported = /* @__PURE__ */ new Map();
|
|
22229
22685
|
const uninitializedForms = /* @__PURE__ */ new Set();
|
|
22230
22686
|
const uninitializedControls = /* @__PURE__ */ new Set();
|
|
22231
|
-
const bindingNamed = (node, name) =>
|
|
22687
|
+
const bindingNamed = (node, name) => import_utils123.ASTUtils.findVariable(context.sourceCode.getScope(node), name);
|
|
22232
22688
|
const bindingOf = (node) => bindingNamed(node, node.name);
|
|
22233
22689
|
const stable = (variable) => !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
22234
22690
|
const importedKind = (node) => {
|
|
@@ -22241,49 +22697,49 @@ var require_use_form_default_values_default = createRule({
|
|
|
22241
22697
|
};
|
|
22242
22698
|
const isDefinitelyUndefined = (node) => {
|
|
22243
22699
|
const value = unwrapExpression(node);
|
|
22244
|
-
return value.type ===
|
|
22700
|
+
return value.type === import_utils123.AST_NODE_TYPES.UnaryExpression && value.operator === "void" || value.type === import_utils123.AST_NODE_TYPES.Identifier && value.name === "undefined" && (bindingOf(value)?.defs.length ?? 0) === 0;
|
|
22245
22701
|
};
|
|
22246
22702
|
const uninitializedUseFormCall = (node) => {
|
|
22247
22703
|
node = unwrapExpression(node);
|
|
22248
22704
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
22249
|
-
if (node.type !==
|
|
22705
|
+
if (node.type !== import_utils123.AST_NODE_TYPES.CallExpression || unwrappedNodeCallee?.type !== import_utils123.AST_NODE_TYPES.Identifier || importedKind(unwrappedNodeCallee) !== "useForm") return false;
|
|
22250
22706
|
const options = node.arguments[0];
|
|
22251
|
-
return options?.type !==
|
|
22707
|
+
return options?.type !== import_utils123.AST_NODE_TYPES.SpreadElement && initializationState(options) === "uninitialized";
|
|
22252
22708
|
};
|
|
22253
22709
|
const initializationState = (node) => {
|
|
22254
22710
|
if (node === void 0) return "uninitialized";
|
|
22255
|
-
if (node.type !==
|
|
22711
|
+
if (node.type !== import_utils123.AST_NODE_TYPES.ObjectExpression) return "unknown";
|
|
22256
22712
|
const initialization = /* @__PURE__ */ new Map();
|
|
22257
22713
|
for (const property of node.properties) {
|
|
22258
|
-
if (property.type ===
|
|
22259
|
-
if (property.type !==
|
|
22260
|
-
const name =
|
|
22714
|
+
if (property.type === import_utils123.AST_NODE_TYPES.SpreadElement || property.computed) return "unknown";
|
|
22715
|
+
if (property.type !== import_utils123.AST_NODE_TYPES.Property) continue;
|
|
22716
|
+
const name = staticPropertyName2(property);
|
|
22261
22717
|
if (name === "defaultValues" || name === "values") initialization.set(name, !isDefinitelyUndefined(property.value));
|
|
22262
22718
|
}
|
|
22263
22719
|
return [...initialization.values()].some(Boolean) ? "initialized" : "uninitialized";
|
|
22264
22720
|
};
|
|
22265
22721
|
const isUninitializedForm = (node) => {
|
|
22266
22722
|
node = unwrapExpression(node);
|
|
22267
|
-
if (node.type !==
|
|
22723
|
+
if (node.type !== import_utils123.AST_NODE_TYPES.Identifier) return false;
|
|
22268
22724
|
const variable = bindingOf(node);
|
|
22269
22725
|
return variable !== null && stable(variable) && uninitializedForms.has(variable);
|
|
22270
22726
|
};
|
|
22271
22727
|
const isUninitializedControl = (node) => {
|
|
22272
22728
|
node = unwrapExpression(node);
|
|
22273
|
-
if (node.type ===
|
|
22729
|
+
if (node.type === import_utils123.AST_NODE_TYPES.Identifier) {
|
|
22274
22730
|
const variable = bindingOf(node);
|
|
22275
22731
|
return variable !== null && stable(variable) && uninitializedControls.has(variable);
|
|
22276
22732
|
}
|
|
22277
|
-
return node.type ===
|
|
22733
|
+
return node.type === import_utils123.AST_NODE_TYPES.MemberExpression && import_utils123.ASTUtils.getPropertyName(node) !== null && (import_utils123.ASTUtils.getPropertyName(node) ?? "") === "control" && isUninitializedForm(node.object);
|
|
22278
22734
|
};
|
|
22279
22735
|
const fieldOptionsNeedDefault = (node) => {
|
|
22280
|
-
if (node?.type !==
|
|
22736
|
+
if (node?.type !== import_utils123.AST_NODE_TYPES.ObjectExpression) return false;
|
|
22281
22737
|
let control = null;
|
|
22282
22738
|
let hasDefault = false;
|
|
22283
22739
|
for (const property of node.properties) {
|
|
22284
|
-
if (property.type ===
|
|
22285
|
-
if (property.type !==
|
|
22286
|
-
const name =
|
|
22740
|
+
if (property.type === import_utils123.AST_NODE_TYPES.SpreadElement || property.computed) return false;
|
|
22741
|
+
if (property.type !== import_utils123.AST_NODE_TYPES.Property) continue;
|
|
22742
|
+
const name = staticPropertyName2(property);
|
|
22287
22743
|
if (name === "control") control = property.value;
|
|
22288
22744
|
if (name === "defaultValue") hasDefault = !isDefinitelyUndefined(property.value);
|
|
22289
22745
|
}
|
|
@@ -22292,14 +22748,14 @@ var require_use_form_default_values_default = createRule({
|
|
|
22292
22748
|
const jsxAttribute = (node, name) => {
|
|
22293
22749
|
let result = null;
|
|
22294
22750
|
for (const attribute of node.attributes) {
|
|
22295
|
-
if (attribute.type ===
|
|
22296
|
-
if (attribute.name.type ===
|
|
22751
|
+
if (attribute.type === import_utils123.AST_NODE_TYPES.JSXSpreadAttribute) return null;
|
|
22752
|
+
if (attribute.name.type === import_utils123.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === name) result = attribute;
|
|
22297
22753
|
}
|
|
22298
22754
|
return result;
|
|
22299
22755
|
};
|
|
22300
22756
|
const trackDestructuredControl = (pattern) => {
|
|
22301
22757
|
for (const property of pattern.properties) {
|
|
22302
|
-
if (property.type !==
|
|
22758
|
+
if (property.type !== import_utils123.AST_NODE_TYPES.Property || staticPropertyName2(property) !== "control" || property.value.type !== import_utils123.AST_NODE_TYPES.Identifier) continue;
|
|
22303
22759
|
const variable = bindingOf(property.value);
|
|
22304
22760
|
if (variable !== null) uninitializedControls.add(variable);
|
|
22305
22761
|
}
|
|
@@ -22308,8 +22764,8 @@ var require_use_form_default_values_default = createRule({
|
|
|
22308
22764
|
ImportDeclaration(node) {
|
|
22309
22765
|
if (node.source.value !== "react-hook-form") return;
|
|
22310
22766
|
for (const specifier of node.specifiers) {
|
|
22311
|
-
if (specifier.type !==
|
|
22312
|
-
const name = specifier.imported.type ===
|
|
22767
|
+
if (specifier.type !== import_utils123.AST_NODE_TYPES.ImportSpecifier) continue;
|
|
22768
|
+
const name = specifier.imported.type === import_utils123.AST_NODE_TYPES.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
22313
22769
|
if (name !== "Controller" && name !== "useController" && name !== "useForm") continue;
|
|
22314
22770
|
const variable = bindingOf(specifier.local);
|
|
22315
22771
|
if (variable !== null) imported.set(variable, name);
|
|
@@ -22318,35 +22774,35 @@ var require_use_form_default_values_default = createRule({
|
|
|
22318
22774
|
VariableDeclarator(node) {
|
|
22319
22775
|
if (node.init === null) return;
|
|
22320
22776
|
if (uninitializedUseFormCall(node.init)) {
|
|
22321
|
-
if (node.id.type ===
|
|
22777
|
+
if (node.id.type === import_utils123.AST_NODE_TYPES.Identifier) {
|
|
22322
22778
|
const variable = bindingOf(node.id);
|
|
22323
22779
|
if (variable !== null) uninitializedForms.add(variable);
|
|
22324
|
-
} else if (node.id.type ===
|
|
22780
|
+
} else if (node.id.type === import_utils123.AST_NODE_TYPES.ObjectPattern) {
|
|
22325
22781
|
trackDestructuredControl(node.id);
|
|
22326
22782
|
}
|
|
22327
22783
|
return;
|
|
22328
22784
|
}
|
|
22329
|
-
if (node.id.type ===
|
|
22785
|
+
if (node.id.type === import_utils123.AST_NODE_TYPES.ObjectPattern && isUninitializedForm(node.init)) {
|
|
22330
22786
|
trackDestructuredControl(node.id);
|
|
22331
22787
|
return;
|
|
22332
22788
|
}
|
|
22333
|
-
if (node.id.type ===
|
|
22789
|
+
if (node.id.type === import_utils123.AST_NODE_TYPES.Identifier && node.init.type === import_utils123.AST_NODE_TYPES.MemberExpression && import_utils123.ASTUtils.getPropertyName(node.init) !== null && (import_utils123.ASTUtils.getPropertyName(node.init) ?? "") === "control" && isUninitializedForm(node.init.object)) {
|
|
22334
22790
|
const variable = bindingOf(node.id);
|
|
22335
22791
|
if (variable !== null) uninitializedControls.add(variable);
|
|
22336
22792
|
}
|
|
22337
22793
|
},
|
|
22338
22794
|
CallExpression(node) {
|
|
22339
22795
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
22340
|
-
if (unwrappedNodeCallee.type !==
|
|
22796
|
+
if (unwrappedNodeCallee.type !== import_utils123.AST_NODE_TYPES.Identifier || importedKind(unwrappedNodeCallee) !== "useController" || !fieldOptionsNeedDefault(node.arguments[0]?.type === import_utils123.AST_NODE_TYPES.SpreadElement ? void 0 : node.arguments[0])) return;
|
|
22341
22797
|
context.report({ node, messageId: "requireUseFormDefaultValues" });
|
|
22342
22798
|
},
|
|
22343
22799
|
JSXOpeningElement(node) {
|
|
22344
|
-
if (node.name.type !==
|
|
22345
|
-
if (node.attributes.some((attribute) => attribute.type ===
|
|
22800
|
+
if (node.name.type !== import_utils123.AST_NODE_TYPES.JSXIdentifier || importedJsxKind(node.name) !== "Controller") return;
|
|
22801
|
+
if (node.attributes.some((attribute) => attribute.type === import_utils123.AST_NODE_TYPES.JSXSpreadAttribute)) return;
|
|
22346
22802
|
const control = jsxAttribute(node, "control");
|
|
22347
|
-
if (control?.value?.type !==
|
|
22803
|
+
if (control?.value?.type !== import_utils123.AST_NODE_TYPES.JSXExpressionContainer || control.value.expression.type === import_utils123.AST_NODE_TYPES.JSXEmptyExpression || !isUninitializedControl(control.value.expression)) return;
|
|
22348
22804
|
const defaultValue = jsxAttribute(node, "defaultValue");
|
|
22349
|
-
if (defaultValue !== null && (defaultValue.value === null || defaultValue.value.type !==
|
|
22805
|
+
if (defaultValue !== null && (defaultValue.value === null || defaultValue.value.type !== import_utils123.AST_NODE_TYPES.JSXExpressionContainer || defaultValue.value.expression.type !== import_utils123.AST_NODE_TYPES.JSXEmptyExpression && !isDefinitelyUndefined(defaultValue.value.expression))) return;
|
|
22350
22806
|
context.report({ node, messageId: "requireUseFormDefaultValues" });
|
|
22351
22807
|
}
|
|
22352
22808
|
};
|
|
@@ -22354,7 +22810,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22354
22810
|
});
|
|
22355
22811
|
|
|
22356
22812
|
// src/rules/require-use-server-in-actions-file.ts
|
|
22357
|
-
var
|
|
22813
|
+
var import_utils124 = require("@typescript-eslint/utils");
|
|
22358
22814
|
var ACTION_MODULE_RE = /(?:^|\/)app\/.*\/(?:actions|[^/]+-actions)\.[cm]?[jt]s$/u;
|
|
22359
22815
|
var REQUIRE_USE_SERVER_IN_ACTIONS_FILE_DOCUMENTATION = {
|
|
22360
22816
|
summary: "route action module missing the use server directive",
|
|
@@ -22421,7 +22877,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
22421
22877
|
});
|
|
22422
22878
|
|
|
22423
22879
|
// src/rules/require-zod-form-validation.ts
|
|
22424
|
-
var
|
|
22880
|
+
var import_utils125 = require("@typescript-eslint/utils");
|
|
22425
22881
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
22426
22882
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
22427
22883
|
rationale: "FormData values are untrusted strings or files and need runtime validation before use.",
|
|
@@ -22447,14 +22903,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
22447
22903
|
var zodReceiverRoot = (node) => {
|
|
22448
22904
|
let current = node;
|
|
22449
22905
|
while (true) {
|
|
22450
|
-
if (current.type ===
|
|
22906
|
+
if (current.type === import_utils125.AST_NODE_TYPES.Identifier) {
|
|
22451
22907
|
return current;
|
|
22452
22908
|
}
|
|
22453
|
-
if (current.type ===
|
|
22909
|
+
if (current.type === import_utils125.AST_NODE_TYPES.CallExpression) {
|
|
22454
22910
|
current = current.callee;
|
|
22455
22911
|
continue;
|
|
22456
22912
|
}
|
|
22457
|
-
if (current.type ===
|
|
22913
|
+
if (current.type === import_utils125.AST_NODE_TYPES.MemberExpression) {
|
|
22458
22914
|
current = current.object;
|
|
22459
22915
|
continue;
|
|
22460
22916
|
}
|
|
@@ -22463,12 +22919,12 @@ var zodReceiverRoot = (node) => {
|
|
|
22463
22919
|
};
|
|
22464
22920
|
var isFormDataMethodCall = (node) => {
|
|
22465
22921
|
let current = node;
|
|
22466
|
-
if (current.type ===
|
|
22922
|
+
if (current.type === import_utils125.AST_NODE_TYPES.AwaitExpression) {
|
|
22467
22923
|
current = current.argument;
|
|
22468
22924
|
}
|
|
22469
|
-
if (current.type !==
|
|
22925
|
+
if (current.type !== import_utils125.AST_NODE_TYPES.CallExpression) return false;
|
|
22470
22926
|
const callee = unwrapExpression(current.callee);
|
|
22471
|
-
return callee.type ===
|
|
22927
|
+
return callee.type === import_utils125.AST_NODE_TYPES.MemberExpression && import_utils125.ASTUtils.getPropertyName(callee) === "formData";
|
|
22472
22928
|
};
|
|
22473
22929
|
var require_zod_form_validation_default = createRule({
|
|
22474
22930
|
name: "require-zod-form-validation",
|
|
@@ -22489,29 +22945,29 @@ var require_zod_form_validation_default = createRule({
|
|
|
22489
22945
|
return {};
|
|
22490
22946
|
}
|
|
22491
22947
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
22492
|
-
const resolvedBinding = (identifier) =>
|
|
22948
|
+
const resolvedBinding = (identifier) => import_utils125.ASTUtils.findVariable(
|
|
22493
22949
|
context.sourceCode.getScope(identifier),
|
|
22494
22950
|
identifier.name
|
|
22495
22951
|
);
|
|
22496
22952
|
const isFormDataGetCall = (node) => {
|
|
22497
22953
|
const callee = unwrapExpression(node.callee);
|
|
22498
|
-
const calleeReceiver = callee.type ===
|
|
22499
|
-
if (callee.type !==
|
|
22500
|
-
if (
|
|
22954
|
+
const calleeReceiver = callee.type === import_utils125.AST_NODE_TYPES.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
22955
|
+
if (callee.type !== import_utils125.AST_NODE_TYPES.MemberExpression) return false;
|
|
22956
|
+
if (import_utils125.ASTUtils.getPropertyName(callee) === null || !FORM_VALUE_METHODS.has(import_utils125.ASTUtils.getPropertyName(callee) ?? "")) {
|
|
22501
22957
|
return false;
|
|
22502
22958
|
}
|
|
22503
22959
|
return isFormSourceIdentifier(calleeReceiver);
|
|
22504
22960
|
};
|
|
22505
22961
|
const isFormSourceIdentifier = (node) => {
|
|
22506
22962
|
node = unwrapExpression(node);
|
|
22507
|
-
if (node.type !==
|
|
22963
|
+
if (node.type !== import_utils125.AST_NODE_TYPES.Identifier) return false;
|
|
22508
22964
|
const conventionalName = /formdata/i.test(node.name);
|
|
22509
22965
|
let scope = context.sourceCode.getScope(node);
|
|
22510
22966
|
while (scope !== null) {
|
|
22511
22967
|
const variable = scope.set.get(node.name);
|
|
22512
22968
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
22513
22969
|
const def = variable.defs[0];
|
|
22514
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
22970
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils125.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
22515
22971
|
return isFormDataMethodCall(def.node.init);
|
|
22516
22972
|
}
|
|
22517
22973
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -22524,24 +22980,24 @@ var require_zod_form_validation_default = createRule({
|
|
|
22524
22980
|
let parent = node.parent;
|
|
22525
22981
|
while (parent !== null && parent !== void 0) {
|
|
22526
22982
|
if (isZodParseCall(parent)) return parent;
|
|
22527
|
-
if (parent.type ===
|
|
22983
|
+
if (parent.type === import_utils125.AST_NODE_TYPES.CallExpression && parent.callee.type === import_utils125.AST_NODE_TYPES.Identifier && ["Number", "String", "Boolean"].includes(parent.callee.name) && parent.arguments.length === 1 && (resolvedBinding(parent.callee)?.defs.length ?? 0) === 0) {
|
|
22528
22984
|
parent = parent.parent;
|
|
22529
22985
|
continue;
|
|
22530
22986
|
}
|
|
22531
|
-
if (parent.type ===
|
|
22987
|
+
if (parent.type === import_utils125.AST_NODE_TYPES.CallExpression && parent.callee.type === import_utils125.AST_NODE_TYPES.MemberExpression && parent.callee.object.type === import_utils125.AST_NODE_TYPES.Identifier && parent.callee.object.name === "Object" && import_utils125.ASTUtils.getPropertyName(parent.callee) === "fromEntries" && (resolvedBinding(parent.callee.object)?.defs.length ?? 0) === 0) {
|
|
22532
22988
|
parent = parent.parent;
|
|
22533
22989
|
continue;
|
|
22534
22990
|
}
|
|
22535
|
-
if (parent.type ===
|
|
22991
|
+
if (parent.type === import_utils125.AST_NODE_TYPES.CallExpression || parent.type === import_utils125.AST_NODE_TYPES.NewExpression || parent.type === import_utils125.AST_NODE_TYPES.TaggedTemplateExpression || parent.type === import_utils125.AST_NODE_TYPES.ArrowFunctionExpression || parent.type === import_utils125.AST_NODE_TYPES.FunctionExpression || parent.type === import_utils125.AST_NODE_TYPES.FunctionDeclaration) return null;
|
|
22536
22992
|
parent = parent.parent;
|
|
22537
22993
|
}
|
|
22538
22994
|
return null;
|
|
22539
22995
|
};
|
|
22540
22996
|
const isZodParseCall = (node) => {
|
|
22541
|
-
if (node.type !==
|
|
22997
|
+
if (node.type !== import_utils125.AST_NODE_TYPES.CallExpression) return false;
|
|
22542
22998
|
const callee = unwrapExpression(node.callee);
|
|
22543
|
-
const calleeReceiver = callee.type ===
|
|
22544
|
-
if (callee.type !==
|
|
22999
|
+
const calleeReceiver = callee.type === import_utils125.AST_NODE_TYPES.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
23000
|
+
if (callee.type !== import_utils125.AST_NODE_TYPES.MemberExpression || import_utils125.ASTUtils.getPropertyName(callee) === null || !ZOD_PARSE_METHODS.has(import_utils125.ASTUtils.getPropertyName(callee) ?? "")) {
|
|
22545
23001
|
return false;
|
|
22546
23002
|
}
|
|
22547
23003
|
const root = zodReceiverRoot(calleeReceiver);
|
|
@@ -22555,25 +23011,25 @@ var require_zod_form_validation_default = createRule({
|
|
|
22555
23011
|
return false;
|
|
22556
23012
|
}
|
|
22557
23013
|
const definition = binding.defs[0];
|
|
22558
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
23014
|
+
if (definition?.type !== "Variable" || definition.node.type !== import_utils125.AST_NODE_TYPES.VariableDeclarator) {
|
|
22559
23015
|
return false;
|
|
22560
23016
|
}
|
|
22561
23017
|
const init = definition.node.init;
|
|
22562
|
-
return init?.type ===
|
|
23018
|
+
return init?.type === import_utils125.AST_NODE_TYPES.ObjectExpression || init?.type === import_utils125.AST_NODE_TYPES.ArrayExpression || init?.type === import_utils125.AST_NODE_TYPES.Literal || init?.type === import_utils125.AST_NODE_TYPES.ArrowFunctionExpression || init?.type === import_utils125.AST_NODE_TYPES.FunctionExpression;
|
|
22563
23019
|
};
|
|
22564
23020
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
22565
23021
|
const isInstanceofNarrowing = (node) => {
|
|
22566
23022
|
const parent = node.parent;
|
|
22567
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
23023
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils125.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils125.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
22568
23024
|
};
|
|
22569
23025
|
const boundDeclarator = (node) => {
|
|
22570
23026
|
let current = node;
|
|
22571
23027
|
let parent = current.parent;
|
|
22572
|
-
while ((parent.type ===
|
|
23028
|
+
while ((parent.type === import_utils125.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils125.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils125.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils125.AST_NODE_TYPES.ChainExpression) && parent.expression === current) {
|
|
22573
23029
|
current = parent;
|
|
22574
23030
|
parent = current.parent;
|
|
22575
23031
|
}
|
|
22576
|
-
if (parent.type ===
|
|
23032
|
+
if (parent.type === import_utils125.AST_NODE_TYPES.VariableDeclarator && parent.init === current && parent.id.type === import_utils125.AST_NODE_TYPES.Identifier) {
|
|
22577
23033
|
return parent;
|
|
22578
23034
|
}
|
|
22579
23035
|
return null;
|
|
@@ -22582,7 +23038,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22582
23038
|
let current = node;
|
|
22583
23039
|
while (current.parent !== void 0) {
|
|
22584
23040
|
const parent = current.parent;
|
|
22585
|
-
if (parent.type ===
|
|
23041
|
+
if (parent.type === import_utils125.AST_NODE_TYPES.BlockStatement || parent.type === import_utils125.AST_NODE_TYPES.Program) {
|
|
22586
23042
|
return current;
|
|
22587
23043
|
}
|
|
22588
23044
|
current = parent;
|
|
@@ -22597,7 +23053,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22597
23053
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
22598
23054
|
return null;
|
|
22599
23055
|
}
|
|
22600
|
-
if (validationStatement.type !==
|
|
23056
|
+
if (validationStatement.type !== import_utils125.AST_NODE_TYPES.VariableDeclaration && validationStatement.type !== import_utils125.AST_NODE_TYPES.ExpressionStatement) {
|
|
22601
23057
|
return null;
|
|
22602
23058
|
}
|
|
22603
23059
|
const method = zodParseMethod(parse2);
|
|
@@ -22610,7 +23066,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22610
23066
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
22611
23067
|
let current = node.parent;
|
|
22612
23068
|
while (current !== void 0 && current !== statement) {
|
|
22613
|
-
if (current.type ===
|
|
23069
|
+
if (current.type === import_utils125.AST_NODE_TYPES.AwaitExpression) return true;
|
|
22614
23070
|
current = current.parent;
|
|
22615
23071
|
}
|
|
22616
23072
|
return false;
|
|
@@ -22618,7 +23074,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22618
23074
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
22619
23075
|
let current = node.parent;
|
|
22620
23076
|
while (current !== void 0 && current !== statement) {
|
|
22621
|
-
if (current.type ===
|
|
23077
|
+
if (current.type === import_utils125.AST_NODE_TYPES.LogicalExpression || current.type === import_utils125.AST_NODE_TYPES.ConditionalExpression) {
|
|
22622
23078
|
return true;
|
|
22623
23079
|
}
|
|
22624
23080
|
current = current.parent;
|
|
@@ -22627,20 +23083,20 @@ var require_zod_form_validation_default = createRule({
|
|
|
22627
23083
|
};
|
|
22628
23084
|
const zodParseMethod = (call) => {
|
|
22629
23085
|
const callee = unwrapExpression(call.callee);
|
|
22630
|
-
return callee.type ===
|
|
23086
|
+
return callee.type === import_utils125.AST_NODE_TYPES.MemberExpression && import_utils125.ASTUtils.getPropertyName(callee) !== null ? import_utils125.ASTUtils.getPropertyName(callee) ?? "" : null;
|
|
22631
23087
|
};
|
|
22632
23088
|
const isSafePrevalidationInspection = (identifier) => {
|
|
22633
23089
|
const parent = identifier.parent;
|
|
22634
|
-
if (parent.type ===
|
|
23090
|
+
if (parent.type === import_utils125.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof") {
|
|
22635
23091
|
return true;
|
|
22636
23092
|
}
|
|
22637
|
-
if (parent.type !==
|
|
23093
|
+
if (parent.type !== import_utils125.AST_NODE_TYPES.BinaryExpression || parent.left !== identifier) {
|
|
22638
23094
|
return false;
|
|
22639
23095
|
}
|
|
22640
23096
|
if (parent.operator === "instanceof") {
|
|
22641
|
-
return parent.right.type ===
|
|
23097
|
+
return parent.right.type === import_utils125.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
22642
23098
|
}
|
|
22643
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
23099
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === import_utils125.AST_NODE_TYPES.Literal && parent.right.value === null || parent.right.type === import_utils125.AST_NODE_TYPES.Identifier && parent.right.name === "undefined");
|
|
22644
23100
|
};
|
|
22645
23101
|
const isDescendantOf = (node, ancestor) => {
|
|
22646
23102
|
let current = node;
|
|
@@ -22651,23 +23107,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
22651
23107
|
return false;
|
|
22652
23108
|
};
|
|
22653
23109
|
const blockTerminates = (node) => {
|
|
22654
|
-
if (node.type ===
|
|
23110
|
+
if (node.type === import_utils125.AST_NODE_TYPES.ReturnStatement || node.type === import_utils125.AST_NODE_TYPES.ThrowStatement) {
|
|
22655
23111
|
return true;
|
|
22656
23112
|
}
|
|
22657
|
-
if (node.type !==
|
|
23113
|
+
if (node.type !== import_utils125.AST_NODE_TYPES.BlockStatement || node.body.length === 0) return false;
|
|
22658
23114
|
const last = node.body.at(-1);
|
|
22659
23115
|
return last !== void 0 && blockTerminates(last);
|
|
22660
23116
|
};
|
|
22661
23117
|
const narrowingIf = (identifier) => {
|
|
22662
23118
|
const comparison = identifier.parent;
|
|
22663
|
-
if (comparison?.type !==
|
|
23119
|
+
if (comparison?.type !== import_utils125.AST_NODE_TYPES.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== import_utils125.AST_NODE_TYPES.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
22664
23120
|
return null;
|
|
22665
23121
|
}
|
|
22666
23122
|
const maybeNegation = comparison.parent;
|
|
22667
|
-
const negated = maybeNegation?.type ===
|
|
23123
|
+
const negated = maybeNegation?.type === import_utils125.AST_NODE_TYPES.UnaryExpression && maybeNegation.operator === "!";
|
|
22668
23124
|
const test = negated ? maybeNegation : comparison;
|
|
22669
23125
|
const branch = test.parent;
|
|
22670
|
-
return branch?.type ===
|
|
23126
|
+
return branch?.type === import_utils125.AST_NODE_TYPES.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
22671
23127
|
};
|
|
22672
23128
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
22673
23129
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -22687,7 +23143,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22687
23143
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
22688
23144
|
if (variable === void 0) return false;
|
|
22689
23145
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
22690
|
-
(identifier) => identifier.type ===
|
|
23146
|
+
(identifier) => identifier.type === import_utils125.AST_NODE_TYPES.Identifier
|
|
22691
23147
|
);
|
|
22692
23148
|
if (references.length === 0) return false;
|
|
22693
23149
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -22713,7 +23169,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22713
23169
|
ImportDeclaration(node) {
|
|
22714
23170
|
if (!isZodModule(node.source.value)) return;
|
|
22715
23171
|
for (const specifier of node.specifiers) {
|
|
22716
|
-
if (specifier.type ===
|
|
23172
|
+
if (specifier.type === import_utils125.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils125.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils125.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils125.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
22717
23173
|
const binding = resolvedBinding(specifier.local);
|
|
22718
23174
|
if (binding !== null) zodBindings.add(binding);
|
|
22719
23175
|
}
|
|
@@ -22734,7 +23190,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22734
23190
|
});
|
|
22735
23191
|
|
|
22736
23192
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
22737
|
-
var
|
|
23193
|
+
var import_utils126 = require("@typescript-eslint/utils");
|
|
22738
23194
|
var STORE_INSERT_REQUIRES_ON_CONFLICT_DOCUMENTATION = {
|
|
22739
23195
|
summary: "Review conflict handling for embedded inserts in replay-named callables.",
|
|
22740
23196
|
rationale: "Names such as seed, enqueue, or upsert suggest that repeated execution deserves a conflict-policy review, but do not prove a replay contract.",
|
|
@@ -22803,7 +23259,7 @@ function expressionCallableName(current) {
|
|
|
22803
23259
|
}
|
|
22804
23260
|
|
|
22805
23261
|
// src/rules/stepdown.ts
|
|
22806
|
-
var
|
|
23262
|
+
var import_utils127 = require("@typescript-eslint/utils");
|
|
22807
23263
|
var STEPDOWN_DOCUMENTATION = {
|
|
22808
23264
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
22809
23265
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -22821,7 +23277,7 @@ var STEPDOWN_DOCUMENTATION = {
|
|
|
22821
23277
|
]
|
|
22822
23278
|
};
|
|
22823
23279
|
function isFunction(node) {
|
|
22824
|
-
return node.type ===
|
|
23280
|
+
return node.type === import_utils127.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils127.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils127.AST_NODE_TYPES.FunctionExpression;
|
|
22825
23281
|
}
|
|
22826
23282
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true) {
|
|
22827
23283
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.key, definition]));
|
|
@@ -22917,7 +23373,7 @@ function cycleComponents(graph) {
|
|
|
22917
23373
|
return components;
|
|
22918
23374
|
}
|
|
22919
23375
|
function isErasedExpression2(node) {
|
|
22920
|
-
return node.type ===
|
|
23376
|
+
return node.type === import_utils127.AST_NODE_TYPES.TSAsExpression || node.type === import_utils127.AST_NODE_TYPES.TSTypeAssertion || node.type === import_utils127.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils127.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils127.AST_NODE_TYPES.TSInstantiationExpression;
|
|
22921
23377
|
}
|
|
22922
23378
|
function unwrapExpression4(node) {
|
|
22923
23379
|
let current = node;
|
|
@@ -22941,11 +23397,11 @@ function localCallCount(context, node, owner) {
|
|
|
22941
23397
|
if (current === void 0 || enclosingFunction5(context, current) !== owner) return null;
|
|
22942
23398
|
const expression = wrappedExpression(current);
|
|
22943
23399
|
const parent = expression.parent;
|
|
22944
|
-
if (parent?.type ===
|
|
23400
|
+
if (parent?.type === import_utils127.AST_NODE_TYPES.CallExpression && parent.callee === expression) {
|
|
22945
23401
|
count += 1;
|
|
22946
23402
|
continue;
|
|
22947
23403
|
}
|
|
22948
|
-
if (parent?.type !==
|
|
23404
|
+
if (parent?.type !== import_utils127.AST_NODE_TYPES.VariableDeclarator || parent.init !== expression || parent.id.type !== import_utils127.AST_NODE_TYPES.Identifier || parent.parent.type !== import_utils127.AST_NODE_TYPES.VariableDeclaration || parent.parent.kind !== "const") return null;
|
|
22949
23405
|
const variable = context.sourceCode.getDeclaredVariables(parent)[0];
|
|
22950
23406
|
if (variable === void 0 || seen.has(variable) || !stableVariable(variable)) return null;
|
|
22951
23407
|
seen.add(variable);
|
|
@@ -22960,11 +23416,11 @@ function declarationScope(context, program) {
|
|
|
22960
23416
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
22961
23417
|
const overloadNames = new Set(
|
|
22962
23418
|
program.body.flatMap((statement) => {
|
|
22963
|
-
const node = statement.type ===
|
|
22964
|
-
return node?.type ===
|
|
23419
|
+
const node = statement.type === import_utils127.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
23420
|
+
return node?.type === import_utils127.AST_NODE_TYPES.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
22965
23421
|
})
|
|
22966
23422
|
);
|
|
22967
|
-
const exported = program.type ===
|
|
23423
|
+
const exported = program.type === import_utils127.AST_NODE_TYPES.Program ? exportedNames(program) : /* @__PURE__ */ new Set();
|
|
22968
23424
|
const scopeDefinitions = declarations.filter((node) => counts.get(node.name) === 1);
|
|
22969
23425
|
const definitions = scopeDefinitions.filter(
|
|
22970
23426
|
(definition) => !exported.has(definition.name) && !overloadNames.has(definition.name)
|
|
@@ -22976,7 +23432,7 @@ function declarationScope(context, program) {
|
|
|
22976
23432
|
runtimeBarrierPrefix.push((runtimeBarrierPrefix.at(-1) ?? 0) + (isDeferredModuleStatement(statement) ? 0 : 1));
|
|
22977
23433
|
}
|
|
22978
23434
|
const canMove = (helper, caller) => {
|
|
22979
|
-
if (helper.node.type ===
|
|
23435
|
+
if (helper.node.type === import_utils127.AST_NODE_TYPES.FunctionDeclaration) return true;
|
|
22980
23436
|
const helperIndex = statementIndex(helper);
|
|
22981
23437
|
const callerIndex = statementIndex(caller);
|
|
22982
23438
|
return helperIndex !== void 0 && callerIndex !== void 0 && runtimeBarrierPrefix[callerIndex + 1] === runtimeBarrierPrefix[helperIndex + 1];
|
|
@@ -23018,26 +23474,26 @@ function moduleCallGraph(context, scopeDefinitions) {
|
|
|
23018
23474
|
return { calls, pinned };
|
|
23019
23475
|
}
|
|
23020
23476
|
function isDeferredModuleStatement(statement) {
|
|
23021
|
-
const node = statement.type ===
|
|
23022
|
-
if (node === null || node.type ===
|
|
23023
|
-
return node.type ===
|
|
23024
|
-
(declaration) => declaration.id.type ===
|
|
23477
|
+
const node = statement.type === import_utils127.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils127.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
23478
|
+
if (node === null || node.type === import_utils127.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils127.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils127.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils127.AST_NODE_TYPES.TSTypeAliasDeclaration || node.type === import_utils127.AST_NODE_TYPES.ImportDeclaration || node.type === import_utils127.AST_NODE_TYPES.ExportAllDeclaration || node.type === import_utils127.AST_NODE_TYPES.EmptyStatement) return true;
|
|
23479
|
+
return node.type === import_utils127.AST_NODE_TYPES.VariableDeclaration && node.declarations.every(
|
|
23480
|
+
(declaration) => declaration.id.type === import_utils127.AST_NODE_TYPES.Identifier && declaration.init !== null && isFunction(unwrapExpression4(declaration.init))
|
|
23025
23481
|
);
|
|
23026
23482
|
}
|
|
23027
23483
|
function exportedNames(program) {
|
|
23028
23484
|
const names = /* @__PURE__ */ new Set();
|
|
23029
23485
|
function collectNamedExports(statement) {
|
|
23030
|
-
if (statement.type !==
|
|
23031
|
-
if (statement.declaration?.type ===
|
|
23486
|
+
if (statement.type !== import_utils127.AST_NODE_TYPES.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) return;
|
|
23487
|
+
if (statement.declaration?.type === import_utils127.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) {
|
|
23032
23488
|
names.add(statement.declaration.id.name);
|
|
23033
23489
|
}
|
|
23034
|
-
if (statement.declaration?.type ===
|
|
23490
|
+
if (statement.declaration?.type === import_utils127.AST_NODE_TYPES.VariableDeclaration) {
|
|
23035
23491
|
for (const declarator of statement.declaration.declarations) {
|
|
23036
|
-
if (declarator.id.type ===
|
|
23492
|
+
if (declarator.id.type === import_utils127.AST_NODE_TYPES.Identifier) names.add(declarator.id.name);
|
|
23037
23493
|
}
|
|
23038
23494
|
}
|
|
23039
23495
|
for (const specifier of statement.specifiers) {
|
|
23040
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
23496
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils127.AST_NODE_TYPES.Identifier) {
|
|
23041
23497
|
names.add(specifier.local.name);
|
|
23042
23498
|
}
|
|
23043
23499
|
}
|
|
@@ -23046,23 +23502,23 @@ function exportedNames(program) {
|
|
|
23046
23502
|
collectNamedExports(statement);
|
|
23047
23503
|
}
|
|
23048
23504
|
for (const statement of program.body) {
|
|
23049
|
-
if (statement.type ===
|
|
23050
|
-
if (statement.type ===
|
|
23505
|
+
if (statement.type === import_utils127.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils127.AST_NODE_TYPES.Identifier) names.add(statement.declaration.name);
|
|
23506
|
+
if (statement.type === import_utils127.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils127.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
23051
23507
|
}
|
|
23052
23508
|
return names;
|
|
23053
23509
|
}
|
|
23054
23510
|
function moduleDefinitions(program) {
|
|
23055
23511
|
const definitions = [];
|
|
23056
23512
|
for (const statement of program.body) {
|
|
23057
|
-
const node = statement.type ===
|
|
23058
|
-
if (node?.type ===
|
|
23513
|
+
const node = statement.type === import_utils127.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils127.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
23514
|
+
if (node?.type === import_utils127.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
23059
23515
|
definitions.push({ key: node.id.name, name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
23060
23516
|
continue;
|
|
23061
23517
|
}
|
|
23062
|
-
if (node?.type !==
|
|
23518
|
+
if (node?.type !== import_utils127.AST_NODE_TYPES.VariableDeclaration || node.kind !== "const" || node.declarations.length !== 1) continue;
|
|
23063
23519
|
for (const declarator of node.declarations) {
|
|
23064
23520
|
const initializer = declarator.init === null ? null : unwrapExpression4(declarator.init);
|
|
23065
|
-
if (declarator.id.type ===
|
|
23521
|
+
if (declarator.id.type === import_utils127.AST_NODE_TYPES.Identifier && initializer !== null && isFunction(initializer)) {
|
|
23066
23522
|
definitions.push({
|
|
23067
23523
|
key: declarator.id.name,
|
|
23068
23524
|
name: declarator.id.name,
|
|
@@ -23076,25 +23532,25 @@ function moduleDefinitions(program) {
|
|
|
23076
23532
|
return definitions;
|
|
23077
23533
|
}
|
|
23078
23534
|
function methodName(node) {
|
|
23079
|
-
if (node.key.type ===
|
|
23080
|
-
if (!node.computed && node.key.type ===
|
|
23081
|
-
return node.key.type ===
|
|
23535
|
+
if (node.key.type === import_utils127.AST_NODE_TYPES.PrivateIdentifier) return `#${node.key.name}`;
|
|
23536
|
+
if (!node.computed && node.key.type === import_utils127.AST_NODE_TYPES.Identifier) return node.key.name;
|
|
23537
|
+
return node.key.type === import_utils127.AST_NODE_TYPES.Literal && typeof node.key.value === "string" ? node.key.value : null;
|
|
23082
23538
|
}
|
|
23083
23539
|
function methodKey(name, isStatic2) {
|
|
23084
23540
|
return `${isStatic2 ? "static" : "instance"}:${name}`;
|
|
23085
23541
|
}
|
|
23086
23542
|
function receiverDomain(context, object, receivers, thisIsStatic) {
|
|
23087
23543
|
const unwrapped = unwrapExpression4(object);
|
|
23088
|
-
if (unwrapped.type ===
|
|
23544
|
+
if (unwrapped.type === import_utils127.AST_NODE_TYPES.ThisExpression) return thisIsStatic;
|
|
23089
23545
|
return externalReceiverDomain(context, unwrapped, receivers);
|
|
23090
23546
|
}
|
|
23091
23547
|
function externalReceiverDomain(context, object, receivers) {
|
|
23092
23548
|
const origin = receiverOrigin(context, object, receivers);
|
|
23093
23549
|
if (origin === null || typeof origin === "boolean") return origin;
|
|
23094
|
-
if (origin.type ===
|
|
23550
|
+
if (origin.type === import_utils127.AST_NODE_TYPES.NewExpression) {
|
|
23095
23551
|
return receiverOrigin(context, origin.callee, receivers) === true ? false : null;
|
|
23096
23552
|
}
|
|
23097
|
-
if (origin.type ===
|
|
23553
|
+
if (origin.type === import_utils127.AST_NODE_TYPES.ObjectExpression || origin.type === import_utils127.AST_NODE_TYPES.ArrayExpression || origin.type === import_utils127.AST_NODE_TYPES.Literal || origin.type === import_utils127.AST_NODE_TYPES.ArrowFunctionExpression || origin.type === import_utils127.AST_NODE_TYPES.FunctionExpression) return "unrelated";
|
|
23098
23554
|
return null;
|
|
23099
23555
|
}
|
|
23100
23556
|
function receiverOrigin(context, object, receivers) {
|
|
@@ -23102,8 +23558,8 @@ function receiverOrigin(context, object, receivers) {
|
|
|
23102
23558
|
const seen = /* @__PURE__ */ new Set();
|
|
23103
23559
|
while (true) {
|
|
23104
23560
|
const unwrapped = unwrapExpression4(current);
|
|
23105
|
-
if (unwrapped.type !==
|
|
23106
|
-
const variable =
|
|
23561
|
+
if (unwrapped.type !== import_utils127.AST_NODE_TYPES.Identifier) return unwrapped;
|
|
23562
|
+
const variable = import_utils127.ASTUtils.findVariable(context.sourceCode.getScope(unwrapped), unwrapped.name);
|
|
23107
23563
|
if (variable === null) return null;
|
|
23108
23564
|
const known = receivers.get(variable);
|
|
23109
23565
|
if (known !== void 0) return known;
|
|
@@ -23116,25 +23572,25 @@ function immutableInitializer(variable, seen) {
|
|
|
23116
23572
|
if (seen.has(variable) || !stableVariable(variable) || variable.defs.length !== 1) return null;
|
|
23117
23573
|
seen.add(variable);
|
|
23118
23574
|
const definition = variable.defs[0];
|
|
23119
|
-
if (definition?.node.type !==
|
|
23575
|
+
if (definition?.node.type !== import_utils127.AST_NODE_TYPES.VariableDeclarator || definition.node.parent.type !== import_utils127.AST_NODE_TYPES.VariableDeclaration || definition.node.parent.kind !== "const") return null;
|
|
23120
23576
|
return definition.node.init;
|
|
23121
23577
|
}
|
|
23122
23578
|
function stableVariable(variable) {
|
|
23123
23579
|
return !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
23124
23580
|
}
|
|
23125
23581
|
function referencedPropertyName(node) {
|
|
23126
|
-
if (node.property.type ===
|
|
23127
|
-
if (!node.computed && node.property.type ===
|
|
23128
|
-
return node.computed && node.property.type ===
|
|
23582
|
+
if (node.property.type === import_utils127.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
23583
|
+
if (!node.computed && node.property.type === import_utils127.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
23584
|
+
return node.computed && node.property.type === import_utils127.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
23129
23585
|
}
|
|
23130
23586
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
23131
23587
|
visit(node, nestedFunction);
|
|
23132
|
-
const nested = nestedFunction || isFunction(node) || node.type ===
|
|
23588
|
+
const nested = nestedFunction || isFunction(node) || node.type === import_utils127.AST_NODE_TYPES.ClassDeclaration || node.type === import_utils127.AST_NODE_TYPES.ClassExpression;
|
|
23133
23589
|
forEachAstChild(node, visitorKeys, (child) => walk(child, visitorKeys, visit, nested));
|
|
23134
23590
|
}
|
|
23135
23591
|
function classScope(context, node, computedReferences) {
|
|
23136
23592
|
const methods = node.body.body.filter(
|
|
23137
|
-
(member) => member.type ===
|
|
23593
|
+
(member) => member.type === import_utils127.AST_NODE_TYPES.MethodDefinition
|
|
23138
23594
|
);
|
|
23139
23595
|
const counts = classMethodCounts(node.body, methods);
|
|
23140
23596
|
const implementations = methods.filter((method) => isFunction(method.value));
|
|
@@ -23145,7 +23601,7 @@ function classScope(context, node, computedReferences) {
|
|
|
23145
23601
|
return name !== null && key !== null && implementationCounts.get(key) === 1 ? [{ key, name, node: method }] : [];
|
|
23146
23602
|
});
|
|
23147
23603
|
const definitions = scopeDefinitions.filter(
|
|
23148
|
-
({ key, node: method }) => (method.accessibility === "private" || method.key.type ===
|
|
23604
|
+
({ key, node: method }) => (method.accessibility === "private" || method.key.type === import_utils127.AST_NODE_TYPES.PrivateIdentifier) && counts.get(key) === 1 && method.decorators.length === 0 && !method.computed && method.kind === "method"
|
|
23149
23605
|
);
|
|
23150
23606
|
if (definitions.length === 0) return;
|
|
23151
23607
|
const methodKeys = new Set(scopeDefinitions.map((definition) => definition.key));
|
|
@@ -23161,11 +23617,11 @@ function classScope(context, node, computedReferences) {
|
|
|
23161
23617
|
};
|
|
23162
23618
|
function pinDestructuredMembers(binding, domain) {
|
|
23163
23619
|
for (const property of binding.properties) {
|
|
23164
|
-
if (property.type ===
|
|
23620
|
+
if (property.type === import_utils127.AST_NODE_TYPES.RestElement || property.computed) {
|
|
23165
23621
|
pinNames(null, domain);
|
|
23166
|
-
} else if (property.key.type ===
|
|
23622
|
+
} else if (property.key.type === import_utils127.AST_NODE_TYPES.Identifier) {
|
|
23167
23623
|
pinNames(property.key.name, domain);
|
|
23168
|
-
} else if (property.key.type ===
|
|
23624
|
+
} else if (property.key.type === import_utils127.AST_NODE_TYPES.Literal && typeof property.key.value === "string") {
|
|
23169
23625
|
pinNames(property.key.value, domain);
|
|
23170
23626
|
}
|
|
23171
23627
|
}
|
|
@@ -23187,15 +23643,15 @@ function classScope(context, node, computedReferences) {
|
|
|
23187
23643
|
}
|
|
23188
23644
|
}
|
|
23189
23645
|
const collectAlias = (current, nestedFunction) => {
|
|
23190
|
-
if (nestedFunction || current.type !==
|
|
23646
|
+
if (nestedFunction || current.type !== import_utils127.AST_NODE_TYPES.VariableDeclarator || current.init === null) return;
|
|
23191
23647
|
const domain = receiverDomain(context, current.init, receivers, method.static);
|
|
23192
23648
|
if (domain === null || domain === "unrelated") return;
|
|
23193
|
-
if (current.id.type ===
|
|
23649
|
+
if (current.id.type === import_utils127.AST_NODE_TYPES.ObjectPattern) {
|
|
23194
23650
|
pinDestructuredMembers(current.id, domain);
|
|
23195
23651
|
return;
|
|
23196
23652
|
}
|
|
23197
|
-
if (current.id.type !==
|
|
23198
|
-
if (current.parent.type !==
|
|
23653
|
+
if (current.id.type !== import_utils127.AST_NODE_TYPES.Identifier) return;
|
|
23654
|
+
if (current.parent.type !== import_utils127.AST_NODE_TYPES.VariableDeclaration || current.parent.kind !== "const") {
|
|
23199
23655
|
pinNames(null, domain);
|
|
23200
23656
|
return;
|
|
23201
23657
|
}
|
|
@@ -23204,7 +23660,7 @@ function classScope(context, node, computedReferences) {
|
|
|
23204
23660
|
const local = variable.references.every((reference) => {
|
|
23205
23661
|
if (!reference.isRead()) return true;
|
|
23206
23662
|
const expression = wrappedExpression(reference.identifier);
|
|
23207
|
-
return enclosingFunction5(context, reference.identifier) === methodFunction && expression.parent?.type ===
|
|
23663
|
+
return enclosingFunction5(context, reference.identifier) === methodFunction && expression.parent?.type === import_utils127.AST_NODE_TYPES.MemberExpression && expression.parent.object === expression;
|
|
23208
23664
|
});
|
|
23209
23665
|
if (local) receivers.set(variable, domain);
|
|
23210
23666
|
else pinNames(null, domain);
|
|
@@ -23216,7 +23672,7 @@ function classScope(context, node, computedReferences) {
|
|
|
23216
23672
|
const domain2 = receiverDomain(context, destructuring.value, receivers, method.static);
|
|
23217
23673
|
if (domain2 !== "unrelated") pinDestructuredMembers(destructuring.binding, domain2);
|
|
23218
23674
|
}
|
|
23219
|
-
if (current.type !==
|
|
23675
|
+
if (current.type !== import_utils127.AST_NODE_TYPES.MemberExpression) return;
|
|
23220
23676
|
const domain = receiverDomain(context, current.object, receivers, method.static);
|
|
23221
23677
|
const targetName = referencedPropertyName(current);
|
|
23222
23678
|
if (domain === "unrelated") return;
|
|
@@ -23250,9 +23706,9 @@ function classScope(context, node, computedReferences) {
|
|
|
23250
23706
|
}
|
|
23251
23707
|
for (const method of methods) collectMethodCalls(method);
|
|
23252
23708
|
for (const member of node.body.body) {
|
|
23253
|
-
if (member.type ===
|
|
23709
|
+
if (member.type === import_utils127.AST_NODE_TYPES.MethodDefinition || member.type === import_utils127.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
23254
23710
|
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
23255
|
-
if (current.type !==
|
|
23711
|
+
if (current.type !== import_utils127.AST_NODE_TYPES.MemberExpression) return;
|
|
23256
23712
|
if (externalReceiverDomain(context, current.object, classReceivers) === "unrelated") return;
|
|
23257
23713
|
pinNames(referencedPropertyName(current));
|
|
23258
23714
|
});
|
|
@@ -23284,32 +23740,32 @@ function classScope(context, node, computedReferences) {
|
|
|
23284
23740
|
function classReceiverBindings(context, node) {
|
|
23285
23741
|
const classReceivers = /* @__PURE__ */ new Map();
|
|
23286
23742
|
if (node.id !== null) {
|
|
23287
|
-
const internal =
|
|
23743
|
+
const internal = import_utils127.ASTUtils.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
23288
23744
|
if (internal !== null && stableVariable(internal)) classReceivers.set(internal, true);
|
|
23289
23745
|
}
|
|
23290
|
-
if (node.type ===
|
|
23291
|
-
const outer =
|
|
23746
|
+
if (node.type === import_utils127.AST_NODE_TYPES.ClassExpression && node.parent.type === import_utils127.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils127.AST_NODE_TYPES.Identifier && node.parent.parent.type === import_utils127.AST_NODE_TYPES.VariableDeclaration && node.parent.parent.kind === "const") {
|
|
23747
|
+
const outer = import_utils127.ASTUtils.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
23292
23748
|
if (outer !== null && stableVariable(outer)) classReceivers.set(outer, true);
|
|
23293
23749
|
}
|
|
23294
23750
|
return classReceivers;
|
|
23295
23751
|
}
|
|
23296
23752
|
function receiverDestructuring(node) {
|
|
23297
|
-
if (node.type ===
|
|
23753
|
+
if (node.type === import_utils127.AST_NODE_TYPES.VariableDeclarator && node.id.type === import_utils127.AST_NODE_TYPES.ObjectPattern && node.init !== null) {
|
|
23298
23754
|
return { binding: node.id, value: node.init };
|
|
23299
23755
|
}
|
|
23300
|
-
if ((node.type ===
|
|
23756
|
+
if ((node.type === import_utils127.AST_NODE_TYPES.AssignmentPattern || node.type === import_utils127.AST_NODE_TYPES.AssignmentExpression) && node.left.type === import_utils127.AST_NODE_TYPES.ObjectPattern) {
|
|
23301
23757
|
return { binding: node.left, value: node.right };
|
|
23302
23758
|
}
|
|
23303
23759
|
return null;
|
|
23304
23760
|
}
|
|
23305
23761
|
function isClassRuntimeBarrier(member) {
|
|
23306
23762
|
switch (member.type) {
|
|
23307
|
-
case
|
|
23763
|
+
case import_utils127.AST_NODE_TYPES.StaticBlock:
|
|
23308
23764
|
return true;
|
|
23309
|
-
case
|
|
23310
|
-
case
|
|
23765
|
+
case import_utils127.AST_NODE_TYPES.PropertyDefinition:
|
|
23766
|
+
case import_utils127.AST_NODE_TYPES.AccessorProperty:
|
|
23311
23767
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
23312
|
-
case
|
|
23768
|
+
case import_utils127.AST_NODE_TYPES.MethodDefinition:
|
|
23313
23769
|
return member.computed || member.decorators.length > 0;
|
|
23314
23770
|
default:
|
|
23315
23771
|
return false;
|
|
@@ -23339,14 +23795,14 @@ var stepdown_default = createRule({
|
|
|
23339
23795
|
classes.push(node);
|
|
23340
23796
|
},
|
|
23341
23797
|
"FunctionDeclaration, FunctionExpression, ArrowFunctionExpression": (node) => {
|
|
23342
|
-
if (isFunction(node) && node.body?.type ===
|
|
23798
|
+
if (isFunction(node) && node.body?.type === import_utils127.AST_NODE_TYPES.BlockStatement) functionBodies.push(node.body);
|
|
23343
23799
|
},
|
|
23344
23800
|
"Program:exit": (program) => {
|
|
23345
23801
|
declarationScope(context, program);
|
|
23346
23802
|
for (const body2 of functionBodies) declarationScope(context, body2);
|
|
23347
23803
|
const computedReferences = [];
|
|
23348
23804
|
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
23349
|
-
if (node.type ===
|
|
23805
|
+
if (node.type === import_utils127.AST_NODE_TYPES.MemberExpression && node.computed) computedReferences.push(node);
|
|
23350
23806
|
});
|
|
23351
23807
|
for (const node of classes) classScope(context, node, computedReferences);
|
|
23352
23808
|
}
|
|
@@ -23363,8 +23819,8 @@ function classMethodCounts(body2, methods) {
|
|
|
23363
23819
|
}
|
|
23364
23820
|
}
|
|
23365
23821
|
for (const member of body2.body) {
|
|
23366
|
-
if (member.type !==
|
|
23367
|
-
const name = !member.computed && member.key.type ===
|
|
23822
|
+
if (member.type !== import_utils127.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
23823
|
+
const name = !member.computed && member.key.type === import_utils127.AST_NODE_TYPES.Identifier ? member.key.name : null;
|
|
23368
23824
|
if (name !== null) {
|
|
23369
23825
|
const key = methodKey(name, member.static);
|
|
23370
23826
|
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
@@ -23374,7 +23830,7 @@ function classMethodCounts(body2, methods) {
|
|
|
23374
23830
|
}
|
|
23375
23831
|
|
|
23376
23832
|
// src/rules/source-coupled-test.ts
|
|
23377
|
-
var
|
|
23833
|
+
var import_utils128 = require("@typescript-eslint/utils");
|
|
23378
23834
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc?|toml|py|[cm]?[jt]s)$/iu;
|
|
23379
23835
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
23380
23836
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -23448,16 +23904,16 @@ var SOURCE_COUPLED_TEST_DOCUMENTATION = {
|
|
|
23448
23904
|
function unwrap6(node) {
|
|
23449
23905
|
for (; ; ) {
|
|
23450
23906
|
node = unwrapExpression(node);
|
|
23451
|
-
if (node.type ===
|
|
23452
|
-
else if (node.type ===
|
|
23907
|
+
if (node.type === import_utils128.AST_NODE_TYPES.AwaitExpression) node = node.argument;
|
|
23908
|
+
else if (node.type === import_utils128.AST_NODE_TYPES.ChainExpression) node = node.expression;
|
|
23453
23909
|
else return node;
|
|
23454
23910
|
}
|
|
23455
23911
|
}
|
|
23456
23912
|
function stringValue(node) {
|
|
23457
23913
|
const current = unwrap6(node);
|
|
23458
|
-
if (current.type ===
|
|
23459
|
-
if (current.type ===
|
|
23460
|
-
if (current.type ===
|
|
23914
|
+
if (current.type === import_utils128.AST_NODE_TYPES.Literal && typeof current.value === "string") return current.value;
|
|
23915
|
+
if (current.type === import_utils128.AST_NODE_TYPES.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
23916
|
+
if (current.type === import_utils128.AST_NODE_TYPES.BinaryExpression && current.operator === "+") {
|
|
23461
23917
|
const left = stringValue(current.left);
|
|
23462
23918
|
const right = stringValue(current.right);
|
|
23463
23919
|
return left === null || right === null ? null : left + right;
|
|
@@ -23469,7 +23925,7 @@ function importSource(node) {
|
|
|
23469
23925
|
}
|
|
23470
23926
|
function requireSource(node) {
|
|
23471
23927
|
const current = unwrap6(node);
|
|
23472
|
-
if (current.type !==
|
|
23928
|
+
if (current.type !== import_utils128.AST_NODE_TYPES.CallExpression || current.callee.type !== import_utils128.AST_NODE_TYPES.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === import_utils128.AST_NODE_TYPES.SpreadElement) return null;
|
|
23473
23929
|
return stringValue(current.arguments[0]);
|
|
23474
23930
|
}
|
|
23475
23931
|
function newScope() {
|
|
@@ -23491,7 +23947,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23491
23947
|
const scopes = [newScope()];
|
|
23492
23948
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
23493
23949
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
23494
|
-
const bindingOf = (node) =>
|
|
23950
|
+
const bindingOf = (node) => import_utils128.ASTUtils.findVariable(context.sourceCode.getScope(node), node.name);
|
|
23495
23951
|
const assertionKind = (node) => {
|
|
23496
23952
|
const binding = bindingOf(node);
|
|
23497
23953
|
if (binding === null || binding.defs.length === 0) {
|
|
@@ -23525,75 +23981,75 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23525
23981
|
const current = unwrap6(node);
|
|
23526
23982
|
const value = stringValue(current);
|
|
23527
23983
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
23528
|
-
if (current.type ===
|
|
23529
|
-
if (current.type ===
|
|
23984
|
+
if (current.type === import_utils128.AST_NODE_TYPES.Identifier) return visible("paths", current);
|
|
23985
|
+
if (current.type === import_utils128.AST_NODE_TYPES.CallExpression || current.type === import_utils128.AST_NODE_TYPES.NewExpression) {
|
|
23530
23986
|
const callee = unwrapExpression(current.callee);
|
|
23531
23987
|
const first = current.arguments[0];
|
|
23532
|
-
if (first === void 0 || first.type ===
|
|
23533
|
-
if (current.type ===
|
|
23534
|
-
if (callee.type ===
|
|
23988
|
+
if (first === void 0 || first.type === import_utils128.AST_NODE_TYPES.SpreadElement) return false;
|
|
23989
|
+
if (current.type === import_utils128.AST_NODE_TYPES.NewExpression && callee.type === import_utils128.AST_NODE_TYPES.Identifier && callee.name === "URL" && (bindingOf(callee)?.defs.length ?? 0) === 0) return sourcePath(first);
|
|
23990
|
+
if (callee.type === import_utils128.AST_NODE_TYPES.Identifier && bindingOf(callee)?.defs.some((definition) => definition.node.type === import_utils128.AST_NODE_TYPES.ImportSpecifier && definition.node.imported.type === import_utils128.AST_NODE_TYPES.Identifier && definition.node.imported.name === "fileURLToPath" && definition.node.parent.type === import_utils128.AST_NODE_TYPES.ImportDeclaration && ["node:url", "url"].includes(String(definition.node.parent.source.value)))) return sourcePath(first);
|
|
23535
23991
|
}
|
|
23536
23992
|
return false;
|
|
23537
23993
|
};
|
|
23538
23994
|
const rawRead = (node) => {
|
|
23539
23995
|
const current = unwrap6(node);
|
|
23540
|
-
if (current.type !==
|
|
23996
|
+
if (current.type !== import_utils128.AST_NODE_TYPES.CallExpression || current.arguments.length === 0) return false;
|
|
23541
23997
|
const callee = unwrap6(current.callee);
|
|
23542
|
-
const calleeReceiver = callee.type ===
|
|
23543
|
-
if (callee.type ===
|
|
23998
|
+
const calleeReceiver = callee.type === import_utils128.AST_NODE_TYPES.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
23999
|
+
if (callee.type === import_utils128.AST_NODE_TYPES.Identifier) {
|
|
23544
24000
|
return visible("fsReaders", callee) && sourcePath(current.arguments[0]);
|
|
23545
24001
|
}
|
|
23546
|
-
if (callee.type !==
|
|
23547
|
-
const name2 =
|
|
24002
|
+
if (callee.type !== import_utils128.AST_NODE_TYPES.MemberExpression) return false;
|
|
24003
|
+
const name2 = import_utils128.ASTUtils.getPropertyName(callee);
|
|
23548
24004
|
const object = unwrap6(calleeReceiver);
|
|
23549
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
24005
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === import_utils128.AST_NODE_TYPES.Identifier && visible("fsObjects", object) && sourcePath(current.arguments[0]);
|
|
23550
24006
|
};
|
|
23551
24007
|
const rawOrigins = (node) => {
|
|
23552
24008
|
const current = unwrap6(node);
|
|
23553
|
-
if (current.type ===
|
|
24009
|
+
if (current.type === import_utils128.AST_NODE_TYPES.Identifier) return visibleRawOrigins(current);
|
|
23554
24010
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
23555
|
-
if (current.type ===
|
|
23556
|
-
if (current.type ===
|
|
23557
|
-
if (current.type !==
|
|
24011
|
+
if (current.type === import_utils128.AST_NODE_TYPES.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
24012
|
+
if (current.type === import_utils128.AST_NODE_TYPES.MemberExpression && import_utils128.ASTUtils.getPropertyName(current) === "length") return rawOrigins(current.object);
|
|
24013
|
+
if (current.type !== import_utils128.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
23558
24014
|
const callee = unwrap6(current.callee);
|
|
23559
|
-
const calleeReceiver = callee.type ===
|
|
23560
|
-
if (callee.type !==
|
|
23561
|
-
const name2 =
|
|
24015
|
+
const calleeReceiver = callee.type === import_utils128.AST_NODE_TYPES.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24016
|
+
if (callee.type !== import_utils128.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
24017
|
+
const name2 = import_utils128.ASTUtils.getPropertyName(callee);
|
|
23562
24018
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(calleeReceiver) : /* @__PURE__ */ new Set();
|
|
23563
24019
|
};
|
|
23564
24020
|
const evidenceOrigins = (node) => {
|
|
23565
24021
|
const current = unwrap6(node);
|
|
23566
24022
|
const direct = rawOrigins(current);
|
|
23567
24023
|
if (direct.size > 0) return direct;
|
|
23568
|
-
if (current.type ===
|
|
23569
|
-
if (current.type ===
|
|
23570
|
-
if (current.type !==
|
|
24024
|
+
if (current.type === import_utils128.AST_NODE_TYPES.BinaryExpression || current.type === import_utils128.AST_NODE_TYPES.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
24025
|
+
if (current.type === import_utils128.AST_NODE_TYPES.UnaryExpression) return evidenceOrigins(current.argument);
|
|
24026
|
+
if (current.type !== import_utils128.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
23571
24027
|
const callee = unwrap6(current.callee);
|
|
23572
|
-
const calleeReceiver = callee.type ===
|
|
23573
|
-
if (callee.type !==
|
|
23574
|
-
const name2 =
|
|
24028
|
+
const calleeReceiver = callee.type === import_utils128.AST_NODE_TYPES.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24029
|
+
if (callee.type !== import_utils128.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
24030
|
+
const name2 = import_utils128.ASTUtils.getPropertyName(callee);
|
|
23575
24031
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(calleeReceiver);
|
|
23576
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
24032
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === import_utils128.AST_NODE_TYPES.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
23577
24033
|
return /* @__PURE__ */ new Set();
|
|
23578
24034
|
};
|
|
23579
24035
|
const rawAssertionOrigins = (node) => {
|
|
23580
24036
|
const callee = unwrap6(node.callee);
|
|
23581
|
-
const calleeReceiver = callee.type ===
|
|
23582
|
-
if (callee.type ===
|
|
23583
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
24037
|
+
const calleeReceiver = callee.type === import_utils128.AST_NODE_TYPES.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24038
|
+
if (callee.type === import_utils128.AST_NODE_TYPES.Identifier && assertionKind(callee) === "assert") {
|
|
24039
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils128.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
23584
24040
|
}
|
|
23585
|
-
if (callee.type !==
|
|
23586
|
-
const matcher =
|
|
24041
|
+
if (callee.type !== import_utils128.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
24042
|
+
const matcher = import_utils128.ASTUtils.getPropertyName(callee);
|
|
23587
24043
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
23588
24044
|
let receiver = unwrap6(calleeReceiver);
|
|
23589
|
-
while (receiver.type ===
|
|
23590
|
-
const expectCallee = receiver.type ===
|
|
23591
|
-
if (receiver.type ===
|
|
24045
|
+
while (receiver.type === import_utils128.AST_NODE_TYPES.MemberExpression && EXPECT_MODIFIERS2.has(import_utils128.ASTUtils.getPropertyName(receiver) ?? "")) receiver = unwrap6(receiver.object);
|
|
24046
|
+
const expectCallee = receiver.type === import_utils128.AST_NODE_TYPES.CallExpression ? unwrapExpression(receiver.callee) : null;
|
|
24047
|
+
if (receiver.type === import_utils128.AST_NODE_TYPES.CallExpression && expectCallee?.type === import_utils128.AST_NODE_TYPES.Identifier && assertionKind(expectCallee) === "expect") {
|
|
23592
24048
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
23593
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
24049
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === import_utils128.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
23594
24050
|
}
|
|
23595
|
-
if (receiver.type !==
|
|
23596
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
24051
|
+
if (receiver.type !== import_utils128.AST_NODE_TYPES.Identifier || assertionKind(receiver) !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
24052
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils128.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
23597
24053
|
};
|
|
23598
24054
|
const declare = (node, state) => {
|
|
23599
24055
|
const name2 = bindingOf(node);
|
|
@@ -23615,7 +24071,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23615
24071
|
};
|
|
23616
24072
|
const sourceCollection = (node) => {
|
|
23617
24073
|
const current = unwrap6(node);
|
|
23618
|
-
return current.type ===
|
|
24074
|
+
return current.type === import_utils128.AST_NODE_TYPES.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== import_utils128.AST_NODE_TYPES.SpreadElement && sourcePath(element));
|
|
23619
24075
|
};
|
|
23620
24076
|
const enterFunction = () => {
|
|
23621
24077
|
scopes.push(newScope());
|
|
@@ -23625,8 +24081,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23625
24081
|
};
|
|
23626
24082
|
function declareFsReaders(pattern) {
|
|
23627
24083
|
for (const property of pattern.properties) {
|
|
23628
|
-
if (property.type !==
|
|
23629
|
-
const key = property.key.type ===
|
|
24084
|
+
if (property.type !== import_utils128.AST_NODE_TYPES.Property || property.value.type !== import_utils128.AST_NODE_TYPES.Identifier) continue;
|
|
24085
|
+
const key = property.key.type === import_utils128.AST_NODE_TYPES.Identifier ? property.key.name : property.key.type === import_utils128.AST_NODE_TYPES.Literal ? String(property.key.value) : "";
|
|
23630
24086
|
if (FS_READERS.has(key)) declare(property.value, { fsReader: true });
|
|
23631
24087
|
}
|
|
23632
24088
|
}
|
|
@@ -23635,8 +24091,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23635
24091
|
const source = importSource(node);
|
|
23636
24092
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
23637
24093
|
for (const specifier of node.specifiers) {
|
|
23638
|
-
if (specifier.type ===
|
|
23639
|
-
const imported = specifier.imported.type ===
|
|
24094
|
+
if (specifier.type === import_utils128.AST_NODE_TYPES.ImportSpecifier) {
|
|
24095
|
+
const imported = specifier.imported.type === import_utils128.AST_NODE_TYPES.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
23640
24096
|
if (FS_READERS.has(imported)) declare(specifier.local, { fsReader: true });
|
|
23641
24097
|
} else {
|
|
23642
24098
|
declare(specifier.local, { fsObject: true });
|
|
@@ -23649,26 +24105,26 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23649
24105
|
if (node.init === null) return;
|
|
23650
24106
|
const required = requireSource(node.init);
|
|
23651
24107
|
const initializer = unwrap6(node.init);
|
|
23652
|
-
if (required !== null && initializer.type ===
|
|
23653
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
24108
|
+
if (required !== null && initializer.type === import_utils128.AST_NODE_TYPES.CallExpression && initializer.callee.type === import_utils128.AST_NODE_TYPES.Identifier && (bindingOf(initializer.callee)?.defs.length ?? 0) > 0) return;
|
|
24109
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === import_utils128.AST_NODE_TYPES.Identifier) {
|
|
23654
24110
|
declare(node.id, { fsObject: true });
|
|
23655
24111
|
return;
|
|
23656
24112
|
}
|
|
23657
|
-
if (node.id.type ===
|
|
24113
|
+
if (node.id.type === import_utils128.AST_NODE_TYPES.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
23658
24114
|
declareFsReaders(node.id);
|
|
23659
24115
|
return;
|
|
23660
24116
|
}
|
|
23661
|
-
if (node.id.type !==
|
|
24117
|
+
if (node.id.type !== import_utils128.AST_NODE_TYPES.Identifier) return;
|
|
23662
24118
|
declare(node.id, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
23663
24119
|
},
|
|
23664
24120
|
AssignmentExpression(node) {
|
|
23665
|
-
if (node.left.type ===
|
|
24121
|
+
if (node.left.type === import_utils128.AST_NODE_TYPES.Identifier) declare(node.left, {});
|
|
23666
24122
|
},
|
|
23667
24123
|
ForOfStatement(node) {
|
|
23668
24124
|
const right = unwrap6(node.right);
|
|
23669
|
-
const collection = right.type ===
|
|
23670
|
-
const left = node.left.type ===
|
|
23671
|
-
if (collection && left?.type ===
|
|
24125
|
+
const collection = right.type === import_utils128.AST_NODE_TYPES.Identifier && visible("collections", right);
|
|
24126
|
+
const left = node.left.type === import_utils128.AST_NODE_TYPES.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
24127
|
+
if (collection && left?.type === import_utils128.AST_NODE_TYPES.Identifier) declare(left, { path: true });
|
|
23672
24128
|
},
|
|
23673
24129
|
CallExpression(node) {
|
|
23674
24130
|
const origins = rawAssertionOrigins(node);
|
|
@@ -23686,22 +24142,22 @@ var source_coupled_test_default = createSourceCoupledRule(
|
|
|
23686
24142
|
GENERAL_SOURCE_SUFFIX_RE
|
|
23687
24143
|
);
|
|
23688
24144
|
function importedAssertionKind(specifier) {
|
|
23689
|
-
if (specifier.type !==
|
|
24145
|
+
if (specifier.type !== import_utils128.AST_NODE_TYPES.ImportSpecifier && specifier.type !== import_utils128.AST_NODE_TYPES.ImportDefaultSpecifier && specifier.type !== import_utils128.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.parent.type !== import_utils128.AST_NODE_TYPES.ImportDeclaration) return null;
|
|
23690
24146
|
const source = importSource(specifier.parent);
|
|
23691
24147
|
if (source !== null && ASSERT_MODULES.has(source)) {
|
|
23692
|
-
if (specifier.type !==
|
|
23693
|
-
const imported2 = specifier.imported.type ===
|
|
24148
|
+
if (specifier.type !== import_utils128.AST_NODE_TYPES.ImportSpecifier) return "assert";
|
|
24149
|
+
const imported2 = specifier.imported.type === import_utils128.AST_NODE_TYPES.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
23694
24150
|
if (imported2 === "strict" || ASSERT_MATCHERS.has(imported2)) return "assert";
|
|
23695
24151
|
return null;
|
|
23696
24152
|
}
|
|
23697
|
-
if (source === null || !EXPECT_MODULES.has(source) || specifier.type !==
|
|
23698
|
-
const imported = specifier.imported.type ===
|
|
24153
|
+
if (source === null || !EXPECT_MODULES.has(source) || specifier.type !== import_utils128.AST_NODE_TYPES.ImportSpecifier) return null;
|
|
24154
|
+
const imported = specifier.imported.type === import_utils128.AST_NODE_TYPES.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
23699
24155
|
if (imported === "assert" || imported === "expect") return imported;
|
|
23700
24156
|
return null;
|
|
23701
24157
|
}
|
|
23702
24158
|
|
|
23703
24159
|
// src/rules/sole-export-matches-filename.ts
|
|
23704
|
-
var
|
|
24160
|
+
var import_utils129 = require("@typescript-eslint/utils");
|
|
23705
24161
|
|
|
23706
24162
|
// src/rules/_is-framework-entrypoint.ts
|
|
23707
24163
|
var import_node_fs2 = require("fs");
|
|
@@ -23817,7 +24273,7 @@ var sole_export_matches_filename_default = createRule({
|
|
|
23817
24273
|
if (only === void 0) return;
|
|
23818
24274
|
if (isFrameworkEntrypoint(normalizedFilename, only.key)) return;
|
|
23819
24275
|
if (only.name === "onRouterTransitionStart" && /(?:^|\/)instrumentation-client\.[jt]s$/u.test(normalizedFilename)) return;
|
|
23820
|
-
if (only.name === "collections" && /(?:^|\/)src\/content\.config\.(?:ts|js|mjs)$/u.test(normalizedFilename) && program.body.some((statement) => statement.type ===
|
|
24276
|
+
if (only.name === "collections" && /(?:^|\/)src\/content\.config\.(?:ts|js|mjs)$/u.test(normalizedFilename) && program.body.some((statement) => statement.type === import_utils129.AST_NODE_TYPES.ImportDeclaration && statement.source.value === "astro:content")) return;
|
|
23821
24277
|
const exportedStem = kebabCase(only.name);
|
|
23822
24278
|
if (exportedStem === "") return;
|
|
23823
24279
|
const expected = `${fileStem.startsWith("_") ? "_" : ""}${exportedStem}`;
|
|
@@ -23867,7 +24323,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
23867
24323
|
);
|
|
23868
24324
|
|
|
23869
24325
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
23870
|
-
var
|
|
24326
|
+
var import_utils130 = require("@typescript-eslint/utils");
|
|
23871
24327
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
23872
24328
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
23873
24329
|
rationale: "A reusable Zod schema is a runtime type contract. PascalCase mirrors that role; SCREAMING_SNAKE_CASE should remain reserved for scalar values and lookup tables.",
|
|
@@ -23999,19 +24455,19 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
23999
24455
|
"superRefine",
|
|
24000
24456
|
"transform"
|
|
24001
24457
|
]);
|
|
24002
|
-
var terminalMethodName = (callee) =>
|
|
24458
|
+
var terminalMethodName = (callee) => import_utils130.ASTUtils.getPropertyName(callee) !== null ? import_utils130.ASTUtils.getPropertyName(callee) ?? "" : null;
|
|
24003
24459
|
var calleeChainRoot2 = (node) => {
|
|
24004
24460
|
let current = node;
|
|
24005
24461
|
for (; ; ) {
|
|
24006
24462
|
current = unwrapExpression(current);
|
|
24007
|
-
if (current.type ===
|
|
24463
|
+
if (current.type === import_utils130.AST_NODE_TYPES.Identifier) {
|
|
24008
24464
|
return current;
|
|
24009
24465
|
}
|
|
24010
|
-
if (current.type ===
|
|
24466
|
+
if (current.type === import_utils130.AST_NODE_TYPES.MemberExpression) {
|
|
24011
24467
|
current = current.object;
|
|
24012
24468
|
continue;
|
|
24013
24469
|
}
|
|
24014
|
-
if (current.type ===
|
|
24470
|
+
if (current.type === import_utils130.AST_NODE_TYPES.CallExpression) {
|
|
24015
24471
|
current = unwrapExpression(current.callee);
|
|
24016
24472
|
continue;
|
|
24017
24473
|
}
|
|
@@ -24023,13 +24479,13 @@ var chainMemberNames2 = (node) => {
|
|
|
24023
24479
|
let current = node;
|
|
24024
24480
|
for (; ; ) {
|
|
24025
24481
|
current = unwrapExpression(current);
|
|
24026
|
-
if (current.type ===
|
|
24027
|
-
if (
|
|
24028
|
-
names.push(
|
|
24482
|
+
if (current.type === import_utils130.AST_NODE_TYPES.MemberExpression) {
|
|
24483
|
+
if (import_utils130.ASTUtils.getPropertyName(current) === null) return [];
|
|
24484
|
+
names.push(import_utils130.ASTUtils.getPropertyName(current) ?? "");
|
|
24029
24485
|
current = current.object;
|
|
24030
24486
|
continue;
|
|
24031
24487
|
}
|
|
24032
|
-
if (current.type ===
|
|
24488
|
+
if (current.type === import_utils130.AST_NODE_TYPES.CallExpression) {
|
|
24033
24489
|
current = unwrapExpression(current.callee);
|
|
24034
24490
|
continue;
|
|
24035
24491
|
}
|
|
@@ -24040,9 +24496,9 @@ var chainMemberNames2 = (node) => {
|
|
|
24040
24496
|
};
|
|
24041
24497
|
var isModuleDeclarator = (node) => {
|
|
24042
24498
|
const declaration = node.parent;
|
|
24043
|
-
if (declaration.type !==
|
|
24499
|
+
if (declaration.type !== import_utils130.AST_NODE_TYPES.VariableDeclaration) return false;
|
|
24044
24500
|
const owner = declaration.parent;
|
|
24045
|
-
return owner.type ===
|
|
24501
|
+
return owner.type === import_utils130.AST_NODE_TYPES.Program || owner.type === import_utils130.AST_NODE_TYPES.ExportNamedDeclaration && owner.parent.type === import_utils130.AST_NODE_TYPES.Program;
|
|
24046
24502
|
};
|
|
24047
24503
|
var require_pascal_case_zod_schema_name_default = createRule({
|
|
24048
24504
|
name: "require-pascal-case-zod-schema-name",
|
|
@@ -24062,7 +24518,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24062
24518
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
24063
24519
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
24064
24520
|
function resolvedBinding(identifier) {
|
|
24065
|
-
return
|
|
24521
|
+
return import_utils130.ASTUtils.findVariable(
|
|
24066
24522
|
context.sourceCode.getScope(identifier),
|
|
24067
24523
|
identifier.name
|
|
24068
24524
|
);
|
|
@@ -24073,10 +24529,10 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24073
24529
|
}
|
|
24074
24530
|
function isConfirmedSchema(expression) {
|
|
24075
24531
|
const init = unwrapExpression(expression);
|
|
24076
|
-
if (init.type ===
|
|
24077
|
-
if (init.type !==
|
|
24532
|
+
if (init.type === import_utils130.AST_NODE_TYPES.Identifier) return isSchemaBinding(init);
|
|
24533
|
+
if (init.type !== import_utils130.AST_NODE_TYPES.CallExpression) return false;
|
|
24078
24534
|
const callee = unwrapExpression(init.callee);
|
|
24079
|
-
if (callee.type !==
|
|
24535
|
+
if (callee.type !== import_utils130.AST_NODE_TYPES.MemberExpression) {
|
|
24080
24536
|
return false;
|
|
24081
24537
|
}
|
|
24082
24538
|
const terminal = terminalMethodName(callee);
|
|
@@ -24106,7 +24562,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24106
24562
|
ImportDeclaration(node) {
|
|
24107
24563
|
if (!isZodModule(node.source.value)) return;
|
|
24108
24564
|
for (const specifier of node.specifiers) {
|
|
24109
|
-
if (specifier.type ===
|
|
24565
|
+
if (specifier.type === import_utils130.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils130.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils130.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils130.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
24110
24566
|
recordZodBinding(specifier.local);
|
|
24111
24567
|
}
|
|
24112
24568
|
}
|
|
@@ -24115,7 +24571,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24115
24571
|
if (!isModuleDeclarator(node)) return;
|
|
24116
24572
|
const init = node.init;
|
|
24117
24573
|
if (init === null || init === void 0) return;
|
|
24118
|
-
if (node.id.type !==
|
|
24574
|
+
if (node.id.type !== import_utils130.AST_NODE_TYPES.Identifier) return;
|
|
24119
24575
|
if (!isConfirmedSchema(init)) return;
|
|
24120
24576
|
const binding = resolvedBinding(node.id);
|
|
24121
24577
|
if (binding !== null) schemaBindings.add(binding);
|
|
@@ -24317,6 +24773,7 @@ var RULES = {
|
|
|
24317
24773
|
"prefer-whole-object-assertion": prefer_whole_object_assertion_default,
|
|
24318
24774
|
"repeated-static-call-cases": repeated_static_call_cases_default,
|
|
24319
24775
|
"prefer-zod-infer": prefer_zod_infer_default,
|
|
24776
|
+
"named-child-schema-type": named_child_schema_type_default,
|
|
24320
24777
|
"prefer-zod-parse-output-type": prefer_zod_parse_output_type_default,
|
|
24321
24778
|
"require-assert-never": require_assert_never_default,
|
|
24322
24779
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
@@ -24333,7 +24790,7 @@ var RULES = {
|
|
|
24333
24790
|
};
|
|
24334
24791
|
var meta = {
|
|
24335
24792
|
name: "@sarj/eslint-plugin",
|
|
24336
|
-
version:
|
|
24793
|
+
version: package_default.version
|
|
24337
24794
|
};
|
|
24338
24795
|
var APPLICATION_ONLY_RULES = [];
|
|
24339
24796
|
var LIBRARY_IMPORT_POLICY = ["error", {
|
|
@@ -24342,6 +24799,7 @@ var LIBRARY_IMPORT_POLICY = ["error", {
|
|
|
24342
24799
|
}];
|
|
24343
24800
|
var ADVISORY_RULES = [
|
|
24344
24801
|
"@sarj/excessive-commentary",
|
|
24802
|
+
"@sarj/named-child-schema-type",
|
|
24345
24803
|
"@sarj/no-bespoke-api-case-conversion",
|
|
24346
24804
|
"@sarj/no-duplicate-test-case",
|
|
24347
24805
|
"@sarj/no-json-stringify-object-equality",
|
|
@@ -24364,6 +24822,7 @@ var ADVISORY_RULES = [
|
|
|
24364
24822
|
"@sarj/require-sql-access-class"
|
|
24365
24823
|
];
|
|
24366
24824
|
var RECOMMENDED_RULES = {
|
|
24825
|
+
"@sarj/named-child-schema-type": "warn",
|
|
24367
24826
|
"@sarj/no-conditional-empty-object-spread": "error",
|
|
24368
24827
|
"@sarj/prefer-typed-reflection": "error",
|
|
24369
24828
|
"@sarj/no-broad-return-type": "error",
|
|
@@ -24481,6 +24940,7 @@ var RECOMMENDED_RULES = {
|
|
|
24481
24940
|
"@sarj/require-pascal-case-zod-schema-name": "error"
|
|
24482
24941
|
};
|
|
24483
24942
|
var STRICT_RULES = {
|
|
24943
|
+
"@sarj/named-child-schema-type": "warn",
|
|
24484
24944
|
"@sarj/no-conditional-empty-object-spread": "error",
|
|
24485
24945
|
"@sarj/prefer-typed-reflection": "error",
|
|
24486
24946
|
"@sarj/no-broad-return-type": "error",
|