0.1.2 • Published 6 months ago
eslint-plugin-z v0.1.2
eslint-plugin-z
!CAUTION This project is in the early stages of development. Please report any issues you encounter.
An ESLint plugin for linting Zod schemas.
Installation
npm install eslint-plugin-z --save-dev
Configuration
// eslint.config.mjs
import pluginZ from "eslint-plugin-z";
export default [pluginZ.configs.recommended];
// .eslintrc.json
{
"extends": ["plugin:z/recommendedLegacy"]
}
Rules
- ✅ ️Set in the recommended configuration.
- 🖼️ Layout, ⚠️ problem, 💡 Suggestion
- 🔧 Automatically fixable by the
--fix
CLI option. - ❌ Deprecated.
Rules | Description | ✅ | Type | 🔧 | ❌ |
---|---|---|---|---|---|
no-duplicate-enum-values | Disallow duplicate enum member values. | ✅ | ⚠️ | ||
no-throw-in-refine | Ban throwing in refinement function. | ✅ | ⚠️ | ||
prefer-enum | Enforce usage of z.enum() instead of z.union([z.literal(""),...]) | ✅ | 💡 | 🔧 | |
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.