feat: add ESLint flat config, Prettier, dependency-cruiser, and Husky
Setup code quality tooling for the monorepo: - ESLint 9 flat config with TypeScript, import ordering, and NestJS rules - Prettier with consistent formatting across all files - dependency-cruiser enforcing module boundary rules (no cross-module internals, no circular deps) - Husky + lint-staged for pre-commit hooks - Auto-fixed existing files for type imports and import ordering Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
79
.dependency-cruiser.cjs
Normal file
79
.dependency-cruiser.cjs
Normal file
@@ -0,0 +1,79 @@
|
||||
/** @type {import('dependency-cruiser').IConfiguration} */
|
||||
module.exports = {
|
||||
forbidden: [
|
||||
// No circular dependencies
|
||||
{
|
||||
name: 'no-circular',
|
||||
severity: 'error',
|
||||
comment: 'Circular dependencies are not allowed.',
|
||||
from: {},
|
||||
to: { circular: true },
|
||||
},
|
||||
|
||||
// Modules must not import internals of other modules directly.
|
||||
// Only import via the module's public barrel (index.ts).
|
||||
{
|
||||
name: 'no-cross-module-internals',
|
||||
severity: 'error',
|
||||
comment:
|
||||
'Modules must not import internal files of other modules. Import from the module index (barrel) instead.',
|
||||
from: {
|
||||
path: 'src/modules/([^/]+)/',
|
||||
},
|
||||
to: {
|
||||
path: 'src/modules/([^/]+)/.+',
|
||||
pathNot: [
|
||||
// Allow importing from the module's own files
|
||||
'src/modules/$1/',
|
||||
// Allow importing from another module's barrel index
|
||||
'src/modules/[^/]+/index\\.ts$',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
// Apps should not import module internals either
|
||||
{
|
||||
name: 'no-app-to-module-internals',
|
||||
severity: 'error',
|
||||
comment: 'Apps must import modules via their barrel index, not internal files.',
|
||||
from: {
|
||||
path: 'apps/',
|
||||
},
|
||||
to: {
|
||||
path: 'src/modules/([^/]+)/.+',
|
||||
pathNot: ['src/modules/[^/]+/index\\.ts$'],
|
||||
},
|
||||
},
|
||||
|
||||
// No orphan modules (files not reachable from any entry point)
|
||||
{
|
||||
name: 'no-orphans',
|
||||
severity: 'warn',
|
||||
comment: 'Orphan modules may indicate dead code.',
|
||||
from: {
|
||||
orphan: true,
|
||||
pathNot: ['\\.(spec|test)\\.ts$', '__tests__/', '\\.d\\.ts$', 'index\\.ts$'],
|
||||
},
|
||||
to: {},
|
||||
},
|
||||
],
|
||||
|
||||
options: {
|
||||
doNotFollow: {
|
||||
path: ['node_modules', '\\.next', 'dist'],
|
||||
},
|
||||
tsPreCompilationDeps: true,
|
||||
tsConfig: {
|
||||
fileName: 'tsconfig.base.json',
|
||||
},
|
||||
enhancedResolveOptions: {
|
||||
exportsFields: ['exports'],
|
||||
conditionNames: ['import', 'require', 'node', 'default'],
|
||||
},
|
||||
reporterOptions: {
|
||||
text: {
|
||||
highlightFocused: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user