mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(linter): false positive in jsx-a11y/label-has-associated-control (#7881)
closes #7849 This is essentially because `get_element_type` does not support recognizing tag names like `<a.b />`. I'm unsure whether we should support it.
This commit is contained in:
parent
fb897f6c3a
commit
32935e6875
1 changed files with 8 additions and 4 deletions
|
|
@ -206,10 +206,12 @@ impl Rule for LabelHasAssociatedControl {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(element_type) = get_element_type(ctx, &element.opening_element) {
|
let Some(element_type) = get_element_type(ctx, &element.opening_element) else {
|
||||||
if self.label_components.binary_search(&element_type.into()).is_err() {
|
return;
|
||||||
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();
|
let has_html_for = has_jsx_prop(&element.opening_element, "htmlFor").is_some();
|
||||||
|
|
@ -915,6 +917,8 @@ fn test() {
|
||||||
}])),
|
}])),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
|
// Issue: <https://github.com/oxc-project/oxc/issues/7849>
|
||||||
|
("<FilesContext.Provider value={{ addAlert, cwdInfo }} />", None, None),
|
||||||
];
|
];
|
||||||
|
|
||||||
let fail = vec![
|
let fail = vec![
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue