{"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,"search_vec":"'3.0.1':32 'absent':71 'aggreg':15 'altern':72 'barrel':4,10,49,86,95 'barrelfil':96 'broader':79 'browser':59 'bundler':27 'cadenc':34 'caus':53 'cdns':60 'current':29 'detect':9 'differenti':46 'drop':40 'environ':28 'eslint':2,6,44,75,90,93 'eslint-plugin':92 'eslint-plugin-barrel-fil':1 'eslint-plugin-import':74 'eslintplugin':91 'export':14 'file':5,11,50,87 'focus':84 'import':17,77 'irregular':36 'issu':55 'javascript':89 'last':37 'like':73 'load':23 'major':38 'modul':22 'non':26 'non-bundl':25 'older':43 'pattern':51 'perform':54 'plugin':3,7,76,94 'prevent':20 're':13 're-export':12 'releas':33 'runner':58 'runtim':65 'scope':80 'server':63 'server-sid':62 'shake':69 'side':64 'specif':47,88 'stabl':30 'support':41 'target':48 'test':57 'tree':68 'tree-shak':67 'unnecessari':21 'v3':39 'version':31,45","created_at":"2026-04-25T11:19:09.534775+00:00","updated_at":"2026-04-25T11:19:09.534775+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/thepassle/eslint-plugin-barrel-files","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/eslint-plugin-barrel-files","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}