oxc-project/oxc · error · OxcDiagnostic

Curly braces are unnecessary here.

Error message

Curly braces are unnecessary here.

What it means

Emitted by report_unnecessary_curly (and the attribute-value variant) in the react jsx-curly-brace-presence rule when a JSX expression container or attribute wraps something that needs no braces, such as a string literal in props or a trivial expression that renders identically without them.

Source

Thrown at crates/oxc_linter/src/rules/react/jsx_curly_brace_presence.rs:25

use oxc_allocator::ArenaVec;

use oxc_ast::{
    AstKind,
    ast::{
        Expression, JSXAttributeItem, JSXAttributeValue, JSXChild, JSXElementName, JSXExpression,
        JSXExpressionContainer,
    },
};
use oxc_codegen::CodegenOptions;
use oxc_diagnostics::{LabeledSpan, OxcDiagnostic};
use oxc_macros::declare_oxc_lint;
use oxc_semantic::NodeId;
use oxc_span::{GetSpan as _, Span};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

fn jsx_curly_brace_presence_unnecessary_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Curly braces are unnecessary here.").with_label(span)
}
fn jsx_curly_brace_presence_necessary_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Curly braces are required here.")
        .with_help("Wrap this value in curly braces")
        .with_labels([LabeledSpan::new_primary_with_span(
            Some("Wrap this value in curly braces".into()),
            span,
        )])
}

#[derive(Debug, Default, Clone, Copy, JsonSchema, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
enum JsxCurlyBracePresenceMode {
    Always,
    Never,
    #[default]
    Ignore,
}

View on GitHub (pinned to 36ec0ef2ba)

Solutions

  1. Remove the curly braces, e.g. prop="text" instead of prop={"text"}
  2. Unwrap trivial string/template expressions that are identical without braces
  3. Configure propsIgnored or other rule options if certain braces are intentional
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/react/jsx_curly_brace_presence.rs:25 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@36ec0ef2ba (2026-08-20). Data as JSON: /api/errors/d53913f3c37b660a. Report an issue: GitHub.