eslint-plugin-barrels
v1.0.0
Published
Plugin with prohibition of import / export from barrel files
Downloads
2
Maintainers
Readme
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.