diff --git a/.dependency-cruiser.json b/.dependency-cruiser.json
index 213c8d31e..a1abe8cc4 100644
--- a/.dependency-cruiser.json
+++ b/.dependency-cruiser.json
@@ -181,6 +181,7 @@
},
{
"name": "not-reachable-from-folder-index",
+ "comment": "(sample rule to demo reachable rules with capturing groups)",
"severity": "info",
"from": {
"path": "^src/([^/]+)/index\\.js$"
@@ -189,6 +190,13 @@
"path": "^src/$1/",
"reachable": false
}
+ },
+ {
+ "name": "utl-module-not-shared-enough",
+ "comment": "(sample rule to demo demo rules based on dependents)",
+ "severity": "info",
+ "from": { "path": "^src" },
+ "module": { "path": "^src/utl", "numberOfDependentsLessThan": 3 }
}
],
"options": {
@@ -387,8 +395,6 @@
}
}
},
- // "progress": { "type": "cli-feedback" }
"progress": { "type": "performance-log" }
- // "progress": {"type": "none"}
}
}
diff --git a/doc/options-reference.md b/doc/options-reference.md
index 77f62c077..d6b57b3d8 100644
--- a/doc/options-reference.md
+++ b/doc/options-reference.md
@@ -25,6 +25,7 @@
- [mono repo behaviour - combinedDependencies](#mono-repo-behaviour---combinedDependencies)
- [exotic ways to require modules - exoticRequireStrings](#exotic-ways-to-require-modules---exoticrequirestrings)
- [enhancedResolveOptions](#enhancedresolveoptions)
+ - [forceDeriveDependents](#forcederivedependents)
## Filters
@@ -1178,3 +1179,9 @@ E.g. to set the cache duration to 1337ms, you can use this:
The cache duration is limited from 0ms (~ don't use a cache) to 1800000ms (0.5h).
The cacheDuration used here overrides any that might be set in webpack configs.
+
+### `forceDeriveDependents`
+
+Dependency-cruiser will automatically determine whether it needs to derive dependents.
+However, if you want to force them to be derived, you can switch this variable
+to `true`.
diff --git a/doc/recipes/internal-orphans/.dependency-cruiser-options-only.js b/doc/recipes/internal-orphans/.dependency-cruiser-options-only.js
new file mode 100644
index 000000000..8fb560765
--- /dev/null
+++ b/doc/recipes/internal-orphans/.dependency-cruiser-options-only.js
@@ -0,0 +1,40 @@
+/** @type {import('dependency-cruiser').IConfiguration} */
+/** @type {import('../../..').IConfiguration} */
+module.exports = {
+ options: {
+ tsPreCompilationDeps: true,
+ baseDir: "src",
+
+ reporterOptions: {
+ dot: {
+ collapsePattern: "node_modules/[^/]+",
+ theme: {
+ graph: {
+ splines: "ortho",
+ rankdir: "TD",
+ },
+ modules: [
+ {
+ criteria: { source: "^common" },
+ attributes: { fillcolor: "#cccccc" },
+ },
+ ],
+ dependencies: [
+ {
+ criteria: { "rules[0].severity": "error" },
+ attributes: { fontcolor: "red", color: "red" },
+ },
+ {
+ criteria: { "rules[0].severity": "warn" },
+ attributes: { fontcolor: "orange", color: "orange" },
+ },
+ {
+ criteria: { "rules[0].severity": "info" },
+ attributes: { fontcolor: "blue", color: "blue" },
+ },
+ ],
+ },
+ },
+ },
+ },
+};
diff --git a/doc/recipes/internal-orphans/.dependency-cruiser-with-rules.js b/doc/recipes/internal-orphans/.dependency-cruiser-with-rules.js
new file mode 100644
index 000000000..1d573aaa3
--- /dev/null
+++ b/doc/recipes/internal-orphans/.dependency-cruiser-with-rules.js
@@ -0,0 +1,17 @@
+const options = require("./.dependency-cruiser-options-only");
+
+/** @type {import('dependency-cruiser').IConfiguration} */
+module.exports = {
+ forbidden: [
+ {
+ name: "no-unshared-utl",
+ severity: "error",
+ from: {},
+ module: {
+ path: "^do-things/",
+ numberOfDependentsLessThan: 1,
+ },
+ },
+ ],
+ ...options,
+};
diff --git a/doc/recipes/internal-orphans/before.svg b/doc/recipes/internal-orphans/before.svg
new file mode 100644
index 000000000..5f353c8d8
--- /dev/null
+++ b/doc/recipes/internal-orphans/before.svg
@@ -0,0 +1,155 @@
+
+
+
+
+
diff --git a/doc/recipes/internal-orphans/rules-applied.svg b/doc/recipes/internal-orphans/rules-applied.svg
new file mode 100644
index 000000000..3621f7a0a
--- /dev/null
+++ b/doc/recipes/internal-orphans/rules-applied.svg
@@ -0,0 +1,155 @@
+
+
+
+
+
diff --git a/doc/recipes/internal-orphans/runme.sh b/doc/recipes/internal-orphans/runme.sh
new file mode 100644
index 000000000..e98b2aa63
--- /dev/null
+++ b/doc/recipes/internal-orphans/runme.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+
+node ../../../bin/dependency-cruise.js . -c .dependency-cruiser-options-only.js -p -T dot | dot -T svg > before.svg
+node ../../../bin/dependency-cruise.js . -c .dependency-cruiser-with-rules.js -p -T dot | dot -T svg > rules-applied.svg
diff --git a/doc/recipes/internal-orphans/src/do-things/analyze.ts b/doc/recipes/internal-orphans/src/do-things/analyze.ts
new file mode 100644
index 000000000..e69de29bb
diff --git a/doc/recipes/internal-orphans/src/do-things/ingest.ts b/doc/recipes/internal-orphans/src/do-things/ingest.ts
new file mode 100644
index 000000000..e69de29bb
diff --git a/doc/recipes/internal-orphans/src/do-things/main.ts b/doc/recipes/internal-orphans/src/do-things/main.ts
new file mode 100644
index 000000000..4c105dd75
--- /dev/null
+++ b/doc/recipes/internal-orphans/src/do-things/main.ts
@@ -0,0 +1,4 @@
+import "./ingest";
+import "./analyze";
+import "./parse";
+import "./validate";
diff --git a/doc/recipes/internal-orphans/src/do-things/not-used-but-using-path.ts b/doc/recipes/internal-orphans/src/do-things/not-used-but-using-path.ts
new file mode 100644
index 000000000..1a8e03caa
--- /dev/null
+++ b/doc/recipes/internal-orphans/src/do-things/not-used-but-using-path.ts
@@ -0,0 +1 @@
+import "path";
diff --git a/doc/recipes/internal-orphans/src/do-things/parse.ts b/doc/recipes/internal-orphans/src/do-things/parse.ts
new file mode 100644
index 000000000..e69de29bb
diff --git a/doc/recipes/internal-orphans/src/do-things/report.ts b/doc/recipes/internal-orphans/src/do-things/report.ts
new file mode 100644
index 000000000..160f24dfe
--- /dev/null
+++ b/doc/recipes/internal-orphans/src/do-things/report.ts
@@ -0,0 +1 @@
+import "snodash";
diff --git a/doc/recipes/internal-orphans/src/do-things/validate.ts b/doc/recipes/internal-orphans/src/do-things/validate.ts
new file mode 100644
index 000000000..e69de29bb
diff --git a/doc/recipes/internal-orphans/src/index.ts b/doc/recipes/internal-orphans/src/index.ts
new file mode 100644
index 000000000..827f82123
--- /dev/null
+++ b/doc/recipes/internal-orphans/src/index.ts
@@ -0,0 +1 @@
+import "./do-things/main";
diff --git a/doc/recipes/internal-orphans/src/node_modules/snodash/index.js b/doc/recipes/internal-orphans/src/node_modules/snodash/index.js
new file mode 100644
index 000000000..e69de29bb
diff --git a/doc/recipes/internal-orphans/src/node_modules/snodash/package.json b/doc/recipes/internal-orphans/src/node_modules/snodash/package.json
new file mode 100644
index 000000000..f58f7ddec
--- /dev/null
+++ b/doc/recipes/internal-orphans/src/node_modules/snodash/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "snodash",
+ "version": "1.0.0",
+ "description": "dummy package",
+ "main": "index.js",
+ "author": "Nigel Tufnel",
+ "license": "MIT"
+}
diff --git a/doc/recipes/internal-orphans/src/package.json b/doc/recipes/internal-orphans/src/package.json
new file mode 100644
index 000000000..dd2a5a997
--- /dev/null
+++ b/doc/recipes/internal-orphans/src/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "internal-orphans",
+ "version": "1.0.0",
+ "description": "This is Spnal Tap",
+ "dependencies": {
+ "snodash": "1.0.0"
+ },
+ "author": "David St. Hubbins",
+ "license": "MIT"
+}
diff --git a/doc/recipes/isolating-peer-folders/before.svg b/doc/recipes/isolating-peer-folders/before.svg
index f64a48b38..b48655522 100644
--- a/doc/recipes/isolating-peer-folders/before.svg
+++ b/doc/recipes/isolating-peer-folders/before.svg
@@ -1,7 +1,7 @@
-