Custom ESLint rules for Zod and ESLint@9.
💼 Configurations enabled in.
✅ Set in the recommended
configuration.
🔧 Automatically fixable by the --fix
CLI option.
💡 Manually fixable by editor suggestions.
Name | Description | 💼 | 🔧 | 💡 |
---|---|---|---|---|
array-style | Enforce consistent Zod array style | ✅ | 🔧 | |
no-any | Disallow usage of z.any() in Zod schemas | ✅ | 💡 | |
no-throw-in-refine | Disallow throwing errors directly inside Zod refine callbacks | ✅ | ||
prefer-meta | Enforce usage of .meta() over .describe() | ✅ | 🔧 | |
prefer-meta-last | Enforce .meta() as last method | ✅ | 🔧 | |
prefer-namespace-import | Enforce importing zod as a namespace import (import * as z from 'zod') | ✅ | 🔧 | |
prefer-strict-object | Enforce usage of .strictObject() over .object() and/or .looseObject() |
npm i --save-dev eslint eslint-plugin-zod-x
yarn add --dev eslint eslint-plugin-zod-x
pnpm add --save-dev eslint eslint-plugin-zod-x
// eslint.config.js
import eslint from '@eslint/js';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';
import eslintPluginZodX from 'eslint-plugin-zod-x';
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
eslintPluginZodX.configs.recommended,
{
languageOptions: {
// ...
},
},
);
TODO (?)