noBarrelFile
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/performance/noBarrelFile
Since: v1.6.0
Sources:
- Inspired from:
barrel-files/avoid-barrel-files
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/
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.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.
code-block.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.
code-block.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.