Skip to content

Commit d4bdb5e

Browse files
committed
chore: update eslint and fix lint errors
1 parent 12960c4 commit d4bdb5e

File tree

12 files changed

+52
-52
lines changed

12 files changed

+52
-52
lines changed

benchmarks/middleware.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ console.log(` ${n}${useAsync ? ' async' : ''} middleware`);
1313

1414
while (n--) {
1515
if (useAsync) {
16-
app.use(async (ctx, next) => await next());
16+
app.use(async(ctx, next) => await next());
1717
} else {
1818
app.use((ctx, next) => next());
1919
}
@@ -22,7 +22,7 @@ while (n--) {
2222
const body = Buffer.from('Hello World');
2323

2424
if (useAsync) {
25-
app.use(async (ctx, next) => { await next(); ctx.body = body; });
25+
app.use(async(ctx, next) => { await next(); ctx.body = body; });
2626
} else {
2727
app.use((ctx, next) => next().then(() => ctx.body = body));
2828
}

lib/response.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = {
4848
const { res } = this;
4949
return typeof res.getHeaders === 'function'
5050
? res.getHeaders()
51-
: res._headers || {}; // Node < 7.7
51+
: res._headers || {}; // Node < 7.7
5252
},
5353

5454
/**

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"vary": "^1.1.2"
4949
},
5050
"devDependencies": {
51-
"eslint": "^3.17.1",
51+
"eslint": "^6.0.1",
5252
"eslint-config-koa": "^2.0.0",
5353
"eslint-config-standard": "^7.0.1",
5454
"eslint-plugin-promise": "^3.5.0",

test/application/respond.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('app.respond', () => {
8787
});
8888

8989
describe('when this.type === null', () => {
90-
it('should not send Content-Type header', async () => {
90+
it('should not send Content-Type header', async() => {
9191
const app = new Koa();
9292

9393
app.use(ctx => {
@@ -106,7 +106,7 @@ describe('app.respond', () => {
106106
});
107107

108108
describe('when HEAD is used', () => {
109-
it('should not respond with the body', async () => {
109+
it('should not respond with the body', async() => {
110110
const app = new Koa();
111111

112112
app.use(ctx => {
@@ -124,7 +124,7 @@ describe('app.respond', () => {
124124
assert(!res.text);
125125
});
126126

127-
it('should keep json headers', async () => {
127+
it('should keep json headers', async() => {
128128
const app = new Koa();
129129

130130
app.use(ctx => {
@@ -142,7 +142,7 @@ describe('app.respond', () => {
142142
assert(!res.text);
143143
});
144144

145-
it('should keep string headers', async () => {
145+
it('should keep string headers', async() => {
146146
const app = new Koa();
147147

148148
app.use(ctx => {
@@ -160,7 +160,7 @@ describe('app.respond', () => {
160160
assert(!res.text);
161161
});
162162

163-
it('should keep buffer headers', async () => {
163+
it('should keep buffer headers', async() => {
164164
const app = new Koa();
165165

166166
app.use(ctx => {
@@ -301,7 +301,7 @@ describe('app.respond', () => {
301301
});
302302

303303
describe('with status=204', () => {
304-
it('should respond without a body', async () => {
304+
it('should respond without a body', async() => {
305305
const app = new Koa();
306306

307307
app.use(ctx => {
@@ -320,7 +320,7 @@ describe('app.respond', () => {
320320
});
321321

322322
describe('with status=205', () => {
323-
it('should respond without a body', async () => {
323+
it('should respond without a body', async() => {
324324
const app = new Koa();
325325

326326
app.use(ctx => {
@@ -339,7 +339,7 @@ describe('app.respond', () => {
339339
});
340340

341341
describe('with status=304', () => {
342-
it('should respond without a body', async () => {
342+
it('should respond without a body', async() => {
343343
const app = new Koa();
344344

345345
app.use(ctx => {
@@ -358,7 +358,7 @@ describe('app.respond', () => {
358358
});
359359

360360
describe('with custom status=700', () => {
361-
it('should respond with the associated status message', async () => {
361+
it('should respond with the associated status message', async() => {
362362
const app = new Koa();
363363
statuses['700'] = 'custom status';
364364

@@ -378,7 +378,7 @@ describe('app.respond', () => {
378378
});
379379

380380
describe('with custom statusMessage=ok', () => {
381-
it('should respond with the custom status message', async () => {
381+
it('should respond with the custom status message', async() => {
382382
const app = new Koa();
383383

384384
app.use(ctx => {
@@ -416,7 +416,7 @@ describe('app.respond', () => {
416416
});
417417

418418
describe('when .body is a null', () => {
419-
it('should respond 204 by default', async () => {
419+
it('should respond 204 by default', async() => {
420420
const app = new Koa();
421421

422422
app.use(ctx => {
@@ -433,7 +433,7 @@ describe('app.respond', () => {
433433
assert.equal(res.headers.hasOwnProperty('content-type'), false);
434434
});
435435

436-
it('should respond 204 with status=200', async () => {
436+
it('should respond 204 with status=200', async() => {
437437
const app = new Koa();
438438

439439
app.use(ctx => {
@@ -451,7 +451,7 @@ describe('app.respond', () => {
451451
assert.equal(res.headers.hasOwnProperty('content-type'), false);
452452
});
453453

454-
it('should respond 205 with status=205', async () => {
454+
it('should respond 205 with status=205', async() => {
455455
const app = new Koa();
456456

457457
app.use(ctx => {
@@ -469,7 +469,7 @@ describe('app.respond', () => {
469469
assert.equal(res.headers.hasOwnProperty('content-type'), false);
470470
});
471471

472-
it('should respond 304 with status=304', async () => {
472+
it('should respond 304 with status=304', async() => {
473473
const app = new Koa();
474474

475475
app.use(ctx => {
@@ -522,7 +522,7 @@ describe('app.respond', () => {
522522
});
523523

524524
describe('when .body is a Stream', () => {
525-
it('should respond', async () => {
525+
it('should respond', async() => {
526526
const app = new Koa();
527527

528528
app.use(ctx => {
@@ -541,7 +541,7 @@ describe('app.respond', () => {
541541
assert.deepEqual(res.body, pkg);
542542
});
543543

544-
it('should strip content-length when overwriting', async () => {
544+
it('should strip content-length when overwriting', async() => {
545545
const app = new Koa();
546546

547547
app.use(ctx => {
@@ -561,7 +561,7 @@ describe('app.respond', () => {
561561
assert.deepEqual(res.body, pkg);
562562
});
563563

564-
it('should keep content-length if not overwritten', async () => {
564+
it('should keep content-length if not overwritten', async() => {
565565
const app = new Koa();
566566

567567
app.use(ctx => {
@@ -582,7 +582,7 @@ describe('app.respond', () => {
582582
});
583583

584584
it('should keep content-length if overwritten with the same stream',
585-
async () => {
585+
async() => {
586586
const app = new Koa();
587587

588588
app.use(ctx => {
@@ -777,7 +777,7 @@ describe('app.respond', () => {
777777
.expect('hello');
778778
});
779779

780-
it('should 204', async () => {
780+
it('should 204', async() => {
781781
const app = new Koa();
782782

783783
app.use(ctx => {

test/application/response.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('app.response', () => {
3333
.expect(204);
3434
});
3535

36-
it('should not include status message in body for http2', async () => {
36+
it('should not include status message in body for http2', async() => {
3737
app3.use((ctx, next) => {
3838
ctx.req.httpVersionMajor = 2;
3939
ctx.status = 404;

test/application/use.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const assert = require('assert');
66
const Koa = require('../..');
77

88
describe('app.use(fn)', () => {
9-
it('should compose middleware', async () => {
9+
it('should compose middleware', async() => {
1010
const app = new Koa();
1111
const calls = [];
1212

@@ -40,7 +40,7 @@ describe('app.use(fn)', () => {
4040
assert.deepEqual(calls, [1, 2, 3, 4, 5, 6]);
4141
});
4242

43-
it('should compose mixed middleware', async () => {
43+
it('should compose mixed middleware', async() => {
4444
process.once('deprecation', () => {}); // silence deprecation message
4545
const app = new Koa();
4646
const calls = [];

test/context/cookies.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const Koa = require('../..');
77

88
describe('ctx.cookies', () => {
99
describe('ctx.cookies.set()', () => {
10-
it('should set an unsigned cookie', async () => {
10+
it('should set an unsigned cookie', async() => {
1111
const app = new Koa();
1212

1313
app.use((ctx, next) => {
@@ -44,7 +44,7 @@ describe('ctx.cookies', () => {
4444
});
4545
});
4646

47-
it('should send a signed cookie', async () => {
47+
it('should send a signed cookie', async() => {
4848
const app = new Koa();
4949

5050
app.keys = ['a', 'b'];
@@ -68,7 +68,7 @@ describe('ctx.cookies', () => {
6868
});
6969

7070
describe('with secure', () => {
71-
it('should get secure from request', async () => {
71+
it('should get secure from request', async() => {
7272
const app = new Koa();
7373

7474
app.proxy = true;
@@ -95,7 +95,7 @@ describe('ctx.cookies', () => {
9595
});
9696

9797
describe('ctx.cookies=', () => {
98-
it('should override cookie work', async () => {
98+
it('should override cookie work', async() => {
9999
const app = new Koa();
100100

101101
app.use((ctx, next) => {

test/context/onerror.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('ctx.onerror(err)', () => {
3333
.expect('Content-Length', '4');
3434
});
3535

36-
it('should unset all headers', async () => {
36+
it('should unset all headers', async() => {
3737
const app = new Koa();
3838

3939
app.use((ctx, next) => {
@@ -56,7 +56,7 @@ describe('ctx.onerror(err)', () => {
5656
assert.equal(res.headers.hasOwnProperty('x-csrf-token'), false);
5757
});
5858

59-
it('should set headers specified in the error', async () => {
59+
it('should set headers specified in the error', async() => {
6060
const app = new Koa();
6161

6262
app.use((ctx, next) => {

test/response/flushHeaders.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('ctx.flushHeaders()', () => {
6161
.expect('Body');
6262
});
6363

64-
it('should ignore set header after flushHeaders', async () => {
64+
it('should ignore set header after flushHeaders', async() => {
6565
const app = new Koa();
6666

6767
app.use((ctx, next) => {
@@ -108,18 +108,18 @@ describe('ctx.flushHeaders()', () => {
108108
http.request({
109109
port
110110
})
111-
.on('response', res => {
112-
const onData = () => done(new Error('boom'));
113-
res.on('data', onData);
114-
115-
// shouldn't receive any data for a while
116-
setTimeout(() => {
117-
res.removeListener('data', onData);
118-
done();
119-
}, 1000);
120-
})
121-
.on('error', done)
122-
.end();
111+
.on('response', res => {
112+
const onData = () => done(new Error('boom'));
113+
res.on('data', onData);
114+
115+
// shouldn't receive any data for a while
116+
setTimeout(() => {
117+
res.removeListener('data', onData);
118+
done();
119+
}, 1000);
120+
})
121+
.on('error', done)
122+
.end();
123123
});
124124
});
125125

test/response/header.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('res.header', () => {
2121
assert.deepEqual(res.header, { 'x-foo': 'baz' });
2222
});
2323

24-
it('should return the response header object when no mocks are in use', async () => {
24+
it('should return the response header object when no mocks are in use', async() => {
2525
const app = new Koa();
2626
let header;
2727

test/response/status.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('res.status=', () => {
6262
});
6363

6464
function strip(status){
65-
it('should strip content related header fields', async () => {
65+
it('should strip content related header fields', async() => {
6666
const app = new Koa();
6767

6868
app.use(ctx => {
@@ -86,7 +86,7 @@ describe('res.status=', () => {
8686
assert.equal(res.text.length, 0);
8787
});
8888

89-
it('should strip content releated header fields after status set', async () => {
89+
it('should strip content releated header fields after status set', async() => {
9090
const app = new Koa();
9191

9292
app.use(ctx => {

test/response/writable.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ describe('res.writable', () => {
5454
const app = new Koa();
5555
app.use(ctx => {
5656
sleep(1000)
57-
.then(() => {
58-
if (ctx.writable) return done(new Error('ctx.writable should not be true'));
59-
done();
60-
});
57+
.then(() => {
58+
if (ctx.writable) return done(new Error('ctx.writable should not be true'));
59+
done();
60+
});
6161
});
6262
const server = app.listen();
6363
requestClosed(server);

0 commit comments

Comments
 (0)