oxlint-plugin-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 CHANGED
@@ -25,19 +25,20 @@ If the project uses JSON configuration, copy the exported rule map into `rules`;
25
25
 
26
26
  ## Recommended Rules
27
27
 
28
- | Rule | Contract |
29
- | ---------------------------- | ----------------------------------------------------------------------------------------- |
30
- | `effect/noAsyncFunction` | Bans async functions and await expressions |
31
- | `effect/noTryCatch` | Bans every try/catch/finally statement |
32
- | `effect/noThrowStatement` | Bans every throw statement |
33
- | `effect/noNewPromise` | Bans new Promise, Promise calls, and Promise static APIs |
34
- | `effect/noNewError` | Allows native Error values only as direct arguments to Effect.die, Cause.die, or Exit.die |
35
- | `effect/noTernary` | Bans conditional expressions while allowing ordinary if statements |
36
- | `effect/noDynamicImports` | Allows import() only behind a named lazy-loading boundary; bans require() |
37
- | `effect/noEffectDo` | Bans Effect.Do |
38
- | `effect/noEffectBind` | Bans Effect.bind |
39
- | `effect/noGlobals` | Bans ambient capabilities with direct Effect replacements |
40
- | `effect/noNodeBuiltinImport` | Bans fully replaced Node modules and replaced operations from partial modules |
28
+ | Rule | Contract |
29
+ | ----------------------------- | ----------------------------------------------------------------------------------------- |
30
+ | `effect/noAsyncFunction` | Bans async functions and await expressions |
31
+ | `effect/noTryCatch` | Bans every try/catch/finally statement |
32
+ | `effect/noTestLifecycleHooks` | Bans `beforeEach`, `afterEach`, `beforeAll`, and `afterAll`; use Effect scopes instead |
33
+ | `effect/noThrowStatement` | Bans every throw statement |
34
+ | `effect/noNewPromise` | Bans new Promise, Promise calls, and Promise static APIs |
35
+ | `effect/noNewError` | Allows native Error values only as direct arguments to Effect.die, Cause.die, or Exit.die |
36
+ | `effect/noTernary` | Bans conditional expressions while allowing ordinary if statements |
37
+ | `effect/noDynamicImports` | Allows import() only behind a named lazy-loading boundary; bans require() |
38
+ | `effect/noEffectDo` | Bans Effect.Do |
39
+ | `effect/noEffectBind` | Bans Effect.bind |
40
+ | `effect/noGlobals` | Bans ambient capabilities with direct Effect replacements |
41
+ | `effect/noNodeBuiltinImport` | Bans fully replaced Node modules and replaced operations from partial modules |
41
42
 
42
43
  The preset intentionally allows `Effect.as`, `Option.as`, `Effect.never`, `Effect.async`, ordinary `if` and `switch` statements, and runtime runners at explicit application boundaries.
43
44
 
@@ -10,6 +10,7 @@ declare const recommended: {
10
10
  readonly "effect/noNewPromise": "error";
11
11
  readonly "effect/noNodeBuiltinImport": "error";
12
12
  readonly "effect/noTernary": "error";
13
+ readonly "effect/noTestLifecycleHooks": "error";
13
14
  readonly "effect/noThrowStatement": "error";
14
15
  readonly "effect/noTryCatch": "error";
15
16
  };
@@ -10,6 +10,7 @@ const recommended = {
10
10
  "effect/noNewPromise": "error",
11
11
  "effect/noNodeBuiltinImport": "error",
12
12
  "effect/noTernary": "error",
13
+ "effect/noTestLifecycleHooks": "error",
13
14
  "effect/noThrowStatement": "error",
14
15
  "effect/noTryCatch": "error"
15
16
  };
@@ -7,12 +7,13 @@ import { noNewError } from "./no-new-error.js";
7
7
  import { noNewPromise } from "./no-new-promise.js";
8
8
  import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
9
9
  import { noTernary } from "./no-ternary.js";
10
+ import { noTestLifecycleHooks } from "./no-test-lifecycle-hooks.js";
10
11
  import { noThrowStatement } from "./no-throw-statement.js";
11
12
  import { noTryCatch } from "./no-try-catch.js";
12
13
 
13
14
  //#region src/rules/index.d.ts
14
15
  declare namespace index_d_exports {
15
- export { noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noThrowStatement, noTryCatch };
16
+ export { noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch };
16
17
  }
17
18
  //#endregion
18
- export { index_d_exports, noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noThrowStatement, noTryCatch };
19
+ export { index_d_exports, noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch };
@@ -8,6 +8,7 @@ import { noNewError } from "./no-new-error.js";
8
8
  import { noNewPromise } from "./no-new-promise.js";
9
9
  import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
10
10
  import { noTernary } from "./no-ternary.js";
11
+ import { noTestLifecycleHooks } from "./no-test-lifecycle-hooks.js";
11
12
  import { noThrowStatement } from "./no-throw-statement.js";
12
13
  import { noTryCatch } from "./no-try-catch.js";
13
14
  //#region src/rules/index.ts
@@ -21,8 +22,9 @@ var rules_exports = /* @__PURE__ */ __exportAll({
21
22
  noNewPromise: () => noNewPromise,
22
23
  noNodeBuiltinImport: () => noNodeBuiltinImport,
23
24
  noTernary: () => noTernary,
25
+ noTestLifecycleHooks: () => noTestLifecycleHooks,
24
26
  noThrowStatement: () => noThrowStatement,
25
27
  noTryCatch: () => noTryCatch
26
28
  });
27
29
  //#endregion
28
- export { noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noThrowStatement, noTryCatch, rules_exports };
30
+ export { noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch, rules_exports };
@@ -0,0 +1,6 @@
1
+ import * as _$_oxlint_plugins0 from "@oxlint/plugins";
2
+
3
+ //#region src/rules/no-test-lifecycle-hooks.d.ts
4
+ declare const noTestLifecycleHooks: _$_oxlint_plugins0.CreateRule;
5
+ //#endregion
6
+ export { noTestLifecycleHooks };
@@ -0,0 +1,37 @@
1
+ import { calleeName, narrow } from "../vendor/effect-oxlint/AST.js";
2
+ import { make } from "../vendor/effect-oxlint/Diagnostic.js";
3
+ import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
4
+ import { define, meta } from "../vendor/effect-oxlint/Rule.js";
5
+ import "../vendor/effect-oxlint/index.js";
6
+ import * as Option from "effect/Option";
7
+ import * as Effect from "effect/Effect";
8
+ //#region src/rules/no-test-lifecycle-hooks.ts
9
+ const lifecycleHooks = new Set([
10
+ "afterAll",
11
+ "afterEach",
12
+ "beforeAll",
13
+ "beforeEach"
14
+ ]);
15
+ const noTestLifecycleHooks = define({
16
+ name: "no-test-lifecycle-hooks",
17
+ meta: meta({
18
+ type: "problem",
19
+ description: "Model test fixtures with Effect scopes instead of lifecycle hooks."
20
+ }),
21
+ create: function* () {
22
+ const ctx = yield* RuleContext;
23
+ return { CallExpression: (node) => Option.match(narrow(node, "CallExpression"), {
24
+ onNone: () => Effect.void,
25
+ onSome: (call) => {
26
+ const name = Option.getOrUndefined(calleeName(call));
27
+ if (name === void 0 || !lifecycleHooks.has(name)) return Effect.void;
28
+ return ctx.report(make({
29
+ node: call,
30
+ message: `Avoid ${name}(). Use effect-bun-test scoped tests and Effect.acquireRelease for fixture lifecycles.`
31
+ }));
32
+ }
33
+ }) };
34
+ }
35
+ });
36
+ //#endregion
37
+ export { noTestLifecycleHooks };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-effect",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "oxlint plugin with Effect-specific lint rules",
5
5
  "license": "MIT",
6
6
  "repository": {