Description
We should detect whether module classes that return a DynamicModule are named register, registerAsync, forRoot or forRootAsync.
Acceptance Criteria
Incorrect:
@Module({})
export class ProductsModule {
static create(options): DynamicModule { // ⚠️ `Dynamic module methods must be named `register/registerAsync` or `forRoot/forRootAsync`
return {
module: ProductsModule,
imports: [TypeOrmModule.forFeature([Product]),
providers: [/* ... */],
}
}
static registerAsync(options): DynamicModule { // ✅
return {
module: ProductsModule,
imports: [TypeOrmModule.forFeature([Product]),
providers: [/* ... */],
}
}
}
Correct:
@Module({})
export class ProductsModule {
static register(options): DynamicModule { // ✅
return {
module: ProductsModule,
imports: [TypeOrmModule.forFeature([Product]),
providers: [/* ... */],
}
}
static registerAsync(options): DynamicModule { // ✅
return {
module: ProductsModule,
imports: [TypeOrmModule.forFeature([Product]),
providers: [/* ... */],
}
}
}