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",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"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",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.20.4",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte": "^2.30.0",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"svelte": "^4.0.0",
"svelte-check": "^3.4.3",
"tslib": "^2.4.1",
"@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/kit": "^1.22.3",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-svelte": "^2.32.4",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.3",
"svelte": "^4.1.1",
"svelte-check": "^3.4.6",
"tslib": "^2.6.1",
"typescript": "^5.1.6",
"vite": "^4.4.0",
"vite": "^4.4.7",
"sveltekit-adapter-deno": "^0.10.2"
},
"type": "module",

View File

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

View File

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

View File

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

View File

@ -5,7 +5,10 @@ import { passthroughSession } from './cookies';
export class APIError extends Error {
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);
this.code = body?.code;
Object.setPrototypeOf(this, APIError.prototype);
@ -23,7 +26,7 @@ export function asQueryParams<T extends QuerySerializable>(obj: T) {
const params = new URLSearchParams();
for (const key of Object.getOwnPropertyNames(obj)) {
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());
}
return params;

View File

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