babel-plugin-forbid-imports
v1.0.3
Published
throw errors if certain packages/directories are imported from
Downloads
1,391
Readme
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
{
"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"]
}
]
]
}