[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.
// Also, support for ESM imports & exports in Markdown content was removed.
import { mdxJsx } from '@astrojs/micromark-extension-mdx-jsx';
import { Parser } from 'acorn';
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 { 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';
export function mdxjs(options: Options): Extension {
@ -18,14 +18,10 @@ export function mdxjs(options: Options): Extension {
{
acorn: Parser.extend(acornJsx()),
acornOptions: { ecmaVersion: 2020, sourceType: 'module' },
addResult: true
addResult: true,
},
options
);
return combineExtensions([
mdxExpression(settings),
mdxJsx(settings),
mdxMd
]);
return combineExtensions([mdxExpression(settings), mdxJsx(settings), mdxMd]);
}

View file

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

View file

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