diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..0799652254 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,20 @@ +node_modules/ +public/src/nodebb.min.js +*.sublime-project +*.sublime-workspace +.project +.vagrant +.DS_Store +logs/ +/public/templates +/public/uploads +/public/sounds +/public/vendor +/public/nodebb.min.js +/public/acp.min.js +/public/src/modules/string.js +.idea/ +.vscode/ +*.ipr +*.iws +/coverage diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..f8ca19c4cb --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,6 @@ +{ + "rules": { + "handle-callback-err": [ "error", "^(e$|(e|(.*(_e|E)))rr)" ] + } +} + diff --git a/.gitignore b/.gitignore index a83a93d01f..510c95a201 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ provision.sh *.komodoproject .DS_Store feeds/recent.rss +.eslintcache logs/ @@ -51,4 +52,4 @@ tx.exe .transifexrc ##Coverage output -coverage \ No newline at end of file +coverage diff --git a/package.json b/package.json index 56323b7773..00f6fb2f30 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "main": "app.js", "scripts": { "start": "node loader.js", + "lint": "eslint --cache .", + "pretest": "npm run lint", "test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- ./tests -t 10000" }, "dependencies": { @@ -90,6 +92,7 @@ "xregexp": "~3.1.0" }, "devDependencies": { + "eslint": "^3.4.0", "grunt": "~0.4.5", "grunt-contrib-watch": "^1.0.0", "istanbul": "^0.4.2", diff --git a/public/src/admin/settings/email.js b/public/src/admin/settings/email.js index 02edfffcaa..e404099800 100644 --- a/public/src/admin/settings/email.js +++ b/public/src/admin/settings/email.js @@ -79,6 +79,10 @@ define('admin/settings/email', ['admin/settings'], function(settings) { } socket.emit('meta.getServerTime', {}, function(err, now) { + if (err) { + return app.alertError(err.message); + } + now = new Date(now); $('#serverTime').text(now.toString()); diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index e0dc2f5649..ce2c652b6a 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -381,7 +381,9 @@ authenticationController.localLogin = function(req, username, password, next) { if (result.banned) { // Retrieve ban reason and show error return user.getLatestBanInfo(uid, function(err, banInfo) { - if (banInfo.reason) { + if (err) { + next(err); + } else if (banInfo.reason) { next(new Error('[[error:user-banned-reason, ' + banInfo.reason + ']]')); } else { next(new Error('[[error:user-banned]]'));