Remaining JS linting TODO (#29289)

* Enable and fix all occurrences with no-mixed-operators rule
* Take care of the max-depth warning in button.js

Signed-off-by: mhatvan <markus_hatvan@aon.at>
This commit is contained in:
Markus Hatvan 2019-08-22 21:17:34 +02:00 committed by XhmikosR
parent 6885d65578
commit 4d101491da
6 changed files with 25 additions and 27 deletions

View File

@ -27,7 +27,7 @@
"always-multiline"
],
"new-cap": "off",
"no-mixed-operators": "off",
"no-mixed-operators": "error",
"object-curly-spacing": [
"error",
"always"

View File

@ -74,17 +74,15 @@ class Button {
if (rootElement) {
const input = SelectorEngine.findOne(Selector.INPUT, this._element)
if (input) {
if (input.type === 'radio') {
if (input.checked &&
this._element.classList.contains(ClassName.ACTIVE)) {
triggerChangeEvent = false
} else {
const activeElement = SelectorEngine.findOne(Selector.ACTIVE, rootElement)
if (input && input.type === 'radio') {
if (input.checked &&
this._element.classList.contains(ClassName.ACTIVE)) {
triggerChangeEvent = false
} else {
const activeElement = SelectorEngine.findOne(Selector.ACTIVE, rootElement)
if (activeElement) {
activeElement.classList.remove(ClassName.ACTIVE)
}
if (activeElement) {
activeElement.classList.remove(ClassName.ACTIVE)
}
}

View File

@ -377,8 +377,8 @@ class Carousel {
const isPrevDirection = direction === Direction.PREV
const activeIndex = this._getItemIndex(activeElement)
const lastItemIndex = this._items.length - 1
const isGoingToWrap = isPrevDirection && activeIndex === 0 ||
isNextDirection && activeIndex === lastItemIndex
const isGoingToWrap = (isPrevDirection && activeIndex === 0) ||
(isNextDirection && activeIndex === lastItemIndex)
if (isGoingToWrap && !this._config.wrap) {
return activeElement
@ -424,8 +424,8 @@ class Carousel {
_slide(direction, element) {
const activeElement = SelectorEngine.findOne(Selector.ACTIVE_ITEM, this._element)
const activeElementIndex = this._getItemIndex(activeElement)
const nextElement = element || activeElement &&
this._getItemByDirection(direction, activeElement)
const nextElement = element || (activeElement &&
this._getItemByDirection(direction, activeElement))
const nextElementIndex = this._getItemIndex(nextElement)
const isCycling = Boolean(this._interval)

View File

@ -81,7 +81,7 @@ const nativeEvents = [
*/
function getUidEvent(element, uid) {
return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++
return (uid && `${uid}::${uidEvent++}`) || element.uidEvent || uidEvent++
}
function getEvent(element) {

View File

@ -390,7 +390,7 @@ class Dropdown {
static clearMenus(event) {
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH ||
event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
(event.type === 'keyup' && event.which !== TAB_KEYCODE))) {
return
}
@ -415,9 +415,9 @@ class Dropdown {
continue
}
if (event && (event.type === 'click' &&
/input|textarea/i.test(event.target.tagName) ||
event.type === 'keyup' && event.which === TAB_KEYCODE) &&
if (event && ((event.type === 'click' &&
/input|textarea/i.test(event.target.tagName)) ||
(event.type === 'keyup' && event.which === TAB_KEYCODE)) &&
parent.contains(event.target)) {
continue
}
@ -459,9 +459,9 @@ class Dropdown {
// - If key is not up or down => not a dropdown command
// - If trigger inside the menu => not a dropdown command
if (/input|textarea/i.test(event.target.tagName) ?
event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE &&
(event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE ||
SelectorEngine.closest(event.target, Selector.MENU)) :
event.which === SPACE_KEYCODE || (event.which !== ESCAPE_KEYCODE &&
((event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE) ||
SelectorEngine.closest(event.target, Selector.MENU))) :
!REGEXP_KEYDOWN.test(event.which)) {
return
}
@ -476,7 +476,7 @@ class Dropdown {
const parent = Dropdown.getParentFromElement(this)
const isActive = parent.classList.contains(ClassName.SHOW)
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (!isActive || (isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE))) {
if (event.which === ESCAPE_KEYCODE) {
SelectorEngine.findOne(Selector.DATA_TOGGLE, parent).focus()
}

View File

@ -78,9 +78,9 @@ class Tab {
// Public
show() {
if (this._element.parentNode &&
if ((this._element.parentNode &&
this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
this._element.classList.contains(ClassName.ACTIVE) ||
this._element.classList.contains(ClassName.ACTIVE)) ||
this._element.classList.contains(ClassName.DISABLED)) {
return
}
@ -108,7 +108,7 @@ class Tab {
})
if (showEvent.defaultPrevented ||
hideEvent !== null && hideEvent.defaultPrevented) {
(hideEvent !== null && hideEvent.defaultPrevented)) {
return
}