{"id":19695,"library":"eslint-plugin-barrel-files","title":"eslint-plugin-barrel-files","description":"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.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/thepassle/eslint-plugin-barrel-files","tags":["javascript","eslint","eslintplugin","eslint-plugin","barrel","barrelfiles"],"install":[{"cmd":"npm install eslint-plugin-barrel-files","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-barrel-files","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-barrel-files","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin requires ESLint >=5","package":"eslint","optional":false}],"imports":[{"note":"Default export is the plugin object; in ESLint flat config, use import plugin from 'eslint-plugin-barrel-files' and spread plugin.configs.recommended.","wrong":"const { rules } = require('eslint-plugin-barrel-files');","symbol":"plugin","correct":"import plugin from 'eslint-plugin-barrel-files';"},{"note":"In ESLint flat config (>=9), use the recommended config exported by the plugin. For legacy .eslintrc, use plugins: ['barrel-files'].","wrong":"module.exports = { plugins: ['barrel-files'], rules: { 'barrel-files/avoid-barrel-files': 'error' } };","symbol":"recommended config","correct":"import plugin from 'eslint-plugin-barrel-files';\nexport default [\n  ...plugin.configs.recommended\n];"},{"note":"Rule names must be prefixed with 'barrel-files/' because the plugin is namespaced.","wrong":"{\n  rules: {\n    'avoid-barrel-files': 'error'\n  }\n}","symbol":"avoid-barrel-files rule","correct":"// flat config:\n{\n  rules: {\n    'barrel-files/avoid-barrel-files': 'error'\n  }\n}"}],"quickstart":{"code":"// eslint.config.js (flat config)\nimport plugin from 'eslint-plugin-barrel-files';\n\nexport default [\n  {\n    files: ['**/*.js', '**/*.ts'],\n    ...plugin.configs.recommended,\n  },\n  // Or selectively enable rules:\n  {\n    files: ['**/*.js'],\n    plugins: { 'barrel-files': plugin },\n    rules: {\n      'barrel-files/avoid-barrel-files': 'error',\n      'barrel-files/avoid-importing-barrel-files': 'warn',\n    }\n  }\n];\n\n// .eslintrc legacy config:\n// {\n//   plugins: ['barrel-files'],\n//   rules: {\n//     'barrel-files/avoid-barrel-files': 'error',\n//   }\n// }\n\n// Then run: npx eslint .","lang":"javascript","description":"Shows how to configure eslint-plugin-barrel-files in ESLint flat config (recommended) and legacy .eslintrc format."},"warnings":[{"fix":"Update to ESLint flat config (eslint.config.js) or continue using v2.x for .eslintrc support.","message":"Version 3.x requires ESLint >=9 or ESLint >=5 but with flat config; legacy .eslintrc support may behave differently.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use 'barrel-files/avoid-re-export-all' instead.","message":"The 'avoid-namespace-import' rule is considered deprecated in favor of 'avoid-re-export-all' as it covers more cases.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"In eslint.config.js, add 'files: [\"**/*.js\"]' to the config object that applies the barrel-files rules.","message":"Plugin rules analyze only files included in ESLint's linting scope; files outside must be explicitly included via 'files' in flat config.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Add 'ignorePatterns: [\"node_modules\"]' in your config.","message":"The plugin does not automatically detect barrel files in node_modules; you must configure ESLint to ignore node_modules or exclude them manually.","severity":"gotcha","affected_versions":">=0.0.0"}],"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-barrel-files --save-dev' and ensure you import it at the top of eslint.config.js: import plugin from 'eslint-plugin-barrel-files';","cause":"Plugin not installed or ESLint cannot resolve it in flat config without import.","error":"ESLint couldn't find the plugin \"eslint-plugin-barrel-files\"."},{"fix":"Use 'barrel-files/avoid-barrel-files': 'error' or 'barrel-files/avoid-barrel-files': ['warn', { /* options */ }].","cause":"Incorrect rule configuration format; rule severity must be a string or number, not an object.","error":"Configuration for rule \"barrel-files/avoid-barrel-files\" is invalid: Expected an array or object."},{"fix":"Use 'barrel-files/avoid-barrel-files' instead of 'avoid-barrel-files'.","cause":"Missing prefix 'barrel-files/' in rule name.","error":"Definition for rule 'avoid-barrel-files' was not found."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}