Skip to content

noNamespaceImport (since v1.6.0)

Diagnostic Category: lint/style/noNamespaceImport

Sources:

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.

import * as foo from "foo";
style/noNamespaceImport.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.
  
import { foo } from "foo"
import type { bar } from "bar"
import type * as baz from "baz"