From 2aa43549e005622d725ca05b009da6a20df51e44 Mon Sep 17 00:00:00 2001 From: tony-sull Date: Mon, 6 Jun 2022 18:41:58 +0000 Subject: [PATCH] [ci] format --- packages/astro/e2e/vue-component.test.js | 2 +- packages/astro/src/core/render/dev/css.ts | 10 +++++----- packages/astro/src/core/render/dev/index.ts | 8 ++++---- packages/astro/src/runtime/client/hmr.ts | 4 +++- packages/astro/test/0-css.test.js | 16 +++++++--------- packages/astro/test/astro-markdown-css.test.js | 2 +- packages/astro/test/astro-partial-html.test.js | 2 +- packages/astro/test/component-library.test.js | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/astro/e2e/vue-component.test.js b/packages/astro/e2e/vue-component.test.js index ea2a76b2ded0..5a75e9512cf7 100644 --- a/packages/astro/e2e/vue-component.test.js +++ b/packages/astro/e2e/vue-component.test.js @@ -142,6 +142,6 @@ test.describe('Vue components', () => { const label = counter.locator('h1'); await expect(label, 'slotted text updated').toHaveText('Hello, updated client:visible!'); - await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid') + await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid'); }); }); diff --git a/packages/astro/src/core/render/dev/css.ts b/packages/astro/src/core/render/dev/css.ts index 7751eb1f7846..657289d36cba 100644 --- a/packages/astro/src/core/render/dev/css.ts +++ b/packages/astro/src/core/render/dev/css.ts @@ -1,9 +1,9 @@ import type * as vite from 'vite'; import path from 'path'; +import { RuntimeMode } from '../../../@types/astro.js'; import { unwrapId, viteID } from '../../util.js'; import { STYLE_EXTENSIONS } from '../util.js'; -import { RuntimeMode } from '../../../@types/astro.js'; /** * List of file extensions signalling we can (and should) SSR ahead-of-time @@ -16,7 +16,7 @@ export async function getStylesForURL( filePath: URL, viteServer: vite.ViteDevServer, mode: RuntimeMode -): Promise<{urls: Set, stylesMap: Map}> { +): Promise<{ urls: Set; stylesMap: Map }> { const importedCssUrls = new Set(); const importedStylesMap = new Map(); @@ -68,8 +68,8 @@ export async function getStylesForURL( const ext = path.extname(importedModule.url).toLowerCase(); if (STYLE_EXTENSIONS.has(ext)) { if ( - mode === 'development' // only inline in development - && typeof importedModule.ssrModule?.default === 'string' // ignore JS module styles + mode === 'development' && // only inline in development + typeof importedModule.ssrModule?.default === 'string' // ignore JS module styles ) { importedStylesMap.set(importedModule.url, importedModule.ssrModule.default); } else { @@ -85,6 +85,6 @@ export async function getStylesForURL( await crawlCSS(viteID(filePath), true); return { urls: importedCssUrls, - stylesMap: importedStylesMap + stylesMap: importedStylesMap, }; } diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts index ba6e3eceb89c..4921fb9d64a2 100644 --- a/packages/astro/src/core/render/dev/index.ts +++ b/packages/astro/src/core/render/dev/index.ts @@ -48,7 +48,7 @@ export type RenderResponse = | { type: 'html'; html: string; response: ResponseInit } | { type: 'response'; response: Response }; -const svelteStylesRE = /svelte\?svelte&type=style/; +const svelteStylesRE = /svelte\?svelte&type=style/; async function loadRenderer( viteServer: ViteDevServer, @@ -155,14 +155,14 @@ export async function render( }); let styles = new Set(); - [...(stylesMap)].forEach(([url, content]) => { + [...stylesMap].forEach(([url, content]) => { // The URL is only used by HMR for Svelte components // See src/runtime/client/hmr.ts for more details styles.add({ props: { - 'data-astro-injected': svelteStylesRE.test(url) ? url : true + 'data-astro-injected': svelteStylesRE.test(url) ? url : true, }, - children: content + children: content, }); }); diff --git a/packages/astro/src/runtime/client/hmr.ts b/packages/astro/src/runtime/client/hmr.ts index f745972255b0..e9cf5bd829c0 100644 --- a/packages/astro/src/runtime/client/hmr.ts +++ b/packages/astro/src/runtime/client/hmr.ts @@ -46,7 +46,9 @@ if (import.meta.hot) { // This will only be called after the svelte component has hydrated in the browser. // At this point Vite is tracking component style updates, we need to remove // styles injected by Astro for the component in favor of Vite's internal HMR. - const injectedStyle = document.querySelector(`style[data-astro-injected="${file.acceptedPath}"]`); + const injectedStyle = document.querySelector( + `style[data-astro-injected="${file.acceptedPath}"]` + ); if (injectedStyle) { injectedStyle.parentElement?.removeChild(injectedStyle); } diff --git a/packages/astro/test/0-css.test.js b/packages/astro/test/0-css.test.js index 573bec8427ac..acfa01b38cec 100644 --- a/packages/astro/test/0-css.test.js +++ b/packages/astro/test/0-css.test.js @@ -298,8 +298,8 @@ describe('CSS', function () { }); it('resolves ESM style imports', async () => { - const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,""); - + const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, ''); + expect(allInjectedStyles, 'styles/imported-url.css').to.contain('.imported{'); expect(allInjectedStyles, 'styles/imported-url.sass').to.contain('.imported-sass{'); expect(allInjectedStyles, 'styles/imported-url.scss').to.contain('.imported-scss{'); @@ -307,7 +307,7 @@ describe('CSS', function () { it('resolves Astro styles', async () => { const allInjectedStyles = $('style[data-astro-injected]').text(); - + expect(allInjectedStyles).to.contain('.linked-css.astro-'); expect(allInjectedStyles).to.contain('.linked-sass.astro-'); expect(allInjectedStyles).to.contain('.linked-scss.astro-'); @@ -318,14 +318,14 @@ describe('CSS', function () { const styles = [ 'ReactModules.module.css', 'ReactModules.module.scss', - 'ReactModules.module.sass' + 'ReactModules.module.sass', ]; for (const style of styles) { const href = $(`link[href$="${style}"]`).attr('href'); expect((await fixture.fetch(href)).status, style).to.equal(200); } - const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,""); + const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, ''); expect(allInjectedStyles).to.contain('.react-title{'); expect(allInjectedStyles).to.contain('.react-sass-title{'); @@ -341,15 +341,13 @@ describe('CSS', function () { }); it('resolves CSS from Vue', async () => { - const styles = [ - 'VueModules.vue?vue&type=style&index=0&lang.module.scss' - ]; + const styles = ['VueModules.vue?vue&type=style&index=0&lang.module.scss']; for (const style of styles) { const href = $(`link[href$="${style}"]`).attr('href'); expect((await fixture.fetch(href)).status, style).to.equal(200); } - const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,""); + const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, ''); expect(allInjectedStyles).to.contain('.vue-css{'); expect(allInjectedStyles).to.contain('.vue-sass{'); diff --git a/packages/astro/test/astro-markdown-css.test.js b/packages/astro/test/astro-markdown-css.test.js index 2798f544c520..8852622f49b0 100644 --- a/packages/astro/test/astro-markdown-css.test.js +++ b/packages/astro/test/astro-markdown-css.test.js @@ -52,7 +52,7 @@ describe('Imported markdown CSS', function () { expect(importedAstroComponent?.name).to.equal('h2'); const cssClass = $(importedAstroComponent).attr('class')?.split(/\s+/)?.[0]; - const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g,""); + const allInjectedStyles = $('style[data-astro-injected]').text().replace(/\s*/g, ''); expect(allInjectedStyles).to.match(new RegExp(`h2.${cssClass}{color:#00f}`)); }); }); diff --git a/packages/astro/test/astro-partial-html.test.js b/packages/astro/test/astro-partial-html.test.js index 7756d58aaf6a..d7828a596cf2 100644 --- a/packages/astro/test/astro-partial-html.test.js +++ b/packages/astro/test/astro-partial-html.test.js @@ -37,7 +37,7 @@ describe('Partial HTML', async () => { expect(html).to.match(/^ { const $ = cheerioLoad(html); // Most styles are inlined in a