refactor: add prefer-const to .eslintrc + fix errors (#14880)

This commit is contained in:
Milan Burda 2018-10-02 03:56:31 +02:00 committed by Samuel Attard
parent 07161a8452
commit 3ad3ade828
47 changed files with 239 additions and 238 deletions

View file

@ -119,7 +119,7 @@ class ClientRequest extends EventEmitter {
let urlStr = options.url
if (!urlStr) {
let urlObj = {}
const urlObj = {}
const protocol = options.protocol || 'http:'
if (!kSupportedProtocols.has(protocol)) {
throw new Error('Protocol "' + protocol + '" not supported. ')
@ -149,7 +149,7 @@ class ClientRequest extends EventEmitter {
// an invalid request.
throw new TypeError('Request path contains unescaped characters.')
}
let pathObj = url.parse(options.path || '/')
const pathObj = url.parse(options.path || '/')
urlObj.pathname = pathObj.pathname
urlObj.search = pathObj.search
urlObj.hash = pathObj.hash
@ -161,7 +161,7 @@ class ClientRequest extends EventEmitter {
throw new Error('redirect mode should be one of follow, error or manual')
}
let urlRequestOptions = {
const urlRequestOptions = {
method: method,
url: urlStr,
redirect: redirectPolicy
@ -180,7 +180,7 @@ class ClientRequest extends EventEmitter {
}
}
let urlRequest = new URLRequest(urlRequestOptions)
const urlRequest = new URLRequest(urlRequestOptions)
// Set back and forward links.
this.urlRequest = urlRequest
@ -192,7 +192,7 @@ class ClientRequest extends EventEmitter {
this.extraHeaders = {}
if (options.headers) {
for (let key in options.headers) {
for (const key in options.headers) {
this.setHeader(key, options.headers[key])
}
}
@ -286,8 +286,8 @@ class ClientRequest extends EventEmitter {
}
_write (chunk, encoding, callback, isLast) {
let chunkIsString = typeof chunk === 'string'
let chunkIsBuffer = chunk instanceof Buffer
const chunkIsString = typeof chunk === 'string'
const chunkIsBuffer = chunk instanceof Buffer
if (!chunkIsString && !chunkIsBuffer) {
throw new TypeError('First argument must be a string or Buffer.')
}
@ -306,7 +306,7 @@ class ClientRequest extends EventEmitter {
// Headers are assumed to be sent on first call to _writeBuffer,
// i.e. after the first call to write or end.
let result = this.urlRequest.write(chunk, isLast)
const result = this.urlRequest.write(chunk, isLast)
// The write callback is fired asynchronously to mimic Node.js.
if (callback) {
@ -318,7 +318,7 @@ class ClientRequest extends EventEmitter {
write (data, encoding, callback) {
if (this.urlRequest.finished) {
let error = new Error('Write after end.')
const error = new Error('Write after end.')
process.nextTick(writeAfterEndNT, this, error, callback)
return true
}