1.0.3 • Published 5 years ago

babel-plugin-forbid-imports v1.0.3

Weekly downloads
100
License
MIT
Repository
github
Last release
5 years ago

babel-plugin-forbid-imports

CircleCI Coverage Status semantic-release Commitizen friendly npm version

throw errors if certain packages/directories are imported from

Purpose

I created this to automatically check whether client code in a webapp project accidentally imports from server code.

Installation

npm install --save-dev babel-plugin-forbid-imports

Configuration options

packages

An array of packages to forbid importing from.

Example

{
  "plugins": [
    [
      "babel-plugin-forbid-imports",
      {
        "packages": ["sequelize"]
      }
    ]
  ]
}

patterns

An array of regular expression patterns. Any imports matching one of these patterns will be forbidden. Each pattern can be a string or an array of [pattern, flags].

Example

{
  "plugins": [
    [
      "babel-plugin-forbid-imports",
      {
        "patterns": ["\\d", ["foo", "i"]]
      }
    ]
  ]
}

paths

An array of paths to files or directories (relative to the babel cwd) to forbid importing from. Subfiles and subdirectories are also forbidden.

Example

{
  "plugins": [
    [
      "babel-plugin-forbid-imports",
      {
        "paths": ["./src/server"]
      }
    ]
  ]
}