@onrails/biome-plugin 0.1.3 → 0.1.4

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
@@ -29,9 +29,19 @@ Reference the rule files in `biome.json` plugins:
29
29
  |------|------------------|
30
30
  | `no-promise-result` | `Promise<Result<T, E>>` in any type position — return `ResultAsync<T, E>` and use `fromAsync` / `tryAsync` at the boundary (error) |
31
31
  | `no-unsafe-unwrap` | `._unsafeUnwrap()` / `._unsafeUnwrapErr()` calls — use `match` / `resolve` / `yieldResult` instead (error) |
32
- | `no-deprecated-synonyms` | Deprecated synonyms (`chain`, `fold`, `getOrElse`, `of`, …) — use the canonical names (error) |
32
+ | `no-deprecated-synonyms` | Deprecated synonyms (`chain`, `fold`, `getOrElse`, `of`, …) — use the canonical names (error, partly fixable) |
33
33
  | `fluent-stays-local` | Bare `FluentResult<…>` / `FluentMaybe<…>` type references — broader net than the ESLint rule, see `ENGINE_DIVERGENCES` (error) |
34
34
 
35
+ ## Fixes
36
+
37
+ `no-deprecated-synonyms` rewrites. `.chain()` → `.flatMap()` is a **safe** fix, applied by `biome check --write`. The free-function renames (`matchResult`/`matchMaybe` → `match`, `getOrElse` → `unwrapOr`, `collect` → `combine`, `sequenceTupleAsync` → `ResultAsync.combineTuple`) are **unsafe** — the canonical name still has to be imported, which GritQL cannot do — so they need `biome check --write --unsafe` plus an import fix, or `@onrails/codemod`, which rewrites the imports too. `fold`, `of`, and `ResultAsync.isOk()` / `.isErr()` have no mechanical rewrite and stay diagnostic-only.
38
+
39
+ ## Scoping
40
+
41
+ `no-deprecated-synonyms` only fires in files that mention an `@onrails/*` module source, so RxJS `of` or fp-ts `fold` in unrelated files are left alone. Files that reach onrails through a local alias or re-export are not matched — use the ESLint plugin, which matches by name everywhere. Declared as `no-deprecated-synonyms` / `import-scoped` in `ENGINE_DIVERGENCES`.
42
+
43
+ Requires Biome >= 2.5.12 for plugin rewrites and `fix_kind`.
44
+
35
45
  ## Tests
36
46
 
37
47
  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",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "Biome GritQL plugin: boundary diagnostics for @onrails/result (Promise<Result<…>>, _unsafeUnwrap*).",
6
6
  "license": "MIT",
@@ -48,9 +48,9 @@
48
48
  "check": "bun test"
49
49
  },
50
50
  "peerDependencies": {
51
- "@biomejs/biome": ">=2.0.0"
51
+ "@biomejs/biome": ">=2.5.12"
52
52
  },
53
53
  "devDependencies": {
54
- "@biomejs/biome": "^2.4.16"
54
+ "@biomejs/biome": "^2.5.12"
55
55
  }
56
56
  }
@@ -9,32 +9,45 @@
9
9
  // - collect() -> combine()
10
10
  // - ResultAsync.isOk() / isErr() -> await and narrow with isOk() / isErr()
11
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.
12
+ // Scoping: only files that mention an `@onrails/*` module source are matched,
13
+ // so same-named calls from other libraries (RxJS `of`, fp-ts `fold`) are left
14
+ // alone. The ESLint rule is name-based everywhere; declared in
15
+ // ENGINE_DIVERGENCES (`no-deprecated-synonyms` / `import-scoped`).
16
+ //
17
+ // Fixes: `.chain()` -> `.flatMap()` is a safe rewrite (method rename, no
18
+ // import churn). The free-function renames are unsafe fixes — they need the
19
+ // canonical name imported, which GritQL cannot add; run `--write --unsafe`
20
+ // and fix the import, or use `@onrails/codemod`, which rewrites both.
16
21
 
17
22
  engine biome(1.0)
18
- language js
23
+ language js(typescript)
19
24
 
20
25
  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 {
26
+ `$x.chain($args)` => `$x.flatMap($args)`,
27
+ `$x?.chain($args)` => `$x?.flatMap($args)`,
28
+ `matchResult($args)` => `match($args)`,
29
+ `matchMaybe($args)` => `match($args)`,
30
+ `getOrElse($args)` => `unwrapOr($args)`,
31
+ `collect($args)` => `combine($args)`,
32
+ `sequenceTupleAsync($args)` => `ResultAsync.combineTuple($args)`,
33
+ `fold($args)`,
34
+ `of($args)`,
35
+ `$x.isOk()`,
36
+ `$x?.isOk()`,
37
+ `$x.isErr()`,
38
+ `$x?.isErr()`
39
+ } as $call where {
40
+ $call <: within JsModule(items = $items),
41
+ $items <: contains JsModuleSource() as $source,
42
+ $source <: r".*@onrails/.*",
43
+ or {
44
+ { $call <: or { `$_.chain($_)`, `$_?.chain($_)` }, $kind = "safe" },
45
+ { $kind = "unsafe" }
46
+ },
35
47
  register_diagnostic(
36
48
  span = $call,
37
49
  message = "Avoid deprecated onrails synonyms/methods. Use the canonical equivalents instead.",
38
- severity = "error"
50
+ severity = "error",
51
+ fix_kind = $kind
39
52
  )
40
53
  }