Skip to content

Commit

Permalink
use eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
zemirco committed Jul 3, 2015
1 parent 04ac1b1 commit 0eb25e3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
9 changes: 9 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

env:
node: true
mocha: true

rules:
quotes: [2, "single"]
camelcase: 0
no-underscore-dangle: 0
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';

var MongoClient = require('mongodb').MongoClient;
var uuid = require('node-uuid');
Expand All @@ -20,7 +21,7 @@ var moment = require('moment');
*/
var Adapter = module.exports = function(config) {

if (!(this instanceof Adapter)) return new Adapter(config);
if (!(this instanceof Adapter)) {return new Adapter(config); }

this.config = config;
this.collection = config.db.collection;
Expand All @@ -31,7 +32,7 @@ var Adapter = module.exports = function(config) {
// create connection as soon as module is required and share global db object
var that = this;
MongoClient.connect(url, function(err, database) {
if (err) throw err;
if (err) {throw err; }
that.db = database;
});

Expand Down Expand Up @@ -82,7 +83,7 @@ Adapter.prototype.save = function(name, email, pw, done) {

// create salt and hash
pwd.hash(pw, function(err, salt, hash) {
if (err) return done(err);
if (err) {return done(err); }
user.salt = salt;
user.derived_key = hash;
that.db.collection(that.collection).save(user, done);
Expand Down Expand Up @@ -148,8 +149,8 @@ Adapter.prototype.find = function(match, query, done) {
Adapter.prototype.update = function(user, done) {
var that = this;
// update user in db
that.db.collection(that.collection).save(user, function(err, res) {
if (err) return done(err);
that.db.collection(that.collection).save(user, function(err) {
if (err) {return done(err); }
// res is not the updated user object! -> find manually
that.db.collection(that.collection).findOne({_id: user._id}, done);
});
Expand All @@ -172,8 +173,8 @@ Adapter.prototype.update = function(user, done) {
*/
Adapter.prototype.remove = function(name, done) {
this.db.collection(this.collection).remove({name: name}, function(err, numberOfRemovedDocs) {
if (err) return done(err);
if (numberOfRemovedDocs === 0) return done(new Error('lockit - Cannot find user "' + name + '"'));
if (err) {return done(err); }
if (numberOfRemovedDocs === 0) {return done(new Error('lockit - Cannot find user "' + name + '"')); }
done(null, true);
});
};
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
"mongodb": "^1.4.5"
},
"devDependencies": {
"should": "^3.3.1",
"grunt-mocha-test": "^0.10.2",
"eslint": "^0.24.0",
"grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.10.0"
"grunt-contrib-jshint": "^0.10.0",
"grunt-mocha-test": "^0.10.2",
"should": "^3.3.1"
}
}

0 comments on commit 0eb25e3

Please sign in to comment.