1.0.0 • Published 2 years ago

eslint-plugin-barrels v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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.

NameDescriptionšŸ’¼šŸ”§šŸ’”
no-importDisallow import from barrel files with specific relative pathāœ… 🌐
no-exportDisallow export from barrel files with specific relative path🌐

Configurations

NameDescription
recommendedOnly recommended rules
allAll 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.