Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format JS Files #8623

Merged
merged 1 commit into from
Nov 6, 2018
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
2 changes: 1 addition & 1 deletion benchmarks/markdown/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
plugins: [`gatsby-transformer-remark`],
};
}
21 changes: 14 additions & 7 deletions benchmarks/markdown/page-template.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
const faker = require(`faker`)
const matter = require(`gray-matter`)

const NUM_ROWS = parseInt(process.env.NUM_ROWS || 25, 10);
const NUM_ROWS = parseInt(process.env.NUM_ROWS || 25, 10)

module.exports = index => `
${matter.stringify(``, {
title: faker.lorem.sentence(),
slug: `/${faker.helpers.slugify(faker.lorem.sentence())}`
}).trim()}
${matter
.stringify(``, {
title: faker.lorem.sentence(),
slug: `/${faker.helpers.slugify(faker.lorem.sentence())}`,
})
.trim()}

## Page #${index}

### API

|Name|Description|Required|
|:--:|-----------|--------|
${new Array(faker.random.number(NUM_ROWS)).fill(undefined).map(() => `
${new Array(faker.random.number(NUM_ROWS))
.fill(undefined)
.map(() =>
`
|${faker.lorem.word()}|${faker.lorem.sentence()}|${faker.random.boolean()}|
`.trim()).join('\n')}
`.trim()
)
.join(`\n`)}

### More Detail

Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/gatsby-image/cypress/integration/fixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe(`fixed`, () => {
// TODO: figure out why these tests are failing
it(`applies 1x/2x/3x`, () => {
cy.getTestElement(fixedTestId)
.find('picture > source')
.should('have.attr', 'srcset')
.find(`picture > source`)
.should(`have.attr`, `srcset`)
.and(srcset => {
;[`1x`, `2x`, `3x`].forEach(size => {
expect(srcset).contains(size)
Expand Down
32 changes: 16 additions & 16 deletions e2e-tests/gatsby-image/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
const path = require('path')
const path = require(`path`)

module.exports = {
pathPrefix: '/blog',
pathPrefix: `/blog`,
siteMetadata: {
title: 'Gatsby Image e2e',
title: `Gatsby Image e2e`,
},
plugins: [
'gatsby-plugin-react-helmet',
`gatsby-plugin-react-helmet`,
{
resolve: 'gatsby-source-filesystem',
resolve: `gatsby-source-filesystem`,
options: {
name: 'images',
path: path.join(__dirname, 'content/images'),
name: `images`,
path: path.join(__dirname, `content/images`),
},
},
'gatsby-transformer-sharp',
'gatsby-plugin-sharp',
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: 'gatsby-starter-default',
short_name: 'starter',
start_url: '/',
background_color: '#663399',
theme_color: '#663399',
display: 'minimal-ui',
icon: 'src/images/gatsby-icon.png', // This path is relative to the root of the site.
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
],
Expand Down
8 changes: 4 additions & 4 deletions e2e-tests/path-prefix/cypress/integration/navigate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ const { pathPrefix } = require(`../../gatsby-config`)

const withTrailingSlash = url => `${url}/`

describe('navigate', () => {
describe(`navigate`, () => {
beforeEach(() => {
cy.visit(`/`).waitForAPI(`onRouteUpdate`)
})

it(`uses pathPrefix`, () => {
cy.getTestElement('page-2-button-link')
cy.getTestElement(`page-2-button-link`)
.click()
.location(`pathname`)
.should(`eq`, withTrailingSlash(`${pathPrefix}/page-2`))
})

it(`can navigate back after using`, () => {
cy.getTestElement('page-2-button-link')
cy.getTestElement(`page-2-button-link`)
.click()
.getTestElement('index-link')
.getTestElement(`index-link`)
.click()
.location(`pathname`)
.should(`eq`, withTrailingSlash(pathPrefix))
Expand Down
20 changes: 10 additions & 10 deletions e2e-tests/path-prefix/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
module.exports = {
pathPrefix: '/blog',
pathPrefix: `/blog`,
siteMetadata: {
title: 'Gatsby Default Starter',
title: `Gatsby Default Starter`,
},
plugins: [
'gatsby-plugin-react-helmet',
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: 'gatsby-starter-default',
short_name: 'starter',
start_url: '/',
background_color: '#663399',
theme_color: '#663399',
display: 'minimal-ui',
icon: 'src/images/gatsby-icon.png', // This path is relative to the root of the site.
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
],
Expand Down
18 changes: 9 additions & 9 deletions e2e-tests/production-runtime/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module.exports = {
siteMetadata: {
title: 'Gatsby Default Starter',
title: `Gatsby Default Starter`,
},
plugins: [
'gatsby-plugin-react-helmet',
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: 'gatsby-starter-default',
short_name: 'starter',
start_url: '/',
background_color: '#663399',
theme_color: '#663399',
display: 'minimal-ui',
icon: 'src/images/gatsby-icon.png', // This path is relative to the root of the site.
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
],
Expand Down
18 changes: 11 additions & 7 deletions examples/gatsbygram/scrape.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const bar = new ProgressBar(
mkdirp.sync(`./data/images`)

let posts = []
let userId
let userId

// Write json
const saveJSON = _ =>
Expand All @@ -45,16 +45,17 @@ const getPosts = maxId => {
let url = `https://www.instagram.com/${username}/?__a=1`
let url2 = `https://www.instagram.com/graphql/query/?query_hash=472f257a40c653c64c666ce877d59d2b`

if (maxId) url = url2 + `&variables={"id":"${userId}","first":12,"after":"${maxId}"}`
if (maxId)
url = url2 + `&variables={"id":"${userId}","first":12,"after":"${maxId}"}`

request(url, { encoding: `utf8` }, (err, res, body) => {
if (err) console.log(`error: ${err}`)
if (maxId) {
body = JSON.parse(body).data
body = JSON.parse(body).data
} else {
//This is the first request, lets get the userId
body = JSON.parse(body).graphql
userId = body.user.id
//This is the first request, lets get the userId
body = JSON.parse(body).graphql
userId = body.user.id
}
body.user.edge_owner_to_timeline_media.edges
.filter(({ node: item }) => item[`__typename`] === `GraphImage`)
Expand Down Expand Up @@ -85,7 +86,10 @@ const getPosts = maxId => {
posts.push(item)
})

const lastId = get(body, `user.edge_owner_to_timeline_media.page_info.end_cursor`)
const lastId = get(
body,
`user.edge_owner_to_timeline_media.page_info.end_cursor`
)
if (posts.length < 100 && lastId) getPosts(lastId)
else saveJSON()
})
Expand Down
14 changes: 7 additions & 7 deletions examples/gatsbygram/utils/download-file.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
var fs = require("fs")
var request = require("request")
var fs = require(`fs`)
var request = require(`request`)

module.exports = function(url, dest, cb) {
var file = fs.createWriteStream(dest)
var sendReq = request.get(url)

// verify response code
sendReq.on("response", function(response) {
sendReq.on(`response`, function(response) {
if (response.statusCode !== 200) {
return cb("Response status was " + response.statusCode)
return cb(`Response status was ` + response.statusCode)
}
})

// check for request errors
sendReq.on("error", function(err) {
sendReq.on(`error`, function(err) {
fs.unlink(dest)

if (cb) {
Expand All @@ -23,11 +23,11 @@ module.exports = function(url, dest, cb) {

sendReq.pipe(file)

file.on("finish", function() {
file.on(`finish`, function() {
file.close(cb) // close() is async, call cb after close completes.
})

file.on("error", function(err) {
file.on(`error`, function(err) {
// Handle errors
fs.unlink(dest)

Expand Down
3 changes: 2 additions & 1 deletion examples/using-emotion/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const IndexPage = () => (
</Helmet>
<Wrapper>
<h1 className={title}>
Hello World, this is my first component styled with{" "}
Hello World, this is my first component styled with
{` `}
<a href="https://emotion.sh/">emotion</a>!
</h1>
<p className={subtitle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default ({ data }) => {
return (
<div>
<h1>{blogPost.title}</h1>
<div>Posted at: {dateformat(blogPost.createdAt, "fullDate")}</div>
<div>Posted at: {dateformat(blogPost.createdAt, `fullDate`)}</div>
<ReactMarkdown source={blogPost.post} />
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion examples/using-gatsby-source-graphql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default ({ data }) => (
{data.cms.blogPosts.map((blog, i) => (
<a key={i} href={makeBlogPath(blog)}>
<h2>
{dateformat(blog.createdAt, "fullDate")} - {blog.title}
{dateformat(blog.createdAt, `fullDate`)} - {blog.title}
</h2>
</a>
))}
Expand Down
2 changes: 1 addition & 1 deletion examples/using-gatsby-source-graphql/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default ({ data }) => (
{data.cms.blogPosts.map((blog, i) => (
<a key={i} href={makeBlogPath(blog)}>
<h2>
{dateformat(blog.createdAt, "fullDate")} - {blog.title}
{dateformat(blog.createdAt, `fullDate`)} - {blog.title}
</h2>
</a>
))}
Expand Down
2 changes: 1 addition & 1 deletion examples/using-jest/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = 'test-file-stub'
module.exports = `test-file-stub`
6 changes: 3 additions & 3 deletions examples/using-jest/__mocks__/gatsby.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const React = require('react')
const gatsby = jest.requireActual('gatsby')
const React = require(`react`)
const gatsby = jest.requireActual(`gatsby`)

module.exports = {
...gatsby,
graphql: jest.fn(),
Link: jest.fn().mockImplementation(({ to, ...rest }) =>
React.createElement('a', {
React.createElement(`a`, {
...rest,
href: to,
})
Expand Down
24 changes: 12 additions & 12 deletions examples/using-jest/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
module.exports = {
siteMetadata: {
title: 'Gatsby Default Starter',
title: `Gatsby Default Starter`,
},
plugins: [
'gatsby-plugin-react-helmet',
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
'gatsby-transformer-sharp',
'gatsby-plugin-sharp',
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: 'gatsby-starter-default',
short_name: 'starter',
start_url: '/',
background_color: '#663399',
theme_color: '#663399',
display: 'minimal-ui',
icon: 'src/images/gatsby-icon.png', // This path is relative to the root of the site.
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
'gatsby-plugin-offline',
`gatsby-plugin-offline`,
],
}
4 changes: 2 additions & 2 deletions examples/using-jest/jest-preprocess.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const babelOptions = {
presets: ['babel-preset-gatsby'],
presets: [`babel-preset-gatsby`],
}

module.exports = require('babel-jest').createTransformer(babelOptions)
module.exports = require(`babel-jest`).createTransformer(babelOptions)
Loading