chore: update eslint and fix lint errors

This commit is contained in:
dead-horse 2019-06-26 11:15:22 +08:00
parent 12960c437c
commit d4bdb5ed9e
12 changed files with 51 additions and 51 deletions

View file

@ -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));
}

View file

@ -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",

View file

@ -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 => {

View file

@ -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;

View file

@ -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 = [];

View file

@ -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) => {

View file

@ -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) => {

View file

@ -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) => {

View file

@ -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;

View file

@ -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 => {