-
-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add noLabelWithoutControl
rule
#2987
feat: add noLabelWithoutControl
rule
#2987
Conversation
387b9c9
to
db234a3
Compare
CodSpeed Performance ReportMerging #2987 will not alter performanceComparing Summary
|
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_label_without_control.rs
Outdated
Show resolved
Hide resolved
287c204
to
63fc953
Compare
0a94209
to
5ee008b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there! We just need to create the arrays statically, all of them, and then we can merge the PR
let default_label_attributes = &["aria-label", "alt"]; | ||
let default_label_components = &["label"]; | ||
let default_input_components = | ||
&["input", "meter", "output", "progress", "select", "textarea"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're creating the same array every time you run the rule. This isn't very efficient. Create a static array instead, for example:
const DEFAULT_LABEL_ATTIRBUTES: &[&str; 2] = &["aria-label", "alt"];
You'll have to place at the top level of the file, for example
pub const BUILTIN: &[&str; 67] = &[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, done!
5ee008b
to
f0664d6
Compare
Summary
Implementation of the
label-has-associated-control
rule from eslint-plugin-jsx-a11y in Biome.Closes #2610
Valid
Invalid
Test Plan
Added snapshots, for valid and invalid cases according to the original rule tests.