diff --git a/.eslintrc b/.eslintrc index 1bd5d05c88..95b90ba253 100644 --- a/.eslintrc +++ b/.eslintrc @@ -50,6 +50,7 @@ "no-shadow": "off", "no-script-url": "off", "no-use-before-define": "off", + "default-case": "off", // "linebreak-style": "off", // "one-var": "off", @@ -72,9 +73,8 @@ "radix": "off", "no-else-return": "off", "no-useless-escape": "off", - "block-scoped-var": "off", - "operator-assignment": "off", - "default-case": "off", + // "block-scoped-var": "off", + // "operator-assignment": "off", // "yoda": "off", // "no-loop-func": "off", // "no-void": "off", diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index 5023eb54e6..689d443ad3 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -311,7 +311,7 @@ define('forum/topic/posts', [ var imageRect = this.getBoundingClientRect(); if (imageRect.top < threshold) { - scrollTop = scrollTop + (newHeight - oldHeight); + scrollTop += newHeight - oldHeight; $(window).scrollTop(scrollTop); } diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js index 40fed9da2b..2796b8d94e 100644 --- a/public/src/modules/helpers.js +++ b/public/src/modules/helpers.js @@ -62,8 +62,8 @@ }; helpers.stripTags = function (str) { - if (typeof S !== 'undefined') { - return S(String(str)).stripTags().s; + if (typeof window !== 'undefined' && window.S) { + return window.S(String(str)).stripTags().s; } else { var S = require('string'); return S(String(str)).stripTags().s; diff --git a/src/batch.js b/src/batch.js index 19595df07e..cb3fd298a1 100644 --- a/src/batch.js +++ b/src/batch.js @@ -95,7 +95,7 @@ exports.processArray = function (array, process, options, callback) { if (err) { return next(err); } - start = start + batch; + start += batch; if (options.interval) { setTimeout(next, options.interval); } else { diff --git a/src/coverPhoto.js b/src/coverPhoto.js index b86d032a24..024ae48f20 100644 --- a/src/coverPhoto.js +++ b/src/coverPhoto.js @@ -20,7 +20,7 @@ function getCover(type, id) { if (typeof id === 'string') { id = (id.charCodeAt(0) + id.charCodeAt(1)) % covers.length; } else { - id = id % covers.length; + id %= covers.length; } return covers[id]; diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js index e253135c47..57c72cdc91 100644 --- a/src/database/mongo/hash.js +++ b/src/database/mongo/hash.js @@ -77,8 +77,9 @@ module.exports = function (db, module) { var _fields = { _id: 0, }; + var i; - for (var i = 0; i < fields.length; i += 1) { + for (i = 0; i < fields.length; i += 1) { fields[i] = helpers.fieldToString(fields[i]); _fields[fields[i]] = 1; } diff --git a/src/pagination.js b/src/pagination.js index c0332ebd14..3e57c5b201 100644 --- a/src/pagination.js +++ b/src/pagination.js @@ -26,7 +26,8 @@ pagination.create = function (currentPage, pageCount, queryObj) { if (startPage > pageCount - 5) { startPage -= 2 - (pageCount - currentPage); } - for (var i = 0; i < 5; i += 1) { + var i; + for (i = 0; i < 5; i += 1) { pagesToShow.push(startPage + i); } diff --git a/src/routes/index.js b/src/routes/index.js index 1091a50fe9..86c7960f6a 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -97,8 +97,11 @@ module.exports = function (app, middleware, hotswapIds) { var relativePath = nconf.get('relative_path'); var ensureLoggedIn = require('connect-ensure-login'); + var idx; + var x; + if (Array.isArray(hotswapIds) && hotswapIds.length) { - for (var idx, x = 0; x < hotswapIds.length; x += 1) { + for (x = 0; x < hotswapIds.length; x += 1) { idx = routers.push(express.Router()) - 1; routers[idx].hotswapId = hotswapIds[x]; } diff --git a/src/socket.io/categories.js b/src/socket.io/categories.js index b1c95af7e9..1678b553bf 100644 --- a/src/socket.io/categories.js +++ b/src/socket.io/categories.js @@ -94,7 +94,7 @@ SocketCategories.loadMore = function (socket, data, callback) { var start = Math.max(0, parseInt(data.after, 10)); if (data.direction === -1) { - start = start - (reverse ? infScrollTopicsPerPage : -infScrollTopicsPerPage); + start -= reverse ? infScrollTopicsPerPage : -infScrollTopicsPerPage; } var stop = start + infScrollTopicsPerPage - 1;