eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

no-unused-modules: option to warn only if all exports unused (file unused)

Open unsupervisednn opened this issue 5 years ago • 5 comments
trafficstars

This is the best plugin I've found that works to find unused files with webpack. However I like keeping some exports available even if unused, this makes it difficult to find the files that have no used exports at all.

unsupervisednn avatar Jun 18 '20 23:06 unsupervisednn

Can you elaborate on why you'd want to keep around anything unused?

ljharb avatar Jun 19 '20 04:06 ljharb

because in a project being developed with other people you would like to keep the API of your modules open instead of only restricting to whats used currently

unsupervisednn avatar Jun 26 '20 01:06 unsupervisednn

Seems like a project in that kind of flux wouldn't want this rule enabled at all?

ljharb avatar Jun 27 '20 04:06 ljharb

Hi everyone, I figured I'd chime in with our use case in favor of this, in case it makes a difference.

We have a pretty large frontend / react project, where some developers may be considered "responsible" for some shared components, while others are merely consumers of it. The producer of a shared component may chose to explicitly export its property-types, as a service to anyone requiring more advanced type-play. Meanwhile, the first consumer may simply use the types implicitly, IE. never actually referencing the type export.

This means that we have a quite a lot of components with excess exports, components that kind of exhibit library-like characteristics, despite still residing alongside the consumer. These all error with no-unused-modules of course. Meanwhile we'd still like to eliminate unused components.

badeball avatar Oct 26 '21 07:10 badeball

Try knip

soryy708 avatar Jan 28 '25 20:01 soryy708