Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev authored and astrobot-houston committed Mar 7, 2023
1 parent fec5839 commit 05c5ef1
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 35 deletions.
4 changes: 1 addition & 3 deletions packages/astro/performance/content-benchmark.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,8 @@ export interface AstroConfig extends z.output<typeof AstroConfigSchema> {
export interface ContentEntryType {
extensions: string[];
getEntryInfo(params: {
fileUrl: URL;
contents: string;
fileUrl: URL;
contents: string;
}): GetEntryInfoReturnType | Promise<GetEntryInfoReturnType>;
contentModuleTypes?: string;
}
Expand All @@ -1031,7 +1031,7 @@ type GetEntryInfoReturnType = {
rawData: string;
body: string;
slug: string;
}
};

export interface AstroSettings {
config: AstroConfig;
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/content/vite-plugin-content-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions packages/integrations/markdoc/src/index.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/integrations/markdoc/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { AstroInstance } from 'astro';
import z from 'astro/zod';
import matter from 'gray-matter';
import path from 'node:path';
import type fsMod from 'node:fs';
import path from 'node:path';
import type { ErrorPayload as ViteErrorPayload } from 'vite';
import type { AstroInstance } from 'astro';
import z from 'astro/zod';

/**
* Match YAML exception handling from Astro core errors
Expand Down
31 changes: 18 additions & 13 deletions packages/integrations/mdx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof markdownConfigDefaults, 'remarkPlugins' | 'rehypePlugins'> & {
extendMarkdownConfig: boolean;
Expand All @@ -23,20 +23,23 @@ export type MdxOptions = Omit<typeof markdownConfigDefaults, 'remarkPlugins' | '
remarkRehype: RemarkRehypeOptions;
};


type IntegrationWithPrivateHooks = {
type IntegrationWithPrivateHooks = {
name: string;
hooks: Omit<AstroIntegration['hooks'], 'astro:config:setup'> & {
'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<void>;
'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<void>;
};
};

export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): IntegrationWithPrivateHooks {
export default function mdx(
partialMdxOptions: Partial<MdxOptions> = {}
): IntegrationWithPrivateHooks {
return {
name: '@astrojs/mdx',
hooks: {
Expand Down Expand Up @@ -70,7 +73,9 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): Integr

const mdxOptions = applyDefaultOptions({
options: partialMdxOptions,
defaults: markdownConfigToMdxOptions(extendMarkdownConfig ? config.markdown : markdownConfigDefaults),
defaults: markdownConfigToMdxOptions(
extendMarkdownConfig ? config.markdown : markdownConfigDefaults
),
});

const mdxPluginOpts: MdxRollupPluginOptions = {
Expand Down Expand Up @@ -188,15 +193,15 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): Integr
const defaultMdxOptions = {
extendMarkdownConfig: true,
recmaPlugins: [],
}
};

function markdownConfigToMdxOptions(markdownConfig: typeof markdownConfigDefaults): MdxOptions {
return {
...defaultMdxOptions,
...markdownConfig,
remarkPlugins: ignoreStringPlugins(markdownConfig.remarkPlugins),
rehypePlugins: ignoreStringPlugins(markdownConfig.rehypePlugins),
remarkRehype: markdownConfig.remarkRehype as any ?? {},
remarkRehype: (markdownConfig.remarkRehype as any) ?? {},
};
}

Expand Down
3 changes: 1 addition & 2 deletions packages/integrations/mdx/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/mdx/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/remark/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
Expand Down

0 comments on commit 05c5ef1

Please sign in to comment.