[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 { PluggableList } from '@mdx-js/mdx/lib/core.js';
import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroIntegration } from 'astro';
import { parse as parseESM } from 'es-module-lexer';
import { blue, bold } from 'kleur/colors';
import { VFile } from 'vfile';
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 {
recmaInjectImportMetaEnvPlugin,
rehypeApplyFrontmatterExport,
getRehypePlugins,
getRemarkPlugins,
recmaInjectImportMetaEnvPlugin,
rehypeApplyFrontmatterExport,
} from './plugins.js';
import { PluggableList } from '@mdx-js/mdx/lib/core.js';
import { getFileInfo, handleExtendsNotSupported, parseFrontmatter } from './utils.js';
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';

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 type { PluggableList } from '@mdx-js/mdx/lib/core.js';
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 rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm';
import remarkSmartypants from 'remark-smartypants';
import type { Data, VFile } from 'vfile';
import { MdxOptions } from './index.js';
import rehypeCollectHeadings from './rehype-collect-headings.js';
import remarkPrism from './remark-prism.js';
import remarkShiki from './remark-shiki.js';
import { MdxOptions } from './index.js';
import { jsToTreeNode } from './utils.js';
export function recmaInjectImportMetaEnvPlugin({
importMetaEnv,

View file

@ -14,7 +14,7 @@ describe('MDX - Vite env vars', () => {
it('Avoids transforming `import.meta.env` outside JSX expressions', async () => {
const html = await fixture.readFile('/vite-env-vars/index.html');
const { document } = parseHTML(html);
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('pre')?.innerHTML).to.contain('import.meta.env.SITE');
@ -28,7 +28,7 @@ describe('MDX - Vite env vars', () => {
const { document } = parseHTML(html);
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 () => {
@ -36,7 +36,7 @@ describe('MDX - Vite env vars', () => {
const { document } = parseHTML(html);
expect(document.querySelector('[data-env-variable-exports]')?.innerHTML).to.contain(
'MODE works',
'MODE works'
);
});
it('Transforms `import.meta.env` in HTML attributes', async () => {
@ -44,15 +44,11 @@ describe('MDX - Vite env vars', () => {
const { document } = parseHTML(html);
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-dev')).to.be.null;
expect(dataAttrDump.getAttribute('data-env-base-url')).to.equal(
'/',
);
expect(dataAttrDump.getAttribute('data-env-mode')).to.equal(
'production',
);
expect(dataAttrDump.getAttribute('data-env-base-url')).to.equal('/');
expect(dataAttrDump.getAttribute('data-env-mode')).to.equal('production');
});
});