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:
1 parent
1824245f13
commit
76c581123a
225 files changed
+1553
-2352
No files matched your search
@@ -1,4 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { getClient } from '$lib/lemmy.svelte.js'
|
||||
import { Button, Modal, toast } from 'mono-svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import {
|
||||
Bookmark,
|
||||
Icon,
|
||||
@@ -8,25 +20,13 @@
|
||||
Plus,
|
||||
Trash,
|
||||
} from 'svelte-hero-icons'
|
||||
import type { CommentNodeI } from './comments.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import CommentForm from './CommentForm.svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
|
||||
import { getClient } from '$lib/lemmy.svelte.js'
|
||||
import { Disclosure, toast } from 'mono-svelte'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { Button, Modal } from 'mono-svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||
import { page } from '$app/state'
|
||||
import { onMount } from 'svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { fly, slide } from 'svelte/transition'
|
||||
import { expoInOut, expoOut } from 'svelte/easing'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import type { ClassValue } from 'svelte/elements'
|
||||
import { fly, slide } from 'svelte/transition'
|
||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||
import CommentForm from './CommentForm.svelte'
|
||||
import type { CommentNodeI } from './comments.svelte'
|
||||
import { errorMessage } from '$lib/lemmy/error'
|
||||
|
||||
interface Props {
|
||||
node: CommentNodeI
|
||||
@@ -76,7 +76,7 @@
|
||||
editing = false
|
||||
} catch (err) {
|
||||
toast({
|
||||
content: err as any,
|
||||
content: errorMessage(err as string),
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
@@ -102,7 +102,7 @@
|
||||
<span>{$t('form.edit')}</span>
|
||||
{/snippet}
|
||||
<form
|
||||
onsubmit={(e) => {
|
||||
onsubmit={e => {
|
||||
e.preventDefault()
|
||||
save()
|
||||
}}
|
||||
@@ -253,7 +253,7 @@
|
||||
label={$t('comment.reply')}
|
||||
{postId}
|
||||
parentId={node.comment_view.comment.id}
|
||||
oncomment={(e) => {
|
||||
oncomment={e => {
|
||||
node.children = [
|
||||
{
|
||||
children: [],
|
||||
|
||||
@@ -1,32 +1,28 @@
|
||||
<script lang="ts">
|
||||
import type { CommentView } from 'lemmy-js-client'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import CommentVote from '$lib/components/lemmy/comment/CommentVote.svelte'
|
||||
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
|
||||
import {
|
||||
amMod,
|
||||
isAdmin,
|
||||
report,
|
||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import type { CommentView } from 'lemmy-js-client'
|
||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||
import {
|
||||
ArrowUturnLeft,
|
||||
Bookmark,
|
||||
BookmarkSlash,
|
||||
ChatBubbleOvalLeft,
|
||||
EllipsisHorizontal,
|
||||
Flag,
|
||||
Icon,
|
||||
Language,
|
||||
PencilSquare,
|
||||
Square2Stack,
|
||||
Trash,
|
||||
} from 'svelte-hero-icons'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { isCommentMutable } from '$lib/components/lemmy/post/helpers.js'
|
||||
import {
|
||||
amMod,
|
||||
isAdmin,
|
||||
report,
|
||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
|
||||
interface Props {
|
||||
comment: CommentView
|
||||
@@ -84,9 +80,11 @@
|
||||
<MenuDivider>{$t('comment.actions.label')}</MenuDivider>
|
||||
<MenuButton
|
||||
onclick={() => {
|
||||
navigator.share?.({
|
||||
url: comment.comment.ap_id,
|
||||
}) ?? navigator.clipboard.writeText(comment.comment.ap_id)
|
||||
if (navigator.share)
|
||||
navigator.share?.({
|
||||
url: comment.comment.ap_id,
|
||||
})
|
||||
else navigator.clipboard.writeText(comment.comment.ap_id)
|
||||
}}
|
||||
>
|
||||
<Icon src={Square2Stack} mini size="16" />
|
||||
@@ -102,11 +100,7 @@
|
||||
<MenuButton
|
||||
onclick={async () => {
|
||||
if (profile.data?.jwt)
|
||||
comment.saved = await save(
|
||||
comment,
|
||||
!comment.saved,
|
||||
profile.data.jwt,
|
||||
)
|
||||
comment.saved = await save(comment, !comment.saved)
|
||||
}}
|
||||
>
|
||||
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
|
||||
@@ -122,7 +116,6 @@
|
||||
comment.comment.deleted = await deleteItem(
|
||||
comment,
|
||||
!comment.comment.deleted,
|
||||
profile.data.jwt,
|
||||
)
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
<script lang="ts">
|
||||
import type { CommentResponse } from 'lemmy-js-client'
|
||||
import { getClient, site } from '$lib/lemmy.svelte.js'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { Menu, Select, Spinner, toast, Option, MenuButton } from 'mono-svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { placeholders } from '$lib/util.svelte.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { getClient, site } from '$lib/lemmy.svelte.js'
|
||||
import { errorMessage } from '$lib/lemmy/error'
|
||||
import { placeholders } from '$lib/util.svelte.js'
|
||||
import type { CommentResponse } from 'lemmy-js-client'
|
||||
import { Button, Menu, MenuButton, toast } from 'mono-svelte'
|
||||
import { ArrowUp, Icon, Language, XMark } from 'svelte-hero-icons'
|
||||
import type { ClassValue, HTMLTextareaAttributes } from 'svelte/elements'
|
||||
|
||||
interface Props {
|
||||
interface Props extends Omit<HTMLTextareaAttributes, 'oncancel'> {
|
||||
postId: number
|
||||
parentId?: number | undefined
|
||||
locked?: boolean
|
||||
@@ -22,10 +21,13 @@
|
||||
value?: string
|
||||
actions?: boolean
|
||||
preview?: boolean
|
||||
class?: ClassValue
|
||||
required?: boolean
|
||||
id?: string
|
||||
label?: string
|
||||
oncomment?: (comment: CommentResponse) => void
|
||||
onconfirm?: (value: string) => void
|
||||
oncancel?: (cancel: boolean) => void
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -40,7 +42,6 @@
|
||||
preview: previewAction = true,
|
||||
oncancel,
|
||||
oncomment,
|
||||
onconfirm,
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
@@ -65,7 +66,7 @@
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
toast({
|
||||
content: errorMessage(err as any),
|
||||
content: errorMessage(err as string),
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
@@ -93,12 +94,6 @@
|
||||
: (placeholder ?? placeholders.get('comment'))}
|
||||
bind:value
|
||||
disabled={locked || loading || banned}
|
||||
onconfirm={() => {
|
||||
if (actions) {
|
||||
submit()
|
||||
onconfirm?.(value)
|
||||
}
|
||||
}}
|
||||
previewButton={previewAction}
|
||||
>
|
||||
<Menu>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { settings, type View } from '$lib/settings.svelte.js'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import type { CommentView } from 'lemmy-js-client'
|
||||
import { Button, Material } from 'mono-svelte'
|
||||
@@ -10,12 +10,11 @@
|
||||
|
||||
interface Props {
|
||||
comment: CommentView
|
||||
view?: any
|
||||
view?: View
|
||||
community?: boolean
|
||||
meta?: boolean
|
||||
class?: string
|
||||
commentClass?: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
let {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script lang="ts">
|
||||
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
||||
import type { Post } from 'lemmy-js-client'
|
||||
import { onMount } from 'svelte'
|
||||
import type { CommentNodeI } from './comments.svelte'
|
||||
import Comments from './Comments.svelte'
|
||||
import { onMount, tick } from 'svelte'
|
||||
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
||||
import { page } from '$app/state'
|
||||
|
||||
interface Props {
|
||||
nodes: CommentNodeI[]
|
||||
@@ -35,7 +34,7 @@
|
||||
|
||||
// IntersectionObserver to watch for shifts
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
entries => {
|
||||
entries.forEach(updateOffset)
|
||||
},
|
||||
{ threshold: [0, 1] },
|
||||
@@ -59,11 +58,11 @@
|
||||
{initialOffset}
|
||||
bind:this={list}
|
||||
>
|
||||
{#snippet item(item, index)}
|
||||
{#snippet item(index)}
|
||||
<div class="-mx-4 sm:-mx-6 px-4 sm:px-6">
|
||||
<Comments
|
||||
isParent={true}
|
||||
bind:nodes={() => [nodes[index]], (v) => (nodes[index] = v[0])}
|
||||
bind:nodes={() => [nodes[index]], v => (nodes[index] = v[0])}
|
||||
{post}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
ArrowDownCircle,
|
||||
ArrowUp,
|
||||
ArrowUpCircle,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
Icon,
|
||||
} from 'svelte-hero-icons'
|
||||
import { getClient, site } from '$lib/lemmy.svelte'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import { Button, buttonColor, toast } from 'mono-svelte'
|
||||
import { vote as voteItem } from '$lib/lemmy/contentview'
|
||||
import { shouldShowVoteColor } from '../post/PostVote.svelte'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { backOut } from 'svelte/easing'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { getClient } from '$lib/lemmy.svelte'
|
||||
import { buttonColor, toast } from 'mono-svelte'
|
||||
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||
import { backOut } from 'svelte/easing'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { shouldShowVoteColor } from '../post/PostVote.svelte'
|
||||
|
||||
interface Props {
|
||||
vote?: number
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
<script lang="ts">
|
||||
import Comments from './Comments.svelte'
|
||||
import Comment from './Comment.svelte'
|
||||
import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
|
||||
import { page } from '$app/state'
|
||||
import { onMount, setContext } from 'svelte'
|
||||
import { Icon, ArrowDownCircle } from 'svelte-hero-icons'
|
||||
import { getClient } from '$lib/lemmy.svelte.js'
|
||||
import type { CommentView, Post } from 'lemmy-js-client'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { afterNavigate, goto } from '$app/navigation'
|
||||
import { backOut, expoOut } from 'svelte/easing'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { browser } from '$app/environment'
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/state'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { getClient } from '$lib/lemmy.svelte.js'
|
||||
import type { Post } from 'lemmy-js-client'
|
||||
import { Button, toast } from 'mono-svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import { ArrowDownCircle, Icon } from 'svelte-hero-icons'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly } from 'svelte/transition'
|
||||
import Comment from './Comment.svelte'
|
||||
import Comments from './Comments.svelte'
|
||||
import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
|
||||
import { errorMessage } from '$lib/lemmy/error'
|
||||
|
||||
interface Props {
|
||||
nodes: CommentNodeI[]
|
||||
@@ -36,7 +35,6 @@
|
||||
}
|
||||
})
|
||||
|
||||
let loadingChildren = false
|
||||
let childrenPage = 0
|
||||
|
||||
async function fetchChildren(parent: CommentNodeI) {
|
||||
@@ -60,7 +58,6 @@
|
||||
})
|
||||
|
||||
if (newComments.comments.length == 0) {
|
||||
loadingChildren = false
|
||||
toast({
|
||||
content: $t('toast.noComments'),
|
||||
type: 'error',
|
||||
@@ -96,10 +93,10 @@
|
||||
}
|
||||
}
|
||||
childrenPage++
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
toast({
|
||||
content: error as any,
|
||||
content: errorMessage(err as string),
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
@@ -162,7 +159,6 @@
|
||||
/>
|
||||
{/snippet}
|
||||
{$t('comment.more', {
|
||||
// @ts-ignore
|
||||
comments: node.comment_view.counts.child_count,
|
||||
})}
|
||||
</Button>
|
||||
|
||||
@@ -26,7 +26,7 @@ function getDepthFromComment(comment?: Comment): number | undefined {
|
||||
export function buildCommentsTree(
|
||||
comments: CommentView[],
|
||||
baseDepth: number = 0,
|
||||
filter: (c: CommentView) => boolean = (c) => true,
|
||||
filter: (c: CommentView) => boolean = () => true,
|
||||
): CommentNodeI[] {
|
||||
const map = new Map<number, CommentNodeI>()
|
||||
|
||||
|
||||
Reference in new issue
Block a user