oxlint-plugin-effect 0.9.0 → 0.11.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 +32 -20
- package/dist/presets/recommended.d.ts +12 -0
- package/dist/presets/recommended.js +13 -1
- package/dist/rules/_effect-context.js +27 -0
- package/dist/rules/_effect-namespaces.js +25 -0
- package/dist/rules/_tagged-control-flow.js +1 -1
- package/dist/rules/index.d.ts +13 -1
- package/dist/rules/index.js +25 -1
- package/dist/rules/no-inline-provide.d.ts +6 -0
- package/dist/rules/no-inline-provide.js +39 -0
- package/dist/rules/no-managed-runtime-in-effect.d.ts +6 -0
- package/dist/rules/no-managed-runtime-in-effect.js +41 -0
- package/dist/rules/no-module-mocks.d.ts +6 -0
- package/dist/rules/no-module-mocks.js +73 -0
- package/dist/rules/no-nested-effect-gen.d.ts +6 -0
- package/dist/rules/no-nested-effect-gen.js +39 -0
- package/dist/rules/no-per-call-cache-construction.d.ts +6 -0
- package/dist/rules/no-per-call-cache-construction.js +52 -0
- package/dist/rules/no-run-collect-on-unbounded-stream.d.ts +6 -0
- package/dist/rules/no-run-collect-on-unbounded-stream.js +81 -0
- package/dist/rules/no-sequential-effect-all.d.ts +6 -0
- package/dist/rules/no-sequential-effect-all.js +61 -0
- package/dist/rules/no-silent-catch-all.d.ts +6 -0
- package/dist/rules/no-silent-catch-all.js +51 -0
- package/dist/rules/no-unbounded-concurrency.d.ts +6 -0
- package/dist/rules/no-unbounded-concurrency.js +50 -0
- package/dist/rules/no-unbounded-retry.d.ts +6 -0
- package/dist/rules/no-unbounded-retry.js +114 -0
- package/dist/rules/prefer-catch-tag.js +33 -6
- package/dist/rules/prefer-match-tags-exhaustive.js +62 -8
- package/dist/rules/prefer-service-of.d.ts +6 -0
- package/dist/rules/prefer-service-of.js +65 -0
- package/dist/rules/require-named-effect-fn.d.ts +6 -0
- package/dist/rules/require-named-effect-fn.js +37 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
2
|
+
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
3
|
+
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
4
|
+
import "../vendor/effect-oxlint/index.js";
|
|
5
|
+
import { importedNamespaces, isStaticMember, visibleNamespaces } from "./_effect-namespaces.js";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
//#region src/rules/require-named-effect-fn.ts
|
|
8
|
+
const isFunction = (node) => node?.type === "ArrowFunctionExpression" || node?.type === "FunctionExpression";
|
|
9
|
+
const requireNamedEffectFn = define({
|
|
10
|
+
name: "require-named-effect-fn",
|
|
11
|
+
meta: meta({
|
|
12
|
+
type: "suggestion",
|
|
13
|
+
description: "Require a stable operation name for Effect.fn."
|
|
14
|
+
}),
|
|
15
|
+
create: function* () {
|
|
16
|
+
const ctx = yield* RuleContext;
|
|
17
|
+
const effectNamespaces = new Set(["Effect"]);
|
|
18
|
+
return {
|
|
19
|
+
ImportDeclaration: (node) => {
|
|
20
|
+
if (node.type !== "ImportDeclaration") return Effect.void;
|
|
21
|
+
for (const name of importedNamespaces(node, "Effect", "effect/Effect")) effectNamespaces.add(name);
|
|
22
|
+
return Effect.void;
|
|
23
|
+
},
|
|
24
|
+
CallExpression: (node) => {
|
|
25
|
+
if (node.type !== "CallExpression" || node.callee.type === "Super") return Effect.void;
|
|
26
|
+
const namespaces = visibleNamespaces(ctx, node, effectNamespaces);
|
|
27
|
+
if (!isStaticMember(node.callee, namespaces, "fn") || !isFunction(node.arguments[0])) return Effect.void;
|
|
28
|
+
return ctx.report(make({
|
|
29
|
+
node,
|
|
30
|
+
message: "Name this operation with Effect.fn(\"Domain.operation\") for stable tracing and diagnostics."
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
//#endregion
|
|
37
|
+
export { requireNamedEffectFn };
|