Merge pull request #159 from seejohnrun/add_eslint
Added eslint and fixed an issue from #158
This commit is contained in:
commit
cf28e23d8e
6 changed files with 36 additions and 13 deletions
25
.eslintrc.json
Normal file
25
.eslintrc.json
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"es6": true,
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"rules": {
|
||||||
|
"indent": [
|
||||||
|
"error",
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"linebreak-style": [
|
||||||
|
"error",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ MemcachedDocumentStore.connect = function(options) {
|
||||||
// Save file in a key
|
// Save file in a key
|
||||||
MemcachedDocumentStore.prototype.set =
|
MemcachedDocumentStore.prototype.set =
|
||||||
function(key, data, callback, skipExpire) {
|
function(key, data, callback, skipExpire) {
|
||||||
MemcachedDocumentStore.client.set(key, data, function(err, reply) {
|
MemcachedDocumentStore.client.set(key, data, function(err) {
|
||||||
err ? callback(false) : callback(true);
|
err ? callback(false) : callback(true);
|
||||||
}, skipExpire ? 0 : this.expire);
|
}, skipExpire ? 0 : this.expire);
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ PostgresDocumentStore.prototype = {
|
||||||
key,
|
key,
|
||||||
data,
|
data,
|
||||||
that.expireJS && !skipExpire ? that.expireJS + now : null
|
that.expireJS && !skipExpire ? that.expireJS + now : null
|
||||||
], function (err, result) {
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error('error persisting value to postgres', { error: err });
|
winston.error('error persisting value to postgres', { error: err });
|
||||||
return callback(false);
|
return callback(false);
|
||||||
|
@ -50,7 +50,7 @@ PostgresDocumentStore.prototype = {
|
||||||
client.query('UPDATE entries SET expiration = $1 WHERE ID = $2', [
|
client.query('UPDATE entries SET expiration = $1 WHERE ID = $2', [
|
||||||
that.expireJS + now,
|
that.expireJS + now,
|
||||||
result.rows[0].id
|
result.rows[0].id
|
||||||
], function (err, result) {
|
], function (err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ RedisDocumentStore.connect = function(options) {
|
||||||
if (options.password) {
|
if (options.password) {
|
||||||
RedisDocumentStore.client.auth(options.password);
|
RedisDocumentStore.client.auth(options.password);
|
||||||
}
|
}
|
||||||
RedisDocumentStore.client.select(index, function(err, reply) {
|
RedisDocumentStore.client.select(index, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error(
|
winston.error(
|
||||||
'error connecting to redis index ' + index,
|
'error connecting to redis index ' + index,
|
||||||
|
@ -46,7 +46,7 @@ RedisDocumentStore.connect = function(options) {
|
||||||
// Save file in a key
|
// Save file in a key
|
||||||
RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) {
|
RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
RedisDocumentStore.client.set(key, data, function(err, reply) {
|
RedisDocumentStore.client.set(key, data, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(false);
|
callback(false);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) {
|
||||||
// Expire a key in expire time if set
|
// Expire a key in expire time if set
|
||||||
RedisDocumentStore.prototype.setExpiration = function(key) {
|
RedisDocumentStore.prototype.setExpiration = function(key) {
|
||||||
if (this.expire) {
|
if (this.expire) {
|
||||||
RedisDocumentStore.client.expire(key, this.expire, function(err, reply) {
|
RedisDocumentStore.client.expire(key, this.expire, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error('failed to set expiry on key: ' + key);
|
winston.error('failed to set expiry on key: ' + key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,11 @@ var fs = require('fs');
|
||||||
|
|
||||||
var DictionaryGenerator = function(options) {
|
var DictionaryGenerator = function(options) {
|
||||||
//Options
|
//Options
|
||||||
if (!options)
|
if (!options) throw Error('No options passed to generator');
|
||||||
return done(Error('No options passed to generator'));
|
if (!options.path) throw Error('No dictionary path specified in options');
|
||||||
if (!options.path)
|
|
||||||
return done(Error('No dictionary path specified in options'));
|
|
||||||
|
|
||||||
//Load dictionary
|
//Load dictionary
|
||||||
fs.readFile(options.path, 'utf8', (err,data) => {
|
fs.readFile(options.path, 'utf8', (err, data) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
this.dictionary = data.split(/[\n\r]+/);
|
this.dictionary = data.split(/[\n\r]+/);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Draws inspiration from pwgen and http://tools.arantius.com/password
|
// Draws inspiration from pwgen and http://tools.arantius.com/password
|
||||||
var PhoneticKeyGenerator = function(options) {
|
var PhoneticKeyGenerator = function() {
|
||||||
// No options
|
// No options
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue