eslint-plugin-barrels
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

  1. Install plugin:
npm install eslint-plugin-barrels --save-dev
  1. 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.

Package Sidebar

Install

npm i eslint-plugin-barrels

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

30.7 kB

Total Files

37

Last publish

Collaborators

  • dkozachenko