Skip to content

Commit

Permalink
eslint no-var updates
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Sep 15, 2017
1 parent 78c895d commit 3c71abc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
8 changes: 0 additions & 8 deletions .eslintrc.json

This file was deleted.

18 changes: 18 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
env:
node: true
es6: true
mocha: true

plugins: [ haraka ]

extends: [ eslint:recommended, plugin:haraka/recommended ]

root: true

globals:
OK: true
CONT: true
DENY: true
DENYSOFT: true
DENYDISCONNECT: true
DENYSOFTDISCONNECT: true
36 changes: 18 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
/* global server */

var redis = require('redis');
const redis = require('redis');

exports.register = function () {
var plugin = this;
const plugin = this;

plugin.load_redis_ini();

Expand All @@ -17,22 +17,22 @@ exports.register = function () {
};

exports.load_redis_ini = function () {
var plugin = this;
const plugin = this;

plugin.redisCfg = plugin.config.get('redis.ini', function () {
plugin.load_redis_ini();
});

if (!plugin.redisCfg.server) plugin.redisCfg.server = {};
var s = plugin.redisCfg.server;
const s = plugin.redisCfg.server;
if (s.ip && !s.host) s.host = s.ip;
if (!s.host) s.host = '127.0.0.1';
if (!s.port) s.port = '6379';

if (!plugin.redisCfg.pubsub) {
plugin.redisCfg.pubsub = JSON.parse(JSON.stringify(s));
}
var ps = plugin.redisCfg.pubsub;
const ps = plugin.redisCfg.pubsub;
if (!ps.host) ps.host = s.host;
if (!ps.port) ps.port = s.port;

Expand All @@ -43,7 +43,7 @@ exports.load_redis_ini = function () {
};

exports.merge_redis_ini = function () {
var plugin = this;
const plugin = this;

if (!plugin.cfg) plugin.cfg = {}; // no <plugin>.ini loaded?

Expand All @@ -60,9 +60,9 @@ exports.merge_redis_ini = function () {
}

exports.init_redis_shared = function (next, server) {
var plugin = this;
const plugin = this;

var calledNext = false;
let calledNext = false;
function nextOnce () {
if (calledNext) return;
calledNext = true;
Expand All @@ -82,20 +82,20 @@ exports.init_redis_shared = function (next, server) {
});
}
else {
let opts = JSON.parse(JSON.stringify(plugin.redisCfg.opts));
const opts = JSON.parse(JSON.stringify(plugin.redisCfg.opts));
opts.host = plugin.redisCfg.server.host;
opts.port = plugin.redisCfg.server.port;
server.notes.redis = plugin.get_redis_client(opts, nextOnce);
}
};

exports.init_redis_plugin = function (next, server) {
var plugin = this;
const plugin = this;

// this function is called by plugins at init_*, to establish their
// shared or unique redis db handle.

var calledNext=false;
let calledNext=false;
function nextOnce () {
if (calledNext) return;
calledNext = true;
Expand Down Expand Up @@ -128,8 +128,8 @@ exports.shutdown = function () {
}

exports.redis_ping = function (done) {
var plugin = this;
var nope = function (err) {
const plugin = this;
const nope = function (err) {
plugin.redis_pings=false;
done(err);
};
Expand All @@ -147,15 +147,15 @@ exports.redis_ping = function (done) {
};

exports.get_redis_client = function (opts, next) {
var plugin = this;
const plugin = this;

var client = redis.createClient(opts)
const client = redis.createClient(opts)
.on('error', function (error) {
plugin.logerror('Redis error: ' + error.message);
next();
})
.on('ready', function () {
var msg = 'connected to redis://' + opts.host + ':' + opts.port;
let msg = 'connected to redis://' + opts.host + ':' + opts.port;
if (opts.db) msg += '/' + opts.db;
if (client.server_info && client.server_info.redis_version) {
msg += ' v' + client.server_info.redis_version;
Expand All @@ -181,7 +181,7 @@ exports.get_redis_sub_channel = function (conn) {
};

exports.redis_subscribe_pattern = function (pattern, next) {
var plugin = this;
const plugin = this;
if (plugin.redis) {
// already subscribed?
return next();
Expand All @@ -199,7 +199,7 @@ exports.redis_subscribe_pattern = function (pattern, next) {
};

exports.redis_subscribe = function (connection, next) {
var plugin = this;
const plugin = this;

if (connection.notes.redis) {
// another plugin has already called this. Do nothing
Expand Down
14 changes: 7 additions & 7 deletions test/redis.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';

var fixtures = require('haraka-test-fixtures');
const fixtures = require('haraka-test-fixtures');

var _set_up_redis = function (done) {
function _set_up_redis (done) {

this.plugin = new fixtures.plugin('index');
this.plugin.register();

done();
};
}

var retry = function (options) {
function retry (options) {
if (options.error) {
console.error(options.error);
}
return undefined;
};
}

exports.redis = {
setUp : _set_up_redis,
Expand All @@ -32,7 +32,7 @@ exports.redis = {
},
'connects' : function (test) {
test.expect(1);
var redis = this.plugin.get_redis_client({
const redis = this.plugin.get_redis_client({
host: this.plugin.redisCfg.server.host,
port: this.plugin.redisCfg.server.port,
retry_strategy: retry,
Expand All @@ -54,7 +54,7 @@ exports.redis = {
this.plugin.merge_redis_ini();
this.plugin.cfg.redis.db = 2;
this.plugin.cfg.redis.retry_strategy = retry;
var client = this.plugin.get_redis_client(this.plugin.cfg.redis, function () {
const client = this.plugin.get_redis_client(this.plugin.cfg.redis, function () {
test.expect(2);
// console.log(client);
test.equal(client.connected, true);
Expand Down

0 comments on commit 3c71abc

Please sign in to comment.