From b4ed8793834247505233156fdb2eb6cb859c82d2 Mon Sep 17 00:00:00 2001 From: Dunqing <29533304+Dunqing@users.noreply.github.com> Date: Fri, 9 Jan 2026 08:38:00 +0000 Subject: [PATCH] refactor(formatter): remove unnecessary `MaybeOptionalSemicolon` (#17796) `MaybeOptionalSemicolon` isn't needed --- crates/oxc_formatter/src/write/semicolon.rs | 10 ---------- crates/oxc_formatter/src/write/variable_declaration.rs | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/crates/oxc_formatter/src/write/semicolon.rs b/crates/oxc_formatter/src/write/semicolon.rs index 1ef1f98f4d942..72981513973af 100644 --- a/crates/oxc_formatter/src/write/semicolon.rs +++ b/crates/oxc_formatter/src/write/semicolon.rs @@ -14,13 +14,3 @@ impl<'a> Format<'a> for OptionalSemicolon { } } } - -pub struct MaybeOptionalSemicolon(pub bool); - -impl<'a> Format<'a> for MaybeOptionalSemicolon { - fn fmt(&self, f: &mut Formatter<'_, 'a>) { - if self.0 { - OptionalSemicolon.fmt(f); - } - } -} diff --git a/crates/oxc_formatter/src/write/variable_declaration.rs b/crates/oxc_formatter/src/write/variable_declaration.rs index 3683077c842e9..bdd6c51a4a11f 100644 --- a/crates/oxc_formatter/src/write/variable_declaration.rs +++ b/crates/oxc_formatter/src/write/variable_declaration.rs @@ -3,7 +3,7 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::utils::assignment_like::AssignmentLike; -use crate::write::semicolon::MaybeOptionalSemicolon; +use crate::write::semicolon::OptionalSemicolon; use crate::{ ast_nodes::{AstNode, AstNodes}, format_args, @@ -36,7 +36,7 @@ impl<'a> FormatWrite<'a> for AstNode<'a, VariableDeclaration<'a>> { self.kind().as_str(), space(), self.declarations(), - MaybeOptionalSemicolon(semicolon) + semicolon.then_some(OptionalSemicolon) )) ); }