oxc-project/oxc · error · OxcDiagnostic

Value must be omitted for `false` attribute {attr:?}

Error message

Value must be omitted for `false` attribute {attr:?}

What it means

Raised by react/jsx-boolean-value in 'always-but-omit-undefined'-like modes when a boolean attribute is set to a falsey/undefined value explicitly (e.g. disabled={false} in a mode requiring omission).

Source

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

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,
}

#[derive(Debug, Default, Clone, JsonSchema, Deserialize, Serialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct JsxBooleanValueOptions {
    /// List of attribute names that should always have explicit boolean values.
    /// Only necessary when main mode is `"never"`.

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Omit attributes whose value is false/undefined.
  2. Keep explicit values only for truthy booleans per the configured mode.
Defensive patterns

Strategy: validation

When it happens

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