Fix eslint

This commit is contained in:
wvffle 2022-08-31 18:43:25 +00:00 committed by Georg Krause
parent 95e3dcb130
commit b17941fc44
24 changed files with 148 additions and 40 deletions

View File

@ -32,6 +32,9 @@ module.exports = {
'no-unused-vars': 'off', 'no-unused-vars': 'off',
'no-use-before-define': 'off', 'no-use-before-define': 'off',
// TODO (wvffle): VUI and #1618
'import/extensions': 'off',
// TODO (wvffle): Enable these rules later // TODO (wvffle): Enable these rules later
'vue/multi-word-component-names': 'off', 'vue/multi-word-component-names': 'off',
'@typescript-eslint/no-this-alias': 'off', '@typescript-eslint/no-this-alias': 'off',
@ -39,9 +42,6 @@ module.exports = {
'@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'off',
// TODO (wvffle): Migrate to pinia // TODO (wvffle): Migrate to pinia
'@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-explicit-any': 'off'
// TODO (wvffle): Migrate to <script setup>
'vue/require-explicit-emits': 'off'
} }
} }

View File

@ -16,10 +16,15 @@ import { useStore } from '~/store'
import { setupDropdown } from '~/utils/fomantic' import { setupDropdown } from '~/utils/fomantic'
import { useCurrentElement } from '@vueuse/core' import { useCurrentElement } from '@vueuse/core'
interface Events {
(e: 'show:set-instance-modal'): void
}
interface Props { interface Props {
width: number width: number
} }
const emit = defineEmits<Events>()
defineProps<Props>() defineProps<Props>()
const store = useStore() const store = useStore()
@ -579,7 +584,7 @@ onMounted(() => {
role="button" role="button"
href="" href=""
class="link item" class="link item"
@click.prevent="$emit('show:set-instance-modal')" @click.prevent="emit('show:set-instance-modal')"
>Switch instance</a> >Switch instance</a>
</div> </div>
</nav> </nav>

View File

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
/* eslint-disable vue/valid-v-model */
import type { BackendError, SettingsGroup, SettingsDataEntry, FunctionRef, Form } from '~/types' import type { BackendError, SettingsGroup, SettingsDataEntry, FunctionRef, Form } from '~/types'
import axios from 'axios' import axios from 'axios'
import SignupFormBuilder from '~/components/admin/SignupFormBuilder.vue' import SignupFormBuilder from '~/components/admin/SignupFormBuilder.vue'
@ -207,7 +208,7 @@ const save = async () => {
class="ui search selection dropdown" class="ui search selection dropdown"
> >
<option <option
v-for="v in setting.additional_data.choices" v-for="v in setting.additional_data?.choices"
:key="v[0]" :key="v[0]"
:value="v[0]" :value="v[0]"
> >

View File

@ -33,7 +33,15 @@ interface Props extends PlayOptionsProps {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
showArt: true, showArt: true,
isArtist: false, isArtist: false,
isAlbum: false isAlbum: false,
tracks: () => [],
artist: null,
album: null,
playlist: null,
library: null,
channel: null,
account: null
}) })
const showTrackModal = ref(false) const showTrackModal = ref(false)

View File

@ -37,7 +37,15 @@ interface Props extends PlayOptionsProps {
const emit = defineEmits<Events>() const emit = defineEmits<Events>()
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
isArtist: false, isArtist: false,
isAlbum: false isAlbum: false,
tracks: () => [],
artist: null,
album: null,
playlist: null,
library: null,
channel: null,
account: null
}) })
const modal = ref() const modal = ref()

View File

@ -34,7 +34,15 @@ interface Props extends PlayOptionsProps {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
showArt: true, showArt: true,
displayActions: true, displayActions: true,
defaultCover: null defaultCover: null,
tracks: () => [],
artist: null,
album: null,
playlist: null,
library: null,
channel: null,
account: null
}) })
const description = ref('') const description = ref('')

View File

@ -33,7 +33,15 @@ interface Props extends PlayOptionsProps {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
showArt: true, showArt: true,
isArtist: false, isArtist: false,
isAlbum: false isAlbum: false,
tracks: () => [],
artist: null,
album: null,
playlist: null,
library: null,
channel: null,
account: null
}) })
const showTrackModal = ref(false) const showTrackModal = ref(false)

View File

@ -37,7 +37,15 @@ interface Props extends PlayOptionsProps {
const emit = defineEmits<Events>() const emit = defineEmits<Events>()
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
isArtist: false, isArtist: false,
isAlbum: false isAlbum: false,
tracks: () => [],
artist: null,
album: null,
playlist: null,
library: null,
channel: null,
account: null
}) })
const modal = ref() const modal = ref()

View File

@ -41,7 +41,14 @@ const props = withDefaults(defineProps<Props>(), {
showArtist: true, showArtist: true,
showDuration: true, showDuration: true,
showPosition: false, showPosition: false,
displayActions: true displayActions: true,
artist: null,
album: null,
playlist: null,
library: null,
channel: null,
account: null
}) })
const { playing, loading } = usePlayer() const { playing, loading } = usePlayer()

View File

@ -4,10 +4,15 @@ import SemanticModal from '~/components/semantic/Modal.vue'
import ChannelAlbumForm from '~/components/channels/AlbumForm.vue' import ChannelAlbumForm from '~/components/channels/AlbumForm.vue'
import { watch, ref } from 'vue' import { watch, ref } from 'vue'
interface Events {
(e: 'created'): void
}
interface Props { interface Props {
channel: Channel channel: Channel
} }
const emit = defineEmits<Events>()
defineProps<Props>() defineProps<Props>()
const isLoading = ref(false) const isLoading = ref(false)
@ -47,7 +52,7 @@ const albumForm = ref()
:channel="channel" :channel="channel"
@loading="isLoading = $event" @loading="isLoading = $event"
@submittable="submittable = $event" @submittable="submittable = $event"
@created="$emit('created', $event)" @created="emit('created')"
/> />
</div> </div>
<div class="actions"> <div class="actions">

View File

@ -1,8 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
interface Events {
(e: 'refresh'): void
}
interface Props { interface Props {
refresh?: boolean refresh?: boolean
} }
const emit = defineEmits<Events>()
withDefaults(defineProps<Props>(), { withDefaults(defineProps<Props>(), {
refresh: false refresh: false
}) })
@ -25,7 +30,7 @@ withDefaults(defineProps<Props>(), {
<button <button
v-if="refresh" v-if="refresh"
class="ui button" class="ui button"
@click="$emit('refresh')" @click="emit('refresh')"
> >
<translate translate-context="Content/*/Button.Label/Short, Verb"> <translate translate-context="Content/*/Button.Label/Short, Verb">
Refresh Refresh

View File

@ -6,10 +6,15 @@ import SemanticModal from '~/components/semantic/Modal.vue'
import { useTimeoutFn } from '@vueuse/core' import { useTimeoutFn } from '@vueuse/core'
import { ref } from 'vue' import { ref } from 'vue'
interface Events {
(e: 'refresh'): void
}
interface Props { interface Props {
url: string url: string
} }
const emit = defineEmits<Events>()
const props = defineProps<Props>() const props = defineProps<Props>()
const MAX_POLLS = 15 const MAX_POLLS = 15
@ -264,7 +269,7 @@ const { start: startPolling } = useTimeoutFn(poll, 1000, { immediate: false })
<button <button
v-if="data && data.status === 'finished'" v-if="data && data.status === 'finished'"
class="ui confirm success button" class="ui confirm success button"
@click.prevent="showModal = false; $emit('refresh')" @click.prevent="showModal = false; emit('refresh')"
> >
<translate translate-context="*/*/Button.Label/Verb"> <translate translate-context="*/*/Button.Label/Verb">
Close and reload page Close and reload page

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Artist, Track, Album } from '~/types' import type { Artist, Track, Album, Library } from '~/types'
import type { ContentFilter } from '~/store/moderation' import type { ContentFilter } from '~/store/moderation'
import { ref, computed, reactive } from 'vue' import { ref, computed, reactive } from 'vue'
@ -13,6 +13,10 @@ import AlbumCard from '~/components/audio/album/Card.vue'
import useErrorHandler from '~/composables/useErrorHandler' import useErrorHandler from '~/composables/useErrorHandler'
interface Events {
(e: 'libraries-loaded', libraries: Library[]): void
}
interface Props { interface Props {
object: Artist object: Artist
tracks: Track[] tracks: Track[]
@ -22,6 +26,7 @@ interface Props {
nextAlbumsUrl?: string | null nextAlbumsUrl?: string | null
} }
const emit = defineEmits<Events>()
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
nextTracksUrl: null, nextTracksUrl: null,
nextAlbumsUrl: null nextAlbumsUrl: null
@ -143,7 +148,7 @@ const loadMoreAlbums = async () => {
</h2> </h2>
<library-widget <library-widget
:url="'artists/' + object.id + '/libraries/'" :url="'artists/' + object.id + '/libraries/'"
@loaded="$emit('libraries-loaded', $event)" @loaded="emit('libraries-loaded', $event)"
> >
<translate translate-context="Content/Artist/Paragraph"> <translate translate-context="Content/Artist/Paragraph">
This artist is present in the following libraries: This artist is present in the following libraries:

View File

@ -273,11 +273,11 @@ const resetField = (fieldId: string) => {
</translate> </translate>
</option> </option>
<option <option
v-for="license in licenses" v-for="{ code, name } in licenses"
:key="license.code" :key="code"
:value="license.code" :value="code"
> >
{{ license.name }} {{ name }}
</option> </option>
</select> </select>
<button <button

View File

@ -21,7 +21,10 @@ defineProps<Props>()
</div> </div>
</div> </div>
<template v-else> <template v-else>
<p v-for="row in data.logs"> <p
v-for="row in data.logs"
:key="row"
>
{{ row }} {{ row }}
</p> </p>
</template> </template>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Track } from '~/types' import type { Track, Library } from '~/types'
import { humanSize, momentFormat, truncate } from '~/utils/filters' import { humanSize, momentFormat, truncate } from '~/utils/filters'
import { computed, ref, watchEffect } from 'vue' import { computed, ref, watchEffect } from 'vue'
@ -13,10 +13,15 @@ import TagsList from '~/components/tags/List.vue'
import useErrorHandler from '~/composables/useErrorHandler' import useErrorHandler from '~/composables/useErrorHandler'
interface Events {
(e: 'libraries-loaded', libraries: Library[]): void
}
interface Props { interface Props {
track: Track track: Track
} }
const emit = defineEmits<Events>()
const props = defineProps<Props>() const props = defineProps<Props>()
const musicbrainzUrl = computed(() => props.track.mbid const musicbrainzUrl = computed(() => props.track.mbid
@ -322,7 +327,7 @@ watchEffect(() => {
</h2> </h2>
<library-widget <library-widget
:url="`tracks/${track.id}/libraries/`" :url="`tracks/${track.id}/libraries/`"
@loaded="$emit('libraries-loaded', $event)" @loaded="emit('libraries-loaded', $event)"
> >
<translate translate-context="Content/Track/Paragraph"> <translate translate-context="Content/Track/Paragraph">
This track is present in the following libraries: This track is present in the following libraries:

View File

@ -3,10 +3,15 @@ import type { InstancePolicy } from '~/types'
import useMarkdown from '~/composables/useMarkdown' import useMarkdown from '~/composables/useMarkdown'
interface Events {
(e: 'update'): void
}
interface Props { interface Props {
object: InstancePolicy object: InstancePolicy
} }
const emit = defineEmits<Events>()
const props = defineProps<Props>() const props = defineProps<Props>()
const summary = useMarkdown(() => props.object.summary) const summary = useMarkdown(() => props.object.summary)
@ -86,7 +91,7 @@ const summary = useMarkdown(() => props.object.summary)
<div class="ui hidden divider" /> <div class="ui hidden divider" />
<button <button
class="ui right floated labeled icon button" class="ui right floated labeled icon button"
@click="$emit('update')" @click="emit('update')"
> >
<i class="edit icon" /> <i class="edit icon" />
<translate translate-context="Content/*/Button.Label/Verb"> <translate translate-context="Content/*/Button.Label/Verb">

View File

@ -95,7 +95,7 @@ const reorder = async ({ oldIndex: from, newIndex: to }: { oldIndex: number, new
isLoading.value = true isLoading.value = true
try { try {
await axios.post(`playlists/${playlist.value!.id}/move/`, { from, to }) await axios.post(`playlists/${playlist.value?.id}/move/`, { from, to })
await store.dispatch('playlists/fetchOwn') await store.dispatch('playlists/fetchOwn')
responseHandlers.success() responseHandlers.success()
} catch (error) { } catch (error) {
@ -110,7 +110,7 @@ const removePlaylistTrack = async (index: number) => {
try { try {
tracks.value.splice(index, 1) tracks.value.splice(index, 1)
await axios.post(`playlists/${playlist.value!.id}/remove/`, { index }) await axios.post(`playlists/${playlist.value?.id}/remove/`, { index })
await store.dispatch('playlists/fetchOwn') await store.dispatch('playlists/fetchOwn')
responseHandlers.success() responseHandlers.success()
} catch (error) { } catch (error) {
@ -125,7 +125,7 @@ const clearPlaylist = async () => {
try { try {
tracks.value = [] tracks.value = []
await axios.post(`playlists/${playlist.value!.id}/clear/`) await axios.post(`playlists/${playlist.value?.id}/clear/`)
await store.dispatch('playlists/fetchOwn') await store.dispatch('playlists/fetchOwn')
responseHandlers.success() responseHandlers.success()
} catch (error) { } catch (error) {
@ -139,7 +139,7 @@ const insertMany = async (insertedTracks: Track[], allowDuplicates: boolean) =>
isLoading.value = true isLoading.value = true
try { try {
const response = await axios.post(`playlists/${playlist.value!.id}/add/`, { const response = await axios.post(`playlists/${playlist.value?.id}/add/`, {
allow_duplicates: allowDuplicates, allow_duplicates: allowDuplicates,
tracks: insertedTracks.map(track => track.id) tracks: insertedTracks.map(track => track.id)
}) })

View File

@ -74,7 +74,7 @@ const submit = async () => {
errors.value = [] errors.value = []
try { try {
const url = props.create ? 'playlists/' : `playlists/${playlist.value!.id}/` const url = props.create ? 'playlists/' : `playlists/${playlist.value?.id}/`
const method = props.create ? 'post' : 'patch' const method = props.create ? 'post' : 'patch'
const data = { const data = {

View File

@ -105,7 +105,7 @@ const types = computed(() => [
} }
] as SearchType[]) ] as SearchType[])
const currentType = computed(() => types.value.find(({ id }) => id === type.value)!) const currentType = computed(() => types.value.find(({ id }) => id === type.value))
const axiosParams = computed(() => { const axiosParams = computed(() => {
const params = new URLSearchParams({ const params = new URLSearchParams({
@ -114,13 +114,13 @@ const axiosParams = computed(() => {
page_size: paginateBy.value as unknown as string page_size: paginateBy.value as unknown as string
}) })
if (currentType.value.contentCategory) params.append('content_category', currentType.value.contentCategory) if (currentType.value?.contentCategory) params.append('content_category', currentType.value.contentCategory)
if (currentType.value.includeChannels) params.append('include_channels', currentType.value.includeChannels as unknown as string) if (currentType.value?.includeChannels) params.append('include_channels', currentType.value.includeChannels as unknown as string)
return params return params
}) })
const currentResults = computed(() => results[currentType.value.id ?? 'artists']) const currentResults = computed(() => results[currentType.value?.id ?? 'artists'])
const router = useRouter() const router = useRouter()
const updateQueryString = () => router.replace({ const updateQueryString = () => router.replace({
@ -133,6 +133,8 @@ const updateQueryString = () => router.replace({
const isLoading = ref(false) const isLoading = ref(false)
const search = async () => { const search = async () => {
if (!currentType.value) return
if (!query.value) { if (!query.value) {
for (const type of types.value) { for (const type of types.value) {
results[type.id] = null results[type.id] = null
@ -193,14 +195,14 @@ const labels = computed(() => ({
const radioConfig = computed(() => { const radioConfig = computed(() => {
const results = Object.values(currentResults.value?.results ?? {}) const results = Object.values(currentResults.value?.results ?? {})
if (results.length) { if (results.length) {
if (currentType.value.id === 'tags') { if (currentType.value?.id === 'tags') {
return { return {
type: 'tag', type: 'tag',
names: results.map(({ name }) => name) names: results.map(({ name }) => name)
} as RadioConfig } as RadioConfig
} }
if (currentType.value.id === 'artists') { if (currentType.value?.id === 'artists') {
return { return {
type: 'artist', type: 'artist',
ids: results.map(({ id }) => id) ids: results.map(({ id }) => id)

View File

@ -11,11 +11,16 @@ import axios from 'axios'
import useErrorHandler from '~/composables/useErrorHandler' import useErrorHandler from '~/composables/useErrorHandler'
import useReport from '~/composables/moderation/useReport' import useReport from '~/composables/moderation/useReport'
interface Events {
(e: 'updated', value: Actor): void
}
interface Props { interface Props {
username: string username: string
domain?: string | null domain?: string | null
} }
const emit = defineEmits<Events>()
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
domain: null domain: null
}) })
@ -161,7 +166,7 @@ watch(props, fetchData, { immediate: true })
:field-name="'summary'" :field-name="'summary'"
:update-url="`users/${$store.state.auth.username}/`" :update-url="`users/${$store.state.auth.username}/`"
:can-update="$store.state.auth.authenticated && object.full_username === $store.state.auth.fullUsername" :can-update="$store.state.auth.authenticated && object.full_username === $store.state.auth.fullUsername"
@updated="$emit('updated', $event)" @updated="emit('updated', $event)"
/> />
</div> </div>
</div> </div>

View File

@ -7,10 +7,15 @@ import ChannelsWidget from '~/components/audio/ChannelsWidget.vue'
import ChannelForm from '~/components/audio/ChannelForm.vue' import ChannelForm from '~/components/audio/ChannelForm.vue'
import { ref } from 'vue' import { ref } from 'vue'
interface Events {
(e: 'updated', value: Actor): void
}
interface Props { interface Props {
object: Actor object: Actor
} }
const emit = defineEmits<Events>()
defineProps<Props>() defineProps<Props>()
const step = ref(1) const step = ref(1)
@ -31,7 +36,7 @@ const createForm = ref()
:field-name="'summary'" :field-name="'summary'"
:update-url="`users/${$store.state.auth.username}/`" :update-url="`users/${$store.state.auth.username}/`"
:can-update="$store.state.auth.authenticated && object.full_username === $store.state.auth.fullUsername" :can-update="$store.state.auth.authenticated && object.full_username === $store.state.auth.fullUsername"
@updated="$emit('updated', $event)" @updated="emit('updated', $event)"
/> />
<div class="ui hidden divider" /> <div class="ui hidden divider" />
</div> </div>

View File

@ -10,10 +10,15 @@ import LibraryForm from '~/views/content/libraries/Form.vue'
import useErrorHandler from '~/composables/useErrorHandler' import useErrorHandler from '~/composables/useErrorHandler'
interface Events {
(e: 'updated'): void
}
interface Props { interface Props {
object: Library object: Library
} }
const emit = defineEmits<Events>()
const props = defineProps<Props>() const props = defineProps<Props>()
type ResponseType = { count: number, results: any[] } type ResponseType = { count: number, results: any[] }
@ -49,7 +54,7 @@ const updateApproved = async (follow: LibraryFollow, approved: boolean) => {
<section> <section>
<library-form <library-form
:library="object" :library="object"
@updated="$emit('updated')" @updated="emit('updated')"
@deleted="$router.push({name: 'profile.overview', params: {username: $store.state.auth.username}})" @deleted="$router.push({name: 'profile.overview', params: {username: $store.state.auth.username}})"
/> />
<div class="ui hidden divider" /> <div class="ui hidden divider" />

View File

@ -6,11 +6,16 @@ import { ref } from 'vue'
import FileUpload from '~/components/library/FileUpload.vue' import FileUpload from '~/components/library/FileUpload.vue'
interface Events {
(e: 'uploads-finished', data: number): void
}
interface Props { interface Props {
object: Library object: Library
defaultImportReference?: string defaultImportReference?: string
} }
const emit = defineEmits<Events>()
withDefaults(defineProps<Props>(), { withDefaults(defineProps<Props>(), {
defaultImportReference: '' defaultImportReference: ''
}) })
@ -36,7 +41,7 @@ onBeforeRouteLeave((to, from, next) => {
ref="fileupload" ref="fileupload"
:default-import-reference="defaultImportReference" :default-import-reference="defaultImportReference"
:library="object" :library="object"
@uploads-finished="$emit('uploads-finished', $event)" @uploads-finished="emit('uploads-finished', $event)"
/> />
</section> </section>
</template> </template>