Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 6d0c35b

Browse files
committed
chore: add strict compiler options
1 parent fe4ace5 commit 6d0c35b

File tree

14 files changed

+78
-45
lines changed

14 files changed

+78
-45
lines changed

deno.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

deno.jsonc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"tasks": {
3+
// Format
4+
"format": "deno fmt modules/",
5+
"format:check": "deno fmt --check modules/",
6+
7+
// Check
8+
"check": "deno check modules/**/*.ts",
9+
10+
// Lint
11+
"lint": "deno lint modules/",
12+
"lint:fix": "deno lint --fix modules/"
13+
},
14+
"lint": {
15+
"include": ["src/"],
16+
"exclude": ["tests/"],
17+
"rules": {
18+
"exclude": ["no-empty-interface", "no-explicit-any", "require-await"]
19+
}
20+
},
21+
"fmt": {
22+
"useTabs": true
23+
},
24+
"compilerOptions": {
25+
"strict": true,
26+
"noImplicitAny": true,
27+
"strictNullChecks": true,
28+
"strictFunctionTypes": true,
29+
"strictBindCallApply": true,
30+
"strictPropertyInitialization": true,
31+
"noImplicitThis": true,
32+
"useUnknownInCatchVariables": true,
33+
"alwaysStrict": true,
34+
// "noUnusedLocals": true,
35+
// "noUnusedParameters": true,
36+
// "exactOptionalPropertyTypes": true,
37+
"noImplicitReturns": true,
38+
"noFallthroughCasesInSwitch": true,
39+
"noUncheckedIndexedAccess": true,
40+
"noImplicitOverride": true,
41+
// "noPropertyAccessFromIndexSignature": true,
42+
"allowUnusedLabels": true,
43+
"allowUnreachableCode": true,
44+
"noImplicitAny": true
45+
}
46+
}

modules/email/config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ export interface Config {
44

55
export type Provider = { test: ProviderTest } | { sendGrid: ProviderSendGrid };
66

7-
export interface ProviderTest {
8-
// No configuration
9-
}
7+
export type ProviderTest = Record<never, never>;
108

119
export interface ProviderSendGrid {
1210
apiKeyVariable?: string;

modules/email/scripts/send_email.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export interface Request {
1414
text?: string;
1515
}
1616

17-
export interface Response {
18-
}
17+
export type Response = Record<never, never>;
1918

2019
export async function run(
2120
ctx: ScriptContext,

modules/friends/scripts/accept_request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function run(
5757
}
5858

5959
// Sort the user IDs to ensure consistency
60-
const [userIdA, userIdB] = [
60+
const userIds = [
6161
friendRequest.senderUserId,
6262
friendRequest.targetUserId,
6363
].sort();
@@ -70,7 +70,7 @@ export async function run(
7070
data: {
7171
acceptedAt: new Date(),
7272
friend: {
73-
create: { userIdA, userIdB },
73+
create: { userIdA: userIds[0]!, userIdB: userIds[1]! },
7474
},
7575
},
7676
});

modules/friends/scripts/remove_friend.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export async function run(
1818
});
1919

2020
// Sort the user IDs to ensure consistency
21-
const [userIdA, userIdB] = [userId, req.targetUserId].sort();
21+
const userIds = [userId, req.targetUserId].sort();
2222

2323
const updated = await ctx.db.friend.update({
2424
where: {
25-
userIdA_userIdB: { userIdA, userIdB },
25+
userIdA_userIdB: { userIdA: userIds[0]!, userIdB: userIds[1]! },
2626
removedAt: null,
2727
},
2828
data: {
@@ -31,7 +31,9 @@ export async function run(
3131
select: { userIdA: true, userIdB: true },
3232
});
3333
if (!updated) {
34-
throw new RuntimeError("FRIEND_NOT_FOUND", { meta: { userIdA, userIdB } });
34+
throw new RuntimeError("FRIEND_NOT_FOUND", {
35+
meta: { userIdA: userIds[0], userIdB: userIds[1] },
36+
});
3537
}
3638

3739
return {};

modules/tokens/scripts/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function generateToken(type: string): string {
5252
// Map to characters
5353
let output = "";
5454
for (let i = 0; i < buf.length; i++) {
55-
output += CHARACTERS[buf[i] % CHARACTERS.length];
55+
output += CHARACTERS[buf[i]! % CHARACTERS.length];
5656
}
5757

5858
return `${type}_${output}`;

modules/tokens/scripts/revoke.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Prisma, ScriptContext } from "../module.gen.ts";
1+
import { ScriptContext } from "../module.gen.ts";
22

33
export interface Request {
44
tokenIds: string[];

modules/tokens/tests/e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test("e2e", async (ctx: TestContext) => {
3535
const getAfterRevoke = await ctx.modules.tokens.fetch({
3636
tokenIds: [token.id],
3737
});
38-
assertExists(getAfterRevoke.tokens[0].revokedAt);
38+
assertExists(getAfterRevoke.tokens[0]!.revokedAt);
3939

4040
const revokeTwiceRes = await ctx.modules.tokens.revoke({
4141
tokenIds: [token.id],

modules/uploads/tests/e2e.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test("e2e", async (ctx: TestContext) => {
3434

3535
// Upload the data using the presigned URL(s) returned
3636
const uploadPutReq = await fetch(
37-
presigned.files[0].presignedChunks[0].url,
37+
presigned.files[0]!.presignedChunks[0]!.url,
3838
{
3939
method: "PUT",
4040
body: fileData,
@@ -77,10 +77,11 @@ test("e2e", async (ctx: TestContext) => {
7777
assertEquals(completed, retrieved);
7878

7979
// Get presigned URLs to download the files from
80-
const { files: [{ url: fileDownloadUrl }] } = await ctx.modules.uploads
80+
const { files } = await ctx.modules.uploads
8181
.getPublicFileUrls({
8282
files: [{ uploadId: completed.id, path: path }],
8383
});
84+
const fileDownloadUrl = files[0]!.url;
8485

8586
// Download the files, and make sure the data matches
8687
const fileDownloadReq = await fetch(fileDownloadUrl);

0 commit comments

Comments
 (0)