Description
While ignoreExports
allows us to ignore unused exports for specific files, we need to be able to ignore used imports.
Why?
Let's assume there's three files:
- entry.js
- utility.js
- utility.spec.js
Both entry.js
and utility.spec.js
import from utility.js
. Here, we'd want to include entry.js
and utility.spec.js
in ignoreExports
since one is an entry point and the other is a test. We're ensured if both files stop importing from utility.js
then the eslint rule will error, which is good!
The issue is when just entry.js
stops importing from utility.js
, which is what we want this rule to identify. Right now, the tests will keep utility.js
from ever being identified as unused, even though practically it's unused by the application. I'd have to manually discover that the application isn't using utility.js
. This will never happen; I'd assume that the change in entry.js
would identify this for me, but I'd have to manually check if utility.spec.js
is the only one importing it, which negates the value of this rule. If I could declare in options to ignoreImports
from **/*.spec.*
, then utility.js
will be identified as unused, which would be good!.
Currently, there's no way to accomplish this. Including **/*.spec.*
in ignoreExports
, setting src
to ['**/!(*.spec.js)']
, or having an override where excludedFiles
includes **/*.spec.*
all do the same thing, which isn't what I want. We specifically need to identify files where we want to ignore their imports. The moment we write a unit test or a storybook story, we're essentially disabling the useful of this rule.