diff --git a/.eslintrc.json b/.eslintrc.json index 4c49fd0b1d..98e24c656a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -51,7 +51,6 @@ "unicorn/no-useless-undefined": "off", "unicorn/prefer-array-find": "off", "unicorn/prefer-dataset": "off", - "unicorn/prefer-includes": "off", "unicorn/prefer-node-append": "off", "unicorn/prefer-node-remove": "off", "unicorn/prefer-number-properties": "off", diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js index bf9aa38dff..64a061ae69 100644 --- a/js/src/dom/event-handler.js +++ b/js/src/dom/event-handler.js @@ -151,7 +151,7 @@ function normalizeParams(originalTypeEvent, handler, delegationFn) { typeEvent = custom } - const isNative = nativeEvents.indexOf(typeEvent) > -1 + const isNative = nativeEvents.includes(typeEvent) if (!isNative) { typeEvent = originalTypeEvent @@ -210,7 +210,7 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) { const storeElementEvent = events[typeEvent] || {} Object.keys(storeElementEvent).forEach(handlerKey => { - if (handlerKey.indexOf(namespace) > -1) { + if (handlerKey.includes(namespace)) { const event = storeElementEvent[handlerKey] removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector) @@ -257,7 +257,7 @@ const EventHandler = { Object.keys(storeElementEvent).forEach(keyHandlers => { const handlerKey = keyHandlers.replace(stripUidRegex, '') - if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) { + if (!inNamespace || originalTypeEvent.includes(handlerKey)) { const event = storeElementEvent[keyHandlers] removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector) @@ -273,7 +273,7 @@ const EventHandler = { const $ = getjQuery() const typeEvent = event.replace(stripNameRegex, '') const inNamespace = event !== typeEvent - const isNative = nativeEvents.indexOf(typeEvent) > -1 + const isNative = nativeEvents.includes(typeEvent) let jQueryEvent let bubbles = true diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2a55992cba..e4616f1f19 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -679,7 +679,7 @@ class Tooltip { const dataAttributes = Manipulator.getDataAttributes(this.element) Object.keys(dataAttributes).forEach(dataAttr => { - if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) { + if (DISALLOWED_ATTRIBUTES.includes(dataAttr)) { delete dataAttributes[dataAttr] } }) diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index d3747bba9d..27c8dcfb6a 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -35,8 +35,8 @@ const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|vid const allowedAttribute = (attr, allowedAttributeList) => { const attrName = attr.nodeName.toLowerCase() - if (allowedAttributeList.indexOf(attrName) !== -1) { - if (uriAttrs.indexOf(attrName) !== -1) { + if (allowedAttributeList.includes(attrName)) { + if (uriAttrs.includes(attrName)) { return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) } @@ -107,7 +107,7 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { const el = elements[i] const elName = el.nodeName.toLowerCase() - if (allowlistKeys.indexOf(elName) === -1) { + if (!allowlistKeys.includes(elName)) { el.parentNode.removeChild(el) continue diff --git a/site/.eslintrc.json b/site/.eslintrc.json index f7b6b4a7f3..ec51527c14 100644 --- a/site/.eslintrc.json +++ b/site/.eslintrc.json @@ -36,7 +36,6 @@ "unicorn/no-for-loop": "off", "unicorn/no-null": "off", "unicorn/prefer-dataset": "off", - "unicorn/prefer-includes": "off", "unicorn/prefer-node-append": "off", "unicorn/prefer-query-selector": "off", "unicorn/prevent-abbreviations": "off"