oxc-project/oxc · error
Redundant `alt` attribute.
Error message
Redundant `alt` attribute.
What it means
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.
Source
Thrown at crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs:26
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use oxc_str::CompactStr;
use schemars::JsonSchema;
use serde_json::Value;
use crate::{
AstNode,
context::LintContext,
rule::Rule,
utils::{
get_element_type, get_prop_value, has_jsx_prop_ignore_case, is_hidden_from_screen_reader,
},
};
// TODO: Update this diagnostic message to actually include the custom words from the config.
fn img_redundant_alt_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Redundant `alt` attribute.")
.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)
}
#[derive(Debug, Default, Clone)]
pub struct ImgRedundantAlt(Box<ImgRedundantAltConfig>);
#[derive(Debug, Clone, JsonSchema)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct ImgRedundantAltConfig {
/// JSX element types to validate (component names) where the rule applies.
/// For example, `["img", "Image"]`.
components: Vec<CompactStr>,
/// Words considered redundant in alt text that should trigger a warning.
words: Vec<Cow<'static, str>>,
}
impl std::ops::Deref for ImgRedundantAlt {
type Target = ImgRedundantAltConfig;View on GitHub (pinned to e1e7af627c)
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs:26 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/d4ab52ae9317d42b.
Report an issue: GitHub.