1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Replace jshint with eslint and add lots of rules

Fix eslint errors accordingly
This commit is contained in:
Ruben Bridgewater
2016-03-26 04:05:43 +01:00
parent 12579e5e8e
commit 94e9f1fcfc
98 changed files with 1621 additions and 1551 deletions

View File

@@ -12,16 +12,16 @@ if (typeof EventEmitter !== 'function') {
EventEmitter = EventEmitter.EventEmitter;
}
function once(cb) {
function once (cb) {
var called = false;
return function() {
return function () {
if (called) return;
called = true;
cb.apply(this, arguments);
};
}
function StunnelProcess(conf_dir) {
function StunnelProcess (conf_dir) {
EventEmitter.call(this);
// set up an stunnel to redis; edit the conf file to include required absolute paths
@@ -33,16 +33,16 @@ function StunnelProcess(conf_dir) {
// handle child process events, and failure to set up tunnel
var self = this;
this.timer = setTimeout(function() {
this.timer = setTimeout(function () {
self.emit('error', new Error('Timeout waiting for stunnel to start'));
}, 8000);
stunnel.on('error', function(err) {
stunnel.on('error', function (err) {
self.clear();
self.emit('error', err);
});
stunnel.on('exit', function(code) {
stunnel.on('exit', function (code) {
self.clear();
if (code === 0) {
self.emit('stopped');
@@ -52,7 +52,7 @@ function StunnelProcess(conf_dir) {
});
// wait to stunnel to start
stunnel.stderr.on("data", function(data) {
stunnel.stderr.on('data', function (data) {
if (data.toString().match(/Service.+redis.+bound/)) {
clearTimeout(this.timer);
self.emit('started');
@@ -61,25 +61,25 @@ function StunnelProcess(conf_dir) {
}
util.inherits(StunnelProcess, EventEmitter);
StunnelProcess.prototype.clear = function() {
StunnelProcess.prototype.clear = function () {
this.stunnel = null;
clearTimeout(this.timer);
};
StunnelProcess.prototype.stop = function(done) {
StunnelProcess.prototype.stop = function (done) {
if (this.stunnel) {
this.stunnel.kill();
}
};
module.exports = {
start: function(done, conf_dir) {
start: function (done, conf_dir) {
done = once(done);
var stunnel = new StunnelProcess(conf_dir);
stunnel.once('error', done.bind(done));
stunnel.once('started', done.bind(done, null, stunnel));
},
stop: function(stunnel, done) {
stop: function (stunnel, done) {
stunnel.removeAllListeners();
stunnel.stop();
stunnel.once('error', done.bind(done));