{"record":{"id":"98914e1e2b4a9138","repo":"oxc-project/oxc","slug":"headings-must-have-content-and-the-content-must-be","errorCode":null,"errorMessage":"Headings must have content and the content must be accessible by a screen reader.","messagePattern":"Headings must have content and the content must be accessible by a screen reader\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/jsx_a11y/heading_has_content.rs","lineNumber":17,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse oxc_str::CompactStr;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::{get_element_type, is_hidden_from_screen_reader, object_has_accessible_child},\n};\n\nfn heading_has_content_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\n        \"Headings must have content and the content must be accessible by a screen reader.\",\n    )\n    .with_help(\"Provide screen reader accessible content when using heading elements.\")\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct HeadingHasContent(Box<HeadingHasContentConfig>);\n\n#[derive(Debug, Default, Clone, PartialEq, Eq, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct HeadingHasContentConfig {\n    /// Additional custom component names to treat as heading elements.\n    /// These will be validated in addition to the standard h1-h6 elements.\n    components: Option<Vec<CompactStr>>,\n}\n\nimpl std::ops::Deref for HeadingHasContent {","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/heading_has_content.rs#L1-L35","documentation":"Fires from jsx-a11y/heading-has-content when a heading element (h1-h6) contains no content, or only content hidden from screen readers (aria-hidden). The run visitor checks heading elements and their accessible children; the helper advises providing screen-reader-accessible content.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/jsx_a11y/heading_has_content.rs:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add text content inside the heading","If content is hidden, provide an accessible alternative such as `aria-label`","Use a non-heading element if the heading is purely decorative"],"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"}