darraghoriordan / eslint-plugin-nestjs-typed

Some eslint rules for working with NestJs projects
http://www.darraghoriordan.com
171 stars 34 forks source link

Should ignore non-verifiable types - param-decorator-name-matches-route-param #69

Open kurt-west opened 1 year ago

kurt-west commented 1 year ago

Currently this rule will skip if the parameter is of type Identifier or TemplateLiteral. Along the same lines, I believe it should skip if the parameter is of type MemberExpression (Enum or Static Class Method).

For example, the below will trigger an error.

enum AppRoutes {
  Root = 'app',
  VerifyParams = ':id',
}

@Controller(AppRoutes.Root)
export class AppController {

  @Post(AppRoutes.VerifyParams)
  verifyParams(@Param('id', ParseUUIDPipe) id: string): VerifyParamsResponseDto {
    return new VerifyParamsResponseDto({ token: id });
  }
}

Another option would be to skip if the parameter is not of type Literal, ArrayExpression, or ObjectExpression.