Skip to content

jeremy-code/eslint-plugin-z

Repository files navigation

eslint-plugin-z

GitHub ActionsLicenseNPM versionGitHub release

An ESLint plugin for linting Zod schemas.

Installation

npm install eslint-plugin-z --save-dev

Configuration

// eslint.config.mjsimportpluginZfrom"eslint-plugin-z";exportdefault[pluginZ.configs.recommended];
// .eslintrc.json{"extends": ["plugin:z/recommendedLegacy"]}

Rules

  • 💼 Configurations enabled in
  • ⚠️ Configurations set to warn in
  • ✅ ️Set in the recommended configuration
  • 🔧 Automatically fixable by the --fix CLI option
NameDescription💼⚠️🔧
no-duplicate-enum-valuesDisallow duplicate enum member values🔧
no-throw-in-refineBan throwing in refinement function
no-undefined-argument-in-customDisallow undefined argument in z.custom()🔧
prefer-enumEnforce usage of z.enum() instead of z.union([z.literal(""),...])⚠️🔧
prefer-nonemptyEnforce usage of z.string().array().nonempty() instead of z.string().array().min(1) or z.array().nonempty() instead of z.array().min(1)⚠️🔧
prefer-nullishEnforce usage of z.nullish() instead of z.null().optional() or z.optional().null()⚠️🔧
prefer-tupleEnforce usage of z.tuple([z.schema()]) instead of z.schema().array().length(1)⚠️🔧

License

This project is licensed under the MIT license.

Contributors 2

  •  
  •