Skip to content

noBarrelFile (since v1.6.0)

Diagnostic Category: lint/performance/noBarrelFile

Sources:

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";
performance/noBarrelFile.js:1:1 lint/performance/noBarrelFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Avoid barrel files, they slow down performance, and cause large module graphs with modules that go unused.
  
  > 1 │ export * from "foo";
   ^^^^^^^^^^^^^^^^^^^^
    2 │ export * from "bar";
    3 │ 
  
   Check this thorough explanation to better understand the context.
  
export { foo } from "foo";
export { bar } from "bar";
performance/noBarrelFile.js:1:1 lint/performance/noBarrelFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Avoid barrel files, they slow down performance, and cause large module graphs with modules that go unused.
  
  > 1 │ export { foo } from "foo";
   ^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ export { bar } from "bar";
    3 │ 
  
   Check this thorough explanation to better understand the context.
  
export { default as module1 } from "./module1";
performance/noBarrelFile.js:1:1 lint/performance/noBarrelFile ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Avoid barrel files, they slow down performance, and cause large module graphs with modules that go unused.
  
  > 1 │ export { default as module1 } from "./module1";
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 
  
   Check this thorough explanation to better understand the context.
  
export type * from "foo";
export type { foo } from "foo";