@opsydyn/oxlint-effect 0.1.0 → 0.2.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 +109 -51
- package/dist/index.mjs +679 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -140,6 +140,181 @@ function getEffectGeneratorArgument(node, propertyName) {
|
|
|
140
140
|
function isEffectGeneratorCall(node, propertyName) {
|
|
141
141
|
return getEffectGeneratorArgument(node, propertyName) !== void 0;
|
|
142
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 effectRunMethods = /* @__PURE__ */ new Set([
|
|
284
|
+
"runCallback",
|
|
285
|
+
"runFork",
|
|
286
|
+
"runPromise",
|
|
287
|
+
"runPromiseExit",
|
|
288
|
+
"runSync",
|
|
289
|
+
"runSyncExit"
|
|
290
|
+
]);
|
|
291
|
+
function isEffectRunCall(node) {
|
|
292
|
+
if (!isEffectMemberCall(node)) return false;
|
|
293
|
+
const property = node.callee.property;
|
|
294
|
+
return isIdentifier(property) && effectRunMethods.has(property.name);
|
|
295
|
+
}
|
|
296
|
+
function isEffectOrDieReference(node) {
|
|
297
|
+
return isMemberExpression(node, "Effect", "orDie") || isMemberExpression(node, "Effect", "orDieWith") || isEffectMemberCallNamed(node, "orDie") || isEffectMemberCallNamed(node, "orDieWith");
|
|
298
|
+
}
|
|
299
|
+
function findEffectOrDieOutsideBoundary(node) {
|
|
300
|
+
if (isEffectOrDieReference(node)) return node;
|
|
301
|
+
if (isPipeCall(node)) return pipeParts(node).find((part) => isEffectOrDieReference(part));
|
|
302
|
+
}
|
|
303
|
+
function isSwallowedCatchAllBody(node) {
|
|
304
|
+
return isEffectMemberCallNamed(node, "succeed") || isEffectMemberCallNamed(node, "asVoid") || isEffectMemberCallNamed(node, "ignore") || isEffectVoidMember(node);
|
|
305
|
+
}
|
|
306
|
+
function getSwallowedCatchAllHandler(node) {
|
|
307
|
+
if (!isEffectMemberCallNamed(node, "catchAll")) return;
|
|
308
|
+
const body = callbackBody(firstArgument(node));
|
|
309
|
+
return isSwallowedCatchAllBody(body) ? body : void 0;
|
|
310
|
+
}
|
|
311
|
+
function isEffectIgnoreReference(node) {
|
|
312
|
+
return isMemberExpression(node, "Effect", "ignore") || isEffectMemberCallNamed(node, "ignore");
|
|
313
|
+
}
|
|
314
|
+
function findEffectIgnore(node) {
|
|
315
|
+
if (isEffectIgnoreReference(node)) return node;
|
|
316
|
+
if (isPipeCall(node)) return pipeParts(node).find((part) => isEffectIgnoreReference(part));
|
|
317
|
+
}
|
|
143
318
|
function isConsoleCall(node) {
|
|
144
319
|
if (typeof node !== "object" || node === null) return false;
|
|
145
320
|
const call = node;
|
|
@@ -232,6 +407,48 @@ function isQualifiedTypeReference(node, leftName, rightName) {
|
|
|
232
407
|
const typeName = node.typeName;
|
|
233
408
|
return typeof typeName === "object" && typeName !== null && typeName.type === "TSQualifiedName" && isIdentifier(typeName.left, leftName) && isIdentifier(typeName.right, rightName);
|
|
234
409
|
}
|
|
410
|
+
function isIdentifierTypeReference(node, name) {
|
|
411
|
+
return typeof node === "object" && node !== null && node.type === "TSTypeReference" && isIdentifier(node.typeName, name);
|
|
412
|
+
}
|
|
413
|
+
function typeArguments(node) {
|
|
414
|
+
if (typeof node !== "object" || node === null) return [];
|
|
415
|
+
const container = node.typeParameters ?? node.typeArguments;
|
|
416
|
+
if (typeof container !== "object" || container === null) return [];
|
|
417
|
+
const params = container.params ?? container.arguments;
|
|
418
|
+
return Array.isArray(params) ? params : [];
|
|
419
|
+
}
|
|
420
|
+
function isGenericErrorType(node) {
|
|
421
|
+
return isIdentifier(node, "Error") || isIdentifierTypeReference(node, "Error");
|
|
422
|
+
}
|
|
423
|
+
function returnTypeAnnotation(node) {
|
|
424
|
+
if (typeof node !== "object" || node === null) return;
|
|
425
|
+
const returnType = node.returnType;
|
|
426
|
+
if (typeof returnType !== "object" || returnType === null) return;
|
|
427
|
+
return returnType.typeAnnotation ?? returnType;
|
|
428
|
+
}
|
|
429
|
+
function genericEffectErrorReturnType(node) {
|
|
430
|
+
const annotation = returnTypeAnnotation(node);
|
|
431
|
+
if (!isQualifiedTypeReference(annotation, "Effect", "Effect")) return;
|
|
432
|
+
const [, error] = typeArguments(annotation);
|
|
433
|
+
return isGenericErrorType(error) ? annotation : void 0;
|
|
434
|
+
}
|
|
435
|
+
function exportedGenericEffectErrorTarget(node) {
|
|
436
|
+
if (typeof node !== "object" || node === null) return;
|
|
437
|
+
const exportNode = node;
|
|
438
|
+
if (exportNode.type !== "ExportNamedDeclaration" && exportNode.type !== "ExportDefaultDeclaration") return;
|
|
439
|
+
const declaration = exportNode.declaration;
|
|
440
|
+
if (typeof declaration !== "object" || declaration === null) return;
|
|
441
|
+
if (declaration.type === "FunctionDeclaration") return genericEffectErrorReturnType(declaration);
|
|
442
|
+
if (declaration.type !== "VariableDeclaration") return;
|
|
443
|
+
for (const declarator of declaration.declarations ?? []) {
|
|
444
|
+
if (typeof declarator !== "object" || declarator === null) continue;
|
|
445
|
+
const init = declarator.init;
|
|
446
|
+
if (typeof init === "object" && init !== null && (init.type === "ArrowFunctionExpression" || init.type === "FunctionExpression")) {
|
|
447
|
+
const target = genericEffectErrorReturnType(init);
|
|
448
|
+
if (target) return target;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
235
452
|
function containsQualifiedTypeReference(node, leftName, rightName, seen = /* @__PURE__ */ new WeakSet()) {
|
|
236
453
|
if (isQualifiedTypeReference(node, leftName, rightName)) return true;
|
|
237
454
|
if (Array.isArray(node)) return node.some((child) => containsQualifiedTypeReference(child, leftName, rightName, seen));
|
|
@@ -574,6 +791,170 @@ function objectPropertyValues(node) {
|
|
|
574
791
|
if (object.type !== "ObjectExpression" || !Array.isArray(object.properties)) return [];
|
|
575
792
|
return object.properties.map((property) => typeof property === "object" && property !== null ? property.value : void 0).filter((value) => value !== void 0);
|
|
576
793
|
}
|
|
794
|
+
function isRawDomainIdAlias(node) {
|
|
795
|
+
if (typeof node !== "object" || node === null || node.type !== "TSTypeAliasDeclaration") return false;
|
|
796
|
+
const aliasName = node.id;
|
|
797
|
+
const typeAnnotation = node.typeAnnotation;
|
|
798
|
+
return isIdentifier(aliasName) && /(?:Id|ID)$/.test(aliasName.name) && (typeAnnotation?.type === "TSStringKeyword" || typeAnnotation?.type === "TSNumberKeyword");
|
|
799
|
+
}
|
|
800
|
+
function isBooleanTypeAnnotation(node) {
|
|
801
|
+
if (typeof node !== "object" || node === null) return false;
|
|
802
|
+
const annotation = node;
|
|
803
|
+
if (annotation.type === "TSBooleanKeyword") return true;
|
|
804
|
+
return annotation.type === "TSTypeAnnotation" && typeof annotation.typeAnnotation === "object" && annotation.typeAnnotation !== null && annotation.typeAnnotation.type === "TSBooleanKeyword";
|
|
805
|
+
}
|
|
806
|
+
function unwrapTypeAnnotation(node) {
|
|
807
|
+
if (typeof node !== "object" || node === null) return;
|
|
808
|
+
const annotation = node;
|
|
809
|
+
if (annotation.type === "TSTypeAnnotation" && typeof annotation.typeAnnotation === "object" && annotation.typeAnnotation !== null) return annotation.typeAnnotation;
|
|
810
|
+
return annotation;
|
|
811
|
+
}
|
|
812
|
+
function isStringOrNumberTypeAnnotation(node) {
|
|
813
|
+
const annotation = unwrapTypeAnnotation(node);
|
|
814
|
+
return annotation?.type === "TSStringKeyword" || annotation?.type === "TSNumberKeyword";
|
|
815
|
+
}
|
|
816
|
+
function isAnyOrObjectTypeAnnotation(node) {
|
|
817
|
+
const annotation = unwrapTypeAnnotation(node);
|
|
818
|
+
return annotation?.type === "TSAnyKeyword" || annotation?.type === "TSObjectKeyword";
|
|
819
|
+
}
|
|
820
|
+
function isDateTypeAnnotation(node) {
|
|
821
|
+
const annotation = unwrapTypeAnnotation(node);
|
|
822
|
+
return annotation?.type === "TSTypeReference" && isIdentifier(annotation.typeName, "Date");
|
|
823
|
+
}
|
|
824
|
+
function primitiveDomainParameters(node) {
|
|
825
|
+
if (typeof node !== "object" || node === null || !Array.isArray(node.params)) return [];
|
|
826
|
+
const domainNamePattern = /(?:id|amount|currency|account|user|order|customer|invoice|payment|price|total|quantity|transfer|fund|balance)/i;
|
|
827
|
+
return node.params.filter((param) => isIdentifier(param) && isStringOrNumberTypeAnnotation(param.typeAnnotation) && domainNamePattern.test(param.name));
|
|
828
|
+
}
|
|
829
|
+
function hasPrimitiveHeavyDomainParameters(node) {
|
|
830
|
+
return primitiveDomainParameters(node).length >= 3;
|
|
831
|
+
}
|
|
832
|
+
function isBooleanDomainFlagParameter(node) {
|
|
833
|
+
if (!isIdentifier(node)) return false;
|
|
834
|
+
return /^(?:is|has|should|with|allow|enable|can|use)[A-Z0-9_]/.test(node.name) && isBooleanTypeAnnotation(node.typeAnnotation);
|
|
835
|
+
}
|
|
836
|
+
function functionBooleanDomainFlagParameters(node) {
|
|
837
|
+
if (typeof node !== "object" || node === null || !Array.isArray(node.params)) return [];
|
|
838
|
+
return node.params.filter(isBooleanDomainFlagParameter);
|
|
839
|
+
}
|
|
840
|
+
function getPropertyName(node) {
|
|
841
|
+
if (isIdentifier(node)) return node.name;
|
|
842
|
+
if (typeof node === "object" && node !== null && typeof node.value === "string") return node.value;
|
|
843
|
+
}
|
|
844
|
+
function isRawTimeFieldName(name) {
|
|
845
|
+
return /(?:createdAt|updatedAt|expiresAt|expiredAt|renewedAt|startedAt|endedAt|deletedAt|timestamp|timeoutMs|durationMs|ttlMs|ttl)$/i.test(name);
|
|
846
|
+
}
|
|
847
|
+
function isRawTimeDomainField(node) {
|
|
848
|
+
if (typeof node !== "object" || node === null || node.type !== "TSPropertySignature") return false;
|
|
849
|
+
const property = node;
|
|
850
|
+
const propertyName = getPropertyName(property.key);
|
|
851
|
+
const typeAnnotation = property.typeAnnotation;
|
|
852
|
+
return propertyName !== void 0 && isRawTimeFieldName(propertyName) && (isStringOrNumberTypeAnnotation(typeAnnotation) || isDateTypeAnnotation(typeAnnotation));
|
|
853
|
+
}
|
|
854
|
+
function typeMembers(node) {
|
|
855
|
+
if (typeof node !== "object" || node === null) return [];
|
|
856
|
+
const object = node;
|
|
857
|
+
if (object.type === "TSInterfaceDeclaration" && typeof object.body === "object" && object.body !== null && Array.isArray(object.body.body)) return object.body.body;
|
|
858
|
+
if (object.type === "TSTypeLiteral" && Array.isArray(object.members)) return object.members;
|
|
859
|
+
return [];
|
|
860
|
+
}
|
|
861
|
+
function rawTimeDomainFields(node) {
|
|
862
|
+
return typeMembers(node).filter(isRawTimeDomainField);
|
|
863
|
+
}
|
|
864
|
+
function isOverloadedOptionsParameter(node) {
|
|
865
|
+
if (!isIdentifier(node)) return false;
|
|
866
|
+
return /^(?:opts|options|config)$/i.test(node.name) && isAnyOrObjectTypeAnnotation(node.typeAnnotation);
|
|
867
|
+
}
|
|
868
|
+
function overloadedOptionsParameters(node) {
|
|
869
|
+
if (typeof node !== "object" || node === null || !Array.isArray(node.params)) return [];
|
|
870
|
+
return node.params.filter(isOverloadedOptionsParameter);
|
|
871
|
+
}
|
|
872
|
+
const comparisonOperators = /* @__PURE__ */ new Set([
|
|
873
|
+
"==",
|
|
874
|
+
"===",
|
|
875
|
+
"!=",
|
|
876
|
+
"!==",
|
|
877
|
+
">",
|
|
878
|
+
">=",
|
|
879
|
+
"<",
|
|
880
|
+
"<="
|
|
881
|
+
]);
|
|
882
|
+
function comparisonCount(node, seen = /* @__PURE__ */ new WeakSet()) {
|
|
883
|
+
if (Array.isArray(node)) return node.reduce((count, child) => count + comparisonCount(child, seen), 0);
|
|
884
|
+
if (typeof node !== "object" || node === null) return 0;
|
|
885
|
+
if (seen.has(node)) return 0;
|
|
886
|
+
seen.add(node);
|
|
887
|
+
const expression = node;
|
|
888
|
+
if (expression.type === "BinaryExpression" && comparisonOperators.has(String(expression.operator))) return 1;
|
|
889
|
+
if (expression.type !== "LogicalExpression") return 0;
|
|
890
|
+
return comparisonCount(expression.left, seen) + comparisonCount(expression.right, seen);
|
|
891
|
+
}
|
|
892
|
+
function isDomainLogicConditional(node) {
|
|
893
|
+
return typeof node === "object" && node !== null && node.type === "LogicalExpression" && comparisonCount(node) >= 3;
|
|
894
|
+
}
|
|
895
|
+
function stateFlagMember(node) {
|
|
896
|
+
if (typeof node !== "object" || node === null || node.type !== "MemberExpression") return;
|
|
897
|
+
const member = node;
|
|
898
|
+
if (member.computed === true || !isIdentifier(member.object) || !isIdentifier(member.property)) return;
|
|
899
|
+
const propertyName = member.property.name;
|
|
900
|
+
if (!/(?:cancelled|canceled|shipped|approved|rejected|pending|active|inactive|enabled|disabled|locked|archived|deleted|submitted|processing|failed|complete|completed)$/i.test(propertyName)) return;
|
|
901
|
+
return {
|
|
902
|
+
objectName: member.object.name,
|
|
903
|
+
propertyName
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
function collectStateFlagMembers(node, members = /* @__PURE__ */ new Map(), seen = /* @__PURE__ */ new WeakSet()) {
|
|
907
|
+
const member = stateFlagMember(node);
|
|
908
|
+
if (member) {
|
|
909
|
+
const properties = members.get(member.objectName) ?? /* @__PURE__ */ new Set();
|
|
910
|
+
properties.add(member.propertyName);
|
|
911
|
+
members.set(member.objectName, properties);
|
|
912
|
+
return members;
|
|
913
|
+
}
|
|
914
|
+
if (Array.isArray(node)) {
|
|
915
|
+
for (const child of node) collectStateFlagMembers(child, members, seen);
|
|
916
|
+
return members;
|
|
917
|
+
}
|
|
918
|
+
if (typeof node !== "object" || node === null) return members;
|
|
919
|
+
if (seen.has(node)) return members;
|
|
920
|
+
seen.add(node);
|
|
921
|
+
const expression = node;
|
|
922
|
+
if (expression.type !== "LogicalExpression") return members;
|
|
923
|
+
collectStateFlagMembers(expression.left, members, seen);
|
|
924
|
+
collectStateFlagMembers(expression.right, members, seen);
|
|
925
|
+
return members;
|
|
926
|
+
}
|
|
927
|
+
function isImplicitStateMachineObject(node) {
|
|
928
|
+
if (typeof node !== "object" || node === null || node.type !== "LogicalExpression") return false;
|
|
929
|
+
return Array.from(collectStateFlagMembers(node).values()).some((properties) => properties.size >= 2);
|
|
930
|
+
}
|
|
931
|
+
function isAdhocEffectFail(node) {
|
|
932
|
+
return isEffectMemberCallNamed(node, "fail") && isStringLiteral(firstArgument(node));
|
|
933
|
+
}
|
|
934
|
+
function isThrowNewStringError(node) {
|
|
935
|
+
if (typeof node !== "object" || node === null || node.type !== "ThrowStatement") return false;
|
|
936
|
+
const argument = node.argument;
|
|
937
|
+
return typeof argument === "object" && argument !== null && argument.type === "NewExpression" && isIdentifier(argument.callee, "Error") && Array.isArray(argument.arguments) && isStringLiteral(argument.arguments[0]);
|
|
938
|
+
}
|
|
939
|
+
function hasRawDomainIdParameter(node) {
|
|
940
|
+
if (typeof node !== "object" || node === null || !Array.isArray(node.params)) return false;
|
|
941
|
+
return node.params.some((param) => isIdentifier(param) && /(?:^id$|Id$|ID$)/.test(param.name) && isStringOrNumberTypeAnnotation(param.typeAnnotation));
|
|
942
|
+
}
|
|
943
|
+
function isContextEncodedDomainFunction(node) {
|
|
944
|
+
if (typeof node !== "object" || node === null || node.type !== "FunctionDeclaration") return false;
|
|
945
|
+
const id = node.id;
|
|
946
|
+
return isIdentifier(id) && /(?:Admin|Public|Internal|External|Private|Backoffice|Panel)/.test(id.name) && hasRawDomainIdParameter(node);
|
|
947
|
+
}
|
|
948
|
+
function isStringLiteralComparison(node) {
|
|
949
|
+
if (typeof node !== "object" || node === null || node.type !== "BinaryExpression") return false;
|
|
950
|
+
const binary = node;
|
|
951
|
+
return [
|
|
952
|
+
"==",
|
|
953
|
+
"===",
|
|
954
|
+
"!=",
|
|
955
|
+
"!=="
|
|
956
|
+
].includes(String(binary.operator)) && (isStringLiteral(binary.left) || isStringLiteral(binary.right)) && !isTypeofBooleanCheck(binary);
|
|
957
|
+
}
|
|
577
958
|
function report(context, node, message) {
|
|
578
959
|
context.report({
|
|
579
960
|
message,
|
|
@@ -745,6 +1126,20 @@ const noNestedEffectGen = defineRule({ create(context) {
|
|
|
745
1126
|
}
|
|
746
1127
|
};
|
|
747
1128
|
} });
|
|
1129
|
+
const noYieldWithoutStarInEffectGen = defineRule({ create(context) {
|
|
1130
|
+
let hasEffectEcosystemImport = false;
|
|
1131
|
+
return {
|
|
1132
|
+
ImportDeclaration(node) {
|
|
1133
|
+
const source = getImportSource(node);
|
|
1134
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1135
|
+
},
|
|
1136
|
+
CallExpression(node) {
|
|
1137
|
+
if (!hasEffectEcosystemImport) return;
|
|
1138
|
+
const yieldNode = findYieldWithoutStarInEffectGen(node);
|
|
1139
|
+
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`.");
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
} });
|
|
748
1143
|
const noMatchVoidBranch = defineRule({ create(context) {
|
|
749
1144
|
let hasEffectEcosystemImport = false;
|
|
750
1145
|
return {
|
|
@@ -789,6 +1184,104 @@ const noEffectAllStepSequencing = defineRule({ create(context) {
|
|
|
789
1184
|
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.");
|
|
790
1185
|
} };
|
|
791
1186
|
} });
|
|
1187
|
+
const noAsyncEffectCombinatorCallback = defineRule({ create(context) {
|
|
1188
|
+
let hasEffectEcosystemImport = false;
|
|
1189
|
+
return {
|
|
1190
|
+
ImportDeclaration(node) {
|
|
1191
|
+
const source = getImportSource(node);
|
|
1192
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1193
|
+
},
|
|
1194
|
+
CallExpression(node) {
|
|
1195
|
+
if (!hasEffectEcosystemImport) return;
|
|
1196
|
+
const callback = findAsyncEffectCombinatorCallback(node);
|
|
1197
|
+
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.");
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
} });
|
|
1201
|
+
const noThrowInEffectLogic = defineRule({ create(context) {
|
|
1202
|
+
let hasEffectEcosystemImport = false;
|
|
1203
|
+
return {
|
|
1204
|
+
ImportDeclaration(node) {
|
|
1205
|
+
const source = getImportSource(node);
|
|
1206
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1207
|
+
},
|
|
1208
|
+
CallExpression(node) {
|
|
1209
|
+
if (!hasEffectEcosystemImport) return;
|
|
1210
|
+
const throwNode = findThrowInEffectLogic(node);
|
|
1211
|
+
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.");
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
} });
|
|
1215
|
+
const noOrDieOutsideBoundary = defineRule({ create(context) {
|
|
1216
|
+
let hasEffectEcosystemImport = false;
|
|
1217
|
+
return {
|
|
1218
|
+
ImportDeclaration(node) {
|
|
1219
|
+
const source = getImportSource(node);
|
|
1220
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1221
|
+
},
|
|
1222
|
+
CallExpression(node) {
|
|
1223
|
+
if (!hasEffectEcosystemImport) return;
|
|
1224
|
+
const target = findEffectOrDieOutsideBoundary(node);
|
|
1225
|
+
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.");
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
} });
|
|
1229
|
+
const noSwallowedCatchAll = defineRule({ create(context) {
|
|
1230
|
+
let hasEffectEcosystemImport = false;
|
|
1231
|
+
return {
|
|
1232
|
+
ImportDeclaration(node) {
|
|
1233
|
+
const source = getImportSource(node);
|
|
1234
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1235
|
+
},
|
|
1236
|
+
CallExpression(node) {
|
|
1237
|
+
if (!hasEffectEcosystemImport) return;
|
|
1238
|
+
const handlerBody = getSwallowedCatchAllHandler(node);
|
|
1239
|
+
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.");
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
} });
|
|
1243
|
+
const noEffectIgnore = defineRule({ create(context) {
|
|
1244
|
+
let hasEffectEcosystemImport = false;
|
|
1245
|
+
return {
|
|
1246
|
+
ImportDeclaration(node) {
|
|
1247
|
+
const source = getImportSource(node);
|
|
1248
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1249
|
+
},
|
|
1250
|
+
CallExpression(node) {
|
|
1251
|
+
if (!hasEffectEcosystemImport) return;
|
|
1252
|
+
const target = findEffectIgnore(node);
|
|
1253
|
+
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.");
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
} });
|
|
1257
|
+
const noTryCatchInEffectLogic = defineRule({ create(context) {
|
|
1258
|
+
let hasEffectEcosystemImport = false;
|
|
1259
|
+
return {
|
|
1260
|
+
ImportDeclaration(node) {
|
|
1261
|
+
const source = getImportSource(node);
|
|
1262
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1263
|
+
},
|
|
1264
|
+
CallExpression(node) {
|
|
1265
|
+
if (!hasEffectEcosystemImport) return;
|
|
1266
|
+
const tryNode = findTryCatchInEffectLogic(node);
|
|
1267
|
+
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.");
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
} });
|
|
1271
|
+
const noPromiseApiInEffectLogic = defineRule({ create(context) {
|
|
1272
|
+
let hasEffectEcosystemImport = false;
|
|
1273
|
+
return {
|
|
1274
|
+
ImportDeclaration(node) {
|
|
1275
|
+
const source = getImportSource(node);
|
|
1276
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1277
|
+
},
|
|
1278
|
+
CallExpression(node) {
|
|
1279
|
+
if (!hasEffectEcosystemImport) return;
|
|
1280
|
+
const promiseNode = findPromiseApiInEffectLogic(node);
|
|
1281
|
+
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.");
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
} });
|
|
792
1285
|
const noTryCatch = defineRule({ create(context) {
|
|
793
1286
|
return { TryStatement(node) {
|
|
794
1287
|
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.");
|
|
@@ -896,6 +1389,23 @@ const noEffectTypeAlias = defineRule({ create(context) {
|
|
|
896
1389
|
}
|
|
897
1390
|
};
|
|
898
1391
|
} });
|
|
1392
|
+
const noPublicGenericEffectError = defineRule({ create(context) {
|
|
1393
|
+
let hasEffectEcosystemImport = false;
|
|
1394
|
+
return {
|
|
1395
|
+
ImportDeclaration(node) {
|
|
1396
|
+
const source = getImportSource(node);
|
|
1397
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1398
|
+
},
|
|
1399
|
+
ExportNamedDeclaration(node) {
|
|
1400
|
+
const target = hasEffectEcosystemImport ? exportedGenericEffectErrorTarget(node) : void 0;
|
|
1401
|
+
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.");
|
|
1402
|
+
},
|
|
1403
|
+
ExportDefaultDeclaration(node) {
|
|
1404
|
+
const target = hasEffectEcosystemImport ? exportedGenericEffectErrorTarget(node) : void 0;
|
|
1405
|
+
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.");
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
} });
|
|
899
1409
|
const noModelOverlayCast = defineRule({ create(context) {
|
|
900
1410
|
let hasEffectEcosystemImport = false;
|
|
901
1411
|
return {
|
|
@@ -969,6 +1479,143 @@ const noStringSentinelConst = defineRule({ create(context) {
|
|
|
969
1479
|
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.");
|
|
970
1480
|
} };
|
|
971
1481
|
} });
|
|
1482
|
+
const noRawDomainIdAlias = 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
|
+
TSTypeAliasDeclaration(node) {
|
|
1490
|
+
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.");
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
} });
|
|
1494
|
+
const noBooleanDomainFlag = defineRule({ create(context) {
|
|
1495
|
+
let hasEffectEcosystemImport = false;
|
|
1496
|
+
const checkFunctionParameters = (node) => {
|
|
1497
|
+
if (!hasEffectEcosystemImport) return;
|
|
1498
|
+
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.");
|
|
1499
|
+
};
|
|
1500
|
+
return {
|
|
1501
|
+
ImportDeclaration(node) {
|
|
1502
|
+
const source = getImportSource(node);
|
|
1503
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1504
|
+
},
|
|
1505
|
+
FunctionDeclaration: checkFunctionParameters,
|
|
1506
|
+
FunctionExpression: checkFunctionParameters,
|
|
1507
|
+
ArrowFunctionExpression: checkFunctionParameters
|
|
1508
|
+
};
|
|
1509
|
+
} });
|
|
1510
|
+
const noMagicDomainString = 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
|
+
BinaryExpression(node) {
|
|
1518
|
+
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.");
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
} });
|
|
1522
|
+
const noRawDomainPrimitiveParams = defineRule({ create(context) {
|
|
1523
|
+
let hasEffectEcosystemImport = false;
|
|
1524
|
+
const checkFunction = (node) => {
|
|
1525
|
+
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.");
|
|
1526
|
+
};
|
|
1527
|
+
return {
|
|
1528
|
+
ImportDeclaration(node) {
|
|
1529
|
+
const source = getImportSource(node);
|
|
1530
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1531
|
+
},
|
|
1532
|
+
FunctionDeclaration: checkFunction,
|
|
1533
|
+
FunctionExpression: checkFunction,
|
|
1534
|
+
ArrowFunctionExpression: checkFunction
|
|
1535
|
+
};
|
|
1536
|
+
} });
|
|
1537
|
+
const noRawTimeDomainField = defineRule({ create(context) {
|
|
1538
|
+
let hasEffectEcosystemImport = false;
|
|
1539
|
+
const checkTypeMembers = (node) => {
|
|
1540
|
+
if (!hasEffectEcosystemImport) return;
|
|
1541
|
+
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.");
|
|
1542
|
+
};
|
|
1543
|
+
return {
|
|
1544
|
+
ImportDeclaration(node) {
|
|
1545
|
+
const source = getImportSource(node);
|
|
1546
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1547
|
+
},
|
|
1548
|
+
TSInterfaceDeclaration: checkTypeMembers,
|
|
1549
|
+
TSTypeLiteral: checkTypeMembers
|
|
1550
|
+
};
|
|
1551
|
+
} });
|
|
1552
|
+
const noOverloadedOptionsObject = defineRule({ create(context) {
|
|
1553
|
+
let hasEffectEcosystemImport = false;
|
|
1554
|
+
const checkFunctionParameters = (node) => {
|
|
1555
|
+
if (!hasEffectEcosystemImport) return;
|
|
1556
|
+
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.");
|
|
1557
|
+
};
|
|
1558
|
+
return {
|
|
1559
|
+
ImportDeclaration(node) {
|
|
1560
|
+
const source = getImportSource(node);
|
|
1561
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1562
|
+
},
|
|
1563
|
+
FunctionDeclaration: checkFunctionParameters,
|
|
1564
|
+
FunctionExpression: checkFunctionParameters,
|
|
1565
|
+
ArrowFunctionExpression: checkFunctionParameters
|
|
1566
|
+
};
|
|
1567
|
+
} });
|
|
1568
|
+
const noDomainLogicInConditional = defineRule({ create(context) {
|
|
1569
|
+
let hasEffectEcosystemImport = false;
|
|
1570
|
+
return {
|
|
1571
|
+
ImportDeclaration(node) {
|
|
1572
|
+
const source = getImportSource(node);
|
|
1573
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1574
|
+
},
|
|
1575
|
+
LogicalExpression(node) {
|
|
1576
|
+
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.");
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
} });
|
|
1580
|
+
const noImplicitStateMachineObject = defineRule({ create(context) {
|
|
1581
|
+
let hasEffectEcosystemImport = false;
|
|
1582
|
+
return {
|
|
1583
|
+
ImportDeclaration(node) {
|
|
1584
|
+
const source = getImportSource(node);
|
|
1585
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1586
|
+
},
|
|
1587
|
+
LogicalExpression(node) {
|
|
1588
|
+
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.");
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
} });
|
|
1592
|
+
const noAdhocDomainError = defineRule({ create(context) {
|
|
1593
|
+
let hasEffectEcosystemImport = false;
|
|
1594
|
+
return {
|
|
1595
|
+
ImportDeclaration(node) {
|
|
1596
|
+
const source = getImportSource(node);
|
|
1597
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1598
|
+
},
|
|
1599
|
+
CallExpression(node) {
|
|
1600
|
+
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.");
|
|
1601
|
+
},
|
|
1602
|
+
ThrowStatement(node) {
|
|
1603
|
+
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.");
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
} });
|
|
1607
|
+
const noDomainMeaningByFolderOnly = defineRule({ create(context) {
|
|
1608
|
+
let hasEffectEcosystemImport = false;
|
|
1609
|
+
return {
|
|
1610
|
+
ImportDeclaration(node) {
|
|
1611
|
+
const source = getImportSource(node);
|
|
1612
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1613
|
+
},
|
|
1614
|
+
FunctionDeclaration(node) {
|
|
1615
|
+
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.");
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1618
|
+
} });
|
|
972
1619
|
const noEffectAs = defineRule({ create(context) {
|
|
973
1620
|
return { CallExpression(node) {
|
|
974
1621
|
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.");
|
|
@@ -988,6 +1635,18 @@ function createForbiddenMemberCallRule(objectName, propertyName, message) {
|
|
|
988
1635
|
}
|
|
989
1636
|
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.");
|
|
990
1637
|
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.");
|
|
1638
|
+
const noRunEffectOutsideBoundary = defineRule({ create(context) {
|
|
1639
|
+
let hasEffectEcosystemImport = false;
|
|
1640
|
+
return {
|
|
1641
|
+
ImportDeclaration(node) {
|
|
1642
|
+
const source = getImportSource(node);
|
|
1643
|
+
if (source && isEffectEcosystemImport(source)) hasEffectEcosystemImport = true;
|
|
1644
|
+
},
|
|
1645
|
+
CallExpression(node) {
|
|
1646
|
+
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.");
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
} });
|
|
991
1650
|
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.");
|
|
992
1651
|
const noNestedEffectCall = defineRule({ create(context) {
|
|
993
1652
|
return { CallExpression(node) {
|
|
@@ -1049,11 +1708,19 @@ const rules = {
|
|
|
1049
1708
|
"no-effect-fn-generator": noEffectFnGenerator,
|
|
1050
1709
|
"no-effect-sync-console": noEffectSyncConsole,
|
|
1051
1710
|
"no-nested-effect-gen": noNestedEffectGen,
|
|
1711
|
+
"no-yield-without-star-in-effect-gen": noYieldWithoutStarInEffectGen,
|
|
1052
1712
|
"no-match-void-branch": noMatchVoidBranch,
|
|
1053
1713
|
"no-match-effect-branch": noMatchEffectBranch,
|
|
1054
1714
|
"warn-effect-sync-wrapper": warnEffectSyncWrapper,
|
|
1055
1715
|
"no-effect-side-effect-wrapper": noEffectSideEffectWrapper,
|
|
1056
1716
|
"no-effect-all-step-sequencing": noEffectAllStepSequencing,
|
|
1717
|
+
"no-async-effect-combinator-callback": noAsyncEffectCombinatorCallback,
|
|
1718
|
+
"no-throw-in-effect-logic": noThrowInEffectLogic,
|
|
1719
|
+
"no-or-die-outside-boundary": noOrDieOutsideBoundary,
|
|
1720
|
+
"no-swallowed-catch-all": noSwallowedCatchAll,
|
|
1721
|
+
"no-effect-ignore": noEffectIgnore,
|
|
1722
|
+
"no-try-catch-in-effect-logic": noTryCatchInEffectLogic,
|
|
1723
|
+
"no-promise-api-in-effect-logic": noPromiseApiInEffectLogic,
|
|
1057
1724
|
"no-try-catch": noTryCatch,
|
|
1058
1725
|
"no-effect-wrapper-alias": noEffectWrapperAlias,
|
|
1059
1726
|
"no-manual-effect-channels": noManualEffectChannels,
|
|
@@ -1065,16 +1732,28 @@ const rules = {
|
|
|
1065
1732
|
"no-naked-object-state-update": noNakedObjectStateUpdate,
|
|
1066
1733
|
"no-effect-succeed-variable": noEffectSucceedVariable,
|
|
1067
1734
|
"no-effect-type-alias": noEffectTypeAlias,
|
|
1735
|
+
"no-public-generic-effect-error": noPublicGenericEffectError,
|
|
1068
1736
|
"no-model-overlay-cast": noModelOverlayCast,
|
|
1069
1737
|
"no-unknown-boolean-coercion-helper": noUnknownBooleanCoercionHelper,
|
|
1070
1738
|
"no-fromnullable-nullish-coalesce": noFromnullableNullishCoalesce,
|
|
1071
1739
|
"no-option-boolean-normalization": noOptionBooleanNormalization,
|
|
1072
1740
|
"no-string-sentinel-return": noStringSentinelReturn,
|
|
1073
1741
|
"no-string-sentinel-const": noStringSentinelConst,
|
|
1742
|
+
"no-raw-domain-id-alias": noRawDomainIdAlias,
|
|
1743
|
+
"no-boolean-domain-flag": noBooleanDomainFlag,
|
|
1744
|
+
"no-magic-domain-string": noMagicDomainString,
|
|
1745
|
+
"no-raw-domain-primitive-params": noRawDomainPrimitiveParams,
|
|
1746
|
+
"no-raw-time-domain-field": noRawTimeDomainField,
|
|
1747
|
+
"no-overloaded-options-object": noOverloadedOptionsObject,
|
|
1748
|
+
"no-domain-logic-in-conditional": noDomainLogicInConditional,
|
|
1749
|
+
"no-implicit-state-machine-object": noImplicitStateMachineObject,
|
|
1750
|
+
"no-adhoc-domain-error": noAdhocDomainError,
|
|
1751
|
+
"no-domain-meaning-by-folder-only": noDomainMeaningByFolderOnly,
|
|
1074
1752
|
"no-effect-as": noEffectAs,
|
|
1075
1753
|
"no-effect-do": noEffectDo,
|
|
1076
1754
|
"no-effect-bind": noEffectBind,
|
|
1077
1755
|
"no-runtime-runfork": noRuntimeRunFork,
|
|
1756
|
+
"no-run-effect-outside-boundary": noRunEffectOutsideBoundary,
|
|
1078
1757
|
"no-effect-async": noEffectAsync,
|
|
1079
1758
|
"prevent-dynamic-imports": defineRule({ create(context) {
|
|
1080
1759
|
return { ImportExpression(node) {
|