# no-barrel-files

Rule `unicorn/no-barrel-files`. Disallow barrel files.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2010 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-barrel-files` | no | no | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-barrel-files.md) |

## Code examples

### Incorrect: the rule reports this

```js
export {foo} from './foo.js';
```

```js
import {foo} from './foo.js';
export {foo};
```

```js
export * from './foo.js';
export * from './bar.js';
```

### Correct: the rule accepts this

```js
export const foo = 1;
```

```js
import {foo} from './foo.js';
export const bar = foo;
```

```js
export {foo} from './foo.js';
export const bar = 1;
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-barrel-files": "error",
    },
  },
];
```

## Related rules

- [unicorn/no-array-front-mutation](https://lintradar.dev/rules/unicorn/no-array-front-mutation.md): Disallow front-of-array mutation.
- [unicorn/key-name-casing](https://lintradar.dev/rules/unicorn/key-name-casing.md): Enforce a case style for data keys.
- [unicorn/iteration-fallback-style](https://lintradar.dev/rules/unicorn/iteration-fallback-style.md): Enforce a consistent style for optional loop sources.
- [unicorn/indent](https://lintradar.dev/rules/unicorn/indent.md): Enforce consistent indentation in JSON and CSS.
- [unicorn/no-keyword-prefix](https://lintradar.dev/rules/unicorn/no-keyword-prefix.md): Disallow identifiers starting with `new` or `class`.
- [unicorn/id-match](https://lintradar.dev/rules/unicorn/id-match.md): Require identifiers to match a specified regular expression.

---

Web page: https://lintradar.dev/rules/unicorn/no-barrel-files. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
