Skip to content

Commit

Permalink
fix(linter): false positive in jsx-a11y/label-has-associated-control
Browse files Browse the repository at this point in the history
  • Loading branch information
shulaoda committed Dec 14, 2024
1 parent 7a087b9 commit bd6b018
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,12 @@ impl Rule for LabelHasAssociatedControl {
return;
};

if let Some(element_type) = get_element_type(ctx, &element.opening_element) {
if self.label_components.binary_search(&element_type.into()).is_err() {
return;
}
let Some(element_type) = get_element_type(ctx, &element.opening_element) else {
return;
};

if self.label_components.binary_search(&element_type.into()).is_err() {
return;
}

let has_html_for = has_jsx_prop(&element.opening_element, "htmlFor").is_some();
Expand Down Expand Up @@ -915,6 +917,8 @@ fn test() {
}])),
None,
),
// Issue: <https://github.com/oxc-project/oxc/issues/7849>
("<FilesContext.Provider value={{ addAlert, cwdInfo }} />", None, None),
];

let fail = vec![
Expand Down

0 comments on commit bd6b018

Please sign in to comment.