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

+2 -3
View File
@@ -23,7 +23,7 @@
}
return urlObj.toString()
} catch (e) {
} catch {
return undefined
}
}
@@ -37,7 +37,6 @@
res?: number | undefined
style?: string
class?: ClassValue
[key: string]: any
}
let {
@@ -53,7 +52,7 @@
}: Props = $props()
let optimizedURLs = $derived(
[2, 3, 6, -1].map((n) => optimizeUrl(url, (res || width) * n)),
[2, 3, 6, -1].map(n => optimizeUrl(url, (res || width) * n)),
)
</script>
+3 -10
View File
@@ -1,15 +1,9 @@
<script lang="ts">
import { Material } from 'mono-svelte'
import Avatar from './Avatar.svelte'
import PostBody from '../lemmy/post/PostBody.svelte'
import LabelStat from './LabelStat.svelte'
import { optimizeImageURL } from '../lemmy/post/helpers'
import FormattedNumber from '../util/FormattedNumber.svelte'
import Expandable from './Expandable.svelte'
import { Icon, InformationCircle } from 'svelte-hero-icons'
import { t } from '$lib/i18n/translations'
import Markdown from '../markdown/Markdown.svelte'
import EndPlaceholder from './EndPlaceholder.svelte'
import FormattedNumber from '../util/FormattedNumber.svelte'
import Avatar from './Avatar.svelte'
import Expandable from './Expandable.svelte'
interface Props {
avatar?: string | undefined
@@ -27,7 +21,6 @@
nameDetail?: import('svelte').Snippet
actions?: import('svelte').Snippet
children?: import('svelte').Snippet
[key: string]: any
}
let {
+3 -6
View File
@@ -1,7 +1,7 @@
<script lang="ts" module>
import { pushState } from '$app/navigation'
export function showImage(url: string, alt: string = '') {
export function showImage(url: string) {
pushState('', {
openImage: url,
})
@@ -30,16 +30,13 @@
</script>
{#if page.state.openImage || '' != ''}
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_positive_tabindex -->
<div
class="fixed top-0 left-0 w-screen h-svh overflow-auto bg-white/50 dark:bg-black/50
flex flex-col z-100 backdrop-blur-xs"
transition:fade={{ duration: 150 }}
onclick={() => history.back()}
onkeydown={(e) => {
onkeydown={e => {
if (e.key == 'Escape') history.back()
}}
use:focusTrap
@@ -60,7 +57,7 @@
rounding="full"
padding="none"
color="uniform"
onclick={(e) => e.stopPropagation()}
onclick={e => e.stopPropagation()}
>
<Button
onclick={() => {
-2
View File
@@ -1,6 +1,4 @@
<script lang="ts">
import { settings } from '$lib/settings.svelte'
interface Props {
width?: number
}
-4
View File
@@ -12,8 +12,6 @@
cursor?: { next?: string; back?: string } | undefined
hasMore?: boolean
children?: import('svelte').Snippet
onchange?: (page: number) => void
onchangecursor?: (cursor: string) => void
href?: (current: number | string) => string
back?: boolean
}
@@ -23,8 +21,6 @@
cursor = undefined,
hasMore = true,
children,
onchange,
onchangecursor,
href,
back = true,
}: Props = $props()
-2
View File
@@ -5,7 +5,6 @@
icon?: IconSource | undefined
title: string
description?: string | undefined
center?: boolean
class?: string
children?: import('svelte').Snippet
}
@@ -14,7 +13,6 @@
icon = undefined,
title,
description = undefined,
center = false,
class: clazz = '',
children,
}: Props = $props()
+3 -2
View File
@@ -1,9 +1,10 @@
<script lang="ts">
interface Props {
import type { HTMLAttributes } from 'svelte/elements'
interface Props extends HTMLAttributes<HTMLSpanElement> {
small?: boolean
class?: string
children?: import('svelte').Snippet
[key: string]: any
}
let { small = false, class: clazz = '', children, ...rest }: Props = $props()
+8 -9
View File
@@ -1,22 +1,20 @@
<script lang="ts">
import { settings } from '$lib/settings.svelte.js'
import { theme } from '$lib/ui/colors.svelte'
import type { Snippet } from 'svelte'
import type { ClassValue, UIEventHandler } from 'svelte/elements'
import { scrollY } from 'svelte/reactivity/window'
interface Props {
route?: { id: string | null } | undefined
class?: ClassValue
children?: import('svelte').Snippet
navbar?: import('svelte').Snippet<[any]>
sidebar?: import('svelte').Snippet<[any]>
main?: import('svelte').Snippet<[any]>
suffix?: import('svelte').Snippet<[any]>
[key: string]: any
children?: Snippet
navbar?: Snippet<[{ class: string; style: string }]>
sidebar?: Snippet<[{ class: string; style: string }]>
main?: Snippet<[{ class: string; style: string }]>
suffix?: Snippet<[{ class: string; style: string }]>
}
let {
route = undefined,
class: clazz = '',
children,
navbar,
@@ -27,7 +25,7 @@
}: Props = $props()
let previousTop = 0
const onscroll: UIEventHandler<Window> = (e) => {
const onscroll: UIEventHandler<Window> = () => {
if (!settings.dock.autoHide) {
dockVisible = true
return
@@ -56,6 +54,7 @@
class: `bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900
pointer-events-auto backdrop-blur-xl border lg:border-t-0 lg:border-x-0
rounded-full lg:rounded-none`,
style: '',
})}
</div>
<div
@@ -1,7 +1,6 @@
<script lang="ts">
import { invalidate, invalidateAll } from '$app/navigation'
import { invalidateAll } from '$app/navigation'
import { page } from '$app/state'
import { fly } from 'svelte/transition'
interface Props {
routes: {
@@ -18,7 +17,7 @@
let {
routes,
currentRoute = undefined,
buildUrl = (route, href) => href,
buildUrl = (_, href) => href,
defaultRoute = undefined,
class: clazz = '',
children,
@@ -49,7 +48,7 @@
''}
"
>
{#each routes as route}
{#each routes as route (route.href)}
<a
onclick={() => invalidateAll()}
href={buildUrl(currentRoute, route.href)}
@@ -3,6 +3,7 @@
import { Button, buttonColor } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'
import type { ButtonProps } from 'mono-svelte/button/Button.svelte'
import type { Snippet } from 'svelte'
interface Props extends ButtonProps {
label: string
@@ -11,9 +12,8 @@
adaptive?: boolean
isSelectedFilter?: (path: string) => boolean
class?: string
customIcon?: import('svelte').Snippet<[any]>
children?: import('svelte').Snippet
[key: string]: any
customIcon?: Snippet<[{ size: number; isSelected?: boolean }]>
children?: Snippet
}
let {
@@ -21,7 +21,7 @@
icon,
href,
adaptive = true,
isSelectedFilter = (path) => href != undefined && path == href,
isSelectedFilter = path => href != undefined && path == href,
class: clazz = '',
customIcon,
children,
+9 -9
View File
@@ -6,8 +6,10 @@
isAdmin,
} from '$lib/components/lemmy/moderation/moderation.js'
import Avatar from '$lib/components/ui/Avatar.svelte'
import { t } from '$lib/i18n/translations'
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
import { site } from '$lib/lemmy.svelte.js'
import { Button, Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
import {
GlobeAlt,
Icon,
@@ -17,13 +19,11 @@
Plus,
ServerStack,
} from 'svelte-hero-icons'
import Profile from './Profile.svelte'
import NavButton from './NavButton.svelte'
import Logo from '../Logo.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
import { t } from '$lib/i18n/translations'
import CommandsWrapper from './commands/CommandsWrapper.svelte'
import type { ClassValue } from 'svelte/elements'
import Logo from '../Logo.svelte'
import NavButton from './NavButton.svelte'
import Profile from './Profile.svelte'
import CommandsWrapper from './commands/CommandsWrapper.svelte'
let promptOpen: boolean = $state(false)
interface Props {
@@ -43,7 +43,7 @@
{style}
>
<NavButton
oncontextmenu={(e) => {
oncontextmenu={e => {
e.preventDefault()
promptOpen = true
return true
@@ -81,7 +81,7 @@
label={$t('nav.admin')}
icon={ServerStack}
class="relative"
isSelectedFilter={(path) => path.startsWith('/admin')}
isSelectedFilter={path => path.startsWith('/admin')}
>
{#if ($notifications.applications ?? 0) > 0}
<div
+15 -16
View File
@@ -3,6 +3,11 @@
import { notifications, profile } from '$lib/auth.svelte'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/i18n/translations'
import { site } from '$lib/lemmy.svelte'
import { settings } from '$lib/settings.svelte'
import { theme } from '$lib/ui/colors.svelte'
import {
Badge,
Button,
@@ -10,12 +15,12 @@
MenuButton,
MenuDivider,
Modal,
Option,
Select,
Spinner,
toast,
Option,
} from 'mono-svelte'
import Avatar from '../Avatar.svelte'
import type { Placement } from 'svelte-floating-ui/core'
import {
Bars3,
Bookmark,
@@ -23,10 +28,8 @@
CodeBracketSquare,
Cog6Tooth,
ComputerDesktop,
Heart,
Icon,
Inbox,
InformationCircle,
Moon,
ServerStack,
Sun,
@@ -34,17 +37,13 @@
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import { theme } from '$lib/ui/colors.svelte'
import { settings } from '$lib/settings.svelte'
import { site } from '$lib/lemmy.svelte'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/i18n/translations'
import Avatar from '../Avatar.svelte'
let showInstance = $state(false)
interface Props {
buttonClass?: string
[key: string]: any
placement?: Placement
}
let { buttonClass = '', ...rest }: Props = $props()
@@ -97,13 +96,13 @@
{/snippet}
<MenuDivider>{$t('nav.menu.label')}</MenuDivider>
{#if profile.data?.jwt}
<MenuButton link href="/profile">
<MenuButton href="/profile">
{#snippet prefix()}
<Icon src={UserCircle} micro width={16} />
{/snippet}
{$t('profile.profile')}
</MenuButton>
<MenuButton link href="/inbox">
<MenuButton href="/inbox">
{#snippet prefix()}
<Icon src={Inbox} micro width={16} />
{/snippet}
@@ -114,21 +113,21 @@
</Badge>
{/if}
</MenuButton>
<MenuButton link href="/saved">
<MenuButton href="/saved">
{#snippet prefix()}
<Icon src={Bookmark} micro width={16} />
{/snippet}
{$t('profile.saved')}
</MenuButton>
{/if}
<MenuButton link href="/accounts">
<MenuButton href="/accounts">
{#snippet prefix()}
<Icon src={UserGroup} micro width={16} />
{/snippet}
{$t('account.accounts')}
</MenuButton>
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
<MenuButton link href="/settings">
<MenuButton href="/settings">
{#snippet prefix()}
<Icon src={Cog6Tooth} micro width={16} />
{/snippet}
@@ -176,7 +175,7 @@
{$t('nav.menu.theme')}
</MenuButton>
{#if settings.debugInfo}
<MenuButton link href="/util">
<MenuButton href="/util">
{#snippet prefix()}
<Icon src={BugAnt} mini width={16} />
{/snippet}
@@ -1,21 +1,16 @@
<script lang="ts">
import { Button, Material } from 'mono-svelte'
import {
ArrowUturnDown,
Icon,
QuestionMarkCircle,
type IconSource,
} from 'svelte-hero-icons'
import { Button } from 'mono-svelte'
import { ArrowUturnDown, Icon, QuestionMarkCircle } from 'svelte-hero-icons'
import type { HTMLButtonAttributes } from 'svelte/elements'
import Avatar from '../../Avatar.svelte'
import type { Action } from './actions.svelte'
import type { HTMLButtonAttributes } from 'svelte/elements'
import type { Snippet } from 'svelte'
interface Props {
action: Action
class?: string
children?: import('svelte').Snippet
children?: Snippet
onclick?: HTMLButtonAttributes['onclick']
[key: string]: any
}
let { action, class: clazz = '', children, ...rest }: Props = $props()
@@ -1,18 +1,16 @@
<script lang="ts">
import { run } from 'svelte/legacy'
import { browser } from '$app/environment'
import { goto } from '$app/navigation'
import { page } from '$app/state'
import { profile, profileData } from '$lib/auth.svelte'
import { t } from '$lib/i18n/translations'
import { resumables } from '$lib/lemmy/item'
import { theme } from '$lib/ui/colors.svelte'
import { TextInput } from 'mono-svelte'
import { createEventDispatcher, onMount } from 'svelte'
import { Home, Icon, MagnifyingGlass } from 'svelte-hero-icons'
import { t } from '$lib/i18n/translations'
import CommandItem from './CommandItem.svelte'
import { browser } from '$app/environment'
import { afterNavigate, goto } from '$app/navigation'
import { profile, profileData } from '$lib/auth.svelte'
import { getGroups, type Action, type Group } from './actions.svelte'
import { theme } from '$lib/ui/colors.svelte'
import { page } from '$app/state'
import CommandItem from './CommandItem.svelte'
interface Props {
open?: boolean
@@ -73,6 +71,7 @@
const debounce = (fn: Function, ms = 300) => {
let timeoutId: ReturnType<typeof setTimeout>
// eslint-disable-next-line
return function (this: any, ...args: any[]) {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => fn.apply(this, args), ms)
@@ -82,16 +81,16 @@
function searchGroup(term: string) {
if (term.length < 1) {
if (breadcrumbs.length <= 0) {
filteredGroups = groups.map((group) => ({
filteredGroups = groups.map(group => ({
...group,
actions: flattenActions(group.actions, false),
}))
}
} else {
filteredGroups = groups
.map((group) => {
.map(group => {
const scoredActions = flattenActions(group.actions)
.map((action) => ({
.map(action => ({
...action,
score: Math.max(
fuzzySearch(action.name, term),
@@ -99,7 +98,7 @@
action.detail ? fuzzySearch(action.detail, term) : -1,
),
}))
.filter((action) => action.score > 0)
.filter(action => action.score > 0)
.sort((a, b) => b.score - a.score)
return {
@@ -107,11 +106,11 @@
actions: scoredActions,
score: Math.max(
fuzzySearch(group.name, term),
...scoredActions.map((a) => a.score),
...scoredActions.map(a => a.score),
),
}
})
.filter((group) => group.actions.length > 0)
.filter(group => group.actions.length > 0)
.sort((a, b) => b.score - a.score)
}
}
@@ -143,7 +142,7 @@
actions: Action[],
subaction: boolean = true,
): Action[] {
return actions.flatMap((action) => [
return actions.flatMap(action => [
action,
...(action.subActions && subaction
? flattenActions(action.subActions)
@@ -164,10 +163,10 @@
function handleKeydown(event: KeyboardEvent) {
if (event.ctrlKey) {
const actions = groups
.flatMap((g) => g.actions)
.filter((a) => a.shortcut != undefined)
.flatMap(g => g.actions)
.filter(a => a.shortcut != undefined)
actions.forEach((a) => {
actions.forEach(a => {
if (event.key === a.shortcut) {
event.preventDefault()
if (a.href) goto(a.href)
@@ -247,7 +246,7 @@
})
let flattenedActions = $derived(
filteredGroups.flatMap((group) => group.actions),
filteredGroups.flatMap(group => group.actions),
)
</script>
@@ -269,7 +268,7 @@
>
<Icon src={Home} size="16" mini />
</button>
{#each breadcrumbs as crumb, index}
{#each breadcrumbs as crumb (crumb.href)}
<span class="text-base text-slate-400 dark:text-zinc-600">/</span>
<span class="text-[13px] font-medium">
{crumb.name}
@@ -278,11 +277,11 @@
</div>
{/if}
<div class="space-y-1" bind:this={container}>
{#each filteredGroups as group, groupIndex}
{#each filteredGroups as group, groupIndex (group.name)}
<div class="space-y-1">
<span class="text-sm font-medium">{group.name}</span>
<ul class="flex flex-col gap-1">
{#each group.actions as action, actionIndex}
{#each group.actions as action, actionIndex (action.href)}
{@const globalIndex =
filteredGroups
.slice(0, groupIndex)
@@ -290,7 +289,7 @@
<li>
<CommandItem
{action}
onclick={(e) => {
onclick={e => {
if (action.href) {
togglePalette()
return
@@ -1,8 +1,6 @@
<script lang="ts">
import { t } from '$lib/i18n/translations'
import { Modal, Spinner } from 'mono-svelte'
import Commands from './Commands.svelte'
import { CommandLine, Icon } from 'svelte-hero-icons'
interface Props {
open?: boolean
@@ -5,47 +5,46 @@ import {
amModOfAny,
isAdmin,
} from '$lib/components/lemmy/moderation/moderation'
import { resumables, type ResumableItem } from '$lib/lemmy/item'
import { settings } from '$lib/settings.svelte'
import { t } from '$lib/i18n/translations'
import { type ResumableItem } from '$lib/lemmy/item'
import { settings } from '$lib/settings.svelte'
import { theme, type ThemeData } from '$lib/ui/colors.svelte'
import { fullCommunityName } from '$lib/util.svelte'
import {
ArrowRightOnRectangle,
ArrowTrendingDown,
ArrowTrendingUp,
Bookmark,
ChartBar,
ChatBubbleLeftRight,
ChatBubbleOvalLeftEllipsis,
Clock,
Cog6Tooth,
ComputerDesktop,
Fire,
GlobeAlt,
GlobeAmericas,
Home,
Identification,
Inbox,
MapPin,
Moon,
Newspaper,
PaintBrush,
PencilSquare,
Plus,
Scale,
ServerStack,
ShieldCheck,
Star,
Sun,
Swatch,
Trophy,
UserCircle,
UserGroup,
ViewColumns,
type IconSource,
PaintBrush,
ComputerDesktop,
Sun,
Moon,
MapPin,
GlobeAmericas,
ChartBar,
Trophy,
ArrowTrendingUp,
Fire,
Scale,
Star,
Clock,
ArrowTrendingDown,
ChatBubbleOvalLeftEllipsis,
ChatBubbleLeftRight,
Swatch,
Plus,
} from 'svelte-hero-icons'
import { get } from 'svelte/store'
export interface Group {
name: string
@@ -55,7 +54,7 @@ export interface Group {
export interface Action {
name: string
desc?: string
handle?: () => any
handle?: () => void
href?: string
shortcut?: string
icon: string | IconSource
@@ -73,7 +72,7 @@ export function getGroups(
return [
{
name: t.get('nav.commands.recents'),
actions: resumables.map((r) => ({
actions: resumables.map(r => ({
name: r.name,
icon: r.avatar ?? PencilSquare,
href: r.url,
@@ -306,7 +305,7 @@ export function getGroups(
},
{
name: t.get('account.accounts'),
actions: profiles.map((p) => ({
actions: profiles.map(p => ({
name: p.username ?? t.get('account.guest'),
icon: p.avatar ?? UserCircle,
detail: p.instance,
@@ -379,7 +378,7 @@ export function getGroups(
{
name: t.get('nav.commands.setTheme'),
icon: Swatch,
subActions: td.themes.map((th) => ({
subActions: td.themes.map(th => ({
name: t.get('nav.commands.setThemeTo', { default: th.name }),
icon: Swatch,
handle: () => (theme.data.currentTheme = th.id),
@@ -405,7 +404,7 @@ export function getGroups(
{
name: t.get('profile.subscribed'),
actions:
profile.user?.follows.map((f) => ({
profile.user?.follows.map(f => ({
icon: f.community.icon,
name: f.community.title,
href: `/c/${fullCommunityName(
-2
View File
@@ -1,6 +1,5 @@
import { t } from '$lib/i18n/translations'
import {
UserCircle,
type IconSource,
Home,
ChartBar,
@@ -17,7 +16,6 @@ import {
ArrowTrendingUp,
Star,
} from 'svelte-hero-icons'
import { get } from 'svelte/store'
export interface Link {
url: string
@@ -5,7 +5,6 @@
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
import { Button } from 'mono-svelte'
import { Icon, QuestionMarkCircle } from 'svelte-hero-icons'
let switching: boolean = $state(false)
+10 -14
View File
@@ -1,4 +1,12 @@
<script lang="ts">
import { notifications, profile, profileData } from '$lib/auth.svelte.js'
import Expandable from '$lib/components/ui/Expandable.svelte'
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import { t } from '$lib/i18n/translations'
import { settings } from '$lib/settings.svelte.js'
import { Badge } from 'mono-svelte'
import {
ArrowLeftOnRectangle,
Bookmark,
@@ -8,17 +16,7 @@
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import { notifications, profile, profileData } from '$lib/auth.svelte.js'
import { settings } from '$lib/settings.svelte.js'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
import { flip } from 'svelte/animate'
import { expoOut } from 'svelte/easing'
import { Badge } from 'mono-svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import EndPlaceholder from '../EndPlaceholder.svelte'
import { t } from '$lib/i18n/translations'
interface Props {
style?: string
@@ -162,7 +160,7 @@
</span>
{/snippet}
<CommunityList
items={profile.data.user.moderates.map((i) => i.community)}
items={profile.data.user.moderates.map(i => i.community)}
/>
</Expandable>
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
@@ -184,9 +182,7 @@
</EndPlaceholder>
</span>
{/snippet}
<CommunityList
items={profile.data.user.follows.map((i) => i.community)}
/>
<CommunityList items={profile.data.user.follows.map(i => i.community)} />
</Expandable>
{/if}
</nav>
@@ -1,17 +1,17 @@
<script lang="ts">
import { page } from '$app/state'
import { Button } from 'mono-svelte'
import type { ButtonProps } from 'mono-svelte/button/Button.svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'
interface Props {
interface Props extends ButtonProps {
href?: string | undefined
icon?: IconSource | undefined
selected?: boolean
class?: string
customIcon?: import('svelte').Snippet<[any]>
customIcon?: import('svelte').Snippet<[{ selected: boolean }]>
children?: import('svelte').Snippet
label?: import('svelte').Snippet
[key: string]: any
}
let {