import/no-named-default

Disallow import { default as name } in favor of import name

Also called import-x/no-named-default

import { default as React } from "react" and import React from "react" do the same thing. The second is shorter, and it's the form readers expect.

Configure#

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"import/no-named-default" = "error" # or "warn"

Examples#

example.js1 problem
import { default as React, useState } from "react";
example.ts1 problem
import type { default as User } from "./user";
example.jsNo problems
import React, { useState } from "react";
example.tsNo problems
import type User from "./user";

A name marked with type inside the braces isn't reported either:

example.tsNo problems
import { type default as User, loadUser } from "./user";