summaryrefslogtreecommitdiff
path: root/tools/node_modules/babel-eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/babel-eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js')
-rw-r--r--tools/node_modules/babel-eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/node_modules/babel-eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js b/tools/node_modules/babel-eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js
new file mode 100644
index 0000000000..79d5682f45
--- /dev/null
+++ b/tools/node_modules/babel-eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js
@@ -0,0 +1,36 @@
+"use strict";
+
+exports.__esModule = true;
+exports.hooks = void 0;
+var hooks = [function (self, parent) {
+ var removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement();
+
+ if (removeParent) {
+ parent.remove();
+ return true;
+ }
+}, function (self, parent) {
+ if (parent.isSequenceExpression() && parent.node.expressions.length === 1) {
+ parent.replaceWith(parent.node.expressions[0]);
+ return true;
+ }
+}, function (self, parent) {
+ if (parent.isBinary()) {
+ if (self.key === "left") {
+ parent.replaceWith(parent.node.right);
+ } else {
+ parent.replaceWith(parent.node.left);
+ }
+
+ return true;
+ }
+}, function (self, parent) {
+ if (parent.isIfStatement() && (self.key === "consequent" || self.key === "alternate") || self.key === "body" && (parent.isLoop() || parent.isArrowFunctionExpression())) {
+ self.replaceWith({
+ type: "BlockStatement",
+ body: []
+ });
+ return true;
+ }
+}];
+exports.hooks = hooks; \ No newline at end of file