oxc-project/oxc · error · OxcDiagnostic
Value must be omitted for boolean attribute {attr:?}
Error message
Value must be omitted for boolean attribute {attr:?} What it means
Raised by react/jsx_boolean_value (with `always` off / default `never`-style config) when a boolean-capable JSX attribute is given an explicit `{true}` or `"true"` value. At the throw site the explicit value is redundant — presence of the attribute already means true in JSX — and the rule enforces the terser `<input disabled />` form. boolean_value_diagnostic fires from run() for each attribute whose value is the boolean true literal or equivalent, unless the attribute is excluded by config.
Source
Thrown at crates/oxc_linter/src/rules/react/jsx_boolean_value.rs:21
ast::{Expression, JSXAttributeItem, JSXAttributeName, JSXAttributeValue},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
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,View on GitHub (pinned to e1e7af627c)
Solutions
- Omit the value: <input disabled /> instead of <input disabled={true}>.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/jsx_boolean_value.rs:21 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/34636a05b8fb8380.
Report an issue: GitHub.