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 { default as foo, bar } 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 in the CLI or using the config file, you can use:

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

References

Released under the MIT License.