From de5a3bb5ddae21bc644b311dac86ecf29f5433d1 Mon Sep 17 00:00:00 2001 From: Noel Kim Date: Tue, 16 Sep 2025 14:27:19 +0900 Subject: [PATCH 1/3] fix(formatter): Add parentheses for `PrivateInExpression` in super class --- crates/oxc_formatter/src/parentheses/expression.rs | 11 ++++++++++- tasks/coverage/snapshots/formatter_babel.snap | 4 +--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/oxc_formatter/src/parentheses/expression.rs b/crates/oxc_formatter/src/parentheses/expression.rs index 7268a9e99be70..b13fc229b7fbe 100644 --- a/crates/oxc_formatter/src/parentheses/expression.rs +++ b/crates/oxc_formatter/src/parentheses/expression.rs @@ -367,7 +367,16 @@ fn is_in_for_initializer(expr: &AstNode<'_, BinaryExpression<'_>>) -> bool { impl<'a> NeedsParentheses<'a> for AstNode<'a, PrivateInExpression<'a>> { #[inline] fn needs_parentheses(&self, f: &Formatter<'_, 'a>) -> bool { - false + match self.parent { + AstNodes::Class(ty) => { + if let Some(super_class) = ty.super_class() { + super_class.span() == self.span() + } else { + false + } + } + _ => false + } } } diff --git a/tasks/coverage/snapshots/formatter_babel.snap b/tasks/coverage/snapshots/formatter_babel.snap index c2ac148e29c2a..6592d0fe21233 100644 --- a/tasks/coverage/snapshots/formatter_babel.snap +++ b/tasks/coverage/snapshots/formatter_babel.snap @@ -2,12 +2,10 @@ commit: 41d96516 formatter_babel Summary: AST Parsed : 2423/2423 (100.00%) -Positive Passed: 2419/2423 (99.83%) +Positive Passed: 2420/2423 (99.88%) Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/comments/basic/try-statement/input.js Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/comments/regression/13750/input.js Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2015/class/division/input.js -Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/private-in/private-in-class-heritage/input.js - From 41bf69886e05ef7adeff35dae014dcff249f22b9 Mon Sep 17 00:00:00 2001 From: Noel Kim Date: Tue, 16 Sep 2025 14:28:17 +0900 Subject: [PATCH 2/3] lint --- crates/oxc_formatter/src/parentheses/expression.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_formatter/src/parentheses/expression.rs b/crates/oxc_formatter/src/parentheses/expression.rs index b13fc229b7fbe..832bdc6cbfb36 100644 --- a/crates/oxc_formatter/src/parentheses/expression.rs +++ b/crates/oxc_formatter/src/parentheses/expression.rs @@ -375,7 +375,7 @@ impl<'a> NeedsParentheses<'a> for AstNode<'a, PrivateInExpression<'a>> { false } } - _ => false + _ => false, } } } From 6fe0265138f70a2e228e7cdba7f3e7192e56bf6d Mon Sep 17 00:00:00 2001 From: Noel Kim Date: Tue, 16 Sep 2025 18:58:31 +0900 Subject: [PATCH 3/3] is_class_extends --- crates/oxc_formatter/src/parentheses/expression.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/crates/oxc_formatter/src/parentheses/expression.rs b/crates/oxc_formatter/src/parentheses/expression.rs index 832bdc6cbfb36..4dc090bb2aa12 100644 --- a/crates/oxc_formatter/src/parentheses/expression.rs +++ b/crates/oxc_formatter/src/parentheses/expression.rs @@ -367,16 +367,7 @@ fn is_in_for_initializer(expr: &AstNode<'_, BinaryExpression<'_>>) -> bool { impl<'a> NeedsParentheses<'a> for AstNode<'a, PrivateInExpression<'a>> { #[inline] fn needs_parentheses(&self, f: &Formatter<'_, 'a>) -> bool { - match self.parent { - AstNodes::Class(ty) => { - if let Some(super_class) = ty.super_class() { - super_class.span() == self.span() - } else { - false - } - } - _ => false, - } + is_class_extends(self.span, self.parent) } }