Node.js based forum software built for the modern web
ESlint no-cond-assign, no-void, valid-jsdoc
Peter Jaszkowiak04bb6513b069
diff --git a/.eslintrc b/.eslintrcindex 9f457493c4..1def8e8e04 100644--- a/.eslintrc+++ b/.eslintrc@@ -24,6 +24,7 @@"func-names": "off","no-tabs": "off","indent": ["error", "tab"],+ "no-eq-null": "off",// ES6"prefer-rest-params": "off",@@ -76,11 +77,9 @@"yoda": "off","no-use-before-define": "off","no-loop-func": "off",- "no-void": "off",- "valid-jsdoc": "off",- "o-eq-null": "off",- "no-cond-assign": "off",- "no-eq-null": "off",+ // "no-void": "off",+ // "valid-jsdoc": "off",+ // "no-cond-assign": "off",// "no-redeclare": "off",// "no-unreachable": "off",// "no-nested-ternary": "off",diff --git a/public/src/modules/settings.js b/public/src/modules/settings.jsindex 67dbb8896b..b8883f2958 100644--- a/public/src/modules/settings.js+++ b/public/src/modules/settings.js@@ -31,7 +31,7 @@ define('settings', function () {}plugin = Settings.plugins[type.toLowerCase()];if (plugin == null) {- return void 0;+ return;}hook = plugin[name];if (typeof hook === 'function') {@@ -137,7 +137,7 @@ define('settings', function () {value = value.trim();}}- if (empty || (value != null ? value.length : void 0)) {+ if (empty || (value != null && value.length)) {cleaned.push(value);}}@@ -167,17 +167,15 @@ define('settings', function () {if (split != null) {empty = helper.isTrue(element.data('empty')); // default empty-value is false for arraysvalue = element.val();- var array = (value != null ? value.split(split || ',') : void 0) || [];+ var array = (value != null && value.split(split || ',')) || [];return helper.cleanArray(array, trim, empty);} else {value = element.val();if (trim && value != null && typeof value.trim === 'function') {value = value.trim();}- if (empty || (value !== void 0 && (value == null || value.length !== 0))) {+ if (empty || (value !== undefined && (value == null || value.length !== 0))) {return value;- } else {- return void 0;}}},@@ -212,7 +210,7 @@ define('settings', function () {} else {value = '';}- if (value !== void 0) {+ if (value !== undefined) {element.val(value);}},@@ -337,7 +335,7 @@ define('settings', function () {@returns Object The settings.*/get: function () {- if (Settings.cfg != null && Settings.cfg._ !== void 0) {+ if (Settings.cfg != null && Settings.cfg._ !== undefined) {return Settings.cfg._;}return Settings.cfg;diff --git a/public/src/modules/settings/array.js b/public/src/modules/settings/array.jsindex 2c96d734be..6268c8d6c9 100644--- a/public/src/modules/settings/array.js+++ b/public/src/modules/settings/array.js@@ -133,14 +133,12 @@ define('settings/array', function () {child = $(child);var val = helper.readValue(child);var empty = helper.isTrue(child.data('empty'));- if (empty || (val !== void 0 && (val == null || val.length !== 0))) {+ if (empty || (val !== undefined && (val == null || val.length !== 0))) {return values.push(val);}});if (empty || values.length) {return values;- } else {- return void 0;}},};diff --git a/public/src/modules/settings/checkbox.js b/public/src/modules/settings/checkbox.jsindex 6d36849b6a..d64212d4e0 100644--- a/public/src/modules/settings/checkbox.js+++ b/public/src/modules/settings/checkbox.js@@ -21,10 +21,13 @@ define('settings/checkbox', function () {get: function (element, trim, empty) {var value = element.prop('checked');if (value == null) {- return void 0;+ return;}if (!empty) {- return value || void 0;+ if (value) {+ return value;+ }+ return;}if (trim) {return value ? 1 : 0;diff --git a/public/src/modules/settings/key.js b/public/src/modules/settings/key.jsindex 73839a087b..52b116b2e3 100644--- a/public/src/modules/settings/key.js+++ b/public/src/modules/settings/key.js@@ -215,13 +215,9 @@ define('settings/key', function () {if (trim) {if (empty || (key != null && key.char)) {return getKeyString(key, false, short, separator);- } else {- return void 0;}} else if (empty || (key != null && key.code)) {return key;- } else {- return void 0;}},};diff --git a/public/src/modules/settings/number.js b/public/src/modules/settings/number.jsindex 52dd38fe44..12ff231076 100644--- a/public/src/modules/settings/number.js+++ b/public/src/modules/settings/number.js@@ -6,7 +6,10 @@ define('settings/number', function () {get: function (element, trim, empty) {var value = element.val();if (!empty) {- return value ? +value : void 0;+ if (value) {+ return +value;+ }+ return;}return value ? +value : 0;},diff --git a/public/src/modules/settings/object.js b/public/src/modules/settings/object.jsindex ed94a8401a..e7c88ec585 100644--- a/public/src/modules/settings/object.js+++ b/public/src/modules/settings/object.js@@ -88,7 +88,7 @@ define('settings/object', function () {attributes = {};}propertyName = attributes['data-prop'] || attributes['data-property'] || propertyIndex;- if (value[propertyName] === void 0 && attributes['data-new'] !== void 0) {+ if (value[propertyName] === undefined && attributes['data-new'] !== undefined) {value[propertyName] = attributes['data-new'];}addObjectPropertyElement(element, key, attributes, propertyName, value[propertyName], separator.clone(), function (el) {@@ -107,15 +107,13 @@ define('settings/object', function () {var val = helper.readValue(property);var prop = property.data('prop');var empty = helper.isTrue(property.data('empty'));- if (empty || (val !== void 0 && (val == null || val.length !== 0))) {+ if (empty || (val !== undefined && (val == null || val.length !== 0))) {value[prop] = val;return val;}});if (empty || Object.keys(value).length) {return value;- } else {- return void 0;}},};diff --git a/public/src/modules/settings/select.js b/public/src/modules/settings/select.jsindex d90c03c4fd..1b28774871 100644--- a/public/src/modules/settings/select.js+++ b/public/src/modules/settings/select.js@@ -39,8 +39,6 @@ define('settings/select', function () {var value = element.val();if (empty || value) {return value;- } else {- return void 0;}},};diff --git a/public/src/modules/settings/textarea.js b/public/src/modules/settings/textarea.jsindex 0397e5bea5..cc36e90762 100644--- a/public/src/modules/settings/textarea.js+++ b/public/src/modules/settings/textarea.js@@ -21,12 +21,14 @@ define('settings/textarea', function () {get: function (element, trim, empty) {var value = element.val();if (trim) {- value = value == null ? void 0 : value.trim();+ if (value == null) {+ value = undefined;+ } else {+ value = value.trim();+ }}if (empty || value) {return value;- } else {- return void 0;}},};diff --git a/public/src/modules/translator.js b/public/src/modules/translator.jsindex 023225c978..4291c82957 100644--- a/public/src/modules/translator.js+++ b/public/src/modules/translator.js@@ -489,7 +489,7 @@prepareDOM: function prepareDOM() {// Load the appropriate timeago locale file,// and correct NodeBB language codes to timeago codes, if necessary- var languageCode = void 0;+ var languageCode;switch (config.userLang) {case 'en-GB':case 'en-US':diff --git a/src/meta/templates.js b/src/meta/templates.jsindex 4fc3205f63..4c2a8b1fb9 100644--- a/src/meta/templates.js+++ b/src/meta/templates.js@@ -117,10 +117,10 @@ function compile(callback) {async.each(Object.keys(paths), function (relativePath, next) {var file = fs.readFileSync(paths[relativePath]).toString();- var matches = null;var regex = /[ \t]*<!-- IMPORT ([\s\S]*?)? -->[ \t]*/;+ var matches = file.match(regex);- while ((matches = file.match(regex)) !== null) {+ while (matches !== null) {var partial = '/' + matches[1];if (paths[partial] && relativePath !== partial) {@@ -129,6 +129,7 @@ function compile(callback) {winston.warn('[meta/templates] Partial not loaded: ' + matches[1]);file = file.replace(regex, '');}+ matches = file.match(regex);}mkdirp.sync(path.join(viewsPath, relativePath.split('/').slice(0, -1).join('/')));diff --git a/src/posts/parse.js b/src/posts/parse.jsindex ff8eb29ce7..946c589056 100644--- a/src/posts/parse.js+++ b/src/posts/parse.js@@ -49,10 +49,10 @@ module.exports = function (Posts) {Posts.relativeToAbsolute = function (content) {// Turns relative links in post body to absolute urlsvar parsed;- var current;+ var current = urlRegex.exec(content);var absolute;- while ((current = urlRegex.exec(content)) !== null) {+ while (current !== null) {if (current[1]) {try {parsed = url.parse(current[1]);@@ -71,6 +71,7 @@ module.exports = function (Posts) {winston.verbose(err.messsage);}}+ current = urlRegex.exec(content);}return content;diff --git a/src/settings.js b/src/settings.jsindex b663721991..b9642c0dce 100644--- a/src/settings.js+++ b/src/settings.js@@ -140,8 +140,8 @@ Settings.prototype.get = function (key, def) {obj = obj[part];}}- if (obj === void 0) {- if (def === void 0) {+ if (obj === undefined) {+ if (def === undefined) {def = this.defCfg;for (var j = 0; j < parts.length; j += 1) {part = parts[j];@@ -198,7 +198,8 @@ Settings.prototype.set = function (key, val) {obj = this.cfg._;parts = key.split('.');for (var i = 0, _len = parts.length - 1; i < _len; i += 1) {- if (part = parts[i]) {+ part = parts[i];+ if (part) {if (!obj.hasOwnProperty(part)) {obj[part] = {};}