@opsydyn/oxlint-effect 0.4.0 → 0.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/README.md +57 -0
- package/dist/index.d.mts +88 -8
- package/dist/index.mjs +1 -2334
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2335 +1,2 @@
|
|
|
1
|
-
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
2
|
-
//#region src/index.ts
|
|
3
|
-
function isIdentifier(node, name) {
|
|
4
|
-
return typeof node === "object" && node !== null && node.type === "Identifier" && typeof node.name === "string" && (name === void 0 || node.name === name);
|
|
5
|
-
}
|
|
6
|
-
function isMemberExpression(node, objectName, propertyName) {
|
|
7
|
-
if (typeof node !== "object" || node === null) return false;
|
|
8
|
-
const member = node;
|
|
9
|
-
return member.type === "MemberExpression" && member.computed !== true && isIdentifier(member.object, objectName) && isIdentifier(member.property, propertyName);
|
|
10
|
-
}
|
|
11
|
-
function isEffectMemberCall(node) {
|
|
12
|
-
if (typeof node !== "object" || node === null) return false;
|
|
13
|
-
const call = node;
|
|
14
|
-
return call.type === "CallExpression" && Array.isArray(call.arguments) && typeof call.callee === "object" && call.callee !== null && call.callee.type === "MemberExpression" && call.callee.computed !== true && isIdentifier(call.callee.object, "Effect") && isIdentifier(call.callee.property);
|
|
15
|
-
}
|
|
16
|
-
function firstArgument(node) {
|
|
17
|
-
return node.arguments[0];
|
|
18
|
-
}
|
|
19
|
-
function isEffectMemberCallNamed(node, propertyName) {
|
|
20
|
-
if (!isEffectMemberCall(node)) return false;
|
|
21
|
-
const callee = node.callee;
|
|
22
|
-
return isIdentifier(callee.property, propertyName);
|
|
23
|
-
}
|
|
24
|
-
function hasDeepNestedEffectFirstArgument(node) {
|
|
25
|
-
if (!isEffectMemberCall(node)) return false;
|
|
26
|
-
const inner = firstArgument(node);
|
|
27
|
-
if (!isEffectMemberCall(inner)) return false;
|
|
28
|
-
return isEffectMemberCall(firstArgument(inner));
|
|
29
|
-
}
|
|
30
|
-
function hasNestedEffectCallArgument(node) {
|
|
31
|
-
if (!isEffectMemberCall(node)) return false;
|
|
32
|
-
return node.arguments.slice(0, 2).some((argument) => isEffectMemberCall(argument));
|
|
33
|
-
}
|
|
34
|
-
function containsEffectMemberCallNamed(node, propertyName) {
|
|
35
|
-
if (isEffectMemberCallNamed(node, propertyName)) return true;
|
|
36
|
-
if (Array.isArray(node)) return node.some((child) => containsEffectMemberCallNamed(child, propertyName));
|
|
37
|
-
if (typeof node !== "object" || node === null) return false;
|
|
38
|
-
return Object.values(node).some((child) => containsEffectMemberCallNamed(child, propertyName));
|
|
39
|
-
}
|
|
40
|
-
function getFlatMapLadderMessage(node) {
|
|
41
|
-
if (isEffectMemberCallNamed(node, "flatMap") && containsEffectMemberCallNamed(node.arguments, "flatMap")) return "Rule: avoid nested Effect.flatMap. Why: it hides sequencing and pushes laddered control flow. Fix: build context once (Effect.all/Effect.map) and run a single flatMap.";
|
|
42
|
-
if (isEffectMemberCallNamed(node, "flatten") && containsEffectMemberCallNamed(firstArgument(node), "map")) return "Rule: avoid map+flatten ladders. Why: they hide sequencing. Fix: build context once (Effect.all/Effect.map) and run a single flatMap.";
|
|
43
|
-
}
|
|
44
|
-
const orElseSequencingCalls = [
|
|
45
|
-
"flatMap",
|
|
46
|
-
"zipRight",
|
|
47
|
-
"as",
|
|
48
|
-
"tap"
|
|
49
|
-
];
|
|
50
|
-
function hasOrElseSequencingFirstArgument(node) {
|
|
51
|
-
if (!isEffectMemberCallNamed(node, "orElse")) return false;
|
|
52
|
-
const first = firstArgument(node);
|
|
53
|
-
return orElseSequencingCalls.some((propertyName) => containsEffectMemberCallNamed(first, propertyName));
|
|
54
|
-
}
|
|
55
|
-
function isPipeCall(node) {
|
|
56
|
-
if (typeof node !== "object" || node === null) return false;
|
|
57
|
-
const call = node;
|
|
58
|
-
if (call.type !== "CallExpression") return false;
|
|
59
|
-
if (isIdentifier(call.callee, "pipe")) return true;
|
|
60
|
-
const callee = call.callee;
|
|
61
|
-
return typeof callee === "object" && callee !== null && callee.type === "MemberExpression" && callee.computed !== true && isIdentifier(callee.property, "pipe");
|
|
62
|
-
}
|
|
63
|
-
function containsPipeCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
64
|
-
if (isPipeCall(node)) return true;
|
|
65
|
-
if (Array.isArray(node)) return node.some((child) => containsPipeCall(child, seen));
|
|
66
|
-
if (typeof node !== "object" || node === null) return false;
|
|
67
|
-
if (seen.has(node)) return false;
|
|
68
|
-
seen.add(node);
|
|
69
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsPipeCall(child, seen));
|
|
70
|
-
}
|
|
71
|
-
function isArrowIifeCall(node) {
|
|
72
|
-
if (typeof node !== "object" || node === null) return false;
|
|
73
|
-
const call = node;
|
|
74
|
-
return call.type === "CallExpression" && Array.isArray(call.arguments) && typeof call.callee === "object" && call.callee !== null && call.callee.type === "ArrowFunctionExpression";
|
|
75
|
-
}
|
|
76
|
-
function isInlineFunctionIifeCall(node) {
|
|
77
|
-
if (typeof node !== "object" || node === null) return false;
|
|
78
|
-
const call = node;
|
|
79
|
-
return call.type === "CallExpression" && Array.isArray(call.arguments) && typeof call.callee === "object" && call.callee !== null && (call.callee.type === "ArrowFunctionExpression" || call.callee.type === "FunctionExpression");
|
|
80
|
-
}
|
|
81
|
-
function findArrowIifeCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
82
|
-
if (isArrowIifeCall(node)) return node;
|
|
83
|
-
if (Array.isArray(node)) {
|
|
84
|
-
for (const child of node) {
|
|
85
|
-
const match = findArrowIifeCall(child, seen);
|
|
86
|
-
if (match) return match;
|
|
87
|
-
}
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (typeof node !== "object" || node === null) return;
|
|
91
|
-
if (seen.has(node)) return;
|
|
92
|
-
seen.add(node);
|
|
93
|
-
for (const [key, child] of Object.entries(node)) {
|
|
94
|
-
if (key === "parent") continue;
|
|
95
|
-
const match = findArrowIifeCall(child, seen);
|
|
96
|
-
if (match) return match;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function findReturnStatements(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
100
|
-
if (Array.isArray(node)) return node.flatMap((child) => findReturnStatements(child, seen));
|
|
101
|
-
if (typeof node !== "object" || node === null) return [];
|
|
102
|
-
if (seen.has(node)) return [];
|
|
103
|
-
seen.add(node);
|
|
104
|
-
if (node.type === "ReturnStatement") return [node];
|
|
105
|
-
return Object.entries(node).flatMap(([key, child]) => key === "parent" ? [] : findReturnStatements(child, seen));
|
|
106
|
-
}
|
|
107
|
-
function isSchemaFilterCall(node) {
|
|
108
|
-
if (typeof node !== "object" || node === null) return false;
|
|
109
|
-
const call = node;
|
|
110
|
-
return call.type === "CallExpression" && (isMemberExpression(call.callee, "S", "filter") || isMemberExpression(call.callee, "Schema", "filter"));
|
|
111
|
-
}
|
|
112
|
-
function directArrowCallbackReturns(node) {
|
|
113
|
-
if (typeof node !== "object" || node === null) return [];
|
|
114
|
-
const call = node;
|
|
115
|
-
if (call.type !== "CallExpression" || !Array.isArray(call.arguments) || isSchemaFilterCall(call)) return [];
|
|
116
|
-
return call.arguments.flatMap((argument) => {
|
|
117
|
-
if (typeof argument !== "object" || argument === null || argument.type !== "ArrowFunctionExpression") return [];
|
|
118
|
-
const body = argument.body;
|
|
119
|
-
if (typeof body !== "object" || body === null || body.type !== "BlockStatement") return [];
|
|
120
|
-
return findReturnStatements(body);
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function directFunctionCallbackReturns(node) {
|
|
124
|
-
if (typeof node !== "object" || node === null) return [];
|
|
125
|
-
const call = node;
|
|
126
|
-
if (call.type !== "CallExpression" || !Array.isArray(call.arguments)) return [];
|
|
127
|
-
return call.arguments.flatMap((argument) => {
|
|
128
|
-
if (typeof argument !== "object" || argument === null || argument.type !== "FunctionExpression" || argument.generator === true) return [];
|
|
129
|
-
return findReturnStatements(argument.body);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function isGeneratorFunctionExpression(node) {
|
|
133
|
-
return typeof node === "object" && node !== null && node.type === "FunctionExpression" && node.generator === true;
|
|
134
|
-
}
|
|
135
|
-
function getEffectGeneratorArgument(node, propertyName) {
|
|
136
|
-
if (!isEffectMemberCallNamed(node, propertyName)) return;
|
|
137
|
-
const fn = firstArgument(node);
|
|
138
|
-
return isGeneratorFunctionExpression(fn) ? fn : void 0;
|
|
139
|
-
}
|
|
140
|
-
function isEffectGeneratorCall(node, propertyName) {
|
|
141
|
-
return getEffectGeneratorArgument(node, propertyName) !== void 0;
|
|
142
|
-
}
|
|
143
|
-
function findYieldWithoutStar(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
144
|
-
if (Array.isArray(node)) {
|
|
145
|
-
for (const child of node) {
|
|
146
|
-
const match = findYieldWithoutStar(child, seen);
|
|
147
|
-
if (match) return match;
|
|
148
|
-
}
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (typeof node !== "object" || node === null) return;
|
|
152
|
-
if (seen.has(node)) return;
|
|
153
|
-
seen.add(node);
|
|
154
|
-
if (node.type === "YieldExpression" && node.delegate !== true) return node;
|
|
155
|
-
for (const [key, child] of Object.entries(node)) {
|
|
156
|
-
if (key === "parent") continue;
|
|
157
|
-
const match = findYieldWithoutStar(child, seen);
|
|
158
|
-
if (match) return match;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function findYieldWithoutStarInEffectGen(node) {
|
|
162
|
-
const generator = getEffectGeneratorArgument(node, "gen");
|
|
163
|
-
return generator ? findYieldWithoutStar(generator.body) : void 0;
|
|
164
|
-
}
|
|
165
|
-
function isAsyncFunctionCallback(node) {
|
|
166
|
-
return typeof node === "object" && node !== null && (node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression") && node.async === true;
|
|
167
|
-
}
|
|
168
|
-
const effectAsyncCallbackCombinators = /* @__PURE__ */ new Set([
|
|
169
|
-
"andThen",
|
|
170
|
-
"catchAll",
|
|
171
|
-
"catchTag",
|
|
172
|
-
"filterOrFail",
|
|
173
|
-
"flatMap",
|
|
174
|
-
"forEach",
|
|
175
|
-
"map",
|
|
176
|
-
"orElse",
|
|
177
|
-
"tap"
|
|
178
|
-
]);
|
|
179
|
-
function findAsyncEffectCombinatorCallback(node) {
|
|
180
|
-
if (!isEffectMemberCall(node)) return;
|
|
181
|
-
const property = node.callee.property;
|
|
182
|
-
if (!isIdentifier(property) || !effectAsyncCallbackCombinators.has(property.name)) return;
|
|
183
|
-
return node.arguments.find((argument) => isAsyncFunctionCallback(argument));
|
|
184
|
-
}
|
|
185
|
-
function findThrowStatement(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
186
|
-
if (Array.isArray(node)) {
|
|
187
|
-
for (const child of node) {
|
|
188
|
-
const match = findThrowStatement(child, seen);
|
|
189
|
-
if (match) return match;
|
|
190
|
-
}
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (typeof node !== "object" || node === null) return;
|
|
194
|
-
if (seen.has(node)) return;
|
|
195
|
-
seen.add(node);
|
|
196
|
-
if (node.type === "ThrowStatement") return node;
|
|
197
|
-
for (const [key, child] of Object.entries(node)) {
|
|
198
|
-
if (key === "parent") continue;
|
|
199
|
-
const match = findThrowStatement(child, seen);
|
|
200
|
-
if (match) return match;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function findThrowInEffectLogic(node) {
|
|
204
|
-
const generator = getEffectGeneratorArgument(node, "gen");
|
|
205
|
-
if (generator) return findThrowStatement(generator.body);
|
|
206
|
-
if (!isEffectMemberCall(node)) return;
|
|
207
|
-
const property = node.callee.property;
|
|
208
|
-
if (!isIdentifier(property) || !effectAsyncCallbackCombinators.has(property.name)) return;
|
|
209
|
-
for (const argument of node.arguments) {
|
|
210
|
-
const body = callbackBody(argument);
|
|
211
|
-
const match = body ? findThrowStatement(body) : void 0;
|
|
212
|
-
if (match) return match;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function findTryStatement(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
216
|
-
if (Array.isArray(node)) {
|
|
217
|
-
for (const child of node) {
|
|
218
|
-
const match = findTryStatement(child, seen);
|
|
219
|
-
if (match) return match;
|
|
220
|
-
}
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
if (typeof node !== "object" || node === null) return;
|
|
224
|
-
if (seen.has(node)) return;
|
|
225
|
-
seen.add(node);
|
|
226
|
-
if (node.type === "TryStatement") return node;
|
|
227
|
-
for (const [key, child] of Object.entries(node)) {
|
|
228
|
-
if (key === "parent") continue;
|
|
229
|
-
const match = findTryStatement(child, seen);
|
|
230
|
-
if (match) return match;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
function findTryCatchInEffectLogic(node) {
|
|
234
|
-
const generator = getEffectGeneratorArgument(node, "gen");
|
|
235
|
-
if (generator) return findTryStatement(generator.body);
|
|
236
|
-
if (!isEffectMemberCall(node)) return;
|
|
237
|
-
const property = node.callee.property;
|
|
238
|
-
if (!isIdentifier(property) || !effectAsyncCallbackCombinators.has(property.name)) return;
|
|
239
|
-
for (const argument of node.arguments) {
|
|
240
|
-
const body = callbackBody(argument);
|
|
241
|
-
const match = body ? findTryStatement(body) : void 0;
|
|
242
|
-
if (match) return match;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
function isPromiseStaticApiCall(node) {
|
|
246
|
-
return isMemberCall(node, "Promise", "all") || isMemberCall(node, "Promise", "allSettled") || isMemberCall(node, "Promise", "any") || isMemberCall(node, "Promise", "race") || isMemberCall(node, "Promise", "reject") || isMemberCall(node, "Promise", "resolve");
|
|
247
|
-
}
|
|
248
|
-
function isPromiseChainCall(node) {
|
|
249
|
-
if (typeof node !== "object" || node === null || node.type !== "CallExpression") return false;
|
|
250
|
-
const callee = node.callee;
|
|
251
|
-
return typeof callee === "object" && callee !== null && callee.type === "MemberExpression" && callee.computed !== true && (isIdentifier(callee.property, "then") || isIdentifier(callee.property, "catch") || isIdentifier(callee.property, "finally"));
|
|
252
|
-
}
|
|
253
|
-
function findPromiseApiCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
254
|
-
if (Array.isArray(node)) {
|
|
255
|
-
for (const child of node) {
|
|
256
|
-
const match = findPromiseApiCall(child, seen);
|
|
257
|
-
if (match) return match;
|
|
258
|
-
}
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
if (typeof node !== "object" || node === null) return;
|
|
262
|
-
if (seen.has(node)) return;
|
|
263
|
-
seen.add(node);
|
|
264
|
-
if (isPromiseStaticApiCall(node) || isPromiseChainCall(node)) return node;
|
|
265
|
-
for (const [key, child] of Object.entries(node)) {
|
|
266
|
-
if (key === "parent") continue;
|
|
267
|
-
const match = findPromiseApiCall(child, seen);
|
|
268
|
-
if (match) return match;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function findPromiseApiInEffectLogic(node) {
|
|
272
|
-
const generator = getEffectGeneratorArgument(node, "gen");
|
|
273
|
-
if (generator) return findPromiseApiCall(generator.body);
|
|
274
|
-
if (!isEffectMemberCall(node)) return;
|
|
275
|
-
const property = node.callee.property;
|
|
276
|
-
if (!isIdentifier(property) || !effectAsyncCallbackCombinators.has(property.name)) return;
|
|
277
|
-
for (const argument of node.arguments) {
|
|
278
|
-
const body = callbackBody(argument);
|
|
279
|
-
const match = body ? findPromiseApiCall(body) : void 0;
|
|
280
|
-
if (match) return match;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
const promiseConcurrencyMethods = /* @__PURE__ */ new Set([
|
|
284
|
-
"all",
|
|
285
|
-
"allSettled",
|
|
286
|
-
"any",
|
|
287
|
-
"race"
|
|
288
|
-
]);
|
|
289
|
-
function isPromiseConcurrencyCall(node) {
|
|
290
|
-
if (typeof node !== "object" || node === null || node.type !== "CallExpression") return false;
|
|
291
|
-
const callee = node.callee;
|
|
292
|
-
return typeof callee === "object" && callee !== null && callee.type === "MemberExpression" && callee.computed !== true && isIdentifier(callee.object, "Promise") && isIdentifier(callee.property) && promiseConcurrencyMethods.has(callee.property.name);
|
|
293
|
-
}
|
|
294
|
-
function findPromiseConcurrencyCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
295
|
-
if (Array.isArray(node)) {
|
|
296
|
-
for (const child of node) {
|
|
297
|
-
const match = findPromiseConcurrencyCall(child, seen);
|
|
298
|
-
if (match) return match;
|
|
299
|
-
}
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (typeof node !== "object" || node === null) return;
|
|
303
|
-
if (seen.has(node)) return;
|
|
304
|
-
seen.add(node);
|
|
305
|
-
if (isPromiseConcurrencyCall(node)) return node;
|
|
306
|
-
for (const [key, child] of Object.entries(node)) {
|
|
307
|
-
if (key === "parent") continue;
|
|
308
|
-
const match = findPromiseConcurrencyCall(child, seen);
|
|
309
|
-
if (match) return match;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
function findPromiseConcurrencyInEffectLogic(node) {
|
|
313
|
-
const generator = getEffectGeneratorArgument(node, "gen");
|
|
314
|
-
if (generator) return findPromiseConcurrencyCall(generator.body);
|
|
315
|
-
if (isEffectMemberCallNamed(node, "sync")) {
|
|
316
|
-
const body = callbackBody(firstArgument(node));
|
|
317
|
-
return body ? findPromiseConcurrencyCall(body) : void 0;
|
|
318
|
-
}
|
|
319
|
-
if (!isEffectMemberCall(node)) return;
|
|
320
|
-
const property = node.callee.property;
|
|
321
|
-
if (!isIdentifier(property) || !effectAsyncCallbackCombinators.has(property.name)) return;
|
|
322
|
-
for (const argument of node.arguments) {
|
|
323
|
-
const body = callbackBody(argument);
|
|
324
|
-
const match = body ? findPromiseConcurrencyCall(body) : void 0;
|
|
325
|
-
if (match) return match;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function callbackHasParameter(node) {
|
|
329
|
-
if (typeof node !== "object" || node === null) return false;
|
|
330
|
-
const callback = node;
|
|
331
|
-
return (callback.type === "ArrowFunctionExpression" || callback.type === "FunctionExpression") && Array.isArray(callback.params) && callback.params.length > 0;
|
|
332
|
-
}
|
|
333
|
-
function isCancellationAwareTryPromise(node) {
|
|
334
|
-
if (!isEffectMemberCallNamed(node, "tryPromise")) return false;
|
|
335
|
-
const argument = firstArgument(node);
|
|
336
|
-
if (callbackHasParameter(argument)) return true;
|
|
337
|
-
return callbackHasParameter(objectPropertyValue(argument, "try"));
|
|
338
|
-
}
|
|
339
|
-
function isNoninterruptiblePromiseEffect(node) {
|
|
340
|
-
if (isEffectMemberCallNamed(node, "promise")) return true;
|
|
341
|
-
return isEffectMemberCallNamed(node, "tryPromise") && !isCancellationAwareTryPromise(node);
|
|
342
|
-
}
|
|
343
|
-
function noninterruptiblePromiseTimeoutNode(node) {
|
|
344
|
-
if (!isEffectMemberCallNamed(node, "timeout")) return;
|
|
345
|
-
const effect = firstArgument(node);
|
|
346
|
-
return isNoninterruptiblePromiseEffect(effect) ? effect : void 0;
|
|
347
|
-
}
|
|
348
|
-
const blockingSyncObjectNames = /* @__PURE__ */ new Set([
|
|
349
|
-
"crypto",
|
|
350
|
-
"fs",
|
|
351
|
-
"zlib"
|
|
352
|
-
]);
|
|
353
|
-
function isBlockingSyncCall(node) {
|
|
354
|
-
if (typeof node !== "object" || node === null || node.type !== "CallExpression") return false;
|
|
355
|
-
const callee = node.callee;
|
|
356
|
-
if (isIdentifier(callee)) return callee.name.endsWith("Sync");
|
|
357
|
-
if (typeof callee !== "object" || callee === null || callee.type !== "MemberExpression" || callee.computed === true || !isIdentifier(callee.object) || !isIdentifier(callee.property)) return false;
|
|
358
|
-
const objectName = callee.object.name;
|
|
359
|
-
const propertyName = callee.property.name;
|
|
360
|
-
return blockingSyncObjectNames.has(objectName) && propertyName.endsWith("Sync");
|
|
361
|
-
}
|
|
362
|
-
function findBlockingSyncCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
363
|
-
if (Array.isArray(node)) {
|
|
364
|
-
for (const child of node) {
|
|
365
|
-
const match = findBlockingSyncCall(child, seen);
|
|
366
|
-
if (match) return match;
|
|
367
|
-
}
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (typeof node !== "object" || node === null) return;
|
|
371
|
-
if (seen.has(node)) return;
|
|
372
|
-
seen.add(node);
|
|
373
|
-
if (isBlockingSyncCall(node)) return node;
|
|
374
|
-
for (const [key, child] of Object.entries(node)) {
|
|
375
|
-
if (key === "parent") continue;
|
|
376
|
-
const match = findBlockingSyncCall(child, seen);
|
|
377
|
-
if (match) return match;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
function findBlockingSyncCallInEffectLogic(node) {
|
|
381
|
-
const generator = getEffectGeneratorArgument(node, "gen");
|
|
382
|
-
if (generator) return findBlockingSyncCall(generator.body);
|
|
383
|
-
if (isEffectMemberCallNamed(node, "sync")) {
|
|
384
|
-
const body = callbackBody(firstArgument(node));
|
|
385
|
-
return body ? findBlockingSyncCall(body) : void 0;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
const effectRunMethods = /* @__PURE__ */ new Set([
|
|
389
|
-
"runCallback",
|
|
390
|
-
"runFork",
|
|
391
|
-
"runPromise",
|
|
392
|
-
"runPromiseExit",
|
|
393
|
-
"runSync",
|
|
394
|
-
"runSyncExit"
|
|
395
|
-
]);
|
|
396
|
-
function isEffectRunCall(node) {
|
|
397
|
-
if (!isEffectMemberCall(node)) return false;
|
|
398
|
-
const property = node.callee.property;
|
|
399
|
-
return isIdentifier(property) && effectRunMethods.has(property.name);
|
|
400
|
-
}
|
|
401
|
-
function isEffectOrDieReference(node) {
|
|
402
|
-
return isMemberExpression(node, "Effect", "orDie") || isMemberExpression(node, "Effect", "orDieWith") || isEffectMemberCallNamed(node, "orDie") || isEffectMemberCallNamed(node, "orDieWith");
|
|
403
|
-
}
|
|
404
|
-
function findEffectOrDieOutsideBoundary(node) {
|
|
405
|
-
if (isEffectOrDieReference(node)) return node;
|
|
406
|
-
if (isPipeCall(node)) return pipeParts(node).find((part) => isEffectOrDieReference(part));
|
|
407
|
-
}
|
|
408
|
-
function isSwallowedCatchAllBody(node) {
|
|
409
|
-
return isEffectMemberCallNamed(node, "succeed") || isEffectMemberCallNamed(node, "asVoid") || isEffectMemberCallNamed(node, "ignore") || isEffectVoidMember(node);
|
|
410
|
-
}
|
|
411
|
-
function getSwallowedCatchAllHandler(node) {
|
|
412
|
-
if (!isEffectMemberCallNamed(node, "catchAll")) return;
|
|
413
|
-
const body = callbackBody(firstArgument(node));
|
|
414
|
-
return isSwallowedCatchAllBody(body) ? body : void 0;
|
|
415
|
-
}
|
|
416
|
-
function isEffectIgnoreReference(node) {
|
|
417
|
-
return isMemberExpression(node, "Effect", "ignore") || isEffectMemberCallNamed(node, "ignore");
|
|
418
|
-
}
|
|
419
|
-
function findEffectIgnore(node) {
|
|
420
|
-
if (isEffectIgnoreReference(node)) return node;
|
|
421
|
-
if (isPipeCall(node)) return pipeParts(node).find((part) => isEffectIgnoreReference(part));
|
|
422
|
-
}
|
|
423
|
-
function isConsoleCall(node) {
|
|
424
|
-
if (typeof node !== "object" || node === null) return false;
|
|
425
|
-
const call = node;
|
|
426
|
-
return call.type === "CallExpression" && typeof call.callee === "object" && call.callee !== null && call.callee.type === "MemberExpression" && call.callee.computed !== true && isIdentifier(call.callee.object, "console") && isIdentifier(call.callee.property);
|
|
427
|
-
}
|
|
428
|
-
function isIdentifierCall(node, name) {
|
|
429
|
-
if (typeof node !== "object" || node === null) return false;
|
|
430
|
-
const call = node;
|
|
431
|
-
return call.type === "CallExpression" && isIdentifier(call.callee, name);
|
|
432
|
-
}
|
|
433
|
-
function isMemberCall(node, objectName, propertyName) {
|
|
434
|
-
if (typeof node !== "object" || node === null) return false;
|
|
435
|
-
const call = node;
|
|
436
|
-
return call.type === "CallExpression" && typeof call.callee === "object" && call.callee !== null && call.callee.type === "MemberExpression" && call.callee.computed !== true && isIdentifier(call.callee.object, objectName) && isIdentifier(call.callee.property) && (propertyName === void 0 || isIdentifier(call.callee.property, propertyName));
|
|
437
|
-
}
|
|
438
|
-
function isEffectLogCall(node) {
|
|
439
|
-
if (typeof node !== "object" || node === null) return false;
|
|
440
|
-
const call = node;
|
|
441
|
-
if (call.type !== "CallExpression" || typeof call.callee !== "object" || call.callee === null || call.callee.type !== "MemberExpression" || call.callee.computed === true || !isIdentifier(call.callee.object, "Effect") || !isIdentifier(call.callee.property)) return false;
|
|
442
|
-
return call.callee.property.name.startsWith("log");
|
|
443
|
-
}
|
|
444
|
-
function containsConsoleCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
445
|
-
if (isConsoleCall(node)) return true;
|
|
446
|
-
if (Array.isArray(node)) return node.some((child) => containsConsoleCall(child, seen));
|
|
447
|
-
if (typeof node !== "object" || node === null) return false;
|
|
448
|
-
if (seen.has(node)) return false;
|
|
449
|
-
seen.add(node);
|
|
450
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsConsoleCall(child, seen));
|
|
451
|
-
}
|
|
452
|
-
function containsWrapperSideEffect(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
453
|
-
if (isIdentifierCall(node, "setState") || isMemberCall(node, "Atom", "set") || isIdentifierCall(node, "invalidate") || isEffectLogCall(node) || isConsoleCall(node)) return true;
|
|
454
|
-
if (Array.isArray(node)) return node.some((child) => containsWrapperSideEffect(child, seen));
|
|
455
|
-
if (typeof node !== "object" || node === null) return false;
|
|
456
|
-
if (seen.has(node)) return false;
|
|
457
|
-
seen.add(node);
|
|
458
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsWrapperSideEffect(child, seen));
|
|
459
|
-
}
|
|
460
|
-
function containsAllStepSideEffect(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
461
|
-
if (isMemberCall(node, "Ref", "set") || isMemberCall(node, "Atom", "set") || isMemberCall(node, "SubscriptionRef", "set") || isMemberCall(node, "Reactivity", "invalidate") || isMemberCall(node, "Fiber", "interrupt") || isEffectLogCall(node)) return true;
|
|
462
|
-
if (Array.isArray(node)) return node.some((child) => containsAllStepSideEffect(child, seen));
|
|
463
|
-
if (typeof node !== "object" || node === null) return false;
|
|
464
|
-
if (seen.has(node)) return false;
|
|
465
|
-
seen.add(node);
|
|
466
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsAllStepSideEffect(child, seen));
|
|
467
|
-
}
|
|
468
|
-
function hasConcurrencyOne(node) {
|
|
469
|
-
if (typeof node !== "object" || node === null) return false;
|
|
470
|
-
const object = node;
|
|
471
|
-
if (object.type !== "ObjectExpression" || !Array.isArray(object.properties)) return false;
|
|
472
|
-
return object.properties.some((entry) => {
|
|
473
|
-
if (typeof entry !== "object" || entry === null) return false;
|
|
474
|
-
const prop = entry;
|
|
475
|
-
const key = prop.key;
|
|
476
|
-
const value = prop.value;
|
|
477
|
-
return (isIdentifier(key, "concurrency") || typeof key === "object" && key !== null && key.value === "concurrency") && typeof value === "object" && value !== null && (value.type === "Literal" || value.type === "NumericLiteral") && value.value === 1;
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
function hasConcurrencyOption(node) {
|
|
481
|
-
if (typeof node !== "object" || node === null) return false;
|
|
482
|
-
const object = node;
|
|
483
|
-
if (object.type !== "ObjectExpression" || !Array.isArray(object.properties)) return false;
|
|
484
|
-
return object.properties.some((entry) => {
|
|
485
|
-
if (typeof entry !== "object" || entry === null) return false;
|
|
486
|
-
const key = entry.key;
|
|
487
|
-
return isIdentifier(key, "concurrency") || typeof key === "object" && key !== null && key.value === "concurrency";
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
function isCollectionMapCall(node) {
|
|
491
|
-
if (typeof node !== "object" || node === null) return false;
|
|
492
|
-
const call = node;
|
|
493
|
-
return call.type === "CallExpression" && typeof call.callee === "object" && call.callee !== null && call.callee.type === "MemberExpression" && call.callee.computed !== true && isIdentifier(call.callee.property, "map");
|
|
494
|
-
}
|
|
495
|
-
function isUnboundedMappedEffectAll(node) {
|
|
496
|
-
return isEffectMemberCallNamed(node, "all") && isCollectionMapCall(firstArgument(node)) && !hasConcurrencyOption(node.arguments[1]);
|
|
497
|
-
}
|
|
498
|
-
function containsEffectForkCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
499
|
-
if (isEffectMemberCallNamed(node, "fork")) return node;
|
|
500
|
-
if (Array.isArray(node)) {
|
|
501
|
-
for (const child of node) {
|
|
502
|
-
const match = containsEffectForkCall(child, seen);
|
|
503
|
-
if (match) return match;
|
|
504
|
-
}
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
if (typeof node !== "object" || node === null) return;
|
|
508
|
-
if (seen.has(node)) return;
|
|
509
|
-
seen.add(node);
|
|
510
|
-
for (const [key, child] of Object.entries(node)) {
|
|
511
|
-
if (key === "parent") continue;
|
|
512
|
-
const match = containsEffectForkCall(child, seen);
|
|
513
|
-
if (match) return match;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
function containsEffectMemberCallInSet(node, propertyNames, seen = /* @__PURE__ */ new WeakSet()) {
|
|
517
|
-
if (isEffectMemberCall(node)) {
|
|
518
|
-
const property = node.callee.property;
|
|
519
|
-
if (isIdentifier(property) && propertyNames.has(property.name)) return true;
|
|
520
|
-
}
|
|
521
|
-
if (Array.isArray(node)) return node.some((child) => containsEffectMemberCallInSet(child, propertyNames, seen));
|
|
522
|
-
if (typeof node !== "object" || node === null) return false;
|
|
523
|
-
if (seen.has(node)) return false;
|
|
524
|
-
seen.add(node);
|
|
525
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsEffectMemberCallInSet(child, propertyNames, seen));
|
|
526
|
-
}
|
|
527
|
-
const raceCleanupCalls = /* @__PURE__ */ new Set([
|
|
528
|
-
"acquireRelease",
|
|
529
|
-
"acquireUseRelease",
|
|
530
|
-
"ensuring",
|
|
531
|
-
"forkIn",
|
|
532
|
-
"forkScoped",
|
|
533
|
-
"scoped"
|
|
534
|
-
]);
|
|
535
|
-
function isEffectRaceWithoutCleanup(node) {
|
|
536
|
-
if (!isEffectMemberCallNamed(node, "race") && !isEffectMemberCallNamed(node, "raceAll")) return false;
|
|
537
|
-
return !containsEffectMemberCallInSet(node.arguments, raceCleanupCalls);
|
|
538
|
-
}
|
|
539
|
-
function isUnboundedEffectForEach(node) {
|
|
540
|
-
return isEffectMemberCallNamed(node, "forEach") && !hasConcurrencyOption(node.arguments[2]);
|
|
541
|
-
}
|
|
542
|
-
const retryCalls = /* @__PURE__ */ new Set(["retry"]);
|
|
543
|
-
function isUnboundedConcurrentRetry(node) {
|
|
544
|
-
return (isUnboundedMappedEffectAll(node) || isUnboundedEffectForEach(node)) && containsEffectMemberCallInSet(node.arguments, retryCalls);
|
|
545
|
-
}
|
|
546
|
-
function variableDeclarationIdentifierNames(node) {
|
|
547
|
-
if (typeof node !== "object" || node === null || node.type !== "VariableDeclaration") return [];
|
|
548
|
-
const declarations = node.declarations;
|
|
549
|
-
if (!Array.isArray(declarations)) return [];
|
|
550
|
-
return declarations.flatMap((declaration) => {
|
|
551
|
-
if (typeof declaration !== "object" || declaration === null) return [];
|
|
552
|
-
const id = declaration.id;
|
|
553
|
-
return isIdentifier(id) ? [id.name] : [];
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
function collectDeclaredIdentifierNames(node, names = /* @__PURE__ */ new Set(), seen = /* @__PURE__ */ new WeakSet()) {
|
|
557
|
-
if (Array.isArray(node)) {
|
|
558
|
-
for (const child of node) collectDeclaredIdentifierNames(child, names, seen);
|
|
559
|
-
return names;
|
|
560
|
-
}
|
|
561
|
-
if (typeof node !== "object" || node === null) return names;
|
|
562
|
-
if (seen.has(node)) return names;
|
|
563
|
-
seen.add(node);
|
|
564
|
-
if (node.type === "VariableDeclaration") for (const name of variableDeclarationIdentifierNames(node)) names.add(name);
|
|
565
|
-
for (const [key, child] of Object.entries(node)) if (key !== "parent") collectDeclaredIdentifierNames(child, names, seen);
|
|
566
|
-
return names;
|
|
567
|
-
}
|
|
568
|
-
const mutatingCollectionMethods = /* @__PURE__ */ new Set([
|
|
569
|
-
"add",
|
|
570
|
-
"clear",
|
|
571
|
-
"delete",
|
|
572
|
-
"pop",
|
|
573
|
-
"push",
|
|
574
|
-
"reverse",
|
|
575
|
-
"set",
|
|
576
|
-
"shift",
|
|
577
|
-
"sort",
|
|
578
|
-
"splice",
|
|
579
|
-
"unshift"
|
|
580
|
-
]);
|
|
581
|
-
function mutatedIdentifierName(node) {
|
|
582
|
-
if (typeof node !== "object" || node === null) return;
|
|
583
|
-
const candidate = node;
|
|
584
|
-
if (candidate.type === "AssignmentExpression" && isIdentifier(candidate.left)) return candidate.left.name;
|
|
585
|
-
if (candidate.type === "UpdateExpression" && isIdentifier(candidate.argument)) return candidate.argument.name;
|
|
586
|
-
if (candidate.type === "CallExpression" && typeof candidate.callee === "object" && candidate.callee !== null && candidate.callee.type === "MemberExpression" && candidate.callee.computed !== true && isIdentifier(candidate.callee.object) && isIdentifier(candidate.callee.property) && mutatingCollectionMethods.has(candidate.callee.property.name)) return candidate.callee.object.name;
|
|
587
|
-
}
|
|
588
|
-
function findSharedMutableStateMutation(node, mutableNames, localNames = collectDeclaredIdentifierNames(node), seen = /* @__PURE__ */ new WeakSet()) {
|
|
589
|
-
if (Array.isArray(node)) {
|
|
590
|
-
for (const child of node) {
|
|
591
|
-
const match = findSharedMutableStateMutation(child, mutableNames, localNames, seen);
|
|
592
|
-
if (match) return match;
|
|
593
|
-
}
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
if (typeof node !== "object" || node === null) return;
|
|
597
|
-
if (seen.has(node)) return;
|
|
598
|
-
seen.add(node);
|
|
599
|
-
const mutatedName = mutatedIdentifierName(node);
|
|
600
|
-
if (mutatedName && mutableNames.has(mutatedName) && !localNames.has(mutatedName)) return node;
|
|
601
|
-
for (const [key, child] of Object.entries(node)) {
|
|
602
|
-
if (key === "parent") continue;
|
|
603
|
-
const match = findSharedMutableStateMutation(child, mutableNames, localNames, seen);
|
|
604
|
-
if (match) return match;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
function concurrentEffectWorkNode(node) {
|
|
608
|
-
if (isEffectMemberCallNamed(node, "fork") || isEffectMemberCallNamed(node, "all") || isEffectMemberCallNamed(node, "forEach")) return node.arguments;
|
|
609
|
-
}
|
|
610
|
-
function forkedFiberVariableName(node) {
|
|
611
|
-
if (typeof node !== "object" || node === null || node.type !== "VariableDeclarator") return;
|
|
612
|
-
const declarator = node;
|
|
613
|
-
return isIdentifier(declarator.id) && isEffectMemberCallNamed(declarator.init, "fork") ? declarator.id.name : void 0;
|
|
614
|
-
}
|
|
615
|
-
const fiberObservationCalls = /* @__PURE__ */ new Set([
|
|
616
|
-
"await",
|
|
617
|
-
"interrupt",
|
|
618
|
-
"join"
|
|
619
|
-
]);
|
|
620
|
-
function observedFiberVariableName(node) {
|
|
621
|
-
if (typeof node !== "object" || node === null || node.type !== "CallExpression") return;
|
|
622
|
-
const call = node;
|
|
623
|
-
const callee = call.callee;
|
|
624
|
-
if (typeof callee !== "object" || callee === null || callee.type !== "MemberExpression" || callee.computed === true || !isIdentifier(callee.object, "Fiber") || !isIdentifier(callee.property) || !fiberObservationCalls.has(callee.property.name) || !Array.isArray(call.arguments)) return;
|
|
625
|
-
const [fiber] = call.arguments;
|
|
626
|
-
return isIdentifier(fiber) ? fiber.name : void 0;
|
|
627
|
-
}
|
|
628
|
-
function isEffectAsVoidPipeArgument(node) {
|
|
629
|
-
return isMemberExpression(node, "Effect", "asVoid") || isMemberCall(node, "Effect", "asVoid");
|
|
630
|
-
}
|
|
631
|
-
function isEffectAllAsVoidPipe(node) {
|
|
632
|
-
if (typeof node !== "object" || node === null) return false;
|
|
633
|
-
const call = node;
|
|
634
|
-
if (call.type !== "CallExpression" || !Array.isArray(call.arguments) || typeof call.callee !== "object" || call.callee === null || call.callee.type !== "MemberExpression" || call.callee.computed === true || !isIdentifier(call.callee.property, "pipe")) return false;
|
|
635
|
-
return isEffectMemberCallNamed(call.callee.object, "all") && call.arguments.some((argument) => isEffectAsVoidPipeArgument(argument));
|
|
636
|
-
}
|
|
637
|
-
function pipeParts(node) {
|
|
638
|
-
if (typeof node !== "object" || node === null || !isPipeCall(node)) return [];
|
|
639
|
-
const call = node;
|
|
640
|
-
if (isIdentifier(call.callee, "pipe")) return call.arguments;
|
|
641
|
-
return [call.callee.object, ...call.arguments];
|
|
642
|
-
}
|
|
643
|
-
function isPipeStartingWithEffect(node) {
|
|
644
|
-
const [first] = pipeParts(node);
|
|
645
|
-
return first !== void 0 && containsAnyEffectMemberCall(first);
|
|
646
|
-
}
|
|
647
|
-
function isEffectWrapperAliasExpression(node) {
|
|
648
|
-
if (isPipeStartingWithEffect(node)) return true;
|
|
649
|
-
if (typeof node === "object" && node !== null && node.type === "ArrowFunctionExpression") {
|
|
650
|
-
const body = node.body;
|
|
651
|
-
return isEffectMemberCall(body) || isPipeStartingWithEffect(body);
|
|
652
|
-
}
|
|
653
|
-
return false;
|
|
654
|
-
}
|
|
655
|
-
function hasEffectWrapperAliasReturn(node) {
|
|
656
|
-
return findReturnStatements(node).some((returnNode) => typeof returnNode === "object" && returnNode !== null && (isEffectWrapperAliasExpression(returnNode.argument) || isEffectMemberCall(returnNode.argument)));
|
|
657
|
-
}
|
|
658
|
-
function isQualifiedTypeReference(node, leftName, rightName) {
|
|
659
|
-
if (typeof node !== "object" || node === null || node.type !== "TSTypeReference") return false;
|
|
660
|
-
const typeName = node.typeName;
|
|
661
|
-
return typeof typeName === "object" && typeName !== null && typeName.type === "TSQualifiedName" && isIdentifier(typeName.left, leftName) && isIdentifier(typeName.right, rightName);
|
|
662
|
-
}
|
|
663
|
-
function isIdentifierTypeReference(node, name) {
|
|
664
|
-
return typeof node === "object" && node !== null && node.type === "TSTypeReference" && isIdentifier(node.typeName, name);
|
|
665
|
-
}
|
|
666
|
-
function typeArguments(node) {
|
|
667
|
-
if (typeof node !== "object" || node === null) return [];
|
|
668
|
-
const container = node.typeParameters ?? node.typeArguments;
|
|
669
|
-
if (typeof container !== "object" || container === null) return [];
|
|
670
|
-
const params = container.params ?? container.arguments;
|
|
671
|
-
return Array.isArray(params) ? params : [];
|
|
672
|
-
}
|
|
673
|
-
function isGenericErrorType(node) {
|
|
674
|
-
return isIdentifier(node, "Error") || isIdentifierTypeReference(node, "Error");
|
|
675
|
-
}
|
|
676
|
-
function returnTypeAnnotation(node) {
|
|
677
|
-
if (typeof node !== "object" || node === null) return;
|
|
678
|
-
const returnType = node.returnType;
|
|
679
|
-
if (typeof returnType !== "object" || returnType === null) return;
|
|
680
|
-
return returnType.typeAnnotation ?? returnType;
|
|
681
|
-
}
|
|
682
|
-
function genericEffectErrorReturnType(node) {
|
|
683
|
-
const annotation = returnTypeAnnotation(node);
|
|
684
|
-
if (!isQualifiedTypeReference(annotation, "Effect", "Effect")) return;
|
|
685
|
-
const [, error] = typeArguments(annotation);
|
|
686
|
-
return isGenericErrorType(error) ? annotation : void 0;
|
|
687
|
-
}
|
|
688
|
-
function exportedGenericEffectErrorTarget(node) {
|
|
689
|
-
if (typeof node !== "object" || node === null) return;
|
|
690
|
-
const exportNode = node;
|
|
691
|
-
if (exportNode.type !== "ExportNamedDeclaration" && exportNode.type !== "ExportDefaultDeclaration") return;
|
|
692
|
-
const declaration = exportNode.declaration;
|
|
693
|
-
if (typeof declaration !== "object" || declaration === null) return;
|
|
694
|
-
if (declaration.type === "FunctionDeclaration") return genericEffectErrorReturnType(declaration);
|
|
695
|
-
if (declaration.type !== "VariableDeclaration") return;
|
|
696
|
-
for (const declarator of declaration.declarations ?? []) {
|
|
697
|
-
if (typeof declarator !== "object" || declarator === null) continue;
|
|
698
|
-
const init = declarator.init;
|
|
699
|
-
if (typeof init === "object" && init !== null && (init.type === "ArrowFunctionExpression" || init.type === "FunctionExpression")) {
|
|
700
|
-
const target = genericEffectErrorReturnType(init);
|
|
701
|
-
if (target) return target;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
function containsQualifiedTypeReference(node, leftName, rightName, seen = /* @__PURE__ */ new WeakSet()) {
|
|
706
|
-
if (isQualifiedTypeReference(node, leftName, rightName)) return true;
|
|
707
|
-
if (Array.isArray(node)) return node.some((child) => containsQualifiedTypeReference(child, leftName, rightName, seen));
|
|
708
|
-
if (typeof node !== "object" || node === null) return false;
|
|
709
|
-
if (seen.has(node)) return false;
|
|
710
|
-
seen.add(node);
|
|
711
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsQualifiedTypeReference(child, leftName, rightName, seen));
|
|
712
|
-
}
|
|
713
|
-
function containsWrapGraphqlCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
714
|
-
if (isIdentifierCall(node, "wrapGraphqlCall")) return true;
|
|
715
|
-
if (Array.isArray(node)) return node.some((child) => containsWrapGraphqlCall(child, seen));
|
|
716
|
-
if (typeof node !== "object" || node === null) return false;
|
|
717
|
-
if (seen.has(node)) return false;
|
|
718
|
-
seen.add(node);
|
|
719
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsWrapGraphqlCall(child, seen));
|
|
720
|
-
}
|
|
721
|
-
function isApplyResponseFlatMap(node) {
|
|
722
|
-
return isEffectMemberCallNamed(node, "flatMap") && isIdentifier(firstArgument(node), "applyResponse");
|
|
723
|
-
}
|
|
724
|
-
function containsApplyResponseFlatMap(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
725
|
-
if (isApplyResponseFlatMap(node)) return true;
|
|
726
|
-
if (Array.isArray(node)) return node.some((child) => containsApplyResponseFlatMap(child, seen));
|
|
727
|
-
if (typeof node !== "object" || node === null) return false;
|
|
728
|
-
if (seen.has(node)) return false;
|
|
729
|
-
seen.add(node);
|
|
730
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsApplyResponseFlatMap(child, seen));
|
|
731
|
-
}
|
|
732
|
-
function findEffectCatchAll(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
733
|
-
if (isEffectMemberCallNamed(node, "catchAll")) return node;
|
|
734
|
-
if (Array.isArray(node)) {
|
|
735
|
-
for (const child of node) {
|
|
736
|
-
const match = findEffectCatchAll(child, seen);
|
|
737
|
-
if (match) return match;
|
|
738
|
-
}
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
741
|
-
if (typeof node !== "object" || node === null) return;
|
|
742
|
-
if (seen.has(node)) return;
|
|
743
|
-
seen.add(node);
|
|
744
|
-
for (const [key, child] of Object.entries(node)) {
|
|
745
|
-
if (key === "parent") continue;
|
|
746
|
-
const match = findEffectCatchAll(child, seen);
|
|
747
|
-
if (match) return match;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
function getWrapGraphqlCatchAll(node) {
|
|
751
|
-
const parts = pipeParts(node);
|
|
752
|
-
if (parts.length === 0) return;
|
|
753
|
-
const catchAll = findEffectCatchAll(parts);
|
|
754
|
-
if (!catchAll) return;
|
|
755
|
-
return containsWrapGraphqlCall(parts) || containsApplyResponseFlatMap(parts) ? catchAll : void 0;
|
|
756
|
-
}
|
|
757
|
-
const atomOperationMethods = /* @__PURE__ */ new Set([
|
|
758
|
-
"get",
|
|
759
|
-
"set",
|
|
760
|
-
"update",
|
|
761
|
-
"modify",
|
|
762
|
-
"refresh"
|
|
763
|
-
]);
|
|
764
|
-
function callbackBody(node) {
|
|
765
|
-
if (typeof node !== "object" || node === null) return;
|
|
766
|
-
const callback = node;
|
|
767
|
-
if (callback.type !== "ArrowFunctionExpression" && callback.type !== "FunctionExpression") return;
|
|
768
|
-
return callback.body;
|
|
769
|
-
}
|
|
770
|
-
function isAtomOperationCall(node) {
|
|
771
|
-
if (typeof node !== "object" || node === null) return false;
|
|
772
|
-
const call = node;
|
|
773
|
-
if (call.type !== "CallExpression" || !Array.isArray(call.arguments) || typeof call.callee !== "object" || call.callee === null || call.callee.type !== "MemberExpression" || call.callee.computed === true) return false;
|
|
774
|
-
const callee = call.callee;
|
|
775
|
-
return (isIdentifier(callee.object, "Atom") || isIdentifier(callee.object, "atomRegistry")) && isIdentifier(callee.property) && atomOperationMethods.has(callee.property.name);
|
|
776
|
-
}
|
|
777
|
-
function findAtomOperationCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
778
|
-
if (isAtomOperationCall(node)) return node;
|
|
779
|
-
if (Array.isArray(node)) {
|
|
780
|
-
for (const child of node) {
|
|
781
|
-
const match = findAtomOperationCall(child, seen);
|
|
782
|
-
if (match) return match;
|
|
783
|
-
}
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
if (typeof node !== "object" || node === null) return;
|
|
787
|
-
if (seen.has(node)) return;
|
|
788
|
-
seen.add(node);
|
|
789
|
-
for (const [key, child] of Object.entries(node)) {
|
|
790
|
-
if (key === "parent") continue;
|
|
791
|
-
const match = findAtomOperationCall(child, seen);
|
|
792
|
-
if (match) return match;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
function findAtomOperationInsideEffectSync(node) {
|
|
796
|
-
if (!isEffectMemberCallNamed(node, "sync")) return;
|
|
797
|
-
const body = callbackBody(firstArgument(node));
|
|
798
|
-
return body ? findAtomOperationCall(body) : void 0;
|
|
799
|
-
}
|
|
800
|
-
function isCollectionAtomIdentifier(node) {
|
|
801
|
-
if (!isIdentifier(node)) return false;
|
|
802
|
-
return /(CollectionAtom|ListAtom|Visible.*Atom|ResultsAtom|ReadStateAtom)$/.test(node.name);
|
|
803
|
-
}
|
|
804
|
-
function getCollectionAtomReadTarget(node) {
|
|
805
|
-
if (typeof node !== "object" || node === null) return;
|
|
806
|
-
const call = node;
|
|
807
|
-
if (call.type !== "CallExpression" || !Array.isArray(call.arguments)) return;
|
|
808
|
-
if (!(isIdentifier(call.callee, "get") || isMemberExpression(call.callee, "Atom", "get") || isMemberExpression(call.callee, "get", "get"))) return;
|
|
809
|
-
const [atom] = call.arguments;
|
|
810
|
-
return isCollectionAtomIdentifier(atom) ? atom : void 0;
|
|
811
|
-
}
|
|
812
|
-
function findFamilyCollectionRead(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
813
|
-
const target = getCollectionAtomReadTarget(node);
|
|
814
|
-
if (target) return target;
|
|
815
|
-
if (Array.isArray(node)) {
|
|
816
|
-
for (const child of node) {
|
|
817
|
-
const match = findFamilyCollectionRead(child, seen);
|
|
818
|
-
if (match) return match;
|
|
819
|
-
}
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
if (typeof node !== "object" || node === null) return;
|
|
823
|
-
if (seen.has(node)) return;
|
|
824
|
-
seen.add(node);
|
|
825
|
-
for (const [key, child] of Object.entries(node)) {
|
|
826
|
-
if (key === "parent") continue;
|
|
827
|
-
const match = findFamilyCollectionRead(child, seen);
|
|
828
|
-
if (match) return match;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
function isEffectProvideWithSingleArgument(node) {
|
|
832
|
-
return isEffectMemberCallNamed(node, "provide") && node.arguments.length === 1;
|
|
833
|
-
}
|
|
834
|
-
function findInlineRuntimeProvide(node) {
|
|
835
|
-
if (!isPipeCall(node)) return;
|
|
836
|
-
return pipeParts(node).find((part) => isEffectProvideWithSingleArgument(part));
|
|
837
|
-
}
|
|
838
|
-
function hasObjectSpread(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
839
|
-
if (typeof node === "object" && node !== null && node.type === "SpreadElement") return true;
|
|
840
|
-
if (Array.isArray(node)) return node.some((child) => hasObjectSpread(child, seen));
|
|
841
|
-
if (typeof node !== "object" || node === null) return false;
|
|
842
|
-
if (seen.has(node)) return false;
|
|
843
|
-
seen.add(node);
|
|
844
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && hasObjectSpread(child, seen));
|
|
845
|
-
}
|
|
846
|
-
function isRefStateUpdateWithSpread(node) {
|
|
847
|
-
if (!isMemberCall(node, "Ref", "update") && !isMemberCall(node, "Ref", "modify")) return false;
|
|
848
|
-
const callback = node.arguments[1];
|
|
849
|
-
return hasObjectSpread(callbackBody(callback));
|
|
850
|
-
}
|
|
851
|
-
function isEmptyObjectExpression(node) {
|
|
852
|
-
return typeof node === "object" && node !== null && node.type === "ObjectExpression" && Array.isArray(node.properties) && node.properties.length === 0;
|
|
853
|
-
}
|
|
854
|
-
function containsObjectEntriesCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
855
|
-
if (isMemberCall(node, "Object", "entries")) return true;
|
|
856
|
-
if (Array.isArray(node)) return node.some((child) => containsObjectEntriesCall(child, seen));
|
|
857
|
-
if (typeof node !== "object" || node === null) return false;
|
|
858
|
-
if (seen.has(node)) return false;
|
|
859
|
-
seen.add(node);
|
|
860
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsObjectEntriesCall(child, seen));
|
|
861
|
-
}
|
|
862
|
-
function isNakedObjectStateUpdate(node) {
|
|
863
|
-
if (isRefStateUpdateWithSpread(node)) return true;
|
|
864
|
-
if (isMemberCall(node, "Object", "assign")) {
|
|
865
|
-
const args = node.arguments;
|
|
866
|
-
return args.length >= 3 && isEmptyObjectExpression(args[0]);
|
|
867
|
-
}
|
|
868
|
-
if (isMemberCall(node, "Object", "fromEntries")) return containsObjectEntriesCall(node.arguments[0]);
|
|
869
|
-
return isMemberCall(node, "JSON", "stringify") || isMemberCall(node, "JSON", "parse");
|
|
870
|
-
}
|
|
871
|
-
function isEffectSucceedVariableArgument(node) {
|
|
872
|
-
if (isIdentifier(node)) return true;
|
|
873
|
-
return typeof node === "object" && node !== null && node.type === "MemberExpression";
|
|
874
|
-
}
|
|
875
|
-
function isVariableAsAssertion(node) {
|
|
876
|
-
if (typeof node !== "object" || node === null || node.type !== "VariableDeclaration") return false;
|
|
877
|
-
return node.declarations?.some((declaration) => {
|
|
878
|
-
if (typeof declaration !== "object" || declaration === null) return false;
|
|
879
|
-
const init = declaration.init;
|
|
880
|
-
return typeof init === "object" && init !== null && init.type === "TSAsExpression" && typeof init.typeAnnotation === "object" && init.typeAnnotation !== null && init.typeAnnotation.type !== "TSConstKeyword";
|
|
881
|
-
}) ?? false;
|
|
882
|
-
}
|
|
883
|
-
function isTypeofBooleanCheck(node) {
|
|
884
|
-
if (typeof node !== "object" || node === null || node.type !== "BinaryExpression") return false;
|
|
885
|
-
const binary = node;
|
|
886
|
-
if (binary.operator !== "===") return false;
|
|
887
|
-
const left = binary.left;
|
|
888
|
-
const right = binary.right;
|
|
889
|
-
return typeof left === "object" && left !== null && left.type === "UnaryExpression" && left.operator === "typeof" && typeof right === "object" && right !== null && (right.type === "Literal" || right.type === "StringLiteral") && right.value === "boolean";
|
|
890
|
-
}
|
|
891
|
-
function isMatchOrElseNullCall(node) {
|
|
892
|
-
return isMatchBranchCall(node, "orElse") && isNullLiteral(arrowCallbackBody(node.arguments[0]));
|
|
893
|
-
}
|
|
894
|
-
function isStringLiteral(node) {
|
|
895
|
-
return typeof node === "object" && node !== null && (node.type === "Literal" || node.type === "StringLiteral") && typeof node.value === "string";
|
|
896
|
-
}
|
|
897
|
-
function isUndefinedIdentifier(node) {
|
|
898
|
-
return isIdentifier(node, "undefined");
|
|
899
|
-
}
|
|
900
|
-
function isNullishRewrap(node) {
|
|
901
|
-
return typeof node === "object" && node !== null && node.type === "LogicalExpression" && node.operator === "??" && (isNullLiteral(node.right) || isUndefinedIdentifier(node.right));
|
|
902
|
-
}
|
|
903
|
-
function isOptionFromNullableNullishCoalesce(node) {
|
|
904
|
-
return isMemberCall(node, "Option", "fromNullable") && isNullishRewrap(node.arguments[0]);
|
|
905
|
-
}
|
|
906
|
-
function objectPropertyValue(node, keyName) {
|
|
907
|
-
if (typeof node !== "object" || node === null || node.type !== "ObjectExpression") return;
|
|
908
|
-
for (const property of node.properties ?? []) {
|
|
909
|
-
if (typeof property !== "object" || property === null) continue;
|
|
910
|
-
const key = property.key;
|
|
911
|
-
if (isIdentifier(key, keyName)) return property.value;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
function isBooleanTrueComparison(node) {
|
|
915
|
-
if (typeof node !== "object" || node === null || node.type !== "BinaryExpression") return false;
|
|
916
|
-
const binary = node;
|
|
917
|
-
return binary.operator === "===" && (isBooleanLiteral(binary.left, true) || isBooleanLiteral(binary.right, true));
|
|
918
|
-
}
|
|
919
|
-
function isOptionBooleanNormalization(node) {
|
|
920
|
-
if (!isMemberCall(node, "Option", "match")) return false;
|
|
921
|
-
const config = node.arguments[1];
|
|
922
|
-
const onSome = objectPropertyValue(config, "onSome");
|
|
923
|
-
const onNone = objectPropertyValue(config, "onNone");
|
|
924
|
-
return isBooleanTrueComparison(arrowCallbackBody(onSome)) && isBooleanLiteral(arrowCallbackBody(onNone), false);
|
|
925
|
-
}
|
|
926
|
-
function isStringSentinelConst(node) {
|
|
927
|
-
if (typeof node !== "object" || node === null || node.type !== "VariableDeclaration") return false;
|
|
928
|
-
return node.declarations?.some((declaration) => typeof declaration === "object" && declaration !== null && isStringLiteral(declaration.init)) ?? false;
|
|
929
|
-
}
|
|
930
|
-
function isBooleanLiteral(node, value) {
|
|
931
|
-
return typeof node === "object" && node !== null && (node.type === "Literal" || node.type === "BooleanLiteral") && node.value === value;
|
|
932
|
-
}
|
|
933
|
-
function isEffectVoidMember(node) {
|
|
934
|
-
return isMemberExpression(node, "Effect", "void");
|
|
935
|
-
}
|
|
936
|
-
function isMatchBranchCall(node, propertyName) {
|
|
937
|
-
if (typeof node !== "object" || node === null) return false;
|
|
938
|
-
const call = node;
|
|
939
|
-
return call.type === "CallExpression" && Array.isArray(call.arguments) && typeof call.callee === "object" && call.callee !== null && call.callee.type === "MemberExpression" && call.callee.computed !== true && isIdentifier(call.callee.object, "Match") && isIdentifier(call.callee.property) && (propertyName === void 0 || isIdentifier(call.callee.property, propertyName));
|
|
940
|
-
}
|
|
941
|
-
function arrowCallbackBody(node) {
|
|
942
|
-
if (typeof node !== "object" || node === null || node.type !== "ArrowFunctionExpression") return;
|
|
943
|
-
return node.body;
|
|
944
|
-
}
|
|
945
|
-
function isVoidMatchBranch(node) {
|
|
946
|
-
if (!isMatchBranchCall(node)) return false;
|
|
947
|
-
const [first, second] = node.arguments;
|
|
948
|
-
if (isIdentifier(node.callee.property, "when")) return (isBooleanLiteral(first, true) || isBooleanLiteral(first, false)) && isEffectVoidMember(arrowCallbackBody(second));
|
|
949
|
-
return isIdentifier(node.callee.property, "orElse") && isEffectVoidMember(arrowCallbackBody(first));
|
|
950
|
-
}
|
|
951
|
-
const branchSequencingEffectCalls = [
|
|
952
|
-
"flatMap",
|
|
953
|
-
"map",
|
|
954
|
-
"andThen",
|
|
955
|
-
"tap",
|
|
956
|
-
"zipRight"
|
|
957
|
-
];
|
|
958
|
-
function isStreamMemberCall(node) {
|
|
959
|
-
if (typeof node !== "object" || node === null) return false;
|
|
960
|
-
const call = node;
|
|
961
|
-
return call.type === "CallExpression" && typeof call.callee === "object" && call.callee !== null && call.callee.type === "MemberExpression" && call.callee.computed !== true && isIdentifier(call.callee.object, "Stream") && isIdentifier(call.callee.property);
|
|
962
|
-
}
|
|
963
|
-
function containsAnyEffectMemberCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
964
|
-
if (isEffectMemberCall(node)) return true;
|
|
965
|
-
if (Array.isArray(node)) return node.some((child) => containsAnyEffectMemberCall(child, seen));
|
|
966
|
-
if (typeof node !== "object" || node === null) return false;
|
|
967
|
-
if (seen.has(node)) return false;
|
|
968
|
-
seen.add(node);
|
|
969
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsAnyEffectMemberCall(child, seen));
|
|
970
|
-
}
|
|
971
|
-
function containsBranchSequencingCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
972
|
-
if (branchSequencingEffectCalls.some((propertyName) => isEffectMemberCallNamed(node, propertyName)) || isPipeCall(node) || isStreamMemberCall(node)) return true;
|
|
973
|
-
if (Array.isArray(node)) return node.some((child) => containsBranchSequencingCall(child, seen));
|
|
974
|
-
if (typeof node !== "object" || node === null) return false;
|
|
975
|
-
if (seen.has(node)) return false;
|
|
976
|
-
seen.add(node);
|
|
977
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsBranchSequencingCall(child, seen));
|
|
978
|
-
}
|
|
979
|
-
function isSequencingBranchBody(node) {
|
|
980
|
-
return containsAnyEffectMemberCall(node) && containsBranchSequencingCall(node);
|
|
981
|
-
}
|
|
982
|
-
function containsSequencingMatchBranch(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
983
|
-
if (isMatchBranchCall(node)) {
|
|
984
|
-
if (isSequencingBranchBody(isIdentifier(node.callee.property, "when") ? arrowCallbackBody(node.arguments[1]) : arrowCallbackBody(node.arguments[0]))) return true;
|
|
985
|
-
}
|
|
986
|
-
if (Array.isArray(node)) return node.some((child) => containsSequencingMatchBranch(child, seen));
|
|
987
|
-
if (typeof node !== "object" || node === null) return false;
|
|
988
|
-
if (seen.has(node)) return false;
|
|
989
|
-
seen.add(node);
|
|
990
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsSequencingMatchBranch(child, seen));
|
|
991
|
-
}
|
|
992
|
-
function containsMatchBranchCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
993
|
-
if (isMatchBranchCall(node)) return true;
|
|
994
|
-
if (Array.isArray(node)) return node.some((child) => containsMatchBranchCall(child, seen));
|
|
995
|
-
if (typeof node !== "object" || node === null) return false;
|
|
996
|
-
if (seen.has(node)) return false;
|
|
997
|
-
seen.add(node);
|
|
998
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsMatchBranchCall(child, seen));
|
|
999
|
-
}
|
|
1000
|
-
function isOptionMatchCall(node) {
|
|
1001
|
-
return typeof node === "object" && node !== null && node.type === "CallExpression" && Array.isArray(node.arguments) && isMemberExpression(node.callee, "Option", "match");
|
|
1002
|
-
}
|
|
1003
|
-
function isExpressionBodiedArrowCall(node) {
|
|
1004
|
-
const body = arrowCallbackBody(node);
|
|
1005
|
-
return typeof body === "object" && body !== null && body.type === "CallExpression";
|
|
1006
|
-
}
|
|
1007
|
-
function findEffectGenCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
1008
|
-
if (isEffectMemberCallNamed(node, "gen")) return node;
|
|
1009
|
-
if (Array.isArray(node)) {
|
|
1010
|
-
for (const child of node) {
|
|
1011
|
-
const match = findEffectGenCall(child, seen);
|
|
1012
|
-
if (match) return match;
|
|
1013
|
-
}
|
|
1014
|
-
return;
|
|
1015
|
-
}
|
|
1016
|
-
if (typeof node !== "object" || node === null) return;
|
|
1017
|
-
if (seen.has(node)) return;
|
|
1018
|
-
seen.add(node);
|
|
1019
|
-
for (const [key, child] of Object.entries(node)) {
|
|
1020
|
-
if (key === "parent") continue;
|
|
1021
|
-
const match = findEffectGenCall(child, seen);
|
|
1022
|
-
if (match) return match;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
function isMatchValuePipeCall(node) {
|
|
1026
|
-
if (!isPipeCall(node) || typeof node !== "object" || node === null) return false;
|
|
1027
|
-
const object = node.callee.object;
|
|
1028
|
-
return typeof object === "object" && object !== null && object.type === "CallExpression" && isMemberExpression(object.callee, "Match", "value");
|
|
1029
|
-
}
|
|
1030
|
-
function isObjectBranchCall(node) {
|
|
1031
|
-
return isMatchValuePipeCall(node) || typeof node === "object" && node !== null && node.type === "CallExpression" && (isMemberExpression(node.callee, "Option", "match") || isMemberExpression(node.callee, "Either", "match"));
|
|
1032
|
-
}
|
|
1033
|
-
function containsObjectBranchCall(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
1034
|
-
if (isObjectBranchCall(node)) return true;
|
|
1035
|
-
if (Array.isArray(node)) return node.some((child) => containsObjectBranchCall(child, seen));
|
|
1036
|
-
if (typeof node !== "object" || node === null) return false;
|
|
1037
|
-
if (seen.has(node)) return false;
|
|
1038
|
-
seen.add(node);
|
|
1039
|
-
return Object.entries(node).some(([key, child]) => key !== "parent" && containsObjectBranchCall(child, seen));
|
|
1040
|
-
}
|
|
1041
|
-
function objectPropertyValues(node) {
|
|
1042
|
-
if (typeof node !== "object" || node === null) return [];
|
|
1043
|
-
const object = node;
|
|
1044
|
-
if (object.type !== "ObjectExpression" || !Array.isArray(object.properties)) return [];
|
|
1045
|
-
return object.properties.map((property) => typeof property === "object" && property !== null ? property.value : void 0).filter((value) => value !== void 0);
|
|
1046
|
-
}
|
|
1047
|
-
function isRawDomainIdAlias(node) {
|
|
1048
|
-
if (typeof node !== "object" || node === null || node.type !== "TSTypeAliasDeclaration") return false;
|
|
1049
|
-
const aliasName = node.id;
|
|
1050
|
-
const typeAnnotation = node.typeAnnotation;
|
|
1051
|
-
return isIdentifier(aliasName) && /(?:Id|ID)$/.test(aliasName.name) && (typeAnnotation?.type === "TSStringKeyword" || typeAnnotation?.type === "TSNumberKeyword");
|
|
1052
|
-
}
|
|
1053
|
-
function isBooleanTypeAnnotation(node) {
|
|
1054
|
-
if (typeof node !== "object" || node === null) return false;
|
|
1055
|
-
const annotation = node;
|
|
1056
|
-
if (annotation.type === "TSBooleanKeyword") return true;
|
|
1057
|
-
return annotation.type === "TSTypeAnnotation" && typeof annotation.typeAnnotation === "object" && annotation.typeAnnotation !== null && annotation.typeAnnotation.type === "TSBooleanKeyword";
|
|
1058
|
-
}
|
|
1059
|
-
function unwrapTypeAnnotation(node) {
|
|
1060
|
-
if (typeof node !== "object" || node === null) return;
|
|
1061
|
-
const annotation = node;
|
|
1062
|
-
if (annotation.type === "TSTypeAnnotation" && typeof annotation.typeAnnotation === "object" && annotation.typeAnnotation !== null) return annotation.typeAnnotation;
|
|
1063
|
-
return annotation;
|
|
1064
|
-
}
|
|
1065
|
-
function isStringOrNumberTypeAnnotation(node) {
|
|
1066
|
-
const annotation = unwrapTypeAnnotation(node);
|
|
1067
|
-
return annotation?.type === "TSStringKeyword" || annotation?.type === "TSNumberKeyword";
|
|
1068
|
-
}
|
|
1069
|
-
function isAnyOrObjectTypeAnnotation(node) {
|
|
1070
|
-
const annotation = unwrapTypeAnnotation(node);
|
|
1071
|
-
return annotation?.type === "TSAnyKeyword" || annotation?.type === "TSObjectKeyword";
|
|
1072
|
-
}
|
|
1073
|
-
function isDateTypeAnnotation(node) {
|
|
1074
|
-
const annotation = unwrapTypeAnnotation(node);
|
|
1075
|
-
return annotation?.type === "TSTypeReference" && isIdentifier(annotation.typeName, "Date");
|
|
1076
|
-
}
|
|
1077
|
-
function primitiveDomainParameters(node) {
|
|
1078
|
-
if (typeof node !== "object" || node === null || !Array.isArray(node.params)) return [];
|
|
1079
|
-
const domainNamePattern = /(?:id|amount|currency|account|user|order|customer|invoice|payment|price|total|quantity|transfer|fund|balance)/i;
|
|
1080
|
-
return node.params.filter((param) => isIdentifier(param) && isStringOrNumberTypeAnnotation(param.typeAnnotation) && domainNamePattern.test(param.name));
|
|
1081
|
-
}
|
|
1082
|
-
function hasPrimitiveHeavyDomainParameters(node) {
|
|
1083
|
-
return primitiveDomainParameters(node).length >= 3;
|
|
1084
|
-
}
|
|
1085
|
-
function isBooleanDomainFlagParameter(node) {
|
|
1086
|
-
if (!isIdentifier(node)) return false;
|
|
1087
|
-
return /^(?:is|has|should|with|allow|enable|can|use)[A-Z0-9_]/.test(node.name) && isBooleanTypeAnnotation(node.typeAnnotation);
|
|
1088
|
-
}
|
|
1089
|
-
function functionBooleanDomainFlagParameters(node) {
|
|
1090
|
-
if (typeof node !== "object" || node === null || !Array.isArray(node.params)) return [];
|
|
1091
|
-
return node.params.filter(isBooleanDomainFlagParameter);
|
|
1092
|
-
}
|
|
1093
|
-
function getPropertyName(node) {
|
|
1094
|
-
if (isIdentifier(node)) return node.name;
|
|
1095
|
-
if (typeof node === "object" && node !== null && typeof node.value === "string") return node.value;
|
|
1096
|
-
}
|
|
1097
|
-
function isRawTimeFieldName(name) {
|
|
1098
|
-
return /(?:createdAt|updatedAt|expiresAt|expiredAt|renewedAt|startedAt|endedAt|deletedAt|timestamp|timeoutMs|durationMs|ttlMs|ttl)$/i.test(name);
|
|
1099
|
-
}
|
|
1100
|
-
function isRawTimeDomainField(node) {
|
|
1101
|
-
if (typeof node !== "object" || node === null || node.type !== "TSPropertySignature") return false;
|
|
1102
|
-
const property = node;
|
|
1103
|
-
const propertyName = getPropertyName(property.key);
|
|
1104
|
-
const typeAnnotation = property.typeAnnotation;
|
|
1105
|
-
return propertyName !== void 0 && isRawTimeFieldName(propertyName) && (isStringOrNumberTypeAnnotation(typeAnnotation) || isDateTypeAnnotation(typeAnnotation));
|
|
1106
|
-
}
|
|
1107
|
-
function typeMembers(node) {
|
|
1108
|
-
if (typeof node !== "object" || node === null) return [];
|
|
1109
|
-
const object = node;
|
|
1110
|
-
if (object.type === "TSInterfaceDeclaration" && typeof object.body === "object" && object.body !== null && Array.isArray(object.body.body)) return object.body.body;
|
|
1111
|
-
if (object.type === "TSTypeLiteral" && Array.isArray(object.members)) return object.members;
|
|
1112
|
-
return [];
|
|
1113
|
-
}
|
|
1114
|
-
function rawTimeDomainFields(node) {
|
|
1115
|
-
return typeMembers(node).filter(isRawTimeDomainField);
|
|
1116
|
-
}
|
|
1117
|
-
function isOverloadedOptionsParameter(node) {
|
|
1118
|
-
if (!isIdentifier(node)) return false;
|
|
1119
|
-
return /^(?:opts|options|config)$/i.test(node.name) && isAnyOrObjectTypeAnnotation(node.typeAnnotation);
|
|
1120
|
-
}
|
|
1121
|
-
function overloadedOptionsParameters(node) {
|
|
1122
|
-
if (typeof node !== "object" || node === null || !Array.isArray(node.params)) return [];
|
|
1123
|
-
return node.params.filter(isOverloadedOptionsParameter);
|
|
1124
|
-
}
|
|
1125
|
-
const comparisonOperators = /* @__PURE__ */ new Set([
|
|
1126
|
-
"==",
|
|
1127
|
-
"===",
|
|
1128
|
-
"!=",
|
|
1129
|
-
"!==",
|
|
1130
|
-
">",
|
|
1131
|
-
">=",
|
|
1132
|
-
"<",
|
|
1133
|
-
"<="
|
|
1134
|
-
]);
|
|
1135
|
-
function comparisonCount(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
1136
|
-
if (Array.isArray(node)) return node.reduce((count, child) => count + comparisonCount(child, seen), 0);
|
|
1137
|
-
if (typeof node !== "object" || node === null) return 0;
|
|
1138
|
-
if (seen.has(node)) return 0;
|
|
1139
|
-
seen.add(node);
|
|
1140
|
-
const expression = node;
|
|
1141
|
-
if (expression.type === "BinaryExpression" && comparisonOperators.has(String(expression.operator))) return 1;
|
|
1142
|
-
if (expression.type !== "LogicalExpression") return 0;
|
|
1143
|
-
return comparisonCount(expression.left, seen) + comparisonCount(expression.right, seen);
|
|
1144
|
-
}
|
|
1145
|
-
function isDomainLogicConditional(node) {
|
|
1146
|
-
return typeof node === "object" && node !== null && node.type === "LogicalExpression" && comparisonCount(node) >= 3;
|
|
1147
|
-
}
|
|
1148
|
-
function stateFlagMember(node) {
|
|
1149
|
-
if (typeof node !== "object" || node === null || node.type !== "MemberExpression") return;
|
|
1150
|
-
const member = node;
|
|
1151
|
-
if (member.computed === true || !isIdentifier(member.object) || !isIdentifier(member.property)) return;
|
|
1152
|
-
const propertyName = member.property.name;
|
|
1153
|
-
if (!/(?:cancelled|canceled|shipped|approved|rejected|pending|active|inactive|enabled|disabled|locked|archived|deleted|submitted|processing|failed|complete|completed)$/i.test(propertyName)) return;
|
|
1154
|
-
return {
|
|
1155
|
-
objectName: member.object.name,
|
|
1156
|
-
propertyName
|
|
1157
|
-
};
|
|
1158
|
-
}
|
|
1159
|
-
function collectStateFlagMembers(node, members = /* @__PURE__ */ new Map(), seen = /* @__PURE__ */ new WeakSet()) {
|
|
1160
|
-
const member = stateFlagMember(node);
|
|
1161
|
-
if (member) {
|
|
1162
|
-
const properties = members.get(member.objectName) ?? /* @__PURE__ */ new Set();
|
|
1163
|
-
properties.add(member.propertyName);
|
|
1164
|
-
members.set(member.objectName, properties);
|
|
1165
|
-
return members;
|
|
1166
|
-
}
|
|
1167
|
-
if (Array.isArray(node)) {
|
|
1168
|
-
for (const child of node) collectStateFlagMembers(child, members, seen);
|
|
1169
|
-
return members;
|
|
1170
|
-
}
|
|
1171
|
-
if (typeof node !== "object" || node === null) return members;
|
|
1172
|
-
if (seen.has(node)) return members;
|
|
1173
|
-
seen.add(node);
|
|
1174
|
-
const expression = node;
|
|
1175
|
-
if (expression.type !== "LogicalExpression") return members;
|
|
1176
|
-
collectStateFlagMembers(expression.left, members, seen);
|
|
1177
|
-
collectStateFlagMembers(expression.right, members, seen);
|
|
1178
|
-
return members;
|
|
1179
|
-
}
|
|
1180
|
-
function isImplicitStateMachineObject(node) {
|
|
1181
|
-
if (typeof node !== "object" || node === null || node.type !== "LogicalExpression") return false;
|
|
1182
|
-
return Array.from(collectStateFlagMembers(node).values()).some((properties) => properties.size >= 2);
|
|
1183
|
-
}
|
|
1184
|
-
function isAdhocEffectFail(node) {
|
|
1185
|
-
return isEffectMemberCallNamed(node, "fail") && isStringLiteral(firstArgument(node));
|
|
1186
|
-
}
|
|
1187
|
-
function isThrowNewStringError(node) {
|
|
1188
|
-
if (typeof node !== "object" || node === null || node.type !== "ThrowStatement") return false;
|
|
1189
|
-
const argument = node.argument;
|
|
1190
|
-
return typeof argument === "object" && argument !== null && argument.type === "NewExpression" && isIdentifier(argument.callee, "Error") && Array.isArray(argument.arguments) && isStringLiteral(argument.arguments[0]);
|
|
1191
|
-
}
|
|
1192
|
-
function hasRawDomainIdParameter(node) {
|
|
1193
|
-
if (typeof node !== "object" || node === null || !Array.isArray(node.params)) return false;
|
|
1194
|
-
return node.params.some((param) => isIdentifier(param) && /(?:^id$|Id$|ID$)/.test(param.name) && isStringOrNumberTypeAnnotation(param.typeAnnotation));
|
|
1195
|
-
}
|
|
1196
|
-
function isContextEncodedDomainFunction(node) {
|
|
1197
|
-
if (typeof node !== "object" || node === null || node.type !== "FunctionDeclaration") return false;
|
|
1198
|
-
const id = node.id;
|
|
1199
|
-
return isIdentifier(id) && /(?:Admin|Public|Internal|External|Private|Backoffice|Panel)/.test(id.name) && hasRawDomainIdParameter(node);
|
|
1200
|
-
}
|
|
1201
|
-
function isStringLiteralComparison(node) {
|
|
1202
|
-
if (typeof node !== "object" || node === null || node.type !== "BinaryExpression") return false;
|
|
1203
|
-
const binary = node;
|
|
1204
|
-
return [
|
|
1205
|
-
"==",
|
|
1206
|
-
"===",
|
|
1207
|
-
"!=",
|
|
1208
|
-
"!=="
|
|
1209
|
-
].includes(String(binary.operator)) && (isStringLiteral(binary.left) || isStringLiteral(binary.right)) && !isTypeofBooleanCheck(binary);
|
|
1210
|
-
}
|
|
1211
|
-
function report(context, node, message) {
|
|
1212
|
-
context.report({
|
|
1213
|
-
message,
|
|
1214
|
-
node
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
function isNullLiteral(node) {
|
|
1218
|
-
if (typeof node !== "object" || node === null) return false;
|
|
1219
|
-
const literal = node;
|
|
1220
|
-
return literal.type === "NullLiteral" || literal.type === "Literal" && literal.value === null;
|
|
1221
|
-
}
|
|
1222
|
-
function getImportSource(node) {
|
|
1223
|
-
if (typeof node !== "object" || node === null) return;
|
|
1224
|
-
const source = node.source;
|
|
1225
|
-
if (typeof source === "string") return source;
|
|
1226
|
-
if (typeof source === "object" && source !== null) {
|
|
1227
|
-
const value = source.value;
|
|
1228
|
-
if (typeof value === "string") return value;
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
function isEffectEcosystemImport(source) {
|
|
1232
|
-
return source === "effect" || source.startsWith("effect/") || source === "@effect-atom/atom-react";
|
|
1233
|
-
}
|
|
1234
|
-
function createEffectGatedStatementRule(visitorName, message) {
|
|
1235
|
-
return defineRule({ create(context) {
|
|
1236
|
-
let hasEffectEcosystemImport = false;
|
|
1237
|
-
return {
|
|
1238
|
-
ImportDeclaration(node) {
|
|
1239
|
-
const source = getImportSource(node);
|
|
1240
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1241
|
-
},
|
|
1242
|
-
[visitorName](node) {
|
|
1243
|
-
if (hasEffectEcosystemImport) report(context, node, message);
|
|
1244
|
-
}
|
|
1245
|
-
};
|
|
1246
|
-
} });
|
|
1247
|
-
}
|
|
1248
|
-
const reactStateHooks = /* @__PURE__ */ new Set([
|
|
1249
|
-
"useState",
|
|
1250
|
-
"useReducer",
|
|
1251
|
-
"useContext",
|
|
1252
|
-
"useCallback",
|
|
1253
|
-
"useEffect",
|
|
1254
|
-
"useSyncExternalStore"
|
|
1255
|
-
]);
|
|
1256
|
-
const noReactState = defineRule({ create(context) {
|
|
1257
|
-
return { CallExpression(node) {
|
|
1258
|
-
const callee = node.callee;
|
|
1259
|
-
const hookName = isIdentifier(callee) ? callee.name : typeof callee === "object" && callee !== null && callee.type === "MemberExpression" && isIdentifier(callee.property) ? callee.property.name : void 0;
|
|
1260
|
-
if (hookName && reactStateHooks.has(hookName)) report(context, callee, "Rule: avoid React state hooks. Why: they bypass the atom runtime and break reactive flow. Fix: use @effect-atom/atom-react instead.");
|
|
1261
|
-
} };
|
|
1262
|
-
} });
|
|
1263
|
-
const noIfStatement = createEffectGatedStatementRule("IfStatement", "Rule: avoid imperative if branching. Why: Effect code should keep branching explicit and typed. Fix: use Match.value/Match.type or Effect combinators instead.");
|
|
1264
|
-
const noSwitchStatement = createEffectGatedStatementRule("SwitchStatement", "Rule: avoid imperative switch branching. Why: Effect code should keep branching explicit and typed. Fix: use Match.value/Match.type instead.");
|
|
1265
|
-
const noTernary = createEffectGatedStatementRule("ConditionalExpression", "Rule: avoid ternary expressions. Why: they hide control flow inside expressions. Fix: use Option.match/Either.match/Match.value or data combinators, then run one Effect pipeline.");
|
|
1266
|
-
const noReturnNull = defineRule({ create(context) {
|
|
1267
|
-
let hasEffectEcosystemImport = false;
|
|
1268
|
-
return {
|
|
1269
|
-
ImportDeclaration(node) {
|
|
1270
|
-
const source = getImportSource(node);
|
|
1271
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1272
|
-
},
|
|
1273
|
-
ReturnStatement(node) {
|
|
1274
|
-
if (hasEffectEcosystemImport && isNullLiteral(node.argument)) report(context, node, "Rule: avoid returning null. Why: null is a sentinel that forces defensive guards. Fix: use Option.none for absence or Effect.fail for errors.");
|
|
1275
|
-
}
|
|
1276
|
-
};
|
|
1277
|
-
} });
|
|
1278
|
-
const noOptionAs = defineRule({ create(context) {
|
|
1279
|
-
let hasEffectEcosystemImport = false;
|
|
1280
|
-
return {
|
|
1281
|
-
ImportDeclaration(node) {
|
|
1282
|
-
const source = getImportSource(node);
|
|
1283
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1284
|
-
},
|
|
1285
|
-
CallExpression(node) {
|
|
1286
|
-
if (hasEffectEcosystemImport && isMemberExpression(node.callee, "Option", "as")) report(context, node, "Rule: avoid Option.as. Why: it hides selection and encourages placeholder flows. Fix: use Option.map or Option.match and return the value explicitly.");
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
} });
|
|
1290
|
-
const noEffectNever = defineRule({ create(context) {
|
|
1291
|
-
let hasEffectEcosystemImport = false;
|
|
1292
|
-
return {
|
|
1293
|
-
ImportDeclaration(node) {
|
|
1294
|
-
const source = getImportSource(node);
|
|
1295
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1296
|
-
},
|
|
1297
|
-
MemberExpression(node) {
|
|
1298
|
-
if (hasEffectEcosystemImport && isMemberExpression(node, "Effect", "never")) report(context, node, "Rule: avoid Effect.never. Why: it hides lifecycle and leaks resources. Fix: use Stream or explicit acquire/release lifecycles with clear teardown.");
|
|
1299
|
-
}
|
|
1300
|
-
};
|
|
1301
|
-
} });
|
|
1302
|
-
const noArrowLadder = defineRule({ create(context) {
|
|
1303
|
-
let hasEffectEcosystemImport = false;
|
|
1304
|
-
return {
|
|
1305
|
-
ImportDeclaration(node) {
|
|
1306
|
-
const source = getImportSource(node);
|
|
1307
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1308
|
-
},
|
|
1309
|
-
CallExpression(node) {
|
|
1310
|
-
if (!hasEffectEcosystemImport || !isArrowIifeCall(node)) return;
|
|
1311
|
-
const nested = findArrowIifeCall(node.callee.body);
|
|
1312
|
-
if (nested) report(context, nested, "Rule: avoid nested IIFEs. Why: they hide sequencing and push wrapper hacks. Fix: bind a named context with const and keep one flat pipeline with a single Match/Option decision.");
|
|
1313
|
-
}
|
|
1314
|
-
};
|
|
1315
|
-
} });
|
|
1316
|
-
const noBranchInObject = defineRule({ create(context) {
|
|
1317
|
-
return { ObjectExpression(node) {
|
|
1318
|
-
if (objectPropertyValues(node).some((value) => containsObjectBranchCall(value))) report(context, node, "Rule: avoid Match/Option/Either inside object literals. Why: it hides the decision and invites workaround scaffolding. Fix: compute the value first (context), then build the object from named values with one flat decision.");
|
|
1319
|
-
} };
|
|
1320
|
-
} });
|
|
1321
|
-
const noIifeWrapper = defineRule({ create(context) {
|
|
1322
|
-
let hasEffectEcosystemImport = false;
|
|
1323
|
-
return {
|
|
1324
|
-
ImportDeclaration(node) {
|
|
1325
|
-
const source = getImportSource(node);
|
|
1326
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1327
|
-
},
|
|
1328
|
-
CallExpression(node) {
|
|
1329
|
-
if (hasEffectEcosystemImport && isInlineFunctionIifeCall(node)) report(context, node, "Rule: avoid immediate invocation of inline functions. Why: it hides decisions and sequencing. Fix: bind a named context with const and keep one Match/Option decision in a flat pipeline.");
|
|
1330
|
-
}
|
|
1331
|
-
};
|
|
1332
|
-
} });
|
|
1333
|
-
const noReturnInArrow = defineRule({ create(context) {
|
|
1334
|
-
return { CallExpression(node) {
|
|
1335
|
-
for (const returnNode of directArrowCallbackReturns(node)) report(context, returnNode, "Rule: avoid block-bodied arrow callbacks with returns. Why: they hide local control flow. Fix: use expression-only callbacks and move the logic into a single pipeline (pipe/Match/Option/A.map).");
|
|
1336
|
-
} };
|
|
1337
|
-
} });
|
|
1338
|
-
const noReturnInCallback = defineRule({ create(context) {
|
|
1339
|
-
return { CallExpression(node) {
|
|
1340
|
-
for (const returnNode of directFunctionCallbackReturns(node)) report(context, returnNode, "Rule: avoid returns inside inline callbacks. Why: they hide control flow. Prefer expression-only callbacks, but leaf-level Effect branches with local bindings may use returns when needed.");
|
|
1341
|
-
} };
|
|
1342
|
-
} });
|
|
1343
|
-
const noEffectFnGenerator = defineRule({ create(context) {
|
|
1344
|
-
let hasEffectEcosystemImport = false;
|
|
1345
|
-
return {
|
|
1346
|
-
ImportDeclaration(node) {
|
|
1347
|
-
const source = getImportSource(node);
|
|
1348
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1349
|
-
},
|
|
1350
|
-
CallExpression(node) {
|
|
1351
|
-
if (hasEffectEcosystemImport && isEffectGeneratorCall(node, "fn")) report(context, node, "Rule: avoid Effect.fn generator wrappers. Why: they hide sequencing and dodge ladder rules. Fix: keep a single flat pipeline or use one Effect.gen.");
|
|
1352
|
-
}
|
|
1353
|
-
};
|
|
1354
|
-
} });
|
|
1355
|
-
const noEffectSyncConsole = defineRule({ create(context) {
|
|
1356
|
-
let hasEffectEcosystemImport = false;
|
|
1357
|
-
return {
|
|
1358
|
-
ImportDeclaration(node) {
|
|
1359
|
-
const source = getImportSource(node);
|
|
1360
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1361
|
-
},
|
|
1362
|
-
CallExpression(node) {
|
|
1363
|
-
if (hasEffectEcosystemImport && isEffectMemberCallNamed(node, "sync") && containsConsoleCall(firstArgument(node))) report(context, node, "Rule: avoid console.* inside Effect.sync. Why: it hides side effects. Fix: replace with Effect.log* or remove the console call.");
|
|
1364
|
-
}
|
|
1365
|
-
};
|
|
1366
|
-
} });
|
|
1367
|
-
const noNestedEffectGen = defineRule({ create(context) {
|
|
1368
|
-
let hasEffectEcosystemImport = false;
|
|
1369
|
-
return {
|
|
1370
|
-
ImportDeclaration(node) {
|
|
1371
|
-
const source = getImportSource(node);
|
|
1372
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1373
|
-
},
|
|
1374
|
-
CallExpression(node) {
|
|
1375
|
-
const generator = getEffectGeneratorArgument(node, "gen");
|
|
1376
|
-
if (!hasEffectEcosystemImport || !generator) return;
|
|
1377
|
-
const nested = findEffectGenCall(generator.body);
|
|
1378
|
-
if (nested) report(context, nested, "Rule: avoid nested Effect.gen. Why: nested generators hide sequencing. Fix: flatten to a single Effect.gen per method or a single flat pipeline.");
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
} });
|
|
1382
|
-
const noYieldWithoutStarInEffectGen = defineRule({ create(context) {
|
|
1383
|
-
let hasEffectEcosystemImport = false;
|
|
1384
|
-
return {
|
|
1385
|
-
ImportDeclaration(node) {
|
|
1386
|
-
const source = getImportSource(node);
|
|
1387
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1388
|
-
},
|
|
1389
|
-
CallExpression(node) {
|
|
1390
|
-
if (!hasEffectEcosystemImport) return;
|
|
1391
|
-
const yieldNode = findYieldWithoutStarInEffectGen(node);
|
|
1392
|
-
if (yieldNode) report(context, yieldNode, "Rule: use yield* inside Effect.gen. Why: plain yield returns an Effect value without delegating to the Effect interpreter. Fix: replace `yield Effect.x` with `yield* Effect.x`.");
|
|
1393
|
-
}
|
|
1394
|
-
};
|
|
1395
|
-
} });
|
|
1396
|
-
const noMatchVoidBranch = defineRule({ create(context) {
|
|
1397
|
-
let hasEffectEcosystemImport = false;
|
|
1398
|
-
return {
|
|
1399
|
-
ImportDeclaration(node) {
|
|
1400
|
-
const source = getImportSource(node);
|
|
1401
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1402
|
-
},
|
|
1403
|
-
CallExpression(node) {
|
|
1404
|
-
if (hasEffectEcosystemImport && isVoidMatchBranch(node)) report(context, node, "Rule: avoid void Match branches. Why: they hide guard-style control flow. Fix: remove the no-op branch or select a value and run one Effect pipeline outside the Match.");
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
} });
|
|
1408
|
-
const noMatchEffectBranch = defineRule({ create(context) {
|
|
1409
|
-
return { CallExpression(node) {
|
|
1410
|
-
if (isMatchValuePipeCall(node) && containsSequencingMatchBranch(node.arguments)) report(context, node, "Rule: avoid multi-step sequencing inside Match branches. Why: it hides control flow. Fix: select a value in Match, then run one Effect pipeline outside. Avoid data-encoded conditionals (Option.toArray/forEach) that only rewrap the branch.");
|
|
1411
|
-
if (isOptionMatchCall(node) && isSequencingBranchBody(node.arguments)) report(context, node, "Rule: avoid multi-step sequencing inside Option.match branches. Why: it hides control flow. Prefer selecting a value in Option.match, then run one Effect pipeline outside. Leaf-level flows with local bindings may keep Option.match but should stay linear.");
|
|
1412
|
-
} };
|
|
1413
|
-
} });
|
|
1414
|
-
const warnEffectSyncWrapper = defineRule({ create(context) {
|
|
1415
|
-
let hasEffectEcosystemImport = false;
|
|
1416
|
-
return {
|
|
1417
|
-
ImportDeclaration(node) {
|
|
1418
|
-
const source = getImportSource(node);
|
|
1419
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1420
|
-
},
|
|
1421
|
-
CallExpression(node) {
|
|
1422
|
-
const callback = firstArgument(node);
|
|
1423
|
-
const body = arrowCallbackBody(callback);
|
|
1424
|
-
if (hasEffectEcosystemImport && isEffectMemberCallNamed(node, "sync") && isExpressionBodiedArrowCall(callback) && !isConsoleCall(body)) report(context, node, "Rule: avoid Effect.sync around side effects. Why: it hides intent. Fix: use Effect.log* or an explicit pipeline step for the side effect.");
|
|
1425
|
-
}
|
|
1426
|
-
};
|
|
1427
|
-
} });
|
|
1428
|
-
const noEffectSideEffectWrapper = defineRule({ create(context) {
|
|
1429
|
-
return { CallExpression(node) {
|
|
1430
|
-
if (isEffectMemberCallNamed(node, "as") && containsWrapperSideEffect(firstArgument(node))) report(context, node, "Rule: avoid Effect.as for side effects. Why: it hides side effects and turns them into placeholders. Fix: use explicit pipeline steps that return real values with Effect.flatMap, Effect.andThen, or Effect.tap.");
|
|
1431
|
-
if (isEffectMemberCallNamed(node, "zipRight") && containsWrapperSideEffect(firstArgument(node))) report(context, node, "Rule: avoid Effect.zipRight for side effects. Why: it hides side effects and discards values. Fix: use explicit pipeline steps that return real values with Effect.flatMap, Effect.andThen, or Effect.tap.");
|
|
1432
|
-
} };
|
|
1433
|
-
} });
|
|
1434
|
-
const noEffectAllStepSequencing = defineRule({ create(context) {
|
|
1435
|
-
return { CallExpression(node) {
|
|
1436
|
-
if (isEffectMemberCallNamed(node, "all") && containsAllStepSideEffect(node.arguments[0]) && hasConcurrencyOne(node.arguments[1])) report(context, node, "Rule: avoid Effect.all for sequential side-effect steps. Why: it hides imperative sequencing in an array. Fix: use one explicit linear pipeline with Effect.andThen/flatMap and reserve Effect.all for real value aggregation.");
|
|
1437
|
-
if (isEffectAllAsVoidPipe(node) && containsAllStepSideEffect(firstArgument(node.callee.object))) report(context, node, "Rule: avoid Effect.all for sequential side-effect steps. Why: it hides imperative sequencing in an array. Fix: use one explicit linear pipeline with Effect.andThen/flatMap and reserve Effect.all for real value aggregation.");
|
|
1438
|
-
} };
|
|
1439
|
-
} });
|
|
1440
|
-
const noAsyncEffectCombinatorCallback = defineRule({ create(context) {
|
|
1441
|
-
let hasEffectEcosystemImport = false;
|
|
1442
|
-
return {
|
|
1443
|
-
ImportDeclaration(node) {
|
|
1444
|
-
const source = getImportSource(node);
|
|
1445
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1446
|
-
},
|
|
1447
|
-
CallExpression(node) {
|
|
1448
|
-
if (!hasEffectEcosystemImport) return;
|
|
1449
|
-
const callback = findAsyncEffectCombinatorCallback(node);
|
|
1450
|
-
if (callback) report(context, callback, "Rule: avoid async callbacks in Effect combinators. Why: async callbacks return Promises and bypass Effect failure, interruption, and tracing semantics. Fix: return an Effect and compose with Effect.flatMap/fromPromise at the boundary.");
|
|
1451
|
-
}
|
|
1452
|
-
};
|
|
1453
|
-
} });
|
|
1454
|
-
const noThrowInEffectLogic = defineRule({ create(context) {
|
|
1455
|
-
let hasEffectEcosystemImport = false;
|
|
1456
|
-
return {
|
|
1457
|
-
ImportDeclaration(node) {
|
|
1458
|
-
const source = getImportSource(node);
|
|
1459
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1460
|
-
},
|
|
1461
|
-
CallExpression(node) {
|
|
1462
|
-
if (!hasEffectEcosystemImport) return;
|
|
1463
|
-
const throwNode = findThrowInEffectLogic(node);
|
|
1464
|
-
if (throwNode) report(context, throwNode, "Rule: avoid throw inside Effect logic. Why: thrown exceptions bypass typed Effect error channels and interruption semantics. Fix: return Effect.fail with a structured tagged error.");
|
|
1465
|
-
}
|
|
1466
|
-
};
|
|
1467
|
-
} });
|
|
1468
|
-
const noOrDieOutsideBoundary = defineRule({ create(context) {
|
|
1469
|
-
let hasEffectEcosystemImport = false;
|
|
1470
|
-
return {
|
|
1471
|
-
ImportDeclaration(node) {
|
|
1472
|
-
const source = getImportSource(node);
|
|
1473
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1474
|
-
},
|
|
1475
|
-
CallExpression(node) {
|
|
1476
|
-
if (!hasEffectEcosystemImport) return;
|
|
1477
|
-
const target = findEffectOrDieOutsideBoundary(node);
|
|
1478
|
-
if (target) report(context, target, "Rule: avoid Effect.orDie outside runtime boundaries. Why: converting typed failures into defects hides recoverable domain errors. Fix: keep typed errors in domain logic and reserve orDie/orDieWith for explicit application boundaries.");
|
|
1479
|
-
}
|
|
1480
|
-
};
|
|
1481
|
-
} });
|
|
1482
|
-
const noSwallowedCatchAll = defineRule({ create(context) {
|
|
1483
|
-
let hasEffectEcosystemImport = false;
|
|
1484
|
-
return {
|
|
1485
|
-
ImportDeclaration(node) {
|
|
1486
|
-
const source = getImportSource(node);
|
|
1487
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1488
|
-
},
|
|
1489
|
-
CallExpression(node) {
|
|
1490
|
-
if (!hasEffectEcosystemImport) return;
|
|
1491
|
-
const handlerBody = getSwallowedCatchAllHandler(node);
|
|
1492
|
-
if (handlerBody) report(context, handlerBody, "Rule: avoid swallowing errors in catchAll. Why: succeed/void recovery can hide failures without telemetry or typed recovery. Fix: log, re-fail with a structured error, or recover through an explicit domain branch.");
|
|
1493
|
-
}
|
|
1494
|
-
};
|
|
1495
|
-
} });
|
|
1496
|
-
const noEffectIgnore = defineRule({ create(context) {
|
|
1497
|
-
let hasEffectEcosystemImport = false;
|
|
1498
|
-
return {
|
|
1499
|
-
ImportDeclaration(node) {
|
|
1500
|
-
const source = getImportSource(node);
|
|
1501
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1502
|
-
},
|
|
1503
|
-
CallExpression(node) {
|
|
1504
|
-
if (!hasEffectEcosystemImport) return;
|
|
1505
|
-
const target = findEffectIgnore(node);
|
|
1506
|
-
if (target) report(context, target, "Rule: avoid Effect.ignore. Why: ignoring failable effects hides failure ownership. Fix: handle the error with typed recovery, log and re-fail, or isolate the ignore at an explicit boundary with a documented reason.");
|
|
1507
|
-
}
|
|
1508
|
-
};
|
|
1509
|
-
} });
|
|
1510
|
-
const noTryCatchInEffectLogic = defineRule({ create(context) {
|
|
1511
|
-
let hasEffectEcosystemImport = false;
|
|
1512
|
-
return {
|
|
1513
|
-
ImportDeclaration(node) {
|
|
1514
|
-
const source = getImportSource(node);
|
|
1515
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1516
|
-
},
|
|
1517
|
-
CallExpression(node) {
|
|
1518
|
-
if (!hasEffectEcosystemImport) return;
|
|
1519
|
-
const tryNode = findTryCatchInEffectLogic(node);
|
|
1520
|
-
if (tryNode) report(context, tryNode, "Rule: avoid try/catch inside Effect logic. Why: it bypasses typed error channels and can miss interruption/cause semantics. Fix: use Effect.try, Effect.catchAll, Effect.catchTag, or typed error combinators.");
|
|
1521
|
-
}
|
|
1522
|
-
};
|
|
1523
|
-
} });
|
|
1524
|
-
const noPromiseApiInEffectLogic = defineRule({ create(context) {
|
|
1525
|
-
let hasEffectEcosystemImport = false;
|
|
1526
|
-
return {
|
|
1527
|
-
ImportDeclaration(node) {
|
|
1528
|
-
const source = getImportSource(node);
|
|
1529
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1530
|
-
},
|
|
1531
|
-
CallExpression(node) {
|
|
1532
|
-
if (!hasEffectEcosystemImport) return;
|
|
1533
|
-
const promiseNode = findPromiseApiInEffectLogic(node);
|
|
1534
|
-
if (promiseNode) report(context, promiseNode, "Rule: avoid Promise APIs inside Effect logic. Why: Promise APIs bypass Effect scheduling, typed errors, cancellation, and tracing. Fix: use Effect.all, Effect.tryPromise, or move Promise interop to a boundary adapter.");
|
|
1535
|
-
}
|
|
1536
|
-
};
|
|
1537
|
-
} });
|
|
1538
|
-
const noTryCatch = defineRule({ create(context) {
|
|
1539
|
-
return { TryStatement(node) {
|
|
1540
|
-
report(context, node, "Rule: avoid try/catch in Effect files. Why: it bypasses Effect error channels and reintroduces imperative control flow. Fix: model failures in Effect and handle them with typed errors and Effect combinators.");
|
|
1541
|
-
} };
|
|
1542
|
-
} });
|
|
1543
|
-
const noEffectWrapperAlias = defineRule({ create(context) {
|
|
1544
|
-
return {
|
|
1545
|
-
VariableDeclaration(node) {
|
|
1546
|
-
for (const declaration of node.declarations ?? []) if (isEffectWrapperAliasExpression(declaration.init)) report(context, node, "Rule: avoid Effect wrapper aliases (`const x = ...Effect...`). Why: it creates wrapper choreography and bloats consts. Fix: inline the pipeline at the call site or define a real domain function that returns data, not an Effect wrapper.");
|
|
1547
|
-
},
|
|
1548
|
-
FunctionDeclaration(node) {
|
|
1549
|
-
if (hasEffectWrapperAliasReturn(node.body)) report(context, node, "Rule: avoid Effect wrapper aliases (`function x(...) { return Effect... }`). Why: it creates wrapper choreography and bloats consts. Fix: inline the pipeline at the call site or define a real domain function that returns data, not an Effect wrapper.");
|
|
1550
|
-
}
|
|
1551
|
-
};
|
|
1552
|
-
} });
|
|
1553
|
-
const noManualEffectChannels = defineRule({ create(context) {
|
|
1554
|
-
return { TSTypeReference(node) {
|
|
1555
|
-
if (isQualifiedTypeReference(node, "Effect", "Effect") || isQualifiedTypeReference(node, "Layer", "Layer")) report(context, node, "Rule: avoid manual Effect channel tuples (`Effect.Effect<...>` / `Layer.Layer<...>`). Why: channels compose through the Effect pipeline and services; hand-written tuples desync from the real flow. Fix: drop the generic and let the return type infer from the Effect/Layer you return, or expose a service method that returns the effect directly.");
|
|
1556
|
-
} };
|
|
1557
|
-
} });
|
|
1558
|
-
const noWrapgraphqlCatchall = defineRule({ create(context) {
|
|
1559
|
-
let hasEffectEcosystemImport = false;
|
|
1560
|
-
return {
|
|
1561
|
-
ImportDeclaration(node) {
|
|
1562
|
-
const source = getImportSource(node);
|
|
1563
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1564
|
-
},
|
|
1565
|
-
CallExpression(node) {
|
|
1566
|
-
const catchAll = hasEffectEcosystemImport ? getWrapGraphqlCatchAll(node) : void 0;
|
|
1567
|
-
if (catchAll) report(context, catchAll, "Rule: avoid catchAll after wrapGraphqlCall/applyResponse. Why: the envelope already surfaces structured errors. Fix: handle errors in the response mapping instead of catchAll.");
|
|
1568
|
-
}
|
|
1569
|
-
};
|
|
1570
|
-
} });
|
|
1571
|
-
const noRenderSideEffects = defineRule({ create(context) {
|
|
1572
|
-
let hasEffectEcosystemImport = false;
|
|
1573
|
-
return {
|
|
1574
|
-
ImportDeclaration(node) {
|
|
1575
|
-
const source = getImportSource(node);
|
|
1576
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1577
|
-
},
|
|
1578
|
-
ExpressionStatement(node) {
|
|
1579
|
-
if (hasEffectEcosystemImport && isMatchValuePipeCall(node.expression) && containsMatchBranchCall(node.expression.arguments)) report(context, node.expression, "Rule: avoid Match.value(...).pipe(...) as a statement. Why: it runs side effects during render. Fix: move the side effect into an Effect runtime action or event handler, and keep Match as a pure expression.");
|
|
1580
|
-
}
|
|
1581
|
-
};
|
|
1582
|
-
} });
|
|
1583
|
-
const noAtomRegistryEffectSync = defineRule({ create(context) {
|
|
1584
|
-
let hasEffectEcosystemImport = false;
|
|
1585
|
-
return {
|
|
1586
|
-
ImportDeclaration(node) {
|
|
1587
|
-
const source = getImportSource(node);
|
|
1588
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1589
|
-
},
|
|
1590
|
-
CallExpression(node) {
|
|
1591
|
-
const atomOperation = hasEffectEcosystemImport ? findAtomOperationInsideEffectSync(node) : void 0;
|
|
1592
|
-
if (atomOperation) report(context, atomOperation, "Rule: do not wrap Atom/atomRegistry ops in Effect.sync. Why: it hides side effects and breaks atom flow. Fix: call Atom.get/Atom.set/Atom.update/Atom.modify/Atom.refresh directly.");
|
|
1593
|
-
}
|
|
1594
|
-
};
|
|
1595
|
-
} });
|
|
1596
|
-
const noFamilyCollectionRead = defineRule({ create(context) {
|
|
1597
|
-
return { CallExpression(node) {
|
|
1598
|
-
if (!isMemberCall(node, "Atom", "family")) return;
|
|
1599
|
-
const collectionAtom = findFamilyCollectionRead(node.arguments);
|
|
1600
|
-
if (collectionAtom) report(context, collectionAtom, "Keyed projection atom reads collection atom. Why: Atom.family should project from keyed/source atoms, not broad collection state. Fix: pass the keyed atom into the family or create a keyed source atom before reading.");
|
|
1601
|
-
} };
|
|
1602
|
-
} });
|
|
1603
|
-
const noInlineRuntimeProvide = defineRule({ create(context) {
|
|
1604
|
-
let hasEffectEcosystemImport = false;
|
|
1605
|
-
return {
|
|
1606
|
-
ImportDeclaration(node) {
|
|
1607
|
-
const source = getImportSource(node);
|
|
1608
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1609
|
-
},
|
|
1610
|
-
CallExpression(node) {
|
|
1611
|
-
const provide = hasEffectEcosystemImport ? findInlineRuntimeProvide(node) : void 0;
|
|
1612
|
-
if (provide) report(context, provide, "Rule: do not inline runtime provisioning inside local helper Effect code. Why: `yield* SomeRuntime.pipe(Effect.provide(SomeRuntimeLive))` and equivalent inline provide chains hide dependency assembly instead of owning it at an Effect.Service boundary or one exported Effect boundary. Fix: declare the live dependency on the owning service or provide it once at the exported boundary, then `yield*` the runtime or service directly inside the body.");
|
|
1613
|
-
}
|
|
1614
|
-
};
|
|
1615
|
-
} });
|
|
1616
|
-
const noNakedObjectStateUpdate = defineRule({ create(context) {
|
|
1617
|
-
return { CallExpression(node) {
|
|
1618
|
-
if (isNakedObjectStateUpdate(node)) report(context, node, "Rule: avoid naked JS state patching/rebuild and raw JSON shortcuts in Effect transitions. Why: spread/Object.assign/fromEntries and inline JSON parse/stringify hide state intent and bypass explicit model contracts. Fix: use `effect/Record` combinators (`Record.set` / `Record.modify` / `Record.remove`) inside `Struct.evolve`, rebuild with schema constructors (`Schema.make` or field `.make`), and keep serialization at boundaries with schema encode/decode flows. Use `linting.md` guidance when available.");
|
|
1619
|
-
} };
|
|
1620
|
-
} });
|
|
1621
|
-
const noEffectSucceedVariable = defineRule({ create(context) {
|
|
1622
|
-
let hasEffectEcosystemImport = false;
|
|
1623
|
-
return {
|
|
1624
|
-
ImportDeclaration(node) {
|
|
1625
|
-
const source = getImportSource(node);
|
|
1626
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1627
|
-
},
|
|
1628
|
-
CallExpression(node) {
|
|
1629
|
-
if (hasEffectEcosystemImport && isEffectMemberCallNamed(node, "succeed") && isEffectSucceedVariableArgument(firstArgument(node))) report(context, node, "Rule: avoid Effect.succeed(variable) as a branch placeholder. Why: it hides a decision and turns data into pseudo-control flow. Fix: select a plain value (Option/Match) and then run one Effect pipeline after the decision; if you already read the state, return it as a value. Avoid Option.toArray/forEach hacks that just re-encode the branch.");
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1632
|
-
} });
|
|
1633
|
-
const noEffectTypeAlias = defineRule({ create(context) {
|
|
1634
|
-
let hasEffectEcosystemImport = false;
|
|
1635
|
-
return {
|
|
1636
|
-
ImportDeclaration(node) {
|
|
1637
|
-
const source = getImportSource(node);
|
|
1638
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1639
|
-
},
|
|
1640
|
-
TSTypeAliasDeclaration(node) {
|
|
1641
|
-
if (hasEffectEcosystemImport && containsQualifiedTypeReference(node.typeAnnotation, "Effect", "Effect")) report(context, node.typeAnnotation, "Rule: avoid Effect.Effect type aliases. Why: they hide the service surface and make types opaque. Fix: keep Effect types on service methods or inline at the call site.");
|
|
1642
|
-
}
|
|
1643
|
-
};
|
|
1644
|
-
} });
|
|
1645
|
-
const noPublicGenericEffectError = defineRule({ create(context) {
|
|
1646
|
-
let hasEffectEcosystemImport = false;
|
|
1647
|
-
return {
|
|
1648
|
-
ImportDeclaration(node) {
|
|
1649
|
-
const source = getImportSource(node);
|
|
1650
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1651
|
-
},
|
|
1652
|
-
ExportNamedDeclaration(node) {
|
|
1653
|
-
const target = hasEffectEcosystemImport ? exportedGenericEffectErrorTarget(node) : void 0;
|
|
1654
|
-
if (target) report(context, target, "Rule: avoid public Effect APIs with generic Error. Why: public services need recoverable, typed error contracts. Fix: expose tagged domain errors instead of Error.");
|
|
1655
|
-
},
|
|
1656
|
-
ExportDefaultDeclaration(node) {
|
|
1657
|
-
const target = hasEffectEcosystemImport ? exportedGenericEffectErrorTarget(node) : void 0;
|
|
1658
|
-
if (target) report(context, target, "Rule: avoid public Effect APIs with generic Error. Why: public services need recoverable, typed error contracts. Fix: expose tagged domain errors instead of Error.");
|
|
1659
|
-
}
|
|
1660
|
-
};
|
|
1661
|
-
} });
|
|
1662
|
-
const noModelOverlayCast = defineRule({ create(context) {
|
|
1663
|
-
let hasEffectEcosystemImport = false;
|
|
1664
|
-
return {
|
|
1665
|
-
ImportDeclaration(node) {
|
|
1666
|
-
const source = getImportSource(node);
|
|
1667
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1668
|
-
},
|
|
1669
|
-
VariableDeclaration(node) {
|
|
1670
|
-
if (hasEffectEcosystemImport && isVariableAsAssertion(node)) report(context, node, "Rule: avoid `as` assertions on decoded model flow. Why: assertions hide schema drift and allow untyped overlays. Fix: decode with the correct schema type and read fields directly.");
|
|
1671
|
-
}
|
|
1672
|
-
};
|
|
1673
|
-
} });
|
|
1674
|
-
const noUnknownBooleanCoercionHelper = defineRule({ create(context) {
|
|
1675
|
-
let hasEffectEcosystemImport = false;
|
|
1676
|
-
let hasMatchOrElseNull = false;
|
|
1677
|
-
const booleanChecks = [];
|
|
1678
|
-
const reported = /* @__PURE__ */ new WeakSet();
|
|
1679
|
-
const reportBooleanCheck = (node) => {
|
|
1680
|
-
if (typeof node !== "object" || node === null || reported.has(node)) return;
|
|
1681
|
-
reported.add(node);
|
|
1682
|
-
report(context, node, "Rule: avoid local unknown-to-boolean coercion helpers in services. Why: runtime coercion belongs at schema boundary, not in service flow. Fix: decode boolean optionality in schema and read typed booleans in the Effect pipeline.");
|
|
1683
|
-
};
|
|
1684
|
-
return {
|
|
1685
|
-
ImportDeclaration(node) {
|
|
1686
|
-
const source = getImportSource(node);
|
|
1687
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1688
|
-
},
|
|
1689
|
-
BinaryExpression(node) {
|
|
1690
|
-
if (!hasEffectEcosystemImport || !isTypeofBooleanCheck(node)) return;
|
|
1691
|
-
if (hasMatchOrElseNull) reportBooleanCheck(node);
|
|
1692
|
-
else booleanChecks.push(node);
|
|
1693
|
-
},
|
|
1694
|
-
CallExpression(node) {
|
|
1695
|
-
if (!hasEffectEcosystemImport || !isMatchOrElseNullCall(node)) return;
|
|
1696
|
-
hasMatchOrElseNull = true;
|
|
1697
|
-
for (const check of booleanChecks) reportBooleanCheck(check);
|
|
1698
|
-
}
|
|
1699
|
-
};
|
|
1700
|
-
} });
|
|
1701
|
-
const noFromnullableNullishCoalesce = defineRule({ create(context) {
|
|
1702
|
-
let hasEffectEcosystemImport = false;
|
|
1703
|
-
return {
|
|
1704
|
-
ImportDeclaration(node) {
|
|
1705
|
-
const source = getImportSource(node);
|
|
1706
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1707
|
-
},
|
|
1708
|
-
CallExpression(node) {
|
|
1709
|
-
if (hasEffectEcosystemImport && isOptionFromNullableNullishCoalesce(node)) report(context, node, "Rule: avoid nullish re-wrap inside Option.fromNullable. Why: `x ?? null` and `x ?? undefined` add noise and hide source shape. Fix: pass the source directly to Option.fromNullable.");
|
|
1710
|
-
}
|
|
1711
|
-
};
|
|
1712
|
-
} });
|
|
1713
|
-
const noOptionBooleanNormalization = defineRule({ create(context) {
|
|
1714
|
-
let hasEffectEcosystemImport = false;
|
|
1715
|
-
return {
|
|
1716
|
-
ImportDeclaration(node) {
|
|
1717
|
-
const source = getImportSource(node);
|
|
1718
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1719
|
-
},
|
|
1720
|
-
CallExpression(node) {
|
|
1721
|
-
if (hasEffectEcosystemImport && isOptionBooleanNormalization(node)) report(context, node, "Rule: avoid repeated Option boolean normalization (`onSome: value === true, onNone: false`). Why: it scatters coercion rules across services. Fix: normalize once at schema boundary and read booleans directly.");
|
|
1722
|
-
}
|
|
1723
|
-
};
|
|
1724
|
-
} });
|
|
1725
|
-
const noStringSentinelReturn = defineRule({ create(context) {
|
|
1726
|
-
return { CallExpression(node) {
|
|
1727
|
-
if (isEffectMemberCallNamed(node, "succeed") && isStringLiteral(firstArgument(node))) report(context, node, "Rule: avoid returning string tokens. Why: it encodes control flow and forces defensive branching. Fix: return domain values (Option/Either/tagged unions) or real Effect results instead.");
|
|
1728
|
-
} };
|
|
1729
|
-
} });
|
|
1730
|
-
const noStringSentinelConst = defineRule({ create(context) {
|
|
1731
|
-
return { VariableDeclaration(node) {
|
|
1732
|
-
if (isStringSentinelConst(node)) report(context, node, "Rule: avoid string status constants. Why: they encode control flow and force defensive branching. Fix: use tagged unions, Option/Either, or meaningful domain values instead of string tokens.");
|
|
1733
|
-
} };
|
|
1734
|
-
} });
|
|
1735
|
-
const noRawDomainIdAlias = defineRule({ create(context) {
|
|
1736
|
-
let hasEffectEcosystemImport = false;
|
|
1737
|
-
return {
|
|
1738
|
-
ImportDeclaration(node) {
|
|
1739
|
-
const source = getImportSource(node);
|
|
1740
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1741
|
-
},
|
|
1742
|
-
TSTypeAliasDeclaration(node) {
|
|
1743
|
-
if (hasEffectEcosystemImport && isRawDomainIdAlias(node)) report(context, node, "Rule: avoid raw primitive domain ID aliases. Why: `type UserId = string` does not protect boundaries from swapped IDs. Fix: use Schema branded IDs or a domain constructor that validates and brands the value.");
|
|
1744
|
-
}
|
|
1745
|
-
};
|
|
1746
|
-
} });
|
|
1747
|
-
const noBooleanDomainFlag = defineRule({ create(context) {
|
|
1748
|
-
let hasEffectEcosystemImport = false;
|
|
1749
|
-
const checkFunctionParameters = (node) => {
|
|
1750
|
-
if (!hasEffectEcosystemImport) return;
|
|
1751
|
-
for (const param of functionBooleanDomainFlagParameters(node)) report(context, param, "Rule: avoid boolean behavior flags in domain operations. Why: flags like `shouldNotify` hide use cases and create implicit branching. Fix: model intent with a command/tagged union or split the operation into explicit functions.");
|
|
1752
|
-
};
|
|
1753
|
-
return {
|
|
1754
|
-
ImportDeclaration(node) {
|
|
1755
|
-
const source = getImportSource(node);
|
|
1756
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1757
|
-
},
|
|
1758
|
-
FunctionDeclaration: checkFunctionParameters,
|
|
1759
|
-
FunctionExpression: checkFunctionParameters,
|
|
1760
|
-
ArrowFunctionExpression: checkFunctionParameters
|
|
1761
|
-
};
|
|
1762
|
-
} });
|
|
1763
|
-
const noMagicDomainString = defineRule({ create(context) {
|
|
1764
|
-
let hasEffectEcosystemImport = false;
|
|
1765
|
-
return {
|
|
1766
|
-
ImportDeclaration(node) {
|
|
1767
|
-
const source = getImportSource(node);
|
|
1768
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1769
|
-
},
|
|
1770
|
-
BinaryExpression(node) {
|
|
1771
|
-
if (hasEffectEcosystemImport && isStringLiteralComparison(node)) report(context, node, "Rule: avoid magic domain string comparisons. Why: comparing domain state to raw strings scatters status vocabulary and misses exhaustiveness. Fix: use a tagged union, Schema literal union, or Match over a named domain status.");
|
|
1772
|
-
}
|
|
1773
|
-
};
|
|
1774
|
-
} });
|
|
1775
|
-
const noRawDomainPrimitiveParams = defineRule({ create(context) {
|
|
1776
|
-
let hasEffectEcosystemImport = false;
|
|
1777
|
-
const checkFunction = (node) => {
|
|
1778
|
-
if (hasEffectEcosystemImport && hasPrimitiveHeavyDomainParameters(node)) report(context, node, "Rule: avoid primitive-heavy domain parameters. Why: clusters of raw string/number domain values are easy to swap and have no invariant boundary. Fix: introduce branded types or a command/schema object with named validated fields.");
|
|
1779
|
-
};
|
|
1780
|
-
return {
|
|
1781
|
-
ImportDeclaration(node) {
|
|
1782
|
-
const source = getImportSource(node);
|
|
1783
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1784
|
-
},
|
|
1785
|
-
FunctionDeclaration: checkFunction,
|
|
1786
|
-
FunctionExpression: checkFunction,
|
|
1787
|
-
ArrowFunctionExpression: checkFunction
|
|
1788
|
-
};
|
|
1789
|
-
} });
|
|
1790
|
-
const noRawTimeDomainField = defineRule({ create(context) {
|
|
1791
|
-
let hasEffectEcosystemImport = false;
|
|
1792
|
-
const checkTypeMembers = (node) => {
|
|
1793
|
-
if (!hasEffectEcosystemImport) return;
|
|
1794
|
-
for (const field of rawTimeDomainFields(node)) report(context, field, "Rule: avoid raw time fields in domain models. Why: number and Date fields hide units, clock ownership, and duration semantics. Fix: model durations with Effect Duration and keep raw timestamps at decode/encode boundaries.");
|
|
1795
|
-
};
|
|
1796
|
-
return {
|
|
1797
|
-
ImportDeclaration(node) {
|
|
1798
|
-
const source = getImportSource(node);
|
|
1799
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1800
|
-
},
|
|
1801
|
-
TSInterfaceDeclaration: checkTypeMembers,
|
|
1802
|
-
TSTypeLiteral: checkTypeMembers
|
|
1803
|
-
};
|
|
1804
|
-
} });
|
|
1805
|
-
const noOverloadedOptionsObject = defineRule({ create(context) {
|
|
1806
|
-
let hasEffectEcosystemImport = false;
|
|
1807
|
-
const checkFunctionParameters = (node) => {
|
|
1808
|
-
if (!hasEffectEcosystemImport) return;
|
|
1809
|
-
for (const param of overloadedOptionsParameters(node)) report(context, param, "Rule: avoid overloaded options objects. Why: `opts`, `options`, and `config` typed as any/object hide required fields and validation. Fix: accept unknown at the boundary and decode with Schema, or use a named typed command/config model.");
|
|
1810
|
-
};
|
|
1811
|
-
return {
|
|
1812
|
-
ImportDeclaration(node) {
|
|
1813
|
-
const source = getImportSource(node);
|
|
1814
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1815
|
-
},
|
|
1816
|
-
FunctionDeclaration: checkFunctionParameters,
|
|
1817
|
-
FunctionExpression: checkFunctionParameters,
|
|
1818
|
-
ArrowFunctionExpression: checkFunctionParameters
|
|
1819
|
-
};
|
|
1820
|
-
} });
|
|
1821
|
-
const noDomainLogicInConditional = defineRule({ create(context) {
|
|
1822
|
-
let hasEffectEcosystemImport = false;
|
|
1823
|
-
return {
|
|
1824
|
-
ImportDeclaration(node) {
|
|
1825
|
-
const source = getImportSource(node);
|
|
1826
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1827
|
-
},
|
|
1828
|
-
LogicalExpression(node) {
|
|
1829
|
-
if (hasEffectEcosystemImport && isDomainLogicConditional(node)) report(context, node, "Rule: avoid embedding domain logic in conditionals. Why: multi-clause business rules become hard to test, reuse, and audit. Fix: extract a named domain predicate or validation Effect and call that from the branch.");
|
|
1830
|
-
}
|
|
1831
|
-
};
|
|
1832
|
-
} });
|
|
1833
|
-
const noImplicitStateMachineObject = defineRule({ create(context) {
|
|
1834
|
-
let hasEffectEcosystemImport = false;
|
|
1835
|
-
return {
|
|
1836
|
-
ImportDeclaration(node) {
|
|
1837
|
-
const source = getImportSource(node);
|
|
1838
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1839
|
-
},
|
|
1840
|
-
LogicalExpression(node) {
|
|
1841
|
-
if (hasEffectEcosystemImport && isImplicitStateMachineObject(node)) report(context, node, "Rule: avoid implicit state machines made from boolean flags. Why: multiple flags on one domain object allow impossible states. Fix: model the lifecycle as a tagged union or Data.TaggedEnum.");
|
|
1842
|
-
}
|
|
1843
|
-
};
|
|
1844
|
-
} });
|
|
1845
|
-
const noAdhocDomainError = defineRule({ create(context) {
|
|
1846
|
-
let hasEffectEcosystemImport = false;
|
|
1847
|
-
return {
|
|
1848
|
-
ImportDeclaration(node) {
|
|
1849
|
-
const source = getImportSource(node);
|
|
1850
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1851
|
-
},
|
|
1852
|
-
CallExpression(node) {
|
|
1853
|
-
if (hasEffectEcosystemImport && isAdhocEffectFail(node)) report(context, node, "Rule: avoid ad hoc domain errors. Why: string failures hide recovery semantics and observability. Fix: use Data.TaggedError or a structured domain error union.");
|
|
1854
|
-
},
|
|
1855
|
-
ThrowStatement(node) {
|
|
1856
|
-
if (hasEffectEcosystemImport && isThrowNewStringError(node)) report(context, node, "Rule: avoid ad hoc domain errors. Why: thrown string Error values bypass typed Effect error channels. Fix: return Effect.fail with a structured tagged domain error.");
|
|
1857
|
-
}
|
|
1858
|
-
};
|
|
1859
|
-
} });
|
|
1860
|
-
const noDomainMeaningByFolderOnly = defineRule({ create(context) {
|
|
1861
|
-
let hasEffectEcosystemImport = false;
|
|
1862
|
-
return {
|
|
1863
|
-
ImportDeclaration(node) {
|
|
1864
|
-
const source = getImportSource(node);
|
|
1865
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1866
|
-
},
|
|
1867
|
-
FunctionDeclaration(node) {
|
|
1868
|
-
if (hasEffectEcosystemImport && isContextEncodedDomainFunction(node)) report(context, node, "Rule: avoid domain meaning by folder or context naming alone. Why: admin/public/internal meaning should be represented in types or services, not inferred from helper names. Fix: encode context with branded IDs, commands, policies, or service boundaries.");
|
|
1869
|
-
}
|
|
1870
|
-
};
|
|
1871
|
-
} });
|
|
1872
|
-
const noEffectAs = defineRule({ create(context) {
|
|
1873
|
-
return { CallExpression(node) {
|
|
1874
|
-
if (isMemberExpression(node.callee, "Effect", "as")) report(context, node.callee, "Rule: avoid Effect.as wrappers. Why: they can hide meaningful sequencing or value flow. Fix: return the intended value directly or use explicit Effect.map/andThen.");
|
|
1875
|
-
} };
|
|
1876
|
-
} });
|
|
1877
|
-
const noEffectDo = defineRule({ create(context) {
|
|
1878
|
-
return { MemberExpression(node) {
|
|
1879
|
-
if (isMemberExpression(node, "Effect", "Do")) report(context, node, "Rule: avoid Effect.Do. Why: it hides sequencing behind builder state. Fix: use Effect.gen or a direct pipe.");
|
|
1880
|
-
} };
|
|
1881
|
-
} });
|
|
1882
|
-
function createForbiddenMemberCallRule(objectName, propertyName, message) {
|
|
1883
|
-
return defineRule({ create(context) {
|
|
1884
|
-
return { CallExpression(node) {
|
|
1885
|
-
if (isMemberExpression(node.callee, objectName, propertyName)) report(context, node.callee, message);
|
|
1886
|
-
} };
|
|
1887
|
-
} });
|
|
1888
|
-
}
|
|
1889
|
-
const noEffectBind = createForbiddenMemberCallRule("Effect", "bind", "Rule: avoid Effect.bind. Why: it obscures linear data flow behind builder-style binding. Fix: use Effect.gen or a direct pipe with flatMap/map.");
|
|
1890
|
-
const noRuntimeRunFork = createForbiddenMemberCallRule("Runtime", "runFork", "Rule: avoid Runtime.runFork. Why: detached fibers hide lifetime and interruption ownership. Fix: run effects through the application runtime boundary.");
|
|
1891
|
-
const noRunEffectOutsideBoundary = defineRule({ create(context) {
|
|
1892
|
-
let hasEffectEcosystemImport = false;
|
|
1893
|
-
return {
|
|
1894
|
-
ImportDeclaration(node) {
|
|
1895
|
-
const source = getImportSource(node);
|
|
1896
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1897
|
-
},
|
|
1898
|
-
CallExpression(node) {
|
|
1899
|
-
if (hasEffectEcosystemImport && isEffectRunCall(node)) report(context, node.callee, "Rule: avoid running Effects outside runtime boundaries. Why: direct Effect.run* calls scatter execution ownership. Fix: return Effects from domain logic and run them at the app, CLI, worker, route, or test boundary.");
|
|
1900
|
-
}
|
|
1901
|
-
};
|
|
1902
|
-
} });
|
|
1903
|
-
const noEffectAsync = createForbiddenMemberCallRule("Effect", "async", "Rule: avoid Effect.async. Why: manual callback bridges are easy to leak or resume incorrectly. Fix: use scoped Effect APIs or a dedicated platform adapter.");
|
|
1904
|
-
const noNestedEffectCall = defineRule({ create(context) {
|
|
1905
|
-
return { CallExpression(node) {
|
|
1906
|
-
if (hasDeepNestedEffectFirstArgument(node)) report(context, node, "Rule: avoid deeply nested Effect calls (Effect.xx(Effect.yy(Effect.zz(...)))). Why: they hide sequencing and spread flow. Fix: build values first, then run one flat Effect pipeline.");
|
|
1907
|
-
} };
|
|
1908
|
-
} });
|
|
1909
|
-
const noEffectLadder = defineRule({ create(context) {
|
|
1910
|
-
return {
|
|
1911
|
-
VariableDeclaration(node) {
|
|
1912
|
-
for (const declaration of node.declarations ?? []) if (hasDeepNestedEffectFirstArgument(declaration.init)) report(context, declaration.init, "Rule: avoid nested Effect combinators. Why: they hide sequencing and create laddered control flow. Fix: build context once (Effect.all/Effect.map) and then run a single flat pipeline.");
|
|
1913
|
-
},
|
|
1914
|
-
ReturnStatement(node) {
|
|
1915
|
-
if (hasDeepNestedEffectFirstArgument(node.argument)) report(context, node.argument, "Rule: avoid nested Effect combinators. Why: they hide sequencing and create laddered control flow. Fix: build context once (Effect.all/Effect.map) and then run a single flat pipeline.");
|
|
1916
|
-
}
|
|
1917
|
-
};
|
|
1918
|
-
} });
|
|
1919
|
-
const noFlatMapLadder = defineRule({ create(context) {
|
|
1920
|
-
return {
|
|
1921
|
-
VariableDeclaration(node) {
|
|
1922
|
-
for (const declaration of node.declarations ?? []) {
|
|
1923
|
-
const message = getFlatMapLadderMessage(declaration.init);
|
|
1924
|
-
if (message) report(context, declaration.init, message);
|
|
1925
|
-
}
|
|
1926
|
-
},
|
|
1927
|
-
ReturnStatement(node) {
|
|
1928
|
-
const message = getFlatMapLadderMessage(node.argument);
|
|
1929
|
-
if (message) report(context, node.argument, message);
|
|
1930
|
-
}
|
|
1931
|
-
};
|
|
1932
|
-
} });
|
|
1933
|
-
const noPipeLadder = defineRule({ create(context) {
|
|
1934
|
-
return { CallExpression(node) {
|
|
1935
|
-
if (isPipeCall(node) && containsPipeCall(node.arguments)) report(context, node, "Rule: avoid nested pipe() chains. Why: they hide sequencing. Fix: refactor into one flat pipeline with a single decision point.");
|
|
1936
|
-
} };
|
|
1937
|
-
} });
|
|
1938
|
-
const noCallTower = defineRule({ create(context) {
|
|
1939
|
-
return { CallExpression(node) {
|
|
1940
|
-
if (hasNestedEffectCallArgument(node)) report(context, node, "Rule: avoid nested Effect call towers (Effect.fn(Effect.fn(...))). Why: it hides sequencing. Fix: build the inner Effect first, then use pipe/Effect.flatMap/Effect.andThen for a single flat pipeline.");
|
|
1941
|
-
} };
|
|
1942
|
-
} });
|
|
1943
|
-
const noEffectOrElseLadder = defineRule({ create(context) {
|
|
1944
|
-
return { CallExpression(node) {
|
|
1945
|
-
if (hasOrElseSequencingFirstArgument(node)) report(context, node, "Rule: avoid Effect.orElse around sequencing chains. Why: it hides error handling and splits the flow. Fix: move error handling to a single terminal decision after the pipeline.");
|
|
1946
|
-
} };
|
|
1947
|
-
} });
|
|
1948
|
-
const noUnboundedEffectAll = defineRule({ create(context) {
|
|
1949
|
-
let hasEffectEcosystemImport = false;
|
|
1950
|
-
return {
|
|
1951
|
-
ImportDeclaration(node) {
|
|
1952
|
-
const source = getImportSource(node);
|
|
1953
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1954
|
-
},
|
|
1955
|
-
CallExpression(node) {
|
|
1956
|
-
if (hasEffectEcosystemImport && isUnboundedMappedEffectAll(node)) report(context, node, "Rule: avoid unbounded Effect.all over mapped collections. Why: it can launch work for every item at once and fail under load. Fix: pass an explicit `{ concurrency: n }` option or use a bounded batching strategy.");
|
|
1957
|
-
}
|
|
1958
|
-
};
|
|
1959
|
-
} });
|
|
1960
|
-
const noFireAndForgetFork = defineRule({ create(context) {
|
|
1961
|
-
let hasEffectEcosystemImport = false;
|
|
1962
|
-
return {
|
|
1963
|
-
ImportDeclaration(node) {
|
|
1964
|
-
const source = getImportSource(node);
|
|
1965
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1966
|
-
},
|
|
1967
|
-
ExpressionStatement(node) {
|
|
1968
|
-
if (hasEffectEcosystemImport && isEffectMemberCallNamed(node.expression, "fork")) report(context, node.expression, "Rule: avoid fire-and-forget Effect.fork. Why: detached fibers hide failure, interruption, and ownership. Fix: bind the fiber and join/await/interrupt it, or use Effect.forkScoped / Effect.forkIn with an explicit scope.");
|
|
1969
|
-
}
|
|
1970
|
-
};
|
|
1971
|
-
} });
|
|
1972
|
-
const noForkInLoop = defineRule({ create(context) {
|
|
1973
|
-
let hasEffectEcosystemImport = false;
|
|
1974
|
-
const checkLoop = (node) => {
|
|
1975
|
-
if (!hasEffectEcosystemImport) return;
|
|
1976
|
-
const fork = containsEffectForkCall(node.body);
|
|
1977
|
-
if (fork) report(context, fork, "Rule: avoid Effect.fork inside loops. Why: loop-spawned fibers create unbounded concurrency and unclear ownership. Fix: use Effect.forEach / Effect.all with an explicit concurrency limit or a scoped supervisor.");
|
|
1978
|
-
};
|
|
1979
|
-
return {
|
|
1980
|
-
ImportDeclaration(node) {
|
|
1981
|
-
const source = getImportSource(node);
|
|
1982
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1983
|
-
},
|
|
1984
|
-
ForStatement: checkLoop,
|
|
1985
|
-
ForInStatement: checkLoop,
|
|
1986
|
-
ForOfStatement: checkLoop,
|
|
1987
|
-
WhileStatement: checkLoop,
|
|
1988
|
-
DoWhileStatement: checkLoop
|
|
1989
|
-
};
|
|
1990
|
-
} });
|
|
1991
|
-
const noRaceWithoutCleanup = defineRule({ create(context) {
|
|
1992
|
-
let hasEffectEcosystemImport = false;
|
|
1993
|
-
return {
|
|
1994
|
-
ImportDeclaration(node) {
|
|
1995
|
-
const source = getImportSource(node);
|
|
1996
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1997
|
-
},
|
|
1998
|
-
CallExpression(node) {
|
|
1999
|
-
if (hasEffectEcosystemImport && isEffectRaceWithoutCleanup(node)) report(context, node, "Rule: avoid Effect.race without loser cleanup. Why: racing effects without ensuring/scoped cleanup can leak losing work or resources. Fix: wrap raced effects with Effect.ensuring/acquireRelease or use a scoped race boundary.");
|
|
2000
|
-
}
|
|
2001
|
-
};
|
|
2002
|
-
} });
|
|
2003
|
-
const noUnobservedFiber = defineRule({ create(context) {
|
|
2004
|
-
let hasEffectEcosystemImport = false;
|
|
2005
|
-
const forkedFibers = /* @__PURE__ */ new Map();
|
|
2006
|
-
const observedFibers = /* @__PURE__ */ new Set();
|
|
2007
|
-
return {
|
|
2008
|
-
ImportDeclaration(node) {
|
|
2009
|
-
const source = getImportSource(node);
|
|
2010
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
2011
|
-
},
|
|
2012
|
-
VariableDeclarator(node) {
|
|
2013
|
-
const name = forkedFiberVariableName(node);
|
|
2014
|
-
if (name) forkedFibers.set(name, node);
|
|
2015
|
-
},
|
|
2016
|
-
CallExpression(node) {
|
|
2017
|
-
const name = observedFiberVariableName(node);
|
|
2018
|
-
if (name) observedFibers.add(name);
|
|
2019
|
-
},
|
|
2020
|
-
"Program:exit"() {
|
|
2021
|
-
if (!hasEffectEcosystemImport) return;
|
|
2022
|
-
for (const [name, node] of forkedFibers) if (!observedFibers.has(name)) report(context, node, "Rule: avoid unobserved forked fibers. Why: forked fiber failures and interruption should be observed. Fix: pass the fiber to Fiber.join, Fiber.await, Fiber.interrupt, or use scoped fork APIs.");
|
|
2023
|
-
}
|
|
2024
|
-
};
|
|
2025
|
-
} });
|
|
2026
|
-
const noUnboundedConcurrentRetry = defineRule({ create(context) {
|
|
2027
|
-
let hasEffectEcosystemImport = false;
|
|
2028
|
-
return {
|
|
2029
|
-
ImportDeclaration(node) {
|
|
2030
|
-
const source = getImportSource(node);
|
|
2031
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
2032
|
-
},
|
|
2033
|
-
CallExpression(node) {
|
|
2034
|
-
if (hasEffectEcosystemImport && isUnboundedConcurrentRetry(node)) report(context, node, "Rule: avoid unbounded concurrent retry. Why: retry inside unbounded parallel collection effects can amplify load and create retry storms. Fix: add an explicit concurrency limit or move retry behind a bounded queue/backoff policy.");
|
|
2035
|
-
}
|
|
2036
|
-
};
|
|
2037
|
-
} });
|
|
2038
|
-
const noBlockingCallInEffect = defineRule({ create(context) {
|
|
2039
|
-
let hasEffectEcosystemImport = false;
|
|
2040
|
-
return {
|
|
2041
|
-
ImportDeclaration(node) {
|
|
2042
|
-
const source = getImportSource(node);
|
|
2043
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
2044
|
-
},
|
|
2045
|
-
CallExpression(node) {
|
|
2046
|
-
if (!hasEffectEcosystemImport) return;
|
|
2047
|
-
const blockingNode = findBlockingSyncCallInEffectLogic(node);
|
|
2048
|
-
if (blockingNode) report(context, blockingNode, "Rule: avoid blocking sync calls inside Effect logic. Why: sync fs/crypto/zlib calls block the runtime worker and hide throughput costs. Fix: use Effect.async/tryPromise at a platform boundary, stream APIs, or a dedicated blocking executor.");
|
|
2049
|
-
}
|
|
2050
|
-
};
|
|
2051
|
-
} });
|
|
2052
|
-
const noPromiseConcurrencyInEffect = defineRule({ create(context) {
|
|
2053
|
-
let hasEffectEcosystemImport = false;
|
|
2054
|
-
return {
|
|
2055
|
-
ImportDeclaration(node) {
|
|
2056
|
-
const source = getImportSource(node);
|
|
2057
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
2058
|
-
},
|
|
2059
|
-
CallExpression(node) {
|
|
2060
|
-
if (!hasEffectEcosystemImport) return;
|
|
2061
|
-
const promiseNode = findPromiseConcurrencyInEffectLogic(node);
|
|
2062
|
-
if (promiseNode) report(context, promiseNode, "Rule: avoid Promise concurrency APIs inside Effect logic. Why: Promise.all/allSettled/race/any bypass Effect concurrency, interruption, tracing, and error channels. Fix: use Effect.all, Effect.forEach, Effect.race, or a boundary adapter with explicit cancellation ownership.");
|
|
2063
|
-
}
|
|
2064
|
-
};
|
|
2065
|
-
} });
|
|
2066
|
-
const noSharedMutableStateAcrossFibers = defineRule({ create(context) {
|
|
2067
|
-
let hasEffectEcosystemImport = false;
|
|
2068
|
-
const mutableNames = /* @__PURE__ */ new Set();
|
|
2069
|
-
return {
|
|
2070
|
-
ImportDeclaration(node) {
|
|
2071
|
-
const source = getImportSource(node);
|
|
2072
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
2073
|
-
},
|
|
2074
|
-
VariableDeclaration(node) {
|
|
2075
|
-
if (node.kind !== "let" && node.kind !== "var") return;
|
|
2076
|
-
for (const name of variableDeclarationIdentifierNames(node)) mutableNames.add(name);
|
|
2077
|
-
},
|
|
2078
|
-
CallExpression(node) {
|
|
2079
|
-
if (!hasEffectEcosystemImport) return;
|
|
2080
|
-
const workNode = concurrentEffectWorkNode(node);
|
|
2081
|
-
if (!workNode) return;
|
|
2082
|
-
const mutationNode = findSharedMutableStateMutation(workNode, mutableNames);
|
|
2083
|
-
if (mutationNode) report(context, mutationNode, "Rule: avoid mutating shared state across fibers. Why: outer let/var state mutated from forked or parallel work creates nondeterministic races. Fix: model shared state with Ref/SynchronizedRef/Queue or aggregate immutable results with bounded Effect.all/forEach.");
|
|
2084
|
-
}
|
|
2085
|
-
};
|
|
2086
|
-
} });
|
|
2087
|
-
const noTimeoutWithNoninterruptiblePromise = defineRule({ create(context) {
|
|
2088
|
-
let hasEffectEcosystemImport = false;
|
|
2089
|
-
return {
|
|
2090
|
-
ImportDeclaration(node) {
|
|
2091
|
-
const source = getImportSource(node);
|
|
2092
|
-
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
2093
|
-
},
|
|
2094
|
-
CallExpression(node) {
|
|
2095
|
-
if (!hasEffectEcosystemImport) return;
|
|
2096
|
-
const promiseNode = noninterruptiblePromiseTimeoutNode(node);
|
|
2097
|
-
if (promiseNode) report(context, promiseNode, "Rule: avoid timeout around noninterruptible Promise effects. Why: timing out Effect.promise or tryPromise without a signal leaves the underlying Promise running after interruption. Fix: use Effect.tryPromise with an AbortSignal parameter and pass it to the async API.");
|
|
2098
|
-
}
|
|
2099
|
-
};
|
|
2100
|
-
} });
|
|
2101
|
-
const rules = {
|
|
2102
|
-
"no-react-state": noReactState,
|
|
2103
|
-
"no-if-statement": noIfStatement,
|
|
2104
|
-
"no-switch-statement": noSwitchStatement,
|
|
2105
|
-
"no-ternary": noTernary,
|
|
2106
|
-
"no-return-null": noReturnNull,
|
|
2107
|
-
"no-option-as": noOptionAs,
|
|
2108
|
-
"no-effect-never": noEffectNever,
|
|
2109
|
-
"no-arrow-ladder": noArrowLadder,
|
|
2110
|
-
"no-branch-in-object": noBranchInObject,
|
|
2111
|
-
"no-iife-wrapper": noIifeWrapper,
|
|
2112
|
-
"no-return-in-arrow": noReturnInArrow,
|
|
2113
|
-
"no-return-in-callback": noReturnInCallback,
|
|
2114
|
-
"no-effect-fn-generator": noEffectFnGenerator,
|
|
2115
|
-
"no-effect-sync-console": noEffectSyncConsole,
|
|
2116
|
-
"no-nested-effect-gen": noNestedEffectGen,
|
|
2117
|
-
"no-yield-without-star-in-effect-gen": noYieldWithoutStarInEffectGen,
|
|
2118
|
-
"no-match-void-branch": noMatchVoidBranch,
|
|
2119
|
-
"no-match-effect-branch": noMatchEffectBranch,
|
|
2120
|
-
"warn-effect-sync-wrapper": warnEffectSyncWrapper,
|
|
2121
|
-
"no-effect-side-effect-wrapper": noEffectSideEffectWrapper,
|
|
2122
|
-
"no-effect-all-step-sequencing": noEffectAllStepSequencing,
|
|
2123
|
-
"no-async-effect-combinator-callback": noAsyncEffectCombinatorCallback,
|
|
2124
|
-
"no-throw-in-effect-logic": noThrowInEffectLogic,
|
|
2125
|
-
"no-or-die-outside-boundary": noOrDieOutsideBoundary,
|
|
2126
|
-
"no-swallowed-catch-all": noSwallowedCatchAll,
|
|
2127
|
-
"no-effect-ignore": noEffectIgnore,
|
|
2128
|
-
"no-try-catch-in-effect-logic": noTryCatchInEffectLogic,
|
|
2129
|
-
"no-promise-api-in-effect-logic": noPromiseApiInEffectLogic,
|
|
2130
|
-
"no-try-catch": noTryCatch,
|
|
2131
|
-
"no-effect-wrapper-alias": noEffectWrapperAlias,
|
|
2132
|
-
"no-manual-effect-channels": noManualEffectChannels,
|
|
2133
|
-
"no-wrapgraphql-catchall": noWrapgraphqlCatchall,
|
|
2134
|
-
"no-render-side-effects": noRenderSideEffects,
|
|
2135
|
-
"no-atom-registry-effect-sync": noAtomRegistryEffectSync,
|
|
2136
|
-
"no-family-collection-read": noFamilyCollectionRead,
|
|
2137
|
-
"no-inline-runtime-provide": noInlineRuntimeProvide,
|
|
2138
|
-
"no-naked-object-state-update": noNakedObjectStateUpdate,
|
|
2139
|
-
"no-effect-succeed-variable": noEffectSucceedVariable,
|
|
2140
|
-
"no-effect-type-alias": noEffectTypeAlias,
|
|
2141
|
-
"no-public-generic-effect-error": noPublicGenericEffectError,
|
|
2142
|
-
"no-model-overlay-cast": noModelOverlayCast,
|
|
2143
|
-
"no-unknown-boolean-coercion-helper": noUnknownBooleanCoercionHelper,
|
|
2144
|
-
"no-fromnullable-nullish-coalesce": noFromnullableNullishCoalesce,
|
|
2145
|
-
"no-option-boolean-normalization": noOptionBooleanNormalization,
|
|
2146
|
-
"no-string-sentinel-return": noStringSentinelReturn,
|
|
2147
|
-
"no-string-sentinel-const": noStringSentinelConst,
|
|
2148
|
-
"no-raw-domain-id-alias": noRawDomainIdAlias,
|
|
2149
|
-
"no-boolean-domain-flag": noBooleanDomainFlag,
|
|
2150
|
-
"no-magic-domain-string": noMagicDomainString,
|
|
2151
|
-
"no-raw-domain-primitive-params": noRawDomainPrimitiveParams,
|
|
2152
|
-
"no-raw-time-domain-field": noRawTimeDomainField,
|
|
2153
|
-
"no-overloaded-options-object": noOverloadedOptionsObject,
|
|
2154
|
-
"no-domain-logic-in-conditional": noDomainLogicInConditional,
|
|
2155
|
-
"no-implicit-state-machine-object": noImplicitStateMachineObject,
|
|
2156
|
-
"no-adhoc-domain-error": noAdhocDomainError,
|
|
2157
|
-
"no-domain-meaning-by-folder-only": noDomainMeaningByFolderOnly,
|
|
2158
|
-
"no-effect-as": noEffectAs,
|
|
2159
|
-
"no-effect-do": noEffectDo,
|
|
2160
|
-
"no-effect-bind": noEffectBind,
|
|
2161
|
-
"no-runtime-runfork": noRuntimeRunFork,
|
|
2162
|
-
"no-run-effect-outside-boundary": noRunEffectOutsideBoundary,
|
|
2163
|
-
"no-effect-async": noEffectAsync,
|
|
2164
|
-
"prevent-dynamic-imports": defineRule({ create(context) {
|
|
2165
|
-
return { ImportExpression(node) {
|
|
2166
|
-
report(context, node, "Rule: avoid dynamic imports. Why: runtime module loading obscures dependency boundaries. Fix: use static imports.");
|
|
2167
|
-
} };
|
|
2168
|
-
} }),
|
|
2169
|
-
"no-nested-effect-call": noNestedEffectCall,
|
|
2170
|
-
"no-effect-ladder": noEffectLadder,
|
|
2171
|
-
"no-flatmap-ladder": noFlatMapLadder,
|
|
2172
|
-
"no-pipe-ladder": noPipeLadder,
|
|
2173
|
-
"no-call-tower": noCallTower,
|
|
2174
|
-
"no-effect-orElse-ladder": noEffectOrElseLadder,
|
|
2175
|
-
"no-unbounded-effect-all": noUnboundedEffectAll,
|
|
2176
|
-
"no-fire-and-forget-fork": noFireAndForgetFork,
|
|
2177
|
-
"no-fork-in-loop": noForkInLoop,
|
|
2178
|
-
"no-race-without-cleanup": noRaceWithoutCleanup,
|
|
2179
|
-
"no-unobserved-fiber": noUnobservedFiber,
|
|
2180
|
-
"no-unbounded-concurrent-retry": noUnboundedConcurrentRetry,
|
|
2181
|
-
"no-blocking-call-in-effect": noBlockingCallInEffect,
|
|
2182
|
-
"no-promise-concurrency-in-effect": noPromiseConcurrencyInEffect,
|
|
2183
|
-
"no-shared-mutable-state-across-fibers": noSharedMutableStateAcrossFibers,
|
|
2184
|
-
"no-timeout-with-noninterruptible-promise": noTimeoutWithNoninterruptiblePromise
|
|
2185
|
-
};
|
|
2186
|
-
function rulesFromNames(ruleNames) {
|
|
2187
|
-
return Object.fromEntries(ruleNames.map((ruleName) => [`linteffect/${ruleName}`, "error"]));
|
|
2188
|
-
}
|
|
2189
|
-
function presetFor(groupRules) {
|
|
2190
|
-
return {
|
|
2191
|
-
jsPlugins,
|
|
2192
|
-
rules: groupRules
|
|
2193
|
-
};
|
|
2194
|
-
}
|
|
2195
|
-
const jsPlugins = [{
|
|
2196
|
-
name: "linteffect",
|
|
2197
|
-
specifier: "@opsydyn/oxlint-effect"
|
|
2198
|
-
}];
|
|
2199
|
-
const reactAndRuntimeBoundariesRules = rulesFromNames([
|
|
2200
|
-
"no-react-state",
|
|
2201
|
-
"no-runtime-runfork",
|
|
2202
|
-
"no-run-effect-outside-boundary",
|
|
2203
|
-
"no-or-die-outside-boundary",
|
|
2204
|
-
"prevent-dynamic-imports",
|
|
2205
|
-
"no-render-side-effects",
|
|
2206
|
-
"no-inline-runtime-provide"
|
|
2207
|
-
]);
|
|
2208
|
-
const effectCompositionRules = rulesFromNames([
|
|
2209
|
-
"no-effect-as",
|
|
2210
|
-
"no-effect-do",
|
|
2211
|
-
"no-effect-bind",
|
|
2212
|
-
"no-effect-async",
|
|
2213
|
-
"no-effect-ignore",
|
|
2214
|
-
"no-effect-never",
|
|
2215
|
-
"no-effect-fn-generator",
|
|
2216
|
-
"no-nested-effect-gen",
|
|
2217
|
-
"no-yield-without-star-in-effect-gen",
|
|
2218
|
-
"no-async-effect-combinator-callback",
|
|
2219
|
-
"no-throw-in-effect-logic",
|
|
2220
|
-
"no-try-catch-in-effect-logic",
|
|
2221
|
-
"no-promise-api-in-effect-logic",
|
|
2222
|
-
"no-swallowed-catch-all",
|
|
2223
|
-
"no-manual-effect-channels",
|
|
2224
|
-
"no-effect-type-alias",
|
|
2225
|
-
"no-public-generic-effect-error"
|
|
2226
|
-
]);
|
|
2227
|
-
const concurrencySafetyRules = rulesFromNames([
|
|
2228
|
-
"no-unbounded-effect-all",
|
|
2229
|
-
"no-fire-and-forget-fork",
|
|
2230
|
-
"no-fork-in-loop",
|
|
2231
|
-
"no-race-without-cleanup",
|
|
2232
|
-
"no-unobserved-fiber",
|
|
2233
|
-
"no-unbounded-concurrent-retry",
|
|
2234
|
-
"no-blocking-call-in-effect",
|
|
2235
|
-
"no-promise-concurrency-in-effect",
|
|
2236
|
-
"no-shared-mutable-state-across-fibers",
|
|
2237
|
-
"no-timeout-with-noninterruptible-promise"
|
|
2238
|
-
]);
|
|
2239
|
-
const pipelineShapeAndSequencingRules = rulesFromNames([
|
|
2240
|
-
"no-nested-effect-call",
|
|
2241
|
-
"no-effect-ladder",
|
|
2242
|
-
"no-flatmap-ladder",
|
|
2243
|
-
"no-pipe-ladder",
|
|
2244
|
-
"no-call-tower",
|
|
2245
|
-
"no-effect-orElse-ladder",
|
|
2246
|
-
"no-effect-wrapper-alias",
|
|
2247
|
-
"warn-effect-sync-wrapper",
|
|
2248
|
-
"no-effect-side-effect-wrapper",
|
|
2249
|
-
"no-effect-all-step-sequencing",
|
|
2250
|
-
"no-effect-succeed-variable"
|
|
2251
|
-
]);
|
|
2252
|
-
const branchingAndLocalControlFlowRules = rulesFromNames([
|
|
2253
|
-
"no-if-statement",
|
|
2254
|
-
"no-switch-statement",
|
|
2255
|
-
"no-ternary",
|
|
2256
|
-
"no-try-catch",
|
|
2257
|
-
"no-arrow-ladder",
|
|
2258
|
-
"no-iife-wrapper",
|
|
2259
|
-
"no-return-in-arrow",
|
|
2260
|
-
"no-return-in-callback",
|
|
2261
|
-
"no-return-null",
|
|
2262
|
-
"no-branch-in-object"
|
|
2263
|
-
]);
|
|
2264
|
-
const optionMatchAndDataNormalizationRules = rulesFromNames([
|
|
2265
|
-
"no-option-as",
|
|
2266
|
-
"no-match-void-branch",
|
|
2267
|
-
"no-match-effect-branch",
|
|
2268
|
-
"no-model-overlay-cast",
|
|
2269
|
-
"no-unknown-boolean-coercion-helper",
|
|
2270
|
-
"no-fromnullable-nullish-coalesce",
|
|
2271
|
-
"no-option-boolean-normalization",
|
|
2272
|
-
"no-string-sentinel-return",
|
|
2273
|
-
"no-string-sentinel-const"
|
|
2274
|
-
]);
|
|
2275
|
-
const atomStateAndPlatformBoundariesRules = rulesFromNames([
|
|
2276
|
-
"no-effect-sync-console",
|
|
2277
|
-
"no-atom-registry-effect-sync",
|
|
2278
|
-
"no-family-collection-read",
|
|
2279
|
-
"no-naked-object-state-update",
|
|
2280
|
-
"no-wrapgraphql-catchall"
|
|
2281
|
-
]);
|
|
2282
|
-
const domainModelingRules = rulesFromNames([
|
|
2283
|
-
"no-raw-domain-id-alias",
|
|
2284
|
-
"no-boolean-domain-flag",
|
|
2285
|
-
"no-magic-domain-string",
|
|
2286
|
-
"no-raw-domain-primitive-params",
|
|
2287
|
-
"no-raw-time-domain-field",
|
|
2288
|
-
"no-overloaded-options-object",
|
|
2289
|
-
"no-domain-logic-in-conditional",
|
|
2290
|
-
"no-implicit-state-machine-object",
|
|
2291
|
-
"no-adhoc-domain-error",
|
|
2292
|
-
"no-domain-meaning-by-folder-only"
|
|
2293
|
-
]);
|
|
2294
|
-
const allRules = rulesFromNames(Object.keys(rules));
|
|
2295
|
-
const ruleGroups = {
|
|
2296
|
-
reactAndRuntimeBoundaries: reactAndRuntimeBoundariesRules,
|
|
2297
|
-
effectComposition: effectCompositionRules,
|
|
2298
|
-
concurrencySafety: concurrencySafetyRules,
|
|
2299
|
-
pipelineShapeAndSequencing: pipelineShapeAndSequencingRules,
|
|
2300
|
-
branchingAndLocalControlFlow: branchingAndLocalControlFlowRules,
|
|
2301
|
-
optionMatchAndDataNormalization: optionMatchAndDataNormalizationRules,
|
|
2302
|
-
atomStateAndPlatformBoundaries: atomStateAndPlatformBoundariesRules,
|
|
2303
|
-
domainModeling: domainModelingRules,
|
|
2304
|
-
ddd: domainModelingRules
|
|
2305
|
-
};
|
|
2306
|
-
const recommended = presetFor(allRules);
|
|
2307
|
-
const reactAndRuntimeBoundaries = presetFor(reactAndRuntimeBoundariesRules);
|
|
2308
|
-
const effectComposition = presetFor(effectCompositionRules);
|
|
2309
|
-
const concurrencySafety = presetFor(concurrencySafetyRules);
|
|
2310
|
-
const pipelineShapeAndSequencing = presetFor(pipelineShapeAndSequencingRules);
|
|
2311
|
-
const branchingAndLocalControlFlow = presetFor(branchingAndLocalControlFlowRules);
|
|
2312
|
-
const optionMatchAndDataNormalization = presetFor(optionMatchAndDataNormalizationRules);
|
|
2313
|
-
const atomStateAndPlatformBoundaries = presetFor(atomStateAndPlatformBoundariesRules);
|
|
2314
|
-
const domainModeling = presetFor(domainModelingRules);
|
|
2315
|
-
const ddd = domainModeling;
|
|
2316
|
-
const presets = {
|
|
2317
|
-
recommended,
|
|
2318
|
-
reactAndRuntimeBoundaries,
|
|
2319
|
-
effectComposition,
|
|
2320
|
-
concurrencySafety,
|
|
2321
|
-
pipelineShapeAndSequencing,
|
|
2322
|
-
branchingAndLocalControlFlow,
|
|
2323
|
-
optionMatchAndDataNormalization,
|
|
2324
|
-
atomStateAndPlatformBoundaries,
|
|
2325
|
-
domainModeling,
|
|
2326
|
-
ddd
|
|
2327
|
-
};
|
|
2328
|
-
var src_default = definePlugin({
|
|
2329
|
-
meta: { name: "linteffect" },
|
|
2330
|
-
rules
|
|
2331
|
-
});
|
|
2332
|
-
//#endregion
|
|
2333
|
-
export { allRules, atomStateAndPlatformBoundaries, atomStateAndPlatformBoundariesRules, branchingAndLocalControlFlow, branchingAndLocalControlFlowRules, concurrencySafety, concurrencySafetyRules, ddd, src_default as default, domainModeling, domainModelingRules, effectComposition, effectCompositionRules, jsPlugins, optionMatchAndDataNormalization, optionMatchAndDataNormalizationRules, pipelineShapeAndSequencing, pipelineShapeAndSequencingRules, presets, reactAndRuntimeBoundaries, reactAndRuntimeBoundariesRules, recommended, ruleGroups };
|
|
2334
|
-
|
|
1
|
+
import{definePlugin as e,defineRule as t}from"@oxlint/plugins";function n(e,t){return typeof e==`object`&&!!e&&e.type===`Identifier`&&typeof e.name==`string`&&(t===void 0||e.name===t)}function r(e,t,r){if(typeof e!=`object`||!e)return!1;let i=e;return i.type===`MemberExpression`&&i.computed!==!0&&n(i.object,t)&&n(i.property,r)}function i(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`CallExpression`&&Array.isArray(t.arguments)&&typeof t.callee==`object`&&t.callee!==null&&t.callee.type===`MemberExpression`&&t.callee.computed!==!0&&n(t.callee.object,`Effect`)&&n(t.callee.property)}function a(e){return e.arguments[0]}function o(e,t){if(!i(e))return!1;let r=e.callee;return n(r.property,t)}function ee(e){if(!i(e))return!1;let t=a(e);return i(t)?i(a(t)):!1}function te(e){return i(e)?e.arguments.slice(0,2).some(e=>i(e)):!1}function s(e,t){return o(e,t)?!0:Array.isArray(e)?e.some(e=>s(e,t)):typeof e!=`object`||!e?!1:Object.values(e).some(e=>s(e,t))}function ne(e){if(o(e,`flatMap`)&&s(e.arguments,`flatMap`))return`Rule: avoid nested Effect.flatMap. Why: it hides sequencing and pushes laddered control flow. Fix: build context once (Effect.all/Effect.map) and run a single flatMap.`;if(o(e,`flatten`)&&s(a(e),`map`))return`Rule: avoid map+flatten ladders. Why: they hide sequencing. Fix: build context once (Effect.all/Effect.map) and run a single flatMap.`}const re=[`flatMap`,`zipRight`,`as`,`tap`];function ie(e){if(!o(e,`orElse`))return!1;let t=a(e);return re.some(e=>s(t,e))}function c(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`CallExpression`)return!1;if(n(t.callee,`pipe`))return!0;let r=t.callee;return typeof r==`object`&&!!r&&r.type===`MemberExpression`&&r.computed!==!0&&n(r.property,`pipe`)}function ae(e,t=new WeakSet){return c(e)?!0:Array.isArray(e)?e.some(e=>ae(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&ae(n,t)))}function oe(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`CallExpression`&&Array.isArray(t.arguments)&&typeof t.callee==`object`&&t.callee!==null&&t.callee.type===`ArrowFunctionExpression`}function se(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`CallExpression`&&Array.isArray(t.arguments)&&typeof t.callee==`object`&&t.callee!==null&&(t.callee.type===`ArrowFunctionExpression`||t.callee.type===`FunctionExpression`)}function l(e,t=new WeakSet){if(oe(e))return e;if(Array.isArray(e)){for(let n of e){let e=l(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){t.add(e);for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=l(r,t);if(e)return e}}}function u(e,t=new WeakSet){return Array.isArray(e)?e.flatMap(e=>u(e,t)):typeof e!=`object`||!e||t.has(e)?[]:(t.add(e),e.type===`ReturnStatement`?[e]:Object.entries(e).flatMap(([e,n])=>e===`parent`?[]:u(n,t)))}function ce(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`CallExpression`&&(r(t.callee,`S`,`filter`)||r(t.callee,`Schema`,`filter`))}function le(e){if(typeof e!=`object`||!e)return[];let t=e;return t.type!==`CallExpression`||!Array.isArray(t.arguments)||ce(t)?[]:t.arguments.flatMap(e=>{if(typeof e!=`object`||!e||e.type!==`ArrowFunctionExpression`)return[];let t=e.body;return typeof t!=`object`||!t||t.type!==`BlockStatement`?[]:u(t)})}function ue(e){if(typeof e!=`object`||!e)return[];let t=e;return t.type!==`CallExpression`||!Array.isArray(t.arguments)?[]:t.arguments.flatMap(e=>typeof e!=`object`||!e||e.type!==`FunctionExpression`||e.generator===!0?[]:u(e.body))}function de(e){return typeof e==`object`&&!!e&&e.type===`FunctionExpression`&&e.generator===!0}function d(e,t){if(!o(e,t))return;let n=a(e);return de(n)?n:void 0}function fe(e,t){return d(e,t)!==void 0}function pe(e,t=new WeakSet){if(Array.isArray(e)){for(let n of e){let e=pe(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e.type===`YieldExpression`&&e.delegate!==!0)return e;for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=pe(r,t);if(e)return e}}}function me(e){let t=d(e,`gen`);return t?pe(t.body):void 0}function he(e,t=new WeakSet){return Array.isArray(e)?e.flatMap(e=>he(e,t)):typeof e!=`object`||!e||t.has(e)?[]:(t.add(e),e.type===`YieldExpression`&&e.delegate===!0&&c(e.argument)?[e]:Object.entries(e).flatMap(([e,n])=>e===`parent`?[]:he(n,t)))}function ge(e){let t=d(e,`gen`);if(!t)return;let n=he(t.body);return n.length>=2?n[1]:void 0}function f(e,t,n=new WeakSet){return Array.isArray(e)?e.some(e=>f(e,t,n)):typeof e!=`object`||!e||n.has(e)?!1:(n.add(e),e.type===t?!0:Object.entries(e).some(([e,r])=>e!==`parent`&&f(r,t,n)))}function p(e,t,r=new WeakSet){return n(e,t)?!0:Array.isArray(e)?e.some(e=>p(e,t,r)):typeof e!=`object`||!e||r.has(e)?!1:(r.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&p(n,t,r)))}function m(e,t=new WeakSet){return i(e)?!0:Array.isArray(e)?e.some(e=>m(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&m(n,t)))}function _e(e){if(typeof e!=`object`||!e||e.type!==`VariableDeclaration`)return;let t=e.declarations;if(!Array.isArray(t)||t.length!==1)return;let r=t[0];if(!(typeof r!=`object`||!r||r.type!==`VariableDeclarator`||!n(r.id)||typeof r.init!=`object`||r.init===null||r.init.type!==`YieldExpression`||r.init.delegate!==!0))return r.id.name}function ve(e,t){if(typeof e!=`object`||!e||e.type!==`ReturnStatement`)return!1;let r=e.argument;return r!==void 0&&!n(r,t)&&!f(r,`YieldExpression`)&&!f(r,`AwaitExpression`)&&!m(r)&&!p(r,`Promise`)}function ye(e){let t=d(e,`gen`);if(!t||typeof t.body!=`object`||t.body===null)return;let n=t.body,r=Array.isArray(n.body)?n.body:[];if(r.length!==2)return;let i=_e(r[0]);return i&&ve(r[1],i)?e:void 0}const be=new Set([`andThen`,`flatMap`,`tap`,`zipRight`]);function xe(e){if(typeof e!=`object`||!e||e.type!==`CallExpression`)return[];let t=e,r=Array.isArray(t.arguments)?t.arguments:[];if(n(t.callee,`pipe`))return r.slice(1);let i=t.callee;return typeof i==`object`&&i&&i.type===`MemberExpression`&&i.computed!==!0&&n(i.property,`pipe`)?r:[]}function Se(e){if(!i(e))return!1;let t=e.callee.property;return n(t)&&be.has(t.name)}function Ce(e){if(c(e))return xe(e).filter(e=>Se(e)).length>=3?e:void 0}function h(e){return typeof e==`object`&&!!e&&e.type===`CallExpression`&&Array.isArray(e.arguments)&&n(e.callee,`flow`)}function we(e){return h(e)&&e.arguments.length>=5}function Te(e,t=new WeakSet){return typeof e==`object`&&e&&(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`)&&e.async===!0?!0:Array.isArray(e)?e.some(e=>Te(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&Te(n,t)))}function Ee(e){return m(e)||f(e,`YieldExpression`)||f(e,`AwaitExpression`)||Te(e)||O(e)||p(e,`Promise`)||p(e,`Runtime`)}function De(e){if(h(e))return e.arguments.find(e=>Ee(e))}function Oe(e){if(!(typeof e!=`object`||!e||e.type!==`CallExpression`))return(e.arguments??[]).find(e=>h(e)&&e.arguments.length>=3)}const ke=new Set([`annotateLogs`,`as`,`catchAll`,`catchSome`,`catchTag`,`map`,`mapBoth`,`provide`,`retry`,`tap`,`tapError`,`timeout`,`timeoutFail`,`withSpan`]);function g(e){if(!i(e))return!1;let t=e.callee.property;return n(t)&&ke.has(t.name)}function Ae(e){return i(e)||c(e)}function je(e){if(!g(e))return;let t=e.arguments[0];return Ae(t)?e:void 0}function Me(e){return typeof e!=`object`||!e||e.type!==`YieldExpression`||e.delegate!==!0||!c(e.argument)?!1:xe(e.argument).some(e=>g(e))}function Ne(e,t=new WeakSet){return Array.isArray(e)?e.flatMap(e=>Ne(e,t)):typeof e!=`object`||!e||t.has(e)?[]:(t.add(e),Me(e)?[e]:Object.entries(e).flatMap(([e,n])=>e===`parent`?[]:Ne(n,t)))}function Pe(e){let t=d(e,`gen`);if(!t)return;let n=Ne(t.body);return n.length>=2?n[1]:void 0}function Fe(e){if(!c(e))return;let t=xe(e);if(!t.some(e=>g(e)))return;let n=t.filter(e=>Se(e)).length,r=t.some(e=>f(e,`IfStatement`)||f(e,`SwitchStatement`)||f(e,`ForStatement`)||f(e,`ForInStatement`)||f(e,`ForOfStatement`)||f(e,`WhileStatement`));return n>=2||r?e:void 0}function _(e,t=new Set,n=new WeakSet){if((o(e,`gen`)||Se(e))&&t.add(`workflow`),h(e)&&t.add(`pure`),g(e)&&t.add(`behavior`),(D(e,`Layer`)||r(e,`Layer`,`pipe`))&&t.add(`layer`),Array.isArray(e)){for(let r of e)_(r,t,n);return t}if(typeof e!=`object`||!e||n.has(e))return t;n.add(e);for(let[r,i]of Object.entries(e))r!==`parent`&&_(i,t,n);return t}function v(e){return typeof e==`object`&&!!e&&(e.type===`FunctionDeclaration`||e.type===`FunctionExpression`||e.type===`ArrowFunctionExpression`)}function Ie(e){if(!v(e))return;let t=e.body;return _(t).size>=3?e:void 0}function Le(e,t=new WeakSet){if(Array.isArray(e))return e.reduce((e,n)=>Math.max(e,Le(n,t)),0);if(typeof e!=`object`||!e||t.has(e))return 0;t.add(e);let n=Object.entries(e).reduce((e,[n,r])=>n===`parent`?e:Math.max(e,Le(r,t)),0);return e.type===`CallExpression`?n+1:n}function Re(e){if(typeof e!=`object`||!e||e.type!==`CallExpression`)return;let t=_(e),n=se(e)||l(e)!==void 0;return t.size>=2&&(Le(e)>=4||n)?e:void 0}function ze(e){if(typeof e!=`object`||!e||e.type!==`CallExpression`)return;let t=e;for(let e of t.arguments??[]){if(typeof e!=`object`||!e||!v(e))continue;let t=e.body;if(typeof t==`object`&&t&&t.type===`BlockStatement`&&Array.isArray(t.body)&&t.body.length>=3)return e}}function Be(e){return r(e,`Effect`,`Service`)?!0:typeof e!=`object`||!e||e.type!==`CallExpression`?!1:Be(e.callee)}function Ve(e){if(typeof e!=`object`||!e||e.type!==`CallExpression`)return;let t=e;if(Be(t.callee))return[...t.arguments??[]].reverse().find(e=>typeof e==`object`&&!!e&&e.type===`ObjectExpression`)}function y(e){if(!(typeof e!=`object`||!e||e.type!==`ClassDeclaration`))return Ve(e.superClass)}function He(e){return D(e,`Context`,`Tag`)||D(e,`Context`,`GenericTag`)}function Ue(e,t=new WeakSet){return D(e,`Layer`,`provide`)?!0:Array.isArray(e)?e.some(e=>Ue(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&Ue(n,t)))}function We(e){return H(V(e,`accessors`),!0)}function Ge(e){if(!X(Y(e)??``))return;let t=typeof e==`object`&&e?e.specifiers:void 0;return Array.isArray(t)?t.find(e=>typeof e==`object`&&!!e&&e.type===`ImportNamespaceSpecifier`):void 0}function Ke(e){return typeof e==`object`&&!!e&&e.type===`YieldExpression`&&e.delegate===!0&&n(e.argument)&&e.argument.name.endsWith(`Service`)}function b(e,t,n=new WeakSet){if(t(e))return e;if(Array.isArray(e)){for(let r of e){let e=b(r,t,n);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!n.has(e)){n.add(e);for(let[r,i]of Object.entries(e)){if(r===`parent`)continue;let e=b(i,t,n);if(e)return e}}}function qe(e){if(!V(e,`dependencies`))return b(V(e,`effect`)??V(e,`scoped`),Ke)}function Je(e){if(!D(e,`Layer`))return!1;let t=e.callee.property;return n(t)&&(t.name===`provide`||t.name.startsWith(`merge`))}function Ye(e){if(typeof e!=`object`||!e||e.type!==`FunctionDeclaration`)return!1;let t=e.id;return n(t)&&/(handler|route|request)$/i.test(t.name)}function Xe(e){if(Ye(e))return b(e.body,Je)?e:void 0}function Ze(e){if(D(e,`Layer`,`provide`))return b(a(e),t=>t!==e&&D(t,`Layer`,`provide`))}function Qe(e){return o(e,`provide`)||D(e,`Layer`,`provide`)}function $e(e){let t=d(e,`gen`);return t?b(t.body,Qe):void 0}function et(e){if(D(e,`Layer`,`merge`))return e.arguments?.find(t=>b(t,t=>t!==e&&D(t,`Layer`,`merge`)))}function tt(e){return n(e)&&/(Layer|Live)$/.test(e.name)}function nt(e){if(!(typeof e!=`object`||!e||e.type!==`VariableDeclaration`))return e.declarations?.find(e=>typeof e==`object`&&!!e&&tt(e.id)&&b(e.init,Qe))}function rt(e){return v(e)?ln(fn(e),`Promise`)||w(e.body)!==void 0:!1}function it(e){return typeof e==`object`&&!!e&&e.type===`Property`&&rt(e.value)}function at(e){return b(e,it)}function ot(e){if(typeof e!=`object`||!e||e.type!==`ObjectExpression`)return!1;let t=e.properties;return Array.isArray(t)&&t.some(e=>typeof e==`object`&&!!e&&e.type===`Property`&&(v(e.value)||o(e.value,`fn`)))}function st(e){if(typeof e!=`object`||!e)return;let t=e.declaration;if(!(typeof t!=`object`||!t)&&t.type===`VariableDeclaration`){for(let e of t.declarations??[])if(typeof e==`object`&&e&&n(e.id)&&e.id.name.endsWith(`Service`)&&ot(e.init))return e}}function ct(e){return typeof e==`object`&&!!e&&(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`)&&e.async===!0}const x=new Set([`andThen`,`catchAll`,`catchTag`,`filterOrFail`,`flatMap`,`forEach`,`map`,`orElse`,`tap`]);function lt(e){if(!i(e))return;let t=e.callee.property;if(!(!n(t)||!x.has(t.name)))return e.arguments.find(e=>ct(e))}function S(e,t=new WeakSet){if(Array.isArray(e)){for(let n of e){let e=S(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e.type===`ThrowStatement`)return e;for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=S(r,t);if(e)return e}}}function ut(e){let t=d(e,`gen`);if(t)return S(t.body);if(!i(e))return;let r=e.callee.property;if(!(!n(r)||!x.has(r.name)))for(let t of e.arguments){let e=R(t),n=e?S(e):void 0;if(n)return n}}function C(e,t=new WeakSet){if(Array.isArray(e)){for(let n of e){let e=C(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e.type===`TryStatement`)return e;for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=C(r,t);if(e)return e}}}function dt(e){let t=d(e,`gen`);if(t)return C(t.body);if(!i(e))return;let r=e.callee.property;if(!(!n(r)||!x.has(r.name)))for(let t of e.arguments){let e=R(t),n=e?C(e):void 0;if(n)return n}}function ft(e){return D(e,`Promise`,`all`)||D(e,`Promise`,`allSettled`)||D(e,`Promise`,`any`)||D(e,`Promise`,`race`)||D(e,`Promise`,`reject`)||D(e,`Promise`,`resolve`)}function pt(e){if(typeof e!=`object`||!e||e.type!==`CallExpression`)return!1;let t=e.callee;return typeof t==`object`&&!!t&&t.type===`MemberExpression`&&t.computed!==!0&&(n(t.property,`then`)||n(t.property,`catch`)||n(t.property,`finally`))}function w(e,t=new WeakSet){if(Array.isArray(e)){for(let n of e){let e=w(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),ft(e)||pt(e))return e;for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=w(r,t);if(e)return e}}}function mt(e){let t=d(e,`gen`);if(t)return w(t.body);if(!i(e))return;let r=e.callee.property;if(!(!n(r)||!x.has(r.name)))for(let t of e.arguments){let e=R(t),n=e?w(e):void 0;if(n)return n}}const ht=new Set([`all`,`allSettled`,`any`,`race`]);function gt(e){if(typeof e!=`object`||!e||e.type!==`CallExpression`)return!1;let t=e.callee;return typeof t==`object`&&!!t&&t.type===`MemberExpression`&&t.computed!==!0&&n(t.object,`Promise`)&&n(t.property)&&ht.has(t.property.name)}function T(e,t=new WeakSet){if(Array.isArray(e)){for(let n of e){let e=T(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),gt(e))return e;for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=T(r,t);if(e)return e}}}function _t(e){let t=d(e,`gen`);if(t)return T(t.body);if(o(e,`sync`)){let t=R(a(e));return t?T(t):void 0}if(!i(e))return;let r=e.callee.property;if(!(!n(r)||!x.has(r.name)))for(let t of e.arguments){let e=R(t),n=e?T(e):void 0;if(n)return n}}function vt(e){if(typeof e!=`object`||!e)return!1;let t=e;return(t.type===`ArrowFunctionExpression`||t.type===`FunctionExpression`)&&Array.isArray(t.params)&&t.params.length>0}function yt(e){if(!o(e,`tryPromise`))return!1;let t=a(e);return vt(t)?!0:vt(V(t,`try`))}function bt(e){return o(e,`promise`)?!0:o(e,`tryPromise`)&&!yt(e)}function xt(e){if(!o(e,`timeout`))return;let t=a(e);return bt(t)?t:void 0}const St=new Set([`crypto`,`fs`,`zlib`]);function Ct(e){if(typeof e!=`object`||!e||e.type!==`CallExpression`)return!1;let t=e.callee;if(n(t))return t.name.endsWith(`Sync`);if(typeof t!=`object`||!t||t.type!==`MemberExpression`||t.computed===!0||!n(t.object)||!n(t.property))return!1;let r=t.object.name,i=t.property.name;return St.has(r)&&i.endsWith(`Sync`)}function E(e,t=new WeakSet){if(Array.isArray(e)){for(let n of e){let e=E(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),Ct(e))return e;for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=E(r,t);if(e)return e}}}function wt(e){let t=d(e,`gen`);if(t)return E(t.body);if(o(e,`sync`)){let t=R(a(e));return t?E(t):void 0}}const Tt=new Set([`runCallback`,`runFork`,`runPromise`,`runPromiseExit`,`runSync`,`runSyncExit`]);function Et(e){if(!i(e))return!1;let t=e.callee.property;return n(t)&&Tt.has(t.name)}function Dt(e){return r(e,`Effect`,`orDie`)||r(e,`Effect`,`orDieWith`)||o(e,`orDie`)||o(e,`orDieWith`)}function Ot(e){if(Dt(e))return e;if(c(e))return I(e).find(e=>Dt(e))}function kt(e){return o(e,`succeed`)||o(e,`asVoid`)||o(e,`ignore`)||Wn(e)}function At(e){if(!o(e,`catchAll`))return;let t=R(a(e));return kt(t)?t:void 0}function jt(e){return r(e,`Effect`,`ignore`)||o(e,`ignore`)}function Mt(e){if(jt(e))return e;if(c(e))return I(e).find(e=>jt(e))}function Nt(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`CallExpression`&&typeof t.callee==`object`&&t.callee!==null&&t.callee.type===`MemberExpression`&&t.callee.computed!==!0&&n(t.callee.object,`console`)&&n(t.callee.property)}function Pt(e,t){if(typeof e!=`object`||!e)return!1;let r=e;return r.type===`CallExpression`&&n(r.callee,t)}function D(e,t,r){if(typeof e!=`object`||!e)return!1;let i=e;return i.type===`CallExpression`&&typeof i.callee==`object`&&i.callee!==null&&i.callee.type===`MemberExpression`&&i.callee.computed!==!0&&n(i.callee.object,t)&&n(i.callee.property)&&(r===void 0||n(i.callee.property,r))}function Ft(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type!==`CallExpression`||typeof t.callee!=`object`||t.callee===null||t.callee.type!==`MemberExpression`||t.callee.computed===!0||!n(t.callee.object,`Effect`)||!n(t.callee.property)?!1:t.callee.property.name.startsWith(`log`)}function O(e,t=new WeakSet){return Nt(e)?!0:Array.isArray(e)?e.some(e=>O(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&O(n,t)))}function k(e,t=new WeakSet){return Pt(e,`setState`)||D(e,`Atom`,`set`)||Pt(e,`invalidate`)||Ft(e)||Nt(e)?!0:Array.isArray(e)?e.some(e=>k(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&k(n,t)))}function A(e,t=new WeakSet){return D(e,`Ref`,`set`)||D(e,`Atom`,`set`)||D(e,`SubscriptionRef`,`set`)||D(e,`Reactivity`,`invalidate`)||D(e,`Fiber`,`interrupt`)||Ft(e)?!0:Array.isArray(e)?e.some(e=>A(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&A(n,t)))}function It(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type!==`ObjectExpression`||!Array.isArray(t.properties)?!1:t.properties.some(e=>{if(typeof e!=`object`||!e)return!1;let t=e,r=t.key,i=t.value;return(n(r,`concurrency`)||typeof r==`object`&&!!r&&r.value===`concurrency`)&&typeof i==`object`&&!!i&&(i.type===`Literal`||i.type===`NumericLiteral`)&&i.value===1})}function Lt(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type!==`ObjectExpression`||!Array.isArray(t.properties)?!1:t.properties.some(e=>{if(typeof e!=`object`||!e)return!1;let t=e.key;return n(t,`concurrency`)||typeof t==`object`&&!!t&&t.value===`concurrency`})}function Rt(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`CallExpression`&&typeof t.callee==`object`&&t.callee!==null&&t.callee.type===`MemberExpression`&&t.callee.computed!==!0&&n(t.callee.property,`map`)}function zt(e){return o(e,`all`)&&Rt(a(e))&&!Lt(e.arguments[1])}function j(e,t=new WeakSet){if(o(e,`fork`))return e;if(Array.isArray(e)){for(let n of e){let e=j(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){t.add(e);for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=j(r,t);if(e)return e}}}function M(e,t,r=new WeakSet){if(i(e)){let r=e.callee.property;if(n(r)&&t.has(r.name))return!0}return Array.isArray(e)?e.some(e=>M(e,t,r)):typeof e!=`object`||!e||r.has(e)?!1:(r.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&M(n,t,r)))}const Bt=new Set([`acquireRelease`,`acquireUseRelease`,`ensuring`,`forkIn`,`forkScoped`,`scoped`]);function Vt(e){return!o(e,`race`)&&!o(e,`raceAll`)?!1:!M(e.arguments,Bt)}function Ht(e){return o(e,`forEach`)&&!Lt(e.arguments[2])}const Ut=new Set([`retry`]);function Wt(e){return(zt(e)||Ht(e))&&M(e.arguments,Ut)}function N(e){if(typeof e!=`object`||!e||e.type!==`VariableDeclaration`)return[];let t=e.declarations;return Array.isArray(t)?t.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e.id;return n(t)?[t.name]:[]}):[]}function P(e,t=new Set,n=new WeakSet){if(Array.isArray(e)){for(let r of e)P(r,t,n);return t}if(typeof e!=`object`||!e||n.has(e))return t;if(n.add(e),e.type===`VariableDeclaration`)for(let n of N(e))t.add(n);for(let[r,i]of Object.entries(e))r!==`parent`&&P(i,t,n);return t}const Gt=new Set([`add`,`clear`,`delete`,`pop`,`push`,`reverse`,`set`,`shift`,`sort`,`splice`,`unshift`]);function Kt(e){if(typeof e!=`object`||!e)return;let t=e;if(t.type===`AssignmentExpression`&&n(t.left))return t.left.name;if(t.type===`UpdateExpression`&&n(t.argument))return t.argument.name;if(t.type===`CallExpression`&&typeof t.callee==`object`&&t.callee!==null&&t.callee.type===`MemberExpression`&&t.callee.computed!==!0&&n(t.callee.object)&&n(t.callee.property)&&Gt.has(t.callee.property.name))return t.callee.object.name}function F(e,t,n=P(e),r=new WeakSet){if(Array.isArray(e)){for(let i of e){let e=F(i,t,n,r);if(e)return e}return}if(typeof e!=`object`||!e||r.has(e))return;r.add(e);let i=Kt(e);if(i&&t.has(i)&&!n.has(i))return e;for(let[i,a]of Object.entries(e)){if(i===`parent`)continue;let e=F(a,t,n,r);if(e)return e}}function qt(e){if(o(e,`fork`)||o(e,`all`)||o(e,`forEach`))return e.arguments}const Jt=new Set([`all`,`forEach`,`fork`,`race`,`raceAll`]);function Yt(e,t=new WeakSet){return M(e,Jt)||D(e,`Queue`,`take`)?!0:Array.isArray(e)?e.some(e=>Yt(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&Yt(n,t)))}function Xt(e){return o(e,`uninterruptible`)&&Yt(e.arguments[0])}function Zt(e){return D(e,`Queue`,`unbounded`)||D(e,`PubSub`,`unbounded`)}function Qt(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`ObjectExpression`||t.type===`ArrayExpression`||t.type===`NewExpression`&&(n(t.callee,`Map`)||n(t.callee,`Set`))||t.type===`CallExpression`&&(n(t.callee,`Map`)||n(t.callee,`Set`))}function $t(e){if(typeof e!=`object`||!e||e.type!==`VariableDeclaration`)return[];let t=e,r=Array.isArray(t.declarations)?t.declarations:[];return t.kind===`let`||t.kind===`var`?N(e):r.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e.id;return n(t)&&Qt(e.init)?[t.name]:[]})}function en(e){if(typeof e!=`object`||!e||e.type!==`VariableDeclarator`)return;let t=e;return n(t.id)&&o(t.init,`fork`)?t.id.name:void 0}const tn=new Set([`await`,`interrupt`,`join`]);function nn(e){if(typeof e!=`object`||!e||e.type!==`CallExpression`)return;let t=e,r=t.callee;if(typeof r!=`object`||!r||r.type!==`MemberExpression`||r.computed===!0||!n(r.object,`Fiber`)||!n(r.property)||!tn.has(r.property.name)||!Array.isArray(t.arguments))return;let[i]=t.arguments;return n(i)?i.name:void 0}function rn(e){return r(e,`Effect`,`asVoid`)||D(e,`Effect`,`asVoid`)}function an(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type!==`CallExpression`||!Array.isArray(t.arguments)||typeof t.callee!=`object`||t.callee===null||t.callee.type!==`MemberExpression`||t.callee.computed===!0||!n(t.callee.property,`pipe`)?!1:o(t.callee.object,`all`)&&t.arguments.some(e=>rn(e))}function I(e){if(typeof e!=`object`||!e||!c(e))return[];let t=e;return n(t.callee,`pipe`)?t.arguments:[t.callee.object,...t.arguments]}function on(e){let[t]=I(e);return t!==void 0&&G(t)}function sn(e){if(on(e))return!0;if(typeof e==`object`&&e&&e.type===`ArrowFunctionExpression`){let t=e.body;return i(t)||on(t)}return!1}function cn(e){return u(e).some(e=>typeof e==`object`&&!!e&&(sn(e.argument)||i(e.argument)))}function L(e,t,r){if(typeof e!=`object`||!e||e.type!==`TSTypeReference`)return!1;let i=e.typeName;return typeof i==`object`&&!!i&&i.type===`TSQualifiedName`&&n(i.left,t)&&n(i.right,r)}function ln(e,t){return typeof e==`object`&&!!e&&e.type===`TSTypeReference`&&n(e.typeName,t)}function un(e){if(typeof e!=`object`||!e)return[];let t=e.typeParameters??e.typeArguments;if(typeof t!=`object`||!t)return[];let n=t.params??t.arguments;return Array.isArray(n)?n:[]}function dn(e){return n(e,`Error`)||ln(e,`Error`)}function fn(e){if(typeof e!=`object`||!e)return;let t=e.returnType;if(!(typeof t!=`object`||!t))return t.typeAnnotation??t}function pn(e){let t=fn(e);if(!L(t,`Effect`,`Effect`))return;let[,n]=un(t);return dn(n)?t:void 0}function mn(e){if(typeof e!=`object`||!e)return;let t=e;if(t.type!==`ExportNamedDeclaration`&&t.type!==`ExportDefaultDeclaration`)return;let n=t.declaration;if(!(typeof n!=`object`||!n)){if(n.type===`FunctionDeclaration`)return pn(n);if(n.type===`VariableDeclaration`)for(let e of n.declarations??[]){if(typeof e!=`object`||!e)continue;let t=e.init;if(typeof t==`object`&&t&&(t.type===`ArrowFunctionExpression`||t.type===`FunctionExpression`)){let e=pn(t);if(e)return e}}}}function hn(e,t,n,r=new WeakSet){return L(e,t,n)?!0:Array.isArray(e)?e.some(e=>hn(e,t,n,r)):typeof e!=`object`||!e||r.has(e)?!1:(r.add(e),Object.entries(e).some(([e,i])=>e!==`parent`&&hn(i,t,n,r)))}function gn(e,t=new WeakSet){return Pt(e,`wrapGraphqlCall`)?!0:Array.isArray(e)?e.some(e=>gn(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&gn(n,t)))}function _n(e){return o(e,`flatMap`)&&n(a(e),`applyResponse`)}function vn(e,t=new WeakSet){return _n(e)?!0:Array.isArray(e)?e.some(e=>vn(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&vn(n,t)))}function yn(e,t=new WeakSet){if(o(e,`catchAll`))return e;if(Array.isArray(e)){for(let n of e){let e=yn(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){t.add(e);for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=yn(r,t);if(e)return e}}}function bn(e){let t=I(e);if(t.length===0)return;let n=yn(t);if(n)return gn(t)||vn(t)?n:void 0}const xn=new Set([`get`,`set`,`update`,`modify`,`refresh`]);function R(e){if(typeof e!=`object`||!e)return;let t=e;if(!(t.type!==`ArrowFunctionExpression`&&t.type!==`FunctionExpression`))return t.body}function Sn(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`CallExpression`||!Array.isArray(t.arguments)||typeof t.callee!=`object`||t.callee===null||t.callee.type!==`MemberExpression`||t.callee.computed===!0)return!1;let r=t.callee;return(n(r.object,`Atom`)||n(r.object,`atomRegistry`))&&n(r.property)&&xn.has(r.property.name)}function Cn(e,t=new WeakSet){if(Sn(e))return e;if(Array.isArray(e)){for(let n of e){let e=Cn(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){t.add(e);for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=Cn(r,t);if(e)return e}}}function wn(e){if(!o(e,`sync`))return;let t=R(a(e));return t?Cn(t):void 0}function Tn(e){return n(e)?/(CollectionAtom|ListAtom|Visible.*Atom|ResultsAtom|ReadStateAtom)$/.test(e.name):!1}function En(e){if(typeof e!=`object`||!e)return;let t=e;if(t.type!==`CallExpression`||!Array.isArray(t.arguments)||!(n(t.callee,`get`)||r(t.callee,`Atom`,`get`)||r(t.callee,`get`,`get`)))return;let[i]=t.arguments;return Tn(i)?i:void 0}function Dn(e,t=new WeakSet){let n=En(e);if(n)return n;if(Array.isArray(e)){for(let n of e){let e=Dn(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){t.add(e);for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=Dn(r,t);if(e)return e}}}function On(e){return o(e,`provide`)&&e.arguments.length===1}function kn(e){if(c(e))return I(e).find(e=>On(e))}function An(e,t=new WeakSet){return typeof e==`object`&&e&&e.type===`SpreadElement`?!0:Array.isArray(e)?e.some(e=>An(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&An(n,t)))}function jn(e){if(!D(e,`Ref`,`update`)&&!D(e,`Ref`,`modify`))return!1;let t=e.arguments[1];return An(R(t))}function Mn(e){return typeof e==`object`&&!!e&&e.type===`ObjectExpression`&&Array.isArray(e.properties)&&e.properties.length===0}function z(e,t=new WeakSet){return D(e,`Object`,`entries`)?!0:Array.isArray(e)?e.some(e=>z(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&z(n,t)))}function Nn(e){if(jn(e))return!0;if(D(e,`Object`,`assign`)){let t=e.arguments;return t.length>=3&&Mn(t[0])}return D(e,`Object`,`fromEntries`)?z(e.arguments[0]):D(e,`JSON`,`stringify`)||D(e,`JSON`,`parse`)}function Pn(e){return n(e)?!0:typeof e==`object`&&!!e&&e.type===`MemberExpression`}function Fn(e){return typeof e!=`object`||!e||e.type!==`VariableDeclaration`?!1:e.declarations?.some(e=>{if(typeof e!=`object`||!e)return!1;let t=e.init;return typeof t==`object`&&!!t&&t.type===`TSAsExpression`&&typeof t.typeAnnotation==`object`&&t.typeAnnotation!==null&&t.typeAnnotation.type!==`TSConstKeyword`})??!1}function In(e){if(typeof e!=`object`||!e||e.type!==`BinaryExpression`)return!1;let t=e;if(t.operator!==`===`)return!1;let n=t.left,r=t.right;return typeof n==`object`&&!!n&&n.type===`UnaryExpression`&&n.operator===`typeof`&&typeof r==`object`&&!!r&&(r.type===`Literal`||r.type===`StringLiteral`)&&r.value===`boolean`}function Ln(e){return U(e,`orElse`)&&jr(W(e.arguments[0]))}function B(e){return typeof e==`object`&&!!e&&(e.type===`Literal`||e.type===`StringLiteral`)&&typeof e.value==`string`}function Rn(e){return n(e,`undefined`)}function zn(e){return typeof e==`object`&&!!e&&e.type===`LogicalExpression`&&e.operator===`??`&&(jr(e.right)||Rn(e.right))}function Bn(e){return D(e,`Option`,`fromNullable`)&&zn(e.arguments[0])}function V(e,t){if(!(typeof e!=`object`||!e||e.type!==`ObjectExpression`))for(let r of e.properties??[]){if(typeof r!=`object`||!r)continue;let e=r.key;if(n(e,t))return r.value}}function Vn(e){if(typeof e!=`object`||!e||e.type!==`BinaryExpression`)return!1;let t=e;return t.operator===`===`&&(H(t.left,!0)||H(t.right,!0))}function Hn(e){if(!D(e,`Option`,`match`))return!1;let t=e.arguments[1],n=V(t,`onSome`),r=V(t,`onNone`);return Vn(W(n))&&H(W(r),!1)}function Un(e){return typeof e!=`object`||!e||e.type!==`VariableDeclaration`?!1:e.declarations?.some(e=>typeof e==`object`&&!!e&&B(e.init))??!1}function H(e,t){return typeof e==`object`&&!!e&&(e.type===`Literal`||e.type===`BooleanLiteral`)&&e.value===t}function Wn(e){return r(e,`Effect`,`void`)}function U(e,t){if(typeof e!=`object`||!e)return!1;let r=e;return r.type===`CallExpression`&&Array.isArray(r.arguments)&&typeof r.callee==`object`&&r.callee!==null&&r.callee.type===`MemberExpression`&&r.callee.computed!==!0&&n(r.callee.object,`Match`)&&n(r.callee.property)&&(t===void 0||n(r.callee.property,t))}function W(e){if(!(typeof e!=`object`||!e||e.type!==`ArrowFunctionExpression`))return e.body}function Gn(e){if(!U(e))return!1;let[t,r]=e.arguments;return n(e.callee.property,`when`)?(H(t,!0)||H(t,!1))&&Wn(W(r)):n(e.callee.property,`orElse`)&&Wn(W(t))}const Kn=[`flatMap`,`map`,`andThen`,`tap`,`zipRight`];function qn(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`CallExpression`&&typeof t.callee==`object`&&t.callee!==null&&t.callee.type===`MemberExpression`&&t.callee.computed!==!0&&n(t.callee.object,`Stream`)&&n(t.callee.property)}function G(e,t=new WeakSet){return i(e)?!0:Array.isArray(e)?e.some(e=>G(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&G(n,t)))}function Jn(e,t=new WeakSet){return Kn.some(t=>o(e,t))||c(e)||qn(e)?!0:Array.isArray(e)?e.some(e=>Jn(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&Jn(n,t)))}function Yn(e){return G(e)&&Jn(e)}function Xn(e,t=new WeakSet){return U(e)&&Yn(n(e.callee.property,`when`)?W(e.arguments[1]):W(e.arguments[0]))?!0:Array.isArray(e)?e.some(e=>Xn(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&Xn(n,t)))}function Zn(e,t=new WeakSet){return U(e)?!0:Array.isArray(e)?e.some(e=>Zn(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&Zn(n,t)))}function Qn(e){return typeof e==`object`&&!!e&&e.type===`CallExpression`&&Array.isArray(e.arguments)&&r(e.callee,`Option`,`match`)}function $n(e){let t=W(e);return typeof t==`object`&&!!t&&t.type===`CallExpression`}function er(e,t=new WeakSet){if(o(e,`gen`))return e;if(Array.isArray(e)){for(let n of e){let e=er(n,t);if(e)return e}return}if(!(typeof e!=`object`||!e)&&!t.has(e)){t.add(e);for(let[n,r]of Object.entries(e)){if(n===`parent`)continue;let e=er(r,t);if(e)return e}}}function tr(e){if(!c(e)||typeof e!=`object`||!e)return!1;let t=e.callee.object;return typeof t==`object`&&!!t&&t.type===`CallExpression`&&r(t.callee,`Match`,`value`)}function nr(e){return tr(e)||typeof e==`object`&&!!e&&e.type===`CallExpression`&&(r(e.callee,`Option`,`match`)||r(e.callee,`Either`,`match`))}function rr(e,t=new WeakSet){return nr(e)?!0:Array.isArray(e)?e.some(e=>rr(e,t)):typeof e!=`object`||!e||t.has(e)?!1:(t.add(e),Object.entries(e).some(([e,n])=>e!==`parent`&&rr(n,t)))}function ir(e){if(typeof e!=`object`||!e)return[];let t=e;return t.type!==`ObjectExpression`||!Array.isArray(t.properties)?[]:t.properties.map(e=>typeof e==`object`&&e?e.value:void 0).filter(e=>e!==void 0)}function ar(e){if(typeof e!=`object`||!e||e.type!==`TSTypeAliasDeclaration`)return!1;let t=e.id,r=e.typeAnnotation;return n(t)&&/(?:Id|ID)$/.test(t.name)&&(r?.type===`TSStringKeyword`||r?.type===`TSNumberKeyword`)}function or(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`TSBooleanKeyword`?!0:t.type===`TSTypeAnnotation`&&typeof t.typeAnnotation==`object`&&t.typeAnnotation!==null&&t.typeAnnotation.type===`TSBooleanKeyword`}function sr(e){if(typeof e!=`object`||!e)return;let t=e;return t.type===`TSTypeAnnotation`&&typeof t.typeAnnotation==`object`&&t.typeAnnotation!==null?t.typeAnnotation:t}function cr(e){let t=sr(e);return t?.type===`TSStringKeyword`||t?.type===`TSNumberKeyword`}function lr(e){let t=sr(e);return t?.type===`TSAnyKeyword`||t?.type===`TSObjectKeyword`}function ur(e){let t=sr(e);return t?.type===`TSTypeReference`&&n(t.typeName,`Date`)}function dr(e){if(typeof e!=`object`||!e||!Array.isArray(e.params))return[];let t=/(?:id|amount|currency|account|user|order|customer|invoice|payment|price|total|quantity|transfer|fund|balance)/i;return e.params.filter(e=>n(e)&&cr(e.typeAnnotation)&&t.test(e.name))}function fr(e){return dr(e).length>=3}function pr(e){return n(e)?/^(?:is|has|should|with|allow|enable|can|use)[A-Z0-9_]/.test(e.name)&&or(e.typeAnnotation):!1}function mr(e){return typeof e!=`object`||!e||!Array.isArray(e.params)?[]:e.params.filter(pr)}function hr(e){if(n(e))return e.name;if(typeof e==`object`&&e&&typeof e.value==`string`)return e.value}function gr(e){return/(?:createdAt|updatedAt|expiresAt|expiredAt|renewedAt|startedAt|endedAt|deletedAt|timestamp|timeoutMs|durationMs|ttlMs|ttl)$/i.test(e)}function _r(e){if(typeof e!=`object`||!e||e.type!==`TSPropertySignature`)return!1;let t=e,n=hr(t.key),r=t.typeAnnotation;return n!==void 0&&gr(n)&&(cr(r)||ur(r))}function vr(e){if(typeof e!=`object`||!e)return[];let t=e;return t.type===`TSInterfaceDeclaration`&&typeof t.body==`object`&&t.body!==null&&Array.isArray(t.body.body)?t.body.body:t.type===`TSTypeLiteral`&&Array.isArray(t.members)?t.members:[]}function yr(e){return vr(e).filter(_r)}function br(e){return n(e)?/^(?:opts|options|config)$/i.test(e.name)&&lr(e.typeAnnotation):!1}function xr(e){return typeof e!=`object`||!e||!Array.isArray(e.params)?[]:e.params.filter(br)}const Sr=new Set([`==`,`===`,`!=`,`!==`,`>`,`>=`,`<`,`<=`]);function K(e,t=new WeakSet){if(Array.isArray(e))return e.reduce((e,n)=>e+K(n,t),0);if(typeof e!=`object`||!e||t.has(e))return 0;t.add(e);let n=e;return n.type===`BinaryExpression`&&Sr.has(String(n.operator))?1:n.type===`LogicalExpression`?K(n.left,t)+K(n.right,t):0}function Cr(e){return typeof e==`object`&&!!e&&e.type===`LogicalExpression`&&K(e)>=3}function wr(e){if(typeof e!=`object`||!e||e.type!==`MemberExpression`)return;let t=e;if(t.computed===!0||!n(t.object)||!n(t.property))return;let r=t.property.name;if(/(?:cancelled|canceled|shipped|approved|rejected|pending|active|inactive|enabled|disabled|locked|archived|deleted|submitted|processing|failed|complete|completed)$/i.test(r))return{objectName:t.object.name,propertyName:r}}function q(e,t=new Map,n=new WeakSet){let r=wr(e);if(r){let e=t.get(r.objectName)??new Set;return e.add(r.propertyName),t.set(r.objectName,e),t}if(Array.isArray(e)){for(let r of e)q(r,t,n);return t}if(typeof e!=`object`||!e||n.has(e))return t;n.add(e);let i=e;return i.type===`LogicalExpression`?(q(i.left,t,n),q(i.right,t,n),t):t}function Tr(e){return typeof e!=`object`||!e||e.type!==`LogicalExpression`?!1:Array.from(q(e).values()).some(e=>e.size>=2)}function Er(e){return o(e,`fail`)&&B(a(e))}function Dr(e){if(typeof e!=`object`||!e||e.type!==`ThrowStatement`)return!1;let t=e.argument;return typeof t==`object`&&!!t&&t.type===`NewExpression`&&n(t.callee,`Error`)&&Array.isArray(t.arguments)&&B(t.arguments[0])}function Or(e){return typeof e!=`object`||!e||!Array.isArray(e.params)?!1:e.params.some(e=>n(e)&&/(?:^id$|Id$|ID$)/.test(e.name)&&cr(e.typeAnnotation))}function kr(e){if(typeof e!=`object`||!e||e.type!==`FunctionDeclaration`)return!1;let t=e.id;return n(t)&&/(?:Admin|Public|Internal|External|Private|Backoffice|Panel)/.test(t.name)&&Or(e)}function Ar(e){if(typeof e!=`object`||!e||e.type!==`BinaryExpression`)return!1;let t=e;return[`==`,`===`,`!=`,`!==`].includes(String(t.operator))&&(B(t.left)||B(t.right))&&!In(t)}function J(e,t,n){e.report({message:n,node:t})}function jr(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`NullLiteral`||t.type===`Literal`&&t.value===null}function Y(e){if(typeof e!=`object`||!e)return;let t=e.source;if(typeof t==`string`)return t;if(typeof t==`object`&&t){let e=t.value;if(typeof e==`string`)return e}}function X(e){return e===`effect`||e.startsWith(`effect/`)||e===`@effect-atom/atom-react`}function Mr(e,n){return t({create(t){let r=!1;return{ImportDeclaration(e){let t=Y(e);t&&X(t)&&(r=!0)},[e](e){r&&J(t,e,n)}}}})}const Nr=new Set([`useState`,`useReducer`,`useContext`,`useCallback`,`useEffect`,`useSyncExternalStore`]),Pr=t({create(e){return{CallExpression(t){let r=t.callee,i=n(r)?r.name:typeof r==`object`&&r&&r.type===`MemberExpression`&&n(r.property)?r.property.name:void 0;i&&Nr.has(i)&&J(e,r,`Rule: avoid React state hooks. Why: they bypass the atom runtime and break reactive flow. Fix: use @effect-atom/atom-react instead.`)}}}}),Fr=Mr(`IfStatement`,`Rule: avoid imperative if branching. Why: Effect code should keep branching explicit and typed. Fix: use Match.value/Match.type or Effect combinators instead.`),Ir=Mr(`SwitchStatement`,`Rule: avoid imperative switch branching. Why: Effect code should keep branching explicit and typed. Fix: use Match.value/Match.type instead.`),Lr=Mr(`ConditionalExpression`,`Rule: avoid ternary expressions. Why: they hide control flow inside expressions. Fix: use Option.match/Either.match/Match.value or data combinators, then run one Effect pipeline.`),Rr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ReturnStatement(n){t&&jr(n.argument)&&J(e,n,`Rule: avoid returning null. Why: null is a sentinel that forces defensive guards. Fix: use Option.none for absence or Effect.fail for errors.`)}}}}),zr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&r(n.callee,`Option`,`as`)&&J(e,n,`Rule: avoid Option.as. Why: it hides selection and encourages placeholder flows. Fix: use Option.map or Option.match and return the value explicitly.`)}}}}),Br=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},MemberExpression(n){t&&r(n,`Effect`,`never`)&&J(e,n,`Rule: avoid Effect.never. Why: it hides lifecycle and leaks resources. Fix: use Stream or explicit acquire/release lifecycles with clear teardown.`)}}}}),Vr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t||!oe(n))return;let r=l(n.callee.body);r&&J(e,r,`Rule: avoid nested IIFEs. Why: they hide sequencing and push wrapper hacks. Fix: bind a named context with const and keep one flat pipeline with a single Match/Option decision.`)}}}}),Hr=t({create(e){return{ObjectExpression(t){ir(t).some(e=>rr(e))&&J(e,t,`Rule: avoid Match/Option/Either inside object literals. Why: it hides the decision and invites workaround scaffolding. Fix: compute the value first (context), then build the object from named values with one flat decision.`)}}}}),Ur=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&se(n)&&J(e,n,`Rule: avoid immediate invocation of inline functions. Why: it hides decisions and sequencing. Fix: bind a named context with const and keep one Match/Option decision in a flat pipeline.`)}}}}),Wr=t({create(e){return{CallExpression(t){for(let n of le(t))J(e,n,`Rule: avoid block-bodied arrow callbacks with returns. Why: they hide local control flow. Fix: use expression-only callbacks and move the logic into a single pipeline (pipe/Match/Option/A.map).`)}}}}),Gr=t({create(e){return{CallExpression(t){for(let n of ue(t))J(e,n,`Rule: avoid returns inside inline callbacks. Why: they hide control flow. Prefer expression-only callbacks, but leaf-level Effect branches with local bindings may use returns when needed.`)}}}}),Kr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&fe(n,`fn`)&&J(e,n,`Rule: avoid Effect.fn generator wrappers. Why: they hide sequencing and dodge ladder rules. Fix: keep a single flat pipeline or use one Effect.gen.`)}}}}),qr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&o(n,`sync`)&&O(a(n))&&J(e,n,`Rule: avoid console.* inside Effect.sync. Why: it hides side effects. Fix: replace with Effect.log* or remove the console call.`)}}}}),Jr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=d(n,`gen`);if(!t||!r)return;let i=er(r.body);i&&J(e,i,`Rule: avoid nested Effect.gen. Why: nested generators hide sequencing. Fix: flatten to a single Effect.gen per method or a single flat pipeline.`)}}}}),Yr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=me(n);r&&J(e,r,"Rule: use yield* inside Effect.gen. Why: plain yield returns an Effect value without delegating to the Effect interpreter. Fix: replace `yield Effect.x` with `yield* Effect.x`.")}}}}),Xr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=ge(n);r&&J(e,r,`Rule: avoid repeated piped yields inside Effect.gen. Why: decorated effects hidden inside generator steps obscure the workflow. Fix: extract decorated effects first, then yield the named workflow steps.`)}}}}),Zr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=ye(n);r&&J(e,r,`Rule: avoid Effect.gen for simple mapping. Why: tiny generators hide pure transformations behind workflow syntax. Fix: map the yielded effect with Effect.map or a named pure transformation.`)}}}}),Qr=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=Ce(n);r&&J(e,r,`Rule: prefer Effect.gen for workflow sequencing. Why: long flatMap/andThen/tap pipelines read like imperative workflow. Fix: move the sequential story into one Effect.gen and keep pipe for behavior decoration.`)}}}}),$r=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&we(n)&&J(e,n,`Rule: avoid large anonymous flow expressions. Why: long pure transformation chains need a domain name. Fix: extract a named flow or split the transformation into named pure steps.`)}}}}),ei=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=De(n);r&&J(e,r,`Rule: avoid Effect work inside flow. Why: flow should stay a reusable pure transformation boundary. Fix: keep Effect sequencing, logging, retries, and dependency access in Effect pipelines.`)}}}}),ti=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=Oe(n);r&&J(e,r,`Rule: prefer named flow transformations. Why: non-trivial pure transformations passed inline are hard to reuse and review. Fix: extract the flow to a named const.`)}}}}),ni=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=je(n);r&&J(e,r,"Rule: prefer .pipe() for behavior decoration. Why: retry, timeout, spans, logging, recovery, DI, and value transforms decorate an existing effect. Fix: write `program.pipe(Effect.retry(policy))` instead of `Effect.retry(program, policy)`.")}}}}),ri=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=Pe(n);r&&J(e,r,`Rule: extract decorated effects before Effect.gen. Why: repeated retry/timeout/span/logging decorators inside generator yields bury behavior policy in workflow steps. Fix: name the decorated effects first, then yield the workflow story.`)}}}}),ii=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=Fe(n);r&&J(e,r,`Rule: avoid workflow sequencing inside behavior pipes. Why: behavior pipes should answer how an effect behaves, not hide the workflow story. Fix: move multi-step sequencing into Effect.gen and keep retry/timeout/spans/logging as decorators around named effects.`)}}}}),ai=t({create(e){let t=!1;function n(n){let r=Ie(n);t&&r&&J(e,r,`Rule: avoid mixing Effect style pillars in one function. Why: workflow, pure transformation, behavior decoration, and Layer wiring each need a clear boundary. Fix: extract named concepts for each pillar and compose them at the call site.`)}return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},FunctionDeclaration:n,FunctionExpression:n,ArrowFunctionExpression:n}}}),oi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=Re(n);t&&r&&J(e,r,`Rule: avoid clever Effect expressions. Why: deeply nested expressions that combine style pillars hide the domain story. Fix: extract named workflow, pure transformation, and behavior steps.`)}}}}),si=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=ze(n);t&&r&&J(e,r,`Rule: prefer extracting named concepts from oversized anonymous callbacks. Why: multi-step inline callbacks hide domain intent. Fix: name the transformation, policy, or workflow step before passing it into Effect.`)}}}}),ci=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&He(n)&&J(e,n,`Rule: prefer Effect.Service. Fix: replace Context.Tag service definitions.`)}}}}),li=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ClassDeclaration(n){let r=y(n);t&&r&&Ue(r)&&J(e,r,`Rule: do not call Layer.provide inside Effect.Service. Fix: move layer wiring to app/test boundaries.`)}}}}),ui=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ClassDeclaration(n){let r=y(n);t&&r&&!We(r)&&J(e,r,`Rule: set accessors: true. Fix: add it to Effect.Service options.`)}}}}),di=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ClassDeclaration(n){let r=y(n),i=r?qe(r):void 0;t&&i&&J(e,i,`Rule: declare service dependencies.`)}}}}),fi=t({create(e){return{ImportDeclaration(t){let n=Ge(t);n&&J(e,n,`Rule: avoid namespace imports from Effect packages.`)}}}}),pi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ExportNamedDeclaration(n){let r=t?st(n):void 0;r&&J(e,r,`Rule: avoid exported manual service objects.`)}}}}),mi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=t?Ze(n):void 0;r&&J(e,r,`Rule: prefer Layer.pipe for nested layer provisioning.`)}}}}),hi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=t?$e(n):void 0;r&&J(e,r,`Rule: avoid inline layer provisioning inside programs.`)}}}}),gi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=t?et(n):void 0;r&&J(e,r,`Rule: prefer Layer.mergeAll for infrastructure layer groups.`)}}}}),_i=t({create(e){let t=!1,n=0;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},VariableDeclaration(r){let i=t?nt(r):void 0;i&&(n+=1,n>=3&&J(e,i,`Rule: group service layers by concern.`))}}}}),vi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},FunctionDeclaration(n){let r=Xe(n);t&&r&&J(e,r,`Rule: avoid Layer composition inside request handlers.`)}}}}),yi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ClassDeclaration(n){let r=y(n),i=r?at(r):void 0;t&&i&&J(e,i,`Rule: return Effect from service methods.`)}}}}),bi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Gn(n)&&J(e,n,`Rule: avoid void Match branches. Why: they hide guard-style control flow. Fix: remove the no-op branch or select a value and run one Effect pipeline outside the Match.`)}}}}),xi=t({create(e){return{CallExpression(t){tr(t)&&Xn(t.arguments)&&J(e,t,`Rule: avoid multi-step sequencing inside Match branches. Why: it hides control flow. Fix: select a value in Match, then run one Effect pipeline outside. Avoid data-encoded conditionals (Option.toArray/forEach) that only rewrap the branch.`),Qn(t)&&Yn(t.arguments)&&J(e,t,`Rule: avoid multi-step sequencing inside Option.match branches. Why: it hides control flow. Prefer selecting a value in Option.match, then run one Effect pipeline outside. Leaf-level flows with local bindings may keep Option.match but should stay linear.`)}}}}),Si=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=a(n),i=W(r);t&&o(n,`sync`)&&$n(r)&&!Nt(i)&&J(e,n,`Rule: avoid Effect.sync around side effects. Why: it hides intent. Fix: use Effect.log* or an explicit pipeline step for the side effect.`)}}}}),Ci=t({create(e){return{CallExpression(t){o(t,`as`)&&k(a(t))&&J(e,t,`Rule: avoid Effect.as for side effects. Why: it hides side effects and turns them into placeholders. Fix: use explicit pipeline steps that return real values with Effect.flatMap, Effect.andThen, or Effect.tap.`),o(t,`zipRight`)&&k(a(t))&&J(e,t,`Rule: avoid Effect.zipRight for side effects. Why: it hides side effects and discards values. Fix: use explicit pipeline steps that return real values with Effect.flatMap, Effect.andThen, or Effect.tap.`)}}}}),wi=t({create(e){return{CallExpression(t){o(t,`all`)&&A(t.arguments[0])&&It(t.arguments[1])&&J(e,t,`Rule: avoid Effect.all for sequential side-effect steps. Why: it hides imperative sequencing in an array. Fix: use one explicit linear pipeline with Effect.andThen/flatMap and reserve Effect.all for real value aggregation.`),an(t)&&A(a(t.callee.object))&&J(e,t,`Rule: avoid Effect.all for sequential side-effect steps. Why: it hides imperative sequencing in an array. Fix: use one explicit linear pipeline with Effect.andThen/flatMap and reserve Effect.all for real value aggregation.`)}}}}),Ti=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=lt(n);r&&J(e,r,`Rule: avoid async callbacks in Effect combinators. Why: async callbacks return Promises and bypass Effect failure, interruption, and tracing semantics. Fix: return an Effect and compose with Effect.flatMap/fromPromise at the boundary.`)}}}}),Ei=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=ut(n);r&&J(e,r,`Rule: avoid throw inside Effect logic. Why: thrown exceptions bypass typed Effect error channels and interruption semantics. Fix: return Effect.fail with a structured tagged error.`)}}}}),Di=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=Ot(n);r&&J(e,r,`Rule: avoid Effect.orDie outside runtime boundaries. Why: converting typed failures into defects hides recoverable domain errors. Fix: keep typed errors in domain logic and reserve orDie/orDieWith for explicit application boundaries.`)}}}}),Oi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=At(n);r&&J(e,r,`Rule: avoid swallowing errors in catchAll. Why: succeed/void recovery can hide failures without telemetry or typed recovery. Fix: log, re-fail with a structured error, or recover through an explicit domain branch.`)}}}}),ki=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=Mt(n);r&&J(e,r,`Rule: avoid Effect.ignore. Why: ignoring failable effects hides failure ownership. Fix: handle the error with typed recovery, log and re-fail, or isolate the ignore at an explicit boundary with a documented reason.`)}}}}),Ai=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=dt(n);r&&J(e,r,`Rule: avoid try/catch inside Effect logic. Why: it bypasses typed error channels and can miss interruption/cause semantics. Fix: use Effect.try, Effect.catchAll, Effect.catchTag, or typed error combinators.`)}}}}),ji=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=mt(n);r&&J(e,r,`Rule: avoid Promise APIs inside Effect logic. Why: Promise APIs bypass Effect scheduling, typed errors, cancellation, and tracing. Fix: use Effect.all, Effect.tryPromise, or move Promise interop to a boundary adapter.`)}}}}),Mi=t({create(e){return{TryStatement(t){J(e,t,`Rule: avoid try/catch in Effect files. Why: it bypasses Effect error channels and reintroduces imperative control flow. Fix: model failures in Effect and handle them with typed errors and Effect combinators.`)}}}}),Ni=t({create(e){return{VariableDeclaration(t){for(let n of t.declarations??[])sn(n.init)&&J(e,t,"Rule: avoid Effect wrapper aliases (`const x = ...Effect...`). Why: it creates wrapper choreography and bloats consts. Fix: inline the pipeline at the call site or define a real domain function that returns data, not an Effect wrapper.")},FunctionDeclaration(t){cn(t.body)&&J(e,t,"Rule: avoid Effect wrapper aliases (`function x(...) { return Effect... }`). Why: it creates wrapper choreography and bloats consts. Fix: inline the pipeline at the call site or define a real domain function that returns data, not an Effect wrapper.")}}}}),Pi=t({create(e){return{TSTypeReference(t){(L(t,`Effect`,`Effect`)||L(t,`Layer`,`Layer`))&&J(e,t,"Rule: avoid manual Effect channel tuples (`Effect.Effect<...>` / `Layer.Layer<...>`). Why: channels compose through the Effect pipeline and services; hand-written tuples desync from the real flow. Fix: drop the generic and let the return type infer from the Effect/Layer you return, or expose a service method that returns the effect directly.")}}}}),Fi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=t?bn(n):void 0;r&&J(e,r,`Rule: avoid catchAll after wrapGraphqlCall/applyResponse. Why: the envelope already surfaces structured errors. Fix: handle errors in the response mapping instead of catchAll.`)}}}}),Ii=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ExpressionStatement(n){t&&tr(n.expression)&&Zn(n.expression.arguments)&&J(e,n.expression,`Rule: avoid Match.value(...).pipe(...) as a statement. Why: it runs side effects during render. Fix: move the side effect into an Effect runtime action or event handler, and keep Match as a pure expression.`)}}}}),Li=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=t?wn(n):void 0;r&&J(e,r,`Rule: do not wrap Atom/atomRegistry ops in Effect.sync. Why: it hides side effects and breaks atom flow. Fix: call Atom.get/Atom.set/Atom.update/Atom.modify/Atom.refresh directly.`)}}}}),Ri=t({create(e){return{CallExpression(t){if(!D(t,`Atom`,`family`))return;let n=Dn(t.arguments);n&&J(e,n,`Keyed projection atom reads collection atom. Why: Atom.family should project from keyed/source atoms, not broad collection state. Fix: pass the keyed atom into the family or create a keyed source atom before reading.`)}}}}),zi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){let r=t?kn(n):void 0;r&&J(e,r,"Rule: do not inline runtime provisioning inside local helper Effect code. Why: `yield* SomeRuntime.pipe(Effect.provide(SomeRuntimeLive))` and equivalent inline provide chains hide dependency assembly instead of owning it at an Effect.Service boundary or one exported Effect boundary. Fix: declare the live dependency on the owning service or provide it once at the exported boundary, then `yield*` the runtime or service directly inside the body.")}}}}),Bi=t({create(e){return{CallExpression(t){Nn(t)&&J(e,t,"Rule: avoid naked JS state patching/rebuild and raw JSON shortcuts in Effect transitions. Why: spread/Object.assign/fromEntries and inline JSON parse/stringify hide state intent and bypass explicit model contracts. Fix: use `effect/Record` combinators (`Record.set` / `Record.modify` / `Record.remove`) inside `Struct.evolve`, rebuild with schema constructors (`Schema.make` or field `.make`), and keep serialization at boundaries with schema encode/decode flows. Use `linting.md` guidance when available.")}}}}),Vi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&o(n,`succeed`)&&Pn(a(n))&&J(e,n,`Rule: avoid Effect.succeed(variable) as a branch placeholder. Why: it hides a decision and turns data into pseudo-control flow. Fix: select a plain value (Option/Match) and then run one Effect pipeline after the decision; if you already read the state, return it as a value. Avoid Option.toArray/forEach hacks that just re-encode the branch.`)}}}}),Hi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},TSTypeAliasDeclaration(n){t&&hn(n.typeAnnotation,`Effect`,`Effect`)&&J(e,n.typeAnnotation,`Rule: avoid Effect.Effect type aliases. Why: they hide the service surface and make types opaque. Fix: keep Effect types on service methods or inline at the call site.`)}}}}),Ui=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ExportNamedDeclaration(n){let r=t?mn(n):void 0;r&&J(e,r,`Rule: avoid public Effect APIs with generic Error. Why: public services need recoverable, typed error contracts. Fix: expose tagged domain errors instead of Error.`)},ExportDefaultDeclaration(n){let r=t?mn(n):void 0;r&&J(e,r,`Rule: avoid public Effect APIs with generic Error. Why: public services need recoverable, typed error contracts. Fix: expose tagged domain errors instead of Error.`)}}}}),Wi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},VariableDeclaration(n){t&&Fn(n)&&J(e,n,"Rule: avoid `as` assertions on decoded model flow. Why: assertions hide schema drift and allow untyped overlays. Fix: decode with the correct schema type and read fields directly.")}}}}),Gi=t({create(e){let t=!1,n=!1,r=[],i=new WeakSet,a=t=>{typeof t!=`object`||!t||i.has(t)||(i.add(t),J(e,t,`Rule: avoid local unknown-to-boolean coercion helpers in services. Why: runtime coercion belongs at schema boundary, not in service flow. Fix: decode boolean optionality in schema and read typed booleans in the Effect pipeline.`))};return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},BinaryExpression(e){!t||!In(e)||(n?a(e):r.push(e))},CallExpression(e){if(!(!t||!Ln(e))){n=!0;for(let e of r)a(e)}}}}}),Ki=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Bn(n)&&J(e,n,"Rule: avoid nullish re-wrap inside Option.fromNullable. Why: `x ?? null` and `x ?? undefined` add noise and hide source shape. Fix: pass the source directly to Option.fromNullable.")}}}}),qi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Hn(n)&&J(e,n,"Rule: avoid repeated Option boolean normalization (`onSome: value === true, onNone: false`). Why: it scatters coercion rules across services. Fix: normalize once at schema boundary and read booleans directly.")}}}}),Ji=t({create(e){return{CallExpression(t){o(t,`succeed`)&&B(a(t))&&J(e,t,`Rule: avoid returning string tokens. Why: it encodes control flow and forces defensive branching. Fix: return domain values (Option/Either/tagged unions) or real Effect results instead.`)}}}}),Yi=t({create(e){return{VariableDeclaration(t){Un(t)&&J(e,t,`Rule: avoid string status constants. Why: they encode control flow and force defensive branching. Fix: use tagged unions, Option/Either, or meaningful domain values instead of string tokens.`)}}}}),Xi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},TSTypeAliasDeclaration(n){t&&ar(n)&&J(e,n,"Rule: avoid raw primitive domain ID aliases. Why: `type UserId = string` does not protect boundaries from swapped IDs. Fix: use Schema branded IDs or a domain constructor that validates and brands the value.")}}}}),Zi=t({create(e){let t=!1,n=n=>{if(t)for(let t of mr(n))J(e,t,"Rule: avoid boolean behavior flags in domain operations. Why: flags like `shouldNotify` hide use cases and create implicit branching. Fix: model intent with a command/tagged union or split the operation into explicit functions.")};return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},FunctionDeclaration:n,FunctionExpression:n,ArrowFunctionExpression:n}}}),Qi=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},BinaryExpression(n){t&&Ar(n)&&J(e,n,`Rule: avoid magic domain string comparisons. Why: comparing domain state to raw strings scatters status vocabulary and misses exhaustiveness. Fix: use a tagged union, Schema literal union, or Match over a named domain status.`)}}}}),$i=t({create(e){let t=!1,n=n=>{t&&fr(n)&&J(e,n,`Rule: avoid primitive-heavy domain parameters. Why: clusters of raw string/number domain values are easy to swap and have no invariant boundary. Fix: introduce branded types or a command/schema object with named validated fields.`)};return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},FunctionDeclaration:n,FunctionExpression:n,ArrowFunctionExpression:n}}}),ea=t({create(e){let t=!1,n=n=>{if(t)for(let t of yr(n))J(e,t,`Rule: avoid raw time fields in domain models. Why: number and Date fields hide units, clock ownership, and duration semantics. Fix: model durations with Effect Duration and keep raw timestamps at decode/encode boundaries.`)};return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},TSInterfaceDeclaration:n,TSTypeLiteral:n}}}),ta=t({create(e){let t=!1,n=n=>{if(t)for(let t of xr(n))J(e,t,"Rule: avoid overloaded options objects. Why: `opts`, `options`, and `config` typed as any/object hide required fields and validation. Fix: accept unknown at the boundary and decode with Schema, or use a named typed command/config model.")};return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},FunctionDeclaration:n,FunctionExpression:n,ArrowFunctionExpression:n}}}),na=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},LogicalExpression(n){t&&Cr(n)&&J(e,n,`Rule: avoid embedding domain logic in conditionals. Why: multi-clause business rules become hard to test, reuse, and audit. Fix: extract a named domain predicate or validation Effect and call that from the branch.`)}}}}),ra=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},LogicalExpression(n){t&&Tr(n)&&J(e,n,`Rule: avoid implicit state machines made from boolean flags. Why: multiple flags on one domain object allow impossible states. Fix: model the lifecycle as a tagged union or Data.TaggedEnum.`)}}}}),ia=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Er(n)&&J(e,n,`Rule: avoid ad hoc domain errors. Why: string failures hide recovery semantics and observability. Fix: use Data.TaggedError or a structured domain error union.`)},ThrowStatement(n){t&&Dr(n)&&J(e,n,`Rule: avoid ad hoc domain errors. Why: thrown string Error values bypass typed Effect error channels. Fix: return Effect.fail with a structured tagged domain error.`)}}}}),aa=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},FunctionDeclaration(n){t&&kr(n)&&J(e,n,`Rule: avoid domain meaning by folder or context naming alone. Why: admin/public/internal meaning should be represented in types or services, not inferred from helper names. Fix: encode context with branded IDs, commands, policies, or service boundaries.`)}}}}),oa=t({create(e){return{CallExpression(t){r(t.callee,`Effect`,`as`)&&J(e,t.callee,`Rule: avoid Effect.as wrappers. Why: they can hide meaningful sequencing or value flow. Fix: return the intended value directly or use explicit Effect.map/andThen.`)}}}}),sa=t({create(e){return{MemberExpression(t){r(t,`Effect`,`Do`)&&J(e,t,`Rule: avoid Effect.Do. Why: it hides sequencing behind builder state. Fix: use Effect.gen or a direct pipe.`)}}}});function ca(e,n,i){return t({create(t){return{CallExpression(a){r(a.callee,e,n)&&J(t,a.callee,i)}}}})}const la=ca(`Effect`,`bind`,`Rule: avoid Effect.bind. Why: it obscures linear data flow behind builder-style binding. Fix: use Effect.gen or a direct pipe with flatMap/map.`),ua=ca(`Runtime`,`runFork`,`Rule: avoid Runtime.runFork. Why: detached fibers hide lifetime and interruption ownership. Fix: run effects through the application runtime boundary.`),da=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Et(n)&&J(e,n.callee,`Rule: avoid running Effects outside runtime boundaries. Why: direct Effect.run* calls scatter execution ownership. Fix: return Effects from domain logic and run them at the app, CLI, worker, route, or test boundary.`)}}}}),fa=ca(`Effect`,`async`,`Rule: avoid Effect.async. Why: manual callback bridges are easy to leak or resume incorrectly. Fix: use scoped Effect APIs or a dedicated platform adapter.`),pa=t({create(e){return{CallExpression(t){ee(t)&&J(e,t,`Rule: avoid deeply nested Effect calls (Effect.xx(Effect.yy(Effect.zz(...)))). Why: they hide sequencing and spread flow. Fix: build values first, then run one flat Effect pipeline.`)}}}}),ma=t({create(e){return{VariableDeclaration(t){for(let n of t.declarations??[])ee(n.init)&&J(e,n.init,`Rule: avoid nested Effect combinators. Why: they hide sequencing and create laddered control flow. Fix: build context once (Effect.all/Effect.map) and then run a single flat pipeline.`)},ReturnStatement(t){ee(t.argument)&&J(e,t.argument,`Rule: avoid nested Effect combinators. Why: they hide sequencing and create laddered control flow. Fix: build context once (Effect.all/Effect.map) and then run a single flat pipeline.`)}}}}),ha=t({create(e){return{VariableDeclaration(t){for(let n of t.declarations??[]){let t=ne(n.init);t&&J(e,n.init,t)}},ReturnStatement(t){let n=ne(t.argument);n&&J(e,t.argument,n)}}}}),ga=t({create(e){return{CallExpression(t){c(t)&&ae(t.arguments)&&J(e,t,`Rule: avoid nested pipe() chains. Why: they hide sequencing. Fix: refactor into one flat pipeline with a single decision point.`)}}}}),_a=t({create(e){return{CallExpression(t){te(t)&&J(e,t,`Rule: avoid nested Effect call towers (Effect.fn(Effect.fn(...))). Why: it hides sequencing. Fix: build the inner Effect first, then use pipe/Effect.flatMap/Effect.andThen for a single flat pipeline.`)}}}}),va=t({create(e){return{CallExpression(t){ie(t)&&J(e,t,`Rule: avoid Effect.orElse around sequencing chains. Why: it hides error handling and splits the flow. Fix: move error handling to a single terminal decision after the pipeline.`)}}}}),ya=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&zt(n)&&J(e,n,"Rule: avoid unbounded Effect.all over mapped collections. Why: it can launch work for every item at once and fail under load. Fix: pass an explicit `{ concurrency: n }` option or use a bounded batching strategy.")}}}}),ba=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ExpressionStatement(n){t&&o(n.expression,`fork`)&&J(e,n.expression,`Rule: avoid fire-and-forget Effect.fork. Why: detached fibers hide failure, interruption, and ownership. Fix: bind the fiber and join/await/interrupt it, or use Effect.forkScoped / Effect.forkIn with an explicit scope.`)}}}}),xa=t({create(e){let t=!1,n=n=>{if(!t)return;let r=j(n.body);r&&J(e,r,`Rule: avoid Effect.fork inside loops. Why: loop-spawned fibers create unbounded concurrency and unclear ownership. Fix: use Effect.forEach / Effect.all with an explicit concurrency limit or a scoped supervisor.`)};return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},ForStatement:n,ForInStatement:n,ForOfStatement:n,WhileStatement:n,DoWhileStatement:n}}}),Sa=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Vt(n)&&J(e,n,`Rule: avoid Effect.race without loser cleanup. Why: racing effects without ensuring/scoped cleanup can leak losing work or resources. Fix: wrap raced effects with Effect.ensuring/acquireRelease or use a scoped race boundary.`)}}}}),Ca=t({create(e){let t=!1,n=new Map,r=new Set;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},VariableDeclarator(e){let t=en(e);t&&n.set(t,e)},CallExpression(e){let t=nn(e);t&&r.add(t)},"Program:exit"(){if(t)for(let[t,i]of n)r.has(t)||J(e,i,`Rule: avoid unobserved forked fibers. Why: forked fiber failures and interruption should be observed. Fix: pass the fiber to Fiber.join, Fiber.await, Fiber.interrupt, or use scoped fork APIs.`)}}}}),wa=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Wt(n)&&J(e,n,`Rule: avoid unbounded concurrent retry. Why: retry inside unbounded parallel collection effects can amplify load and create retry storms. Fix: add an explicit concurrency limit or move retry behind a bounded queue/backoff policy.`)}}}}),Ta=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=wt(n);r&&J(e,r,`Rule: avoid blocking sync calls inside Effect logic. Why: sync fs/crypto/zlib calls block the runtime worker and hide throughput costs. Fix: use Effect.async/tryPromise at a platform boundary, stream APIs, or a dedicated blocking executor.`)}}}}),Ea=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=_t(n);r&&J(e,r,`Rule: avoid Promise concurrency APIs inside Effect logic. Why: Promise.all/allSettled/race/any bypass Effect concurrency, interruption, tracing, and error channels. Fix: use Effect.all, Effect.forEach, Effect.race, or a boundary adapter with explicit cancellation ownership.`)}}}}),Da=t({create(e){let t=!1,n=new Set;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},VariableDeclaration(e){if(!(e.kind!==`let`&&e.kind!==`var`))for(let t of N(e))n.add(t)},CallExpression(r){if(!t)return;let i=qt(r);if(!i)return;let a=F(i,n);a&&J(e,a,`Rule: avoid mutating shared state across fibers. Why: outer let/var state mutated from forked or parallel work creates nondeterministic races. Fix: model shared state with Ref/SynchronizedRef/Queue or aggregate immutable results with bounded Effect.all/forEach.`)}}}}),Oa=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){if(!t)return;let r=xt(n);r&&J(e,r,`Rule: avoid timeout around noninterruptible Promise effects. Why: timing out Effect.promise or tryPromise without a signal leaves the underlying Promise running after interruption. Fix: use Effect.tryPromise with an AbortSignal parameter and pass it to the async API.`)}}}}),ka=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Xt(n)&&J(e,n,`Rule: avoid uninterruptible concurrent regions. Why: wrapping fork/race/all/forEach or queue work in uninterruptible blocks cancellation and can strand work under shutdown. Fix: keep only the critical section uninterruptible and leave concurrent work interruptible or scoped.`)}}}}),Aa=t({create(e){let t=!1;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},CallExpression(n){t&&Zt(n)&&J(e,n,`Rule: avoid unbounded Queue or PubSub constructors. Why: unbounded buffers hide backpressure and can fail under load. Fix: use Queue.bounded / PubSub.bounded with an explicit capacity at the owning boundary.`)}}}}),ja=t({create(e){let t=!1,n=new Set;return{ImportDeclaration(e){let n=Y(e);n&&X(n)&&(t=!0)},VariableDeclaration(e){for(let t of $t(e))n.add(t)},CallExpression(r){if(!t)return;let i=qt(r);if(!i)return;let a=F(i,n);a&&J(e,a,`Rule: avoid global mutable concurrency state. Why: module-scope mutable state touched from concurrent Effect work behaves like shared mutable global state. Fix: move ownership into Ref/SynchronizedRef/Queue/Layer state or pass immutable values through bounded effects.`)}}}}),Ma={"no-react-state":Pr,"no-if-statement":Fr,"no-switch-statement":Ir,"no-ternary":Lr,"no-return-null":Rr,"no-option-as":zr,"no-effect-never":Br,"no-arrow-ladder":Vr,"no-branch-in-object":Hr,"no-iife-wrapper":Ur,"no-return-in-arrow":Wr,"no-return-in-callback":Gr,"no-effect-fn-generator":Kr,"no-effect-sync-console":qr,"no-nested-effect-gen":Jr,"no-yield-without-star-in-effect-gen":Yr,"no-piped-yield-in-gen":Xr,"no-gen-for-mapping":Zr,"prefer-gen-for-workflow":Qr,"no-large-anonymous-flow":$r,"no-effect-in-flow":ei,"prefer-named-flow":ti,"prefer-pipe-for-behavior":ni,"prefer-decorated-effect-before-gen":ri,"no-workflow-in-behavior-pipe":ii,"no-mixed-pillar-function":ai,"no-clever-effect-expression":oi,"prefer-extracted-concept":si,"prefer-effect-service":ci,"no-layer-provide-in-service-definition":li,"require-service-accessors":ui,"require-service-dependencies":di,"no-namespace-effect-import":fi,"no-manual-service-object-export":pi,"no-layer-merge-in-request-handler":vi,"no-service-method-returning-promise":yi,"prefer-layer-pipe":mi,"no-inline-layer-provide-in-program":hi,"prefer-layer-mergeall-for-infrastructure":gi,"no-service-layer-scatter":_i,"no-match-void-branch":bi,"no-match-effect-branch":xi,"warn-effect-sync-wrapper":Si,"no-effect-side-effect-wrapper":Ci,"no-effect-all-step-sequencing":wi,"no-async-effect-combinator-callback":Ti,"no-throw-in-effect-logic":Ei,"no-or-die-outside-boundary":Di,"no-swallowed-catch-all":Oi,"no-effect-ignore":ki,"no-try-catch-in-effect-logic":Ai,"no-promise-api-in-effect-logic":ji,"no-try-catch":Mi,"no-effect-wrapper-alias":Ni,"no-manual-effect-channels":Pi,"no-wrapgraphql-catchall":Fi,"no-render-side-effects":Ii,"no-atom-registry-effect-sync":Li,"no-family-collection-read":Ri,"no-inline-runtime-provide":zi,"no-naked-object-state-update":Bi,"no-effect-succeed-variable":Vi,"no-effect-type-alias":Hi,"no-public-generic-effect-error":Ui,"no-model-overlay-cast":Wi,"no-unknown-boolean-coercion-helper":Gi,"no-fromnullable-nullish-coalesce":Ki,"no-option-boolean-normalization":qi,"no-string-sentinel-return":Ji,"no-string-sentinel-const":Yi,"no-raw-domain-id-alias":Xi,"no-boolean-domain-flag":Zi,"no-magic-domain-string":Qi,"no-raw-domain-primitive-params":$i,"no-raw-time-domain-field":ea,"no-overloaded-options-object":ta,"no-domain-logic-in-conditional":na,"no-implicit-state-machine-object":ra,"no-adhoc-domain-error":ia,"no-domain-meaning-by-folder-only":aa,"no-effect-as":oa,"no-effect-do":sa,"no-effect-bind":la,"no-runtime-runfork":ua,"no-run-effect-outside-boundary":da,"no-effect-async":fa,"prevent-dynamic-imports":t({create(e){return{ImportExpression(t){J(e,t,`Rule: avoid dynamic imports. Why: runtime module loading obscures dependency boundaries. Fix: use static imports.`)}}}}),"no-nested-effect-call":pa,"no-effect-ladder":ma,"no-flatmap-ladder":ha,"no-pipe-ladder":ga,"no-call-tower":_a,"no-effect-orElse-ladder":va,"no-unbounded-effect-all":ya,"no-fire-and-forget-fork":ba,"no-fork-in-loop":xa,"no-race-without-cleanup":Sa,"no-unobserved-fiber":Ca,"no-unbounded-concurrent-retry":wa,"no-blocking-call-in-effect":Ta,"no-promise-concurrency-in-effect":Ea,"no-shared-mutable-state-across-fibers":Da,"no-timeout-with-noninterruptible-promise":Oa,"no-uninterruptible-concurrent-region":ka,"no-unbounded-queue-or-pubsub":Aa,"no-global-mutable-concurrency-state":ja};function Z(e){return Object.fromEntries(e.map(e=>[`linteffect/${e}`,`error`]))}function Q(e){return{jsPlugins:Na,rules:e}}const Na=[{name:`linteffect`,specifier:`@opsydyn/oxlint-effect`}],Pa=Z([`no-react-state`,`no-runtime-runfork`,`no-run-effect-outside-boundary`,`no-or-die-outside-boundary`,`prevent-dynamic-imports`,`no-render-side-effects`,`no-inline-runtime-provide`]),Fa=Z([`no-effect-as`,`no-effect-do`,`no-effect-bind`,`no-effect-async`,`no-effect-ignore`,`no-effect-never`,`no-effect-fn-generator`,`no-nested-effect-gen`,`no-yield-without-star-in-effect-gen`,`no-async-effect-combinator-callback`,`no-throw-in-effect-logic`,`no-try-catch-in-effect-logic`,`no-promise-api-in-effect-logic`,`no-swallowed-catch-all`,`no-manual-effect-channels`,`no-effect-type-alias`,`no-public-generic-effect-error`]),Ia=Z([`no-unbounded-effect-all`,`no-fire-and-forget-fork`,`no-fork-in-loop`,`no-race-without-cleanup`,`no-unobserved-fiber`,`no-unbounded-concurrent-retry`,`no-blocking-call-in-effect`,`no-promise-concurrency-in-effect`,`no-shared-mutable-state-across-fibers`,`no-timeout-with-noninterruptible-promise`,`no-uninterruptible-concurrent-region`,`no-unbounded-queue-or-pubsub`,`no-global-mutable-concurrency-state`]),La=Z([`no-nested-effect-call`,`no-effect-ladder`,`no-flatmap-ladder`,`no-pipe-ladder`,`no-call-tower`,`no-effect-orElse-ladder`,`no-effect-wrapper-alias`,`warn-effect-sync-wrapper`,`no-effect-side-effect-wrapper`,`no-effect-all-step-sequencing`,`no-effect-succeed-variable`]),Ra=Z([`no-if-statement`,`no-switch-statement`,`no-ternary`,`no-try-catch`,`no-arrow-ladder`,`no-iife-wrapper`,`no-return-in-arrow`,`no-return-in-callback`,`no-return-null`,`no-branch-in-object`]),za=Z([`no-option-as`,`no-match-void-branch`,`no-match-effect-branch`,`no-model-overlay-cast`,`no-unknown-boolean-coercion-helper`,`no-fromnullable-nullish-coalesce`,`no-option-boolean-normalization`,`no-string-sentinel-return`,`no-string-sentinel-const`]),Ba=Z([`no-effect-sync-console`,`no-atom-registry-effect-sync`,`no-family-collection-read`,`no-naked-object-state-update`,`no-wrapgraphql-catchall`]),$=Z([`no-raw-domain-id-alias`,`no-boolean-domain-flag`,`no-magic-domain-string`,`no-raw-domain-primitive-params`,`no-raw-time-domain-field`,`no-overloaded-options-object`,`no-domain-logic-in-conditional`,`no-implicit-state-machine-object`,`no-adhoc-domain-error`,`no-domain-meaning-by-folder-only`]),Va=Z([`no-piped-yield-in-gen`,`no-gen-for-mapping`,`prefer-gen-for-workflow`]),Ha=Z([`no-large-anonymous-flow`,`no-effect-in-flow`,`prefer-named-flow`]),Ua=Z([`prefer-pipe-for-behavior`,`prefer-decorated-effect-before-gen`,`no-workflow-in-behavior-pipe`]),Wa=Z([`no-mixed-pillar-function`,`no-clever-effect-expression`,`prefer-extracted-concept`]),Ga=Z([`prefer-effect-service`,`no-layer-provide-in-service-definition`,`require-service-accessors`,`require-service-dependencies`,`no-namespace-effect-import`,`no-manual-service-object-export`,`no-layer-merge-in-request-handler`,`no-service-method-returning-promise`,`prefer-layer-pipe`,`no-inline-layer-provide-in-program`,`prefer-layer-mergeall-for-infrastructure`,`no-service-layer-scatter`]),Ka=Z(Object.keys(Ma)),qa={reactAndRuntimeBoundaries:Pa,effectComposition:Fa,concurrencySafety:Ia,pipelineShapeAndSequencing:La,branchingAndLocalControlFlow:Ra,optionMatchAndDataNormalization:za,atomStateAndPlatformBoundaries:Ba,domainModeling:$,effectFlow:Va,pureTransformation:Ha,behaviorDecoration:Ua,styleSeparation:Wa,serviceAndLayerArchitecture:Ga,ddd:$},Ja=Q(Ka),Ya=Q(Pa),Xa=Q(Fa),Za=Q(Ia),Qa=Q(La),$a=Q(Ra),eo=Q(za),to=Q(Ba),no=Q($),ro=no,io=Q(Va),ao=Q(Ha),oo=Q(Ua),so=Q(Wa),co=Q(Ga),lo={recommended:Ja,reactAndRuntimeBoundaries:Ya,effectComposition:Xa,concurrencySafety:Za,pipelineShapeAndSequencing:Qa,branchingAndLocalControlFlow:$a,optionMatchAndDataNormalization:eo,atomStateAndPlatformBoundaries:to,domainModeling:no,ddd:ro,effectFlow:io,pureTransformation:ao,behaviorDecoration:oo,styleSeparation:so,serviceAndLayerArchitecture:co};var uo=e({meta:{name:`linteffect`},rules:Ma});export{Ka as allRules,to as atomStateAndPlatformBoundaries,Ba as atomStateAndPlatformBoundariesRules,oo as behaviorDecoration,Ua as behaviorDecorationRules,$a as branchingAndLocalControlFlow,Ra as branchingAndLocalControlFlowRules,Za as concurrencySafety,Ia as concurrencySafetyRules,ro as ddd,uo as default,no as domainModeling,$ as domainModelingRules,Xa as effectComposition,Fa as effectCompositionRules,io as effectFlow,Va as effectFlowRules,Na as jsPlugins,eo as optionMatchAndDataNormalization,za as optionMatchAndDataNormalizationRules,Qa as pipelineShapeAndSequencing,La as pipelineShapeAndSequencingRules,lo as presets,ao as pureTransformation,Ha as pureTransformationRules,Ya as reactAndRuntimeBoundaries,Pa as reactAndRuntimeBoundariesRules,Ja as recommended,qa as ruleGroups,co as serviceAndLayerArchitecture,Ga as serviceAndLayerArchitectureRules,so as styleSeparation,Wa as styleSeparationRules};
|
|
2335
2
|
//# sourceMappingURL=index.mjs.map
|