Skip to content

Commit bdab43f

Browse files
chore: upgrade to biome v2 (#101)
1 parent 87eb06a commit bdab43f

File tree

11 files changed

+66
-66
lines changed

11 files changed

+66
-66
lines changed

biome.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
33
"files": {
4-
"include": ["src/**/*.ts", "examples/*.js"]
5-
},
6-
"organizeImports": {
7-
"enabled": true
4+
"includes": ["**/src/**/*.ts", "**/examples/**/*.js"]
85
},
6+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
97
"linter": {
108
"enabled": true,
119
"rules": {

examples/express_app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ app.post(
2828
app.post(
2929
'/events',
3030
verifyWebhookEventMiddleware(process.env.CLIENT_PUBLIC_KEY),
31-
(req, res) => {
31+
(req, _res) => {
3232
console.log('📨 Event Received!');
3333
console.log(
3434
util.inspect(req.body, { showHidden: false, colors: true, depth: null }),
@@ -37,7 +37,7 @@ app.post(
3737
);
3838

3939
// Simple health check, to also make it easy to check if the app is up and running
40-
app.get('/health', (req, res) => {
40+
app.get('/health', (_req, res) => {
4141
res.send('ok');
4242
});
4343

package-lock.json

Lines changed: 47 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"discord-interactions": "^4.3.0"
3535
},
3636
"devDependencies": {
37-
"@biomejs/biome": "^1.7.3",
37+
"@biomejs/biome": "^2.2.5",
3838
"@types/express": "^4.17.9",
3939
"@types/jest": "^29.0.0",
4040
"@types/node": "^22.0.0",

src/__tests__/utils/SharedTestUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export async function signRequestWithKeyPair(
7777
body: string,
7878
privateKey: CryptoKey,
7979
) {
80-
const timestamp = String(Math.round(new Date().getTime() / 1000));
80+
const timestamp = String(Math.round(Date.now() / 1000));
8181
const signature = await subtleCrypto.sign(
8282
{
8383
name: 'ed25519',

src/__tests__/verifyKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('verify key method', () => {
128128
const isValid = await verifyKey(
129129
signedRequest.body,
130130
signedRequest.signature,
131-
String(Math.round(new Date().getTime() / 1000) - 10000),
131+
String(Math.round(Date.now() / 1000) - 10000),
132132
validKeyPair.publicKey,
133133
);
134134
expect(isValid).toBe(false);

src/__tests__/verifyKeyMiddleware.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import type * as http from 'node:http';
22
import type { AddressInfo } from 'node:net';
33
import type { Request, Response } from 'express';
4+
import express from 'express';
45
import {
56
InteractionResponseFlags,
67
InteractionResponseType,
78
InteractionType,
89
verifyKeyMiddleware,
910
} from '../index';
11+
import { subtleCrypto } from '../util';
1012
import {
1113
applicationCommandRequestBody,
1214
autocompleteRequestBody,
@@ -17,9 +19,6 @@ import {
1719
signRequestWithKeyPair,
1820
} from './utils/SharedTestUtils';
1921

20-
import express from 'express';
21-
import { subtleCrypto } from '../util';
22-
2322
const expressApp = express();
2423

2524
const exampleApplicationCommandResponse = {
@@ -246,9 +245,7 @@ describe('verify key middleware', () => {
246245
exampleInteractionsUrl,
247246
{
248247
'x-signature-ed25519': signedRequest.signature,
249-
'x-signature-timestamp': String(
250-
Math.round(new Date().getTime() / 1000) - 10000,
251-
),
248+
'x-signature-timestamp': String(Math.round(Date.now() / 1000) - 10000),
252249
'content-type': 'application/json',
253250
},
254251
signedRequest.body,

src/__tests__/verifyWebhookEventMiddleware.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import type * as http from 'node:http';
22
import type { AddressInfo } from 'node:net';
33
import type { Request, Response } from 'express';
4+
import express from 'express';
45
import { verifyWebhookEventMiddleware } from '../index';
6+
import { subtleCrypto } from '../util';
57
import { WebhookEventType, WebhookType } from '../webhooks';
68
import {
79
generateKeyPair,
810
sendExampleRequest,
911
signRequestWithKeyPair,
1012
} from './utils/SharedTestUtils';
1113

12-
import express from 'express';
13-
import { subtleCrypto } from '../util';
14-
1514
const expressApp = express();
1615

1716
// Example webhook ping request body
@@ -63,7 +62,7 @@ describe('verify webhook event middleware', () => {
6362
next();
6463
},
6564
verifyWebhookEventMiddleware(rawPublicKey),
66-
(req: Request, res: Response) => {
65+
(_req: Request, res: Response) => {
6766
// This handler will be reached but the response has already been sent
6867
// by the middleware with 204 status
6968
if (!res.headersSent) {
@@ -183,9 +182,7 @@ describe('verify webhook event middleware', () => {
183182
exampleWebhookUrl,
184183
{
185184
'x-signature-ed25519': signedRequest.signature,
186-
'x-signature-timestamp': String(
187-
Math.round(new Date().getTime() / 1000) - 10000,
188-
),
185+
'x-signature-timestamp': String(Math.round(Date.now() / 1000) - 10000),
189186
'content-type': 'application/json',
190187
},
191188
signedRequest.body,
@@ -266,7 +263,7 @@ describe('verify webhook event middleware', () => {
266263
testApp.post(
267264
'/webhook-test',
268265
verifyWebhookEventMiddleware(rawPublicKey),
269-
(req: Request, res: Response) => {
266+
(_req: Request, res: Response) => {
270267
// This handler tries to send a response after middleware already sent one
271268
try {
272269
res.json({ shouldFail: true });

src/components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export type EmojiInfo = {
211211
name: string | undefined;
212212
id: string | undefined;
213213
// Should define the user object in future
214-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
214+
// biome-ignore lint/suspicious/noExplicitAny: user object not fully typed yet
215215
user?: { [key: string]: any };
216216
roles?: string[];
217217
require_colons?: boolean;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export async function verifyKey(
129129
message,
130130
);
131131
return isValid;
132-
} catch (ex) {
132+
} catch (_ex) {
133133
return false;
134134
}
135135
}

0 commit comments

Comments
 (0)