Skip to content

Commit 1a884a8

Browse files
committed
Merge pull request #1019 from NodeRedis/eslint
Replace jshint with eslint and fix everything according to the new rules
2 parents 12579e5 + 94e9f1f commit 1a884a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1621
-1551
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules/**
22
coverage/**
33
**.md
4-
**.log
4+
**.log

.eslintrc

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
env:
2+
node: true
3+
es6: false
4+
5+
rules:
6+
# Possible Errors
7+
# http://eslint.org/docs/rules/#possible-errors
8+
comma-dangle: [2, "only-multiline"]
9+
no-constant-condition: 2
10+
no-control-regex: 2
11+
no-debugger: 2
12+
no-dupe-args: 2
13+
no-dupe-keys: 2
14+
no-duplicate-case: 2
15+
no-empty: 2
16+
no-empty-character-class: 2
17+
no-ex-assign: 2
18+
no-extra-boolean-cast : 2
19+
no-extra-parens: [2, "functions"]
20+
no-extra-semi: 2
21+
no-func-assign: 2
22+
no-invalid-regexp: 2
23+
no-irregular-whitespace: 2
24+
no-negated-in-lhs: 2
25+
no-obj-calls: 2
26+
no-regex-spaces: 2
27+
no-sparse-arrays: 2
28+
no-inner-declarations: 2
29+
no-unexpected-multiline: 2
30+
no-unreachable: 2
31+
use-isnan: 2
32+
valid-typeof: 2
33+
34+
# Best Practices
35+
# http://eslint.org/docs/rules/#best-practices
36+
array-callback-return: 2
37+
block-scoped-var: 2
38+
dot-notation: 2
39+
eqeqeq: 2
40+
no-else-return: 2
41+
no-extend-native: 2
42+
no-floating-decimal: 2
43+
no-extra-bind: 2
44+
no-fallthrough: 2
45+
no-labels: 2
46+
no-lone-blocks: 2
47+
no-loop-func: 2
48+
no-multi-spaces: 2
49+
no-multi-str: 2
50+
no-native-reassign: 2
51+
no-new-wrappers: 2
52+
no-octal: 2
53+
no-proto: 2
54+
no-redeclare: 2
55+
no-return-assign: 2
56+
no-self-assign: 2
57+
no-self-compare: 2
58+
no-sequences: 2
59+
no-throw-literal: 2
60+
no-useless-call: 2
61+
no-useless-concat: 2
62+
no-useless-escape: 2
63+
no-void: 2
64+
no-unmodified-loop-condition: 2
65+
yoda: 2
66+
67+
# Strict Mode
68+
# http://eslint.org/docs/rules/#strict-mode
69+
strict: [2, "global"]
70+
71+
# Variables
72+
# http://eslint.org/docs/rules/#variables
73+
no-delete-var: 2
74+
no-shadow-restricted-names: 2
75+
no-undef: 2
76+
no-unused-vars: [2, {"args": "none"}]
77+
78+
# http://eslint.org/docs/rules/#nodejs-and-commonjs
79+
no-mixed-requires: 2
80+
no-new-require: 2
81+
no-path-concat: 2
82+
83+
# Stylistic Issues
84+
# http://eslint.org/docs/rules/#stylistic-issues
85+
comma-spacing: 2
86+
eol-last: 2
87+
indent: [2, 4, {SwitchCase: 2}]
88+
keyword-spacing: 2
89+
max-len: [2, 200, 2]
90+
new-parens: 2
91+
no-mixed-spaces-and-tabs: 2
92+
no-multiple-empty-lines: [2, {max: 2}]
93+
no-trailing-spaces: 2
94+
quotes: [2, "single", "avoid-escape"]
95+
semi: 2
96+
space-before-blocks: [2, "always"]
97+
space-before-function-paren: [2, "always"]
98+
space-in-parens: [2, "never"]
99+
space-infix-ops: 2
100+
space-unary-ops: 2
101+
102+
globals:
103+
it: true
104+
describe: true
105+
before: true
106+
after: true
107+
beforeEach: true
108+
afterEach: true

.jshintrc

Lines changed: 0 additions & 27 deletions
This file was deleted.

benchmarks/diff_multi_bench_output.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ var total_ops = new metrics.Histogram.createUniformHistogram();
2323

2424
console.log('Comparing before,', file1, '(', before_lines.length, 'lines)', 'to after,', file2, '(', after_lines.length, 'lines)');
2525

26-
function is_whitespace(s) {
26+
function is_whitespace (s) {
2727
return !!s.trim();
2828
}
2929

30-
function pad(input, len, chr, right) {
30+
function pad (input, len, chr, right) {
3131
var str = input.toString();
3232
chr = chr || ' ';
3333

@@ -44,20 +44,20 @@ function pad(input, len, chr, right) {
4444
}
4545

4646
// green if greater than 0, red otherwise
47-
function humanize_diff(num, unit, toFixed) {
47+
function humanize_diff (num, unit, toFixed) {
4848
unit = unit || '';
4949
if (num > 0) {
5050
return ' +' + pad(num.toFixed(toFixed || 0) + unit, 7);
5151
}
5252
return ' -' + pad(Math.abs(num).toFixed(toFixed || 0) + unit, 7);
5353
}
5454

55-
function command_name(words) {
55+
function command_name (words) {
5656
var line = words.join(' ');
5757
return line.substr(0, line.indexOf(','));
5858
}
5959

60-
before_lines.forEach(function(b, i) {
60+
before_lines.forEach(function (b, i) {
6161
var a = after_lines[i];
6262
if (!a || !b || !b.trim() || !a.trim()) {
6363
// console.log('#ignored#', '>'+a+'<', '>'+b+'<');
@@ -66,10 +66,10 @@ before_lines.forEach(function(b, i) {
6666
var b_words = b.split(' ').filter(is_whitespace);
6767
var a_words = a.split(' ').filter(is_whitespace);
6868

69-
var ops = [b_words, a_words].map(function(words) {
69+
var ops = [b_words, a_words].map(function (words) {
7070
// console.log(words);
7171
return words.slice(-2, -1) | 0;
72-
}).filter(function(num) {
72+
}).filter(function (num) {
7373
var isNaN = !num && num !== 0;
7474
return !isNaN;
7575
});

benchmarks/multi_bench.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var tests = [];
1313
// bluebird.promisifyAll(redis.Multi.prototype);
1414

1515
function returnArg (name, def) {
16-
var matches = process.argv.filter(function(entry) {
16+
var matches = process.argv.filter(function (entry) {
1717
return entry.indexOf(name + '=') === 0;
1818
});
1919
if (matches.length) {
@@ -30,7 +30,7 @@ var client_options = {
3030
};
3131
var small_str, large_str, small_buf, large_buf, very_large_str, very_large_buf;
3232

33-
function lpad(input, len, chr) {
33+
function lpad (input, len, chr) {
3434
var str = input.toString();
3535
chr = chr || ' ';
3636
while (str.length < len) {
@@ -44,7 +44,7 @@ metrics.Histogram.prototype.print_line = function () {
4444
return lpad((obj.min / 1e6).toFixed(2), 6) + '/' + lpad((obj.max / 1e6).toFixed(2), 6) + '/' + lpad((obj.mean / 1e6).toFixed(2), 6);
4545
};
4646

47-
function Test(args) {
47+
function Test (args) {
4848
this.args = args;
4949
this.callback = null;
5050
this.clients = [];
@@ -101,7 +101,7 @@ Test.prototype.new_client = function (id) {
101101
});
102102

103103
// If no redis server is running, start one
104-
new_client.on('error', function(err) {
104+
new_client.on('error', function (err) {
105105
if (err.code === 'CONNECTION_BROKEN') {
106106
throw err;
107107
}
@@ -268,15 +268,15 @@ tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['foo_rand0000
268268
tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['foo_rand000000000002'], pipeline: 1, client_opts: { return_buffers: true} }));
269269
tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['foo_rand000000000002'], batch: 20, client_opts: { return_buffers: true} }));
270270

271-
function next() {
271+
function next () {
272272
var test = tests.shift();
273273
if (test) {
274274
test.run(function () {
275275
next();
276276
});
277277
} else if (rp) {
278278
// Stop the redis process if started by the benchmark
279-
rp.stop(function() {
279+
rp.stop(function () {
280280
rp = undefined;
281281
next();
282282
});

examples/auth.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
var redis = require('redis'),
4-
client = redis.createClient();
5-
3+
var redis = require('redis');
64
// The client stashes the password and will reauthenticate on every connect.
7-
client.auth('somepass');
5+
redis.createClient({
6+
password: 'somepass'
7+
});

examples/backpressure_drain.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict';
22

3-
var redis = require('../index'),
4-
client = redis.createClient(),
5-
remaining_ops = 100000, paused = false;
3+
var redis = require('../index');
4+
var client = redis.createClient();
5+
var remaining_ops = 100000;
6+
var paused = false;
67

7-
function op() {
8+
function op () {
89
if (remaining_ops <= 0) {
910
console.error('Finished.');
1011
process.exit(0);

examples/eval.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
var redis = require('../index'),
4-
client = redis.createClient();
3+
var redis = require('../index');
4+
var client = redis.createClient();
55

66
client.eval('return 100.5', 0, function (err, res) {
77
console.dir(err);

examples/extend.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
var redis = require('redis'),
4-
client = redis.createClient();
3+
var redis = require('redis');
4+
var client = redis.createClient();
55

66
// Extend the RedisClient prototype to add a custom method
77
// This one converts the results from 'INFO' into a JavaScript Object

examples/file.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
// Read a file from disk, store it in Redis, then read it back from Redis.
44

5-
var redis = require('redis'),
6-
client = redis.createClient({
7-
return_buffers: true
8-
}),
9-
fs = require('fs'),
10-
assert = require('assert'),
11-
filename = 'grumpyCat.jpg';
5+
var redis = require('redis');
6+
var client = redis.createClient({
7+
return_buffers: true
8+
});
9+
var fs = require('fs');
10+
var assert = require('assert');
11+
var filename = 'grumpyCat.jpg';
1212

1313
// Get the file I use for testing like this:
1414
// curl http://media4.popsugar-assets.com/files/2014/08/08/878/n/1922507/caef16ec354ca23b_thumb_temp_cover_file32304521407524949.xxxlarge/i/Funny-Cat-GIFs.jpg -o grumpyCat.jpg

0 commit comments

Comments
 (0)