{"record":{"id":"475857208bcd8dcf","repo":"oxc-project/oxc","slug":"missing-alternative-text","errorCode":null,"errorMessage":"Missing alternative text.","messagePattern":"Missing alternative text\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs","lineNumber":54,"sourceCode":"    OxcDiagnostic::warn(\"Missing value for `aria-label` attribute.\")\n        .with_help(\"Give `aria-label` a meaningful value. Prever the `alt` attribute over `aria-label` for images.\")\n        .with_label(span)\n}\n\nfn aria_labelled_by_value(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing value for `aria-labelledby` attribute.\")\n        .with_help(\"Give `aria-labelledby` an ID to a label element. Prefer the `alt` attribute over `aria-labelledby` for images.\")\n        .with_label(span)\n}\n\nfn prefer_alt(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"ARIA used where native HTML could suffice.\")\n        .with_help(\"Prefer alt=\\\"\\\" over presentational role. Native HTML attributes should be preferred for accessibility before resorting to ARIA attributes.\")\n        .with_label(span)\n}\n\nfn object(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing alternative text.\")\n        .with_help(\"Embedded <object> elements must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.\")\n        .with_label(span)\n}\n\nfn area(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing alternative text.\")\n        .with_help(\"Each area of an image map must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.\")\n        .with_label(span)\n}\n\nfn input_type_image(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing alternative text.\")\n        .with_help(\"<input> elements with type=\\\"image\\\" must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct AltText(Box<AltTextConfig>);","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs#L36-L72","documentation":"This is the oxlint `jsx-a11y/alt-text` diagnostic for `<object>` embeds without a text alternative. Embedded `<object>` content (PDFs, plugins, media) is invisible to assistive technology unless the element exposes `alt`, `aria-label`, or `aria-labelledby`, so the rule requires one of the three.","triggerScenarios":"A JSX opening element resolves to `object` (default element set or via the rule's `object` config list) and has none of `alt`, `aria-label`, `aria-labelledby` with a usable value.","commonSituations":"PDF viewer embeds, legacy plugin embeds, and data visualizations rendered through `<object>`; wrapper components (`<PdfEmbed>`) that don't forward an accessible name.","solutions":["Add `aria-label` (or `aria-labelledby` to visible text) describing the embed: `<object data=\"/report.pdf\" aria-label=\"2024 annual report, PDF\" />`.","Add `title` plus a text fallback inside the object tag for broader support.","Register custom wrappers in the rule config so they are checked too."],"exampleFix":"// before\n<object data=\"/report.pdf\" type=\"application/pdf\" />\n\n// after\n<object data=\"/report.pdf\" type=\"application/pdf\" aria-label=\"2024 annual report (PDF)\">\n  <p>Your browser cannot display PDFs. <a href=\"/report.pdf\">Download the report</a>.</p>\n</object>","handlingStrategy":"validation","validationCode":"// Wrapper that forces an accessible name on object embeds\ntype PdfEmbedProps = { src: string; label: string };\nexport function PdfEmbed({ src, label }: PdfEmbedProps) {\n  return <object data={src} type=\"application/pdf\" aria-label={label} />;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat every `<object>` like an `<img>`: no accessible name, no merge.","Put fallback text inside the object element for non-JS/legacy contexts.","Add jsx-a11y/alt-text with your `object` wrappers registered to CI."],"tags":["jsx-a11y","accessibility","alt-text","object-embed","react","lint","oxlint"],"backgroundTag":"jsx-a11y-alt-text","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}