refactor: expose upcoming-events public api and guard its boundary (WealthLedger/backend#163)
This commit is contained in:
+23
-15
@@ -15,6 +15,18 @@ import globals from 'globals';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
const tests = ['**/*.spec.ts', 'test/**/*.ts'];
|
||||
const guardedModules = [
|
||||
{
|
||||
name: 'tbank-sync',
|
||||
except: [
|
||||
'./tbank-sync.api.ts',
|
||||
'./tbank-sync.dto.ts',
|
||||
'./tbank-sync.module.ts',
|
||||
'./tbank-sync-repository.module.ts',
|
||||
],
|
||||
},
|
||||
{ name: 'upcoming-events', except: ['./upcoming-events.api.ts', './upcoming-events.module.ts'] },
|
||||
];
|
||||
const prismaImports = [
|
||||
'@prisma/*', '**/generated/prisma/**', '**/prisma.service',
|
||||
];
|
||||
@@ -212,24 +224,20 @@ export default defineConfig(
|
||||
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['src/**/*.ts'],
|
||||
ignores: [...tests, 'src/modules/investments/tbank-sync/**'],
|
||||
// Separate rule so it does not replace layer-specific no-restricted-imports configs.
|
||||
// A module may import its own internals, so each guarded module gets a block without its zone.
|
||||
...[undefined, ...guardedModules].map((own) => ({
|
||||
files: own ? [`src/modules/investments/${own.name}/**/*.ts`] : ['src/**/*.ts'],
|
||||
ignores: own ? tests : [...tests, ...guardedModules.map(({ name }) => `src/modules/investments/${name}/**`)],
|
||||
rules: {
|
||||
// Separate rule so it does not replace layer-specific no-restricted-imports configs.
|
||||
'import-x/no-restricted-paths': ['error', {
|
||||
zones: [{
|
||||
zones: guardedModules.filter((module) => module !== own).map(({ except, name }) => ({
|
||||
target: './src',
|
||||
from: './src/modules/investments/tbank-sync',
|
||||
except: [
|
||||
'./tbank-sync.api.ts',
|
||||
'./tbank-sync.dto.ts',
|
||||
'./tbank-sync.module.ts',
|
||||
'./tbank-sync-repository.module.ts',
|
||||
],
|
||||
message: 'Use tbank-sync.api for cross-module access.',
|
||||
}],
|
||||
from: `./src/modules/investments/${name}`,
|
||||
except,
|
||||
message: `Use ${name}.api for cross-module access.`,
|
||||
})),
|
||||
}],
|
||||
},
|
||||
},
|
||||
})),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user