diff --git a/crates/oxc_linter/src/rules/eslint/no_lone_blocks.rs b/crates/oxc_linter/src/rules/eslint/no_lone_blocks.rs index 57f3e9b84b52a..1d76bfdda1017 100644 --- a/crates/oxc_linter/src/rules/eslint/no_lone_blocks.rs +++ b/crates/oxc_linter/src/rules/eslint/no_lone_blocks.rs @@ -6,11 +6,12 @@ use oxc_span::{GetSpan, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; -fn no_lone_blocks_diagnostic(span: Span, is_nested_block: bool) -> OxcDiagnostic { - let message = - if is_nested_block { "Nested block is redundant." } else { "Block is unnecessary." }; - // See for details - OxcDiagnostic::warn(message).with_label(span) +fn no_lone_blocks_diagnostic(span: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("Block is unnecessary.").with_label(span) +} + +fn no_lone_blocks_diagnostic_nested(span: Span) -> OxcDiagnostic { + OxcDiagnostic::warn("Nested block is redundant.").with_label(span) } #[derive(Debug, Default, Clone)] @@ -116,9 +117,9 @@ impl Rule for NoLoneBlocks { fn report(ctx: &LintContext, node: &AstNode, parent_node: &AstNode) { match parent_node.kind() { AstKind::BlockStatement(_) | AstKind::StaticBlock(_) => { - ctx.diagnostic(no_lone_blocks_diagnostic(node.span(), true)); + ctx.diagnostic(no_lone_blocks_diagnostic_nested(node.span())); } - _ => ctx.diagnostic(no_lone_blocks_diagnostic(node.span(), false)), + _ => ctx.diagnostic(no_lone_blocks_diagnostic(node.span())), }; }