1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

Enable unicorn/no-for-loop rule

This commit is contained in:
XhmikosR 2021-08-10 18:07:39 +03:00
parent 9f1579aa04
commit 2b4d0d166b
6 changed files with 15 additions and 20 deletions

View file

@ -53,7 +53,6 @@
"unicorn/no-array-callback-reference": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-array-method-this-argument": "off",
"unicorn/no-for-loop": "off",
"unicorn/no-null": "off",
"unicorn/no-unused-properties": "error",
"unicorn/numeric-separators-style": "off",

View file

@ -366,10 +366,10 @@ class Carousel extends BaseComponent {
const indicators = SelectorEngine.find(SELECTOR_INDICATOR, this._indicatorsElement)
for (let i = 0; i < indicators.length; i++) {
if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
indicators[i].classList.add(CLASS_NAME_ACTIVE)
indicators[i].setAttribute('aria-current', 'true')
for (const indicator of indicators) {
if (Number.parseInt(indicator.getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
indicator.classList.add(CLASS_NAME_ACTIVE)
indicator.setAttribute('aria-current', 'true')
break
}
}
@ -574,8 +574,8 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.da
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)
for (let i = 0, len = carousels.length; i < len; i++) {
Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]))
for (const carousel of carousels) {
Carousel.carouselInterface(carousel, Carousel.getInstance(carousel))
}
})

View file

@ -75,8 +75,7 @@ class Collapse extends BaseComponent {
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
for (let i = 0, len = toggleList.length; i < len; i++) {
const elem = toggleList[i]
for (const elem of toggleList) {
const selector = getSelectorFromElement(elem)
const filterElement = SelectorEngine.find(selector)
.filter(foundElem => foundElem === this._element)
@ -203,9 +202,7 @@ class Collapse extends BaseComponent {
this._element.classList.add(CLASS_NAME_COLLAPSING)
this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW)
const triggerArrayLength = this._triggerArray.length
for (let i = 0; i < triggerArrayLength; i++) {
const trigger = this._triggerArray[i]
for (const trigger of this._triggerArray) {
const elem = getElementFromSelector(trigger)
if (elem && !this._isShown(elem)) {

View file

@ -129,8 +129,8 @@ function bootstrapDelegationHandler(element, selector, fn) {
function findHandler(events, handler, delegationSelector = null) {
const uidEventList = Object.keys(events)
for (let i = 0, len = uidEventList.length; i < len; i++) {
const event = events[uidEventList[i]]
for (const uidEvent of uidEventList) {
const event = events[uidEvent]
if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
return event

View file

@ -377,8 +377,8 @@ class Dropdown extends BaseComponent {
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
for (let i = 0, len = toggles.length; i < len; i++) {
const context = Dropdown.getInstance(toggles[i])
for (const toggle of toggles) {
const context = Dropdown.getInstance(toggle)
if (!context || context._config.autoClose === false) {
continue
}

View file

@ -46,8 +46,8 @@ const allowedAttribute = (attribute, allowedAttributeList) => {
const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp)
// Check if a regular expression validates the attribute.
for (let i = 0, len = regExp.length; i < len; i++) {
if (regExp[i].test(attributeName)) {
for (const element of regExp) {
if (element.test(attributeName)) {
return true
}
}
@ -102,8 +102,7 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')
const elements = [].concat(...createdDocument.body.querySelectorAll('*'))
for (let i = 0, len = elements.length; i < len; i++) {
const element = elements[i]
for (const element of elements) {
const elementName = element.nodeName.toLowerCase()
if (!Object.keys(allowList).includes(elementName)) {