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

Rule no-unused-modules does not count re-export all declarations #1945

Open
DMartens opened this issue Nov 12, 2020 · 1 comment
Open

Rule no-unused-modules does not count re-export all declarations #1945

DMartens opened this issue Nov 12, 2020 · 1 comment

Comments

@DMartens
Copy link
Contributor

The rule no-unused-modules reports files which only have re-export all declarations for not having exports, eg:

export * from './foo.js';
export * from './bar.js';

This seems to be intentional as the re-exports are deleted from the count before the check.
I did not find any information on the reasoning for this behavior.

My proposed solution is to add an option flag, eg. allowReExportOnly, to allow this.
The rule would still report if not a single re-export has an export.
I am willing to create a PR for this functionality if this change is approved.

@ljharb
Copy link
Member

ljharb commented Jan 22, 2021

The reasoning I cam surmise is that there's no purpose in having this file - the consumers of it can (and should) be directly importing from foo.js or bar.js (I don't see any discussion about it in #1142 tho).

A PR for an option is reasonable, but when enabled, it should actually check that somebody is importing from that file - iow, if the file in your OP is index.js, and nobody is importing from index.js, then that file should be reported as unused.

Similarly, if that option is enabled, and only one of the foo.js exports (let's say "baz") is imported from index.js, and none of the bar.js exports, I would expect the rule to error until index.js has been reduced to export { baz } from './foo.js'.

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