Skip to content

Commit 4d6faa7

Browse files
committed
chore(lint): add plugin to ensure that only zod/v4/core is imported
1 parent f746da2 commit 4d6faa7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Ensures that only `zod/v4/core` is imported.
2+
// https://zod.dev/library-authors?id=how-to-support-zod-and-zod-mini-simultaneously
3+
// > Your library code should only import from "zod/v4/core".
4+
// > This sub-package defines the interfaces, classes, and utilities that are shared between zod/v4 and zod/v4-mini.
5+
6+
`import $imports from $source` where {
7+
$source <: or {`'zod'`, `'zod/v4'`},
8+
register_diagnostic(
9+
span = $source,
10+
message = "This plugins supports both `zod` and `zod-mini`, so please import only from `zod/v4/core`"
11+
)
12+
}

biome.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
}
2929
}
3030
}
31+
},
32+
{
33+
"includes": ["src/**"],
34+
"plugins": ["./biome-plugins/ensures-zod-core-import.grit"]
3135
}
3236
]
3337
}

0 commit comments

Comments
 (0)