diff options
author | 2024-08-29 08:17:42 +0200 | |
---|---|---|
committer | 2024-08-29 08:17:42 +0200 | |
commit | a73afb7f43f4cfd4da70f10091702500fdef229c (patch) | |
tree | 51f4967fbf3a5b409e221e8a3d591f1a88a7b433 /packages/integrations/vercel/src | |
parent | 6446ea1092753db02244216d5fdbab861bade4df (diff) | |
download | astro-a73afb7f43f4cfd4da70f10091702500fdef229c.tar.gz astro-a73afb7f43f4cfd4da70f10091702500fdef229c.tar.zst astro-a73afb7f43f4cfd4da70f10091702500fdef229c.zip |
chore: supress linting
Diffstat (limited to 'packages/integrations/vercel/src')
12 files changed, 136 insertions, 96 deletions
diff --git a/packages/integrations/vercel/src/image/build-service.ts b/packages/integrations/vercel/src/image/build-service.ts index e793b896e..ab2a49e0e 100644 --- a/packages/integrations/vercel/src/image/build-service.ts +++ b/packages/integrations/vercel/src/image/build-service.ts @@ -53,6 +53,7 @@ const service: ExternalImageService = { options.width && searchParams.append('w', options.width.toString()); options.quality && searchParams.append('q', options.quality.toString()); + // biome-ignore lint/style/useTemplate: <explanation> return '/_vercel/image?' + searchParams; }, }; diff --git a/packages/integrations/vercel/src/image/shared-dev-service.ts b/packages/integrations/vercel/src/image/shared-dev-service.ts index 8ca87e99a..4edf11d3a 100644 --- a/packages/integrations/vercel/src/image/shared-dev-service.ts +++ b/packages/integrations/vercel/src/image/shared-dev-service.ts @@ -15,6 +15,7 @@ export const baseDevService: Omit<LocalImageService, 'transform'> = { options.width && searchParams.append('w', options.width.toString()); options.quality && searchParams.append('q', options.quality.toString()); + // biome-ignore lint/style/useTemplate: <explanation> return '/_image?' + searchParams; }, parseURL(url) { @@ -25,8 +26,10 @@ export const baseDevService: Omit<LocalImageService, 'transform'> = { } const transform = { + // biome-ignore lint/style/noNonNullAssertion: <explanation> src: params.get('href')!, - width: params.has('w') ? parseInt(params.get('w')!) : undefined, + // biome-ignore lint/style/noNonNullAssertion: <explanation> + width: params.has('w') ? Number.parseInt(params.get('w')!) : undefined, quality: params.get('q'), }; diff --git a/packages/integrations/vercel/src/image/shared.ts b/packages/integrations/vercel/src/image/shared.ts index da9342f29..dfae0d06f 100644 --- a/packages/integrations/vercel/src/image/shared.ts +++ b/packages/integrations/vercel/src/image/shared.ts @@ -68,7 +68,7 @@ export function getAstroImageConfig( imagesConfig: VercelImageConfig | undefined, command: string, devImageService: DevImageService, - astroImageConfig: AstroConfig['image'], + astroImageConfig: AstroConfig['image'] ) { let devService = '@astrojs/vercel/dev-image-service'; @@ -105,7 +105,7 @@ export function getAstroImageConfig( export function sharedValidateOptions( options: ImageTransform, serviceConfig: Record<string, any>, - mode: 'development' | 'production', + mode: 'development' | 'production' ) { const vercelImageOptions = serviceConfig as VercelImageConfig; @@ -145,6 +145,7 @@ export function sharedValidateOptions( } else { if (!configuredWidths.includes(options.width)) { const nearestWidth = configuredWidths.reduce((prev, curr) => { + // biome-ignore lint/style/noNonNullAssertion: <explanation> return Math.abs(curr - options.width!) < Math.abs(prev - options.width!) ? curr : prev; }); diff --git a/packages/integrations/vercel/src/lib/nft.ts b/packages/integrations/vercel/src/lib/nft.ts index 7f21f3f27..61dcd8f9e 100644 --- a/packages/integrations/vercel/src/lib/nft.ts +++ b/packages/integrations/vercel/src/lib/nft.ts @@ -18,7 +18,7 @@ export async function copyDependenciesToFunction( logger: AstroIntegrationLogger; }, // we want to pass the caching by reference, and not by value - cache: object, + cache: object ): Promise<{ handler: string }> { const entryPath = fileURLToPath(entry); logger.info(`Bundling function ${relativePath(fileURLToPath(outDir), entryPath)}`); @@ -44,6 +44,7 @@ export async function copyDependenciesToFunction( for (const error of result.warnings) { if (error.message.startsWith('Failed to resolve dependency')) { + // biome-ignore lint/style/noNonNullAssertion: <explanation> const [, module, file] = /Cannot find module '(.+?)' loaded from (.+)/.exec(error.message)!; // The import(astroRemark) sometimes fails to resolve, but it's not a problem @@ -54,11 +55,11 @@ export async function copyDependenciesToFunction( if (entryPath === file) { logger.debug( - `[@astrojs/vercel] The module "${module}" couldn't be resolved. This may not be a problem, but it's worth checking.`, + `[@astrojs/vercel] The module "${module}" couldn't be resolved. This may not be a problem, but it's worth checking.` ); } else { logger.debug( - `[@astrojs/vercel] The module "${module}" inside the file "${file}" couldn't be resolved. This may not be a problem, but it's worth checking.`, + `[@astrojs/vercel] The module "${module}" inside the file "${file}" couldn't be resolved. This may not be a problem, but it's worth checking.` ); } } @@ -66,6 +67,7 @@ export async function copyDependenciesToFunction( // such as this html file in "main" meant for nw instead of node: // https://github.com/vercel/nft/issues/311 else if (error.message.startsWith('Failed to parse')) { + // biome-ignore lint/correctness/noUnnecessaryContinue: <explanation> continue; } else { throw error; @@ -75,7 +77,7 @@ export async function copyDependenciesToFunction( const commonAncestor = await copyFilesToFolder( [...result.fileList].map((file) => new URL(file, base)).concat(includeFiles), outDir, - excludeFiles, + excludeFiles ); return { diff --git a/packages/integrations/vercel/src/lib/redirects.ts b/packages/integrations/vercel/src/lib/redirects.ts index 1e476cb1f..54c883b3c 100644 --- a/packages/integrations/vercel/src/lib/redirects.ts +++ b/packages/integrations/vercel/src/lib/redirects.ts @@ -49,19 +49,19 @@ function getMatchPattern(segments: RoutePart[][]) { return segment[0].spread ? '(?:\\/(.*?))?' : segment - .map((part) => { - if (part) - return part.dynamic - ? '([^/]+?)' - : part.content - .normalize() - .replace(/\?/g, '%3F') - .replace(/#/g, '%23') - .replace(/%5B/g, '[') - .replace(/%5D/g, ']') - .replace(/[*+?^${}()|[\]\\]/g, '\\$&'); - }) - .join(''); + .map((part) => { + if (part) + return part.dynamic + ? '([^/]+?)' + : part.content + .normalize() + .replace(/\?/g, '%3F') + .replace(/#/g, '%23') + .replace(/%5B/g, '[') + .replace(/%5D/g, ']') + .replace(/[*+?^${}()|[\]\\]/g, '\\$&'); + }) + .join(''); }) .join('/'); } @@ -72,6 +72,7 @@ function getReplacePattern(segments: RoutePart[][]) { for (const segment of segments) { for (const part of segment) { + // biome-ignore lint/style/useTemplate: <explanation> if (part.dynamic) result += '$' + ++n; else result += part.content; } @@ -89,8 +90,10 @@ function getRedirectLocation(route: RouteData, config: AstroConfig): string { const pattern = getReplacePattern(route.redirectRoute.segments); const path = config.trailingSlash === 'always' ? appendForwardSlash(pattern) : pattern; return pathJoin(config.base, path); + // biome-ignore lint/style/noUselessElse: <explanation> } else if (typeof route.redirect === 'object') { return pathJoin(config.base, route.redirect.destination); + // biome-ignore lint/style/noUselessElse: <explanation> } else { return pathJoin(config.base, route.redirect || ''); } @@ -114,7 +117,7 @@ export function escapeRegex(content: string) { } export function getRedirects(routes: RouteData[], config: AstroConfig): VercelRoute[] { - let redirects: VercelRoute[] = []; + const redirects: VercelRoute[] = []; for (const route of routes) { if (route.type === 'redirect') { @@ -127,11 +130,13 @@ export function getRedirects(routes: RouteData[], config: AstroConfig): VercelRo if (config.trailingSlash === 'always') { redirects.push({ src: config.base + getMatchPattern(route.segments), + // biome-ignore lint/style/useTemplate: <explanation> headers: { Location: config.base + getReplacePattern(route.segments) + '/' }, status: 308, }); } else if (config.trailingSlash === 'never') { redirects.push({ + // biome-ignore lint/style/useTemplate: <explanation> src: config.base + getMatchPattern(route.segments) + '/', headers: { Location: config.base + getReplacePattern(route.segments) }, status: 308, diff --git a/packages/integrations/vercel/src/lib/speed-insights.ts b/packages/integrations/vercel/src/lib/speed-insights.ts index 8e3639536..033a705c5 100644 --- a/packages/integrations/vercel/src/lib/speed-insights.ts +++ b/packages/integrations/vercel/src/lib/speed-insights.ts @@ -19,6 +19,7 @@ export function getSpeedInsightsViteConfig(enabled?: boolean) { export function exposeEnv(envs: string[]): Record<string, unknown> { const mapped: Record<string, unknown> = {}; + // biome-ignore lint/complexity/noForEach: <explanation> envs .filter((env) => process.env[env]) .forEach((env) => { diff --git a/packages/integrations/vercel/src/lib/web-analytics.ts b/packages/integrations/vercel/src/lib/web-analytics.ts index d6ee4d78d..e994ab652 100644 --- a/packages/integrations/vercel/src/lib/web-analytics.ts +++ b/packages/integrations/vercel/src/lib/web-analytics.ts @@ -7,6 +7,7 @@ export async function getInjectableWebAnalyticsContent({ }: { mode: 'development' | 'production'; }) { + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> const base = `window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };`; if (mode === 'development') { diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts index 364d2c861..1d7e64de4 100644 --- a/packages/integrations/vercel/src/serverless/adapter.ts +++ b/packages/integrations/vercel/src/serverless/adapter.ts @@ -194,9 +194,11 @@ export default function vercelServerless({ }: VercelServerlessConfig = {}): AstroIntegration { if (maxDuration) { if (typeof maxDuration !== 'number') { + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> throw new TypeError(`maxDuration must be a number`, { cause: maxDuration }); } if (maxDuration <= 0) { + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> throw new TypeError(`maxDuration must be a positive number`, { cause: maxDuration }); } } @@ -217,10 +219,11 @@ export default function vercelServerless({ 'astro:config:setup': async ({ command, config, updateConfig, injectScript, logger }) => { if (maxDuration && maxDuration > 900) { logger.warn( - `maxDuration is set to ${maxDuration} seconds, which is longer than the maximum allowed duration of 900 seconds.`, + `maxDuration is set to ${maxDuration} seconds, which is longer than the maximum allowed duration of 900 seconds.` ); logger.warn( - `Please make sure that your plan allows for this duration. See https://vercel.com/docs/functions/serverless-functions/runtimes#maxduration for more information.`, + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + `Please make sure that your plan allows for this duration. See https://vercel.com/docs/functions/serverless-functions/runtimes#maxduration for more information.` ); } @@ -229,7 +232,7 @@ export default function vercelServerless({ 'head-inline', await getInjectableWebAnalyticsContent({ mode: command === 'dev' ? 'development' : 'production', - }), + }) ); } if (command === 'build' && speedInsights?.enabled) { @@ -243,9 +246,10 @@ export default function vercelServerless({ if (vercelConfig.trailingSlash === true && config.trailingSlash === 'always') { logger.warn( '\n' + - `\tYour "vercel.json" \`trailingSlash\` configuration (set to \`true\`) will conflict with your Astro \`trailinglSlash\` configuration (set to \`"always"\`).\n` + - `\tThis would cause infinite redirects under certain conditions and throw an \`ERR_TOO_MANY_REDIRECTS\` error.\n` + - `\tTo prevent this, your Astro configuration is updated to \`"ignore"\` during builds.\n`, + `\tYour "vercel.json" \`trailingSlash\` configuration (set to \`true\`) will conflict with your Astro \`trailinglSlash\` configuration (set to \`"always"\`).\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + `\tThis would cause infinite redirects under certain conditions and throw an \`ERR_TOO_MANY_REDIRECTS\` error.\n` + + `\tTo prevent this, your Astro configuration is updated to \`"ignore"\` during builds.\n` ); updateConfig({ trailingSlash: 'ignore', @@ -277,27 +281,32 @@ export default function vercelServerless({ imagesConfig, command, devImageService, - config.image, + config.image ), }); }, 'astro:config:done': ({ setAdapter, config, logger }) => { if (functionPerRoute === true) { logger.warn( + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> `\n` + - `\tVercel's hosting plans might have limits to the number of functions you can create.\n` + - `\tMake sure to check your plan carefully to avoid incurring additional costs.\n` + - `\tYou can set functionPerRoute: false to prevent surpassing the limit.\n`, + `\tVercel's hosting plans might have limits to the number of functions you can create.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + `\tMake sure to check your plan carefully to avoid incurring additional costs.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + `\tYou can set functionPerRoute: false to prevent surpassing the limit.\n` ); logger.warn( + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> `\n` + - `\t\`functionPerRoute\` is deprecated and will be removed in a future version of the adapter.\n`, + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + `\t\`functionPerRoute\` is deprecated and will be removed in a future version of the adapter.\n` ); } setAdapter( - getAdapter({ functionPerRoute, edgeMiddleware, middlewareSecret, skewProtection }), + getAdapter({ functionPerRoute, edgeMiddleware, middlewareSecret, skewProtection }) ); _config = config; @@ -306,13 +315,13 @@ export default function vercelServerless({ if (config.output === 'static') { throw new AstroError( - '`output: "server"` or `output: "hybrid"` is required to use the serverless adapter.', + '`output: "server"` or `output: "hybrid"` is required to use the serverless adapter.' ); } }, 'astro:build:ssr': async ({ entryPoints, middlewareEntryPoint }) => { _entryPoints = new Map( - Array.from(entryPoints).filter(([routeData]) => !routeData.prerender), + Array.from(entryPoints).filter(([routeData]) => !routeData.prerender) ); _middlewareEntryPoint = middlewareEntryPoint; }, @@ -397,12 +406,13 @@ export default function vercelServerless({ await builder.buildMiddlewareFolder( _middlewareEntryPoint, MIDDLEWARE_PATH, - middlewareSecret, + middlewareSecret ); } const fourOhFourRoute = routes.find((route) => route.pathname === '/404'); // Output configuration // https://vercel.com/docs/build-output-api/v3#build-output-configuration + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> await writeJson(new URL(`./config.json`, _config.outDir), { version: 3, routes: [ @@ -416,31 +426,31 @@ export default function vercelServerless({ ...routeDefinitions, ...(fourOhFourRoute ? [ - { - src: '/.*', - dest: fourOhFourRoute.prerender - ? '/404.html' - : _middlewareEntryPoint - ? MIDDLEWARE_PATH - : NODE_PATH, - status: 404, - }, - ] + { + src: '/.*', + dest: fourOhFourRoute.prerender + ? '/404.html' + : _middlewareEntryPoint + ? MIDDLEWARE_PATH + : NODE_PATH, + status: 404, + }, + ] : []), ], ...(imageService || imagesConfig ? { - images: imagesConfig - ? { - ...imagesConfig, - domains: [...imagesConfig.domains, ..._config.image.domains], - remotePatterns: [ - ...(imagesConfig.remotePatterns ?? []), - ..._config.image.remotePatterns, - ], - } - : getDefaultImageConfig(_config.image), - } + images: imagesConfig + ? { + ...imagesConfig, + domains: [...imagesConfig.domains, ..._config.image.domains], + remotePatterns: [ + ...(imagesConfig.remotePatterns ?? []), + ..._config.image.remotePatterns, + ], + } + : getDefaultImageConfig(_config.image), + } : {}), }); @@ -472,8 +482,8 @@ class VercelBuilder { readonly includeFiles: URL[], readonly logger: AstroIntegrationLogger, readonly maxDuration?: number, - readonly runtime = getRuntime(process, logger), - ) {} + readonly runtime = getRuntime(process, logger) + ) { } async buildServerlessFolder(entry: URL, functionName: string) { const { config, includeFiles, excludeFiles, logger, NTF_CACHE, runtime, maxDuration } = this; @@ -491,7 +501,7 @@ class VercelBuilder { excludeFiles, logger, }, - NTF_CACHE, + NTF_CACHE ); // Enable ESM @@ -513,7 +523,7 @@ class VercelBuilder { await this.buildServerlessFolder(entry, functionName); const prerenderConfig = new URL( `./functions/${functionName}.prerender-config.json`, - this.config.outDir, + this.config.outDir ); // https://vercel.com/docs/build-output-api/v3/primitives#prerender-configuration-file await writeJson(prerenderConfig, { @@ -533,9 +543,10 @@ class VercelBuilder { new URL(VERCEL_EDGE_MIDDLEWARE_FILE, this.config.srcDir), new URL('./middleware.mjs', functionFolder), middlewareSecret, - this.logger, + this.logger ); + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> await writeJson(new URL(`./.vc-config.json`, functionFolder), { runtime: 'edge', entrypoint: 'middleware.mjs', @@ -549,10 +560,14 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru const support = SUPPORTED_NODE_VERSIONS[major]; if (support === undefined) { logger.warn( + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + // biome-ignore lint/style/useTemplate: <explanation> `\n` + - `\tThe local Node.js version (${major}) is not supported by Vercel Serverless Functions.\n` + - `\tYour project will use Node.js 18 as the runtime instead.\n` + - `\tConsider switching your local version to 18.\n`, + `\tThe local Node.js version (${major}) is not supported by Vercel Serverless Functions.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + `\tYour project will use Node.js 18 as the runtime instead.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + `\tConsider switching your local version to 18.\n` ); return 'nodejs18.x'; } @@ -562,26 +577,29 @@ function getRuntime(process: NodeJS.Process, logger: AstroIntegrationLogger): Ru if (support.status === 'retiring') { if (support.warnDate && new Date() >= support.warnDate) { logger.warn( - `Your project is being built for Node.js ${major} as the runtime, which is retiring by ${support.removal}.`, + `Your project is being built for Node.js ${major} as the runtime, which is retiring by ${support.removal}.` ); } return `nodejs${major}.x`; } if (support.status === 'beta') { logger.warn( - `Your project is being built for Node.js ${major} as the runtime, which is currently in beta for Vercel Serverless Functions.`, + `Your project is being built for Node.js ${major} as the runtime, which is currently in beta for Vercel Serverless Functions.` ); return `nodejs${major}.x`; } if (support.status === 'deprecated') { const removeDate = new Intl.DateTimeFormat(undefined, { dateStyle: 'long' }).format( - support.removal, + support.removal ); logger.warn( + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + // biome-ignore lint/style/useTemplate: <explanation> `\n` + - `\tYour project is being built for Node.js ${major} as the runtime.\n` + - `\tThis version is deprecated by Vercel Serverless Functions, and scheduled to be disabled on ${removeDate}.\n` + - `\tConsider upgrading your local version to 18.\n`, + `\tYour project is being built for Node.js ${major} as the runtime.\n` + + `\tThis version is deprecated by Vercel Serverless Functions, and scheduled to be disabled on ${removeDate}.\n` + + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + `\tConsider upgrading your local version to 18.\n` ); return `nodejs${major}.x`; } diff --git a/packages/integrations/vercel/src/serverless/entrypoint.ts b/packages/integrations/vercel/src/serverless/entrypoint.ts index a881d701a..31f78bb8a 100644 --- a/packages/integrations/vercel/src/serverless/entrypoint.ts +++ b/packages/integrations/vercel/src/serverless/entrypoint.ts @@ -19,7 +19,7 @@ await import('astro/env/setup') export const createExports = ( manifest: SSRManifest, - { middlewareSecret, skewProtection }: { middlewareSecret: string; skewProtection: boolean }, + { middlewareSecret, skewProtection }: { middlewareSecret: string; skewProtection: boolean } ) => { const app = new NodeApp(manifest); const handler = async (req: IncomingMessage, res: ServerResponse) => { diff --git a/packages/integrations/vercel/src/serverless/middleware.ts b/packages/integrations/vercel/src/serverless/middleware.ts index 07d0843bf..ca84bff33 100644 --- a/packages/integrations/vercel/src/serverless/middleware.ts +++ b/packages/integrations/vercel/src/serverless/middleware.ts @@ -26,13 +26,13 @@ export async function generateEdgeMiddleware( vercelEdgeMiddlewareHandlerPath: URL, outPath: URL, middlewareSecret: string, - logger: AstroIntegrationLogger, + logger: AstroIntegrationLogger ): Promise<URL> { const code = edgeMiddlewareTemplate( astroMiddlewareEntryPointPath, vercelEdgeMiddlewareHandlerPath, middlewareSecret, - logger, + logger ); // https://vercel.com/docs/concepts/functions/edge-middleware#create-edge-middleware const bundledFilePath = fileURLToPath(outPath); @@ -57,6 +57,7 @@ export async function generateEdgeMiddleware( name: 'esbuild-namespace-node-built-in-modules', setup(build) { const filter = new RegExp(builtinModules.map((mod) => `(^${mod}$)`).join('|')); + // biome-ignore lint/style/useTemplate: <explanation> build.onResolve({ filter }, (args) => ({ path: 'node:' + args.path, external: true })); }, }, @@ -69,20 +70,22 @@ function edgeMiddlewareTemplate( astroMiddlewareEntryPointPath: URL, vercelEdgeMiddlewareHandlerPath: URL, middlewareSecret: string, - logger: AstroIntegrationLogger, + logger: AstroIntegrationLogger ) { const middlewarePath = JSON.stringify( - fileURLToPath(astroMiddlewareEntryPointPath).replace(/\\/g, '/'), + fileURLToPath(astroMiddlewareEntryPointPath).replace(/\\/g, '/') ); const filePathEdgeMiddleware = fileURLToPath(vercelEdgeMiddlewareHandlerPath); let handlerTemplateImport = ''; let handlerTemplateCall = '{}'; + // biome-ignore lint/style/useTemplate: <explanation> if (existsSync(filePathEdgeMiddleware + '.js') || existsSync(filePathEdgeMiddleware + '.ts')) { logger.warn( - 'Usage of `vercel-edge-middleware.js` is deprecated. You can now use the `waitUntil(promise)` function directly as `ctx.locals.waitUntil(promise)`.', + 'Usage of `vercel-edge-middleware.js` is deprecated. You can now use the `waitUntil(promise)` function directly as `ctx.locals.waitUntil(promise)`.' ); const stringified = JSON.stringify(filePathEdgeMiddleware.replace(/\\/g, '/')); handlerTemplateImport = `import handler from ${stringified}`; + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> handlerTemplateCall = `await handler({ request, context })`; } else { } diff --git a/packages/integrations/vercel/src/speed-insights.ts b/packages/integrations/vercel/src/speed-insights.ts index cd2ae7fe8..e8634a270 100644 --- a/packages/integrations/vercel/src/speed-insights.ts +++ b/packages/integrations/vercel/src/speed-insights.ts @@ -7,8 +7,11 @@ type Options = { path: string; analyticsId: string }; const getConnectionSpeed = () => { return 'connection' in navigator && + // biome-ignore lint/complexity/useLiteralKeys: <explanation> navigator['connection'] && + // biome-ignore lint/complexity/useLiteralKeys: <explanation> 'effectiveType' in (navigator['connection'] as unknown as { effectiveType: string }) + // biome-ignore lint/complexity/useLiteralKeys: <explanation> ? (navigator['connection'] as unknown as { effectiveType: string })['effectiveType'] : ''; }; diff --git a/packages/integrations/vercel/src/static/adapter.ts b/packages/integrations/vercel/src/static/adapter.ts index efe3d2da5..bb5762993 100644 --- a/packages/integrations/vercel/src/static/adapter.ts +++ b/packages/integrations/vercel/src/static/adapter.ts @@ -74,7 +74,7 @@ export default function vercelStatic({ 'head-inline', await getInjectableWebAnalyticsContent({ mode: command === 'dev' ? 'development' : 'production', - }), + }) ); } if (command === 'build' && speedInsights?.enabled) { @@ -95,7 +95,7 @@ export default function vercelStatic({ imagesConfig, command, devImageService, - config.image, + config.image ), }); }, @@ -128,27 +128,29 @@ export default function vercelStatic({ { handle: 'filesystem' }, ...(routes.find((route) => route.pathname === '/404') ? [ - { - src: `/.*`, - dest: `/404.html`, - status: 404, - }, - ] + { + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + src: `/.*`, + // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation> + dest: `/404.html`, + status: 404, + }, + ] : []), ], ...(imageService || imagesConfig ? { - images: imagesConfig - ? { - ...imagesConfig, - domains: [...imagesConfig.domains, ..._config.image.domains], - remotePatterns: [ - ...(imagesConfig.remotePatterns ?? []), - ..._config.image.remotePatterns, - ], - } - : getDefaultImageConfig(_config.image), - } + images: imagesConfig + ? { + ...imagesConfig, + domains: [...imagesConfig.domains, ..._config.image.domains], + remotePatterns: [ + ...(imagesConfig.remotePatterns ?? []), + ..._config.image.remotePatterns, + ], + } + : getDefaultImageConfig(_config.image), + } : {}), }); }, |