oxc-project/oxc · error · OxcDiagnostic

Value must be set for boolean attribute {attr:?}

Error message

Value must be set for boolean attribute {attr:?}

What it means

Raised by react/jsx_boolean_value when configured with `always` and a boolean JSX attribute is written without an explicit value (bare `<input disabled />`). At the throw site the rule's configured style requires the value to be spelled out (`disabled={true}`) so readers and tooling never rely on implicit presence semantics. boolean_value_always_diagnostic fires from run() for shorthand boolean attributes when the config selects the always-explicit style.

Source

Thrown at crates/oxc_linter/src/rules/react/jsx_boolean_value.rs:26

use oxc_str::CompactStr;
use rustc_hash::FxHashSet;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::{
    AstNode,
    context::{ContextHost, LintContext},
    rule::{Rule, TupleRuleConfig},
    utils::get_prop_value,
};

fn boolean_value_diagnostic(attr: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Value must be omitted for boolean attribute {attr:?}"))
        .with_label(span)
}

fn boolean_value_always_diagnostic(attr: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Value must be set for boolean attribute {attr:?}"))
        .with_label(span)
}

fn boolean_value_undefined_false_diagnostic(attr: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Value must be omitted for `false` attribute {attr:?}"))
        .with_label(span)
}

#[derive(Debug, Default, Clone, JsonSchema, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum EnforceBooleanAttribute {
    /// All boolean attributes must have explicit values.
    Always,
    /// All boolean attributes must omit values that are set to `true`.
    #[default]
    Never,
}

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Add the explicit value: <input disabled={true} />.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/react/jsx_boolean_value.rs:26 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/4289902f057041de. Report an issue: GitHub.