Skip to content

Commit 713be0d

Browse files
committed
enforce function return types
1 parent 7afe7bf commit 713be0d

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed

.eslintrc.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
"no-unused-vars": "off",
1515
"@typescript-eslint/no-unused-vars": "error",
1616
"curly": ["error", "all"],
17-
"eqeqeq": ["error", "always"]
17+
"eqeqeq": ["error", "always"],
18+
"@typescript-eslint/explicit-function-return-type": [
19+
"error",
20+
{
21+
"allowExpressions": true
22+
}
23+
]
1824
},
1925
"plugins": ["prettier"]
2026
}

src/commands/banana/banana-rps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export default {
140140
"BUTTON"
141141
);
142142

143-
async function finishRound() {
143+
async function finishRound(): Promise<void> {
144144
if (round !== 3) {
145145
const roundField = embed.fields[0];
146146

src/events/ready.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ interface GitHubLabel {
6666
name: string;
6767
}
6868

69-
async function fetchLabels(client: Client<true>) {
69+
async function fetchLabels(client: Client<true>): Promise<void> {
7070
console.log("Fetching GitHub labels...");
7171

7272
const response = await fetch(
@@ -89,7 +89,7 @@ async function fetchLabels(client: Client<true>) {
8989
updateIssueCommand(client);
9090
}
9191

92-
async function updateIssueCommand(client: Client<true>) {
92+
async function updateIssueCommand(client: Client<true>): Promise<void> {
9393
console.log("Updating issue command...");
9494

9595
const labels = parseJSON<string[]>(readFileOrCreate("labels.json", "[]"));

src/functions/banana.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function getData(): MonkeyTypes.BananaData {
5656
);
5757
}
5858

59-
function setData(bananaData: MonkeyTypes.BananaData) {
59+
function setData(bananaData: MonkeyTypes.BananaData): void {
6060
fs.writeFileSync("bananas.json", JSON.stringify(bananaData, null, 2));
6161
}
6262

src/functions/mongodb.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/** @format */
22

3-
import { MongoClient } from "mongodb";
3+
import { Db, MongoClient } from "mongodb";
44

55
let mongoClient: MongoClient;
66

7-
export async function connectDB() {
7+
export async function connectDB(): Promise<MongoClient> {
88
const dbURI = process.env["DB_URI"];
99

1010
if (!dbURI) {
@@ -24,6 +24,6 @@ export async function connectDB() {
2424
return mongoClient;
2525
}
2626

27-
export function mongoDB() {
27+
export function mongoDB(): Db {
2828
return mongoClient.db(process.env["DB_NAME"]);
2929
}

src/functions/redis.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Redis from "ioredis";
44

55
let redisClient: Redis;
66

7-
export async function connectRedis() {
7+
export async function connectRedis(): Promise<Redis> {
88
const redisURI = process.env["REDIS_URI"];
99

1010
if (!redisURI) {
@@ -21,6 +21,6 @@ export async function connectRedis() {
2121
return redisClient;
2222
}
2323

24-
export function redis() {
24+
export function redis(): Redis {
2525
return redisClient;
2626
}

src/structures/client.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class Client<T extends boolean> extends Discord.Client<T> {
144144
console.log(`Initialized task worker "${worker.name}"`);
145145
}
146146

147-
public async start(token: string) {
147+
public async start(token: string): Promise<string> {
148148
await this.login(token);
149149

150150
const [commands, events] = await this.load();
@@ -244,7 +244,9 @@ export class Client<T extends boolean> extends Discord.Client<T> {
244244
console.log(`Created slash command "${c.name}" (${c.id})`);
245245
}
246246
} else {
247-
const mapper = (option: Discord.ApplicationCommandOption) => {
247+
const mapper = (
248+
option: Discord.ApplicationCommandOption
249+
): Discord.ApplicationCommandOption => {
248250
type Keys = keyof typeof option;
249251

250252
type Values = typeof option[Keys];
@@ -297,7 +299,10 @@ export class Client<T extends boolean> extends Discord.Client<T> {
297299
return [this.commands.size, events.length];
298300
}
299301

300-
public embed(embedOptions: Discord.MessageEmbedOptions, user?: Discord.User) {
302+
public embed(
303+
embedOptions: Discord.MessageEmbedOptions,
304+
user?: Discord.User
305+
): Discord.MessageEmbed {
301306
// if (!embedOptions.title?.startsWith(this.user?.username ?? "George")) {
302307
// embedOptions.title = `${this.user?.username ?? "George"}: \`${
303308
// embedOptions.title
@@ -323,7 +328,7 @@ export class Client<T extends boolean> extends Discord.Client<T> {
323328
return embed;
324329
}
325330

326-
public async paginate<T>(options: PaginationOptions<T>) {
331+
public async paginate<T>(options: PaginationOptions<T>): Promise<void> {
327332
const {
328333
embedOptions,
329334
interaction,

0 commit comments

Comments
 (0)