{"name":"eslint-plugin-zod","version":"4.2.2","keywords":["eslint","eslint-plugin","eslintplugin","oxlint","zod"],"author":"Marco Pasqualetti @marcalexiei","license":"MIT","_id":"eslint-plugin-zod@4.2.2","maintainers":[{"name":"gajus","email":"gajus@gajus.com"},{"name":"marcalexiei","email":"marco.pasqualetti@live.com"}],"homepage":"https://github.com/marcalexiei/eslint-zod#readme","bugs":{"url":"https://github.com/marcalexiei/eslint-zod/issues"},"dist":{"shasum":"1fb905ac1c9c46bcff57ae35495d2e7bbc7c656f","tarball":"http://registry-npm.ywwl.com/eslint-plugin-zod/download/eslint-plugin-zod-4.2.2.tgz","fileCount":70,"integrity":"sha512-8QVvc4PBr6WLbDK5nJehNYVu0t1wcs9GNYBdhhFZCgEneXJ3wrclhpmiwyOlXGRu37/Rk63aHS3kQDDi8nT79g==","signatures":[{"sig":"MEQCIFEWmIO604M3+/d57Zba7DLxLakw7Y6k9cbq3qCe8yt/AiBdv6a5jOEyrb1yFe5Z1bs00X+9cY0LeE5mWP1Lxvn6Uw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/eslint-plugin-zod@4.2.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":157369,"size":28978,"noattachment":false,"key":"/eslint-plugin-zod/-/eslint-plugin-zod-4.2.2.tgz"},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.cts","module":"./dist/index.mjs","engines":{"node":"^20 || ^22 || >=24"},"exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"test":"vitest","build":"tsdown","lint:docs":"eslint-doc-generator --check","build:docs":"pnpm run build && eslint-doc-generator"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:523f48dc-0e63-406b-8a7e-87e31e154b17"}},"repository":{"url":"https://github.com/marcalexiei/eslint-zod","type":"git","directory":"plugins/eslint-plugin-zod"},"description":"ESLint plugin that adds custom linting rules to enforce best practices when using Zod","directories":{},"_nodeVersion":"25.9.0","dependencies":{"esquery":"^1.6.0","@eslint-zod/utils":"1.2.0","@typescript-eslint/utils":"^8.57.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"dedent":"1.7.2","tsdown":"0.21.10","vitest":"4.1.5","prettier":"3.8.3","@types/esquery":"1.5.4","eslint-doc-generator":"3.3.2","@marcalexiei/prettier-config":"1.1.4","@typescript-eslint/rule-tester":"8.59.2"},"peerDependencies":{"zod":"^4","eslint":"^9 || ^10","oxlint":"^1.59.0"},"peerDependenciesMeta":{"zod":{"optional":true},"eslint":{"optional":true},"oxlint":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/eslint-plugin-zod_4.2.2_1778480043435_0.28065296417808505","host":"s3://npm-registry-packages-npm-production"},"readme":"# eslint-plugin-zod\n\n[![CI Status][CIBadge]][CIURL]\n[![Code style: prettier][CodeStyleBadge]][CodeStyleURL]\n[![Lint: eslint][lintBadge]][lintURL]\n[![Open on npmx][npmVersionBadge]][npmVersionURL]\n[![Open issue tracker][issuesBadge]][issuesURL]\n\n[CIBadge]: https://img.shields.io/github/actions/workflow/status/marcalexiei/eslint-zod/ci.yml?style=for-the-badge&logo=github&event=push&label=CI\n[CIURL]: https://github.com/marcalexiei/eslint-zod/actions/workflows/CI.yml/badge.svg\n[CodeStyleBadge]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge&logo=prettier\n[CodeStyleURL]: https://prettier.io\n[npmVersionBadge]: https://img.shields.io/npm/v/eslint-plugin-zod.svg?style=for-the-badge&logo=npm\n[npmVersionURL]: https://npmx.dev/package/eslint-plugin-zod\n[lintBadge]: https://img.shields.io/badge/lint-eslint-3A33D1?logo=eslint&style=for-the-badge\n[lintURL]: https://eslint.org\n[issuesBadge]: https://img.shields.io/github/issues/marcalexiei/eslint-zod.svg?style=for-the-badge\n[issuesURL]: https://github.com/marcalexiei/eslint-zod/issues\n\n[ESLint](https://eslint.org) plugin that adds custom linting rules to enforce best practices when using [Zod](https://github.com/colinhacks/zod).\n\nIt can also work with [Oxlint](https://oxc.rs/docs/guide/usage/linter.html)!\\\nFind out more about [Oxlint's `jsPlugins`](https://oxc.rs/docs/guide/usage/linter/js-plugins.html).\n\n## Rules\n\n<!-- begin auto-generated rules list -->\n\n💼 Configurations enabled in.\\\n✅ Set in the `recommended` configuration.\\\n🔒 Set in the `strict` configuration.\\\n🎨 Set in the `stylistic` configuration.\\\n🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\\\n💡 Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).\n\n| Name                                                                                             | Description                                                                                                                    | 💼    | 🔧  | 💡  |\n| :----------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------- | :---- | :-- | :-- |\n| [array-style](docs/rules/array-style.md)                                                         | Enforce consistent Zod array style                                                                                             | 🎨    | 🔧  |     |\n| [consistent-import](docs/rules/consistent-import.md)                                             | Enforce a consistent import style for Zod                                                                                      | ✅ 🔒 | 🔧  |     |\n| [consistent-import-source](docs/rules/consistent-import-source.md)                               | Enforce consistent source from Zod imports                                                                                     | 🎨    |     | 💡  |\n| [consistent-object-schema-type](docs/rules/consistent-object-schema-type.md)                     | Enforce consistent usage of Zod schema methods                                                                                 |       |     | 💡  |\n| [consistent-schema-output-type-style](docs/rules/consistent-schema-output-type-style.md)         | Enforce consistent use of z.infer or z.output for schema type inference                                                        | 🎨    | 🔧  |     |\n| [consistent-schema-var-name](docs/rules/consistent-schema-var-name.md)                           | Enforce a consistent naming convention for Zod schema variables                                                                | ✅ 🔒 |     |     |\n| [no-any-schema](docs/rules/no-any-schema.md)                                                     | Disallow usage of `z.any()` in Zod schemas                                                                                     | ✅ 🔒 |     | 💡  |\n| [no-coerce-boolean](docs/rules/no-coerce-boolean.md)                                             | Disallow `z.coerce.boolean()` because it treats any non-empty string as `true`.                                                | ✅ 🔒 |     | 💡  |\n| [no-conflicting-checks](docs/rules/no-conflicting-checks.md)                                     | Disallow check combinations that can never match, are redundant, or do not apply to the schema type                            | ✅ 🔒 |     |     |\n| [no-duplicate-schema-methods](docs/rules/no-duplicate-schema-methods.md)                         | Disallow calling the same schema method more than once in a single chain                                                       | ✅ 🔒 |     |     |\n| [no-dynamic-schema-value](docs/rules/no-dynamic-schema-value.md)                                 | Disallow non-static values passed as arguments in a Zod schema expression                                                      | 🔒    |     |     |\n| [no-empty-custom-schema](docs/rules/no-empty-custom-schema.md)                                   | Disallow usage of `z.custom()` without arguments                                                                               | ✅ 🔒 |     |     |\n| [no-function-scoped-schema](docs/rules/no-function-scoped-schema.md)                             | Disallow constructing a Zod schema inside a function body                                                                      | 🔒    |     |     |\n| [no-native-enum](docs/rules/no-native-enum.md)                                                   | Disallow deprecated `z.nativeEnum()` in favor of `z.enum()`.                                                                   | ✅ 🔒 | 🔧  |     |\n| [no-number-schema-with-finite](docs/rules/no-number-schema-with-finite.md)                       | Disallow deprecated `z.number().finite()`. In Zod 4+ number schemas do not allow infinite values by default, so it is a no-op. | ✅ 🔒 | 🔧  |     |\n| [no-number-schema-with-int](docs/rules/no-number-schema-with-int.md)                             | Disallow usage of `z.number().int()` as it is considered legacy                                                                | ✅ 🔒 | 🔧  |     |\n| [no-number-schema-with-is-finite](docs/rules/no-number-schema-with-is-finite.md)                 | Disallow using deprecated `isFinite` on a Zod number schema; in v4+ it is always `true`.                                       | ✅ 🔒 |     |     |\n| [no-number-schema-with-is-int](docs/rules/no-number-schema-with-is-int.md)                       | Disallow using deprecated `isInt` on a Zod number schema; check the `format` property instead.                                 | ✅ 🔒 |     |     |\n| [no-number-schema-with-safe](docs/rules/no-number-schema-with-safe.md)                           | Disallow deprecated `z.number().safe()`. Use `z.int()`; `.safe()` is now identical to `.int()`.                                | ✅ 🔒 | 🔧  |     |\n| [no-number-schema-with-step](docs/rules/no-number-schema-with-step.md)                           | Disallow deprecated `z.number().step()`. Use `.multipleOf()` instead.                                                          | ✅ 🔒 | 🔧  |     |\n| [no-optional-and-default-together](docs/rules/no-optional-and-default-together.md)               | Disallow using both `.optional()` and `.default()` on the same Zod schema                                                      | ✅ 🔒 | 🔧  |     |\n| [no-promise-schema](docs/rules/no-promise-schema.md)                                             | Disallow deprecated `z.promise()` schemas.                                                                                     | ✅ 🔒 |     |     |\n| [no-schema-with-is-nullable](docs/rules/no-schema-with-is-nullable.md)                           | Disallow deprecated `.isNullable()` on a Zod schema; use `safeParse(null).success` instead.                                    | ✅ 🔒 |     |     |\n| [no-schema-with-is-optional](docs/rules/no-schema-with-is-optional.md)                           | Disallow deprecated `.isOptional()` on a Zod schema; use `safeParse(undefined).success` instead.                               | ✅ 🔒 |     |     |\n| [no-throw-in-refine](docs/rules/no-throw-in-refine.md)                                           | Disallow throwing errors directly inside Zod refine callbacks                                                                  | ✅ 🔒 |     |     |\n| [no-transform-in-record-key](docs/rules/no-transform-in-record-key.md)                           | Disallow transforms in z.record() key schemas, which can cause silent key mutations and data loss through key collisions       | ✅ 🔒 |     |     |\n| [no-unknown-schema](docs/rules/no-unknown-schema.md)                                             | Disallow usage of `z.unknown()` in Zod schemas                                                                                 | 🔒    |     |     |\n| [no-unnecessary-readonly](docs/rules/no-unnecessary-readonly.md)                                 | Disallow `.readonly()` on schemas whose output is already immutable                                                            | 🔒    | 🔧  |     |\n| [prefer-enum-over-literal-union](docs/rules/prefer-enum-over-literal-union.md)                   | Prefer `z.enum()` over `z.union()` when all members are string literals.                                                       | 🎨    | 🔧  |     |\n| [prefer-loose-object](docs/rules/prefer-loose-object.md)                                         | Prefer `z.looseObject()` over `z.object().passthrough()` and `z.object().loose()`                                              | 🎨    | 🔧  |     |\n| [prefer-map-set-size-over-min-max](docs/rules/prefer-map-set-size-over-min-max.md)               | Prefer `.size(n)` over `.min(n).max(n)` with the same value on a set or map schema                                             | 🎨    | 🔧  |     |\n| [prefer-meta](docs/rules/prefer-meta.md)                                                         | Enforce usage of `.meta()` over `.describe()`                                                                                  | 🎨    | 🔧  |     |\n| [prefer-meta-last](docs/rules/prefer-meta-last.md)                                               | Enforce `.meta()` as last method                                                                                               | 🎨    | 🔧  |     |\n| [prefer-nullish](docs/rules/prefer-nullish.md)                                                   | Enforce `.nullish()` instead of combining `.optional()` and `.nullable()`                                                      | 🎨    | 🔧  |     |\n| [prefer-strict-object](docs/rules/prefer-strict-object.md)                                       | Prefer `z.strictObject()` over `z.object().strict()`                                                                           | 🎨    | 🔧  |     |\n| [prefer-string-length-over-min-max](docs/rules/prefer-string-length-over-min-max.md)             | Prefer `.length(n)` over `.min(n).max(n)` with the same value on a string schema                                               | 🎨    | 🔧  |     |\n| [prefer-string-schema-with-trim](docs/rules/prefer-string-schema-with-trim.md)                   | Enforce `z.string().trim()` to prevent accidental leading/trailing whitespace                                                  | 🎨    | 🔧  |     |\n| [prefer-top-level-string-formats](docs/rules/prefer-top-level-string-formats.md)                 | Prefer top-level string format schemas over deprecated `z.string().<format>()` methods                                         | ✅ 🔒 | 🔧  |     |\n| [prefer-trim-before-string-length-checks](docs/rules/prefer-trim-before-string-length-checks.md) | Enforce `.trim()` is called before string length checks to ensure accurate validation                                          | 🔒    | 🔧  |     |\n| [prefer-tuple-over-array-length](docs/rules/prefer-tuple-over-array-length.md)                   | Prefer `z.tuple()` over a length-constrained `z.array()` so the length is preserved in the inferred type.                      | 🎨    | 🔧  |     |\n| [prefer-validate](docs/rules/prefer-validate.md)                                                 | Prefer boolean validation when only the success of parsing is used                                                             | 🎨    |     | 💡  |\n| [require-brand-type-parameter](docs/rules/require-brand-type-parameter.md)                       | Require type parameter on `.brand()` functions                                                                                 | ✅ 🔒 |     | 💡  |\n| [require-error-message](docs/rules/require-error-message.md)                                     | Enforce that custom refinements include an error message                                                                       | ✅ 🔒 | 🔧  |     |\n| [schema-error-property-style](docs/rules/schema-error-property-style.md)                         | Enforce consistent style for error messages in Zod schema validation (using ESQuery patterns)                                  | 🎨    |     |     |\n\n<!-- end auto-generated rules list -->\n\n## Installation\n\n### ESLint\n\nInstall `eslint` and `eslint-plugin-zod` using your preferred package manager:\n\n```shell\nnpm i --save-dev eslint eslint-plugin-zod\n```\n\n```shell\nyarn add --dev eslint eslint-plugin-zod\n```\n\n```shell\npnpm add --save-dev eslint eslint-plugin-zod\n```\n\n#### ESLint Configuration\n\n1. Import the plugin\n\n   ```ts\n   import eslintPluginZod from 'eslint-plugin-zod';\n   ```\n\n2. Add `recommended` config to your ESLint setup\n\n   ```ts\n   eslintPluginZod.configs.recommended,\n   ```\n\nHere's a minimal example using the flat config format:\n\n```ts\n// eslint.config.js\nimport { defineConfig } from 'eslint/config';\nimport eslint from '@eslint/js';\nimport eslintPluginZod from 'eslint-plugin-zod';\n\nexport default defineConfig(eslint.configs.recommended, eslintPluginZod.configs.recommended);\n```\n\n### Oxlint\n\nInstall `oxlint` and `eslint-plugin-zod` using your preferred package manager:\n\n```shell\nnpm i --save-dev oxlint eslint-plugin-zod\n```\n\n```shell\nyarn add --dev oxlint eslint-plugin-zod\n```\n\n```shell\npnpm add --save-dev oxlint eslint-plugin-zod\n```\n\n#### Oxlint Configuration\n\n1. Import the plugin\n\n   ```ts\n   import eslintPluginZod from 'eslint-plugin-zod';\n   ```\n\n2. Add `eslint-plugin-zod` to the `jsPlugins` key\n\n   ```ts\n   {\n     jsPlugins: ['eslint-plugin-zod'],\n     // ...\n   }\n   ```\n\n3. Add `eslintPluginZod.configs.recommended.rules` to your Oxlint config.\\\n   Alternatively you can specify the rules manually\n\nHere's a minimal example using the flat config format:\n\n```ts\n// oxlint.config.ts\nimport eslintPluginZod from 'eslint-plugin-zod';\nimport { defineConfig } from 'oxlint';\n\nexport default defineConfig({\n  jsPlugins: ['eslint-plugin-zod'],\n  rules: {\n    ...eslintPluginZod.configs.recommended.rules,\n  },\n});\n```\n\n## Configurations\n\n| Config        | Contents                                                             |\n| ------------- | -------------------------------------------------------------------- |\n| `recommended` | Rules catching bugs and deprecated APIs                              |\n| `strict`      | `recommended` plus stricter rules; use it in place of `recommended`  |\n| `stylistic`   | Style and consistency rules; layer it on top of either of the above  |\n| `all`         | Every non-deprecated rule; meant for discovery rather than daily use |\n\n`strict` already includes `recommended`, so enable one of the two, then add `stylistic` if you want it:\n\n```ts\nexport default defineConfig(\n  eslint.configs.recommended,\n  eslintPluginZod.configs.strict,\n  eslintPluginZod.configs.stylistic,\n);\n```\n\nThe same configs work in Oxlint through their `rules` key.\n\n## Zod peer dependency version\n\n`eslint-plugin-zod` is designed for projects that use `zod@^4`.\nWhile the plugin analyzes Zod schemas in your code,\nit doesn't import or depend on Zod at runtime.\nTo document this relationship without forcing installation,\nZod is declared as an optional peer dependency in the plugin's `package.json`.\n\nIf your project uses Zod v4, the plugin will automatically lint your schemas.\nIf you're not using Zod (for example, in a separate ESLint workspace), you don't need to install it.\n\n`eslint` and `oxlint` are optional peer dependencies too: a project runs one of the two linters, so the plugin cannot require either.\n","publish_time":1778480043568,"_cnpm_publish_time":1778480043568,"dist-tags":{"latest":"5.2.2"}}