eslint: add no-var rule
This commit is contained in:
parent
e7c72d7873
commit
16db0f60c4
8 changed files with 9 additions and 8 deletions
|
@ -5,6 +5,7 @@ extends: standard
|
|||
|
||||
rules:
|
||||
eqeqeq: 0
|
||||
no-var: 2
|
||||
semi: [2, always]
|
||||
space-before-function-paren: [2, never]
|
||||
yoda: 0
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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('/')
|
||||
|
|
|
@ -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(){
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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']);
|
||||
|
|
Loading…
Reference in a new issue