Enable `unicorn/prefer-prototype-methods` rule

This commit is contained in:
XhmikosR 2021-03-18 12:58:26 +02:00
parent 57d80fcd32
commit 9f1579aa04
17 changed files with 16 additions and 18 deletions

View File

@ -60,7 +60,6 @@
"unicorn/prefer-array-flat": "off",
"unicorn/prefer-dom-node-dataset": "off",
"unicorn/prefer-module": "off",
"unicorn/prefer-prototype-methods": "off",
"unicorn/prefer-query-selector": "off",
"unicorn/prefer-spread": "off",
"unicorn/prevent-abbreviations": "off"

View File

@ -15,7 +15,7 @@ const toType = obj => {
return `${obj}`
}
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase()
return Object.prototype.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase()
}
/**

View File

@ -220,12 +220,12 @@
}
}
[].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
.forEach(function (popover) {
new Popover(popover)
})
var tooltipList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
tooltipList.forEach(function (tooltip) {
new Tooltip(tooltip)
})

View File

@ -40,7 +40,7 @@
<script src="../../dist/tooltip.js"></script>
<script src="../../dist/popover.js"></script>
<script>
[].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
.forEach(function (popover) {
new Popover(popover)
})

View File

@ -92,7 +92,7 @@
})
}
[].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
.forEach(function (tooltip) {
new Tooltip(tooltip)
})

View File

@ -54,7 +54,6 @@
"unicorn/prefer-array-flat": "off",
"unicorn/prefer-dom-node-dataset": "off",
"unicorn/prefer-module": "off",
"unicorn/prefer-prototype-methods": "off",
"unicorn/prefer-query-selector": "off",
"unicorn/prevent-abbreviations": "off"
}

View File

@ -182,7 +182,7 @@ Initialize elements as alerts
```js
var alertList = document.querySelectorAll('.alert')
var alerts = [].slice.call(alertList).map(function (element) {
var alerts = Array.prototype.slice.call(alertList).map(function (element) {
return new bootstrap.Alert(element)
})
```

View File

@ -133,7 +133,7 @@ To add accordion-like group management to a collapsible area, add the data attri
Enable manually with:
```js
var collapseElementList = [].slice.call(document.querySelectorAll('.collapse'))
var collapseElementList = Array.prototype.slice.call(document.querySelectorAll('.collapse'))
var collapseList = collapseElementList.map(function (collapseEl) {
return new bootstrap.Collapse(collapseEl)
})

View File

@ -1003,7 +1003,7 @@ Add `data-bs-toggle="dropdown"` to a link or button to toggle a dropdown.
Call the dropdowns via JavaScript:
```js
var dropdownElementList = [].slice.call(document.querySelectorAll('.dropdown-toggle'))
var dropdownElementList = Array.prototype.slice.call(document.querySelectorAll('.dropdown-toggle'))
var dropdownList = dropdownElementList.map(function (dropdownToggleEl) {
return new bootstrap.Dropdown(dropdownToggleEl)
})

View File

@ -397,7 +397,7 @@ You can activate a list group navigation without writing any JavaScript by simpl
Enable tabbable list item via JavaScript (each list item needs to be activated individually):
```js
var triggerTabList = [].slice.call(document.querySelectorAll('#myTab a'))
var triggerTabList = Array.prototype.slice.call(document.querySelectorAll('#myTab a'))
triggerTabList.forEach(function (triggerEl) {
var tabTrigger = new bootstrap.Tab(triggerEl)

View File

@ -525,7 +525,7 @@ You can activate a tab or pill navigation without writing any JavaScript by simp
Enable tabbable tabs via JavaScript (each tab needs to be activated individually):
```js
var triggerTabList = [].slice.call(document.querySelectorAll('#myTab button'))
var triggerTabList = Array.prototype.slice.call(document.querySelectorAll('#myTab button'))
triggerTabList.forEach(function (triggerEl) {
var tabTrigger = new bootstrap.Tab(triggerEl)

View File

@ -211,7 +211,7 @@ While both ways to dismiss an offcanvas are supported, keep in mind that dismiss
Enable manually with:
```js
var offcanvasElementList = [].slice.call(document.querySelectorAll('.offcanvas'))
var offcanvasElementList = Array.prototype.slice.call(document.querySelectorAll('.offcanvas'))
var offcanvasList = offcanvasElementList.map(function (offcanvasEl) {
return new bootstrap.Offcanvas(offcanvasEl)
})

View File

@ -36,7 +36,7 @@ Keep reading to see how popovers work with some examples.
One way to initialize all popovers on a page would be to select them by their `data-bs-toggle` attribute:
```js
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverTriggerList = Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})

View File

@ -278,7 +278,7 @@ Target elements that are not visible will be ignored and their corresponding nav
When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:
```js
var dataSpyList = [].slice.call(document.querySelectorAll('[data-bs-spy="scroll"]'))
var dataSpyList = Array.prototype.slice.call(document.querySelectorAll('[data-bs-spy="scroll"]'))
dataSpyList.forEach(function (dataSpyEl) {
bootstrap.ScrollSpy.getInstance(dataSpyEl)
.refresh()

View File

@ -335,7 +335,7 @@ While technically it's possible to add focusable/actionable controls (such as ad
Initialize toasts via JavaScript:
```js
var toastElList = [].slice.call(document.querySelectorAll('.toast'))
var toastElList = Array.prototype.slice.call(document.querySelectorAll('.toast'))
var toastList = toastElList.map(function (toastEl) {
return new bootstrap.Toast(toastEl, option)
})

View File

@ -35,7 +35,7 @@ Got all that? Great, let's see how they work with some examples.
One way to initialize all tooltips on a page would be to select them by their `data-bs-toggle` attribute:
```js
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipTriggerList = Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})

View File

@ -1,7 +1,7 @@
/* global bootstrap: false */
(function () {
'use strict'
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipTriggerList = Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
tooltipTriggerList.forEach(function (tooltipTriggerEl) {
new bootstrap.Tooltip(tooltipTriggerEl)
})