Fix indentation and add .eslint rules

closes #555
This commit is contained in:
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 yoda: 0
arrow-parens: [2, "as-needed"] arrow-parens: [2, "as-needed"]
arrow-spacing: 2 arrow-spacing: 2
dot-location: [2, "property"]

View file

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

View file

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

View file

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

View file

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

View file

@ -23,8 +23,7 @@ describe('res.lastModified', function(){
const res = response(); const res = response();
const date = new Date(); const date = new Date();
res.lastModified = date; res.lastModified = date;
(res.lastModified.getTime() / 1000) (res.lastModified.getTime() / 1000).should.equal(Math.floor(date.getTime() / 1000));
.should.equal(Math.floor(date.getTime() / 1000));
}); });
describe('when lastModified not set', function(){ 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(); const app = new Koa();
app.use(function(ctx){ app.use(function(ctx){