dependency-cruiser
Advanced tools
Comparing version 1.4.0 to 1.5.0
{ | ||
"allowed": [{ | ||
"from": "^(src|test)", | ||
"to": "^(src|node_modules)" | ||
},{ | ||
"from": "^(src|test)", | ||
"to": "^(fs|path)$", | ||
"comment": "because these core modules make sense here" | ||
},{ | ||
"from": "^bin", | ||
"to": "^src/index\\.js" | ||
},{ | ||
"from": "^src/index\\.js", | ||
"to": "^package\\.json$" | ||
},{ | ||
"from": "^node_modules", | ||
"to": ".+" | ||
},{ | ||
"from": "^test", | ||
"to": "^test" | ||
} | ||
], | ||
"from": { "path": "^(src|test)" }, | ||
"to": { "path": "^(src|node_modules)" } | ||
}, { | ||
"comment": "because these core modules make sense here", | ||
"from": { "path": "^(src|test)" }, | ||
"to": { "path": "^(fs|path)$" } | ||
}, { | ||
"from": { "path": "^bin" }, | ||
"to": { "path": "^src/index\\.js" } | ||
}, { | ||
"from": { "path": "^src/index\\.js" }, | ||
"to": { "path": "^package\\.json$" } | ||
}, { | ||
"comment": "node_modules may depend core modules", | ||
"from": { "path": "^node_modules" }, | ||
"to": { "coreModule": false } | ||
}, { | ||
"comment": "node_modules may depend on node_modules", | ||
"from": { "path": "^node_modules" }, | ||
"to": { "path": "^node_modules" } | ||
}, { | ||
"from": { "path": "^test" }, | ||
"to": { "path": "^test" } | ||
}], | ||
"forbidden": [{ | ||
"name": "no-dep-on-test", | ||
"level": "error", | ||
"from": "^src", | ||
"to": "^test" | ||
},{ | ||
"name": "no-external-to-here", | ||
"level": "information", | ||
"from": "node_modules", | ||
"to": "^(src|test|lib)", | ||
"comment": "you never know..." | ||
}] | ||
"name": "no-dep-on-test", | ||
"severity": "error", | ||
"from": { "path": "^src" }, | ||
"to": { "path": "^test" } | ||
}, { | ||
"name": "no-external-to-here", | ||
"comment": "you never know...", | ||
"severity": "info", | ||
"from": { "path": "node_modules" }, | ||
"to": { "path": "^(src|test|lib)" } | ||
}, { | ||
"name": "not-to-unresolvable", | ||
"severity": "error", | ||
"from": { }, | ||
"to": { "couldNotResolve": true } | ||
}] | ||
} |
error sub-not-allowed: test/fixtures/cjs/root_one.js => test/fixtures/cjs/sub/dir.js | ||
error sub-not-allowed: test/fixtures/cjs/sub/dir.js => test/fixtures/cjs/sub/depindir.js | ||
error sub-not-allowed: test/fixtures/cjs/two_only_one.js => test/fixtures/cjs/sub/dir.js | ||
3 violations found | ||
2 violations found | ||
[ | ||
{ | ||
"source": "test/fixtures/cjs/one_only_one.js", | ||
"dependencies": [ | ||
{ | ||
"module": "path", | ||
"resolved": "path", | ||
"moduleSystem": "cjs", | ||
"coreModule": true, | ||
{ | ||
"source": "test/fixtures/cjs/one_only_one.js", | ||
"dependencies": [ | ||
{ | ||
"resolved": "path", | ||
"coreModule": true, | ||
"followable": false, | ||
"couldNotResolve": false, | ||
"module": "path", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "path", | ||
"followable": false, | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "path", | ||
"followable": false, | ||
"coreModule": true, | ||
"dependencies": [] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/one_only_two.js", | ||
"dependencies": [ | ||
{ | ||
"module": "path", | ||
"resolved": "path", | ||
"moduleSystem": "cjs", | ||
"coreModule": true, | ||
"couldNotResolve": false, | ||
"dependencies": [] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/one_only_two.js", | ||
"dependencies": [ | ||
{ | ||
"resolved": "path", | ||
"coreModule": true, | ||
"followable": false, | ||
"couldNotResolve": false, | ||
"module": "path", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/root_one.js", | ||
"dependencies": [ | ||
{ | ||
"resolved": "test/fixtures/cjs/one_only_one.js", | ||
"coreModule": false, | ||
"followable": true, | ||
"couldNotResolve": false, | ||
"module": "./one_only_one", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
}, | ||
{ | ||
"resolved": "test/fixtures/cjs/one_only_two.js", | ||
"coreModule": false, | ||
"followable": true, | ||
"couldNotResolve": false, | ||
"module": "./one_only_two", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
}, | ||
{ | ||
"resolved": "test/fixtures/cjs/shared.js", | ||
"coreModule": false, | ||
"followable": true, | ||
"couldNotResolve": false, | ||
"module": "./shared", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
}, | ||
{ | ||
"resolved": "test/fixtures/cjs/sub/dir.js", | ||
"coreModule": false, | ||
"followable": true, | ||
"couldNotResolve": false, | ||
"module": "./sub/dir", | ||
"moduleSystem": "cjs", | ||
"valid": false, | ||
"rule": { | ||
"severity": "error", | ||
"name": "sub-not-allowed" | ||
} | ||
}, | ||
{ | ||
"resolved": "fs", | ||
"coreModule": true, | ||
"followable": false, | ||
"couldNotResolve": false, | ||
"module": "fs", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "fs", | ||
"followable": false, | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/root_one.js", | ||
"dependencies": [ | ||
{ | ||
"module": "./one_only_one", | ||
"resolved": "test/fixtures/cjs/one_only_one.js", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": true, | ||
"valid": true | ||
}, | ||
{ | ||
"module": "./one_only_two", | ||
"resolved": "test/fixtures/cjs/one_only_two.js", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": true, | ||
"valid": true | ||
}, | ||
{ | ||
"module": "./shared", | ||
"resolved": "test/fixtures/cjs/shared.js", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": true, | ||
"valid": true | ||
}, | ||
{ | ||
"module": "./sub/dir", | ||
"resolved": "test/fixtures/cjs/sub/dir.js", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": true, | ||
"valid": false, | ||
"rule": { | ||
"level": "error", | ||
"name": "sub-not-allowed" | ||
} | ||
}, | ||
{ | ||
"module": "fs", | ||
"resolved": "fs", | ||
"moduleSystem": "cjs", | ||
"coreModule": true, | ||
"couldNotResolve": false, | ||
"dependencies": [] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/shared.js", | ||
"dependencies": [ | ||
{ | ||
"resolved": "path", | ||
"coreModule": true, | ||
"followable": false, | ||
"couldNotResolve": false, | ||
"module": "path", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/sub/dir.js", | ||
"dependencies": [ | ||
{ | ||
"resolved": "test/fixtures/cjs/sub/depindir.js", | ||
"coreModule": false, | ||
"followable": true, | ||
"couldNotResolve": false, | ||
"module": "./depindir", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
}, | ||
{ | ||
"resolved": "path", | ||
"coreModule": true, | ||
"followable": false, | ||
"couldNotResolve": false, | ||
"module": "path", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/sub/depindir.js", | ||
"dependencies": [ | ||
{ | ||
"resolved": "path", | ||
"coreModule": true, | ||
"followable": false, | ||
"couldNotResolve": false, | ||
"module": "path", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/root_two.js", | ||
"dependencies": [ | ||
{ | ||
"resolved": "test/fixtures/cjs/shared.js", | ||
"coreModule": false, | ||
"followable": true, | ||
"couldNotResolve": false, | ||
"module": "./shared", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
}, | ||
{ | ||
"resolved": "test/fixtures/cjs/somedata.json", | ||
"coreModule": false, | ||
"followable": false, | ||
"couldNotResolve": false, | ||
"module": "./somedata.json", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
}, | ||
{ | ||
"resolved": "test/fixtures/cjs/two_only_one.js", | ||
"coreModule": false, | ||
"followable": true, | ||
"couldNotResolve": false, | ||
"module": "./two_only_one", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
}, | ||
{ | ||
"resolved": "http", | ||
"coreModule": true, | ||
"followable": false, | ||
"couldNotResolve": false, | ||
"module": "http", | ||
"moduleSystem": "cjs", | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/somedata.json", | ||
"followable": false, | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "fs", | ||
"followable": false, | ||
"coreModule": true, | ||
"dependencies": [] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/shared.js", | ||
"dependencies": [ | ||
{ | ||
"module": "path", | ||
"resolved": "path", | ||
"moduleSystem": "cjs", | ||
"coreModule": true, | ||
"followable": false, | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/sub/dir.js", | ||
"dependencies": [ | ||
{ | ||
"module": "./depindir", | ||
"resolved": "test/fixtures/cjs/sub/depindir.js", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": true, | ||
"valid": false, | ||
"rule": { | ||
"level": "error", | ||
"name": "sub-not-allowed" | ||
} | ||
}, | ||
{ | ||
"module": "path", | ||
"resolved": "path", | ||
"moduleSystem": "cjs", | ||
"coreModule": true, | ||
"couldNotResolve": false, | ||
"dependencies": [] | ||
}, | ||
{ | ||
"source": "http", | ||
"followable": false, | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/sub/depindir.js", | ||
"dependencies": [ | ||
{ | ||
"module": "path", | ||
"resolved": "path", | ||
"moduleSystem": "cjs", | ||
"coreModule": true, | ||
"followable": false, | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/root_two.js", | ||
"dependencies": [ | ||
{ | ||
"module": "./shared", | ||
"resolved": "test/fixtures/cjs/shared.js", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": true, | ||
"valid": true | ||
}, | ||
{ | ||
"module": "./somedata.json", | ||
"resolved": "test/fixtures/cjs/somedata.json", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": false, | ||
"valid": true | ||
}, | ||
{ | ||
"module": "./two_only_one", | ||
"resolved": "test/fixtures/cjs/two_only_one.js", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": true, | ||
"valid": true | ||
}, | ||
{ | ||
"module": "http", | ||
"resolved": "http", | ||
"moduleSystem": "cjs", | ||
"coreModule": true, | ||
"followable": false, | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/somedata.json", | ||
"followable": false, | ||
"coreModule": false, | ||
"dependencies": [] | ||
}, | ||
{ | ||
"source": "http", | ||
"followable": false, | ||
"coreModule": true, | ||
"dependencies": [] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/two_only_one.js", | ||
"dependencies": [ | ||
{ | ||
"module": "./sub/dir", | ||
"resolved": "test/fixtures/cjs/sub/dir.js", | ||
"moduleSystem": "cjs", | ||
"coreModule": false, | ||
"followable": true, | ||
"valid": false, | ||
"rule": { | ||
"level": "error", | ||
"name": "sub-not-allowed" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
"couldNotResolve": false, | ||
"dependencies": [] | ||
}, | ||
{ | ||
"source": "test/fixtures/cjs/two_only_one.js", | ||
"dependencies": [ | ||
{ | ||
"resolved": "test/fixtures/cjs/sub/dir.js", | ||
"coreModule": false, | ||
"followable": true, | ||
"couldNotResolve": false, | ||
"module": "./sub/dir", | ||
"moduleSystem": "cjs", | ||
"valid": false, | ||
"rule": { | ||
"severity": "error", | ||
"name": "sub-not-allowed" | ||
} | ||
} | ||
] | ||
} | ||
] |
@@ -12,9 +12,10 @@ # Daphne's dependencies | ||
"name": "sub-not-allowed", | ||
"level": "error", | ||
"from": ".+", | ||
"to": "sub" | ||
"severity": "error", | ||
"from": { "pathNot": "sub" }, | ||
"to": { "path": "sub" } | ||
}] | ||
} | ||
``` | ||
Dependencies from everywhere to the `sub` folder are _verboten_ from now on. :heart:. | ||
Dependencies from everywhere to the `sub` folder are _verboten_ from now on. | ||
Except when they come from sub itself. :heart:. | ||
@@ -42,8 +43,7 @@ ## dot | ||
error sub-not-allowed: test/fixtures/cjs/root_one.js => test/fixtures/cjs/sub/dir.js | ||
error sub-not-allowed: test/fixtures/cjs/sub/dir.js => test/fixtures/cjs/sub/depindir.js | ||
error sub-not-allowed: test/fixtures/cjs/two_only_one.js => test/fixtures/cjs/sub/dir.js | ||
3 violations found | ||
2 violations found | ||
make: *** [dependency-cruise] Error 3 | ||
make: *** [dependency-cruise] Error 2 | ||
``` | ||
@@ -67,4 +67,4 @@ (Daphne also loves how `-T err` just _shuts up_ and _stays out of her way_ | ||
(_Actually the build server didn't. You know that. Build servers aren't that | ||
nice. In fact that darn clever Daphne put it in her Makefile. Over where she | ||
lets the coverage reporting happen. The build server just ran it blindly._) | ||
nice. In fact that darn clever Daphne put it in her Makefile. Near her coverage | ||
reporting. The build server just ran it blindly._) | ||
@@ -71,0 +71,0 @@ ![sample html output](https://raw.githubusercontent.com/sverweij/dependency-cruiser/master/doc/assets/sample-html-output.png) |
{ | ||
"name": "dependency-cruiser", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Visualize and validate javascript dependencies. With your rules. ES6, CommonJS, AMD", | ||
@@ -38,3 +38,3 @@ "bin": { | ||
"mocha": "3.2.0", | ||
"npm-check-updates": "2.8.6", | ||
"npm-check-updates": "2.8.7", | ||
"nsp": "2.6.2" | ||
@@ -41,0 +41,0 @@ }, |
102
README.md
@@ -40,5 +40,4 @@ # Dependency cruiser ![Dependency cruiser](https://raw.githubusercontent.com/sverweij/dependency-cruiser/master/doc/assets/ZKH-Dependency-recolored-160.png) | ||
-M, --system <items> list of module systems (default: amd,cjs,es6) | ||
-T, --output-type <type> output type - html|dot|csv|err|json (default:json) | ||
-v, --validate validate against rules in .dependency-cruiser.json | ||
-r, --rules-file <file> read rules from <file> (default: .dependency-cruiser.json) | ||
-T, --output-type <type> output type - html|dot|err|json (default:json) | ||
-v, --validate [file] validate against rules from [file] (default: .dependency-cruiser.json) | ||
``` | ||
@@ -68,7 +67,6 @@ | ||
### err | ||
For use in build scripts, in combination with `--validate` and/ or | ||
`--rules-file` e.g. | ||
For use in build scripts, in combination with `--validate` e.g. | ||
```sh | ||
dependency-cruise -T err --rules-file my-depcruise-rules.json src | ||
dependency-cruise -T err --validate my-depcruise-rules.json src | ||
``` | ||
@@ -107,7 +105,6 @@ | ||
Validates against a list of rules in a rules file. This defaults to a file | ||
called `.dependency-cruiser.json`, but you can specify your own rules file | ||
with `--rules-file`. | ||
called `.dependency-cruiser.json`, but you can specify your own rules file. | ||
```shell | ||
dependency-cruise -T err -x node_modules -v --rules-file my.rules.json | ||
dependency-cruise -T err -x node_modules --validate my.rules.json | ||
``` | ||
@@ -124,4 +121,4 @@ | ||
"forbidden": [{ | ||
"from": "^src", | ||
"to": "^test" | ||
"from": {"path": "^src"}, | ||
"to": {"path": "^test"} | ||
}] | ||
@@ -131,4 +128,4 @@ } | ||
You can optionally specify a name and an error level ('error', 'warning' (the | ||
default) and 'information') with them that will appear in some reporters: | ||
You can optionally specify a name and an error severity ('error', 'warn' (the | ||
default) and 'info') with them that will appear in some reporters: | ||
@@ -139,5 +136,5 @@ ```json | ||
"name": "no-src-to-test", | ||
"level": "error", | ||
"from": "^src", | ||
"to": "^test" | ||
"severity": "error", | ||
"from": {"path": "^src"}, | ||
"to": {"path": "^test"} | ||
}] | ||
@@ -156,2 +153,3 @@ } | ||
dependencies to stuff in `node_modules`. | ||
- modules can't have references to modules that can't be resolved | ||
@@ -162,43 +160,41 @@ | ||
"allowed": [{ | ||
"from": "^src", | ||
"to": "^(src|node_modules)" | ||
},{ | ||
"from": "^src", | ||
"to": "^(fs|path)$", | ||
"comment": "other core modules don't make sense for the current project" | ||
},{ | ||
"from": "^node_modules", | ||
"to": ".+", | ||
"comment": "outside our circle of influence" | ||
} | ||
], | ||
"from": { "path": "^(src|test)" }, | ||
"to": { "path": "^(src|node_modules)" } | ||
}, { | ||
"comment": "because these are the only core that modules make sense here", | ||
"from": { "path": "^(src|test)" }, | ||
"to": { "coreModule": true, "path": "^(fs|path)$" } | ||
}, { | ||
"from": { "path": "^bin" }, | ||
"to": { "path": "^src/index\\.js" } | ||
}, { | ||
"from": { "path": "^src/index\\.js" }, | ||
"to": { "path": "^package\\.json$" } | ||
}, { | ||
"from": { "path": "^node_modules" }, | ||
"to": { "path": "^node_modules" } | ||
}, { | ||
"from": { "path": "^test" }, | ||
"to": { "path": "^test" } | ||
}], | ||
"forbidden": [{ | ||
"from": "^src", | ||
"to": "^test", | ||
"name": "no-src-to-test", | ||
"level": "error" | ||
},{ | ||
"from": "dependencyless\\.js", | ||
"to": ".+", | ||
"comment": "level & name default to 'level' and 'unnamed'" | ||
},{ | ||
"from": "externalDependencyLess\\.js", | ||
"to": "node_modules", | ||
"level": "warning" | ||
},{ | ||
"from": "node_modules", | ||
"to": "^(src|test|lib)", | ||
"name": "external-depends-on-you", | ||
"level": "error", | ||
"comment": "well, you never know ..." | ||
} | ||
] | ||
"name": "no-dep-on-test", | ||
"severity": "error", | ||
"from": { "path": "^src" }, | ||
"to": { "path": "^test" } | ||
}, { | ||
"name": "no-external-to-here", | ||
"comment": "you never know...", | ||
"severity": "info", | ||
"from": { "path": "node_modules" }, | ||
"to": { "path": "^(src|test|lib)" } | ||
}, { | ||
"name": "not-to-unresolvable", | ||
"severity": "error", | ||
"from": {}, | ||
"to": { "couldNotResolve": true } | ||
}] | ||
} | ||
``` | ||
### --rules-file implies --validate | ||
Because if you supply a rules file, you probably intend them to | ||
be used in validation, dependency-cruiser assumes `--validate` | ||
to be passed even if it wasn't. | ||
## License | ||
@@ -205,0 +201,0 @@ [MIT](LICENSE) |
"use strict"; | ||
const fs = require("fs"); | ||
const extract = require("../extract").extract; | ||
const validateParameters = require("./parameterValidator").validate; | ||
const normalizeOptions = require("./optionNormalizer").normalize; | ||
const reportHtml = require("../report/htmlReporter").render; | ||
const reportJson = require("../report/jsonReporter").render; | ||
const reportDot = require("../report/dotReporter").render; | ||
const reportCsv = require("../report/csvReporter").render; | ||
const reportErr = require("../report/errReporter").render; | ||
const extract = require("../extract"); | ||
const validateParameters = require("./parameterValidator"); | ||
const normalizeOptions = require("./optionNormalizer"); | ||
const reportHtml = require("../report/htmlReporter"); | ||
const reportJson = require("../report/jsonReporter"); | ||
const reportDot = require("../report/dotReporter"); | ||
const reportCsv = require("../report/csvReporter"); | ||
const reportErr = require("../report/errReporter"); | ||
@@ -50,3 +50,3 @@ const TYPE2REPORTER = { | ||
exports.main = (pDirOrFile, pOptions) => { | ||
module.exports = (pDirOrFile, pOptions) => { | ||
try { | ||
@@ -53,0 +53,0 @@ validateParameters(pDirOrFile, pOptions); |
@@ -19,12 +19,2 @@ "use strict"; | ||
function normalizeValidation(pValidate, pRulesFile) { | ||
if (pRulesFile){ | ||
return true; | ||
} | ||
if (Boolean(pValidate)){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
function normalize(pOptions){ | ||
@@ -39,9 +29,16 @@ pOptions = _.defaults(pOptions, { | ||
pOptions.moduleSystems = normalizeModuleSystems(pOptions.system); | ||
pOptions.validate = normalizeValidation(pOptions.validate, pOptions.rulesFile); | ||
if (pOptions.validate && !pOptions.hasOwnProperty("rulesFile")){ | ||
pOptions.rulesFile = ".dependency-cruiser.json"; | ||
if (pOptions.hasOwnProperty("validate")){ | ||
if (typeof pOptions.validate === 'boolean' && pOptions.validate){ | ||
pOptions.rulesFile = ".dependency-cruiser.json"; | ||
} else { | ||
pOptions.rulesFile = pOptions.validate; | ||
} | ||
} | ||
pOptions.validate = pOptions.hasOwnProperty("validate"); | ||
return pOptions; | ||
} | ||
exports.normalize = normalize; | ||
module.exports = normalize; |
@@ -43,16 +43,6 @@ "use strict"; | ||
function validateValidationCombinations(pOptions) { | ||
if ( | ||
pOptions.hasOwnProperty("validate") && | ||
Boolean(pOptions.rulesFile) && | ||
!(Boolean(pOptions.validate)) | ||
){ | ||
throw Error( | ||
`Confused here. You passed a rules file, but don't want to validate? :-S` | ||
); | ||
} | ||
if (pOptions.hasOwnProperty("rulesFile")){ | ||
validateFileExistence(pOptions.rulesFile); | ||
} else if (pOptions.validate){ | ||
function validateValidation(pOptions) { | ||
if (pOptions.hasOwnProperty("validate") && typeof pOptions.validate !== 'boolean'){ | ||
validateFileExistence(pOptions.validate); | ||
} else if (pOptions.validate === true){ | ||
validateFileExistence(".dependency-cruiser.json"); | ||
@@ -68,6 +58,6 @@ } | ||
validateOutputType(pOptions.outputType); | ||
validateValidationCombinations(pOptions); | ||
validateValidation(pOptions); | ||
} | ||
} | ||
exports.validate = validateParameters; | ||
module.exports = validateParameters; |
"use strict"; | ||
const walk = require('acorn/dist/walk'); | ||
const extractCommonJSDependencies = require("./extractor-commonJS").extract; | ||
const extractCommonJSDependencies = require("./extractor-commonJS"); | ||
exports.extract = (pAST, pDependencies) => { | ||
module.exports = (pAST, pDependencies) => { | ||
walk.simple( | ||
@@ -8,0 +8,0 @@ pAST, |
@@ -5,3 +5,3 @@ "use strict"; | ||
exports.extract = (pAST, pDependencies, pModuleSystem) => { | ||
module.exports = (pAST, pDependencies, pModuleSystem) => { | ||
@@ -8,0 +8,0 @@ // var/const lalala = require('./lalala'); |
@@ -5,3 +5,3 @@ "use strict"; | ||
exports.extract = (pAST, pDependencies) => { | ||
module.exports = (pAST, pDependencies) => { | ||
function pushSourceValue(pNode){ | ||
@@ -8,0 +8,0 @@ if (pNode.source && pNode.source.value){ |
@@ -11,5 +11,5 @@ "use strict"; | ||
const utl = require('../utl'); | ||
const extractES6Dependencies = require('./extractor-ES6').extract; | ||
const extractCommonJSDependencies = require('./extractor-commonJS').extract; | ||
const extractAMDDependencies = require('./extractor-AMD').extract; | ||
const extractES6Dependencies = require('./extractor-ES6'); | ||
const extractCommonJSDependencies = require('./extractor-commonJS'); | ||
const extractAMDDependencies = require('./extractor-AMD'); | ||
@@ -82,3 +82,3 @@ function getASTBare(pFileName) { | ||
pDependency => { | ||
const lResolved = resolver.resolveModuleToPath( | ||
const lResolved = resolver( | ||
pDependency, | ||
@@ -99,3 +99,3 @@ pOptions.baseDir, | ||
pFileName, | ||
lResolved.resolved | ||
lResolved | ||
) | ||
@@ -112,2 +112,2 @@ ); | ||
exports.extractDependencies = extractDependencies; | ||
module.exports = extractDependencies; |
@@ -30,3 +30,3 @@ "use strict"; | ||
let lRetval = []; | ||
const lDependencies = extractor.extractDependencies(pFileName, pOptions); | ||
const lDependencies = extractor(pFileName, pOptions); | ||
@@ -111,2 +111,2 @@ lRetval.push({ | ||
exports.extract = extract; | ||
module.exports = extract; |
@@ -56,3 +56,3 @@ "use strict"; | ||
exports.resolveModuleToPath = (pDependency, pBaseDir, pFileDir) => { | ||
module.exports = (pDependency, pBaseDir, pFileDir) => { | ||
if (isRelativeModuleName(pDependency.moduleName)){ | ||
@@ -59,0 +59,0 @@ return resolveCJSModule(pDependency.moduleName, pBaseDir, pFileDir); |
@@ -23,4 +23,3 @@ "use strict"; | ||
.option("-T, --output-type <type>", "output type - html|dot|err|json (default:json)") | ||
.option("-v, --validate", "validate against rules in .dependency-cruiser.json") | ||
.option("-r, --rules-file <file>", "read rules from <file> (default: .dependency-cruiser.json)") | ||
.option("-v, --validate [file]", "validate against rules in [file] (default: .dependency-cruiser.json)") | ||
.arguments("<directory-or-file>") | ||
@@ -30,3 +29,3 @@ .parse(process.argv); | ||
if (Boolean(program.args[0])) { | ||
cli.main( | ||
cli( | ||
program.args[0], | ||
@@ -33,0 +32,0 @@ program |
@@ -14,2 +14,2 @@ "use strict"; | ||
exports.render = render; | ||
module.exports = render; |
@@ -23,3 +23,3 @@ "use strict"; | ||
: { | ||
incidence: lDep.rule.level, | ||
incidence: lDep.rule.severity, | ||
rule: lDep.rule.name | ||
@@ -26,0 +26,0 @@ }; |
@@ -8,6 +8,6 @@ "use strict"; | ||
const LEVEL2COLOR = { | ||
const SEVERITY2COLOR = { | ||
error : "red", | ||
warning : "orange", | ||
information : "blue" | ||
warn : "orange", | ||
info : "blue" | ||
}; | ||
@@ -52,3 +52,3 @@ const DEFAULT_VIOLATION_COLOR = "red"; | ||
if (pDependency.hasOwnProperty("valid") && !pDependency.valid) { | ||
lColorAddition.color = LEVEL2COLOR[pDependency.rule.level] || DEFAULT_VIOLATION_COLOR; | ||
lColorAddition.color = SEVERITY2COLOR[pDependency.rule.severity] || DEFAULT_VIOLATION_COLOR; | ||
} | ||
@@ -77,2 +77,2 @@ | ||
exports.render = render; | ||
module.exports = render; |
@@ -5,10 +5,10 @@ "use strict"; | ||
const LEVEL2CHALK = { | ||
const SEVERITY2CHALK = { | ||
'error' : chalk.red, | ||
'warning' : chalk.yellow, | ||
'information' : chalk.cyan | ||
'warn' : chalk.yellow, | ||
'info' : chalk.cyan | ||
}; | ||
function formatError(pErr) { | ||
return `${LEVEL2CHALK[pErr.rule.level](pErr.rule.level)} ${pErr.rule.name}: ` + | ||
return `${SEVERITY2CHALK[pErr.rule.severity](pErr.rule.severity)} ${pErr.rule.name}: ` + | ||
`${chalk.bold(pErr.source)} => ${chalk.bold(pErr.resolved)}`; | ||
@@ -50,2 +50,2 @@ } | ||
exports.render = render; | ||
module.exports = render; |
@@ -65,3 +65,3 @@ var Handlebars = require("handlebars/runtime"); var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; | ||
return "<style media=\"screen\">\n html {\n font-family: sans-serif;\n font-size: 10pt;\n }\n table, td.controls {\n transition-duration: 0.4s;\n }\n table, th, td{\n border: solid black 1px;\n border-collapse: collapse;\n font-size: inherit;\n }\n th{\n text-align:start;\n vertical-align: bottom;\n max-width: 1em;\n max-height: 30em;\n height: 20em;\n font-weight: normal;\n white-space: nowrap;\n overflow: hidden;\n }\n th div {\n transform: rotateZ(-90deg);\n transform-origin: 0.5em;\n text-align: start;\n height: 1em;\n width: 30em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n td {\n text-align: center;\n }\n td.first-cell {\n text-align: left;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n td.top-left {\n border-top: solid 1px transparent;\n border-left: solid 1px transparent;\n }\n td.top-right {\n border-top: solid 1px transparent;\n border-right: solid 1px transparent;\n }\n td.bottom-left {\n border-bottom: solid 1px transparent;\n border-left: solid 1px transparent;\n }\n td.bottom-right {\n border-bottom: solid 1px transparent;\n border-right: solid 1px transparent;\n }\n tbody tr:hover {\n background-color: lightgrey;\n }\n #table-rotated:target {\n transform: rotateZ(45deg);\n transform-origin: bottom left;\n }\n #table-rotated:target #unrotate {\n opacity: 1;\n }\n #table-rotated:target #rotate {\n opacity: 0;\n }\n #unrotate {\n opacity: 0;\n }\n #rotate {\n opacity: 1;\n }\n .controls {\n opacity: 0.2;\n vertical-align: bottom;\n padding: 0.5em;\n }\n .controls:hover {\n opacity: 1;\n }\n .controls a {\n font-style: normal;\n text-decoration: none;\n background-color: #eee;\n padding: 0.2em 0.5em 0.2em 0.5em;\n }\n .cell-core-module {\n color: grey;\n font-style: italic;\n }\n .cell-unresolvable-module {\n color: red;\n font-style: italic;\n }\n .cell-true {\n background-color: black;\n opacity: 0.5;\n }\n .cell-false {\n background-color: white;\n opacity: 0.5;\n }\n .cell-error {\n background-color: red;\n opacity: 0.5;\n }\n .cell-warning {\n background-color: orange;\n opacity: 0.5;\n }\n .cell-information {\n background-color: blue;\n opacity: 0.5;\n }\n</style>\n<table id=\"table-rotated\">\n <thead>\n <tr>\n <td class=\"controls top-left\">\n <a id=\"rotate\" href=\"#table-rotated\">rotate</a>\n <a id=\"unrotate\" href=\"#\">rotate back</a>\n </td>\n " | ||
return "<style media=\"screen\">\n html {\n font-family: sans-serif;\n font-size: 10pt;\n }\n table, td.controls {\n transition-duration: 0.4s;\n }\n table, th, td{\n border: solid black 1px;\n border-collapse: collapse;\n font-size: inherit;\n }\n th{\n text-align:start;\n vertical-align: bottom;\n max-width: 1em;\n max-height: 30em;\n height: 20em;\n font-weight: normal;\n white-space: nowrap;\n overflow: hidden;\n }\n th div {\n transform: rotateZ(-90deg);\n transform-origin: 0.5em;\n text-align: start;\n height: 1em;\n width: 30em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n td {\n text-align: center;\n }\n td.first-cell {\n text-align: left;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n td.top-left {\n border-top: solid 1px transparent;\n border-left: solid 1px transparent;\n }\n td.top-right {\n border-top: solid 1px transparent;\n border-right: solid 1px transparent;\n }\n td.bottom-left {\n border-bottom: solid 1px transparent;\n border-left: solid 1px transparent;\n }\n td.bottom-right {\n border-bottom: solid 1px transparent;\n border-right: solid 1px transparent;\n }\n tbody tr:hover {\n background-color: lightgrey;\n }\n #table-rotated:target {\n transform: rotateZ(45deg);\n transform-origin: bottom left;\n }\n #table-rotated:target #unrotate {\n opacity: 1;\n }\n #table-rotated:target #rotate {\n opacity: 0;\n }\n #unrotate {\n opacity: 0;\n }\n #rotate {\n opacity: 1;\n }\n .controls {\n opacity: 0.2;\n vertical-align: bottom;\n padding: 0.5em;\n }\n .controls:hover {\n opacity: 1;\n }\n .controls a {\n font-style: normal;\n text-decoration: none;\n background-color: #eee;\n padding: 0.2em 0.5em 0.2em 0.5em;\n }\n .cell-core-module {\n color: grey;\n font-style: italic;\n }\n .cell-unresolvable-module {\n color: red;\n font-style: italic;\n }\n .cell-true {\n background-color: black;\n opacity: 0.5;\n }\n .cell-false {\n background-color: white;\n opacity: 0.5;\n }\n .cell-error {\n background-color: red;\n opacity: 0.5;\n }\n .cell-warn {\n background-color: orange;\n opacity: 0.5;\n }\n .cell-info {\n background-color: blue;\n opacity: 0.5;\n }\n</style>\n<table id=\"table-rotated\">\n <thead>\n <tr>\n <td class=\"controls top-left\">\n <a id=\"rotate\" href=\"#table-rotated\">rotate</a>\n <a id=\"unrotate\" href=\"#\">rotate back</a>\n </td>\n " | ||
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.things : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") | ||
@@ -68,0 +68,0 @@ + "\n <td class=\"top-right\"></td>\n </tr>\n </thead>\n <tbody>\n" |
@@ -30,4 +30,4 @@ "use strict"; | ||
exports.render = render; | ||
module.exports = render; | ||
/* eslint arrow-body-style: 0 */ |
"use strict"; | ||
exports.render = pInput => JSON.stringify(pInput, null, " "); | ||
module.exports = pInput => JSON.stringify(pInput, null, " "); |
"use strict"; | ||
const VALID_LEVELS = /^(error|warning|information)$/; | ||
const DEFAULT_LEVEL = 'warning'; | ||
const DEFAULT_RULE = 'unnamed'; | ||
const VALID_SEVERITIES = /^(error|warn|info)$/; | ||
const DEFAULT_SEVERITY = 'warn'; | ||
const DEFAULT_RULE = 'unnamed'; | ||
function normalizeLevel (pLevel){ | ||
let lLevel = pLevel ? pLevel : DEFAULT_LEVEL; | ||
function normalizeSeverity (pSeverity){ | ||
let lSeverity = pSeverity ? pSeverity : DEFAULT_SEVERITY; | ||
return Boolean(lLevel.match(VALID_LEVELS)) ? lLevel : DEFAULT_LEVEL; | ||
return Boolean(lSeverity.match(VALID_SEVERITIES)) ? lSeverity : DEFAULT_SEVERITY; | ||
} | ||
@@ -21,4 +21,4 @@ | ||
{ | ||
level : normalizeLevel(pRule.level), | ||
name : normalizeName(pRule.name) | ||
severity : normalizeSeverity(pRule.severity), | ||
name : normalizeName(pRule.name) | ||
} | ||
@@ -40,2 +40,2 @@ ); | ||
exports.normalize = normalize; | ||
module.exports = normalize; |
@@ -5,7 +5,12 @@ "use strict"; | ||
function hasPath(pObject, pPath) { | ||
return pObject.hasOwnProperty(pPath[0]) && | ||
pObject[pPath[0]].hasOwnProperty(pPath[1]); | ||
} | ||
function checkRuleSafety(pRule) { | ||
if ( | ||
!( | ||
safeRegex(pRule.from) && | ||
safeRegex(pRule.to) | ||
(!hasPath(pRule, ["from", "path"]) || safeRegex(pRule.from.path)) && | ||
(!hasPath(pRule, ["to", "path"]) || safeRegex(pRule.to.path)) | ||
) | ||
@@ -28,2 +33,2 @@ ){ | ||
exports.validate = validate; | ||
module.exports = validate; |
@@ -12,9 +12,21 @@ "use strict"; | ||
ruleSetValidator.validate(lRetval); | ||
return ruleSetNormalizer.normalize(lRetval); | ||
ruleSetValidator(lRetval); | ||
return ruleSetNormalizer(lRetval); | ||
} | ||
); | ||
function propertyEquals(pTo, pRule, pProperty) { | ||
return pRule.to.hasOwnProperty(pProperty) | ||
? pTo[pProperty] === pRule.to[pProperty] | ||
: true; | ||
} | ||
function matchRule(pFrom, pTo) { | ||
return pRule => pFrom.match(pRule.from) && pTo.match(pRule.to); | ||
return pRule => | ||
(!Boolean(pRule.from.path) || pFrom.match(pRule.from.path)) && | ||
(!Boolean(pRule.from.pathNot) || !(pFrom.match(pRule.from.pathNot))) && | ||
(!Boolean(pRule.to.path) || pTo.resolved.match(pRule.to.path)) && | ||
(!Boolean(pRule.to.pathNot) || !(pTo.resolved.match(pRule.to.pathNot))) && | ||
propertyEquals(pTo, pRule, "coreModule") && | ||
propertyEquals(pTo, pRule, "couldNotResolve"); | ||
} | ||
@@ -31,3 +43,3 @@ | ||
rule: { | ||
level: "warning", | ||
severity: "warn", | ||
name: "not-in-allowed" | ||
@@ -44,4 +56,4 @@ } | ||
rule: { | ||
level: lMatchedRule.level, | ||
name : lMatchedRule.name | ||
severity : lMatchedRule.severity, | ||
name : lMatchedRule.name | ||
} | ||
@@ -62,1 +74,7 @@ }; | ||
exports.validate = validate; | ||
/* ignore security/detect-object-injection because: | ||
- we only use it from within the module with two fixed values | ||
- the propertyEquals function is not exposed externaly | ||
*/ | ||
/* eslint security/detect-object-injection: 0 */ |
@@ -58,3 +58,3 @@ "use strict"; | ||
outputType: "html", | ||
rulesFile: "test/fixtures/rules.sub-not-allowed.json", | ||
validate: "test/fixtures/rules.sub-not-allowed.json", | ||
exclude: "node_modules" | ||
@@ -70,3 +70,3 @@ }, | ||
outputTo: path.join(OUT_DIR, "{{moduleType}}.dir.filtered.dot"), | ||
rulesFile: "test/fixtures/rules.sub-not-allowed.json", | ||
validate: "test/fixtures/rules.sub-not-allowed.json", | ||
outputType: "dot", | ||
@@ -95,3 +95,3 @@ exclude: "node_modules" | ||
outputType: "csv", | ||
rulesFile: "test/fixtures/rules.sub-not-allowed.json", | ||
validate: "test/fixtures/rules.sub-not-allowed.json", | ||
exclude: "node_modules" | ||
@@ -108,3 +108,3 @@ }, | ||
outputType: "err", | ||
rulesFile: "test/fixtures/rules.everything-allowed.json" | ||
validate: "test/fixtures/rules.everything-allowed.json" | ||
}, | ||
@@ -164,3 +164,3 @@ expect: "{{moduleType}}.dir.filtered.err", | ||
it(pPair.description, () => { | ||
main.main(pPair.dirOrFile, pPair.options); | ||
main(pPair.dirOrFile, pPair.options); | ||
tst.assertFileEqual( | ||
@@ -195,3 +195,3 @@ pPair.options.outputTo, | ||
main.main("test/fixtures/cjs"); | ||
main("test/fixtures/cjs"); | ||
unhookIntercept(); | ||
@@ -216,3 +216,3 @@ fs.writeFileSync( | ||
main.main("test/fixtures/cjs", {outputTo: "-", outputType: 'json'}); | ||
main("test/fixtures/cjs", {outputTo: "-", outputType: 'json'}); | ||
unhookIntercept(); | ||
@@ -241,3 +241,3 @@ fs.writeFileSync( | ||
main.main("this-doesnot-exist", {outputTo: path.join(OUT_DIR, "cjs.dir.wontmarch.json")}); | ||
main("this-doesnot-exist", {outputTo: path.join(OUT_DIR, "cjs.dir.wontmarch.json")}); | ||
unhookInterceptStdOut(); | ||
@@ -263,3 +263,3 @@ unhookInterceptStdErr(); | ||
main.main( | ||
main( | ||
"test/fixtures", | ||
@@ -294,3 +294,3 @@ { | ||
main.main( | ||
main( | ||
"test/fixtures", | ||
@@ -325,3 +325,3 @@ { | ||
main.main( | ||
main( | ||
"test/fixtures", | ||
@@ -355,3 +355,3 @@ { | ||
main.main( | ||
main( | ||
"test/fixtures", | ||
@@ -358,0 +358,0 @@ { |
@@ -8,3 +8,3 @@ "use strict"; | ||
expect( | ||
optionNormalizer.normalize({}) | ||
optionNormalizer({}) | ||
).to.deep.equal( | ||
@@ -24,3 +24,3 @@ { | ||
expect( | ||
optionNormalizer.normalize({system: "cjs,es6"}) | ||
optionNormalizer({system: "cjs,es6"}) | ||
).to.deep.equal( | ||
@@ -40,3 +40,3 @@ { | ||
expect( | ||
optionNormalizer.normalize({system: {}}) | ||
optionNormalizer({system: {}}) | ||
).to.deep.equal( | ||
@@ -54,5 +54,5 @@ { | ||
it("-v without -r assumes .dependency-cruiser for rules", () => { | ||
it("-v parameter assumes .dependency-cruiser for rules", () => { | ||
expect( | ||
optionNormalizer.normalize({validate: true}) | ||
optionNormalizer({validate: true}) | ||
).to.deep.equal( | ||
@@ -65,10 +65,10 @@ { | ||
moduleSystems: ["amd", "cjs", "es6"], | ||
validate: true, | ||
rulesFile: ".dependency-cruiser.json" | ||
rulesFile: ".dependency-cruiser.json", | ||
validate: true | ||
} | ||
); | ||
}); | ||
it("-r implies -v", () => { | ||
it("-v with parameter uses that parameter as rules file", () => { | ||
expect( | ||
optionNormalizer.normalize({rulesFile: "./fixtures/rules.empty.json"}) | ||
optionNormalizer({validate: "./fixtures/rules.empty.json"}) | ||
).to.deep.equal( | ||
@@ -81,4 +81,4 @@ { | ||
moduleSystems: ["amd", "cjs", "es6"], | ||
validate: true, | ||
rulesFile: "./fixtures/rules.empty.json" | ||
rulesFile: "./fixtures/rules.empty.json", | ||
validate: true | ||
} | ||
@@ -85,0 +85,0 @@ ); |
@@ -8,3 +8,3 @@ "use strict"; | ||
try { | ||
parameterValidator.validate("file-or-dir-does-not-exist"); | ||
parameterValidator("file-or-dir-does-not-exist"); | ||
expect("not to be here").to.equal("still here, though"); | ||
@@ -18,3 +18,3 @@ } catch (e) { | ||
try { | ||
parameterValidator.validate("test/fixtures", {"rulesFile": "non-existing-rule-file"}); | ||
parameterValidator("test/fixtures", {"validate": "non-existing-rule-file"}); | ||
expect("not to be here").to.equal("still here, though"); | ||
@@ -28,3 +28,3 @@ } catch (e) { | ||
try { | ||
parameterValidator.validate("test/fixtures", {"validate": true}); | ||
parameterValidator("test/fixtures", {"validate": true}); | ||
expect("not to be here").to.equal("still here, though"); | ||
@@ -38,3 +38,3 @@ } catch (e) { | ||
try { | ||
parameterValidator.validate("test/fixtures", {"rulesFile": "test/fixtures/rules.empty.json"}); | ||
parameterValidator("test/fixtures", {"validate": "test/fixtures/rules.empty.json"}); | ||
expect("to be here without throws happening").to.equal("to be here without throws happening"); | ||
@@ -46,15 +46,2 @@ } catch (e) { | ||
}); | ||
it("throws when validate is false, but there's a rules file nonetheless", () => { | ||
try { | ||
parameterValidator.validate( | ||
"test/fixtures", | ||
{"validate": false, "rulesFile": "test/fixtures/rules.empty.json"} | ||
); | ||
expect("not to be here").to.equal("still here, though"); | ||
} catch (e) { | ||
expect(e).to.deep.equal(Error(`Confused here. You passed a rules file, but don't want to validate? :-S`)); | ||
} | ||
}); | ||
}); |
@@ -10,3 +10,3 @@ const expect = require('chai').expect; | ||
expect( | ||
extractor.extract( | ||
extractor( | ||
pFixture.input.fileName, | ||
@@ -13,0 +13,0 @@ pFixture.input.options |
@@ -10,3 +10,3 @@ const expect = require('chai').expect; | ||
expect( | ||
extractor.extractDependencies( | ||
extractor( | ||
pFixture.input.fileName, | ||
@@ -31,3 +31,3 @@ { | ||
expect( | ||
() => extractor.extractDependencies("test/extractor-fixtures/syntax-error.js") | ||
() => extractor("test/extractor-fixtures/syntax-error.js") | ||
).to.not.throw("Extracting dependencies ran afoul of... Unexpected token (1:3)"); | ||
@@ -37,3 +37,3 @@ }); | ||
expect( | ||
() => extractor.extractDependencies("non-existing-file.js") | ||
() => extractor("non-existing-file.js") | ||
).to.throw( | ||
@@ -40,0 +40,0 @@ "Extracting dependencies ran afoul of... ENOENT: no such file or directory, open 'non-existing-file.js'" |
@@ -21,3 +21,3 @@ [ | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -34,3 +34,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -52,3 +52,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -76,3 +76,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -94,3 +94,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -107,3 +107,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -120,3 +120,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -133,3 +133,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -146,3 +146,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -159,3 +159,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -184,3 +184,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -202,3 +202,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -215,3 +215,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -233,3 +233,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -251,3 +251,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -264,3 +264,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -277,3 +277,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -290,3 +290,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -320,3 +320,3 @@ } | ||
"rule": { | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -323,0 +323,0 @@ } |
@@ -1,1 +0,1 @@ | ||
{} | ||
{} |
{ | ||
"allowed":[{ | ||
"from": ".+", | ||
"to": ".+" | ||
}] | ||
"allowed": [ | ||
{ | ||
"from": { | ||
}, | ||
"to": { | ||
} | ||
} | ||
] | ||
} |
{ | ||
"allowed":[{ | ||
"from": "only-this-one", | ||
"to": "only-that-one" | ||
}] | ||
} | ||
"allowed": [ | ||
{ | ||
"from": { | ||
"path": "only-this-one" | ||
}, | ||
"to": { | ||
"path": "only-that-one" | ||
} | ||
} | ||
] | ||
} |
{ | ||
"allowed":[{ | ||
"from": ".+", | ||
"to": ".+" | ||
}], | ||
"forbidden":[{ | ||
"from": ".+", | ||
"to": "node_modules" | ||
}] | ||
"allowed": [ | ||
{ | ||
"from": { | ||
}, | ||
"to": { | ||
} | ||
} | ||
], | ||
"forbidden": [ | ||
{ | ||
"from": { | ||
}, | ||
"to": { | ||
"path": "node_modules" | ||
} | ||
} | ||
] | ||
} |
{ | ||
"forbidden":[{ | ||
"from": ".+", | ||
"to": ".+" | ||
}] | ||
"forbidden": [ | ||
{ | ||
"from": { | ||
}, | ||
"to": { | ||
"path": ".+" | ||
} | ||
} | ||
] | ||
} |
{ | ||
"forbidden":[{ | ||
"from": ".+", | ||
"to": "(.+)*" | ||
}] | ||
"forbidden": [ | ||
{ | ||
"from": { | ||
"path": ".+" | ||
}, | ||
"to": { | ||
"path": "(.+)*" | ||
} | ||
} | ||
] | ||
} |
{ | ||
"allowed":[{ | ||
"from": ".+", | ||
"to": ".+" | ||
}], | ||
"forbidden":[{ | ||
"name": "sub-not-allowed", | ||
"level": "error", | ||
"from": ".+", | ||
"to": "sub" | ||
}] | ||
"allowed": [ | ||
{ | ||
"from": { | ||
}, | ||
"to": { | ||
} | ||
} | ||
], | ||
"forbidden": [ | ||
{ | ||
"name": "sub-not-allowed", | ||
"severity": "error", | ||
"from": { | ||
}, | ||
"to": { | ||
"path": "sub" | ||
} | ||
} | ||
] | ||
} |
"use strict"; | ||
const expect = require('chai').expect; | ||
const render = require('../src/report/dotReporter').render; | ||
const render = require('../src/report/dotReporter'); | ||
const deps = require('./fixtures/cjs-no-dependency-valid.json'); | ||
@@ -5,0 +5,0 @@ |
"use strict"; | ||
const expect = require('chai').expect; | ||
const render = require('../src/report/errReporter').render; | ||
const render = require('../src/report/errReporter'); | ||
const deps = require('./fixtures/cjs-no-dependency-valid.json'); | ||
@@ -5,0 +5,0 @@ |
"use strict"; | ||
const expect = require('chai').expect; | ||
const render = require('../src/report/htmlReporter').render; | ||
const render = require('../src/report/htmlReporter'); | ||
const deps = require('./fixtures/cjs-no-dependency-valid.json'); | ||
@@ -117,7 +117,7 @@ | ||
} | ||
.cell-warning { | ||
.cell-warn { | ||
background-color: orange; | ||
opacity: 0.5; | ||
} | ||
.cell-information { | ||
.cell-info { | ||
background-color: blue; | ||
@@ -151,5 +151,5 @@ opacity: 0.5; | ||
<td class="first-cell">node_modules/somemodule/src/somemodule.js</td> | ||
<td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-warn" title="unnamed: | ||
node_modules/somemodule/src/somemodule.js -> | ||
node_modules/somemodule/node_modules/someothermodule/main.js"></td><td class="cell cell-warning" title="unnamed: | ||
node_modules/somemodule/node_modules/someothermodule/main.js"></td><td class="cell cell-warn" title="unnamed: | ||
node_modules/somemodule/src/somemodule.js -> | ||
@@ -161,3 +161,3 @@ node_modules/somemodule/src/moar-javascript.js"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td> | ||
<td class="first-cell">one_only_one.js</td> | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
one_only_one.js -> | ||
@@ -169,3 +169,3 @@ path"></td> | ||
<td class="first-cell">one_only_two.js</td> | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
one_only_two.js -> | ||
@@ -177,13 +177,13 @@ path"></td> | ||
<td class="first-cell">root_one.js</td> | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
root_one.js -> | ||
node_modules/somemodule/src/somemodule.js"></td><td class="cell cell-warning" title="unnamed: | ||
node_modules/somemodule/src/somemodule.js"></td><td class="cell cell-warn" title="unnamed: | ||
root_one.js -> | ||
one_only_one.js"></td><td class="cell cell-warning" title="unnamed: | ||
one_only_one.js"></td><td class="cell cell-warn" title="unnamed: | ||
root_one.js -> | ||
one_only_two.js"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
one_only_two.js"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
root_one.js -> | ||
shared.js"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
shared.js"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
root_one.js -> | ||
sub/dir.js"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
sub/dir.js"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
root_one.js -> | ||
@@ -195,9 +195,9 @@ fs"></td><td class="cell cell-false"></td><td class="cell cell-false"></td> | ||
<td class="first-cell">root_two.js</td> | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
root_two.js -> | ||
shared.js"></td><td class="cell cell-warning" title="unnamed: | ||
shared.js"></td><td class="cell cell-warn" title="unnamed: | ||
root_two.js -> | ||
somedata.json"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
somedata.json"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
root_two.js -> | ||
two_only_one.js"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
two_only_one.js"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
root_two.js -> | ||
@@ -209,3 +209,3 @@ http"></td><td class="cell cell-false"></td> | ||
<td class="first-cell cell-unresolvable-module">shared.js</td> | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
shared.js -> | ||
@@ -222,3 +222,3 @@ path"></td> | ||
<td class="first-cell">sub/depindir.js</td> | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
sub/depindir.js -> | ||
@@ -230,5 +230,5 @@ path"></td> | ||
<td class="first-cell">sub/dir.js</td> | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
sub/dir.js -> | ||
sub/depindir.js"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
sub/depindir.js"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
sub/dir.js -> | ||
@@ -240,3 +240,3 @@ path"></td> | ||
<td class="first-cell">two_only_one.js</td> | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warning" title="unnamed: | ||
<td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-warn" title="unnamed: | ||
two_only_one.js -> | ||
@@ -243,0 +243,0 @@ sub/dir.js"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td><td class="cell cell-false"></td> |
@@ -7,7 +7,7 @@ "use strict"; | ||
it("leaves the empty ruleset alone", () => { | ||
expect(normalizer.normalize({})).to.deep.equal({}); | ||
expect(normalizer({})).to.deep.equal({}); | ||
}); | ||
it("adds defaults for level and warning when they're not filled", () => { | ||
expect(normalizer.normalize({ | ||
it("adds defaults for severity and warn when they're not filled", () => { | ||
expect(normalizer({ | ||
"allowed": [{ | ||
@@ -21,3 +21,3 @@ "from": ".+", | ||
"to": ".+", | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "unnamed" | ||
@@ -28,8 +28,8 @@ }] | ||
it("corrects the level to a default when it's not a recognized one", () => { | ||
expect(normalizer.normalize({ | ||
it("corrects the severity to a default when it's not a recognized one", () => { | ||
expect(normalizer({ | ||
"allowed": [{ | ||
"from": ".+", | ||
"to": ".+", | ||
"level": "unrecognized", | ||
"severity": "unrecognized", | ||
"name": "all-ok" | ||
@@ -41,3 +41,3 @@ }] | ||
"to": ".+", | ||
"level": "warning", | ||
"severity": "warn", | ||
"name": "all-ok" | ||
@@ -48,8 +48,8 @@ }] | ||
it("keeps the level if it's a recognized one", () => { | ||
expect(normalizer.normalize({ | ||
it("keeps the severity if it's a recognized one", () => { | ||
expect(normalizer({ | ||
"allowed": [{ | ||
"from": ".+", | ||
"to": ".+", | ||
"level": "error", | ||
"severity": "error", | ||
"name": "all-ok" | ||
@@ -61,3 +61,3 @@ }] | ||
"to": ".+", | ||
"level": "error", | ||
"severity": "error", | ||
"name": "all-ok" | ||
@@ -69,7 +69,7 @@ }] | ||
it("also works for 'forbidden' rules", () => { | ||
expect(normalizer.normalize({ | ||
expect(normalizer({ | ||
"forbidden": [{ | ||
"from": ".+", | ||
"to": ".+", | ||
"level": "error", | ||
"severity": "error", | ||
"name": "all-ok", | ||
@@ -82,3 +82,3 @@ "comment": "this comment is kept" | ||
"to": ".+", | ||
"level": "error", | ||
"severity": "error", | ||
"name": "all-ok", | ||
@@ -85,0 +85,0 @@ "comment": "this comment is kept" |
"use strict"; | ||
const expect = require('chai').expect; | ||
const expect = require('chai').expect; | ||
const validator = require('../src/validate/validator'); | ||
describe("validator", () => { | ||
it("bails out on scary regexps", () => { | ||
try { | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.scary-regex.json", | ||
"koos koets", | ||
{"resolved": "robby van de kerkhof"} | ||
); | ||
expect("not to be here").to.equal("still here, though"); | ||
} catch (e) { | ||
expect(e).to.deep.equal( | ||
Error( | ||
'Error: rule {"from":".+","to":"(.+)*"} has an unsafe regular expression. Bailing out.\n' | ||
) | ||
); | ||
} | ||
}); | ||
it("is ok with the empty validation", () => { | ||
@@ -12,3 +31,3 @@ expect( | ||
"koos koets", | ||
"robby van de kerkhof" | ||
{"resolved": "robby van de kerkhof"} | ||
) | ||
@@ -24,3 +43,3 @@ ).to.deep.equal({valid: true}); | ||
"koos koets", | ||
"robby van de kerkhof" | ||
{"resolved": "robby van de kerkhof"} | ||
) | ||
@@ -36,5 +55,5 @@ ).to.deep.equal({valid: true}); | ||
"koos koets", | ||
"robby van de kerkhof" | ||
{"resolved": "robby van de kerkhof"} | ||
) | ||
).to.deep.equal({valid: false, rule: {level: "warning", "name": "not-in-allowed"}}); | ||
).to.deep.equal({valid: false, rule: {severity: "warn", "name": "not-in-allowed"}}); | ||
}); | ||
@@ -49,5 +68,5 @@ | ||
"koos koets", | ||
"robby van de kerkhof" | ||
{"resolved": "robby van de kerkhof"} | ||
) | ||
).to.deep.equal({valid: false, rule: {level: 'warning', name: 'unnamed'}}); | ||
).to.deep.equal({valid: false, rule: {severity: 'warn', name: 'unnamed'}}); | ||
}); | ||
@@ -61,3 +80,3 @@ | ||
"koos koets", | ||
"robby van de kerkhof" | ||
{"resolved": "robby van de kerkhof"} | ||
) | ||
@@ -67,3 +86,3 @@ ).to.deep.equal({valid: true}); | ||
it("node_modules inhibition - transgression", () => { | ||
it("node_modules inhibition - violation", () => { | ||
expect( | ||
@@ -74,24 +93,184 @@ validator.validate( | ||
"koos koets", | ||
"./node_modules/evil-module" | ||
{"resolved": "./node_modules/evil-module"} | ||
) | ||
).to.deep.equal({valid: false, rule: {level: 'warning', name: 'unnamed'}}); | ||
).to.deep.equal({valid: false, rule: {severity: 'warn', name: 'unnamed'}}); | ||
}); | ||
it("bails out on scary regexps", () => { | ||
try { | ||
it("not to core - ok", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.scary-regex.json", | ||
"./test/fixtures/rules.not-to-core.json", | ||
"koos koets", | ||
"robby van de kerkhof" | ||
); | ||
expect("not to be here").to.deep.equal("still here, though"); | ||
} catch (e) { | ||
expect(e).to.deep.equal( | ||
Error( | ||
'Error: rule {"from":".+","to":"(.+)*"} has an unsafe regular expression. Bailing out.\n' | ||
) | ||
); | ||
} | ||
{"resolved": "path", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("not to core - violation", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-core.json", | ||
"koos koets", | ||
{"resolved": "path", "coreModule": true} | ||
) | ||
).to.deep.equal({valid: false, rule: {severity: 'error', name: 'not-to-core'}}); | ||
}); | ||
it("not to core fs os - ok", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-core-fs-os.json", | ||
"koos koets", | ||
{"resolved": "path", "coreModule": true} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("not to core fs os - violation", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-core-fs-os.json", | ||
"koos koets", | ||
{"resolved": "os", "coreModule": true} | ||
) | ||
).to.deep.equal({valid: false, rule: {severity: 'error', name: 'not-to-core-fs-os'}}); | ||
}); | ||
it("not to unresolvable - ok", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-unresolvable.json", | ||
"koos koets", | ||
{"resolved": "diana charitee", "couldNotResolve": false} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("not to unresolvable - violation", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-unresolvable.json", | ||
"koos koets", | ||
{"resolved": "diana charitee", "couldNotResolve": true} | ||
) | ||
).to.deep.equal({valid: false, rule: {severity: 'error', name: 'not-to-unresolvable'}}); | ||
}); | ||
it("only to core - via 'allowed' - ok", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.only-to-core.allowed.json", | ||
"koos koets", | ||
{"resolved": "os", "coreModule": true} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("only to core - via 'allowed' - violation", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.only-to-core.allowed.json", | ||
"koos koets", | ||
{"resolved": "ger hekking", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: false, rule: {severity: 'warn', name: 'not-in-allowed'}}); | ||
}); | ||
it("only to core - via 'forbidden' - ok", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.only-to-core.forbidden.json", | ||
"koos koets", | ||
{"resolved": "os", "coreModule": true} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("only to core - via 'forbidden' - violation", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.only-to-core.forbidden.json", | ||
"koos koets", | ||
{"resolved": "ger hekking", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: false, rule: {severity: 'error', name: 'only-to-core'}}); | ||
}); | ||
it("not to sub except sub itself - ok - sub to sub", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-sub-except-sub.json", | ||
"./keek/op/de/sub/week.js", | ||
{"resolved": "./keek/op/de/sub/maand.js", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("not to sub except sub itself - ok - not sub to not sub", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-sub-except-sub.json", | ||
"./doctor/clavan.js", | ||
{"resolved": "./rochebrune.js", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("not to sub except sub itself - ok - sub to not sub", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-sub-except-sub.json", | ||
"./doctor/sub/clavan.js", | ||
{"resolved": "./rochebrune.js", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("not to sub except sub itself - violation - not sub to sub", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-sub-except-sub.json", | ||
"./doctor/clavan.js", | ||
{"resolved": "./keek/op/de/sub/week.js", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: false, rule: {severity: 'error', name: 'not-to-sub-except-sub'}}); | ||
}); | ||
it("not to not sub (=> everything must go to 'sub')- ok - sub to sub", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-not-sub.json", | ||
"./keek/op/de/sub/week.js", | ||
{"resolved": "./keek/op/de/sub/maand.js", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: true}); | ||
}); | ||
it("not to not sub (=> everything must go to 'sub')- violation - not sub to not sub", () => { | ||
expect( | ||
validator.validate( | ||
true, | ||
"./test/fixtures/rules.not-to-not-sub.json", | ||
"./amber.js", | ||
{"resolved": "./jade.js", "coreModule": false} | ||
) | ||
).to.deep.equal({valid: false, rule: {severity: 'error', name: 'not-to-not-sub'}}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
165
5279
579353
204
16