Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update eslint #1494

Merged
merged 1 commit into from Mar 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion .eslintrc
Expand Up @@ -3,6 +3,8 @@
"node": true
},
"rules": {
// 2-space indentation
"indent": [2, 2],
// Disallow semi-colons, unless needed to disambiguate statement
"semi": [2, "never"],
// Require strings to use single quotes
Expand All @@ -17,6 +19,21 @@
"no-unused-vars": [2, {"args":"none"}],
// Allow leading underscores for method names
// REASON: we use underscores to denote private methods
"no-underscore-dangle": 0
"no-underscore-dangle": 0,
// Allow multi spaces around operators since they are
// used for alignment. This is not consistent in the
// code.
"no-multi-spaces": 0,
// Style rule is: most objects use { beforeColon: false, afterColon: true }, unless aligning which uses:
//
// {
// beforeColon : true,
// afterColon : true
// }
//
// eslint can't handle this, so the check is disabled.
"key-spacing": 0,
// Allow shadowing vars in outer scope (needs discussion)
"no-shadow": 0
}
}
4 changes: 2 additions & 2 deletions lib/getProxyFromURI.js
Expand Up @@ -49,7 +49,7 @@ function getProxyFromURI(uri) {
if (noProxy === '*') {
return null
}

// if the noProxy is not empty and the uri is found return null

if (noProxy !== '' && uriInNoProxy(uri, noProxy)) {
Expand All @@ -62,7 +62,7 @@ function getProxyFromURI(uri) {
return process.env.HTTP_PROXY ||
process.env.http_proxy || null
}

if (uri.protocol === 'https:') {
return process.env.HTTPS_PROXY ||
process.env.https_proxy ||
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers.js
Expand Up @@ -8,7 +8,7 @@ function deferMethod() {
if(typeof setImmediate === 'undefined') {
return process.nextTick
}

return setImmediate
}

Expand Down
3 changes: 1 addition & 2 deletions lib/oauth.js
@@ -1,7 +1,6 @@
'use strict'

var querystring = require('querystring')
, qs = require('qs')
var qs = require('qs')
, caseless = require('caseless')
, uuid = require('node-uuid')
, oauth = require('oauth-sign')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -49,7 +49,7 @@
"browserify": "~5.9.1",
"browserify-istanbul": "~0.1.3",
"coveralls": "~2.11.2",
"eslint": "0.5.1",
"eslint": "0.17.1",
"function-bind": "~1.0.0",
"istanbul": "~0.3.2",
"karma": "~0.12.21",
Expand Down
4 changes: 1 addition & 3 deletions request.js
Expand Up @@ -21,15 +21,13 @@ var http = require('http')
, FormData = require('form-data')
, cookies = require('./lib/cookies')
, copy = require('./lib/copy')
, net = require('net')
, getProxyFromURI = require('./lib/getProxyFromURI')
, Auth = require('./lib/auth').Auth
, OAuth = require('./lib/oauth').OAuth
, Multipart = require('./lib/multipart').Multipart
, Redirect = require('./lib/redirect').Redirect

var safeStringify = helpers.safeStringify
, md5 = helpers.md5
, isReadStream = helpers.isReadStream
, toBase64 = helpers.toBase64
, defer = helpers.defer
Expand Down Expand Up @@ -1292,7 +1290,7 @@ Request.prototype.form = function (form) {
}
// create form-data object
self._form = new FormData()
self._form.on('error',function(err) {
self._form.on('error', function(err) {
err.message = 'form-data: ' + err.message
self.emit('error', err)
self.abort()
Expand Down
20 changes: 10 additions & 10 deletions tests/browser/start.js
Expand Up @@ -7,16 +7,16 @@ var path = require('path')
var port = 6767

var server = https.createServer({
key: fs.readFileSync(path.join(__dirname, '/ssl/server.key')),
cert: fs.readFileSync(path.join(__dirname, '/ssl/server.crt')),
ca: fs.readFileSync(path.join(__dirname, '/ssl/ca.crt')),
requestCert: true,
rejectUnauthorized: false
}, function (req, res) {
// Set CORS header, since that is something we are testing.
res.setHeader('Access-Control-Allow-Origin', '*')
res.writeHead(200)
res.end('Can you hear the sound of an enormous door slamming in the depths of hell?\n')
key: fs.readFileSync(path.join(__dirname, '/ssl/server.key')),
cert: fs.readFileSync(path.join(__dirname, '/ssl/server.crt')),
ca: fs.readFileSync(path.join(__dirname, '/ssl/ca.crt')),
requestCert: true,
rejectUnauthorized: false
}, function (req, res) {
// Set CORS header, since that is something we are testing.
res.setHeader('Access-Control-Allow-Origin', '*')
res.writeHead(200)
res.end('Can you hear the sound of an enormous door slamming in the depths of hell?\n')
})
server.listen(port, function() {
console.log('Started https server for karma tests on port ' + port)
Expand Down
3 changes: 1 addition & 2 deletions tests/browser/test.js
Expand Up @@ -9,8 +9,7 @@ if (!Function.prototype.bind) {
}


var assert = require('assert')
, tape = require('tape')
var tape = require('tape')
, request = require('../../index')

tape('returns on error', function(t) {
Expand Down
3 changes: 1 addition & 2 deletions tests/server.js
Expand Up @@ -4,14 +4,13 @@ var fs = require('fs')
, http = require('http')
, path = require('path')
, https = require('https')
, events = require('events')
, stream = require('stream')
, assert = require('assert')

exports.port = 6767
exports.portSSL = 16167

exports.createServer = function (port) {
exports.createServer = function (port) {
port = port || exports.port
var s = http.createServer(function (req, resp) {
s.emit(req.url, req, resp)
Expand Down
2 changes: 1 addition & 1 deletion tests/test-basic-auth.js
Expand Up @@ -158,7 +158,7 @@ tape('pass - undefined', function(t) {
tape('auth method', function(t) {
var r = request
.get('http://localhost:6767/test/')
.auth('user','',false)
.auth('user', '', false)
.on('response', function (res) {
t.equal(r._auth.user, 'user')
t.equal(res.statusCode, 200)
Expand Down
4 changes: 2 additions & 2 deletions tests/test-bearer-auth.js
Expand Up @@ -98,7 +98,7 @@ tape('', function(t) {
tape('', function(t) {
request
.get('http://localhost:6767/test/')
.auth(null,null,false,'theToken')
.auth(null, null, false, 'theToken')
.on('response', function (res) {
t.equal(res.statusCode, 200)
t.equal(numBearerRequests, 7)
Expand All @@ -109,7 +109,7 @@ tape('', function(t) {
tape('', function(t) {
request
.get('http://localhost:6767/test/')
.auth(null,null,true,'theToken')
.auth(null, null, true, 'theToken')
.on('response', function (res) {
t.equal(res.statusCode, 200)
t.equal(numBearerRequests, 8)
Expand Down
4 changes: 1 addition & 3 deletions tests/test-body.js
@@ -1,8 +1,6 @@
'use strict'

var server = require('./server')
, events = require('events')
, stream = require('stream')
, request = require('../index')
, tape = require('tape')

Expand Down Expand Up @@ -146,6 +144,6 @@ addTest('testPutMultipartPostambleCRLF', {

tape('cleanup', function(t) {
s.close(function() {
t.end()
t.end()
})
})
3 changes: 1 addition & 2 deletions tests/test-errors.js
@@ -1,7 +1,6 @@
'use strict'

var server = require('./server')
, request = require('../index')
var request = require('../index')
, tape = require('tape')

var local = 'http://localhost:8888/asdf'
Expand Down
2 changes: 1 addition & 1 deletion tests/test-httpModule.js
Expand Up @@ -64,7 +64,7 @@ tape('setup', function(t) {

function run_tests(name, httpModules) {
tape(name, function(t) {
var to_https = 'http://localhost:' + plain_server.port + '/to_https'
var to_https = 'http://localhost:' + plain_server.port + '/to_https'
, to_plain = 'https://localhost:' + https_server.port + '/to_plain'
, options = { httpModules: httpModules, strictSSL: false }
, modulesTest = httpModules || {}
Expand Down
1 change: 0 additions & 1 deletion tests/test-json-request.js
@@ -1,7 +1,6 @@
'use strict'

var server = require('./server')
, stream = require('stream')
, request = require('../index')
, tape = require('tape')

Expand Down
5 changes: 3 additions & 2 deletions tests/test-multipart.js
Expand Up @@ -107,9 +107,10 @@ var testHeaders = [
'multipart/related; boundary=XXX; type=text/xml; start="<root>"'
]

var suite = ['post', 'get'].forEach(function(method) {
var methods = ['post', 'get']
methods.forEach(function(method) {
testHeaders.forEach(function(header) {
[true, false].forEach(function(json) {
[true, false].forEach(function(json) {
var name = [
'multipart-related', method.toUpperCase(),
(header || 'default'),
Expand Down
2 changes: 1 addition & 1 deletion tests/test-oauth.js
Expand Up @@ -451,7 +451,7 @@ tape('query transport_method with qs parameter and existing query string in url'
t.notOk(r.headers.Authorization, 'oauth Authorization header should not be present with transport_method \'query\'')
t.notOk(r.path.match(/\?&/), 'there should be no ampersand at the beginning of the query')
t.equal('OB33pYjWAnf+xtOHN4Gmbdil168=', qs.parse(r.path).oauth_signature)

var params = qs.parse(r.path.split('?')[1])
, keys = Object.keys(params)

Expand Down
3 changes: 1 addition & 2 deletions tests/test-pipes.js
@@ -1,7 +1,6 @@
'use strict'

var server = require('./server')
, events = require('events')
, stream = require('stream')
, fs = require('fs')
, request = require('../index')
Expand Down Expand Up @@ -238,7 +237,7 @@ tape('piping after response', function(t) {

tape('piping through a redirect', function(t) {
s.once('/forward1', function(req, res) {
res.writeHead(302, { location: '/forward2' })
res.writeHead(302, { location: '/forward2' })
res.end()
})
s.once('/forward2', function(req, res) {
Expand Down
3 changes: 1 addition & 2 deletions tests/test-proxy-connect.js
@@ -1,7 +1,6 @@
'use strict'

var net = require('net')
, request = require('../index')
var request = require('../index')
, tape = require('tape')

var port = 6768
Expand Down
1 change: 0 additions & 1 deletion tests/test-redirect-auth.js
Expand Up @@ -3,7 +3,6 @@
var server = require('./server')
, request = require('../index')
, util = require('util')
, events = require('events')
, tape = require('tape')

var s = server.createServer()
Expand Down
2 changes: 1 addition & 1 deletion tests/test-redirect-complex.js
Expand Up @@ -73,7 +73,7 @@ tape('lots of redirects', function(t) {
})
}

for (var i = 0; i < n; i ++) {
for (var i = 0; i < n; i++) {
doRedirect(i)
}
})
Expand Down
6 changes: 3 additions & 3 deletions tests/test-redirect.js
Expand Up @@ -323,9 +323,9 @@ tape('should have the referer when following redirect by default', function(t) {
t.equal(res.statusCode, 200)
t.end()
})
.on('redirect',function() {
.on('redirect', function() {
t.notEqual(this.headers.referer, undefined)
t.equal(this.headers.referer.substring(this.headers.referer.lastIndexOf('/')),'/temp_landing')
t.equal(this.headers.referer.substring(this.headers.referer.lastIndexOf('/')), '/temp_landing')
})
})

Expand All @@ -341,7 +341,7 @@ tape('should not have a referer when removeRefererHeader is true', function(t) {
t.equal(res.statusCode, 200)
t.end()
})
.on('redirect',function() {
.on('redirect', function() {
t.equal(this.headers.referer, undefined)
})
})
Expand Down
2 changes: 0 additions & 2 deletions tests/test-timeout.js
Expand Up @@ -11,8 +11,6 @@ if (process.env.TRAVIS === 'true') {
/*eslint no-process-exit:0*/
} else {
var server = require('./server')
, events = require('events')
, stream = require('stream')
, request = require('../index')
, tape = require('tape')

Expand Down
3 changes: 1 addition & 2 deletions tests/test-timing.js
@@ -1,7 +1,6 @@
'use strict'

var http = require('http')
, server = require('./server')
var server = require('./server')
, request = require('../index')
, tape = require('tape')

Expand Down
8 changes: 4 additions & 4 deletions tests/test-toJSON.js
Expand Up @@ -25,12 +25,12 @@ tape('request().toJSON()', function(t) {

t.equal(err, null)

t.equal(json_r.uri.href , r.uri.href)
t.equal(json_r.method , r.method)
t.equal(json_r.uri.href, r.uri.href)
t.equal(json_r.method, r.method)
t.equal(json_r.headers.foo, r.headers.foo)

t.equal(json_res.statusCode , res.statusCode)
t.equal(json_res.body , res.body)
t.equal(json_res.statusCode, res.statusCode)
t.equal(json_res.body, res.body)
t.equal(json_res.headers.date, res.headers.date)

t.end()
Expand Down
2 changes: 1 addition & 1 deletion tests/test-unix.js
Expand Up @@ -27,7 +27,7 @@ tape('setup', function(t) {
})

tape('unix socket connection', function(t) {
request('http://unix:' + socket + ':' + path, function(err, res, body) {
request('http://unix:' + socket + ':' + path, function(err, res, body) {
t.equal(err, null, 'no error in connection')
t.equal(res.statusCode, statusCode, 'got HTTP 200 OK response')
t.equal(body, expectedBody, 'expected response body is received')
Expand Down