ESlint no-mixed-operators

v1.18.x
Peter Jaszkowiak 8 years ago
parent 2e031f3759
commit a5a3f3089a

@ -15,6 +15,7 @@
"no-underscore-dangle": "off",
"newline-per-chained-call": "off",
"no-console": "off",
"no-mixed-operators": ["error", { "allowSamePrecedence": true }],
// ES6
"prefer-rest-params": "off",
@ -99,7 +100,7 @@
"no-multi-spaces": "off",
"quotes": "off",
"keyword-spacing": "off",
"no-mixed-operators": "off",
// "no-mixed-operators": "off",
// "comma-spacing": "off",
// "no-trailing-spaces": "off",
// "key-spacing": "off",

@ -60,7 +60,7 @@ Loader.addWorkerEvents = function (worker) {
Loader.timesStarted = 0;
}, 10000);
} 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();
}
}

@ -216,7 +216,7 @@
function onOpeningMenu() {
$('#header').css({
top: $('#panel').position().top * -1 + 'px',
top: ($('#panel').position().top * -1) + 'px',
position: 'absolute',
});
}

@ -99,7 +99,7 @@ define('admin/manage/users', ['translator'], function (translator) {
data[cur.name] = cur.value;
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));
},
},

@ -129,7 +129,7 @@ define('forum/account/header', [
data[cur.name] = cur.value;
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) {
if (err) {

@ -355,7 +355,7 @@ define('forum/chats', [
messagesList.height($(window).height() - (fromTop + inputHeight + (margin * 4)));
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();

@ -298,7 +298,7 @@ define('chat', [
hideAfter = true;
}
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) {
chatModal.addClass('hide');

@ -114,7 +114,7 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
var scrollTop = $(window).scrollTop();
var windowHeight = $(window).height();
var documentHeight = $(document).height();
var middleOfViewport = scrollTop + windowHeight / 2;
var middleOfViewport = scrollTop + (windowHeight / 2);
var previousDistance = Number.MAX_VALUE;
els.each(function () {
var distanceToMiddle = Math.abs(middleOfViewport - $(this).offset().top);

@ -171,7 +171,7 @@ define('settings', function () {
if (trim && value != null && typeof value.trim === 'function') {
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;
} else {
return void 0;

@ -130,7 +130,7 @@ 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 !== void 0 && (val == null || val.length !== 0))) {
return values.push(val);
}
});

@ -102,7 +102,7 @@ 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 !== void 0 && (val == null || val.length !== 0))) {
return value[prop] = val;
}
});

@ -15,7 +15,7 @@
process.elapsedTimeSince = function (start) {
var diff = process.hrtime(start);
return diff[0] * 1e3 + diff[1] / 1e6;
return (diff[0] * 1e3) + (diff[1] / 1e6);
};
} else {
@ -27,7 +27,7 @@
generateUUID: function () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
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);
});
},

@ -87,7 +87,7 @@ categoryController.get = function (req, res, callback) {
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 payload = {

@ -113,7 +113,7 @@ topicsController.get = function (req, res, callback) {
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;
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);
} else {
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);
}
} else {

@ -107,7 +107,7 @@ module.exports = function (middleware) {
}
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;
translator.translate(str, language, function (translated) {
next(null, translator.unescape(translated));

@ -162,7 +162,7 @@ module.exports = function (Posts) {
var hook;
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;
} else if (voteStatus.upvoted || voteStatus.downvoted) { // e.g. User *has* upvoted, clicks upvote (so we "unvote")
hook = 'unvote';

@ -128,7 +128,7 @@ module.exports = function (privileges) {
if (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'));
}

@ -64,7 +64,8 @@ module.exports = function (Topics) {
};
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) {

@ -57,7 +57,7 @@ var emailer = require('../emailer');
}, 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) {
user.getUserField(uid, 'username', next);

@ -48,7 +48,7 @@ var emailer = require('../emailer');
db.sortedSetScore('reset:issueDate:uid', uid, 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]]'));
}
next();

@ -156,7 +156,7 @@ module.exports = function (User) {
},
function (users, next) {
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});
},
], callback);

Loading…
Cancel
Save