New: no-unused-modules rule#1142
Conversation
Signed-off-by: René Fermann <rene.fermann@gmx.de>
Signed-off-by: René Fermann <rene.fermann@gmx.de>
Signed-off-by: René Fermann <rene.fermann@gmx.de>
…ilename Signed-off-by: René Fermann <rene.fermann@gmx.de>
Signed-off-by: René Fermann <rene.fermann@gmx.de>
Signed-off-by: René Fermann <rene.fermann@gmx.de>
This comment has been minimized.
This comment has been minimized.
|
While looking into how import *I'm unsure what should happen when import * as localVar from './file-1';
localVar.something();Can we detect that we're actually using the named export export fromGiven
dynamic importI suspect dynamic import cannot be detected, this should be mentioned in the docs. |
|
Yes, an import * should mark all exports as used, i think. |
… sanity checks Signed-off-by: René Fermann <rene.fermann@gmx.de>
Signed-off-by: René Fermann <rene.fermann@gmx.de>
…rom ', revised docs
|
Support for How can I analyze, why the AppVeyor build is failing all the time? It btw also fails for tests I haven't touched at all 😕 |
|
@ljharb: do you have any ideas how to tackle the failing AppVeyor build? |
|
@rfermann i believe it's on master, and unrelated to this PR. |
|
Okay, good to know. What else needs to be done from my site to let this PR be merged? Should I adjust the change log? Or is that one of these tasks you will perform @ljharb? |
|
@rfermann you don't have to worry about the changelog; the appveyor issue should be fixed on master if you rebase. |
…orts', revised docs Signed-off-by: René Fermann <rene.fermann@gmx.de>
Signed-off-by: René Fermann <rene.fermann@gmx.de>
|
@ljharb , @benmosher: what else am I expected to do to get this PR merged? Is it the outstanding rebase which is blocking the merge? |
ljharb
left a comment
There was a problem hiding this comment.
Doing a fresh review - looks good overall. Just a few comments.
…riable, fixed documentation Signed-off-by: Fermann <rene.fermann@capgemini.com>
ljharb
left a comment
There was a problem hiding this comment.
Please ensure all files have trailing newlines.
|
Thanks for your latest feedback. I implemented your suggestions.
I don't get that. Did I forgot the trailing newline anywhere? I checked the files I pushed today and all already had a trailing newline 😕 |
| specifiers.some(({ type }) => type === IMPORT_DEFAULT_SPECIFIER) | ||
|
|
||
| module.exports = { | ||
| isNodeModule, |
There was a problem hiding this comment.
Basically for testing, just as you supposed.
There was a problem hiding this comment.
This shouldn't need direct testing; let's please not export it.
| specifiers.some(({ type }) => type === IMPORT_DEFAULT_SPECIFIER) | ||
|
|
||
| module.exports = { | ||
| isNodeModule, |
There was a problem hiding this comment.
This shouldn't need direct testing; let's please not export it.
|
|
||
| module.exports = { | ||
| meta: { | ||
| docs: { url: docsUrl('no-unused-modules') }, |
There was a problem hiding this comment.
Isn't the name no-unused-modules misleading? This rule reports individual export declarations, but the name suggests it reports whole files as unused.
There was a problem hiding this comment.
my understanding is that it reports on both - both unused files, and unused exports.
There was a problem hiding this comment.
Just as @ljharb says, it reports on both:
- modules without any exports are reported here
- and modules with unused exports are reported here and here
However this rule currently does not report, if a module only consists of unused exports. Each of these exports is reported separately.
I am not sure whether it makes sense to have one single report being triggered if none of the existing exports is used.
There was a problem hiding this comment.
It does make sense to me in that case to only provide one report; just as I’d expect when a module has no exports.
ljharb
left a comment
There was a problem hiding this comment.
Thanks, let's give this a shot :-)
As discussed in #186, this rule adds the possibility to find modules without any exports and/or exports within a module, which aren't used in other modules
ToDos:
This is the first rule I created. Writing tests for it may therefor take some additional time.