From bae719505d4ac447ba9ca7a16becf26c3d7f67d5 Mon Sep 17 00:00:00 2001 From: FredKSchott Date: Sat, 2 Apr 2022 18:30:48 +0000 Subject: [PATCH] [ci] format --- examples/with-markdown-shiki/astro.config.mjs | 2 +- packages/astro/src/@types/astro.ts | 96 +++++++++---------- packages/astro/src/core/build/static-build.ts | 2 +- packages/astro/src/core/config.ts | 40 ++++---- .../astro/src/vite-plugin-markdown/index.ts | 2 +- packages/astro/test/astro-global.test.js | 2 +- packages/astro/test/cli.test.js | 4 +- packages/astro/test/config-validate.test.js | 2 +- packages/astro/test/ssr-request.test.js | 4 +- 9 files changed, 75 insertions(+), 79 deletions(-) diff --git a/examples/with-markdown-shiki/astro.config.mjs b/examples/with-markdown-shiki/astro.config.mjs index 0a928c898..a091e103c 100644 --- a/examples/with-markdown-shiki/astro.config.mjs +++ b/examples/with-markdown-shiki/astro.config.mjs @@ -10,5 +10,5 @@ export default defineConfig({ // Learn more about this configuration here: // https://docs.astro.build/en/guides/markdown-content/#syntax-highlighting }, - } + }, }); diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 98b76757c..e1a82c8f8 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -274,18 +274,18 @@ export interface AstroUserConfig { * @kind heading * @name Server Options * @description - * + * * Customize the Astro dev server, used by both `astro dev` and `astro serve`. - * - * ```js + * + * ```js * { * server: {port: 1234, host: true} * } * ``` - * + * * To set different configuration based on the command run ("dev", "preview") a function can also be passed to this configuration option. - * - * ```js + * + * ```js * { * // Example: Use the function syntax to customize based on command * server: (command) => ({port: command === 'dev' ? 3000 : 4000}) @@ -324,7 +324,7 @@ export interface AstroUserConfig { * @kind heading * @name Markdown Options */ - markdown?: { + markdown?: { /** * @docs * @name markdown.drafts @@ -353,7 +353,7 @@ export interface AstroUserConfig { * @description * Shiki configuration options. See [the markdown configuration docs](https://docs.astro.build/en/guides/markdown-content/#shiki-configuration) for usage. */ - shikiConfig?: ShikiConfig; + shikiConfig?: ShikiConfig; /** * @docs @@ -365,7 +365,7 @@ export interface AstroUserConfig { * - `shiki` - use the [Shiki](https://github.com/shikijs/shiki) highlighter * - `prism` - use the [Prism](https://prismjs.com/) highlighter * - `false` - do not apply syntax highlighting. - * + * * ```js * { * markdown: { @@ -383,17 +383,17 @@ export interface AstroUserConfig { * @type {Plugin[]} * @description * Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built. - * - * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired. - * - * ```js - * { + * + * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired. + * + * ```js + * { * markdown: { * // Example: The default set of remark plugins used by Astro * remarkPlugins: ['remark-code-titles', ['rehype-autolink-headings', { behavior: 'prepend' }]], * }, - * }; - * ``` + * }; + * ``` */ remarkPlugins?: Plugin[]; /** @@ -402,17 +402,17 @@ export interface AstroUserConfig { * @type {Plugin[]} * @description * Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built. - * - * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired. - * - * ```js - * { + * + * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support, [Footnotes](https://github.com/remarkjs/remark-footnotes) syntax, [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired. + * + * ```js + * { * markdown: { * // Example: The default set of rehype plugins used by Astro - * rehypePlugins: [['rehype-toc', { headings: ['h2', 'h3'] }], [addClasses, { 'h1,h2,h3': 'title' }], 'rehype-slug'], + * rehypePlugins: [['rehype-toc', { headings: ['h2', 'h3'] }], [addClasses, { 'h1,h2,h3': 'title' }], 'rehype-slug'], * }, - * }; - * ``` + * }; + * ``` */ rehypePlugins?: Plugin[]; }; @@ -424,29 +424,28 @@ export interface AstroUserConfig { * @description * Add an adapter to build for SSR (server-side rendering). An adapter makes it easy to connect a deployed Astro app to a hosting provider or runtime environment. */ - adapter?: AstroIntegration; - - /** - * @docs - * @kind heading - * @name Integrations - * @description - * - * Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown and Turbolinks). - * - * Read our [Integrations Guide](/en/guides/integrations-guide/) for help getting started with Astro Integrations. - * - * ```js - * import react from '@astrojs/react'; - * import tailwind from '@astrojs/tailwind'; - * { - * // Example: Add React + Tailwind support to Astro - * integrations: [react(), tailwind()] - * } - * ``` - */ - integrations?: Array; + adapter?: AstroIntegration; + /** + * @docs + * @kind heading + * @name Integrations + * @description + * + * Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown and Turbolinks). + * + * Read our [Integrations Guide](/en/guides/integrations-guide/) for help getting started with Astro Integrations. + * + * ```js + * import react from '@astrojs/react'; + * import tailwind from '@astrojs/tailwind'; + * { + * // Example: Add React + Tailwind support to Astro + * integrations: [react(), tailwind()] + * } + * ``` + */ + integrations?: Array; /** * @docs @@ -482,7 +481,7 @@ export interface AstroUserConfig { */ vite?: vite.UserConfig & { ssr?: vite.SSROptions }; - experimental?: { + experimental?: { /** * Enable experimental support for 3rd-party integrations. * Default: false @@ -496,9 +495,6 @@ export interface AstroUserConfig { ssr?: boolean; }; - - - // Legacy options to be removed /** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */ diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index 583183f2c..4c2a32e29 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -184,7 +184,7 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals, // TODO: use vite.mergeConfig() here? info(opts.logging, null, `\n${bgGreen(black(' building client '))}`); - + const viteBuildConfig = { logLevel: 'info', mode: 'production', diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts index 19ac9d66d..b9be48988 100644 --- a/packages/astro/src/core/config.ts +++ b/packages/astro/src/core/config.ts @@ -11,7 +11,7 @@ import load from '@proload/core'; import loadTypeScript from '@proload/plugin-tsm'; import postcssrc from 'postcss-load-config'; import { arraify, isObject } from './util.js'; -import { appendForwardSlash, trimSlashes } from './path.js' +import { appendForwardSlash, trimSlashes } from './path.js'; load.use([loadTypeScript]); @@ -54,7 +54,7 @@ export const LegacyAstroConfigKeys = new Set([ 'markdownOptions', 'buildOptions', 'devOptions', - 'experimentalIntegrations' + 'experimentalIntegrations', ]); export const AstroConfigSchema = z.object({ @@ -85,9 +85,9 @@ export const AstroConfigSchema = z.object({ .optional() .transform((val) => (val ? appendForwardSlash(val) : val)) .refine((val) => !val || new URL(val).pathname.length <= 1, { - message: '"site" must be a valid URL origin (ex: "https://example.com") but cannot contain a URL path (ex: "https://example.com/blog"). Use "base" to configure your deployed URL path', - - }), + message: + '"site" must be a valid URL origin (ex: "https://example.com") but cannot contain a URL path (ex: "https://example.com/blog"). Use "base" to configure your deployed URL path', + }), base: z .string() .optional() @@ -108,16 +108,17 @@ export const AstroConfigSchema = z.object({ .default({}), server: z.preprocess( // preprocess - // NOTE: Uses the "error" command here because this is overwritten by the + // NOTE: Uses the "error" command here because this is overwritten by the // individualized schema parser with the correct command. (val) => (typeof val === 'function' ? val({ command: 'error' }) : val), // validate - z.object({ - host: z.union([z.string(), z.boolean()]).optional().default(false), - port: z.number().optional().default(3000), - }) - .optional() - .default({}), + z + .object({ + host: z.union([z.string(), z.boolean()]).optional().default(false), + port: z.number().optional().default(3000), + }) + .optional() + .default({}) ), integrations: z.preprocess( // preprocess @@ -207,7 +208,7 @@ export async function validateConfig(userConfig: any, root: string, cmd: string) } } if (oldConfig) { - throw new Error(`Legacy configuration detected. Please update your configuration to the new format!\nSee https://astro.build/config for more information.`) + throw new Error(`Legacy configuration detected. Please update your configuration to the new format!\nSee https://astro.build/config for more information.`); } /* eslint-enable no-console */ @@ -234,12 +235,13 @@ export async function validateConfig(userConfig: any, root: string, cmd: string) // preprocess (val) => (typeof val === 'function' ? val({ command: cmd === 'dev' ? 'dev' : 'preview' }) : val), // validate - z.object({ - host: z.union([z.string(), z.boolean()]).optional().default(false), - port: z.number().optional().default(3000), - }) - .optional() - .default({}), + z + .object({ + host: z.union([z.string(), z.boolean()]).optional().default(false), + port: z.number().optional().default(3000), + }) + .optional() + .default({}) ), style: z .object({ diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts index 8f174556f..2f5314ac2 100644 --- a/packages/astro/src/vite-plugin-markdown/index.ts +++ b/packages/astro/src/vite-plugin-markdown/index.ts @@ -82,7 +82,7 @@ export default function markdown({ config }: AstroPluginOptions): Plugin { // Return the file's JS representation, including all Markdown // frontmatter and a deferred `import() of the compiled markdown content. if (id.startsWith(VIRTUAL_MODULE_ID)) { - const sitePathname = config.site ? appendForwardSlash(new URL(config.base, config.site).pathname) : '/'; + const sitePathname = config.site ? appendForwardSlash(new URL(config.base, config.site).pathname) : '/'; const fileId = id.substring(VIRTUAL_MODULE_ID.length); const fileUrl = fileId.includes('/pages/') ? fileId.replace(/^.*\/pages\//, sitePathname).replace(/(\/index)?\.md$/, '') : undefined; const source = await fs.promises.readFile(fileId, 'utf8'); diff --git a/packages/astro/test/astro-global.test.js b/packages/astro/test/astro-global.test.js index 41baa39de..01c92f584 100644 --- a/packages/astro/test/astro-global.test.js +++ b/packages/astro/test/astro-global.test.js @@ -7,7 +7,7 @@ describe('Astro.*', () => { before(async () => { fixture = await loadFixture({ - root: './fixtures/astro-global/' + root: './fixtures/astro-global/', }); await fixture.build(); }); diff --git a/packages/astro/test/cli.test.js b/packages/astro/test/cli.test.js index b40807f11..bb56b9150 100644 --- a/packages/astro/test/cli.test.js +++ b/packages/astro/test/cli.test.js @@ -64,9 +64,7 @@ describe('astro cli', () => { }); }); - const hostToExposeFlags = [ - ['', ''], - ]; + const hostToExposeFlags = [['', '']]; hostToExposeFlags.forEach(([flag, flagValue]) => { it(`astro ${cmd} ${flag} ${flagValue} - host to expose`, async () => { const { local, network } = await cliServerLogSetupWithFixture([flag, flagValue], cmd); diff --git a/packages/astro/test/config-validate.test.js b/packages/astro/test/config-validate.test.js index dadc69582..c3bed9d46 100644 --- a/packages/astro/test/config-validate.test.js +++ b/packages/astro/test/config-validate.test.js @@ -61,6 +61,6 @@ describe('Config Validation', () => { expect(configError.message).to.include('Astro integrations are still experimental.'); }); it('allows third-party "integration" values with the --experimental-integrations flag', async () => { - await validateConfig({ integrations: [{ name: '@my-plugin/a' }], experimental: { integrations: true }}, process.cwd()).catch((err) => err); + await validateConfig({ integrations: [{ name: '@my-plugin/a' }], experimental: { integrations: true } }, process.cwd()).catch((err) => err); }); }); diff --git a/packages/astro/test/ssr-request.test.js b/packages/astro/test/ssr-request.test.js index 29e6ea50e..0cba2a49e 100644 --- a/packages/astro/test/ssr-request.test.js +++ b/packages/astro/test/ssr-request.test.js @@ -13,8 +13,8 @@ describe('Using Astro.request in SSR', () => { root: './fixtures/ssr-request/', adapter: testAdapter(), experimental: { - ssr: true - } + ssr: true, + }, }); await fixture.build(); });