Eslint rules for zod-openapi
npm install eslint-plugin-zod-openapiThis is a set of Eslint rules created for use with zod-openapi. This aims to optimise the overall developer experience with a little sprinkle of magic āØ.




To install simply run on yarn, npm or pnpm
``bash`
yarn add -D eslint-plugin-zod-openapior
npm i -D eslint-plugin-zod-openapior
pnpm i -D eslint-plugin-zod-openapi
Add the following configuration to your .eslintrc file
`js`
{
"plugins": ["zod-openapi"]
}
`js`
{
"rules": {
"zod-openapi/require-meta": "error"
"zod-openapi/require-comment": "error",
"zod-openapi/prefer-zod-default": "warn",
}
}
You may wish to use overrides as this plugin by default will assume that all Zod Objects are using zod-openapi.
`js`
"overrides": [
{
"files": ["src/api-types/*.ts"],
"rules": {
"zod-openapi/require-meta": "error"
}
}
]
š§ This rule is automatically fixable by the --fix CLI option.
| Name | Description | š§ |
| -------------------------------------------------------- | --------------------------------------------------------------------------- | :-: |
| require-meta | Requires that all ZodTypes have an .meta() method. | |description
| require-comment | Requires that all ZodTypes have a and matching JSDoc comment. | ā
|example
| require-example | Requires that all ZodTypes have an or examples field. | |.meta()
| prefer-meta-last | Prefers that the method be the last method in the ZodType chain. | |default
| prefer-zod-default | Provides an error when in .meta() is used | |
`shell`
pnpm test
`shellFix issues
pnpm format
$3
To release a new version
1. Create a new GitHub Release
2. Select
š·ļø Choose a tag, enter a version number. eg. v1.2.0 and click + Create new tag: vX.X.X on publish.
3. Click the Generate release notes button and adjust the description.
4. Tick the Set as the latest release box and click Publish release. This will trigger the Release workflow.
5. Check the Pull Requests tab for a PR labelled Release vX.X.X.
6. Click Merge Pull Request on that Pull Request to update master with the new package version.To release a new beta version
1. Create a new GitHub Release
2. Select
š·ļø Choose a tag, enter a version number with a -beta.X suffix eg. v1.2.0-beta.1 and click + Create new tag: vX.X.X-beta.X on publish.
3. Click the Generate release notes button and adjust the description.
4. Tick the Set as a pre-release box and click Publish release. This will trigger the Prerelease` workflow.