-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy path.dependency-cruiser.cjs
More file actions
149 lines (141 loc) · 5.18 KB
/
.dependency-cruiser.cjs
File metadata and controls
149 lines (141 loc) · 5.18 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/** @type {import('dependency-cruiser').IConfiguration} */
module.exports = {
forbidden: [
// Rule 1: No circular dependencies
{
name: "no-circular",
severity: "error",
comment: "Circular dependencies cause tight coupling and make refactoring hard.",
from: {},
to: { circular: true },
},
// Rule 2: Stores must not import components
{
name: "stores-no-import-components",
severity: "error",
comment: "Data layer must not know about UI. Stores are leaf dependencies.",
from: { path: "^src/stores/" },
to: { path: "^src/components/" },
},
// Rule 3: utils/types/lib must not import plugins/components/stores
//
// Exempted files — verified "wiring" or "service" modules that inherently
// need cross-layer imports. New utils should stay pure; add exemptions here
// only after review.
{
name: "leaf-modules-stay-pure",
severity: "error",
comment:
"utils/, types/, and lib/ are leaf modules. They must not import from plugins/, components/, or stores/.",
from: {
path: "^src/(utils|types|lib)/",
pathNot: [
// Assembler files (wire plugins into editor configurations)
"src/utils/tiptapExtensions\\.ts$",
"src/utils/sourceEditorExtensions\\.ts$",
"src/utils/modeSwitchCleanup\\.ts$",
// File operation services (need store access for tab/document state)
"src/utils/activeDocument",
"src/utils/saveToPath",
"src/utils/newFile",
"src/utils/reloadFromDisk",
"src/utils/workspaceBootstrap",
// Large-file routing — reads settingsStore for autoSourceMode / warnAbove5MB
"src/utils/largeFileRouting",
// macOS quarantine auto-strip — reads settingsStore for clearMacQuarantineOnOpen toggle
"src/utils/macQuarantineNotice",
// Media path resolution (needs tab/document store for relative path resolution)
"src/utils/resolveMediaSrc",
// Startup wiring (rebuilds native menu with saved locale on boot)
"src/utils/startupMenuSync",
// Native menu rebuild pipeline (reads shortcuts, re-syncs recent files/workspaces)
"src/utils/rebuildNativeMenu",
// Editor services (bridge between editor internals and stores)
"src/utils/tiptapFocus",
"src/utils/sourcePeek",
"src/utils/extractContext",
"src/utils/menuListenerHelper",
"src/utils/clipboardUrl",
"src/utils/imageResize",
// Hot exit module (captures/restores full app state)
"src/utils/hotExit/",
// Type bridging (imports plugin format types for unified type definitions)
"src/types/cursorContext",
// Read-only guard (reads document store for read-only state)
"src/utils/readOnlyGuard",
// CJK formatter (reads settings for formatting rules)
"src/lib/cjkFormatter/",
],
},
to: { path: "^src/(plugins|components|stores)/" },
},
// Rule 4: Cross-plugin imports only via shared/ or sourcePopup/
//
// Coordination plugins are exempted — they orchestrate multiple plugins
// by design. The rule still catches isolated plugins that shouldn't reach
// into other plugins' internals.
{
name: "plugin-isolation",
severity: "warn",
comment:
"Plugins should be self-contained. Cross-plugin imports are allowed only through shared/, sourcePopup/, or coordination plugins.",
from: {
path: "^src/plugins/([^/]+)/",
pathNot: [
// Coordination plugins (inherently cross-cutting)
"src/plugins/toolbarActions/",
"src/plugins/toolbarContext/",
"src/plugins/sourceContextDetection/",
"src/plugins/codemirror/",
"src/plugins/formatToolbar/",
"src/plugins/editorPlugins/",
"src/plugins/codePreview/",
// Plugins with verified cross-plugin dependencies
"src/plugins/tabIndent/",
"src/plugins/blockEscape/",
"src/plugins/blockImage/",
"src/plugins/sourcePeekInline/",
"src/plugins/sourceLinkPopup/",
"src/plugins/sourceImagePopup/",
"src/plugins/htmlPaste/",
"src/plugins/markdownPaste/",
"src/plugins/aiSuggestion/",
"src/plugins/mathPopup/",
"src/plugins/mathPreview/",
"src/plugins/mermaidPreview/",
"src/plugins/latex/",
"src/plugins/shared/",
],
},
to: {
path: "^src/plugins/",
pathNot: [
"^src/plugins/$1/",
"^src/plugins/shared/",
"^src/plugins/sourcePopup/",
],
},
},
],
options: {
doNotFollow: {
path: [
"node_modules",
"dist",
"target",
"vmark-mcp-server",
"website",
"coverage",
],
},
tsPreCompilationDeps: true,
tsConfig: { fileName: "tsconfig.json" },
enhancedResolveOptions: {
exportsFields: ["exports"],
conditionNames: ["import", "require", "node", "default"],
},
reporterOptions: {
text: { highlightFocused: true },
},
},
};