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.

testing
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.

Default export is the plugin object; in ESLint flat config, use import plugin from 'eslint-plugin-barrel-files' and spread plugin.configs.recommended.

import plugin from 'eslint-plugin-barrel-files';

In ESLint flat config (>=9), use the recommended config exported by the plugin. For legacy .eslintrc, use plugins: ['barrel-files'].

import plugin from 'eslint-plugin-barrel-files'; export default [ ...plugin.configs.recommended ];

Rule names must be prefixed with 'barrel-files/' because the plugin is namespaced.

// flat config: { rules: { 'barrel-files/avoid-barrel-files': 'error' } }

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 footguns
breakingVersion 3.x requires ESLint >=9 or ESLint >=5 but with flat config; legacy .eslintrc support may behave differently.
deprecatedThe 'avoid-namespace-import' rule is considered deprecated in favor of 'avoid-re-export-all' as it covers more cases.
gotchaPlugin rules analyze only files included in ESLint's linting scope; files outside must be explicitly included via 'files' in flat config.
gotchaThe plugin does not automatically detect barrel files in node_modules; you must configure ESLint to ignore node_modules or exclude them manually.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
14 hits · last 30 days
gptbot
4
ahrefsbot
4
amazonbot
4
script
1
bytedance
1
Resources