chore(deps): update lint (#1928)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
This commit is contained in:
renovate[bot] 2023-03-30 19:01:24 +00:00 committed by GitHub
parent 2838e18ff7
commit 3c43a1cdd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 464 additions and 434 deletions

View file

@ -3,7 +3,7 @@ export type AriaAnnounceType = 'announce' | 'mute' | 'unmute'
const ariaAnnouncer = useEventBus<AriaAnnounceType, string | undefined>(Symbol('aria-announcer'))
export const useAriaAnnouncer = () => {
export function useAriaAnnouncer() {
const announce = (message: string) => {
ariaAnnouncer.emit('announce', message)
}
@ -19,7 +19,7 @@ export const useAriaAnnouncer = () => {
return { announce, ariaAnnouncer, mute, unmute }
}
export const useAriaLog = () => {
export function useAriaLog() {
let logs = $ref<any[]>([])
const announceLogs = (messages: any[]) => {
@ -42,7 +42,7 @@ export const useAriaLog = () => {
}
}
export const useAriaStatus = () => {
export function useAriaStatus() {
let status = $ref<any>('')
const announceStatus = (message: any) => {

View file

@ -78,8 +78,9 @@ export interface QueryResult {
grouped: Map<CommandScopeNames, QueryResultItem[]>
}
const r = <T extends Object | undefined>(i: T | (() => T)): T =>
typeof i === 'function' ? i() : i
function r<T extends Object | undefined>(i: T | (() => T)): T {
return typeof i === 'function' ? i() : i
}
export const useCommandRegistry = defineStore('command', () => {
const providers = reactive(new Set<CommandProvider>())
@ -237,7 +238,7 @@ export function useCommands(cmds: () => CommandProvider[]) {
tryOnScopeDispose(cleanup)
}
export const provideGlobalCommands = () => {
export function provideGlobalCommands() {
const { locale, t } = useI18n()
const { locales } = useI18n() as { locales: ComputedRef<LocaleObject[]> }
const router = useRouter()

View file

@ -55,7 +55,7 @@ const accountFieldIconsLowercase = Object.fromEntries(
),
)
export const getAccountFieldIcon = (value: string) => {
export function getAccountFieldIcon(value: string) {
const name = value.trim().toLowerCase()
return accountFieldIconsLowercase[name] || undefined
}

View file

@ -6,7 +6,7 @@ import type { ElkInstance } from '../users'
import type { Mutable } from '~/types/utils'
import type { UserLogin } from '~/types'
export const createMasto = () => {
export function createMasto() {
let client = $shallowRef<mastodon.Client>(undefined as never)
let params = $ref<Mutable<CreateClientParams>>()
const canStreaming = $computed(() => !!params?.streamingApiUrl)
@ -26,8 +26,12 @@ export const createMasto = () => {
}
export type ElkMasto = ReturnType<typeof createMasto>
export const useMasto = () => useNuxtApp().$masto as ElkMasto
export const useMastoClient = () => useMasto().client.value
export function useMasto() {
return useNuxtApp().$masto as ElkMasto
}
export function useMastoClient() {
return useMasto().client.value
}
export function mastoLogin(masto: ElkMasto, user: Pick<UserLogin, 'server' | 'token'>) {
const { setParams } = $(masto)

View file

@ -2,7 +2,7 @@ import type { WsEvents } from 'masto'
const notifications = reactive<Record<string, undefined | [Promise<WsEvents>, string[]]>>({})
export const useNotifications = () => {
export function useNotifications() {
const id = currentUser.value?.account.id
const { client, canStreaming } = $(useMasto())

View file

@ -64,11 +64,12 @@ export function getStatusInReplyToRoute(status: mastodon.v1.Status) {
})
}
export const navigateToStatus = ({ status, focusReply = false }: {
export function navigateToStatus({ status, focusReply = false }: {
status: mastodon.v1.Status
focusReply?: boolean
}) =>
navigateTo({
}) {
return navigateTo({
path: getStatusRoute(status).href,
state: { focusReply },
})
}

View file

@ -84,7 +84,7 @@ export function getReplyDraft(status: mastodon.v1.Status) {
}
}
export const isEmptyDraft = (draft: Draft | null | undefined) => {
export function isEmptyDraft(draft: Draft | null | undefined) {
if (!draft)
return true
const { params, attachments } = draft

View file

@ -42,7 +42,7 @@ export const supportedTranslationCodes = [
'zh',
] as const
export const getLanguageCode = () => {
export function getLanguageCode() {
let code = 'en'
const getCode = (code: string) => code.replace(/-.*$/, '')
if (!process.server) {

View file

@ -27,13 +27,15 @@ export function emojisArrayToObject(emojis: mastodon.v1.CustomEmoji[]) {
export function noop() {}
export const useIsMac = () => {
export function useIsMac() {
const headers = useRequestHeaders(['user-agent'])
return computed(() => headers['user-agent']?.includes('Macintosh')
?? navigator?.platform?.includes('Mac') ?? false)
}
export const isEmptyObject = (object: Object) => Object.keys(object).length === 0
export function isEmptyObject(object: Object) {
return Object.keys(object).length === 0
}
export function removeHTMLTags(str: string) {
return str.replaceAll(HTMLTagRE, '')

View file

@ -6,12 +6,10 @@ import type {
} from '~/composables/push-notifications/types'
import { PushSubscriptionError } from '~/composables/push-notifications/types'
export const createPushSubscription = async (
user: RequiredUserLogin,
export async function createPushSubscription(user: RequiredUserLogin,
notificationData: CreatePushNotification,
policy: mastodon.v1.SubscriptionPolicy = 'all',
force = false,
): Promise<mastodon.v1.WebPushSubscription | undefined> => {
force = false): Promise<mastodon.v1.WebPushSubscription | undefined> {
const { server: serverEndpoint, vapidKey } = user
return await getRegistration()

View file

@ -13,7 +13,7 @@ const supportsPushNotifications = typeof window !== 'undefined'
&& 'PushManager' in window
&& 'getKey' in PushSubscription.prototype
export const usePushManager = () => {
export function usePushManager() {
const { client } = $(useMasto())
const isSubscribed = ref(false)
const notificationPermission = ref<PermissionState | undefined>(

View file

@ -1,6 +1,6 @@
import type { Ref } from 'vue'
export const useSignIn = (input?: Ref<HTMLInputElement | undefined>) => {
export function useSignIn(input?: Ref<HTMLInputElement | undefined>) {
const singleInstanceServer = useRuntimeConfig().public.singleInstance
const userSettings = useUserSettings()
const users = useUsers()

View file

@ -6,10 +6,8 @@ import {
} from '@tiptap/core'
import { emojiRegEx, getEmojiAttributes } from '~/config/emojis'
const createEmojiRule = <NR extends typeof nodeInputRule | typeof nodePasteRule>(
nodeRule: NR,
type: Parameters<NR>[0]['type'],
): ReturnType<NR>[] => {
function createEmojiRule<NR extends typeof nodeInputRule | typeof nodePasteRule>(nodeRule: NR,
type: Parameters<NR>[0]['type']): ReturnType<NR>[] {
const rule = nodeRule({
find: emojiRegEx as RegExp,
type,

View file

@ -14,7 +14,9 @@ import TiptapEmojiList from '~/components/tiptap/TiptapEmojiList.vue'
export { Emoji }
export type CustomEmoji = (mastodon.v1.CustomEmoji & { custom: true })
export const isCustomEmoji = (emoji: CustomEmoji | Emoji): emoji is CustomEmoji => !!(emoji as CustomEmoji).custom
export function isCustomEmoji(emoji: CustomEmoji | Emoji): emoji is CustomEmoji {
return !!(emoji as CustomEmoji).custom
}
export const TiptapMentionSuggestion: Partial<SuggestionOptions> = process.server
? {}

View file

@ -19,7 +19,7 @@ import { useAsyncIDBKeyval } from '~/composables/idb'
const mock = process.mock
const initializeUsers = (): Promise<Ref<UserLogin[]> | RemovableRef<UserLogin[]>> | Ref<UserLogin[]> | RemovableRef<UserLogin[]> => {
function initializeUsers(): Promise<Ref<UserLogin[]> | RemovableRef<UserLogin[]>> | Ref<UserLogin[]> | RemovableRef<UserLogin[]> {
let defaultUsers = mock ? [mock.user] : []
// Backward compatibility with localStorage
@ -52,7 +52,9 @@ export type ElkInstance = Partial<mastodon.v1.Instance> & {
/** support GoToSocial */
accountDomain?: string | null
}
export const getInstanceCache = (server: string): mastodon.v1.Instance | undefined => instanceStorage.value[server]
export function getInstanceCache(server: string): mastodon.v1.Instance | undefined {
return instanceStorage.value[server]
}
export const currentUser = computed<UserLogin | undefined>(() => {
if (currentUserHandle.value) {
@ -109,9 +111,12 @@ if (process.client) {
}, { immediate: true, flush: 'post' })
}
export const useUsers = () => users
export const useSelfAccount = (user: MaybeComputedRef<mastodon.v1.Account | undefined>) =>
computed(() => currentUser.value && resolveUnref(user)?.id === currentUser.value.account.id)
export function useUsers() {
return users
}
export function useSelfAccount(user: MaybeComputedRef<mastodon.v1.Account | undefined>) {
return computed(() => currentUser.value && resolveUnref(user)?.id === currentUser.value.account.id)
}
export const characterLimit = computed(() => currentInstance.value?.configuration?.statuses.maxCharacters ?? DEFAULT_POST_CHARS_LIMIT)

View file

@ -5,7 +5,7 @@ import type { SchemaAugmentations } from '@unhead/schema'
export const isHydrated = ref(false)
export const onHydrated = (cb: () => unknown) => {
export function onHydrated(cb: () => unknown) {
watchOnce(isHydrated, () => cb(), { immediate: isHydrated.value })
}