0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-13 22:11:20 -05:00

[ci] format

This commit is contained in:
bholmesdev 2022-09-26 22:25:48 +00:00 committed by fredkbot
parent 58a2dca228
commit 1dc651d74e
3 changed files with 19 additions and 23 deletions

View file

@ -1,19 +1,19 @@
import type { AstroIntegration } from 'astro';
import type { Plugin as VitePlugin } from 'vite';
import { compile as mdxCompile } from '@mdx-js/mdx'; import { compile as mdxCompile } from '@mdx-js/mdx';
import { PluggableList } from '@mdx-js/mdx/lib/core.js';
import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup'; import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroIntegration } from 'astro';
import { parse as parseESM } from 'es-module-lexer'; import { parse as parseESM } from 'es-module-lexer';
import { blue, bold } from 'kleur/colors'; import { blue, bold } from 'kleur/colors';
import { VFile } from 'vfile';
import fs from 'node:fs/promises'; import fs from 'node:fs/promises';
import { getFileInfo, handleExtendsNotSupported, parseFrontmatter } from './utils.js'; import { VFile } from 'vfile';
import type { Plugin as VitePlugin } from 'vite';
import { import {
recmaInjectImportMetaEnvPlugin,
rehypeApplyFrontmatterExport,
getRehypePlugins, getRehypePlugins,
getRemarkPlugins, getRemarkPlugins,
recmaInjectImportMetaEnvPlugin,
rehypeApplyFrontmatterExport,
} from './plugins.js'; } from './plugins.js';
import { PluggableList } from '@mdx-js/mdx/lib/core.js'; import { getFileInfo, handleExtendsNotSupported, parseFrontmatter } from './utils.js';
const RAW_CONTENT_ERROR = const RAW_CONTENT_ERROR =
'MDX does not support rawContent()! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins'; 'MDX does not support rawContent()! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins';

View file

@ -1,19 +1,19 @@
import type { MemberExpression, Literal } from 'estree';
import type { MarkdownAstroData, AstroConfig } from 'astro';
import type { Data, VFile } from 'vfile';
import { visit as estreeVisit } from 'estree-util-visit';
import { jsToTreeNode } from './utils.js';
import { nodeTypes } from '@mdx-js/mdx'; import { nodeTypes } from '@mdx-js/mdx';
import type { PluggableList } from '@mdx-js/mdx/lib/core.js'; import type { PluggableList } from '@mdx-js/mdx/lib/core.js';
import type { Options as MdxRollupPluginOptions } from '@mdx-js/rollup'; import type { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroConfig, MarkdownAstroData } from 'astro';
import type { Literal, MemberExpression } from 'estree';
import { visit as estreeVisit } from 'estree-util-visit';
import { bold, yellow } from 'kleur/colors'; import { bold, yellow } from 'kleur/colors';
import rehypeRaw from 'rehype-raw'; import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm'; import remarkGfm from 'remark-gfm';
import remarkSmartypants from 'remark-smartypants'; import remarkSmartypants from 'remark-smartypants';
import type { Data, VFile } from 'vfile';
import { MdxOptions } from './index.js';
import rehypeCollectHeadings from './rehype-collect-headings.js'; import rehypeCollectHeadings from './rehype-collect-headings.js';
import remarkPrism from './remark-prism.js'; import remarkPrism from './remark-prism.js';
import remarkShiki from './remark-shiki.js'; import remarkShiki from './remark-shiki.js';
import { MdxOptions } from './index.js'; import { jsToTreeNode } from './utils.js';
export function recmaInjectImportMetaEnvPlugin({ export function recmaInjectImportMetaEnvPlugin({
importMetaEnv, importMetaEnv,

View file

@ -14,7 +14,7 @@ describe('MDX - Vite env vars', () => {
it('Avoids transforming `import.meta.env` outside JSX expressions', async () => { it('Avoids transforming `import.meta.env` outside JSX expressions', async () => {
const html = await fixture.readFile('/vite-env-vars/index.html'); const html = await fixture.readFile('/vite-env-vars/index.html');
const { document } = parseHTML(html); const { document } = parseHTML(html);
expect(document.querySelector('h1')?.innerHTML).to.contain('import.meta.env.SITE'); expect(document.querySelector('h1')?.innerHTML).to.contain('import.meta.env.SITE');
expect(document.querySelector('code')?.innerHTML).to.contain('import.meta.env.SITE'); expect(document.querySelector('code')?.innerHTML).to.contain('import.meta.env.SITE');
expect(document.querySelector('pre')?.innerHTML).to.contain('import.meta.env.SITE'); expect(document.querySelector('pre')?.innerHTML).to.contain('import.meta.env.SITE');
@ -28,7 +28,7 @@ describe('MDX - Vite env vars', () => {
const { document } = parseHTML(html); const { document } = parseHTML(html);
expect(document.querySelector('[data-env-site]')?.innerHTML).to.contain( expect(document.querySelector('[data-env-site]')?.innerHTML).to.contain(
'https://mdx-is-neat.com/blog/cool-post', 'https://mdx-is-neat.com/blog/cool-post'
); );
}); });
it('Transforms `import.meta.env` in variable exports', async () => { it('Transforms `import.meta.env` in variable exports', async () => {
@ -36,7 +36,7 @@ describe('MDX - Vite env vars', () => {
const { document } = parseHTML(html); const { document } = parseHTML(html);
expect(document.querySelector('[data-env-variable-exports]')?.innerHTML).to.contain( expect(document.querySelector('[data-env-variable-exports]')?.innerHTML).to.contain(
'MODE works', 'MODE works'
); );
}); });
it('Transforms `import.meta.env` in HTML attributes', async () => { it('Transforms `import.meta.env` in HTML attributes', async () => {
@ -44,15 +44,11 @@ describe('MDX - Vite env vars', () => {
const { document } = parseHTML(html); const { document } = parseHTML(html);
const dataAttrDump = document.querySelector('[data-env-dump]'); const dataAttrDump = document.querySelector('[data-env-dump]');
expect(dataAttrDump).to.not.be.null; expect(dataAttrDump).to.not.be.null;
expect(dataAttrDump.getAttribute('data-env-prod')).to.not.be.null; expect(dataAttrDump.getAttribute('data-env-prod')).to.not.be.null;
expect(dataAttrDump.getAttribute('data-env-dev')).to.be.null; expect(dataAttrDump.getAttribute('data-env-dev')).to.be.null;
expect(dataAttrDump.getAttribute('data-env-base-url')).to.equal( expect(dataAttrDump.getAttribute('data-env-base-url')).to.equal('/');
'/', expect(dataAttrDump.getAttribute('data-env-mode')).to.equal('production');
);
expect(dataAttrDump.getAttribute('data-env-mode')).to.equal(
'production',
);
}); });
}); });