Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Merge pull request #605 from amclin/dependabot/npm_and_yarn/eslint-co…
Browse files Browse the repository at this point in the history
…nfig-prettier-7.2.0

refactor(deps-dev): bump eslint-config-prettier from 6.13.0 to 7.2.0
  • Loading branch information
amclin authored Jan 28, 2021
2 parents b89467a + 94a0dc9 commit 4941aeb
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 148 deletions.
4 changes: 1 addition & 3 deletions helpers/copy-template-files.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const cpy = require('cpy')
const path = require('path')

const copyTemplateFiles = (root, dir) => {
return cpy(['**', '.dependabot/**'], root, {
const copyTemplateFiles = (root, dir) => cpy(['**', '.dependabot/**'], root, {
parents: true,
cwd: path.join(__dirname, '..', 'templates', dir),
rename: name => {
Expand All @@ -19,7 +18,6 @@ const copyTemplateFiles = (root, dir) => {
return name
}
})
}

module.exports = {
copyTemplateFiles
Expand Down
4 changes: 1 addition & 3 deletions helpers/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ const hasExample = async name => {
return res.statusCode === 200
}

const downloadAndExtractExample = async (root, name) => {
return promisePipe(
const downloadAndExtractExample = async (root, name) => promisePipe(
got.stream('https://codeload.github.com/zeit/next.js/tar.gz/canary'),
tar.extract({ cwd: root, strip: 3 }, [`next.js-canary/examples/${name}`])
)
}

module.exports = {
hasExample,
Expand Down
8 changes: 2 additions & 6 deletions helpers/init-git.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const canUseGit = () => {
}
}

const initGit = (root, { gitRemote }) => {
return new Promise((resolve, reject) => {
const initGit = (root, { gitRemote }) => new Promise((resolve, reject) => {
if (canUseGit()) {
try {
execSync('git init')
Expand All @@ -27,10 +26,8 @@ const initGit = (root, { gitRemote }) => {
reject(new Error('No git binary found'))
}
})
}

const commitFirst = ({ version }) => {
return new Promise((resolve, reject) => {
const commitFirst = ({ version }) => new Promise((resolve, reject) => {
if (canUseGit()) {
try {
// Add all files
Expand All @@ -53,7 +50,6 @@ const commitFirst = ({ version }) => {
reject(new Error('No git binary found'))
}
})
}

module.exports = {
canUseGit,
Expand Down
4 changes: 1 addition & 3 deletions helpers/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ const install = ({
useYarn,
isOnline,
devDependencies = false
}) => {
return new Promise((resolve, reject) => {
}) => new Promise((resolve, reject) => {
const buildCommand = (useYarn) ? buildYarnCommand : buildNpmCommand
const {command, args} = buildCommand({dependencies, devDependencies, isOnline, root})

Expand All @@ -67,7 +66,6 @@ const install = ({
resolve()
})
})
}

module.exports = {
install
Expand Down
48 changes: 16 additions & 32 deletions helpers/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,24 @@ describe('install', () => {
dependencies,
useYarn: false,
}
it('can install a list of primary dependencies', () => {
return install(defaults).then(() => {
it('can install a list of primary dependencies', () => install(defaults).then(() => {
expect(spawn).toBeCalledWith(
'npm',
['install', '--save', '--loglevel', 'error', ...dependencies],
expect.objectContaining({ stdio: "inherit" }))
})
})
it('can install a list of devDependencies', () => {
return install({ ...defaults, devDependencies: true }).then(() => {
}))
it('can install a list of devDependencies', () => install({ ...defaults, devDependencies: true }).then(() => {
expect(spawn).toBeCalledWith(
'npm',
['install', '--save-dev', '--loglevel', 'error', ...dependencies],
expect.objectContaining({ stdio: "inherit" }))
})
})
it('can run project install command', () => {
return install({ ...defaults, dependencies: undefined }).then(() => {
}))
it('can run project install command', () => install({ ...defaults, dependencies: undefined }).then(() => {
expect(spawn).toBeCalledWith(
'npm',
['install', '--loglevel', 'error'],
expect.objectContaining({ stdio: "inherit" }))
})
})
}))
})
describe('yarn environment', () => {
const defaults = {
Expand All @@ -50,41 +44,32 @@ describe('install', () => {
isOnline: true
}
const root = 'mockRoot'
it('can install a list of primary dependencies', () => {
return install(defaults).then(() => {
it('can install a list of primary dependencies', () => install(defaults).then(() => {
expect(spawn).toBeCalledWith(
'yarn',
['add', ...dependencies, '--cwd', root],
expect.objectContaining({ stdio: "inherit" }))
})
})
it('can install a list of devDependencies', () => {
return install({ ...defaults, devDependencies: true }).then(() => {
}))
it('can install a list of devDependencies', () => install({ ...defaults, devDependencies: true }).then(() => {
expect(spawn).toBeCalledWith(
'yarn',
['add', '--dev', ...dependencies, '--cwd', root],
expect.objectContaining({ stdio: "inherit" }))
})
})
it('can run project install command', () => {
return install({ ...defaults, dependencies: undefined }).then(() => {
}))
it('can run project install command', () => install({ ...defaults, dependencies: undefined }).then(() => {
expect(spawn).toBeCalledWith(
'yarn',
['install', '--cwd', root],
expect.objectContaining({ stdio: "inherit" }))
})
})
it('can specify that Yarn runs in offline mode', () => {
return install({ ...defaults, dependencies: undefined, isOnline: false }).then(() => {
}))
it('can specify that Yarn runs in offline mode', () => install({ ...defaults, dependencies: undefined, isOnline: false }).then(() => {
expect(spawn).toBeCalledWith(
'yarn',
['install', '--offline', '--cwd', root],
expect.objectContaining({ stdio: "inherit" }))
})
})
}))
})
it('handles errors in the spawned process by rejecting a promise', () => {
return new Promise((resolveTest, rejectTest) => {
it('handles errors in the spawned process by rejecting a promise', () => new Promise((resolveTest, rejectTest) => {
// Mock the spawned process failing
spawn.mockReturnValueOnce({
on: jest.fn((event, callback) => {
Expand All @@ -102,7 +87,6 @@ describe('install', () => {
expect('Process Failed').toEqual('Process Failed')
resolveTest()
})
})
})
}))
})
})
8 changes: 2 additions & 6 deletions helpers/is-online.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const getProxy = () => {
}
}

const getOnline = () => {
return new Promise(resolve => {
return dns.lookup('registry.yarnpkg.com', registryErr => {
const getOnline = () => new Promise(resolve => dns.lookup('registry.yarnpkg.com', registryErr => {
if (!registryErr) {
return resolve(true)
}
Expand All @@ -37,9 +35,7 @@ const getOnline = () => {
return dns.lookup(hostname, proxyErr => {
resolve(proxyErr == null)
})
})
})
}
}))

module.exports = {
getOnline,
Expand Down
21 changes: 5 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dotenv": "^8.2.0",
"eslint": "^7.3.1",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.3.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.17.0",
Expand Down
16 changes: 7 additions & 9 deletions templates/default/src/components/atoms/HeadLink/HeadLink.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React from 'react'
import PropTypes from 'prop-types'

const HeadLink = ({rel, href, type, sizes}) => {
return(
<link
rel={rel}
type={type}
sizes={sizes}
href={href}
/>
const HeadLink = ({rel, href, type, sizes}) => (
<link
rel={rel}
type={type}
sizes={sizes}
href={href}
/>
)
}

HeadLink.propTypes = {
rel: PropTypes.string.isRequired,
Expand Down
44 changes: 21 additions & 23 deletions templates/default/src/components/molecules/Favicon/Favicon.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import React from 'react'
import HeadLink from '../../atoms/HeadLink'

const Favicon = () => {
return(
<>
<HeadLink
rel="apple-touch-icon"
type="image/png"
sizes="180x180"
href="/static/apple-touch-icon.png"
/>
<HeadLink
rel="icon"
type="image/png"
sizes="32x32"
href="/static/favicon-32x32.png"
/>
<HeadLink
rel="icon"
type="image/png"
sizes="16x16"
href="/static/favicon-16x16.png"
/>
</>
const Favicon = () => (
<>
<HeadLink
rel="apple-touch-icon"
type="image/png"
sizes="180x180"
href="/static/apple-touch-icon.png"
/>
<HeadLink
rel="icon"
type="image/png"
sizes="32x32"
href="/static/favicon-32x32.png"
/>
<HeadLink
rel="icon"
type="image/png"
sizes="16x16"
href="/static/favicon-16x16.png"
/>
</>
)
}

export default Favicon
12 changes: 5 additions & 7 deletions templates/default/src/components/molecules/Manifest/Manifest.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React from 'react'
import HeadLink from '../../atoms/HeadLink'

const Manifest = () => {
return(
<HeadLink
rel="manifest"
href="/site.webmanifest"
/>
const Manifest = () => (
<HeadLink
rel="manifest"
href="/site.webmanifest"
/>
)
}

export default Manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import React from 'react'
import PropTypes from 'prop-types'
import Head from 'next/head'

const PageTitle = ({ title }) => {
return (
<Head>
<title data-testid="title" key="title">
{title}
</title>
</Head>
const PageTitle = ({ title }) => (
<Head>
<title data-testid="title" key="title">
{title}
</title>
</Head>
)
}

PageTitle.propTypes = {
title: PropTypes.string.isRequired
Expand Down
30 changes: 14 additions & 16 deletions templates/default/src/pages/example/second-page/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@ import React from 'react'
import Link from 'next/link'
import PageTitle from '../../../components/organisms/PageTitle'

const SecondPage = () => {
return (
<div className="text-center">
<PageTitle title="Second Page - %%APPNAME%%" />
<main>
<p>This is another page at a different URL.</p>
<p>
Return to the&nbsp;
<Link href="/">homepage</Link>
</p>
</main>
<style jsx global>
{`
const SecondPage = () => (
<div className="text-center">
<PageTitle title="Second Page - %%APPNAME%%" />
<main>
<p>This is another page at a different URL.</p>
<p>
Return to the&nbsp;
<Link href="/">homepage</Link>
</p>
</main>
<style jsx global>
{`
.text-center {
text-align: center;
}
`}
</style>
</div>
</style>
</div>
)
}

export default SecondPage
Loading

0 comments on commit 4941aeb

Please sign in to comment.