Skip to content

Controller parameters ordering

Choose a tag to compare

@rcupic rcupic released this 10 Apr 12:55
· 7 commits to main since this release
573f9c8

Only NestJS controller files are linted.
Only controller function parameters are linted.
Parameters are linted only if all parameters have decorator.
Custom parameters are last and ordered by name ascending.

// Bad
public findAll(
  @Req() req: ProficoRequest,
  @Query() queryParams: QueryParams,
  @Custom2() customParam2: CustomParam,
  @Custom1() customParam1: CustomParam,
) {
  return this.service.find();
}

// Good
public findAll(
  @Query() queryParams: QueryParams,
  @Req() req: ProficoRequest,
  @Custom1() customParam1: CustomParam,
  @Custom2() customParam2: CustomParam,
) {
  return this.service.find();
}