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,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(
|
||||
|
||||
Reference in new issue
Block a user