@re-reduced/biome-plugin 0.2.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 +26 -0
- package/package.json +30 -0
- package/rules/no-unstable-selector.grit +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @re-reduced/biome-plugin
|
|
2
|
+
|
|
3
|
+
Biome [GritQL](https://biomejs.dev/linter/plugins/) lint rules for the
|
|
4
|
+
`re-reduced` container API — catching **type-valid but semantically-wrong**
|
|
5
|
+
usage that TypeScript can't see.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
- **no-unstable-selector** — a `useSelect` selector that returns a fresh object
|
|
10
|
+
or array literal (`(s) => ({ … })` / `(s) => [ … ]`). It type-checks, but
|
|
11
|
+
produces a new reference every call, defeating the snapshot bail-out so the
|
|
12
|
+
component re-renders on **every** store update. Return a primitive or stable
|
|
13
|
+
reference, or split into multiple `useSelect` calls.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```jsonc
|
|
18
|
+
// biome.json
|
|
19
|
+
{
|
|
20
|
+
"plugins": [
|
|
21
|
+
"./node_modules/@re-reduced/biome-plugin/rules/no-unstable-selector.grit"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Requires `@biomejs/biome >= 2.0`.
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@re-reduced/biome-plugin",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Biome GritQL plugin: lint rules for the re-reduced container API.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/alanrsoares/re-reduced.git",
|
|
9
|
+
"directory": "packages/biome-plugin"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"rules"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
"./rules/no-unstable-selector.grit": "./rules/no-unstable-selector.grit"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "bun test"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@biomejs/biome": ">=2.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@biomejs/biome": "^2.5.0"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @re-reduced/biome-plugin: no-unstable-selector
|
|
2
|
+
//
|
|
3
|
+
// TypeScript can't catch this: a `useSelect` selector that returns a fresh
|
|
4
|
+
// object or array literal type-checks fine, but produces a new reference on
|
|
5
|
+
// every call — defeating the snapshot bail-out, so the component re-renders on
|
|
6
|
+
// EVERY store update. Return a primitive or a stable reference, or split into
|
|
7
|
+
// multiple `useSelect` calls.
|
|
8
|
+
|
|
9
|
+
engine biome(1.0)
|
|
10
|
+
language js
|
|
11
|
+
|
|
12
|
+
or {
|
|
13
|
+
`useSelect($store, ($args) => ({ $props }))` as $sel,
|
|
14
|
+
`useSelect($store, ($args) => [$elems])` as $sel
|
|
15
|
+
} where {
|
|
16
|
+
register_diagnostic(
|
|
17
|
+
span = $sel,
|
|
18
|
+
message = "useSelect selector returns a fresh object/array each call — this defeats the bail-out and re-renders on every update. Return a primitive/stable ref, or use multiple useSelect calls.",
|
|
19
|
+
severity = "warn"
|
|
20
|
+
)
|
|
21
|
+
}
|