{"record":{"id":"4412af1f2446482f","repo":"oxc-project/oxc","slug":"lang-attribute-must-have-a-valid-value","errorCode":null,"errorMessage":"`lang` attribute must have a valid value.","messagePattern":"`lang` attribute must have a valid value\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/jsx_a11y/lang.rs","lineNumber":18,"sourceCode":"use language_tags::LanguageTag;\nuse oxc_ast::{\n    AstKind,\n    ast::{JSXAttributeItem, JSXAttributeValue},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::Rule,\n    utils::{get_element_type, get_prop_value, has_jsx_prop_ignore_case},\n};\n\nfn lang_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`lang` attribute must have a valid value.\")\n        .with_help(\"Set a valid value for `lang` attribute.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct Lang;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// The lang prop on the `<html>` element must be a valid IETF BCP 47 language tag.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// If the language of a webpage is not specified as valid,\n    /// the screen reader assumes the default language set by the user.\n    /// Language settings become an issue for users who speak multiple languages\n    /// and access website in more than one language.","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/lang.rs#L1-L36","documentation":"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.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/jsx_a11y/lang.rs:18 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}