Fix indentation and add .eslint rules

closes #555
master
Slobodan Stojanovic 2015-10-28 08:53:49 +01:00 committed by jongleberry
parent 6d3b81fe50
commit b08facb7bd
16 changed files with 318 additions and 319 deletions

View File

@ -11,3 +11,4 @@ rules:
yoda: 0
arrow-parens: [2, "as-needed"]
arrow-spacing: 2
dot-location: [2, "property"]

View File

@ -92,9 +92,7 @@ module.exports = class Application extends Emitter {
use(fn) {
debug('use %s', fn._name || fn.name || '-');
if (typeof fn !== 'function') throw new TypeError('middleware must be a function!');
if (isGeneratorFunction(fn)) {
throw new TypeError('Support for generators has been removed. Use Promises or wrap your generator with co.wrap');
}
if (isGeneratorFunction(fn)) throw new TypeError('Support for generators has been removed. Use Promises or wrap your generator with co.wrap');
this.middleware.push(fn);
return this;
}

View File

@ -81,9 +81,7 @@ module.exports = {
get href() {
// support: `GET http://example.com/foo`
if (/^https?:\/\//i.test(this.originalUrl)) {
return this.originalUrl;
}
if (/^https?:\/\//i.test(this.originalUrl)) return this.originalUrl;
return this.origin + this.originalUrl;
},
@ -400,12 +398,13 @@ module.exports = {
/**
* Return subdomains as an array.
*
* Subdomains are the dot-separated parts of the host before the main domain of
* the app. By default, the domain of the app is assumed to be the last two
* Subdomains are the dot-separated parts of the host before the main domain
* of the app. By default, the domain of the app is assumed to be the last two
* parts of the host. This can be changed by setting `app.subdomainOffset`.
*
* For example, if the domain is "tobi.ferrets.example.com":
* If `app.subdomainOffset` is not set, this.subdomains is `["ferrets", "tobi"]`.
* If `app.subdomainOffset` is not set, this.subdomains is
* `["ferrets", "tobi"]`.
* If `app.subdomainOffset` is 3, this.subdomains is `["tobi"]`.
*
* @return {Array}

View File

@ -446,9 +446,11 @@ module.exports = {
*
* Examples:
*
* ```
* this.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
* this.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
* this.append('Warning', '199 Miscellaneous warning');
* ```
*
* @param {String} field
* @param {String|Array} val

View File

@ -590,7 +590,8 @@ describe('app.respond', function(){
});
});
it('should keep content-length if overwritten with the same stream', function(done){
it('should keep content-length if overwritten with the same stream',
done => {
const app = new Koa();
app.use(function(ctx){

View File

@ -21,8 +21,7 @@ describe('ctx.cookies.set()', function(){
.end(function(err, res){
if (err) return done(err);
res.headers['set-cookie'].some(cookie => /^name=/.test(cookie))
.should.be.ok;
res.headers['set-cookie'].some(cookie => /^name=/.test(cookie)).should.be.ok;
done();
});

View File

@ -23,8 +23,7 @@ describe('res.lastModified', function(){
const res = response();
const date = new Date();
res.lastModified = date;
(res.lastModified.getTime() / 1000)
.should.equal(Math.floor(date.getTime() / 1000));
(res.lastModified.getTime() / 1000).should.equal(Math.floor(date.getTime() / 1000));
});
describe('when lastModified not set', function(){

View File

@ -85,7 +85,7 @@ describe('res.status=', function(){
});
});
it('should strip content releated header fields after status set', function(done){
it('should strip content releated header fields after status set', done => {
const app = new Koa();
app.use(function(ctx){