Plugin for adviser that contains rules related to dependencies in the package.json
You'll first need to install Adviser:
$ npm i adviser --save-dev
Next, install adviser-plugin-dependencies:
$ npm install adviser-plugin-dependencies --save-dev
Note: If you installed Adviser globally (using the -g flag) then you must also install adviser-plugin-dependencies globally.
Add dependencies to the plugins section of your .adviserrc configuration file. You can omit the adviser-plugin- prefix:
{
"plugins": ["dependencies"]
}Then configure the rules you want to use under the rules section.
{
"rules": {
"dependencies/min-vulnerabilities-allow": ["error", { "level": "low", "skip": ["780"] }]
}
}If you don't have a .adviserrc you can create one running $ adviser --init
{
"plugins": ["dependencies"],
"rules": {
"dependencies/min-vulnerabilities-allow": ["error", { "level": "high", "skip": ["780"] }],
"dependencies/licenses-allowlist": [
"warn",
{ "allowlist": ["MIT", "ISC", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause"] }
],
"dependencies/not-allowed-packages": ["error", { "packages": ["jquery", "lodash", "kill-port", "la-tata"] }],
"dependencies/outdated-packages": ["warn", { "criteria": "major", "exclude": [] }]
}
}
If you would like to contribute and later on test your changes there are a couple ways explained below.
The package (adviser-plugin-dependencies) is setup to run tests under the folder __tests__ with Jest. Save your tests there and they will run before push code and by travis once the PR is created.
To run your rules with adviser, we recommend you to create an empty folder (We have one under ./examples/integration) with:
- An example package.json with example packages (in case is related with security, make sure to include some of them that fail your test)
- An
adviserconfiguration file. You can grab the example in this README or generate one using$ adviser --init(adviser must be installed globally or usingnpx) - Link this repo to the example project.
- Run
$ npm linkin theadviser-plugin-dependenciesroot - Run
$ npm link adviser-plugin-dependenciesin the example project root
- Run