diff --git a/.eslintrc.json b/.eslintrc.json index f96c075add..6d13f18de6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -76,7 +76,6 @@ "no-multi-spaces": "off", "quotes": "off", "keyword-spacing": "off", - "space-infix-ops": "off", "no-plusplus": "off", "no-mixed-operators": "off", "semi": "off", diff --git a/app.js b/app.js index c348cbfed5..8e19fb5184 100644 --- a/app.js +++ b/app.js @@ -251,7 +251,7 @@ function setup() { install.setup(function (err, data) { var separator = ' '; if (process.stdout.columns > 10) { - for(var x=0,cols=process.stdout.columns-10;x'; + html += ''; break; } html += '
'; diff --git a/public/src/admin/extend/widgets.js b/public/src/admin/extend/widgets.js index 91e05beb04..ad7479f247 100644 --- a/public/src/admin/extend/widgets.js +++ b/public/src/admin/extend/widgets.js @@ -197,13 +197,13 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) { $.get(RELATIVE_PATH + '/api/admin/extend/widgets', function(data) { var areas = data.areas; - for(var i=0; i'+ data.onlineRegisteredCount +'' + + '
' + data.onlineRegisteredCount + '
' + '
Users
' + '' + '
' + - '
'+ data.onlineGuestCount +'
' + + '
' + data.onlineGuestCount + '
' + '
Guests
' + '
' + '
' + - '
'+ (data.onlineRegisteredCount + data.onlineGuestCount) +'
' + + '
' + (data.onlineRegisteredCount + data.onlineGuestCount) + '
' + '
Total
' + '
' + '
' + - '
'+ data.socketCount +'
' + + '
' + data.socketCount + '
' + '
Connections
' + '
'; @@ -150,7 +150,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) { if (g > 255) g = 255; else if (g < 0) g = 0; - return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16); + return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16); } function setupGraphs() { @@ -277,7 +277,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) { switch($(this).attr('data-until')) { case 'last-month': var lastMonth = new Date(); - lastMonth.setDate(lastMonth.getDate()-30); + lastMonth.setDate(lastMonth.getDate() - 30); until = lastMonth.getTime(); } updateTrafficGraph($(this).attr('data-units'), until); diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js index 398d24dd42..c406f0f879 100644 --- a/public/src/admin/manage/categories.js +++ b/public/src/admin/manage/categories.js @@ -179,7 +179,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri container.append(html); // Handle and children categories in this level have - for(var x=0,numCategories=categories.length;x' : + '' : '
' + userObj['icon:text'] + '
') + ' ' + userObj.username; } diff --git a/public/src/client/recent.js b/public/src/client/recent.js index 973819d44d..0a990560fc 100644 --- a/public/src/client/recent.js +++ b/public/src/client/recent.js @@ -108,7 +108,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite } else if (newPostCount === 1) { text = '[[recent:there-is-a-new-topic-and-a-new-post]]'; } else if (newPostCount > 1) { - text = '[[recent:there-is-a-new-topic-and-new-posts, ' + newPostCount +']]'; + text = '[[recent:there-is-a-new-topic-and-new-posts, ' + newPostCount + ']]'; } } else if (newTopicCount > 1) { if (newPostCount === 0) { @@ -116,7 +116,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite } else if (newPostCount === 1) { text = '[[recent:there-are-new-topics-and-a-new-post, ' + newTopicCount + ']]'; } else if (newPostCount > 1) { - text = '[[recent:there-are-new-topics-and-new-posts, ' + newTopicCount + ', ' + newPostCount +']]'; + text = '[[recent:there-are-new-topics-and-new-posts, ' + newTopicCount + ', ' + newPostCount + ']]'; } } diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js index bba3cb0dcb..2c63abc4fb 100644 --- a/public/src/client/topic/events.js +++ b/public/src/client/topic/events.js @@ -158,7 +158,7 @@ define('forum/topic/events', [ return true; } - for (var i=0; i 0) { - topicSearchEl.find('.count').html((index+1) + ' / ' + Search.current.results.length); + topicSearchEl.find('.count').html((index + 1) + ' / ' + Search.current.results.length); topicSearchEl.find('.prev, .next').removeAttr('disabled'); var data = { pid: Search.current.results[index], diff --git a/public/src/modules/taskbar.js b/public/src/modules/taskbar.js index 7f5978250b..3b38787e65 100644 --- a/public/src/modules/taskbar.js +++ b/public/src/modules/taskbar.js @@ -114,7 +114,7 @@ define('taskbar', function() { .addClass(data.options.className) .html('' + (data.options.icon ? ' ' : '') + - (data.options.image ? ' ': '') + + (data.options.image ? ' ' : '') + '' + title + '' + '') .attr({ diff --git a/public/src/modules/topicSelect.js b/public/src/modules/topicSelect.js index d0dd85b601..8362980993 100644 --- a/public/src/modules/topicSelect.js +++ b/public/src/modules/topicSelect.js @@ -71,7 +71,7 @@ define('topicSelect', ['components'], function(components) { end = tmp; } - for(var i=start; i<=end; ++i) { + for(var i = start; i <= end; ++i) { var topic = $('[component="category/topic"]').eq(i); toggleSelect(topic.find('[component="topic/select"]'), isSelected); } diff --git a/public/src/utils.js b/public/src/utils.js index 989a9506a6..474df8151c 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -276,7 +276,7 @@ for (var i = envs.length - 1; i >= 0; i--) { var env = envs[i]; - $el.addClass('hidden-'+env); + $el.addClass('hidden-' + env); if ($el.is(':hidden')) { $el.remove(); return env; @@ -309,8 +309,8 @@ labels = [], tmpDate; - for(var x=29;x>=0;x--) { - tmpDate = new Date(currentDay - (1000*60*60*24*x)); + for(var x = 29;x >= 0;x--) { + tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x)); labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate()); } @@ -461,7 +461,7 @@ } var len = this.length; var suffixLen = suffix.length; - for (var i=1; (i <= suffixLen && this[len - i] === suffix[suffixLen - i]); ++i) { + for (var i = 1; (i <= suffixLen && this[len - i] === suffix[suffixLen - i]); ++i) { continue; } return i > suffixLen; diff --git a/public/src/widgets.js b/public/src/widgets.js index 8bae7cc465..c798ce0f93 100644 --- a/public/src/widgets.js +++ b/public/src/widgets.js @@ -42,12 +42,12 @@ url: url, isMobile: utils.isMobile() }, function(renderedAreas) { - for (var x=0; x 1) { url += '?page=' + currentPage; @@ -149,7 +149,7 @@ topicsController.get = function(req, res, callback) { }, function (topicData, next) { function findPost(index) { - for(var i=0; i origRatio) { - desiredRatio = 1/desiredRatio; + desiredRatio = 1 / desiredRatio; } if (origRatio >= 1) { y = 0; // height is the smaller dimension here - x = Math.floor((w/2) - (h * desiredRatio / 2)); + x = Math.floor((w / 2) - (h * desiredRatio / 2)); crop = async.apply(image.crop.bind(image), x, y, h * desiredRatio, h); } else { x = 0; // width is the smaller dimension here - y = Math.floor(h/2 - (w * desiredRatio / 2)); + y = Math.floor(h / 2 - (w * desiredRatio / 2)); crop = async.apply(image.crop.bind(image), x, y, w, w * desiredRatio); } } else { diff --git a/src/logger.js b/src/logger.js index e646046bd9..b99fbfbb91 100644 --- a/src/logger.js +++ b/src/logger.js @@ -148,7 +148,7 @@ var opts = { * The format is: io: */ try { - return 'io: '+_uid+' '+_type+' '+util.inspect(Array.prototype.slice.call(_args))+'\n'; + return 'io: ' + _uid + ' ' + _type + ' ' + util.inspect(Array.prototype.slice.call(_args)) + '\n'; } catch(err) { winston.info("Logger.prepare_io_string: Failed", err); return "error"; diff --git a/src/messaging.js b/src/messaging.js index ae554f7359..cdf5f77ce4 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -156,10 +156,10 @@ var userNotifications = require('./user/notifications'); // Add a spacer in between messages with time gaps between them messages = messages.map(function(message, index) { // Compare timestamps with the previous message, and check if a spacer needs to be added - if (index > 0 && parseInt(message.timestamp, 10) > parseInt(messages[index-1].timestamp, 10) + (1000*60*5)) { + if (index > 0 && parseInt(message.timestamp, 10) > parseInt(messages[index - 1].timestamp, 10) + (1000 * 60 * 5)) { // If it's been 5 minutes, this is a new set of messages message.newSet = true; - } else if (index > 0 && message.fromuid !== messages[index-1].fromuid) { + } else if (index > 0 && message.fromuid !== messages[index - 1].fromuid) { // If the previous message was from the other person, this is also a new set message.newSet = true; } @@ -176,7 +176,7 @@ var userNotifications = require('./user/notifications'); function(index, next) { // Continue only if this isn't the first message in sorted set if (index > 0) { - db.getSortedSetRange(key, index-1, index-1, next); + db.getSortedSetRange(key, index - 1, index - 1, next); } else { messages[0].newSet = true; return next(undefined, messages); @@ -191,7 +191,7 @@ var userNotifications = require('./user/notifications'); } if ( - (parseInt(messages[0].timestamp, 10) > parseInt(fields.timestamp, 10) + (1000*60*5)) || + (parseInt(messages[0].timestamp, 10) > parseInt(fields.timestamp, 10) + (1000 * 60 * 5)) || (parseInt(messages[0].fromuid, 10) !== parseInt(fields.fromuid, 10)) ) { // If it's been 5 minutes, this is a new set of messages diff --git a/src/middleware/header.js b/src/middleware/header.js index be56abc44b..3386e35856 100644 --- a/src/middleware/header.js +++ b/src/middleware/header.js @@ -50,7 +50,7 @@ module.exports = function(middleware) { 'brand:logo': meta.config['brand:logo'] || '', 'brand:logo:url': meta.config['brand:logo:url'] || '', 'brand:logo:alt': meta.config['brand:logo:alt'] || '', - 'brand:logo:display': meta.config['brand:logo']?'':'hide', + 'brand:logo:display': meta.config['brand:logo'] ? '' : 'hide', allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval' || registrationType === 'admin-approval-ip', searchEnabled: plugins.hasListeners('filter:search.query'), config: res.locals.config, diff --git a/src/middleware/maintenance.js b/src/middleware/maintenance.js index 33079b88ef..2c8d30305b 100644 --- a/src/middleware/maintenance.js +++ b/src/middleware/maintenance.js @@ -43,7 +43,7 @@ module.exports = function(middleware) { }; var isAllowed = function(url) { - for(var x=0,numAllowed=allowedRoutes.length,route;x0; --i) { + for (i = pages.length - 1; i > 0; --i) { if (pages[i - 1].page !== pages[i].page - 1) { pages.splice(i, 0, {separator: true}); } diff --git a/src/plugins.js b/src/plugins.js index af3bc887c9..74cb39d034 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -126,7 +126,7 @@ var middleware; if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') { process.stdout.write('\n'); winston.warn('[plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it.'); - for(var x=0,numPlugins=Plugins.versionWarning.length;x= preventTopicDeleteAfterReplies) { var langKey = preventTopicDeleteAfterReplies > 1 ? - '[[error:cant-delete-topic-has-replies, ' + meta.config.preventTopicDeleteAfterReplies + ']]': + '[[error:cant-delete-topic-has-replies, ' + meta.config.preventTopicDeleteAfterReplies + ']]' : '[[error:cant-delete-topic-has-reply]]'; return callback(new Error(langKey)); } diff --git a/src/routes/feeds.js b/src/routes/feeds.js index 3ceefbb4d6..721a34cffc 100644 --- a/src/routes/feeds.js +++ b/src/routes/feeds.js @@ -350,7 +350,7 @@ function generateForPostsFeed(feedOptions, posts) { feed.item({ title: postData.topic ? postData.topic.title : '', description: postData.content, - url: nconf.get('url') + '/topic/' + (postData.topic ? postData.topic.slug : '#') + '/'+postData.index, + url: nconf.get('url') + '/topic/' + (postData.topic ? postData.topic.slug : '#') + '/' + postData.index, author: postData.user ? postData.user.username : '', date: new Date(parseInt(postData.timestamp, 10)).toUTCString() }); diff --git a/src/routes/index.js b/src/routes/index.js index 659f4132ae..3ef899d4df 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -94,7 +94,7 @@ module.exports = function(app, middleware, hotswapIds) { var ensureLoggedIn = require('connect-ensure-login'); if (Array.isArray(hotswapIds) && hotswapIds.length) { - for(var idx,x=0;x parseInt(max, 10)) { - return callback(new Error('[[error:'+ maxError + ', ' + max + ']]')); + return callback(new Error('[[error:' + maxError + ', ' + max + ']]')); } callback(); } diff --git a/src/topics/data.js b/src/topics/data.js index 6e7172bb5f..9a7553f2b0 100644 --- a/src/topics/data.js +++ b/src/topics/data.js @@ -40,7 +40,7 @@ module.exports = function(Topics) { Topics.getTopicsData = function(tids, callback) { var keys = []; - for (var i=0; i 19) { diff --git a/src/user/data.js b/src/user/data.js index c8af4698a9..19c54895dc 100644 --- a/src/user/data.js +++ b/src/user/data.js @@ -126,7 +126,7 @@ module.exports = function(User) { user.status = User.getStatus(user); } - for(var i=0; i 10 seconds', function(done) { - User.setUserField(testUid, 'lastposttime', +new Date()-(11*1000), function() { + User.setUserField(testUid, 'lastposttime', +new Date() - (11 * 1000), function() { Topics.post({ uid: testUid, title: 'Topic 3', @@ -141,7 +141,7 @@ describe('User', function() { Meta.config.newbiePostDelay = 30; Meta.config.newbiePostDelayThreshold = 3; - User.setUserField(testUid, 'lastposttime', +new Date()-(20*1000), function() { + User.setUserField(testUid, 'lastposttime', +new Date() - (20 * 1000), function() { Topics.post({ uid: testUid, title: 'Topic 4', @@ -156,7 +156,7 @@ describe('User', function() { it('should not error if a non-newbie user posts if the last post time is 10 < 30 seconds', function(done) { User.setUserFields(testUid, { - lastposttime: +new Date()-(20*1000), + lastposttime: +new Date() - (20 * 1000), reputation: 10 }, function() { Topics.post({