@onrails/biome-plugin 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -25,9 +25,9 @@ Reference the rule files in `biome.json` plugins:
|
|
|
25
25
|
|
|
26
26
|
| Rule | What it catches |
|
|
27
27
|
|------|------------------|
|
|
28
|
-
| `no-promise-result` | `Promise<Result<T, E>>` in any type position — return `ResultAsync<T, E>` and use `fromAsync` / `tryAsync` at the boundary |
|
|
29
|
-
| `no-unsafe-unwrap` | `._unsafeUnwrap()` / `._unsafeUnwrapErr()` calls — use `match` / `resolve` / `yieldResult` instead |
|
|
28
|
+
| `no-promise-result` | `Promise<Result<T, E>>` in any type position — return `ResultAsync<T, E>` and use `fromAsync` / `tryAsync` at the boundary (error) |
|
|
29
|
+
| `no-unsafe-unwrap` | `._unsafeUnwrap()` / `._unsafeUnwrapErr()` calls — use `match` / `resolve` / `yieldResult` instead (error) |
|
|
30
30
|
|
|
31
31
|
## Tests
|
|
32
32
|
|
|
33
|
-
Fixtures under `fixtures/{valid,invalid}
|
|
33
|
+
Fixtures under `test/fixtures/{valid,invalid}/` (isolated `biome.json` with `root: true`). Tests in `test/rules.spec.ts` shell out to `biome lint --reporter=json` from that directory and assert message substrings.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onrails/biome-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Biome GritQL plugin: boundary diagnostics for @onrails/result (Promise<Result<…>>, _unsafeUnwrap*).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
"@biomejs/biome": ">=2.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@biomejs/biome": "^2.4.
|
|
52
|
+
"@biomejs/biome": "^2.4.16"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @onrails/biome-plugin: no-deprecated-synonyms
|
|
2
|
+
//
|
|
3
|
+
// Flag deprecated railway/maybe synonyms. Use canonical versions instead:
|
|
4
|
+
// - chain() -> flatMap() / andThen()
|
|
5
|
+
// - getOrElse() -> unwrapOr()
|
|
6
|
+
// - of() -> ok() / some()
|
|
7
|
+
// - fold() / matchResult() / matchMaybe() -> match()
|
|
8
|
+
// - sequenceTupleAsync() -> ResultAsync.combineTuple()
|
|
9
|
+
// - collect() -> combine()
|
|
10
|
+
// - ResultAsync.isOk() / isErr() -> await and narrow with isOk() / isErr()
|
|
11
|
+
//
|
|
12
|
+
// Limitation: matching is name-based — GritQL cannot scope by import, so
|
|
13
|
+
// same-named calls from other libraries (RxJS `of`, fp-ts `fold`,
|
|
14
|
+
// neverthrow `.isOk()`) are flagged too. Suppress with an inline
|
|
15
|
+
// biome-ignore comment in mixed codebases.
|
|
16
|
+
|
|
17
|
+
engine biome(1.0)
|
|
18
|
+
language js
|
|
19
|
+
|
|
20
|
+
or {
|
|
21
|
+
`$_.chain($_)` as $call,
|
|
22
|
+
`$_?.chain($_)` as $call,
|
|
23
|
+
`$_.isOk()` as $call,
|
|
24
|
+
`$_?.isOk()` as $call,
|
|
25
|
+
`$_.isErr()` as $call,
|
|
26
|
+
`$_?.isErr()` as $call,
|
|
27
|
+
`fold($_)` as $call,
|
|
28
|
+
`matchResult($_)` as $call,
|
|
29
|
+
`matchMaybe($_)` as $call,
|
|
30
|
+
`getOrElse($_)` as $call,
|
|
31
|
+
`sequenceTupleAsync($_)` as $call,
|
|
32
|
+
`collect($_)` as $call,
|
|
33
|
+
`of($_)` as $call
|
|
34
|
+
} where {
|
|
35
|
+
register_diagnostic(
|
|
36
|
+
span = $call,
|
|
37
|
+
message = "Avoid deprecated onrails synonyms/methods. Use the canonical equivalents instead.",
|
|
38
|
+
severity = "error"
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -9,11 +9,14 @@ language js
|
|
|
9
9
|
|
|
10
10
|
or {
|
|
11
11
|
`$_._unsafeUnwrap()` as $call,
|
|
12
|
-
`$_._unsafeUnwrapErr()` as $call
|
|
12
|
+
`$_._unsafeUnwrapErr()` as $call,
|
|
13
|
+
`unwrapOk($_)` as $call,
|
|
14
|
+
`unwrapErr($_)` as $call,
|
|
15
|
+
`unwrap($_)` as $call
|
|
13
16
|
} where {
|
|
14
17
|
register_diagnostic(
|
|
15
18
|
span = $call,
|
|
16
|
-
message = "Avoid _unsafeUnwrap* — use match(), resolve(), or yieldResult() in tryGen.",
|
|
17
|
-
severity = "
|
|
19
|
+
message = "Avoid _unsafeUnwrap* and unwrap* outside tests — use match(), resolve(), or yieldResult() in tryGen.",
|
|
20
|
+
severity = "error"
|
|
18
21
|
)
|
|
19
22
|
}
|