Skip to content

NestJS

The nestjs configuration adds the rules of eslint-plugin-nestjs-typed, two patterns for the response object and module cycles, and the compiler options that decorators need. Its rules run in javascript/eslint and typescript/tsconfig.

When a scope uses nestjs, typescript/tsconfig requires experimentalDecorators and emitDecoratorMetadata in each tsconfig that you write. For a scope without a tsconfig, gspot writes one that turns both on.

javascript/eslint runs the flatRecommended preset of eslint-plugin-nestjs-typed on the TypeScript files of the scope, without the Swagger rules when the scope does not depend on @nestjs/swagger. It also reports an @Injectable() class that no module lists in its providers, and lets a class with a decorator have no members. Level all adds @darraghor/nestjs-typed/api-operation-summary-description-capitalized.

The gspot/restricted-syntax rule reports two patterns:

Pattern Level Message
@Res() or @Response() without passthrough Both Taking the response object turns off interceptors and the return value. Return the value, or pass { passthrough: true }.
A forwardRef() call all forwardRef hides a cycle between two modules that import each other. Move what both need into a third module.

At level all, gspot reports functions and files that do almost nothing, and *.module.ts files do not count, because a Nest module is an empty decorated class. Level all also reports sibling files that share a name prefix, and Nest files such as users.controller.ts and users.service.ts do not count.