We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent faf0685 commit 7e7f885Copy full SHA for 7e7f885
babel-preset/transforms/transform-remove-console.js
@@ -1,15 +1,11 @@
1
var template = require('babel-template');
2
-module.exports = function (babel) {
3
- var t = babel.types;
+module.exports = function () {
4
return {
5
visitor: {
6
CallExpression(path) {
7
- if (path.get("callee").matchesPattern("console", true)) {
8
- path.node.callee = template(`
9
- (function () {
10
- Array.prototype.slice.call(arguments).forEach(m => (typeof m === 'function') ? m() : m)
11
- })
12
- `)().expression
+ const callee = path.get("callee")
+ if (callee.matchesPattern("console", true) && !callee.matchesPattern("console.error")) {
+ path.node.callee = template(`Function.prototype`)().expression
13
}
14
15
0 commit comments