import { baseConfig } from './base.js'; /** * NestJS config. * * The two rules that matter architecturally: * 1. Only the persistence layer may import PrismaService / Redis directly. * 2. A module must not deep-import another module's internals — cross-module * access goes through the other module's public surface (`/public`). * * @type {import("eslint").Linter.Config[]} */ export const nestConfig = [ ...baseConfig, { files: ['**/*.ts'], rules: { /** * OFF, and it must stay off. * * Nest resolves constructor dependencies from `emitDecoratorMetadata`, * which requires the parameter's type to survive as a *value* import. * This rule cannot tell an injected class from a pure type, so its * autofix silently rewrites `import { PrismaService }` into * `import { type PrismaService }` — which compiles cleanly and then * fails at runtime with "Nest can't resolve dependencies". * * The same reasoning is why `verbatimModuleSyntax` is disabled in * @sport/config/typescript/nestjs.json. */ '@typescript-eslint/consistent-type-imports': 'off', // Nest relies on parameter decorators and class-based DI. '@typescript-eslint/no-extraneous-class': 'off', '@typescript-eslint/no-empty-object-type': 'off', 'no-console': 'error', 'no-restricted-imports': [ 'error', { patterns: [ { /** * Two things may cross a module boundary and nothing else: * * - `.module` — the NestJS module class, so it can be * listed in another module's `imports`. Wiring the DI graph is * exactly what a modular monolith is supposed to allow. * - `/public` — the curated public surface. * * Everything else — repositories, mappers, DTOs, internal * services — stays private. */ group: ['@/modules/*/*', '!@/modules/*/public', '!@/modules/*/*.module'], message: 'Cross-module deep imports are forbidden. Import `@/modules//public` for behaviour, or `@/modules//.module` to wire it into your module.', }, ], }, ], }, }, { // Decorated DTO / entity classes legitimately have empty bodies. files: ['**/*.dto.ts', '**/*.entity.ts'], rules: { '@typescript-eslint/no-extraneous-class': 'off' }, }, ]; export default nestConfig;