Giter VIP home page Giter VIP logo

eslint-plugin-zod-openapi's Introduction

eslint-plugin-zod-openapi

This is a set of Eslint rules created for use with zod-openapi. This aims to optimise the overall developer experience with a little sprinkle of magic โœจ.

npm version npm downloads Node.js version Powered by skuba

Installation

To install simply run on yarn, npm or pnpm

yarn add -D eslint-plugin-zod-openapi
# or
npm i -D eslint-plugin-zod-openapi
# or
pnpm i -D eslint-plugin-zod-openapi

Add the following configuration to your .eslintrc file

{
  "plugins": ["zod-openapi"]
}
{
  "rules": {
    "zod-openapi/require-openapi": "error"
    "zod-openapi/require-comment": "error",
    "zod-openapi/prefer-zod-default": "warn",
  }
}

You may wish to use overrides as this plugin by default will assume that all Zod Objects are using zod-openapi.

"overrides": [
    {
      "files": ["src/api-types/*.ts"],
      "rules": {
        "zod-openapi/require-openapi": "error"
      }
    }
  ]

Rules

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

Name Description ๐Ÿ”ง
require-openapi Requires that all ZodTypes have an .openapi() method.
require-comment Requires that all ZodTypes have a description and matching JSDoc comment. โœ…
require-example Requires that all ZodTypes have an example or examples field.
prefer-openapi-last Prefers that the .openapi() method be the last method in the ZodType chain.
prefer-zod-default Provides an error when default in .openapi() is used

Development

Test

pnpm test

Lint

# Fix issues
pnpm format

# Check for issues
pnpm lint

Release

To release a new version

  1. Create a new GitHub Release
  2. Select ๐Ÿท๏ธ Choose a tag, enter a version number. eg. v1.2.0 and click + Create new tag: vX.X.X on publish.
  3. Click the Generate release notes button and adjust the description.
  4. Tick the Set as the latest release box and click Publish release. This will trigger the Release workflow.
  5. Check the Pull Requests tab for a PR labelled Release vX.X.X.
  6. Click Merge Pull Request on that Pull Request to update master with the new package version.

To release a new beta version

  1. Create a new GitHub Release
  2. Select ๐Ÿท๏ธ Choose a tag, enter a version number with a -beta.X suffix eg. v1.2.0-beta.1 and click + Create new tag: vX.X.X-beta.X on publish.
  3. Click the Generate release notes button and adjust the description.
  4. Tick the Set as a pre-release box and click Publish release. This will trigger the Prerelease workflow.

eslint-plugin-zod-openapi's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar samchungy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

eslint-plugin-zod-openapi's Issues

Error on objects

Hi, I don't know if it's the right thing to do or not, but I think this plugin should not throw an error to every key of a zod object if the object itself has the .openapi method declared.
For example:
image
This should not occur in my opinion. Let me know what you think!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.