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

Destructured exports no unused modules #2038

Conversation

KristjanTammekivi
Copy link
Contributor

Fixes #2037

@coveralls
Copy link

coveralls commented Apr 27, 2021

Coverage Status

Coverage increased (+12.9%) to 84.007% when pulling 2057c05 on KristjanTammekivi:destructured-exports-no-unused-modules into 5898e28 on benmosher:master.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named exports aren’t destructuring; please update the terminology :-)

tests/src/rules/no-unused-modules.js Outdated Show resolved Hide resolved
tests/src/rules/no-unused-modules.js Outdated Show resolved Hide resolved
@KristjanTammekivi
Copy link
Contributor Author

I don't see how export const { a } = { a: 5 }; is not destructuring? In MDN there's an example of destructured assignments

// Exporting destructured assignments with renaming
export const { name1, name2: bar } = o;

@ljharb
Copy link
Member

ljharb commented Apr 27, 2021

Ohh, i misunderstood! Thanks.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, seems good

@ljharb
Copy link
Member

ljharb commented Apr 28, 2021

(Note that merging this is blocked on #1986)

@ljharb ljharb force-pushed the destructured-exports-no-unused-modules branch from 4953c36 to 2057c05 Compare May 12, 2021 23:21
@ljharb
Copy link
Member

ljharb commented May 12, 2021

This was actually fixed by #1997, but I've rebased this to keep the test.

@ljharb ljharb merged commit 2057c05 into import-js:master May 13, 2021
@emreboga
Copy link

Hey @ljharb, I don't think this was fully fixed by #1997 as it only addresses object type destucturing, not including array types. You can see it in the code:
https://github.com/import-js/eslint-plugin-import/pull/1997/files#diff-7d2908b010ec724c0f3a0d7615cb91f4673d765d52c6ba6607501e23470f2966R85

I'm seeing this in the code with the version 2.28.1, which has the fix with #1997. Here is a code chunk I have:

export const [authUserLoading, authUserError] = createLoadingAndErrorSelectors(
  AUTH_USER
);

and here is the error I get:

error  exported declaration 'undefined' not used within other modules  import/no-unused-modules

@ljharb
Copy link
Member

ljharb commented Nov 18, 2023

@emreboga interesting - would you mind filing a new issue about that one?

@emreboga
Copy link

@ljharb Sure! Please see #2930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants