{"record":{"id":"ec51b08bd22b7f7f","repo":"oxc-project/oxc","slug":"missing-track-element-with-captions-inside-a","errorCode":null,"errorMessage":"Missing `<track>` element with captions inside `<audio>` or `<video>` element","messagePattern":"Missing `<track>` element with captions inside `<audio>` or `<video>` element","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs","lineNumber":17,"sourceCode":"use std::borrow::Cow;\n\nuse oxc_ast::{\n    AstKind,\n    ast::{JSXAttributeItem, JSXAttributeName, JSXAttributeValue, JSXChild, JSXExpression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\nuse serde_json::Value;\n\nuse crate::{AstNode, context::LintContext, rule::Rule, utils::get_element_type};\n\nfn media_has_caption_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\n        \"Missing `<track>` element with captions inside `<audio>` or `<video>` element\",\n    )\n    .with_help(\"Media elements such as `<audio>` and `<video>` must have a `<track>` for captions.\")\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct MediaHasCaption(Box<MediaHasCaptionConfig>);\n\n#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct MediaHasCaptionConfig {\n    /// Element names to treat as `<audio>` elements\n    audio: Vec<Cow<'static, str>>,\n    /// Element names to treat as `<video>` elements\n    video: Vec<Cow<'static, str>>,\n    /// Element names to treat as `<track>` elements\n    track: Vec<Cow<'static, str>>,","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs#L1-L35","documentation":"Raised by jsx-a11y/media-has-caption when an <audio> or <video> element does not contain a <track> element with kind=\"captions\". Deaf and hard-of-hearing users cannot access audio content without captions.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/jsx_a11y/media_has_caption.rs:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add <track kind=\"captions\" src=\"...\" srcLang=\"...\" /> inside the media element.","Mark the media as decorative if it has no meaningful audio (per rule configuration)."],"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"}