-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.dependency-cruiser.cjs
More file actions
129 lines (129 loc) · 3.31 KB
/
.dependency-cruiser.cjs
File metadata and controls
129 lines (129 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* Dependency Cruiser Configuration
*
* Validates architectural boundaries and prevents problematic dependency patterns
* across the monorepo. Rules enforce circular dependency prevention, orphan detection,
* test isolation, production/dev dependency separation, and module system consistency.
*
* Each rule's `comment` field documents its purpose.
*
* Usage:
* nx run <project>:dependency-analysis
*
* CI: Runs automatically via .github/workflows/dependency-analysis.yml
* (on PRs affecting source files + weekly scheduled run)
*
* @type {import('dependency-cruiser').IConfiguration}
* @see https://github.com/sverweij/dependency-cruiser
*/
module.exports = {
forbidden: [
{
name: "no-circular",
severity: "error",
comment: "Circular dependencies cause maintenance issues",
from: {},
to: {
circular: true,
},
},
{
name: "no-orphans",
severity: "warn",
comment: "Orphaned files may indicate dead code",
from: {
orphan: true,
pathNot: [
"(^|/)\\.[^/]+\\.(js|cjs|mjs|ts|cts|mts|json)$",
"(^|/)package\\.json$",
"(^|/)tsconfig\\.json$",
"\\.d\\.ts$",
"^applications/.+/project\\.json$",
"^applications/.+/vitest\\.config\\.ts$",
"^documentation/.*\\.md$",
"^packages/.+/project\\.json$",
"^planning/.*\\.md$",
"^scripts/.*\\.sh$",
"^tools/.+/project\\.json$",
],
},
to: {},
},
{
name: "no-test-imports-in-app",
severity: "error",
comment: "Application code should not import test utilities",
from: {
pathNot: "\\.test\\.(ts|tsx)$",
},
to: {
path: "(^|/)(testing|__tests__|__mocks__)/",
},
},
{
name: "not-to-dev-dep",
severity: "error",
comment: "Production code should not depend on devDependencies",
from: {
path: "^applications",
pathNot: [
"\\.test\\.(ts|tsx)$",
"\\.spec\\.(ts|tsx)$",
"(^|/)testing/",
"(^|/)tests/",
"(^|/)__tests__/",
"(^|/)__mocks__/",
"(^|/)vitest\\.config",
"(^|/)vite\\.config",
],
},
to: {
dependencyTypes: ["npm-dev"],
pathNot: ["node_modules/@types/"],
},
},
{
name: "no-esm-in-cjs",
severity: "error",
comment: "Don't import ESM in CommonJS files",
from: {
path: "\\.cjs$",
},
to: {
path: "\\.mjs$",
},
},
],
options: {
doNotFollow: {
path: "node_modules",
},
exclude: {
path: [
// Build outputs should not be analyzed
"^dist/",
// Generator template files are not valid TS/JS
"/files/",
"__[a-zA-Z]+__",
// Auto-generated files may have circular deps
"\\.gen\\.(ts|tsx|js|jsx)$",
],
},
tsPreCompilationDeps: true,
tsConfig: {
fileName: "./tsconfig.base.json",
},
enhancedResolveOptions: {
exportsFields: ["exports"],
conditionNames: ["import", "require", "node", "default"],
},
reporterOptions: {
dot: {
collapsePattern: "^node_modules/[^/]+",
},
archi: {
collapsePattern: "^(applications|packages)/[^/]+",
},
},
},
};