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", dir: process.cwd() + "/server/api",
}) })
console.log("[+] Starting FediProject...");
Bun.serve({ Bun.serve({
port: 8080, port: 8653,
hostname: "0.0.0.0", // defaults to "0.0.0.0" hostname: "0.0.0.0", // defaults to "0.0.0.0"
async fetch(req) { async fetch(req) {
const url = new URL(req.url);
const matchedRoute = router.match(req); const matchedRoute = router.match(req);
if (matchedRoute) { 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 { } else {
const response = new Response(undefined, { return new Response(undefined, {
status: 404, status: 404,
statusText: "Route not found", statusText: "Route not found",
}); });
} }
}, },
}); });
console.log("[+] FediProject started!")

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
export type PollOption = { export interface PollOption {
title: string; title: string;
votes_count: number | null; 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:visibility": "public" | "unlisted" | "private" | "direct";
"posting:default:sensitive": boolean; "posting:default:sensitive": boolean;
"posting:default:language": string | null; "posting:default:language": string | null;
"reading:expand:media": "default" | "show_all" | "hide_all"; "reading:expand:media": "default" | "show_all" | "hide_all";
"reading:expand:spoilers": boolean; "reading:expand:spoilers": boolean;
}; }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
import data from "../config/config.toml"; import data from "../config/config.toml";
export type ConfigType = { export interface ConfigType {
database: { database: {
host: string; host: string;
port: number; port: number;
@ -8,7 +8,7 @@ export type ConfigType = {
password: string; password: string;
database: string; database: string;
} }
[ key: string ]: any; [ key: string ]: unknown;
} }
export const getConfig = () => { 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), { return new Response(JSON.stringify(data), {
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"