@onrails/biome-plugin 0.1.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 ADDED
@@ -0,0 +1,33 @@
1
+ # @onrails/biome-plugin
2
+
3
+ Biome GritQL rules for `@onrails/result` boundaries — mirrors `@onrails/eslint-plugin` for projects that lint with Biome.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add -d @onrails/biome-plugin @biomejs/biome
9
+ ```
10
+
11
+ ## Use
12
+
13
+ Reference the rule files in `biome.json` plugins:
14
+
15
+ ```jsonc
16
+ {
17
+ "plugins": [
18
+ "./node_modules/@onrails/biome-plugin/rules/no-promise-result.grit",
19
+ "./node_modules/@onrails/biome-plugin/rules/no-unsafe-unwrap.grit"
20
+ ]
21
+ }
22
+ ```
23
+
24
+ ## Rules
25
+
26
+ | Rule | What it catches |
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 |
30
+
31
+ ## Tests
32
+
33
+ Fixtures under `fixtures/{valid,invalid}/`. Tests in `src/rules.spec.ts` shell out to `biome lint --reporter=json` and assert message substrings.
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@onrails/biome-plugin",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Biome GritQL plugin: boundary diagnostics for @onrails/result (Promise<Result<…>>, _unsafeUnwrap*).",
6
+ "license": "MIT",
7
+ "author": "Alan R. Soares",
8
+ "homepage": "https://github.com/alanrsoares/onrails/tree/main/packages/biome-plugin#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/alanrsoares/onrails.git",
12
+ "directory": "packages/biome-plugin"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/alanrsoares/onrails/issues"
16
+ },
17
+ "keywords": [
18
+ "biome",
19
+ "biome-plugin",
20
+ "gritql",
21
+ "result",
22
+ "onrails",
23
+ "boundary",
24
+ "lint"
25
+ ],
26
+ "engines": {
27
+ "node": ">=18",
28
+ "bun": ">=1.0"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "provenance": true
33
+ },
34
+ "files": [
35
+ "rules",
36
+ "README.md",
37
+ "LICENSE"
38
+ ],
39
+ "exports": {
40
+ "./rules/no-promise-result.grit": "./rules/no-promise-result.grit",
41
+ "./rules/no-unsafe-unwrap.grit": "./rules/no-unsafe-unwrap.grit"
42
+ },
43
+ "scripts": {
44
+ "typecheck": "echo 'noop (grit files only)'",
45
+ "test": "bun test",
46
+ "check": "bun test"
47
+ },
48
+ "peerDependencies": {
49
+ "@biomejs/biome": ">=2.0.0"
50
+ },
51
+ "devDependencies": {
52
+ "@biomejs/biome": "^2.4.15"
53
+ }
54
+ }
@@ -0,0 +1,16 @@
1
+ // @onrails/biome-plugin: no-promise-result
2
+ //
3
+ // Flag `Promise<Result<T, E>>` in type annotations and return types.
4
+ // Public APIs should expose `ResultAsync<T, E>` instead — the boundary
5
+ // helper (`fromAsync` / `tryAsync`) handles the lift.
6
+
7
+ engine biome(1.0)
8
+ language js
9
+
10
+ `Promise<Result<$ok, $err>>` as $t where {
11
+ register_diagnostic(
12
+ span = $t,
13
+ message = "Promise<Result<…>> in a type position — use ResultAsync<T, E> at the boundary (fromAsync / tryAsync).",
14
+ severity = "warn"
15
+ )
16
+ }
@@ -0,0 +1,19 @@
1
+ // @onrails/biome-plugin: no-unsafe-unwrap
2
+ //
3
+ // Flag `._unsafeUnwrap()` and `._unsafeUnwrapErr()` calls — they throw
4
+ // on the unhappy branch and bypass railway semantics. Prefer `match`,
5
+ // `resolve`, or `yieldResult` inside `tryGen`.
6
+
7
+ engine biome(1.0)
8
+ language js
9
+
10
+ or {
11
+ `$_._unsafeUnwrap()` as $call,
12
+ `$_._unsafeUnwrapErr()` as $call
13
+ } where {
14
+ register_diagnostic(
15
+ span = $call,
16
+ message = "Avoid _unsafeUnwrap* — use match(), resolve(), or yieldResult() in tryGen.",
17
+ severity = "warn"
18
+ )
19
+ }