{"id":19846,"library":"eslint-plugin-no-barrel-files","title":"ESLint Plugin No Barrel Files","description":"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.","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/art0rz/eslint-plugin-no-barrel-files","tags":["javascript","eslint","plugin","addon","extension","rule","barrel","import","export","typescript"],"install":[{"cmd":"npm install eslint-plugin-no-barrel-files","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-no-barrel-files","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-no-barrel-files","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin requires ESLint 8, 9, or 10.","package":"eslint","optional":false}],"imports":[{"note":"ESM default import; CommonJS require works but may not provide correct types. For flat config (ESLint 9+), use default import.","wrong":"const noBarrelFiles = require('eslint-plugin-no-barrel-files')","symbol":"default (plugin object)","correct":"import noBarrelFiles from 'eslint-plugin-no-barrel-files'"},{"note":"Since v1.0.0, `configs.recommended` is the canonical flat config. `flat` export maintained for backwards compatibility but deprecated.","wrong":"noBarrelFiles.flat","symbol":"flat config","correct":"noBarrelFiles.configs.recommended"},{"note":"For ESLint 8 legacy config, use `legacy-recommended`. The `recommended` config is for flat config (ESLint 9+).","wrong":"noBarrelFiles.configs.recommended","symbol":"legacy config","correct":"noBarrelFiles.configs['legacy-recommended']"}],"quickstart":{"code":"// .eslintrc.cjs (legacy ESLint 8)\nmodule.exports = {\n  plugins: ['no-barrel-files'],\n  rules: {\n    'no-barrel-files/no-barrel-files': 'error'\n  }\n};\n\n// eslint.config.js (flat ESLint 9+)\nimport noBarrelFiles from 'eslint-plugin-no-barrel-files';\n\nexport default [\n  ...noBarrelFiles.configs.recommended,\n  {\n    rules: {\n      // Override or add more rules\n    }\n  }\n];\n","lang":"javascript","description":"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."},"warnings":[{"fix":"Replace `noBarrelFiles.flat` with `noBarrelFiles.configs.recommended` in flat config.","message":"In v1.0.0, the flat config export changed from `plugin.flat` to `plugin.configs.recommended`. If using `plugin.flat`, update to `configs.recommended`.","severity":"breaking","affected_versions":">=1.0.0 <1.3.0"},{"fix":"Use `configs.recommended` instead of `flat`.","message":"The `flat` export is deprecated since v1.0.0. It will be removed in a future major version.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Set rule name as `'no-barrel-files/no-barrel-files'`.","message":"Legacy config users must use the plugin prefix in rule names: `'no-barrel-files/no-barrel-files'`. Using just `'no-barrel-files'` will not work.","severity":"gotcha","affected_versions":"*"},{"fix":"If needed, manually audit or extend the rule. Check plugin issue tracker for potential updates.","message":"The rule does not flag `export { default } from './foo'` (named export with alias 'default'); only `export { default as Moo } from './Moo'` is flagged.","severity":"gotcha","affected_versions":"<=1.3.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install eslint-plugin-no-barrel-files --save-dev`.","cause":"Plugin not installed or not in node_modules.","error":"Error: Failed to load plugin 'no-barrel-files' declared in '.eslintrc': Cannot find module 'eslint-plugin-no-barrel-files'"},{"fix":"Set severity to 2 (or 'error') in an array: `['error']` or `2`.","cause":"Rule severity incorrectly set (e.g., as string 'error' instead of number 2).","error":"Configuration for rule \"no-barrel-files/no-barrel-files\" is invalid: Value \"error\" should be one of 0, 1, 2."},{"fix":"Use `noBarrelFiles.configs.recommended` instead of `noBarrelFiles.flat`.","cause":"Using deprecated `flat` export which is no longer a function but an array.","error":"TypeError: noBarrelFiles.flat is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}