babel-plugin-transform-remove-console
Advanced tools
Comparing version 6.10.0-alpha.15ca1f11 to 6.10.0-alpha.18dcfe13
"use strict"; | ||
module.exports = function (_ref) { | ||
var t = _ref.types; | ||
module.exports = function ({ | ||
types: t | ||
}) { | ||
return { | ||
@@ -10,4 +10,3 @@ name: "transform-remove-console", | ||
CallExpression(path, state) { | ||
var callee = path.get("callee"); | ||
const callee = path.get("callee"); | ||
if (!callee.isMemberExpression()) return; | ||
@@ -27,2 +26,3 @@ | ||
}, | ||
MemberExpression: { | ||
@@ -38,2 +38,3 @@ exit(path, state) { | ||
} | ||
} | ||
@@ -44,30 +45,33 @@ } | ||
function isGlobalConsoleId(id) { | ||
var name = "console"; | ||
return id.isIdentifier({ name }) && !id.scope.getBinding(name) && id.scope.hasGlobal(name); | ||
const name = "console"; | ||
return id.isIdentifier({ | ||
name | ||
}) && !id.scope.getBinding(name) && id.scope.hasGlobal(name); | ||
} | ||
function isExcluded(property, excludeArray) { | ||
return excludeArray && excludeArray.some(function (name) { | ||
return property.isIdentifier({ name }); | ||
}); | ||
return excludeArray && excludeArray.some(name => property.isIdentifier({ | ||
name | ||
})); | ||
} | ||
function isIncludedConsole(memberExpr, excludeArray) { | ||
var object = memberExpr.get("object"); | ||
var property = memberExpr.get("property"); | ||
const object = memberExpr.get("object"); | ||
const property = memberExpr.get("property"); | ||
if (isExcluded(property, excludeArray)) return false; | ||
if (isGlobalConsoleId(object)) return true; | ||
return isGlobalConsoleId(object.get("object")) && (property.isIdentifier({ name: "call" }) || property.isIdentifier({ name: "apply" })); | ||
return isGlobalConsoleId(object.get("object")) && (property.isIdentifier({ | ||
name: "call" | ||
}) || property.isIdentifier({ | ||
name: "apply" | ||
})); | ||
} | ||
function isIncludedConsoleBind(memberExpr, excludeArray) { | ||
var object = memberExpr.get("object"); | ||
const object = memberExpr.get("object"); | ||
if (!object.isMemberExpression()) return false; | ||
if (isExcluded(object.get("property"), excludeArray)) return false; | ||
return isGlobalConsoleId(object.get("object")) && memberExpr.get("property").isIdentifier({ name: "bind" }); | ||
return isGlobalConsoleId(object.get("object")) && memberExpr.get("property").isIdentifier({ | ||
name: "bind" | ||
}); | ||
} | ||
@@ -74,0 +78,0 @@ |
{ | ||
"name": "babel-plugin-transform-remove-console", | ||
"version": "6.10.0-alpha.15ca1f11", | ||
"version": "6.10.0-alpha.18dcfe13", | ||
"description": "Remove all console.* calls.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -22,3 +22,3 @@ # babel-plugin-transform-remove-console | ||
```sh | ||
npm install babel-plugin-transform-remove-console | ||
npm install babel-plugin-transform-remove-console --save-dev | ||
``` | ||
@@ -55,3 +55,3 @@ | ||
```javascript | ||
require("babel-core").transform("code", { | ||
require("@babel/core").transform("code", { | ||
plugins: ["transform-remove-console"] | ||
@@ -58,0 +58,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3677
71