Skip to content

Commit

Permalink
Merge branch 'canary' into bugfix/typescript-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored May 11, 2021
2 parents ba122c2 + f97b82a commit 36913a1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
}

const hrefValue = attributes.value('href')
const isGoogleFont = hrefValue.includes(
const isGoogleFont = hrefValue?.startsWith(
'https://fonts.googleapis.com/css'
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
attributes.value('rel') !== 'preconnect'

if (
hrefValue.includes('https://fonts.gstatic.com') &&
hrefValue?.startsWith('https://fonts.gstatic.com') &&
preconnectMissing
) {
context.report({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
}

const hrefValue = attributes.value('href')
const isGoogleFont = hrefValue.includes(
const isGoogleFont = hrefValue?.startsWith(
'https://fonts.googleapis.com/css'
)

Expand Down
11 changes: 10 additions & 1 deletion test/eslint-plugin-next/google-font-display.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester

RuleTester.setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
modules: true,
Expand All @@ -20,6 +20,15 @@ ruleTester.run('google-font-display', rule, {
export default Test = () => {
return (
<Head>
<link href={test} rel="test" />
<link
href={process.env.NEXT_PUBLIC_CANONICAL_URL}
rel="canonical"
/>
<link
href={new URL("../public/favicon.ico", import.meta.url).toString()}
rel="icon"
/>
<link
href="https://fonts.googleapis.com/css2?family=Krona+One&display=optional"
rel="stylesheet"
Expand Down
10 changes: 9 additions & 1 deletion test/eslint-plugin-next/google-font-preconnect.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester

RuleTester.setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
modules: true,
Expand All @@ -18,6 +18,14 @@ ruleTester.run('google-font-preconnect', rule, {
`export const Test = () => (
<div>
<link rel="preconnect" href="https://fonts.gstatic.com"/>
<link
href={process.env.NEXT_PUBLIC_CANONICAL_URL}
rel="canonical"
/>
<link
href={new URL("../public/favicon.ico", import.meta.url).toString()}
rel="icon"
/>
</div>
)
`,
Expand Down
10 changes: 9 additions & 1 deletion test/eslint-plugin-next/no-page-custom-font.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester

RuleTester.setDefaultConfig({
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
modules: true,
Expand All @@ -26,6 +26,14 @@ ruleTester.run('no-page-custom-font', rule, {
href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
rel="stylesheet"
/>
<link
href={process.env.NEXT_PUBLIC_CANONICAL_URL}
rel="canonical"
/>
<link
href={new URL("../public/favicon.ico", import.meta.url).toString()}
rel="icon"
/>
</Head>
</Html>
);
Expand Down

0 comments on commit 36913a1

Please sign in to comment.