Skip to content

Commit cd3c845

Browse files
authored
Update eslint to 2.13.1, make eslintrc more strict (#205)
1 parent 29b14f8 commit cd3c845

File tree

11 files changed

+298
-275
lines changed

11 files changed

+298
-275
lines changed

.eslintrc

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,86 @@
33
"node": true,
44
"mocha": true,
55
},
6+
"extends": "eslint:recommended",
67
"rules": {
8+
"array-bracket-spacing": [2, "never"],
79
"block-scoped-var": 2,
8-
"dot-notation": [
9-
2,
10-
{
11-
"allowKeywords": true
12-
}
13-
],
14-
"eqeqeq": [
15-
2,
16-
"allow-null"
17-
],
10+
"brace-style": [2, "1tbs"],
11+
"camelcase": [1, "properties": "never"],
12+
"comma-dangle": 0,
13+
"comma-spacing": [2, {"before": false, "after": true}],
14+
"comma-style": [2, "last"],
15+
"computed-property-spacing": [2, "never"],
16+
"consistent-return": 2,
17+
"consistent-this": [2, "self"],
18+
"curly": [2, "multi-line"],
19+
"default-case": 2,
20+
"dot-notation": 2,
21+
"eol-last": 2,
22+
"eqeqeq": [2, "allow-null"],
1823
"guard-for-in": 2,
24+
"indent": [2, 2, {"SwitchCase": 1, "VariableDeclarator": { "var": 2, "let": 2, "const": 3}}],
25+
"key-spacing": [1, {"beforeColon": false, "afterColon": true}],
26+
"keyword-spacing": 2,
27+
"max-len": [1, 120],
1928
"new-cap": 2,
29+
"no-alert": 2,
2030
"no-caller": 2,
21-
"no-cond-assign": [
22-
2,
23-
"except-parens"
24-
],
31+
"no-catch-shadow": 1,
32+
"no-console": 1,
2533
"no-debugger": 2,
26-
"no-empty": 2,
34+
"no-else-return": 2,
35+
"no-empty": [2, {"allowEmptyCatch": true}],
2736
"no-eval": 2,
37+
"no-extra-bind": 2,
2838
"no-extend-native": 2,
2939
"no-extra-parens": 2,
30-
"no-irregular-whitespace": 2,
40+
"no-fallthrough": 2,
41+
"no-floating-decimal": 2,
42+
"no-implied-eval": 2,
43+
"no-inner-declarations": 2,
3144
"no-iterator": 2,
45+
"no-lonely-if": 2,
3246
"no-loop-func": 2,
47+
"no-mixed-spaces-and-tabs": 2,
48+
"no-multiple-empty-lines": [2, {"max": 2}],
49+
"no-multi-spaces": 2,
3350
"no-multi-str": 2,
3451
"no-new": 2,
52+
"no-param-reassign": 1,
3553
"no-proto": 2,
54+
"no-redeclare": 2,
55+
"no-return-assign": 2,
3656
"no-script-url": 2,
57+
"no-self-compare": 2,
3758
"no-sequences": 2,
3859
"no-shadow": 2,
60+
"no-shadow-restricted-names": 2,
61+
"no-spaced-func": 2,
62+
"no-trailing-spaces": 2,
3963
"no-undef": 2,
40-
"no-unused-vars": [
41-
2,
42-
{"args": "none"}
43-
],
64+
"no-undefined": 2,
65+
"no-underscore-dangle": 0,
66+
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
67+
"no-use-before-define": [2, "nofunc"],
68+
"no-useless-call": 2,
69+
"no-useless-escape": 2,
70+
"no-warning-comments": 0,
4471
"no-with": 2,
45-
"quotes": [
46-
2,
47-
"single",
48-
"avoid-escape"
49-
],
50-
"semi": [
51-
0,
52-
"never"
53-
],
54-
"strict": [
55-
2,
56-
"global"
57-
],
72+
"object-curly-spacing": [2, "always"],
73+
"quotes": [2, "single", "avoid-escape"],
74+
"semi": [2, "always"],
75+
"semi-spacing": [2, {"before": false, "after": true}],
76+
"space-before-blocks": 2,
77+
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
78+
"space-in-parens": 2,
79+
"space-infix-ops": 2,
80+
"space-unary-ops": 2,
81+
"spaced-comment": [2, "always"],
82+
"strict": [2, "global"],
83+
"valid-jsdoc": 0,
5884
"valid-typeof": 2,
59-
"wrap-iife": [
60-
2,
61-
"inside"
62-
]
85+
"wrap-iife": [2, "inside"],
86+
"yoda": [2, "never"]
6387
}
6488
}

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module.exports = require('./lib/client');
44
module.exports.utils = require('./lib/utils');
55
module.exports.middleware = {
6-
connect: require('./lib/middleware/connect')
6+
connect: require('./lib/middleware/connect')
77
};
88
// friendly alias for "raven.middleware.express"
99
module.exports.middleware.express = module.exports.middleware.connect;

lib/client.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ var zlib = require('zlib');
66
var utils = require('./utils');
77
var uuid = require('node-uuid');
88
var transports = require('./transports');
9-
var node_util = require('util'); // node_util to avoid confusion with "utils"
9+
var nodeUtil = require('util'); // nodeUtil to avoid confusion with "utils"
1010
var events = require('events');
1111

1212
module.exports.version = require('../package.json').version;
1313

14-
var extend = Object.assign || function(target) {
14+
var extend = Object.assign || function (target) {
1515
for (var i = 1; i < arguments.length; i++) {
1616
var source = arguments[i];
1717
for (var key in source) {
@@ -63,9 +63,9 @@ var Client = function Client(dsn, options) {
6363
globalContext.extra = options.extra;
6464
}
6565

66-
this.on('error', function(e) {}); // noop
66+
this.on('error', function (e) {}); // noop
6767
};
68-
node_util.inherits(Client, events.EventEmitter);
68+
nodeUtil.inherits(Client, events.EventEmitter);
6969
var proto = Client.prototype;
7070

7171
module.exports.Client = Client;
@@ -110,25 +110,25 @@ proto.process = function process(kwargs) {
110110
kwargs = this.dataCallback(kwargs);
111111
}
112112

113-
// this will happen asynchronously. We don't care about it's response.
113+
// this will happen asynchronously. We don't care about its response.
114114
this._enabled && this.send(kwargs, ident);
115115

116116
return ident;
117117
};
118118

119119
proto.send = function send(kwargs, ident) {
120120
var self = this;
121-
121+
122122
var skwargs = stringify(kwargs);
123123

124-
zlib.deflate(skwargs, function(err, buff) {
124+
zlib.deflate(skwargs, function (err, buff) {
125125
var message = buff.toString('base64'),
126-
timestamp = new Date().getTime(),
127-
headers = {
128-
'X-Sentry-Auth': utils.getAuthHeader(timestamp, self.dsn.public_key, self.dsn.private_key),
129-
'Content-Type': 'application/octet-stream',
130-
'Content-Length': message.length
131-
};
126+
timestamp = new Date().getTime(),
127+
headers = {
128+
'X-Sentry-Auth': utils.getAuthHeader(timestamp, self.dsn.public_key, self.dsn.private_key),
129+
'Content-Type': 'application/octet-stream',
130+
'Content-Length': message.length
131+
};
132132

133133
self.transport.send(self, message, headers, ident);
134134
});
@@ -161,7 +161,7 @@ proto.captureException = function captureError(err, kwargs, cb) {
161161
} else {
162162
kwargs = kwargs || {};
163163
}
164-
parsers.parseError(err, kwargs, function(kw) {
164+
parsers.parseError(err, kwargs, function (kw) {
165165
var result = self.process(kw);
166166
cb && cb(result);
167167
});
@@ -230,7 +230,7 @@ module.exports.patchGlobal = function patchGlobal(client, cb) {
230230
!(client instanceof Client) && (client = new Client());
231231

232232
var called = false;
233-
process.on('uncaughtException', function(err) {
233+
process.on('uncaughtException', function (err) {
234234
if (cb) { // bind event listeners only if a callback was supplied
235235
var onLogged = function onLogged() {
236236
called = false;
@@ -254,8 +254,8 @@ module.exports.patchGlobal = function patchGlobal(client, cb) {
254254

255255
called = true;
256256

257-
client.captureError(err, function(result) {
258-
node_util.log('uncaughtException: ' + client.getIdent(result));
257+
return client.captureError(err, function (result) {
258+
nodeUtil.log('uncaughtException: ' + client.getIdent(result));
259259
});
260260
});
261261
};

lib/middleware/connect.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ var raven = require('../client');
44
var parsers = require('../parsers');
55

66
// Legacy support
7-
var connectMiddleware = function(client) {
7+
var connectMiddleware = function (client) {
88
return connectMiddleware.errorHandler(client);
99
};
1010

1111
// Error handler. This should be the last item listed in middleware, but
1212
// before any other error handlers.
13-
connectMiddleware.errorHandler = function(client) {
13+
connectMiddleware.errorHandler = function (client) {
1414
client = client instanceof raven.Client ? client : new raven.Client(client);
15-
return function(err, req, res, next) {
15+
return function (err, req, res, next) {
1616
var status = err.status || err.statusCode || err.status_code || 500;
1717

1818
// skip anything not marked as an internal server error
1919
if (status < 500) return next(err);
2020

2121
var kwargs = parsers.parseRequest(req);
22-
client.captureError(err, kwargs, function(result) {
22+
return client.captureError(err, kwargs, function (result) {
2323
res.sentry = client.getIdent(result);
2424
next(err, req, res);
2525
});
@@ -28,13 +28,13 @@ connectMiddleware.errorHandler = function(client) {
2828

2929
// Ensures asynchronous exceptions are routed to the errorHandler. This
3030
// should be the **first** item listed in middleware.
31-
connectMiddleware.requestHandler = function(client) {
31+
connectMiddleware.requestHandler = function (client) {
3232
var domain = require('domain');
33-
return function(req, res, next) {
33+
return function (req, res, next) {
3434
var reqDomain = domain.create();
3535
reqDomain.on('error', next);
3636
return reqDomain.run(next);
3737
};
3838
};
3939

40-
module.exports = connectMiddleware;
40+
module.exports = connectMiddleware;

lib/parsers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports.parseText = function parseText(message, kwargs) {
1414
};
1515

1616
module.exports.parseError = function parseError(err, kwargs, cb) {
17-
utils.parseStack(err, function(frames) {
17+
utils.parseStack(err, function (frames) {
1818
var name = err.name + '';
1919
if (typeof kwargs.message === 'undefined') {
2020
kwargs.message = name + ': ' + (err.message || '<no message>');
@@ -96,7 +96,7 @@ module.exports.parseRequest = function parseRequest(req, kwargs) {
9696
// express: req.protocol
9797
// koa: req.protocol
9898
//
99-
var protocol = 'https' === req.protocol || true === req.secure || true === (req.socket || {}).encrypted ? 'https' : 'http';
99+
var protocol = req.protocol === 'https' || req.secure || (req.socket || {}).encrypted ? 'https' : 'http';
100100

101101
// url (including path and query string):
102102
//

lib/transports.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function HTTPTransport(options) {
1414
this.options = options || {};
1515
}
1616
util.inherits(HTTPTransport, Transport);
17-
HTTPTransport.prototype.send = function(client, message, headers, ident) {
17+
HTTPTransport.prototype.send = function (client, message, headers, ident) {
1818
var options = {
1919
hostname: client.dsn.host,
2020
path: client.dsn.path + 'api/' + client.dsn.project_id + '/store/',
@@ -28,7 +28,7 @@ HTTPTransport.prototype.send = function(client, message, headers, ident) {
2828
options[key] = this.options[key];
2929
}
3030
}
31-
var req = this.transport.request(options, function(res) {
31+
var req = this.transport.request(options, function (res) {
3232
res.setEncoding('utf8');
3333
if (res.statusCode >= 200 && res.statusCode < 300) {
3434
client.emit('logged', ident);
@@ -44,11 +44,11 @@ HTTPTransport.prototype.send = function(client, message, headers, ident) {
4444
client.emit('error', e);
4545
}
4646
// force the socket to drain
47-
var noop = function() {};
47+
var noop = function () {};
4848
res.on('data', noop);
4949
res.on('end', noop);
5050
});
51-
req.on('error', function(e) {
51+
req.on('error', function (e) {
5252
client.emit('error', e);
5353
});
5454
req.end(message);

0 commit comments

Comments
 (0)