Registry / testing / eslint-plugin-no-barrel-files

eslint-plugin-no-barrel-files

JSON →
library1.3.1jsnpmunverified

ESLint plugin (v1.3.1) that disallows barrel files — re-export modules that aggregate and re-export other modules. Barrel files are known to slow down builds/tests, cause circular dependencies, and hinder tree shaking. This plugin provides a single rule `no-barrel-files` that flags patterns like `export * from './foo'` or re-importing a default and re-exporting it. Supports flat config (ESLint 9+) and legacy config (ESLint 8). Actively maintained with TypeScript type declarations. Alternative to manual code review or other linting rules that partially address barrel files.

npm install eslint-plugin-no-barrel-files
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-NO-B
E
eslint-plugin-no-barrel-files
testingjavascriptv1.3.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.

default (plugin object)
import noBarrelFiles from 'eslint-plugin-no-barrel-files'
const noBarrelFiles = require('eslint-plugin-no-barrel-files')
ESM default import; CommonJS require works but may not provide correct types. For flat config (ESLint 9+), use default import.
flat config
noBarrelFiles.configs.recommended
noBarrelFiles.flat
Since v1.0.0, `configs.recommended` is the canonical flat config. `flat` export maintained for backwards compatibility but deprecated.
legacy config
noBarrelFiles.configs['legacy-recommended']
noBarrelFiles.configs.recommended
For ESLint 8 legacy config, use `legacy-recommended`. The `recommended` config is for flat config (ESLint 9+).

Shows two ESLint configurations: legacy CommonJS for ESLint 8 and modern ESM flat config for ESLint 9+. Enables the single rule that flags barrel file patterns.

// .eslintrc.cjs (legacy ESLint 8) module.exports = { plugins: ['no-barrel-files'], rules: { 'no-barrel-files/no-barrel-files': 'error' } }; // eslint.config.js (flat ESLint 9+) import noBarrelFiles from 'eslint-plugin-no-barrel-files'; export default [ ...noBarrelFiles.configs.recommended, { rules: { // Override or add more rules } } ];
Debug
Known issues
breakingIn v1.0.0, the flat config export changed from `plugin.flat` to `plugin.configs.recommended`. If using `plugin.flat`, update to `configs.recommended`.
fix
Replace `noBarrelFiles.flat` with `noBarrelFiles.configs.recommended` in flat config.
affects: >=1.0.0 <1.3.0
deprecatedThe `flat` export is deprecated since v1.0.0. It will be removed in a future major version.
fix
Use `configs.recommended` instead of `flat`.
affects: >=1.0.0
gotchaLegacy config users must use the plugin prefix in rule names: `'no-barrel-files/no-barrel-files'`. Using just `'no-barrel-files'` will not work.
fix
Set rule name as `'no-barrel-files/no-barrel-files'`.
affects: *
gotchaThe rule does not flag `export { default } from './foo'` (named export with alias 'default'); only `export { default as Moo } from './Moo'` is flagged.
fix
If needed, manually audit or extend the rule. Check plugin issue tracker for potential updates.
affects: <=1.3.1
Errors
Common errors & fixes
Error: Failed to load plugin 'no-barrel-files' declared in '.eslintrc': Cannot find module 'eslint-plugin-no-barrel-files'
Plugin not installed or not in node_modules.
fix
Run `npm install eslint-plugin-no-barrel-files --save-dev`.
Configuration for rule "no-barrel-files/no-barrel-files" is invalid: Value "error" should be one of 0, 1, 2.
Rule severity incorrectly set (e.g., as string 'error' instead of number 2).
fix
Set severity to 2 (or 'error') in an array: `['error']` or `2`.
TypeError: noBarrelFiles.flat is not a function
Using deprecated `flat` export which is no longer a function but an array.
fix
Use `noBarrelFiles.configs.recommended` instead of `noBarrelFiles.flat`.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies
eslintrequiredPeer dependency; plugin requires ESLint 8, 9, or 10.
Agent activity
2 hits · last 30 days
node
2
Resources