Skip to content

Commit

Permalink
chore: update eslint and fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse committed Jun 26, 2019
1 parent 12960c4 commit d4bdb5e
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions benchmarks/middleware.js
Expand Up @@ -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());
}
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/response.js
Expand Up @@ -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
},

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
38 changes: 19 additions & 19 deletions test/application/respond.js
Expand Up @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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';

Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand Down Expand Up @@ -777,7 +777,7 @@ describe('app.respond', () => {
.expect('hello');
});

it('should 204', async () => {
it('should 204', async() => {
const app = new Koa();

app.use(ctx => {
Expand Down
2 changes: 1 addition & 1 deletion test/application/response.js
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/application/use.js
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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 = [];
Expand Down
8 changes: 4 additions & 4 deletions test/context/cookies.js
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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'];
Expand All @@ -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;
Expand All @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions test/context/onerror.js
Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand Down
26 changes: 13 additions & 13 deletions test/response/flushHeaders.js
Expand Up @@ -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) => {
Expand Down Expand Up @@ -108,18 +108,18 @@ describe('ctx.flushHeaders()', () => {
http.request({
port
})
.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();
.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();
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/response/header.js
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions test/response/status.js
Expand Up @@ -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 => {
Expand All @@ -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 => {
Expand Down
8 changes: 4 additions & 4 deletions test/response/writable.js
Expand Up @@ -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);
Expand Down

0 comments on commit d4bdb5e

Please sign in to comment.