Fix ESLint

This commit is contained in:
Jesse Wierzbinski 2023-09-10 17:46:20 -10:00
parent 436a79d99f
commit 636f2ffff8
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
44 changed files with 171 additions and 161 deletions

14
.eslintrc.cjs Normal file
View file

@ -0,0 +1,14 @@
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
},
ignorePatterns: ["node_modules/", "dist/", ".eslintrc.cjs"],
plugins: ["@typescript-eslint"],
root: true,
};

View file

@ -1,7 +0,0 @@
module.exports = {
extends: [
"eslint:strict",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic",
],
};

BIN
bun.lockb

Binary file not shown.

View file

@ -3,21 +3,24 @@ const router = new Bun.FileSystemRouter({
dir: process.cwd() + "/server/api",
})
console.log("[+] Starting FediProject...");
Bun.serve({
port: 8080,
port: 8653,
hostname: "0.0.0.0", // defaults to "0.0.0.0"
async fetch(req) {
const url = new URL(req.url);
const matchedRoute = router.match(req);
if (matchedRoute) {
return (await import(matchedRoute.filePath)).default(req, matchedRoute);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
return (await import(matchedRoute.filePath)).default(req, matchedRoute) as Response | Promise<Response>;
} else {
const response = new Response(undefined, {
return new Response(undefined, {
status: 404,
statusText: "Route not found",
});
}
},
});
console.log("[+] FediProject started!")

View file

@ -4,8 +4,10 @@
"type": "module",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"bun-types": "latest",
"eslint": "^8.49.0"
"eslint": "^8.49.0",
"typescript": "^5.2.2"
},
"peerDependencies": {
"typescript": "^5.0.0"

View file

@ -3,7 +3,7 @@ import { Field } from "./field";
import { Role } from "./role";
import { Source } from "./source";
export type Account = {
export interface Account {
id: string;
username: string;
acct: string;
@ -24,11 +24,11 @@ export type Account = {
avatar_static: string;
header: string;
header_static: string;
emojis: Array<Emoji>;
emojis: Emoji[];
moved: Account | null;
fields: Array<Field>;
fields: Field[];
bot: boolean;
source?: Source;
role?: Role;
mute_expires_at?: string;
};
}

View file

@ -1,6 +1,6 @@
export type Activity = {
export interface Activity {
week: string;
statuses: string;
logins: string;
registrations: string;
};
}

View file

@ -1,7 +1,7 @@
import { Emoji } from "./emoji";
import { StatusTag } from "./status";
export type Announcement = {
export interface Announcement {
id: string;
content: string;
starts_at: string | null;
@ -11,29 +11,29 @@ export type Announcement = {
published_at: string;
updated_at: string;
read: boolean | null;
mentions: Array<AnnouncementAccount>;
statuses: Array<AnnouncementStatus>;
tags: Array<StatusTag>;
emojis: Array<Emoji>;
reactions: Array<AnnouncementReaction>;
};
mentions: AnnouncementAccount[];
statuses: AnnouncementStatus[];
tags: StatusTag[];
emojis: Emoji[];
reactions: AnnouncementReaction[];
}
export type AnnouncementAccount = {
export interface AnnouncementAccount {
id: string;
username: string;
url: string;
acct: string;
};
}
export type AnnouncementStatus = {
export interface AnnouncementStatus {
id: string;
url: string;
};
}
export type AnnouncementReaction = {
export interface AnnouncementReaction {
name: string;
count: number;
me: boolean | null;
url: string | null;
static_url: string | null;
};
}

View file

@ -1,5 +1,5 @@
export type Application = {
export interface Application {
name: string;
website?: string | null;
vapid_key?: string | null;
};
}

View file

@ -1,6 +1,6 @@
import { Meta } from "./attachment";
export type AsyncAttachment = {
export interface AsyncAttachment {
id: string;
type: "unknown" | "image" | "gifv" | "video" | "audio";
url: string | null;
@ -10,4 +10,4 @@ export type AsyncAttachment = {
meta: Meta | null;
description: string | null;
blurhash: string | null;
};
}

View file

@ -1,4 +1,4 @@
export type Sub = {
export interface Sub {
// For Image, Gifv, and Video
width?: number;
height?: number;
@ -11,14 +11,14 @@ export type Sub = {
// For Audio, Gifv, and Video
duration?: number;
bitrate?: number;
};
}
export type Focus = {
export interface Focus {
x: number;
y: number;
};
}
export type Meta = {
export interface Meta {
original?: Sub;
small?: Sub;
focus?: Focus;
@ -32,9 +32,9 @@ export type Meta = {
audio_encode?: string;
audio_bitrate?: string;
audio_channel?: string;
};
}
export type Attachment = {
export interface Attachment {
id: string;
type: "unknown" | "image" | "gifv" | "video" | "audio";
url: string;
@ -44,4 +44,4 @@ export type Attachment = {
meta: Meta | null;
description: string | null;
blurhash: string | null;
};
}

View file

@ -1,4 +1,4 @@
export type Card = {
export interface Card {
url: string;
title: string;
description: string;
@ -13,4 +13,4 @@ export type Card = {
height: number;
embed_url: string;
blurhash: string | null;
};
}

View file

@ -1,6 +1,6 @@
import { Status } from "./status";
export type Context = {
ancestors: Array<Status>;
descendants: Array<Status>;
};
export interface Context {
ancestors: Status[];
descendants: Status[];
}

View file

@ -1,9 +1,9 @@
import { Account } from "./account";
import { Status } from "./status";
export type Conversation = {
export interface Conversation {
id: string;
accounts: Array<Account>;
accounts: Account[];
last_status: Status | null;
unread: boolean;
};
}

View file

@ -1,7 +1,7 @@
export type Emoji = {
export interface Emoji {
shortcode: string;
static_url: string;
url: string;
visible_in_picker: boolean;
category?: string;
};
}

View file

@ -1,6 +1,6 @@
export type FeaturedTag = {
export interface FeaturedTag {
id: string;
name: string;
statuses_count: number;
last_status_at: string;
};
}

View file

@ -1,5 +1,5 @@
export type Field = {
export interface Field {
name: string;
value: string;
verified_at: string | null;
};
}

View file

@ -1,10 +1,10 @@
export type Filter = {
export interface Filter {
id: string;
phrase: string;
context: Array<FilterContext>;
context: FilterContext[];
expires_at: string | null;
irreversible: boolean;
whole_word: boolean;
};
}
export type FilterContext = string;

View file

@ -1,5 +1,5 @@
export type History = {
export interface History {
day: string;
uses: number;
accounts: number;
};
}

View file

@ -1,7 +1,7 @@
export type IdentityProof = {
export interface IdentityProof {
provider: string;
provider_username: string;
updated_at: string;
proof_url: string;
profile_url: string;
};
}

View file

@ -2,7 +2,7 @@ import { Account } from "./account";
import { Stats } from "./stats";
import { URLs } from "./urls";
export type Instance = {
export interface Instance {
uri: string;
title: string;
description: string;
@ -11,7 +11,7 @@ export type Instance = {
thumbnail: string | null;
urls: URLs;
stats: Stats;
languages: Array<string>;
languages: string[];
registrations: boolean;
approval_required: boolean;
invites_enabled: boolean;
@ -23,7 +23,7 @@ export type Instance = {
characters_reserved_per_url: number;
};
media_attachments: {
supported_mime_types: Array<string>;
supported_mime_types: string[];
image_size_limit: number;
image_matrix_limit: number;
video_size_limit: number;
@ -38,10 +38,10 @@ export type Instance = {
};
};
contact_account: Account;
rules: Array<InstanceRule>;
};
rules: InstanceRule[];
}
export type InstanceRule = {
export interface InstanceRule {
id: string;
text: string;
};
}

View file

@ -1,7 +1,7 @@
export type List = {
export interface List {
id: string;
title: string;
replies_policy: RepliesPolicy;
};
}
export type RepliesPolicy = "followed" | "list" | "none";

View file

@ -1,4 +1,4 @@
export type Marker = {
export interface Marker {
home: {
last_read_id: string;
version: number;
@ -9,4 +9,4 @@ export type Marker = {
version: number;
updated_at: string;
};
};
}

View file

@ -1,6 +1,6 @@
export type Mention = {
export interface Mention {
id: string;
username: string;
url: string;
acct: string;
};
}

View file

@ -1,14 +1,12 @@
import { Account } from "./account"
import { Status } from "./status"
import { Account } from "./account";
import { Status } from "./status";
namespace MastodonEntity {
export type Notification = {
account: Account
created_at: string
id: string
status?: Status
type: NotificationType
export interface Notification {
account: Account;
created_at: string;
id: string;
status?: Status;
type: NotificationType;
}
export type NotificationType = string
}
export type NotificationType = string;

View file

@ -1,11 +1,11 @@
import { PollOption } from "./poll_option";
export type Poll = {
export interface Poll {
id: string;
expires_at: string | null;
expired: boolean;
multiple: boolean;
votes_count: number;
options: Array<PollOption>;
options: PollOption[];
voted: boolean;
};
}

View file

@ -1,4 +1,4 @@
export type PollOption = {
export interface PollOption {
title: string;
votes_count: number | null;
};
}

View file

@ -1,7 +1,7 @@
export type Preferences = {
export interface Preferences {
"posting:default:visibility": "public" | "unlisted" | "private" | "direct";
"posting:default:sensitive": boolean;
"posting:default:language": string | null;
"reading:expand:media": "default" | "show_all" | "hide_all";
"reading:expand:spoilers": boolean;
};
}

View file

@ -1,14 +1,14 @@
export type Alerts = {
export interface Alerts {
follow: boolean;
favourite: boolean;
mention: boolean;
reblog: boolean;
poll: boolean;
};
}
export type PushSubscription = {
export interface PushSubscription {
id: string;
endpoint: string;
server_key: string;
alerts: Alerts;
};
}

View file

@ -1,4 +1,4 @@
export type Relationship = {
export interface Relationship {
id: string;
following: boolean;
followed_by: boolean;
@ -12,5 +12,5 @@ export type Relationship = {
endorsed: boolean;
notifying: boolean;
note: string;
languages: Array<string>;
};
languages: string[];
}

View file

@ -1,15 +1,15 @@
import { Account } from "./account";
export type Report = {
export interface Report {
id: string;
action_taken: boolean;
action_taken_at: string | null;
category: Category;
comment: string;
forwarded: boolean;
status_ids: Array<string> | null;
rule_ids: Array<string> | null;
status_ids: string[] | null;
rule_ids: string[] | null;
target_account: Account;
};
}
export type Category = "spam" | "violation" | "other";

View file

@ -2,8 +2,8 @@ import { Account } from "./account";
import { Status } from "./status";
import { Tag } from "./tag";
export type Results = {
accounts: Array<Account>;
statuses: Array<Status>;
hashtags: Array<Tag>;
};
export interface Results {
accounts: Account[];
statuses: Status[];
hashtags: Tag[];
}

View file

@ -1,3 +1,3 @@
export type Role = {
export interface Role {
name: string;
};
}

View file

@ -1,9 +1,9 @@
import { Attachment } from "./attachment";
import { StatusParams } from "./status_params";
export type ScheduledStatus = {
export interface ScheduledStatus {
id: string;
scheduled_at: string;
params: StatusParams;
media_attachments: Array<Attachment>;
};
media_attachments: Attachment[];
}

View file

@ -1,9 +1,9 @@
import { Field } from "./field";
export type Source = {
export interface Source {
privacy: string | null;
sensitive: boolean | null;
language: string | null;
note: string;
fields: Array<Field>;
};
fields: Field[];
}

View file

@ -1,5 +1,5 @@
export type Stats = {
export interface Stats {
user_count: number;
status_count: number;
domain_count: number;
};
}

View file

@ -6,7 +6,7 @@ import { Emoji } from "./emoji";
import { Mention } from "./mention";
import { Poll } from "./poll";
export type Status = {
export interface Status {
id: string;
uri: string;
url: string;
@ -26,9 +26,9 @@ export type Status = {
sensitive: boolean;
spoiler_text: string;
visibility: "public" | "unlisted" | "private" | "direct";
media_attachments: Array<Attachment>;
mentions: Array<Mention>;
tags: Array<StatusTag>;
media_attachments: Attachment[];
mentions: Mention[];
tags: StatusTag[];
card: Card | null;
poll: Poll | null;
application: Application | null;
@ -38,9 +38,9 @@ export type Status = {
// These parameters are unique parameters in fedibird.com for quote.
quote_id?: string;
quote?: Status | null;
};
}
export type StatusTag = {
export interface StatusTag {
name: string;
url: string;
};
}

View file

@ -1,10 +1,10 @@
export type StatusParams = {
export interface StatusParams {
text: string;
in_reply_to_id: string | null;
media_ids: Array<string> | null;
media_ids: string[] | null;
sensitive: boolean | null;
spoiler_text: string | null;
visibility: "public" | "unlisted" | "private" | "direct" | null;
scheduled_at: string | null;
application_id: number;
};
}

View file

@ -1,5 +1,5 @@
export type StatusSource = {
export interface StatusSource {
id: string;
text: string;
spoiler_text: string;
};
}

View file

@ -1,8 +1,8 @@
import { History } from "./history";
export type Tag = {
export interface Tag {
name: string;
url: string;
history: Array<History>;
history: History[];
following?: boolean;
};
}

View file

@ -1,6 +1,6 @@
export type Token = {
export interface Token {
access_token: string;
token_type: string;
scope: string;
created_at: number;
};
}

View file

@ -1,3 +1,3 @@
export type URLs = {
export interface URLs {
streaming_api: string;
};
}

View file

@ -1,6 +1,6 @@
import data from "../config/config.toml";
export type ConfigType = {
export interface ConfigType {
database: {
host: string;
port: number;
@ -8,7 +8,7 @@ export type ConfigType = {
password: string;
database: string;
}
[ key: string ]: any;
[ key: string ]: unknown;
}
export const getConfig = () => {

View file

@ -1,4 +1,4 @@
export const jsonResponse = (data: object, status: number = 200) => {
export const jsonResponse = (data: object, status = 200) => {
return new Response(JSON.stringify(data), {
headers: {
"Content-Type": "application/json"