Add stricter ESLint rules

This commit is contained in:
Jesse Wierzbinski 2023-09-12 14:29:13 -10:00
parent 887128356e
commit e618996936
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
18 changed files with 102 additions and 63 deletions

View file

@ -30,6 +30,6 @@ export class Application extends BaseEntity {
name: "",
website: null,
vapid_key: null,
}
};
}
}
}

View file

@ -25,6 +25,6 @@ export class Emoji extends BaseEntity {
url: "",
visible_in_picker: false,
category: undefined,
}
};
}
}
}

View file

@ -1,4 +1,10 @@
import { BaseEntity, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import {
BaseEntity,
Column,
Entity,
ManyToOne,
PrimaryGeneratedColumn,
} from "typeorm";
import { User } from "./User";
import { Status } from "./Status";
@ -12,12 +18,12 @@ export class Favourite extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
id!: string;
@ManyToOne(() => User, (user) => user.id)
@ManyToOne(() => User, user => user.id)
actor!: User;
@ManyToOne(() => Status, (status) => status.id)
@ManyToOne(() => Status, status => status.id)
object!: Status;
@Column("datetime")
published!: Date;
}
}

View file

@ -1,4 +1,10 @@
import { BaseEntity, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import {
BaseEntity,
Column,
Entity,
ManyToOne,
PrimaryGeneratedColumn,
} from "typeorm";
import { APIInstance } from "~types/entities/instance";
import { User } from "./User";
@ -9,7 +15,7 @@ export class Instance extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
id!: string;
@ManyToOne(() => User, (user) => user.id)
@ManyToOne(() => User, user => user.id)
contact_account!: User;
@Column("jsonb", {
@ -63,4 +69,4 @@ export class Instance extends BaseEntity {
max_toot_chars: 0,
};
}
}
}

View file

@ -1,7 +1,5 @@
import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import {
APObject,
} from "activitypub-types";
import { APObject } from "activitypub-types";
/**
* Stores an ActivityPub object as raw JSON-LD data
@ -15,4 +13,4 @@ export class RawObject extends BaseEntity {
@Column("json")
data!: APObject;
}
}

View file

@ -18,10 +18,10 @@ export class Renote extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
id!: string;
@ManyToOne(() => User, (user) => user.id)
@ManyToOne(() => User, user => user.id)
actor!: User;
@ManyToOne(() => Status, (status) => status.id)
@ManyToOne(() => Status, status => status.id)
object!: Status;
@Column("datetime")

View file

@ -27,7 +27,7 @@ export class Status extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
id!: string;
@ManyToOne(() => User, (user) => user.id)
@ManyToOne(() => User, user => user.id)
account!: User;
@CreateDateColumn()
@ -36,7 +36,7 @@ export class Status extends BaseEntity {
@UpdateDateColumn()
updated_at!: Date;
@ManyToOne(() => Status, (status) => status.id, {
@ManyToOne(() => Status, status => status.id, {
nullable: true,
})
reblog?: Status;
@ -60,31 +60,33 @@ export class Status extends BaseEntity {
})
spoiler_text!: string;
@ManyToOne(() => Application, (app) => app.id, {
nullable: true
@ManyToOne(() => Application, app => app.id, {
nullable: true,
})
application!: Application | null;
@ManyToMany(() => Emoji, (emoji) => emoji.id)
@ManyToMany(() => Emoji, emoji => emoji.id)
emojis!: Emoji[];
async getFavourites(): Promise<Favourite[]> {
return Favourite.find({
where: {
object: {
id: this.id
id: this.id,
},
},
});
}
async toAPI(): Promise<APIStatus> {
return {
account: await this.account.toAPI(),
application: await this.application?.toAPI() ?? null,
application: (await this.application?.toAPI()) ?? null,
bookmarked: false,
created_at: this.created_at.toISOString(),
emojis: await Promise.all(this.emojis.map(async (emoji) => await emoji.toAPI())),
emojis: await Promise.all(
this.emojis.map(async emoji => await emoji.toAPI())
),
favourited: false,
favourites_count: (await this.getFavourites()).length,
id: this.id,
@ -96,7 +98,7 @@ export class Status extends BaseEntity {
muted: false,
pinned: false,
poll: null,
reblog: this.isReblog ? await this.reblog?.toAPI() ?? null : null,
reblog: this.isReblog ? (await this.reblog?.toAPI()) ?? null : null,
reblogged: false,
reblogs_count: 0,
replies_count: 0,

View file

@ -1,5 +1,12 @@
import { getConfig, getHost } from "@config";
import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from "typeorm";
import { APIAccount } from "~types/entities/account";
const config = getConfig();
@ -73,6 +80,6 @@ export class User extends BaseEntity {
discoverable: undefined,
role: undefined,
mute_expires_at: undefined,
}
};
}
}
}