import-js / import-js/eslint-plugin-import

Suggestion [`no-named-default`]: add option to allow type imports with multiple imports

Open
#1,869 6 comments 4 reactions 0 assignees View on GitHub
bug help wanted typescript
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Typescript's [`import type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) cannot be used to import the default export and named exports without using `default as`:

```ts
import type Foo, {Bar} from 'foo'
// A type-only import can specify a default import or named bindings, but not both.
```

However, these both work but trigger `no-duplicates` and `no-named-default` respectively:

```ts
import type Foo from 'foo'
import type {Bar} from 'foo'
```

```ts
import type {default as Foo, Bar} from 'foo'
```

Could there be a new option to `no-named-default` that allows type imports with multiple imports? For example:

```ts
import type {default as Foo} from 'foo' // lint warning
import type {default as Foo, Bar} from 'foo' // fine
```

Contributor guide

Open the contributing guide

Research direction

Start by reading the no-named-default and no-duplicates rule implementations and their tests, then trace how type-only imports are represented. Confirm the requested option distinguishes a single default type import from a type import combining default and named bindings, and add coverage for both examples in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.