From 666fe596bf4629777f995dd79046b1db632ffdfb Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 30 Jul 2021 09:28:51 +0300 Subject: Enable `unicorn/no-array-for-each` rule --- js/src/util/index.js | 8 +++++--- js/src/util/sanitizer.js | 4 ++-- js/src/util/scrollbar.js | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'js/src/util') diff --git a/js/src/util/index.js b/js/src/util/index.js index b994963018..9cee979dfc 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -125,7 +125,7 @@ const getElement = obj => { } const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { + for (const property of Object.keys(configTypes)) { const expectedTypes = configTypes[property] const value = config[property] const valueType = value && isElement(value) ? 'element' : toType(value) @@ -135,7 +135,7 @@ const typeCheckConfig = (componentName, config, configTypes) => { `${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".` ) } - }) + } } const isVisible = element => { @@ -217,7 +217,9 @@ const onDOMContentLoaded = callback => { // add listener on the first call when the document is in loading state if (!DOMContentLoadedCallbacks.length) { document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()) + for (const callback of DOMContentLoadedCallbacks) { + callback() + } }) } diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js index c02a4eb906..e27961e9a3 100644 --- a/js/src/util/sanitizer.js +++ b/js/src/util/sanitizer.js @@ -114,11 +114,11 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { const attributeList = [].concat(...element.attributes) const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []) - attributeList.forEach(attribute => { + for (const attribute of attributeList) { if (!allowedAttribute(attribute, allowedAttributes)) { element.removeAttribute(attribute.nodeName) } - }) + } } return createdDocument.body.innerHTML diff --git a/js/src/util/scrollbar.js b/js/src/util/scrollbar.js index 2d5d0ffa65..f9a2d992dd 100644 --- a/js/src/util/scrollbar.js +++ b/js/src/util/scrollbar.js @@ -85,7 +85,9 @@ class ScrollBarHelper { if (isElement(selector)) { callBack(selector) } else { - SelectorEngine.find(selector, this._element).forEach(callBack) + for (const sel of SelectorEngine.find(selector, this._element)) { + callBack(sel) + } } } -- cgit v1.2.3