diff --git a/.changeset/fix-hr-presentation-role.md b/.changeset/fix-hr-presentation-role.md new file mode 100644 index 000000000000..14e7fd4eb2fc --- /dev/null +++ b/.changeset/fix-hr-presentation-role.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": patch +--- + +Fixed [#9024](https://github.com/biomejs/biome/issues/9024): Biome no longer reports `
` under [`noInteractiveElementToNoninteractiveRole`](https://biomejs.dev/linter/rules/no-interactive-element-to-noninteractive-role/). diff --git a/crates/biome_js_analyze/src/lint/a11y/no_interactive_element_to_noninteractive_role.rs b/crates/biome_js_analyze/src/lint/a11y/no_interactive_element_to_noninteractive_role.rs index dad221ceae1f..da64c2919e84 100644 --- a/crates/biome_js_analyze/src/lint/a11y/no_interactive_element_to_noninteractive_role.rs +++ b/crates/biome_js_analyze/src/lint/a11y/no_interactive_element_to_noninteractive_role.rs @@ -64,6 +64,12 @@ impl Rule for NoInteractiveElementToNoninteractiveRole { let element_name = node.name().ok()?.as_jsx_name()?.value_token().ok()?; let element_name = element_name.text_trimmed(); + // `hr` implicitly maps to `separator`, and `presentation`/`none` is explicitly + // allowed on separators. + if element_name == "hr" && matches!(role_attribute_value, "presentation" | "none") { + return None; + } + if !ctx.aria_roles().is_not_interactive_element(node) && AriaRole::from_roles(role_attribute_value) .is_some_and(|role| role.is_non_interactive()) diff --git a/crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx b/crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx index 4fb8419839d3..69603fe45dc2 100644 --- a/crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx +++ b/crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx @@ -172,6 +172,8 @@
; /* Presentation is a special case role that indicates intentional static semantics */
; +
; +
; /* HTML elements attributed with an abstract role */
;
; @@ -276,4 +278,3 @@ alt='An ASCII-style headshot' /> - diff --git a/crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx.snap b/crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx.snap index e33025cb2833..a62e6caf4e16 100644 --- a/crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx.snap +++ b/crates/biome_js_analyze/tests/specs/a11y/noInteractiveElementToNoninteractiveRole/valid.jsx.snap @@ -1,5 +1,6 @@ --- source: crates/biome_js_analyze/tests/spec_tests.rs +assertion_line: 152 expression: valid.jsx --- # Input @@ -178,6 +179,8 @@ expression: valid.jsx
; /* Presentation is a special case role that indicates intentional static semantics */
; +
; +
; /* HTML elements attributed with an abstract role */
;
; @@ -283,5 +286,4 @@ expression: valid.jsx /> - ```