Fix renameTo
not taking property shorthands into account
#211
+46
−0
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.
This fixes the
renameTo
helper method not properly renaming object properties that are shorthands.Bug reproduction in AST Explorer: http://astexplorer.net/#/gist/0ad1434f08e1720089d7085fbdfe7ba0/6f6632f0bb6e2e3aa77d5e873d0ab05d6c3be0e3
The previous version of the code would rename the property's
value
correctly, but sinceshorthand
was still set astrue
, the output result would still be the old variable as a shorthandproperty.
Now, if an identifier to be renamed is of type
Property
and is a shorthand (but not a method), we flip theshorthand
value to befalse
.Added a test for this as well.