{"record":{"id":"d4ab52ae9317d42b","repo":"oxc-project/oxc","slug":"redundant-alt-attribute","errorCode":null,"errorMessage":"Redundant `alt` attribute.","messagePattern":"Redundant `alt` attribute\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs","lineNumber":26,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse oxc_str::CompactStr;\nuse schemars::JsonSchema;\nuse serde_json::Value;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::Rule,\n    utils::{\n        get_element_type, get_prop_value, has_jsx_prop_ignore_case, is_hidden_from_screen_reader,\n    },\n};\n\n// TODO: Update this diagnostic message to actually include the custom words from the config.\nfn img_redundant_alt_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Redundant `alt` attribute.\")\n        .with_help(\"Provide no redundant alt text for image. Screen-readers already announce `img` tags as an image. You don't need to use the words `image`, `photo`, or `picture` (or any specified custom words) in the `alt` prop.\").with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ImgRedundantAlt(Box<ImgRedundantAltConfig>);\n\n#[derive(Debug, Clone, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct ImgRedundantAltConfig {\n    /// JSX element types to validate (component names) where the rule applies.\n    /// For example, `[\"img\", \"Image\"]`.\n    components: Vec<CompactStr>,\n    /// Words considered redundant in alt text that should trigger a warning.\n    words: Vec<Cow<'static, str>>,\n}\n\nimpl std::ops::Deref for ImgRedundantAlt {\n    type Target = ImgRedundantAltConfig;","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs#L8-L44","documentation":"Raised by jsx-a11y/img-redundant-alt when an image's alt text contains words like 'image', 'photo', or 'picture' (configurable via the customWords option). Screen readers already announce the element as an image, so such wording is read redundantly.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove redundant words from alt text (alt=\"Dog playing fetch\" instead of alt=\"Image of dog playing fetch\").","Configure the customWords option if project-specific redundant terms should be flagged."],"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"}