npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-nest-swagger-checker-lint

v1.0.7

Published

nest-swagger-checker-linter is linter version of [nest-swagger-checker](https://github.com/ozkersemih/nest-swagger-checker) package to use it as ESLint rule.

Downloads

303

Readme

nest-swagger-checker-linter

nest-swagger-checker-linter is linter version of nest-swagger-checker package to use it as ESLint rule.

This package uses nsc(nest-swagger-checker) package inside its own.

configuration

Like nsc package, this linter package can be configured by using .swautomaterc file at the root path of project. You can see detail of configuration

setup

Like other eslint plugins, this plugin needs to be added to eslintrc configuration.

// .eslintrc.json file in project
...
"plugins": [
  "nest-swagger-checker-lint"
],
...
"rules": {
  "nest-swagger-checker-lint/api-property-rule": "error",
  "nest-swagger-checker-lint/api-information-rule": "error",
  "nest-swagger-checker-lint/api-param-rule": "error",
....
}

examples

  • Lets assume you have endpoint method in a controller like below:

    @Post('')
    @HttpCode(HttpStatus.OK)
    ..
    @AnotherDecorator()
    public async create(
      ...
    )

    You will get eslint error because there is no ApiOperation decorator ta describe summary and description for endpoint.

    Error should be like below: Screenshot 2024-05-19 at 17 28 19 💡 You can enable/disable this checking by setting scopes.endpoint.information.check config value


  • There is a request param for endpoint method in below example but name in ApiParam decorator does not match with it.

    ....
    @ApiParam({ name: 'customerId', description: 'Customer ID', type: Number, example: 60 })
    async getCount(@Param('userId') userId: string, @Query() parameters: Parameters): Promise<Count> {
      return this.service.getCount(Number(userId), parameters);
    }
    ...

    You will get eslint error like below. Screenshot 2024-05-20 at 23 29 52 💡 You can enable/disable this checking by setting scopes.endpoint.params.check config value


  • If you have request parameter that given with @Param decorator like above but you don't have any @ApiParam decorator, you will also get eslint error.

    ....
    @ApiResponse({ status: HttpStatus.BAD_REQUEST, description: 'Request Is Not Valid' })
    @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'An Error Occurred' })
    async getCount(@Param('userId') userId: string, @Query() parameters: Paramters): Promise<Count> {
      return this.affiliateAdService.getCount(Number(userId), searchParameters);
    }

    Screenshot 2024-05-20 at 23 33 42 💡 You can enable/disable this checking by setting scopes.endpoint.params.check config value


  • Lets assume you have a custom query class type for your endpoint endpoint method like below:

     async getCount(..., @Query() parameters: Parameters): Promise<Count> {
      return this.service.getCount(Number(sellerId), parameters);
    }
    ....
    export class SearchParametersDto {
    @IsInt()
    @IsOptional()
    @IsPositive()
    @Type(() => Number)
    @ApiProperty({
      type: Number,
      description: 'Pagination Index, Default: 1',
      example: 1,
      required: false,
    })
    public pageIndex?: number;
    ....

    If you gave pattern something like that ^[A-Z][a-z0-9]*(?:\s[a-z0-9]*)*$, you will give eslint error because your description text should be match with your pattern.

    In this example, only first words first letter should be uppercase according to example pattern. Eslint error will be like below: Screenshot 2024-05-20 at 23 50 40 💡 You can enable/disable this checking by setting scopes.endpoint.query.description.check config value and you can set pattern by setting scopes.endpoint.query.description.pattern value.