Registry / devops / eslint-plugin-zod-openapi

eslint-plugin-zod-openapi

JSON →
library2.0.0jsnpmunverified

ESLint plugin providing custom lint rules for projects using zod-openapi, which extends Zod with OpenAPI metadata. Version 2.0.0 requires Node >=16.11 and ships TypeScript types. It enforces best practices like requiring `.meta()`, JSDoc comments, and examples on Zod types, and provides auto-fixable rules. Differentiates from generic ESLint plugins by being purpose-built for zod-openapi's `.meta()` chain pattern. Released via GitHub Releases with manual tagging.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The plugin should be referenced by name 'zod-openapi' in the plugins array, not required directly. Configuration is done via rules object.

module.exports = { plugins: ['zod-openapi'] }

Rule names are prefixed with 'zod-openapi/' in the rules object. Forgetting the prefix will not apply the rule.

rules: { 'zod-openapi/require-meta': 'error' }

Rule does not accept options. The fix is auto-applied with --fix.

rules: { 'zod-openapi/require-comment': 'error' }

Typical usage is as warn; severity can be adjusted per project.

rules: { 'zod-openapi/prefer-zod-default': 'warn' }

ESLint configuration enabling all zod-openapi rules with overrides for API type files.

// .eslintrc.js module.exports = { plugins: ['zod-openapi'], rules: { 'zod-openapi/require-meta': 'error', 'zod-openapi/require-comment': 'error', 'zod-openapi/require-example': 'warn', 'zod-openapi/prefer-meta-last': 'warn', 'zod-openapi/prefer-zod-default': 'warn', }, overrides: [ { files: ['src/api-types/*.ts'], rules: { 'zod-openapi/require-meta': 'error', }, }, ], };
Debug
Known footguns
gotchaRule names must be prefixed with 'zod-openapi/' in the rules object, e.g., 'zod-openapi/require-meta'. Omitting the prefix will silently fail to apply the rule.
gotchaThe plugin expects all Zod objects to use zod-openapi's `.meta()` method. If used with plain Zod objects without `.meta()`, the 'require-meta' rule will flag errors unless you scope it via overrides.
breakingVersion 2.0.0 drops support for Node <16.11. Projects on older Node versions will see install/run failures.
deprecatedThe 'require-comment' rule auto-fixes missing descriptions but may need JSDoc comment style adjustments; it is generally safe but could conflict with other comment rules.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
ahrefsbot
2
Resources