@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 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,8 @@
1
+ `$prop: $val` where {
2
+ $val <: r"['\x22].*var\(--.*['\x22]",
3
+ register_diagnostic(
4
+ span = $val,
5
+ message = "CSS variable usage in styled component. Import tokens directly from @moderneinc/neo-design instead of using var(--...).",
6
+ severity = "warn"
7
+ )
8
+ }
@@ -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
+ `fontSize: $val` where {
2
+ $val <: r"^\d+$",
3
+ register_diagnostic(
4
+ span = $val,
5
+ message = "Hardcoded font size. Use theme.typography.pxToRem() or typography.fontSize.* from @moderneinc/neo-design instead.",
6
+ severity = "warn"
7
+ )
8
+ }
@@ -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,8 @@
1
+ `$key: $val` where {
2
+ $key <: r"'[^']*\.Mui[A-Z][^']*'",
3
+ register_diagnostic(
4
+ span = $key,
5
+ message = "Hardcoded MUI class selector. Use imported *Classes constants instead (e.g., `[`& .${checkboxClasses.root}`]`).",
6
+ severity = "warn"
7
+ )
8
+ }
@@ -0,0 +1,8 @@
1
+ `boxShadow: $val` where {
2
+ $val <: r"'[^']*\d+px[^']*'",
3
+ register_diagnostic(
4
+ span = $val,
5
+ message = "Hardcoded box shadow. Use shadows.* from @moderneinc/neo-design (e.g., shadows.neutralSmall, shadows.dropdown).",
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
+ }
@@ -0,0 +1,9 @@
1
+ `$prop: $val` where {
2
+ $prop <: not `fontSize`,
3
+ $val <: contains `$_.pxToRem($_)`,
4
+ register_diagnostic(
5
+ span = $val,
6
+ message = "pxToRem() is only for fontSize. Use numeric values, theme.spacing(), or design tokens directly.",
7
+ severity = "warn"
8
+ )
9
+ }