0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-03-15 15:29:22 +01: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-callback-reference": "off",
"unicorn/no-array-for-each": "off", "unicorn/no-array-for-each": "off",
"unicorn/no-array-method-this-argument": "off", "unicorn/no-array-method-this-argument": "off",
"unicorn/no-for-loop": "off",
"unicorn/no-null": "off", "unicorn/no-null": "off",
"unicorn/no-unused-properties": "error", "unicorn/no-unused-properties": "error",
"unicorn/numeric-separators-style": "off", "unicorn/numeric-separators-style": "off",

View File

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

View File

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

View File

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

View File

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

View File

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