mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
parent
439ce5bc85
commit
94440ad35f
2 changed files with 9 additions and 2 deletions
|
|
@ -94,8 +94,7 @@ fn is_valid_lang_prop(item: &JSXAttributeItem) -> bool {
|
|||
!container.expression.is_expression() || !container.expression.is_undefined()
|
||||
}
|
||||
Some(JSXAttributeValue::StringLiteral(str)) => {
|
||||
let language_tag = LanguageTag::parse(str.value.as_str()).unwrap();
|
||||
language_tag.is_valid()
|
||||
LanguageTag::parse(str.value.as_str()).as_ref().is_ok_and(LanguageTag::is_valid)
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
|
|
@ -135,6 +134,7 @@ fn test() {
|
|||
|
||||
let fail = vec![
|
||||
("<html lang='foo' />", None, None, None),
|
||||
("<html lang='n'></html>", None, None, None),
|
||||
("<html lang='zz-LL' />", None, None, None),
|
||||
("<html lang={undefined} />", None, None, None),
|
||||
("<Foo lang={undefined} />", None, Some(settings()), None),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ source: crates/oxc_linter/src/tester.rs
|
|||
╰────
|
||||
help: Set a valid value for lang attribute.
|
||||
|
||||
⚠ eslint-plugin-jsx-a11y(lang): Lang attribute must have a valid value.
|
||||
╭─[lang.tsx:1:7]
|
||||
1 │ <html lang='n'></html>
|
||||
· ────────
|
||||
╰────
|
||||
help: Set a valid value for lang attribute.
|
||||
|
||||
⚠ eslint-plugin-jsx-a11y(lang): Lang attribute must have a valid value.
|
||||
╭─[lang.tsx:1:7]
|
||||
1 │ <html lang='zz-LL' />
|
||||
|
|
|
|||
Loading…
Reference in a new issue