-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path.dependency-cruiser.js
More file actions
85 lines (83 loc) · 3.02 KB
/
Copy path.dependency-cruiser.js
File metadata and controls
85 lines (83 loc) · 3.02 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
/** @type {import('dependency-cruiser').IConfiguration} */
// dependency-cruiser runs with tsPreCompilationDeps disabled, so modules only referenced by
// `import type`/`export type` are intentionally classified here instead of hidden by a broad glob.
const TYPE_ONLY_ORPHAN_MODULES = [
String.raw`^packages/config/src/lib/types\.ts$`,
String.raw`^packages/embedex/src/lib/internal/types\.ts$`,
String.raw`^packages/embedex/src/lib/types\.ts$`,
String.raw`^packages/execution-context/src/types/types\.ts$`,
String.raw`^packages/json-api-nestjs/src/lib/types\.ts$`,
String.raw`^packages/json-api/src/lib/types\.ts$`,
String.raw`^packages/mongo-jobs/src/lib/handler\.ts$`,
String.raw`^packages/mongo-jobs/src/lib/internal/logger\.ts$`,
String.raw`^packages/mongo-jobs/src/lib/internal/worker/queueConsumer\.ts$`,
String.raw`^packages/oxlint-config/src/internal/types\.ts$`,
String.raw`^packages/phone-number/src/lib/types\.ts$`,
String.raw`^packages/playwright-reporter-llm/src/lib/types\.ts$`,
String.raw`^packages/rules-engine/src/lib/rule\.ts$`,
String.raw`^packages/util-ts/src/lib/logger\.ts$`,
String.raw`^packages/util-ts/src/lib/types\.ts$`,
];
// Files that are valid package entry/subentry/test-support files without static runtime edges.
const INTENTIONAL_ORPHAN_MODULES = [
String.raw`^packages/eslint-config/src/react\.js$`,
String.raw`^packages/mongo-jobs/src/lib/testing\.ts$`,
String.raw`^packages/nx-plugin/src/index\.ts$`,
];
module.exports = {
forbidden: [
{
name: "no-circular",
severity: "error",
comment: "No circular dependencies",
from: {},
to: { circular: true },
},
{
name: "no-orphans",
severity: "error",
comment: "Modules should be reachable from an entry point",
from: {
orphan: true,
pathNot: [
String.raw`\.(spec|test)\.ts$`,
String.raw`\.d\.ts$`,
String.raw`jest\.config\.ts$`,
...TYPE_ONLY_ORPHAN_MODULES,
...INTENTIONAL_ORPHAN_MODULES,
],
},
to: {},
},
{
name: "no-reaching-inside-packages",
severity: "error",
comment:
"Don't import from inside another package's internal files — use the public API (@clipboard-health/*)",
from: { path: "^packages/([^/]+)/" },
to: {
path: "^packages/([^/]+)/src/",
pathNot: [
// Allow imports within the same package
"^packages/$1/",
// Allow imports to a package's public API (index.ts)
String.raw`^packages/[^/]+/src/index\.ts$`,
],
},
},
],
options: {
doNotFollow: { path: "node_modules" },
tsPreCompilationDeps: false,
tsConfig: { fileName: "tsconfig.base.json" },
enhancedResolveOptions: {
exportsFields: ["exports"],
conditionNames: ["import", "require", "node", "default"],
mainFields: ["main", "types", "typings"],
},
reporterOptions: {
dot: { collapsePattern: "node_modules/(@[^/]+/[^/]+|[^/]+)" },
text: { highlightFocused: true },
},
},
};