Skip to content

Commit 96a8abb

Browse files
tesseralisgatsbybot
and
gatsbybot
authored
maintenance(www): Get eslint to work on www again (gatsbyjs#24133)
* Get eslint to work on www again * fragment * add rule explanation * get rid of reporter Co-authored-by: gatsbybot <[email protected]>
1 parent 9abf974 commit 96a8abb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+507
-522
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ packages/*/scripts/**
88
**/dist/*
99
**/__testfixtures__/**
1010
**/__tests__/fixtures/**
11+
www/public
12+
www/src/components/search-form/docsearch.min.js
1113
peril
1214
docs
1315
plop-templates
1416
starters
15-
www
1617
benchmarks
1718
e2e-tests
1819
examples

.eslintrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ module.exports = {
7979
Cypress: false,
8080
},
8181
},
82+
{
83+
files: ["www/**/*"],
84+
rules: {
85+
// We need to import React to use the Fragment shorthand (`<>`).
86+
// When we use theme-ui's JSX pragma, it lists React as an unused var
87+
// even though it's still needed.
88+
"no-unused-vars": ["error", { varsIgnorePattern: "React" }],
89+
},
90+
},
8291
{
8392
files: ["*.ts", "*.tsx"],
8493
parser: "@typescript-eslint/parser",

www/__mocks__/gatsby.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
Link: jest.fn().mockImplementation(({ children, to, onClick, id }) => {
88
// Prevent the default click event to stop a console.error from jsdom.
99
// https://github.com/jsdom/jsdom/issues/2112
10-
const onClickWithoutDefault = (ev) => {
10+
const onClickWithoutDefault = ev => {
1111
ev.preventDefault()
1212
onClick(ev)
1313
}

www/gatsby-config.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,17 @@ if (process.env.AIRTABLE_API_KEY) {
5555

5656
if (i18nEnabled) {
5757
dynamicPlugins.push(
58-
...langCodes.map(code => ({
59-
resolve: `gatsby-source-git`,
60-
options: {
61-
name: `docs-${code}`,
62-
remote: `https://github.com/gatsbyjs/gatsby-${code}.git`,
63-
branch: `master`,
64-
patterns: [`docs/**`],
65-
},
66-
})),
58+
...langCodes.map(code => {
59+
return {
60+
resolve: `gatsby-source-git`,
61+
options: {
62+
name: `docs-${code}`,
63+
remote: `https://github.com/gatsbyjs/gatsby-${code}.git`,
64+
branch: `master`,
65+
patterns: [`docs/**`],
66+
},
67+
}
68+
}),
6769
{
6870
resolve: `gatsby-plugin-i18n`, // local plugin
6971
options: {
@@ -93,7 +95,7 @@ module.exports = {
9395
// Relative paths when importing components from MDX break translations of the docs,
9496
// so use an alias instead inside MDX:
9597
// https://www.gatsbyjs.org/contributing/docs-and-blog-components/#importing-other-components
96-
"@components": "src/components",
98+
"@components": `src/components`,
9799
},
98100
},
99101
},

www/gatsby-node.js

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ exports.onPostBuild = () => {
5959
exports.sourceNodes = async ({
6060
actions: { createTypes, createNode },
6161
createContentDigest,
62-
schema,
6362
}) => {
6463
/*
6564
* NOTE: This _only_ defines the schema we currently query for. If anything in

www/src/assets/ornaments/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export {
77
CirclesOrnament,
88
NewsletterFormOrnament,
99
QuotationMarkOrnament,
10-
StarOrnament
10+
StarOrnament,
1111
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
jest.mock("../../hooks/use-site-metadata", () => {
2-
return () => {
3-
return { siteUrl: "https://www.gatsbyjs.org" }
4-
}
1+
jest.mock(`../../hooks/use-site-metadata`, () => () => {
2+
return { siteUrl: `https://www.gatsbyjs.org` }
53
})
64

75
import React from "react"
@@ -12,88 +10,88 @@ import BlogPostMetadata from "../blog-post-metadata"
1210
const basePost = {
1311
timeToRead: 2,
1412
fields: {
15-
excerpt: "This is the very first Gatsby blog post.",
13+
excerpt: `This is the very first Gatsby blog post.`,
1614
},
1715
frontmatter: {
18-
title: "My first Gatsby blog post!",
19-
seoTitle: "How to write a Gatsby blog post",
16+
title: `My first Gatsby blog post!`,
17+
seoTitle: `How to write a Gatsby blog post`,
2018
rawDate: 12345,
2119
author: {
22-
id: "Kyle Mathews",
23-
twitter: "@kylemathews",
20+
id: `Kyle Mathews`,
21+
twitter: `@kylemathews`,
2422
fields: {
25-
slug: "/contributors/kyle-mathews/",
23+
slug: `/contributors/kyle-mathews/`,
2624
},
2725
},
2826
},
2927
}
3028

31-
it("generates an alternate url the post has a canonicalLink in frontmatter", () => {
29+
it(`generates an alternate url the post has a canonicalLink in frontmatter`, () => {
3230
const post = {
3331
...basePost,
3432
frontmatter: {
3533
...basePost.frontmatter,
36-
canonicalLink: "https://reactjs.org/",
34+
canonicalLink: `https://reactjs.org/`,
3735
},
3836
}
3937
render(<BlogPostMetadata post={post} />)
4038
const content = Helmet.peek()
4139
expect(content.linkTags).toContainEqual({
42-
rel: "canonical",
43-
href: "https://reactjs.org/",
40+
rel: `canonical`,
41+
href: `https://reactjs.org/`,
4442
})
4543
expect(content.metaTags).toContainEqual({
46-
property: "og:url",
47-
content: "https://reactjs.org/",
44+
property: `og:url`,
45+
content: `https://reactjs.org/`,
4846
})
4947
})
5048

51-
it("does not generate an alternate url if the post doesn't have a canonicalLink", () => {
49+
it(`does not generate an alternate url if the post doesn't have a canonicalLink`, () => {
5250
render(<BlogPostMetadata post={basePost} />)
5351
const content = Helmet.peek()
5452
expect(content.linkTags).not.toContainEqual({
55-
rel: "canonical",
56-
href: "https://reactjs.org/",
53+
rel: `canonical`,
54+
href: `https://reactjs.org/`,
5755
})
5856
expect(content.metaTags).not.toContainEqual({
59-
property: "og:url",
60-
content: "https://reactjs.org/",
57+
property: `og:url`,
58+
content: `https://reactjs.org/`,
6159
})
6260
})
6361

64-
it("populates the author info and published time", () => {
62+
it(`populates the author info and published time`, () => {
6563
render(<BlogPostMetadata post={basePost} />)
6664
const content = Helmet.peek()
6765
expect(content.linkTags).toContainEqual({
68-
rel: "author",
69-
href: "https://www.gatsbyjs.org/contributors/kyle-mathews/",
66+
rel: `author`,
67+
href: `https://www.gatsbyjs.org/contributors/kyle-mathews/`,
7068
})
7169
expect(content.metaTags).toContainEqual({
72-
name: "author",
73-
content: "Kyle Mathews",
70+
name: `author`,
71+
content: `Kyle Mathews`,
7472
})
7573
expect(content.metaTags).toContainEqual({
76-
name: "twitter:creator",
77-
content: "@kylemathews",
74+
name: `twitter:creator`,
75+
content: `@kylemathews`,
7876
})
7977
expect(content.metaTags).toContainEqual({
80-
property: "article:author",
81-
content: "Kyle Mathews",
78+
property: `article:author`,
79+
content: `Kyle Mathews`,
8280
})
8381
expect(content.metaTags).toContainEqual({
84-
property: "article:published_time",
82+
property: `article:published_time`,
8583
content: 12345,
8684
})
8785
})
8886

89-
it("uses the seoTitle when available", () => {
87+
it(`uses the seoTitle when available`, () => {
9088
render(<BlogPostMetadata post={basePost} />)
9189
const content = Helmet.peek()
9290

93-
expect(content.title).toEqual("How to write a Gatsby blog post")
91+
expect(content.title).toEqual(`How to write a Gatsby blog post`)
9492
})
9593

96-
it("uses the default title when seoTitle is not available", () => {
94+
it(`uses the default title when seoTitle is not available`, () => {
9795
const basePostWithoutSeoTitle = {
9896
...basePost,
9997
frontmatter: {
@@ -105,5 +103,5 @@ it("uses the default title when seoTitle is not available", () => {
105103
render(<BlogPostMetadata post={basePostWithoutSeoTitle} />)
106104
const content = Helmet.peek()
107105

108-
expect(content.title).toEqual("My first Gatsby blog post!")
106+
expect(content.title).toEqual(`My first Gatsby blog post!`)
109107
})

0 commit comments

Comments
 (0)