1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Upgrade standard.js (#4064)

* Upgrade standard.js

# Conflicts:
#	yarn.lock

* Upgrade babel-eslint
This commit is contained in:
Tim Neutkens 2018-03-27 20:11:03 +02:00 committed by GitHub
parent 603b90ce02
commit ebf0c47c25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 1667 additions and 947 deletions

View file

@ -43,7 +43,7 @@ if (!existsSync(join(dir, 'pages'))) {
}
build(dir)
.catch((err) => {
.catch((err) => {
console.error(err)
process.exit(1)
})
})

View file

@ -54,12 +54,12 @@ if (!existsSync(join(dir, 'pages'))) {
const srv = new Server({ dir, dev: true })
srv.start(argv.port, argv.hostname)
.then(async () => {
.then(async () => {
if (!process.env.NOW) {
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
}
})
.catch((err) => {
})
.catch((err) => {
if (err.code === 'EADDRINUSE') {
let errorMessage = `Port ${argv.port} is already in use.`
const pkgAppPath = require('find-up').sync('package.json', {
@ -73,4 +73,4 @@ srv.start(argv.port, argv.hostname)
console.error(err)
}
process.nextTick(() => process.exit(1))
})
})

View file

@ -46,12 +46,12 @@ const dir = resolve(argv._[0] || '.')
const srv = new Server({ dir })
srv.start(argv.port, argv.hostname)
.then(() => {
.then(() => {
if (!process.env.NOW) {
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
}
})
.catch((err) => {
})
.catch((err) => {
console.error(err)
process.exit(1)
})
})

View file

@ -8,7 +8,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
@ -18,4 +18,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -7,7 +7,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
const server = express()
server.get('/a', (req, res) => {
@ -30,4 +30,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -7,7 +7,7 @@ const app = Next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
const server = fastify()
server.get('/a', (req, res) => {
@ -26,4 +26,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -10,8 +10,8 @@ const server = new Hapi.Server({
})
app
.prepare()
.then(async () => {
.prepare()
.then(async () => {
server.route({
method: 'GET',
path: '/a',
@ -43,4 +43,4 @@ app
console.log('Error starting server')
console.log(error)
}
})
})

View file

@ -8,7 +8,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
const server = new Koa()
const router = new Router()
@ -36,4 +36,4 @@ app.prepare()
server.listen(port, () => {
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -8,7 +8,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const { pathname, query } = parsedUrl
@ -25,4 +25,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -8,7 +8,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const { pathname, query } = parsedUrl
@ -25,4 +25,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -6,7 +6,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
const server = express()
server.get('/', (req, res) => {
@ -21,8 +21,8 @@ app.prepare()
if (err) throw err
console.log('> Ready on http://localhost:3000')
})
})
.catch((ex) => {
})
.catch((ex) => {
console.error(ex.stack)
process.exit(1)
})
})

View file

@ -11,7 +11,7 @@ const route = pathMatch()
const match = route('/blog/:id')
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const { pathname, query } = parse(req.url, true)
const params = match(pathname)
@ -28,4 +28,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -9,7 +9,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const rootStaticFiles = [
@ -28,4 +28,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -14,7 +14,7 @@ const ssrCache = new LRUCache({
})
app.prepare()
.then(() => {
.then(() => {
const server = express()
// Use the `renderAndCache` utility defined below to serve pages
@ -35,7 +35,7 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})
/*
* NB: make sure to modify this to take into account anything that should trigger

View file

@ -18,7 +18,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
@ -27,4 +27,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -17,7 +17,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
@ -26,4 +26,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -11,7 +11,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
@ -20,4 +20,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -1,3 +1,4 @@
/* eslint-disable */
const withCss = require('@zeit/next-css')
// fix: prevents error when .css files are required by node

View file

@ -10,7 +10,7 @@ export default connect({
mounted: signal`clock.mounted`,
unMounted: signal`clock.unMounted`
},
class Page extends React.Component {
class Page extends React.Component {
componentDidMount () {
this.props.mounted()
}
@ -29,5 +29,5 @@ export default connect({
</div>
)
}
}
}
)

View file

@ -5,7 +5,7 @@ import {
RichUtils,
convertToRaw,
convertFromRaw
} from 'draft-js'
} from 'draft-js'
export default class App extends React.Component {
constructor (props) {

View file

@ -16,7 +16,7 @@ const firebase = admin.initializeApp({
}, 'server')
app.prepare()
.then(() => {
.then(() => {
const server = express()
server.use(bodyParser.json())
@ -61,4 +61,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -8,10 +8,10 @@ const app = next({ dev })
const handler = routes.getRequestHandler(app)
app.prepare()
.then(() => {
.then(() => {
createServer(handler)
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -8,10 +8,10 @@ const app = next({ dev })
const handler = routes.getRequestHandler(app)
app.prepare()
.then(() => {
.then(() => {
createServer(handler)
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -8,10 +8,10 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => handle(req, res, parse(req.url, true).pathname))
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -1,13 +1,11 @@
/* eslint no-extend-native: 0 */
// Add your polyfills
// This files runs at the very beginning (even before React and Next.js core)
console.log('Load your polyfills')
// core-js comes with Next.js. So, you can import it like below
import includes from 'core-js/library/fn/string/virtual/includes'
import repeat from 'core-js/library/fn/string/virtual/repeat'
// Add your polyfills
// This files runs at the very beginning (even before React and Next.js core)
console.log('Load your polyfills')
String.prototype.includes = includes
String.prototype.repeat = repeat

View file

@ -8,7 +8,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
const server = express()
Router.forEachPattern((page, pattern, defaultParams) => server.get(pattern, (req, res) =>
@ -17,4 +17,4 @@ app.prepare()
server.get('*', (req, res) => handle(req, res))
server.listen(port)
})
})

View file

@ -39,5 +39,5 @@ export default connect(
character: state.character,
error: state.error,
isFetchedOnServer: state.isFetchedOnServer
}),
})
)(CharacterInfo)

View file

@ -46,5 +46,5 @@ export default withRedux(
{
startFetchingCharacters: actions.startFetchingCharacters,
stopFetchingCharacters: actions.stopFetchingCharacters
},
}
)(Counter)

View file

@ -15,7 +15,7 @@ module.exports = {
query: { id: post.id }
}
}),
{},
{}
)
// combine the map of post pages with the home

View file

@ -7,7 +7,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
const server = express()
// custom route for posts
@ -25,4 +25,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -9,7 +9,7 @@ const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const { pathname } = parsedUrl
@ -25,4 +25,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -11,7 +11,7 @@ const route = pathMatch()
const match = route('/about/:name')
app.prepare()
.then(() => {
.then(() => {
createServer((req, res) => {
const { pathname } = parse(req.url)
const params = match(pathname)
@ -26,4 +26,4 @@ app.prepare()
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
})

View file

@ -15,7 +15,7 @@ export default class EventEmitter {
emit (event, ...data) {
if (!this.listeners[event]) return
this.listeners[event].forEach(cb => cb(...data))
this.listeners[event].forEach(cb => cb(...data)) // eslint-disable-line standard/no-callback-literal
}
off (event, cb) {

View file

@ -355,7 +355,7 @@ export default class Router {
}
async fetchRoute (route) {
return await this.pageLoader.loadPage(route)
return this.pageLoader.loadPage(route)
}
abortComponentLoad (as) {

View file

@ -113,7 +113,7 @@
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
"@zeit/next-css": "0.0.7",
"babel-eslint": "8.0.1",
"babel-eslint": "8.2.2",
"babel-jest": "21.2.0",
"babel-plugin-istanbul": "4.1.5",
"babel-plugin-transform-remove-strict-mode": "0.0.2",
@ -139,7 +139,7 @@
"react": "16.2.0",
"react-dom": "16.2.0",
"rimraf": "2.6.2",
"standard": "9.0.2",
"standard": "11.0.1",
"taskr": "1.1.0",
"wd": "1.4.1"
},

View file

@ -1,3 +1,4 @@
/* eslint-disable import/first, no-return-await */
require('@zeit/source-map-support').install()
import { resolve, join, sep } from 'path'
import { parse as parseUrl } from 'url'

View file

@ -2,7 +2,7 @@ import React from 'react'
export default class AsyncProps extends React.Component {
static async getInitialProps () {
return await fetchData()
return fetchData()
}
render () {

View file

@ -29,7 +29,7 @@ export default (context, render) => {
browser.close()
})
it('should not show the default HMR error overlay', async() => {
it('should not show the default HMR error overlay', async () => {
const browser = await webdriver(context.appPort, '/hmr/about')
const text = await browser
.elementByCss('p').text()

View file

@ -70,7 +70,7 @@ describe('Custom Server', () => {
expect($dynamic('img').attr('src')).toBe(`http://127.0.0.1:${context.appPort}/static/myimage.png`)
})
it('should support next/asset in client side', async() => {
it('should support next/asset in client side', async () => {
const browser = await webdriver(context.appPort, '/')
await browser
.elementByCss('#go-asset').click()

View file

@ -18,27 +18,27 @@ export default function (context) {
expect(filePathLink).toEqual('/file-name.md')
})
it('should render a page with getInitialProps', async() => {
it('should render a page with getInitialProps', async () => {
const html = await renderViaHTTP(context.port, '/dynamic')
expect(html).toMatch(/cool dynamic text/)
})
it('should render a dynamically rendered custom url page', async() => {
it('should render a dynamically rendered custom url page', async () => {
const html = await renderViaHTTP(context.port, '/dynamic/one')
expect(html).toMatch(/next export is nice/)
})
it('should render pages with dynamic imports', async() => {
it('should render pages with dynamic imports', async () => {
const html = await renderViaHTTP(context.port, '/dynamic-imports')
expect(html).toMatch(/Welcome to dynamic imports/)
})
it('should render paths with extensions', async() => {
it('should render paths with extensions', async () => {
const html = await renderViaHTTP(context.port, '/file-name.md')
expect(html).toMatch(/this file has an extension/)
})
it('should give empty object for query if there is no query', async() => {
it('should give empty object for query if there is no query', async () => {
const html = await renderViaHTTP(context.port, '/get-initial-props-with-no-query')
expect(html).toMatch(/Query is: {}/)
})

1568
yarn.lock

File diff suppressed because it is too large Load diff