@moderneinc/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 +47 -0
- package/package.json +23 -0
- package/plugins/no-css-variables.grit +8 -0
- package/plugins/no-hardcoded-border-radius.grit +13 -0
- package/plugins/no-hardcoded-colors.grit +12 -0
- package/plugins/no-hardcoded-font-sizes.grit +8 -0
- package/plugins/no-hardcoded-font-weights.grit +8 -0
- package/plugins/no-hardcoded-mui-classes.grit +8 -0
- package/plugins/no-hardcoded-shadows.grit +8 -0
- package/plugins/no-hardcoded-spacing.grit +16 -0
- package/plugins/no-pxToRem-non-font.grit +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @moderneinc/biome-plugins
|
|
2
|
+
|
|
3
|
+
Biome GritQL lint plugins for enforcing Moderne design token usage in styled components.
|
|
4
|
+
|
|
5
|
+
## Plugins
|
|
6
|
+
|
|
7
|
+
| Plugin | Description |
|
|
8
|
+
|--------|-------------|
|
|
9
|
+
| `no-hardcoded-colors` | Flags hex colors — use `semanticColors.*` or `colors.*` tokens |
|
|
10
|
+
| `no-hardcoded-font-sizes` | Flags numeric font sizes — use `theme.typography.pxToRem()` or `typography.fontSize.*` |
|
|
11
|
+
| `no-hardcoded-font-weights` | Flags numeric font weights — use `typography.fontWeight.*` tokens |
|
|
12
|
+
| `no-hardcoded-spacing` | Flags hardcoded spacing — use `theme.spacing()` or `spacing.*` tokens |
|
|
13
|
+
| `no-hardcoded-shadows` | Flags hardcoded box shadows — use `shadows.*` tokens |
|
|
14
|
+
| `no-pxToRem-non-font` | Flags `pxToRem()` on non-fontSize properties |
|
|
15
|
+
| `no-hardcoded-border-radius` | Flags hardcoded border radius — use `borderRadius.*` tokens |
|
|
16
|
+
| `no-hardcoded-mui-classes` | Flags hardcoded `.Mui*` class selectors — use `*Classes` imports |
|
|
17
|
+
| `no-css-variables` | Flags `var(--)` usage — import tokens directly |
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Install the package:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install --save-dev @moderneinc/biome-plugins
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Add the plugin paths to your `biome.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"plugins": [
|
|
32
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-hardcoded-colors.grit",
|
|
33
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-hardcoded-font-sizes.grit",
|
|
34
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-hardcoded-font-weights.grit",
|
|
35
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-hardcoded-spacing.grit",
|
|
36
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-hardcoded-shadows.grit",
|
|
37
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-pxToRem-non-font.grit",
|
|
38
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-hardcoded-border-radius.grit",
|
|
39
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-hardcoded-mui-classes.grit",
|
|
40
|
+
"./node_modules/@moderneinc/biome-plugins/plugins/no-css-variables.grit"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Requirements
|
|
46
|
+
|
|
47
|
+
- [Biome](https://biomejs.dev/) v2.0+ with GritQL plugin support
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@moderneinc/biome-plugins",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Biome GritQL lint plugins for Moderne design token enforcement",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"plugins",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"keywords": [
|
|
11
|
+
"biome",
|
|
12
|
+
"gritql",
|
|
13
|
+
"lint",
|
|
14
|
+
"design-tokens",
|
|
15
|
+
"moderne"
|
|
16
|
+
],
|
|
17
|
+
"author": "Moderne",
|
|
18
|
+
"license": "UNLICENSED",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/moderneinc/neo-design.git"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
`$prop: $val` where {
|
|
2
|
+
$prop <: or {
|
|
3
|
+
`borderRadius`,
|
|
4
|
+
`borderTopLeftRadius`, `borderTopRightRadius`,
|
|
5
|
+
`borderBottomLeftRadius`, `borderBottomRightRadius`
|
|
6
|
+
},
|
|
7
|
+
$val <: r"^[1-9][0-9]*$",
|
|
8
|
+
register_diagnostic(
|
|
9
|
+
span = $val,
|
|
10
|
+
message = "Hardcoded border radius. Use borderRadius.* tokens from @moderneinc/neo-design (xXS=2, xS=4, s=8, m=12, l=20, xL=30, full=999).",
|
|
11
|
+
severity = "warn"
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
`$prop: $val` where {
|
|
2
|
+
$prop <: or {
|
|
3
|
+
`color`, `backgroundColor`, `borderColor`,
|
|
4
|
+
`outlineColor`, `fill`, `stroke`
|
|
5
|
+
},
|
|
6
|
+
$val <: r"['\x22]#[0-9a-fA-F]{3,8}['\x22]",
|
|
7
|
+
register_diagnostic(
|
|
8
|
+
span = $val,
|
|
9
|
+
message = "Hardcoded hex color. Use semanticColors.* or colors.* from @moderneinc/neo-design instead.",
|
|
10
|
+
severity = "warn"
|
|
11
|
+
)
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
`fontWeight: $val` where {
|
|
2
|
+
$val <: or { `300`, `400`, `500`, `600`, `700`, `800`, `900` },
|
|
3
|
+
register_diagnostic(
|
|
4
|
+
span = $val,
|
|
5
|
+
message = "Hardcoded font weight. Use typography.fontWeight.* from @moderneinc/neo-design (light=300, regular=400, medium=500, semibold=600, bold=700).",
|
|
6
|
+
severity = "warn"
|
|
7
|
+
)
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
`$prop: $val` where {
|
|
2
|
+
$prop <: or {
|
|
3
|
+
`padding`, `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft`,
|
|
4
|
+
`paddingInline`, `paddingBlock`, `paddingInlineStart`, `paddingInlineEnd`,
|
|
5
|
+
`margin`, `marginTop`, `marginRight`, `marginBottom`, `marginLeft`,
|
|
6
|
+
`marginInline`, `marginBlock`, `marginInlineStart`, `marginInlineEnd`,
|
|
7
|
+
`gap`, `rowGap`, `columnGap`,
|
|
8
|
+
`top`, `right`, `bottom`, `left`
|
|
9
|
+
},
|
|
10
|
+
$val <: r"^[2-9]$|^[1-9][0-9]+$",
|
|
11
|
+
register_diagnostic(
|
|
12
|
+
span = $val,
|
|
13
|
+
message = "Hardcoded spacing value. Use theme.spacing() or spacing.* tokens from @moderneinc/neo-design instead.",
|
|
14
|
+
severity = "warn"
|
|
15
|
+
)
|
|
16
|
+
}
|