oxlint-plugin-effect 0.3.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 +80 -38
- package/dist/presets/index.d.ts +3 -9
- package/dist/presets/index.js +3 -17
- package/dist/presets/recommended.d.ts +18 -0
- package/dist/presets/recommended.js +18 -0
- package/dist/rules/index.d.ts +5 -61
- package/dist/rules/index.js +6 -118
- package/dist/rules/no-async-function.js +8 -13
- package/dist/rules/no-dynamic-imports.js +89 -60
- package/dist/rules/no-globals.js +164 -127
- package/dist/rules/no-new-error.js +26 -13
- package/dist/rules/no-new-promise.js +22 -21
- package/dist/rules/no-node-builtin-import.js +98 -41
- package/dist/rules/no-test-lifecycle-hooks.d.ts +6 -0
- package/dist/rules/no-test-lifecycle-hooks.js +37 -0
- package/dist/rules/no-throw-statement.js +4 -16
- package/dist/rules/no-try-catch.js +4 -16
- package/package.json +2 -2
- package/dist/presets/core.d.ts +0 -50
- package/dist/presets/core.js +0 -50
- package/dist/presets/effect-native.d.ts +0 -29
- package/dist/presets/effect-native.js +0 -29
- package/dist/presets/full.d.ts +0 -68
- package/dist/presets/full.js +0 -68
- package/dist/presets/functional.d.ts +0 -22
- package/dist/presets/functional.js +0 -22
- package/dist/presets/strict.d.ts +0 -73
- package/dist/presets/strict.js +0 -73
- package/dist/presets/v3-strict.d.ts +0 -16
- package/dist/presets/v3-strict.js +0 -16
- package/dist/presets/v3.d.ts +0 -18
- package/dist/presets/v3.js +0 -18
- package/dist/rules/_effect-context.d.ts +0 -19
- package/dist/rules/_effect-context.js +0 -22
- package/dist/rules/no-arrow-ladder.d.ts +0 -6
- package/dist/rules/no-arrow-ladder.js +0 -61
- package/dist/rules/no-catch-all-to-map-error.d.ts +0 -6
- package/dist/rules/no-catch-all-to-map-error.js +0 -67
- package/dist/rules/no-effect-all-step-sequencing.d.ts +0 -6
- package/dist/rules/no-effect-all-step-sequencing.js +0 -63
- package/dist/rules/no-effect-as.d.ts +0 -6
- package/dist/rules/no-effect-as.js +0 -16
- package/dist/rules/no-effect-async.d.ts +0 -6
- package/dist/rules/no-effect-async.js +0 -16
- package/dist/rules/no-effect-fn-generator.d.ts +0 -6
- package/dist/rules/no-effect-fn-generator.js +0 -30
- package/dist/rules/no-effect-gen-adapter.d.ts +0 -6
- package/dist/rules/no-effect-gen-adapter.js +0 -30
- package/dist/rules/no-effect-map-flatten.d.ts +0 -6
- package/dist/rules/no-effect-map-flatten.js +0 -53
- package/dist/rules/no-effect-map-void.d.ts +0 -6
- package/dist/rules/no-effect-map-void.js +0 -40
- package/dist/rules/no-effect-never.d.ts +0 -6
- package/dist/rules/no-effect-never.js +0 -16
- package/dist/rules/no-effect-orElse-ladder.d.ts +0 -6
- package/dist/rules/no-effect-orElse-ladder.js +0 -53
- package/dist/rules/no-effect-succeed-string.d.ts +0 -6
- package/dist/rules/no-effect-succeed-string.js +0 -30
- package/dist/rules/no-effect-succeed-variable.d.ts +0 -6
- package/dist/rules/no-effect-succeed-variable.js +0 -30
- package/dist/rules/no-effect-succeed-void.d.ts +0 -6
- package/dist/rules/no-effect-succeed-void.js +0 -33
- package/dist/rules/no-effect-sync-console.d.ts +0 -6
- package/dist/rules/no-effect-sync-console.js +0 -63
- package/dist/rules/no-effect-sync-wrapper.d.ts +0 -6
- package/dist/rules/no-effect-sync-wrapper.js +0 -37
- package/dist/rules/no-effect-type-alias.d.ts +0 -6
- package/dist/rules/no-effect-type-alias.js +0 -52
- package/dist/rules/no-effect-wrapper-alias.d.ts +0 -6
- package/dist/rules/no-effect-wrapper-alias.js +0 -69
- package/dist/rules/no-extends-native-error.d.ts +0 -6
- package/dist/rules/no-extends-native-error.js +0 -41
- package/dist/rules/no-flatmap-ladder.d.ts +0 -6
- package/dist/rules/no-flatmap-ladder.js +0 -48
- package/dist/rules/no-fromnullable-coalesce.d.ts +0 -6
- package/dist/rules/no-fromnullable-coalesce.js +0 -36
- package/dist/rules/no-global-error-in-catch.d.ts +0 -6
- package/dist/rules/no-global-error-in-catch.js +0 -75
- package/dist/rules/no-global-error-in-failure.d.ts +0 -6
- package/dist/rules/no-global-error-in-failure.js +0 -54
- package/dist/rules/no-hand-rolled-tagged-union.d.ts +0 -6
- package/dist/rules/no-hand-rolled-tagged-union.js +0 -70
- package/dist/rules/no-if-statement.d.ts +0 -6
- package/dist/rules/no-if-statement.js +0 -18
- package/dist/rules/no-iife-wrapper.d.ts +0 -6
- package/dist/rules/no-iife-wrapper.js +0 -37
- package/dist/rules/no-inline-provide.d.ts +0 -6
- package/dist/rules/no-inline-provide.js +0 -31
- package/dist/rules/no-instanceof-schema.d.ts +0 -6
- package/dist/rules/no-instanceof-schema.js +0 -35
- package/dist/rules/no-make-unsafe.d.ts +0 -6
- package/dist/rules/no-make-unsafe.js +0 -30
- package/dist/rules/no-manual-data-guard.d.ts +0 -6
- package/dist/rules/no-manual-data-guard.js +0 -56
- package/dist/rules/no-manual-effect-channels.d.ts +0 -6
- package/dist/rules/no-manual-effect-channels.js +0 -40
- package/dist/rules/no-match-effect-branch.d.ts +0 -6
- package/dist/rules/no-match-effect-branch.js +0 -64
- package/dist/rules/no-match-void-branch.d.ts +0 -6
- package/dist/rules/no-match-void-branch.js +0 -50
- package/dist/rules/no-multiple-effect-provide.d.ts +0 -6
- package/dist/rules/no-multiple-effect-provide.js +0 -45
- package/dist/rules/no-nested-effect-call.d.ts +0 -6
- package/dist/rules/no-nested-effect-call.js +0 -97
- package/dist/rules/no-nested-effect-gen.d.ts +0 -6
- package/dist/rules/no-nested-effect-gen.js +0 -46
- package/dist/rules/no-nested-pipe.d.ts +0 -6
- package/dist/rules/no-nested-pipe.js +0 -38
- package/dist/rules/no-option-as.d.ts +0 -6
- package/dist/rules/no-option-as.js +0 -16
- package/dist/rules/no-option-boolean-normalization.d.ts +0 -6
- package/dist/rules/no-option-boolean-normalization.js +0 -50
- package/dist/rules/no-positional-log-error.d.ts +0 -6
- package/dist/rules/no-positional-log-error.js +0 -52
- package/dist/rules/no-promise-control-flow-in-tests.d.ts +0 -6
- package/dist/rules/no-promise-control-flow-in-tests.js +0 -94
- package/dist/rules/no-redundant-schema-tag-identifier.d.ts +0 -6
- package/dist/rules/no-redundant-schema-tag-identifier.js +0 -46
- package/dist/rules/no-return-in-arrow.d.ts +0 -6
- package/dist/rules/no-return-in-arrow.js +0 -41
- package/dist/rules/no-return-nullish.d.ts +0 -6
- package/dist/rules/no-return-nullish.js +0 -47
- package/dist/rules/no-run-in-effect-gen.d.ts +0 -6
- package/dist/rules/no-run-in-effect-gen.js +0 -48
- package/dist/rules/no-runtime-run-fork.d.ts +0 -6
- package/dist/rules/no-runtime-run-fork.js +0 -19
- package/dist/rules/no-schema-struct-with-tag.d.ts +0 -6
- package/dist/rules/no-schema-struct-with-tag.js +0 -48
- package/dist/rules/no-schema-struct.d.ts +0 -6
- package/dist/rules/no-schema-struct.js +0 -28
- package/dist/rules/no-schema-union-of-literals.d.ts +0 -6
- package/dist/rules/no-schema-union-of-literals.js +0 -35
- package/dist/rules/no-sleep-in-tests.d.ts +0 -6
- package/dist/rules/no-sleep-in-tests.js +0 -55
- package/dist/rules/no-spread.d.ts +0 -6
- package/dist/rules/no-spread.js +0 -26
- package/dist/rules/no-string-sentinel-const.d.ts +0 -6
- package/dist/rules/no-string-sentinel-const.js +0 -38
- package/dist/rules/no-switch-statement.d.ts +0 -6
- package/dist/rules/no-switch-statement.js +0 -16
- package/dist/rules/no-unnecessary-arrow-block.d.ts +0 -6
- package/dist/rules/no-unnecessary-arrow-block.js +0 -34
- package/dist/rules/no-unnecessary-effect-gen.d.ts +0 -6
- package/dist/rules/no-unnecessary-effect-gen.js +0 -35
- package/dist/rules/no-unnecessary-pipe-chain.d.ts +0 -6
- package/dist/rules/no-unnecessary-pipe-chain.js +0 -36
- package/dist/rules/no-unnecessary-pipe.d.ts +0 -6
- package/dist/rules/no-unnecessary-pipe.js +0 -29
package/README.md
CHANGED
|
@@ -1,44 +1,106 @@
|
|
|
1
1
|
# oxlint-plugin-effect
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A strict, non-type-aware oxlint plugin for Effect-native TypeScript.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The package has one recommended preset. It protects application code from imperative failure handling, Promise control flow, ambient runtime dependencies, and a small set of non-idiomatic Effect APIs. Effect tsgo remains responsible for semantic and type-aware correctness.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
10
|
bun add -D oxlint oxlint-plugin-effect
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Load the plugin and enable the recommended rules in your oxlint configuration:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { recommended } from "oxlint-plugin-effect/presets/recommended";
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
jsPlugins: ["oxlint-plugin-effect/plugin"],
|
|
20
|
+
rules: recommended,
|
|
21
|
+
};
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
If the project uses JSON configuration, copy the exported rule map into `rules`; every recommended rule has `error` severity.
|
|
25
|
+
|
|
26
|
+
## Recommended Rules
|
|
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/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 |
|
|
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.
|
|
44
|
+
|
|
45
|
+
## Platform Boundaries
|
|
46
|
+
|
|
47
|
+
Application code should use Effect services for time, randomness, crypto randomness and supported digests, configuration, files, paths, child processes, stdio, HTTP, sockets, workers, streams, logging, JSON boundaries, encoding, and key-value storage.
|
|
48
|
+
|
|
49
|
+
The rules are capability-based rather than runtime-wide. They do not pretend Effect replaces HMAC, signing, encryption, password hashing, DNS, UDP, compression, module resolution, FFI, VM inspection, or every Buffer/EventEmitter/native-stream operation.
|
|
50
|
+
|
|
51
|
+
Put unmatched host calls in named adapter files and disable only the relevant rule there:
|
|
12
52
|
|
|
13
53
|
```json
|
|
14
54
|
{
|
|
15
|
-
"jsPlugins": ["oxlint-plugin-effect/plugin"],
|
|
16
|
-
"rules": {
|
|
17
|
-
"effect/noEffectDo": "error",
|
|
18
|
-
"effect/noNestedPipe": "error",
|
|
19
|
-
"effect/noThrowStatement": "error",
|
|
20
|
-
"effect/noGlobals": "warn"
|
|
21
|
-
},
|
|
22
55
|
"overrides": [
|
|
23
56
|
{
|
|
24
|
-
"files": ["
|
|
57
|
+
"files": ["src/platform/**/*.ts"],
|
|
25
58
|
"rules": {
|
|
26
|
-
"effect/
|
|
59
|
+
"effect/noGlobals": "off",
|
|
60
|
+
"effect/noNodeBuiltinImport": "off"
|
|
27
61
|
}
|
|
28
62
|
}
|
|
29
63
|
]
|
|
30
64
|
}
|
|
31
65
|
```
|
|
32
66
|
|
|
33
|
-
|
|
67
|
+
## Effect tsgo Pairing
|
|
34
68
|
|
|
35
|
-
|
|
36
|
-
|
|
69
|
+
Oxlint owns unconditional syntax. Effect tsgo owns floating Effects, missing channels, nested execution, leaking requirements, strict provisioning, schema semantics, and other type-aware diagnostics.
|
|
70
|
+
|
|
71
|
+
When using both tools, disable the tsgo diagnostics duplicated by this preset:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"diagnosticSeverity": {
|
|
76
|
+
"asyncFunction": "off",
|
|
77
|
+
"cryptoRandomUUID": "off",
|
|
78
|
+
"cryptoRandomUUIDInEffect": "off",
|
|
79
|
+
"globalConsole": "off",
|
|
80
|
+
"globalConsoleInEffect": "off",
|
|
81
|
+
"globalDate": "off",
|
|
82
|
+
"globalDateInEffect": "off",
|
|
83
|
+
"globalFetch": "off",
|
|
84
|
+
"globalFetchInEffect": "off",
|
|
85
|
+
"globalRandom": "off",
|
|
86
|
+
"globalRandomInEffect": "off",
|
|
87
|
+
"globalTimers": "off",
|
|
88
|
+
"globalTimersInEffect": "off",
|
|
89
|
+
"newPromise": "off",
|
|
90
|
+
"nodeBuiltinImport": "off",
|
|
91
|
+
"preferSchemaOverJson": "off",
|
|
92
|
+
"processEnv": "off",
|
|
93
|
+
"processEnvInEffect": "off",
|
|
94
|
+
"tryCatchInEffectGen": "off"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
37
97
|
```
|
|
38
98
|
|
|
99
|
+
Leave type-aware diagnostics such as `floatingEffect`, `runEffectInsideEffect`, `strictEffectProvide`, `extendsNativeError`, and `unsafeEffectTypeAssertion` enabled.
|
|
100
|
+
|
|
39
101
|
## Rule Authoring
|
|
40
102
|
|
|
41
|
-
The package
|
|
103
|
+
The package exports Effect-first rule-authoring bindings:
|
|
42
104
|
|
|
43
105
|
```ts
|
|
44
106
|
import { Diagnostic, Rule, RuleContext } from "oxlint-plugin-effect/rule-bindings";
|
|
@@ -50,40 +112,20 @@ export const noThing = Rule.define({
|
|
|
50
112
|
description: "Avoid thing.",
|
|
51
113
|
}),
|
|
52
114
|
create: function* () {
|
|
53
|
-
const
|
|
115
|
+
const context = yield* RuleContext;
|
|
54
116
|
return {
|
|
55
|
-
Identifier: (node) =>
|
|
117
|
+
Identifier: (node) => context.report(Diagnostic.make({ node, message: "Avoid thing." })),
|
|
56
118
|
};
|
|
57
119
|
},
|
|
58
120
|
});
|
|
59
121
|
```
|
|
60
122
|
|
|
61
|
-
The same bindings are available from the root export for convenience:
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
import { Rule, Diagnostic, RuleContext } from "oxlint-plugin-effect";
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Rules
|
|
68
|
-
|
|
69
|
-
68 AST-only rules across categories: API bans, global bans, import bans, statement bans, AST patterns, and Effect-context rules. Five presets are available: `core`, `full`, `effect-native`, `functional`, and `strict`.
|
|
70
|
-
|
|
71
|
-
`effect/noTryCatch` rejects every JavaScript `try` statement, including
|
|
72
|
-
`try/catch`, bare `try/finally`, and `try/catch/finally`. Use Effect's typed
|
|
73
|
-
failure channel and scoped finalization operators instead.
|
|
74
|
-
|
|
75
|
-
The core presets also reject sequential state mutations hidden in
|
|
76
|
-
`Effect.all(..., { concurrency: 1 })`. The stricter `noManualDataGuard` rule
|
|
77
|
-
requires unknown input to cross a Schema boundary instead of being promoted by
|
|
78
|
-
a hand-written type predicate.
|
|
79
|
-
|
|
80
123
|
## Development
|
|
81
124
|
|
|
82
125
|
```bash
|
|
83
126
|
bun install
|
|
84
127
|
bun run gate
|
|
85
128
|
bun run codegen
|
|
86
|
-
bun run add-rule <name> [--context]
|
|
87
129
|
```
|
|
88
130
|
|
|
89
131
|
## License
|
package/dist/presets/index.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { core } from "./core.js";
|
|
3
|
-
import { effectNative } from "./effect-native.js";
|
|
4
|
-
import { functional } from "./functional.js";
|
|
5
|
-
import { strict } from "./strict.js";
|
|
6
|
-
import { v3 } from "./v3.js";
|
|
7
|
-
import { v3Strict } from "./v3-strict.js";
|
|
1
|
+
import { recommended } from "./recommended.js";
|
|
8
2
|
|
|
9
3
|
//#region src/presets/index.d.ts
|
|
10
4
|
declare namespace index_d_exports {
|
|
11
|
-
export {
|
|
5
|
+
export { recommended };
|
|
12
6
|
}
|
|
13
7
|
//#endregion
|
|
14
|
-
export {
|
|
8
|
+
export { index_d_exports, recommended };
|
package/dist/presets/index.js
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import {
|
|
3
|
-
import { core } from "./core.js";
|
|
4
|
-
import { effectNative } from "./effect-native.js";
|
|
5
|
-
import { functional } from "./functional.js";
|
|
6
|
-
import { strict } from "./strict.js";
|
|
7
|
-
import { v3 } from "./v3.js";
|
|
8
|
-
import { v3Strict } from "./v3-strict.js";
|
|
2
|
+
import { recommended } from "./recommended.js";
|
|
9
3
|
//#region src/presets/index.ts
|
|
10
|
-
var presets_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
-
core: () => core,
|
|
12
|
-
effectNative: () => effectNative,
|
|
13
|
-
full: () => full,
|
|
14
|
-
functional: () => functional,
|
|
15
|
-
strict: () => strict,
|
|
16
|
-
v3: () => v3,
|
|
17
|
-
v3Strict: () => v3Strict
|
|
18
|
-
});
|
|
4
|
+
var presets_exports = /* @__PURE__ */ __exportAll({ recommended: () => recommended });
|
|
19
5
|
//#endregion
|
|
20
|
-
export {
|
|
6
|
+
export { presets_exports, recommended };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/presets/recommended.d.ts
|
|
2
|
+
/** Strict, non-type-aware policy for Effect-native application code. */
|
|
3
|
+
declare const recommended: {
|
|
4
|
+
readonly "effect/noAsyncFunction": "error";
|
|
5
|
+
readonly "effect/noDynamicImports": "error";
|
|
6
|
+
readonly "effect/noEffectBind": "error";
|
|
7
|
+
readonly "effect/noEffectDo": "error";
|
|
8
|
+
readonly "effect/noGlobals": "error";
|
|
9
|
+
readonly "effect/noNewError": "error";
|
|
10
|
+
readonly "effect/noNewPromise": "error";
|
|
11
|
+
readonly "effect/noNodeBuiltinImport": "error";
|
|
12
|
+
readonly "effect/noTernary": "error";
|
|
13
|
+
readonly "effect/noTestLifecycleHooks": "error";
|
|
14
|
+
readonly "effect/noThrowStatement": "error";
|
|
15
|
+
readonly "effect/noTryCatch": "error";
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { recommended };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/presets/recommended.ts
|
|
2
|
+
/** Strict, non-type-aware policy for Effect-native application code. */
|
|
3
|
+
const recommended = {
|
|
4
|
+
"effect/noAsyncFunction": "error",
|
|
5
|
+
"effect/noDynamicImports": "error",
|
|
6
|
+
"effect/noEffectBind": "error",
|
|
7
|
+
"effect/noEffectDo": "error",
|
|
8
|
+
"effect/noGlobals": "error",
|
|
9
|
+
"effect/noNewError": "error",
|
|
10
|
+
"effect/noNewPromise": "error",
|
|
11
|
+
"effect/noNodeBuiltinImport": "error",
|
|
12
|
+
"effect/noTernary": "error",
|
|
13
|
+
"effect/noTestLifecycleHooks": "error",
|
|
14
|
+
"effect/noThrowStatement": "error",
|
|
15
|
+
"effect/noTryCatch": "error"
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { recommended };
|
package/dist/rules/index.d.ts
CHANGED
|
@@ -1,75 +1,19 @@
|
|
|
1
|
-
import { noEffectAs } from "./no-effect-as.js";
|
|
2
|
-
import { noEffectAsync } from "./no-effect-async.js";
|
|
3
1
|
import { noEffectBind } from "./no-effect-bind.js";
|
|
4
2
|
import { noEffectDo } from "./no-effect-do.js";
|
|
5
|
-
import { noEffectNever } from "./no-effect-never.js";
|
|
6
|
-
import { noOptionAs } from "./no-option-as.js";
|
|
7
|
-
import { noRuntimeRunFork } from "./no-runtime-run-fork.js";
|
|
8
|
-
import { noIfStatement } from "./no-if-statement.js";
|
|
9
|
-
import { noSwitchStatement } from "./no-switch-statement.js";
|
|
10
|
-
import { noArrowLadder } from "./no-arrow-ladder.js";
|
|
11
3
|
import { noAsyncFunction } from "./no-async-function.js";
|
|
12
|
-
import { noCatchAllToMapError } from "./no-catch-all-to-map-error.js";
|
|
13
4
|
import { noDynamicImports } from "./no-dynamic-imports.js";
|
|
14
|
-
import { noEffectAllStepSequencing } from "./no-effect-all-step-sequencing.js";
|
|
15
|
-
import { noEffectFnGenerator } from "./no-effect-fn-generator.js";
|
|
16
|
-
import { noEffectGenAdapter } from "./no-effect-gen-adapter.js";
|
|
17
|
-
import { noEffectMapFlatten } from "./no-effect-map-flatten.js";
|
|
18
|
-
import { noEffectMapVoid } from "./no-effect-map-void.js";
|
|
19
|
-
import { noEffectOrElseLadder } from "./no-effect-orElse-ladder.js";
|
|
20
|
-
import { noEffectSucceedString } from "./no-effect-succeed-string.js";
|
|
21
|
-
import { noEffectSucceedVariable } from "./no-effect-succeed-variable.js";
|
|
22
|
-
import { noEffectSucceedVoid } from "./no-effect-succeed-void.js";
|
|
23
|
-
import { noEffectSyncConsole } from "./no-effect-sync-console.js";
|
|
24
|
-
import { noEffectSyncWrapper } from "./no-effect-sync-wrapper.js";
|
|
25
|
-
import { noEffectTypeAlias } from "./no-effect-type-alias.js";
|
|
26
|
-
import { noEffectWrapperAlias } from "./no-effect-wrapper-alias.js";
|
|
27
|
-
import { noExtendsNativeError } from "./no-extends-native-error.js";
|
|
28
|
-
import { noFlatmapLadder } from "./no-flatmap-ladder.js";
|
|
29
|
-
import { noFromNullableCoalesce } from "./no-fromnullable-coalesce.js";
|
|
30
|
-
import { noGlobalErrorInCatch } from "./no-global-error-in-catch.js";
|
|
31
|
-
import { noGlobalErrorInFailure } from "./no-global-error-in-failure.js";
|
|
32
|
-
import { noHandRolledTaggedUnion } from "./no-hand-rolled-tagged-union.js";
|
|
33
|
-
import { noIifeWrapper } from "./no-iife-wrapper.js";
|
|
34
|
-
import { noInstanceofSchema } from "./no-instanceof-schema.js";
|
|
35
|
-
import { noMakeUnsafe } from "./no-make-unsafe.js";
|
|
36
|
-
import { noManualDataGuard } from "./no-manual-data-guard.js";
|
|
37
|
-
import { noManualEffectChannels } from "./no-manual-effect-channels.js";
|
|
38
|
-
import { noMatchEffectBranch } from "./no-match-effect-branch.js";
|
|
39
|
-
import { noMatchVoidBranch } from "./no-match-void-branch.js";
|
|
40
|
-
import { noMultipleEffectProvide } from "./no-multiple-effect-provide.js";
|
|
41
|
-
import { noNestedEffectCall } from "./no-nested-effect-call.js";
|
|
42
|
-
import { noNestedEffectGen } from "./no-nested-effect-gen.js";
|
|
43
|
-
import { noNestedPipe } from "./no-nested-pipe.js";
|
|
44
|
-
import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
|
|
45
|
-
import { noOptionBooleanNormalization } from "./no-option-boolean-normalization.js";
|
|
46
|
-
import { noPositionalLogError } from "./no-positional-log-error.js";
|
|
47
|
-
import { noPromiseControlFlowInTests } from "./no-promise-control-flow-in-tests.js";
|
|
48
|
-
import { noRedundantSchemaTagIdentifier } from "./no-redundant-schema-tag-identifier.js";
|
|
49
|
-
import { noReturnInArrow } from "./no-return-in-arrow.js";
|
|
50
|
-
import { noSchemaStructWithTag } from "./no-schema-struct-with-tag.js";
|
|
51
|
-
import { noSchemaStruct } from "./no-schema-struct.js";
|
|
52
|
-
import { noSchemaUnionOfLiterals } from "./no-schema-union-of-literals.js";
|
|
53
|
-
import { noSleepInTests } from "./no-sleep-in-tests.js";
|
|
54
|
-
import { noSpread } from "./no-spread.js";
|
|
55
|
-
import { noStringSentinelConst } from "./no-string-sentinel-const.js";
|
|
56
|
-
import { noTernary } from "./no-ternary.js";
|
|
57
|
-
import { noUnnecessaryArrowBlock } from "./no-unnecessary-arrow-block.js";
|
|
58
|
-
import { noUnnecessaryEffectGen } from "./no-unnecessary-effect-gen.js";
|
|
59
|
-
import { noUnnecessaryPipeChain } from "./no-unnecessary-pipe-chain.js";
|
|
60
|
-
import { noUnnecessaryPipe } from "./no-unnecessary-pipe.js";
|
|
61
5
|
import { noGlobals } from "./no-globals.js";
|
|
62
|
-
import { noInlineProvide } from "./no-inline-provide.js";
|
|
63
6
|
import { noNewError } from "./no-new-error.js";
|
|
64
7
|
import { noNewPromise } from "./no-new-promise.js";
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
8
|
+
import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
|
|
9
|
+
import { noTernary } from "./no-ternary.js";
|
|
10
|
+
import { noTestLifecycleHooks } from "./no-test-lifecycle-hooks.js";
|
|
67
11
|
import { noThrowStatement } from "./no-throw-statement.js";
|
|
68
12
|
import { noTryCatch } from "./no-try-catch.js";
|
|
69
13
|
|
|
70
14
|
//#region src/rules/index.d.ts
|
|
71
15
|
declare namespace index_d_exports {
|
|
72
|
-
export {
|
|
16
|
+
export { noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch };
|
|
73
17
|
}
|
|
74
18
|
//#endregion
|
|
75
|
-
export { index_d_exports,
|
|
19
|
+
export { index_d_exports, noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch };
|
package/dist/rules/index.js
CHANGED
|
@@ -1,142 +1,30 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { noEffectAs } from "./no-effect-as.js";
|
|
3
|
-
import { noEffectAsync } from "./no-effect-async.js";
|
|
4
2
|
import { noEffectBind } from "./no-effect-bind.js";
|
|
5
3
|
import { noEffectDo } from "./no-effect-do.js";
|
|
6
|
-
import { noEffectNever } from "./no-effect-never.js";
|
|
7
|
-
import { noOptionAs } from "./no-option-as.js";
|
|
8
|
-
import { noRuntimeRunFork } from "./no-runtime-run-fork.js";
|
|
9
|
-
import { noIfStatement } from "./no-if-statement.js";
|
|
10
|
-
import { noSwitchStatement } from "./no-switch-statement.js";
|
|
11
|
-
import { noArrowLadder } from "./no-arrow-ladder.js";
|
|
12
4
|
import { noAsyncFunction } from "./no-async-function.js";
|
|
13
|
-
import { noCatchAllToMapError } from "./no-catch-all-to-map-error.js";
|
|
14
5
|
import { noDynamicImports } from "./no-dynamic-imports.js";
|
|
15
|
-
import { noEffectAllStepSequencing } from "./no-effect-all-step-sequencing.js";
|
|
16
|
-
import { noEffectFnGenerator } from "./no-effect-fn-generator.js";
|
|
17
|
-
import { noEffectGenAdapter } from "./no-effect-gen-adapter.js";
|
|
18
|
-
import { noEffectMapFlatten } from "./no-effect-map-flatten.js";
|
|
19
|
-
import { noEffectMapVoid } from "./no-effect-map-void.js";
|
|
20
|
-
import { noEffectOrElseLadder } from "./no-effect-orElse-ladder.js";
|
|
21
|
-
import { noEffectSucceedString } from "./no-effect-succeed-string.js";
|
|
22
|
-
import { noEffectSucceedVariable } from "./no-effect-succeed-variable.js";
|
|
23
|
-
import { noEffectSucceedVoid } from "./no-effect-succeed-void.js";
|
|
24
|
-
import { noEffectSyncConsole } from "./no-effect-sync-console.js";
|
|
25
|
-
import { noEffectSyncWrapper } from "./no-effect-sync-wrapper.js";
|
|
26
|
-
import { noEffectTypeAlias } from "./no-effect-type-alias.js";
|
|
27
|
-
import { noEffectWrapperAlias } from "./no-effect-wrapper-alias.js";
|
|
28
|
-
import { noExtendsNativeError } from "./no-extends-native-error.js";
|
|
29
|
-
import { noFlatmapLadder } from "./no-flatmap-ladder.js";
|
|
30
|
-
import { noFromNullableCoalesce } from "./no-fromnullable-coalesce.js";
|
|
31
|
-
import { noGlobalErrorInCatch } from "./no-global-error-in-catch.js";
|
|
32
|
-
import { noGlobalErrorInFailure } from "./no-global-error-in-failure.js";
|
|
33
|
-
import { noHandRolledTaggedUnion } from "./no-hand-rolled-tagged-union.js";
|
|
34
|
-
import { noIifeWrapper } from "./no-iife-wrapper.js";
|
|
35
|
-
import { noInstanceofSchema } from "./no-instanceof-schema.js";
|
|
36
|
-
import { noMakeUnsafe } from "./no-make-unsafe.js";
|
|
37
|
-
import { noManualDataGuard } from "./no-manual-data-guard.js";
|
|
38
|
-
import { noManualEffectChannels } from "./no-manual-effect-channels.js";
|
|
39
|
-
import { noMatchEffectBranch } from "./no-match-effect-branch.js";
|
|
40
|
-
import { noMatchVoidBranch } from "./no-match-void-branch.js";
|
|
41
|
-
import { noMultipleEffectProvide } from "./no-multiple-effect-provide.js";
|
|
42
|
-
import { noNestedEffectCall } from "./no-nested-effect-call.js";
|
|
43
|
-
import { noNestedEffectGen } from "./no-nested-effect-gen.js";
|
|
44
|
-
import { noNestedPipe } from "./no-nested-pipe.js";
|
|
45
|
-
import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
|
|
46
|
-
import { noOptionBooleanNormalization } from "./no-option-boolean-normalization.js";
|
|
47
|
-
import { noPositionalLogError } from "./no-positional-log-error.js";
|
|
48
|
-
import { noPromiseControlFlowInTests } from "./no-promise-control-flow-in-tests.js";
|
|
49
|
-
import { noRedundantSchemaTagIdentifier } from "./no-redundant-schema-tag-identifier.js";
|
|
50
|
-
import { noReturnInArrow } from "./no-return-in-arrow.js";
|
|
51
|
-
import { noSchemaStructWithTag } from "./no-schema-struct-with-tag.js";
|
|
52
|
-
import { noSchemaStruct } from "./no-schema-struct.js";
|
|
53
|
-
import { noSchemaUnionOfLiterals } from "./no-schema-union-of-literals.js";
|
|
54
|
-
import { noSleepInTests } from "./no-sleep-in-tests.js";
|
|
55
|
-
import { noSpread } from "./no-spread.js";
|
|
56
|
-
import { noStringSentinelConst } from "./no-string-sentinel-const.js";
|
|
57
|
-
import { noTernary } from "./no-ternary.js";
|
|
58
|
-
import { noUnnecessaryArrowBlock } from "./no-unnecessary-arrow-block.js";
|
|
59
|
-
import { noUnnecessaryEffectGen } from "./no-unnecessary-effect-gen.js";
|
|
60
|
-
import { noUnnecessaryPipeChain } from "./no-unnecessary-pipe-chain.js";
|
|
61
|
-
import { noUnnecessaryPipe } from "./no-unnecessary-pipe.js";
|
|
62
6
|
import { noGlobals } from "./no-globals.js";
|
|
63
|
-
import { noInlineProvide } from "./no-inline-provide.js";
|
|
64
7
|
import { noNewError } from "./no-new-error.js";
|
|
65
8
|
import { noNewPromise } from "./no-new-promise.js";
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
9
|
+
import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
|
|
10
|
+
import { noTernary } from "./no-ternary.js";
|
|
11
|
+
import { noTestLifecycleHooks } from "./no-test-lifecycle-hooks.js";
|
|
68
12
|
import { noThrowStatement } from "./no-throw-statement.js";
|
|
69
13
|
import { noTryCatch } from "./no-try-catch.js";
|
|
70
14
|
//#region src/rules/index.ts
|
|
71
15
|
var rules_exports = /* @__PURE__ */ __exportAll({
|
|
72
|
-
noArrowLadder: () => noArrowLadder,
|
|
73
16
|
noAsyncFunction: () => noAsyncFunction,
|
|
74
|
-
noCatchAllToMapError: () => noCatchAllToMapError,
|
|
75
17
|
noDynamicImports: () => noDynamicImports,
|
|
76
|
-
noEffectAllStepSequencing: () => noEffectAllStepSequencing,
|
|
77
|
-
noEffectAs: () => noEffectAs,
|
|
78
|
-
noEffectAsync: () => noEffectAsync,
|
|
79
18
|
noEffectBind: () => noEffectBind,
|
|
80
19
|
noEffectDo: () => noEffectDo,
|
|
81
|
-
noEffectFnGenerator: () => noEffectFnGenerator,
|
|
82
|
-
noEffectGenAdapter: () => noEffectGenAdapter,
|
|
83
|
-
noEffectMapFlatten: () => noEffectMapFlatten,
|
|
84
|
-
noEffectMapVoid: () => noEffectMapVoid,
|
|
85
|
-
noEffectNever: () => noEffectNever,
|
|
86
|
-
noEffectOrElseLadder: () => noEffectOrElseLadder,
|
|
87
|
-
noEffectSucceedString: () => noEffectSucceedString,
|
|
88
|
-
noEffectSucceedVariable: () => noEffectSucceedVariable,
|
|
89
|
-
noEffectSucceedVoid: () => noEffectSucceedVoid,
|
|
90
|
-
noEffectSyncConsole: () => noEffectSyncConsole,
|
|
91
|
-
noEffectSyncWrapper: () => noEffectSyncWrapper,
|
|
92
|
-
noEffectTypeAlias: () => noEffectTypeAlias,
|
|
93
|
-
noEffectWrapperAlias: () => noEffectWrapperAlias,
|
|
94
|
-
noExtendsNativeError: () => noExtendsNativeError,
|
|
95
|
-
noFlatmapLadder: () => noFlatmapLadder,
|
|
96
|
-
noFromNullableCoalesce: () => noFromNullableCoalesce,
|
|
97
|
-
noGlobalErrorInCatch: () => noGlobalErrorInCatch,
|
|
98
|
-
noGlobalErrorInFailure: () => noGlobalErrorInFailure,
|
|
99
20
|
noGlobals: () => noGlobals,
|
|
100
|
-
noHandRolledTaggedUnion: () => noHandRolledTaggedUnion,
|
|
101
|
-
noIfStatement: () => noIfStatement,
|
|
102
|
-
noIifeWrapper: () => noIifeWrapper,
|
|
103
|
-
noInlineProvide: () => noInlineProvide,
|
|
104
|
-
noInstanceofSchema: () => noInstanceofSchema,
|
|
105
|
-
noMakeUnsafe: () => noMakeUnsafe,
|
|
106
|
-
noManualDataGuard: () => noManualDataGuard,
|
|
107
|
-
noManualEffectChannels: () => noManualEffectChannels,
|
|
108
|
-
noMatchEffectBranch: () => noMatchEffectBranch,
|
|
109
|
-
noMatchVoidBranch: () => noMatchVoidBranch,
|
|
110
|
-
noMultipleEffectProvide: () => noMultipleEffectProvide,
|
|
111
|
-
noNestedEffectCall: () => noNestedEffectCall,
|
|
112
|
-
noNestedEffectGen: () => noNestedEffectGen,
|
|
113
|
-
noNestedPipe: () => noNestedPipe,
|
|
114
21
|
noNewError: () => noNewError,
|
|
115
22
|
noNewPromise: () => noNewPromise,
|
|
116
23
|
noNodeBuiltinImport: () => noNodeBuiltinImport,
|
|
117
|
-
noOptionAs: () => noOptionAs,
|
|
118
|
-
noOptionBooleanNormalization: () => noOptionBooleanNormalization,
|
|
119
|
-
noPositionalLogError: () => noPositionalLogError,
|
|
120
|
-
noPromiseControlFlowInTests: () => noPromiseControlFlowInTests,
|
|
121
|
-
noRedundantSchemaTagIdentifier: () => noRedundantSchemaTagIdentifier,
|
|
122
|
-
noReturnInArrow: () => noReturnInArrow,
|
|
123
|
-
noReturnNullish: () => noReturnNullish,
|
|
124
|
-
noRunInEffectGen: () => noRunInEffectGen,
|
|
125
|
-
noRuntimeRunFork: () => noRuntimeRunFork,
|
|
126
|
-
noSchemaStruct: () => noSchemaStruct,
|
|
127
|
-
noSchemaStructWithTag: () => noSchemaStructWithTag,
|
|
128
|
-
noSchemaUnionOfLiterals: () => noSchemaUnionOfLiterals,
|
|
129
|
-
noSleepInTests: () => noSleepInTests,
|
|
130
|
-
noSpread: () => noSpread,
|
|
131
|
-
noStringSentinelConst: () => noStringSentinelConst,
|
|
132
|
-
noSwitchStatement: () => noSwitchStatement,
|
|
133
24
|
noTernary: () => noTernary,
|
|
25
|
+
noTestLifecycleHooks: () => noTestLifecycleHooks,
|
|
134
26
|
noThrowStatement: () => noThrowStatement,
|
|
135
|
-
noTryCatch: () => noTryCatch
|
|
136
|
-
noUnnecessaryArrowBlock: () => noUnnecessaryArrowBlock,
|
|
137
|
-
noUnnecessaryEffectGen: () => noUnnecessaryEffectGen,
|
|
138
|
-
noUnnecessaryPipe: () => noUnnecessaryPipe,
|
|
139
|
-
noUnnecessaryPipeChain: () => noUnnecessaryPipeChain
|
|
27
|
+
noTryCatch: () => noTryCatch
|
|
140
28
|
});
|
|
141
29
|
//#endregion
|
|
142
|
-
export {
|
|
30
|
+
export { noAsyncFunction, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noNewError, noNewPromise, noNodeBuiltinImport, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch, rules_exports };
|
|
@@ -4,27 +4,18 @@ import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
|
4
4
|
import "../vendor/effect-oxlint/index.js";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
//#region src/rules/no-async-function.ts
|
|
7
|
-
/**
|
|
8
|
-
* Ban `async` functions.
|
|
9
|
-
*
|
|
10
|
-
* Use Effect.promise, Effect.tryPromise, or Effect.gen instead.
|
|
11
|
-
*
|
|
12
|
-
* Source: language-service/asyncFunction
|
|
13
|
-
*
|
|
14
|
-
* Note: This is an effectNative rule — off by default.
|
|
15
|
-
* Only enable in codebases fully committed to Effect.
|
|
16
|
-
*/
|
|
7
|
+
/** Ban async functions and await expressions. */
|
|
17
8
|
const noAsyncFunction = define({
|
|
18
9
|
name: "no-async-function",
|
|
19
10
|
meta: meta({
|
|
20
11
|
type: "suggestion",
|
|
21
|
-
description: "Avoid async
|
|
12
|
+
description: "Avoid async/await. Compose asynchronous work with Effect."
|
|
22
13
|
}),
|
|
23
14
|
create: function* () {
|
|
24
15
|
const ctx = yield* RuleContext;
|
|
25
16
|
const report = (node) => ctx.report(make({
|
|
26
17
|
node,
|
|
27
|
-
message: "Avoid async functions. Use Effect.
|
|
18
|
+
message: "Avoid async functions. Use Effect.gen with Effect.promise or Effect.tryPromise."
|
|
28
19
|
}));
|
|
29
20
|
return {
|
|
30
21
|
FunctionDeclaration: (node) => {
|
|
@@ -38,7 +29,11 @@ const noAsyncFunction = define({
|
|
|
38
29
|
ArrowFunctionExpression: (node) => {
|
|
39
30
|
if ("async" in node && node.async === true) return report(node);
|
|
40
31
|
return Effect.void;
|
|
41
|
-
}
|
|
32
|
+
},
|
|
33
|
+
AwaitExpression: (node) => ctx.report(make({
|
|
34
|
+
node,
|
|
35
|
+
message: "Avoid await. Yield Effect.promise or Effect.tryPromise inside Effect.gen."
|
|
36
|
+
}))
|
|
42
37
|
};
|
|
43
38
|
}
|
|
44
39
|
});
|