Giter Club home page Giter Club logo

dependency-cruiser's Introduction

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, 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 dependency-cruise target in the Makefile

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 coverage bitHound Overall Score bitHound Dependencies bitHound Dev Dependencies npm stable version total downloads on npm

Made with ๐Ÿค˜ in Holland.

dependency-cruiser's People

Contributors

ajafff avatar hellopao avatar jessitron avatar sverweij avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.