Zod linting rules for ESLint.
- Install ESLint.
- Install
eslint-plugin-zod
plugin.
npm install eslint --save-dev
npm install eslint-plugin-zod --save-dev
- Add
plugins
section and specifyeslint-plugin-zod
as a plugin. - Enable rules.
{
"plugins": [
"zod"
],
"rules": {
"zod/prefer-enum": 2,
"zod/require-strict": 2
}
}
The --fix
option on the command line automatically fixes problems reported by this rule.
Prefers z.enum
over a union of literals.
The --fix
option on the command line automatically fixes problems reported by this rule.
Requires that objects are initialized with .strict()
.
configuration | format | default | description |
---|---|---|---|
allowPassthrough |
boolean | true |
Ignores objects explicitly set to allowPassthrough() . |