Skip to content

no unused route params

github-actions[bot] edited this page Apr 7, 2024 · 1 revision

Disallow unused route parameters (nestjs-pedantic/no-unused-route-params)

💼 This rule is enabled in the following configs: 🌐 all, ✅ recommended.

💡 This rule is manually fixable by editor suggestions.

Rule Details

Incorrect code:

@Controller("user")
class UserController {
  @Get(":id")
  getById() {}

  @Put("details/:id")
  putDetailsById() {}

  @Post("other/:userId")
  postOtherByUserId() {}
}

Corrrect code:

@Controller("user")
class UserController {
  @Get(":id")
  getById(@Param("id") id: string) {}

  @Put("details")
  putDetails() {}

  @Post("other/:userId")
  postOtherByUserId(@Param() params: Record<string, string>) {}
}