eslint: add no-var rule

master
jongleberry 2015-10-22 15:46:47 -07:00
parent e7c72d7873
commit 16db0f60c4
8 changed files with 9 additions and 8 deletions

View File

@ -5,6 +5,7 @@ extends: standard
rules:
eqeqeq: 0
no-var: 2
semi: [2, always]
space-before-function-paren: [2, never]
yoda: 0

View File

@ -183,7 +183,7 @@ function respond() {
const res = this.res;
if (res.headersSent || !this.writable) return;
var body = this.body;
let body = this.body;
const code = this.status;
// ignore body

View File

@ -222,7 +222,7 @@ module.exports = {
get host() {
const proxy = this.app.proxy;
var host = proxy && this.get('X-Forwarded-Host');
let host = proxy && this.get('X-Forwarded-Host');
host = host || this.get('Host');
if (!host) return '';
return host.split(/\s*,\s*/)[0];

View File

@ -435,7 +435,7 @@ module.exports = {
else val = String(val);
this.res.setHeader(field, val);
} else {
for (var key in field) {
for (const key in field) {
this.set(key, field[key]);
}
}

View File

@ -36,14 +36,14 @@ describe('app.respond', function(){
describe('when this.type === null', function(){
it('should not send Content-Type header', function(done){
var app = new Koa();
const app = new Koa();
app.use(function *(){
this.body = '';
this.type = null;
});
var server = app.listen();
const server = app.listen();
request(server)
.get('/')

View File

@ -37,7 +37,7 @@ describe('ctx.href', function(){
port: address.port
}, function(res){
res.statusCode.should.equal(200);
var buf = '';
let buf = '';
res.setEncoding('utf8');
res.on('data', function(s){ buf += s; });
res.on('end', function(){

View File

@ -51,7 +51,7 @@ describe('ctx.redirect(url)', function(){
it('should escape the url', function(){
const ctx = context();
var url = '<script>';
let url = '<script>';
ctx.header.accept = 'text/html';
ctx.redirect(url);
url = escape(url);

View File

@ -43,7 +43,7 @@ describe('ctx.type=', function(){
describe('with an unknown extension', function(){
it('should not set a content-type', function(){
var ctx = context();
const ctx = context();
ctx.type = 'asdf';
assert(!ctx.type);
assert(!ctx.response.header['content-type']);