Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect no-duplicates prefer-inline default type import handling #162

Merged
merged 3 commits into from
Sep 29, 2024

Conversation

AaronMoat
Copy link

@AaronMoat AaronMoat commented Sep 28, 2024

I ran into this issue in one of my repositories with Koa:

import { type Middleware } from 'koa';
import type Koa from 'koa';

The rule was rewriting it to invalid syntax:

import Koa, type { Middleware } from 'koa';

One approach could be just to allow it to:

import Koa, { type Middleware } from 'koa';

However, I don't think this plugin should be changing type imports into value imports in this scenario.
Therefore, after this change, it leaves the imports alone. I hope this should be not too controversial given it was previously producing invalid syntax.

I am of course not an expert in this code :) but the change seems suspiciously simple. Are there any additional test cases I can add to help verify this?

Copy link

changeset-bot bot commented Sep 28, 2024

🦋 Changeset detected

Latest commit: 5d5ff0e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-import-x Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codesandbox-ci bot commented Sep 28, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@SukkaW
Copy link
Collaborator

SukkaW commented Sep 29, 2024

LGTM, I have approved the CI!

@SukkaW SukkaW merged commit 38d0081 into un-ts:master Sep 29, 2024
21 checks passed
renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull request Sep 29, 2024
##### [v4.3.1](https://github.com/un-ts/eslint-plugin-import-x/blob/HEAD/CHANGELOG.md#431)

##### Patch Changes

-   [#162](un-ts/eslint-plugin-import-x#162) [`38d0081`](un-ts/eslint-plugin-import-x@38d0081) Thanks [@AaronMoat](https://github.com/AaronMoat)! - Fix issue where `no-duplicates` rule with `prefer-inline` incorrectly marks default type and named type imports as duplicates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants