biome-plugin-solidjs 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tommy Morgan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # biome-plugin-solidjs
2
+
3
+ Biome [GritQL](https://biomejs.dev/linter/plugins/) lint rules for [SolidJS](https://www.solidjs.com/). Catches common reactivity bugs at lint time.
4
+
5
+ ## Rules
6
+
7
+ | Rule | Description |
8
+ |------|-------------|
9
+ | `solid-no-destructured-props` | Flags destructured props in component signatures. Props are reactive getter objects — destructuring severs reactivity. |
10
+ | `solid-no-array-map-in-jsx` | Flags `.map()` inside JSX expressions. In Solid, `.map()` runs once and produces static DOM. Use `<For>` or `<Index>`. |
11
+ | `solid-no-memo-in-loop` | Flags `createMemo()` inside `.map()`, `.forEach()`, and other array method callbacks. |
12
+ | `solid-no-toplevel-effect` | Flags `createEffect()` and `createMemo()` at module scope, where they have no reactive owner and will leak. |
13
+ | `solid-no-stored-jsx` | Flags JSX stored in module-scope variables. Solid JSX compiles to real DOM operations, not virtual DOM descriptors. |
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install -D biome-plugin-solidjs
19
+ ```
20
+
21
+ ## Setup
22
+
23
+ Add the rules you want to your `biome.json` or `biome.jsonc`:
24
+
25
+ ```jsonc
26
+ {
27
+ "plugins": [
28
+ "./node_modules/biome-plugin-solidjs/rules/solid-no-destructured-props.grit",
29
+ "./node_modules/biome-plugin-solidjs/rules/solid-no-array-map-in-jsx.grit",
30
+ "./node_modules/biome-plugin-solidjs/rules/solid-no-memo-in-loop.grit",
31
+ "./node_modules/biome-plugin-solidjs/rules/solid-no-toplevel-effect.grit",
32
+ "./node_modules/biome-plugin-solidjs/rules/solid-no-stored-jsx.grit"
33
+ ]
34
+ }
35
+ ```
36
+
37
+ Pick only the rules relevant to your project — you don't have to use all of them.
38
+
39
+ ## Requirements
40
+
41
+ - [Biome](https://biomejs.dev/) >= 2.0.0 (GritQL plugin support)
42
+
43
+ ## How it works
44
+
45
+ Each rule is a `.grit` file using Biome's GritQL engine (`engine biome(1.0)`) to match AST patterns. The rules use structural heuristics rather than type information:
46
+
47
+ - **Component detection**: Functions returning JSX are treated as components (for the destructured props rule).
48
+ - **Scope detection**: `! $node <: within JsArrowFunctionExpression()` patterns distinguish module-level code from code inside functions.
49
+ - **No type inference**: These rules can't catch bugs that require knowing TypeScript types (e.g., uncalled signals, direct store mutation). For those, consider [eslint-plugin-solid](https://github.com/solidjs-community/eslint-plugin-solid).
50
+
51
+ ## What these rules don't cover
52
+
53
+ Some SolidJS pitfalls require TypeScript type information that GritQL doesn't have access to:
54
+
55
+ - Signals referenced without `()` (needs to know what's a signal)
56
+ - Direct store mutation (needs to know what's a store proxy)
57
+ - Store prop destructuring from custom hooks (needs return type info)
58
+
59
+ For full type-aware linting, use these rules alongside `eslint-plugin-solid`.
60
+
61
+ ## License
62
+
63
+ MIT
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "biome-plugin-solidjs",
3
+ "version": "0.1.0",
4
+ "description": "Biome GritQL lint rules for SolidJS — catches common reactivity bugs at lint time",
5
+ "license": "MIT",
6
+ "author": "Tommy Morgan",
7
+ "type": "module",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/tommymorgan/biome-plugin-solidjs"
11
+ },
12
+ "keywords": [
13
+ "biome",
14
+ "gritql",
15
+ "solidjs",
16
+ "solid-js",
17
+ "lint",
18
+ "plugin",
19
+ "reactivity"
20
+ ],
21
+ "files": [
22
+ "rules/*.grit",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "scripts": {
27
+ "test": "node --test test.js"
28
+ },
29
+ "peerDependencies": {
30
+ "@biomejs/biome": ">=2.0.0"
31
+ }
32
+ }
@@ -0,0 +1,20 @@
1
+ engine biome(1.0)
2
+ language js(typescript, jsx)
3
+
4
+ // SolidJS: Never use Array.map() in JSX for reactive lists.
5
+ // .map() runs once at component initialization and produces static DOM nodes.
6
+ // Use <For> for arrays where order/length changes, or <Index> for stable-length lists.
7
+
8
+ JsxExpressionChild() as $expr where {
9
+ $expr <: contains JsCallExpression() as $call where {
10
+ $call <: contains JsStaticMemberExpression() as $member where {
11
+ $member <: contains JsName() as $method where {
12
+ $method <: `map`
13
+ }
14
+ }
15
+ },
16
+ register_diagnostic(
17
+ span = $call,
18
+ message = "SolidJS: Do not use .map() in JSX. It runs once and produces static DOM nodes. Use <For> or <Index> for reactive lists."
19
+ )
20
+ }
@@ -0,0 +1,31 @@
1
+ engine biome(1.0)
2
+ language js(typescript, jsx)
3
+
4
+ // SolidJS: Never destructure props in component signatures.
5
+ // Props are reactive getter objects — destructuring severs reactivity.
6
+ // Use `props.value` or `splitProps(props, [...])` instead.
7
+ //
8
+ // Detects functions that return JSX and have destructured parameters.
9
+ // This heuristic identifies components without relying on naming conventions.
10
+
11
+ or {
12
+ // Arrow function component: const Comp = ({ value }) => <div>...</div>
13
+ JsArrowFunctionExpression() as $arrow where {
14
+ $arrow <: contains JsObjectBindingPattern() as $pattern,
15
+ $arrow <: contains JsxOpeningElement(),
16
+ register_diagnostic(
17
+ span = $pattern,
18
+ message = "SolidJS: Do not destructure props. Props are reactive getter objects — destructuring breaks reactivity. Use `props` parameter and access `props.value`, or use `splitProps()`."
19
+ )
20
+ },
21
+
22
+ // Function declaration component: function Comp({ value }) { return <div>...</div> }
23
+ JsFunctionDeclaration() as $func where {
24
+ $func <: contains JsObjectBindingPattern() as $pattern,
25
+ $func <: contains JsxOpeningElement(),
26
+ register_diagnostic(
27
+ span = $pattern,
28
+ message = "SolidJS: Do not destructure props. Props are reactive getter objects — destructuring breaks reactivity. Use `props` parameter and access `props.value`, or use `splitProps()`."
29
+ )
30
+ }
31
+ }
@@ -0,0 +1,25 @@
1
+ engine biome(1.0)
2
+ language js(typescript, jsx)
3
+
4
+ // SolidJS: Don't create reactive primitives inside loop callbacks.
5
+ // createMemo inside .map()/.forEach()/.filter() creates a new memo on every
6
+ // iteration, which is wasteful and likely a bug.
7
+
8
+ JsCallExpression() as $outerCall where {
9
+ $outerCall <: contains JsStaticMemberExpression() as $member where {
10
+ $member <: contains JsName() as $method where {
11
+ $method <: or { `map`, `forEach`, `filter`, `reduce`, `flatMap` }
12
+ }
13
+ },
14
+ $outerCall <: contains JsArrowFunctionExpression() as $callback where {
15
+ $callback <: contains JsCallExpression() as $innerCall where {
16
+ $innerCall <: contains JsReferenceIdentifier() as $callee where {
17
+ $callee <: `createMemo`
18
+ }
19
+ }
20
+ },
21
+ register_diagnostic(
22
+ span = $innerCall,
23
+ message = "SolidJS: Do not call createMemo() inside loop callbacks (.map, .forEach, etc.). It creates a new memo on every iteration. Derive data inline or restructure upstream."
24
+ )
25
+ }
@@ -0,0 +1,29 @@
1
+ engine biome(1.0)
2
+ language js(typescript, jsx)
3
+
4
+ // SolidJS: Do not store JSX in variables at module scope.
5
+ // In Solid, JSX compiles to real DOM operations — not virtual DOM descriptors.
6
+ // Storing JSX creates live DOM nodes immediately, which has side effects.
7
+
8
+ // Match JSX elements that are NOT inside any function body
9
+ or {
10
+ JsxElement() as $jsx where {
11
+ ! $jsx <: within JsArrowFunctionExpression(),
12
+ ! $jsx <: within JsFunctionDeclaration(),
13
+ ! $jsx <: within JsFunctionExpression(),
14
+ register_diagnostic(
15
+ span = $jsx,
16
+ message = "SolidJS: Do not store JSX in variables. In Solid, JSX creates live DOM nodes immediately — not virtual DOM descriptors. Return JSX directly from components instead."
17
+ )
18
+ },
19
+
20
+ JsxSelfClosingElement() as $jsx where {
21
+ ! $jsx <: within JsArrowFunctionExpression(),
22
+ ! $jsx <: within JsFunctionDeclaration(),
23
+ ! $jsx <: within JsFunctionExpression(),
24
+ register_diagnostic(
25
+ span = $jsx,
26
+ message = "SolidJS: Do not store JSX in variables. In Solid, JSX creates live DOM nodes immediately — not virtual DOM descriptors. Return JSX directly from components instead."
27
+ )
28
+ }
29
+ }
@@ -0,0 +1,19 @@
1
+ engine biome(1.0)
2
+ language js(typescript, jsx)
3
+
4
+ // SolidJS: Reactive primitives must be created inside a reactive root.
5
+ // createEffect/createMemo at module scope have no owner and will leak.
6
+ // Place them inside a component or wrap with createRoot().
7
+
8
+ // Match createEffect/createRenderEffect/createMemo reference identifiers
9
+ // that are NOT inside any function body.
10
+ JsReferenceIdentifier() as $callee where {
11
+ $callee <: or { `createEffect`, `createRenderEffect`, `createMemo` },
12
+ ! $callee <: within JsArrowFunctionExpression(),
13
+ ! $callee <: within JsFunctionDeclaration(),
14
+ ! $callee <: within JsFunctionExpression(),
15
+ register_diagnostic(
16
+ span = $callee,
17
+ message = "SolidJS: Reactive primitive at module scope has no owner and will leak. Place it inside a component or wrap with createRoot()."
18
+ )
19
+ }