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-unused-modules] Imports overriding reexports #1722

Closed
Ephem opened this issue Apr 7, 2020 · 4 comments · Fixed by #1727
Closed

[no-unused-modules] Imports overriding reexports #1722

Ephem opened this issue Apr 7, 2020 · 4 comments · Fixed by #1727

Comments

@Ephem
Copy link
Contributor

Ephem commented Apr 7, 2020

I noticed that no-unused-modules with unusedExports trips up on this syntax:

a.js:

export function a() {}

// The following line will wrongly error as unused:
export function aa() {}

b.js:

import { a } from './a';

export { aa } from './a';

I've tracked this down to this line in the src, which overwrites any previously detected reexports. The proposed fix is to do something like what is already being done in these lines to keep both reexported entries and imports.

I can give a shot at throwing together a PR if this looks reasonable?

@golopot

This comment has been minimized.

@Ephem

This comment has been minimized.

@ljharb
Copy link
Member

ljharb commented Apr 7, 2020

Yes, that seems like a good fix - the code was probably assuming that duplicate imports were always merged.

@Ephem
Copy link
Contributor Author

Ephem commented Apr 7, 2020

Yeah, having a import and a reexport from the same file isn't a super common pattern. 😄

I have some code that works, just need to write a test and I'll send a PR within the next few days.

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

Successfully merging a pull request may close this issue.

3 participants