refactor: 🚨 Turn every linter rule on and fix issues (there were a LOT :3)

This commit is contained in:
Jesse Wierzbinski 2024-06-12 16:26:43 -10:00
parent 2e98859153
commit a1e02d0d78
No known key found for this signature in database
177 changed files with 1826 additions and 1248 deletions

View file

@ -4,7 +4,9 @@ import { lookup } from "mime-types";
export const getBestContentType = (
content?: typeof EntityValidator.$ContentFormat,
) => {
if (!content) return { content: "", format: "text/plain" };
if (!content) {
return { content: "", format: "text/plain" };
}
const bestFormatsRanked = [
"text/x.misskeymarkdown",
@ -14,8 +16,9 @@ export const getBestContentType = (
];
for (const format of bestFormatsRanked) {
if (content[format])
if (content[format]) {
return { content: content[format].content, format };
}
}
return { content: "", format: "text/plain" };
@ -24,7 +27,9 @@ export const getBestContentType = (
export const urlToContentFormat = (
url?: string,
): typeof EntityValidator.$ContentFormat | null => {
if (!url) return null;
if (!url) {
return null;
}
if (url.startsWith("https://api.dicebear.com/")) {
return {
"image/svg+xml": {
@ -46,7 +51,9 @@ export const urlToContentFormat = (
export const mimeLookup = async (url: string) => {
const naiveLookup = lookup(url.replace(new URL(url).search, ""));
if (naiveLookup) return naiveLookup;
if (naiveLookup) {
return naiveLookup;
}
const fetchLookup = fetch(url, { method: "HEAD" }).then(
(response) => response.headers.get("content-type") || "",