Validate and visualize dependencies. Your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.
MIT License
With these changes you can now define rules on the number of dependents a module must have. E.g. with this rule in the forbidden
section, you can ensure modules in the shared
folder are used at least twice (and if it drops below that you can move them to the sole dependent or remove the module altogether):
// ...
{
name: "no-unshared-in-shared",
from: {
path: "^src",
pathNot: "^src/shared"
},
module: {
path: "^src/shared",
numberOfDependentsLessThan: 2
}
},
// ...
You can read more about it in the rules reference on dependents rules and in the illustrated recipes.
depcruise
and depcruise-fmt
use a reporter that is not shipped with dependency-cruiser via a simple plugin system. See the PR and the FAQ entry for details.Two fixes that makes using babel with TypeScript possible (with @babel/config-typescript) - thanks to @lwolle for providing the reproduction repo to test this against!
bugfix(parse): for the typescript-via-acorn route pass jsx'ness of the original source (#433)
In order of impact:
.dependency-cruiser.js
get a comment on top that declares the type of the exported object. In editors that support this, this will grow you code completion for the configuration.You can use this type declaration in your own .dependency-cruiser.js
configurations too:
/** @type {import('dependency-cruiser').IConfiguration} */
module.exports = {
forbidden: [
...
],
options: {
...
}
}
If you're using a .json configuration - if you point it to the location of the schema (with the
"$schema"
attribute at root level)
it'll get you code completion as well{ "$schema": "https://raw.githubusercontent.com/sverweij/dependency-cruiser/master/src/schema/configuration.schema.json", "forbidden": [ ... ], "options": { ... } }
Do upgrade to 9.21.0 for this to work, though.
20 has proven to be an unlucky number this year, so we skipped it.
dependency-cruiser/config-utl/extract-ts-config
), you need to be on a fairly recent version of node; ^12.19 || >=14.17