ESlint no-cond-assign, no-void, valid-jsdoc

v1.18.x
Peter Jaszkowiak 8 years ago
parent 5a45087fc8
commit 04bb6513b0

@ -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",

@ -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 arrays
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);
} 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;

@ -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;
}
},
};

@ -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;

@ -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;
}
},
};

@ -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;
},

@ -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;
}
},
};

@ -39,8 +39,6 @@ define('settings/select', function () {
var value = element.val();
if (empty || value) {
return value;
} else {
return void 0;
}
},
};

@ -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;
}
},
};

@ -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':

@ -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('/')));

@ -49,10 +49,10 @@ module.exports = function (Posts) {
Posts.relativeToAbsolute = function (content) {
// Turns relative links in post body to absolute urls
var 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;

@ -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] = {};
}

Loading…
Cancel
Save