eslint-plugin-z
v0.2.1
Published
ESLint rules for Zod
Maintainers
Readme
eslint-plugin-z
An ESLint plugin for linting Zod schemas.
Installation
npm install eslint-plugin-z --save-devConfiguration
// eslint.config.mjs
import pluginZ from "eslint-plugin-z";
export default [pluginZ.configs.recommended];// .eslintrc.json
{
"extends": ["plugin:z/recommendedLegacy"]
}Rules
- 💼 Configurations enabled in
- ⚠️ Configurations set to warn in
- ✅ ️Set in the
recommendedconfiguration - 🔧 Automatically fixable by the
--fixCLI option
| Name | Description | 💼 | ⚠️ | 🔧 |
|---|---|---|---|---|
| no-duplicate-enum-values| Disallow duplicate enum member values | ✅ | | 🔧 |
| no-throw-in-refine | Ban throwing in refinement function | ✅ | | |
| no-undefined-argument-in-custom | Disallow undefined argument in z.custom() | ✅ | | 🔧 |
| prefer-enum | Enforce usage of z.enum() instead of z.union([z.literal(""),...]) | | ⚠️ | 🔧 |
| prefer-nonempty | Enforce usage of z.string().array().nonempty() instead of z.string().array().min(1) or z.array().nonempty() instead of z.array().min(1) | ✅ | ⚠️ | 🔧 |
| prefer-nullish | Enforce usage of z.nullish() instead of z.null().optional() or z.optional().null() | ✅ | ⚠️ | 🔧 |
| prefer-tuple | Enforce usage of z.tuple([z.schema()]) instead of z.schema().array().length(1) | ✅ | ⚠️ | 🔧 |
License
This project is licensed under the MIT license.
