@onrails/biome-plugin 0.1.1 → 0.1.3
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 +5 -1
- package/package.json +4 -2
- package/rules/fluent-stays-local.grit +27 -0
package/README.md
CHANGED
|
@@ -16,7 +16,9 @@ Reference the rule files in `biome.json` plugins:
|
|
|
16
16
|
{
|
|
17
17
|
"plugins": [
|
|
18
18
|
"./node_modules/@onrails/biome-plugin/rules/no-promise-result.grit",
|
|
19
|
-
"./node_modules/@onrails/biome-plugin/rules/no-unsafe-unwrap.grit"
|
|
19
|
+
"./node_modules/@onrails/biome-plugin/rules/no-unsafe-unwrap.grit",
|
|
20
|
+
"./node_modules/@onrails/biome-plugin/rules/no-deprecated-synonyms.grit",
|
|
21
|
+
"./node_modules/@onrails/biome-plugin/rules/fluent-stays-local.grit"
|
|
20
22
|
]
|
|
21
23
|
}
|
|
22
24
|
```
|
|
@@ -27,6 +29,8 @@ Reference the rule files in `biome.json` plugins:
|
|
|
27
29
|
|------|------------------|
|
|
28
30
|
| `no-promise-result` | `Promise<Result<T, E>>` in any type position — return `ResultAsync<T, E>` and use `fromAsync` / `tryAsync` at the boundary (error) |
|
|
29
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) |
|
|
33
|
+
| `fluent-stays-local` | Bare `FluentResult<…>` / `FluentMaybe<…>` type references — broader net than the ESLint rule, see `ENGINE_DIVERGENCES` (error) |
|
|
30
34
|
|
|
31
35
|
## Tests
|
|
32
36
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onrails/biome-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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,9 @@
|
|
|
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",
|
|
43
|
+
"./rules/fluent-stays-local.grit": "./rules/fluent-stays-local.grit"
|
|
42
44
|
},
|
|
43
45
|
"scripts": {
|
|
44
46
|
"typecheck": "echo 'noop (grit files only)'",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @onrails/biome-plugin: fluent-stays-local
|
|
2
|
+
//
|
|
3
|
+
// Flag `FluentResult<T, E>` / `FluentMaybe<T>` named as a type — the fluent
|
|
4
|
+
// wrapper (`@onrails/result/fluent`, `@onrails/maybe/fluent`) must open and
|
|
5
|
+
// close within a function body, never escape as a return type, an exported
|
|
6
|
+
// binding, or a stored field.
|
|
7
|
+
//
|
|
8
|
+
// Limitation: GritQL matches the bare type reference wherever it appears —
|
|
9
|
+
// a broader net than the ESLint rule, which only flags the four scoped
|
|
10
|
+
// positions (return type, exported binding, stored field, serialize-sink
|
|
11
|
+
// argument) and inspects call-argument shape for the sink check. This rule
|
|
12
|
+
// cannot express that argument heuristic at all; declared in
|
|
13
|
+
// ENGINE_DIVERGENCES (`fluent-stays-local` / `no-position-scoping`).
|
|
14
|
+
|
|
15
|
+
engine biome(1.0)
|
|
16
|
+
language js
|
|
17
|
+
|
|
18
|
+
or {
|
|
19
|
+
`FluentResult<$ok, $err>` as $t,
|
|
20
|
+
`FluentMaybe<$value>` as $t
|
|
21
|
+
} where {
|
|
22
|
+
register_diagnostic(
|
|
23
|
+
span = $t,
|
|
24
|
+
message = "FluentResult/FluentMaybe must stay local — it was flagged as a return type, an exported binding, a stored field, or an argument to a serialize/postMessage/cache call. Call toResult()/toMaybe()/toString() before it leaves the function.",
|
|
25
|
+
severity = "error"
|
|
26
|
+
)
|
|
27
|
+
}
|