oxlint-plugin-effect 0.12.1 → 0.13.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 +1 -1
- package/dist/rules/no-as.js +12 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ If the project uses JSON configuration, copy the exported rule map into `rules`;
|
|
|
27
27
|
|
|
28
28
|
| Rule | Contract |
|
|
29
29
|
| -------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
30
|
-
| `effect/noAs` | Bans TypeScript `as` assertions; use `satisfies`
|
|
30
|
+
| `effect/noAs` | Bans TypeScript `as` assertions; use `satisfies` (`as const` is allowed) |
|
|
31
31
|
| `effect/noAsyncFunction` | Bans async functions and await expressions |
|
|
32
32
|
| `effect/noTryCatch` | Bans every try/catch/finally statement |
|
|
33
33
|
| `effect/noTestLifecycleHooks` | Bans `beforeEach`, `afterEach`, `beforeAll`, and `afterAll`; use Effect scopes instead |
|
package/dist/rules/no-as.js
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
+
import { narrow } from "../vendor/effect-oxlint/AST.js";
|
|
1
2
|
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
2
3
|
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
3
4
|
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
4
5
|
import "../vendor/effect-oxlint/index.js";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
5
8
|
//#region src/rules/no-as.ts
|
|
6
|
-
|
|
9
|
+
const isConstAssertion = (node) => Option.exists(narrow(node, "TSAsExpression"), ({ typeAnnotation }) => typeAnnotation.type === "TSTypeReference" && typeAnnotation.typeName.type === "Identifier" && typeAnnotation.typeName.name === "const");
|
|
7
10
|
const noAs = define({
|
|
8
11
|
name: "no-as",
|
|
9
12
|
meta: meta({
|
|
10
13
|
type: "problem",
|
|
11
|
-
description: "Use satisfies instead of an as assertion."
|
|
14
|
+
description: "Use satisfies instead of an as assertion; `as const` is allowed."
|
|
12
15
|
}),
|
|
13
16
|
create: function* () {
|
|
14
17
|
const ctx = yield* RuleContext;
|
|
15
|
-
return { TSAsExpression: (node) =>
|
|
16
|
-
node
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
return { TSAsExpression: (node) => {
|
|
19
|
+
if (isConstAssertion(node)) return Effect.void;
|
|
20
|
+
return ctx.report(make({
|
|
21
|
+
node,
|
|
22
|
+
message: "Avoid as assertions. Use satisfies instead."
|
|
23
|
+
}));
|
|
24
|
+
} };
|
|
19
25
|
}
|
|
20
26
|
});
|
|
21
27
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-plugin-effect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "oxlint plugin with Effect-specific lint rules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@oxlint/plugins": "^1.64.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@changesets/changelog-github": "^0.
|
|
65
|
-
"@changesets/cli": "^
|
|
64
|
+
"@changesets/changelog-github": "^1.0.1",
|
|
65
|
+
"@changesets/cli": "^3.0.3",
|
|
66
66
|
"@effect/language-service": "latest",
|
|
67
67
|
"@effect/vitest": "latest",
|
|
68
68
|
"@types/bun": "latest",
|