Skip to content

Commit

Permalink
Fix linting for new version of Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthachatterjee committed Nov 10, 2019
1 parent 7d4c28d commit 7447d10
Show file tree
Hide file tree
Showing 31 changed files with 147 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,27 +397,29 @@ Let's remedy that. Import the `Link` component and swap it for the simple
`<a>` tag that was in there before:

```jsx
import React from 'react';
import { Link } from 'gatsby';
import React from "react"
import { Link } from "gatsby"

export default class BlogIndex extends React.Component {
render() {
// Handle graphql errors
if (this.props.errors && this.props.errors.length) {
this.props.errors.forEach(({ message }) => {
console.error(`BlogIndex render errr: ${message}`);
});
return <h1>Errors found: Check the console for details</h1>;
console.error(`BlogIndex render errr: ${message}`)
})
return <h1>Errors found: Check the console for details</h1>
}

return (
<div>
<h2>Some things I wrote</h2>
{this.props.data.allMarkdownRemark.edges.map(({ node }, i) => (
<Link to={/* ??? */} key={i}>{node.frontmatter.title}</Link>
<Link to={/* ??? */} key={i}>
{node.frontmatter.title}
</Link>
))}
</div>
);
)
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/blog/2018-11-07-gatsby-for-apps/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ class Messages extends React.Component {

// note: this is a simplified example without error handling, authentication, etc.
async componentDidMount() {
const messages = await fetch(`/api/some-url-to-get-messages`).then(
response => response.json()
)
const messages = await fetch(
`/api/some-url-to-get-messages`
).then(response => response.json())

this.setState({
messages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,25 @@ I highly recommend using the breakpoint syntax and reading the [documentation](h
So far, so normal you'd say. But I had a cool idea to solve my problem of positioning shapes around my theme entries which I collect in a `.yaml` file (see the [source file](https://github.com/LekoArts/gatsby-themes/blob/master/www/data/themes.yaml)). Just define the shapes in the respective theme entry! YAML is a great format for that as it makes it possible (together with the Gatsby transformer) to create arrays and array of objects. The shapes entry looks like this:

```yaml
shapes: [
{
type: "circle",
color: "green",
size: ["200px", "300px"],
xOffset: ["-140px", "-120px"],
yOffset: ["-70px"],
opacity: 0.5,
},
{
type: "donut",
color: "teal",
size: ["25px", "100px"],
xOffset: ["50px"],
yOffset: ["-60px"],
opacity: 1,
},
]
shapes:
[
{
type: "circle",
color: "green",
size: ["200px", "300px"],
xOffset: ["-140px", "-120px"],
yOffset: ["-70px"],
opacity: 0.5,
},
{
type: "donut",
color: "teal",
size: ["25px", "100px"],
xOffset: ["50px"],
yOffset: ["-60px"],
opacity: 1,
},
]
```

These are all the information that my shape components need to render the desired output. I didn't use _left_ and _right_ here as the shapes should always face the outside (on the inside it could overlap the text). As you can see the array / breakpoint notation for position and size was used — I think that's just cool 😎
Expand Down
7 changes: 2 additions & 5 deletions docs/docs/add-seo-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ Now define the query and place it in the StaticQuery (you can also save the quer

```jsx:title=src/components/SEO.js
const SEO = ({ title, description, image, pathname, article }) => (
<StaticQuery
query={query}
render={}
/>
<StaticQuery query={query} render={} />
)

export default SEO
Expand All @@ -84,7 +81,7 @@ const query = graphql`
}
}
}
`;
`
```

The next step is to destructure the data from the query and to create an object that checks if the props were used — if not the default values are utilized. The name aliasing comes in handy here: It avoids name collisions.
Expand Down
2 changes: 0 additions & 2 deletions docs/docs/mdx/writing-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ author: Jay Gatsby
---

<h1>{props.pageContext.frontmatter.title}</h1>

<span>{props.pageContext.frontmatter.author}</span>

(Blog post content, components, etc.)
Expand All @@ -80,7 +79,6 @@ import FAQ from "../components/faq.mdx"
The chart is rendered inside our MDX document.

<Chart />

<FAQ />
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ describe(`focus management`, () => {
})

it(`Focus router wrapper after navigation from 404`, () => {
cy.visit(`/broken-path`, { failOnStatusCode: false }).waitForAPIorTimeout(
`onRouteUpdate`,
{ timeout: 5000 }
)
cy.visit(`/broken-path`, {
failOnStatusCode: false,
}).waitForAPIorTimeout(`onRouteUpdate`, { timeout: 5000 })

cy.changeFocus()
cy.assertRouterWrapperFocus(false)
Expand All @@ -39,10 +38,9 @@ describe(`focus management`, () => {
})

it(`Focus router wrapper after navigation from one 404 path to another 404 path`, () => {
cy.visit(`/broken-path`, { failOnStatusCode: false }).waitForAPIorTimeout(
`onRouteUpdate`,
{ timeout: 5000 }
)
cy.visit(`/broken-path`, {
failOnStatusCode: false,
}).waitForAPIorTimeout(`onRouteUpdate`, { timeout: 5000 })

// navigating to different not existing page should also trigger
// router wrapper focus as this is different page
Expand Down
5 changes: 1 addition & 4 deletions examples/using-redux/src/components/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ const mapDispatchToProps = dispatch => {
return { increment: () => dispatch({ type: `INCREMENT` }) }
}

const ConnectedCounter = connect(
mapStateToProps,
mapDispatchToProps
)(Counter)
const ConnectedCounter = connect(mapStateToProps, mapDispatchToProps)(Counter)

class DefaultLayout extends React.Component {
render() {
Expand Down
24 changes: 13 additions & 11 deletions integration-tests/long-term-caching/__tests__/long-term-caching.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ const getDirFilesWalk = async dir => {
const dirFiles = await readdir(dir)

const additionalFiles = [].concat(
...(await Promise.all(
dirFiles.map(async file => {
const filePath = `${dir}/${file}`
const fileStat = await stat(filePath)

if (fileStat.isDirectory()) {
return await getDirFilesWalk(filePath)
}
return undefined
})
)).filter(Boolean)
...(
await Promise.all(
dirFiles.map(async file => {
const filePath = `${dir}/${file}`
const fileStat = await stat(filePath)

if (fileStat.isDirectory()) {
return await getDirFilesWalk(filePath)
}
return undefined
})
)
).filter(Boolean)
)

return [...dirFiles, ...additionalFiles]
Expand Down
10 changes: 7 additions & 3 deletions packages/gatsby-cli/src/init-starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,13 @@ const clone = async (hostInfo: any, rootPath: string) => {

report.info(`Creating new site from git: ${url}`)

const args = [`clone`, ...branch, url, rootPath, `--single-branch`].filter(
arg => Boolean(arg)
)
const args = [
`clone`,
...branch,
url,
rootPath,
`--single-branch`,
].filter(arg => Boolean(arg))

await spawnWithArgs(`git`, args)

Expand Down
8 changes: 5 additions & 3 deletions packages/gatsby-source-npm-package-search/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ exports.sourceNodes = async (

if (!hit.readme) {
try {
hit.readme = (await got.get(
url.resolve(`https://unpkg.com/`, `/${hit.objectID}/README.md`)
)).body
hit.readme = (
await got.get(
url.resolve(`https://unpkg.com/`, `/${hit.objectID}/README.md`)
)
).body
} catch (err) {
// carry-on
}
Expand Down
5 changes: 1 addition & 4 deletions packages/gatsby-source-shopify/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ const createShopPolicies = async ({
Object.entries(policies)
.filter(([_, policy]) => Boolean(policy))
.forEach(
pipe(
([type, policy]) => ShopPolicyNode(policy, { type }),
createNode
)
pipe(([type, policy]) => ShopPolicyNode(policy, { type }), createNode)
)
if (verbose) console.timeEnd(msg)
}
Expand Down
5 changes: 4 additions & 1 deletion packages/gatsby-source-wordpress/src/__tests__/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ describe(`Process WordPress data`, () => {
})

it(`Removes the acf key when acf is not an object`, () => {
let dummyEntities = [{ id: 1, acf: false }, { id: 2, acf: {} }]
let dummyEntities = [
{ id: 1, acf: false },
{ id: 2, acf: {} },
]
expect(normalize.normalizeACF(dummyEntities)).toEqual([
{ id: 1 },
{ id: 2, acf: {} },
Expand Down
18 changes: 11 additions & 7 deletions packages/gatsby-source-wordpress/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ exports.normalizeACF = normalizeACF
exports.combineACF = function(entities) {
let acfOptionData = {}
// Map each ACF Options object keys/data to single object
_.forEach(entities.filter(e => e.__type === `wordpress__acf_options`), e => {
if (e[`acf`]) {
acfOptionData[e.__acfOptionPageId || `options`] = {}
Object.keys(e[`acf`]).map(
k => (acfOptionData[e.__acfOptionPageId || `options`][k] = e[`acf`][k])
)
_.forEach(
entities.filter(e => e.__type === `wordpress__acf_options`),
e => {
if (e[`acf`]) {
acfOptionData[e.__acfOptionPageId || `options`] = {}
Object.keys(e[`acf`]).map(
k =>
(acfOptionData[e.__acfOptionPageId || `options`][k] = e[`acf`][k])
)
}
}
})
)

// Remove previous ACF Options objects (if any)
_.pullAll(
Expand Down
5 changes: 4 additions & 1 deletion packages/gatsby-transformer-csv/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ describe(`Process nodes correctly`, () => {

it(`correctly creates nodes from JSON which is an array of objects`, async () => {
const fields = [`blue`, `funny`]
const data = [{ blue: true, funny: `yup` }, { blue: false, funny: `nope` }]
const data = [
{ blue: true, funny: `yup` },
{ blue: false, funny: `nope` },
]
const csv = json2csv({ data: data, fields: fields })
node.content = csv

Expand Down
18 changes: 15 additions & 3 deletions packages/gatsby-transformer-excel/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ describe(`Process nodes correctly`, () => {
const loadNodeContent = node => Promise.resolve(node.content)

it(`correctly creates nodes from JSON which is an array of objects`, async () => {
const data = [[`blue`, `funny`], [true, `yup`], [false, `nope`]]
const data = [
[`blue`, `funny`],
[true, `yup`],
[false, `nope`],
]
const csv = XLSX.utils.sheet_to_csv(XLSX.utils.aoa_to_sheet(data))
node.content = csv

Expand All @@ -47,7 +51,11 @@ describe(`Process nodes correctly`, () => {
})

it(`should correctly create nodes from JSON with raw option false`, async () => {
const data = [[`red`, `veryfunny`], [true, `certainly`], [false, `nada`]]
const data = [
[`red`, `veryfunny`],
[true, `certainly`],
[false, `nada`],
]
const csv = XLSX.utils.sheet_to_csv(XLSX.utils.aoa_to_sheet(data))
node.content = csv

Expand Down Expand Up @@ -77,7 +85,11 @@ describe(`Process nodes correctly`, () => {
})

it(`should correctly create nodes from JSON with legacy rawOutput option false`, async () => {
const data = [[`red`, `veryfunny`], [true, `certainly`], [false, `nada`]]
const data = [
[`red`, `veryfunny`],
[true, `certainly`],
[false, `nada`],
]
const csv = XLSX.utils.sheet_to_csv(XLSX.utils.aoa_to_sheet(data))
node.content = csv

Expand Down
10 changes: 8 additions & 2 deletions packages/gatsby-transformer-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ It's probably because you have arrays of mixed values somewhere. For instance:
```json
{
"stuff": [25, "bob"],
"orEven": [[25, "bob"], [23, "joe"]]
"orEven": [
[25, "bob"],
[23, "joe"]
]
}
```

Expand All @@ -244,6 +247,9 @@ If you can rewrite your data with objects, you should be good to go:
```json
{
"stuff": [{ "count": 25, "name": "bob" }],
"orEven": [{ "count": 25, "name": "bob" }, { "count": 23, "name": "joe" }]
"orEven": [
{ "count": 25, "name": "bob" },
{ "count": 23, "name": "joe" }
]
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -1104,9 +1104,9 @@ console.log('hello world')
`htmlAst`,
node => {
expect(node).toMatchSnapshot()
expect(node.htmlAst.children[0].children[0].properties.className).toEqual(
[`language-js`]
)
expect(
node.htmlAst.children[0].children[0].properties.className
).toEqual([`language-js`])
expect(node.htmlAst.children[0].children[0].properties.dataMeta).toEqual(
`foo bar`
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ module.exports = class GatsbyThemeComponentShadowingResolverPlugin {
cache = {}

constructor({ projectRoot, themes, extensions }) {
debug(`themes list`, themes.map(({ themeName }) => themeName))
debug(
`themes list`,
themes.map(({ themeName }) => themeName)
)
this.themes = themes
this.projectRoot = projectRoot
this.extensions = extensions
Expand Down
Loading

0 comments on commit 7447d10

Please sign in to comment.