Skip to content

Commit

Permalink
scope.rename() missing identifier in VariableDeclarator (#11595)
Browse files Browse the repository at this point in the history
  • Loading branch information
yulanggong committed May 26, 2020
1 parent 0ca5f8b commit 429840d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/babel-traverse/src/scope/lib/renamer.js
Expand Up @@ -20,7 +20,8 @@ const renameVisitor = {
}
},

"AssignmentExpression|Declaration"(path, state) {
"AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
if (path.isVariableDeclaration()) return;
const ids = path.getOuterBindingIdentifiers();

for (const name in ids) {
Expand Down
@@ -0,0 +1,7 @@
function c(b) {
var a = b + 1,
a = a + 1,
a = a + 1;

return a;
}
@@ -0,0 +1,3 @@
{
"plugins": ["./plugin"]
}
@@ -0,0 +1,7 @@
function c(b) {
var _a = b + 1,
_a = _a + 1,
_a = _a + 1;

return _a;
}
@@ -0,0 +1,9 @@
module.exports = function() {
return {
visitor: {
Scope(path) {
path.scope.rename("a", "_a");
}
}
};
}

0 comments on commit 429840d

Please sign in to comment.