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

@@ -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