Skip to content

Commit

Permalink
Support ClassProperty variable renaming (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
henryqdineen authored and fkling committed Jan 16, 2019
1 parent 16fcf0a commit 76734f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9.11.2
9 changes: 9 additions & 0 deletions src/collections/VariableDeclarator.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ const transformMethods = {
return false;
}

if (
types.ClassProperty.check(parent) &&
parent.key === path.node &&
!parent.computed
) {
// class A { oldName = 3 }
return false;
}

if (
types.JSXAttribute.check(parent) &&
parent.name === path.node &&
Expand Down
1 change: 1 addition & 0 deletions src/collections/__tests__/VariableDeclarator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('VariableDeclarators', function() {
' };',
' obj.blah = 3;',
' class A {',
' blah = 10',
' blah() {}',
' }',
'}',
Expand Down

0 comments on commit 76734f7

Please sign in to comment.