]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
ESLint: enable prefer-template rule (#37484)
authorXhmikosR <xhmikosr@gmail.com>
Sat, 12 Nov 2022 08:09:36 +0000 (10:09 +0200)
committerGitHub <noreply@github.com>
Sat, 12 Nov 2022 08:09:36 +0000 (10:09 +0200)
.eslintrc.json
build/build-plugins.js
js/src/util/index.js
js/tests/karma.conf.js
js/tests/unit/collapse.spec.js
js/tests/unit/tab.spec.js
js/tests/unit/util/config.spec.js
js/tests/visual/carousel.html
js/tests/visual/modal.html

index d8e83a8d2eec8f9da62e0280c61c67d9b39b9103..b632124b37852a386db7336d99a1fb3b8ce211d2 100644 (file)
@@ -46,6 +46,7 @@
       "error",
       "after"
     ],
+    "prefer-template": "error",
     "semi": [
       "error",
       "never"
index 89fbe1d720be6622f1890513f4fc80e59d574e50..b6ce58df842121d0c5e84619999a7ae3a6db8a08 100644 (file)
@@ -16,7 +16,7 @@ const { babel } = require('@rollup/plugin-babel')
 const banner = require('./banner.js')
 
 const sourcePath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/')
-const jsFiles = globby.sync(sourcePath + '/**/*.js')
+const jsFiles = globby.sync(`${sourcePath}/**/*.js`)
 
 // Array which holds the resolved plugins
 const resolvedPlugins = []
index b04fdc12016151376cb04649d6ab162da9ad1517..b3e577b10b99f52ead14e0909aeb7c4a2ef219a8 100644 (file)
@@ -17,7 +17,7 @@ const TRANSITION_END = 'transitionend'
 const parseSelector = selector => {
   if (selector && window.CSS && window.CSS.escape) {
     // document.querySelector needs escaping to handle IDs (html5+) containing for instance /
-    selector = selector.replace(/#([^\s"#']+)/g, (match, id) => '#' + CSS.escape(id))
+    selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`)
   }
 
   return selector
index 6636ff15d597465efc55162d3598d12838d69b63..11c6f30451f2d9d371ab9fa8b6f0ce1692e6365c 100644 (file)
@@ -105,7 +105,7 @@ if (BROWSERSTACK) {
   config.browserStack = {
     username: ENV.BROWSER_STACK_USERNAME,
     accessKey: ENV.BROWSER_STACK_ACCESS_KEY,
-    build: `bootstrap-${ENV.GITHUB_SHA ? ENV.GITHUB_SHA.slice(0, 7) + '-' : ''}${new Date().toISOString()}`,
+    build: `bootstrap-${ENV.GITHUB_SHA ? `${ENV.GITHUB_SHA.slice(0, 7)}-` : ''}${new Date().toISOString()}`,
     project: 'Bootstrap',
     retryLimit: 2
   }
index 834d1b98e4a46374ad5ff4f5231f338ccee06294..d5af724fe20b87d761422257f15a6d59beabfbb7 100644 (file)
@@ -897,7 +897,7 @@ describe('Collapse', () => {
         const trigger2 = fixtureEl.querySelector('#trigger2')
         const trigger3 = fixtureEl.querySelector('#trigger3')
         const target1 = fixtureEl.querySelector('#test1')
-        const target2 = fixtureEl.querySelector('#' + CSS.escape('0/my/id'))
+        const target2 = fixtureEl.querySelector(`#${CSS.escape('0/my/id')}`)
 
         const target2Shown = () => {
           expect(trigger1).not.toHaveClass('collapsed')
index 66238efbb8b152b4843103a78d81f44d93955dae..1ac5929e178bde883a42a7582fca7356ee4134e6 100644 (file)
@@ -207,7 +207,7 @@ describe('Tab', () => {
       const tab = new Tab(profileTriggerEl)
 
       profileTriggerEl.addEventListener('shown.bs.tab', () => {
-        expect(fixtureEl.querySelector('#' + CSS.escape('2'))).toHaveClass('active')
+        expect(fixtureEl.querySelector(`#${CSS.escape('2')}`)).toHaveClass('active')
         done()
       })
 
index e1693c0c1f255bc7875782c6832f8d84e28425e5..0037e09d78769b5ebef4da7e9c66ebf4f55eea19 100644 (file)
@@ -128,7 +128,7 @@ describe('Config', () => {
       const obj = new DummyConfigClass()
       expect(() => {
         obj._typeCheckConfig(config)
-      }).toThrowError(TypeError, obj.constructor.NAME.toUpperCase() + ': Option "parent" provided type "number" but expected type "(string|element)".')
+      }).toThrowError(TypeError, `${obj.constructor.NAME.toUpperCase()}: Option "parent" provided type "number" but expected type "(string|element)".`)
     })
 
     it('should return null stringified when null is passed', () => {
index 153c8660429ddd7d7b9e41a602064eff7a7dac1e..1b2de52913599e471232ab3dc2df81909a74a89d 100644 (file)
@@ -55,7 +55,7 @@
       // Test to show that transition-duration can be changed with css
       carousel.addEventListener('slid.bs.carousel', event => {
         t1 = performance.now()
-        console.log('transition-duration took ' + (t1 - t0) + 'ms, slid at ' + event.timeStamp)
+        console.log(`transition-duration took ${t1 - t0}ms, slid at ${event.timeStamp}`)
       })
       carousel.addEventListener('slide.bs.carousel', () => {
         t0 = performance.now()
index b738d9e81b149db4ac05b9aea4b6cf76fb6aee09..09d42333d8c29b64d63207dd6bd4cfe81fcb5133 100644 (file)
 
       slowModal.addEventListener('shown.bs.modal', () => {
         t1 = performance.now()
-        console.log('transition-duration took ' + (t1 - t0) + 'ms.')
+        console.log(`transition-duration took ${t1 - t0}ms.`)
       })
 
       slowModal.addEventListener('show.bs.modal', () => {