noNamespaceImport
このコンテンツはまだ日本語訳がありません。
Diagnostic Category: lint/style/noNamespaceImport
Since: v1.6.0
Sources:
- Same as:
barrel-files/avoid-namespace-import
Disallow the use of namespace imports.
Namespace imports might impact the efficiency of tree shaking, a process that removes unused code from bundles. The effectiveness of tree shaking largely depends on the bundler (e.g., Webpack, Rollup) and its configuration. Modern bundlers are generally capable of handling namespace imports effectively, but using named imports is recommended for optimal tree shaking and minimizing bundle size.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:8 lint/style/noNamespaceImport ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Avoid namespace imports, it can prevent efficient tree shaking and increase bundle size.
> 1 │ import * as foo from “foo”;
│ ^^^^^^^^^^^^^^^^^^^
2 │
ℹ Use named imports instead.