From 1dc651d74efce7e06f25d149692f891710e103f7 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 26 Sep 2022 22:25:48 +0000 Subject: [PATCH] [ci] format --- packages/integrations/mdx/src/index.ts | 14 +++++++------- packages/integrations/mdx/src/plugins.ts | 12 ++++++------ .../mdx/test/mdx-vite-env-vars.test.js | 16 ++++++---------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index 8909c8cae..de72e40f1 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -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'; diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts index f6911ba99..eb53fa629 100644 --- a/packages/integrations/mdx/src/plugins.ts +++ b/packages/integrations/mdx/src/plugins.ts @@ -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, diff --git a/packages/integrations/mdx/test/mdx-vite-env-vars.test.js b/packages/integrations/mdx/test/mdx-vite-env-vars.test.js index 9504b7305..9c11c9ca3 100644 --- a/packages/integrations/mdx/test/mdx-vite-env-vars.test.js +++ b/packages/integrations/mdx/test/mdx-vite-env-vars.test.js @@ -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'); }); });