dependency-cruiser 13.1.0-beta-3 → 13.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,13 +16,13 @@ try {
16
16
  .description(
17
17
  "Writes all known violations of rules in a .dependency-cruiser.js to a file.\n" +
18
18
  "Alias for depcruise -c -T baseline -f .dependency-cruiser-known-violations.json [files-or-directories]\n" +
19
- "Details: https://github.com/sverweij/dependency-cruiser"
19
+ "Details: https://github.com/sverweij/dependency-cruiser",
20
20
  )
21
21
  .option("-c, --config [file]", "read rules and options from [file]", true)
22
22
  .option(
23
23
  "-f, --output-to [file]",
24
24
  "file to write output to; - for stdout",
25
- ".dependency-cruiser-known-violations.json"
25
+ ".dependency-cruiser-known-violations.json",
26
26
  )
27
27
  .version(meta.version)
28
28
  .arguments("<files-or-directories>")
@@ -15,55 +15,55 @@ try {
15
15
 
16
16
  program
17
17
  .description(
18
- "Format dependency-cruiser output json.\nDetails: https://github.com/sverweij/dependency-cruiser"
18
+ "Format dependency-cruiser output json.\nDetails: https://github.com/sverweij/dependency-cruiser",
19
19
  )
20
20
  .option(
21
21
  "-f, --output-to <file>",
22
22
  "file to write output to; - for stdout",
23
- "-"
23
+ "-",
24
24
  )
25
25
  .option(
26
26
  "-T, --output-type <type>",
27
27
  "output type; e.g. err, err-html, dot, ddot, archi, flat, baseline or json",
28
- "err"
28
+ "err",
29
29
  )
30
30
  .option(
31
31
  "-I, --include-only <regex>",
32
- "only include modules matching the regex"
32
+ "only include modules matching the regex",
33
33
  )
34
34
  .option(
35
35
  "-F, --focus <regex>",
36
- "only include modules matching the regex + their direct neighbours"
36
+ "only include modules matching the regex + their direct neighbours",
37
37
  )
38
38
  .option(
39
39
  "--focus-depth <number>",
40
40
  "the depth to focus on - only applied when --focus is passed too. " +
41
41
  "1= direct neighbors, 2=neighbours of neighbours etc.",
42
- 1
42
+ 1,
43
43
  )
44
44
  .option(
45
45
  "-R, --reaches <regex>",
46
- "only include modules matching the regex + all modules that can reach it"
46
+ "only include modules matching the regex + all modules that can reach it",
47
47
  )
48
48
  .option(
49
49
  "-H, --highlight <regex>",
50
- "mark modules matching the regex as 'highlighted'"
50
+ "mark modules matching the regex as 'highlighted'",
51
51
  )
52
52
  .option("-x, --exclude <regex>", "exclude all modules matching the regex")
53
53
  .option(
54
54
  "-S, --collapse <regex>",
55
55
  "collapse a to a folder depth by passing a single digit (e.g. 2). Or pass a " +
56
56
  "regex to collapse to a pattern E.g. ^packages/[^/]+/ would collapse to " +
57
- "modules/ folders directly under your packages folder. "
57
+ "modules/ folders directly under your packages folder. ",
58
58
  )
59
59
  .option(
60
60
  "-P, --prefix <prefix>",
61
- "prefix to use for links in the dot and err-html reporters"
61
+ "prefix to use for links in the dot and err-html reporters",
62
62
  )
63
63
  .option(
64
64
  "-e, --exit-code",
65
65
  "exit with a non-zero exit code when the input json contains error level " +
66
- "dependency violations. Works for err, err-long and teamcity output types"
66
+ "dependency violations. Works for err, err-long and teamcity output types",
67
67
  )
68
68
  .version(meta.version)
69
69
  .arguments("<dependency-cruiser-json>")
@@ -10,159 +10,159 @@ try {
10
10
 
11
11
  program
12
12
  .description(
13
- `Validate and visualize dependencies.${EOL}Details: https://github.com/sverweij/dependency-cruiser`
13
+ `Validate and visualize dependencies.${EOL}Details: https://github.com/sverweij/dependency-cruiser`,
14
14
  )
15
15
  .option(
16
16
  "--init [oneshot]",
17
- `set up dependency-cruiser for use in your environment (<<< recommended!)${EOL}${EOL}`
17
+ `set up dependency-cruiser for use in your environment (<<< recommended!)${EOL}${EOL}`,
18
18
  )
19
19
  .option(
20
20
  "-c, --config [file]",
21
21
  "read rules and options from [file] (e.g. .dependency-cruiser.js)",
22
- true
22
+ true,
23
23
  )
24
24
  .addOption(
25
25
  new program.Option(
26
26
  "--no-config",
27
27
  "do not use a configuration file. " +
28
- "Overrides any --config option set earlier"
29
- ).hideHelp(true)
28
+ "Overrides any --config option set earlier",
29
+ ).hideHelp(true),
30
30
  )
31
31
  .option(
32
32
  "-T, --output-type <type>",
33
33
  "output type; e.g. err, err-html, dot, ddot, archi, flat, text or json",
34
- "err"
34
+ "err",
35
35
  )
36
36
  .option("-m, --metrics", "calculate stability metrics", false)
37
37
  .addOption(new program.Option("--no-metrics").hideHelp(true))
38
38
  .option(
39
39
  "-f, --output-to <file>",
40
40
  "file to write output to; - for stdout",
41
- "-"
41
+ "-",
42
42
  )
43
43
  .option(
44
44
  "-I, --include-only <regex>",
45
- "only include modules matching the regex"
45
+ "only include modules matching the regex",
46
46
  )
47
47
  .option(
48
48
  "-F, --focus <regex>",
49
- "only include modules matching the regex + their direct neighbours"
49
+ "only include modules matching the regex + their direct neighbours",
50
50
  )
51
51
  .option(
52
52
  "--focus-depth <number>",
53
53
  "the depth to focus on - only applied when --focus is passed too. " +
54
54
  "1= direct neighbors, 2=neighbours of neighbours etc.",
55
- 1
55
+ 1,
56
56
  )
57
57
  .option(
58
58
  "-R, --reaches <regex>",
59
- "only include modules matching the regex + all modules that can reach it"
59
+ "only include modules matching the regex + all modules that can reach it",
60
60
  )
61
61
  .option(
62
62
  "-H, --highlight <regex>",
63
- "mark modules matching the regex as 'highlighted'"
63
+ "mark modules matching the regex as 'highlighted'",
64
64
  )
65
65
  .option("-x, --exclude <regex>", "exclude all modules matching the regex")
66
66
  .option(
67
67
  "-X, --do-not-follow <regex>",
68
- "include modules matching the regex, but don't follow their dependencies"
68
+ "include modules matching the regex, but don't follow their dependencies",
69
69
  )
70
70
  .option(
71
71
  "--ignore-known [file]",
72
- "ignore known violations as saved in [file] (default: .dependency-cruiser-known-violations.json)"
72
+ "ignore known violations as saved in [file] (default: .dependency-cruiser-known-violations.json)",
73
73
  )
74
74
  .addOption(new program.Option("--no-ignore-known").hideHelp(true))
75
75
  .addOption(
76
76
  new program.Option(
77
77
  "--ts-config [file]",
78
- "use a TypeScript configuration (e.g. tsconfig.json) or it's JavaScript counterpart (e.g. jsconfig.json)"
79
- ).hideHelp(true)
78
+ "use a TypeScript configuration (e.g. tsconfig.json) or it's JavaScript counterpart (e.g. jsconfig.json)",
79
+ ).hideHelp(true),
80
80
  )
81
81
  .addOption(
82
82
  new program.Option(
83
83
  "--webpack-config [file]",
84
- "use a webpack configuration (e.g. webpack.config.js)"
85
- ).hideHelp(true)
84
+ "use a webpack configuration (e.g. webpack.config.js)",
85
+ ).hideHelp(true),
86
86
  )
87
87
  .addOption(
88
88
  new program.Option(
89
89
  "--ts-pre-compilation-deps",
90
90
  "detect dependencies that only exist before typescript-to-javascript " +
91
- "compilation (off by default)"
92
- ).hideHelp(true)
91
+ "compilation (off by default)",
92
+ ).hideHelp(true),
93
93
  )
94
94
  .option(
95
95
  "-S, --collapse <regex>",
96
96
  "collapse a to a folder depth by passing a single digit (e.g. 2). When passed a " +
97
97
  'regex collapses to that pattern. E.g. "^packages/[^/]+/" would collapse to ' +
98
- "modules/ folders directly under your packages folder. "
98
+ "modules/ folders directly under your packages folder. ",
99
99
  )
100
100
  .addOption(
101
101
  new program.Option(
102
102
  "-p, --progress [type]",
103
- "show progress while dependency-cruiser is busy"
104
- ).choices(["cli-feedback", "performance-log", "ndjson", "none"])
103
+ "show progress while dependency-cruiser is busy",
104
+ ).choices(["cli-feedback", "performance-log", "ndjson", "none"]),
105
105
  )
106
106
  .addOption(
107
107
  new program.Option("--no-progress", "Alias of --progress none").hideHelp(
108
- true
109
- )
108
+ true,
109
+ ),
110
110
  )
111
111
  .addOption(
112
112
  new program.Option(
113
113
  "-d, --max-depth <n>",
114
114
  "You probably want to use --collapse instead of --max-depth. " +
115
- "(max-depth would limit the cruise depth; 0 <= n <= 99 (default: 0 - no limit))."
116
- ).hideHelp(true)
115
+ "(max-depth would limit the cruise depth; 0 <= n <= 99 (default: 0 - no limit)).",
116
+ ).hideHelp(true),
117
117
  )
118
118
  .addOption(
119
119
  new program.Option(
120
120
  "-M, --module-systems <items>",
121
- "list of module systems (default: amd, cjs, es6, tsd)"
122
- ).hideHelp(true)
121
+ "list of module systems (default: amd, cjs, es6, tsd)",
122
+ ).hideHelp(true),
123
123
  )
124
124
  .option(
125
125
  "-P, --prefix <prefix>",
126
- `prefix to use for links in the dot and err-html reporters${EOL}${EOL}`
126
+ `prefix to use for links in the dot and err-html reporters${EOL}${EOL}`,
127
127
  )
128
128
  .option(
129
129
  "-C, --cache [cache-directory]",
130
130
  "(experimental) use a cache to speed up execution. " +
131
- "The directory defaults to node_modules/.cache/dependency-cruiser"
131
+ "The directory defaults to node_modules/.cache/dependency-cruiser",
132
132
  )
133
133
  .addOption(
134
134
  new program.Option(
135
135
  "--cache-strategy <strategy>",
136
- "(experimental) strategy to use for detecting changed files in the cache."
137
- ).choices(["metadata", "content"])
136
+ "(experimental) strategy to use for detecting changed files in the cache.",
137
+ ).choices(["metadata", "content"]),
138
138
  )
139
139
  .addOption(
140
140
  new program.Option(
141
141
  "--no-cache",
142
142
  "switch off caching. Overrides the 'cache' key in .dependency-cruiser.js " +
143
- "and --cache options set earlier on the command line"
144
- ).hideHelp(true)
143
+ "and --cache options set earlier on the command line",
144
+ ).hideHelp(true),
145
145
  )
146
146
  .addOption(
147
147
  new program.Option(
148
148
  "--preserve-symlinks",
149
- "leave symlinks unchanged (off by default)"
150
- ).hideHelp(true)
149
+ "leave symlinks unchanged (off by default)",
150
+ ).hideHelp(true),
151
151
  )
152
152
  .addOption(
153
153
  new program.Option(
154
154
  "-v, --validate [file]",
155
- `alias for --config`
156
- ).hideHelp(true)
155
+ `alias for --config`,
156
+ ).hideHelp(true),
157
157
  )
158
158
  .option(
159
159
  "-i, --info",
160
- "shows what languages and extensions dependency-cruiser supports"
160
+ "shows what languages and extensions dependency-cruiser supports",
161
161
  )
162
162
  .addHelpText(
163
163
  "after",
164
164
  `${EOL}Other options:` +
165
- `${EOL} see https://github.com/sverweij/dependency-cruiser/blob/main/doc/cli.md${EOL}`
165
+ `${EOL} see https://github.com/sverweij/dependency-cruiser/blob/main/doc/cli.md${EOL}`,
166
166
  )
167
167
  .version(meta.version)
168
168
  .arguments("[files-or-directories]")
@@ -75,7 +75,7 @@ function formatFileName(pFileName) {
75
75
  }
76
76
  function formatDependency(pFrom, pTo) {
77
77
  return `${formatFileName(pFrom)} ${figures.arrowRight}</br>${formatFileName(
78
- pTo
78
+ pTo,
79
79
  )}`;
80
80
  }
81
81
 
@@ -100,14 +100,14 @@ function render3DThing(pCruiseResult) {
100
100
  source: pCurrentModule.source,
101
101
  target: pDependency.resolved,
102
102
  label: formatDependency(pCurrentModule.source, pDependency.resolved),
103
- }))
103
+ })),
104
104
  ),
105
- []
105
+ [],
106
106
  );
107
107
 
108
108
  return TEMPLATE.replace(/@@NODES@@/g, JSON.stringify(lNodes)).replace(
109
109
  /@@LINKS@@/g,
110
- JSON.stringify(lLinks)
110
+ JSON.stringify(lLinks),
111
111
  );
112
112
  }
113
113
 
@@ -76,7 +76,7 @@ module.exports = (pCruiseResult) => ({
76
76
  output: JSON.stringify(
77
77
  samplePluginReporter(pCruiseResult),
78
78
  null,
79
- DEFAULT_JSON_INDENT
79
+ DEFAULT_JSON_INDENT,
80
80
  ),
81
81
  exitCode: 0,
82
82
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "13.1.0-beta-3",
3
+ "version": "13.1.1",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -108,8 +108,8 @@
108
108
  "depcruise:report:view": "node ./bin/dependency-cruise.mjs src bin test configs types --output-type err-html --config configs/.dependency-cruiser-show-metrics-config.mjs --output-to - | browser",
109
109
  "depcruise:focus": "node ./bin/dependency-cruise.mjs src bin test configs types tools --progress --no-cache --output-type text --focus",
110
110
  "depcruise:reaches": "node ./bin/dependency-cruise.mjs src bin test configs types tools --progress --no-cache --config configs/.dependency-cruiser-unlimited.mjs --output-type text --reaches",
111
- "format": "prettier --loglevel warn --write \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
112
- "format:check": "prettier --loglevel warn --check \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
111
+ "format": "prettier --log-level warn --write \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
112
+ "format:check": "prettier --log-level warn --check \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
113
113
  "lint": "npm-run-all --parallel --aggregate-output lint:eslint format:check lint:types",
114
114
  "lint:eslint": "eslint bin/dependency-cruise.mjs bin src test configs tools/**/*.mjs --cache --cache-location node_modules/.cache/eslint/",
115
115
  "lint:eslint:fix": "eslint --fix bin src test configs tools/**/*.mjs --cache --cache-location node_modules/.cache/eslint/",
@@ -148,7 +148,7 @@
148
148
  "version": "npm-run-all build depcruise:graph:doc scm:stage"
149
149
  },
150
150
  "dependencies": {
151
- "acorn": "8.9.0",
151
+ "acorn": "8.10.0",
152
152
  "acorn-jsx": "5.3.2",
153
153
  "acorn-jsx-walk": "2.0.0",
154
154
  "acorn-loose": "8.3.0",
@@ -158,7 +158,7 @@
158
158
  "commander": "11.0.0",
159
159
  "enhanced-resolve": "5.15.0",
160
160
  "figures": "5.0.0",
161
- "glob": "10.3.1",
161
+ "glob": "10.3.3",
162
162
  "handlebars": "4.7.7",
163
163
  "ignore": "5.2.4",
164
164
  "indent-string": "5.0.0",
@@ -169,29 +169,29 @@
169
169
  "prompts": "2.4.2",
170
170
  "rechoir": "^0.8.0",
171
171
  "safe-regex": "2.1.1",
172
- "semver": "^7.5.3",
172
+ "semver": "^7.5.4",
173
173
  "semver-try-require": "6.2.3",
174
174
  "teamcity-service-messages": "0.1.14",
175
- "tsconfig-paths-webpack-plugin": "4.0.1",
176
- "watskeburt": "0.11.5",
175
+ "tsconfig-paths-webpack-plugin": "4.1.0",
176
+ "watskeburt": "0.11.6",
177
177
  "wrap-ansi": "8.1.0"
178
178
  },
179
179
  "devDependencies": {
180
- "@babel/core": "7.22.5",
180
+ "@babel/core": "7.22.9",
181
181
  "@babel/plugin-transform-modules-commonjs": "7.22.5",
182
182
  "@babel/preset-typescript": "7.22.5",
183
- "@swc/core": "1.3.67",
183
+ "@swc/core": "1.3.69",
184
184
  "@types/lodash": "4.14.195",
185
- "@types/node": "20.3.3",
185
+ "@types/node": "20.4.2",
186
186
  "@types/prompts": "2.4.4",
187
- "@typescript-eslint/eslint-plugin": "5.60.1",
188
- "@typescript-eslint/parser": "5.60.1",
187
+ "@typescript-eslint/eslint-plugin": "6.0.0",
188
+ "@typescript-eslint/parser": "6.0.0",
189
189
  "@vue/compiler-sfc": "3.3.4",
190
190
  "c8": "8.0.0",
191
191
  "chai": "4.3.7",
192
192
  "chai-json-schema": "1.5.1",
193
193
  "coffeescript": "2.7.0",
194
- "eslint": "8.44.0",
194
+ "eslint": "8.45.0",
195
195
  "eslint-config-moving-meadow": "4.0.2",
196
196
  "eslint-config-prettier": "8.8.0",
197
197
  "eslint-plugin-budapestian": "5.0.1",
@@ -207,7 +207,7 @@
207
207
  "mocha": "10.2.0",
208
208
  "normalize-newline": "4.1.0",
209
209
  "npm-run-all": "4.1.5",
210
- "prettier": "2.8.8",
210
+ "prettier": "3.0.0",
211
211
  "proxyquire": "2.1.3",
212
212
  "shx": "0.3.4",
213
213
  "svelte": "3.59.1",
@@ -218,10 +218,10 @@
218
218
  "yarn": "1.22.19"
219
219
  },
220
220
  "overrides": {
221
- "semver": "^7.5.3"
221
+ "semver": "^7.5.4"
222
222
  },
223
223
  "resolutions": {
224
- "semver": "^7.5.3"
224
+ "semver": "^7.5.4"
225
225
  },
226
226
  "upem": {
227
227
  "policies": [
package/src/cli/index.mjs CHANGED
@@ -81,16 +81,16 @@ async function extractBabelConfigOptions(pCruiseOptions) {
81
81
  }
82
82
 
83
83
  function setUpListener(pCruiseOptions) {
84
- const lString2Listener = {
85
- "cli-feedback": setUpCliFeedbackListener,
86
- "performance-log": setUpPerformanceLogListener,
87
- ndjson: setUpNDJSONListener,
88
- };
84
+ const lString2Listener = new Map([
85
+ ["cli-feedback", setUpCliFeedbackListener],
86
+ ["performance-log", setUpPerformanceLogListener],
87
+ ["ndjson", setUpNDJSONListener],
88
+ ]);
89
89
  const lListenerID =
90
90
  pCruiseOptions?.progress ??
91
91
  pCruiseOptions?.ruleSet?.options?.progress?.type;
92
- // eslint-disable-next-line security/detect-object-injection
93
- const lListenerFunction = lString2Listener?.[lListenerID];
92
+
93
+ const lListenerFunction = lString2Listener.get(lListenerID);
94
94
  /* c8 ignore next 6 */
95
95
  if (Boolean(lListenerFunction)) {
96
96
  lListenerFunction(
@@ -44,22 +44,27 @@ function getOneShotConfig(pOneShotConfigId) {
44
44
  babelConfig: getBabelConfigCandidates().shift(),
45
45
  specifyResolutionExtensions: true,
46
46
  };
47
- /** @type {Record<import("./types").OneShotConfigIDType, import("./types").IPartialInitConfig>} */
48
- const lOneShotConfigs = {
49
- preset: {
50
- configType: "preset",
51
- preset: "dependency-cruiser/configs/recommended-strict",
52
- ...lBaseConfig,
53
- },
54
- yes: lBaseConfig,
55
- "experimental-scripts": {
56
- updateManifest: fileExists(PACKAGE_MANIFEST),
57
- ...lBaseConfig,
58
- },
59
- };
47
+ /** @type {Map<import("./types").OneShotConfigIDType, import("./types").IPartialInitConfig>} */
48
+ const lOneShotConfigs = new Map([
49
+ [
50
+ "preset",
51
+ {
52
+ configType: "preset",
53
+ preset: "dependency-cruiser/configs/recommended-strict",
54
+ ...lBaseConfig,
55
+ },
56
+ ],
57
+ ["yes", lBaseConfig],
58
+ [
59
+ "experimental-scripts",
60
+ {
61
+ updateManifest: fileExists(PACKAGE_MANIFEST),
62
+ ...lBaseConfig,
63
+ },
64
+ ],
65
+ ]);
60
66
 
61
- // eslint-disable-next-line security/detect-object-injection
62
- return lOneShotConfigs[pOneShotConfigId] || lBaseConfig;
67
+ return lOneShotConfigs.get(pOneShotConfigId) || lBaseConfig;
63
68
  }
64
69
 
65
70
  /**
@@ -188,7 +188,7 @@ function nodeListToArray(pNodeList) {
188
188
 
189
189
  function resetNodesAndEdges() {
190
190
  nodeListToArray(document.querySelectorAll(".current")).forEach(
191
- removeHighlight
191
+ removeHighlight,
192
192
  );
193
193
  }
194
194
 
@@ -2,7 +2,6 @@ import { readFile } from "node:fs/promises";
2
2
 
3
3
  import { extname } from "node:path";
4
4
  import json5 from "json5";
5
- import has from "lodash/has.js";
6
5
  import tryImport from "semver-try-require";
7
6
  import meta from "../meta.js";
8
7
  import makeAbsolute from "./make-absolute.mjs";
@@ -54,23 +53,23 @@ async function getJSON5Config(pBabelConfigFileName) {
54
53
  }
55
54
 
56
55
  async function getConfig(pBabelConfigFileName) {
57
- const lExtensionToParseFunction = {
58
- ".js": getJSConfig,
59
- ".cjs": getJSConfig,
60
- ".mjs": getJSConfig,
61
- "": getJSON5Config,
62
- ".json": getJSON5Config,
63
- ".json5": getJSON5Config,
64
- };
56
+ const lExtensionToParseFunction = new Map([
57
+ [".js", getJSConfig],
58
+ [".cjs", getJSConfig],
59
+ [".mjs", getJSConfig],
60
+ ["", getJSON5Config],
61
+ [".json", getJSON5Config],
62
+ [".json5", getJSON5Config],
63
+ ]);
65
64
  const lExtension = extname(pBabelConfigFileName);
66
65
 
67
- if (!has(lExtensionToParseFunction, lExtension)) {
66
+ if (!lExtensionToParseFunction.has(lExtension)) {
68
67
  throw new Error(
69
68
  `${`The babel config '${pBabelConfigFileName}' is in a format ('${lExtension}')\n`} dependency-cruiser doesn't support yet.\n`
70
69
  );
71
70
  }
72
- // eslint-disable-next-line security/detect-object-injection, no-return-await
73
- return await lExtensionToParseFunction[lExtension](pBabelConfigFileName);
71
+ // eslint-disable-next-line no-return-await
72
+ return await lExtensionToParseFunction.get(lExtension)(pBabelConfigFileName);
74
73
  }
75
74
 
76
75
  /**
@@ -20,12 +20,12 @@ function dependencyKeyHasModuleName(
20
20
  has(pPackageDependencies[pKey], join(pPrefix, pModuleName));
21
21
  }
22
22
 
23
- const NPM2DEP_TYPE = {
24
- dependencies: "npm",
25
- devDependencies: "npm-dev",
26
- optionalDependencies: "npm-optional",
27
- peerDependencies: "npm-peer",
28
- };
23
+ const NPM2DEP_TYPE = new Map([
24
+ ["dependencies", "npm"],
25
+ ["devDependencies", "npm-dev"],
26
+ ["optionalDependencies", "npm-optional"],
27
+ ["peerDependencies", "npm-peer"],
28
+ ]);
29
29
 
30
30
  function findModuleInPackageDependencies(
31
31
  pPackageDependencies,
@@ -36,7 +36,7 @@ function findModuleInPackageDependencies(
36
36
  .filter(
37
37
  dependencyKeyHasModuleName(pPackageDependencies, pModuleName, pPrefix)
38
38
  )
39
- .map((pKey) => NPM2DEP_TYPE[pKey] || "npm-no-pkg");
39
+ .map((pKey) => NPM2DEP_TYPE.get(pKey) || "npm-no-pkg");
40
40
  }
41
41
 
42
42
  function needToLookAtTypesToo(pResolverModulePaths) {
@@ -74,14 +74,14 @@ function resolveYarnVirtual(pPath) {
74
74
  * @returns {string}
75
75
  */
76
76
  function getTypeScriptExtensionsToTry(pJavaScriptExtension) {
77
- const lJS2TSMap = {
78
- ".js": [".ts", ".tsx", ".d.ts"],
79
- ".jsx": [".ts", ".tsx", ".d.ts"],
80
- ".cjs": [".cts", ".d.cts"],
81
- ".mjs": [".mts", ".d.mts"],
82
- };
83
- // eslint-disable-next-line security/detect-object-injection
84
- return lJS2TSMap[pJavaScriptExtension] ?? [];
77
+ const lJS2TSMap = new Map([
78
+ [".js", [".ts", ".tsx", ".d.ts"]],
79
+ [".jsx", [".ts", ".tsx", ".d.ts"]],
80
+ [".cjs", [".cts", ".d.cts"]],
81
+ [".mjs", [".mts", ".d.mts"]],
82
+ ]);
83
+
84
+ return lJS2TSMap.get(pJavaScriptExtension) ?? [];
85
85
  }
86
86
 
87
87
  // eslint-disable-next-line max-lines-per-function
@@ -4,6 +4,14 @@ import { builtinModules } from "node:module";
4
4
  import memoize from "lodash/memoize.js";
5
5
  import pathToPosix from "../../utl/path-to-posix.mjs";
6
6
 
7
+ // builtinModules does not expose all builtin modules for #reasons -
8
+ // see https://github.com/nodejs/node/issues/42785. In stead we could use
9
+ // isBuiltin, but that is not available in node 16.14, the lowest version
10
+ // of node dependency-cruiser currently supports. So we add the missing
11
+ // modules here.
12
+ // b.t.w. code is duplicated in resolve-cjs.mjs
13
+ const REALLY_BUILTIN_MODULES = builtinModules.concat(["test", "node:test"]);
14
+
7
15
  const fileExists = memoize((pFile) => {
8
16
  try {
9
17
  accessSync(pFile, R_OK);
@@ -16,7 +24,7 @@ const fileExists = memoize((pFile) => {
16
24
 
17
25
  function guessPath(pBaseDirectory, pFileDirectory, pStrippedModuleName) {
18
26
  return pathToPosix(
19
- relative(pBaseDirectory, join(pFileDirectory, pStrippedModuleName))
27
+ relative(pBaseDirectory, join(pFileDirectory, pStrippedModuleName)),
20
28
  );
21
29
  }
22
30
 
@@ -27,8 +35,8 @@ function guessLikelyPath(pBaseDirectory, pFileDirectory, pStrippedModuleName) {
27
35
  guessPath(
28
36
  pBaseDirectory,
29
37
  pFileDirectory,
30
- `${pStrippedModuleName}${pExtension}`
31
- )
38
+ `${pStrippedModuleName}${pExtension}`,
39
+ ),
32
40
  )
33
41
  .find(fileExists) || pStrippedModuleName
34
42
  );
@@ -37,7 +45,7 @@ function guessLikelyPath(pBaseDirectory, pFileDirectory, pStrippedModuleName) {
37
45
  export function resolveAMD(
38
46
  pStrippedModuleName,
39
47
  pBaseDirectory,
40
- pFileDirectory
48
+ pFileDirectory,
41
49
  ) {
42
50
  // lookups:
43
51
  // - [x] could be relative in the end (implemented)
@@ -48,15 +56,15 @@ export function resolveAMD(
48
56
  const lResolvedPath = guessLikelyPath(
49
57
  pBaseDirectory,
50
58
  pFileDirectory,
51
- pStrippedModuleName
59
+ pStrippedModuleName,
52
60
  );
53
61
 
54
62
  return {
55
63
  resolved: lResolvedPath,
56
- coreModule: builtinModules.includes(pStrippedModuleName),
64
+ coreModule: REALLY_BUILTIN_MODULES.includes(pStrippedModuleName),
57
65
  followable: fileExists(lResolvedPath) && lResolvedPath.endsWith(".js"),
58
66
  couldNotResolve:
59
- !builtinModules.includes(pStrippedModuleName) &&
67
+ !REALLY_BUILTIN_MODULES.includes(pStrippedModuleName) &&
60
68
  !fileExists(lResolvedPath),
61
69
  };
62
70
  }
@@ -4,27 +4,35 @@ import pathToPosix from "../../utl/path-to-posix.mjs";
4
4
  import { isFollowable } from "./module-classifiers.mjs";
5
5
  import { resolve } from "./resolve.mjs";
6
6
 
7
+ // builtinModules does not expose all builtin modules for #reasons -
8
+ // see https://github.com/nodejs/node/issues/42785. In stead we could use
9
+ // isBuiltin, but that is not available in node 16.14, the lowest version
10
+ // of node dependency-cruiser currently supports. So we add the missing
11
+ // modules here.
12
+ // b.t.w. code is duplicated in resolve-amd.mjs
13
+ const REALLY_BUILTIN_MODULES = builtinModules.concat(["test", "node:test"]);
14
+
7
15
  function addResolutionAttributes(
8
16
  pBaseDirectory,
9
17
  pModuleName,
10
18
  pFileDirectory,
11
- pResolveOptions
19
+ pResolveOptions,
12
20
  ) {
13
21
  let lReturnValue = {};
14
22
 
15
- if (builtinModules.includes(pModuleName)) {
23
+ if (REALLY_BUILTIN_MODULES.includes(pModuleName)) {
16
24
  lReturnValue.coreModule = true;
17
25
  } else {
18
26
  try {
19
27
  lReturnValue.resolved = pathToPosix(
20
28
  relative(
21
29
  pBaseDirectory,
22
- resolve(pModuleName, pFileDirectory, pResolveOptions)
23
- )
30
+ resolve(pModuleName, pFileDirectory, pResolveOptions),
31
+ ),
24
32
  );
25
33
  lReturnValue.followable = isFollowable(
26
34
  lReturnValue.resolved,
27
- pResolveOptions
35
+ pResolveOptions,
28
36
  );
29
37
  } catch (pError) {
30
38
  lReturnValue.couldNotResolve = true;
@@ -40,7 +48,7 @@ export default function resolveCommonJS(
40
48
  pStrippedModuleName,
41
49
  pBaseDirectory,
42
50
  pFileDirectory,
43
- pResolveOptions
51
+ pResolveOptions,
44
52
  ) {
45
53
  return {
46
54
  resolved: pStrippedModuleName,
@@ -51,7 +59,7 @@ export default function resolveCommonJS(
51
59
  pBaseDirectory,
52
60
  pStrippedModuleName,
53
61
  pFileDirectory,
54
- pResolveOptions
62
+ pResolveOptions,
55
63
  ),
56
64
  };
57
65
  }
@@ -1,4 +1,3 @@
1
- /* eslint security/detect-object-injection : 0*/
2
1
  import javaScriptWrap from "./javascript-wrap.mjs";
3
2
  import typeScriptWrap from "./typescript-wrap.mjs";
4
3
  import liveScriptWrap from "./livescript-wrap.mjs";
@@ -14,27 +13,27 @@ const coffeeVanillaWrap = coffeeWrap();
14
13
  const litCoffeeWrap = coffeeWrap(true);
15
14
  const svelteWrap = svelteDingus(typeScriptVanillaWrap);
16
15
 
17
- export const EXTENSION2WRAPPER = {
18
- ".js": javaScriptWrap,
19
- ".cjs": javaScriptWrap,
20
- ".mjs": javaScriptWrap,
21
- ".jsx": javaScriptWrap,
22
- ".ts": typeScriptVanillaWrap,
23
- ".tsx": typeScriptTsxWrap,
24
- ".d.ts": typeScriptVanillaWrap,
25
- ".cts": typeScriptVanillaWrap,
26
- ".d.cts": typeScriptVanillaWrap,
27
- ".mts": typeScriptESMWrap,
28
- ".d.mts": typeScriptESMWrap,
29
- ".vue": vueWrap,
30
- ".svelte": svelteWrap,
31
- ".ls": liveScriptWrap,
32
- ".coffee": coffeeVanillaWrap,
33
- ".litcoffee": litCoffeeWrap,
34
- ".coffee.md": litCoffeeWrap,
35
- ".csx": coffeeVanillaWrap,
36
- ".cjsx": coffeeVanillaWrap,
37
- };
16
+ export const EXTENSION2WRAPPER = new Map([
17
+ [".js", javaScriptWrap],
18
+ [".cjs", javaScriptWrap],
19
+ [".mjs", javaScriptWrap],
20
+ [".jsx", javaScriptWrap],
21
+ [".ts", typeScriptVanillaWrap],
22
+ [".tsx", typeScriptTsxWrap],
23
+ [".d.ts", typeScriptVanillaWrap],
24
+ [".cts", typeScriptVanillaWrap],
25
+ [".d.cts", typeScriptVanillaWrap],
26
+ [".mts", typeScriptESMWrap],
27
+ [".d.mts", typeScriptESMWrap],
28
+ [".vue", vueWrap],
29
+ [".svelte", svelteWrap],
30
+ [".ls", liveScriptWrap],
31
+ [".coffee", coffeeVanillaWrap],
32
+ [".litcoffee", litCoffeeWrap],
33
+ [".coffee.md", litCoffeeWrap],
34
+ [".csx", coffeeVanillaWrap],
35
+ [".cjsx", coffeeVanillaWrap],
36
+ ]);
38
37
 
39
38
  const BABELEABLE_EXTENSIONS = [
40
39
  ".js",
@@ -69,7 +68,7 @@ export function getWrapper(pExtension, pTranspilerOptions) {
69
68
  return babelWrap;
70
69
  }
71
70
 
72
- return EXTENSION2WRAPPER[pExtension] || javaScriptWrap;
71
+ return EXTENSION2WRAPPER.get(pExtension) || javaScriptWrap;
73
72
  }
74
73
 
75
74
  /**
@@ -28,29 +28,31 @@ const TRANSPILER2AVAILABLE = {
28
28
  ),
29
29
  };
30
30
 
31
- export const EXTENSION2AVAILABLE = {
32
- ".js": TRANSPILER2AVAILABLE.javascript,
33
- ".cjs": TRANSPILER2AVAILABLE.javascript,
34
- ".mjs": TRANSPILER2AVAILABLE.javascript,
35
- ".jsx": TRANSPILER2AVAILABLE.javascript,
36
- ".ts": TRANSPILER2AVAILABLE.typescript,
37
- ".tsx": TRANSPILER2AVAILABLE.typescript,
38
- ".d.ts": TRANSPILER2AVAILABLE.typescript,
39
- ".cts": TRANSPILER2AVAILABLE.typescript,
40
- ".d.cts": TRANSPILER2AVAILABLE.typescript,
41
- ".mts": TRANSPILER2AVAILABLE.typescript,
42
- ".d.mts": TRANSPILER2AVAILABLE.typescript,
43
- ".vue":
31
+ export const EXTENSION2AVAILABLE = new Map([
32
+ [".js", TRANSPILER2AVAILABLE.javascript],
33
+ [".cjs", TRANSPILER2AVAILABLE.javascript],
34
+ [".mjs", TRANSPILER2AVAILABLE.javascript],
35
+ [".jsx", TRANSPILER2AVAILABLE.javascript],
36
+ [".ts", TRANSPILER2AVAILABLE.typescript],
37
+ [".tsx", TRANSPILER2AVAILABLE.typescript],
38
+ [".d.ts", TRANSPILER2AVAILABLE.typescript],
39
+ [".cts", TRANSPILER2AVAILABLE.typescript],
40
+ [".d.cts", TRANSPILER2AVAILABLE.typescript],
41
+ [".mts", TRANSPILER2AVAILABLE.typescript],
42
+ [".d.mts", TRANSPILER2AVAILABLE.typescript],
43
+ [
44
+ ".vue",
44
45
  TRANSPILER2AVAILABLE["vue-template-compiler"] ||
45
- TRANSPILER2AVAILABLE["@vue/compiler-sfc"],
46
- ".svelte": TRANSPILER2AVAILABLE.svelte,
47
- ".ls": TRANSPILER2AVAILABLE.livescript,
48
- ".coffee": gotCoffee(),
49
- ".litcoffee": gotCoffee(),
50
- ".coffee.md": gotCoffee(),
51
- ".csx": gotCoffee(),
52
- ".cjsx": gotCoffee(),
53
- };
46
+ TRANSPILER2AVAILABLE["@vue/compiler-sfc"],
47
+ ],
48
+ [".svelte", TRANSPILER2AVAILABLE.svelte],
49
+ [".ls", TRANSPILER2AVAILABLE.livescript],
50
+ [".coffee", gotCoffee()],
51
+ [".litcoffee", gotCoffee()],
52
+ [".coffee.md", gotCoffee()],
53
+ [".csx", gotCoffee()],
54
+ [".cjsx", gotCoffee()],
55
+ ]);
54
56
 
55
57
  const EXTENSIONS_PER_PARSER = {
56
58
  swc: [".js", ".cjs", ".mjs", ".jsx", ".ts", ".tsx", ".d.ts"],
@@ -60,7 +62,7 @@ const EXTENSIONS_PER_PARSER = {
60
62
 
61
63
  function extensionIsAvailable(pExtension) {
62
64
  return (
63
- EXTENSION2AVAILABLE[pExtension] ||
65
+ EXTENSION2AVAILABLE.get(pExtension) ||
64
66
  // should eventually also check whether swc is enabled as a parser?
65
67
  (TRANSPILER2AVAILABLE.swc && EXTENSIONS_PER_PARSER.swc.includes(pExtension))
66
68
  );
@@ -72,7 +74,7 @@ function extensionIsAvailable(pExtension) {
72
74
  *
73
75
  * @type {IAvailableExtension[]}
74
76
  */
75
- export const allExtensions = Object.keys(EXTENSION2AVAILABLE).map(
77
+ export const allExtensions = Array.from(EXTENSION2AVAILABLE.keys()).map(
76
78
  (pExtension) => ({
77
79
  extension: pExtension,
78
80
  available: extensionIsAvailable(pExtension),
@@ -85,8 +87,9 @@ export const allExtensions = Object.keys(EXTENSION2AVAILABLE).map(
85
87
  *
86
88
  * @type {string[]}
87
89
  */
88
- export const scannableExtensions =
89
- Object.keys(EXTENSION2AVAILABLE).filter(extensionIsAvailable);
90
+ export const scannableExtensions = Array.from(
91
+ EXTENSION2AVAILABLE.keys()
92
+ ).filter(extensionIsAvailable);
90
93
 
91
94
  /**
92
95
  * returns an array of supported transpilers, with for each transpiler:
@@ -1,13 +1,13 @@
1
+ /* eslint-disable no-magic-numbers */
1
2
  function severity2number(pSeverity) {
2
- const lSeverity2Number = {
3
- error: 1,
4
- warn: 2,
5
- info: 3,
6
- ignore: 4,
7
- };
3
+ const lSeverity2Number = new Map([
4
+ ["error", 1],
5
+ ["warn", 2],
6
+ ["info", 3],
7
+ ["ignore", 4],
8
+ ]);
8
9
 
9
- // eslint-disable-next-line security/detect-object-injection
10
- return lSeverity2Number[pSeverity] || -1;
10
+ return lSeverity2Number.get(pSeverity) || -1;
11
11
  }
12
12
 
13
13
  export function severities(pFirstSeverity, pSecondSeverity) {
package/src/meta.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "13.1.0-beta-3",
4
+ version: "13.1.1",
5
5
  engines: {
6
6
  node: "^16.14||>=18",
7
7
  },
@@ -8,7 +8,7 @@ const SEVERITY2VSO_TYPE = new Map([
8
8
  // "error" | "warn" | "info" | "ignore"
9
9
  ["error", "error"],
10
10
  ["warn", "warning"],
11
- // azure devops doesn't seem to understand 'info'. We still want to
11
+ // azure devops doesn't seem to know 'info'. We still want to
12
12
  // show them, though, hence:
13
13
  ["info", "warning"],
14
14
  ]);
@@ -30,7 +30,6 @@ function formatModuleViolation(pViolation) {
30
30
  }
31
31
 
32
32
  /**
33
- *
34
33
  * @param {import("../../types/violations.js").IViolation} pViolation
35
34
  * @returns {string}
36
35
  */
@@ -93,28 +92,18 @@ function formatViolation(pViolation) {
93
92
  }
94
93
 
95
94
  /**
96
- *
97
95
  * @param {number} pNumberOfErrors
98
- * @param {number} pNumberOfWarns
99
- * @param {number} pNumberOfInfos
100
96
  *
101
- * @returns
97
+ * @returns {string}
102
98
  */
103
- function formatResultStatus(
104
- pNumberOfErrors,
105
- pNumberOfWarns,
106
- pNumberOfInfos,
107
- pNumberOfIgnored
108
- ) {
109
- if (pNumberOfErrors > 0) {
110
- return "Failed";
111
- }
112
- if (pNumberOfWarns + pNumberOfInfos + pNumberOfIgnored > 0) {
113
- return "SucceededWithIssues";
114
- }
115
- return "Succeeded";
99
+ function formatResultStatus(pNumberOfErrors) {
100
+ return pNumberOfErrors > 0 ? "Failed" : "Succeeded";
116
101
  }
117
102
 
103
+ /**
104
+ * @param {import("../../types/cruise-result.js").ISummary} pMeta
105
+ * @returns {string}
106
+ */
118
107
  function formatMeta(pMeta) {
119
108
  const lWarningCount = pMeta.warn + pMeta.info;
120
109
  const lError = `${pMeta.error} error`;
@@ -129,7 +118,6 @@ function sumMeta(pMeta) {
129
118
  }
130
119
 
131
120
  /**
132
- *
133
121
  * @param {number} pNumberOfIgnored
134
122
  * @returns {string}
135
123
  */
@@ -140,8 +128,8 @@ function formatIgnoreWarning(pNumberOfIgnored) {
140
128
  }
141
129
 
142
130
  /**
143
- *
144
131
  * @param {import("../../types/cruise-result.js").ISummary} pSummary
132
+ * @returns {string}
145
133
  */
146
134
  function formatResultMessage(pSummary) {
147
135
  let lStatSummary = `${pSummary.totalCruised} modules, ${
@@ -160,15 +148,12 @@ function formatResultMessage(pSummary) {
160
148
  }
161
149
 
162
150
  /**
163
- *
164
151
  * @param {import("../../types/cruise-result.js").ISummary} pSummary
152
+ * @returns {string}
165
153
  */
166
154
  function formatSummary(pSummary) {
167
155
  return `##vso[task.complete result=${formatResultStatus(
168
- pSummary.error,
169
- pSummary.warn,
170
- pSummary.info,
171
- pSummary?.ignore ?? 0
156
+ pSummary.error
172
157
  )};]${formatResultMessage(pSummary)}${EOL}`;
173
158
  }
174
159
 
@@ -9,12 +9,12 @@ import prepareFlatLevel from "./prepare-flat-level.mjs";
9
9
 
10
10
  await import("./dot.template.js");
11
11
 
12
- const GRANULARITY2FUNCTION = {
13
- module: prepareCustomLevel,
14
- folder: prepareFolderLevel,
15
- custom: prepareCustomLevel,
16
- flat: prepareFlatLevel,
17
- };
12
+ const GRANULARITY2FUNCTION = new Map([
13
+ ["module", prepareCustomLevel],
14
+ ["folder", prepareFolderLevel],
15
+ ["custom", prepareCustomLevel],
16
+ ["flat", prepareFlatLevel],
17
+ ]);
18
18
 
19
19
  function report(
20
20
  pResults,
@@ -34,8 +34,8 @@ function report(
34
34
  nodeAttrs: moduleUtl.attributizeObject(lTheme.node || {}),
35
35
  edgeAttrs: moduleUtl.attributizeObject(lTheme.edge || {}),
36
36
  clustersHaveOwnNode: "folder" === pGranularity,
37
- // eslint-disable-next-line security/detect-object-injection
38
- modules: (GRANULARITY2FUNCTION[pGranularity] || prepareCustomLevel)(
37
+
38
+ modules: (GRANULARITY2FUNCTION.get(pGranularity) || prepareCustomLevel)(
39
39
  lResults,
40
40
  lTheme,
41
41
  collapsePattern,
@@ -44,12 +44,12 @@ function report(
44
44
  });
45
45
  }
46
46
 
47
- const GRANULARITY2REPORTER_OPTIONS = {
48
- module: "summary.optionsUsed.reporterOptions.dot",
49
- folder: "summary.optionsUsed.reporterOptions.ddot",
50
- custom: "summary.optionsUsed.reporterOptions.archi",
51
- flat: "summary.optionsUsed.reporterOptions.flat",
52
- };
47
+ const GRANULARITY2REPORTER_OPTIONS = new Map([
48
+ ["module", "summary.optionsUsed.reporterOptions.dot"],
49
+ ["folder", "summary.optionsUsed.reporterOptions.ddot"],
50
+ ["custom", "summary.optionsUsed.reporterOptions.archi"],
51
+ ["flat", "summary.optionsUsed.reporterOptions.flat"],
52
+ ]);
53
53
 
54
54
  function pryReporterOptionsFromResults(pGranularity, pResults) {
55
55
  const lFallbackReporterOptions = get(
@@ -59,8 +59,7 @@ function pryReporterOptionsFromResults(pGranularity, pResults) {
59
59
 
60
60
  return get(
61
61
  pResults,
62
- // eslint-disable-next-line security/detect-object-injection
63
- GRANULARITY2REPORTER_OPTIONS[pGranularity],
62
+ GRANULARITY2REPORTER_OPTIONS.get(pGranularity),
64
63
  lFallbackReporterOptions
65
64
  );
66
65
  }
@@ -8,12 +8,12 @@ import {
8
8
  formatViolation as _formatViolation,
9
9
  } from "./utl/index.mjs";
10
10
 
11
- const SEVERITY2CHALK = {
12
- error: chalk.red,
13
- warn: chalk.yellow,
14
- info: chalk.cyan,
15
- ignore: chalk.gray,
16
- };
11
+ const SEVERITY2CHALK = new Map([
12
+ ["error", chalk.red],
13
+ ["warn", chalk.yellow],
14
+ ["info", chalk.cyan],
15
+ ["ignore", chalk.gray],
16
+ ]);
17
17
 
18
18
  const EXTRA_PATH_INFORMATION_INDENT = 6;
19
19
 
@@ -74,9 +74,9 @@ function formatViolation(pViolation) {
74
74
  );
75
75
 
76
76
  return (
77
- `${SEVERITY2CHALK[pViolation.rule.severity](pViolation.rule.severity)} ${
78
- pViolation.rule.name
79
- }: ${lFormattedViolators}` +
77
+ `${SEVERITY2CHALK.get(pViolation.rule.severity)(
78
+ pViolation.rule.severity
79
+ )} ${pViolation.rule.name}: ${lFormattedViolators}` +
80
80
  `${
81
81
  pViolation.comment
82
82
  ? `${EOL}${wrapAndIndent(chalk.dim(pViolation.comment))}${EOL}`
@@ -30,22 +30,22 @@ const REPORT_DEFAULTS = {
30
30
  };
31
31
 
32
32
  /**
33
- *
34
33
  * @param {import("../../types/shared-types.js").SeverityType} pSeverity
34
+ * @returns {string}
35
35
  */
36
36
  function severity2Icon(pSeverity) {
37
- const lSeverity2IconMap = {
38
- error: ":exclamation:",
39
- info: ":grey_exclamation:",
40
- ignore: ":see_no_evil:",
41
- };
42
- // eslint-disable-next-line security/detect-object-injection
43
- return lSeverity2IconMap[pSeverity] || ":warning:";
37
+ const lSeverity2IconMap = new Map([
38
+ ["error", ":exclamation:"],
39
+ ["info", ":grey_exclamation:"],
40
+ ["ignore", ":see_no_evil:"],
41
+ ]);
42
+
43
+ return lSeverity2IconMap.get(pSeverity) || ":warning:";
44
44
  }
45
45
 
46
46
  /**
47
- *
48
47
  * @param {import("../../types/cruise-result.js").ISummary} pSummary
48
+ * @return {string}
49
49
  */
50
50
  function formatStatsSummary(pSummary) {
51
51
  const lSpacerLength = 4;
@@ -54,7 +54,6 @@ function formatStatsSummary(pSummary) {
54
54
  }
55
55
 
56
56
  /**
57
- *
58
57
  * @param {import("../../types/cruise-result.js").ICruiseResult} pCruiseResult
59
58
  * @param {Boolean} pIncludeIgnoredInSummary
60
59
  * @return {string}
@@ -108,6 +107,7 @@ function formatViolations(pViolations, pIncludeIgnoredInDetails) {
108
107
  *
109
108
  * @param {import("../../types/cruise-result.js").ICruiseResult} pResults
110
109
  * @param {import("../../types/reporter-options.js").IMarkdownReporterOptions} pOptions
110
+ * @returns {string}
111
111
  */
112
112
  // eslint-disable-next-line complexity, max-statements
113
113
  function report(pResults, pOptions) {
@@ -2,15 +2,14 @@ import tsm from "teamcity-service-messages";
2
2
  import { formatPercentage, formatViolation } from "./utl/index.mjs";
3
3
 
4
4
  const CATEGORY = "dependency-cruiser";
5
- const SEVERITY2TEAMCITY_SEVERITY = {
6
- error: "ERROR",
7
- warn: "WARNING",
8
- info: "INFO",
9
- };
5
+ const SEVERITY2TEAMCITY_SEVERITY = new Map([
6
+ ["error", "ERROR"],
7
+ ["warn", "WARNING"],
8
+ ["info", "INFO"],
9
+ ]);
10
10
 
11
11
  function severity2teamcitySeverity(pSeverity) {
12
- // eslint-disable-next-line security/detect-object-injection
13
- return SEVERITY2TEAMCITY_SEVERITY[pSeverity] || "INFO";
12
+ return SEVERITY2TEAMCITY_SEVERITY.get(pSeverity) || "INFO";
14
13
  }
15
14
 
16
15
  function reportRules(pRules, pViolations) {
@@ -91,7 +91,7 @@ export function cruise(
91
91
  pFileAndDirectoryArray: string[],
92
92
  pCruiseOptions?: ICruiseOptions,
93
93
  pResolveOptions?: IResolveOptions,
94
- pTranspileOptions?: ITranspileOptions
94
+ pTranspileOptions?: ITranspileOptions,
95
95
  ): Promise<IReporterOutput>;
96
96
 
97
97
  /**
@@ -103,7 +103,7 @@ export function cruise(
103
103
  */
104
104
  export function format(
105
105
  pResult: ICruiseResult,
106
- pFormatOptions: IFormatOptions
106
+ pFormatOptions: IFormatOptions,
107
107
  ): Promise<IReporterOutput>;
108
108
 
109
109
  /**
@@ -11,7 +11,7 @@
11
11
  * when dependency-cruiser can't yet process it
12
12
  */
13
13
  export default function extractBabelConfig(
14
- pBabelConfigFileName: string
14
+ pBabelConfigFileName: string,
15
15
  ): Promise<object>;
16
16
 
17
17
  // regarding the rather unspecific _object_ type - this is what's
@@ -20,5 +20,5 @@ import { ICruiseOptions } from "./options";
20
20
  export default function extractDepcruiseConfig(
21
21
  pConfigFileName: string,
22
22
  pAlreadyVisited?: Set<string>,
23
- pBaseDirectory?: string
23
+ pBaseDirectory?: string,
24
24
  ): Promise<ICruiseOptions>;
@@ -12,5 +12,5 @@ import { ParsedCommandLine } from "typescript";
12
12
  * @throws {TypeError} when the tsconfig is unreadable
13
13
  */
14
14
  export default function extractTSConfig(
15
- pTSConfigFileName: string
15
+ pTSConfigFileName: string,
16
16
  ): ParsedCommandLine;
@@ -14,5 +14,5 @@
14
14
  export default function extractWebpackResolveConfig(
15
15
  pWebpackConfigFilename: string,
16
16
  pEnvironment?: string,
17
- pArguments?: string | any
17
+ pArguments?: any, // string or a list of arguments
18
18
  ): Promise<any>;
@@ -2,6 +2,10 @@
2
2
  export type ModuleSystemType = "cjs" | "amd" | "es6" | "tsd";
3
3
 
4
4
  // cruise options, dependency-cruiser
5
+ /* as we don't care about types beyond code completion, we ignore the
6
+ * eslint warning that the 'string' type is redundant here.
7
+ */
8
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
5
9
  export type OutputType =
6
10
  | "json"
7
11
  | "html"