1.0.0 ⢠Published 10 months ago
eslint-plugin-zod-openapi v1.0.0
eslint-plugin-zod-openapi
This 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 āØ.
Installation
To install simply run on yarn, npm or pnpm
yarn add -D eslint-plugin-zod-openapi
# or
npm i -D eslint-plugin-zod-openapi
# or
pnpm i -D eslint-plugin-zod-openapi
Add the following configuration to your .eslintrc
file
{
"plugins": ["zod-openapi"]
}
{
"rules": {
"zod-openapi/require-openapi": "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.
"overrides": [
{
"files": ["src/api-types/*.ts"],
"rules": {
"zod-openapi/require-openapi": "error"
}
}
]
Rules
š§ This rule is automatically fixable by the --fix CLI option.
Name | Description | š§ |
---|---|---|
require-openapi | Requires that all ZodTypes have an .openapi() method. | |
require-comment | Requires that all ZodTypes have a description and matching JSDoc comment. | ā |
require-example | Requires that all ZodTypes have an example or examples field. | |
prefer-openapi-last | Prefers that the .openapi() method be the last method in the ZodType chain. | |
prefer-zod-default | Provides an error when default in .openapi() is used |
Development
Test
pnpm test
Lint
# Fix issues
pnpm format
# Check for issues
pnpm lint
Release
To release a new version
- Create a new GitHub Release
- Select
š·ļø Choose a tag
, enter a version number. eg.v1.2.0
and click+ Create new tag: vX.X.X on publish
. - Click the
Generate release notes
button and adjust the description. - Tick the
Set as the latest release
box and clickPublish release
. This will trigger theRelease
workflow. - Check the
Pull Requests
tab for a PR labelledRelease vX.X.X
. - Click
Merge Pull Request
on that Pull Request to update master with the new package version.
To release a new beta version
- Create a new GitHub Release
- 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
. - Click the
Generate release notes
button and adjust the description. - Tick the
Set as a pre-release
box and clickPublish release
. This will trigger thePrerelease
workflow.
1.0.0
10 months ago
1.0.0-beta.0
10 months ago
0.3.0-beta.0
1 year ago
0.2.0
1 year ago
0.1.0
2 years ago
0.1.0-beta.6
2 years ago
0.1.0-beta.5
2 years ago
0.1.0-beta.4
2 years ago
0.1.0-beta.3
2 years ago
0.1.0-beta.2
2 years ago
0.0.3
2 years ago
0.0.3-beta.4
2 years ago
0.0.3-beta.3
2 years ago
0.0.2
2 years ago
0.0.3-beta.2
2 years ago
0.0.1
2 years ago