From be931f41731b1ab0f42265b05c06faccdef15b58 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Mon, 1 Apr 2024 15:13:42 +0200 Subject: [PATCH] [web] Lint source code --- web-src/src/App.vue | 9 ++++----- web-src/src/components/LyricsPane.vue | 4 ++-- web-src/src/lib/SVGRenderer.js | 8 ++++---- web-src/src/pages/PageQueue.vue | 7 ++----- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/web-src/src/App.vue b/web-src/src/App.vue index bc7d4d96..e21ad49b 100644 --- a/web-src/src/App.vue +++ b/web-src/src/App.vue @@ -97,9 +97,8 @@ export default { // Hook the progress bar to start before we move router-view this.$router.beforeEach((to, from, next) => { if (to.meta.show_progress && !(to.path === from.path && to.hash)) { - if (to.meta.progress !== undefined) { - const meta = to.meta.progress - this.$Progress.parseMeta(meta) + if (to.meta.progress) { + this.$Progress.parseMeta(to.meta.progress) } this.$Progress.start() } @@ -171,7 +170,7 @@ export default { maxReconnectInterval: 2000 }) - socket.onopen = function () { + socket.onopen = () => { vm.reconnect_attempts = 0 socket.send( JSON.stringify({ @@ -239,7 +238,7 @@ export default { } }) - socket.onmessage = function (response) { + socket.onmessage = (response) => { const data = JSON.parse(response.data) if ( data.notify.includes('update') || diff --git a/web-src/src/components/LyricsPane.vue b/web-src/src/components/LyricsPane.vue index df1c491c..3eaea074 100644 --- a/web-src/src/components/LyricsPane.vue +++ b/web-src/src/components/LyricsPane.vue @@ -146,7 +146,7 @@ export default { methods: { reset_scrolling() { // Scroll to the start of the lyrics in all cases - if (this.player.item_id != this.lastItemId && this.$refs.lyrics) { + if (this.player.item_id !== this.lastItemId && this.$refs.lyrics) { this.$refs.lyrics.scrollTo(0, 0) } this.lastItemId = this.player.item_id @@ -154,7 +154,7 @@ export default { }, start_scrolling(e) { // Consider only user events - if (e.screenX || e.screenX != 0 || e.screenY || e.screenY != 0) { + if (e.screenX || e.screenX !== 0 || e.screenY || e.screenY !== 0) { this.autoScrolling = false if (this.scrollingTimer) { clearTimeout(this.scrollingTimer) diff --git a/web-src/src/lib/SVGRenderer.js b/web-src/src/lib/SVGRenderer.js index 27f3e021..eb736111 100644 --- a/web-src/src/lib/SVGRenderer.js +++ b/web-src/src/lib/SVGRenderer.js @@ -1,15 +1,15 @@ const toColor = (string) => { let hash = 0 - for (let i = 0; i < string.length; i++) { - hash = string.charCodeAt(i) + ((hash << 5) - hash) + for (const char of string) { + hash = char.charCodeAt(0) + ((hash << 5) - hash) } return (hash & 0x00ffffff).toString(16) } const luminance = (color) => [0.2126, 0.7152, 0.0722].reduce( - (luminance, factor, index) => - luminance + Number(`0x${color.slice(index * 2, index * 2 + 2)}`) * factor, + (value, factor, index) => + value + Number(`0x${color.slice(index * 2, index * 2 + 2)}`) * factor, 0 ) / 255 diff --git a/web-src/src/pages/PageQueue.vue b/web-src/src/pages/PageQueue.vue index 8438ee4d..fe813336 100644 --- a/web-src/src/pages/PageQueue.vue +++ b/web-src/src/pages/PageQueue.vue @@ -135,10 +135,7 @@ export default { computed: { current_position() { - const nowPlaying = this.$store.getters.now_playing - return nowPlaying === undefined || nowPlaying.position === undefined - ? -1 - : this.$store.getters.now_playing.position + return this.$store.getters.now_playing?.position ?? -1 }, is_queue_save_allowed() { return ( @@ -189,7 +186,7 @@ export default { remove(item) { webapi.queue_remove(item.id) }, - update_show_next_items(e) { + update_show_next_items() { this.$store.commit(types.SHOW_ONLY_NEXT_ITEMS, !this.show_only_next_items) }, save_dialog() {