oxlint-plugin-effect 0.2.2 → 0.3.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 +91 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.js +13 -1
- package/dist/presets/core.d.ts +7 -0
- package/dist/presets/core.js +8 -1
- package/dist/presets/effect-native.d.ts +1 -0
- package/dist/presets/effect-native.js +1 -0
- package/dist/presets/full.d.ts +8 -0
- package/dist/presets/full.js +9 -1
- package/dist/presets/functional.d.ts +1 -0
- package/dist/presets/functional.js +2 -1
- package/dist/presets/strict.d.ts +9 -0
- package/dist/presets/strict.js +10 -1
- package/dist/rules/index.d.ts +11 -2
- package/dist/rules/index.js +19 -1
- package/dist/rules/no-dynamic-imports.d.ts +6 -0
- package/dist/rules/no-dynamic-imports.js +90 -0
- package/dist/rules/no-effect-all-step-sequencing.d.ts +6 -0
- package/dist/rules/no-effect-all-step-sequencing.js +63 -0
- package/dist/rules/no-hand-rolled-tagged-union.d.ts +6 -0
- package/dist/rules/no-hand-rolled-tagged-union.js +70 -0
- package/dist/rules/no-make-unsafe.d.ts +6 -0
- package/dist/rules/no-make-unsafe.js +30 -0
- package/dist/rules/no-manual-data-guard.d.ts +6 -0
- package/dist/rules/no-manual-data-guard.js +56 -0
- package/dist/rules/no-promise-control-flow-in-tests.d.ts +6 -0
- package/dist/rules/no-promise-control-flow-in-tests.js +94 -0
- package/dist/rules/no-schema-struct.d.ts +6 -0
- package/dist/rules/no-schema-struct.js +28 -0
- package/dist/rules/no-sleep-in-tests.d.ts +6 -0
- package/dist/rules/no-sleep-in-tests.js +55 -0
- package/dist/rules/no-spread.d.ts +6 -0
- package/dist/rules/no-spread.js +26 -0
- package/dist/rules/no-try-catch.js +3 -3
- package/dist/vendor/effect-oxlint/Rule.d.ts +6 -6
- package/dist/vendor/effect-oxlint/RuleContext.d.ts +1 -1
- package/dist/vendor/effect-oxlint/RuleContext.js +1 -1
- package/dist/vendor/effect-oxlint/Testing.js +4 -1
- package/dist/vendor/effect-oxlint/Visitor.d.ts +1 -1
- package/dist/vendor/effect-oxlint/index.d.ts +7 -1
- package/dist/vendor/effect-oxlint/index.js +24 -1
- package/package.json +23 -10
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# oxlint-plugin-effect
|
|
2
|
+
|
|
3
|
+
Oxlint plugin for [Effect](https://effect.website) codebases.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add -D oxlint oxlint-plugin-effect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`.oxlintrc.json`:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
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
|
+
"overrides": [
|
|
23
|
+
{
|
|
24
|
+
"files": ["**/*.test.ts", "**/*.test.tsx", "**/tests/**", "**/test/**"],
|
|
25
|
+
"rules": {
|
|
26
|
+
"effect/noInlineProvide": "off"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The `overrides` entry turns off `noInlineProvide` in test files. The rule's intent is "provide layers at the boundary, not scattered through production code" — in tests, `it.effect(() => Effect.gen(function*() { ... }).pipe(Effect.provide(TestLayer)))` is the boundary.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
oxlint
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Rule Authoring
|
|
40
|
+
|
|
41
|
+
The package also exports the Effect-first rule authoring bindings:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { Diagnostic, Rule, RuleContext } from "oxlint-plugin-effect/rule-bindings";
|
|
45
|
+
|
|
46
|
+
export const noThing = Rule.define({
|
|
47
|
+
name: "no-thing",
|
|
48
|
+
meta: Rule.meta({
|
|
49
|
+
type: "problem",
|
|
50
|
+
description: "Avoid thing.",
|
|
51
|
+
}),
|
|
52
|
+
create: function* () {
|
|
53
|
+
const ctx = yield* RuleContext;
|
|
54
|
+
return {
|
|
55
|
+
Identifier: (node) => ctx.report(Diagnostic.make({ node, message: "Avoid thing." })),
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
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
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
bun install
|
|
84
|
+
bun run gate
|
|
85
|
+
bun run codegen
|
|
86
|
+
bun run add-rule <name> [--context]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
import { AST_d_exports } from "./vendor/effect-oxlint/AST.js";
|
|
2
|
+
import { Comment_d_exports } from "./vendor/effect-oxlint/Comment.js";
|
|
3
|
+
import { Diagnostic_d_exports } from "./vendor/effect-oxlint/Diagnostic.js";
|
|
4
|
+
import { Plugin_d_exports } from "./vendor/effect-oxlint/Plugin.js";
|
|
5
|
+
import { RuleContext, ast, cwd, filename, id, report, sourceCode, text } from "./vendor/effect-oxlint/RuleContext.js";
|
|
6
|
+
import { Visitor_d_exports } from "./vendor/effect-oxlint/Visitor.js";
|
|
7
|
+
import { Rule_d_exports } from "./vendor/effect-oxlint/Rule.js";
|
|
8
|
+
import { Scope_d_exports } from "./vendor/effect-oxlint/Scope.js";
|
|
9
|
+
import { SourceCode_d_exports } from "./vendor/effect-oxlint/SourceCode.js";
|
|
10
|
+
import { Testing_d_exports } from "./vendor/effect-oxlint/Testing.js";
|
|
11
|
+
import { Token_d_exports } from "./vendor/effect-oxlint/Token.js";
|
|
12
|
+
import { Context, CreateOnceRule, CreateRule, Definition, DefinitionType, ESTree, Fix, FixFn, Fixer, LineColumn, Location, OxlintComment, OxlintPlugin, OxlintRule, OxlintScope, OxlintSourceCode, OxlintToken, OxlintVisitor, Range, Ranged, Reference, RuleDocs, RuleMeta, ScopeManager, ScopeType, Settings, Span, Suggestion, Variable, index_d_exports as index_d_exports$1 } from "./vendor/effect-oxlint/index.js";
|
|
1
13
|
import _default from "./plugin.js";
|
|
2
|
-
import { index_d_exports as index_d_exports$
|
|
14
|
+
import { index_d_exports as index_d_exports$2 } from "./rules/index.js";
|
|
3
15
|
import { index_d_exports } from "./presets/index.js";
|
|
4
|
-
export { _default as plugin, index_d_exports as presets, index_d_exports$1 as rules };
|
|
16
|
+
export { AST_d_exports as AST, Comment_d_exports as Comment, Context, CreateOnceRule, CreateRule, Definition, DefinitionType, Diagnostic_d_exports as Diagnostic, ESTree, Fix, FixFn, Fixer, LineColumn, Location, OxlintComment, OxlintPlugin, OxlintRule, OxlintScope, OxlintSourceCode, OxlintToken, OxlintVisitor, Plugin_d_exports as Plugin, Range, Ranged, Reference, Rule_d_exports as Rule, RuleContext, RuleDocs, RuleMeta, Scope_d_exports as Scope, ScopeManager, ScopeType, Settings, SourceCode_d_exports as SourceCode, Span, Suggestion, Testing_d_exports as Testing, Token_d_exports as Token, Variable, Visitor_d_exports as Visitor, ast, cwd, filename, id, _default as plugin, index_d_exports as presets, report, index_d_exports$1 as ruleBindings, index_d_exports$2 as rules, sourceCode, text };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
import { AST_exports } from "./vendor/effect-oxlint/AST.js";
|
|
2
|
+
import { Comment_exports } from "./vendor/effect-oxlint/Comment.js";
|
|
3
|
+
import { Diagnostic_exports } from "./vendor/effect-oxlint/Diagnostic.js";
|
|
4
|
+
import { Plugin_exports } from "./vendor/effect-oxlint/Plugin.js";
|
|
5
|
+
import { RuleContext, ast, cwd, filename, id, report, sourceCode, text } from "./vendor/effect-oxlint/RuleContext.js";
|
|
6
|
+
import { Visitor_exports } from "./vendor/effect-oxlint/Visitor.js";
|
|
7
|
+
import { Rule_exports } from "./vendor/effect-oxlint/Rule.js";
|
|
8
|
+
import { Scope_exports } from "./vendor/effect-oxlint/Scope.js";
|
|
9
|
+
import { SourceCode_exports } from "./vendor/effect-oxlint/SourceCode.js";
|
|
10
|
+
import { Testing_exports } from "./vendor/effect-oxlint/Testing.js";
|
|
11
|
+
import { Token_exports } from "./vendor/effect-oxlint/Token.js";
|
|
12
|
+
import { effect_oxlint_exports } from "./vendor/effect-oxlint/index.js";
|
|
1
13
|
import { rules_exports } from "./rules/index.js";
|
|
2
14
|
import plugin_default from "./plugin.js";
|
|
3
15
|
import { presets_exports } from "./presets/index.js";
|
|
4
|
-
export { plugin_default as plugin, presets_exports as presets, rules_exports as rules };
|
|
16
|
+
export { AST_exports as AST, Comment_exports as Comment, Diagnostic_exports as Diagnostic, Plugin_exports as Plugin, Rule_exports as Rule, RuleContext, Scope_exports as Scope, SourceCode_exports as SourceCode, Testing_exports as Testing, Token_exports as Token, Visitor_exports as Visitor, ast, cwd, filename, id, plugin_default as plugin, presets_exports as presets, report, effect_oxlint_exports as ruleBindings, rules_exports as rules, sourceCode, text };
|
package/dist/presets/core.d.ts
CHANGED
|
@@ -27,10 +27,15 @@ declare const core: {
|
|
|
27
27
|
readonly "effect/noUnnecessaryPipeChain": "error";
|
|
28
28
|
readonly "effect/noMultipleEffectProvide": "error";
|
|
29
29
|
readonly "effect/noSchemaUnionOfLiterals": "warn";
|
|
30
|
+
readonly "effect/noSchemaStruct": "error";
|
|
30
31
|
readonly "effect/noSchemaStructWithTag": "warn";
|
|
31
32
|
readonly "effect/noRedundantSchemaTagIdentifier": "warn";
|
|
32
33
|
readonly "effect/noEffectMapFlatten": "warn";
|
|
33
34
|
readonly "effect/noPositionalLogError": "error";
|
|
35
|
+
readonly "effect/noMakeUnsafe": "error";
|
|
36
|
+
readonly "effect/noHandRolledTaggedUnion": "error";
|
|
37
|
+
readonly "effect/noDynamicImports": "error";
|
|
38
|
+
readonly "effect/noEffectAllStepSequencing": "error";
|
|
34
39
|
readonly "effect/noThrowStatement": "error";
|
|
35
40
|
readonly "effect/noTryCatch": "error";
|
|
36
41
|
readonly "effect/noNewPromise": "error";
|
|
@@ -38,6 +43,8 @@ declare const core: {
|
|
|
38
43
|
readonly "effect/noReturnNullish": "warn";
|
|
39
44
|
readonly "effect/noGlobals": "error";
|
|
40
45
|
readonly "effect/noInlineProvide": "error";
|
|
46
|
+
readonly "effect/noPromiseControlFlowInTests": "error";
|
|
47
|
+
readonly "effect/noSleepInTests": "error";
|
|
41
48
|
};
|
|
42
49
|
//#endregion
|
|
43
50
|
export { core };
|
package/dist/presets/core.js
CHANGED
|
@@ -27,17 +27,24 @@ const core = {
|
|
|
27
27
|
"effect/noUnnecessaryPipeChain": "error",
|
|
28
28
|
"effect/noMultipleEffectProvide": "error",
|
|
29
29
|
"effect/noSchemaUnionOfLiterals": "warn",
|
|
30
|
+
"effect/noSchemaStruct": "error",
|
|
30
31
|
"effect/noSchemaStructWithTag": "warn",
|
|
31
32
|
"effect/noRedundantSchemaTagIdentifier": "warn",
|
|
32
33
|
"effect/noEffectMapFlatten": "warn",
|
|
33
34
|
"effect/noPositionalLogError": "error",
|
|
35
|
+
"effect/noMakeUnsafe": "error",
|
|
36
|
+
"effect/noHandRolledTaggedUnion": "error",
|
|
37
|
+
"effect/noDynamicImports": "error",
|
|
38
|
+
"effect/noEffectAllStepSequencing": "error",
|
|
34
39
|
"effect/noThrowStatement": "error",
|
|
35
40
|
"effect/noTryCatch": "error",
|
|
36
41
|
"effect/noNewPromise": "error",
|
|
37
42
|
"effect/noNewError": "error",
|
|
38
43
|
"effect/noReturnNullish": "warn",
|
|
39
44
|
"effect/noGlobals": "error",
|
|
40
|
-
"effect/noInlineProvide": "error"
|
|
45
|
+
"effect/noInlineProvide": "error",
|
|
46
|
+
"effect/noPromiseControlFlowInTests": "error",
|
|
47
|
+
"effect/noSleepInTests": "error"
|
|
41
48
|
};
|
|
42
49
|
//#endregion
|
|
43
50
|
export { core };
|
|
@@ -9,6 +9,7 @@ declare const effectNative: {
|
|
|
9
9
|
readonly "effect/noNodeBuiltinImport": "error";
|
|
10
10
|
readonly "effect/noThrowStatement": "error";
|
|
11
11
|
readonly "effect/noTryCatch": "error";
|
|
12
|
+
readonly "effect/noEffectAllStepSequencing": "error";
|
|
12
13
|
readonly "effect/noNewPromise": "error";
|
|
13
14
|
readonly "effect/noNewError": "error";
|
|
14
15
|
readonly "effect/noReturnNullish": "error";
|
|
@@ -9,6 +9,7 @@ const effectNative = {
|
|
|
9
9
|
"effect/noNodeBuiltinImport": "error",
|
|
10
10
|
"effect/noThrowStatement": "error",
|
|
11
11
|
"effect/noTryCatch": "error",
|
|
12
|
+
"effect/noEffectAllStepSequencing": "error",
|
|
12
13
|
"effect/noNewPromise": "error",
|
|
13
14
|
"effect/noNewError": "error",
|
|
14
15
|
"effect/noReturnNullish": "error",
|
package/dist/presets/full.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare const full: {
|
|
|
14
14
|
readonly "effect/noOptionAs": "error";
|
|
15
15
|
readonly "effect/noRunInEffectGen": "error";
|
|
16
16
|
readonly "effect/noNodeBuiltinImport": "warn";
|
|
17
|
+
readonly "effect/noSpread": "error";
|
|
17
18
|
readonly "effect/noNestedPipe": "error";
|
|
18
19
|
readonly "effect/noNestedEffectGen": "error";
|
|
19
20
|
readonly "effect/noUnnecessaryEffectGen": "error";
|
|
@@ -42,12 +43,17 @@ declare const full: {
|
|
|
42
43
|
readonly "effect/noUnnecessaryPipeChain": "error";
|
|
43
44
|
readonly "effect/noMultipleEffectProvide": "error";
|
|
44
45
|
readonly "effect/noSchemaUnionOfLiterals": "warn";
|
|
46
|
+
readonly "effect/noSchemaStruct": "error";
|
|
45
47
|
readonly "effect/noSchemaStructWithTag": "warn";
|
|
46
48
|
readonly "effect/noRedundantSchemaTagIdentifier": "warn";
|
|
47
49
|
readonly "effect/noEffectMapFlatten": "warn";
|
|
48
50
|
readonly "effect/noGlobalErrorInFailure": "error";
|
|
49
51
|
readonly "effect/noGlobalErrorInCatch": "error";
|
|
50
52
|
readonly "effect/noPositionalLogError": "error";
|
|
53
|
+
readonly "effect/noMakeUnsafe": "error";
|
|
54
|
+
readonly "effect/noHandRolledTaggedUnion": "error";
|
|
55
|
+
readonly "effect/noDynamicImports": "error";
|
|
56
|
+
readonly "effect/noEffectAllStepSequencing": "error";
|
|
51
57
|
readonly "effect/noThrowStatement": "error";
|
|
52
58
|
readonly "effect/noTryCatch": "error";
|
|
53
59
|
readonly "effect/noNewPromise": "error";
|
|
@@ -55,6 +61,8 @@ declare const full: {
|
|
|
55
61
|
readonly "effect/noReturnNullish": "warn";
|
|
56
62
|
readonly "effect/noGlobals": "error";
|
|
57
63
|
readonly "effect/noInlineProvide": "error";
|
|
64
|
+
readonly "effect/noPromiseControlFlowInTests": "error";
|
|
65
|
+
readonly "effect/noSleepInTests": "error";
|
|
58
66
|
};
|
|
59
67
|
//#endregion
|
|
60
68
|
export { full };
|
package/dist/presets/full.js
CHANGED
|
@@ -14,6 +14,7 @@ const full = {
|
|
|
14
14
|
"effect/noOptionAs": "error",
|
|
15
15
|
"effect/noRunInEffectGen": "error",
|
|
16
16
|
"effect/noNodeBuiltinImport": "warn",
|
|
17
|
+
"effect/noSpread": "error",
|
|
17
18
|
"effect/noNestedPipe": "error",
|
|
18
19
|
"effect/noNestedEffectGen": "error",
|
|
19
20
|
"effect/noUnnecessaryEffectGen": "error",
|
|
@@ -42,19 +43,26 @@ const full = {
|
|
|
42
43
|
"effect/noUnnecessaryPipeChain": "error",
|
|
43
44
|
"effect/noMultipleEffectProvide": "error",
|
|
44
45
|
"effect/noSchemaUnionOfLiterals": "warn",
|
|
46
|
+
"effect/noSchemaStruct": "error",
|
|
45
47
|
"effect/noSchemaStructWithTag": "warn",
|
|
46
48
|
"effect/noRedundantSchemaTagIdentifier": "warn",
|
|
47
49
|
"effect/noEffectMapFlatten": "warn",
|
|
48
50
|
"effect/noGlobalErrorInFailure": "error",
|
|
49
51
|
"effect/noGlobalErrorInCatch": "error",
|
|
50
52
|
"effect/noPositionalLogError": "error",
|
|
53
|
+
"effect/noMakeUnsafe": "error",
|
|
54
|
+
"effect/noHandRolledTaggedUnion": "error",
|
|
55
|
+
"effect/noDynamicImports": "error",
|
|
56
|
+
"effect/noEffectAllStepSequencing": "error",
|
|
51
57
|
"effect/noThrowStatement": "error",
|
|
52
58
|
"effect/noTryCatch": "error",
|
|
53
59
|
"effect/noNewPromise": "error",
|
|
54
60
|
"effect/noNewError": "error",
|
|
55
61
|
"effect/noReturnNullish": "warn",
|
|
56
62
|
"effect/noGlobals": "error",
|
|
57
|
-
"effect/noInlineProvide": "error"
|
|
63
|
+
"effect/noInlineProvide": "error",
|
|
64
|
+
"effect/noPromiseControlFlowInTests": "error",
|
|
65
|
+
"effect/noSleepInTests": "error"
|
|
58
66
|
};
|
|
59
67
|
//#endregion
|
|
60
68
|
export { full };
|
|
@@ -16,6 +16,7 @@ declare const functional: {
|
|
|
16
16
|
readonly "effect/noMatchEffectBranch": "error";
|
|
17
17
|
readonly "effect/noOptionBooleanNormalization": "error";
|
|
18
18
|
readonly "effect/noArrowLadder": "error";
|
|
19
|
+
readonly "effect/noSpread": "error";
|
|
19
20
|
};
|
|
20
21
|
//#endregion
|
|
21
22
|
export { functional };
|
|
@@ -15,7 +15,8 @@ const functional = {
|
|
|
15
15
|
"effect/noMatchVoidBranch": "error",
|
|
16
16
|
"effect/noMatchEffectBranch": "error",
|
|
17
17
|
"effect/noOptionBooleanNormalization": "error",
|
|
18
|
-
"effect/noArrowLadder": "error"
|
|
18
|
+
"effect/noArrowLadder": "error",
|
|
19
|
+
"effect/noSpread": "error"
|
|
19
20
|
};
|
|
20
21
|
//#endregion
|
|
21
22
|
export { functional };
|
package/dist/presets/strict.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare const strict: {
|
|
|
17
17
|
readonly "effect/noReturnInArrow": "error";
|
|
18
18
|
readonly "effect/noStringSentinelConst": "error";
|
|
19
19
|
readonly "effect/noArrowLadder": "error";
|
|
20
|
+
readonly "effect/noSpread": "error";
|
|
20
21
|
readonly "effect/noNodeBuiltinImport": "error";
|
|
21
22
|
readonly "effect/noNestedPipe": "error";
|
|
22
23
|
readonly "effect/noNestedEffectGen": "error";
|
|
@@ -46,19 +47,27 @@ declare const strict: {
|
|
|
46
47
|
readonly "effect/noUnnecessaryPipeChain": "error";
|
|
47
48
|
readonly "effect/noMultipleEffectProvide": "error";
|
|
48
49
|
readonly "effect/noSchemaUnionOfLiterals": "error";
|
|
50
|
+
readonly "effect/noSchemaStruct": "error";
|
|
49
51
|
readonly "effect/noSchemaStructWithTag": "error";
|
|
50
52
|
readonly "effect/noRedundantSchemaTagIdentifier": "error";
|
|
51
53
|
readonly "effect/noEffectMapFlatten": "error";
|
|
52
54
|
readonly "effect/noGlobalErrorInFailure": "error";
|
|
53
55
|
readonly "effect/noGlobalErrorInCatch": "error";
|
|
54
56
|
readonly "effect/noPositionalLogError": "error";
|
|
57
|
+
readonly "effect/noMakeUnsafe": "error";
|
|
58
|
+
readonly "effect/noHandRolledTaggedUnion": "error";
|
|
59
|
+
readonly "effect/noDynamicImports": "error";
|
|
55
60
|
readonly "effect/noThrowStatement": "error";
|
|
56
61
|
readonly "effect/noTryCatch": "error";
|
|
62
|
+
readonly "effect/noEffectAllStepSequencing": "error";
|
|
63
|
+
readonly "effect/noManualDataGuard": "error";
|
|
57
64
|
readonly "effect/noNewPromise": "error";
|
|
58
65
|
readonly "effect/noNewError": "error";
|
|
59
66
|
readonly "effect/noReturnNullish": "error";
|
|
60
67
|
readonly "effect/noGlobals": "error";
|
|
61
68
|
readonly "effect/noInlineProvide": "error";
|
|
69
|
+
readonly "effect/noPromiseControlFlowInTests": "error";
|
|
70
|
+
readonly "effect/noSleepInTests": "error";
|
|
62
71
|
};
|
|
63
72
|
//#endregion
|
|
64
73
|
export { strict };
|
package/dist/presets/strict.js
CHANGED
|
@@ -17,6 +17,7 @@ const strict = {
|
|
|
17
17
|
"effect/noReturnInArrow": "error",
|
|
18
18
|
"effect/noStringSentinelConst": "error",
|
|
19
19
|
"effect/noArrowLadder": "error",
|
|
20
|
+
"effect/noSpread": "error",
|
|
20
21
|
"effect/noNodeBuiltinImport": "error",
|
|
21
22
|
"effect/noNestedPipe": "error",
|
|
22
23
|
"effect/noNestedEffectGen": "error",
|
|
@@ -46,19 +47,27 @@ const strict = {
|
|
|
46
47
|
"effect/noUnnecessaryPipeChain": "error",
|
|
47
48
|
"effect/noMultipleEffectProvide": "error",
|
|
48
49
|
"effect/noSchemaUnionOfLiterals": "error",
|
|
50
|
+
"effect/noSchemaStruct": "error",
|
|
49
51
|
"effect/noSchemaStructWithTag": "error",
|
|
50
52
|
"effect/noRedundantSchemaTagIdentifier": "error",
|
|
51
53
|
"effect/noEffectMapFlatten": "error",
|
|
52
54
|
"effect/noGlobalErrorInFailure": "error",
|
|
53
55
|
"effect/noGlobalErrorInCatch": "error",
|
|
54
56
|
"effect/noPositionalLogError": "error",
|
|
57
|
+
"effect/noMakeUnsafe": "error",
|
|
58
|
+
"effect/noHandRolledTaggedUnion": "error",
|
|
59
|
+
"effect/noDynamicImports": "error",
|
|
55
60
|
"effect/noThrowStatement": "error",
|
|
56
61
|
"effect/noTryCatch": "error",
|
|
62
|
+
"effect/noEffectAllStepSequencing": "error",
|
|
63
|
+
"effect/noManualDataGuard": "error",
|
|
57
64
|
"effect/noNewPromise": "error",
|
|
58
65
|
"effect/noNewError": "error",
|
|
59
66
|
"effect/noReturnNullish": "error",
|
|
60
67
|
"effect/noGlobals": "error",
|
|
61
|
-
"effect/noInlineProvide": "error"
|
|
68
|
+
"effect/noInlineProvide": "error",
|
|
69
|
+
"effect/noPromiseControlFlowInTests": "error",
|
|
70
|
+
"effect/noSleepInTests": "error"
|
|
62
71
|
};
|
|
63
72
|
//#endregion
|
|
64
73
|
export { strict };
|
package/dist/rules/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ import { noSwitchStatement } from "./no-switch-statement.js";
|
|
|
10
10
|
import { noArrowLadder } from "./no-arrow-ladder.js";
|
|
11
11
|
import { noAsyncFunction } from "./no-async-function.js";
|
|
12
12
|
import { noCatchAllToMapError } from "./no-catch-all-to-map-error.js";
|
|
13
|
+
import { noDynamicImports } from "./no-dynamic-imports.js";
|
|
14
|
+
import { noEffectAllStepSequencing } from "./no-effect-all-step-sequencing.js";
|
|
13
15
|
import { noEffectFnGenerator } from "./no-effect-fn-generator.js";
|
|
14
16
|
import { noEffectGenAdapter } from "./no-effect-gen-adapter.js";
|
|
15
17
|
import { noEffectMapFlatten } from "./no-effect-map-flatten.js";
|
|
@@ -27,8 +29,11 @@ import { noFlatmapLadder } from "./no-flatmap-ladder.js";
|
|
|
27
29
|
import { noFromNullableCoalesce } from "./no-fromnullable-coalesce.js";
|
|
28
30
|
import { noGlobalErrorInCatch } from "./no-global-error-in-catch.js";
|
|
29
31
|
import { noGlobalErrorInFailure } from "./no-global-error-in-failure.js";
|
|
32
|
+
import { noHandRolledTaggedUnion } from "./no-hand-rolled-tagged-union.js";
|
|
30
33
|
import { noIifeWrapper } from "./no-iife-wrapper.js";
|
|
31
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";
|
|
32
37
|
import { noManualEffectChannels } from "./no-manual-effect-channels.js";
|
|
33
38
|
import { noMatchEffectBranch } from "./no-match-effect-branch.js";
|
|
34
39
|
import { noMatchVoidBranch } from "./no-match-void-branch.js";
|
|
@@ -39,10 +44,14 @@ import { noNestedPipe } from "./no-nested-pipe.js";
|
|
|
39
44
|
import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
|
|
40
45
|
import { noOptionBooleanNormalization } from "./no-option-boolean-normalization.js";
|
|
41
46
|
import { noPositionalLogError } from "./no-positional-log-error.js";
|
|
47
|
+
import { noPromiseControlFlowInTests } from "./no-promise-control-flow-in-tests.js";
|
|
42
48
|
import { noRedundantSchemaTagIdentifier } from "./no-redundant-schema-tag-identifier.js";
|
|
43
49
|
import { noReturnInArrow } from "./no-return-in-arrow.js";
|
|
44
50
|
import { noSchemaStructWithTag } from "./no-schema-struct-with-tag.js";
|
|
51
|
+
import { noSchemaStruct } from "./no-schema-struct.js";
|
|
45
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";
|
|
46
55
|
import { noStringSentinelConst } from "./no-string-sentinel-const.js";
|
|
47
56
|
import { noTernary } from "./no-ternary.js";
|
|
48
57
|
import { noUnnecessaryArrowBlock } from "./no-unnecessary-arrow-block.js";
|
|
@@ -60,7 +69,7 @@ import { noTryCatch } from "./no-try-catch.js";
|
|
|
60
69
|
|
|
61
70
|
//#region src/rules/index.d.ts
|
|
62
71
|
declare namespace index_d_exports {
|
|
63
|
-
export { noArrowLadder, noAsyncFunction, noCatchAllToMapError, noEffectAs, noEffectAsync, noEffectBind, noEffectDo, noEffectFnGenerator, noEffectGenAdapter, noEffectMapFlatten, noEffectMapVoid, noEffectNever, noEffectOrElseLadder, noEffectSucceedString, noEffectSucceedVariable, noEffectSucceedVoid, noEffectSyncConsole, noEffectSyncWrapper, noEffectTypeAlias, noEffectWrapperAlias, noExtendsNativeError, noFlatmapLadder, noFromNullableCoalesce, noGlobalErrorInCatch, noGlobalErrorInFailure, noGlobals, noIfStatement, noIifeWrapper, noInlineProvide, noInstanceofSchema, noManualEffectChannels, noMatchEffectBranch, noMatchVoidBranch, noMultipleEffectProvide, noNestedEffectCall, noNestedEffectGen, noNestedPipe, noNewError, noNewPromise, noNodeBuiltinImport, noOptionAs, noOptionBooleanNormalization, noPositionalLogError, noRedundantSchemaTagIdentifier, noReturnInArrow, noReturnNullish, noRunInEffectGen, noRuntimeRunFork, noSchemaStructWithTag, noSchemaUnionOfLiterals, noStringSentinelConst, noSwitchStatement, noTernary, noThrowStatement, noTryCatch, noUnnecessaryArrowBlock, noUnnecessaryEffectGen, noUnnecessaryPipe, noUnnecessaryPipeChain };
|
|
72
|
+
export { noArrowLadder, noAsyncFunction, noCatchAllToMapError, noDynamicImports, noEffectAllStepSequencing, noEffectAs, noEffectAsync, noEffectBind, noEffectDo, noEffectFnGenerator, noEffectGenAdapter, noEffectMapFlatten, noEffectMapVoid, noEffectNever, noEffectOrElseLadder, noEffectSucceedString, noEffectSucceedVariable, noEffectSucceedVoid, noEffectSyncConsole, noEffectSyncWrapper, noEffectTypeAlias, noEffectWrapperAlias, noExtendsNativeError, noFlatmapLadder, noFromNullableCoalesce, noGlobalErrorInCatch, noGlobalErrorInFailure, noGlobals, noHandRolledTaggedUnion, noIfStatement, noIifeWrapper, noInlineProvide, noInstanceofSchema, noMakeUnsafe, noManualDataGuard, noManualEffectChannels, noMatchEffectBranch, noMatchVoidBranch, noMultipleEffectProvide, noNestedEffectCall, noNestedEffectGen, noNestedPipe, noNewError, noNewPromise, noNodeBuiltinImport, noOptionAs, noOptionBooleanNormalization, noPositionalLogError, noPromiseControlFlowInTests, noRedundantSchemaTagIdentifier, noReturnInArrow, noReturnNullish, noRunInEffectGen, noRuntimeRunFork, noSchemaStruct, noSchemaStructWithTag, noSchemaUnionOfLiterals, noSleepInTests, noSpread, noStringSentinelConst, noSwitchStatement, noTernary, noThrowStatement, noTryCatch, noUnnecessaryArrowBlock, noUnnecessaryEffectGen, noUnnecessaryPipe, noUnnecessaryPipeChain };
|
|
64
73
|
}
|
|
65
74
|
//#endregion
|
|
66
|
-
export { index_d_exports, noArrowLadder, noAsyncFunction, noCatchAllToMapError, noEffectAs, noEffectAsync, noEffectBind, noEffectDo, noEffectFnGenerator, noEffectGenAdapter, noEffectMapFlatten, noEffectMapVoid, noEffectNever, noEffectOrElseLadder, noEffectSucceedString, noEffectSucceedVariable, noEffectSucceedVoid, noEffectSyncConsole, noEffectSyncWrapper, noEffectTypeAlias, noEffectWrapperAlias, noExtendsNativeError, noFlatmapLadder, noFromNullableCoalesce, noGlobalErrorInCatch, noGlobalErrorInFailure, noGlobals, noIfStatement, noIifeWrapper, noInlineProvide, noInstanceofSchema, noManualEffectChannels, noMatchEffectBranch, noMatchVoidBranch, noMultipleEffectProvide, noNestedEffectCall, noNestedEffectGen, noNestedPipe, noNewError, noNewPromise, noNodeBuiltinImport, noOptionAs, noOptionBooleanNormalization, noPositionalLogError, noRedundantSchemaTagIdentifier, noReturnInArrow, noReturnNullish, noRunInEffectGen, noRuntimeRunFork, noSchemaStructWithTag, noSchemaUnionOfLiterals, noStringSentinelConst, noSwitchStatement, noTernary, noThrowStatement, noTryCatch, noUnnecessaryArrowBlock, noUnnecessaryEffectGen, noUnnecessaryPipe, noUnnecessaryPipeChain };
|
|
75
|
+
export { index_d_exports, noArrowLadder, noAsyncFunction, noCatchAllToMapError, noDynamicImports, noEffectAllStepSequencing, noEffectAs, noEffectAsync, noEffectBind, noEffectDo, noEffectFnGenerator, noEffectGenAdapter, noEffectMapFlatten, noEffectMapVoid, noEffectNever, noEffectOrElseLadder, noEffectSucceedString, noEffectSucceedVariable, noEffectSucceedVoid, noEffectSyncConsole, noEffectSyncWrapper, noEffectTypeAlias, noEffectWrapperAlias, noExtendsNativeError, noFlatmapLadder, noFromNullableCoalesce, noGlobalErrorInCatch, noGlobalErrorInFailure, noGlobals, noHandRolledTaggedUnion, noIfStatement, noIifeWrapper, noInlineProvide, noInstanceofSchema, noMakeUnsafe, noManualDataGuard, noManualEffectChannels, noMatchEffectBranch, noMatchVoidBranch, noMultipleEffectProvide, noNestedEffectCall, noNestedEffectGen, noNestedPipe, noNewError, noNewPromise, noNodeBuiltinImport, noOptionAs, noOptionBooleanNormalization, noPositionalLogError, noPromiseControlFlowInTests, noRedundantSchemaTagIdentifier, noReturnInArrow, noReturnNullish, noRunInEffectGen, noRuntimeRunFork, noSchemaStruct, noSchemaStructWithTag, noSchemaUnionOfLiterals, noSleepInTests, noSpread, noStringSentinelConst, noSwitchStatement, noTernary, noThrowStatement, noTryCatch, noUnnecessaryArrowBlock, noUnnecessaryEffectGen, noUnnecessaryPipe, noUnnecessaryPipeChain };
|
package/dist/rules/index.js
CHANGED
|
@@ -11,6 +11,8 @@ import { noSwitchStatement } from "./no-switch-statement.js";
|
|
|
11
11
|
import { noArrowLadder } from "./no-arrow-ladder.js";
|
|
12
12
|
import { noAsyncFunction } from "./no-async-function.js";
|
|
13
13
|
import { noCatchAllToMapError } from "./no-catch-all-to-map-error.js";
|
|
14
|
+
import { noDynamicImports } from "./no-dynamic-imports.js";
|
|
15
|
+
import { noEffectAllStepSequencing } from "./no-effect-all-step-sequencing.js";
|
|
14
16
|
import { noEffectFnGenerator } from "./no-effect-fn-generator.js";
|
|
15
17
|
import { noEffectGenAdapter } from "./no-effect-gen-adapter.js";
|
|
16
18
|
import { noEffectMapFlatten } from "./no-effect-map-flatten.js";
|
|
@@ -28,8 +30,11 @@ import { noFlatmapLadder } from "./no-flatmap-ladder.js";
|
|
|
28
30
|
import { noFromNullableCoalesce } from "./no-fromnullable-coalesce.js";
|
|
29
31
|
import { noGlobalErrorInCatch } from "./no-global-error-in-catch.js";
|
|
30
32
|
import { noGlobalErrorInFailure } from "./no-global-error-in-failure.js";
|
|
33
|
+
import { noHandRolledTaggedUnion } from "./no-hand-rolled-tagged-union.js";
|
|
31
34
|
import { noIifeWrapper } from "./no-iife-wrapper.js";
|
|
32
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";
|
|
33
38
|
import { noManualEffectChannels } from "./no-manual-effect-channels.js";
|
|
34
39
|
import { noMatchEffectBranch } from "./no-match-effect-branch.js";
|
|
35
40
|
import { noMatchVoidBranch } from "./no-match-void-branch.js";
|
|
@@ -40,10 +45,14 @@ import { noNestedPipe } from "./no-nested-pipe.js";
|
|
|
40
45
|
import { noNodeBuiltinImport } from "./no-node-builtin-import.js";
|
|
41
46
|
import { noOptionBooleanNormalization } from "./no-option-boolean-normalization.js";
|
|
42
47
|
import { noPositionalLogError } from "./no-positional-log-error.js";
|
|
48
|
+
import { noPromiseControlFlowInTests } from "./no-promise-control-flow-in-tests.js";
|
|
43
49
|
import { noRedundantSchemaTagIdentifier } from "./no-redundant-schema-tag-identifier.js";
|
|
44
50
|
import { noReturnInArrow } from "./no-return-in-arrow.js";
|
|
45
51
|
import { noSchemaStructWithTag } from "./no-schema-struct-with-tag.js";
|
|
52
|
+
import { noSchemaStruct } from "./no-schema-struct.js";
|
|
46
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";
|
|
47
56
|
import { noStringSentinelConst } from "./no-string-sentinel-const.js";
|
|
48
57
|
import { noTernary } from "./no-ternary.js";
|
|
49
58
|
import { noUnnecessaryArrowBlock } from "./no-unnecessary-arrow-block.js";
|
|
@@ -63,6 +72,8 @@ var rules_exports = /* @__PURE__ */ __exportAll({
|
|
|
63
72
|
noArrowLadder: () => noArrowLadder,
|
|
64
73
|
noAsyncFunction: () => noAsyncFunction,
|
|
65
74
|
noCatchAllToMapError: () => noCatchAllToMapError,
|
|
75
|
+
noDynamicImports: () => noDynamicImports,
|
|
76
|
+
noEffectAllStepSequencing: () => noEffectAllStepSequencing,
|
|
66
77
|
noEffectAs: () => noEffectAs,
|
|
67
78
|
noEffectAsync: () => noEffectAsync,
|
|
68
79
|
noEffectBind: () => noEffectBind,
|
|
@@ -86,10 +97,13 @@ var rules_exports = /* @__PURE__ */ __exportAll({
|
|
|
86
97
|
noGlobalErrorInCatch: () => noGlobalErrorInCatch,
|
|
87
98
|
noGlobalErrorInFailure: () => noGlobalErrorInFailure,
|
|
88
99
|
noGlobals: () => noGlobals,
|
|
100
|
+
noHandRolledTaggedUnion: () => noHandRolledTaggedUnion,
|
|
89
101
|
noIfStatement: () => noIfStatement,
|
|
90
102
|
noIifeWrapper: () => noIifeWrapper,
|
|
91
103
|
noInlineProvide: () => noInlineProvide,
|
|
92
104
|
noInstanceofSchema: () => noInstanceofSchema,
|
|
105
|
+
noMakeUnsafe: () => noMakeUnsafe,
|
|
106
|
+
noManualDataGuard: () => noManualDataGuard,
|
|
93
107
|
noManualEffectChannels: () => noManualEffectChannels,
|
|
94
108
|
noMatchEffectBranch: () => noMatchEffectBranch,
|
|
95
109
|
noMatchVoidBranch: () => noMatchVoidBranch,
|
|
@@ -103,13 +117,17 @@ var rules_exports = /* @__PURE__ */ __exportAll({
|
|
|
103
117
|
noOptionAs: () => noOptionAs,
|
|
104
118
|
noOptionBooleanNormalization: () => noOptionBooleanNormalization,
|
|
105
119
|
noPositionalLogError: () => noPositionalLogError,
|
|
120
|
+
noPromiseControlFlowInTests: () => noPromiseControlFlowInTests,
|
|
106
121
|
noRedundantSchemaTagIdentifier: () => noRedundantSchemaTagIdentifier,
|
|
107
122
|
noReturnInArrow: () => noReturnInArrow,
|
|
108
123
|
noReturnNullish: () => noReturnNullish,
|
|
109
124
|
noRunInEffectGen: () => noRunInEffectGen,
|
|
110
125
|
noRuntimeRunFork: () => noRuntimeRunFork,
|
|
126
|
+
noSchemaStruct: () => noSchemaStruct,
|
|
111
127
|
noSchemaStructWithTag: () => noSchemaStructWithTag,
|
|
112
128
|
noSchemaUnionOfLiterals: () => noSchemaUnionOfLiterals,
|
|
129
|
+
noSleepInTests: () => noSleepInTests,
|
|
130
|
+
noSpread: () => noSpread,
|
|
113
131
|
noStringSentinelConst: () => noStringSentinelConst,
|
|
114
132
|
noSwitchStatement: () => noSwitchStatement,
|
|
115
133
|
noTernary: () => noTernary,
|
|
@@ -121,4 +139,4 @@ var rules_exports = /* @__PURE__ */ __exportAll({
|
|
|
121
139
|
noUnnecessaryPipeChain: () => noUnnecessaryPipeChain
|
|
122
140
|
});
|
|
123
141
|
//#endregion
|
|
124
|
-
export { noArrowLadder, noAsyncFunction, noCatchAllToMapError, noEffectAs, noEffectAsync, noEffectBind, noEffectDo, noEffectFnGenerator, noEffectGenAdapter, noEffectMapFlatten, noEffectMapVoid, noEffectNever, noEffectOrElseLadder, noEffectSucceedString, noEffectSucceedVariable, noEffectSucceedVoid, noEffectSyncConsole, noEffectSyncWrapper, noEffectTypeAlias, noEffectWrapperAlias, noExtendsNativeError, noFlatmapLadder, noFromNullableCoalesce, noGlobalErrorInCatch, noGlobalErrorInFailure, noGlobals, noIfStatement, noIifeWrapper, noInlineProvide, noInstanceofSchema, noManualEffectChannels, noMatchEffectBranch, noMatchVoidBranch, noMultipleEffectProvide, noNestedEffectCall, noNestedEffectGen, noNestedPipe, noNewError, noNewPromise, noNodeBuiltinImport, noOptionAs, noOptionBooleanNormalization, noPositionalLogError, noRedundantSchemaTagIdentifier, noReturnInArrow, noReturnNullish, noRunInEffectGen, noRuntimeRunFork, noSchemaStructWithTag, noSchemaUnionOfLiterals, noStringSentinelConst, noSwitchStatement, noTernary, noThrowStatement, noTryCatch, noUnnecessaryArrowBlock, noUnnecessaryEffectGen, noUnnecessaryPipe, noUnnecessaryPipeChain, rules_exports };
|
|
142
|
+
export { noArrowLadder, noAsyncFunction, noCatchAllToMapError, noDynamicImports, noEffectAllStepSequencing, noEffectAs, noEffectAsync, noEffectBind, noEffectDo, noEffectFnGenerator, noEffectGenAdapter, noEffectMapFlatten, noEffectMapVoid, noEffectNever, noEffectOrElseLadder, noEffectSucceedString, noEffectSucceedVariable, noEffectSucceedVoid, noEffectSyncConsole, noEffectSyncWrapper, noEffectTypeAlias, noEffectWrapperAlias, noExtendsNativeError, noFlatmapLadder, noFromNullableCoalesce, noGlobalErrorInCatch, noGlobalErrorInFailure, noGlobals, noHandRolledTaggedUnion, noIfStatement, noIifeWrapper, noInlineProvide, noInstanceofSchema, noMakeUnsafe, noManualDataGuard, noManualEffectChannels, noMatchEffectBranch, noMatchVoidBranch, noMultipleEffectProvide, noNestedEffectCall, noNestedEffectGen, noNestedPipe, noNewError, noNewPromise, noNodeBuiltinImport, noOptionAs, noOptionBooleanNormalization, noPositionalLogError, noPromiseControlFlowInTests, noRedundantSchemaTagIdentifier, noReturnInArrow, noReturnNullish, noRunInEffectGen, noRuntimeRunFork, noSchemaStruct, noSchemaStructWithTag, noSchemaUnionOfLiterals, noSleepInTests, noSpread, noStringSentinelConst, noSwitchStatement, noTernary, noThrowStatement, noTryCatch, noUnnecessaryArrowBlock, noUnnecessaryEffectGen, noUnnecessaryPipe, noUnnecessaryPipeChain, rules_exports };
|
|
@@ -0,0 +1,90 @@
|
|
|
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 * as Effect from "effect/Effect";
|
|
6
|
+
//#region src/rules/no-dynamic-imports.ts
|
|
7
|
+
const allowPattern = /\beffect\/no-dynamic-imports:\s*allow\s+\S/;
|
|
8
|
+
const isAstNode = (value) => typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
9
|
+
const getNodeField = (node, field) => {
|
|
10
|
+
const value = node[field];
|
|
11
|
+
return isAstNode(value) ? value : void 0;
|
|
12
|
+
};
|
|
13
|
+
const getStringField = (node, field) => {
|
|
14
|
+
const value = node[field];
|
|
15
|
+
return typeof value === "string" ? value : void 0;
|
|
16
|
+
};
|
|
17
|
+
const getLine = (node, edge) => {
|
|
18
|
+
const loc = node["loc"];
|
|
19
|
+
if (typeof loc !== "object" || loc === null) return void 0;
|
|
20
|
+
const point = loc[edge];
|
|
21
|
+
if (typeof point !== "object" || point === null) return void 0;
|
|
22
|
+
const line = point["line"];
|
|
23
|
+
return typeof line === "number" ? line : void 0;
|
|
24
|
+
};
|
|
25
|
+
const hasAllowComment = (node, comments) => {
|
|
26
|
+
const startLine = getLine(node, "start");
|
|
27
|
+
if (startLine === void 0) return false;
|
|
28
|
+
return comments.some((comment) => {
|
|
29
|
+
const endLine = getLine(comment, "end");
|
|
30
|
+
if (endLine === void 0) return false;
|
|
31
|
+
if (endLine !== startLine - 1 && endLine !== startLine) return false;
|
|
32
|
+
return allowPattern.test(comment.value);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const createRequireAliasName = (node) => {
|
|
36
|
+
if (node.type !== "VariableDeclarator") return void 0;
|
|
37
|
+
const id = getNodeField(node, "id");
|
|
38
|
+
const init = getNodeField(node, "init");
|
|
39
|
+
if (id?.type !== "Identifier" || init?.type !== "CallExpression") return void 0;
|
|
40
|
+
const callee = getNodeField(init, "callee");
|
|
41
|
+
if (callee?.type !== "Identifier" || getStringField(callee, "name") !== "createRequire") return void 0;
|
|
42
|
+
return getStringField(id, "name");
|
|
43
|
+
};
|
|
44
|
+
const classifyDynamicLoadCall = (callee, createRequireAliases) => {
|
|
45
|
+
if (callee === void 0) return void 0;
|
|
46
|
+
if (callee.type === "Identifier") {
|
|
47
|
+
const name = getStringField(callee, "name");
|
|
48
|
+
if (name === "require") return "`require(...)` is forbidden. Use a top-level static import.";
|
|
49
|
+
if (name !== void 0 && createRequireAliases.has(name)) return "`createRequire(...)` aliases are forbidden. Use a top-level static import.";
|
|
50
|
+
}
|
|
51
|
+
if (callee.type === "MemberExpression") {
|
|
52
|
+
const object = getNodeField(callee, "object");
|
|
53
|
+
const property = getNodeField(callee, "property");
|
|
54
|
+
if (object?.type === "Identifier" && getStringField(object, "name") === "module" && property?.type === "Identifier" && getStringField(property, "name") === "require") return "`module.require(...)` is forbidden. Use a top-level static import.";
|
|
55
|
+
}
|
|
56
|
+
if (callee.type === "CallExpression") {
|
|
57
|
+
const inner = getNodeField(callee, "callee");
|
|
58
|
+
if (inner?.type === "Identifier" && getStringField(inner, "name") === "createRequire") return "`createRequire(...)(...)` is forbidden. Use a top-level static import.";
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const noDynamicImports = define({
|
|
62
|
+
name: "no-dynamic-imports",
|
|
63
|
+
meta: meta({
|
|
64
|
+
type: "problem",
|
|
65
|
+
description: "Avoid dynamic import/require. Use top-level static imports."
|
|
66
|
+
}),
|
|
67
|
+
create: function* () {
|
|
68
|
+
const ctx = yield* RuleContext;
|
|
69
|
+
const createRequireAliases = /* @__PURE__ */ new Set();
|
|
70
|
+
const reportUnlessAllowed = (node, message) => hasAllowComment(node, ctx.sourceCode.getAllComments()) ? Effect.void : ctx.report(make({
|
|
71
|
+
node,
|
|
72
|
+
message
|
|
73
|
+
}));
|
|
74
|
+
return {
|
|
75
|
+
VariableDeclarator: (node) => {
|
|
76
|
+
const alias = createRequireAliasName(node);
|
|
77
|
+
if (alias === void 0) return Effect.void;
|
|
78
|
+
createRequireAliases.add(alias);
|
|
79
|
+
return reportUnlessAllowed(node, "`createRequire(...)` is forbidden. Use a top-level static import.");
|
|
80
|
+
},
|
|
81
|
+
ImportExpression: (node) => reportUnlessAllowed(node, "Dynamic `import(...)` is forbidden. Use a top-level static import."),
|
|
82
|
+
CallExpression: (node) => {
|
|
83
|
+
const message = classifyDynamicLoadCall(getNodeField(node, "callee"), createRequireAliases);
|
|
84
|
+
return message === void 0 ? Effect.void : reportUnlessAllowed(node, message);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
//#endregion
|
|
90
|
+
export { noDynamicImports };
|