From b8373a4ee0d003cddf93420f4346200ac6baf140 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Sun, 21 Apr 2024 17:44:55 +0200 Subject: [PATCH] [web] Lint source code --- web-src/src/App.vue | 12 +++---- web-src/src/components/IndexButtonList.vue | 3 +- web-src/src/components/LyricsPane.vue | 16 +++++---- web-src/src/components/NavbarBottom.vue | 22 ++++++------ web-src/src/components/NavbarTop.vue | 12 +++---- web-src/src/lib/GroupedList.js | 8 +++-- web-src/src/pages/PageAbout.vue | 35 ++++++++++---------- web-src/src/pages/PageMusic.vue | 6 ++-- web-src/src/pages/PageMusicSpotify.vue | 6 ++-- web-src/src/templates/ContentWithHeading.vue | 6 ++-- web-src/vite.config.js | 4 +-- 11 files changed, 69 insertions(+), 61 deletions(-) diff --git a/web-src/src/App.vue b/web-src/src/App.vue index e21ad49b..cd64217b 100644 --- a/web-src/src/App.vue +++ b/web-src/src/App.vue @@ -143,15 +143,13 @@ export default { return } - const vm = this - let protocol = 'ws://' if (window.location.protocol === 'https:') { protocol = 'wss://' } let wsUrl = `${protocol + window.location.hostname}:${ - vm.$store.state.config.websocket_port + this.$store.state.config.websocket_port }` if (import.meta.env.DEV && import.meta.env.VITE_OWNTONE_URL) { @@ -161,7 +159,7 @@ export default { */ const owntoneUrl = new URL(import.meta.env.VITE_OWNTONE_URL) wsUrl = `${protocol + owntoneUrl.hostname}:${ - vm.$store.state.config.websocket_port + this.$store.state.config.websocket_port }` } @@ -170,6 +168,7 @@ export default { maxReconnectInterval: 2000 }) + const vm = this socket.onopen = () => { vm.reconnect_attempts = 0 socket.send( @@ -188,7 +187,6 @@ export default { ] }) ) - vm.update_outputs() vm.update_player_status() vm.update_library_stats() @@ -207,11 +205,10 @@ export default { */ let update_throttled = false - function update_info() { + const update_info = () => { if (update_throttled) { return } - vm.update_outputs() vm.update_player_status() vm.update_library_stats() @@ -220,7 +217,6 @@ export default { vm.update_spotify() vm.update_lastfm() vm.update_pairing() - update_throttled = true setTimeout(() => { update_throttled = false diff --git a/web-src/src/components/IndexButtonList.vue b/web-src/src/components/IndexButtonList.vue index 92853ada..22b02623 100644 --- a/web-src/src/components/IndexButtonList.vue +++ b/web-src/src/components/IndexButtonList.vue @@ -6,8 +6,9 @@ :key="index" class="button is-small" :to="{ hash: `#index_${index}`, query: $route.query }" - >{{ index }} + {{ index }} + diff --git a/web-src/src/components/LyricsPane.vue b/web-src/src/components/LyricsPane.vue index 3eaea074..c7868114 100644 --- a/web-src/src/components/LyricsPane.vue +++ b/web-src/src/components/LyricsPane.vue @@ -68,17 +68,19 @@ export default { (this.lastIndex < la.length - 1 && la[this.lastIndex + 1].time > currentTime) || this.lastIndex === la.length - 1 - ) + ) { return this.lastIndex + } if ( this.lastIndex < la.length - 2 && la[this.lastIndex + 2].time > currentTime - ) + ) { return this.lastIndex + 1 + } // Not found, then start a binary search - let start = 0, - end = la.length - 1, - index + let end = la.length - 1, + index = 0, + start = 0 while (start <= end) { index = (start + end) >> 1 const currentVerse = la[index] @@ -103,7 +105,7 @@ export default { const parsed = [] if (raw) { // Parse the lyrics - const regex = /(\[(\d+):(\d+)(?:\.\d+)?\] ?)?(.*)/ + const regex = /(\[(\d+):(\d+)(?:\.\d+)?\] ?)?(.*)/u raw.split('\n').forEach((item, index) => { const matches = regex.exec(item) if (matches && matches[4]) { @@ -120,7 +122,7 @@ export default { index < lyrics.length - 1 ? lyrics[index + 1].time - verse.time : 3 const unitDuration = duration / verse.text.length let delay = 0 - verse.words = verse.text.match(/\S+\s*/g).map((text) => { + verse.words = verse.text.match(/\S+\s*/gu).map((text) => { const duration = text.length * unitDuration delay += duration return { diff --git a/web-src/src/components/NavbarBottom.vue b/web-src/src/components/NavbarBottom.vue index 6105c726..fa60e6bc 100644 --- a/web-src/src/components/NavbarBottom.vue +++ b/web-src/src/components/NavbarBottom.vue @@ -60,7 +60,8 @@ 'is-loading': loading }" @click="togglePlay" - > + > +
@@ -70,8 +71,8 @@ :class="{ 'has-text-grey-light': !playing }" >

- + + > +

diff --git a/web-src/src/lib/GroupedList.js b/web-src/src/lib/GroupedList.js index af340763..ba8101d0 100644 --- a/web-src/src/lib/GroupedList.js +++ b/web-src/src/lib/GroupedList.js @@ -8,8 +8,8 @@ const stringComparator = (a, b) => a.localeCompare(b, locale.value) const dateComparator = (a, b) => new Date(a) - new Date(b) || (!a ? -1 : !b ? 1 : 0) -function createComparators(criteria) { - return criteria.map(({ field, type, order = 1 }) => { +const createComparators = (criteria) => { + criteria.map(({ field, type, order = 1 }) => { switch (type) { case String: return (a, b) => stringComparator(a[field], b[field]) * order @@ -17,6 +17,8 @@ function createComparators(criteria) { return (a, b) => numberComparator(a[field], b[field]) * order case Date: return (a, b) => dateComparator(a[field], b[field]) * order + default: + return null } }) } @@ -49,7 +51,7 @@ const timeIndex = (string) => { return times.find((item) => isNaN(diff) || diff < item.difference)?.text(date) } -function createIndexer({ field, type = undefined } = {}) { +const createIndexer = ({ field, type = undefined } = {}) => { switch (type) { case String: return (item) => characterIndex(item[field]) diff --git a/web-src/src/pages/PageAbout.vue b/web-src/src/pages/PageAbout.vue index ec6604ef..d4fc4ff5 100644 --- a/web-src/src/pages/PageAbout.vue +++ b/web-src/src/pages/PageAbout.vue @@ -146,25 +146,26 @@ keypath="page.about.built-with" scope="global" > - - - - - + + + + + /> + diff --git a/web-src/src/pages/PageMusic.vue b/web-src/src/pages/PageMusic.vue index a6bb16dd..dbc3b430 100644 --- a/web-src/src/pages/PageMusic.vue +++ b/web-src/src/pages/PageMusic.vue @@ -15,8 +15,9 @@ {{ $t('page.music.show-more') }} + {{ $t('page.music.show-more') }} +

@@ -35,8 +36,9 @@ {{ $t('page.music.show-more') }} + {{ $t('page.music.show-more') }} +

diff --git a/web-src/src/pages/PageMusicSpotify.vue b/web-src/src/pages/PageMusicSpotify.vue index 99c00508..f5485dd8 100644 --- a/web-src/src/pages/PageMusicSpotify.vue +++ b/web-src/src/pages/PageMusicSpotify.vue @@ -15,8 +15,9 @@ {{ $t('page.spotify.music.show-more') }} + {{ $t('page.spotify.music.show-more') }} +

@@ -38,8 +39,9 @@ {{ $t('page.spotify.music.show-more') }} + {{ $t('page.spotify.music.show-more') }} +

diff --git a/web-src/src/templates/ContentWithHeading.vue b/web-src/src/templates/ContentWithHeading.vue index 8c72a280..85d1d621 100644 --- a/web-src/src/templates/ContentWithHeading.vue +++ b/web-src/src/templates/ContentWithHeading.vue @@ -7,9 +7,9 @@
diff --git a/web-src/vite.config.js b/web-src/vite.config.js index 25dd6109..87933a3b 100644 --- a/web-src/vite.config.js +++ b/web-src/vite.config.js @@ -1,7 +1,7 @@ -import path from 'path' import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' import i18n from '@intlify/unplugin-vue-i18n/vite' +import path from 'path' +import vue from '@vitejs/plugin-vue' /* * In development mode, use the VITE_OWNTONE_URL environment variable to set