From 4b8ae1a78e2cf00ee7224e2b5d2e49f3176b5abe Mon Sep 17 00:00:00 2001 From: Phan An Date: Fri, 2 Dec 2022 17:17:37 +0100 Subject: [PATCH] chore: code style and some minor fixes --- .eslintrc | 4 +- resources/assets/js/App.vue | 38 ++++++++-------- .../js/__tests__/factory/albumInfoFactory.ts | 2 +- .../factory/smartPlaylistRuleGroupFactory.ts | 2 +- resources/assets/js/__tests__/stubs.ts | 12 ++--- .../assets/js/components/album/AlbumCard.vue | 2 - .../js/components/album/AlbumContextMenu.vue | 8 ++-- .../assets/js/components/album/AlbumInfo.vue | 10 ++--- .../js/components/album/AlbumTrackList.vue | 3 +- .../components/album/AlbumTrackListItem.vue | 2 +- .../__snapshots__/AlbumCard.spec.ts.snap | 2 +- .../js/components/artist/ArtistCard.vue | 2 - .../components/artist/ArtistContextMenu.vue | 8 ++-- .../js/components/artist/ArtistInfo.vue | 8 ++-- .../__snapshots__/ArtistCard.spec.ts.snap | 2 +- .../js/components/auth/LoginForm.spec.ts | 4 +- .../js/components/layout/ModalWrapper.vue | 6 +-- .../layout/app-footer/AudioPlayer.vue | 2 +- .../layout/app-footer/FooterExtraControls.vue | 6 +-- .../app-footer/FooterPlaybackControls.spec.ts | 4 +- .../app-footer/FooterPlaybackControls.vue | 12 ++--- .../layout/app-footer/FooterSongInfo.spec.ts | 6 +-- .../layout/app-footer/FooterSongInfo.vue | 4 +- .../js/components/layout/app-footer/index.vue | 8 ++-- .../layout/main-wrapper/ExtraPanel.vue | 32 +++++++------- .../layout/main-wrapper/MainContent.vue | 44 +++++++++---------- .../layout/main-wrapper/Sidebar.vue | 26 +++++------ .../components/layout/main-wrapper/index.vue | 10 ++--- .../js/components/meta/AboutKoelModal.vue | 5 ++- .../assets/js/components/meta/SupportKoel.vue | 2 +- .../CreateNewPlaylistContextMenu.spec.ts | 2 +- .../playlist/CreatePlaylistFolderForm.spec.ts | 2 +- .../playlist/CreatePlaylistForm.vue | 4 +- .../components/playlist/EditPlaylistForm.vue | 4 +- .../playlist/PlaylistContextMenu.spec.ts | 4 +- .../playlist/PlaylistContextMenu.vue | 12 ++--- .../PlaylistFolderContextMenu.spec.ts | 4 +- .../playlist/PlaylistFolderContextMenu.vue | 16 +++---- .../playlist/PlaylistFolderSidebarItem.vue | 6 +-- .../playlist/PlaylistSidebarList.vue | 8 ++-- .../CreateSmartPlaylistForm.vue | 8 ++-- .../smart-playlist/EditSmartPlaylistForm.vue | 12 +++-- .../smart-playlist/SmartPlaylistFormBase.vue | 2 +- .../smart-playlist/SmartPlaylistRule.vue | 14 +++--- .../smart-playlist/SmartPlaylistRuleGroup.vue | 8 ++-- .../smart-playlist/SmartPlaylistRuleInput.vue | 2 +- .../profile-preferences/LastfmIntegration.vue | 2 +- .../profile-preferences/PreferencesForm.vue | 14 +++--- .../profile-preferences/ProfileForm.vue | 6 +-- .../profile-preferences/ThemeCard.vue | 2 + .../profile-preferences/ThemeList.vue | 2 +- .../js/components/screens/AlbumListScreen.vue | 10 ++--- .../js/components/screens/AlbumScreen.vue | 41 +++++++++-------- .../js/components/screens/AllSongsScreen.vue | 16 +++---- .../components/screens/ArtistListScreen.vue | 10 ++--- .../js/components/screens/ArtistScreen.vue | 35 +++++++-------- .../js/components/screens/FavoritesScreen.vue | 23 +++++----- .../js/components/screens/GenreListScreen.vue | 8 ++-- .../js/components/screens/GenreScreen.vue | 24 +++++----- .../js/components/screens/HomeScreen.vue | 18 ++++---- .../js/components/screens/NotFoundScreen.vue | 4 +- .../js/components/screens/PlaylistScreen.vue | 27 ++++++------ .../js/components/screens/ProfileScreen.vue | 11 ++--- .../js/components/screens/QueueScreen.vue | 22 +++++----- .../screens/RecentlyPlayedScreen.vue | 22 +++++----- .../js/components/screens/UploadScreen.vue | 24 +++++----- .../js/components/screens/UserListScreen.vue | 10 ++--- .../components/screens/VisualizerScreen.vue | 8 ++-- .../js/components/screens/YouTubeScreen.vue | 4 +- .../screens/home/MostPlayedAlbums.vue | 4 +- .../screens/home/MostPlayedArtists.vue | 4 +- .../screens/home/MostPlayedSongs.vue | 4 +- .../screens/home/RecentlyAddedAlbums.vue | 4 +- .../screens/home/RecentlyAddedSongs.vue | 4 +- .../screens/home/RecentlyPlayedSongs.vue | 4 +- .../screens/search/SearchExcerptsScreen.vue | 16 +++---- .../search/SearchSongResultsScreen.vue | 18 ++++---- .../js/components/song/EditSongForm.vue | 18 ++++---- .../assets/js/components/song/SongCard.vue | 4 +- .../js/components/song/SongContextMenu.vue | 20 ++++----- .../js/components/song/SongLikeButton.vue | 4 +- .../assets/js/components/song/SongList.vue | 26 +++++------ .../js/components/song/SongListControls.vue | 18 ++++---- .../js/components/song/SongListItem.vue | 6 +-- .../js/components/song/SongListSorter.vue | 15 ++++--- .../js/components/song/SongThumbnail.vue | 4 +- .../js/components/ui/AlbumArtOverlay.vue | 2 +- .../js/components/ui/AlbumArtistThumbnail.vue | 7 ++- .../js/components/ui/AppleMusicButton.vue | 4 +- .../js/components/ui/ArtistAlbumCard.vue | 6 +-- .../components/ui/ArtistAlbumScreenTabs.vue | 4 +- resources/assets/js/components/ui/Btn.vue | 2 +- .../assets/js/components/ui/BtnCloseModal.vue | 2 +- .../assets/js/components/ui/BtnGroup.vue | 2 +- .../js/components/ui/BtnScrollToTop.vue | 2 +- .../assets/js/components/ui/CheckBox.vue | 4 +- .../js/components/ui/ContextMenuBase.vue | 6 +-- .../assets/js/components/ui/Equalizer.vue | 6 +-- .../js/components/ui/ExtraPanelTabHeader.vue | 18 ++++---- .../js/components/ui/FooterPlayButton.spec.ts | 6 ++- .../js/components/ui/FooterPlayButton.vue | 4 +- .../assets/js/components/ui/LyricsPane.vue | 2 +- .../assets/js/components/ui/Magnifier.vue | 4 +- .../assets/js/components/ui/MessageToast.vue | 8 ++-- .../js/components/ui/MessageToaster.vue | 2 +- .../js/components/ui/OfflineNotification.vue | 7 +-- resources/assets/js/components/ui/Overlay.vue | 14 +++--- .../assets/js/components/ui/ProfileAvatar.vue | 2 +- .../js/components/ui/RepeatModeSwitch.vue | 4 +- .../js/components/ui/ScreenControlsToggle.vue | 4 +- .../assets/js/components/ui/ScreenHeader.vue | 8 ++-- .../assets/js/components/ui/SearchForm.vue | 4 +- .../components/ui/SidebarMenuToggleButton.vue | 2 +- .../assets/js/components/ui/SoundBars.vue | 6 +-- .../assets/js/components/ui/TooltipIcon.vue | 2 +- .../js/components/ui/ViewModeSwitch.vue | 4 +- .../js/components/ui/VirtualScroller.vue | 2 +- resources/assets/js/components/ui/Volume.vue | 8 ++-- .../js/components/ui/YouTubeVideoList.vue | 4 +- .../AlbumArtistThumbnail.spec.ts.snap | 4 +- .../ui/skeletons/ArtistAlbumCardSkeleton.vue | 8 ++-- .../ui/skeletons/GenreItemSkeleton.vue | 4 +- .../ui/skeletons/ScreenHeaderSkeleton.vue | 8 ++-- .../ui/skeletons/SongCardSkeleton.vue | 6 +-- .../ui/skeletons/SongListSkeleton.vue | 26 +++++------ .../js/components/ui/upload/DropZone.vue | 2 +- .../js/components/ui/upload/UploadItem.vue | 6 +-- .../assets/js/components/user/AddUserForm.vue | 4 +- .../js/components/user/EditUserForm.vue | 4 +- .../assets/js/components/user/UserBadge.vue | 7 ++- .../assets/js/components/user/UserCard.vue | 2 +- .../user/__snapshots__/UserBadge.spec.ts.snap | 2 +- .../assets/js/composables/useContextMenu.ts | 11 +---- .../assets/js/composables/useFloatingUi.ts | 38 +++++++++------- .../js/composables/useInfiniteScroll.ts | 4 +- .../js/composables/useSmartPlaylistForm.ts | 2 +- .../assets/js/composables/useSongList.ts | 2 +- resources/assets/js/composables/useUpload.ts | 4 +- resources/assets/js/config/events.ts | 5 +-- resources/assets/js/directives/focus.ts | 3 -- resources/assets/js/remote/App.vue | 26 +++++------ resources/assets/js/stores/playlistStore.ts | 5 ++- resources/assets/js/stores/queueStore.spec.ts | 2 +- resources/assets/js/types.d.ts | 15 ++++--- resources/assets/js/utils/floatingUi.ts | 6 +-- resources/assets/js/utils/logger.ts | 8 ++-- 146 files changed, 642 insertions(+), 634 deletions(-) diff --git a/.eslintrc b/.eslintrc index 1044ba11..e7d1ba9a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -45,6 +45,8 @@ "vue/valid-v-on": 0, "vue/no-side-effects-in-computed-properties": 0, "vue/max-attributes-per-line": 0, - "vue/no-v-html": 0 + "vue/no-v-html": 0, + "vue/singleline-html-element-content-newline": 0, + "vue/multi-word-component-names": 0 } } diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index fedc01bb..f21cc9f7 100644 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -1,26 +1,26 @@ @@ -92,7 +92,7 @@ onMounted(async () => { }) const init = async () => { - overlay.value.show({ message: 'Just a little patience…' }) + overlay.value!.show({ message: 'Just a little patience…' }) try { await commonStore.init() @@ -108,7 +108,7 @@ const init = async () => { }) await socketService.init() && socketListener.listen() - overlay.value.hide() + overlay.value!.hide() } catch (err) { authenticated.value = false throw err diff --git a/resources/assets/js/__tests__/factory/albumInfoFactory.ts b/resources/assets/js/__tests__/factory/albumInfoFactory.ts index c356177e..85745cbb 100644 --- a/resources/assets/js/__tests__/factory/albumInfoFactory.ts +++ b/resources/assets/js/__tests__/factory/albumInfoFactory.ts @@ -7,6 +7,6 @@ export default (faker: Faker): AlbumInfo => ({ summary: faker.lorem.sentence(), full: faker.lorem.sentences(4) }, - tracks: factory('album-track', 8), + tracks: factory('album-track', 8), url: faker.internet.url() }) diff --git a/resources/assets/js/__tests__/factory/smartPlaylistRuleGroupFactory.ts b/resources/assets/js/__tests__/factory/smartPlaylistRuleGroupFactory.ts index 9c38e3c0..b0f4683f 100644 --- a/resources/assets/js/__tests__/factory/smartPlaylistRuleGroupFactory.ts +++ b/resources/assets/js/__tests__/factory/smartPlaylistRuleGroupFactory.ts @@ -3,5 +3,5 @@ import factory from 'factoria' export default (faker: Faker): SmartPlaylistRuleGroup => ({ id: faker.datatype.number(), - rules: factory('smart-playlist-rule', 3) + rules: factory('smart-playlist-rule', 3) }) diff --git a/resources/assets/js/__tests__/stubs.ts b/resources/assets/js/__tests__/stubs.ts index 8a657a05..3e931f81 100644 --- a/resources/assets/js/__tests__/stubs.ts +++ b/resources/assets/js/__tests__/stubs.ts @@ -5,22 +5,22 @@ import MessageToaster from '@/components/ui/MessageToaster.vue' import DialogBox from '@/components/ui/DialogBox.vue' import Overlay from '@/components/ui/Overlay.vue' -export const MessageToasterStub: Ref> = ref({ +export const MessageToasterStub = ref({ info: noop, success: noop, warning: noop, error: noop -}) +}) as unknown as Ref> -export const DialogBoxStub: Ref> = ref({ +export const DialogBoxStub = ref({ info: noop, success: noop, warning: noop, error: noop, confirm: noop -}) +}) as unknown as Ref> -export const OverlayStub: Ref> = ref({ +export const OverlayStub = ref({ show: noop, hide: noop -}) +}) as unknown as Ref> diff --git a/resources/assets/js/components/album/AlbumCard.vue b/resources/assets/js/components/album/AlbumCard.vue index eaa9781e..3478c2d1 100644 --- a/resources/assets/js/components/album/AlbumCard.vue +++ b/resources/assets/js/components/album/AlbumCard.vue @@ -18,7 +18,6 @@ @@ -28,7 +27,6 @@ v-if="allowDownload" :title="`Download all songs in the album ${album.name}`" class="download-album" - href role="button" @click.prevent="download" > diff --git a/resources/assets/js/components/album/AlbumContextMenu.vue b/resources/assets/js/components/album/AlbumContextMenu.vue index be61e590..a1826084 100644 --- a/resources/assets/js/components/album/AlbumContextMenu.vue +++ b/resources/assets/js/components/album/AlbumContextMenu.vue @@ -3,11 +3,11 @@ @@ -22,7 +22,7 @@ import { useContextMenu, useRouter } from '@/composables' import { eventBus } from '@/utils' const { go } = useRouter() -const { context, base, ContextMenuBase, open, trigger } = useContextMenu() +const { base, ContextMenuBase, open, trigger } = useContextMenu() const album = ref() const allowDownload = toRef(commonStore.state, 'allow_download') @@ -49,6 +49,6 @@ const download = () => trigger(() => downloadService.fromAlbum(album.value!)) eventBus.on('ALBUM_CONTEXT_MENU_REQUESTED', async (e, _album) => { album.value = _album - await open(e.pageY, e.pageX, { album }) + await open(e.pageY, e.pageX) }) diff --git a/resources/assets/js/components/album/AlbumInfo.vue b/resources/assets/js/components/album/AlbumInfo.vue index 1a1aed85..9d37601d 100644 --- a/resources/assets/js/components/album/AlbumInfo.vue +++ b/resources/assets/js/components/album/AlbumInfo.vue @@ -3,24 +3,24 @@

{{ album.name }}

- + diff --git a/resources/assets/js/components/album/__snapshots__/AlbumCard.spec.ts.snap b/resources/assets/js/components/album/__snapshots__/AlbumCard.spec.ts.snap index 1199b2b4..2bf0943e 100644 --- a/resources/assets/js/components/album/__snapshots__/AlbumCard.spec.ts.snap +++ b/resources/assets/js/components/album/__snapshots__/AlbumCard.spec.ts.snap @@ -4,7 +4,7 @@ exports[`renders 1`] = ` `; diff --git a/resources/assets/js/components/artist/ArtistCard.vue b/resources/assets/js/components/artist/ArtistCard.vue index 443b7fa4..496e3448 100644 --- a/resources/assets/js/components/artist/ArtistCard.vue +++ b/resources/assets/js/components/artist/ArtistCard.vue @@ -15,7 +15,6 @@ @@ -25,7 +24,6 @@ v-if="allowDownload" :title="`Download all songs by ${artist.name}`" class="download-artist" - href role="button" @click.prevent="download" > diff --git a/resources/assets/js/components/artist/ArtistContextMenu.vue b/resources/assets/js/components/artist/ArtistContextMenu.vue index 2ad0d7bc..7456da7e 100644 --- a/resources/assets/js/components/artist/ArtistContextMenu.vue +++ b/resources/assets/js/components/artist/ArtistContextMenu.vue @@ -4,11 +4,11 @@
  • Play All
  • Shuffle All
  • @@ -23,7 +23,7 @@ import { useContextMenu, useRouter } from '@/composables' import { eventBus } from '@/utils' const { go } = useRouter() -const { context, base, ContextMenuBase, open, trigger } = useContextMenu() +const { base, ContextMenuBase, open, trigger } = useContextMenu() const artist = ref() const allowDownload = toRef(commonStore.state, 'allow_download') @@ -48,6 +48,6 @@ const download = () => trigger(() => downloadService.fromArtist(artist.value!)) eventBus.on('ARTIST_CONTEXT_MENU_REQUESTED', async (e, _artist) => { artist.value = _artist - await open(e.pageY, e.pageX, { _artist }) + await open(e.pageY, e.pageX) }) diff --git a/resources/assets/js/components/artist/ArtistInfo.vue b/resources/assets/js/components/artist/ArtistInfo.vue index a59e7581..73d5cb8e 100644 --- a/resources/assets/js/components/artist/ArtistInfo.vue +++ b/resources/assets/js/components/artist/ArtistInfo.vue @@ -3,17 +3,17 @@

    {{ artist.name }}

    - + @@ -23,7 +23,7 @@ import { playbackService } from '@/services' import { useContextMenu, useRouter } from '@/composables' const { go } = useRouter() -const { context, base, ContextMenuBase, open, trigger } = useContextMenu() +const { base, ContextMenuBase, open, trigger } = useContextMenu() const folder = ref() @@ -40,13 +40,13 @@ const shuffle = () => trigger(async () => { go('queue') }) -const createPlaylist = () => trigger(() => eventBus.emit('MODAL_SHOW_CREATE_PLAYLIST_FORM', folder.value)) -const createSmartPlaylist = () => trigger(() => eventBus.emit('MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM', folder.value)) -const rename = () => trigger(() => eventBus.emit('MODAL_SHOW_EDIT_PLAYLIST_FOLDER_FORM', folder.value)) -const destroy = () => trigger(() => eventBus.emit('PLAYLIST_FOLDER_DELETE', folder.value)) +const createPlaylist = () => trigger(() => eventBus.emit('MODAL_SHOW_CREATE_PLAYLIST_FORM', folder.value!)) +const createSmartPlaylist = () => trigger(() => eventBus.emit('MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM', folder.value!)) +const rename = () => trigger(() => eventBus.emit('MODAL_SHOW_EDIT_PLAYLIST_FOLDER_FORM', folder.value!)) +const destroy = () => trigger(() => eventBus.emit('PLAYLIST_FOLDER_DELETE', folder.value!)) eventBus.on('PLAYLIST_FOLDER_CONTEXT_MENU_REQUESTED', async (e, _folder) => { folder.value = _folder - await open(e.pageY, e.pageX, { folder }) + await open(e.pageY, e.pageX) }) diff --git a/resources/assets/js/components/playlist/PlaylistFolderSidebarItem.vue b/resources/assets/js/components/playlist/PlaylistFolderSidebarItem.vue index 2767621e..52e1044a 100644 --- a/resources/assets/js/components/playlist/PlaylistFolderSidebarItem.vue +++ b/resources/assets/js/components/playlist/PlaylistFolderSidebarItem.vue @@ -2,18 +2,18 @@
  • - + {{ folder.name }}
      - +
      - - - - + + + +
    diff --git a/resources/assets/js/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue b/resources/assets/js/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue index 66945a88..89ab31ce 100644 --- a/resources/assets/js/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue +++ b/resources/assets/js/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue @@ -14,8 +14,8 @@
    @@ -25,11 +25,11 @@ v-for="(group, index) in collectedRuleGroups" :key="group.id" :group="group" - :isFirstGroup="index === 0" + :is-first-group="index === 0" @input="onGroupChanged" /> - + Group diff --git a/resources/assets/js/components/playlist/smart-playlist/EditSmartPlaylistForm.vue b/resources/assets/js/components/playlist/smart-playlist/EditSmartPlaylistForm.vue index 22a04d4c..eb46f650 100644 --- a/resources/assets/js/components/playlist/smart-playlist/EditSmartPlaylistForm.vue +++ b/resources/assets/js/components/playlist/smart-playlist/EditSmartPlaylistForm.vue @@ -20,8 +20,8 @@ @@ -31,11 +31,11 @@ v-for="(group, index) in mutablePlaylist.rules" :key="group.id" :group="group" - :isFirstGroup="index === 0" + :is-first-group="index === 0" @input="onGroupChanged" /> - +
  • @@ -63,9 +63,7 @@ const playlist = useModal().getFromContext('playlist') const folders = toRef(playlistFolderStore.state, 'folders') -let mutablePlaylist: Playlist - -watch(playlist, () => (mutablePlaylist = reactive(cloneDeep(playlist))), { immediate: true }) +const mutablePlaylist = reactive(cloneDeep(playlist)) const isPristine = () => isEqual(mutablePlaylist.rules, playlist.rules) && mutablePlaylist.name.trim() === playlist.name diff --git a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistFormBase.vue b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistFormBase.vue index 7789423b..df663d6f 100644 --- a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistFormBase.vue +++ b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistFormBase.vue @@ -1,6 +1,6 @@ diff --git a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRule.vue b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRule.vue index 077c19bc..dcac5ec6 100644 --- a/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRule.vue +++ b/resources/assets/js/components/playlist/smart-playlist/SmartPlaylistRule.vue @@ -1,11 +1,11 @@