oxc-project/oxc · error · OxcDiagnostic

React does not recognize data-* props with uppercase charact

Error message

React does not recognize data-* props with uppercase characters on a DOM element

What it means

Raised by react/no_unknown_property when a `data-*` attribute on a DOM element contains uppercase characters (e.g. `data-testId`). At the throw site React will drop or warn about such props because dataset keys are lowercased to match the HTML attribute rules, so the intended data attribute never reaches the DOM as written. data_lowercase_required fires from run() with a lowercase-corrected suggested prop name in the help.

Source

Thrown at crates/oxc_linter/src/rules/react/no_unknown_property.rs:32

use schemars::JsonSchema;
use serde::Deserialize;

use crate::{
    AstNode,
    context::{ContextHost, LintContext},
    globals::is_valid_aria_property,
    rule::{DefaultRuleConfig, Rule},
    utils::get_jsx_attribute_name,
};

fn invalid_prop_on_tag(span: Span, prop: &str, tag: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn("Invalid property found")
        .with_help(format!("Property '{prop}' is only allowed on: {tag}"))
        .with_label(span)
}

fn data_lowercase_required(span: Span, suggested_prop: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(
        "React does not recognize data-* props with uppercase characters on a DOM element",
    )
    .with_help(format!("Use '{suggested_prop}' instead"))
    .with_label(span)
}

fn unknown_prop_with_standard_name(span: Span, x1: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unknown property found")
        .with_help(format!("Use '{x1}' instead"))
        .with_label(span)
}

fn unknown_prop(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unknown property found")
        .with_help("Remove unknown property")
        .with_label(span)
}

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Rename the attribute to the lowercase form suggested by the diagnostic.
  2. Keep data-* attribute names all-lowercase.
Defensive patterns

Strategy: validation

When it happens

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