From 0eb25e367458a2e94bdbd18c96e6dce8b6306557 Mon Sep 17 00:00:00 2001 From: Mirco Zeiss Date: Fri, 3 Jul 2015 13:43:23 +0200 Subject: [PATCH] use eslint --- .eslintrc | 9 +++++++++ index.js | 15 ++++++++------- package.json | 7 ++++--- 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..1e99864 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,9 @@ + +env: + node: true + mocha: true + +rules: + quotes: [2, "single"] + camelcase: 0 + no-underscore-dangle: 0 diff --git a/index.js b/index.js index d2168af..15f8c1a 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +'use strict'; var MongoClient = require('mongodb').MongoClient; var uuid = require('node-uuid'); @@ -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; @@ -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; }); @@ -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); @@ -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); }); @@ -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); }); }; diff --git a/package.json b/package.json index 4951421..4cc6a94 100644 --- a/package.json +++ b/package.json @@ -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" } }