diff --git a/biome.json b/biome.json index ba98d9f605..43554be16a 100644 --- a/biome.json +++ b/biome.json @@ -82,7 +82,8 @@ "noControlCharactersInRegex": "warn", "noPrototypeBuiltins": "warn", "noAssignInExpressions": "warn", - "noArrayIndexKey": "warn" + "noArrayIndexKey": "warn", + "useAwait": "error" }, "a11y": { "useSemanticElements": "warn", @@ -152,6 +153,13 @@ "include": ["*.test.ts", "packages/gitbook/tests/**/*"], "javascript": { "globals": ["Bun"] + }, + "linter": { + "rules": { + "suspicious": { + "useAwait": "off" + } + } } }, { @@ -170,6 +178,16 @@ "ExportedHandler" ] } + }, + { + "include": ["packages/gitbook/openNext/**/*"], + "linter": { + "rules": { + "suspicious": { + "useAwait": "off" + } + } + } } ] } diff --git a/packages/gitbook/e2e/internal.spec.ts b/packages/gitbook/e2e/internal.spec.ts index 5d22b9f60f..6ea40cea44 100644 --- a/packages/gitbook/e2e/internal.spec.ts +++ b/packages/gitbook/e2e/internal.spec.ts @@ -425,7 +425,7 @@ const testCases: TestsCase[] = [ name: 'Text page', url: 'text-page.md', screenshot: false, - run: async (_page, response) => { + run: (_page, response) => { expect(response?.status()).toBe(200); expect(response?.headers()['content-type']).toContain('text/markdown'); }, @@ -441,7 +441,7 @@ const testCases: TestsCase[] = [ name: 'llms.txt', url: 'llms.txt', screenshot: false, - run: async (_page, response) => { + run: (_page, response) => { expect(response?.status()).toBe(200); expect(response?.headers()['content-type']).toContain('text/markdown'); }, @@ -457,7 +457,7 @@ const testCases: TestsCase[] = [ name: 'llms-full.txt', url: 'llms-full.txt', screenshot: false, - run: async (_page, response) => { + run: (_page, response) => { expect(response?.status()).toBe(200); expect(response?.headers()['content-type']).toContain('text/markdown'); }, @@ -473,7 +473,7 @@ const testCases: TestsCase[] = [ name: 'blocks.md', url: 'blocks.md', screenshot: false, - run: async (_page, response) => { + run: (_page, response) => { expect(response?.status()).toBe(200); expect(response?.headers()['content-type']).toContain('text/markdown'); }, diff --git a/packages/gitbook/e2e/util.ts b/packages/gitbook/e2e/util.ts index fdbd2a3421..279ce7f5dd 100644 --- a/packages/gitbook/e2e/util.ts +++ b/packages/gitbook/e2e/util.ts @@ -144,7 +144,7 @@ export async function waitForCookiesDialog(page: Page) { await expect(dialog).toBeVisible(); } -export async function waitForNotFound(_page: Page, response: Response | null) { +export function waitForNotFound(_page: Page, response: Response | null) { expect(response).not.toBeNull(); expect(response?.status()).toBe(404); } diff --git a/packages/gitbook/next.config.mjs b/packages/gitbook/next.config.mjs index d915cf312d..450380518f 100644 --- a/packages/gitbook/next.config.mjs +++ b/packages/gitbook/next.config.mjs @@ -54,7 +54,7 @@ const nextConfig = { ], }, - async headers() { + headers() { return [ { source: '/~gitbook/static/:path*', diff --git a/packages/gitbook/openNext/customWorkers/default.js b/packages/gitbook/openNext/customWorkers/default.js index 535c218167..b3b1db4e74 100644 --- a/packages/gitbook/openNext/customWorkers/default.js +++ b/packages/gitbook/openNext/customWorkers/default.js @@ -22,7 +22,7 @@ export class R2WriteBuffer extends DurableObject { } export default { - async fetch(request, env, ctx) { + fetch(request, env, ctx) { return runWithCloudflareRequestContext(request, env, ctx, async () => { // We can't move the handler import to the top level, otherwise the runtime will not be properly initialized const { handler } = await import( diff --git a/packages/gitbook/openNext/customWorkers/do.js b/packages/gitbook/openNext/customWorkers/do.js index 04f3cf3bec..0e7499c872 100644 --- a/packages/gitbook/openNext/customWorkers/do.js +++ b/packages/gitbook/openNext/customWorkers/do.js @@ -26,7 +26,7 @@ export { DOQueueHandler } from '../../.open-next/.build/durable-objects/queue.js export { DOShardedTagCache } from '../../.open-next/.build/durable-objects/sharded-tag-cache.js'; export default { - async fetch() { + fetch() { // This worker does not handle any requests, it only provides Durable Objects return new Response('This worker is not meant to handle requests directly', { status: 400, diff --git a/packages/gitbook/openNext/customWorkers/middleware.js b/packages/gitbook/openNext/customWorkers/middleware.js index 78a84a9760..321dfe5efa 100644 --- a/packages/gitbook/openNext/customWorkers/middleware.js +++ b/packages/gitbook/openNext/customWorkers/middleware.js @@ -8,7 +8,7 @@ export { DOQueueHandler } from '../../.open-next/.build/durable-objects/queue.js export { DOShardedTagCache } from '../../.open-next/.build/durable-objects/sharded-tag-cache.js'; export default class extends WorkerEntrypoint { - async fetch(request) { + fetch(request) { return runWithCloudflareRequestContext(request, this.env, this.ctx, async () => { // - `Request`s are handled by the Next server const reqOrResp = await middlewareHandler(request, this.env, this.ctx); diff --git a/packages/gitbook/openNext/queue/middleware.ts b/packages/gitbook/openNext/queue/middleware.ts index 5ab486a975..a5014bf20f 100644 --- a/packages/gitbook/openNext/queue/middleware.ts +++ b/packages/gitbook/openNext/queue/middleware.ts @@ -5,8 +5,8 @@ import doQueue from '@opennextjs/cloudflare/overrides/queue/do-queue'; export default { name: 'GitbookISRQueue', - send: async (msg) => { - return trace({ operation: 'gitbookISRQueueSend', name: msg.MessageBody.url }, async () => { + send: (msg) => { + return trace({ operation: 'gitbookISRQueueSend', name: msg.MessageBody.url }, () => { const { ctx } = getCloudflareContext(); ctx.waitUntil(doQueue.send(msg)); }); diff --git a/packages/gitbook/openNext/queue/server.ts b/packages/gitbook/openNext/queue/server.ts index 9a5b3b689b..cde39396b7 100644 --- a/packages/gitbook/openNext/queue/server.ts +++ b/packages/gitbook/openNext/queue/server.ts @@ -2,7 +2,7 @@ import type { Queue } from '@opennextjs/aws/types/overrides.js'; export default { name: 'GitbookISRQueue', - send: async (msg) => { + send: (msg) => { // We should never reach this point in the server. If that's the case, we should log it. console.warn('GitbookISRQueue: send called on server side, this should not happen.', msg); }, diff --git a/packages/gitbook/openNext/tagCache/middleware.ts b/packages/gitbook/openNext/tagCache/middleware.ts index 4f06d7896b..0585ec3a08 100644 --- a/packages/gitbook/openNext/tagCache/middleware.ts +++ b/packages/gitbook/openNext/tagCache/middleware.ts @@ -20,7 +20,7 @@ const originalTagCache = doShardedTagCache({ export default { name: 'GitbookTagCache', mode: 'nextMode', - getLastRevalidated: async (tags: string[]) => { + getLastRevalidated: (tags: string[]) => { const tagsToCheck = tags.filter(softTagFilter); if (tagsToCheck.length === 0) { // If we reach here, it probably means that there is an issue that we'll need to address. @@ -40,7 +40,7 @@ export default { } ); }, - hasBeenRevalidated: async (tags: string[], lastModified?: number) => { + hasBeenRevalidated: (tags: string[], lastModified?: number) => { const tagsToCheck = tags.filter(softTagFilter); if (tagsToCheck.length === 0) { // If we reach here, it probably means that there is an issue that we'll need to address. @@ -61,7 +61,7 @@ export default { } ); }, - writeTags: async (tags: string[]) => { + writeTags: (tags: string[]) => { return trace( { operation: 'gitbookTagCacheWriteTags', diff --git a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx index c715d5dd4e..c1d70a8869 100644 --- a/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx +++ b/packages/gitbook/src/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/not-found.tsx @@ -1,5 +1,5 @@ import { SitePageNotFound } from '@/components/SitePage'; -export default async function NotFound() { +export default function NotFound() { return ; } diff --git a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/[pagePath]/not-found.tsx b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/[pagePath]/not-found.tsx index c715d5dd4e..c1d70a8869 100644 --- a/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/[pagePath]/not-found.tsx +++ b/packages/gitbook/src/app/sites/static/[mode]/[siteURL]/[siteData]/[pagePath]/not-found.tsx @@ -1,5 +1,5 @@ import { SitePageNotFound } from '@/components/SitePage'; -export default async function NotFound() { +export default function NotFound() { return ; } diff --git a/packages/gitbook/src/app/~gitbook/env/route.ts b/packages/gitbook/src/app/~gitbook/env/route.ts index 5d89fe423e..062b16ff44 100644 --- a/packages/gitbook/src/app/~gitbook/env/route.ts +++ b/packages/gitbook/src/app/~gitbook/env/route.ts @@ -19,7 +19,7 @@ import { /** * Output the public environment variables for this deployment */ -export async function GET(_req: NextRequest) { +export function GET(_req: NextRequest) { return NextResponse.json({ GITBOOK_URL, GITBOOK_APP_URL, diff --git a/packages/gitbook/src/app/~gitbook/revalidate/route.ts b/packages/gitbook/src/app/~gitbook/revalidate/route.ts index 17d03c1b84..40f46c2bc2 100644 --- a/packages/gitbook/src/app/~gitbook/revalidate/route.ts +++ b/packages/gitbook/src/app/~gitbook/revalidate/route.ts @@ -11,7 +11,7 @@ interface JsonBody { * Revalidate cached data based on tags. * The body should be a JSON with { tags: string[] } */ -export async function POST(req: NextRequest) { +export function POST(req: NextRequest) { return withVerifySignature(req, async (body) => { if (!body.tags || !Array.isArray(body.tags)) { return NextResponse.json( diff --git a/packages/gitbook/src/components/AI/useAIPage.tsx b/packages/gitbook/src/components/AI/useAIPage.tsx index 9c9eb430dd..283049bc09 100644 --- a/packages/gitbook/src/components/AI/useAIPage.tsx +++ b/packages/gitbook/src/components/AI/useAIPage.tsx @@ -97,7 +97,7 @@ export function useAIPage( * Generate a new page for a query. */ const generate = React.useCallback( - async (query: string) => { + (query: string) => { generateFromStream( streamGenerateAIPage({ query, diff --git a/packages/gitbook/src/components/DocumentView/InlineIcon.tsx b/packages/gitbook/src/components/DocumentView/InlineIcon.tsx index 0eca373f69..fa8e177b2a 100644 --- a/packages/gitbook/src/components/DocumentView/InlineIcon.tsx +++ b/packages/gitbook/src/components/DocumentView/InlineIcon.tsx @@ -3,7 +3,7 @@ import type { DocumentInlineIcon } from '@gitbook/api'; import { Icon, type IconName } from '@gitbook/icons'; import type { InlineProps } from './Inline'; -export async function InlineIcon(props: InlineProps) { +export function InlineIcon(props: InlineProps) { const { inline } = props; return ; diff --git a/packages/gitbook/src/components/DocumentView/Math.tsx b/packages/gitbook/src/components/DocumentView/Math.tsx index d6b20b3799..c09a1c298d 100644 --- a/packages/gitbook/src/components/DocumentView/Math.tsx +++ b/packages/gitbook/src/components/DocumentView/Math.tsx @@ -9,7 +9,7 @@ import type { InlineProps } from './Inline'; const assetsUrl = getAssetURL('math'); -export async function BlockMath(props: BlockProps) { +export function BlockMath(props: BlockProps) { const { block, style } = props; return ( @@ -22,7 +22,7 @@ export async function BlockMath(props: BlockProps) { ); } -export async function InlineMath(props: InlineProps) { +export function InlineMath(props: InlineProps) { const { inline } = props; return ; diff --git a/packages/gitbook/src/components/Header/HeaderLinks.tsx b/packages/gitbook/src/components/Header/HeaderLinks.tsx index a96467c20d..6cbe287260 100644 --- a/packages/gitbook/src/components/Header/HeaderLinks.tsx +++ b/packages/gitbook/src/components/Header/HeaderLinks.tsx @@ -9,7 +9,7 @@ interface HeaderLinksProps { style?: ClassValue; } -export async function HeaderLinks({ children, style }: HeaderLinksProps) { +export function HeaderLinks({ children, style }: HeaderLinksProps) { return (
{ diff --git a/packages/gitbook/src/lib/markdown.ts b/packages/gitbook/src/lib/markdown.ts index f602082073..cebf7aaf9c 100644 --- a/packages/gitbook/src/lib/markdown.ts +++ b/packages/gitbook/src/lib/markdown.ts @@ -8,7 +8,7 @@ import { unified } from 'unified'; /** * Parse markdown and output HTML. */ -export async function parseMarkdown(markdown: string): Promise { +export function parseMarkdown(markdown: string): Promise { const promise = unified() .use(remarkParse) .use(remarkGfm) diff --git a/packages/openapi-parser/src/v2.ts b/packages/openapi-parser/src/v2.ts index 434d854b09..228400ada2 100644 --- a/packages/openapi-parser/src/v2.ts +++ b/packages/openapi-parser/src/v2.ts @@ -7,7 +7,7 @@ import { parseOpenAPIV3 } from './v3'; /** * Convert a Swagger 2.0 schema to an OpenAPI 3.0 schema. */ -export async function convertOpenAPIV2ToOpenAPIV3( +export function convertOpenAPIV2ToOpenAPIV3( input: ParseOpenAPIInput ): Promise> { const { value, rootURL } = input; diff --git a/packages/react-contentkit/src/ElementMarkdown.tsx b/packages/react-contentkit/src/ElementMarkdown.tsx index ccc9a664ae..06f76603c0 100644 --- a/packages/react-contentkit/src/ElementMarkdown.tsx +++ b/packages/react-contentkit/src/ElementMarkdown.tsx @@ -10,9 +10,9 @@ export function ElementMarkdown(props: ContentKitServerElementProps; + return Promise.resolve(); } return (