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:
Sebastian Martinez
2024-05-27 17:35:16 +02:00
parent ffd49e82ee
commit 0c7ea70c1b
22 changed files with 370 additions and 276 deletions
+1 -3
View File
@@ -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][];
+2
View File
@@ -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 {
+1
View File
@@ -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;
+1
View File
@@ -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[];
+1
View File
@@ -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[];
+12
View File
@@ -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.",
},
};
}
+14 -6
View File
@@ -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();
}
}
}