[import/no-unused-modules] Report error on export specifier node #2842
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed when an export declaration has multiple specifiers of which only a subset is unused the rule reports the error on the whole statement. In my code editor this draws a red squiggly under the whole statement. I can read which specifier is unused from the message of the reported error. Wouldn't it be nicer if the error was reported only on the specifier that is unused? That way I wouldn't necessarily need to even read and can let the red squiggly lead my monkey brain.
Consider the following export declaration
Assume
foo
is used,bar
is unused. Usually the fix would be to removebar
. I'd expect the reported error to point to that node as it would make it slightly more intuitive to attack it directly.I'd imagine this change isn't breaking as the same errors still get reported for the same reasons, just pointing to different nodes.
I couldn't think of a reason one would want the report on the parent declaration instead but if there is one please educate me.
I changed the test assertions that have to do with a declaration that has multiple specifiers to also assert a specific location for the reported errors. I changed the node the errors are reported on to make the tests pass again. I then reverted the test changes because CI disagreed even though they passed locally 🤷.