Validate and visualize dependencies. Your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.
MIT License
Published by sverweij over 7 years ago
The changes in this release are not that big, they are however 'breaking' a.c.t. the previous releases. Despite this, the migration effort will probably be small to non-existent. Here's the list of breaking changes, so you can judge for yourself:
Maintenance release: with only an ⬆️ of some dependencies (a.o. typescript, coffee-script, acorn, ajv)
v1.15.7 is not published to npm. If you need it over there let me know.
"([^\\.])/(.+)$"
stuff before the slash is available in $1
, after the slash in $2
- and the whole match is available in $0
.to
of your rule:path
you want to be matched is between brackets."^src/([^/]+)/.+"
from
part of your rule:$1
in path
pathNot
rules. Like so: "pathNot": "^src/$1/.+"
.ownFolder
attribute is deprecated. 'matching groups' offer more flexibility and more straightforward semantics, while they can achieve the same.--init-rules
option. This creates a .dependency-cruiser.json with some useful rules in it to the current folder and exits. See below for the 'starter kit' rules.--info
option a bitThe rules:
Rule | Description |
---|---|
not-to-test |
Don't allow dependencies from outside the test folder to test |
not-to-spec |
Don't allow dependencies to (typescript/ javascript/ coffeescript) spec files |
no-deprecated-core |
Warn about dependencies on deprecated core modules. |
not-to-unresolvable |
Don't allow dependencies on modules dependency-cruiser can't resolve to files on disk (which probably means they don't exist) |
not-to-dev-dep |
Don't allow dependencies from src/app/lib to a development only package |
no-non-package-json |
Don't allow dependencies to packages not in package.json (except from within node_modules) |
optional-deps-used |
Inform about the use of dependencies labeled as 'optional' (so you can ensure their imports a are sufficiently managed) |
peer-deps-used |
Warn about the use of a peer dependency (peer dependencies are deprecated with the advent of npm 3 - and probably gone with version 4). |
no-duplicate-dep-types |
Warn if a dependency occurs in your package.json more than once (technically: has more than one dependency type) |
moreThanOneDependencyType
property to the validation rule format so it is possible to check on "multiple inclusions" (e.g. both in dependencies
and in devDependencies
) see rules.md#more-than-one-dependencytype-per-dependency for an example.dependencyTypes
when they're on a 'from' side in the output objectDeprecated means: will definitely be gone in version v2.0.0 and higher.
depcruise --info
) dependency-cruiserlivescript
is available - but if it isn't dependency-cruiser will happily chug along on the other supported languages (currently javascript, typescript and coffee script)--info
command line option that shows what alt-js/ transpilers dependency-cruiser thinks are supported.Changes since v1.5.0:
coreModule
or notcouldNotResolve
).dependency-cruise -v my-dependency-rules.json -T err src
note the utl/map-1-4-ruleset-to1-5.js
script takes a pre 1.5.0 ruleset and transforms it to a post 1.5.0 one:
node url/utl/map-1-4-ruleset-to1-5.js your-pre-1-5-0-ruleset.json
from
and to
are now objects so they can contain multiple properties to match against.
from
and to
:
path
- a regular expression of a path to match againstpathNot
- match against all paths except the one matching this regular expressionto
:coreModule
- a boolean value indicating whether to match against node.js core modulescouldNotResolve
- a boolean value indicating whether to match against modules dependency cruiser could resolve them to something on disk (or a core module)level
renamed to severity
severity
can now be error
, warning
and info