-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.dependency-cruiser.cjs
More file actions
74 lines (74 loc) · 2.17 KB
/
Copy path.dependency-cruiser.cjs
File metadata and controls
74 lines (74 loc) · 2.17 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
/** @type {import('dependency-cruiser').IConfiguration} */
module.exports = {
forbidden: [
{
name: "no-circular",
severity: "warn",
comment:
"Circular dependencies make code hard to reason about and refactor. " +
"Break cycles by extracting shared types/helpers.",
from: {},
to: { circular: true },
},
{
name: "no-orphans",
severity: "warn",
comment:
"Orphan modules (not reachable from any entry) are typically dead code. " +
"Either wire them up or delete them.",
from: {
orphan: true,
pathNot: [
"(^|/)\\.[^/]+\\.(js|cjs|mjs|ts|cts|mts|json)$",
"\\.d\\.ts$",
"(^|/)tsconfig\\.json$",
"(^|/)tsdown\\.config\\.(js|cjs|mjs|ts|cts|mts|json)$",
"(^|/)src/lib/build-info\\.gen\\.ts$",
"(^|/)src/pages/usage-viewer\\.gen\\.ts$",
"(^|/)src/pages/.+",
],
},
to: {},
},
{
name: "not-to-test",
severity: "error",
comment:
"Production code should not depend on test fixtures or specs.",
from: { pathNot: "^(tests|src/.+\\.test\\.ts$)" },
to: { path: "^(tests|src/.+\\.test\\.ts$)" },
},
{
name: "no-route-imports-from-lib-or-services",
severity: "error",
comment:
"Layering rule per CLAUDE.md: routes -> services -> lib. " +
"Modules under src/lib and src/services must not import from src/routes.",
from: { path: "^src/(lib|services)/" },
to: { path: "^src/routes/" },
},
],
options: {
doNotFollow: {
path: ["node_modules"],
},
tsConfig: {
fileName: "tsconfig.json",
},
tsPreCompilationDeps: true,
enhancedResolveOptions: {
exportsFields: ["exports"],
conditionNames: ["import", "require", "node", "default", "types"],
mainFields: ["module", "main", "types", "typings"],
},
reporterOptions: {
dot: {
collapsePattern: "node_modules/(?:@[^/]+/[^/]+|[^/]+)",
},
archi: {
collapsePattern:
"^(?:packages|src|lib|app|bin|test(?:s?)|spec(?:s?))/[^/]+|node_modules/(?:@[^/]+/[^/]+|[^/]+)",
},
},
},
}