@onrails/biome-plugin 0.1.0 → 0.1.2

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}/`. Tests in `src/rules.spec.ts` shell out to `biome lint --reporter=json` and assert message substrings.
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.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Biome GritQL plugin: boundary diagnostics for @onrails/result (Promise<Result<…>>, _unsafeUnwrap*).",
6
6
  "license": "MIT",
@@ -38,7 +38,8 @@
38
38
  ],
39
39
  "exports": {
40
40
  "./rules/no-promise-result.grit": "./rules/no-promise-result.grit",
41
- "./rules/no-unsafe-unwrap.grit": "./rules/no-unsafe-unwrap.grit"
41
+ "./rules/no-unsafe-unwrap.grit": "./rules/no-unsafe-unwrap.grit",
42
+ "./rules/no-deprecated-synonyms.grit": "./rules/no-deprecated-synonyms.grit"
42
43
  },
43
44
  "scripts": {
44
45
  "typecheck": "echo 'noop (grit files only)'",
@@ -49,6 +50,6 @@
49
50
  "@biomejs/biome": ">=2.0.0"
50
51
  },
51
52
  "devDependencies": {
52
- "@biomejs/biome": "^2.4.15"
53
+ "@biomejs/biome": "^2.4.16"
53
54
  }
54
55
  }
@@ -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
+ }
@@ -11,6 +11,6 @@ language js
11
11
  register_diagnostic(
12
12
  span = $t,
13
13
  message = "Promise<Result<…>> in a type position — use ResultAsync<T, E> at the boundary (fromAsync / tryAsync).",
14
- severity = "warn"
14
+ severity = "error"
15
15
  )
16
16
  }
@@ -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 = "warn"
19
+ message = "Avoid _unsafeUnwrap* and unwrap* outside tests — use match(), resolve(), or yieldResult() in tryGen.",
20
+ severity = "error"
18
21
  )
19
22
  }