summaryrefslogtreecommitdiff
path: root/node_modules/babel-plugin-transform-remove-console
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:10:59 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:41:44 +0800
commitfc87c009806dcc98867f6b58efe29b042aa01dee (patch)
tree8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/babel-plugin-transform-remove-console
parent3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff)
node: updatemain
Diffstat (limited to 'node_modules/babel-plugin-transform-remove-console')
-rw-r--r--node_modules/babel-plugin-transform-remove-console/README.md61
-rw-r--r--node_modules/babel-plugin-transform-remove-console/lib/index.js82
-rw-r--r--node_modules/babel-plugin-transform-remove-console/package.json14
3 files changed, 0 insertions, 157 deletions
diff --git a/node_modules/babel-plugin-transform-remove-console/README.md b/node_modules/babel-plugin-transform-remove-console/README.md
deleted file mode 100644
index efe5d2be..00000000
--- a/node_modules/babel-plugin-transform-remove-console/README.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# babel-plugin-transform-remove-console
-
-This plugin removes all `console.*` calls.
-
-## Example
-
-**In**
-
-```javascript
-console.log("foo");
-console.error("bar");
-```
-
-**Out**
-
-```javascript
-```
-
-## Installation
-
-```sh
-npm install babel-plugin-transform-remove-console --save-dev
-```
-
-## Usage
-
-### Via `.babelrc` (Recommended)
-
-**.babelrc**
-
-```json
-// without options
-{
- "plugins": ["transform-remove-console"]
-}
-```
-
-```json
-// with options
-{
- "plugins": [ ["transform-remove-console", { "exclude": [ "error", "warn"] }] ]
-}
-```
-
-### Via CLI
-
-```sh
-babel --plugins transform-remove-console script.js
-```
-
-### Via Node API
-
-```javascript
-require("@babel/core").transform("code", {
- plugins: ["transform-remove-console"]
-});
-```
-
-## Options
-
-+ `exclude` - An array of console methods to exclude from removal.
diff --git a/node_modules/babel-plugin-transform-remove-console/lib/index.js b/node_modules/babel-plugin-transform-remove-console/lib/index.js
deleted file mode 100644
index 3d910896..00000000
--- a/node_modules/babel-plugin-transform-remove-console/lib/index.js
+++ /dev/null
@@ -1,82 +0,0 @@
-"use strict";
-
-module.exports = function ({
- types: t
-}) {
- return {
- name: "transform-remove-console",
- visitor: {
- CallExpression(path, state) {
- const callee = path.get("callee");
- if (!callee.isMemberExpression()) return;
-
- if (isIncludedConsole(callee, state.opts.exclude)) {
- // console.log()
- if (path.parentPath.isExpressionStatement()) {
- path.remove();
- } else {
- path.replaceWith(createVoid0());
- }
- } else if (isIncludedConsoleBind(callee, state.opts.exclude)) {
- // console.log.bind()
- path.replaceWith(createNoop());
- }
- },
-
- MemberExpression: {
- exit(path, state) {
- if (isIncludedConsole(path, state.opts.exclude) && !path.parentPath.isMemberExpression()) {
- if (path.parentPath.isAssignmentExpression() && path.parentKey === "left") {
- path.parentPath.get("right").replaceWith(createNoop());
- } else {
- path.replaceWith(createNoop());
- }
- }
- }
-
- }
- }
- };
-
- function isGlobalConsoleId(id) {
- const name = "console";
- return id.isIdentifier({
- name
- }) && !id.scope.getBinding(name) && id.scope.hasGlobal(name);
- }
-
- function isExcluded(property, excludeArray) {
- return excludeArray && excludeArray.some(name => property.isIdentifier({
- name
- }));
- }
-
- function isIncludedConsole(memberExpr, excludeArray) {
- 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"
- }));
- }
-
- function isIncludedConsoleBind(memberExpr, excludeArray) {
- 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"
- });
- }
-
- function createNoop() {
- return t.functionExpression(null, [], t.blockStatement([]));
- }
-
- function createVoid0() {
- return t.unaryExpression("void", t.numericLiteral(0));
- }
-}; \ No newline at end of file
diff --git a/node_modules/babel-plugin-transform-remove-console/package.json b/node_modules/babel-plugin-transform-remove-console/package.json
deleted file mode 100644
index ad24d1f5..00000000
--- a/node_modules/babel-plugin-transform-remove-console/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "babel-plugin-transform-remove-console",
- "version": "6.9.4",
- "description": "Remove all console.* calls.",
- "keywords": [
- "babel-plugin"
- ],
- "homepage": "https://github.com/babel/minify#readme",
- "bugs": "https://github.com/babel/minify/issues",
- "license": "MIT",
- "author": "amasad",
- "main": "lib/index.js",
- "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-remove-console"
-}