import nx from '@nx/eslint-plugin'; export default [ ...nx.configs['flat/base'], ...nx.configs['flat/typescript'], ...nx.configs['flat/javascript'], { ignores: ['**/dist', '**/out-tsc', '**/vitest.config.*.timestamp*'], }, { files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], rules: { '@nx/enforce-module-boundaries': [ 'error', { enforceBuildableLibDependency: true, allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?[jt]s$'], depConstraints: [ // Hexagonal layers: dependencies only point inwards. { // Pure model. Only @nestjs/common (@Injectable factories) and // @nestjs/cqrs (AggregateRoot) are allowed. sourceTag: 'type:domain', onlyDependOnLibsWithTags: ['type:domain'], bannedExternalImports: [ '@nestjs/core', '@nestjs/config', '@nestjs/typeorm', '@nestjs/mongoose', '@nestjs/graphql', '@nestjs/apollo', 'typeorm', 'mongoose', 'ioredis', 'graphql*', 'pg', '@angular/*', '@ngrx/*', '@apollo/*', 'apollo-angular', '@pi/ui', ], }, { // Use cases: services + CQRS handlers + ports. sourceTag: 'type:application', onlyDependOnLibsWithTags: ['type:domain', 'type:application'], bannedExternalImports: [ 'typeorm', 'mongoose', 'ioredis', 'graphql*', 'pg', '@nestjs/typeorm', '@nestjs/mongoose', '@nestjs/graphql', '@apollo/*', 'apollo-angular', '@pi/ui', ], }, { // Driving adapters (GraphQL, HTTP): talk to application services only. sourceTag: 'type:presenters', onlyDependOnLibsWithTags: [ 'type:domain', 'type:application', 'type:presenters', ], bannedExternalImports: [ 'typeorm', 'mongoose', 'ioredis', 'pg', '@nestjs/typeorm', '@nestjs/mongoose', '@nestjs/cqrs', 'graphql-redis-subscriptions', '@apollo/*', 'apollo-angular', ], }, { // Driven adapters (Postgres, Mongo, Redis, Pireon). Never presenters. sourceTag: 'type:infrastructure', onlyDependOnLibsWithTags: [ 'type:domain', 'type:application', 'type:infrastructure', ], }, { sourceTag: 'type:app', onlyDependOnLibsWithTags: ['*'], }, // API (NestJS) bounded contexts. Never depend on the web client. { sourceTag: 'scope:api', onlyDependOnLibsWithTags: ['scope:api-shared', 'scope:api-identity', 'scope:api-tracker'], }, { sourceTag: 'scope:api-shared', onlyDependOnLibsWithTags: ['scope:api-shared'], }, { sourceTag: 'scope:api-identity', onlyDependOnLibsWithTags: ['scope:api-identity', 'scope:api-shared'], }, { sourceTag: 'scope:api-tracker', onlyDependOnLibsWithTags: ['scope:api-tracker', 'scope:api-identity', 'scope:api-shared'], }, // Web client (Angular). Never depends on backend libraries. { sourceTag: 'scope:web', onlyDependOnLibsWithTags: ['scope:web-shared', 'scope:web-identity', 'scope:web-tracker'], }, { sourceTag: 'scope:web-shared', onlyDependOnLibsWithTags: ['scope:web-shared'], }, { sourceTag: 'scope:web-identity', onlyDependOnLibsWithTags: ['scope:web-identity', 'scope:web-shared'], }, { sourceTag: 'scope:web-tracker', onlyDependOnLibsWithTags: ['scope:web-tracker', 'scope:web-identity', 'scope:web-shared'], }, ], }, ], }, }, { files: [ '**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts', '**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs', ], rules: { '@typescript-eslint/no-unused-vars': [ 'warn', { ignoreRestSiblings: true, argsIgnorePattern: '^_', varsIgnorePattern: '^_', }, ], }, }, ];