From 05c5ef155f414d4939f84e1d1720a62763315423 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Tue, 7 Mar 2023 19:07:44 +0000 Subject: [PATCH] [ci] format --- .../astro/performance/content-benchmark.mjs | 4 +-- packages/astro/src/@types/astro.ts | 6 ++-- .../content/vite-plugin-content-imports.ts | 3 +- packages/astro/src/core/config/settings.ts | 2 +- packages/integrations/markdoc/src/index.ts | 10 +++--- packages/integrations/markdoc/src/utils.ts | 8 ++--- packages/integrations/mdx/src/index.ts | 31 +++++++++++-------- packages/integrations/mdx/src/plugins.ts | 3 +- packages/integrations/mdx/src/utils.ts | 4 +-- packages/markdown/remark/src/index.ts | 2 +- 10 files changed, 37 insertions(+), 36 deletions(-) diff --git a/packages/astro/performance/content-benchmark.mjs b/packages/astro/performance/content-benchmark.mjs index 126d99c73..5ec095034 100644 --- a/packages/astro/performance/content-benchmark.mjs +++ b/packages/astro/performance/content-benchmark.mjs @@ -57,9 +57,7 @@ async function benchmark({ fixtures, templates, numPosts }) { if (test.includes('simple')) { const fixtures = formats; - console.log( - `\n${bold('Simple')} ${dim(`${numPosts} posts (${formatsToString(fixtures)})`)}` - ); + console.log(`\n${bold('Simple')} ${dim(`${numPosts} posts (${formatsToString(fixtures)})`)}`); process.env.ASTRO_PERFORMANCE_TEST_NAME = 'simple'; await benchmark({ fixtures, diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 7dbcf183d..d4349cf72 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1015,8 +1015,8 @@ export interface AstroConfig extends z.output { export interface ContentEntryType { extensions: string[]; getEntryInfo(params: { - fileUrl: URL; - contents: string; + fileUrl: URL; + contents: string; }): GetEntryInfoReturnType | Promise; contentModuleTypes?: string; } @@ -1031,7 +1031,7 @@ type GetEntryInfoReturnType = { rawData: string; body: string; slug: string; -} +}; export interface AstroSettings { config: AstroConfig; diff --git a/packages/astro/src/content/vite-plugin-content-imports.ts b/packages/astro/src/content/vite-plugin-content-imports.ts index 194b19cc4..7c335e112 100644 --- a/packages/astro/src/content/vite-plugin-content-imports.ts +++ b/packages/astro/src/content/vite-plugin-content-imports.ts @@ -11,15 +11,14 @@ import { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index import { CONTENT_FLAG } from './consts.js'; import { ContentConfig, - getContentEntryExts, extractFrontmatterAssets, + getContentEntryExts, getContentPaths, getEntryData, getEntryInfo, getEntrySlug, getEntryType, globalContentConfigObserver, - parseFrontmatter, } from './utils.js'; function isContentFlagImport(viteId: string, contentEntryExts: string[]) { diff --git a/packages/astro/src/core/config/settings.ts b/packages/astro/src/core/config/settings.ts index 9b4b287b8..4d8278b80 100644 --- a/packages/astro/src/core/config/settings.ts +++ b/packages/astro/src/core/config/settings.ts @@ -3,10 +3,10 @@ import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../constants.js'; import { fileURLToPath, pathToFileURL } from 'url'; import jsxRenderer from '../../jsx/renderer.js'; +import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js'; import { createDefaultDevConfig } from './config.js'; import { AstroTimer } from './timer.js'; import { loadTSConfig } from './tsconfig.js'; -import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js'; export function createBaseSettings(config: AstroConfig): AstroSettings { return { diff --git a/packages/integrations/markdoc/src/index.ts b/packages/integrations/markdoc/src/index.ts index b71fe6968..d272af96e 100644 --- a/packages/integrations/markdoc/src/index.ts +++ b/packages/integrations/markdoc/src/index.ts @@ -1,15 +1,15 @@ -import type { AstroIntegration, AstroConfig, ContentEntryType, HookParameters } from 'astro'; -import { InlineConfig } from 'vite'; import type { Config } from '@markdoc/markdoc'; import Markdoc from '@markdoc/markdoc'; +import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro'; +import fs from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { InlineConfig } from 'vite'; import { - prependForwardSlash, getAstroConfigPath, MarkdocError, parseFrontmatter, + prependForwardSlash, } from './utils.js'; -import { fileURLToPath } from 'node:url'; -import fs from 'node:fs'; type IntegrationWithPrivateHooks = { name: string; diff --git a/packages/integrations/markdoc/src/utils.ts b/packages/integrations/markdoc/src/utils.ts index fc41f651d..275c711f0 100644 --- a/packages/integrations/markdoc/src/utils.ts +++ b/packages/integrations/markdoc/src/utils.ts @@ -1,9 +1,9 @@ -import matter from 'gray-matter'; -import path from 'node:path'; -import type fsMod from 'node:fs'; -import type { ErrorPayload as ViteErrorPayload } from 'vite'; import type { AstroInstance } from 'astro'; import z from 'astro/zod'; +import matter from 'gray-matter'; +import type fsMod from 'node:fs'; +import path from 'node:path'; +import type { ErrorPayload as ViteErrorPayload } from 'vite'; /** * Match YAML exception handling from Astro core errors diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index 3e9cc945c..fe8a61891 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -11,7 +11,7 @@ import type { Options as RemarkRehypeOptions } from 'remark-rehype'; import { VFile } from 'vfile'; import type { Plugin as VitePlugin } from 'vite'; import { getRehypePlugins, getRemarkPlugins, recmaInjectImportMetaEnvPlugin } from './plugins.js'; -import { getFileInfo, parseFrontmatter, ignoreStringPlugins } from './utils.js'; +import { getFileInfo, ignoreStringPlugins, parseFrontmatter } from './utils.js'; export type MdxOptions = Omit & { extendMarkdownConfig: boolean; @@ -23,20 +23,23 @@ export type MdxOptions = Omit & { - 'astro:config:setup': (params: HookParameters<'astro:config:setup'> & { - // `addPageExtension` and `contentEntryType` are not a public APIs - // Add type defs here - addPageExtension: (extension: string) => void - addContentEntryType: (contentEntryType: ContentEntryType) => void - }) => void | Promise; + 'astro:config:setup': ( + params: HookParameters<'astro:config:setup'> & { + // `addPageExtension` and `contentEntryType` are not a public APIs + // Add type defs here + addPageExtension: (extension: string) => void; + addContentEntryType: (contentEntryType: ContentEntryType) => void; + } + ) => void | Promise; }; }; -export default function mdx(partialMdxOptions: Partial = {}): IntegrationWithPrivateHooks { +export default function mdx( + partialMdxOptions: Partial = {} +): IntegrationWithPrivateHooks { return { name: '@astrojs/mdx', hooks: { @@ -70,7 +73,9 @@ export default function mdx(partialMdxOptions: Partial = {}): Integr const mdxOptions = applyDefaultOptions({ options: partialMdxOptions, - defaults: markdownConfigToMdxOptions(extendMarkdownConfig ? config.markdown : markdownConfigDefaults), + defaults: markdownConfigToMdxOptions( + extendMarkdownConfig ? config.markdown : markdownConfigDefaults + ), }); const mdxPluginOpts: MdxRollupPluginOptions = { @@ -188,7 +193,7 @@ export default function mdx(partialMdxOptions: Partial = {}): Integr const defaultMdxOptions = { extendMarkdownConfig: true, recmaPlugins: [], -} +}; function markdownConfigToMdxOptions(markdownConfig: typeof markdownConfigDefaults): MdxOptions { return { @@ -196,7 +201,7 @@ function markdownConfigToMdxOptions(markdownConfig: typeof markdownConfigDefault ...markdownConfig, remarkPlugins: ignoreStringPlugins(markdownConfig.remarkPlugins), rehypePlugins: ignoreStringPlugins(markdownConfig.rehypePlugins), - remarkRehype: markdownConfig.remarkRehype as any ?? {}, + remarkRehype: (markdownConfig.remarkRehype as any) ?? {}, }; } diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts index 850911077..fca2ce0a2 100644 --- a/packages/integrations/mdx/src/plugins.ts +++ b/packages/integrations/mdx/src/plugins.ts @@ -4,12 +4,11 @@ import { safelyGetAstroData, } from '@astrojs/markdown-remark/dist/internal.js'; import { nodeTypes } from '@mdx-js/mdx'; -import type { Options as MdxRollupPluginOptions } from '@mdx-js/rollup'; import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; +import type { Options as MdxRollupPluginOptions } from '@mdx-js/rollup'; import type { AstroConfig } from 'astro'; import type { Literal, MemberExpression } from 'estree'; import { visit as estreeVisit } from 'estree-util-visit'; -import type { Image } from 'mdast'; import rehypeRaw from 'rehype-raw'; import remarkGfm from 'remark-gfm'; import remarkSmartypants from 'remark-smartypants'; diff --git a/packages/integrations/mdx/src/utils.ts b/packages/integrations/mdx/src/utils.ts index a76186292..80f8c3e20 100644 --- a/packages/integrations/mdx/src/utils.ts +++ b/packages/integrations/mdx/src/utils.ts @@ -1,9 +1,9 @@ +import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; import type { Options as AcornOpts } from 'acorn'; import { parse } from 'acorn'; import type { AstroConfig, SSRError } from 'astro'; -import { bold, yellow } from 'kleur/colors'; import matter from 'gray-matter'; -import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; +import { bold, yellow } from 'kleur/colors'; import type { MdxjsEsm } from 'mdast-util-mdx'; function appendForwardSlash(path: string) { diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index 6d440218f..5c5dcdc66 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -93,7 +93,7 @@ export async function renderMarkdown( } else if (syntaxHighlight === 'prism') { parser.use([remarkPrism(scopedClassName)]); } - + if (opts.experimentalAssets) { // Apply later in case user plugins resolve relative image paths parser.use([toRemarkCollectImages(opts.resolveImage)]);