-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unused variables sharing names of imports
If you have code that looks something like the following: ```js import uuid from 'uuid'; function bar() { return uuid.v4(); } export default function foo() { const things = { uuid: bar(), henric: 'is cool', }; const { uuid, henric } = things; return henric; } ``` Running fix imports will toggle between adding and removing the `uuid` import. This is because the error that eslint reports relates to the `uuid` defined by `const { uuid, henric } = things;` line. However, after it is removed, we get a second error saying that it is used but never defined (by `return uuid.v4()`), so it gets added back again. To fix this, I added some logic that verifies that the eslint error for unused variables happens within the imports block. While I was working on the fix_imports method, I found a couple of opportunities to return early to avoid doing unnecessary work. Fixes #203
- Loading branch information
Showing
2 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters