oxc-project/oxc · error
`lang` attribute must have a valid value.
Error message
`lang` attribute must have a valid value.
What it means
Raised by jsx-a11y/lang when the lang attribute value on an element is not a valid language tag according to the language-tags (BCP-47) parser. Invalid tags prevent assistive technology from determining the content language.
Source
Thrown at crates/oxc_linter/src/rules/jsx_a11y/lang.rs:18
use language_tags::LanguageTag;
use oxc_ast::{
AstKind,
ast::{JSXAttributeItem, JSXAttributeValue},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{
AstNode,
context::LintContext,
rule::Rule,
utils::{get_element_type, get_prop_value, has_jsx_prop_ignore_case},
};
fn lang_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`lang` attribute must have a valid value.")
.with_help("Set a valid value for `lang` attribute.")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct Lang;
declare_oxc_lint!(
/// ### What it does
///
/// The lang prop on the `<html>` element must be a valid IETF BCP 47 language tag.
///
/// ### Why is this bad?
///
/// If the language of a webpage is not specified as valid,
/// the screen reader assumes the default language set by the user.
/// Language settings become an issue for users who speak multiple languages
/// and access website in more than one language.View on GitHub (pinned to e1e7af627c)
Solutions
- Use a valid BCP-47 language tag such as "en", "fr", or "zh-Hans".
- Check for typos, stray whitespace, or empty strings in the lang value.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/jsx_a11y/lang.rs:18 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/4412af1f2446482f.
Report an issue: GitHub.