diff --git a/.eslintrc b/.eslintrc index 3ba166a274..d09a88ac00 100644 --- a/.eslintrc +++ b/.eslintrc @@ -86,9 +86,9 @@ "no-nested-ternary": "off", "operator-linebreak": "off", "guard-for-in": "off", - "no-unneeded-ternary": "off", - "no-sequences": "off", - "no-extend-native": "off", + // "no-unneeded-ternary": "off", + // "no-sequences": "off", + // "no-extend-native": "off", // "no-shadow-restricted-names": "off", // "no-extra-boolean-cast": "off", // "no-path-concat": "off", diff --git a/install/web.js b/install/web.js index dc9af8cce6..88b2495614 100644 --- a/install/web.js +++ b/install/web.js @@ -75,8 +75,8 @@ function welcome(req, res) { res.render('install/index', { databases: databases, skipDatabaseSetup: !!nconf.get('database'), - error: res.locals.error ? true : false, - success: res.locals.success ? true : false, + error: !!res.locals.error, + success: !!res.locals.success, values: req.body, minimumPasswordLength: defaults.minimumPasswordLength, }); diff --git a/loader.js b/loader.js index 66c2de862a..ead0e36125 100644 --- a/loader.js +++ b/loader.js @@ -111,7 +111,7 @@ function forkWorker(index, isPrimary) { } process.env.isPrimary = isPrimary; - process.env.isCluster = ports.length > 1 ? true : false; + process.env.isCluster = ports.length > 1; process.env.port = ports[index]; var worker = fork('app.js', args, { diff --git a/public/src/admin/manage/group.js b/public/src/admin/manage/group.js index f2e5c8c92e..8b77b2bf52 100644 --- a/public/src/admin/manage/group.js +++ b/public/src/admin/manage/group.js @@ -108,7 +108,7 @@ define('admin/manage/group', [ var btnEl = $(this); var userRow = btnEl.parents('[data-uid]'); var ownerFlagEl = userRow.find('.member-name i'); - var isOwner = !ownerFlagEl.hasClass('invisible') ? true : false; + var isOwner = !ownerFlagEl.hasClass('invisible'); var uid = userRow.attr('data-uid'); var action = btnEl.attr('data-action'); diff --git a/public/src/admin/modules/search.js b/public/src/admin/modules/search.js index 26ecd8eee0..e950ea76c5 100644 --- a/public/src/admin/modules/search.js +++ b/public/src/admin/modules/search.js @@ -73,7 +73,7 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) { if (!selected.length) { selected = menu.find('li.result > a').first().attr('href'); } - var href = selected ? selected : config.relative_path + '/search/' + input.val(); + var href = selected || config.relative_path + '/search/' + input.val(); ajaxify.go(href.replace(/^\//, '')); diff --git a/public/src/app.js b/public/src/app.js index e38f49178e..9983aef36f 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -129,7 +129,7 @@ app.cacheBuster = null; title: '[[global:alert.success]]', message: message, type: 'success', - timeout: timeout ? timeout : 5000, + timeout: timeout || 5000, }); }; @@ -144,7 +144,7 @@ app.cacheBuster = null; title: '[[global:alert.error]]', message: message, type: 'danger', - timeout: timeout ? timeout : 10000, + timeout: timeout || 10000, }); }; diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js index e4443ab7ff..e334f70ec5 100644 --- a/public/src/client/groups/details.js +++ b/public/src/client/groups/details.js @@ -54,7 +54,7 @@ define('forum/groups/details', [ var btnEl = $(this); var userRow = btnEl.parents('[data-uid]'); var ownerFlagEl = userRow.find('.member-name > i'); - var isOwner = !ownerFlagEl.hasClass('invisible') ? true : false; + var isOwner = !ownerFlagEl.hasClass('invisible'); var uid = userRow.attr('data-uid'); var action = btnEl.attr('data-action'); diff --git a/public/src/client/topic/move.js b/public/src/client/topic/move.js index 1b5b3b6c8a..5ff9a02c49 100644 --- a/public/src/client/topic/move.js +++ b/public/src/client/topic/move.js @@ -10,7 +10,7 @@ define('forum/topic/move', function () { Move.tids = tids; Move.currentCid = currentCid; Move.onComplete = onComplete; - Move.moveAll = tids ? false : true; + Move.moveAll = !tids; socket.emit('categories.getMoveCategories', onCategoriesLoaded); }; diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index eaaf4894ce..5023eb54e6 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -21,7 +21,7 @@ define('forum/topic/posts', [ return; } - data.loggedIn = app.user.uid ? true : false; + data.loggedIn = !!app.user.uid; data.privileges = ajaxify.data.privileges; Posts.modifyPostsByPrivileges(data.posts); diff --git a/public/src/utils.js b/public/src/utils.js index 2c2f4ac4dd..9d4692668d 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -448,6 +448,11 @@ }, }; + if ('undefined' !== typeof window) { + window.utils = module.exports; + } + + /* eslint "no-extend-native": "off" */ if (typeof String.prototype.startsWith !== 'function') { String.prototype.startsWith = function (prefix) { if (this.length < prefix.length) { @@ -474,10 +479,6 @@ return this.replace(/\s+$/g, ''); }; } - - if ('undefined' !== typeof window) { - window.utils = module.exports; - } }('undefined' === typeof module ? { module: { exports: {}, diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 47a15c1161..3a44f7b134 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -214,7 +214,7 @@ authenticationController.login = function (req, res, next) { if (err) { return next(err); } - req.body.username = username ? username : req.body.username; + req.body.username = username || req.body.username; continueLogin(req, res, next); }); } else if (loginWith.indexOf('username') !== -1 && !validator.isEmail(req.body.username)) { diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index d274146f67..c52d616624 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -138,7 +138,7 @@ module.exports = function (db, module) { } db.collection('objects').count(query, function (err, count) { - callback(err, count ? count : 0); + callback(err, count || 0); }); }; @@ -148,7 +148,7 @@ module.exports = function (db, module) { } db.collection('objects').count({ _key: key }, function (err, count) { count = parseInt(count, 10); - callback(err, count ? count : 0); + callback(err, count || 0); }); }; diff --git a/src/groups.js b/src/groups.js index 775d19b378..5ac3116db7 100644 --- a/src/groups.js +++ b/src/groups.js @@ -285,7 +285,7 @@ var utils = require('../public/src/utils'); return callback(err); } - callback(null, (parseInt(isPrivate, 10) === 0) ? false : true); + callback(null, parseInt(isPrivate, 10) !== 0); }); }; diff --git a/src/middleware/admin.js b/src/middleware/admin.js index fb950b7480..3e36b74db9 100644 --- a/src/middleware/admin.js +++ b/src/middleware/admin.js @@ -102,7 +102,7 @@ module.exports = function (middleware) { authentication: results.custom_header.authentication, scripts: results.scripts, 'cache-buster': meta.config['cache-buster'] || '', - env: process.env.NODE_ENV ? true : false, + env: !!process.env.NODE_ENV, title: (acpPath || 'Dashboard') + ' | NodeBB Admin Control Panel', bodyClass: data.bodyClass, }; diff --git a/src/user/settings.js b/src/user/settings.js index 115d0d92ad..870dd2e59c 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -17,7 +17,7 @@ module.exports = function (User) { return callback(err); } - onSettingsLoaded(uid, settings ? settings : {}, callback); + onSettingsLoaded(uid, settings || {}, callback); }); };