From d4bdb5ed9e2fe06ec44698b66c029f624135a0ab Mon Sep 17 00:00:00 2001 From: dead-horse Date: Wed, 26 Jun 2019 11:15:22 +0800 Subject: [PATCH] chore: update eslint and fix lint errors --- benchmarks/middleware.js | 4 ++-- lib/response.js | 2 +- package.json | 2 +- test/application/respond.js | 38 +++++++++++++++++------------------ test/application/response.js | 2 +- test/application/use.js | 4 ++-- test/context/cookies.js | 8 ++++---- test/context/onerror.js | 4 ++-- test/response/flushHeaders.js | 24 +++++++++++----------- test/response/header.js | 2 +- test/response/status.js | 4 ++-- test/response/writable.js | 8 ++++---- 12 files changed, 51 insertions(+), 51 deletions(-) diff --git a/benchmarks/middleware.js b/benchmarks/middleware.js index 039ccb6..7723396 100644 --- a/benchmarks/middleware.js +++ b/benchmarks/middleware.js @@ -13,7 +13,7 @@ console.log(` ${n}${useAsync ? ' async' : ''} middleware`); while (n--) { if (useAsync) { - app.use(async (ctx, next) => await next()); + app.use(async(ctx, next) => await next()); } else { app.use((ctx, next) => next()); } @@ -22,7 +22,7 @@ while (n--) { const body = Buffer.from('Hello World'); if (useAsync) { - app.use(async (ctx, next) => { await next(); ctx.body = body; }); + app.use(async(ctx, next) => { await next(); ctx.body = body; }); } else { app.use((ctx, next) => next().then(() => ctx.body = body)); } diff --git a/lib/response.js b/lib/response.js index f9b33d5..e5865f2 100644 --- a/lib/response.js +++ b/lib/response.js @@ -48,7 +48,7 @@ module.exports = { const { res } = this; return typeof res.getHeaders === 'function' ? res.getHeaders() - : res._headers || {}; // Node < 7.7 + : res._headers || {}; // Node < 7.7 }, /** diff --git a/package.json b/package.json index 9317949..a9db1e2 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "vary": "^1.1.2" }, "devDependencies": { - "eslint": "^3.17.1", + "eslint": "^6.0.1", "eslint-config-koa": "^2.0.0", "eslint-config-standard": "^7.0.1", "eslint-plugin-promise": "^3.5.0", diff --git a/test/application/respond.js b/test/application/respond.js index 3bc6a74..2834649 100644 --- a/test/application/respond.js +++ b/test/application/respond.js @@ -87,7 +87,7 @@ describe('app.respond', () => { }); describe('when this.type === null', () => { - it('should not send Content-Type header', async () => { + it('should not send Content-Type header', async() => { const app = new Koa(); app.use(ctx => { @@ -106,7 +106,7 @@ describe('app.respond', () => { }); describe('when HEAD is used', () => { - it('should not respond with the body', async () => { + it('should not respond with the body', async() => { const app = new Koa(); app.use(ctx => { @@ -124,7 +124,7 @@ describe('app.respond', () => { assert(!res.text); }); - it('should keep json headers', async () => { + it('should keep json headers', async() => { const app = new Koa(); app.use(ctx => { @@ -142,7 +142,7 @@ describe('app.respond', () => { assert(!res.text); }); - it('should keep string headers', async () => { + it('should keep string headers', async() => { const app = new Koa(); app.use(ctx => { @@ -160,7 +160,7 @@ describe('app.respond', () => { assert(!res.text); }); - it('should keep buffer headers', async () => { + it('should keep buffer headers', async() => { const app = new Koa(); app.use(ctx => { @@ -301,7 +301,7 @@ describe('app.respond', () => { }); describe('with status=204', () => { - it('should respond without a body', async () => { + it('should respond without a body', async() => { const app = new Koa(); app.use(ctx => { @@ -320,7 +320,7 @@ describe('app.respond', () => { }); describe('with status=205', () => { - it('should respond without a body', async () => { + it('should respond without a body', async() => { const app = new Koa(); app.use(ctx => { @@ -339,7 +339,7 @@ describe('app.respond', () => { }); describe('with status=304', () => { - it('should respond without a body', async () => { + it('should respond without a body', async() => { const app = new Koa(); app.use(ctx => { @@ -358,7 +358,7 @@ describe('app.respond', () => { }); describe('with custom status=700', () => { - it('should respond with the associated status message', async () => { + it('should respond with the associated status message', async() => { const app = new Koa(); statuses['700'] = 'custom status'; @@ -378,7 +378,7 @@ describe('app.respond', () => { }); describe('with custom statusMessage=ok', () => { - it('should respond with the custom status message', async () => { + it('should respond with the custom status message', async() => { const app = new Koa(); app.use(ctx => { @@ -416,7 +416,7 @@ describe('app.respond', () => { }); describe('when .body is a null', () => { - it('should respond 204 by default', async () => { + it('should respond 204 by default', async() => { const app = new Koa(); app.use(ctx => { @@ -433,7 +433,7 @@ describe('app.respond', () => { assert.equal(res.headers.hasOwnProperty('content-type'), false); }); - it('should respond 204 with status=200', async () => { + it('should respond 204 with status=200', async() => { const app = new Koa(); app.use(ctx => { @@ -451,7 +451,7 @@ describe('app.respond', () => { assert.equal(res.headers.hasOwnProperty('content-type'), false); }); - it('should respond 205 with status=205', async () => { + it('should respond 205 with status=205', async() => { const app = new Koa(); app.use(ctx => { @@ -469,7 +469,7 @@ describe('app.respond', () => { assert.equal(res.headers.hasOwnProperty('content-type'), false); }); - it('should respond 304 with status=304', async () => { + it('should respond 304 with status=304', async() => { const app = new Koa(); app.use(ctx => { @@ -522,7 +522,7 @@ describe('app.respond', () => { }); describe('when .body is a Stream', () => { - it('should respond', async () => { + it('should respond', async() => { const app = new Koa(); app.use(ctx => { @@ -541,7 +541,7 @@ describe('app.respond', () => { assert.deepEqual(res.body, pkg); }); - it('should strip content-length when overwriting', async () => { + it('should strip content-length when overwriting', async() => { const app = new Koa(); app.use(ctx => { @@ -561,7 +561,7 @@ describe('app.respond', () => { assert.deepEqual(res.body, pkg); }); - it('should keep content-length if not overwritten', async () => { + it('should keep content-length if not overwritten', async() => { const app = new Koa(); app.use(ctx => { @@ -582,7 +582,7 @@ describe('app.respond', () => { }); it('should keep content-length if overwritten with the same stream', - async () => { + async() => { const app = new Koa(); app.use(ctx => { @@ -777,7 +777,7 @@ describe('app.respond', () => { .expect('hello'); }); - it('should 204', async () => { + it('should 204', async() => { const app = new Koa(); app.use(ctx => { diff --git a/test/application/response.js b/test/application/response.js index b1ef016..9fb4fc9 100644 --- a/test/application/response.js +++ b/test/application/response.js @@ -33,7 +33,7 @@ describe('app.response', () => { .expect(204); }); - it('should not include status message in body for http2', async () => { + it('should not include status message in body for http2', async() => { app3.use((ctx, next) => { ctx.req.httpVersionMajor = 2; ctx.status = 404; diff --git a/test/application/use.js b/test/application/use.js index 4d544b7..93988fd 100644 --- a/test/application/use.js +++ b/test/application/use.js @@ -6,7 +6,7 @@ const assert = require('assert'); const Koa = require('../..'); describe('app.use(fn)', () => { - it('should compose middleware', async () => { + it('should compose middleware', async() => { const app = new Koa(); const calls = []; @@ -40,7 +40,7 @@ describe('app.use(fn)', () => { assert.deepEqual(calls, [1, 2, 3, 4, 5, 6]); }); - it('should compose mixed middleware', async () => { + it('should compose mixed middleware', async() => { process.once('deprecation', () => {}); // silence deprecation message const app = new Koa(); const calls = []; diff --git a/test/context/cookies.js b/test/context/cookies.js index e12df80..4644f37 100644 --- a/test/context/cookies.js +++ b/test/context/cookies.js @@ -7,7 +7,7 @@ const Koa = require('../..'); describe('ctx.cookies', () => { describe('ctx.cookies.set()', () => { - it('should set an unsigned cookie', async () => { + it('should set an unsigned cookie', async() => { const app = new Koa(); app.use((ctx, next) => { @@ -44,7 +44,7 @@ describe('ctx.cookies', () => { }); }); - it('should send a signed cookie', async () => { + it('should send a signed cookie', async() => { const app = new Koa(); app.keys = ['a', 'b']; @@ -68,7 +68,7 @@ describe('ctx.cookies', () => { }); describe('with secure', () => { - it('should get secure from request', async () => { + it('should get secure from request', async() => { const app = new Koa(); app.proxy = true; @@ -95,7 +95,7 @@ describe('ctx.cookies', () => { }); describe('ctx.cookies=', () => { - it('should override cookie work', async () => { + it('should override cookie work', async() => { const app = new Koa(); app.use((ctx, next) => { diff --git a/test/context/onerror.js b/test/context/onerror.js index f1a44a0..89dd51e 100644 --- a/test/context/onerror.js +++ b/test/context/onerror.js @@ -33,7 +33,7 @@ describe('ctx.onerror(err)', () => { .expect('Content-Length', '4'); }); - it('should unset all headers', async () => { + it('should unset all headers', async() => { const app = new Koa(); app.use((ctx, next) => { @@ -56,7 +56,7 @@ describe('ctx.onerror(err)', () => { assert.equal(res.headers.hasOwnProperty('x-csrf-token'), false); }); - it('should set headers specified in the error', async () => { + it('should set headers specified in the error', async() => { const app = new Koa(); app.use((ctx, next) => { diff --git a/test/response/flushHeaders.js b/test/response/flushHeaders.js index b1c5de6..4f2c2e5 100644 --- a/test/response/flushHeaders.js +++ b/test/response/flushHeaders.js @@ -61,7 +61,7 @@ describe('ctx.flushHeaders()', () => { .expect('Body'); }); - it('should ignore set header after flushHeaders', async () => { + it('should ignore set header after flushHeaders', async() => { const app = new Koa(); app.use((ctx, next) => { @@ -108,18 +108,18 @@ describe('ctx.flushHeaders()', () => { http.request({ port }) - .on('response', res => { - const onData = () => done(new Error('boom')); - res.on('data', onData); + .on('response', res => { + const onData = () => done(new Error('boom')); + res.on('data', onData); - // shouldn't receive any data for a while - setTimeout(() => { - res.removeListener('data', onData); - done(); - }, 1000); - }) - .on('error', done) - .end(); + // shouldn't receive any data for a while + setTimeout(() => { + res.removeListener('data', onData); + done(); + }, 1000); + }) + .on('error', done) + .end(); }); }); diff --git a/test/response/header.js b/test/response/header.js index b7ccfc1..c8f3389 100644 --- a/test/response/header.js +++ b/test/response/header.js @@ -21,7 +21,7 @@ describe('res.header', () => { assert.deepEqual(res.header, { 'x-foo': 'baz' }); }); - it('should return the response header object when no mocks are in use', async () => { + it('should return the response header object when no mocks are in use', async() => { const app = new Koa(); let header; diff --git a/test/response/status.js b/test/response/status.js index af33948..b7e6b0b 100644 --- a/test/response/status.js +++ b/test/response/status.js @@ -62,7 +62,7 @@ describe('res.status=', () => { }); function strip(status){ - it('should strip content related header fields', async () => { + it('should strip content related header fields', async() => { const app = new Koa(); app.use(ctx => { @@ -86,7 +86,7 @@ describe('res.status=', () => { assert.equal(res.text.length, 0); }); - it('should strip content releated header fields after status set', async () => { + it('should strip content releated header fields after status set', async() => { const app = new Koa(); app.use(ctx => { diff --git a/test/response/writable.js b/test/response/writable.js index 3f5d011..21aa25e 100644 --- a/test/response/writable.js +++ b/test/response/writable.js @@ -54,10 +54,10 @@ describe('res.writable', () => { const app = new Koa(); app.use(ctx => { sleep(1000) - .then(() => { - if (ctx.writable) return done(new Error('ctx.writable should not be true')); - done(); - }); + .then(() => { + if (ctx.writable) return done(new Error('ctx.writable should not be true')); + done(); + }); }); const server = app.listen(); requestClosed(server);