Add block if parent is no block statement for remove-console/debugger

This commit is contained in:
Jhen 2016-07-18 02:18:11 +08:00
parent 3cc38a0063
commit e464b9ab87

View File

@ -64,5 +64,18 @@ export let hooks = [
}
return true;
}
},
function (self, parent) {
if (
(parent.isIfStatement() && (self.key === 'consequent' || self.key === 'alternate')) ||
(parent.isLoop() && self.key === 'body')
) {
self.replaceWith({
type: 'BlockStatement',
body: []
});
return true;
}
}
];