babel-plugin-forbid-imports

1.0.3 • Public • Published

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"]
      }
    ]
  ]
}

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-forbid-imports

Weekly Downloads

150

Version

1.0.3

License

MIT

Unpacked Size

362 kB

Total Files

12

Last publish

Collaborators

  • jedwards1211