Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Mar 28, 2024
1 parent 7200266 commit f37d519
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions crates/oxc_linter/Source/rules/nextjs/google_font_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Rule for GoogleFontDisplay {

let Some(href_prop_value) = get_string_literal_prop_value(href_prop) else { return };

if href_prop_value.starts_with("https://Fonts.GoogleAPIs.Com/css") {
if href_prop_value.starts_with("https://fonts.googleapis.com/css") {
let Ok(url) = url::Url::parse(href_prop_value) else { return };

let Some((_, display_value)) = url.query_pairs().find(|(key, _)| key == "display")
Expand Down Expand Up @@ -108,7 +108,7 @@ fn test() {
rel="icon"
/>
<link
href="https://Fonts.GoogleAPIs.Com/css2?family=Krona+One&display=optional"
href="https://fonts.googleapis.com/css2?family=Krona+One&display=optional"
rel="stylesheet"
/>
</Head>
Expand All @@ -123,7 +123,7 @@ fn test() {
<Html>
<Head>
<link
href="https://Fonts.GoogleAPIs.Com/css?family=Krona+One&display=swap"
href="https://fonts.googleapis.com/css?family=Krona+One&display=swap"
rel="stylesheet"
/>
</Head>
Expand All @@ -142,7 +142,7 @@ fn test() {
<Html>
<Head>
<link
href="https://Fonts.GoogleAPIs.Com/css?family=Krona+One&display=swap"
href="https://fonts.googleapis.com/css?family=Krona+One&display=swap"
rel="stylesheet"
crossOrigin=""
/>
Expand All @@ -163,7 +163,7 @@ fn test() {
return (
<Head>
<link
href="https://Fonts.GoogleAPIs.Com/css2?family=Krona+One"
href="https://fonts.googleapis.com/css2?family=Krona+One"
rel="stylesheet"
/>
</Head>
Expand All @@ -176,7 +176,7 @@ fn test() {
return (
<Head>
<link
href="https://Fonts.GoogleAPIs.Com/css2?family=Krona+One&display=block"
href="https://fonts.googleapis.com/css2?family=Krona+One&display=block"
rel="stylesheet"
/>
</Head>
Expand All @@ -189,7 +189,7 @@ fn test() {
return (
<Head>
<link
href="https://Fonts.GoogleAPIs.Com/css2?family=Krona+One&display=auto"
href="https://fonts.googleapis.com/css2?family=Krona+One&display=auto"
rel="stylesheet"
/>
</Head>
Expand All @@ -202,7 +202,7 @@ fn test() {
return (
<Head>
<link
href="https://Fonts.GoogleAPIs.Com/css2?display=fallback&family=Krona+One"
href="https://fonts.googleapis.com/css2?display=fallback&family=Krona+One"
rel="stylesheet"
/>
</Head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Rule for GoogleFontPreconnect {
rel_prop_value != Some("preconnect")
});

if href_prop_value.starts_with("https://Fonts.GStatic.Com") && preconnect_missing {
if href_prop_value.starts_with("https://fonts.gstatic.com") && preconnect_missing {
ctx.diagnostic(GoogleFontPreconnectDiagnostic(jsx_opening_element_name.span));
}
}
Expand All @@ -74,7 +74,7 @@ fn test() {
let pass = vec![
r#"export const Test = () => (
<div>
<link rel="preconnect" href="https://Fonts.GStatic.Com"/>
<link rel="preconnect" href="https://fonts.gstatic.com"/>
<link
href={process.env.NEXT_PUBLIC_CANONICAL_URL}
rel="canonical"
Expand All @@ -92,14 +92,14 @@ fn test() {
r#"
export const Test = () => (
<div>
<link href="https://Fonts.GStatic.Com"/>
<link href="https://fonts.gstatic.com"/>
</div>
)
"#,
r#"
export const Test = () => (
<div>
<link rel="preload" href="https://Fonts.GStatic.Com"/>
<link rel="preload" href="https://fonts.gstatic.com"/>
</div>
)
"#,
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/Source/rules/nextjs/no_css_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn test() {
return (
<div>
<h1>Hello title</h1>
<link href="https://Fonts.GoogleAPIs.Com/css?family=Open+Sans&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet" />
</div>
);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_linter/Source/snapshots/google_font_display.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ expression: google_font_display
5 │ <Head>
6 │ <link
· ────
7 href="https://Fonts.GoogleAPIs.Com/css2?family=Krona+One"
7 href="https://fonts.googleapis.com/css2?family=Krona+One"
╰────
help: See https://nextjs.org/docs/messages/google-font-display

eslint-plugin-next(google-font-display): `block` is not a recommended font-display value.
╭─[google_font_display.tsx:7:17]
6 <link
7 href="https://Fonts.GoogleAPIs.Com/css2?family=Krona+One&display=block"
7 href="https://fonts.googleapis.com/css2?family=Krona+One&display=block"
· ───────────────────────────────────────────────────────────────────────
8 rel="stylesheet"
╰────
Expand All @@ -23,7 +23,7 @@ expression: google_font_display
eslint-plugin-next(google-font-display): `auto` is not a recommended font-display value.
╭─[google_font_display.tsx:7:17]
6 <link
7 href="https://Fonts.GoogleAPIs.Com/css2?family=Krona+One&display=auto"
7 href="https://fonts.googleapis.com/css2?family=Krona+One&display=auto"
· ──────────────────────────────────────────────────────────────────────
8 rel="stylesheet"
╰────
Expand All @@ -32,7 +32,7 @@ expression: google_font_display
eslint-plugin-next(google-font-display): `fallback` is not a recommended font-display value.
╭─[google_font_display.tsx:7:17]
6 <link
7 href="https://Fonts.GoogleAPIs.Com/css2?display=fallback&family=Krona+One"
7 href="https://fonts.googleapis.com/css2?display=fallback&family=Krona+One"
· ──────────────────────────────────────────────────────────────────────────
8 rel="stylesheet"
╰────
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: google_font_preconnect
eslint-plugin-next(google-font-preconnect): `rel="preconnect"` is missing from Google Font.
╭─[google_font_preconnect.tsx:4:15]
3 │ <div>
4 │ <link href="https://Fonts.GStatic.Com"/>
4 │ <link href="https://fonts.gstatic.com"/>
· ────
5 │ </div>
╰────
Expand All @@ -14,7 +14,7 @@ expression: google_font_preconnect
eslint-plugin-next(google-font-preconnect): `rel="preconnect"` is missing from Google Font.
╭─[google_font_preconnect.tsx:4:15]
3 │ <div>
4 │ <link rel="preload" href="https://Fonts.GStatic.Com"/>
4 │ <link rel="preload" href="https://fonts.gstatic.com"/>
· ────
5 │ </div>
╰────
Expand Down

0 comments on commit f37d519

Please sign in to comment.