34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import { base } from '../../eslint.config.mjs';
|
|
|
|
// Backend architecture layering (route → service → repository → db), enforced
|
|
// with path-based no-restricted-imports. Boundaries' element model is folder-
|
|
// oriented and our feature modules are flat files, so we enforce the key edges
|
|
// directly and reliably:
|
|
// - routes may NOT import repositories or the db layer (must go via a service)
|
|
// - services may NOT import the db layer (must go via a repository)
|
|
// - only repositories (and the db plugin) touch src/db
|
|
const noDbLayer = {
|
|
group: ['**/db', '**/db/*'],
|
|
message: 'Only repositories may access the db layer — go through a repository.',
|
|
};
|
|
const noRepository = {
|
|
group: ['**/*.repository'],
|
|
message: 'Routes must go through a service, not a repository directly.',
|
|
};
|
|
|
|
export default [
|
|
{ ignores: ['dist/**', 'migrations/**'] },
|
|
...base,
|
|
{
|
|
files: ['src/modules/*/*.routes.ts'],
|
|
rules: {
|
|
'no-restricted-imports': ['error', { patterns: [noRepository, noDbLayer] }],
|
|
},
|
|
},
|
|
{
|
|
files: ['src/modules/*/*.service.ts'],
|
|
rules: {
|
|
'no-restricted-imports': ['error', { patterns: [noDbLayer] }],
|
|
},
|
|
},
|
|
];
|