oxlint-plugin-effect 0.2.3 → 0.4.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 +79 -29
- package/dist/presets/index.d.ts +3 -9
- package/dist/presets/index.js +3 -17
- package/dist/presets/recommended.d.ts +17 -0
- package/dist/presets/recommended.js +17 -0
- package/dist/rules/index.d.ts +4 -59
- package/dist/rules/index.js +4 -114
- 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-throw-statement.js +4 -16
- package/dist/rules/no-try-catch.js +5 -17
- package/package.json +2 -2
- package/dist/presets/core.d.ts +0 -49
- package/dist/presets/core.js +0 -49
- package/dist/presets/effect-native.d.ts +0 -28
- package/dist/presets/effect-native.js +0 -28
- package/dist/presets/full.d.ts +0 -67
- package/dist/presets/full.js +0 -67
- package/dist/presets/functional.d.ts +0 -22
- package/dist/presets/functional.js +0 -22
- package/dist/presets/strict.d.ts +0 -71
- package/dist/presets/strict.js +0 -71
- 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-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-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
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { banMember } from "../vendor/effect-oxlint/Rule.js";
|
|
2
|
-
import "../vendor/effect-oxlint/index.js";
|
|
3
|
-
//#region src/rules/no-runtime-run-fork.ts
|
|
4
|
-
/**
|
|
5
|
-
* Ban `Runtime.runFork`.
|
|
6
|
-
*
|
|
7
|
-
* Use `forkScoped`, `Stream`, or runtime-provided layers.
|
|
8
|
-
*
|
|
9
|
-
* Source: biome-effect-linting-rules/no-runtime-runfork
|
|
10
|
-
*/
|
|
11
|
-
const noRuntimeRunFork = banMember("Runtime", "runFork", {
|
|
12
|
-
message: "Avoid Runtime.runFork. Use forkScoped, Stream, or runtime-provided layers.",
|
|
13
|
-
meta: {
|
|
14
|
-
type: "problem",
|
|
15
|
-
effectVersion: "v3"
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
//#endregion
|
|
19
|
-
export { noRuntimeRunFork };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { matchCallOf } from "../vendor/effect-oxlint/AST.js";
|
|
2
|
-
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
3
|
-
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
4
|
-
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
5
|
-
import "../vendor/effect-oxlint/index.js";
|
|
6
|
-
import * as Option from "effect/Option";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
-
//#region src/rules/no-schema-struct-with-tag.ts
|
|
9
|
-
const isTagKey = (key) => {
|
|
10
|
-
if (key.type === "Identifier" && "name" in key && key.name === "_tag") return true;
|
|
11
|
-
if (key.type === "Literal" && "value" in key && key.value === "_tag") return true;
|
|
12
|
-
return false;
|
|
13
|
-
};
|
|
14
|
-
const noSchemaStructWithTag = define({
|
|
15
|
-
name: "no-schema-struct-with-tag",
|
|
16
|
-
meta: meta({
|
|
17
|
-
type: "suggestion",
|
|
18
|
-
description: "Use Schema.TaggedStruct(\"Tag\", { ... }) instead of Schema.Struct({ _tag: Schema.Literal(\"Tag\"), ... })."
|
|
19
|
-
}),
|
|
20
|
-
create: function* () {
|
|
21
|
-
const ctx = yield* RuleContext;
|
|
22
|
-
return { CallExpression: (node) => {
|
|
23
|
-
const call = node;
|
|
24
|
-
if (Option.isNone(matchCallOf(call, "Schema", "Struct"))) return Effect.void;
|
|
25
|
-
const args = call.arguments;
|
|
26
|
-
if (args.length !== 1) return Effect.void;
|
|
27
|
-
const arg = args[0];
|
|
28
|
-
if (arg === void 0) return Effect.void;
|
|
29
|
-
if (arg.type !== "ObjectExpression") return Effect.void;
|
|
30
|
-
const props = arg["properties"];
|
|
31
|
-
if (!Array.isArray(props)) return Effect.void;
|
|
32
|
-
for (const prop of props) {
|
|
33
|
-
const p = prop;
|
|
34
|
-
if (p.type !== "Property") continue;
|
|
35
|
-
const key = p["key"];
|
|
36
|
-
if (!isTagKey(key)) continue;
|
|
37
|
-
const value = p["value"];
|
|
38
|
-
if (value.type === "CallExpression" && Option.isSome(matchCallOf(value, "Schema", "Literal"))) return ctx.report(make({
|
|
39
|
-
node,
|
|
40
|
-
message: "Use Schema.TaggedStruct(\"Tag\", { ... }) instead of Schema.Struct({ _tag: Schema.Literal(...), ... })."
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
return Effect.void;
|
|
44
|
-
} };
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
//#endregion
|
|
48
|
-
export { noSchemaStructWithTag };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { matchCallOf } from "../vendor/effect-oxlint/AST.js";
|
|
2
|
-
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
3
|
-
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
4
|
-
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
5
|
-
import "../vendor/effect-oxlint/index.js";
|
|
6
|
-
import * as Option from "effect/Option";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
-
//#region src/rules/no-schema-struct.ts
|
|
9
|
-
const noSchemaStruct = define({
|
|
10
|
-
name: "no-schema-struct",
|
|
11
|
-
meta: meta({
|
|
12
|
-
type: "suggestion",
|
|
13
|
-
description: "Use Schema.Class instead of Schema.Struct."
|
|
14
|
-
}),
|
|
15
|
-
create: function* () {
|
|
16
|
-
const ctx = yield* RuleContext;
|
|
17
|
-
return { CallExpression: (node) => {
|
|
18
|
-
const call = node;
|
|
19
|
-
if (Option.isNone(matchCallOf(call, "Schema", "Struct"))) return Effect.void;
|
|
20
|
-
return ctx.report(make({
|
|
21
|
-
node,
|
|
22
|
-
message: "Use Schema.Class instead of Schema.Struct."
|
|
23
|
-
}));
|
|
24
|
-
} };
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
//#endregion
|
|
28
|
-
export { noSchemaStruct };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { matchCallOf } from "../vendor/effect-oxlint/AST.js";
|
|
2
|
-
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
3
|
-
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
4
|
-
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
5
|
-
import "../vendor/effect-oxlint/index.js";
|
|
6
|
-
import * as Option from "effect/Option";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
-
//#region src/rules/no-schema-union-of-literals.ts
|
|
9
|
-
const isSchemaLiteral = (node) => {
|
|
10
|
-
if (node.type !== "CallExpression") return false;
|
|
11
|
-
return Option.isSome(matchCallOf(node, "Schema", "Literal"));
|
|
12
|
-
};
|
|
13
|
-
const noSchemaUnionOfLiterals = define({
|
|
14
|
-
name: "no-schema-union-of-literals",
|
|
15
|
-
meta: meta({
|
|
16
|
-
type: "suggestion",
|
|
17
|
-
description: "Use Schema.Literal('a', 'b') instead of Schema.Union(Schema.Literal('a'), Schema.Literal('b'))."
|
|
18
|
-
}),
|
|
19
|
-
create: function* () {
|
|
20
|
-
const ctx = yield* RuleContext;
|
|
21
|
-
return { CallExpression: (node) => {
|
|
22
|
-
const call = node;
|
|
23
|
-
if (Option.isNone(matchCallOf(call, "Schema", "Union"))) return Effect.void;
|
|
24
|
-
const args = call.arguments;
|
|
25
|
-
if (args.length < 2) return Effect.void;
|
|
26
|
-
if (!args.every((arg) => isSchemaLiteral(arg))) return Effect.void;
|
|
27
|
-
return ctx.report(make({
|
|
28
|
-
node,
|
|
29
|
-
message: "Use Schema.Literal('a', 'b') instead of Schema.Union(Schema.Literal('a'), Schema.Literal('b'))."
|
|
30
|
-
}));
|
|
31
|
-
} };
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
//#endregion
|
|
35
|
-
export { noSchemaUnionOfLiterals };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { memberNames } from "../vendor/effect-oxlint/AST.js";
|
|
2
|
-
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
3
|
-
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
4
|
-
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
5
|
-
import "../vendor/effect-oxlint/index.js";
|
|
6
|
-
import * as Option from "effect/Option";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
-
//#region src/rules/no-sleep-in-tests.ts
|
|
9
|
-
const allowPattern = /\beffect\/no-sleep-in-tests:\s*allow\s+\S/;
|
|
10
|
-
const isTestFilename = (filename) => /\.test\.tsx?$/.test(filename) || /\/tests\/.*\.[cm]?tsx?$/.test(filename);
|
|
11
|
-
const getLine = (node, edge) => {
|
|
12
|
-
const loc = node["loc"];
|
|
13
|
-
if (typeof loc !== "object" || loc === null) return void 0;
|
|
14
|
-
const point = loc[edge];
|
|
15
|
-
if (typeof point !== "object" || point === null) return void 0;
|
|
16
|
-
const line = point["line"];
|
|
17
|
-
return typeof line === "number" ? line : void 0;
|
|
18
|
-
};
|
|
19
|
-
const hasAllowComment = (node, comments) => {
|
|
20
|
-
const startLine = getLine(node, "start");
|
|
21
|
-
if (startLine === void 0) return false;
|
|
22
|
-
return comments.some((comment) => {
|
|
23
|
-
const endLine = getLine(comment, "end");
|
|
24
|
-
if (endLine === void 0) return false;
|
|
25
|
-
if (endLine !== startLine - 1 && endLine !== startLine) return false;
|
|
26
|
-
return allowPattern.test(comment.value);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const noSleepInTests = define({
|
|
30
|
-
name: "no-sleep-in-tests",
|
|
31
|
-
meta: meta({
|
|
32
|
-
type: "problem",
|
|
33
|
-
description: "Avoid fixed sleeps in tests. Use deterministic synchronization."
|
|
34
|
-
}),
|
|
35
|
-
create: function* () {
|
|
36
|
-
const ctx = yield* RuleContext;
|
|
37
|
-
if (!isTestFilename(ctx.filename)) return {};
|
|
38
|
-
return { CallExpression: (node) => {
|
|
39
|
-
const call = node;
|
|
40
|
-
if (call.callee.type !== "MemberExpression") return Effect.void;
|
|
41
|
-
const names = Option.getOrUndefined(memberNames(call.callee));
|
|
42
|
-
if (names === void 0) return Effect.void;
|
|
43
|
-
const [object, property] = names;
|
|
44
|
-
if (property !== "sleep") return Effect.void;
|
|
45
|
-
if (object !== "Effect" && object !== "Bun") return Effect.void;
|
|
46
|
-
if (hasAllowComment(node, ctx.sourceCode.getAllComments())) return Effect.void;
|
|
47
|
-
return ctx.report(make({
|
|
48
|
-
node,
|
|
49
|
-
message: `Avoid ${object}.sleep(...) in tests. Wait on Deferred, polling helpers, or test controls instead of fixed delays.`
|
|
50
|
-
}));
|
|
51
|
-
} };
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
//#endregion
|
|
55
|
-
export { noSleepInTests };
|
package/dist/rules/no-spread.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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-spread.ts
|
|
6
|
-
const message = "Avoid spread syntax. Use explicit construction or a named transformation instead.";
|
|
7
|
-
const noSpread = define({
|
|
8
|
-
name: "no-spread",
|
|
9
|
-
meta: meta({
|
|
10
|
-
type: "suggestion",
|
|
11
|
-
description: message
|
|
12
|
-
}),
|
|
13
|
-
create: function* () {
|
|
14
|
-
const ctx = yield* RuleContext;
|
|
15
|
-
const reportSpread = (node) => ctx.report(make({
|
|
16
|
-
node,
|
|
17
|
-
message
|
|
18
|
-
}));
|
|
19
|
-
return {
|
|
20
|
-
SpreadElement: reportSpread,
|
|
21
|
-
JSXSpreadAttribute: reportSpread
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
//#endregion
|
|
26
|
-
export { noSpread };
|
|
@@ -1,38 +0,0 @@
|
|
|
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-string-sentinel-const.ts
|
|
7
|
-
/**
|
|
8
|
-
* Ban `const x = "some-string"` string literal const declarations.
|
|
9
|
-
*
|
|
10
|
-
* Use tagged unions, Option, or meaningful domain values.
|
|
11
|
-
*
|
|
12
|
-
* Source: biome-effect-linting-rules/no-string-sentinel-const
|
|
13
|
-
*
|
|
14
|
-
* Note: Very aggressive — should probably be off by default or in a strict preset only.
|
|
15
|
-
*/
|
|
16
|
-
const noStringSentinelConst = define({
|
|
17
|
-
name: "no-string-sentinel-const",
|
|
18
|
-
meta: meta({
|
|
19
|
-
type: "suggestion",
|
|
20
|
-
description: "Avoid string literal const declarations. Use tagged unions or domain values."
|
|
21
|
-
}),
|
|
22
|
-
create: function* () {
|
|
23
|
-
const ctx = yield* RuleContext;
|
|
24
|
-
return { VariableDeclarator: (node) => {
|
|
25
|
-
if (!("init" in node) || node.init == null) return Effect.void;
|
|
26
|
-
const init = node.init;
|
|
27
|
-
if (init["type"] === "Literal" && typeof init["value"] === "string") {
|
|
28
|
-
if ("parent" in node && node.parent != null && typeof node.parent === "object" && "type" in node.parent && node.parent.type === "VariableDeclaration" && "kind" in node.parent && node.parent.kind === "const") return ctx.report(make({
|
|
29
|
-
node,
|
|
30
|
-
message: "Avoid string literal const. Use tagged unions, Option, or domain values."
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
return Effect.void;
|
|
34
|
-
} };
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
//#endregion
|
|
38
|
-
export { noStringSentinelConst };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { banStatement } from "../vendor/effect-oxlint/Rule.js";
|
|
2
|
-
import "../vendor/effect-oxlint/index.js";
|
|
3
|
-
//#region src/rules/no-switch-statement.ts
|
|
4
|
-
/**
|
|
5
|
-
* Ban `switch` statements.
|
|
6
|
-
*
|
|
7
|
-
* Use `Match.value`, `Option.match`, `Either.match` instead.
|
|
8
|
-
*
|
|
9
|
-
* Source: biome-effect-linting-rules/no-switch-statement
|
|
10
|
-
*/
|
|
11
|
-
const noSwitchStatement = banStatement("SwitchStatement", {
|
|
12
|
-
message: "Avoid switch statements. Use Match.value, Option.match, or Either.match.",
|
|
13
|
-
meta: { type: "suggestion" }
|
|
14
|
-
});
|
|
15
|
-
//#endregion
|
|
16
|
-
export { noSwitchStatement };
|
|
@@ -1,34 +0,0 @@
|
|
|
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-unnecessary-arrow-block.ts
|
|
7
|
-
/**
|
|
8
|
-
* Ban `() => { return x }` — use `() => x` instead.
|
|
9
|
-
*
|
|
10
|
-
* Source: language-service/unnecessaryArrowBlock
|
|
11
|
-
*/
|
|
12
|
-
const noUnnecessaryArrowBlock = define({
|
|
13
|
-
name: "no-unnecessary-arrow-block",
|
|
14
|
-
meta: meta({
|
|
15
|
-
type: "suggestion",
|
|
16
|
-
description: "Unnecessary arrow block body. Use concise arrow `() => expr`.",
|
|
17
|
-
fixable: "code"
|
|
18
|
-
}),
|
|
19
|
-
create: function* () {
|
|
20
|
-
const ctx = yield* RuleContext;
|
|
21
|
-
return { ArrowFunctionExpression: (node) => {
|
|
22
|
-
if ("body" in node && node.body != null && typeof node.body === "object" && "type" in node.body && node.body.type === "BlockStatement" && "body" in node.body && Array.isArray(node.body.body) && node.body.body.length === 1) {
|
|
23
|
-
const stmt = node.body.body[0];
|
|
24
|
-
if (stmt != null && typeof stmt === "object" && "type" in stmt && stmt.type === "ReturnStatement" && "argument" in stmt && stmt.argument != null) return ctx.report(make({
|
|
25
|
-
node,
|
|
26
|
-
message: "Unnecessary arrow block body. Use `() => expr` instead of `() => { return expr }`."
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
return Effect.void;
|
|
30
|
-
} };
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
//#endregion
|
|
34
|
-
export { noUnnecessaryArrowBlock };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { isCallOf } from "../vendor/effect-oxlint/AST.js";
|
|
2
|
-
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
3
|
-
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
4
|
-
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
5
|
-
import "../vendor/effect-oxlint/index.js";
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
|
-
//#region src/rules/no-unnecessary-effect-gen.ts
|
|
8
|
-
const noUnnecessaryEffectGen = define({
|
|
9
|
-
name: "no-unnecessary-effect-gen",
|
|
10
|
-
meta: meta({
|
|
11
|
-
type: "suggestion",
|
|
12
|
-
description: "Unnecessary Effect.gen — single yield can be replaced with the yielded effect directly.",
|
|
13
|
-
fixable: "code"
|
|
14
|
-
}),
|
|
15
|
-
create: function* () {
|
|
16
|
-
const ctx = yield* RuleContext;
|
|
17
|
-
return { CallExpression: (node) => {
|
|
18
|
-
if (!isCallOf(node, "Effect", "gen")) return Effect.void;
|
|
19
|
-
if (!("arguments" in node) || !Array.isArray(node.arguments) || node.arguments.length !== 1) return Effect.void;
|
|
20
|
-
const arg = node.arguments[0];
|
|
21
|
-
if (arg == null || typeof arg !== "object" || !("type" in arg)) return Effect.void;
|
|
22
|
-
if (arg.type !== "FunctionExpression" || !("generator" in arg) || !arg.generator) return Effect.void;
|
|
23
|
-
if (!("body" in arg) || arg.body == null || typeof arg.body !== "object" || !("type" in arg.body) || arg.body.type !== "BlockStatement" || !("body" in arg.body) || !Array.isArray(arg.body.body) || arg.body.body.length !== 1) return Effect.void;
|
|
24
|
-
const stmt = arg.body.body[0];
|
|
25
|
-
if (stmt == null || typeof stmt !== "object" || !("type" in stmt)) return Effect.void;
|
|
26
|
-
if (stmt.type === "ReturnStatement" && "argument" in stmt && stmt.argument != null && typeof stmt.argument === "object" && "type" in stmt.argument && stmt.argument.type === "YieldExpression" && "delegate" in stmt.argument && stmt.argument.delegate === true) return ctx.report(make({
|
|
27
|
-
node,
|
|
28
|
-
message: "Unnecessary Effect.gen — single yield*. Replace with the yielded effect directly."
|
|
29
|
-
}));
|
|
30
|
-
return Effect.void;
|
|
31
|
-
} };
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
//#endregion
|
|
35
|
-
export { noUnnecessaryEffectGen };
|
|
@@ -1,36 +0,0 @@
|
|
|
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-unnecessary-pipe-chain.ts
|
|
7
|
-
const isMethodPipe = (node) => {
|
|
8
|
-
if (node.type !== "CallExpression") return false;
|
|
9
|
-
const callee = node["callee"];
|
|
10
|
-
if (callee == null || typeof callee !== "object" || !("type" in callee)) return false;
|
|
11
|
-
if (callee.type !== "MemberExpression") return false;
|
|
12
|
-
const prop = callee["property"];
|
|
13
|
-
if (prop == null || typeof prop !== "object" || !("type" in prop)) return false;
|
|
14
|
-
return prop.type === "Identifier" && "name" in prop && prop.name === "pipe";
|
|
15
|
-
};
|
|
16
|
-
const noUnnecessaryPipeChain = define({
|
|
17
|
-
name: "no-unnecessary-pipe-chain",
|
|
18
|
-
meta: meta({
|
|
19
|
-
type: "suggestion",
|
|
20
|
-
description: "Avoid chaining .pipe().pipe(). Merge into a single .pipe() call."
|
|
21
|
-
}),
|
|
22
|
-
create: function* () {
|
|
23
|
-
const ctx = yield* RuleContext;
|
|
24
|
-
return { CallExpression: (node) => {
|
|
25
|
-
if (!isMethodPipe(node)) return Effect.void;
|
|
26
|
-
const obj = node["callee"]["object"];
|
|
27
|
-
if (obj != null && typeof obj === "object" && isMethodPipe(obj)) return ctx.report(make({
|
|
28
|
-
node,
|
|
29
|
-
message: "Unnecessary .pipe() chain. Merge into a single .pipe() call."
|
|
30
|
-
}));
|
|
31
|
-
return Effect.void;
|
|
32
|
-
} };
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
//#endregion
|
|
36
|
-
export { noUnnecessaryPipeChain };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { calleeName } from "../vendor/effect-oxlint/AST.js";
|
|
2
|
-
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
3
|
-
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
4
|
-
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
5
|
-
import "../vendor/effect-oxlint/index.js";
|
|
6
|
-
import * as Option from "effect/Option";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
-
//#region src/rules/no-unnecessary-pipe.ts
|
|
9
|
-
const noUnnecessaryPipe = define({
|
|
10
|
-
name: "no-unnecessary-pipe",
|
|
11
|
-
meta: meta({
|
|
12
|
-
type: "suggestion",
|
|
13
|
-
description: "Unnecessary pipe() with single argument. Use the value directly.",
|
|
14
|
-
fixable: "code"
|
|
15
|
-
}),
|
|
16
|
-
create: function* () {
|
|
17
|
-
const ctx = yield* RuleContext;
|
|
18
|
-
return { CallExpression: (node) => {
|
|
19
|
-
if (Option.getOrUndefined(calleeName(node)) !== "pipe") return Effect.void;
|
|
20
|
-
if ("arguments" in node && Array.isArray(node.arguments) && node.arguments.length === 1) return ctx.report(make({
|
|
21
|
-
node,
|
|
22
|
-
message: "Unnecessary pipe() with single argument. Use the value directly."
|
|
23
|
-
}));
|
|
24
|
-
return Effect.void;
|
|
25
|
-
} };
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
//#endregion
|
|
29
|
-
export { noUnnecessaryPipe };
|