eslint-plugin-barrels v1.0.0
eslint-plugin-barrels
Plugin with prohibition of import / export from barrel files with specific relative path.
Motivation
Twice in my life Webpack failed build of Angular application with unexpected error because of import from barrel file like this:
import { smth } from '..';If I changed import to particular path like this:
import { smth } from './smth.ts';It would work.
!NOTE
There were not circular dependencies in my files. Crash depended only on path.
Unfortunately, I didn't found some issues or questions on Stack Overflow with same problem, so you should take my word for it.
Rules
š¼ Configurations enabled in.\
ā
Set in the recommended configuration.\
š Set in the all configuration.\
š§ Automatically fixable by the --fix CLI option.\
š” Manually fixable by editor suggestions.
| Name | Description | š¼ | š§ | š” |
|---|---|---|---|---|
| no-import | Disallow import from barrel files with specific relative path | ā š | ||
| no-export | Disallow export from barrel files with specific relative path | š |
Configurations
| Name | Description |
|---|---|
| recommended | Only recommended rules |
| all | All rules |
Usage
- Install plugin:
npm install eslint-plugin-barrels --save-dev- Update eslint config:
{
"plugins": ["barrels"],
"rules": {
"barrels/no-import": "error"
}
}or
{
"extends": [
"plugin:barrels/recommended"
],
}Contributing
If you have any suggestions, ideas, or problems, feel free to create an issue or PR.
2 years ago