Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f97b82a2
Unverified
Commit
f97b82a2
authored
May 11, 2021
by
Yamagishi Kazutoshi
Committed by
GitHub
May 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip processing when href is not a simple string (#24986)
parent
2f142b62
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
6 deletions
+31
-6
google-font-display.js
packages/eslint-plugin-next/lib/rules/google-font-display.js
+1
-1
google-font-preconnect.js
...es/eslint-plugin-next/lib/rules/google-font-preconnect.js
+1
-1
no-page-custom-font.js
packages/eslint-plugin-next/lib/rules/no-page-custom-font.js
+1
-1
google-font-display.unit.test.js
test/eslint-plugin-next/google-font-display.unit.test.js
+10
-1
google-font-preconnect.unit.test.js
test/eslint-plugin-next/google-font-preconnect.unit.test.js
+9
-1
no-page-custom-font.unit.test.js
test/eslint-plugin-next/no-page-custom-font.unit.test.js
+9
-1
No files found.
packages/eslint-plugin-next/lib/rules/google-font-display.js
View file @
f97b82a2
...
@@ -23,7 +23,7 @@ module.exports = {
...
@@ -23,7 +23,7 @@ module.exports = {
}
}
const
hrefValue
=
attributes
.
value
(
'href'
)
const
hrefValue
=
attributes
.
value
(
'href'
)
const
isGoogleFont
=
hrefValue
.
includes
(
const
isGoogleFont
=
hrefValue
?.
startsWith
(
'https://fonts.googleapis.com/css'
'https://fonts.googleapis.com/css'
)
)
...
...
packages/eslint-plugin-next/lib/rules/google-font-preconnect.js
View file @
f97b82a2
...
@@ -26,7 +26,7 @@ module.exports = {
...
@@ -26,7 +26,7 @@ module.exports = {
attributes
.
value
(
'rel'
)
!==
'preconnect'
attributes
.
value
(
'rel'
)
!==
'preconnect'
if
(
if
(
hrefValue
.
includes
(
'https://fonts.gstatic.com'
)
&&
hrefValue
?.
startsWith
(
'https://fonts.gstatic.com'
)
&&
preconnectMissing
preconnectMissing
)
{
)
{
context
.
report
({
context
.
report
({
...
...
packages/eslint-plugin-next/lib/rules/no-page-custom-font.js
View file @
f97b82a2
...
@@ -38,7 +38,7 @@ module.exports = {
...
@@ -38,7 +38,7 @@ module.exports = {
}
}
const
hrefValue
=
attributes
.
value
(
'href'
)
const
hrefValue
=
attributes
.
value
(
'href'
)
const
isGoogleFont
=
hrefValue
.
includes
(
const
isGoogleFont
=
hrefValue
?.
startsWith
(
'https://fonts.googleapis.com/css'
'https://fonts.googleapis.com/css'
)
)
...
...
test/eslint-plugin-next/google-font-display.unit.test.js
View file @
f97b82a2
...
@@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester
...
@@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester
RuleTester
.
setDefaultConfig
({
RuleTester
.
setDefaultConfig
({
parserOptions
:
{
parserOptions
:
{
ecmaVersion
:
20
18
,
ecmaVersion
:
20
20
,
sourceType
:
'module'
,
sourceType
:
'module'
,
ecmaFeatures
:
{
ecmaFeatures
:
{
modules
:
true
,
modules
:
true
,
...
@@ -20,6 +20,15 @@ ruleTester.run('google-font-display', rule, {
...
@@ -20,6 +20,15 @@ ruleTester.run('google-font-display', rule, {
export default Test = () => {
export default Test = () => {
return (
return (
<Head>
<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
<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"
rel="stylesheet"
...
...
test/eslint-plugin-next/google-font-preconnect.unit.test.js
View file @
f97b82a2
...
@@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester
...
@@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester
RuleTester
.
setDefaultConfig
({
RuleTester
.
setDefaultConfig
({
parserOptions
:
{
parserOptions
:
{
ecmaVersion
:
20
18
,
ecmaVersion
:
20
20
,
sourceType
:
'module'
,
sourceType
:
'module'
,
ecmaFeatures
:
{
ecmaFeatures
:
{
modules
:
true
,
modules
:
true
,
...
@@ -18,6 +18,14 @@ ruleTester.run('google-font-preconnect', rule, {
...
@@ -18,6 +18,14 @@ ruleTester.run('google-font-preconnect', rule, {
`export const Test = () => (
`export const Test = () => (
<div>
<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"
/>
<link
href={new URL("../public/favicon.ico", import.meta.url).toString()}
rel="icon"
/>
</div>
</div>
)
)
`
,
`
,
...
...
test/eslint-plugin-next/no-page-custom-font.unit.test.js
View file @
f97b82a2
...
@@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester
...
@@ -3,7 +3,7 @@ const RuleTester = require('eslint').RuleTester
RuleTester
.
setDefaultConfig
({
RuleTester
.
setDefaultConfig
({
parserOptions
:
{
parserOptions
:
{
ecmaVersion
:
20
18
,
ecmaVersion
:
20
20
,
sourceType
:
'module'
,
sourceType
:
'module'
,
ecmaFeatures
:
{
ecmaFeatures
:
{
modules
:
true
,
modules
:
true
,
...
@@ -26,6 +26,14 @@ ruleTester.run('no-page-custom-font', rule, {
...
@@ -26,6 +26,14 @@ ruleTester.run('no-page-custom-font', rule, {
href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
rel="stylesheet"
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>
</Head>
</Html>
</Html>
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment