Skip to content

Commit c46150d

Browse files
committed
Switch from jshint to eslint
1 parent 2c95881 commit c46150d

15 files changed

+103
-87
lines changed
File renamed without changes.

.eslintrc

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"rules": {
6+
"no-bitwise": true,
7+
"camelcase": true,
8+
"curly": true,
9+
"eqeqeq": true,
10+
"forin": true,
11+
"freeze": true,
12+
"immed": true,
13+
"indent": [2,2],
14+
"no-shadow": false,
15+
"latedef": true,
16+
"newcap": true,
17+
"noarg": true,
18+
"noempty": true,
19+
"nonew": true,
20+
"strict": true,
21+
"quotes": "single",
22+
"max-depth": 3,
23+
"trailing": true,
24+
"max-statements": 15,
25+
"max-len": [2,100,4],
26+
"eqnull": true,
27+
"funcscope": true,
28+
"undef": true,
29+
"unused": true,
30+
"node": true,
31+
"no-underscore-dangle": false
32+
}
33+
}

.jshintrc

-26
This file was deleted.

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
'use strict';
22

3-
module.exports = require('./lib/multi');
3+
module.exports = require('./lib/multi');

lib/cache-lib/node-cache.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ module.exports = function(options) {
66

77
return new NodeCache(options);
88

9-
};
9+
};

lib/multi.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
'use strict';
22

3-
var MultiCache;
3+
44
var createCache = require('./create-cache');
55
var async = require('async');
66
var _ = require('lodash');
77
var MultiError = require('./cache-lib/multi-error');
88

9-
module.exports = MultiCache = (function(){
10-
9+
var MultiCache = (function(){
1110
function MultiCache(localCache, remoteCache, options) {
1211
this.options = options != null ? options : {};
1312
if(!this.options.disabled) {
@@ -38,24 +37,24 @@ module.exports = MultiCache = (function(){
3837
}
3938

4039
if(self._useLocalCache(options)) {
41-
self.localCache.get(keys, function(err,value){
40+
self.localCache.get(keys, function(err, value){
4241
if(err) {
43-
return callback(err,value);
42+
return callback(err, value);
4443
}
4544
if(!_.isEmpty(value) || !self._useRemoteCache(options)) {
4645
return callback(err, value);
4746
}
4847

49-
self.remoteCache.get(keys, function(err,value){
48+
self.remoteCache.get(keys, function(err, value){
5049
if(err) {
51-
return callback(err,value);
50+
return callback(err, value);
5251
}
5352
if(options && options.setLocal && !_.isEmpty(value)) {
5453
self.localCache.set(keys, value, {localCache: true, remoteCache: false}, function(){
5554
return callback(err, value);
5655
});
5756
} else {
58-
return callback(err,value);
57+
return callback(err, value);
5958
}
6059
});
6160

@@ -84,18 +83,19 @@ module.exports = MultiCache = (function(){
8483
}
8584
}
8685
}
87-
return this._set(key, value, ttl, options, callback);
88-
};
8986

90-
MultiCache.prototype._set = function(key, value, ttl, options, callback) {
9187
if(this.options.disabled) {
9288
if(callback) {
9389
return callback(null);
9490
} else {
95-
return;
91+
return undefined;
9692
}
9793
}
9894

95+
return this._set(key, value, ttl, options, callback);
96+
};
97+
98+
MultiCache.prototype._set = function(key, value, ttl, options, callback) {
9999
var setters = this._useMethods(options, 'set');
100100

101101
if(setters.length === 0) {
@@ -163,3 +163,4 @@ module.exports = MultiCache = (function(){
163163
return MultiCache;
164164
})();
165165

166+
module.exports = MultiCache;

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
"main": "index.js",
66
"public": true,
77
"publishConfig": {
8-
"registry":"http://registry.npmjs.org/"
8+
"registry": "http://registry.npmjs.org/"
99
},
1010
"scripts": {
1111
"pre-commit-update": "node_modules/.bin/npm-update-outdated",
1212
"test": "mocha --recursive",
13-
"posttest": "jshint .",
14-
"jshint": "jshint .",
13+
"posttest": "eslint .",
14+
"lint": "eslint .",
1515
"check-coverage": "istanbul check-coverage --statements 100 --branches 100 --functions 100 --lines 100 ./coverage/coverage.json",
1616
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- --recursive",
1717
"pre-commit-stash-save": "git stash --keep-index",
1818
"post-commit-stash-pop": "git stash pop"
1919
},
2020
"pre-commit": [
2121
"pre-commit-update",
22-
"jshint",
22+
"lint",
2323
"pre-commit-stash-save",
2424
"coverage",
2525
"post-commit-stash-pop",
@@ -49,12 +49,12 @@
4949
"redis": "0.12.1"
5050
},
5151
"devDependencies": {
52+
"eslint": "^0.19.0",
5253
"istanbul": "^0.3.13",
53-
"jshint": "^2.6.3",
5454
"mocha": "^2.2.4",
5555
"npm-update-outdated": "^0.1.4",
5656
"pre-commit": "^1.0.6",
57-
"sinon" : "^1.14.1"
57+
"sinon": "^1.14.1"
5858
},
5959
"engines": {
6060
"node": ">= 0.10.0"

test/.eslintrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
}
5+
}

test/.jshintrc

-5
This file was deleted.

test/lib/cache-lib/test.multi-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var assert = require('assert');
44
var MultiError = require('../../../lib/cache-lib/multi-error');
55

6-
describe('Multi-Error',function(){
6+
describe('Multi-Error', function(){
77

88
it('should create with params', function(done){
99
var multiError = new MultiError();

test/lib/cache-lib/test.redis.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ describe('redis plugin', function(){
6565
done();
6666
});
6767
});
68-
});
68+
});

test/lib/cache-lib/test.validate-api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var assert = require('assert');
44
var nodeCache = require('../../../lib/cache-lib/node-cache')();
55
var redis = require('../../../lib/cache-lib/redis')();
66

7-
describe('Validate API',function(){
7+
describe('Validate API', function(){
88

99
it('should validate end points of APIs', function(done){
1010
var apis = [nodeCache, redis];

test/lib/test.create-cache.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var createCache = require('../../lib/create-cache');
44
var assert = require('assert');
55

6-
describe('Multi Cache',function(){
6+
describe('Multi Cache', function(){
77

88
it('should be null if the cache type is not supported', function(done){
99
var cache = createCache('this cache does not exist');

test/lib/test.multi-expiration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var MultiCache = require('../..');
44
var assert = require('assert');
55
var _ = require('lodash');
66

7-
describe('Multi Cache',function(){
7+
describe('Multi Cache', function(){
88
var testRemoteOnly = {
99
useLocalCache: false,
1010
useRemoteCache: true

test/lib/test.multi.js

+39-31
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,35 @@ var assert = require('assert');
66
var _ = require('lodash');
77
var sinon = require('sinon');
88

9-
describe('Multi Cache',function(){
10-
var localCacheName = 'node-cache';
11-
var remoteCacheName = 'node-cache';
12-
var testRemoteOnly = {
13-
useLocalCache: false,
14-
useRemoteCache: true
15-
};
16-
var testLocalOnly = {
17-
useLocalCache: true,
18-
useRemoteCache: false
19-
};
20-
var testBothActive = {
21-
useLocalCache: true,
22-
useRemoteCache: true
23-
};
24-
var testBothInactive = {
25-
useLocalCache: false,
26-
useRemoteCache: false
27-
};
28-
29-
describe('Class creation',function() {
9+
describe('Multi Cache', function(){
10+
var localCacheName,
11+
remoteCacheName,
12+
testRemoteOnly,
13+
testLocalOnly,
14+
testBothActive,
15+
testBothInactive;
16+
before(function(){
17+
localCacheName = 'node-cache';
18+
remoteCacheName = 'node-cache';
19+
testRemoteOnly = {
20+
useLocalCache: false,
21+
useRemoteCache: true
22+
};
23+
testLocalOnly = {
24+
useLocalCache: true,
25+
useRemoteCache: false
26+
};
27+
testBothActive = {
28+
useLocalCache: true,
29+
useRemoteCache: true
30+
};
31+
testBothInactive = {
32+
useLocalCache: false,
33+
useRemoteCache: false
34+
};
35+
});
36+
37+
describe('Class creation', function() {
3038

3139
it('should create a Multi-Cache without options', function (done) {
3240
var multiCache = new MultiCache(localCacheName, remoteCacheName);
@@ -78,7 +86,7 @@ describe('Multi Cache',function(){
7886

7987
});
8088

81-
describe('Setting',function() {
89+
describe('Setting', function() {
8290

8391
it('should set an object in the local cache only', function (done) {
8492
var multiCache = new MultiCache(localCacheName, remoteCacheName, testLocalOnly);
@@ -107,7 +115,7 @@ describe('Multi Cache',function(){
107115
assert(!_.isEmpty(result));
108116
multiCache.get('myKey', testLocalOnly, function (err, value) {
109117
assert(!err);
110-
assert.equal(undefined, value);
118+
assert.equal(undefined, value);
111119
// Test that key/value is in remoteCache
112120
multiCache.get('myKey', testRemoteOnly, function (err, value) {
113121
assert(!err);
@@ -188,7 +196,7 @@ describe('Multi Cache',function(){
188196
assert(!_.isEmpty(result));
189197
multiCache.get('myKey', testBothInactive, function (err, value) {
190198
assert(typeof err === 'object');
191-
assert.equal(undefined, value);
199+
assert.equal(undefined, value);
192200
assert.equal('local or remote must be specified when getting from cache', err.message);
193201
done();
194202
});
@@ -197,13 +205,13 @@ describe('Multi Cache',function(){
197205

198206
});
199207

200-
describe('Disabled',function() {
208+
describe('Disabled', function() {
201209

202210
it('should noop on set when disabled with callback', function (done) {
203211
var multiCache = new MultiCache(localCacheName, remoteCacheName, {disabled: true});
204212
multiCache.set('myKey', 'myValue', function (err, result) {
205213
assert(!err);
206-
assert.equal(undefined,result);
214+
assert.equal(undefined, result);
207215
done();
208216
});
209217
});
@@ -225,15 +233,15 @@ describe('Multi Cache',function(){
225233
it('should noop on del when disabled', function (done) {
226234
var multiCache = new MultiCache(localCacheName, remoteCacheName, {disabled: true});
227235
multiCache.del('myKey', function (err, result) {
228-
assert.equal(undefined,err);
229-
assert.equal(undefined,result);
236+
assert.equal(undefined, err);
237+
assert.equal(undefined, result);
230238
done();
231239
});
232240
});
233241

234242
});
235243

236-
describe('Getting',function() {
244+
describe('Getting', function() {
237245

238246
it('should get an object from the remote cache if local is empty', function (done) {
239247
var multiCache = new MultiCache(localCacheName, remoteCacheName);
@@ -307,7 +315,7 @@ describe('Multi Cache',function(){
307315

308316
});
309317

310-
describe('Deleting',function() {
318+
describe('Deleting', function() {
311319

312320
it('should delete an object in the local cache only', function (done) {
313321
var multiCache = new MultiCache(localCacheName, remoteCacheName);
@@ -405,7 +413,7 @@ describe('Multi Cache',function(){
405413
});
406414
});
407415

408-
describe('Complex objects',function() {
416+
describe('Complex objects', function() {
409417

410418
it('should set and get complex objects', function (done) {
411419
var multiCache = new MultiCache(localCacheName, remoteCacheName);

0 commit comments

Comments
 (0)