From 9846b3e93588626b73026b3f6499c1a62df79a24 Mon Sep 17 00:00:00 2001 From: matthewp Date: Fri, 31 Mar 2023 19:29:49 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/core/app/index.ts | 2 +- packages/astro/src/core/cookies/cookies.ts | 2 +- packages/astro/src/core/render/result.ts | 2 +- packages/astro/src/runtime/server/render/common.ts | 5 ++++- packages/astro/src/vite-plugin-astro-server/response.ts | 6 +++++- packages/astro/test/ssr-redirect.test.js | 6 ++++-- packages/astro/test/units/cookies/error.test.js | 2 +- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 2088baca4..328769f2a 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -202,7 +202,7 @@ export class App { }); const response = await renderPage(mod, ctx, this.#env); - Reflect.set(request, responseSentSymbol, true) + Reflect.set(request, responseSentSymbol, true); return response; } catch (err: any) { error(this.#logging, 'ssr', err.stack || err.message || String(err)); diff --git a/packages/astro/src/core/cookies/cookies.ts b/packages/astro/src/core/cookies/cookies.ts index c9429d142..e997c772e 100644 --- a/packages/astro/src/core/cookies/cookies.ts +++ b/packages/astro/src/core/cookies/cookies.ts @@ -163,7 +163,7 @@ class AstroCookies implements AstroCookiesInterface { true, ]); - if((this.#request as any)[responseSentSymbol]) { + if ((this.#request as any)[responseSentSymbol]) { throw new AstroError({ ...AstroErrorData.ResponseSentError, }); diff --git a/packages/astro/src/core/render/result.ts b/packages/astro/src/core/render/result.ts index c5f6a3bc9..fe88c8b6b 100644 --- a/packages/astro/src/core/render/result.ts +++ b/packages/astro/src/core/render/result.ts @@ -199,7 +199,7 @@ export function createResult(args: CreateResultArgs): SSRResult { redirect: args.ssr ? (path, status) => { // If the response is already sent, error as we cannot proceed with the redirect. - if((request as any)[responseSentSymbol]) { + if ((request as any)[responseSentSymbol]) { throw new AstroError({ ...AstroErrorData.ResponseSentError, }); diff --git a/packages/astro/src/runtime/server/render/common.ts b/packages/astro/src/runtime/server/render/common.ts index 53eb3de18..e9e74f9fa 100644 --- a/packages/astro/src/runtime/server/render/common.ts +++ b/packages/astro/src/runtime/server/render/common.ts @@ -20,7 +20,10 @@ export const decoder = new TextDecoder(); // Rendering produces either marked strings of HTML or instructions for hydration. // These directive instructions bubble all the way up to renderPage so that we // can ensure they are added only once, and as soon as possible. -export function stringifyChunk(result: SSRResult, chunk: string | SlotString | RenderInstruction): string { +export function stringifyChunk( + result: SSRResult, + chunk: string | SlotString | RenderInstruction +): string { if (typeof (chunk as any).type === 'string') { const instruction = chunk as RenderInstruction; switch (instruction.type) { diff --git a/packages/astro/src/vite-plugin-astro-server/response.ts b/packages/astro/src/vite-plugin-astro-server/response.ts index 7aef08a4c..3c075405f 100644 --- a/packages/astro/src/vite-plugin-astro-server/response.ts +++ b/packages/astro/src/vite-plugin-astro-server/response.ts @@ -99,7 +99,11 @@ export async function writeWebResponse(res: http.ServerResponse, webResponse: Re res.end(); } -export async function writeSSRResult(webRequest: Request, webResponse: Response, res: http.ServerResponse) { +export async function writeSSRResult( + webRequest: Request, + webResponse: Response, + res: http.ServerResponse +) { Reflect.set(webRequest, Symbol.for('astro.responseSent'), true); return writeWebResponse(res, webResponse); } diff --git a/packages/astro/test/ssr-redirect.test.js b/packages/astro/test/ssr-redirect.test.js index 3374b3246..bb4f747cd 100644 --- a/packages/astro/test/ssr-redirect.test.js +++ b/packages/astro/test/ssr-redirect.test.js @@ -30,8 +30,10 @@ describe('Astro.redirect', () => { try { const text = await response.text(); expect(false).to.equal(true); - } catch(e) { - expect(e.message).to.equal('The response has already been sent to the browser and cannot be altered.'); + } catch (e) { + expect(e.message).to.equal( + 'The response has already been sent to the browser and cannot be altered.' + ); } }); }); diff --git a/packages/astro/test/units/cookies/error.test.js b/packages/astro/test/units/cookies/error.test.js index ecea13b71..3052042d4 100644 --- a/packages/astro/test/units/cookies/error.test.js +++ b/packages/astro/test/units/cookies/error.test.js @@ -13,7 +13,7 @@ describe('astro/src/core/cookies', () => { try { cookies.set('foo', 'bar'); expect(false).to.equal(true); - } catch(err) { + } catch (err) { expect(err.errorCode).to.equal(3030); } });