diff --git a/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs index 380676483..e6b9362ca 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/img_redundant_alt.rs @@ -219,6 +219,7 @@ fn test() { (r"{() {}} />", None), (r"{function(e){}}", None), (r"Doing cool things.", None), + (r"photo of cool person", None), (r"test", None), (r"", None), (r"{imageAlt}", None), diff --git a/crates/oxc_linter/src/utils/react.rs b/crates/oxc_linter/src/utils/react.rs index 044e0efa3..828ba505c 100644 --- a/crates/oxc_linter/src/utils/react.rs +++ b/crates/oxc_linter/src/utils/react.rs @@ -90,6 +90,10 @@ pub fn is_hidden_from_screen_reader(node: &JSXOpeningElement) -> bool { has_jsx_prop_lowercase(node, "aria-hidden").map_or(false, |v| match get_prop_value(v) { None => true, Some(JSXAttributeValue::StringLiteral(s)) if s.value == "true" => true, + Some(JSXAttributeValue::ExpressionContainer(JSXExpressionContainer { + expression: JSXExpression::Expression(expr), + .. + })) => expr.get_boolean_value().unwrap_or(false), _ => false, }) }