forked from sverweij/dependency-cruiser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.dependency-cruiser.json
364 lines (354 loc) · 13.5 KB
/
.dependency-cruiser.json
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
{
"extends": "./configs/recommended-strict",
"forbidden": [
{
"name": "not-to-unresolvable",
"comment": "This module tried to depend on something that can't be resolved to disk. Revise yer code",
"from": {},
"to": {
"couldNotResolve": true,
"exoticallyRequired": false
}
},
{
"name": "cli-to-main-only",
"comment": "This cli module depends on something not in the public interface - which means it either doesn't belong in cli, or the main public interface needs to be expanded.",
"severity": "error",
"from": {
"path": "(^src/cli/)",
"pathNot": "^(src/cli/compile-config/index\\.js)$"
},
"to": {
"pathNot": [
"^src/(main|utl)/",
"^node_modules",
"^fs$",
"^path$",
"$1",
"^package.json$"
]
}
},
{
"name": "cli-to-main-only-warn",
"comment": "This cli module depends on something not in the public interface - which means it either doesn't belong in cli, or the main public interface needs to be expanded (this warn-only rule is a temporary exception for the compileConfig depending on the resolver).",
"severity": "warn",
"from": { "path": "^(src/cli/compile-config/index\\.js)$" },
"to": {
"pathNot": [
"$1",
"^src/(cli|main)",
"^node_modules",
"^(fs|path|package.json)$"
]
}
},
{
"name": "report-stays-in-report",
"comment": "This reporting module depends directly on a non-reporting one that is not a utility. That is odd as reporting modules should only read dependency cruiser output json.",
"severity": "error",
"from": {
"path": "(^src/report/)"
},
"to": {
"pathNot": [
"$1",
"^node_modules",
"^(path|package.json)$",
"^src/graph-utl",
"^src/utl"
]
}
},
{
"name": "extract-to-utl-only",
"comment": "This extraction module depends on something outside extraction that is not a utility. Which is odd, given the goal of the extraction step.",
"severity": "error",
"from": {
"path": "(^src/extract/)"
},
"to": {
"pathNot": [
"$1",
"^node_modules",
"^(path|fs|module|package.json)$",
"^src/graph-utl",
"^src/utl"
],
"exoticallyRequired": false
}
},
{
"name": "bin-to-cli-only",
"comment": "This module in the bin/ folder depends on something not in the cli interface. This means it either contains code that doesn't belong in bin/, or the thing it depends upon should be put in the cli interface. ",
"severity": "error",
"from": { "path": "(^bin/)" },
"to": { "pathNot": ["^src/cli", "^node_modules", "^package.json$"] }
},
{
"name": "restrict-fs-access",
"comment": "This module depends on a the node 'fs' module, and it resides in a spot where that is not allowed.",
"severity": "error",
"from": {
"pathNot": [
"^src/(main/resolve-options/normalize\\.js|extract/parse|extract/resolve|extract/gather-initial-sources\\.js|cli)",
"^test",
"^tools"
]
},
"to": { "path": "^fs$" }
},
{
"name": "no-inter-module-test",
"comment": "This test depends on something in the test tree that is neither a utility, nor a mock nor a fixture.",
"severity": "error",
"from": { "path": "(^test/[^\\/]+/)[^\\.]+\\.spec\\.js" },
"to": { "path": "^test/[^\\/]+/.+", "pathNot": ["utl", "$1.+\\.json$"] }
},
{
"name": "prefer-lodash-individuals",
"comment": "This module directly depends on 'lodash' as a whole. Preferably don't include lodash as a whole, but use individual lodash packages instead e.g. 'lodash/get' - this keeps the download of the package small(er)",
"severity": "info",
"from": {},
"to": { "path": "lodash\\.js$" }
},
{
"name": "no-dep-on-test",
"comment": "This module depends on a spec files. A spec file should have a single responsibility (testing whether a module function correctly). If there's something in a spec that's of use, factor it out into (e.g.) a separate utility/ helper or mock",
"severity": "error",
"from": { "path": "^(src|bin)" },
"to": { "path": "^test|\\.spec\\.js$" }
},
{
"name": "no-external-to-here",
"comment": "Apparently something outside of the src/ test/ and bin/ points to something inside them. That's incredibly odd and might denote a security problem.",
"severity": "error",
"from": { "pathNot": "^(src|test|bin)" },
"to": { "path": "^(src|test)" }
},
{
"name": "not-to-dev-dep",
"severity": "error",
"comment": "In production code do not depend on external ('npm') modules not declared in your package.json's dependencies - otherwise a production only install (i.e. 'npm ci') will break. If this rule triggers on something that's only used during development, adapt the 'from' of the rule in the dependency-cruiser configuration.",
"from": { "path": "^(bin|src)" },
"to": {
"dependencyTypes": ["npm-dev"],
"exoticallyRequired": false
}
},
{
"name": "only-try-require-exotic",
"severity": "error",
"comment": "The only 'exotic' require allowed is tryRequire",
"from": {},
"to": {
"exoticRequireNot": "^tryRequire$",
"exoticallyRequired": true
}
},
{
"name": "optional-deps-used",
"severity": "error",
"comment": "This module uses an external dependency that in package.json shows up as an optional dependency. In dependency-cruiser optional dependencies donot make sense - and are hence forbidden. Either make it a regular dependency (if it's production code) or a dev one (if it's for development only)",
"from": {},
"to": { "dependencyTypes": ["npm-optional"] }
},
{
"name": "peer-deps-used",
"comment": "This module uses an external dependency that in package.json shows up as a peer dependency. In dependency-cruiser peer dependencies donot make sense - and are hence forbidden. Either make it a regular dependency (if it's production code) or a dev one (if it's for development only)",
"severity": "error",
"from": {},
"to": { "dependencyTypes": ["npm-peer"] }
},
{
"name": "no-unvetted-license",
"comment": "This module uses an external dependency that has license that's not vetted. The license itself might be OK, but bigcorp legal departments might get jittery over anything other than MIT (or ISC).",
"severity": "error",
"from": {},
"to": { "licenseNot": "MIT|ISC|Apache-2\\.0" }
},
{
"name": "not-unreachable-from-cli",
"severity": "error",
"comment": "This module in the src/ tree is not reachable from the cli - and is likely dead wood. Either use it or remove it. If a module is flagged for which it's logical it is not reachable from cli (i.e. a configuration file), add it to the pathNot in the 'to' of this rule.",
"from": { "path": "^bin/" },
"to": { "path": "^src", "reachable": false }
},
{
"name": "not-unreachable-from-test",
"comment": "This module in src is not reachable by any test. Please provide a test that covers this (poor man's test coverage - this task is better suited for a proper test coverage tool :-) )",
"severity": "error",
"from": { "path": "\\.spec\\.js$" },
"to": { "path": "^src", "reachable": false }
}
],
"options": {
/* pattern specifying which files not to follow further when encountered
(regular expression)
no need to specify here as well as we use the same as is in the
recommended preset anyway
*/
// "doNotFollow": "node_modules",
/* pattern specifying which files to exclude (regular expression) */
"exclude": [
"mocks",
"fixtures",
"test/integration",
"src/cli/tools/svg-in-html-snippets/script.snippet.js"
],
/* list of module systems to cruise */
// "moduleSystems": ["amd", "cjs", "es6", "tsd"],
/* prefix for links in html and svg output (e.g. https://github.com/you/yourrepo/blob/develop/) */
"prefix": "https://github.com/sverweij/dependency-cruiser/blob/develop/",
/* if true detect dependencies that only exist before typescript-to-javascript compilation */
"tsPreCompilationDeps": true,
/* if true leave symlinks untouched, otherwise use the realpath */
// "preserveSymlinks": false,
/* TypeScript project file ('tsconfig.json') to use for
(1) compilation and
(2) resolution (e.g. with the paths property)
The (optional) fileName attribute specifies which file to take (relative to dependency-cruiser's
current working directory. When not provided defaults to './tsconfig.json'.
*/
// "tsConfig": {
// "fileName": "./tsconfig.json"
// },
/* Webpack configuration to use to get resolve options from.
The (optional) fileName attribute specifies which file to take (relative to dependency-cruiser's
current working directory. When not provided defaults to './webpack.conf.js'.
The (optional) `env` and `args` attributes contain the parameters to be passed if
your webpack config is a function and takes them (see webpack documentation
for details)
*/
// "webpackConfig": {
// "fileName": "./webpack.conf.js",
// "env": {},
// "args": {}
// },
// "babelConfig": {
// "fileName": "./babel.config.json"
// },
// "enhancedResolveOptions": {
// "cachedInputFileSystem": {
// "cacheDuration": 1800000
// }
// },
"exoticRequireStrings": ["tryRequire"],
"reporterOptions": {
"archi": {
"collapsePattern": ["^(node_modules|src|test)/[^/]+", "^bin/"]
},
"dot": {
"filters": {
"includeOnly": { "path": "^(src|bin)" }
},
"theme": {
"replace": false,
"graph": {
"splines": "ortho"
},
"modules": [
{
"criteria": { "source": "^src/cli" },
"attributes": { "fillcolor": "#ccccff" }
},
{
"criteria": { "source": "^src/report" },
"attributes": { "fillcolor": "#ffccff" }
},
{
"criteria": { "source": "^src/extract" },
"attributes": { "fillcolor": "#ccffcc" }
},
{
"criteria": { "source": "^src/enrich" },
"attributes": { "fillcolor": "#77eeaa" }
},
{
"criteria": { "source": "^src/validate" },
"attributes": { "fillcolor": "#ccccff" }
},
{
"criteria": { "source": "^src/main" },
"attributes": { "fillcolor": "#ffcccc" }
},
{
"criteria": { "source": "^src/utl" },
"attributes": { "fillcolor": "#cccccc" }
},
{
"criteria": { "source": "^src/graph-utl" },
"attributes": { "fillcolor": "#ffcccc" }
},
{
"criteria": { "source": "\\.template\\.js$" },
"attributes": { "style": "filled" }
},
{
"criteria": { "source": "\\.json$" },
"attributes": { "shape": "cylinder" }
}
],
"dependencies": [
{
"criteria": { "rules[0].severity": "error" },
"attributes": { "fontcolor": "red", "color": "red" }
},
{
"criteria": { "rules[0].severity": "warn" },
"attributes": {
"fontcolor": "orange",
"color": "orange"
}
},
{
"criteria": { "rules[0].severity": "info" },
"attributes": { "fontcolor": "blue", "color": "blue" }
},
{
"criteria": { "valid": false },
"attributes": { "fontcolor": "red", "color": "red" }
},
{
"criteria": { "resolved": "^src/cli" },
"attributes": { "color": "#0000ff77" }
},
{
"criteria": { "resolved": "^src/report" },
"attributes": { "color": "#ff00ff77" }
},
{
"criteria": { "resolved": "^src/extract" },
"attributes": { "color": "#00770077" }
},
{
"criteria": { "resolved": "^src/enrich" },
"attributes": { "color": "#00776677" }
},
{
"criteria": { "resolved": "^src/validate" },
"attributes": { "color": "#0000ff77" }
},
{
"criteria": { "resolved": "^src/main" },
"attributes": { "color": "#77000077" }
},
{
"criteria": { "resolved": "^src/utl" },
"attributes": { "color": "#aaaaaa77" }
},
{
"criteria": { "resolved": "^src/graph-utl" },
"attributes": { "color": "#77000077" }
}
]
}
}
},
// "progress" is an experimental feature. Works but names & structures
// could change without notice
// "progress": { "type": "cli-feedback" }
"progress": { "type": "performance-log" }
// "progress": {"type": "none"}
}
}