From 2f205052edce82f89d34dda7c09454cdecd455f4 Mon Sep 17 00:00:00 2001 From: bananaappletw Date: Thu, 20 Oct 2016 13:12:07 +0800 Subject: [PATCH] Fix space-before-blocks --- 404/app.js | 2 +- 404/test.js | 6 +++--- base-auth/app.js | 4 ++-- base-auth/test.js | 14 ++++++------- blog/test.js | 24 +++++++++++----------- body-parsing/app.js | 2 +- body-parsing/test.js | 20 +++++++++--------- compose/app.js | 6 +++--- compose/test.js | 12 +++++------ conditional-middleware/app.js | 4 ++-- cookies/app.js | 2 +- cookies/test.js | 6 +++--- csrf/test.js | 6 +++--- errors/app.js | 6 +++--- errors/test.js | 6 +++--- flash-messages/app.js | 4 ++-- flash-messages/test.js | 10 ++++----- hello-world/app.js | 2 +- hello-world/test.js | 4 ++-- multipart/app.js | 2 +- negotiation/app.js | 6 +++--- stream-file/test.js | 10 ++++----- stream-objects/app.js | 2 +- stream-objects/test.js | 6 +++--- stream-view/test.js | 6 +++--- templates/app.js | 2 +- templates/test.js | 6 +++--- upload/app.js | 4 ++-- vhost/apps/array.js | 2 +- vhost/test.js | 38 +++++++++++++++++------------------ 30 files changed, 112 insertions(+), 112 deletions(-) diff --git a/404/app.js b/404/app.js index df55c2e..759a316 100644 --- a/404/app.js +++ b/404/app.js @@ -2,7 +2,7 @@ var koa = require('koa'); var app = module.exports = koa(); -app.use(function *pageNotFound(next){ +app.use(function *pageNotFound(next) { yield next; if (404 != this.status) return; diff --git a/404/test.js b/404/test.js index f78256d..43183b7 100644 --- a/404/test.js +++ b/404/test.js @@ -2,9 +2,9 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('404', function(){ - describe('when GET /', function(){ - it('should return the 404 page', function(done){ +describe('404', function() { + describe('when GET /', function() { + it('should return the 404 page', function(done) { request .get('/') .expect(404) diff --git a/base-auth/app.js b/base-auth/app.js index 6b2d590..ffeca65 100644 --- a/base-auth/app.js +++ b/base-auth/app.js @@ -4,7 +4,7 @@ var app = module.exports = koa(); // custom 401 handling -app.use(function* (next){ +app.use(function* (next) { try { yield next; } catch (err) { @@ -24,7 +24,7 @@ app.use(auth({ name: 'tj', pass: 'tobi' })); // secret response -app.use(function* (){ +app.use(function* () { this.body = 'secret'; }); diff --git a/base-auth/test.js b/base-auth/test.js index cb177cb..5bcd3c6 100644 --- a/base-auth/test.js +++ b/base-auth/test.js @@ -1,17 +1,17 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Koa Basic Auth', function(){ - describe('with no credentials', function(){ - it('should `throw` 401', function(done){ +describe('Koa Basic Auth', function() { + describe('with no credentials', function() { + it('should `throw` 401', function(done) { request .get('/') .expect(401, done); }) }) - describe('with invalid credentials', function(){ - it('should `throw` 401', function(done){ + describe('with invalid credentials', function() { + it('should `throw` 401', function(done) { request .get('/') .auth('user', 'invalid password') @@ -19,8 +19,8 @@ describe('Koa Basic Auth', function(){ }) }) - describe('with valid credentials', function(){ - it('should call the next middleware', function(done){ + describe('with valid credentials', function() { + it('should call the next middleware', function(done) { request .get('/') .auth('tj', 'tobi') diff --git a/blog/test.js b/blog/test.js index afc312d..6d2ef1f 100644 --- a/blog/test.js +++ b/blog/test.js @@ -1,12 +1,12 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Blog', function(){ - describe('GET /', function(){ - it('should see title "Posts"', function(done){ +describe('Blog', function() { + describe('GET /', function() { + it('should see title "Posts"', function(done) { request .get('/') - .expect(200, function(err, res){ + .expect(200, function(err, res) { if (err) return done(err); res.should.be.html; @@ -14,10 +14,10 @@ describe('Blog', function(){ done(); }); }); - it('should see 0 post', function(done){ + it('should see 0 post', function(done) { request .get('/') - .expect(200, function(err, res){ + .expect(200, function(err, res) { if (err) return done(err); res.should.be.html; @@ -26,12 +26,12 @@ describe('Blog', function(){ }); }); }); - describe('POST /post/new', function(){ - it('should create post and redirect to /', function(done){ + describe('POST /post/new', function() { + it('should create post and redirect to /', function(done) { request .post('/post') .send({title: 'Title', body: 'Contents'}) - .end(function(err, res){ + .end(function(err, res) { if (err) return done(err); res.header.location.should.be.equal('/') @@ -39,11 +39,11 @@ describe('Blog', function(){ }); }); }); - describe('GET /post/0', function(){ - it('should see post', function(done){ + describe('GET /post/0', function() { + it('should see post', function(done) { request .get('/post/0') - .expect(200, function(err, res){ + .expect(200, function(err, res) { if (err) return done(err); res.should.be.html; diff --git a/body-parsing/app.js b/body-parsing/app.js index 2c3b7cf..67b62cf 100644 --- a/body-parsing/app.js +++ b/body-parsing/app.js @@ -8,7 +8,7 @@ var app = module.exports = koa(); // co-body accepts application/json // and application/x-www-form-urlencoded -app.use(function *(next){ +app.use(function *(next) { if ('POST' != this.method) return yield next; var body = yield parse(this, { limit: '1kb' }); if (!body.name) this.throw(400, '.name required'); diff --git a/body-parsing/test.js b/body-parsing/test.js index 38bef30..df78f38 100644 --- a/body-parsing/test.js +++ b/body-parsing/test.js @@ -1,10 +1,10 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Body Parsing', function(){ - describe('POST /uppercase', function(){ - describe('with JSON', function(){ - it('should work', function(done){ +describe('Body Parsing', function() { + describe('POST /uppercase', function() { + describe('with JSON', function() { + it('should work', function(done) { request .post('/uppercase') .send({ name: 'tobi' }) @@ -13,8 +13,8 @@ describe('Body Parsing', function(){ }) }) - describe('with urlencoded', function(){ - it('should work', function(done){ + describe('with urlencoded', function() { + it('should work', function(done) { request .post('/uppercase') .send('name=tj') @@ -23,8 +23,8 @@ describe('Body Parsing', function(){ }) }) - describe('when length > limit', function(){ - it('should 413', function(done){ + describe('when length > limit', function() { + it('should 413', function(done) { request .post('/json') .send({ name: Array(5000).join('a') }) @@ -32,8 +32,8 @@ describe('Body Parsing', function(){ }) }) - describe('when no name is sent', function(){ - it('should 400', function(done){ + describe('when no name is sent', function() { + it('should 400', function(done) { request .post('/uppsercase') .send('age=10') diff --git a/compose/app.js b/compose/app.js index 6ae8ee8..1cf9abf 100644 --- a/compose/app.js +++ b/compose/app.js @@ -18,7 +18,7 @@ var app = module.exports = koa(); // x-response-time -function *responseTime(next){ +function *responseTime(next) { var start = new Date(); yield next; var ms = new Date() - start; @@ -27,7 +27,7 @@ function *responseTime(next){ // logger -function* logger(next){ +function* logger(next) { var start = new Date(); yield next; var ms = new Date() - start; @@ -38,7 +38,7 @@ function* logger(next){ // response -function* respond(next){ +function* respond(next) { yield next; if ('/' != this.url) return; this.body = 'Hello World'; diff --git a/compose/test.js b/compose/test.js index 8abee23..cd589e6 100644 --- a/compose/test.js +++ b/compose/test.js @@ -1,16 +1,16 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Compose', function(){ - describe('when GET /', function(){ - it('should say "Hello World"', function(done){ +describe('Compose', function() { + describe('when GET /', function() { + it('should say "Hello World"', function(done) { request .get('/') .expect(200) .expect('Hello World', done); }) - it('should set X-Response-Time', function(done){ + it('should set X-Response-Time', function(done) { request .get('/') .expect('X-Response-Time', /ms$/) @@ -18,8 +18,8 @@ describe('Compose', function(){ }) }) - describe('when not GET /', function(){ - it('should 404', function(done){ + describe('when not GET /', function() { + it('should 404', function(done) { request .get('/aklsjdf') .expect(404, done); diff --git a/conditional-middleware/app.js b/conditional-middleware/app.js index f47be86..3467e43 100644 --- a/conditional-middleware/app.js +++ b/conditional-middleware/app.js @@ -8,7 +8,7 @@ var app = koa(); // middleware may "wrap" other middleware. function ignoreAssets(mw) { - return function *(next){ + return function *(next) { if (/(\.js|\.css|\.ico)$/.test(this.path)) { yield next; } else { @@ -26,7 +26,7 @@ function ignoreAssets(mw) { app.use(ignoreAssets(logger())); -app.use(function *(){ +app.use(function *() { this.body = 'Hello World'; }); diff --git a/cookies/app.js b/cookies/app.js index 2554195..82f3853 100644 --- a/cookies/app.js +++ b/cookies/app.js @@ -6,7 +6,7 @@ var koa = require('koa'); var app = module.exports = koa(); -app.use(function *(){ +app.use(function *() { var n = ~~this.cookies.get('view') + 1; this.cookies.set('view', n); this.body = n + ' views'; diff --git a/cookies/test.js b/cookies/test.js index 5404802..c4b89e5 100644 --- a/cookies/test.js +++ b/cookies/test.js @@ -1,10 +1,10 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Cookies Views', function(){ +describe('Cookies Views', function() { [1, 2, 3].forEach(function(i) { - describe('on iteration #' + i, function(){ - it('should set the views as a cookie and as the body', function(done){ + describe('on iteration #' + i, function() { + it('should set the views as a cookie and as the body', function(done) { request .get('/') .expect(200) diff --git a/csrf/test.js b/csrf/test.js index 77fb454..c53b295 100644 --- a/csrf/test.js +++ b/csrf/test.js @@ -4,9 +4,9 @@ var request = require('supertest').agent(app.listen()); var token; var cookie; -describe('csrf', function(){ - describe('GET /token', function(){ - it('should get token', function(done){ +describe('csrf', function() { + describe('GET /token', function() { + it('should get token', function(done) { request .get('/token') .expect(200) diff --git a/errors/app.js b/errors/app.js index 3147f78..d045d48 100644 --- a/errors/app.js +++ b/errors/app.js @@ -4,7 +4,7 @@ var app = module.exports = koa(); // look ma, error propagation! -app.use(function *(next){ +app.use(function *(next) { try { yield next; } catch (err) { @@ -24,13 +24,13 @@ app.use(function *(next){ // response -app.use(function *(){ +app.use(function *() { throw new Error('boom boom'); }); // error handler -app.on('error', function(err){ +app.on('error', function(err) { if (process.env.NODE_ENV != 'test') { console.log('sent error %s to the cloud', err.message); console.log(err); diff --git a/errors/test.js b/errors/test.js index dabd901..9f92ca5 100644 --- a/errors/test.js +++ b/errors/test.js @@ -2,14 +2,14 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); describe('Errors', function() { - it('should catch the error', function(done){ + it('should catch the error', function(done) { request .get('/') .expect(500) .expect('Content-Type', /text\/html/, done); }) - it('should emit the error on app', function(done){ + it('should emit the error on app', function(done) { app.once('error', function(err, ctx) { err.message.should.equal('boom boom'); ctx.should.be.ok; @@ -18,6 +18,6 @@ describe('Errors', function() { request .get('/') - .end(function(){}); + .end(function() {}); }) }) diff --git a/flash-messages/app.js b/flash-messages/app.js index 1dcaa2f..8e7273b 100644 --- a/flash-messages/app.js +++ b/flash-messages/app.js @@ -13,7 +13,7 @@ var app = module.exports = koa(); app.keys = ['key1', 'key2']; app.use(session(app)); -app.use(function *(next){ +app.use(function *(next) { if (this.method !== 'GET' || this.path !== '/messages') return yield next; // get any messages saved in the session @@ -24,7 +24,7 @@ app.use(function *(next){ delete this.session.messages; }) -app.use(function *(next){ +app.use(function *(next) { if (this.method !== 'POST' || this.path !== '/messages') return yield next; // the request string is the flash message diff --git a/flash-messages/test.js b/flash-messages/test.js index 626036b..1ece119 100644 --- a/flash-messages/test.js +++ b/flash-messages/test.js @@ -1,8 +1,8 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Flash Messages', function(){ - it('GET should return an empty array', function(done){ +describe('Flash Messages', function() { + it('GET should return an empty array', function(done) { request .get('/messages') .expect(200) @@ -10,14 +10,14 @@ describe('Flash Messages', function(){ .expect('[]', done); }) - it('POST should return 204', function(done){ + it('POST should return 204', function(done) { request .post('/messages') .send('hello') .expect(204, done); }) - it('GET should return the message', function(done){ + it('GET should return the message', function(done) { request .get('/messages') .expect(200) @@ -25,7 +25,7 @@ describe('Flash Messages', function(){ .expect('["hello"]', done); }) - it('GET should return no more messages', function(done){ + it('GET should return no more messages', function(done) { request .get('/messages') .expect(200) diff --git a/hello-world/app.js b/hello-world/app.js index cf7eeee..81ed703 100644 --- a/hello-world/app.js +++ b/hello-world/app.js @@ -2,7 +2,7 @@ var koa = require('koa'); var app = module.exports = koa(); -app.use(function *(){ +app.use(function *() { this.body = 'Hello World'; }); diff --git a/hello-world/test.js b/hello-world/test.js index 7859fd6..6473b7a 100644 --- a/hello-world/test.js +++ b/hello-world/test.js @@ -1,8 +1,8 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Hello World', function(){ - it('should say "Hello World"', function(done){ +describe('Hello World', function() { + it('should say "Hello World"', function(done) { request .get('/') .expect(200) diff --git a/multipart/app.js b/multipart/app.js index 076c757..b99d5de 100644 --- a/multipart/app.js +++ b/multipart/app.js @@ -14,7 +14,7 @@ var saveTo = require('save-to'); var app = module.exports = koa(); -app.use(function *(){ +app.use(function *() { // parse the multipart body var parts = parse(this, { autoFields: true // saves the fields to parts.field(s) diff --git a/negotiation/app.js b/negotiation/app.js index 8974452..b4e0ab3 100644 --- a/negotiation/app.js +++ b/negotiation/app.js @@ -25,7 +25,7 @@ var users = { // may want to check the type, as it may // be a stream, buffer, string, etc. -app.use(function *(next){ +app.use(function *(next) { yield next; // no body? nothing to format, early return @@ -64,7 +64,7 @@ app.use(function *(next){ // filter responses, in this case remove ._id // since it's private -app.use(function *(next){ +app.use(function *(next) { yield next; if (!this.body) return; @@ -75,7 +75,7 @@ app.use(function *(next){ // try $ GET /tobi // try $ GET /loki -app.use(function *(){ +app.use(function *() { var name = this.path.slice(1); var user = users[name]; this.body = user; diff --git a/stream-file/test.js b/stream-file/test.js index 26ef6ec..ed44f95 100644 --- a/stream-file/test.js +++ b/stream-file/test.js @@ -1,28 +1,28 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Stream File', function(){ - it('GET /app.js', function(done){ +describe('Stream File', function() { + it('GET /app.js', function(done) { request .get('/app.js') .expect('content-type', /application\/javascript/) .expect(200, done); }); - it('GET /test.js', function(done){ + it('GET /test.js', function(done) { request .get('/test.js') .expect('content-type', /application\/javascript/) .expect(200, done); }); - it('GET /alksjdf.js', function(done){ + it('GET /alksjdf.js', function(done) { request .get('/lajksdf.js') .expect(404, done); }); - it('GET /', function(done){ + it('GET /', function(done) { request .get('/') .expect(404, done); diff --git a/stream-objects/app.js b/stream-objects/app.js index e3222d7..9c51599 100644 --- a/stream-objects/app.js +++ b/stream-objects/app.js @@ -4,7 +4,7 @@ var JSONStream = require('streaming-json-stringify'); var app = module.exports = koa(); -app.use(function *(){ +app.use(function *() { this.type = 'json'; var stream = this.body = JSONStream(); diff --git a/stream-objects/test.js b/stream-objects/test.js index ce99c57..cdb6b29 100644 --- a/stream-objects/test.js +++ b/stream-objects/test.js @@ -1,11 +1,11 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Stream Objects', function(){ - it('GET /', function(done){ +describe('Stream Objects', function() { + it('GET /', function(done) { request .get('/app.js') - .expect(200, function(err, res){ + .expect(200, function(err, res) { if (err) return done(err); res.body.should.eql([{ diff --git a/stream-view/test.js b/stream-view/test.js index 7450ea9..a600dd2 100644 --- a/stream-view/test.js +++ b/stream-view/test.js @@ -1,11 +1,11 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Stream View', function(){ - it('GET /', function(done){ +describe('Stream View', function() { + it('GET /', function(done) { request .get('/') - .expect(200, function(err, res){ + .expect(200, function(err, res) { if (err) return done(err); res.should.be.html; diff --git a/templates/app.js b/templates/app.js index 3e9eadb..fed5fc9 100644 --- a/templates/app.js +++ b/templates/app.js @@ -21,7 +21,7 @@ var user = { // render -app.use(function *(){ +app.use(function *() { this.body = yield render('user', { user: user }); }); diff --git a/templates/test.js b/templates/test.js index f0a5a18..06dca14 100644 --- a/templates/test.js +++ b/templates/test.js @@ -1,9 +1,9 @@ var app = require('./app'); var request = require('supertest').agent(app.listen()); -describe('Templates', function(){ - describe('GET /', function(){ - it('should respond with a rendered view', function(done){ +describe('Templates', function() { + describe('GET /', function() { + it('should respond with a rendered view', function(done) { request .get('/') .expect(200) diff --git a/upload/app.js b/upload/app.js index da092b9..5cb76f8 100644 --- a/upload/app.js +++ b/upload/app.js @@ -18,7 +18,7 @@ app.use(logger()); // custom 404 -app.use(function *(next){ +app.use(function *(next) { yield next; if (this.body || !this.idempotent) return; this.redirect('/404.html'); @@ -30,7 +30,7 @@ app.use(serve(__dirname + '/public')); // handle uploads -app.use(function *(next){ +app.use(function *(next) { // ignore non-POSTs if ('POST' != this.method) return yield next; diff --git a/vhost/apps/array.js b/vhost/apps/array.js index 27cc6cb..dd33372 100644 --- a/vhost/apps/array.js +++ b/vhost/apps/array.js @@ -1,7 +1,7 @@ // rather than koa apps we can also use array // bundles of middleware to the same effect. -function *responseTime(next){ +function *responseTime(next) { var start = new Date(); yield next; var ms = new Date() - start; diff --git a/vhost/test.js b/vhost/test.js index 089beab..f3d7b73 100644 --- a/vhost/test.js +++ b/vhost/test.js @@ -1,10 +1,10 @@ var app = require('./app'); var request = require('supertest').agent(app.listen());; -describe('Virtual Host', function(){ - describe('www subdomain koa app', function(){ - describe('when GET /', function(){ - it('should say "Hello from www app"', function(done){ +describe('Virtual Host', function() { + describe('www subdomain koa app', function() { + describe('when GET /', function() { + it('should say "Hello from www app"', function(done) { request .get('/') .set('Host', 'www.example.com') @@ -12,7 +12,7 @@ describe('Virtual Host', function(){ .expect('Hello from www app', done); }) - it('should set X-Custom', function(done){ + it('should set X-Custom', function(done) { request .get('/') .set('Host', 'www.example.com') @@ -21,8 +21,8 @@ describe('Virtual Host', function(){ }) }) - describe('when GET / without subdomain', function(){ - it('should say "Hello from www app"', function(done){ + describe('when GET / without subdomain', function() { + it('should say "Hello from www app"', function(done) { request .get('/') .set('Host', 'example.com') @@ -30,7 +30,7 @@ describe('Virtual Host', function(){ .expect('Hello from www app', done); }) - it('should set X-Custom', function(done){ + it('should set X-Custom', function(done) { request .get('/') .set('Host', 'example.com') @@ -39,8 +39,8 @@ describe('Virtual Host', function(){ }) }) - describe('when not GET /', function(){ - it('should 404', function(done){ + describe('when not GET /', function() { + it('should 404', function(done) { request .get('/aklsjdf') .set('Host', 'example.com') @@ -48,9 +48,9 @@ describe('Virtual Host', function(){ }) }) }) - describe('bar subdomain array bundle', function(){ - describe('when GET /', function(){ - it('should say "Howzit? From bar middleware bundle"', function(done){ + describe('bar subdomain array bundle', function() { + describe('when GET /', function() { + it('should say "Howzit? From bar middleware bundle"', function(done) { request .get('/') .set('Host', 'bar.example.com') @@ -58,7 +58,7 @@ describe('Virtual Host', function(){ .expect('Howzit? From bar middleware bundle', done); }) - it('should set X-Response-Time', function(done){ + it('should set X-Response-Time', function(done) { request .get('/') .set('Host', 'bar.example.com') @@ -67,8 +67,8 @@ describe('Virtual Host', function(){ }) }) - describe('when not GET /', function(){ - it('should 404', function(done){ + describe('when not GET /', function() { + it('should 404', function(done) { request .get('/aklsjdf') .set('Host', 'bar.example.com') @@ -76,9 +76,9 @@ describe('Virtual Host', function(){ }) }) }) - describe('default vhost', function(){ - describe('when GET /', function(){ - it('should 404', function(done){ + describe('default vhost', function() { + describe('when GET /', function() { + it('should 404', function(done) { request .get('/') .set('Host', '127.0.0.1')