oxc-project/oxc · error
Unexpected block statement surrounding arrow body.
Error message
Unexpected block statement surrounding arrow body.
What it means
Lint diagnostic from eslint/arrow-body-style (unexpected_block_diagnostic, as-needed mode): an arrow function body is wrapped in braces for a single expression. In as-needed mode braces are only required when the body is not a single expression, so the block is unnecessary noise.
Source
Thrown at crates/oxc_linter/src/rules/eslint/arrow_body_style.rs:28
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use oxc_syntax::operator::BinaryOperator;
use crate::{
AstNode,
context::LintContext,
fixer::{RuleFix, RuleFixer},
rule::{Rule, TupleRuleConfig},
};
fn expected_block_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Expected block statement surrounding arrow body.")
.with_help("Surround the arrow body with braces and use a return statement.")
.with_label(span)
}
fn unexpected_block_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected block statement surrounding arrow body.")
.with_help("Move the returned value to be immediately after the `=>`.")
.with_label(span)
}
fn unexpected_empty_block_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected empty block statement surrounding arrow body.")
.with_help("Put a value of `undefined` immediately after the `=>`.")
.with_label(span)
}
/// Diagnostic that is emitted when we don't have a specific help message to provide
fn unexpected_block_with_unknown_help_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected block statement surrounding arrow body.").with_label(span)
}
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "kebab-case")]
enum Mode {View on GitHub (pinned to e1e7af627c)
Solutions
- Remove the braces and return: (x) => x
- Apply the rule's autofix
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/eslint/arrow_body_style.rs:28 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/787631f7002b1a37.
Report an issue: GitHub.