Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 1.6 KB

ban-dependencies.md

File metadata and controls

76 lines (56 loc) · 1.6 KB

Bans a list of dependencies from being used

This rule bans dependencies based on a preset list or a user defined list.

Options

presets

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 your package.json if it is set. In that only native functionality available in your defined engines.node version range will be considered (or all if it isn't set)
  • preferred - an opinionated list of packages with better maintained and lighter alternatives

Example config:

{
  "rules": {
    "depend/ban-dependencies": ["error", {
      "presets": ["native"]
    }]
  }
}

The default is ['native', 'microutilities', 'preferred'].

modules

You may also specify your own list of packages which will be disallowed in code.

For example:

{
  "rules": {
    "depend/ban-dependencies": ["error", {
      "modules": ["im-a-banned-package"]
    }]
  }
}

Rule Details

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);

When Not To Use It

If you prefer not to restrict which dependencies are used, this rule should be disabled.