fix: fix all eslint errors

This commit is contained in:
sam 2024-12-14 00:46:27 +01:00
parent 1cf2619393
commit 39a3098a99
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
19 changed files with 420 additions and 412 deletions

View file

@ -30,4 +30,16 @@ export default ts.config(
{ {
ignores: ["build/", ".svelte-kit/", "dist/"], ignores: ["build/", ".svelte-kit/", "dist/"],
}, },
{
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
},
},
); );

View file

@ -12,29 +12,29 @@
"lint": "prettier --check . && eslint ." "lint": "prettier --check . && eslint ."
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-node": "^5.2.9", "@sveltejs/adapter-node": "^5.2.10",
"@sveltejs/kit": "^2.0.0", "@sveltejs/kit": "^2.11.1",
"@sveltejs/vite-plugin-svelte": "^4.0.0", "@sveltejs/vite-plugin-svelte": "^4.0.3",
"@sveltestrap/sveltestrap": "^6.2.7", "@sveltestrap/sveltestrap": "^6.2.7",
"@types/eslint": "^9.6.0", "@types/eslint": "^9.6.1",
"@types/luxon": "^3.4.2", "@types/luxon": "^3.4.2",
"@types/markdown-it": "^14.1.2", "@types/markdown-it": "^14.1.2",
"@types/sanitize-html": "^2.13.0", "@types/sanitize-html": "^2.13.0",
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
"eslint": "^9.7.0", "eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0", "eslint-plugin-svelte": "^2.46.1",
"globals": "^15.0.0", "globals": "^15.13.0",
"prettier": "^3.3.2", "prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.2.6", "prettier-plugin-svelte": "^3.3.2",
"sass": "^1.81.0", "sass": "^1.83.0",
"svelte": "^5.0.0", "svelte": "^5.12.0",
"svelte-bootstrap-icons": "^3.1.1", "svelte-bootstrap-icons": "^3.1.1",
"svelte-check": "^4.0.0", "svelte-check": "^4.1.1",
"sveltekit-i18n": "^2.4.2", "sveltekit-i18n": "^2.4.2",
"typescript": "^5.0.0", "typescript": "^5.7.2",
"typescript-eslint": "^8.0.0", "typescript-eslint": "^8.18.0",
"vite": "^5.0.3" "vite": "^5.4.11"
}, },
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee", "packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee",
"dependencies": { "dependencies": {

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@ export default function createCallbackLoader(
bodyFn?: (event: ServerLoadEvent) => Promise<unknown>, bodyFn?: (event: ServerLoadEvent) => Promise<unknown>,
) { ) {
return async (event: ServerLoadEvent) => { return async (event: ServerLoadEvent) => {
const { url, parent, fetch, cookies } = event; const { parent, fetch, cookies } = event;
bodyFn ??= async ({ url }) => { bodyFn ??= async ({ url }) => {
const code = url.searchParams.get("code") as string | null; const code = url.searchParams.get("code") as string | null;

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
export default class ApiError { export default class ApiError {
raw?: RawApiError; raw?: RawApiError;
code: ErrorCode; code: ErrorCode;

View file

@ -23,7 +23,7 @@ export type RequestArgs = {
/** /**
* The body for this request, which will be serialized to JSON. Should be a plain JS object. * The body for this request, which will be serialized to JSON. Should be a plain JS object.
*/ */
body?: any; body?: unknown;
/** /**
* The fetch function to use. Should be passed in loader and action functions, but can be safely ignored for client-side requests. * The fetch function to use. Should be passed in loader and action functions, but can be safely ignored for client-side requests.
*/ */

View file

@ -21,6 +21,8 @@
{#if value !== ""} {#if value !== ""}
<div class="card"> <div class="card">
<div class="card-header">{$t("edit-profile.preview")}</div> <div class="card-header">{$t("edit-profile.preview")}</div>
<!-- bios are sanitized before being passed to @html and the allowed markdown is heavily restricted -->
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<div class="card-body">{@html renderMarkdown(value)}</div> <div class="card-body">{@html renderMarkdown(value)}</div>
</div> </div>
{/if} {/if}

View file

@ -47,6 +47,8 @@
{/if} {/if}
{#if bio} {#if bio}
<hr /> <hr />
<!-- bios are sanitized before being passed to @html and the allowed markdown is heavily restricted -->
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<p>{@html bio}</p> <p>{@html bio}</p>
{/if} {/if}
</div> </div>

View file

@ -1,6 +1,7 @@
import { ErrorCode } from "$api/error"; import { ErrorCode } from "$api/error";
import type { Modifier } from "sveltekit-i18n"; import type { Modifier } from "sveltekit-i18n";
// eslint-disable-next-line
type TranslateFn = (key: string, payload?: any, props?: Modifier.Props<{}> | undefined) => any; type TranslateFn = (key: string, payload?: any, props?: Modifier.Props<{}> | undefined) => any;
export default function errorDescription(t: TranslateFn, code: ErrorCode): string { export default function errorDescription(t: TranslateFn, code: ErrorCode): string {

View file

@ -1,6 +1,7 @@
import { PUBLIC_LANGUAGE } from "$env/static/public"; import { PUBLIC_LANGUAGE } from "$env/static/public";
import i18n, { type Config } from "sveltekit-i18n"; import i18n, { type Config } from "sveltekit-i18n";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const config: Config<any> = { const config: Config<any> = {
initLocale: PUBLIC_LANGUAGE, initLocale: PUBLIC_LANGUAGE,
fallbackLocale: "en", fallbackLocale: "en",

View file

@ -1,12 +1,12 @@
<script lang="ts"> <script lang="ts">
import type { ActionData, PageData } from "./$types"; import type { ActionData } from "./$types";
import { t } from "$lib/i18n"; import { t } from "$lib/i18n";
import { enhance } from "$app/forms"; import { enhance } from "$app/forms";
import { Button, Input, InputGroup } from "@sveltestrap/sveltestrap"; import { Button, Input, InputGroup } from "@sveltestrap/sveltestrap";
import FormStatusMarker from "$components/editor/FormStatusMarker.svelte"; import FormStatusMarker from "$components/editor/FormStatusMarker.svelte";
type Props = { data: PageData; form: ActionData }; type Props = { form: ActionData };
let { data, form }: Props = $props(); let { form }: Props = $props();
</script> </script>
<svelte:head> <svelte:head>

View file

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import type { ActionData, PageData } from "./$types"; import type { ActionData, PageData } from "./$types";
import { t } from "$lib/i18n"; import { t } from "$lib/i18n";
import { Button, FormGroup, Icon, Input, InputGroup, Label } from "@sveltestrap/sveltestrap"; import { Button, FormGroup, Icon, Input, InputGroup } from "@sveltestrap/sveltestrap";
import Avatar from "$components/Avatar.svelte"; import Avatar from "$components/Avatar.svelte";
import { firstErrorFor } from "$api/error"; import { firstErrorFor } from "$api/error";
import Error from "$components/Error.svelte"; import Error from "$components/Error.svelte";

View file

@ -1,7 +1,6 @@
import { fastRequest } from "$api"; import { fastRequest } from "$api";
import ApiError, { ErrorCode, type RawApiError } from "$api/error.js"; import ApiError, { ErrorCode, type RawApiError } from "$api/error.js";
import log from "$lib/log.js"; import log from "$lib/log.js";
import { redirect } from "@sveltejs/kit";
export const load = async ({ parent }) => { export const load = async ({ parent }) => {
const { user } = await parent(); const { user } = await parent();

View file

@ -1,6 +1,5 @@
<script lang="ts"> <script lang="ts">
import { t } from "$lib/i18n"; import { t } from "$lib/i18n";
import { Button } from "@sveltestrap/sveltestrap";
import type { ActionData, PageData } from "./$types"; import type { ActionData, PageData } from "./$types";
import FormStatusMarker from "$components/editor/FormStatusMarker.svelte"; import FormStatusMarker from "$components/editor/FormStatusMarker.svelte";

View file

@ -1,8 +1,6 @@
<script lang="ts"> <script lang="ts">
import { DateTime } from "luxon"; import { DateTime } from "luxon";
import type { ActionData, PageData } from "./$types"; import type { ActionData, PageData } from "./$types";
import ErrorAlert from "$components/ErrorAlert.svelte";
import { Icon } from "@sveltestrap/sveltestrap";
import { t } from "$lib/i18n"; import { t } from "$lib/i18n";
import { enhance } from "$app/forms"; import { enhance } from "$app/forms";
import FormStatusMarker from "$components/editor/FormStatusMarker.svelte"; import FormStatusMarker from "$components/editor/FormStatusMarker.svelte";

View file

@ -4,7 +4,7 @@ import type { PrideFlag } from "$api/models/user";
import log from "$lib/log"; import log from "$lib/log";
import { encode } from "base64-arraybuffer"; import { encode } from "base64-arraybuffer";
export const load = async ({ url, fetch, cookies }) => { export const load = async ({ fetch, cookies }) => {
const resp = await apiRequest<PrideFlag[]>("GET", "/users/@me/flags", { fetch, cookies }); const resp = await apiRequest<PrideFlag[]>("GET", "/users/@me/flags", { fetch, cookies });
return { return {

View file

@ -82,7 +82,7 @@ export const actions = {
}, },
options: async ({ params, request, fetch, cookies }) => { options: async ({ params, request, fetch, cookies }) => {
const body = await request.formData(); const body = await request.formData();
let unlisted = !!body.get("unlisted"); const unlisted = !!body.get("unlisted");
try { try {
await fastRequest("PATCH", `/users/@me/members/${params.id}`, { await fastRequest("PATCH", `/users/@me/members/${params.id}`, {

View file

@ -5,12 +5,11 @@
import { apiRequest, fastRequest } from "$api"; import { apiRequest, fastRequest } from "$api";
import ApiError from "$api/error"; import ApiError from "$api/error";
import log from "$lib/log"; import log from "$lib/log";
import { Icon, InputGroup } from "@sveltestrap/sveltestrap"; import { InputGroup } from "@sveltestrap/sveltestrap";
import InfoCircleFill from "svelte-bootstrap-icons/lib/InfoCircleFill.svelte"; import InfoCircleFill from "svelte-bootstrap-icons/lib/InfoCircleFill.svelte";
import { t } from "$lib/i18n"; import { t } from "$lib/i18n";
import AvatarEditor from "$components/editor/AvatarEditor.svelte"; import AvatarEditor from "$components/editor/AvatarEditor.svelte";
import ErrorAlert from "$components/ErrorAlert.svelte"; import ErrorAlert from "$components/ErrorAlert.svelte";
import NoscriptWarning from "$components/editor/NoscriptWarning.svelte";
import FormStatusMarker from "$components/editor/FormStatusMarker.svelte"; import FormStatusMarker from "$components/editor/FormStatusMarker.svelte";
import SidEditor from "$components/editor/SidEditor.svelte"; import SidEditor from "$components/editor/SidEditor.svelte";
import BioEditor from "$components/editor/BioEditor.svelte"; import BioEditor from "$components/editor/BioEditor.svelte";

View file

@ -11,7 +11,7 @@ export const actions = {
let timezone = body.get("timezone") as string | null; let timezone = body.get("timezone") as string | null;
if (!timezone || timezone === "") timezone = null; if (!timezone || timezone === "") timezone = null;
let hideMemberList = !!body.get("hide-member-list"); const hideMemberList = !!body.get("hide-member-list");
try { try {
await fastRequest("PATCH", "/users/@me", { await fastRequest("PATCH", "/users/@me", {