lint issues begone

This commit is contained in:
Hamcha 2023-07-29 16:10:03 +02:00
parent b6d9d45398
commit 4254368597
Signed by: hamcha
GPG Key ID: 1669C533B8CF6D89
8 changed files with 332 additions and 474 deletions

View File

@ -4,6 +4,5 @@
"trailingComma": "none", "trailingComma": "none",
"printWidth": 100, "printWidth": 100,
"plugins": ["prettier-plugin-svelte"], "plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
} }

748
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,24 +11,24 @@
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .", "lint": "prettier --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ." "format": "prettier --write ."
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/kit": "^1.20.4", "@sveltejs/kit": "^1.22.3",
"@typescript-eslint/eslint-plugin": "^5.45.0", "@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^5.45.0", "@typescript-eslint/parser": "^6.2.0",
"eslint": "^8.45.0", "eslint": "^8.46.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.9.0",
"eslint-plugin-svelte": "^2.30.0", "eslint-plugin-svelte": "^2.32.4",
"prettier": "^2.8.8", "prettier": "^3.0.0",
"prettier-plugin-svelte": "^2.10.1", "prettier-plugin-svelte": "^3.0.3",
"svelte": "^4.0.0", "svelte": "^4.1.1",
"svelte-check": "^3.4.3", "svelte-check": "^3.4.6",
"tslib": "^2.4.1", "tslib": "^2.6.1",
"typescript": "^5.1.6", "typescript": "^5.1.6",
"vite": "^4.4.0", "vite": "^4.4.7",
"sveltekit-adapter-deno": "^0.10.2" "sveltekit-adapter-deno": "^0.10.2"
}, },
"type": "module", "type": "module",

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />

View File

@ -37,7 +37,9 @@ export async function isLoggedIn(cookies: Cookies) {
// Check that login is valid // Check that login is valid
await getLoggedInUser(cookies); await getLoggedInUser(cookies);
return true; return true;
} catch (e) {} } catch (e) {
// do nothing, we'll just return false below
}
} }
return false; return false;

View File

@ -1,4 +1,3 @@
import type { Cookies } from '@sveltejs/kit';
import type { PaginatedWithCursor, TimePaginationQuery } from './pagination'; import type { PaginatedWithCursor, TimePaginationQuery } from './pagination';
import type { Post } from './posts'; import type { Post } from './posts';
import { callJSON, withQuery } from './request'; import { callJSON, withQuery } from './request';

View File

@ -5,7 +5,10 @@ import { passthroughSession } from './cookies';
export class APIError extends Error { export class APIError extends Error {
readonly code?: string; readonly code?: string;
constructor(readonly response: Response, body?: { code: string; message: string }) { constructor(
readonly response: Response,
body?: { code: string; message: string }
) {
super(body?.message ?? response.statusText); super(body?.message ?? response.statusText);
this.code = body?.code; this.code = body?.code;
Object.setPrototypeOf(this, APIError.prototype); Object.setPrototypeOf(this, APIError.prototype);
@ -23,7 +26,7 @@ export function asQueryParams<T extends QuerySerializable>(obj: T) {
const params = new URLSearchParams(); const params = new URLSearchParams();
for (const key of Object.getOwnPropertyNames(obj)) { for (const key of Object.getOwnPropertyNames(obj)) {
const value = obj[key]; const value = obj[key];
if (value === null || value === undefined || typeof value === 'undefined') continue; if (value == null || typeof value === 'undefined') continue;
params.append(key, value.toString()); params.append(key, value.toString());
} }
return params; return params;

View File

@ -1,4 +1,3 @@
import { PUBLIC_API_BASE } from '$env/static/public';
import { redirect } from '@sveltejs/kit'; import { redirect } from '@sveltejs/kit';
import type { Actions, PageServerLoad } from './$types'; import type { Actions, PageServerLoad } from './$types';
import { APIError } from '$lib/api/request'; import { APIError } from '$lib/api/request';
@ -9,13 +8,13 @@ export const load = async function ({ url, cookies }) {
// Check that login is valid // Check that login is valid
if (session) { if (session) {
let user = null;
try { try {
user = await getLoggedInUser(cookies); const user = await getLoggedInUser(cookies);
} catch (e) {} if (user) {
throw redirect(302, url.searchParams.get('then') || '/admin');
if (user) { }
throw redirect(302, url.searchParams.get('then') || '/admin'); } catch (e) {
// do nothing if not logged in
} }
} }
} satisfies PageServerLoad; } satisfies PageServerLoad;