fix: Fix lint errors (#559)

* cleanup: postactions styling

* misc: fix first round of errors

* pkg: remove vitest

* fix: fix lint errors stage 2

* fix: fix lint errors stage 3

* fix: fix lint errors, stage 3

* misc: update eslint rules to warn for writable derived
This commit is contained in:
Xylight authored and GitHub committed 2025-06-09 16:34:06 -07:00
1 parent 1824245f13
commit 76c581123a
225 files changed
+1553 -2352

No files matched your search

+51 -126
View File
@@ -1,43 +1,25 @@
<script lang="ts">
import type { PostView } from 'lemmy-js-client'
import PostVote from './PostVote.svelte'
import { site } from '$lib/lemmy.svelte.js'
import {
ArrowsUpDown,
ArrowTopRightOnSquare,
Bookmark,
BookmarkSlash,
BugAnt,
ChatBubbleOvalLeft,
ChatBubbleOvalLeftEllipsis,
Clock,
EllipsisHorizontal,
Eye,
EyeSlash,
Flag,
GlobeAmericas,
Icon,
MapPin,
Newspaper,
Pencil,
PencilSquare,
Share,
Trash,
UserCircle,
XMark,
} from 'svelte-hero-icons'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import { goto } from '$app/navigation'
import { profile } from '$lib/auth.svelte.js'
import {
amMod,
isAdmin,
report,
} from '$lib/components/lemmy/moderation/moderation.js'
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
import { profile } from '$lib/auth.svelte.js'
import TextProps from '$lib/components/ui/text/TextProps.svelte'
import { publishedToDate } from '$lib/components/util/date'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import { t } from '$lib/i18n/translations'
import { instance } from '$lib/instance.svelte'
import { site } from '$lib/lemmy.svelte.js'
import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js'
import { communityLink, userLink } from '$lib/lemmy/generic'
import { setSessionStorage } from '$lib/session.js'
import { goto } from '$app/navigation'
import { settings, type View } from '$lib/settings.svelte.js'
import { instanceToURL } from '$lib/util.svelte'
import { feature } from '$lib/version'
import type { PostView } from 'lemmy-js-client'
import {
Button,
Menu,
@@ -47,17 +29,29 @@
Spinner,
toast,
} from 'mono-svelte'
import { t } from '$lib/i18n/translations'
import {
ArrowTopRightOnSquare,
Bookmark,
BookmarkSlash,
BugAnt,
ChatBubbleOvalLeft,
ChatBubbleOvalLeftEllipsis,
EllipsisHorizontal,
Eye,
EyeSlash,
Flag,
GlobeAmericas,
Icon,
MapPin,
Newspaper,
PencilSquare,
Share,
Trash,
UserCircle,
XMark,
} from 'svelte-hero-icons'
import { hidePost, postLink } from './helpers'
import { feature } from '$lib/version'
import { instanceId, instanceToURL } from '$lib/util.svelte'
import { publishedToDate } from '$lib/components/util/date'
import TextProps from '$lib/components/ui/text/TextProps.svelte'
import { communityLink, userLink } from '$lib/lemmy/generic'
import RelativeDate, {
formatRelativeDate,
} from '$lib/components/util/RelativeDate.svelte'
import { instance } from '$lib/instance.svelte'
import PostVote from './PostVote.svelte'
let editing = $state(false)
let saving = $state(false)
@@ -98,7 +92,7 @@
<PostForm
edit
editingPost={post.post}
onsubmit={(e) => {
onsubmit={e => {
editing = false
post = e
onedit?.(e)
@@ -106,7 +100,6 @@
>
{#snippet formtitle()}
<!-- Have the title not exist at all -->
{''}
{/snippet}
</PostForm>
{/await}
@@ -136,7 +129,6 @@
rounding="pill"
target={settings.openLinksInNewTab ? '_blank' : ''}
title={$t('post.actions.comments')}
animations={{ scale: true, large: false }}
>
{@const newComment =
publishedToDate(post.counts.newest_comment_time).getTime() >
@@ -148,7 +140,6 @@
<FormattedNumber number={post.counts.comments} />
</Button>
<div class="flex-1"></div>
{#if settings.debugInfo}
{#if debug}
{#await import('$lib/components/util/debug/DebugObject.svelte') then { default: DebugObject }}
@@ -185,7 +176,7 @@
onclick={async () => {
if (!profile.data?.jwt) return
saving = true
post.saved = await save(post, !post.saved, profile.data?.jwt)
post.saved = await save(post, !post.saved)
saving = false
}}
size="custom"
@@ -195,7 +186,6 @@
loading={saving}
disabled={saving}
title={post.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
animations={{ scale: true, large: true }}
>
{#snippet prefix()}
<Icon src={post.saved ? BookmarkSlash : Bookmark} size="16" mini />
@@ -203,13 +193,7 @@
</Button>
{/if}
<Menu
placement="bottom-end"
containerClass="overflow-auto max-h-[400px]"
class="h-8"
targetClass="h-full"
title={$t('post.actions.more.label')}
>
<Menu placement="bottom-end" class="h-8">
{#snippet target()}
<Button
title={$t('post.actions.more.label')}
@@ -224,59 +208,6 @@
{/snippet}
</Button>
{/snippet}
<MenuDivider>{$t('cards.site.stats')}</MenuDivider>
<div class="flex flex-row gap-1 items-center">
<MenuButton class="flex-1">
{#snippet prefix()}
<Icon src={Clock} size="16" micro />
{/snippet}
<span>
{publishedToDate(post.post.published).toLocaleDateString(undefined, {
dateStyle: 'short',
})}
</span>
</MenuButton>
{#if post.post.updated}
{@const editedTime = formatRelativeDate(
publishedToDate(post.post.updated),
{
style: 'long',
},
)}
<MenuButton class="flex-1" aria-label={editedTime}>
{#snippet prefix()}
<Icon src={Pencil} size="16" micro />
{/snippet}
<RelativeDate date={publishedToDate(post.post.updated)} />
</MenuButton>
{/if}
</div>
{#if post.counts.score}
{@const ratio =
post.counts.upvotes / (post.counts.upvotes + post.counts.downvotes)}
<MenuButton
aria-label={$t('aria.vote.score', { default: post.counts.score })}
>
{#snippet prefix()}
<Icon src={ArrowsUpDown} size="16" micro />
{/snippet}
{$t('post.actions.vote.score')}
•
<FormattedNumber
number={post.counts.score}
options={{ notation: 'standard' }}
class="font-medium"
/>
•
<FormattedNumber
number={ratio}
options={{ style: 'percent' }}
class="font-medium {ratio > 0.7
? 'text-blue-700 dark:text-blue-300'
: 'text-red-500'}"
/>
</MenuButton>
{/if}
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
<MenuButton link href={userLink(post.creator)}>
{#snippet prefix()}
@@ -309,11 +240,7 @@
<MenuButton
onclick={async () => {
if (profile.data?.jwt)
post.read = await markAsRead(
post.post,
!post.read,
profile.data.jwt,
)
post.read = await markAsRead(post.post, !post.read)
}}
>
{#snippet prefix()}
@@ -326,11 +253,13 @@
{/if}
<MenuButton
onclick={() => {
navigator.share?.({
url: localShare
? `${instanceToURL(instance.data)}/post/${post.post.id}`
: post.post.ap_id,
}) ??
if (navigator.share)
navigator.share?.({
url: localShare
? `${instanceToURL(instance.data)}/post/${post.post.id}`
: post.post.ap_id,
})
else
navigator.clipboard.writeText(
localShare
? `${instanceToURL(instance.data)}/post/${post.post.id}`
@@ -346,11 +275,11 @@
{$t('post.actions.more.share')}
<div class="flex-1"></div>
{#if !post.post.local}
<div class="flex">
<div class="flex gap-1">
<Button
color={!localShare ? 'primary' : 'secondary'}
size="square-md"
roundingSide="left"
size="square-sm"
rounding="pill"
onclick={() => (localShare = false)}
title={$t('filter.location.global')}
>
@@ -358,8 +287,8 @@
</Button>
<Button
color={localShare ? 'primary' : 'secondary'}
size="square-md"
roundingSide="right"
size="square-sm"
rounding="pill"
onclick={() => (localShare = true)}
title={$t('filter.location.local')}
>
@@ -401,11 +330,7 @@
<MenuButton
onclick={async () => {
if (profile.data?.jwt)
post.post.deleted = await deleteItem(
post,
!post.post.deleted,
profile.data.jwt,
)
post.post.deleted = await deleteItem(post, !post.post.deleted)
}}
color="danger-subtle"
>