Registry / testing / eslint-plugin-barrel-files

eslint-plugin-barrel-files

JSON →
library3.0.1jsnpmunverified

ESLint plugin to detect barrel files (re-export aggregators) and imports from them, preventing unnecessary module loading in non-bundler environments. Current stable version 3.0.1. Release cadence is irregular; last major v3 dropped support for older ESLint versions. Differentiator: specifically targets barrel file patterns that cause performance issues in test runners, browsers, CDNs, and server-side runtimes where tree-shaking is absent. Alternatives like eslint-plugin-import have broader scope but don't focus on barrel files specifically.

npm install eslint-plugin-barrel-files
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-BARR
E
eslint-plugin-barrel-files
testingjavascriptv3.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
import plugin from 'eslint-plugin-barrel-files';
const { rules } = require('eslint-plugin-barrel-files');
Default export is the plugin object; in ESLint flat config, use import plugin from 'eslint-plugin-barrel-files' and spread plugin.configs.recommended.
recommended config
import plugin from 'eslint-plugin-barrel-files'; export default [ ...plugin.configs.recommended ];
module.exports = { plugins: ['barrel-files'], rules: { 'barrel-files/avoid-barrel-files': 'error' } };
In ESLint flat config (>=9), use the recommended config exported by the plugin. For legacy .eslintrc, use plugins: ['barrel-files'].
avoid-barrel-files rule
// flat config: { rules: { 'barrel-files/avoid-barrel-files': 'error' } }
{ rules: { 'avoid-barrel-files': 'error' } }
Rule names must be prefixed with 'barrel-files/' because the plugin is namespaced.

Shows how to configure eslint-plugin-barrel-files in ESLint flat config (recommended) and legacy .eslintrc format.

// eslint.config.js (flat config) import plugin from 'eslint-plugin-barrel-files'; export default [ { files: ['**/*.js', '**/*.ts'], ...plugin.configs.recommended, }, // Or selectively enable rules: { files: ['**/*.js'], plugins: { 'barrel-files': plugin }, rules: { 'barrel-files/avoid-barrel-files': 'error', 'barrel-files/avoid-importing-barrel-files': 'warn', } } ]; // .eslintrc legacy config: // { // plugins: ['barrel-files'], // rules: { // 'barrel-files/avoid-barrel-files': 'error', // } // } // Then run: npx eslint .
Debug
Known issues
breakingVersion 3.x requires ESLint >=9 or ESLint >=5 but with flat config; legacy .eslintrc support may behave differently.
fix
Update to ESLint flat config (eslint.config.js) or continue using v2.x for .eslintrc support.
affects: >=3.0.0
deprecatedThe 'avoid-namespace-import' rule is considered deprecated in favor of 'avoid-re-export-all' as it covers more cases.
fix
Use 'barrel-files/avoid-re-export-all' instead.
affects: >=3.0.0
gotchaPlugin rules analyze only files included in ESLint's linting scope; files outside must be explicitly included via 'files' in flat config.
fix
In eslint.config.js, add 'files: ["**/*.js"]' to the config object that applies the barrel-files rules.
affects: >=3.0.0
gotchaThe plugin does not automatically detect barrel files in node_modules; you must configure ESLint to ignore node_modules or exclude them manually.
fix
Add 'ignorePatterns: ["node_modules"]' in your config.
affects: >=0.0.0
Errors
Common errors & fixes
ESLint couldn't find the plugin "eslint-plugin-barrel-files".
Plugin not installed or ESLint cannot resolve it in flat config without import.
fix
Run 'npm install eslint-plugin-barrel-files --save-dev' and ensure you import it at the top of eslint.config.js: import plugin from 'eslint-plugin-barrel-files';
Configuration for rule "barrel-files/avoid-barrel-files" is invalid: Expected an array or object.
Incorrect rule configuration format; rule severity must be a string or number, not an object.
fix
Use 'barrel-files/avoid-barrel-files': 'error' or 'barrel-files/avoid-barrel-files': ['warn', { /* options */ }].
Definition for rule 'avoid-barrel-files' was not found.
Missing prefix 'barrel-files/' in rule name.
fix
Use 'barrel-files/avoid-barrel-files' instead of 'avoid-barrel-files'.
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency; plugin requires ESLint >=5
Agent activity
8 hits · last 30 days
node
6
Amazon
1
Resources
eslint-plugin-barrel-files — npm install eslint-plugin-barrel-files · libregistry