mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
ESlint no-cond-assign, no-void, valid-jsdoc
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
"func-names": "off",
|
"func-names": "off",
|
||||||
"no-tabs": "off",
|
"no-tabs": "off",
|
||||||
"indent": ["error", "tab"],
|
"indent": ["error", "tab"],
|
||||||
|
"no-eq-null": "off",
|
||||||
|
|
||||||
// ES6
|
// ES6
|
||||||
"prefer-rest-params": "off",
|
"prefer-rest-params": "off",
|
||||||
@@ -76,11 +77,9 @@
|
|||||||
"yoda": "off",
|
"yoda": "off",
|
||||||
"no-use-before-define": "off",
|
"no-use-before-define": "off",
|
||||||
"no-loop-func": "off",
|
"no-loop-func": "off",
|
||||||
"no-void": "off",
|
// "no-void": "off",
|
||||||
"valid-jsdoc": "off",
|
// "valid-jsdoc": "off",
|
||||||
"o-eq-null": "off",
|
// "no-cond-assign": "off",
|
||||||
"no-cond-assign": "off",
|
|
||||||
"no-eq-null": "off",
|
|
||||||
// "no-redeclare": "off",
|
// "no-redeclare": "off",
|
||||||
// "no-unreachable": "off",
|
// "no-unreachable": "off",
|
||||||
// "no-nested-ternary": "off",
|
// "no-nested-ternary": "off",
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ define('settings', function () {
|
|||||||
}
|
}
|
||||||
plugin = Settings.plugins[type.toLowerCase()];
|
plugin = Settings.plugins[type.toLowerCase()];
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
return void 0;
|
return;
|
||||||
}
|
}
|
||||||
hook = plugin[name];
|
hook = plugin[name];
|
||||||
if (typeof hook === 'function') {
|
if (typeof hook === 'function') {
|
||||||
@@ -137,7 +137,7 @@ define('settings', function () {
|
|||||||
value = value.trim();
|
value = value.trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty || (value != null ? value.length : void 0)) {
|
if (empty || (value != null && value.length)) {
|
||||||
cleaned.push(value);
|
cleaned.push(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,17 +167,15 @@ define('settings', function () {
|
|||||||
if (split != null) {
|
if (split != null) {
|
||||||
empty = helper.isTrue(element.data('empty')); // default empty-value is false for arrays
|
empty = helper.isTrue(element.data('empty')); // default empty-value is false for arrays
|
||||||
value = element.val();
|
value = element.val();
|
||||||
var array = (value != null ? value.split(split || ',') : void 0) || [];
|
var array = (value != null && value.split(split || ',')) || [];
|
||||||
return helper.cleanArray(array, trim, empty);
|
return helper.cleanArray(array, trim, empty);
|
||||||
} else {
|
} else {
|
||||||
value = element.val();
|
value = element.val();
|
||||||
if (trim && value != null && typeof value.trim === 'function') {
|
if (trim && value != null && typeof value.trim === 'function') {
|
||||||
value = value.trim();
|
value = value.trim();
|
||||||
}
|
}
|
||||||
if (empty || (value !== void 0 && (value == null || value.length !== 0))) {
|
if (empty || (value !== undefined && (value == null || value.length !== 0))) {
|
||||||
return value;
|
return value;
|
||||||
} else {
|
|
||||||
return void 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -212,7 +210,7 @@ define('settings', function () {
|
|||||||
} else {
|
} else {
|
||||||
value = '';
|
value = '';
|
||||||
}
|
}
|
||||||
if (value !== void 0) {
|
if (value !== undefined) {
|
||||||
element.val(value);
|
element.val(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -337,7 +335,7 @@ define('settings', function () {
|
|||||||
@returns Object The settings.
|
@returns Object The settings.
|
||||||
*/
|
*/
|
||||||
get: function () {
|
get: function () {
|
||||||
if (Settings.cfg != null && Settings.cfg._ !== void 0) {
|
if (Settings.cfg != null && Settings.cfg._ !== undefined) {
|
||||||
return Settings.cfg._;
|
return Settings.cfg._;
|
||||||
}
|
}
|
||||||
return Settings.cfg;
|
return Settings.cfg;
|
||||||
|
|||||||
@@ -133,14 +133,12 @@ define('settings/array', function () {
|
|||||||
child = $(child);
|
child = $(child);
|
||||||
var val = helper.readValue(child);
|
var val = helper.readValue(child);
|
||||||
var empty = helper.isTrue(child.data('empty'));
|
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);
|
return values.push(val);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (empty || values.length) {
|
if (empty || values.length) {
|
||||||
return values;
|
return values;
|
||||||
} else {
|
|
||||||
return void 0;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,10 +21,13 @@ define('settings/checkbox', function () {
|
|||||||
get: function (element, trim, empty) {
|
get: function (element, trim, empty) {
|
||||||
var value = element.prop('checked');
|
var value = element.prop('checked');
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return void 0;
|
return;
|
||||||
}
|
}
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
return value || void 0;
|
if (value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (trim) {
|
if (trim) {
|
||||||
return value ? 1 : 0;
|
return value ? 1 : 0;
|
||||||
|
|||||||
@@ -215,13 +215,9 @@ define('settings/key', function () {
|
|||||||
if (trim) {
|
if (trim) {
|
||||||
if (empty || (key != null && key.char)) {
|
if (empty || (key != null && key.char)) {
|
||||||
return getKeyString(key, false, short, separator);
|
return getKeyString(key, false, short, separator);
|
||||||
} else {
|
|
||||||
return void 0;
|
|
||||||
}
|
}
|
||||||
} else if (empty || (key != null && key.code)) {
|
} else if (empty || (key != null && key.code)) {
|
||||||
return key;
|
return key;
|
||||||
} else {
|
|
||||||
return void 0;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ define('settings/number', function () {
|
|||||||
get: function (element, trim, empty) {
|
get: function (element, trim, empty) {
|
||||||
var value = element.val();
|
var value = element.val();
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
return value ? +value : void 0;
|
if (value) {
|
||||||
|
return +value;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return value ? +value : 0;
|
return value ? +value : 0;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ define('settings/object', function () {
|
|||||||
attributes = {};
|
attributes = {};
|
||||||
}
|
}
|
||||||
propertyName = attributes['data-prop'] || attributes['data-property'] || propertyIndex;
|
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'];
|
value[propertyName] = attributes['data-new'];
|
||||||
}
|
}
|
||||||
addObjectPropertyElement(element, key, attributes, propertyName, value[propertyName], separator.clone(), function (el) {
|
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 val = helper.readValue(property);
|
||||||
var prop = property.data('prop');
|
var prop = property.data('prop');
|
||||||
var empty = helper.isTrue(property.data('empty'));
|
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;
|
value[prop] = val;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (empty || Object.keys(value).length) {
|
if (empty || Object.keys(value).length) {
|
||||||
return value;
|
return value;
|
||||||
} else {
|
|
||||||
return void 0;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ define('settings/select', function () {
|
|||||||
var value = element.val();
|
var value = element.val();
|
||||||
if (empty || value) {
|
if (empty || value) {
|
||||||
return value;
|
return value;
|
||||||
} else {
|
|
||||||
return void 0;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,12 +21,14 @@ define('settings/textarea', function () {
|
|||||||
get: function (element, trim, empty) {
|
get: function (element, trim, empty) {
|
||||||
var value = element.val();
|
var value = element.val();
|
||||||
if (trim) {
|
if (trim) {
|
||||||
value = value == null ? void 0 : value.trim();
|
if (value == null) {
|
||||||
|
value = undefined;
|
||||||
|
} else {
|
||||||
|
value = value.trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (empty || value) {
|
if (empty || value) {
|
||||||
return value;
|
return value;
|
||||||
} else {
|
|
||||||
return void 0;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -489,7 +489,7 @@
|
|||||||
prepareDOM: function prepareDOM() {
|
prepareDOM: function prepareDOM() {
|
||||||
// Load the appropriate timeago locale file,
|
// Load the appropriate timeago locale file,
|
||||||
// and correct NodeBB language codes to timeago codes, if necessary
|
// and correct NodeBB language codes to timeago codes, if necessary
|
||||||
var languageCode = void 0;
|
var languageCode;
|
||||||
switch (config.userLang) {
|
switch (config.userLang) {
|
||||||
case 'en-GB':
|
case 'en-GB':
|
||||||
case 'en-US':
|
case 'en-US':
|
||||||
|
|||||||
@@ -117,10 +117,10 @@ function compile(callback) {
|
|||||||
|
|
||||||
async.each(Object.keys(paths), function (relativePath, next) {
|
async.each(Object.keys(paths), function (relativePath, next) {
|
||||||
var file = fs.readFileSync(paths[relativePath]).toString();
|
var file = fs.readFileSync(paths[relativePath]).toString();
|
||||||
var matches = null;
|
|
||||||
var regex = /[ \t]*<!-- IMPORT ([\s\S]*?)? -->[ \t]*/;
|
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];
|
var partial = '/' + matches[1];
|
||||||
|
|
||||||
if (paths[partial] && relativePath !== partial) {
|
if (paths[partial] && relativePath !== partial) {
|
||||||
@@ -129,6 +129,7 @@ function compile(callback) {
|
|||||||
winston.warn('[meta/templates] Partial not loaded: ' + matches[1]);
|
winston.warn('[meta/templates] Partial not loaded: ' + matches[1]);
|
||||||
file = file.replace(regex, '');
|
file = file.replace(regex, '');
|
||||||
}
|
}
|
||||||
|
matches = file.match(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdirp.sync(path.join(viewsPath, relativePath.split('/').slice(0, -1).join('/')));
|
mkdirp.sync(path.join(viewsPath, relativePath.split('/').slice(0, -1).join('/')));
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ module.exports = function (Posts) {
|
|||||||
Posts.relativeToAbsolute = function (content) {
|
Posts.relativeToAbsolute = function (content) {
|
||||||
// Turns relative links in post body to absolute urls
|
// Turns relative links in post body to absolute urls
|
||||||
var parsed;
|
var parsed;
|
||||||
var current;
|
var current = urlRegex.exec(content);
|
||||||
var absolute;
|
var absolute;
|
||||||
|
|
||||||
while ((current = urlRegex.exec(content)) !== null) {
|
while (current !== null) {
|
||||||
if (current[1]) {
|
if (current[1]) {
|
||||||
try {
|
try {
|
||||||
parsed = url.parse(current[1]);
|
parsed = url.parse(current[1]);
|
||||||
@@ -71,6 +71,7 @@ module.exports = function (Posts) {
|
|||||||
winston.verbose(err.messsage);
|
winston.verbose(err.messsage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
current = urlRegex.exec(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
|
|||||||
@@ -140,8 +140,8 @@ Settings.prototype.get = function (key, def) {
|
|||||||
obj = obj[part];
|
obj = obj[part];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (obj === void 0) {
|
if (obj === undefined) {
|
||||||
if (def === void 0) {
|
if (def === undefined) {
|
||||||
def = this.defCfg;
|
def = this.defCfg;
|
||||||
for (var j = 0; j < parts.length; j += 1) {
|
for (var j = 0; j < parts.length; j += 1) {
|
||||||
part = parts[j];
|
part = parts[j];
|
||||||
@@ -198,7 +198,8 @@ Settings.prototype.set = function (key, val) {
|
|||||||
obj = this.cfg._;
|
obj = this.cfg._;
|
||||||
parts = key.split('.');
|
parts = key.split('.');
|
||||||
for (var i = 0, _len = parts.length - 1; i < _len; i += 1) {
|
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)) {
|
if (!obj.hasOwnProperty(part)) {
|
||||||
obj[part] = {};
|
obj[part] = {};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user