Skip to content

Commit

Permalink
Merge pull request #1536 from froatsnook/more-eslint
Browse files Browse the repository at this point in the history
More eslint style rules
  • Loading branch information
simov committed Apr 13, 2015
2 parents faddddb + 759ffc3 commit 3afa3fa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
8 changes: 7 additions & 1 deletion .eslintrc
Expand Up @@ -34,6 +34,12 @@
// eslint can't handle this, so the check is disabled.
"key-spacing": 0,
// Allow shadowing vars in outer scope (needs discussion)
"no-shadow": 0
"no-shadow": 0,
// Use if () { }
// ^ space
"space-after-keywords": [2, "always"],
// Use if () { }
// ^ space
"space-before-blocks": [2, "always"]
}
}
2 changes: 1 addition & 1 deletion lib/helpers.js
Expand Up @@ -4,7 +4,7 @@ var jsonSafeStringify = require('json-stringify-safe')
, crypto = require('crypto')

function deferMethod() {
if(typeof setImmediate === 'undefined') {
if (typeof setImmediate === 'undefined') {
return process.nextTick
}

Expand Down
2 changes: 1 addition & 1 deletion lib/multipart.js
Expand Up @@ -31,7 +31,7 @@ Multipart.prototype.isChunked = function (options) {

if (!chunked) {
parts.forEach(function (part) {
if(typeof part.body === 'undefined') {
if (typeof part.body === 'undefined') {
throw new Error('Body attribute missing in multipart.')
}
if (isstream(part.body)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -50,7 +50,7 @@
"browserify": "~5.9.1",
"browserify-istanbul": "~0.1.3",
"coveralls": "~2.11.2",
"eslint": "0.17.1",
"eslint": "0.18.0",
"function-bind": "~1.0.0",
"istanbul": "~0.3.2",
"karma": "~0.12.21",
Expand Down
20 changes: 11 additions & 9 deletions request.js
Expand Up @@ -415,7 +415,7 @@ Request.prototype.init = function (options) {
}

// If a string URI/URL was given, parse it into a URL object
if(typeof self.uri === 'string') {
if (typeof self.uri === 'string') {
self.uri = url.parse(self.uri)
}

Expand All @@ -425,7 +425,7 @@ Request.prototype.init = function (options) {
}

// Support Unix Sockets
if(self.uri.host === 'unix') {
if (self.uri.host === 'unix') {
// Get the socket & request paths from the URL
var unixParts = self.uri.path.split(':')
, host = unixParts[0]
Expand All @@ -443,7 +443,7 @@ Request.prototype.init = function (options) {
self.rejectUnauthorized = false
}

if(!self.hasOwnProperty('proxy')) {
if (!self.hasOwnProperty('proxy')) {
self.proxy = getProxyFromURI(self.uri)
}

Expand Down Expand Up @@ -579,12 +579,12 @@ Request.prototype.init = function (options) {
}

if (self.uri.auth && !self.hasHeader('authorization')) {
var uriAuthPieces = self.uri.auth.split(':').map(function(item){ return querystring.unescape(item) })
var uriAuthPieces = self.uri.auth.split(':').map(function(item) { return querystring.unescape(item) })
self.auth(uriAuthPieces[0], uriAuthPieces.slice(1).join(':'), true)
}

if (!self.tunnel && self.proxy && self.proxy.auth && !self.hasHeader('proxy-authorization')) {
var proxyAuthPieces = self.proxy.auth.split(':').map(function(item){
var proxyAuthPieces = self.proxy.auth.split(':').map(function(item) {
return querystring.unescape(item)
})
var authHeader = 'Basic ' + toBase64(proxyAuthPieces.join(':'))
Expand Down Expand Up @@ -1210,17 +1210,19 @@ Request.prototype.onRequestResponse = function (response) {
if (self._json) {
try {
response.body = JSON.parse(response.body, self._jsonReviver)
} catch (e) {}
} catch (e) {
// empty
}
}
debug('emitting complete', self.uri.href)
if(typeof response.body === 'undefined' && !self._json) {
if (typeof response.body === 'undefined' && !self._json) {
response.body = self.encoding === null ? new Buffer(0) : ''
}
self.emit('complete', response, response.body)
})
}
//if no callback
else{
else {
self.on('end', function () {
if (self._aborted) {
debug('aborted', self.uri.href)
Expand Down Expand Up @@ -1299,7 +1301,7 @@ Request.prototype.qs = function (q, clobber) {
base[i] = q[i]
}

if (self.qsLib.stringify(base, self.qsStringifyOptions) === ''){
if (self.qsLib.stringify(base, self.qsStringifyOptions) === '') {
return self
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test-baseUrl.js
Expand Up @@ -6,7 +6,7 @@ var http = require('http')
, url = require('url')

var s = http.createServer(function(req, res) {
if(req.url === '/redirect/') {
if (req.url === '/redirect/') {
res.writeHead(302, {
location : '/'
})
Expand Down

0 comments on commit 3afa3fa

Please sign in to comment.