[ci] format

This commit is contained in:
natemoo-re 2022-06-08 17:43:10 +00:00 committed by github-actions[bot]
parent c549f161ca
commit c15e7ebc5e
3 changed files with 24 additions and 69 deletions

View file

@ -4,13 +4,13 @@
// See `@astrojs/micromark-extension-mdx-jsx` on NPM for more details. // See `@astrojs/micromark-extension-mdx-jsx` on NPM for more details.
// Also, support for ESM imports & exports in Markdown content was removed. // Also, support for ESM imports & exports in Markdown content was removed.
import { mdxJsx } from '@astrojs/micromark-extension-mdx-jsx';
import { Parser } from 'acorn'; import { Parser } from 'acorn';
import acornJsx from 'acorn-jsx'; import acornJsx from 'acorn-jsx';
import { combineExtensions } from 'micromark-util-combine-extensions';
import { mdxExpression } from 'micromark-extension-mdx-expression';
import { mdxJsx } from '@astrojs/micromark-extension-mdx-jsx';
import { mdxMd } from 'micromark-extension-mdx-md';
import type { Options } from 'micromark-extension-mdx-expression'; import type { Options } from 'micromark-extension-mdx-expression';
import { mdxExpression } from 'micromark-extension-mdx-expression';
import { mdxMd } from 'micromark-extension-mdx-md';
import { combineExtensions } from 'micromark-util-combine-extensions';
import type { Extension } from 'micromark-util-types'; import type { Extension } from 'micromark-util-types';
export function mdxjs(options: Options): Extension { export function mdxjs(options: Options): Extension {
@ -18,14 +18,10 @@ export function mdxjs(options: Options): Extension {
{ {
acorn: Parser.extend(acornJsx()), acorn: Parser.extend(acornJsx()),
acornOptions: { ecmaVersion: 2020, sourceType: 'module' }, acornOptions: { ecmaVersion: 2020, sourceType: 'module' },
addResult: true addResult: true,
}, },
options options
); );
return combineExtensions([ return combineExtensions([mdxExpression(settings), mdxJsx(settings), mdxMd]);
mdxExpression(settings),
mdxJsx(settings),
mdxMd
]);
} }

View file

@ -1,7 +1,7 @@
import type * as fromMarkdown from 'mdast-util-from-markdown'; import type * as fromMarkdown from 'mdast-util-from-markdown';
import type { Tag } from 'mdast-util-mdx-jsx'; import type { Tag } from 'mdast-util-mdx-jsx';
import { mdxjs } from './mdxjs.js';
import { mdxFromMarkdown, mdxToMarkdown } from './mdast-util-mdxish.js'; import { mdxFromMarkdown, mdxToMarkdown } from './mdast-util-mdxish.js';
import { mdxjs } from './mdxjs.js';
export default function remarkMdxish(this: any, options = {}) { export default function remarkMdxish(this: any, options = {}) {
const data = this.data(); const data = this.data();

View file

@ -17,36 +17,21 @@ describe('strictness', () => {
}); });
it('should allow attribute names starting with ":" after element names', async () => { it('should allow attribute names starting with ":" after element names', async () => {
const { code } = await renderMarkdown( const { code } = await renderMarkdown(`<div :class="open ? '' : 'hidden'">Test</div>`, {});
`<div :class="open ? '' : 'hidden'">Test</div>`,
{}
);
chai chai.expect(code.trim()).to.equal(`<div :class="open ? '' : 'hidden'">Test</div>`);
.expect(code.trim())
.to.equal(`<div :class="open ? '' : 'hidden'">Test</div>`);
}); });
it('should allow attribute names starting with ":" after local element names', async () => { it('should allow attribute names starting with ":" after local element names', async () => {
const { code } = await renderMarkdown( const { code } = await renderMarkdown(`<div.abc :class="open ? '' : 'hidden'">x</div.abc>`, {});
`<div.abc :class="open ? '' : 'hidden'">x</div.abc>`,
{}
);
chai chai.expect(code.trim()).to.equal(`<div.abc :class="open ? '' : 'hidden'">x</div.abc>`);
.expect(code.trim())
.to.equal(`<div.abc :class="open ? '' : 'hidden'">x</div.abc>`);
}); });
it('should allow attribute names starting with ":" after attribute names', async () => { it('should allow attribute names starting with ":" after attribute names', async () => {
const { code } = await renderMarkdown( const { code } = await renderMarkdown(`<input type="text" disabled :placeholder="hi">`, {});
`<input type="text" disabled :placeholder="hi">`,
{}
);
chai chai.expect(code.trim()).to.equal(`<input type="text" disabled :placeholder="hi" />`);
.expect(code.trim())
.to.equal(`<input type="text" disabled :placeholder="hi" />`);
}); });
it('should allow attribute names starting with ":" after local attribute names', async () => { it('should allow attribute names starting with ":" after local attribute names', async () => {
@ -55,31 +40,19 @@ describe('strictness', () => {
{} {}
); );
chai chai.expect(code.trim()).to.equal(`<input type="text" x-test:disabled :placeholder="hi" />`);
.expect(code.trim())
.to.equal(`<input type="text" x-test:disabled :placeholder="hi" />`);
}); });
it('should allow attribute names starting with ":" after attribute values', async () => { it('should allow attribute names starting with ":" after attribute values', async () => {
const { code } = await renderMarkdown( const { code } = await renderMarkdown(`<input type="text" :placeholder="placeholder">`, {});
`<input type="text" :placeholder="placeholder">`,
{}
);
chai chai.expect(code.trim()).to.equal(`<input type="text" :placeholder="placeholder" />`);
.expect(code.trim())
.to.equal(`<input type="text" :placeholder="placeholder" />`);
}); });
it('should allow attribute names starting with "@" after element names', async () => { it('should allow attribute names starting with "@" after element names', async () => {
const { code } = await renderMarkdown( const { code } = await renderMarkdown(`<button @click="handleClick">Test</button>`, {});
`<button @click="handleClick">Test</button>`,
{}
);
chai chai.expect(code.trim()).to.equal(`<button @click="handleClick">Test</button>`);
.expect(code.trim())
.to.equal(`<button @click="handleClick">Test</button>`);
}); });
it('should allow attribute names starting with "@" after local element names', async () => { it('should allow attribute names starting with "@" after local element names', async () => {
@ -88,9 +61,7 @@ describe('strictness', () => {
{} {}
); );
chai chai.expect(code.trim()).to.equal(`<button.local @click="handleClick">Test</button.local>`);
.expect(code.trim())
.to.equal(`<button.local @click="handleClick">Test</button.local>`);
}); });
it('should allow attribute names starting with "@" after attribute names', async () => { it('should allow attribute names starting with "@" after attribute names', async () => {
@ -99,9 +70,7 @@ describe('strictness', () => {
{} {}
); );
chai chai.expect(code.trim()).to.equal(`<button disabled @click="handleClick">Test</button>`);
.expect(code.trim())
.to.equal(`<button disabled @click="handleClick">Test</button>`);
}); });
it('should allow attribute names starting with "@" after local attribute names', async () => { it('should allow attribute names starting with "@" after local attribute names', async () => {
@ -110,9 +79,7 @@ describe('strictness', () => {
{} {}
); );
chai chai.expect(code.trim()).to.equal(`<button x-test:disabled @click="handleClick">Test</button>`);
.expect(code.trim())
.to.equal(`<button x-test:disabled @click="handleClick">Test</button>`);
}); });
it('should allow attribute names starting with "@" after attribute values', async () => { it('should allow attribute names starting with "@" after attribute values', async () => {
@ -121,20 +88,12 @@ describe('strictness', () => {
{} {}
); );
chai chai.expect(code.trim()).to.equal(`<button type="submit" @click="handleClick">Test</button>`);
.expect(code.trim())
.to.equal(`<button type="submit" @click="handleClick">Test</button>`);
}); });
it('should allow attribute names containing dots', async () => { it('should allow attribute names containing dots', async () => {
const { code } = await renderMarkdown( const { code } = await renderMarkdown(`<input x-on:input.debounce.500ms="fetchResults">`, {});
`<input x-on:input.debounce.500ms="fetchResults">`,
{}
);
chai chai.expect(code.trim()).to.equal(`<input x-on:input.debounce.500ms="fetchResults" />`);
.expect(code.trim())
.to.equal(`<input x-on:input.debounce.500ms="fetchResults" />`);
}); });
}); });