Skip to content

Commit 8393490

Browse files
fix: modernize
1 parent 0c0b49a commit 8393490

23 files changed

+11719
-4487
lines changed

.dependency-cruiser.js

+136-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// eslint-disable-next-line no-undef
1+
/** @type {import('dependency-cruiser').IConfiguration} */
22
module.exports = {
33
forbidden: [
4-
/* rules from the 'recommended' preset: */
54
{
65
name: "no-circular",
76
severity: "warn",
@@ -18,16 +17,16 @@ module.exports = {
1817
"This is an orphan module - it's likely not used (anymore?). Either use it or " +
1918
"remove it. If it's logical this module is an orphan (i.e. it's a config file), " +
2019
"add an exception for it in your dependency-cruiser configuration. By default " +
21-
"this rule does not scrutinize dotfiles (e.g. .eslintrc.js), TypeScript declaration " +
20+
"this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration " +
2221
"files (.d.ts), tsconfig.json and some of the babel and webpack configs.",
2322
severity: "warn",
2423
from: {
2524
orphan: true,
2625
pathNot: [
27-
"(^|/)\\.[^/]+\\.(js|cjs|mjs|ts|json)$", // dot files
28-
"\\.d\\.ts$", // TypeScript declaration files
29-
"(^|/)tsconfig\\.json$", // TypeScript config
30-
"(^|/)(babel|webpack)\\.config\\.(js|cjs|mjs|ts|json)$", // other configs
26+
"(^|/).[^/]+.(js|cjs|mjs|ts|json)$", // dot files
27+
".d.ts$", // TypeScript declaration files
28+
"(^|/)tsconfig.json$", // TypeScript config
29+
"(^|/)(babel|webpack).config.(js|cjs|mjs|ts|json)$", // other configs
3130
],
3231
},
3332
to: {},
@@ -39,7 +38,28 @@ module.exports = {
3938
from: {},
4039
to: {
4140
dependencyTypes: ["core"],
42-
path: "^(punycode|domain|constants|sys|_linklist|_stream_wrap)$",
41+
path: [
42+
"^(v8/tools/codemap)$",
43+
"^(v8/tools/consarray)$",
44+
"^(v8/tools/csvparser)$",
45+
"^(v8/tools/logreader)$",
46+
"^(v8/tools/profile_view)$",
47+
"^(v8/tools/profile)$",
48+
"^(v8/tools/SourceMap)$",
49+
"^(v8/tools/splaytree)$",
50+
"^(v8/tools/tickprocessor-driver)$",
51+
"^(v8/tools/tickprocessor)$",
52+
"^(node-inspect/lib/_inspect)$",
53+
"^(node-inspect/lib/internal/inspect_client)$",
54+
"^(node-inspect/lib/internal/inspect_repl)$",
55+
"^(async_hooks)$",
56+
"^(punycode)$",
57+
"^(domain)$",
58+
"^(constants)$",
59+
"^(sys)$",
60+
"^(_linklist)$",
61+
"^(_stream_wrap)$",
62+
],
4363
},
4464
},
4565
{
@@ -80,17 +100,22 @@ module.exports = {
80100
{
81101
name: "no-duplicate-dep-types",
82102
comment:
83-
"Likeley this module depends on an external ('npm') package that occurs more than once " +
103+
"Likely this module depends on an external ('npm') package that occurs more than once " +
84104
"in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " +
85105
"maintenance problems later on.",
86106
severity: "warn",
87107
from: {},
88108
to: {
89109
moreThanOneDependencyType: true,
110+
// as it's pretty common to have a type import be a type only import
111+
// _and_ (e.g.) a devDependency - don't consider type-only dependency
112+
// types for this rule
113+
dependencyTypesNot: ["type-only"],
90114
},
91115
},
92116

93117
/* rules you might want to tweak for your specific situation: */
118+
94119
{
95120
name: "not-to-spec",
96121
comment:
@@ -100,7 +125,7 @@ module.exports = {
100125
severity: "error",
101126
from: {},
102127
to: {
103-
path: "\\.spec\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$",
128+
path: ".(spec|test).(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee.md)$",
104129
},
105130
},
106131
{
@@ -114,7 +139,7 @@ module.exports = {
114139
"from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration",
115140
from: {
116141
path: "^(src)",
117-
pathNot: "\\.spec\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$",
142+
pathNot: ".(spec|test).(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee.md)$",
118143
},
119144
to: {
120145
dependencyTypes: ["npm-dev"],
@@ -127,7 +152,7 @@ module.exports = {
127152
"This module depends on an npm package that is declared as an optional dependency " +
128153
"in your package.json. As this makes sense in limited situations only, it's flagged here. " +
129154
"If you're using an optional dependency here by design - add an exception to your" +
130-
"depdency-cruiser configuration.",
155+
"dependency-cruiser configuration.",
131156
from: {},
132157
to: {
133158
dependencyTypes: ["npm-optional"],
@@ -150,12 +175,11 @@ module.exports = {
150175
options: {
151176
/* conditions specifying which files not to follow further when encountered:
152177
- path: a regular expression to match
153-
- dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/master/doc/rules-reference.md#dependencytypes
178+
- dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/main/doc/rules-reference.md#dependencytypes-and-dependencytypesnot
154179
for a complete list
155180
*/
156181
doNotFollow: {
157182
path: "node_modules",
158-
dependencyTypes: ["npm", "npm-dev", "npm-optional", "npm-peer", "npm-bundled", "npm-no-pkg"],
159183
},
160184

161185
/* conditions specifying which dependencies to exclude
@@ -182,14 +206,24 @@ module.exports = {
182206
/* list of module systems to cruise */
183207
// moduleSystems: ['amd', 'cjs', 'es6', 'tsd'],
184208

185-
/* prefix for links in html and svg output (e.g. https://github.com/you/yourrepo/blob/develop/) */
209+
/* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/develop/'
210+
to open it on your online repo or `vscode://file/${process.cwd()}/` to
211+
open it in visual studio code),
212+
*/
186213
// prefix: '',
187214

188215
/* false (the default): ignore dependencies that only exist before typescript-to-javascript compilation
189216
true: also detect dependencies that only exist before typescript-to-javascript compilation
190217
"specify": for each dependency identify whether it only exists before compilation or also after
191218
*/
192-
// tsPreCompilationDeps: false,
219+
tsPreCompilationDeps: true,
220+
221+
/*
222+
list of extensions to scan that aren't javascript or compile-to-javascript.
223+
Empty by default. Only put extensions in here that you want to take into
224+
account that are _not_ parsable.
225+
*/
226+
// extraExtensionsToScan: [".json", ".jpg", ".png", ".svg", ".webp"],
193227

194228
/* if true combines the package.jsons found from the module up to the base
195229
folder the cruise is initiated from. Useful for how (some) mono-repos
@@ -218,14 +252,14 @@ module.exports = {
218252
to dependency-cruiser's current working directory. When not provided defaults
219253
to './webpack.conf.js'.
220254
221-
The (optional) `env` and `args` attributes contain the parameters to be passed if
255+
The (optional) `env` and `arguments` attributes contain the parameters to be passed if
222256
your webpack config is a function and takes them (see webpack documentation
223257
for details)
224258
*/
225259
// webpackConfig: {
226-
// fileName: './webpack.config.js',
260+
// fileName: 'webpack.config.js',
227261
// env: {},
228-
// args: {},
262+
// arguments: {}
229263
// },
230264

231265
/* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
@@ -235,30 +269,72 @@ module.exports = {
235269
systems) without dependency-cruiser getting a major version bump.
236270
*/
237271
// babelConfig: {
238-
// fileName: './.babelrc'
272+
// fileName: '.babelrc',
239273
// },
240274

241-
/* How to resolve external modules - use "yarn-pnp" if you're using yarn's Plug'n'Play.
242-
otherwise leave it out (or set to the default, which is 'node_modules')
243-
*/
244-
// externalModuleResolutionStrategy: 'node_modules',
245275
/* List of strings you have in use in addition to cjs/ es6 requires
246276
& imports to declare module dependencies. Use this e.g. if you've
247-
redeclared require, use a require-wrapper or use window.require as
277+
re-declared require, use a require-wrapper or use window.require as
248278
a hack.
249279
*/
250280
// exoticRequireStrings: [],
281+
/* options to pass on to enhanced-resolve, the package dependency-cruiser
282+
uses to resolve module references to disk. You can set most of these
283+
options in a webpack.conf.js - this section is here for those
284+
projects that don't have a separate webpack config file.
285+
286+
Note: settings in webpack.conf.js override the ones specified here.
287+
*/
288+
enhancedResolveOptions: {
289+
/* List of strings to consider as 'exports' fields in package.json. Use
290+
['exports'] when you use packages that use such a field and your environment
291+
supports it (e.g. node ^12.19 || >=14.7 or recent versions of webpack).
292+
293+
If you have an `exportsFields` attribute in your webpack config, that one
294+
will have precedence over the one specified here.
295+
*/
296+
exportsFields: ["exports"],
297+
/* List of conditions to check for in the exports field. e.g. use ['imports']
298+
if you're only interested in exposed es6 modules, ['require'] for commonjs,
299+
or all conditions at once `(['import', 'require', 'node', 'default']`)
300+
if anything goes for you. Only works when the 'exportsFields' array is
301+
non-empty.
302+
303+
If you have a 'conditionNames' attribute in your webpack config, that one will
304+
have precedence over the one specified here.
305+
*/
306+
conditionNames: ["import", "require", "node", "default"],
307+
/*
308+
The extensions, by default are the same as the ones dependency-cruiser
309+
can access (run `npx depcruise --info` to see which ones that are in
310+
_your_ environment. If that list is larger than what you need (e.g.
311+
it contains .js, .jsx, .ts, .tsx, .cts, .mts - but you don't use
312+
TypeScript you can pass just the extensions you actually use (e.g.
313+
[".js", ".jsx"]). This can speed up the most expensive step in
314+
dependency cruising (module resolution) quite a bit.
315+
*/
316+
// extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
317+
/*
318+
If your TypeScript project makes use of types specified in 'types'
319+
fields in package.jsons of external dependencies, specify "types"
320+
in addition to "main" in here, so enhanced-resolve (the resolver
321+
dependency-cruiser uses) knows to also look there. You can also do
322+
this if you're not sure, but still use TypeScript. In a future version
323+
of dependency-cruiser this will likely become the default.
324+
*/
325+
mainFields: ["main", "types", "typings"],
326+
},
251327
reporterOptions: {
252328
dot: {
253329
/* pattern of modules that can be consolidated in the detailed
254330
graphical dependency graph. The default pattern in this configuration
255331
collapses everything in node_modules to one folder deep so you see
256332
the external modules, but not the innards your app depends upon.
257333
*/
258-
collapsePattern: "node_modules/[^/]+",
334+
collapsePattern: "node_modules/(@[^/]+/[^/]+|[^/]+)",
259335

260336
/* Options to tweak the appearance of your graph.See
261-
https://github.com/sverweij/dependency-cruiser/blob/master/doc/rules-reference.md#dot
337+
https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
262338
for details and some examples. If you don't specify a theme
263339
don't worry - dependency-cruiser will fall back to the default one.
264340
*/
@@ -272,13 +348,39 @@ module.exports = {
272348
// },
273349
// modules: [
274350
// {
351+
// criteria: { matchesFocus: true },
352+
// attributes: {
353+
// fillcolor: "lime",
354+
// penwidth: 2,
355+
// },
356+
// },
357+
// {
358+
// criteria: { matchesFocus: false },
359+
// attributes: {
360+
// fillcolor: "lightgrey",
361+
// },
362+
// },
363+
// {
364+
// criteria: { matchesReaches: true },
365+
// attributes: {
366+
// fillcolor: "lime",
367+
// penwidth: 2,
368+
// },
369+
// },
370+
// {
371+
// criteria: { matchesReaches: false },
372+
// attributes: {
373+
// fillcolor: "lightgrey",
374+
// },
375+
// },
376+
// {
275377
// criteria: { source: "^src/model" },
276378
// attributes: { fillcolor: "#ccccff" }
277379
// },
278380
// {
279381
// criteria: { source: "^src/view" },
280382
// attributes: { fillcolor: "#ccffcc" }
281-
// }
383+
// },
282384
// ],
283385
// dependencies: [
284386
// {
@@ -310,18 +412,21 @@ module.exports = {
310412
dependency graph reporter (`archi`) you probably want to tweak
311413
this collapsePattern to your situation.
312414
*/
313-
collapsePattern: "^(node_modules|packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+",
415+
collapsePattern: "^(packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+|node_modules/(@[^/]+/[^/]+|[^/]+)",
314416

315417
/* Options to tweak the appearance of your graph.See
316-
https://github.com/sverweij/dependency-cruiser/blob/master/doc/rules-reference.md#dot
418+
https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
317419
for details and some examples. If you don't specify a theme
318420
for 'archi' dependency-cruiser will use the one specified in the
319421
dot section (see above), if any, and otherwise use the default one.
320422
*/
321423
// theme: {
322424
// },
323425
},
426+
text: {
427+
highlightFocused: true,
428+
},
324429
},
325430
},
326431
};
327-
// generated: dependency-cruiser@9.9.2 on 2020-11-12T22:29:07.287Z
432+
// generated: dependency-cruiser@13.1.5 on 2023-09-10T03:31:28.165Z

0 commit comments

Comments
 (0)