From 3b1a66c93cc8f04e379382ed528272bdb57ed809 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Mon, 11 Mar 2024 19:53:25 +0900 Subject: [PATCH] fix: fix `vue/no-ref-as-operand` and `vue/return-in-computed-property` ESLint errors (#2679) --- components/command/CommandPanel.vue | 4 ++-- components/list/ListEntry.vue | 2 +- components/modal/ModalConfirm.vue | 2 +- components/user/UserSignIn.vue | 2 +- composables/masto/search.ts | 4 ++-- composables/push-notifications/usePushManager.ts | 4 ++-- pages/[[server]]/@[account]/[status].vue | 2 +- pages/notifications.vue | 2 ++ pages/notifications/[filter].vue | 2 ++ 9 files changed, 14 insertions(+), 10 deletions(-) diff --git a/components/command/CommandPanel.vue b/components/command/CommandPanel.vue index 1787eba4..dd2115a7 100644 --- a/components/command/CommandPanel.vue +++ b/components/command/CommandPanel.vue @@ -22,7 +22,7 @@ onMounted(() => { const commandMode = computed(() => input.value.startsWith('>')) -const query = computed(() => commandMode ? '' : input.value.trim()) +const query = computed(() => commandMode.value ? '' : input.value.trim()) const { accounts, hashtags, loading } = useSearch(query) @@ -61,7 +61,7 @@ const searchResult = computed(() => { } }) -const result = computed(() => commandMode +const result = computed(() => commandMode.value ? registry.query(scopes.value.map(s => s.id).join('.'), input.value.slice(1).trim()) : searchResult.value, ) diff --git a/components/list/ListEntry.vue b/components/list/ListEntry.vue index 5fabdd7d..874475cc 100644 --- a/components/list/ListEntry.vue +++ b/components/list/ListEntry.vue @@ -92,7 +92,7 @@ async function removeList() { async function clearError() { actionError.value = undefined await nextTick() - if (isEditing) + if (isEditing.value) input.value?.focus() else deleteBtn.value?.focus() diff --git a/components/modal/ModalConfirm.vue b/components/modal/ModalConfirm.vue index d138ad18..48c27cd1 100644 --- a/components/modal/ModalConfirm.vue +++ b/components/modal/ModalConfirm.vue @@ -17,7 +17,7 @@ const isMute = computed(() => props.extraOptionType === 'mute') function handleChoice(choice: ConfirmDialogChoice['choice']) { const dialogChoice = { choice, - ...isMute && { + ...isMute.value && { extraOptions: { mute: { duration: hasDuration.value ? duration.value : 0, diff --git a/components/user/UserSignIn.vue b/components/user/UserSignIn.vue index 4d588115..177cd1cb 100644 --- a/components/user/UserSignIn.vue +++ b/components/user/UserSignIn.vue @@ -72,7 +72,7 @@ function onEnter(e: KeyboardEvent) { } function escapeAutocomplete(evt: KeyboardEvent) { - if (!autocompleteShow) + if (!autocompleteShow.value) return autocompleteShow.value = false evt.stopPropagation() diff --git a/composables/masto/search.ts b/composables/masto/search.ts index c17b8a69..e6215ea8 100644 --- a/composables/masto/search.ts +++ b/composables/masto/search.ts @@ -59,7 +59,7 @@ export function useSearch(query: MaybeRefOrGetter, options: UseSearchOpt } watch(() => resolveUnref(query), () => { - loading.value = !!(q && isHydrated.value) + loading.value = !!(q.value && isHydrated.value) }) debouncedWatch(() => resolveUnref(query), async () => { @@ -87,7 +87,7 @@ export function useSearch(query: MaybeRefOrGetter, options: UseSearchOpt }, { debounce: 300 }) const next = async () => { - if (!q || !isHydrated.value || !paginator) + if (!q.value || !isHydrated.value || !paginator) return loading.value = true diff --git a/composables/push-notifications/usePushManager.ts b/composables/push-notifications/usePushManager.ts index a94d9841..fa2757f4 100644 --- a/composables/push-notifications/usePushManager.ts +++ b/composables/push-notifications/usePushManager.ts @@ -64,7 +64,7 @@ export function usePushManager() { policy?: mastodon.v1.WebPushSubscriptionPolicy, force?: boolean, ): Promise => { - if (!isSupported) + if (!isSupported.value) return 'not-supported' if (!currentUser.value) @@ -112,7 +112,7 @@ export function usePushManager() { } const unsubscribe = async () => { - if (!isSupported || !isSubscribed || !currentUser.value) + if (!isSupported.value || !isSubscribed.value || !currentUser.value) return false await removePushNotifications(currentUser.value) diff --git a/pages/[[server]]/@[account]/[status].vue b/pages/[[server]]/@[account]/[status].vue index 707c73dd..18fd3203 100644 --- a/pages/[[server]]/@[account]/[status].vue +++ b/pages/[[server]]/@[account]/[status].vue @@ -21,7 +21,7 @@ const { data: status, pending, refresh: refreshStatus } = useAsyncData( ) const { client } = useMasto() const { data: context, pending: pendingContext, refresh: refreshContext } = useAsyncData( - `context:${id}`, + `context:${id.value}`, async () => client.value.v1.statuses.$select(id.value).context.fetch(), { watch: [isHydrated], immediate: isHydrated.value, lazy: true, default: () => shallowRef() }, ) diff --git a/pages/notifications.vue b/pages/notifications.vue index d35cf778..bb3fec61 100644 --- a/pages/notifications.vue +++ b/pages/notifications.vue @@ -32,6 +32,8 @@ const filter = computed(() => { const actualFilter = Array.isArray(rawFilter) ? rawFilter[0] : rawFilter if (isNotificationFilter(actualFilter)) return actualFilter + + return undefined }) const filterIconMap: Record = { diff --git a/pages/notifications/[filter].vue b/pages/notifications/[filter].vue index 52cc7daa..e24bc4a8 100644 --- a/pages/notifications/[filter].vue +++ b/pages/notifications/[filter].vue @@ -12,6 +12,8 @@ const filter = computed(() => { const actualFilter = Array.isArray(rawFilter) ? rawFilter[0] : rawFilter if (isNotification(actualFilter)) return actualFilter + + return undefined }) useHydratedHead({