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

[import/no-duplicates] Autofix merges imports incorrectly - single index.d.ts but multiple modules #2992

Open
mpellegrini opened this issue Mar 28, 2024 · 2 comments

Comments

@mpellegrini
Copy link

Working on a Svelte project. For a majority of their packages, they have a single index.d.ts that is used but the d.ts file uses modules for namespacing.

Subset of the package.json exports

"./animate": {
      "types": "./types/index.d.ts",
      "default": "./src/runtime/animate/index.js"
    },
    "./easing": {
      "types": "./types/index.d.ts",
      "default": "./src/runtime/easing/index.js"
    },

so for the above fragment I have an imports that looks like this

  import { quadOut } from 'svelte/easing'
  import { crossfade } from 'svelte/transition'

This yields the following warning:

warning  '.../node_modules/.pnpm/svelte@4.2.12/node_modules/svelte/types/index.d.ts' imported multiple times  import/no-duplicates

but auto fix changes this to the following - which is not correct and doesn't work from a code perspective

  import { quadOut, crossfade } from 'svelte'

Trying to determine if there is any way to keep this rule but allow for exception to the rules.

Thanks in advance for any help / guidance.

@ljharb
Copy link
Member

ljharb commented Mar 28, 2024

Are you using eslint-import-resolver-typescript? Please share your config if that doesn't fix it.

@mpellegrini
Copy link
Author

Thanks for the quick reply. I am using eslint-import-resolver-typescript. If it helps I created a sample app that uses the standard create svelte app skeleton project.

https://github.com/mpellegrini/eslint-import-plugin-no-duplicates-issue

config being used is here - https://github.com/mpellegrini/eslint-import-plugin-no-duplicates-issue/blob/main/.eslintrc.cjs

The specific file that is exhibiting this behavior is here https://github.com/mpellegrini/eslint-import-plugin-no-duplicates-issue/blob/main/src/routes/%2Bpage.svelte#L2

I have already added the eslint disable on one of the imports that is auto fixing incorrectly.

For other types of imports it is working for me, bot collapsing and keeping things separate as expected. Just specifically with these imports from Svelte.

If there is anything else I can provide please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants