rules:
- name: NestJS structure
rule: Always follow the standard NestJS structure: use modules, controllers, services, and providers. Keep each responsibility in its proper layer.
globs: "**/*.ts"
- name: TypeScript best practices
rule: Always use TypeScript interfaces or classes for DTOs and response types. Use type aliases only for unions or simple types.
globs: "**/*.ts"
- name: Dependency injection
rule: Always inject services using NestJS's constructor-based dependency injection. Avoid using manual instantiation or static classes.
globs: "**/*.ts"
- name: Exception handling
rule: Use NestJS's built-in HttpException and ExceptionFilter classes to handle errors. Avoid using raw error throws without proper mapping.
globs: "**/*.ts"
- name: Testing patterns
rule: In NestJS tests, use Jest's describe/it pattern. Use TestingModule and Test.createTestingModule() to set up unit tests with dependency injection.
globs:
- "src/**/*.spec.ts"
- "tests/**/*.ts"
- name: Logging
rule: Use NestJS Logger for logging instead of console.log. Provide meaningful context in logs.
globs: "**/*.ts"
- name: Validation
rule: Always use class-validator decorators (e.g., @IsString, @IsInt) on DTOs and enable validation pipes globally.
globs: "**/*.ts"
- name: Use NestJS CLI
rule: Always use the NestJS CLI (e.g., `nest generate`, `nest g`) for generating modules, controllers, services, providers, and other scaffolding.
Do not manually create files or boilerplate code.
Ensure CLI-generated code follows the correct naming conventions and folder structure.
globs: "**/*.ts"