Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions crates/oxc_linter/src/rules/react/no_unknown_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ const ATTRIBUTE_TAGS_MAP: Map<&'static str, Set<&'static str>> = phf_map! {
"displaystyle" => phf_set! {"math"},
// https://html.spec.whatwg.org/multipage/links.html#downloading-resources
"download" => phf_set! {"a", "area"},
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes
"fetchPriority" => phf_set! {"img", "link", "script"},
"fill" => phf_set! {
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill
// Fill color
Expand Down Expand Up @@ -340,6 +342,7 @@ const DOM_ATTRIBUTES_TO_CAMEL: Map<&'static str, &'static str> = phf_map! {
"class" => "className",
"http-equiv" => "httpEquiv",
"crossorigin" => "crossOrigin",
"fetchpriority" => "fetchPriority",
"for" => "htmlFor",
"nomodule" => "noModule",
"popovertarget" => "popoverTarget",
Expand Down Expand Up @@ -692,6 +695,12 @@ fn test() {
r#"<input type="button" popoverTarget="locale-switcher" popoverTargetAction="show" />"#,
None,
),
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes
(r#"<img fetchPriority="high" src="foo.jpg" />"#, None),
(r#"<img fetchPriority="low" src="foo.jpg" />"#, None),
(r#"<img fetchPriority="auto" src="foo.jpg" />"#, None),
(r#"<link fetchPriority="high" href="style.css" rel="stylesheet" />"#, None),
(r#"<script fetchPriority="high" src="script.js" />"#, None),
(
r#"
<table align="top">
Expand Down Expand Up @@ -773,6 +782,10 @@ fn test() {
(r#"<div imageSizes="someImageSizes" />"#, None),
(r#"<div popoverTarget="locale-switcher" />"#, None),
(r#"<div popoverTargetAction="show" />"#, None),
(r#"<div fetchPriority="high" />"#, None),
(r#"<img fetchpriority="high" src="foo.jpg" />"#, None),
(r#"<link fetchpriority="high" href="style.css" rel="stylesheet" />"#, None),
(r#"<script fetchpriority="high" src="script.js" />"#, None),
(r#"<div data-xml-anything="invalid" />"#, None),
(
r#"<div data-testID="bar" data-under_sCoRe="bar" />;"#,
Expand Down
28 changes: 28 additions & 0 deletions crates/oxc_linter/src/snapshots/react_no_unknown_property.snap
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,34 @@ source: crates/oxc_linter/src/tester.rs
╰────
help: Property 'popoverTargetAction' is only allowed on: input, button

⚠ eslint-plugin-react(no-unknown-property): Invalid property found
╭─[no_unknown_property.tsx:1:6]
1 │ <div fetchPriority="high" />
· ─────────────
╰────
help: Property 'fetchPriority' is only allowed on: link, img, script

⚠ eslint-plugin-react(no-unknown-property): Unknown property found
╭─[no_unknown_property.tsx:1:6]
1 │ <img fetchpriority="high" src="foo.jpg" />
· ─────────────
╰────
help: Use 'fetchPriority' instead

⚠ eslint-plugin-react(no-unknown-property): Unknown property found
╭─[no_unknown_property.tsx:1:7]
1 │ <link fetchpriority="high" href="style.css" rel="stylesheet" />
· ─────────────
╰────
help: Use 'fetchPriority' instead

⚠ eslint-plugin-react(no-unknown-property): Unknown property found
╭─[no_unknown_property.tsx:1:9]
1 │ <script fetchpriority="high" src="script.js" />
· ─────────────
╰────
help: Use 'fetchPriority' instead

⚠ eslint-plugin-react(no-unknown-property): Unknown property found
╭─[no_unknown_property.tsx:1:6]
1 │ <div data-xml-anything="invalid" />
Expand Down
Loading