mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
ESlint no-mixed-operators
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
"no-underscore-dangle": "off",
|
"no-underscore-dangle": "off",
|
||||||
"newline-per-chained-call": "off",
|
"newline-per-chained-call": "off",
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
|
"no-mixed-operators": ["error", { "allowSamePrecedence": true }],
|
||||||
|
|
||||||
// ES6
|
// ES6
|
||||||
"prefer-rest-params": "off",
|
"prefer-rest-params": "off",
|
||||||
@@ -99,7 +100,7 @@
|
|||||||
"no-multi-spaces": "off",
|
"no-multi-spaces": "off",
|
||||||
"quotes": "off",
|
"quotes": "off",
|
||||||
"keyword-spacing": "off",
|
"keyword-spacing": "off",
|
||||||
"no-mixed-operators": "off",
|
// "no-mixed-operators": "off",
|
||||||
// "comma-spacing": "off",
|
// "comma-spacing": "off",
|
||||||
// "no-trailing-spaces": "off",
|
// "no-trailing-spaces": "off",
|
||||||
// "key-spacing": "off",
|
// "key-spacing": "off",
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ Loader.addWorkerEvents = function (worker) {
|
|||||||
Loader.timesStarted = 0;
|
Loader.timesStarted = 0;
|
||||||
}, 10000);
|
}, 10000);
|
||||||
} else {
|
} else {
|
||||||
console.log(numProcs * 3 + ' restarts in 10 seconds, most likely an error on startup. Halting.');
|
console.log((numProcs * 3) + ' restarts in 10 seconds, most likely an error on startup. Halting.');
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,7 @@
|
|||||||
|
|
||||||
function onOpeningMenu() {
|
function onOpeningMenu() {
|
||||||
$('#header').css({
|
$('#header').css({
|
||||||
top: $('#panel').position().top * -1 + 'px',
|
top: ($('#panel').position().top * -1) + 'px',
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ define('admin/manage/users', ['translator'], function (translator) {
|
|||||||
data[cur.name] = cur.value;
|
data[cur.name] = cur.value;
|
||||||
return data;
|
return data;
|
||||||
}, {});
|
}, {});
|
||||||
var until = formData.length ? (Date.now() + formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
|
var until = formData.length ? (Date.now() + (formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1))) : 0;
|
||||||
socket.emit('user.banUsers', { uids: uids, until: until, reason: formData.reason }, done('[[admin/manage/users:alerts.ban-success]]', '.ban', true));
|
socket.emit('user.banUsers', { uids: uids, until: until, reason: formData.reason }, done('[[admin/manage/users:alerts.ban-success]]', '.ban', true));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ define('forum/account/header', [
|
|||||||
data[cur.name] = cur.value;
|
data[cur.name] = cur.value;
|
||||||
return data;
|
return data;
|
||||||
}, {});
|
}, {});
|
||||||
var until = parseInt(formData.length, 10) ? (Date.now() + formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
|
var until = parseInt(formData.length, 10) ? (Date.now() + (formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1))) : 0;
|
||||||
|
|
||||||
socket.emit('user.banUsers', { uids: [ajaxify.data.theirid], until: until, reason: formData.reason || '' }, function (err) {
|
socket.emit('user.banUsers', { uids: [ajaxify.data.theirid], until: until, reason: formData.reason || '' }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ define('forum/chats', [
|
|||||||
|
|
||||||
messagesList.height($(window).height() - (fromTop + inputHeight + (margin * 4)));
|
messagesList.height($(window).height() - (fromTop + inputHeight + (margin * 4)));
|
||||||
components.get('chat/recent').height($('.expanded-chat').height() - (searchHeight + searchListHeight));
|
components.get('chat/recent').height($('.expanded-chat').height() - (searchHeight + searchListHeight));
|
||||||
$('[component="chat/search/list"]').css('max-height', components.get('chat/recent').height() / 2 + 'px');
|
$('[component="chat/search/list"]').css('max-height', (components.get('chat/recent').height() / 2) + 'px');
|
||||||
}
|
}
|
||||||
|
|
||||||
Chats.setActive();
|
Chats.setActive();
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ define('chat', [
|
|||||||
hideAfter = true;
|
hideAfter = true;
|
||||||
}
|
}
|
||||||
chatModal.css('left', Math.max(0, (($(window).width() - $(chatModal).outerWidth()) / 2) + $(window).scrollLeft()) + 'px');
|
chatModal.css('left', Math.max(0, (($(window).width() - $(chatModal).outerWidth()) / 2) + $(window).scrollLeft()) + 'px');
|
||||||
chatModal.css('top', Math.max(0, $(window).height() / 2 - $(chatModal).outerHeight() / 2) + 'px');
|
chatModal.css('top', Math.max(0, ($(window).height() / 2) - ($(chatModal).outerHeight() / 2)) + 'px');
|
||||||
|
|
||||||
if (hideAfter) {
|
if (hideAfter) {
|
||||||
chatModal.addClass('hide');
|
chatModal.addClass('hide');
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
|
|||||||
var scrollTop = $(window).scrollTop();
|
var scrollTop = $(window).scrollTop();
|
||||||
var windowHeight = $(window).height();
|
var windowHeight = $(window).height();
|
||||||
var documentHeight = $(document).height();
|
var documentHeight = $(document).height();
|
||||||
var middleOfViewport = scrollTop + windowHeight / 2;
|
var middleOfViewport = scrollTop + (windowHeight / 2);
|
||||||
var previousDistance = Number.MAX_VALUE;
|
var previousDistance = Number.MAX_VALUE;
|
||||||
els.each(function () {
|
els.each(function () {
|
||||||
var distanceToMiddle = Math.abs(middleOfViewport - $(this).offset().top);
|
var distanceToMiddle = Math.abs(middleOfViewport - $(this).offset().top);
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ define('settings', function () {
|
|||||||
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 !== void 0 && (value == null || value.length !== 0))) {
|
||||||
return value;
|
return value;
|
||||||
} else {
|
} else {
|
||||||
return void 0;
|
return void 0;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ 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 !== void 0 && (val == null || val.length !== 0))) {
|
||||||
return values.push(val);
|
return values.push(val);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ 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 !== void 0 && (val == null || val.length !== 0))) {
|
||||||
return value[prop] = val;
|
return value[prop] = val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
process.elapsedTimeSince = function (start) {
|
process.elapsedTimeSince = function (start) {
|
||||||
var diff = process.hrtime(start);
|
var diff = process.hrtime(start);
|
||||||
return diff[0] * 1e3 + diff[1] / 1e6;
|
return (diff[0] * 1e3) + (diff[1] / 1e6);
|
||||||
};
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
generateUUID: function () {
|
generateUUID: function () {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
var r = Math.random() * 16 | 0;
|
var r = Math.random() * 16 | 0;
|
||||||
var v = c === 'x' ? r : (r & 0x3 | 0x8);
|
var v = c === 'x' ? r : ((r & 0x3) | 0x8);
|
||||||
return v.toString(16);
|
return v.toString(16);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ categoryController.get = function (req, res, callback) {
|
|||||||
set = 'cid:' + cid + ':tids:posts';
|
set = 'cid:' + cid + ':tids:posts';
|
||||||
}
|
}
|
||||||
|
|
||||||
var start = (currentPage - 1) * settings.topicsPerPage + topicIndex;
|
var start = ((currentPage - 1) * settings.topicsPerPage) + topicIndex;
|
||||||
var stop = start + settings.topicsPerPage - 1;
|
var stop = start + settings.topicsPerPage - 1;
|
||||||
|
|
||||||
var payload = {
|
var payload = {
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ topicsController.get = function (req, res, callback) {
|
|||||||
currentPage = Math.max(1, Math.ceil(index / settings.postsPerPage));
|
currentPage = Math.max(1, Math.ceil(index / settings.postsPerPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
var start = (currentPage - 1) * settings.postsPerPage + postIndex;
|
var start = ((currentPage - 1) * settings.postsPerPage) + postIndex;
|
||||||
var stop = start + settings.postsPerPage - 1;
|
var stop = start + settings.postsPerPage - 1;
|
||||||
|
|
||||||
topics.getTopicWithPosts(results.topic, set, req.uid, start, stop, reverse, next);
|
topics.getTopicWithPosts(results.topic, set, req.uid, start, stop, reverse, next);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ image.resizeImage = function (data, callback) {
|
|||||||
crop = async.apply(image.crop.bind(image), x, y, h * desiredRatio, h);
|
crop = async.apply(image.crop.bind(image), x, y, h * desiredRatio, h);
|
||||||
} else {
|
} else {
|
||||||
x = 0; // width is the smaller dimension here
|
x = 0; // width is the smaller dimension here
|
||||||
y = Math.floor(h / 2 - (w * desiredRatio / 2));
|
y = Math.floor((h / 2) - (w * desiredRatio / 2));
|
||||||
crop = async.apply(image.crop.bind(image), x, y, w, w * desiredRatio);
|
crop = async.apply(image.crop.bind(image), x, y, w, w * desiredRatio);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ module.exports = function (middleware) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function translate(str, req, res, next) {
|
function translate(str, req, res, next) {
|
||||||
var language = res.locals.config && res.locals.config.userLang || 'en-GB';
|
var language = (res.locals.config && res.locals.config.userLang) || 'en-GB';
|
||||||
language = req.query.lang ? validator.escape(String(req.query.lang)) : language;
|
language = req.query.lang ? validator.escape(String(req.query.lang)) : language;
|
||||||
translator.translate(str, language, function (translated) {
|
translator.translate(str, language, function (translated) {
|
||||||
next(null, translator.unescape(translated));
|
next(null, translator.unescape(translated));
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ module.exports = function (Posts) {
|
|||||||
var hook;
|
var hook;
|
||||||
var current = voteStatus.upvoted ? 'upvote' : 'downvote';
|
var current = voteStatus.upvoted ? 'upvote' : 'downvote';
|
||||||
|
|
||||||
if (voteStatus.upvoted && command === 'downvote' || voteStatus.downvoted && command === 'upvote') { // e.g. User *has* upvoted, and clicks downvote
|
if ((voteStatus.upvoted && command === 'downvote') || (voteStatus.downvoted && command === 'upvote')) { // e.g. User *has* upvoted, and clicks downvote
|
||||||
hook = command;
|
hook = command;
|
||||||
} else if (voteStatus.upvoted || voteStatus.downvoted) { // e.g. User *has* upvoted, clicks upvote (so we "unvote")
|
} else if (voteStatus.upvoted || voteStatus.downvoted) { // e.g. User *has* upvoted, clicks upvote (so we "unvote")
|
||||||
hook = 'unvote';
|
hook = 'unvote';
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ module.exports = function (privileges) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
if (Array.isArray(uid) && !Array.isArray(data.isModerator) || Array.isArray(cid) && !Array.isArray(data.isModerator)) {
|
if ((Array.isArray(uid) || Array.isArray(cid)) && !Array.isArray(data.isModerator)) {
|
||||||
return callback(new Error('filter:user.isModerator - i/o mismatch'));
|
return callback(new Error('filter:user.isModerator - i/o mismatch'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ module.exports = function (Topics) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topics.unreadCutoff = function () {
|
Topics.unreadCutoff = function () {
|
||||||
return Date.now() - (parseInt(meta.config.unreadCutoff, 10) || 2) * 86400000;
|
var cutoff = parseInt(meta.config.unreadCutoff, 10) || 2;
|
||||||
|
return Date.now() - (cutoff * 86400000);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.getUnreadTids = function (cid, uid, filter, callback) {
|
Topics.getUnreadTids = function (cid, uid, filter, callback) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ var emailer = require('../emailer');
|
|||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
db.expireAt('confirm:' + confirm_code, Math.floor(Date.now() / 1000 + 60 * 60 * 24), next);
|
db.expireAt('confirm:' + confirm_code, Math.floor((Date.now() / 1000) + (60 * 60 * 24)), next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
user.getUserField(uid, 'username', next);
|
user.getUserField(uid, 'username', next);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ var emailer = require('../emailer');
|
|||||||
db.sortedSetScore('reset:issueDate:uid', uid, next);
|
db.sortedSetScore('reset:issueDate:uid', uid, next);
|
||||||
},
|
},
|
||||||
function (score, next) {
|
function (score, next) {
|
||||||
if (score > Date.now() - 1000 * 60) {
|
if (score > Date.now() - (1000 * 60)) {
|
||||||
return next(new Error('[[error:cant-reset-password-more-than-once-a-minute]]'));
|
return next(new Error('[[error:cant-reset-password-more-than-once-a-minute]]'));
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ module.exports = function (User) {
|
|||||||
},
|
},
|
||||||
function (users, next) {
|
function (users, next) {
|
||||||
var diff = process.hrtime(start);
|
var diff = process.hrtime(start);
|
||||||
var timing = (diff[0] * 1e3 + diff[1] / 1e6).toFixed(1);
|
var timing = ((diff[0] * 1e3) + (diff[1] / 1e6)).toFixed(1);
|
||||||
next(null, {timing: timing, users: users});
|
next(null, {timing: timing, users: users});
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user