dependency-cruiser 16.6.0 → 16.7.0-beta-2

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.
Files changed (71) hide show
  1. package/bin/depcruise-baseline.mjs +1 -1
  2. package/package.json +6 -6
  3. package/src/cache/cache.mjs +3 -4
  4. package/src/cache/content-strategy.mjs +5 -7
  5. package/src/cache/find-content-changes.mjs +11 -5
  6. package/src/cache/helpers.mjs +8 -8
  7. package/src/cache/metadata-strategy.mjs +6 -8
  8. package/src/cache/options-compatible.mjs +2 -1
  9. package/src/cli/index.mjs +4 -2
  10. package/src/cli/init-config/build-config.mjs +13 -9
  11. package/src/cli/init-config/config-template.mjs +11 -0
  12. package/src/cli/init-config/index.mjs +10 -6
  13. package/src/cli/init-config/normalize-init-options.mjs +10 -6
  14. package/src/cli/listeners/performance-log/format-helpers.mjs +1 -1
  15. package/src/cli/normalize-cli-options.mjs +1 -0
  16. package/src/cli/utl/io.mjs +1 -2
  17. package/src/config-utl/extract-babel-config.mjs +0 -1
  18. package/src/config-utl/extract-depcruise-options.mjs +8 -4
  19. package/src/config-utl/extract-known-violations.mjs +6 -6
  20. package/src/config-utl/extract-webpack-resolve-config.mjs +1 -1
  21. package/src/enrich/soften-known-violations.mjs +1 -1
  22. package/src/enrich/summarize/add-rule-set-used.mjs +1 -0
  23. package/src/enrich/summarize/summarize-modules.mjs +0 -1
  24. package/src/enrich/summarize/summarize-options.mjs +2 -0
  25. package/src/extract/extract-dependencies.mjs +16 -11
  26. package/src/extract/extract-stats.mjs +9 -4
  27. package/src/extract/gather-initial-sources.mjs +8 -5
  28. package/src/extract/index.mjs +9 -4
  29. package/src/extract/resolve/determine-dependency-types.mjs +22 -15
  30. package/src/extract/resolve/external-module-helpers.mjs +4 -4
  31. package/src/extract/resolve/index.mjs +11 -5
  32. package/src/extract/resolve/module-classifiers.mjs +9 -4
  33. package/src/extract/resolve/resolve-helpers.mjs +3 -3
  34. package/src/extract/swc/dependency-visitor.mjs +2 -6
  35. package/src/extract/swc/parse.mjs +8 -4
  36. package/src/extract/tsc/extract-typescript-deps.mjs +121 -16
  37. package/src/extract/tsc/extract.mjs +2 -1
  38. package/src/graph-utl/consolidate-module-dependencies.mjs +8 -4
  39. package/src/graph-utl/filter-bank.mjs +8 -4
  40. package/src/graph-utl/indexed-module-graph.mjs +7 -11
  41. package/src/graph-utl/rule-set.mjs +9 -5
  42. package/src/main/cruise.mjs +2 -2
  43. package/src/main/format.mjs +0 -1
  44. package/src/main/options/assert-validity.mjs +13 -9
  45. package/src/main/options/defaults.mjs +1 -0
  46. package/src/main/options/normalize.mjs +23 -13
  47. package/src/main/report-wrap.mjs +12 -7
  48. package/src/main/resolve-options/normalize.mjs +10 -5
  49. package/src/main/rule-set/assert-validity.mjs +5 -2
  50. package/src/main/rule-set/normalize.mjs +21 -11
  51. package/src/meta.cjs +1 -1
  52. package/src/report/anon/anonymize-path.mjs +1 -1
  53. package/src/report/d2.mjs +2 -2
  54. package/src/report/dot/index.mjs +3 -3
  55. package/src/report/dot-webpage/svg-in-html-snippets/script.cjs +4 -4
  56. package/src/report/markdown.mjs +41 -30
  57. package/src/report/mermaid.mjs +2 -2
  58. package/src/report/teamcity.mjs +1 -0
  59. package/src/schema/baseline-violations.schema.mjs +1 -1
  60. package/src/schema/configuration.schema.mjs +1 -1
  61. package/src/schema/cruise-result.schema.mjs +1 -1
  62. package/src/utl/get-extension.mjs +1 -1
  63. package/src/utl/try-import.mjs +0 -1
  64. package/src/utl/try-require.cjs +2 -2
  65. package/src/validate/index.mjs +6 -2
  66. package/src/validate/match-dependency-rule.mjs +8 -4
  67. package/src/validate/match-module-rule-helpers.mjs +16 -10
  68. package/src/validate/match-module-rule.mjs +8 -5
  69. package/src/validate/matchers.mjs +1 -3
  70. package/types/options.d.mts +5 -0
  71. package/types/shared-types.d.mts +3 -0
@@ -15,6 +15,11 @@ import {
15
15
  } from "./helpers.mjs";
16
16
  import { uniqBy, intersects } from "#utl/array-util.mjs";
17
17
 
18
+ /**
19
+ * @import { IDependency } from "../../types/cruise-result.mjs";
20
+ * @import { IResolveOptions, IStrictCruiseOptions, ITranspileOptions } from "../../types/dependency-cruiser.mjs";
21
+ */
22
+
18
23
  function extractWithTsc(pCruiseOptions, pFileName, pTranspileOptions) {
19
24
  let lDependencies = tscExtract(pCruiseOptions, pFileName, pTranspileOptions);
20
25
 
@@ -30,7 +35,7 @@ function extractWithTsc(pCruiseOptions, pFileName, pTranspileOptions) {
30
35
  /**
31
36
  * @param {IStrictCruiseOptions} pCruiseOptions
32
37
  * @param {string} pFileName
33
- * @returns {(IStrictCruiseOptions, string, any) => import("../../types/cruise-result.mjs").IDependency[]}
38
+ * @returns {(IStrictCruiseOptions, string, any) => IDependency[]}
34
39
  */
35
40
  function determineExtractionFunction(pCruiseOptions, pFileName) {
36
41
  let lExtractionFunction = acornExtract;
@@ -45,13 +50,13 @@ function determineExtractionFunction(pCruiseOptions, pFileName) {
45
50
  }
46
51
 
47
52
  /**
48
- * @param {import('../../types/dependency-cruiser.js').IStrictCruiseOptions} pCruiseOptions
53
+ * @param {IStrictCruiseOptions} pCruiseOptions
49
54
  * @param {string} pFileName
50
55
  * @param {any} pTranspileOptions
51
- * @returns {import('../../types/cruise-result.mjs').IDependency[]}
56
+ * @returns {IDependency[]}
52
57
  */
53
58
  function extractDependencies(pCruiseOptions, pFileName, pTranspileOptions) {
54
- /** @type import('../../types/cruise-result.mjs').IDependency[] */
59
+ /** @type IDependency[] */
55
60
  let lDependencies = [];
56
61
 
57
62
  if (!pCruiseOptions.extraExtensionsToScan.includes(extname(pFileName))) {
@@ -73,10 +78,10 @@ function extractDependencies(pCruiseOptions, pFileName, pTranspileOptions) {
73
78
  }
74
79
 
75
80
  function matchesDoNotFollow({ resolved, dependencyTypes }, pDoNotFollow) {
76
- const lMatchesPath = Boolean(pDoNotFollow.path)
81
+ const lMatchesPath = pDoNotFollow.path
77
82
  ? RegExp(pDoNotFollow.path, "g").test(resolved)
78
83
  : false;
79
- const lMatchesDependencyTypes = Boolean(pDoNotFollow.dependencyTypes)
84
+ const lMatchesDependencyTypes = pDoNotFollow.dependencyTypes
80
85
  ? intersects(dependencyTypes, pDoNotFollow.dependencyTypes)
81
86
  : false;
82
87
 
@@ -114,7 +119,7 @@ function matchesPattern(pFullPathToFile, pPattern) {
114
119
 
115
120
  /**
116
121
  *
117
- * @param {import("../../types/dependency-cruiser.js").IDependency} pDependency
122
+ * @param {IDependency} pDependency
118
123
  * @returns {string}
119
124
  */
120
125
  function getDependencyUniqueKey({ module, moduleSystem, dependencyTypes }) {
@@ -143,12 +148,12 @@ function compareDeps(pLeft, pRight) {
143
148
  *
144
149
  *
145
150
  * @param {string} pFileName path to the file
146
- * @param {import("../../types/dependency-cruiser.js").IStrictCruiseOptions} pCruiseOptions cruise options
147
- * @param {import("../../types/dependency-cruiser.js").IResolveOptions} pResolveOptions webpack 'enhanced-resolve' options
148
- * @param {import("../../types/dependency-cruiser.js").ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
151
+ * @param {IStrictCruiseOptions} pCruiseOptions cruise options
152
+ * @param {IResolveOptions} pResolveOptions webpack 'enhanced-resolve' options
153
+ * @param {ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
149
154
  * ('flattened' so there's no need for file access on any
150
155
  * 'extends' option in there)
151
- * @return {import("../../types/dependency-cruiser.js").IDependency[]} an array of dependency objects (see above)
156
+ * @return {IDependency[]} an array of dependency objects (see above)
152
157
  */
153
158
  export default function getDependencies(
154
159
  pFileName,
@@ -4,10 +4,15 @@ import {
4
4
  } from "./tsc/extract.mjs";
5
5
  import { getStats as acornStats } from "./acorn/extract.mjs";
6
6
 
7
+ /**
8
+ * @import { IStrictCruiseOptions, ITranspileOptions } from "../../types/dependency-cruiser.mjs";
9
+ * @import { IDependency } from "../../types/cruise-result.mjs";
10
+ */
11
+
7
12
  /**
8
13
  * @param {IStrictCruiseOptions} pCruiseOptions
9
14
  * @param {string} pFileName
10
- * @returns {(IStrictCruiseOptions, string, any) => import("../../types/cruise-result.mjs").IDependency[]}
15
+ * @returns {(IStrictCruiseOptions, string, any) => IDependency[]}
11
16
  */
12
17
  function determineExtractionFunction(pCruiseOptions, pFileName) {
13
18
  let lExtractionFunction = acornStats;
@@ -23,11 +28,11 @@ function determineExtractionFunction(pCruiseOptions, pFileName) {
23
28
  * Returns some stats for the module in pFileName
24
29
  *
25
30
  * @param {string} pFileName path to the file
26
- * @param {import("../../types/dependency-cruiser.js").IStrictCruiseOptions} pCruiseOptions cruise options
27
- * @param {import("../../types/dependency-cruiser.js").ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
31
+ * @param {IStrictCruiseOptions} pCruiseOptions cruise options
32
+ * @param {ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
28
33
  * ('flattened' so there's no need for file access on any
29
34
  * 'extends' option in there)
30
- * @return {import("../../types/dependency-cruiser.js").IDependency[]} an array of dependency objects (see above)
35
+ * @return {IDependency[]} an array of dependency objects (see above)
31
36
  */
32
37
  export default function extractStats(
33
38
  pFileName,
@@ -1,5 +1,6 @@
1
1
  import { readdirSync, statSync } from "node:fs";
2
2
  import { join, normalize } from "node:path";
3
+ // eslint-disable-next-line n/prefer-global/process
3
4
  import { platform } from "node:process";
4
5
  import picomatch from "picomatch";
5
6
  import { scannableExtensions } from "./transpile/meta.mjs";
@@ -8,8 +9,11 @@ import getExtension from "#utl/get-extension.mjs";
8
9
  import pathToPosix from "#utl/path-to-posix.mjs";
9
10
 
10
11
  /**
11
- *
12
- * @param {import('../../types/options.mjs').IStrictCruiseOptions} pOptions
12
+ * @import {IStrictCruiseOptions} from "../../types/options.mjs";
13
+ */
14
+
15
+ /**
16
+ * @param {IStrictCruiseOptions} pOptions
13
17
  * @returns {string[]}
14
18
  */
15
19
  function getScannableExtensions(pOptions) {
@@ -37,9 +41,8 @@ function shouldNotBeExcluded(pFullPathToFile, pOptions) {
37
41
  }
38
42
 
39
43
  /**
40
- *
41
44
  * @param {string} pDirectoryName
42
- * @param {import('../../types/options.mjs').IStrictCruiseOptions} pOptions options that
45
+ * @param {IStrictCruiseOptions} pOptions options that
43
46
  * @returns {string[]}
44
47
  */
45
48
  function gatherScannableFilesFromDirectory(pDirectoryName, pOptions) {
@@ -90,7 +93,7 @@ function expandGlob(pBaseDirectory, pScannedGlob) {
90
93
  *
91
94
  * @param {string[]} pFileDirectoryAndGlobArray globs and/ or paths to files or
92
95
  * directories to be gathered
93
- * @param {import('../../types/dependency-cruiser.js').IStrictCruiseOptions} pOptions options that
96
+ * @param {IStrictCruiseOptions} pOptions options that
94
97
  * influence what needs to be gathered/ scanned
95
98
  * notably useful attributes:
96
99
  * - exclude - regexp of what to exclude
@@ -4,6 +4,11 @@ import gatherInitialSources from "./gather-initial-sources.mjs";
4
4
  import clearCaches from "./clear-caches.mjs";
5
5
  import { bus } from "#utl/bus.mjs";
6
6
 
7
+ /**
8
+ * @import {IStrictCruiseOptions} from "../../types/options.mjs";
9
+ * @import { IModule, IResolveOptions, ITranspileOptions } from "../../types/dependency-cruiser.mjs";
10
+ */
11
+
7
12
  /* eslint max-params:0 , max-lines-per-function:0*/
8
13
  function extractRecursive(
9
14
  pFileName,
@@ -142,10 +147,10 @@ function filterExcludedDynamicDependencies(pModule, pExclude) {
142
147
  * returns an array of all the modules it finds that way.
143
148
  *
144
149
  * @param {string[]} pFileDirectoryArray
145
- * @param {import("../../types/dependency-cruiser.js").IStrictCruiseOptions} pCruiseOptions
146
- * @param {import("../../types/dependency-cruiser.js").IResolveOptions} pResolveOptions
147
- * @param {import("../../types/dependency-cruiser.js").ITranspileOptions} pTranspileOptions
148
- * @returns {Partial<import("../../types/dependency-cruiser.js").IModule[]>}
150
+ * @param {IStrictCruiseOptions} pCruiseOptions
151
+ * @param {IResolveOptions} pResolveOptions
152
+ * @param {ITranspileOptions} pTranspileOptions
153
+ * @returns {Partial<IModule[]>}
149
154
  */
150
155
  export default function extract(
151
156
  pFileDirectoryArray,
@@ -9,6 +9,13 @@ import {
9
9
  getPackageRoot,
10
10
  } from "./external-module-helpers.mjs";
11
11
 
12
+ /**
13
+ * @import { DependencyType } from "../../../types/shared-types.mjs"
14
+ * @import { IResolveOptions, ITranspileOptions } from "../../../types/dependency-cruiser.mjs"
15
+ * @import { IDependency } from "../../../types/cruise-result.mjs"
16
+ * @import { IResolveOptions } from "../../../types/resolve-options.mjs"
17
+ */
18
+
12
19
  function dependencyKeyHasModuleName(
13
20
  pPackageDependencies,
14
21
  pModuleName,
@@ -49,10 +56,10 @@ function determineManifestDependencyTypes(
49
56
  pPackageDependencies,
50
57
  pResolverModulePaths,
51
58
  ) {
52
- /** @type {import("../../../types/shared-types.js").DependencyType[]} */
59
+ /** @type {DependencyType[]} */
53
60
  let lReturnValue = ["npm-unknown"];
54
61
 
55
- if (Boolean(pPackageDependencies)) {
62
+ if (pPackageDependencies) {
56
63
  lReturnValue = findModuleInPackageDependencies(
57
64
  pPackageDependencies,
58
65
  pModuleName,
@@ -82,7 +89,7 @@ function determineManifestDependencyTypes(
82
89
  function dependencyIsBundled(pModule, pPackageDeps) {
83
90
  let lReturnValue = false;
84
91
 
85
- if (Boolean(pPackageDeps)) {
92
+ if (pPackageDeps) {
86
93
  const lBundledDependencies =
87
94
  pPackageDeps.bundledDependencies || pPackageDeps.bundleDependencies;
88
95
 
@@ -98,8 +105,8 @@ function dependencyIsBundled(pModule, pPackageDeps) {
98
105
  * @param {string} pModuleName
99
106
  * @param {string} pPackageDeps
100
107
  * @param {string} pFileDirectory
101
- * @param {import("../../../types/dependency-cruiser.js").IResolveOptions} pResolveOptions
102
- * @returns {import("../../../types/shared-types.js").DependencyType[]}
108
+ * @param {IResolveOptions} pResolveOptions
109
+ * @returns {DependencyType[]}
103
110
  */
104
111
  function determineNodeModuleDependencyTypes(
105
112
  pModuleName,
@@ -107,7 +114,7 @@ function determineNodeModuleDependencyTypes(
107
114
  pFileDirectory,
108
115
  pResolveOptions,
109
116
  ) {
110
- /** @type {import("../../../types/shared-types.js").DependencyType[]} */
117
+ /** @type { DependencyType[] } */
111
118
  let lReturnValue = determineManifestDependencyTypes(
112
119
  getPackageRoot(pModuleName),
113
120
  pPackageDeps,
@@ -127,13 +134,13 @@ function determineNodeModuleDependencyTypes(
127
134
 
128
135
  /**
129
136
  *
130
- * @param {import("../../../types/cruise-result.mjs").IDependency} pDependency
137
+ * @param {IDependency} pDependency
131
138
  * @param {string} pModuleName
132
139
  * @param {any} pPackageDeps
133
140
  * @param {string} pFileDirectory
134
- * @param {import("../../../types/dependency-cruiser.js").IResolveOptions} pResolveOptions
141
+ * @param {IResolveOptions} pResolveOptions
135
142
  * @param {string} pBaseDirectory
136
- * @returns {import("../../../types/shared-types.js").DependencyType[]}
143
+ * @returns {DependencyType[]}
137
144
  */
138
145
  function determineExternalModuleDependencyTypes(
139
146
  pDependency,
@@ -143,7 +150,7 @@ function determineExternalModuleDependencyTypes(
143
150
  pResolveOptions,
144
151
  pBaseDirectory,
145
152
  ) {
146
- /** @type {import("../../../types/shared-types.js").DependencyType[]} */
153
+ /** @type { DependencyType[] } */
147
154
  let lReturnValue = [];
148
155
 
149
156
  if (
@@ -164,15 +171,15 @@ function determineExternalModuleDependencyTypes(
164
171
  /* eslint max-params:0, complexity:0 */
165
172
  /**
166
173
  *
167
- * @param {import("../../../types/cruise-result.mjs").IDependency} pDependency the dependency object with all information found hitherto
174
+ * @param {IDependency} pDependency the dependency object with all information found hitherto
168
175
  * @param {string} pModuleName the module name as found in the source
169
176
  * @param {any} pManifest a package.json, in object format
170
177
  * @param {string} pFileDirectory the directory relative to which to resolve (only used for npm deps here)
171
- * @param {import("../../../types/resolve-options.mjs").IResolveOptions} pResolveOptions an enhanced resolve 'resolve' key
178
+ * @param {IResolveOptions} pResolveOptions an enhanced resolve 'resolve' key
172
179
  * @param {string} pBaseDirectory the base directory dependency cruise is run on
173
- * @param {import("../../../types/dependency-cruiser.mjs").ITranspileOptions} pTranspileOptions
180
+ * @param {ITranspileOptions} pTranspileOptions
174
181
  *
175
- * @return {import("../../../types/shared-types.js").DependencyType[]} an array of dependency types for the dependency
182
+ * @return { DependencyType[] }an array of dependency types for the dependency
176
183
  */
177
184
  // eslint-disable-next-line max-lines-per-function
178
185
  export default function determineDependencyTypes(
@@ -184,7 +191,7 @@ export default function determineDependencyTypes(
184
191
  pBaseDirectory,
185
192
  pTranspileOptions,
186
193
  ) {
187
- /** @type {import("../../../types/shared-types.js").DependencyType[]}*/
194
+ /** @type {DependencyType[]}*/
188
195
  let lReturnValue = [];
189
196
  const lResolveOptions = pResolveOptions || {};
190
197
 
@@ -32,7 +32,7 @@ import { isScoped, isRelativeModuleName } from "./module-classifiers.mjs";
32
32
  * @return {string} the module name root
33
33
  */
34
34
  export function getPackageRoot(pModule) {
35
- if (!Boolean(pModule) || isRelativeModuleName(pModule)) {
35
+ if (!pModule || isRelativeModuleName(pModule)) {
36
36
  return pModule;
37
37
  }
38
38
 
@@ -78,7 +78,7 @@ function bareGetPackageJson(pModuleName, pFileDirectory, pResolveOptions) {
78
78
  try {
79
79
  const lPackageJsonFilename = resolve(
80
80
  join(getPackageRoot(pModuleName), "package.json"),
81
- pFileDirectory ? pFileDirectory : process.cwd(),
81
+ pFileDirectory ?? process.cwd(),
82
82
  {
83
83
  ...pResolveOptions,
84
84
  // if a module has exports fields _and_ does not expose package.json
@@ -129,7 +129,7 @@ export function dependencyIsDeprecated(
129
129
  pResolveOptions,
130
130
  );
131
131
 
132
- if (Boolean(lPackageJson)) {
132
+ if (lPackageJson) {
133
133
  lReturnValue =
134
134
  Object.hasOwn(lPackageJson, "deprecated") && lPackageJson.deprecated;
135
135
  }
@@ -154,7 +154,7 @@ export function getLicense(pModuleName, pFileDirectory, pResolveOptions) {
154
154
  );
155
155
 
156
156
  if (
157
- Boolean(lPackageJson) &&
157
+ lPackageJson &&
158
158
  Object.hasOwn(lPackageJson, "license") &&
159
159
  typeof lPackageJson.license === "string"
160
160
  ) {
@@ -8,12 +8,18 @@ import determineDependencyTypes from "./determine-dependency-types.mjs";
8
8
  import { getManifest } from "./get-manifest.mjs";
9
9
  import pathToPosix from "#utl/path-to-posix.mjs";
10
10
 
11
+ /**
12
+ * @import { IModule, IResolveOptions } from "../../../types/dependency-cruiser.mjs";
13
+ * @import { IResolveOptions } from "../../../types/resolve-options.mjs";
14
+ * @import { IDependency } from "../../../types/cruise-result.mjs";
15
+ */
16
+
11
17
  /**
12
18
  *
13
- * @param {import("../../../types/dependency-cruiser.js").IModule} pModule
19
+ * @param {IModule} pModule
14
20
  * @param {string} pBaseDirectory
15
21
  * @param {string} pFileDirectory
16
- * @param {import("../../../types/dependency-cruiser.js").IResolveOptions} pResolveOptions
22
+ * @param {IResolveOptions} pResolveOptions
17
23
  * @returns {any}
18
24
  */
19
25
  function resolveModule(
@@ -154,14 +160,14 @@ function resolveWithRetry(
154
160
  /**
155
161
  * resolves the module name of the pDependency to a file on disk.
156
162
  *
157
- * @param {Partial <import("../../../types/cruise-result.mjs").IDependency>} pDependency
163
+ * @param {Partial <IDependency>} pDependency
158
164
  * @param {string} pBaseDirectory the directory to consider as base (or 'root')
159
165
  * for resolved files.
160
166
  * @param {string} pFileDirectory the directory of the file the dependency was
161
167
  * detected in
162
- * @param {import("../../../types/resolve-options.mjs").IResolveOptions} pResolveOptions
168
+ * @param {IResolveOptions} pResolveOptions
163
169
  * @param {any} pTranspileOptions
164
- * @return {Partial <import("../../../types/cruise-result.mjs").IDependency>}
170
+ * @return {Partial <IDependency>}
165
171
  *
166
172
  *
167
173
  */
@@ -4,6 +4,11 @@ import { join as posix_join } from "node:path/posix";
4
4
  import picomatch from "picomatch";
5
5
  import getExtension from "#utl/get-extension.mjs";
6
6
 
7
+ /**
8
+ * @import { IResolveOptions } from "../../../types/resolve-options.mjs"
9
+ * @import { ITranspileOptions } from "../../../types/dependency-cruiser.mjs"
10
+ */
11
+
7
12
  let gFollowableExtensionsCache = new Set();
8
13
  let gFollowableExtensionsCacheInitialized = false;
9
14
 
@@ -145,7 +150,7 @@ function isWorkspaceAliased(pModuleName, pResolvedModuleName, pManifest) {
145
150
  // an object. To prevent the code from borking we check whether it's an array
146
151
  // see https://github.com/sverweij/dependency-cruiser/issues/919
147
152
  const lWorkspaces = getWorkspacesArray(pManifest?.workspaces);
148
- if (lWorkspaces.length >= 0) {
153
+ if (lWorkspaces.length > 0) {
149
154
  // workspaces are an array of globs that match the (sub) workspace
150
155
  // folder itself only.
151
156
  //
@@ -188,7 +193,7 @@ function isWorkspaceAliased(pModuleName, pResolvedModuleName, pManifest) {
188
193
  // of the workspace, not the path of the workspace itself. So if it's
189
194
  // in node_modules we need to check against the unresolved modulename.
190
195
  //
191
- // Other then the detection for when symlinks are resolved to their realpath
196
+ // Other than the detection for when symlinks are resolved to their realpath
192
197
  // (the if above), this is a 'best effort' detection only for now; there's
193
198
  // guaranteed to be scenarios where this will fail. How often is the
194
199
  // --preserve-symlinks flag used in practice, though?
@@ -278,9 +283,9 @@ function matchesTSConfigBaseURL(
278
283
  /**
279
284
  * @param {string} pModuleName
280
285
  * @param {string} pResolvedModuleName
281
- * @param {import("../../../types/resolve-options.mjs").IResolveOptions} pResolveOptions
286
+ * @param {importIResolveOptions} pResolveOptions
282
287
  * @param {any} pManifest
283
- * @param {import("../../../types/dependency-cruiser.mjs").ITranspileOptions} pTranspileOptions
288
+ * @param {ITranspileOptions} pTranspileOptions
284
289
  * @returns {string[]}
285
290
  */
286
291
  // eslint-disable-next-line max-params, complexity
@@ -5,7 +5,7 @@ export function addLicenseAttribute(
5
5
  pModuleName,
6
6
  pResolvedModuleName,
7
7
  { baseDirectory, fileDirectory },
8
- pResolveOptions
8
+ pResolveOptions,
9
9
  ) {
10
10
  let lReturnValue = {};
11
11
  if (
@@ -13,12 +13,12 @@ export function addLicenseAttribute(
13
13
  isExternalModule(
14
14
  pResolvedModuleName,
15
15
  pResolveOptions.modules,
16
- baseDirectory
16
+ baseDirectory,
17
17
  )
18
18
  ) {
19
19
  const lLicense = getLicense(pModuleName, fileDirectory, pResolveOptions);
20
20
 
21
- if (Boolean(lLicense)) {
21
+ if (lLicense) {
22
22
  lReturnValue.license = lLicense;
23
23
  }
24
24
  }
@@ -41,7 +41,7 @@ function argumentsAreUsable(pArguments) {
41
41
  ["StringLiteral", "TemplateLiteral"].includes(
42
42
  pArguments[0].expression.type,
43
43
  ) &&
44
- (!(pArguments[0].expression.type === "TemplateLiteral") ||
44
+ (pArguments[0].expression.type !== "TemplateLiteral" ||
45
45
  isPlaceholderlessTemplateLiteral(pArguments[0]))
46
46
  );
47
47
  }
@@ -250,11 +250,7 @@ export default Visitor
250
250
  // as visitors for some shapes of type annotations aren't completely
251
251
  // implemented yet (1.2.51) pNode can come in as null (also see
252
252
  // comments in accompanying unit test)
253
- if (
254
- Boolean(pNode) &&
255
- Boolean(pNode.typeAnnotation) &&
256
- Boolean(pNode.typeAnnotation.argument)
257
- )
253
+ if (pNode && pNode.typeAnnotation && pNode.typeAnnotation.argument)
258
254
  this.lResult.push({
259
255
  module: pNode.typeAnnotation.argument.value,
260
256
  moduleSystem: "es6",
@@ -2,10 +2,14 @@ import memoize, { memoizeClear } from "memoize";
2
2
  import tryImport from "#utl/try-import.mjs";
3
3
  import meta from "#meta.cjs";
4
4
 
5
- /** @type {import('@swc/core')} */
5
+ /**
6
+ * @import swcCore, { ParseOptions, ModuleItem } from "@swc/core";
7
+ */
8
+
9
+ /** @type {swcCore} */
6
10
  const swc = await tryImport("@swc/core", meta.supportedTranspilers.swc);
7
11
 
8
- /** @type {import('@swc/core').ParseOptions} */
12
+ /** @type {ParseOptions} */
9
13
  const SWC_PARSE_OPTIONS = {
10
14
  dynamicImport: true,
11
15
  // typescript is a superset of ecmascript, so we use typescript always
@@ -22,7 +26,7 @@ export function getASTFromSource(pSource) {
22
26
  }
23
27
 
24
28
  function getAST(pFileName) {
25
- /** @type {import('@swc/core')} swc */
29
+ /** @type {swcCore swc} */
26
30
  return swc.parseFileSync(pFileName, SWC_PARSE_OPTIONS);
27
31
  }
28
32
 
@@ -32,7 +36,7 @@ function getAST(pFileName) {
32
36
  * return the result from a cache
33
37
  *
34
38
  * @param {string} pFileName - the name of the file to compile
35
- * @return {import('@swc/core').ModuleItem[]} - an (swc) AST
39
+ * @return {ModuleItem[]} - an (swc) AST
36
40
  */
37
41
  export const getASTCached = memoize(getAST);
38
42