mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Update eslint config to flat config
Since the legacy config is being deprecated at the end of 2024, we should start moving to the eslint flat config. I avoided the tseslint config helper function so we avoid wrapping magic. This seems to have triggered more checking since any checks in svelte files have appeared and the $$Generic type that is being deprecated had to be rewritten. Also fixes some any types that weren't caught previously
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
<script lang="ts">
|
||||
type T = $$Generic;
|
||||
|
||||
<script lang="ts" generics="T">
|
||||
export let items: T[];
|
||||
export let styleDropdownMinWidth: string | undefined = undefined;
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import debounce from "lodash/debounce";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
export let onShow: () => void = () => {};
|
||||
export let stylePopoverPositionLeft: string | undefined = undefined;
|
||||
export let stylePopoverPositionRight: string | undefined = undefined;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script lang="ts">
|
||||
type T = $$Generic;
|
||||
|
||||
<script lang="ts" generics="T">
|
||||
export let items: T[];
|
||||
</script>
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
export let breaks: boolean = false;
|
||||
|
||||
let container: HTMLElement;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let frontMatter: [string, any][] | undefined = undefined;
|
||||
|
||||
$: {
|
||||
|
||||
+6
-4
@@ -286,10 +286,12 @@ export function twemoji(
|
||||
{ exclude }: { exclude: string[] } = { exclude: [] },
|
||||
) {
|
||||
twemojiModule.parse(node, {
|
||||
callback: (icon, options: Record<string, any>) => {
|
||||
return exclude.includes(icon)
|
||||
? false
|
||||
: "".concat(options.base, options.size, "/", icon, options.ext);
|
||||
callback: (icon, options) => {
|
||||
const { base, size, ext } = options as Record<string, string>;
|
||||
if (!exclude.includes(icon)) {
|
||||
return `${base}${size}/${icon}${ext}`;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
base: "/",
|
||||
folder: "twemoji",
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { BaseUrl, NodeStats, Policy, Scope } from "@httpd-client";
|
||||
import type { ErrorRoute, NotFoundRoute } from "@app/lib/router/definitions";
|
||||
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import config from "virtual:config";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { ResponseError, ResponseParseError } from "@httpd-client/lib/fetcher";
|
||||
import { baseUrlToString } from "@app/lib/utils";
|
||||
import { handleError } from "@app/views/nodes/error";
|
||||
import { unreachableError } from "@app/views/projects/error";
|
||||
|
||||
export interface NodesRouteParams {
|
||||
baseUrl: BaseUrl;
|
||||
@@ -58,7 +60,15 @@ export async function loadNodeRoute(
|
||||
scope: node.config?.scope,
|
||||
},
|
||||
};
|
||||
} catch (error: any) {
|
||||
return handleError(error, baseUrlToString(api.baseUrl));
|
||||
} catch (error) {
|
||||
if (
|
||||
error instanceof Error ||
|
||||
error instanceof ResponseError ||
|
||||
error instanceof ResponseParseError
|
||||
) {
|
||||
return handleError(error, baseUrlToString(api.baseUrl));
|
||||
} else {
|
||||
return unreachableError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script lang="ts">
|
||||
<script lang="ts" generics="CobState">
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
|
||||
import isEqual from "lodash/isEqual";
|
||||
@@ -11,8 +11,6 @@
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
|
||||
type CobState = $$Generic;
|
||||
|
||||
export let state: CobState;
|
||||
export let selectedItem: [string, CobState];
|
||||
export let items: [string, CobState][];
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
type State = "read" | "submit" | "edit";
|
||||
|
||||
let response: DiffResponse | undefined = undefined;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let error: any | undefined = undefined;
|
||||
let loading: boolean = false;
|
||||
let revisionState: State = "read";
|
||||
@@ -135,6 +136,7 @@
|
||||
try {
|
||||
loading = true;
|
||||
response = await api.project.getDiff(projectId, fromCommit, revisionOid);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (err: any) {
|
||||
error = err;
|
||||
} finally {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
const api = new HttpdClient(baseUrl);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let error: any;
|
||||
let page = 0;
|
||||
let loading = false;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
let loading = false;
|
||||
let page = 0;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let error: any;
|
||||
let allIssues: Issue[];
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
let loading = false;
|
||||
let page = 0;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let error: any;
|
||||
let allPatches: Patch[];
|
||||
|
||||
|
||||
@@ -73,3 +73,15 @@ export function handleError(
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function unreachableError(): NotFoundRoute | ErrorRoute {
|
||||
return {
|
||||
resource: "error",
|
||||
params: {
|
||||
error: undefined,
|
||||
title: "Could not load this route",
|
||||
description:
|
||||
"You stumbled on an unknown error, we aren't exactly sure what happened.",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ import type {
|
||||
import * as Syntax from "@app/lib/syntax";
|
||||
import * as httpd from "@app/lib/httpd";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { ResponseError } from "@httpd-client/lib/fetcher";
|
||||
import { handleError } from "@app/views/projects/error";
|
||||
import { ResponseError, ResponseParseError } from "@httpd-client/lib/fetcher";
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
import { get } from "svelte/store";
|
||||
import { handleError, unreachableError } from "@app/views/projects/error";
|
||||
import { nodePath } from "@app/views/nodes/router";
|
||||
import { unreachable } from "@app/lib/utils";
|
||||
import { get } from "svelte/store";
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
|
||||
export const COMMITS_PER_PAGE = 30;
|
||||
export const PATCHES_PER_PAGE = 10;
|
||||
@@ -315,8 +315,16 @@ export async function loadProjectRoute(
|
||||
} else {
|
||||
return unreachable(route);
|
||||
}
|
||||
} catch (error: any) {
|
||||
return handleError(error, route);
|
||||
} catch (error) {
|
||||
if (
|
||||
error instanceof Error ||
|
||||
error instanceof ResponseError ||
|
||||
error instanceof ResponseParseError
|
||||
) {
|
||||
return handleError(error, route);
|
||||
} else {
|
||||
return unreachableError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user