@aliou/biome-plugins 0.0.1
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,55 @@
|
|
|
1
|
+
# biome-plugins
|
|
2
|
+
|
|
3
|
+
Custom Biome lint rules written as GritQL plugins.
|
|
4
|
+
|
|
5
|
+
## Plugins
|
|
6
|
+
|
|
7
|
+
| Plugin | Description |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `no-inline-imports` | Disallows `await import()` and `require()` inside functions. All imports should be static `import` statements at the top of the file. |
|
|
10
|
+
| `no-interpolated-classname` | Disallows template literals in `className` attributes. Enforces using a `cn()` utility instead. |
|
|
11
|
+
| `phosphor-icon-suffix` | Enforces that Phosphor icon imports end with the `Icon` suffix (e.g. `HouseIcon`, not `House`). |
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### 1. Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save-dev @aliou/biome-plugins
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or with any other package manager:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add -D @aliou/biome-plugins
|
|
25
|
+
bun add -d @aliou/biome-plugins
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Configure
|
|
29
|
+
|
|
30
|
+
Reference the plugins you want in your `biome.json` using relative paths to `node_modules`:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"plugins": [
|
|
35
|
+
"./node_modules/@aliou/biome-plugins/plugins/no-interpolated-classname.grit",
|
|
36
|
+
"./node_modules/@aliou/biome-plugins/plugins/phosphor-icon-suffix.grit"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Pick only the ones you need. Each plugin is a standalone `.grit` file.
|
|
42
|
+
|
|
43
|
+
### 3. Run
|
|
44
|
+
|
|
45
|
+
Plugin diagnostics show up when running `biome lint` or `biome check` as usual:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
biome check .
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Limitations
|
|
52
|
+
|
|
53
|
+
Biome's plugin system is still experimental. There is no automatic npm package resolution for plugins -- you must use explicit relative paths to `node_modules` as shown above.
|
|
54
|
+
|
|
55
|
+
See [biomejs/biome#6265](https://github.com/biomejs/biome/discussions/6265) for the ongoing discussion on plugin distribution.
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aliou/biome-plugins",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Custom Biome lint rules written as GritQL plugins",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"plugins"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "bash scripts/test.sh"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@biomejs/biome": "^2.3.12",
|
|
17
|
+
"@changesets/cli": "^2.29.8"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@biomejs/biome": ">=2.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript,jsx)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
JsFunctionBody() as $body where {
|
|
6
|
+
$body <: contains `await import($source)` as $import,
|
|
7
|
+
register_diagnostic(
|
|
8
|
+
span = $import,
|
|
9
|
+
message = "All imports should be at the top of the file. Use a static `import` statement instead of a dynamic `await import()` buried in a function.",
|
|
10
|
+
severity = "error"
|
|
11
|
+
)
|
|
12
|
+
},
|
|
13
|
+
JsFunctionBody() as $body where {
|
|
14
|
+
$body <: contains `require($source)` as $req,
|
|
15
|
+
register_diagnostic(
|
|
16
|
+
span = $req,
|
|
17
|
+
message = "All imports should be at the top of the file. Use a static `import` statement instead of `require()` buried in a function.",
|
|
18
|
+
severity = "error"
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(jsx)
|
|
3
|
+
|
|
4
|
+
jsx_attribute(name = "className", $value) where {
|
|
5
|
+
$value <: contains JsTemplateExpression(),
|
|
6
|
+
register_diagnostic(
|
|
7
|
+
span = $value,
|
|
8
|
+
message = "Use cn() instead of template literal in className",
|
|
9
|
+
severity = "error"
|
|
10
|
+
)
|
|
11
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(jsx)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
`import { $a } from "@phosphor-icons/react"` where {
|
|
6
|
+
$a <: not r".*Icon",
|
|
7
|
+
register_diagnostic(span = $a, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
8
|
+
},
|
|
9
|
+
`import { $a, $b } from "@phosphor-icons/react"` where {
|
|
10
|
+
$a <: not r".*Icon",
|
|
11
|
+
register_diagnostic(span = $a, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
12
|
+
},
|
|
13
|
+
`import { $a, $b } from "@phosphor-icons/react"` where {
|
|
14
|
+
$b <: not r".*Icon",
|
|
15
|
+
register_diagnostic(span = $b, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
16
|
+
},
|
|
17
|
+
`import { $a, $b, $c } from "@phosphor-icons/react"` where {
|
|
18
|
+
$a <: not r".*Icon",
|
|
19
|
+
register_diagnostic(span = $a, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
20
|
+
},
|
|
21
|
+
`import { $a, $b, $c } from "@phosphor-icons/react"` where {
|
|
22
|
+
$b <: not r".*Icon",
|
|
23
|
+
register_diagnostic(span = $b, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
24
|
+
},
|
|
25
|
+
`import { $a, $b, $c } from "@phosphor-icons/react"` where {
|
|
26
|
+
$c <: not r".*Icon",
|
|
27
|
+
register_diagnostic(span = $c, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
28
|
+
},
|
|
29
|
+
`import { $a, $b, $c, $d } from "@phosphor-icons/react"` where {
|
|
30
|
+
$a <: not r".*Icon",
|
|
31
|
+
register_diagnostic(span = $a, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
32
|
+
},
|
|
33
|
+
`import { $a, $b, $c, $d } from "@phosphor-icons/react"` where {
|
|
34
|
+
$b <: not r".*Icon",
|
|
35
|
+
register_diagnostic(span = $b, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
36
|
+
},
|
|
37
|
+
`import { $a, $b, $c, $d } from "@phosphor-icons/react"` where {
|
|
38
|
+
$c <: not r".*Icon",
|
|
39
|
+
register_diagnostic(span = $c, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
40
|
+
},
|
|
41
|
+
`import { $a, $b, $c, $d } from "@phosphor-icons/react"` where {
|
|
42
|
+
$d <: not r".*Icon",
|
|
43
|
+
register_diagnostic(span = $d, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
44
|
+
},
|
|
45
|
+
`import { $a, $b, $c, $d, $e } from "@phosphor-icons/react"` where {
|
|
46
|
+
$a <: not r".*Icon",
|
|
47
|
+
register_diagnostic(span = $a, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
48
|
+
},
|
|
49
|
+
`import { $a, $b, $c, $d, $e } from "@phosphor-icons/react"` where {
|
|
50
|
+
$b <: not r".*Icon",
|
|
51
|
+
register_diagnostic(span = $b, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
52
|
+
},
|
|
53
|
+
`import { $a, $b, $c, $d, $e } from "@phosphor-icons/react"` where {
|
|
54
|
+
$c <: not r".*Icon",
|
|
55
|
+
register_diagnostic(span = $c, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
56
|
+
},
|
|
57
|
+
`import { $a, $b, $c, $d, $e } from "@phosphor-icons/react"` where {
|
|
58
|
+
$d <: not r".*Icon",
|
|
59
|
+
register_diagnostic(span = $d, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
60
|
+
},
|
|
61
|
+
`import { $a, $b, $c, $d, $e } from "@phosphor-icons/react"` where {
|
|
62
|
+
$e <: not r".*Icon",
|
|
63
|
+
register_diagnostic(span = $e, message = "Phosphor icon imports require Icon suffix", severity = "error")
|
|
64
|
+
}
|
|
65
|
+
}
|