Node.js based forum software built for the modern web
ESlint n-loop-func, yoda
Peter Jaszkowiaka0a50677da13
diff --git a/.eslintrc b/.eslintrcindex 1def8e8e04..1bd5d05c88 100644--- a/.eslintrc+++ b/.eslintrc@@ -49,6 +49,7 @@"no-restricted-syntax": "off","no-shadow": "off","no-script-url": "off",+ "no-use-before-define": "off",// "linebreak-style": "off",// "one-var": "off",@@ -74,9 +75,8 @@"block-scoped-var": "off","operator-assignment": "off","default-case": "off",- "yoda": "off",- "no-use-before-define": "off",- "no-loop-func": "off",+ // "yoda": "off",+ // "no-loop-func": "off",// "no-void": "off",// "valid-jsdoc": "off",// "no-cond-assign": "off",diff --git a/public/src/overrides.js b/public/src/overrides.jsindex e1e192274a..144fb63ef3 100644--- a/public/src/overrides.js+++ b/public/src/overrides.js@@ -3,7 +3,7 @@var overrides = overrides || {};-if ('undefined' !== typeof window) {+if (typeof window !== 'undefined') {(function ($) {require(['translator'], function (translator) {$.fn.getCursorPosition = function () {diff --git a/public/src/utils.js b/public/src/utils.jsindex 9d4692668d..292ba3694a 100644--- a/public/src/utils.js+++ b/public/src/utils.js@@ -5,7 +5,7 @@var fs;var XRegExp;- if ('undefined' === typeof window) {+ if (typeof window === 'undefined') {fs = require('fs');XRegExp = require('xregexp');@@ -448,7 +448,7 @@},};- if ('undefined' !== typeof window) {+ if (typeof window !== 'undefined') {window.utils = module.exports;}@@ -479,7 +479,7 @@return this.replace(/\s+$/g, '');};}-}('undefined' === typeof module ? {+}(typeof module === 'undefined' ? {module: {exports: {},},diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.jsindex c35658b08f..974e20c0dc 100644--- a/src/controllers/accounts/settings.js+++ b/src/controllers/accounts/settings.js@@ -75,10 +75,10 @@ settingsController.get = function (req, res, callback) {}userData.dailyDigestFreqOptions = [- { value: 'off', name: '[[user:digest_off]]', selected: 'off' === userData.settings.dailyDigestFreq },- { value: 'day', name: '[[user:digest_daily]]', selected: 'day' === userData.settings.dailyDigestFreq },- { value: 'week', name: '[[user:digest_weekly]]', selected: 'week' === userData.settings.dailyDigestFreq },- { value: 'month', name: '[[user:digest_monthly]]', selected: 'month' === userData.settings.dailyDigestFreq },+ { value: 'off', name: '[[user:digest_off]]', selected: userData.settings.dailyDigestFreq === 'off' },+ { value: 'day', name: '[[user:digest_daily]]', selected: userData.settings.dailyDigestFreq === 'day' },+ { value: 'week', name: '[[user:digest_weekly]]', selected: userData.settings.dailyDigestFreq === 'week' },+ { value: 'month', name: '[[user:digest_monthly]]', selected: userData.settings.dailyDigestFreq === 'month' },];diff --git a/src/middleware/render.js b/src/middleware/render.jsindex 9109e8daaf..48d4a0b526 100644--- a/src/middleware/render.js+++ b/src/middleware/render.js@@ -23,11 +23,11 @@ module.exports = function (middleware) {};options = options || {};- if ('function' === typeof options) {+ if (typeof options === 'function') {fn = options;options = {};}- if ('function' !== typeof fn) {+ if (typeof fn !== 'function') {fn = defaultFn;}diff --git a/src/socket.io/categories.js b/src/socket.io/categories.jsindex 2c0ef102b4..b1c95af7e9 100644--- a/src/socket.io/categories.js+++ b/src/socket.io/categories.js@@ -204,16 +204,15 @@ function ignoreOrWatch(fn, socket, cid, callback) {// filter to subcategories of cid- var any = true;- while (any) {- any = false;- categoryData.forEach(function (c) {- if (cids.indexOf(c.cid) === -1 && cids.indexOf(c.parentCid) !== -1) {- cids.push(c.cid);- any = true;- }+ var cat;+ do {+ cat = categoryData.find(function (c) {+ return cids.indexOf(c.cid) === -1 && cids.indexOf(c.parentCid) !== -1;});- }+ if (cat) {+ cids.push(cat.cid);+ }+ } while (cat);async.each(cids, function (cid, next) {fn(socket.uid, cid, next);