darraghoriordan / eslint-plugin-nestjs-typed

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

param-decorator-name-matches-route-param: why does it fails in this case? #110

Closed micalevisk closed 11 months ago

micalevisk commented 11 months ago

image

can you clarify in the docs why the above isn't valid? I seems to be a valid usage to me when thinking of apps that are slowly migrating to nestjs from express, or in edge-cases where we can't avoid the @Request() decorator somehow

darraghoriordan commented 11 months ago

This is literally why this rule exists. It's a bit confusing to use the @Param decorator the first time(s).

In NestJS you do not put ":" in the @Param decorator, instead you use the id only e.g. uuid in your case. See the example here: https://docs.nestjs.com/controllers#route-parameters

@Get(':id')
findOne(@Param('id') id: string): string {
  return `This action returns a #${id} cat`;
}