https://github.com/jcoreio/babel-plugin-forbid-imports
throw errors if certain packages/directories are imported from
https://github.com/jcoreio/babel-plugin-forbid-imports
babel babel-plugin imports
Last synced: 25 days ago
JSON representation
throw errors if certain packages/directories are imported from
- Host: GitHub
- URL: https://github.com/jcoreio/babel-plugin-forbid-imports
- Owner: jcoreio
- License: mit
- Created: 2019-01-28T22:46:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-28T23:30:30.000Z (over 7 years ago)
- Last Synced: 2025-10-17T18:36:19.341Z (8 months ago)
- Topics: babel, babel-plugin, imports
- Language: JavaScript
- Homepage:
- Size: 577 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# babel-plugin-forbid-imports
[](https://circleci.com/gh/jcoreio/babel-plugin-forbid-imports)
[](https://codecov.io/gh/jcoreio/babel-plugin-forbid-imports)
[](https://github.com/semantic-release/semantic-release)
[](http://commitizen.github.io/cz-cli/)
[](https://badge.fury.io/js/babel-plugin-forbid-imports)
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
```json
{
"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
```json
{
"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
```json
{
"plugins": [
[
"babel-plugin-forbid-imports",
{
"paths": ["./src/server"]
}
]
]
}
```