Skip to content

import/no-named-default Style

What it does

Reports use of a default export as a locally named import.

Why is this bad?

Rationale: the syntax exists to import default exports expressively, let's use it.

Examples

Examples of incorrect code for this rule:

js
// message: Using exported name 'bar' as identifier for default export.
import { default as foo } from "./foo.js";
import { bar, default as foo } from "./foo.js";

Examples of correct code for this rule:

js
import foo from "./foo.js";
import foo, { bar } from "./foo.js";

How to use

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["import"],
  "rules": {
    "import/no-named-default": "error"
  }
}
bash
oxlint --deny import/no-named-default --import-plugin

References

Released under the MIT License.