chore(deps): update dependency @antfu/eslint-config to ^2.19.0 (#2726)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
renovate[bot] 2024-08-16 14:52:08 +00:00 committed by GitHub
parent 23f82d3296
commit 0fba07e6e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 820 additions and 710 deletions

View file

@ -38,12 +38,14 @@ onMounted(() => {
announce(t('a11y.loading_page'))
})
router.afterEach((to, from) => {
from && setTimeout(() => {
if (from) {
setTimeout(() => {
requestAnimationFrame(() => {
const title = document.title.trim().split('|')
announce(t('a11y.route_loaded', [title[0]]))
})
}, 512)
}
})
})
</script>

View file

@ -20,7 +20,7 @@ const tabs = computed(() => {
})
function toValidName(option: string) {
return option.toLowerCase().replace(/[^a-zA-Z0-9]/g, '-')
return option.toLowerCase().replace(/[^a-z0-9]/gi, '-')
}
useCommands(() => command

View file

@ -15,9 +15,10 @@ const isRemoved = ref(false)
async function edit() {
try {
isRemoved.value
? await client.v1.lists.$select(list).accounts.create({ accountIds: [account.id] })
: await client.v1.lists.$select(list).accounts.remove({ accountIds: [account.id] })
if (isRemoved.value)
await client.v1.lists.$select(list).accounts.create({ accountIds: [account.id] })
else
await client.v1.lists.$select(list).accounts.remove({ accountIds: [account.id] })
isRemoved.value = !isRemoved.value
}
catch (err) {

View file

@ -32,9 +32,10 @@ async function openEmojiPicker() {
picker.value = new Picker({
data: () => dataPromise,
onEmojiSelect({ native, src, alt, name }: any) {
native
? emit('select', native)
: emit('selectCustom', { src, alt, 'data-emoji-id': name })
if (native)
emit('select', native)
else
emit('selectCustom', { src, alt, 'data-emoji-id': name })
},
set: 'twitter',
theme: colorMode,

View file

@ -85,11 +85,13 @@ function trimPollOptions() {
const trimmedOptions = draft.value.params.poll!.options.slice(0, indexLastNonEmpty + 1)
if (currentInstance.value?.configuration
&& trimmedOptions.length >= currentInstance.value?.configuration?.polls.maxOptions)
&& trimmedOptions.length >= currentInstance.value?.configuration?.polls.maxOptions) {
draft.value.params.poll!.options = trimmedOptions
else
}
else {
draft.value.params.poll!.options = [...trimmedOptions, '']
}
}
function editPollOptionDraft(event: Event, index: number) {
draft.value.params.poll!.options = Object.assign(draft.value.params.poll!.options.slice(), { [index]: (event.target as HTMLInputElement).value })
@ -135,10 +137,10 @@ const characterCount = computed(() => {
let length = stringLength(text)
// taken from https://github.com/mastodon/mastodon/blob/07f8b4d1b19f734d04e69daeb4c3421ef9767aac/app/lib/text_formatter.rb
const linkRegex = /(https?:\/\/(www\.)?|xmpp:)\S+/g
const linkRegex = /(https?:\/\/|xmpp:)\S+/g
// taken from https://github.com/mastodon/mastodon/blob/af578e/app/javascript/mastodon/features/compose/util/counter.js
const countableMentionRegex = /(^|[^/\w])@(([a-z0-9_]+)@[a-z0-9.-]+[a-z0-9]+)/ig
const countableMentionRegex = /(^|[^/\w])@((\w+)@[a-z0-9.-]+[a-z0-9])/gi
// maximum of 23 chars per link
// https://github.com/elk-zone/elk/issues/1651

View file

@ -83,7 +83,8 @@ useIntersectionObserver(video, (entries) => {
entries.forEach((entry) => {
if (entry.intersectionRatio <= 0.75) {
ready && !video.value?.paused && video.value?.pause()
if (ready && !video.value?.paused)
video.value?.pause()
}
else {
video.value?.play().then(() => {

View file

@ -26,7 +26,7 @@ async function toggleFollowTag() {
emit('change')
}
catch (error) {
catch {
// eslint-disable-next-line vue/no-mutating-props
tag.following = previousFollowingState
}

View file

@ -27,7 +27,7 @@ function isValidUrl(str: string) {
new URL(str)
return true
}
catch (err) {
catch {
return false
}
}
@ -42,14 +42,17 @@ async function handleInput() {
if (
isValidUrl(`https://${input}`)
&& input.match(/^[a-z0-9-]+(\.[a-z0-9-]+)+(:[0-9]+)?$/i)
&& input.match(/^[a-z0-9-]+(\.[a-z0-9-]+)+(:\d+)?$/i)
// Do not hide the autocomplete if a result has an exact substring match on the input
&& !filteredServers.value.some(s => s.includes(input))
)
) {
autocompleteShow.value = false
else
}
else {
autocompleteShow.value = true
}
}
function toSelector(server: string) {
return server.replace(/[^\w-]/g, '-')

View file

@ -19,7 +19,7 @@ export interface ContentParseOptions {
inReplyToStatus?: mastodon.v1.Status
}
const sanitizerBasicClasses = filterClasses(/^(h-\S*|p-\S*|u-\S*|dt-\S*|e-\S*|mention|hashtag|ellipsis|invisible)$/u)
const sanitizerBasicClasses = filterClasses(/^h-\S*|p-\S*|u-\S*|dt-\S*|e-\S*|mention|hashtag|ellipsis|invisible$/u)
const sanitizer = sanitize({
// Allow basic elements as seen in https://github.com/mastodon/mastodon/blob/17f79082b098e05b68d6f0d38fabb3ac121879a9/lib/sanitize_ext/sanitize_config.rb
br: {},
@ -93,6 +93,7 @@ export function parseMastodonHTML(
if (markdown) {
// Handle code blocks
html = html
/* eslint-disable regexp/no-super-linear-backtracking, regexp/no-misleading-capturing-group */
.replace(/>(```|~~~)(\w*)([\s\S]+?)\1/g, (_1, _2, lang: string, raw: string) => {
const code = htmlToText(raw)
.replace(/</g, '&lt;')
@ -191,7 +192,7 @@ export function recursiveTreeToText(input: Node): string {
return treeToText(input)
}
const emojiIdNeedsWrappingRE = /^(\d|\w|-|_)+$/
const emojiIdNeedsWrappingRE = /^([\w\-])+$/
export function treeToText(input: Node): string {
let pre = ''
@ -417,7 +418,7 @@ function removeCustomEmoji(customEmojis: Record<string, mastodon.v1.CustomEmoji>
if (node.type !== TEXT_NODE)
return node
const split = node.value.split(/\s?:([\w-]+?):/g)
const split = node.value.split(/\s?:([\w-]+):/g)
if (split.length === 1)
return node
@ -439,7 +440,7 @@ function replaceCustomEmoji(customEmojis: Record<string, mastodon.v1.CustomEmoji
if (node.type !== TEXT_NODE)
return node
const split = node.value.split(/:([\w-]+?):/g)
const split = node.value.split(/:([\w-]+):/g)
if (split.length === 1)
return node
@ -484,9 +485,9 @@ const _markdownReplacements: [RegExp, (c: (string | Node)[]) => Node][] = [
[/\*\*(.*?)\*\*/g, c => h('b', null, c)],
[/\*(.*?)\*/g, c => h('em', null, c)],
[/~~(.*?)~~/g, c => h('del', null, c)],
[/`([^`]+?)`/g, c => h('code', null, c)],
[/`([^`]+)`/g, c => h('code', null, c)],
// transform @username@twitter.com as links
[/\B@([a-zA-Z0-9_]+)@twitter\.com\b/gi, c => h('a', { href: `https://twitter.com/${c}`, target: '_blank', rel: 'nofollow noopener noreferrer', class: 'mention external' }, `@${c}@twitter.com`)],
[/\B@(\w+)@twitter\.com\b/gi, c => h('a', { href: `https://twitter.com/${c}`, target: '_blank', rel: 'nofollow noopener noreferrer', class: 'mention external' }, `@${c}@twitter.com`)],
]
function _markdownProcess(value: string) {

View file

@ -4,7 +4,7 @@ export function getDisplayName(account: mastodon.v1.Account, options?: { rich?:
const displayName = account.displayName || account.username || account.acct || ''
if (options?.rich)
return displayName
return displayName.replace(/:([\w-]+?):/g, '')
return displayName.replace(/:([\w-]+):/g, '')
}
export function accountToShortHandle(acct: string) {

View file

@ -80,8 +80,9 @@ export function usePublish(options: {
options.length < currentInstance.value.configuration.polls.maxOptions
|| options[options.length - 1].trim().length === 0
)
)
) {
options = options.slice(0, options.length - 1)
}
poll = { ...draftItem.value.params.poll, options }
}

View file

@ -123,8 +123,9 @@ export function usePaginator<T, P, U = T>(
&& state.value === 'idle'
// No new content is loaded when the keepAlive page enters the background
&& deactivated.value === false
)
) {
loadNext()
}
},
)
}

View file

@ -102,7 +102,8 @@ async function unsubscribeFromBackend(fromSWPushManager: boolean, removePushNoti
const cu = currentUser.value
if (cu) {
await removePushNotifications(cu)
removePushNotification && await removePushNotificationData(cu, fromSWPushManager)
if (removePushNotification)
await removePushNotificationData(cu, fromSWPushManager)
}
}

View file

@ -178,7 +178,8 @@ export function usePushManager() {
else
currentUser.value.pushSubscription = await client.value.v1.push.subscription.update({ data })
policyChanged && await nextTick()
if (policyChanged)
await nextTick()
// force change policy when changed: watch is resetting it on push subscription update
await saveSettings(policyChanged ? policy : undefined)

View file

@ -29,7 +29,7 @@ declare module '@tiptap/core' {
}
}
const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/
const inputRegex = /(?:^|\s)(!\[(.+|:?)\]\((\S+)(?:\s+["'](\S+)["'])?\))$/
export const TiptapPluginCustomEmoji = Node.create<EmojiOptions>({
name: 'custom-emoji',

View file

@ -14,7 +14,7 @@ function wrapHandler<T extends (...args: any[]) => any>(handler: T): T {
try {
return handler(...args)
}
catch (e) {
catch {
return null
}
})

View file

@ -119,7 +119,8 @@ function createSuggestionRenderer(component: Component): SuggestionOptions['rend
// Use arrow function here because Nuxt will transform it incorrectly as Vue hook causing the build to fail
onBeforeUpdate: (props) => {
props.editor.isFocused && renderer.updateProps({ ...props, isPending: true })
if (props.editor.isFocused)
renderer.updateProps({ ...props, isPending: true })
},
onUpdate(props) {

View file

@ -83,7 +83,8 @@ export const isGlitchEdition = computed(() => currentInstance.value?.version?.in
// when multiple tabs: we need to reload window when sign in, switch account or sign out
if (import.meta.client) {
const windowReload = () => {
document.visibilityState === 'visible' && window.location.reload()
if (document.visibilityState === 'visible')
window.location.reload()
}
watch(currentUserHandle, async (handle, oldHandle) => {
// when sign in or switch account

View file

@ -26,7 +26,7 @@ export const STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE = 'elk-last-accessed-n
export const STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE = 'elk-last-accessed-explore-route'
export const STORAGE_KEY_BOTTOM_NAV_BUTTONS = 'elk-bottom-nav-buttons'
export const HANDLED_MASTO_URLS = /^(https?:\/\/)?([\w\d-]+\.)+\w+\/(@[@\w\d-\.]+)(\/objects)?(\/\d+)?$/
export const HANDLED_MASTO_URLS = /^(https?:\/\/)?([\w\-]+\.)+\w+\/(@[@\w\-.]+)(\/objects)?(\/\d+)?$/
export const NOTIFICATION_FILTER_TYPES: mastodon.v1.NotificationType[] = ['status', 'reblog', 'follow', 'follow_request', 'favourite', 'poll', 'update', 'admin.sign_up', 'admin.report']

View file

@ -14,7 +14,7 @@ export default defineNuxtModule({
return
const s = new MagicString(code)
s.replace(/<!--(?:.*?)-->/sg, '')
s.replace(/<!--.*?-->/gs, '')
if (s.hasChanged()) {
return {

View file

@ -76,7 +76,7 @@ function createManifestTransform(base: string, appManifestFolder?: string): impo
})
if (appManifestFolder) {
const regExp = /(\/)?[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\.json$/i
const regExp = /\/?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.json$/i
// we need to remove the revision from the sw prechaing manifest, UUID is enough:
// we don't use dontCacheBustURLsMatching, single regex
entries.filter(e => e && e.url.startsWith(appManifestFolder) && regExp.test(e.url)).forEach((e) => {

View file

@ -276,7 +276,7 @@ export default defineNuxtConfig({
},
},
// eslint-disable-next-line ts/prefer-ts-expect-error
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore nuxt-security is conditional
security: {
headers: {

View file

@ -112,7 +112,7 @@
"ws": "^8.15.1"
},
"devDependencies": {
"@antfu/eslint-config": "^2.9.0",
"@antfu/eslint-config": "^2.26.0",
"@antfu/ni": "^0.21.12",
"@types/chroma-js": "^2.4.4",
"@types/file-saver": "^2.0.7",
@ -122,12 +122,12 @@
"@types/wicg-file-system-access": "^2023.10.5",
"@types/ws": "^8.5.10",
"@unlazy/nuxt": "^0.11.2",
"@unocss/eslint-config": "^0.58.9",
"@unocss/eslint-config": "^0.62.2",
"@vue/test-utils": "2.4.5",
"bumpp": "^9.4.0",
"consola": "^3.2.3",
"eslint": "^8.57.0",
"eslint-plugin-format": "^0.1.0",
"eslint-plugin-format": "^0.1.2",
"flat": "^6.0.1",
"fs-extra": "^11.2.0",
"lint-staged": "^15.2.2",

View file

@ -50,10 +50,12 @@ async function createList() {
function clearError(focusBtn: boolean) {
actionError.value = undefined
focusBtn && nextTick(() => {
if (focusBtn) {
nextTick(() => {
inputRef.value?.focus()
})
}
}
function updateEntry(list: mastodon.v1.List) {
paginatorRef.value?.updateEntry(list)

View file

@ -31,7 +31,7 @@ export default defineNuxtPlugin(() => {
if (settings.themeColors) {
Object.entries(settings.themeColors).map(i => html.style.setProperty(i[0], i[1]))
}
})()`.trim().replace(/\s*\n+\s*/g, ';'),
})()`.trim().replace(/\s*\n\s*/g, ';'),
},
],
})

File diff suppressed because it is too large Load diff

View file

@ -38,7 +38,7 @@ export default defineEventHandler(async (event) => {
const url = `/signin/callback?${stringifyQuery({ server, token: result.access_token, vapid_key: app.vapid_key })}`
await sendRedirect(event, url, 302)
}
catch (e) {
catch {
throw createError({
statusCode: 400,
statusMessage: 'Could not complete log in.',

View file

@ -62,7 +62,7 @@ async function fetchAppInfo(origin: string, server: string) {
}
export async function getApp(origin: string, server: string) {
const host = origin.replace(/^https?:\/\//, '').replace(/[^\w\d]/g, '-').replace(/\?.*$/, '')
const host = origin.replace(/^https?:\/\//, '').replace(/\W/g, '-').replace(/\?.*$/, '')
const key = `servers:v3:${server}:${host}.json`.toLowerCase()
try {

View file

@ -60,8 +60,8 @@ export function createNotificationOptions(
icon,
lang: preferred_locale,
tag: notification_id,
// eslint-disable-next-line ts/prefer-ts-expect-error
// @ts-ignore error missing type, just ignore
// @ts-expect-error error missing type, just ignore
timestamp: new Date().getTime(),
}
@ -73,8 +73,7 @@ export function createNotificationOptions(
notificationOptions.icon = notification.account.avatar_static
*/
if (notification.created_at) {
// eslint-disable-next-line ts/prefer-ts-expect-error
// @ts-ignore error missing type, just ignore
// @ts-expect-error error missing type, just ignore
notificationOptions.timestamp = new Date(notification.created_at).getTime()
}
@ -89,8 +88,7 @@ export function createNotificationOptions(
if (notification.status) {
// notificationOptions.body = htmlToPlainText(notification.status.content)
if (notification.status.media_attachments && notification.status.media_attachments.length > 0 && notification.status.media_attachments[0].preview_url) {
// eslint-disable-next-line ts/prefer-ts-expect-error
// @ts-ignore error missing type, just ignore
// @ts-expect-error error missing type, just ignore
notificationOptions.image = notification.status.media_attachments[0].preview_url
}

View file

@ -194,7 +194,7 @@ describe('editor', () => {
async function render(content: string, options?: ContentParseOptions) {
const vnode = contentToVNode(content, options)
const html = (await renderToString(vnode))
.replace(/<!--[\[\]]-->/g, '')
.replace(/<!--[[\]]-->/g, '')
let formatted = ''
try {
@ -202,7 +202,7 @@ async function render(content: string, options?: ContentParseOptions) {
parser: 'html',
})
}
catch (e) {
catch {
formatted = html
}

View file

@ -75,7 +75,7 @@ async function render(input: string, options?: ContentParseOptions) {
parser: 'html',
})
}
catch (e) {
catch {
formatted = html
}

View file

@ -68,7 +68,7 @@ export default defineConfig({
'timeline-title-style': 'text-primary text-lg font-bold',
},
[/^elk-group-hover[:-]([a-z0-9\/-]+)$/, ([,r]) => `media-mouse-group-hover-${r} group-active-${r}`],
[/^elk-group-hover[:-]([a-z0-9/-]+)$/, ([,r]) => `media-mouse-group-hover-${r} group-active-${r}`],
],
presets: [
presetUno({