Skip to content

Commit f478059

Browse files
committed
refactor: remove unnecessary async usage
1 parent 2800866 commit f478059

File tree

28 files changed

+54
-36
lines changed

28 files changed

+54
-36
lines changed

biome.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
"noControlCharactersInRegex": "warn",
8383
"noPrototypeBuiltins": "warn",
8484
"noAssignInExpressions": "warn",
85-
"noArrayIndexKey": "warn"
85+
"noArrayIndexKey": "warn",
86+
"useAwait": "error"
8687
},
8788
"a11y": {
8889
"useSemanticElements": "warn",
@@ -152,6 +153,13 @@
152153
"include": ["*.test.ts", "packages/gitbook/tests/**/*"],
153154
"javascript": {
154155
"globals": ["Bun"]
156+
},
157+
"linter": {
158+
"rules": {
159+
"suspicious": {
160+
"useAwait": "off"
161+
}
162+
}
155163
}
156164
},
157165
{
@@ -170,6 +178,16 @@
170178
"ExportedHandler"
171179
]
172180
}
181+
},
182+
{
183+
"include": ["packages/gitbook/openNext/**/*"],
184+
"linter": {
185+
"rules": {
186+
"suspicious": {
187+
"useAwait": "off"
188+
}
189+
}
190+
}
173191
}
174192
]
175193
}

packages/gitbook/e2e/internal.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ const testCases: TestsCase[] = [
425425
name: 'Text page',
426426
url: 'text-page.md',
427427
screenshot: false,
428-
run: async (_page, response) => {
428+
run: (_page, response) => {
429429
expect(response?.status()).toBe(200);
430430
expect(response?.headers()['content-type']).toContain('text/markdown');
431431
},
@@ -441,7 +441,7 @@ const testCases: TestsCase[] = [
441441
name: 'llms.txt',
442442
url: 'llms.txt',
443443
screenshot: false,
444-
run: async (_page, response) => {
444+
run: (_page, response) => {
445445
expect(response?.status()).toBe(200);
446446
expect(response?.headers()['content-type']).toContain('text/markdown');
447447
},
@@ -457,7 +457,7 @@ const testCases: TestsCase[] = [
457457
name: 'llms-full.txt',
458458
url: 'llms-full.txt',
459459
screenshot: false,
460-
run: async (_page, response) => {
460+
run: (_page, response) => {
461461
expect(response?.status()).toBe(200);
462462
expect(response?.headers()['content-type']).toContain('text/markdown');
463463
},
@@ -473,7 +473,7 @@ const testCases: TestsCase[] = [
473473
name: 'blocks.md',
474474
url: 'blocks.md',
475475
screenshot: false,
476-
run: async (_page, response) => {
476+
run: (_page, response) => {
477477
expect(response?.status()).toBe(200);
478478
expect(response?.headers()['content-type']).toContain('text/markdown');
479479
},

packages/gitbook/e2e/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export async function waitForCookiesDialog(page: Page) {
144144
await expect(dialog).toBeVisible();
145145
}
146146

147-
export async function waitForNotFound(_page: Page, response: Response | null) {
147+
export function waitForNotFound(_page: Page, response: Response | null) {
148148
expect(response).not.toBeNull();
149149
expect(response?.status()).toBe(404);
150150
}

packages/gitbook/next.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const nextConfig = {
5454
],
5555
},
5656

57-
async headers() {
57+
headers() {
5858
return [
5959
{
6060
source: '/~gitbook/static/:path*',

packages/gitbook/openNext/customWorkers/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class R2WriteBuffer extends DurableObject {
2222
}
2323

2424
export default {
25-
async fetch(request, env, ctx) {
25+
fetch(request, env, ctx) {
2626
return runWithCloudflareRequestContext(request, env, ctx, async () => {
2727
// We can't move the handler import to the top level, otherwise the runtime will not be properly initialized
2828
const { handler } = await import(

packages/gitbook/openNext/customWorkers/do.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export { DOQueueHandler } from '../../.open-next/.build/durable-objects/queue.js
2626
export { DOShardedTagCache } from '../../.open-next/.build/durable-objects/sharded-tag-cache.js';
2727

2828
export default {
29-
async fetch() {
29+
fetch() {
3030
// This worker does not handle any requests, it only provides Durable Objects
3131
return new Response('This worker is not meant to handle requests directly', {
3232
status: 400,

packages/gitbook/openNext/customWorkers/middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export { DOQueueHandler } from '../../.open-next/.build/durable-objects/queue.js
88
export { DOShardedTagCache } from '../../.open-next/.build/durable-objects/sharded-tag-cache.js';
99

1010
export default class extends WorkerEntrypoint {
11-
async fetch(request) {
11+
fetch(request) {
1212
return runWithCloudflareRequestContext(request, this.env, this.ctx, async () => {
1313
// - `Request`s are handled by the Next server
1414
const reqOrResp = await middlewareHandler(request, this.env, this.ctx);

packages/gitbook/openNext/queue/middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import doQueue from '@opennextjs/cloudflare/overrides/queue/do-queue';
55

66
export default {
77
name: 'GitbookISRQueue',
8-
send: async (msg) => {
9-
return trace({ operation: 'gitbookISRQueueSend', name: msg.MessageBody.url }, async () => {
8+
send: (msg) => {
9+
return trace({ operation: 'gitbookISRQueueSend', name: msg.MessageBody.url }, () => {
1010
const { ctx } = getCloudflareContext();
1111
ctx.waitUntil(doQueue.send(msg));
1212
});

packages/gitbook/openNext/queue/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Queue } from '@opennextjs/aws/types/overrides.js';
22

33
export default {
44
name: 'GitbookISRQueue',
5-
send: async (msg) => {
5+
send: (msg) => {
66
// We should never reach this point in the server. If that's the case, we should log it.
77
console.warn('GitbookISRQueue: send called on server side, this should not happen.', msg);
88
},

packages/gitbook/openNext/tagCache/middleware.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const originalTagCache = doShardedTagCache({
2020
export default {
2121
name: 'GitbookTagCache',
2222
mode: 'nextMode',
23-
getLastRevalidated: async (tags: string[]) => {
23+
getLastRevalidated: (tags: string[]) => {
2424
const tagsToCheck = tags.filter(softTagFilter);
2525
if (tagsToCheck.length === 0) {
2626
// If we reach here, it probably means that there is an issue that we'll need to address.
@@ -40,7 +40,7 @@ export default {
4040
}
4141
);
4242
},
43-
hasBeenRevalidated: async (tags: string[], lastModified?: number) => {
43+
hasBeenRevalidated: (tags: string[], lastModified?: number) => {
4444
const tagsToCheck = tags.filter(softTagFilter);
4545
if (tagsToCheck.length === 0) {
4646
// If we reach here, it probably means that there is an issue that we'll need to address.
@@ -61,7 +61,7 @@ export default {
6161
}
6262
);
6363
},
64-
writeTags: async (tags: string[]) => {
64+
writeTags: (tags: string[]) => {
6565
return trace(
6666
{
6767
operation: 'gitbookTagCacheWriteTags',

0 commit comments

Comments
 (0)