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

no-duplicates: fix false positive #232

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

steved-stripe
Copy link

@steved-stripe steved-stripe commented Feb 13, 2025

fixes #231

This PR removes the auto fix for:

import {AValue, type x, BValue} from './foo';
import {type y} from './foo'

as our heuristic for type vs non-type imports has changed slightly.

The second import would be considered a type-only import, and the first import would be considered a value import, so we aren't combining them.

We could make this more sophisticated if we wanted to but this fixes the bad autofix that would change:

import {
  type bar,
  buzz,
} from 'foo';
import type {bizz} from 'foo';

into:

import type {
  type bar,
  buzz,
  bizz,
} from 'foo';

related: import-js#2697

Copy link

changeset-bot bot commented Feb 13, 2025

⚠️ No Changeset found

Latest commit: 098ee4c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

codesandbox-ci bot commented Feb 13, 2025

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 Feb 14, 2025

Just wondering, will import-x/consistent-type-specifier-style (along with its autofixes) work for you? This means, after you get a "not-ideal" from the no-duplicates output you can then get the right one from import-x/consistent-type-specifier-style.

@steved-stripe
Copy link
Author

hmm I'm not sure, but it would be a significant amount of work to migrate the codebase to a consistent import style, there's a lot of various import styles currently

I think the current setup of the autofix resulting in broken builds is what I'm trying to avoid!

@JounQin
Copy link
Member

JounQin commented Feb 14, 2025

But this PR is not a correct fix, it's just ignoring issues.

@steved-stripe steved-stripe marked this pull request as draft February 26, 2025 17:44
@steved-stripe
Copy link
Author

Yeah fair enough, need to think about this more. I've updated the test cases with a new failing test that exercise the issue I ran into

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.

no-duplicates autofix incorrectly combines type and non-type typescript imports
3 participants