Skip to content

Commit cff4dc2

Browse files
committed
it's not that great, packages are ignored so far@
1 parent e94f1e0 commit cff4dc2

File tree

4 files changed

+8327
-0
lines changed

4 files changed

+8327
-0
lines changed

.dependency-cruiser.js

Lines changed: 399 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,399 @@
1+
/** @type {import('dependency-cruiser').IConfiguration} */
2+
module.exports = {
3+
forbidden: [
4+
{
5+
name: 'no-circular',
6+
severity: 'warn',
7+
comment:
8+
'This dependency is part of a circular relationship. You might want to revise ' +
9+
'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
10+
from: {},
11+
to: {
12+
circular: true
13+
}
14+
},
15+
{
16+
name: 'no-orphans',
17+
comment:
18+
"This is an orphan module - it's likely not used (anymore?). Either use it or " +
19+
"remove it. If it's logical this module is an orphan (i.e. it's a config file), " +
20+
"add an exception for it in your dependency-cruiser configuration. By default " +
21+
"this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration " +
22+
"files (.d.ts), tsconfig.json and some of the babel and webpack configs.",
23+
severity: 'warn',
24+
from: {
25+
orphan: true,
26+
pathNot: [
27+
'(^|/)[.][^/]+[.](?:js|cjs|mjs|ts|cts|mts|json)$', // dot files
28+
'[.]d[.]ts$', // TypeScript declaration files
29+
'(^|/)tsconfig[.]json$', // TypeScript config
30+
'(^|/)(?:babel|webpack)[.]config[.](?:js|cjs|mjs|ts|cts|mts|json)$' // other configs
31+
]
32+
},
33+
to: {},
34+
},
35+
{
36+
name: 'no-deprecated-core',
37+
comment:
38+
'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +
39+
"bound to exist - node doesn't deprecate lightly.",
40+
severity: 'warn',
41+
from: {},
42+
to: {
43+
dependencyTypes: [
44+
'core'
45+
],
46+
path: [
47+
'^v8/tools/codemap$',
48+
'^v8/tools/consarray$',
49+
'^v8/tools/csvparser$',
50+
'^v8/tools/logreader$',
51+
'^v8/tools/profile_view$',
52+
'^v8/tools/profile$',
53+
'^v8/tools/SourceMap$',
54+
'^v8/tools/splaytree$',
55+
'^v8/tools/tickprocessor-driver$',
56+
'^v8/tools/tickprocessor$',
57+
'^node-inspect/lib/_inspect$',
58+
'^node-inspect/lib/internal/inspect_client$',
59+
'^node-inspect/lib/internal/inspect_repl$',
60+
'^async_hooks$',
61+
'^punycode$',
62+
'^domain$',
63+
'^constants$',
64+
'^sys$',
65+
'^_linklist$',
66+
'^_stream_wrap$'
67+
],
68+
}
69+
},
70+
{
71+
name: 'not-to-deprecated',
72+
comment:
73+
'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +
74+
'version of that module, or find an alternative. Deprecated modules are a security risk.',
75+
severity: 'warn',
76+
from: {},
77+
to: {
78+
dependencyTypes: [
79+
'deprecated'
80+
]
81+
}
82+
},
83+
{
84+
name: 'no-non-package-json',
85+
severity: 'error',
86+
comment:
87+
"This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " +
88+
"That's problematic as the package either (1) won't be available on live (2 - worse) will be " +
89+
"available on live with an non-guaranteed version. Fix it by adding the package to the dependencies " +
90+
"in your package.json.",
91+
from: {},
92+
to: {
93+
dependencyTypes: [
94+
'npm-no-pkg',
95+
'npm-unknown'
96+
]
97+
}
98+
},
99+
{
100+
name: 'not-to-unresolvable',
101+
comment:
102+
"This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " +
103+
'module: add it to your package.json. In all other cases you likely already know what to do.',
104+
severity: 'error',
105+
from: {},
106+
to: {
107+
couldNotResolve: true
108+
}
109+
},
110+
{
111+
name: 'no-duplicate-dep-types',
112+
comment:
113+
"Likely this module depends on an external ('npm') package that occurs more than once " +
114+
"in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " +
115+
"maintenance problems later on.",
116+
severity: 'warn',
117+
from: {},
118+
to: {
119+
moreThanOneDependencyType: true,
120+
// as it's pretty common to have a type import be a type only import
121+
// _and_ (e.g.) a devDependency - don't consider type-only dependency
122+
// types for this rule
123+
dependencyTypesNot: ["type-only"]
124+
}
125+
},
126+
127+
/* rules you might want to tweak for your specific situation: */
128+
129+
{
130+
name: 'not-to-spec',
131+
comment:
132+
'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' +
133+
"If there's something in a spec that's of use to other modules, it doesn't have that single " +
134+
'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',
135+
severity: 'error',
136+
from: {},
137+
to: {
138+
path: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$'
139+
}
140+
},
141+
{
142+
name: 'not-to-dev-dep',
143+
severity: 'error',
144+
comment:
145+
"This module depends on an npm package from the 'devDependencies' section of your " +
146+
'package.json. It looks like something that ships to production, though. To prevent problems ' +
147+
"with npm packages that aren't there on production declare it (only!) in the 'dependencies'" +
148+
'section of your package.json. If this module is development only - add it to the ' +
149+
'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',
150+
from: {
151+
path: '^(packages)',
152+
pathNot: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$'
153+
},
154+
to: {
155+
dependencyTypes: [
156+
'npm-dev',
157+
],
158+
// type only dependencies are not a problem as they don't end up in the
159+
// production code or are ignored by the runtime.
160+
dependencyTypesNot: [
161+
'type-only'
162+
],
163+
pathNot: [
164+
'node_modules/@types/'
165+
]
166+
}
167+
},
168+
{
169+
name: 'optional-deps-used',
170+
severity: 'info',
171+
comment:
172+
"This module depends on an npm package that is declared as an optional dependency " +
173+
"in your package.json. As this makes sense in limited situations only, it's flagged here. " +
174+
"If you're using an optional dependency here by design - add an exception to your" +
175+
"dependency-cruiser configuration.",
176+
from: {},
177+
to: {
178+
dependencyTypes: [
179+
'npm-optional'
180+
]
181+
}
182+
},
183+
{
184+
name: 'peer-deps-used',
185+
comment:
186+
"This module depends on an npm package that is declared as a peer dependency " +
187+
"in your package.json. This makes sense if your package is e.g. a plugin, but in " +
188+
"other cases - maybe not so much. If the use of a peer dependency is intentional " +
189+
"add an exception to your dependency-cruiser configuration.",
190+
severity: 'warn',
191+
from: {},
192+
to: {
193+
dependencyTypes: [
194+
'npm-peer'
195+
]
196+
}
197+
}
198+
],
199+
options: {
200+
201+
/* Which modules not to follow further when encountered */
202+
doNotFollow: {
203+
/* path: an array of regular expressions in strings to match against */
204+
path: ['node_modules']
205+
},
206+
207+
/* Which modules to exclude */
208+
// exclude : {
209+
// /* path: an array of regular expressions in strings to match against */
210+
// path: '',
211+
// },
212+
213+
/* Which modules to exclusively include (array of regular expressions in strings)
214+
dependency-cruiser will skip everything not matching this pattern
215+
*/
216+
// includeOnly : [''],
217+
218+
/* List of module systems to cruise.
219+
When left out dependency-cruiser will fall back to the list of _all_
220+
module systems it knows of. It's the default because it's the safe option
221+
It might come at a performance penalty, though.
222+
moduleSystems: ['amd', 'cjs', 'es6', 'tsd']
223+
224+
As in practice only commonjs ('cjs') and ecmascript modules ('es6')
225+
are widely used, you can limit the moduleSystems to those.
226+
*/
227+
228+
// moduleSystems: ['cjs', 'es6'],
229+
230+
/*
231+
false: don't look at JSDoc imports (the default)
232+
true: dependency-cruiser will detect dependencies in JSDoc-style
233+
import statements. Implies "parser": "tsc", so the dependency-cruiser
234+
will use the typescript parser for JavaScript files.
235+
236+
For this to work the typescript compiler will need to be installed in the
237+
same spot as you're running dependency-cruiser from.
238+
*/
239+
// detectJSDocImports: true,
240+
241+
/* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/main/'
242+
to open it on your online repo or `vscode://file/${process.cwd()}/` to
243+
open it in visual studio code),
244+
*/
245+
// prefix: `vscode://file/${process.cwd()}/`,
246+
247+
/* false (the default): ignore dependencies that only exist before typescript-to-javascript compilation
248+
true: also detect dependencies that only exist before typescript-to-javascript compilation
249+
"specify": for each dependency identify whether it only exists before compilation or also after
250+
*/
251+
// tsPreCompilationDeps: false,
252+
253+
/* list of extensions to scan that aren't javascript or compile-to-javascript.
254+
Empty by default. Only put extensions in here that you want to take into
255+
account that are _not_ parsable.
256+
*/
257+
// extraExtensionsToScan: [".json", ".jpg", ".png", ".svg", ".webp"],
258+
259+
/* if true combines the package.jsons found from the module up to the base
260+
folder the cruise is initiated from. Useful for how (some) mono-repos
261+
manage dependencies & dependency definitions.
262+
*/
263+
// combinedDependencies: false,
264+
265+
/* if true leave symlinks untouched, otherwise use the realpath */
266+
// preserveSymlinks: false,
267+
268+
/* TypeScript project file ('tsconfig.json') to use for
269+
(1) compilation and
270+
(2) resolution (e.g. with the paths property)
271+
272+
The (optional) fileName attribute specifies which file to take (relative to
273+
dependency-cruiser's current working directory). When not provided
274+
defaults to './tsconfig.json'.
275+
*/
276+
// tsConfig: {
277+
// fileName: 'tsconfig.json'
278+
// },
279+
280+
/* Webpack configuration to use to get resolve options from.
281+
282+
The (optional) fileName attribute specifies which file to take (relative
283+
to dependency-cruiser's current working directory. When not provided defaults
284+
to './webpack.conf.js'.
285+
286+
The (optional) `env` and `arguments` attributes contain the parameters
287+
to be passed if your webpack config is a function and takes them (see
288+
webpack documentation for details)
289+
*/
290+
// webpackConfig: {
291+
// fileName: 'webpack.config.js',
292+
// env: {},
293+
// arguments: {}
294+
// },
295+
296+
/* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
297+
for compilation
298+
*/
299+
// babelConfig: {
300+
// fileName: '.babelrc',
301+
// },
302+
303+
/* List of strings you have in use in addition to cjs/ es6 requires
304+
& imports to declare module dependencies. Use this e.g. if you've
305+
re-declared require, use a require-wrapper or use window.require as
306+
a hack.
307+
*/
308+
// exoticRequireStrings: [],
309+
310+
/* options to pass on to enhanced-resolve, the package dependency-cruiser
311+
uses to resolve module references to disk. The values below should be
312+
suitable for most situations
313+
314+
If you use webpack: you can also set these in webpack.conf.js. The set
315+
there will override the ones specified here.
316+
*/
317+
enhancedResolveOptions: {
318+
/* What to consider as an 'exports' field in package.jsons */
319+
exportsFields: ["exports"],
320+
/* List of conditions to check for in the exports field.
321+
Only works when the 'exportsFields' array is non-empty.
322+
*/
323+
conditionNames: ["import", "require", "node", "default", "types"],
324+
/* The extensions, by default are the same as the ones dependency-cruiser
325+
can access (run `npx depcruise --info` to see which ones that are in
326+
_your_ environment). If that list is larger than you need you can pass
327+
the extensions you actually use (e.g. [".js", ".jsx"]). This can speed
328+
up module resolution, which is the most expensive step.
329+
*/
330+
// extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
331+
/* What to consider a 'main' field in package.json */
332+
333+
// if you migrate to ESM (or are in an ESM environment already) you will want to
334+
// have "module" in the list of mainFields, like so:
335+
// mainFields: ["module", "main", "types", "typings"],
336+
mainFields: ["main", "types", "typings"],
337+
/* A list of alias fields in package.jsons
338+
339+
See [this specification](https://github.com/defunctzombie/package-browser-field-spec) and
340+
the webpack [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealiasfields)
341+
documentation.
342+
343+
Defaults to an empty array (= don't use alias fields).
344+
*/
345+
// aliasFields: ["browser"],
346+
},
347+
348+
/* skipAnalysisNotInRules will make dependency-cruiser execute
349+
analysis strictly necessary for checking the rule set only.
350+
351+
See https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#skipanalysisnotinrules
352+
for details
353+
*/
354+
skipAnalysisNotInRules: true,
355+
356+
reporterOptions: {
357+
dot: {
358+
/* pattern of modules that can be consolidated in the detailed
359+
graphical dependency graph. The default pattern in this configuration
360+
collapses everything in node_modules to one folder deep so you see
361+
the external modules, but their innards.
362+
*/
363+
collapsePattern: 'node_modules/(?:@[^/]+/[^/]+|[^/]+)',
364+
365+
/* Options to tweak the appearance of your graph.See
366+
https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
367+
for details and some examples. If you don't specify a theme
368+
dependency-cruiser falls back to a built-in one.
369+
*/
370+
// theme: {
371+
// graph: {
372+
// /* splines: "ortho" gives straight lines, but is slow on big graphs
373+
// splines: "true" gives bezier curves (fast, not as nice as ortho)
374+
// */
375+
// splines: "true"
376+
// },
377+
// }
378+
},
379+
archi: {
380+
/* pattern of modules that can be consolidated in the high level
381+
graphical dependency graph. If you use the high level graphical
382+
dependency graph reporter (`archi`) you probably want to tweak
383+
this collapsePattern to your situation.
384+
*/
385+
collapsePattern: '^(?:packages|src|lib(s?)|app(s?)|bin|test(s?)|spec(s?))/[^/]+|node_modules/(?:@[^/]+/[^/]+|[^/]+)',
386+
387+
/* Options to tweak the appearance of your graph. If you don't specify a
388+
theme for 'archi' dependency-cruiser will use the one specified in the
389+
dot section above and otherwise use the default one.
390+
*/
391+
// theme: { },
392+
},
393+
"text": {
394+
"highlightFocused": true
395+
},
396+
}
397+
}
398+
};
399+
// generated: [email protected] on 2025-06-05T13:47:49.760Z

0 commit comments

Comments
 (0)