File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 "jsPlugins" : [
88 " ./oxlint-plugins/no-thrown-unawaited-redirect.mjs" ,
99 " ./oxlint-plugins/runops-residency.mjs" ,
10- " ./oxlint-plugins/prisma-in-filter.mjs"
10+ " ./oxlint-plugins/prisma-in-filter.mjs" ,
11+ " ./oxlint-plugins/zod-imports.mjs"
1112 ],
1213 "ignorePatterns" : [
1314 " **/dist/**" ,
158159 "trigger-runops/no-control-plane-in-runops-slot" : " error"
159160 }
160161 },
162+ {
163+ "files" : [" packages/core/src/**/*.ts" , " packages/core/src/**/*.tsx" ],
164+ "rules" : {
165+ "trigger-zod/require-versioned-import" : " error"
166+ }
167+ },
161168 {
162169 "files" : [" packages/react-hooks/src/**/*.ts" , " packages/react-hooks/src/**/*.tsx" ],
163170 "rules" : {
Original file line number Diff line number Diff line change 1+ /** @type {import("eslint").Rule.RuleModule } */
2+ const requireVersionedImport = {
3+ meta : {
4+ type : "problem" ,
5+ docs : {
6+ description :
7+ "Require an explicit Zod version import in packages that support multiple Zod major versions." ,
8+ } ,
9+ fixable : "code" ,
10+ messages : {
11+ unversioned :
12+ 'Import Zod 4 from "zod/v4" rather than "zod". The package supports Zod 3 and 4, so the bare import can resolve to the wrong major version.' ,
13+ } ,
14+ schema : [ ] ,
15+ } ,
16+ create ( context ) {
17+ function checkSource ( node ) {
18+ if ( node . source ?. value !== "zod" ) return ;
19+
20+ context . report ( {
21+ node : node . source ,
22+ messageId : "unversioned" ,
23+ fix : ( fixer ) => fixer . replaceText ( node . source , '"zod/v4"' ) ,
24+ } ) ;
25+ }
26+
27+ return {
28+ ImportDeclaration : checkSource ,
29+ ExportAllDeclaration : checkSource ,
30+ ExportNamedDeclaration : checkSource ,
31+ } ;
32+ } ,
33+ } ;
34+
35+ /** @type {import("eslint").ESLint.Plugin } */
36+ const plugin = {
37+ meta : { name : "trigger-zod" } ,
38+ rules : {
39+ "require-versioned-import" : requireVersionedImport ,
40+ } ,
41+ } ;
42+
43+ export default plugin ;
You can’t perform that action at this time.
0 commit comments