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

+1 -7
View File
@@ -1,5 +1,5 @@
import { getClient } from '$lib/lemmy.svelte.js'
import { isComment, isCommentView, isPostView } from '$lib/lemmy/item.js'
import { isComment, isCommentView } from '$lib/lemmy/item.js'
import type {
CommentView,
Person,
@@ -63,7 +63,6 @@ export const contentItem = (item: Submission): ContentView => {
export async function save(
item: ContentView | SubmissionView,
save: boolean,
jwt: string,
): Promise<boolean> {
if (isSubmissionView(item)) item = contentView(item)
@@ -88,7 +87,6 @@ export async function save(
export async function deleteItem(
item: ContentView | SubmissionView,
deleted: boolean,
jwt: string,
): Promise<boolean> {
if (isSubmissionView(item)) item = contentView(item)
@@ -113,7 +111,6 @@ export async function deleteItem(
export async function vote(
item: ContentView | Submission,
vote: number,
jwt: string,
): Promise<{ upvotes: number; downvotes: number; score: number }> {
if (isSubmission(item)) item = contentItem(item)
@@ -138,14 +135,11 @@ export async function vote(
export async function markAsRead(
item: ContentView | Submission,
read: boolean,
jwt: string,
): Promise<boolean> {
if (isSubmission(item)) item = contentItem(item)
if (item.type == 'post') {
getClient().markPostAsRead({
// @ts-ignore
post_id: item.id,
post_ids: [item.id],
read: read,
})
+3 -1
View File
@@ -1,5 +1,6 @@
import { t } from '$lib/i18n/translations'
// eslint-disable-next-line
export function errorMessage(error: any, instance?: string): string {
try {
if (error?.body?.message) {
@@ -12,7 +13,8 @@ export function errorMessage(error: any, instance?: string): string {
if (!error) throw error
return t.get(`error.${error}`)
} catch (e) {
} catch {
// eslint-disable-next-line
return error as any
}
}
-1
View File
@@ -1,5 +1,4 @@
import type {
Comment,
CommentReplyView,
CommentView,
Person,
+11 -11
View File
@@ -1,18 +1,18 @@
import { profile, profileData } from '$lib/auth.svelte'
import { profile } from '$lib/auth.svelte'
import type {
Comment,
CommentReportView,
CommentView,
Community,
CommunityView,
Comment,
PersonView,
Post,
PostReportView,
PostView,
Post,
PrivateMessageReportView,
PrivateMessageView,
Community,
} from 'lemmy-js-client'
import { get, writable } from 'svelte/store'
import { writable } from 'svelte/store'
export type Result =
| PostView
@@ -90,8 +90,8 @@ function resumableStore(limit: number = 10) {
set,
update,
add: (item: ResumableItem) => {
update((resumables) => {
if (resumables.find((i) => JSON.stringify(i) == JSON.stringify(item)))
update(resumables => {
if (resumables.find(i => JSON.stringify(i) == JSON.stringify(item)))
return resumables
resumables.unshift(item)
if (resumables.length > limit) resumables.pop()
@@ -101,13 +101,13 @@ function resumableStore(limit: number = 10) {
}
}
export let resumables = resumableStore()
export const resumables = resumableStore()
export function addFavorite(item: Community, add: boolean = true) {
let favs = profile.data.favorites ?? []
if (favs.map((fav) => fav.id).includes(item.id)) if (add) return
const favs = profile.data.favorites ?? []
if (favs.map(fav => fav.id).includes(item.id)) if (add) return
if (!add) {
favs.splice(favs.map((c) => c.id).indexOf(item.id), 1)
favs.splice(favs.map(c => c.id).indexOf(item.id), 1)
} else {
favs.unshift(item)
}
+1 -1
View File
@@ -104,4 +104,4 @@ export interface PostFeed {
}
}
export let postFeeds = new PostFeedState()
export const postFeeds = new PostFeedState()
-1
View File
@@ -7,7 +7,6 @@ import type {
PostView,
PrivateMessage,
PrivateMessageReportView,
PrivateMessageView,
} from 'lemmy-js-client'
interface CommentReport {
+10 -10
View File
@@ -1,34 +1,34 @@
import { profile, profileData, type Profile } from '$lib/auth.svelte'
import { profile, type Profile } from '$lib/auth.svelte'
import { getClient } from '$lib/lemmy.svelte.js'
import { trycatch } from '$lib/util.svelte'
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
import { get } from 'svelte/store'
import type { Community, MyUserInfo } from 'lemmy-js-client'
// TODO obliterate this file
export const blockUser = async (block: boolean, id: number) => {
const auth = profile.data?.jwt
if (!auth) throw new Error('Unauthorized')
const response = await getClient().blockPerson({
await getClient().blockPerson({
block: block,
person_id: id,
})
}
export const isBlocked = (me: MyUserInfo, user: number) =>
me.person_blocks.map((b) => b.target.id).includes(user)
me.person_blocks.map(b => b.target.id).includes(user)
export const addSubscription = (
community: Community,
subscribe: boolean = true,
) => {
const index = profile.data.user?.follows
.map((f) => f.community.id)
.map(f => f.community.id)
.indexOf(community.id)
if (subscribe && index == -1) {
profile.data.user?.follows.push({
// @ts-ignore
follower: profile.data.user.follows[0]?.follower,
community: community,
})
@@ -37,7 +37,7 @@ export const addSubscription = (
}
}
export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
export const addAdmin = async (handle: string, added: boolean) =>
trycatch(async () => {
const user = await getClient().resolveObject({
q: handle,
@@ -46,10 +46,10 @@ export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
if (!user.person) throw new Error('No user found')
return await getClient().addAdmin({
added: true,
added: added,
person_id: user.person.person.id,
})
})
export const hasFavorite = (profile: Profile, id: number): boolean =>
profile.favorites?.map((i) => i.id).includes(id) ?? false
profile.favorites?.map(i => i.id).includes(id) ?? false