This rule bans dependencies based on a preset list or a user defined list.
You may choose a preset list of dependencies (or none). The following are available:
microutilities
- micro utilities (e.g. one liners)native
- redundant packages with native equivalents- Note that this preset will take into account
engines
in yourpackage.json
if it is set. In that only native functionality available in your definedengines.node
version range will be considered (or all if it isn't set)
- Note that this preset will take into account
preferred
- an opinionated list of packages with better maintained and lighter alternatives- Note the list for this is sourced from
module-replacements
- Note the list for this is sourced from
Example config:
{
"rules": {
"depend/ban-dependencies": ["error", {
"presets": ["native"]
}]
}
}
The default is ['native', 'microutilities', 'preferred']
.
You may specify your own list of packages which will be disallowed in code.
For example:
{
"rules": {
"depend/ban-dependencies": ["error", {
"modules": ["im-a-banned-package"]
}]
}
}
You may specify your own list of packages that will be allowed in code even if they are in presets.
For example:
{
"rules": {
"depend/ban-dependencies": ["error", {
"allowed": ["is-nan"]
}]
}
}
This rule bans certain dependencies from being used.
The following patterns are considered warnings:
// with `presets: ['native']`
const isNaN = require('is-nan');
isNaN(v);
The following patterns are not warnings:
// with `presets: ['native']`
Number.isNaN(v);
// with `presets: ['native'], allowed: ['is-nan']`
const isNaN = require('is-nan');
isNaN(v);
If you prefer not to restrict which dependencies are used, this rule should be disabled.