Skip to content

Commit

Permalink
Let path.remove() remove IfStatement.alternate
Browse files Browse the repository at this point in the history
Special-casing "consequent" makes sense, but there is no need to deviate from the normal `remove()` behavior for "alternate", which is permitted to be null.
  • Loading branch information
djpohly committed Aug 8, 2022
1 parent 08d6423 commit e2456fc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/babel-traverse/src/path/lib/removal-hooks.ts
Expand Up @@ -62,8 +62,7 @@ export const hooks = [

function (self: NodePath, parent: NodePath) {
if (
(parent.isIfStatement() &&
(self.key === "consequent" || self.key === "alternate")) ||
(parent.isIfStatement() && self.key === "consequent") ||
(self.key === "body" &&
(parent.isLoop() || parent.isArrowFunctionExpression()))
) {
Expand Down

0 comments on commit e2456fc

Please sign in to comment.