From 41f4a8f9cbdd58e3fff7ce051bb74f058fcd3587 Mon Sep 17 00:00:00 2001 From: tony-sull Date: Fri, 22 Jul 2022 22:47:21 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/@types/astro.ts | 2 +- packages/astro/src/core/config.ts | 7 ++-- packages/astro/src/core/render/dev/index.ts | 2 +- packages/astro/src/runtime/server/jsx.ts | 14 ++++---- packages/markdown/remark/src/index.ts | 2 +- .../markdown/remark/test/autolinking.test.js | 32 +++++++++---------- .../markdown/remark/test/strictness.test.js | 5 +-- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 3c73edbad0..6e5068e894 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -703,7 +703,7 @@ export interface AstroUserConfig { * @see https://docs.astro.build/en/guides/integrations-guide/mdx/ * Default: false */ - astroFlavoredMarkdown?: boolean; + astroFlavoredMarkdown?: boolean; }; } diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts index 42e44c62ac..ff6b1557c8 100644 --- a/packages/astro/src/core/config.ts +++ b/packages/astro/src/core/config.ts @@ -52,7 +52,7 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = { vite: {}, legacy: { astroFlavoredMarkdown: false, - } + }, }; async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise { @@ -214,7 +214,10 @@ export const AstroConfigSchema = z.object({ .default(ASTRO_CONFIG_DEFAULTS.vite), legacy: z .object({ - astroFlavoredMarkdown: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.legacy.astroFlavoredMarkdown), + astroFlavoredMarkdown: z + .boolean() + .optional() + .default(ASTRO_CONFIG_DEFAULTS.legacy.astroFlavoredMarkdown), }) .optional() .default({}), diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts index d4af8c1ed0..df0d131778 100644 --- a/packages/astro/src/core/render/dev/index.ts +++ b/packages/astro/src/core/render/dev/index.ts @@ -175,7 +175,7 @@ export async function render( logging, markdown: { ...astroConfig.markdown, - isAstroFlavoredMd: astroConfig.legacy.astroFlavoredMarkdown + isAstroFlavoredMd: astroConfig.legacy.astroFlavoredMarkdown, }, mod, mode, diff --git a/packages/astro/src/runtime/server/jsx.ts b/packages/astro/src/runtime/server/jsx.ts index 44d69e702a..687d0c9b99 100644 --- a/packages/astro/src/runtime/server/jsx.ts +++ b/packages/astro/src/runtime/server/jsx.ts @@ -59,7 +59,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise { if (vnode.type) { if (typeof vnode.type === 'function' && (vnode.type as any)['astro:renderer']) { - skipAstroJSXCheck.add(vnode.type) + skipAstroJSXCheck.add(vnode.type); } if (typeof vnode.type === 'function' && vnode.props['server:root']) { const output = await vnode.type(vnode.props ?? {}); @@ -91,7 +91,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise { } if (!isVNode(child)) { _slots.default.push(child); - return + return; } if ('slot' in child.props) { _slots[child.props.slot] = [...(_slots[child.props.slot] ?? []), child]; @@ -110,10 +110,12 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise { const slotPromises = []; const slots: Record = {}; for (const [key, value] of Object.entries(_slots)) { - slotPromises.push(renderJSX(result, value).then(output => { - if (output.toString().trim().length === 0) return; - slots[key] = () => output; - })) + slotPromises.push( + renderJSX(result, value).then((output) => { + if (output.toString().trim().length === 0) return; + slots[key] = () => output; + }) + ); } await Promise.all(slotPromises); diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index 706fc7458b..8748eff2b3 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -29,7 +29,7 @@ export const DEFAULT_REHYPE_PLUGINS = []; /** Shared utility for rendering markdown */ export async function renderMarkdown( content: string, - opts: MarkdownRenderingOptions, + opts: MarkdownRenderingOptions ): Promise { let { fileURL, diff --git a/packages/markdown/remark/test/autolinking.test.js b/packages/markdown/remark/test/autolinking.test.js index 61117bddc5..c5cd64657c 100644 --- a/packages/markdown/remark/test/autolinking.test.js +++ b/packages/markdown/remark/test/autolinking.test.js @@ -5,26 +5,26 @@ describe('autolinking', () => { describe('plain md', () => { it('autolinks URLs starting with a protocol in plain text', async () => { const { code } = await renderMarkdown(`See https://example.com for more.`, {}); - + chai .expect(code.replace(/\n/g, '')) .to.equal(`

See https://example.com for more.

`); }); - + it('autolinks URLs starting with "www." in plain text', async () => { const { code } = await renderMarkdown(`See www.example.com for more.`, {}); - + chai .expect(code.trim()) .to.equal(`

See www.example.com for more.

`); }); - + it('does not autolink URLs in code blocks', async () => { const { code } = await renderMarkdown( 'See `https://example.com` or `www.example.com` for more.', {} ); - + chai .expect(code.trim()) .to.equal( @@ -35,14 +35,14 @@ describe('autolinking', () => { }); describe('astro-flavored md', () => { - const renderAstroMd = text => renderMarkdown(text, { isAstroFlavoredMd: true }); + const renderAstroMd = (text) => renderMarkdown(text, { isAstroFlavoredMd: true }); it('does not autolink URLs in code blocks', async () => { const { code } = await renderAstroMd( 'See `https://example.com` or `www.example.com` for more.', {} ); - + chai .expect(code.trim()) .to.equal( @@ -50,24 +50,24 @@ describe('autolinking', () => { `www.example.com for more.

` ); }); - + it('does not autolink URLs in fenced code blocks', async () => { const { code } = await renderAstroMd( 'Example:\n```\nGo to https://example.com or www.example.com now.\n```' ); - + chai .expect(code) .to.contain(`
 {
 			const { code } = await renderAstroMd(
 				`See [http://example.com](http://example.com) or ` +
 					`https://example.com`
 			);
-	
+
 			chai
 				.expect(code.replace(/\n/g, ''))
 				.to.equal(
@@ -75,13 +75,13 @@ describe('autolinking', () => {
 						`https://example.com

` ); }); - + it('does not autolink URLs starting with "www." when nested inside links', async () => { const { code } = await renderAstroMd( `See [www.example.com](https://www.example.com) or ` + `www.example.com` ); - + chai .expect(code.replace(/\n/g, '')) .to.equal( @@ -89,13 +89,13 @@ describe('autolinking', () => { `www.example.com

` ); }); - + it('does not autolink URLs when nested several layers deep inside links', async () => { const { code } = await renderAstroMd( `**Visit _our www.example.com or ` + `http://localhost pages_ for more!**` ); - + chai .expect(code.replace(/\n/g, '')) .to.equal( @@ -104,5 +104,5 @@ describe('autolinking', () => { `` ); }); - }) + }); }); diff --git a/packages/markdown/remark/test/strictness.test.js b/packages/markdown/remark/test/strictness.test.js index c70872701f..324415c6a2 100644 --- a/packages/markdown/remark/test/strictness.test.js +++ b/packages/markdown/remark/test/strictness.test.js @@ -67,10 +67,7 @@ describe('strictness in Astro-flavored markdown', () => { }); it('should allow attribute names starting with "@" after attribute names', async () => { - const { code } = await renderAstroMd( - ``, - {} - ); + const { code } = await renderAstroMd(``, {}); chai.expect(code.trim()).to.equal(``); });