From d57be363f50187abc8244cb5509b964d2a516b0d Mon Sep 17 00:00:00 2001 From: ematipico Date: Tue, 27 Sep 2022 08:41:01 +0100 Subject: [PATCH] chore: code review --- .../analyzers/correctness/use_block_statements.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/rome_js_analyze/src/analyzers/correctness/use_block_statements.rs b/crates/rome_js_analyze/src/analyzers/correctness/use_block_statements.rs index 51c0cb4f2d0..c216da40aca 100644 --- a/crates/rome_js_analyze/src/analyzers/correctness/use_block_statements.rs +++ b/crates/rome_js_analyze/src/analyzers/correctness/use_block_statements.rs @@ -216,10 +216,18 @@ impl Rule for UseBlockStatements { r_curly_token.with_leading_trivia(leading_trivia) } else { - let has_trailing_comments = stmt.syntax().has_trailing_comments(); - // if the node we have to enclose has some leading comments, then we add a new line + let has_trailing_single_line_comments = stmt + .syntax() + .last_trailing_trivia() + .map(|trivia| { + trivia + .pieces() + .any(|trivia| trivia.kind() == TriviaPieceKind::SingleLineComment) + }) + .unwrap_or(false); + // if the node we have to enclose has some trailing comments, then we add a new line // to the leading trivia of the right curly brace - if !has_trailing_comments { + if !has_trailing_single_line_comments { r_curly_token .with_leading_trivia(iter::once((TriviaPieceKind::Whitespace, " "))) } else {