dependency-cruiser 18.0.0 → 18.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.
Files changed (111) hide show
  1. package/configs/plugins/3d-reporter-plugin.mjs +1 -1
  2. package/configs/plugins/stats-reporter-plugin.mjs +2 -2
  3. package/package.json +5 -5
  4. package/src/analyze/add-validations.mjs +1 -1
  5. package/src/analyze/derive/folders/utl.mjs +2 -2
  6. package/src/analyze/summarize/index.mjs +121 -4
  7. package/src/analyze/summarize/summarize-modules.mjs +1 -1
  8. package/src/cache/cache.mjs +5 -5
  9. package/src/cache/helpers.mjs +2 -2
  10. package/src/cli/format-meta-info.mjs +12 -14
  11. package/src/cli/index.mjs +3 -4
  12. package/src/cli/init-config/check-and-warn-inconsistencies.mjs +3 -3
  13. package/src/cli/init-config/environment-helpers.mjs +4 -4
  14. package/src/cli/init-config/get-user-input.mjs +1 -1
  15. package/src/cli/init-config/index.mjs +1 -1
  16. package/src/cli/init-config/normalize-init-options.mjs +3 -3
  17. package/src/cli/init-config/validators.mjs +1 -1
  18. package/src/cli/init-config/write-run-scripts-to-manifest.mjs +2 -2
  19. package/src/cli/listeners/ndjson.mjs +1 -1
  20. package/src/cli/listeners/performance-log/index.mjs +1 -1
  21. package/src/cli/normalize-cli-options.mjs +6 -4
  22. package/src/cli/utl/assert-file-existence.mjs +1 -1
  23. package/src/config-utl/extract-babel-config.mjs +3 -1
  24. package/src/config-utl/extract-depcruise-config/index.mjs +1 -1
  25. package/src/config-utl/extract-depcruise-config/merge-configs.mjs +5 -3
  26. package/src/config-utl/extract-ts-config.mjs +1 -1
  27. package/src/config-utl/extract-webpack-resolve-config.mjs +2 -2
  28. package/src/environment.mjs +17 -0
  29. package/src/extract/acorn/extract.mjs +1 -1
  30. package/src/extract/acorn/parse.mjs +2 -2
  31. package/src/extract/extract-dependencies.mjs +1 -1
  32. package/src/extract/extract-stats.mjs +1 -1
  33. package/src/extract/gather-initial-sources.mjs +1 -1
  34. package/src/extract/helpers.mjs +1 -1
  35. package/src/extract/index.mjs +1 -1
  36. package/src/extract/resolve/determine-dependency-types.mjs +3 -2
  37. package/src/extract/resolve/external-module-helpers.mjs +8 -8
  38. package/src/extract/resolve/get-manifest.mjs +7 -7
  39. package/src/extract/resolve/index.mjs +2 -1
  40. package/src/extract/resolve/merge-manifests.mjs +2 -2
  41. package/src/extract/resolve/module-classifiers.mjs +1 -1
  42. package/src/extract/resolve/resolve-amd.mjs +1 -1
  43. package/src/extract/resolve/resolve-cjs.mjs +2 -2
  44. package/src/extract/resolve/resolve-helpers.mjs +1 -1
  45. package/src/extract/resolve/resolve.mjs +2 -2
  46. package/src/extract/swc/dependency-visitor.mjs +1 -0
  47. package/src/extract/swc/parse.mjs +2 -2
  48. package/src/extract/transpile/index.mjs +1 -1
  49. package/src/extract/transpile/meta.mjs +1 -1
  50. package/src/extract/transpile/try-import-available.mjs +1 -1
  51. package/src/extract/transpile/typescript-wrap.mjs +1 -1
  52. package/src/extract/tsc/extract-typescript-deps.mjs +1 -1
  53. package/src/extract/tsc/parse.mjs +3 -3
  54. package/src/graph-utl/add-focus.mjs +1 -1
  55. package/src/graph-utl/consolidate-to-pattern.mjs +1 -0
  56. package/src/graph-utl/indexed-module-graph.mjs +6 -6
  57. package/src/graph-utl/module-graph-with-dependency-set.mjs +1 -1
  58. package/src/graph-utl/rule-set.mjs +3 -3
  59. package/src/main/cruise.mjs +1 -1
  60. package/src/main/helpers.mjs +1 -1
  61. package/src/main/options/normalize.mjs +2 -2
  62. package/src/main/report-wrap.mjs +1 -0
  63. package/src/main/resolve-options/normalize.mjs +2 -2
  64. package/src/main/rule-set/assert-validity.mjs +1 -1
  65. package/src/main/rule-set/normalize.mjs +1 -1
  66. package/src/meta.cjs +1 -1
  67. package/src/report/anon/anonymize-path-element.mjs +1 -1
  68. package/src/report/anon/index.mjs +1 -1
  69. package/src/report/anon/random-string.mjs +1 -1
  70. package/src/report/azure-devops.mjs +2 -2
  71. package/src/report/baseline.mjs +1 -1
  72. package/src/report/d2.mjs +3 -3
  73. package/src/report/dot/index.mjs +1 -1
  74. package/src/report/dot/module-utl.mjs +2 -2
  75. package/src/report/dot/theming.mjs +12 -6
  76. package/src/report/dot-webpage/svg-in-html-snippets/script.cjs +7 -7
  77. package/src/report/error-html/error-html-template.mjs +7 -0
  78. package/src/report/error.mjs +33 -2
  79. package/src/report/html/index.mjs +2 -2
  80. package/src/report/index.mjs +1 -0
  81. package/src/report/markdown.mjs +3 -3
  82. package/src/report/mermaid.mjs +3 -3
  83. package/src/report/metrics.mjs +2 -2
  84. package/src/report/plugins.mjs +2 -1
  85. package/src/report/teamcity.mjs +2 -2
  86. package/src/report/utl/dependency-to-incidence-transformer.mjs +1 -1
  87. package/src/report/utl/index.mjs +1 -1
  88. package/src/schema/cruise-result.validate.mjs +1 -1
  89. package/src/utl/array-util.mjs +1 -1
  90. package/src/utl/find-all-files.mjs +1 -1
  91. package/src/utl/get-extension.mjs +1 -1
  92. package/src/utl/path-to-posix.mjs +1 -1
  93. package/src/utl/regex-util.mjs +4 -2
  94. package/src/utl/try-import.mjs +1 -1
  95. package/src/utl/try-require.cjs +3 -3
  96. package/src/validate/index.mjs +2 -2
  97. package/types/config-utl/extract-babel-config.d.mts +1 -1
  98. package/types/config-utl/extract-depcruise-config.d.mts +1 -1
  99. package/types/config-utl/extract-depcruise-options.d.mts +1 -1
  100. package/types/config-utl/extract-ts-config.d.mts +1 -1
  101. package/types/config-utl/extract-webpack-resolve-config.d.mts +1 -1
  102. package/types/cruise-result.d.mts +27 -0
  103. package/types/dependency-cruiser.d.mts +5 -26
  104. package/types/environment.d.mts +29 -0
  105. package/types/options.d.mts +1 -4
  106. package/types/plugins/3d-reporter-plugin.d.mts +1 -1
  107. package/types/plugins/mermaid-reporter-plugin.d.mts +1 -1
  108. package/types/plugins/stats-reporter-plugin.d.mts +1 -1
  109. package/types/rule-set.d.mts +2 -5
  110. package/types/shared-types.d.mts +1 -5
  111. package/types/strict-rule-set.d.mts +2 -5
@@ -6,7 +6,9 @@ function extendNamedRule(pExtendedRule, pForbiddenArrayBase) {
6
6
  .filter(({ name }) => name === pExtendedRule.name)
7
7
  .reduce(
8
8
  (pAll, pBaseRule) => ({
9
+ /* oxlint-disable-next-line no-accumulating-spread */
9
10
  ...pBaseRule,
11
+ /* oxlint-disable-next-line no-accumulating-spread */
10
12
  ...pAll,
11
13
  }),
12
14
  pExtendedRule,
@@ -25,11 +27,11 @@ function extendNamedRule(pExtendedRule, pForbiddenArrayBase) {
25
27
  * @param {*} pRuleArrayExtended - array of 'forbidden' rules that extend the ...
26
28
  * @param {*} pRuleArrayBase - array of 'forbidden' rules to extend
27
29
  *
28
- * @return {Array} - the merged array
30
+ * @returns {Array} - the merged array
29
31
  */
30
32
  function mergeRules(pRuleArrayExtended, pRuleArrayBase) {
31
33
  // merge anonymous on 100% equality
32
- let lAnonymousRules = uniqWith(
34
+ const lAnonymousRules = uniqWith(
33
35
  pRuleArrayExtended.concat(pRuleArrayBase).filter(({ name }) => !name),
34
36
  isDeepStrictEqual,
35
37
  );
@@ -61,7 +63,7 @@ function mergeRules(pRuleArrayExtended, pRuleArrayBase) {
61
63
  * @param {*} pAllowedArrayExtended - array of 'allowed' rules that extend the ///
62
64
  * @param {*} pAllowedArrayBase - array of 'allowed' rules to extend
63
65
  *
64
- * @return {Array} - the merged array
66
+ * @returns {Array} - the merged array
65
67
  */
66
68
  function mergeAllowedRules(pAllowedArrayExtended, pAllowedArrayBase) {
67
69
  return uniqWith(
@@ -34,7 +34,7 @@ const FORMAT_DIAGNOSTICS_HOST = {
34
34
  * Silently fails if a supported version of the typescript compiler isn't available
35
35
  *
36
36
  * @param {string} pTSConfigFileName
37
- * @return {import("typescript").ParsedCommandLine} tsconfig as an object
37
+ * @returns {import("typescript").ParsedCommandLine} tsconfig as an object
38
38
  * @throws {Error} when the tsconfig is invalid/ has errors
39
39
  * @throws {TypeError} when the tsconfig is unreadable
40
40
  */
@@ -90,7 +90,7 @@ async function attemptImport(pAbsoluteWebpackConfigFileName) {
90
90
  * module system. If we'd use a dynamic import, these monkey-patches wouldn't
91
91
  * be used.
92
92
  */
93
- /* eslint n/global-require:0, security/detect-non-literal-require:0, import/no-dynamic-require:0 */
93
+ /* oxlint-disable-next-line no-dynamic-require */
94
94
  return require(pAbsoluteWebpackConfigFileName);
95
95
  }
96
96
  } catch (pError) {
@@ -112,7 +112,7 @@ async function attemptImport(pAbsoluteWebpackConfigFileName) {
112
112
  * @param {string} pWebpackConfigFilename
113
113
  * @param {{ [key: string]: any }=} pEnvironment
114
114
  * @param {webpackArgumentsType=} pArguments
115
- * @return {Promise<import("enhanced-resolve").ResolveOptions|{}>} webpack resolve config as an object
115
+ * @returns {Promise<import("enhanced-resolve").ResolveOptions|{}>} webpack resolve config as an object
116
116
  * @throws {Error} when the webpack config isn't usable (e.g. because it
117
117
  * doesn't exist, or because it's invalid)
118
118
  */
@@ -0,0 +1,17 @@
1
+ import { release, platform, arch } from "node:os";
2
+ import meta from "#meta.cjs";
3
+ import {
4
+ getAvailableTranspilers,
5
+ allExtensions,
6
+ } from "#extract/transpile/meta.mjs";
7
+
8
+ export function getEnvironmentInfo() {
9
+ return {
10
+ version: meta.version,
11
+ nodeVersionSupported: meta.engines.node,
12
+ nodeVersionFound: process.version,
13
+ osVersionFound: `${arch()} ${platform()}@${release()}`,
14
+ transpilersFound: getAvailableTranspilers(),
15
+ extensionsFound: structuredClone(allExtensions),
16
+ };
17
+ }
@@ -15,7 +15,7 @@ export function extract(
15
15
  pFileName,
16
16
  pTranspileOptions,
17
17
  ) {
18
- let lDependencies = [];
18
+ const lDependencies = [];
19
19
  const lAST = getASTCached(join(baseDir, pFileName), pTranspileOptions);
20
20
 
21
21
  if (moduleSystems.includes("cjs")) {
@@ -46,7 +46,7 @@ export function getASTFromSource(pFileRecord, pTranspileOptions) {
46
46
  // ecmaVersion 11 necessary for acorn to understand dynamic imports
47
47
  // explicitly passing ecmaVersion is recommended from acorn 8
48
48
  return acornParse(lJavaScriptSource, ACORN_OPTIONS);
49
- } catch (pError) {
49
+ } catch {
50
50
  return acornLooseParse(lJavaScriptSource, ACORN_OPTIONS);
51
51
  }
52
52
  }
@@ -62,7 +62,7 @@ export function getASTFromSource(pFileRecord, pTranspileOptions) {
62
62
  *
63
63
  * @param {string} pFileName - the name of the file to compile
64
64
  * @param {any} pTranspileOptions - options for the transpiler(s) - typically a tsconfig or a babel config
65
- * @return {acorn.Node} - a (javascript) AST
65
+ * @returns {acorn.Node} - a (javascript) AST
66
66
  */
67
67
  export function getASTCached(pFileName, pTranspileOptions) {
68
68
  // taking the transpile options into account of the cache key seems like
@@ -154,7 +154,7 @@ function compareDeps(pLeft, pRight) {
154
154
  * @param {ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
155
155
  * ('flattened' so there's no need for file access on any
156
156
  * 'extends' option in there)
157
- * @return {IDependency[]} an array of dependency objects (see above)
157
+ * @returns {IDependency[]} an array of dependency objects (see above)
158
158
  */
159
159
  export default function getDependencies(
160
160
  pFileName,
@@ -32,7 +32,7 @@ function determineExtractionFunction(pCruiseOptions, pFileName) {
32
32
  * @param {ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
33
33
  * ('flattened' so there's no need for file access on any
34
34
  * 'extends' option in there)
35
- * @return {IDependency[]} an array of dependency objects (see above)
35
+ * @returns {IDependency[]} an array of dependency objects (see above)
36
36
  */
37
37
  export default function extractStats(
38
38
  pFileName,
@@ -100,7 +100,7 @@ function expandGlob(pBaseDirectory, pScannedGlob) {
100
100
  * notably useful attributes:
101
101
  * - exclude - regexp of what to exclude
102
102
  * - includeOnly - regexp what to include
103
- * @return {string[]} paths to files to be gathered.
103
+ * @returns {string[]} paths to files to be gathered.
104
104
  */
105
105
  export default function gatherInitialSources(
106
106
  pFileDirectoryAndGlobArray,
@@ -75,7 +75,7 @@ function getCanonicalModuleName(pModuleName, pProtocol) {
75
75
  */
76
76
  // eslint-disable-next-line complexity
77
77
  export function extractModuleAttributes(pString) {
78
- let lReturnValue = { module: pString };
78
+ const lReturnValue = { module: pString };
79
79
  const lModuleAttributes = pString.match(
80
80
  // eslint-disable-next-line security/detect-unsafe-regex
81
81
  /^(?<protocol>node:|file:|data:|bun:)(?:(?<mimeType>[^,]+),)?(?<module>.+)$/,
@@ -68,7 +68,7 @@ function extractFileDirectoryArray(
68
68
  pResolveOptions,
69
69
  pTranspileOptions,
70
70
  ) {
71
- let lVisited = new Set();
71
+ const lVisited = new Set();
72
72
 
73
73
  bus.debug("extract: gather initial sources");
74
74
  const lInitialSources = gatherInitialSources(
@@ -115,7 +115,7 @@ function determineNodeModuleDependencyTypes(
115
115
  pResolveOptions,
116
116
  ) {
117
117
  /** @type { DependencyType[] } */
118
- let lReturnValue = determineManifestDependencyTypes(
118
+ const lReturnValue = determineManifestDependencyTypes(
119
119
  getPackageRoot(pModuleName),
120
120
  pPackageDeps,
121
121
  pResolveOptions.modules,
@@ -151,6 +151,7 @@ function determineExternalModuleDependencyTypes(
151
151
  pBaseDirectory,
152
152
  ) {
153
153
  /** @type { DependencyType[] } */
154
+ /* oxlint-disable-next-line no-useless-assignment */
154
155
  let lReturnValue = [];
155
156
 
156
157
  if (
@@ -179,7 +180,7 @@ function determineExternalModuleDependencyTypes(
179
180
  * @param {string} pBaseDirectory the base directory dependency cruise is run on
180
181
  * @param {ITranspileOptions} pTranspileOptions
181
182
  *
182
- * @return { DependencyType[] }an array of dependency types for the dependency
183
+ * @returns { DependencyType[] }an array of dependency types for the dependency
183
184
  */
184
185
  // eslint-disable-next-line max-lines-per-function
185
186
  export default function determineDependencyTypes(
@@ -30,14 +30,14 @@ const PACKAGE_JSON_CACHE = new Map();
30
30
  * non-commonJS and are still using node_modules) e.g. '../node_modules/oldash/fp'
31
31
  *
32
32
  * @param {string} pModule a module name
33
- * @return {string} the module name root
33
+ * @returns {string} the module name root
34
34
  */
35
35
  export function getPackageRoot(pModule) {
36
36
  if (!pModule || isRelativeModuleName(pModule)) {
37
37
  return pModule;
38
38
  }
39
39
 
40
- let lPathElements = pModule.split("/");
40
+ const lPathElements = pModule.split("/");
41
41
 
42
42
  if (isScoped(pModule)) {
43
43
  // '@imdoingweirdvoodoo'
@@ -69,7 +69,7 @@ export function getPackageRoot(pModule) {
69
69
  * @param {string} pModuleName The name of the module to get the package.json of
70
70
  * @param {string} pFileDirectory The folder the module resides in. Defaults to the current working directory
71
71
  * @param {any} pResolveOptions options for the resolver
72
- * @return {Record<string, any>} The package.json as a javascript object, or
72
+ * @returns {Record<string, any>} The package.json as a javascript object, or
73
73
  * null if either module or package.json could
74
74
  * not be found
75
75
  */
@@ -104,7 +104,7 @@ export function getPackageJson(pModuleName, pFileDirectory, pResolveOptions) {
104
104
  "manifest-resolution",
105
105
  );
106
106
  lReturnValue = JSON.parse(readFileSync(lPackageJsonFilename, "utf8"));
107
- } catch (pError) {
107
+ } catch {
108
108
  // left empty on purpose
109
109
  }
110
110
  PACKAGE_JSON_CACHE.set(lCacheKey, lReturnValue);
@@ -117,7 +117,7 @@ export function getPackageJson(pModuleName, pFileDirectory, pResolveOptions) {
117
117
  * @param {string} pModuleName The name of the module to get the deprecation status of
118
118
  * @param {string} pFileDirectory The folder the module resides in.
119
119
  * @param {any} pResolveOptions options for the resolver
120
- * @return {boolean} true when deprecated, false in all other cases
120
+ * @returns {boolean} true when deprecated, false in all other cases
121
121
  */
122
122
  export function dependencyIsDeprecated(
123
123
  pModuleName,
@@ -125,7 +125,7 @@ export function dependencyIsDeprecated(
125
125
  pResolveOptions,
126
126
  ) {
127
127
  let lReturnValue = false;
128
- let lPackageJson = getPackageJson(
128
+ const lPackageJson = getPackageJson(
129
129
  pModuleName,
130
130
  pFileDirectory,
131
131
  pResolveOptions,
@@ -144,12 +144,12 @@ export function dependencyIsDeprecated(
144
144
  * @param {string} pModuleName The name of the module to get the license of
145
145
  * @param {string} pFileDirectory The folder the module resides in.
146
146
  * @param {any} pResolveOptions options for the resolver
147
- * @return {string} The module's license string, or '' in case
147
+ * @returns {string} The module's license string, or '' in case
148
148
  * there is no package.json or no license field
149
149
  */
150
150
  export function getLicense(pModuleName, pFileDirectory, pResolveOptions) {
151
151
  let lReturnValue = "";
152
- let lPackageJson = getPackageJson(
152
+ const lPackageJson = getPackageJson(
153
153
  pModuleName,
154
154
  pFileDirectory,
155
155
  pResolveOptions,
@@ -14,7 +14,7 @@ const COMBINED_MANIFEST_CACHE = new Map();
14
14
  *
15
15
  * @param {string} pFileDirectory the folder relative to which to find
16
16
  * the package.json
17
- * @return {any} the contents of the package.json as a javascript
17
+ * @returns {any} the contents of the package.json as a javascript
18
18
  * object or null if the package.json could not be
19
19
  * found or is invalid
20
20
  */
@@ -34,10 +34,10 @@ function getSingleManifest(pFileDirectory) {
34
34
 
35
35
  try {
36
36
  lReturnValue = JSON.parse(lPackageContent);
37
- } catch (pError) {
37
+ } catch {
38
38
  // left empty on purpose
39
39
  }
40
- } catch (pError) {
40
+ } catch {
41
41
  const lNextDirectory = dirname(pFileDirectory);
42
42
 
43
43
  if (lNextDirectory !== pFileDirectory) {
@@ -60,17 +60,17 @@ function maybeReadPackage(pFileDirectory) {
60
60
 
61
61
  try {
62
62
  lReturnValue = JSON.parse(lPackageContent);
63
- } catch (pError) {
63
+ } catch {
64
64
  // left empty on purpose
65
65
  }
66
- } catch (pError) {
66
+ } catch {
67
67
  // left empty on purpose
68
68
  }
69
69
  return lReturnValue;
70
70
  }
71
71
 
72
72
  function getIntermediatePaths(pFileDirectory, pBaseDirectory) {
73
- let lReturnValue = [];
73
+ const lReturnValue = [];
74
74
  let lIntermediate = pFileDirectory;
75
75
 
76
76
  while (
@@ -133,7 +133,7 @@ function getCombinedManifests(pFileDirectory, pBaseDirectory) {
133
133
  * @param {string} pBaseDirectory the directory to consider as base (or 'root')
134
134
  * @param {Boolean} pCombinedDependencies whether to stop (false) or continue
135
135
  * searching until the 'root'
136
- * @return {any} the contents of a package.json as a javascript
136
+ * @returns {any} the contents of a package.json as a javascript
137
137
  * object or null if a package.json could not be
138
138
  * found or is invalid
139
139
  */
@@ -30,6 +30,7 @@ function resolveModule(
30
30
  pFileDirectory,
31
31
  pResolveOptions,
32
32
  ) {
33
+ /* oxlint-disable-next-line no-useless-assignment */
33
34
  let lReturnValue = null;
34
35
 
35
36
  const lStrippedModuleName = stripToModuleName(pModule.module);
@@ -178,7 +179,7 @@ function resolveWithRetry(
178
179
  * detected in
179
180
  * @param {IResolveOptions} pResolveOptions
180
181
  * @param {any} pTranspileOptions
181
- * @return {Partial <IDependency>}
182
+ * @returns {Partial <IDependency>}
182
183
  *
183
184
  *
184
185
  */
@@ -2,7 +2,7 @@ import { uniq } from "#utl/array-util.mjs";
2
2
 
3
3
  /* eslint-disable security/detect-object-injection */
4
4
  function normalizeManifestKeys(pManifest) {
5
- let lReturnValue = pManifest;
5
+ const lReturnValue = pManifest;
6
6
 
7
7
  if (pManifest.bundleDependencies) {
8
8
  pManifest.bundledDependencies = structuredClone(
@@ -60,7 +60,7 @@ function isAnArrayKey(pKey) {
60
60
  * source being perused (e.g. ./packages/sub/package.json)
61
61
  * @param {any} pFurtherManifest the contents of a package.json further away
62
62
  * (e.g. ./package.json)
63
- * @return {any} the combined dependency-keys within those manifests
63
+ * @returns {any} the combined dependency-keys within those manifests
64
64
  */
65
65
  export default function mergeManifests(pClosestManifest, pFurtherManifest) {
66
66
  return getJointUniqueDependencyKeys(
@@ -54,7 +54,7 @@ export function isExternalModule(
54
54
  }
55
55
 
56
56
  function determineFollowableExtensions(pResolveOptions) {
57
- let lReturnValue = new Set(pResolveOptions.extensions);
57
+ const lReturnValue = new Set(pResolveOptions.extensions);
58
58
 
59
59
  // we could include things like pictures, movies, html, xml etc in
60
60
  // lKnownUnfollowables as well. Ijavascript-like sources you don't
@@ -11,7 +11,7 @@ const fileExists = (pFile) => {
11
11
 
12
12
  try {
13
13
  accessSync(pFile, constants.R_OK);
14
- } catch (pError) {
14
+ } catch {
15
15
  FILE_EXISTENCE_CACHE.set(pFile, false);
16
16
  return false;
17
17
  }
@@ -10,7 +10,7 @@ function addResolutionAttributes(
10
10
  pFileDirectory,
11
11
  pResolveOptions,
12
12
  ) {
13
- let lReturnValue = {};
13
+ const lReturnValue = {};
14
14
 
15
15
  if (isBuiltin(pModuleName, pResolveOptions)) {
16
16
  lReturnValue.coreModule = true;
@@ -26,7 +26,7 @@ function addResolutionAttributes(
26
26
  lReturnValue.resolved,
27
27
  pResolveOptions,
28
28
  );
29
- } catch (pError) {
29
+ } catch {
30
30
  lReturnValue.couldNotResolve = true;
31
31
  }
32
32
  }
@@ -7,7 +7,7 @@ export function addLicenseAttribute(
7
7
  { baseDirectory, fileDirectory },
8
8
  pResolveOptions,
9
9
  ) {
10
- let lReturnValue = {};
10
+ const lReturnValue = {};
11
11
  if (
12
12
  pResolveOptions.resolveLicenses &&
13
13
  isExternalModule(
@@ -5,9 +5,9 @@ import pathToPosix from "#utl/path-to-posix.mjs";
5
5
  /** @import {IResolveOptions} from "../../../types/resolve-options.mjs" */
6
6
 
7
7
  /** @type {Map<string, enhancedResolve.Resolver>} */
8
- let gResolvers = new Map();
8
+ const gResolvers = new Map();
9
9
  /** @type {Set<string>} */
10
- let gInitialized = new Set();
10
+ const gInitialized = new Set();
11
11
 
12
12
  /**
13
13
  * Initializes a resolver for the given caching context if not already done
@@ -273,5 +273,6 @@ export default Visitor
273
273
  }
274
274
  }
275
275
  : /* c8 ignore start */
276
+ /* oxlint-disable-next-line typescript/no-extraneous-class */
276
277
  class Empty {};
277
278
  /* c8 ignore stop */
@@ -32,7 +32,7 @@ export function getASTFromSource(pSource) {
32
32
  * return the result from a cache
33
33
  *
34
34
  * @param {string} pFileName - the name of the file to compile
35
- * @return {ModuleItem[]} - an (swc) AST
35
+ * @returns {ModuleItem[]} - an (swc) AST
36
36
  */
37
37
  export function getASTCached(pFileName) {
38
38
  if (CACHE.has(pFileName)) {
@@ -49,7 +49,7 @@ export function clearCache() {
49
49
  }
50
50
 
51
51
  /**
52
- * @return {boolean} - true if the swc compiler is available,
52
+ * @returns {boolean} - true if the swc compiler is available,
53
53
  * false in all other cases
54
54
  */
55
55
  // @ts-expect-error dfdfd
@@ -89,7 +89,7 @@ export function getWrapper(pExtension, pTranspilerOptions) {
89
89
  * @param {{ extension:string; source:string; filename:string; }} pFileRecord Record with source code, an extension and a filename
90
90
  * @param {any} pTranspilerOptions (optional) object with options influencing
91
91
  * the underlying transpiler behavior.
92
- * @return {string} the transpiled version of the file (or the file
92
+ * @returns {string} the transpiled version of the file (or the file
93
93
  * itself when the function could not find a
94
94
  * transpiler matching pExtension
95
95
  */
@@ -155,7 +155,7 @@ export const scannableExtensions = Array.from(
155
155
  * - the version (range) supported
156
156
  * - whether or not it is available in the current environment
157
157
  *
158
- * @return {IAvailableTranspiler[]} an array of supported transpilers
158
+ * @returns {IAvailableTranspiler[]} an array of supported transpilers
159
159
  */
160
160
  export function getAvailableTranspilers() {
161
161
  return ["javascript"]
@@ -38,7 +38,7 @@ export default function tryImportAvailable(pModuleName, pSemanticVersion) {
38
38
  // of course we'd love to use something like import.meta.resolve, but
39
39
  // that's _experimental_, so ¯\_(ツ)_/¯
40
40
  return Boolean(require.resolve(pModuleName));
41
- } catch (pError) {
41
+ } catch {
42
42
  return false;
43
43
  }
44
44
  }
@@ -7,7 +7,7 @@ const typescript = await tryImport(
7
7
  );
8
8
 
9
9
  function getCompilerOptions(pFlavor, pTSConfig) {
10
- let lCompilerOptions = {};
10
+ const lCompilerOptions = {};
11
11
 
12
12
  if (pFlavor === "tsx") {
13
13
  lCompilerOptions.jsx = "react";
@@ -540,7 +540,7 @@ function extractNestedDependencies(
540
540
  pDetectJSDocImports,
541
541
  pDetectProcessBuiltinModuleCalls,
542
542
  ) {
543
- let lResult = [];
543
+ const lResult = [];
544
544
 
545
545
  walk(
546
546
  lResult,
@@ -18,7 +18,7 @@ const CACHE = new Map();
18
18
  * @param {object} pFileRecord Record with source code, an extension and a filename
19
19
  * @param {any} [pTranspileOptions] options for the transpiler(s) - a tsconfig or
20
20
  * a babel config
21
- * @return {object} - a (typescript) AST
21
+ * @returns {object} - a (typescript) AST
22
22
  */
23
23
  export function getASTFromSource(pFileRecord, pTranspileOptions) {
24
24
  let lSource = pFileRecord.source;
@@ -42,7 +42,7 @@ export function getASTFromSource(pFileRecord, pTranspileOptions) {
42
42
  * @param {string} pFileName - the name of the file to compile
43
43
  * @param {any} [pTranspileOptions] options for the transpiler(s) - a tsconfig or
44
44
  * a babel config
45
- * @return {object} - a (typescript) AST
45
+ * @returns {object} - a (typescript) AST
46
46
  */
47
47
  export function getASTCached(pFileName, pTranspileOptions) {
48
48
  if (CACHE.has(pFileName)) {
@@ -61,7 +61,7 @@ export function getASTCached(pFileName, pTranspileOptions) {
61
61
  }
62
62
 
63
63
  /**
64
- * @return {boolean} - true if the typescript compiler is available,
64
+ * @returns {boolean} - true if the typescript compiler is available,
65
65
  * false in all other cases
66
66
  */
67
67
  export const isAvailable = () => typescript !== false;
@@ -34,7 +34,7 @@ export default function addFocus(pModules, pFilter) {
34
34
  ({ source }) => source,
35
35
  );
36
36
  let lReachableModuleNamesArray = [];
37
- let lIndexedModules = new IndexedModuleGraph(pModules);
37
+ const lIndexedModules = new IndexedModuleGraph(pModules);
38
38
 
39
39
  for (const lFocusedModule of lFocusedModuleNames) {
40
40
  lReachableModuleNamesArray = lReachableModuleNamesArray
@@ -16,6 +16,7 @@ function squashDependencyToPattern(pCollapsePattern) {
16
16
  }
17
17
 
18
18
  function determineConsolidatedness(pConsolidated, pCollapseMatch, pSource) {
19
+ /* oxlint-disable-next-line no-useless-assignment */
19
20
  let lReturnValue = false;
20
21
 
21
22
  // if it was already established it's consolidated (e.g. from an earlier
@@ -43,7 +43,7 @@ export default class IndexedModuleGraph {
43
43
 
44
44
  /**
45
45
  * @param {string} pName
46
- * @return {IVertex}
46
+ * @returns {IVertex}
47
47
  */
48
48
  findVertexByName(pName) {
49
49
  return this.#indexedGraph.get(pName);
@@ -71,7 +71,7 @@ export default class IndexedModuleGraph {
71
71
  const lModule = this.#indexedGraph.get(pName);
72
72
 
73
73
  if (lModule && (!pMaxDepth || pDepth <= pMaxDepth)) {
74
- let lDependents = lModule.dependents || [];
74
+ const lDependents = lModule.dependents || [];
75
75
  const lVisited = pVisited.add(pName);
76
76
 
77
77
  // @TODO this works for modules, but not for folders yet
@@ -115,7 +115,7 @@ export default class IndexedModuleGraph {
115
115
  const lModule = this.#indexedGraph.get(pName);
116
116
 
117
117
  if (lModule && (!pMaxDepth || pDepth <= pMaxDepth)) {
118
- let lDependencies = lModule.dependencies;
118
+ const lDependencies = lModule.dependencies;
119
119
  const lVisited = pVisited.add(pName);
120
120
 
121
121
  if (lDependencies.length > 0) {
@@ -169,7 +169,7 @@ export default class IndexedModuleGraph {
169
169
  if (lDependency.name === pTo) {
170
170
  return [this.#geldEdge(lDependency)];
171
171
  }
172
- let lCandidatePath = this.getPath(lDependency.name, pTo, pVisited);
172
+ const lCandidatePath = this.getPath(lDependency.name, pTo, pVisited);
173
173
 
174
174
  if (lCandidatePath.length > 0) {
175
175
  return [this.#geldEdge(lDependency)].concat(lCandidatePath);
@@ -187,7 +187,7 @@ export default class IndexedModuleGraph {
187
187
  * @param {string} pInitialSource The 'source' attribute of the node to be tested (source uniquely identifying a node)
188
188
  * @param {IEdge} pCurrentDependency The 'to' node to be traversed as a dependency object of the previous 'from' traversed
189
189
  * @param {Set<string>=} pVisited Technical parameter - best to leave out of direct calls
190
- * @return {Array<IMiniDependency>} see description above
190
+ * @returns {Array<IMiniDependency>} see description above
191
191
  */
192
192
  #getCycle(pInitialSource, pCurrentDependency, pVisited) {
193
193
  const lVisited = pVisited || new Set();
@@ -239,7 +239,7 @@ export default class IndexedModuleGraph {
239
239
  * (source uniquely identifying a node)
240
240
  * @param {string} pCurrentSource The 'source' attribute of the 'to' node to
241
241
  * be traversed
242
- * @return {Array<IMiniDependency>} see description above
242
+ * @returns {Array<IMiniDependency>} see description above
243
243
  */
244
244
  getCycle(pInitialSource, pCurrentSource) {
245
245
  /** @type {IVertex} */
@@ -3,7 +3,7 @@ export default class ModuleGraphWithDependencySet {
3
3
  #modulesWithDependencySet;
4
4
  /**
5
5
  * Creates a module graph optimized for querying dependents
6
- * @constructor
6
+ * @class
7
7
  * @param {import("../../types/dependency-cruiser.mjs").IModule[]} pModules
8
8
  */
9
9
  constructor(pModules) {
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @param {IFlattenedRuleSet} pRuleSet - The rule set to search in
13
13
  * @param {string} pName - The rule name to look for
14
- * @return {IForbiddenRuleType|undefined} - a rule (or 'undefined' if nothing found)
14
+ * @returns {IForbiddenRuleType|undefined} - a rule (or 'undefined' if nothing found)
15
15
  */
16
16
  export function findRuleByName(pRuleSet, pName) {
17
17
  const lNamedRules = (pRuleSet?.forbidden ?? []).concat(
@@ -34,7 +34,7 @@ function ruleHasALicenseLikeAttribute(pRule) {
34
34
  * Returns false in all other cases
35
35
  *
36
36
  * @param {IFlattenedRuleSet} pRuleSet
37
- * @return {boolean}
37
+ * @returns {boolean}
38
38
  */
39
39
  export function ruleSetHasLicenseRule(pRuleSet) {
40
40
  return (
@@ -45,7 +45,7 @@ export function ruleSetHasLicenseRule(pRuleSet) {
45
45
 
46
46
  /**
47
47
  * @param {IFlattenedRuleSet} pRuleSet
48
- * @return {boolean}
48
+ * @returns {boolean}
49
49
  */
50
50
  export function ruleSetHasDeprecationRule(pRuleSet) {
51
51
  return (
@@ -22,7 +22,7 @@ export default async function cruise(
22
22
  bus.summary("startup: parse options", c(1));
23
23
  const lCruiseOptionsValid = assertCruiseOptionsValid(pCruiseOptions);
24
24
  /** @type {import("../../types/strict-options.mjs").IStrictCruiseOptions} */
25
- let lCruiseOptions = normalizeCruiseOptions(
25
+ const lCruiseOptions = normalizeCruiseOptions(
26
26
  lCruiseOptionsValid,
27
27
  pFileAndDirectoryArray,
28
28
  );
@@ -25,7 +25,7 @@ export function normalizeREProperties(
25
25
  pPropertyContainer,
26
26
  pREProperties = RE_PROPERTIES,
27
27
  ) {
28
- let lPropertyContainer = structuredClone(pPropertyContainer);
28
+ const lPropertyContainer = structuredClone(pPropertyContainer);
29
29
 
30
30
  for (const lProperty of pREProperties) {
31
31
  // lProperty can be nested properties, so we use _.has and _.get