Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Déramond <julien.deramond@orange.com>2022-09-27 22:53:59 +0300
committerGitHub <noreply@github.com>2022-09-27 22:53:59 +0300
commitabb1cf529fb8dfb8e66e44506eb32f8a9e0e0ee2 (patch)
tree7fa480ede0394209bfe603a1417799c6f82f61b0
parentf84d82ada02084cc6567b7ff60f25650084b8bea (diff)
Add eslint-plugin-html to lint JS in HTML files (#37186)
-rw-r--r--.eslintignore2
-rw-r--r--js/tests/visual/.eslintrc.json19
-rw-r--r--js/tests/visual/modal.html9
-rw-r--r--js/tests/visual/popover.html2
-rw-r--r--js/tests/visual/toast.html6
-rw-r--r--js/tests/visual/tooltip.html17
-rw-r--r--package-lock.json160
-rw-r--r--package.json3
8 files changed, 204 insertions, 14 deletions
diff --git a/.eslintignore b/.eslintignore
index a18b03a5df..04bae15411 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -3,4 +3,6 @@
**/vendor/
/_site/
/js/coverage/
+/js/tests/integration/
/site/static/sw.js
+/site/layouts/
diff --git a/js/tests/visual/.eslintrc.json b/js/tests/visual/.eslintrc.json
new file mode 100644
index 0000000000..8a33225720
--- /dev/null
+++ b/js/tests/visual/.eslintrc.json
@@ -0,0 +1,19 @@
+{
+ "plugins": [
+ "html"
+ ],
+ "extends": "../../../.eslintrc.json",
+ "parserOptions": {
+ "sourceType": "module"
+ },
+ "settings": {
+ "html/html-extensions": [
+ ".html"
+ ]
+ },
+ "rules": {
+ "no-console": "off",
+ "no-new": "off",
+ "unicorn/no-array-for-each": "off"
+ }
+}
diff --git a/js/tests/visual/modal.html b/js/tests/visual/modal.html
index 5056c6e7c5..fd93c068ac 100644
--- a/js/tests/visual/modal.html
+++ b/js/tests/visual/modal.html
@@ -201,6 +201,8 @@
<script src="../../../dist/js/bootstrap.bundle.js"></script>
<script>
+ /* global bootstrap: false */
+
const ffBugTestResult = document.getElementById('ff-bug-test-result')
const firefoxTestDone = false
@@ -217,11 +219,7 @@
const tall = document.getElementById('tall')
document.getElementById('tall-toggle').addEventListener('click', () => {
- if (tall.style.display === 'none') {
- tall.style.display = 'block'
- } else {
- tall.style.display = 'none'
- }
+ tall.style.display = tall.style.display === 'none' ? 'block' : 'none'
})
const ffBugInput = document.getElementById('ff-bug-input')
@@ -231,6 +229,7 @@
ffBugInput.addEventListener('focus', reportFirefoxTestResult.bind(true))
ffBugInput.removeEventListener('focus', handlerClickFfBugInput)
}
+
ffBugInput.addEventListener('focus', handlerClickFfBugInput)
const modalFf = new bootstrap.Modal(firefoxModal)
diff --git a/js/tests/visual/popover.html b/js/tests/visual/popover.html
index 96b746b728..73edf998d4 100644
--- a/js/tests/visual/popover.html
+++ b/js/tests/visual/popover.html
@@ -33,6 +33,8 @@
<script src="../../../dist/js/bootstrap.bundle.js"></script>
<script>
+ /* global bootstrap: false */
+
document.querySelectorAll('[data-bs-toggle="popover"]').forEach(popoverEl => new bootstrap.Popover(popoverEl))
</script>
</body>
diff --git a/js/tests/visual/toast.html b/js/tests/visual/toast.html
index cacc7da707..f86926d019 100644
--- a/js/tests/visual/toast.html
+++ b/js/tests/visual/toast.html
@@ -52,15 +52,17 @@
<script src="../../../dist/js/bootstrap.bundle.js"></script>
<script>
+ /* global bootstrap: false */
+
window.addEventListener('load', () => {
document.querySelectorAll('.toast').forEach(toastEl => new bootstrap.Toast(toastEl))
document.getElementById('btnShowToast').addEventListener('click', () => {
- document.querySelectorAll('.toast').forEach(toastEl => bootstrap.Toast.getInstance(toastEl).show())
+ document.querySelectorAll('.toast').forEach(toastEl => bootstrap.Toast.getInstance(toastEl).show())
})
document.getElementById('btnHideToast').addEventListener('click', () => {
- document.querySelectorAll('.toast').forEach(toastEl => bootstrap.Toast.getInstance(toastEl).hide())
+ document.querySelectorAll('.toast').forEach(toastEl => bootstrap.Toast.getInstance(toastEl).hide())
})
})
</script>
diff --git a/js/tests/visual/tooltip.html b/js/tests/visual/tooltip.html
index 9a65640b44..1a3b9f21db 100644
--- a/js/tests/visual/tooltip.html
+++ b/js/tests/visual/tooltip.html
@@ -85,6 +85,8 @@
<script src="../../../dist/js/bootstrap.bundle.js"></script>
<script>
+ /* global bootstrap: false */
+
if (typeof document.body.attachShadow === 'function') {
const shadowRoot = document.getElementById('shadow').attachShadow({ mode: 'open' })
shadowRoot.innerHTML =
@@ -101,32 +103,35 @@
})
}
-
new bootstrap.Tooltip('#tooltipElement', {
container: '#customContainer'
})
const targetTooltip = new bootstrap.Tooltip('#target', {
- placement : 'top',
- trigger : 'manual'
+ placement: 'top',
+ trigger: 'manual'
})
targetTooltip.show()
- document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(tooltipEl=> new bootstrap.Tooltip(tooltipEl))
+ document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(tooltipEl => new bootstrap.Tooltip(tooltipEl))
</script>
<script>
+ /* global bootstrap: false */
+
new bootstrap.Tooltip('#wrapperTriggeredBySelector', {
animation: false,
selector: '.bs-dynamic-tooltip'
})
+ /* eslint-disable no-unused-vars */
function duplicateButtons() {
const buttonsBlock = document.querySelector('.selectorButtonsBlock')// get first
const buttonsBlockClone = buttonsBlock.cloneNode(true)
- buttonsBlockClone.innerHTML+= new Date().toLocaleString()
- document.querySelector('#wrapperTriggeredBySelector').append(buttonsBlockClone)
+ buttonsBlockClone.innerHTML += new Date().toLocaleString()
+ document.querySelector('#wrapperTriggeredBySelector').append(buttonsBlockClone)
}
+ /* eslint-enable no-unused-vars */
</script>
</body>
diff --git a/package-lock.json b/package-lock.json
index 88a8bd5c64..e783c945da 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -33,6 +33,7 @@
"cross-env": "^7.0.3",
"eslint": "^8.24.0",
"eslint-config-xo": "^0.42.0",
+ "eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-unicorn": "^43.0.2",
@@ -3907,6 +3908,61 @@
"void-elements": "^2.0.0"
}
},
+ "node_modules/dom-serializer": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
+ "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.2",
+ "entities": "^4.2.0"
+ },
+ "funding": {
+ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
+ }
+ },
+ "node_modules/domelementtype": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
+ "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/fb55"
+ }
+ ]
+ },
+ "node_modules/domhandler": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
+ "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
+ "dev": true,
+ "dependencies": {
+ "domelementtype": "^2.3.0"
+ },
+ "engines": {
+ "node": ">= 4"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/domhandler?sponsor=1"
+ }
+ },
+ "node_modules/domutils": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.0.1.tgz",
+ "integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==",
+ "dev": true,
+ "dependencies": {
+ "dom-serializer": "^2.0.0",
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.1"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/domutils?sponsor=1"
+ }
+ },
"node_modules/download": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/download/-/download-7.1.0.tgz",
@@ -4044,6 +4100,18 @@
"integrity": "sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA==",
"dev": true
},
+ "node_modules/entities": {
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz",
+ "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.12"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/entities?sponsor=1"
+ }
+ },
"node_modules/error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@@ -4275,6 +4343,15 @@
"ms": "^2.1.1"
}
},
+ "node_modules/eslint-plugin-html": {
+ "version": "7.1.0",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-7.1.0.tgz",
+ "integrity": "sha512-fNLRraV/e6j8e3XYOC9xgND4j+U7b1Rq+OygMlLcMg+wI/IpVbF+ubQa3R78EjKB9njT6TQOlcK5rFKBVVtdfg==",
+ "dev": true,
+ "dependencies": {
+ "htmlparser2": "^8.0.1"
+ }
+ },
"node_modules/eslint-plugin-import": {
"version": "2.26.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
@@ -5565,6 +5642,25 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/htmlparser2": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.1.tgz",
+ "integrity": "sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==",
+ "dev": true,
+ "funding": [
+ "https://github.com/fb55/htmlparser2?sponsor=1",
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/fb55"
+ }
+ ],
+ "dependencies": {
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.2",
+ "domutils": "^3.0.1",
+ "entities": "^4.3.0"
+ }
+ },
"node_modules/http-cache-semantics": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz",
@@ -13242,6 +13338,43 @@
"void-elements": "^2.0.0"
}
},
+ "dom-serializer": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
+ "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
+ "dev": true,
+ "requires": {
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.2",
+ "entities": "^4.2.0"
+ }
+ },
+ "domelementtype": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
+ "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
+ "dev": true
+ },
+ "domhandler": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
+ "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
+ "dev": true,
+ "requires": {
+ "domelementtype": "^2.3.0"
+ }
+ },
+ "domutils": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.0.1.tgz",
+ "integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==",
+ "dev": true,
+ "requires": {
+ "dom-serializer": "^2.0.0",
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.1"
+ }
+ },
"download": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/download/-/download-7.1.0.tgz",
@@ -13363,6 +13496,12 @@
"integrity": "sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA==",
"dev": true
},
+ "entities": {
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz",
+ "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==",
+ "dev": true
+ },
"error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@@ -13635,6 +13774,15 @@
}
}
},
+ "eslint-plugin-html": {
+ "version": "7.1.0",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-7.1.0.tgz",
+ "integrity": "sha512-fNLRraV/e6j8e3XYOC9xgND4j+U7b1Rq+OygMlLcMg+wI/IpVbF+ubQa3R78EjKB9njT6TQOlcK5rFKBVVtdfg==",
+ "dev": true,
+ "requires": {
+ "htmlparser2": "^8.0.1"
+ }
+ },
"eslint-plugin-import": {
"version": "2.26.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
@@ -14517,6 +14665,18 @@
"integrity": "sha512-vy7ClnArOZwCnqZgvv+ddgHgJiAFXe3Ge9ML5/mBctVJoUoYPCdxVucOywjDARn6CVoh3dRSFdPHy2sX80L0Wg==",
"dev": true
},
+ "htmlparser2": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.1.tgz",
+ "integrity": "sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==",
+ "dev": true,
+ "requires": {
+ "domelementtype": "^2.3.0",
+ "domhandler": "^5.0.2",
+ "domutils": "^3.0.1",
+ "entities": "^4.3.0"
+ }
+ },
"http-cache-semantics": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz",
diff --git a/package.json b/package.json
index 7af88f8411..f4bf383e2e 100644
--- a/package.json
+++ b/package.json
@@ -63,7 +63,7 @@
"js-compile-standalone-esm": "rollup --environment ESM:true,BUNDLE:false --config build/rollup.config.js --sourcemap",
"js-compile-bundle": "rollup --environment BUNDLE:true --config build/rollup.config.js --sourcemap",
"js-compile-plugins": "node build/build-plugins.js",
- "js-lint": "eslint --cache --cache-location .cache/.eslintcache --report-unused-disable-directives .",
+ "js-lint": "eslint --cache --cache-location .cache/.eslintcache --report-unused-disable-directives --ext .html,.js .",
"js-minify": "npm-run-all --aggregate-output --parallel js-minify-*",
"js-minify-standalone": "terser --compress passes=2 --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.js.map,includeSources,url=bootstrap.min.js.map\" --output dist/js/bootstrap.min.js dist/js/bootstrap.js",
"js-minify-standalone-esm": "terser --compress passes=2 --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.esm.js.map,includeSources,url=bootstrap.esm.min.js.map\" --output dist/js/bootstrap.esm.min.js dist/js/bootstrap.esm.js",
@@ -118,6 +118,7 @@
"cross-env": "^7.0.3",
"eslint": "^8.24.0",
"eslint-config-xo": "^0.42.0",
+ "eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-unicorn": "^43.0.2",