JavaScript HTML Makefile TypeScript Vue CoffeeScript
Clone or download
Permalink
Failed to load latest commit information.
.github ci(issues): set up stale robot Feb 25, 2018
bin feature(typescript): support passing tsconfigs and using its compileO… Aug 4, 2018
doc feature(typescript): add tsConfig as an option into the dependency-cr… Aug 14, 2018
docs doc(site): remove scrolling behavior for divs Jul 23, 2018
src doc(cli): move flattenTypeScriptConfig jsdoc to the right spot Aug 14, 2018
test feature(typescript): add tsConfig as an option into the dependency-cr… Aug 14, 2018
types feature(typescript): support passing tsconfigs and using its compileO… Aug 4, 2018
.codeclimate.yml ci(codeclimate): document check exceptions Jun 2, 2018
.dependency-cruiser-custom.json WIP: add support for web pack's config resolution alias (#50) Jun 23, 2018
.eslintrc.json refactor(resolve): split the resolution main thing in two Jun 8, 2018
.gitignore ci(test): make lowering test coverage break the build Feb 25, 2018
.gitlab-ci.yml build(npm): 👞 nsp as it's now baked into npm Jul 17, 2018
.npmrc build(npm): make sure newly installed deps are pinned Mar 23, 2018
.travis.yml build(npm): 👞 nsp as it's now baked into npm Jul 17, 2018
CODE_OF_CONDUCT.md 📖 updates the contributor coventant to version 1.4.0 Dec 10, 2016
LICENSE doc(license): happy 2018 Jan 16, 2018
Makefile build(npm): replace .npmignore with a files array in package.json Jul 17, 2018
README.md doc(readme): add link to the faq contact section in the readme Jul 21, 2018
appveyor.yml ci(appveyor): use npm test i/o npm run test:long Jul 8, 2018
package.json build(npm): ⬆️ eslint-plugin-import, eslint-plugin-mocha Aug 14, 2018
tslint.json refactor(types): make the type definition tslint recommended compliant Jan 21, 2018

README.md

Dependency cruiser Dependency cruiser

Validate and visualize dependencies. With your rules. JavaScript. TypeScript. CoffeeScript. ES6, CommonJS, AMD.

What's this do?

Snazzy dot output to whet your appetite

This runs through the dependencies in any JavaScript, TypeScript, LiveScript or CoffeeScript project and ...

  • ... validates them against (your own) rules
  • ... reports violated rules
    • in text (for your builds)
    • in graphics (for your eyeballs)

As a side effect it can generate cool dependency graphs you can stick on the wall to impress your grandma.

How do I use it?

Install it

  • npm install --save-dev dependency-cruiser to use it as a validator in your project or...
  • npm install --global dependency-cruiser if you just want to to inspect multiple projects.

Show stuff to your grandma

To create a graph of the dependencies in your src folder, you'd run dependency cruiser with output type dot and run GraphViz dot on the result. In a one liner:

depcruise --exclude "^node_modules" --output-type dot src | dot -T svg > dependencygraph.svg
  • You can read more about what you can do with --exclude and other command line options in the command line interface documentation.
  • Real world samples contains dependency cruises of some of the most used projects on npm.

Validate things

Declare some rules

The easy way to get you started:

depcruise --init

This will create a .dependency-cruiser.json with some rules that make sense in most projects (detecting circular dependencies, dependencies missing in package.json, orphans, production code relying on dev- or optionalDependencies, ...).

Start adding your rules by tweaking that file.

Sample rule:

{
    "forbidden": [{
        "name": "not-to-test",
        "comment": "don't allow dependencies from outside the test folder to test",
        "severity": "error",
        "from": { "pathNot": "^test" },
        "to": { "path": "^test" }
    }]
}

Report them

depcruise --validate .dependency-cruiser.json src

This will validate against your rules and shows any violations in an eslint-like format:

sample err output

There's more ways to report validations; in a graph (like the one on top of this readme) or in a table.

  • Read more about the err, dot, csv and html reporters in the command line interface documentation.
  • dependency-cruiser uses itself to check on itself in its own build process; see the decpruise script in the package.json

I want to know more!

You've come to the right place :-) :

License

MIT

Thanks

  • Marijn Haverbeke and other people who collaborated on acorn - the excellent JavaScript parser dependency-cruiser uses to infer dependencies.

Build status

build status Build status Build Status coverage Maintainability Test Coverage total downloads on npm

Made with 🤘 in Holland.