oxlint-plugin-effect 0.6.0 → 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
@@ -34,6 +34,7 @@ If the project uses JSON configuration, copy the exported rule map into `rules`;
34
34
  | `effect/noThrowStatement` | Bans every throw statement |
35
35
  | `effect/noNewPromise` | Bans new Promise, Promise calls, and Promise static APIs |
36
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 |
37
38
  | `effect/noTernary` | Bans conditional expressions while allowing ordinary if statements |
38
39
  | `effect/noDynamicImports` | Allows import() only behind a named lazy-loading boundary; bans require() |
39
40
  | `effect/noEffectDo` | Bans Effect.Do |
@@ -10,6 +10,7 @@ declare const recommended: {
10
10
  readonly "effect/noNewError": "error";
11
11
  readonly "effect/noNewPromise": "error";
12
12
  readonly "effect/noNodeBuiltinImport": "error";
13
+ readonly "effect/noNullish": "error";
13
14
  readonly "effect/noTernary": "error";
14
15
  readonly "effect/noTestLifecycleHooks": "error";
15
16
  readonly "effect/noThrowStatement": "error";
@@ -10,6 +10,7 @@ const recommended = {
10
10
  "effect/noNewError": "error",
11
11
  "effect/noNewPromise": "error",
12
12
  "effect/noNodeBuiltinImport": "error",
13
+ "effect/noNullish": "error",
13
14
  "effect/noTernary": "error",
14
15
  "effect/noTestLifecycleHooks": "error",
15
16
  "effect/noThrowStatement": "error",
@@ -7,6 +7,7 @@ import { noGlobals } from "./no-globals.js";
7
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
+ import { noNullish } from "./no-nullish.js";
10
11
  import { noTernary } from "./no-ternary.js";
11
12
  import { noTestLifecycleHooks } from "./no-test-lifecycle-hooks.js";
12
13
  import { noThrowStatement } from "./no-throw-statement.js";
@@ -14,7 +15,7 @@ import { noTryCatch } from "./no-try-catch.js";
14
15
 
15
16
  //#region src/rules/index.d.ts
16
17
  declare namespace index_d_exports {
17
- export { noAs, 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 };
18
19
  }
19
20
  //#endregion
20
- export { index_d_exports, noAs, 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 };
@@ -8,6 +8,7 @@ import { noGlobals } from "./no-globals.js";
8
8
  import { noNewError } from "./no-new-error.js";
9
9
  import { noNewPromise } from "./no-new-promise.js";
10
10
  import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
11
+ import { noNullish } from "./no-nullish.js";
11
12
  import { noTernary } from "./no-ternary.js";
12
13
  import { noTestLifecycleHooks } from "./no-test-lifecycle-hooks.js";
13
14
  import { noThrowStatement } from "./no-throw-statement.js";
@@ -23,10 +24,11 @@ var rules_exports = /* @__PURE__ */ __exportAll({
23
24
  noNewError: () => noNewError,
24
25
  noNewPromise: () => noNewPromise,
25
26
  noNodeBuiltinImport: () => noNodeBuiltinImport,
27
+ noNullish: () => noNullish,
26
28
  noTernary: () => noTernary,
27
29
  noTestLifecycleHooks: () => noTestLifecycleHooks,
28
30
  noThrowStatement: () => noThrowStatement,
29
31
  noTryCatch: () => noTryCatch
30
32
  });
31
33
  //#endregion
32
- export { noAs, 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-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.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "oxlint plugin with Effect-specific lint rules",
5
5
  "license": "MIT",
6
6
  "repository": {