Rework how the linting is done

This commit is contained in:
Taevas 2025-02-16 17:05:02 +01:00
parent 51091d6d59
commit 96911a8d95
30 changed files with 111 additions and 108 deletions

View file

@ -6,7 +6,6 @@ const handler: Handler = async () => {
method: "POST",
headers: {
"Content-Type": "application/json",
// eslint-disable-next-line @typescript-eslint/naming-convention
"Accept": "application/json",
},
body: JSON.stringify({

View file

@ -7,12 +7,10 @@ const handler: Handler = async () => {
headers: {
"PRIVATE-TOKEN": process.env.API_GITLAB!,
"Content-Type": "application/json",
// eslint-disable-next-line @typescript-eslint/naming-convention
"Accept": "application/json",
},
});
// eslint-disable-next-line @typescript-eslint/naming-convention
const {created_at} = (await gitlab.json() as Record<string, any>)[0];
if (typeof created_at !== "string") {
return {

View file

@ -31,7 +31,7 @@ const handler: Handler = async () => {
emojis: details.user.emojis,
text: details.text,
date: details.createdAt
}
};
return {
statusCode: 200,

View file

@ -5,14 +5,14 @@ import {type LastfmInfo} from "../../src/components/Info/Music/Lastfm.js";
const handler: Handler = async () => {
const lastfm = await api<{
recenttracks: {
track: Array<{
track: {
artist: {
"#text": string;
};
image: Array<{
image: {
size: string;
"#text": string;
}>;
}[];
album: {
"#text": string;
};
@ -25,7 +25,7 @@ const handler: Handler = async () => {
uts: string;
"#text": string;
};
}>;
}[];
};
}>(`http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=TTTaevas&api_key=${process.env.API_LASTFM}&format=json&limit=1`);
const image = lastfm.recenttracks.track[0].image.find((i) => i.size == "large");

View file

@ -13,7 +13,6 @@ const handler: Handler = async () => {
const token = await collection.findOne();
void client.close();
// eslint-disable-next-line @typescript-eslint/naming-convention
const api = new osu.API({access_token: token?.access_token});
const profile = await api.getUser(7276846, osu.Ruleset.fruits);

View file

@ -13,7 +13,6 @@ const handler: Handler = async () => {
const token = await collection.findOne();
void client.close();
// eslint-disable-next-line @typescript-eslint/naming-convention
const api = new osu.API({access_token: token?.access_token});
const profile = await api.getUser(7276846, osu.Ruleset.mania);

View file

@ -13,7 +13,6 @@ const handler: Handler = async () => {
const token = await collection.findOne();
void client.close();
// eslint-disable-next-line @typescript-eslint/naming-convention
const api = new osu.API({access_token: token?.access_token});
const profile = await api.getUser(7276846, osu.Ruleset.osu);

View file

@ -13,7 +13,6 @@ const handler: Handler = async () => {
const token = await collection.findOne();
void client.close();
// eslint-disable-next-line @typescript-eslint/naming-convention
const api = new osu.API({access_token: token?.access_token});
const profile = await api.getUser(7276846, osu.Ruleset.taiko);

View file

@ -1,12 +1,13 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint no-async-promise-executor: 0 */ // Doing promises is needed in order to make multiple requests at once, lowering wait time
import {type Handler} from "@netlify/functions";
import {API} from "osu-api-v2-js";
import {MongoClient} from "mongodb";
export type Token = {
export interface Token {
access_token: API["access_token"];
expires: API["expires"];
};
}
const handler: Handler = async () => {
const client = new MongoClient(process.env.URL_MONGODB!);
@ -20,7 +21,7 @@ const handler: Handler = async () => {
const token = tokens.find((t) => t.expires > now);
const expiredTokens = tokens.filter((t) => now > t.expires);
const promises: Array<Promise<void>> = [];
const promises: Promise<void>[] = [];
if (!token) {
promises.push(new Promise(async (resolve) => {

View file

@ -1,5 +1,5 @@
export async function api<T>(url: string, restful_token?: string): Promise<T> {
// eslint-disable-next-line @typescript-eslint/naming-convention
return (restful_token ? fetch(url, {headers: {"Authorization": `Bearer ${restful_token}`}}) : fetch(url))
.then(async response => {
if (!response.ok) {

View file

@ -5,7 +5,7 @@ import {type SpeedruncomInfo} from "../../src/components/Info/Speedrunning/Speed
const handler: Handler = async () => {
// using the API's embedding would be stupid here, as that'd create lag due to irrelevant runs
const speedruncom = await api<{
data: Array<{
data: {
place: number;
run: {
weblink: string;
@ -14,7 +14,7 @@ const handler: Handler = async () => {
category: string | undefined;
date: string;
};
}>;
}[];
}>("https://www.speedrun.com/api/v1/users/j03v45mj/personal-bests");
const detailsToRequest = [new Promise((resolve) => {

View file

@ -2,30 +2,30 @@ import {type Handler} from "@netlify/functions";
import {api} from "./shared/api.js";
import {type WanikaniInfo} from "../../src/components/Info/Japanese/Wanikani.js";
type Subject = {
interface Subject {
id: number;
object: string;
data: {
characters: string;
slug: string;
document_url: string;
meanings: Array<{
meanings: {
meaning: string;
}>;
}[];
};
};
}
type StuffToLearn = {
interface StuffToLearn {
available_at: string;
type: string;
writing: string;
meanings: Array<{
meanings: {
meaning: string;
}>;
}[];
url: string;
};
}
function addStuffToLearn(ids: number[], data: Array<{available_at: string; subject_ids: number[]}>, subjects: Subject[]): StuffToLearn[] {
function addStuffToLearn(ids: number[], data: {available_at: string; subject_ids: number[]}[], subjects: Subject[]): StuffToLearn[] {
const arr: StuffToLearn[] = [];
for (const id of ids) {
@ -37,7 +37,6 @@ function addStuffToLearn(ids: number[], data: Array<{available_at: string; subje
}
arr.push({
// eslint-disable-next-line @typescript-eslint/naming-convention
available_at: summaryData.available_at,
type: subject.object,
writing: subject.data.characters || subject.data.slug || subject.data.meanings[0].meaning,
@ -64,14 +63,14 @@ const handler: Handler = async () => {
const progression: {
total_count: number;
data: Array<{
data: {
data: {
level: number;
unlocked_at: undefined | string;
completed_at: undefined | string;
abandoned_at: undefined | string;
};
}>;
}[];
} = data[0];
const resets: {
@ -86,14 +85,14 @@ const handler: Handler = async () => {
const summary: {
data: {
lessons: Array<{
lessons: {
available_at: string;
subject_ids: number[];
}>;
reviews: Array<{
}[];
reviews: {
available_at: string;
subject_ids: number[];
}>;
}[];
next_reviews_at: undefined | string;
};
} = data[2];
@ -113,14 +112,15 @@ const handler: Handler = async () => {
}
const now = new Date();
// next_reviews checks what reviews will be available in the next 23 hours
// summary.data.next_reviews_at checks beyond that, but will be the current time if a review is already available
// next_reviews | Checks what reviews will be available in the next 23 hours
// summary.data.next_reviews_at | Checks beyond that, but will be the current time if a review is already available
const nextReviews = summary.data.reviews
.map((r: {subject_ids: number[]; available_at: Date | string}) => {
r.available_at = new Date(r.available_at); return r;
})
.filter((r) => r.available_at > now && r.subject_ids.length) as Array<{subject_ids: number[]; available_at: Date}>;
const moreThingsToReviewAt = nextReviews[0] ? nextReviews[0].available_at.toISOString() : summary.data.next_reviews_at ? summary.data.next_reviews_at : undefined;
.filter((r) => r.available_at > now && r.subject_ids.length) as {subject_ids: number[]; available_at: Date}[];
const moreThingsToReviewAt = nextReviews.at(0)?.available_at.toISOString() ?? summary.data.next_reviews_at;
const subjectIdsAll = subjectIdsLessons.concat(subjectIdsReviews);
const subjects = await api<{data: Subject[]}>(`https://api.wanikani.com/v2/subjects?ids=${subjectIdsAll.toString()}`, process.env.API_WANIKANI);