Plugin with prohibition of import / export from barrel files with specific relative path.
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.
💼 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 | 🌐 |
Name | Description |
---|---|
recommended | Only recommended rules |
all | All rules |
- Install plugin:
npm install eslint-plugin-barrels --save-dev
- Update eslint config:
{
"plugins": ["barrels"],
"rules": {
"barrels/no-import": "error"
}
}
or
{
"extends": [
"plugin:barrels/recommended"
],
}
If you have any suggestions, ideas, or problems, feel free to create an issue or PR.