Skip to content

Commit 3ca066b

Browse files
authored
fix(noUnknownAttribute): add closedby as a valid attribute for <dialog> (#9142)
1 parent 6918c9e commit 3ca066b

6 files changed

Lines changed: 50 additions & 21 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#9141](https://github.com/biomejs/biome/issues/9141): The `noUnknownAttribute` rule no longer reports `closedby` as an unknown attribute on `<dialog>` elements.

crates/biome_js_analyze/src/lint/nursery/no_unknown_attribute.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ const ATTRIBUTE_TAGS_MAP: &[(&str, &[&str])] = &[
114114
("autoPictureInPicture", &["video"]),
115115
("charset", &["meta"]),
116116
("checked", &["input"]),
117+
("closedby", &["dialog"]),
117118
("controls", &["audio", "video"]),
118119
("controlsList", &["audio", "video"]),
119120
(

crates/biome_js_analyze/tests/specs/nursery/noUnknownAttribute/invalid.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<div data-xml-anything="invalid" />
4343
<div data-testID="bar" data-under_sCoRe="bar" dataNotAnDataAttribute="yes" />
4444
<div abbr="abbr" />
45+
<div closedby="any" />
4546
<div webkitDirectory="" />
4647
<div webkitdirectory="" />
4748
<div

crates/biome_js_analyze/tests/specs/nursery/noUnknownAttribute/invalid.jsx.snap

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ expression: invalid.jsx
4848
<div data-xml-anything="invalid" />
4949
<div data-testID="bar" data-under_sCoRe="bar" dataNotAnDataAttribute="yes" />
5050
<div abbr="abbr" />
51+
<div closedby="any" />
5152
<div webkitDirectory="" />
5253
<div webkitdirectory="" />
5354
<div
@@ -847,7 +848,7 @@ invalid.jsx:43:48 lint/nursery/noUnknownAttribute ━━━━━━━━━━
847848
> 43 │ <div data-testID="bar" data-under_sCoRe="bar" dataNotAnDataAttribute="yes" />
848849
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
849850
44 │ <div abbr="abbr" />
850-
45 │ <div webkitDirectory="" />
851+
45 │ <div closedby="any" />
851852
852853
i This property is not recognized as a valid HTML/DOM attribute or React prop.
853854
@@ -867,8 +868,8 @@ invalid.jsx:44:7 lint/nursery/noUnknownAttribute ━━━━━━━━━━
867868
43 │ <div data-testID="bar" data-under_sCoRe="bar" dataNotAnDataAttribute="yes" />
868869
> 44 │ <div abbr="abbr" />
869870
│ ^^^^^^^^^^^
870-
45 │ <div webkitDirectory="" />
871-
46 │ <div webkitdirectory="" />
871+
45 │ <div closedby="any" />
872+
46 │ <div webkitDirectory="" />
872873
873874
i This attribute is restricted and cannot be used on this HTML element
874875
@@ -882,18 +883,18 @@ invalid.jsx:44:7 lint/nursery/noUnknownAttribute ━━━━━━━━━━
882883
```
883884
invalid.jsx:45:7 lint/nursery/noUnknownAttribute ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
884885
885-
i Property 'webkitDirectory' is not valid on a <div> element.
886+
i Property 'closedby' is not valid on a <div> element.
886887
887888
43 │ <div data-testID="bar" data-under_sCoRe="bar" dataNotAnDataAttribute="yes" />
888889
44 │ <div abbr="abbr" />
889-
> 45 │ <div webkitDirectory="" />
890-
│ ^^^^^^^^^^^^^^^^^^
891-
46 │ <div webkitdirectory="" />
892-
47 │ <div
890+
> 45 │ <div closedby="any" />
891+
│ ^^^^^^^^^^^^^^
892+
46 │ <div webkitDirectory="" />
893+
47 │ <div webkitdirectory="" />
893894
894895
i This attribute is restricted and cannot be used on this HTML element
895896
896-
i This attribute is only allowed on: input
897+
i This attribute is only allowed on: dialog
897898
898899
i This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
899900
@@ -906,11 +907,32 @@ invalid.jsx:46:7 lint/nursery/noUnknownAttribute ━━━━━━━━━━
906907
i Property 'webkitDirectory' is not valid on a <div> element.
907908
908909
44 │ <div abbr="abbr" />
909-
45 │ <div webkitDirectory="" />
910-
> 46 │ <div webkitdirectory="" />
910+
45 │ <div closedby="any" />
911+
> 46 │ <div webkitDirectory="" />
912+
│ ^^^^^^^^^^^^^^^^^^
913+
47 │ <div webkitdirectory="" />
914+
48 │ <div
915+
916+
i This attribute is restricted and cannot be used on this HTML element
917+
918+
i This attribute is only allowed on: input
919+
920+
i This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
921+
922+
923+
```
924+
925+
```
926+
invalid.jsx:47:7 lint/nursery/noUnknownAttribute ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
927+
928+
i Property 'webkitDirectory' is not valid on a <div> element.
929+
930+
45 <div closedby="any" />
931+
46 │ <div webkitDirectory="" />
932+
> 47 │ <div webkitdirectory="" />
911933
│ ^^^^^^^^^^^^^^^^^^
912-
47 │ <div
913-
48 className="App"
934+
48 │ <div
935+
49 className="App"
914936
915937
i This attribute is restricted and cannot be used on this HTML element
916938
@@ -922,16 +944,16 @@ invalid.jsx:46:7 lint/nursery/noUnknownAttribute ━━━━━━━━━━
922944
```
923945
924946
```
925-
invalid.jsx:49:3 lint/nursery/noUnknownAttribute ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
947+
invalid.jsx:50:3 lint/nursery/noUnknownAttribute ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
926948
927949
i The property 'data-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash:c' is not a valid DOM attribute.
928950
929-
47 <div
930-
48 className="App"
931-
> 49 │ data-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash:c="customValue"
951+
48 <div
952+
49 className="App"
953+
> 50 │ data-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash-crash:c="customValue"
932954
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
933-
50 │ >
934-
51 │ Hello, world!
955+
51 │ >
956+
52 │ Hello, world!
935957
936958
i This property is not recognized as a valid HTML/DOM attribute or React prop.
937959

crates/biome_js_analyze/tests/specs/nursery/noUnknownAttribute/valid.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
<hr align="top" />
153153
<applet align="top" />
154154
<marker fill="#000" />
155-
<dialog onClose={handler} open id="dialog" returnValue="something" onCancel={handler2} />
155+
<dialog closedby="any" onClose={handler} open id="dialog" returnValue="something" onCancel={handler2} />
156156

157157
<table align="top">
158158
<caption align="top">Table Caption</caption>

crates/biome_js_analyze/tests/specs/nursery/noUnknownAttribute/valid.jsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ expression: valid.jsx
158158
<hr align="top" />
159159
<applet align="top" />
160160
<marker fill="#000" />
161-
<dialog onClose={handler} open id="dialog" returnValue="something" onCancel={handler2} />
161+
<dialog closedby="any" onClose={handler} open id="dialog" returnValue="something" onCancel={handler2} />
162162
163163
<table align="top">
164164
<caption align="top">Table Caption</caption>

0 commit comments

Comments
 (0)