Skip to content

Commit f62fb8b

Browse files
authored
fix(useValidAutocomplete): update autocomplete attribute validation (#10752)
1 parent d9b5133 commit f62fb8b

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

.changeset/chatty-ears-taste.md

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 [#10739](https://github.com/biomejs/biome/issues/10739). Now the rule [`useValidAutocomplete`](https://biomejs.dev/linter/rules/use-valid-autocomplete/) correctly flags the `autoComplete` attribute.

crates/biome_js_analyze/src/lint/a11y/use_valid_autocomplete.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ impl Rule for UseValidAutocomplete {
154154
return None;
155155
}
156156

157-
let autocomplete_attribute = node.attributes().find_by_name("autocomplete")?;
157+
let autocomplete_attribute = node
158+
.attributes()
159+
.find_by_name("autocomplete")
160+
.or(node.attributes().find_by_name("autoComplete"))?;
158161
let autocomplete_val = autocomplete_attribute.as_static_value()?;
159162
let autocompletes = autocomplete_val
160163
.text()

crates/biome_js_analyze/tests/specs/a11y/useValidAutocomplete/invalid.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<input type="text" autocomplete="home url" />
77
<Bar autocomplete="baz"></Bar>
88
<Input type="text" autocomplete="baz" />
9+
<Input type="text" autoComplete="baz" />
910
</>

crates/biome_js_analyze/tests/specs/a11y/useValidAutocomplete/invalid.jsx.snap

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ expression: invalid.jsx
1212
<input type="text" autocomplete="home url" />
1313
<Bar autocomplete="baz"></Bar>
1414
<Input type="text" autocomplete="baz" />
15+
<Input type="text" autoComplete="baz" />
1516
</>
1617
1718
```
@@ -115,7 +116,7 @@ invalid.jsx:7:7 lint/a11y/useValidAutocomplete ━━━━━━━━━━━
115116
> 7 │ <Bar autocomplete="baz"></Bar>
116117
│ ^^^^^^^^^^^^^^^^^^
117118
8 │ <Input type="text" autocomplete="baz" />
118-
9 │ </>
119+
9 │ <Input type="text" autoComplete="baz" />
119120
120121
i The autocomplete attribute only accepts a certain number of specific fixed values.
121122
@@ -136,8 +137,30 @@ invalid.jsx:8:21 lint/a11y/useValidAutocomplete ━━━━━━━━━━
136137
7 │ <Bar autocomplete="baz"></Bar>
137138
> 8 │ <Input type="text" autocomplete="baz" />
138139
│ ^^^^^^^^^^^^^^^^^^
139-
9 │ </>
140-
10 │
140+
9 │ <Input type="text" autoComplete="baz" />
141+
10 │ </>
142+
143+
i The autocomplete attribute only accepts a certain number of specific fixed values.
144+
145+
i Follow the links for more information,
146+
WCAG 1.3.5
147+
HTML Living Standard autofill
148+
HTML attribute: autocomplete - HTML: HyperText Markup Language | MDN
149+
150+
151+
```
152+
153+
```
154+
invalid.jsx:9:21 lint/a11y/useValidAutocomplete ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
155+
156+
× Use valid values for the autocomplete attribute.
157+
158+
7 │ <Bar autocomplete="baz"></Bar>
159+
8 │ <Input type="text" autocomplete="baz" />
160+
> 9 │ <Input type="text" autoComplete="baz" />
161+
│ ^^^^^^^^^^^^^^^^^^
162+
10 │ </>
163+
11 │
141164
142165
i The autocomplete attribute only accepts a certain number of specific fixed values.
143166

0 commit comments

Comments
 (0)