oxlint-plugin-effect 0.5.1 → 0.7.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
@@ -27,12 +27,14 @@ If the project uses JSON configuration, copy the exported rule map into `rules`;
27
27
 
28
28
  | Rule | Contract |
29
29
  | ----------------------------- | ----------------------------------------------------------------------------------------- |
30
+ | `effect/noAs` | Bans TypeScript `as` assertions; use `satisfies` |
30
31
  | `effect/noAsyncFunction` | Bans async functions and await expressions |
31
32
  | `effect/noTryCatch` | Bans every try/catch/finally statement |
32
33
  | `effect/noTestLifecycleHooks` | Bans `beforeEach`, `afterEach`, `beforeAll`, and `afterAll`; use Effect scopes instead |
33
34
  | `effect/noThrowStatement` | Bans every throw statement |
34
35
  | `effect/noNewPromise` | Bans new Promise, Promise calls, and Promise static APIs |
35
36
  | `effect/noNewError` | Allows native Error values only as direct arguments to Effect.die, Cause.die, or Exit.die |
37
+ | `effect/noNullish` | Bans null and undefined; use Option or a domain enum for richer state |
36
38
  | `effect/noTernary` | Bans conditional expressions while allowing ordinary if statements |
37
39
  | `effect/noDynamicImports` | Allows import() only behind a named lazy-loading boundary; bans require() |
38
40
  | `effect/noEffectDo` | Bans Effect.Do |
@@ -1,6 +1,7 @@
1
1
  //#region src/presets/recommended.d.ts
2
2
  /** Strict, non-type-aware policy for Effect-native application code. */
3
3
  declare const recommended: {
4
+ readonly "effect/noAs": "error";
4
5
  readonly "effect/noAsyncFunction": "error";
5
6
  readonly "effect/noDynamicImports": "error";
6
7
  readonly "effect/noEffectBind": "error";
@@ -9,6 +10,7 @@ declare const recommended: {
9
10
  readonly "effect/noNewError": "error";
10
11
  readonly "effect/noNewPromise": "error";
11
12
  readonly "effect/noNodeBuiltinImport": "error";
13
+ readonly "effect/noNullish": "error";
12
14
  readonly "effect/noTernary": "error";
13
15
  readonly "effect/noTestLifecycleHooks": "error";
14
16
  readonly "effect/noThrowStatement": "error";
@@ -1,6 +1,7 @@
1
1
  //#region src/presets/recommended.ts
2
2
  /** Strict, non-type-aware policy for Effect-native application code. */
3
3
  const recommended = {
4
+ "effect/noAs": "error",
4
5
  "effect/noAsyncFunction": "error",
5
6
  "effect/noDynamicImports": "error",
6
7
  "effect/noEffectBind": "error",
@@ -9,6 +10,7 @@ const recommended = {
9
10
  "effect/noNewError": "error",
10
11
  "effect/noNewPromise": "error",
11
12
  "effect/noNodeBuiltinImport": "error",
13
+ "effect/noNullish": "error",
12
14
  "effect/noTernary": "error",
13
15
  "effect/noTestLifecycleHooks": "error",
14
16
  "effect/noThrowStatement": "error",
@@ -1,11 +1,13 @@
1
1
  import { noEffectBind } from "./no-effect-bind.js";
2
2
  import { noEffectDo } from "./no-effect-do.js";
3
+ import { noAs } from "./no-as.js";
3
4
  import { noAsyncFunction } from "./no-async-function.js";
4
5
  import { noDynamicImports } from "./no-dynamic-imports.js";
5
6
  import { noGlobals } from "./no-globals.js";
6
7
  import { noNewError } from "./no-new-error.js";
7
8
  import { noNewPromise } from "./no-new-promise.js";
8
9
  import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
10
+ import { noNullish } from "./no-nullish.js";
9
11
  import { noTernary } from "./no-ternary.js";
10
12
  import { noTestLifecycleHooks } from "./no-test-lifecycle-hooks.js";
11
13
  import { noThrowStatement } from "./no-throw-statement.js";
@@ -13,7 +15,7 @@ import { noTryCatch } from "./no-try-catch.js";
13
15
 
14
16
  //#region src/rules/index.d.ts
15
17
  declare namespace index_d_exports {
16
- export { noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch };
18
+ export { noAs, noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noNullish, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch };
17
19
  }
18
20
  //#endregion
19
- export { index_d_exports, noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch };
21
+ export { index_d_exports, noAs, noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noNullish, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch };
@@ -1,18 +1,21 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  import { noEffectBind } from "./no-effect-bind.js";
3
3
  import { noEffectDo } from "./no-effect-do.js";
4
+ import { noAs } from "./no-as.js";
4
5
  import { noAsyncFunction } from "./no-async-function.js";
5
6
  import { noDynamicImports } from "./no-dynamic-imports.js";
6
7
  import { noGlobals } from "./no-globals.js";
7
8
  import { noNewError } from "./no-new-error.js";
8
9
  import { noNewPromise } from "./no-new-promise.js";
9
10
  import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
11
+ import { noNullish } from "./no-nullish.js";
10
12
  import { noTernary } from "./no-ternary.js";
11
13
  import { noTestLifecycleHooks } from "./no-test-lifecycle-hooks.js";
12
14
  import { noThrowStatement } from "./no-throw-statement.js";
13
15
  import { noTryCatch } from "./no-try-catch.js";
14
16
  //#region src/rules/index.ts
15
17
  var rules_exports = /* @__PURE__ */ __exportAll({
18
+ noAs: () => noAs,
16
19
  noAsyncFunction: () => noAsyncFunction,
17
20
  noDynamicImports: () => noDynamicImports,
18
21
  noEffectBind: () => noEffectBind,
@@ -21,10 +24,11 @@ var rules_exports = /* @__PURE__ */ __exportAll({
21
24
  noNewError: () => noNewError,
22
25
  noNewPromise: () => noNewPromise,
23
26
  noNodeBuiltinImport: () => noNodeBuiltinImport,
27
+ noNullish: () => noNullish,
24
28
  noTernary: () => noTernary,
25
29
  noTestLifecycleHooks: () => noTestLifecycleHooks,
26
30
  noThrowStatement: () => noThrowStatement,
27
31
  noTryCatch: () => noTryCatch
28
32
  });
29
33
  //#endregion
30
- export { noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch, rules_exports };
34
+ export { noAs, noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noNullish, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch, rules_exports };
@@ -0,0 +1,6 @@
1
+ import * as _$_oxlint_plugins0 from "@oxlint/plugins";
2
+
3
+ //#region src/rules/no-as.d.ts
4
+ declare const noAs: _$_oxlint_plugins0.CreateRule;
5
+ //#endregion
6
+ export { noAs };
@@ -0,0 +1,22 @@
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
+ //#region src/rules/no-as.ts
6
+ /** Ban TypeScript `as` assertions. */
7
+ const noAs = define({
8
+ name: "no-as",
9
+ meta: meta({
10
+ type: "problem",
11
+ description: "Use satisfies instead of an as assertion."
12
+ }),
13
+ create: function* () {
14
+ const ctx = yield* RuleContext;
15
+ return { TSAsExpression: (node) => ctx.report(make({
16
+ node,
17
+ message: "Avoid as assertions. Use satisfies instead."
18
+ })) };
19
+ }
20
+ });
21
+ //#endregion
22
+ export { noAs };
@@ -0,0 +1,6 @@
1
+ import * as _$_oxlint_plugins0 from "@oxlint/plugins";
2
+
3
+ //#region src/rules/no-nullish.d.ts
4
+ declare const noNullish: _$_oxlint_plugins0.CreateRule;
5
+ //#endregion
6
+ export { noNullish };
@@ -0,0 +1,50 @@
1
+ import { 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 { isGlobalReference } from "../vendor/effect-oxlint/SourceCode.js";
6
+ import "../vendor/effect-oxlint/index.js";
7
+ import * as Option from "effect/Option";
8
+ import * as Effect from "effect/Effect";
9
+ //#region src/rules/no-nullish.ts
10
+ const message = "Avoid null and undefined. Use Option for presence or absence. Use a domain enum when the state has more than two cases.";
11
+ const noNullish = define({
12
+ name: "no-nullish",
13
+ meta: meta({
14
+ type: "problem",
15
+ description: "Use Option or a domain enum instead of null and undefined."
16
+ }),
17
+ create: function* () {
18
+ const ctx = yield* RuleContext;
19
+ const report = (node) => ctx.report(make({
20
+ node,
21
+ message
22
+ }));
23
+ return {
24
+ Identifier: (node) => Option.match(narrow(node, "Identifier"), {
25
+ onNone: () => Effect.void,
26
+ onSome: (identifier) => {
27
+ if (identifier.name !== "undefined") return Effect.void;
28
+ return isGlobalReference(identifier).pipe(Effect.flatMap((isGlobal) => {
29
+ if (!isGlobal) return Effect.void;
30
+ return report(identifier);
31
+ }));
32
+ }
33
+ }),
34
+ Literal: (node) => Option.match(narrow(node, "Literal"), {
35
+ onNone: () => Effect.void,
36
+ onSome: (literal) => literal.value === null && !("regex" in literal) ? report(literal) : Effect.void
37
+ }),
38
+ TSNullKeyword: (node) => Option.match(narrow(node, "TSNullKeyword"), {
39
+ onNone: () => Effect.void,
40
+ onSome: report
41
+ }),
42
+ TSUndefinedKeyword: (node) => Option.match(narrow(node, "TSUndefinedKeyword"), {
43
+ onNone: () => Effect.void,
44
+ onSome: report
45
+ })
46
+ };
47
+ }
48
+ });
49
+ //#endregion
50
+ export { noNullish };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-effect",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "oxlint plugin with Effect-specific lint rules",
5
5
  "license": "MIT",
6
6
  "repository": {