Merge pull request #3583 from jhen0409/patch-3
Add block if parent is non-block statement for remove-console/debugger
This commit is contained in:
commit
40ec299df5
@ -0,0 +1,6 @@
|
||||
if (blah) console.log(blah);
|
||||
for (;;) console.log(blah);
|
||||
for (var blah in []) console.log(blah);
|
||||
for (var blah of []) console.log(blah);
|
||||
while (blah) console.log(blah);
|
||||
do console.log(blah); while (blah);
|
||||
@ -0,0 +1,6 @@
|
||||
if (blah) {}
|
||||
for (;;) {}
|
||||
for (var blah in []) {}
|
||||
for (var blah of []) {}
|
||||
while (blah) {}
|
||||
do {} while (blah);
|
||||
3
packages/babel-plugin-transform-remove-debugger/test/fixtures/remove-debugger/options.json
vendored
Normal file
3
packages/babel-plugin-transform-remove-debugger/test/fixtures/remove-debugger/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-remove-debugger"]
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
if (blah) debugger;
|
||||
for (;;) debugger;
|
||||
for (var blah in []) debugger;
|
||||
for (var blah of []) debugger;
|
||||
while (blah) debugger;
|
||||
do debugger; while (blah);
|
||||
@ -0,0 +1,6 @@
|
||||
if (blah) {}
|
||||
for (;;) {}
|
||||
for (var blah in []) {}
|
||||
for (var blah of []) {}
|
||||
while (blah) {}
|
||||
do {} while (blah);
|
||||
@ -0,0 +1 @@
|
||||
require("babel-helper-plugin-test-runner")(__dirname);
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user