src/content/docs/linter/rules/no-barrel-file.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.6.0` - Diagnostic Category: [`lint/performance/noBarrelFile`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Inspired from [`barrel-files/avoid-barrel-files`](https://github.com/thepassle/eslint-plugin-barrel-files/blob/main/docs/rules/avoid-barrel-files.md){
"linter": {
"rules": {
"performance": {
"noBarrelFile": "error"
}
}
}
}
Disallow the use of barrel file.
A barrel file is a file that re-exports all of the exports from other files in a directory. This structure results in the unnecessary loading of many modules, significantly impacting performance in large-scale applications. Additionally, it complicates the codebase, making it difficult to navigate and understand the project's dependency graph. This rule ignores .d.ts files and type-only exports.
For a more detailed explanation, check out https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7/
export * from "foo";
export * from "bar";
export { foo } from "foo";
export { bar } from "bar";
export { default as module1 } from "./module1";
export type * from "foo";
export type { foo } from "foo";