Rule: import-blacklist

Disallows importing the specified modules via import and require, or importing specific named exports of the specified modules, or using imports matching specified regular expression patterns.

Rationale

For some libraries, importing the library directly can cause unused submodules to be loaded, so you may want to block these imports and require that users directly import only the submodules they need. In other cases, you may simply want to ban an import because using it is undesirable or unsafe.

Config

A list of blacklisted modules, named imports, or regular expression patterns.

Config examples
"import-blacklist": true
"import-blacklist": [true, "rxjs", "lodash"]
"import-blacklist": [true, [".*\\.temp$", ".*\\.tmp$"]]
"import-blacklist": [true, {"lodash": ["pull", "pullAll"]}]
"import-blacklist": [true, "lodash", {"lodash": ["pull", "pullAll"]}]
"import-blacklist": [true, "rxjs", {"lodash": ["pull", "pullAll"]}, [".*\\.temp$", ".*\\.tmp$"]]
Schema
{
  "type": "array",
  "items": {
    "oneOf": [
      {
        "type": "string",
        "minLength": 1
      },
      {
        "type": "object",
        "additionalProperties": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      {
        "type": "array",
        "items": {
          "type": "string"
        },
        "minLength": 1
      }
    ]
  }
}