Skip to content

Commit

Permalink
fix(lint/noInteractiveElementToNoninteractiveRole): fix <source /> er…
Browse files Browse the repository at this point in the history
…ror case (#4300)

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
  • Loading branch information
eryue0220 and ematipico authored Oct 16, 2024
1 parent 5a1710f commit ea7d35c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

- Improved the message for unused suppression comments. Contributed by @dyc3

- Fix [#4228](https://github.com/biomejs/biome/issues/4228), where the rule `a11y/noInteractiveElementToNoninteractiveRole` incorrectlly reports a `role` for non interactive elements. Contributed by @eryue0220
- Catch suspicious semicolon in react fragment in `noSuspiciousSemicolonInJsx`. Contributed by @vasucp1207

### CLI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Rule for NoInteractiveElementToNoninteractiveRole {
{
// <div> and <span> are considered neither interactive nor non-interactive, depending on the presence or absence of the role attribute.
// We don't report <div> and <span> here, because we cannot determine whether they are interactive or non-interactive.
let role_sensitive_elements = ["div", "span"];
let role_sensitive_elements = ["div", "span", "source"];
if role_sensitive_elements.contains(&element_name.text_trimmed()) {
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,15 @@
<Link href="http://x.y.z" role="img" />;
<Link href="http://x.y.z" />;
<Button onClick={doFoo} />;
<picture>
<source
srcSet={'/assets/head.webp'}
role='img'
type='image/webp'
/>
<img
src={'/assets/head.png'}
alt='An ASCII-style headshot'
/>
</picture>

Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ expression: valid.jsx
<Link href="http://x.y.z" role="img" />;
<Link href="http://x.y.z" />;
<Button onClick={doFoo} />;
<picture>
<source
srcSet={'/assets/head.webp'}
role='img'
type='image/webp'
/>
<img
src={'/assets/head.png'}
alt='An ASCII-style headshot'
/>
</picture>


```

0 comments on commit ea7d35c

Please sign in to comment.