From e113f8fbab259a4e17728432fbb6e6ea7a5748d8 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 12 Oct 2017 11:20:47 +0100 Subject: [PATCH] Issue #2914723 by droplet, dawehner: JS codestyle: no-mixed-operators --- core/.eslintrc.passing.json | 1 - core/misc/tabledrag.es6.js | 12 +++++++----- core/modules/block/js/block.admin.es6.js | 2 +- core/modules/color/color.es6.js | 4 ++-- core/modules/history/js/history.es6.js | 3 ++- core/modules/history/js/history.js | 3 ++- .../quickedit/js/views/EntityToolbarView.es6.js | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/core/.eslintrc.passing.json b/core/.eslintrc.passing.json index 6cd07bad56ac..104286667ab0 100644 --- a/core/.eslintrc.passing.json +++ b/core/.eslintrc.passing.json @@ -8,7 +8,6 @@ "no-restricted-syntax": "off", "no-new": "off", "no-multi-assign": "off", - "no-mixed-operators": "off", "no-empty": "off", "no-continue": "off", "new-cap": "off", diff --git a/core/misc/tabledrag.es6.js b/core/misc/tabledrag.es6.js index eeabb4714f64..ce621da43d08 100644 --- a/core/misc/tabledrag.es6.js +++ b/core/misc/tabledrag.es6.js @@ -713,7 +713,8 @@ // Stop any current scrolling. clearInterval(self.scrollInterval); // Continue scrolling if the mouse has moved in the scroll direction. - if (scrollAmount > 0 && self.rowObject.direction === 'down' || scrollAmount < 0 && self.rowObject.direction === 'up') { + if ((scrollAmount > 0 && self.rowObject.direction === 'down') + || (scrollAmount < 0 && self.rowObject.direction === 'up')) { self.setScroll(scrollAmount); } @@ -827,8 +828,8 @@ return { x: event.pageX, y: event.pageY }; } return { - x: event.clientX + document.body.scrollLeft - document.body.clientLeft, - y: event.clientY + document.body.scrollTop - document.body.clientTop, + x: (event.clientX + document.body.scrollLeft) - document.body.clientLeft, + y: (event.clientY + document.body.scrollTop) - document.body.clientTop, }; }; @@ -1119,7 +1120,7 @@ // Return a scroll speed relative to the edge of the screen. if (cursorY - scrollY > windowHeight - trigger) { - delta = trigger / (windowHeight + scrollY - cursorY); + delta = trigger / ((windowHeight + scrollY) - cursorY); delta = (delta > 0 && delta < trigger) ? delta : trigger; return delta * this.scrollSettings.amount; } @@ -1144,7 +1145,8 @@ self.checkScroll(self.currentPointerCoords.y); const aboveTable = self.scrollY > self.table.topY; const belowTable = self.scrollY + self.windowHeight < self.table.bottomY; - if (scrollAmount > 0 && belowTable || scrollAmount < 0 && aboveTable) { + if ((scrollAmount > 0 && belowTable) + || (scrollAmount < 0 && aboveTable)) { window.scrollBy(0, scrollAmount); } }, this.scrollSettings.interval); diff --git a/core/modules/block/js/block.admin.es6.js b/core/modules/block/js/block.admin.es6.js index 77c65c373185..86a3e366d653 100644 --- a/core/modules/block/js/block.admin.es6.js +++ b/core/modules/block/js/block.admin.es6.js @@ -91,7 +91,7 @@ // Just scrolling the document.body will not work in Firefox. The html // element is needed as well. $('html, body').animate({ - scrollTop: $('.js-block-placed').offset().top - $container.offset().top + $container.scrollTop(), + scrollTop: ($('.js-block-placed').offset().top - $container.offset().top) + $container.scrollTop(), }, 500); }); } diff --git a/core/modules/color/color.es6.js b/core/modules/color/color.es6.js index 9a6eb071e45b..5a514e564ca2 100644 --- a/core/modules/color/color.es6.js +++ b/core/modules/color/color.es6.js @@ -124,7 +124,7 @@ given[1] /= d; } else { - given[1] = 1 - (1 - given[1]) * d; + given[1] = 1 - ((1 - given[1]) * d); } } @@ -138,7 +138,7 @@ given[2] /= d; } else { - given[2] = 1 - (1 - given[2]) * d; + given[2] = 1 - ((1 - given[2]) * d); } } diff --git a/core/modules/history/js/history.es6.js b/core/modules/history/js/history.es6.js index 53a1d05f25e7..c34a4adcee8b 100644 --- a/core/modules/history/js/history.es6.js +++ b/core/modules/history/js/history.es6.js @@ -10,7 +10,8 @@ // Any comment that is older than 30 days is automatically considered read, // so for these we don't need to perform a request at all! - const thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - 30 * 24 * 60 * 60; + const secondsIn30Days = 2592000; + const thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - secondsIn30Days; // Use the data embedded in the page, if available. let embeddedLastReadTimestamps = false; diff --git a/core/modules/history/js/history.js b/core/modules/history/js/history.js index aa5ca78a8b15..6dbd15cb99bf 100644 --- a/core/modules/history/js/history.js +++ b/core/modules/history/js/history.js @@ -8,7 +8,8 @@ (function ($, Drupal, drupalSettings, storage) { var currentUserID = parseInt(drupalSettings.user.uid, 10); - var thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - 30 * 24 * 60 * 60; + var secondsIn30Days = 2592000; + var thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - secondsIn30Days; var embeddedLastReadTimestamps = false; if (drupalSettings.history && drupalSettings.history.lastReadTimestamps) { diff --git a/core/modules/quickedit/js/views/EntityToolbarView.es6.js b/core/modules/quickedit/js/views/EntityToolbarView.es6.js index 7557ed7f179d..9975ff353569 100644 --- a/core/modules/quickedit/js/views/EntityToolbarView.es6.js +++ b/core/modules/quickedit/js/views/EntityToolbarView.es6.js @@ -296,7 +296,7 @@ suggested.top = fenceTop; } else if ((suggested.top + toolbarHeight) > (fenceTop + fenceHeight)) { - suggested.top = fenceTop + fenceHeight - toolbarHeight; + suggested.top = (fenceTop + fenceHeight) - toolbarHeight; } // Position the toolbar. info.element.element.css({ -- GitLab