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] False positive on multiple imports from submodules #2054

Closed
SCasarotto opened this issue May 13, 2021 · 8 comments
Closed

Comments

@SCasarotto
Copy link

I am seeing the following warning twice for .../node_modules/firebase/empty-import.d.ts' imported multiple times import/no-duplicates for the following code:

import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';

Interesting I am no seeing this warning if its simply

import firebase from 'firebase/app';
import 'firebase/database';

Additionally I saw this PR #1612 where a comment is made about circling back on the second case. The fact that the second case isn't triggering a warning makes me think that maybe this is just a bug handling 3 and not 2 🤷‍♂️ .

@ljharb
Copy link
Member

ljharb commented May 14, 2021

This seems like it's related to the typescript resolver.

@SCasarotto
Copy link
Author

If it helps I am using eslint-import-resolver-typescript with the following settings:

'import/resolver': {
      typescript: {
        alwaysTryTypes: true,
      },
    },

If this is an issue in that lib, happy to move this issue. I am a bit new to these two libs so I am stilling trying to get my bearings on what owns what part.

@ljharb
Copy link
Member

ljharb commented May 14, 2021

What I mean is, if all of the imports are resolving to the same d.ts file, then the import plugin will assume they're duplicate imports.

@murilocp
Copy link

I have the same problem, but with date-fns lib.

this is the code where I got the "import/no-duplicates" warning:

import ptBR from 'date-fns/locale/pt-BR';
import { addDays, format, getYear } from 'date-fns';

this is not correct, right?

@ljharb
Copy link
Member

ljharb commented Aug 18, 2021

@murilocp you're correct, those are two different specifiers/modules and should not be warned on.

@the-ult
Copy link

the-ult commented Jan 14, 2022

I have the same problem, but with date-fns lib.

this is the code where I got the "import/no-duplicates" warning:

import ptBR from 'date-fns/locale/pt-BR';
import { addDays, format, getYear } from 'date-fns';

this is not correct, right?

This stil seems to be a problem.
Is this something which should be fixed in date-fns or in estlint-plugin-import?

@ljharb
Copy link
Member

ljharb commented Jan 14, 2022

@the-ult here, which is why there’s a help wanted label.

@JounQin
Copy link
Collaborator

JounQin commented Jul 19, 2022

duplicate of #1479

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants