diff --git a/.changeset/ninety-bugs-dance.md b/.changeset/ninety-bugs-dance.md new file mode 100644 index 0000000..32d775b --- /dev/null +++ b/.changeset/ninety-bugs-dance.md @@ -0,0 +1,5 @@ +--- +"eslint-mdx": patch +--- + +fix: incorrect `JSXAttribute` node position info - close #488, related #425 diff --git a/.eslintrc.js b/.eslintrc.js index 92013a5..746a57d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,6 +22,7 @@ module.exports = { files: '*.{md,mdx}', rules: { 'react/jsx-curly-brace-presence': 'error', + 'react/jsx-sort-props': 'error', 'react/self-closing-comp': 'error', 'react/no-unescaped-entities': 'warn', }, diff --git a/packages/eslint-mdx/src/worker.ts b/packages/eslint-mdx/src/worker.ts index 2dd50f5..2322c2b 100644 --- a/packages/eslint-mdx/src/worker.ts +++ b/packages/eslint-mdx/src/worker.ts @@ -633,7 +633,7 @@ runAsWorker( } return { - ...attrNamePos, + ...normalizeNode(attrStart, lastAttrOffset + 1), type: 'JSXAttribute', name: { ...attrNamePos, @@ -713,11 +713,16 @@ runAsWorker( const expression = handleNode(node) + // keep for debugging + // if (+1 === 1) { + // throw new SyntaxError(JSON.stringify({ node, expression }, null, 2)) + // } + if (expression) { body.push({ ...normalizePosition(node.position), type: 'ExpressionStatement', - expression: handleNode(node) as Expression, + expression: expression as Expression, }) } diff --git a/test/__snapshots__/fixtures.test.ts.snap b/test/__snapshots__/fixtures.test.ts.snap index 0acc464..1d4a3c3 100644 --- a/test/__snapshots__/fixtures.test.ts.snap +++ b/test/__snapshots__/fixtures.test.ts.snap @@ -160,6 +160,59 @@ import React from 'react' ] `; +exports[`fixtures lint code blocks should work as expected: code-blocks.md 2`] = ` +"# abc + +# abc + +
Hello World!
+ + + +\`\`\`JavaScript +export var a = 1 == 2 + +export const b = [a].flat() +\`\`\` + + export var a = 1 == 2 + +\`\`\`log +This is not parsable as JavaScript! +\`\`\` + + + +\`\`\`jsx +export const App = () =>
2 > 1
+\`\`\` + + + +\`\`\`TypeScript +export type Value = 1 | 2 | 3 | 4 | 5 +\`\`\` + +\`\`\`MarkDown +# abc + +# abc +\`\`\` + + + +\`\`\`mdx +import React from 'react' + +
Header
+ +# abc + +# abc +\`\`\` +" +`; + exports[`fixtures lint code blocks should work as expected: code-blocks.mdx 1`] = ` [ { @@ -219,6 +272,19 @@ exports[`fixtures lint code blocks should work as expected: code-blocks.mdx 1`] ] `; +exports[`fixtures lint code blocks should work as expected: code-blocks.mdx 2`] = ` +"\`\`\`js +let a + +const b = [1, 2, 3] + +const c = b.at(-1) + +export { c } +\`\`\` +" +`; + exports[`fixtures should match all snapshots: 287.mdx 1`] = `[]`; exports[`fixtures should match all snapshots: 292.mdx 1`] = ` @@ -246,7 +312,7 @@ exports[`fixtures should match all snapshots: 292.mdx 1`] = ` }, { "column": 46, - "endColumn": 51, + "endColumn": 58, "endLine": 5, "line": 5, "message": "Unknown property 'story' found", @@ -258,6 +324,21 @@ exports[`fixtures should match all snapshots: 292.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: 292.mdx 2`] = ` +"# Header + +paragraph
content
+ +- -
+ Vuetify preset +
+ : some extra text describing the preset +" +`; + exports[`fixtures should match all snapshots: 334.mdx 1`] = `[]`; exports[`fixtures should match all snapshots: 336.mdx 1`] = `[]`; @@ -287,8 +368,131 @@ exports[`fixtures should match all snapshots: 371.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: 371.mdx 2`] = ` +"# Hello, World! + +
+ +\`\`\`js +function foo() { + return 123 +} +\`\`\` + +
+" +`; + exports[`fixtures should match all snapshots: 380.mdx 1`] = ` [ + { + "column": 3, + "endColumn": 13, + "endLine": 21, + "fix": { + "range": [ + 426, + 720, + ], + "text": "decorators={[ + moduleMetadata({ + imports: [ + ButtonModule, + IconModule, + FormsModule, + FormModule, + RadioModule, + TabsModule, + CardModule, + ], + declarations: [ActiveTestComponent, LazyTestComponent], + }), + ]} + title="Tabs"", + }, + "line": 21, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, + { + "column": 5, + "endColumn": 11, + "endLine": 46, + "fix": { + "range": [ + 824, + 855, + ], + "text": "height="100px" + name="Basic"", + }, + "line": 46, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, + { + "column": 5, + "endColumn": 11, + "endLine": 83, + "fix": { + "range": [ + 1499, + 1529, + ], + "text": "height="200px" + name="Card"", + }, + "line": 83, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, + { + "column": 5, + "endColumn": 11, + "endLine": 105, + "fix": { + "range": [ + 1982, + 2012, + ], + "text": "height="200px" + name="Size"", + }, + "line": 105, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, + { + "column": 5, + "endColumn": 11, + "endLine": 139, + "fix": { + "range": [ + 2920, + 2957, + ], + "text": "height="200px" + name="CustomLabel"", + }, + "line": 139, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 28, "endColumn": 24, @@ -326,6 +530,25 @@ exports[`fixtures should match all snapshots: 380.mdx 1`] = ` "ruleId": "unicorn/template-indent", "severity": 2, }, + { + "column": 5, + "endColumn": 11, + "endLine": 174, + "fix": { + "range": [ + 3750, + 3784, + ], + "text": "height="100px" + name="Editable"", + }, + "line": 174, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 13, "endColumn": 16, @@ -423,6 +646,63 @@ exports[`fixtures should match all snapshots: 380.mdx 1`] = ` "ruleId": "unicorn/prefer-at", "severity": 2, }, + { + "column": 5, + "endColumn": 11, + "endLine": 220, + "fix": { + "range": [ + 4788, + 4822, + ], + "text": "height="100px" + name="Disabled"", + }, + "line": 220, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, + { + "column": 5, + "endColumn": 11, + "endLine": 253, + "fix": { + "range": [ + 5581, + 5611, + ], + "text": "height="150px" + name="Lazy"", + }, + "line": 253, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, + { + "column": 5, + "endColumn": 11, + "endLine": 299, + "fix": { + "range": [ + 6792, + 6822, + ], + "text": "height="100px" + name="Nest"", + }, + "line": 299, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 28, "endColumn": 26, @@ -476,9 +756,447 @@ exports[`fixtures should match all snapshots: 380.mdx 1`] = ` "ruleId": "unicorn/template-indent", "severity": 2, }, + { + "column": 5, + "endColumn": 11, + "endLine": 348, + "fix": { + "range": [ + 8233, + 8264, + ], + "text": "height="100px" + name="Title"", + }, + "line": 348, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, ] `; +exports[`fixtures should match all snapshots: 380.mdx 2`] = ` +"import { FormsModule } from '@angular/forms' +import { Canvas, Meta, Story } from '@storybook/addon-docs' +import { moduleMetadata } from '@storybook/angular' + +import { ActiveTestComponent } from './active-test.component' +import { LazyTestComponent } from './lazy-test.component' + +import { + ButtonModule, + IconModule, + FormModule, + RadioModule, + TabSize, + TabType, + TabsModule, + CardModule, +} from '@alauda/ui' + + + +# Tabs + +> 移植自 Angular Material, 增加了风格(卡片/线条)和尺寸(大/中/小)选项和 lazy 模式。 + +## 基础用法 + + + + {{ + template: /* HTML */ \` + + + Content 1 + + + Content 2 + + + Content 3 + + + \`, + props: { + tab: 'a', + }, + }} + + + +## Card + + + + {{ + template: /* HTML */ \` + + Content 1 + Content 2 + Content 3 + + \`, + props: { + type: TabType.Card, + }, + }} + + + +## Size + + + + {{ + template: /* HTML */ \` + + + + + + + + + + Content 1 + Content 2 + Content 3 + + \`, + props: { + size: TabSize.Medium, + }, + }} + + + +## 自定义 Label + + + + {{ + template: /* HTML */ \` + + aa2 + + + + Custom Label + + Content 1 + + Content 2 + + + + Custom Label + + Content 3 + + + \`, + props: { + tabs: Array.from({ length: 3 }).fill(), + }, + }} + + + +## 添加删除 + +> 通过自定义 Group Header 实现 + + + + {{ + template: /* HTML */ \` + + + content {{ i }} + + + + \`, + props: { + tabs: [1, 2, 3], + add(number_ = 1) { + this.tabs = this.tabs.concat( + Array.from({ length: number_ }) + .fill() + .map((_, index) => this.tabs.at(-1) + index + 1), + ) + }, + remove(index) { + this.tabs.splice(index, 1) + }, + }, + }} + + + +## 禁用 + + + + {{ + template: /* HTML */ \` + + Content 1 + Content 2 + Content 3 + Content 4 + + \`, + props: { + tabs: Array.from({ length: 10 }).fill(), + }, + }} + + + +## Lazy 模式 + +> 依赖 \`*auiTabContent\`,与默认模式按需加载每次切换 Tab 都会销毁重新创建相比,lazy 启用时在按需加载组件的同时会缓存已加载的 Tab 内容。 + + + + {{ + template: /* HTML */ \` + + + + + + + + + + Content 1 + + + Content 2 + + + Content 3 + + + \`, + props: { + tabs: Array.from({ length: 10 }).fill(), + lazy: true, + }, + }} + + + +## Tab 嵌套 + + + + {{ + template: /* HTML */ \` + + + + + + + + + + Content 1 + + + + + + + Content 2-1 + + + + + Content 2-2 + + + + + + + \`, + props: { + lazy: true, + }, + }} + + + +## 自定义 Title + + + + {{ + template: /* HTML */ \` + + Title + Content 1 + Content 2 + Content 3 + Content 4 + + \`, + }} + + + +## TabGroupComponent Inputs + +| 名称 | 类型 | 默认值 | 描述 | +| ------------- | ------- | -------------- | --------------- | +| type | TabType | TabType.Line | 样式主题 | +| size | TabSize | TabSize.Medium | 尺寸 | +| tab | string | - | 选中 Tab 的名称 | +| selectedIndex | number | - | 选中 Tab 的索引 | +| lazy | boolean | false | 懒加载模式 | + +## TabGroupComponent Outputs + +\`\`\`ts +interface TabChangeEvent { + index: number + tab: TabComponent +} +\`\`\` + +| 名称 | 类型 | 描述 | +| ------------------- | -------------- | ----------------------------- | +| tabChange | string | Tab 切换时发射 Tab 的名称 | +| selectedIndexChange | number | Tab 切换时发射 Tab 的索引 | +| selectedTabChange | TabChangeEvent | Tab 切换时发射 TabChangeEvent | +| focusChange | TabChangeEvent | Tab \`focus\` 切换时发射 | + +## TabComponent Inputs + +| 名称 | 类型 | 默认值 | 说明 | +| --------- | ------- | ------ | ---------------- | +| name | string | - | tab 的名称 | +| label | string | - | 文字 label | +| closeable | boolean | false | 是否显示关闭按键 | +| disabled | boolean | false | 是否禁用此 tab | + +## TabComponent Outputs + +| 名称 | 类型 | 描述 | +| ----- | ---- | -------------------- | +| close | void | 关闭按键被点击时发射 | + +## Directives + +| 名称 | 作用范围 | 描述 | +| ----------------- | ----------------- | --------------------------- | +| auiTabHeaderAddon | TabGroupComponent | 自定义 Group Header | +| auiTabLabel | TabComponent | 自定义 Tab Label | +| auiTabContent | TabComponent | Tab 内容区域,lazy 模式必用 | +" +`; + exports[`fixtures should match all snapshots: 391.mdx 1`] = ` [ { @@ -495,6 +1213,8 @@ exports[`fixtures should match all snapshots: 391.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: 391.mdx 2`] = `undefined`; + exports[`fixtures should match all snapshots: 429.mdx 1`] = ` [ { @@ -518,6 +1238,13 @@ exports[`fixtures should match all snapshots: 429.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: 429.mdx 2`] = ` +" + + + +- list + + +" +`; + exports[`fixtures should match all snapshots: 437.mdx 1`] = ` [ { @@ -732,6 +1478,11 @@ exports[`fixtures should match all snapshots: 437.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: 437.mdx 2`] = ` +"bar +" +`; + exports[`fixtures should match all snapshots: 445.mdx 1`] = ` [ { @@ -766,6 +1517,19 @@ exports[`fixtures should match all snapshots: 445.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: 445.mdx 2`] = ` +"import { DefinitionList } from './DefinitionList' + + + Hello World ! + + + + + +" +`; + exports[`fixtures should match all snapshots: 450.mdx 1`] = ` [ { @@ -786,6 +1550,66 @@ exports[`fixtures should match all snapshots: 450.mdx 1`] = ` "ruleId": "prettier/prettier", "severity": 2, }, + { + "column": 3, + "endColumn": 6, + "endLine": 11, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", + }, + "line": 11, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, + { + "column": 3, + "endColumn": 16, + "endLine": 13, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", + }, + "line": 13, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 1, "endColumn": 3, @@ -804,6 +1628,36 @@ exports[`fixtures should match all snapshots: 450.mdx 1`] = ` "ruleId": "prettier/prettier", "severity": 2, }, + { + "column": 3, + "endColumn": 12, + "endLine": 15, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", + }, + "line": 15, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 1, "endColumn": 3, @@ -831,13 +1685,43 @@ exports[`fixtures should match all snapshots: 450.mdx 1`] = ` 230, 232, ], - "text": "", + "text": "", + }, + "line": 17, + "message": "Delete \`··\`", + "messageId": "delete", + "nodeType": null, + "ruleId": "prettier/prettier", + "severity": 2, + }, + { + "column": 3, + "endColumn": 9, + "endLine": 17, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", }, "line": 17, - "message": "Delete \`··\`", - "messageId": "delete", - "nodeType": null, - "ruleId": "prettier/prettier", + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", "severity": 2, }, { @@ -858,6 +1742,36 @@ exports[`fixtures should match all snapshots: 450.mdx 1`] = ` "ruleId": "prettier/prettier", "severity": 2, }, + { + "column": 3, + "endColumn": 10, + "endLine": 18, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", + }, + "line": 18, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 1, "endColumn": 3, @@ -876,6 +1790,36 @@ exports[`fixtures should match all snapshots: 450.mdx 1`] = ` "ruleId": "prettier/prettier", "severity": 2, }, + { + "column": 3, + "endColumn": 8, + "endLine": 19, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", + }, + "line": 19, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 1, "endColumn": 3, @@ -894,6 +1838,36 @@ exports[`fixtures should match all snapshots: 450.mdx 1`] = ` "ruleId": "prettier/prettier", "severity": 2, }, + { + "column": 3, + "endColumn": 9, + "endLine": 20, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", + }, + "line": 20, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 1, "endColumn": 3, @@ -912,6 +1886,36 @@ exports[`fixtures should match all snapshots: 450.mdx 1`] = ` "ruleId": "prettier/prettier", "severity": 2, }, + { + "column": 3, + "endColumn": 10, + "endLine": 21, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", + }, + "line": 21, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 1, "endColumn": 3, @@ -930,9 +1934,137 @@ exports[`fixtures should match all snapshots: 450.mdx 1`] = ` "ruleId": "prettier/prettier", "severity": 2, }, + { + "column": 3, + "endColumn": 10, + "endLine": 22, + "fix": { + "range": [ + 114, + 414, + ], + "text": "alt="" + aria-disabled + className="my-image" + height={250} + + loading="eager" + onClick={() => console.log('onClick')} + onError={() => console.log('onError')} + onLoad={() => console.log('onLoad')} + src="https://via.placeholder.com/250x250" + style={{ display: 'block' }} + title="" + width={250}", + }, + "line": 22, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, +] +`; + +exports[`fixtures should match all snapshots: 450.mdx 2`] = ` +"import { Meta } from '@storybook/addon-docs' + + + +# Test + +Lorem ipsum dolor sit amet. + + console.log('onClick')} +onError={() => console.log('onError')} +onLoad={() => console.log('onLoad')} +src="https://via.placeholder.com/250x250" +style={{ display: 'block' }} +title="" +width={250} +/> +" +`; + +exports[`fixtures should match all snapshots: 488.mdx 1`] = ` +[ + { + "column": 2, + "endColumn": 7, + "endLine": 1, + "line": 1, + "message": "'Image' is not defined.", + "messageId": "undefined", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-no-undef", + "severity": 2, + }, + { + "column": 3, + "endColumn": 9, + "endLine": 5, + "fix": { + "range": [ + 9, + 74, + ], + "text": "alt="alt" + format="svg" + height="100" + src="src" + width="315"", + }, + "line": 5, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, + { + "column": 3, + "endColumn": 9, + "endLine": 6, + "fix": { + "range": [ + 9, + 74, + ], + "text": "alt="alt" + format="svg" + height="100" + src="src" + width="315"", + }, + "line": 6, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, ] `; +exports[`fixtures should match all snapshots: 488.mdx 2`] = ` +"alt +" +`; + exports[`fixtures should match all snapshots: acorn.mdx 1`] = ` [ { @@ -947,6 +2079,8 @@ exports[`fixtures should match all snapshots: acorn.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: acorn.mdx 2`] = `undefined`; + exports[`fixtures should match all snapshots: adjacent.mdx 1`] = ` [ { @@ -970,6 +2104,13 @@ exports[`fixtures should match all snapshots: adjacent.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: adjacent.mdx 2`] = ` +"import Basic from './basic' + + +" +`; + exports[`fixtures should match all snapshots: basic.mdx 1`] = ` [ { @@ -993,6 +2134,33 @@ exports[`fixtures should match all snapshots: basic.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: basic.mdx 2`] = ` +"import Basic from './basic' + +export const meta = { + title: 'Blog Post', +} + +# Blog Post + +Lorem ipsum dolor sit amet, consectetur adipiscing **elit**. Ut ac lobortis velit. + +{/* This is a comment */} + +\`\`\`css +@media (min-width: 400px) { + border-color: #000; +} +\`\`\` + +{/* This is a comment */} + +## Subtitle + +Lorem ipsum dolor sit _amet_, consectetur adipiscing elit. Ut ac lobortis velit. +" +`; + exports[`fixtures should match all snapshots: basic.tsx 1`] = `[]`; exports[`fixtures should match all snapshots: blank-lines.mdx 1`] = ` @@ -1015,6 +2183,29 @@ exports[`fixtures should match all snapshots: blank-lines.mdx 1`] = ` "ruleId": "prettier/prettier", "severity": 2, }, + { + "column": 3, + "endColumn": 5, + "endLine": 10, + "fix": { + "range": [ + 163, + 250, + ], + "text": "bg='lightgray' + p={3} + style={{ + textAlign: 'center', + fontWeight: 'bold', + }}", + }, + "line": 10, + "message": "Props should be sorted alphabetically", + "messageId": "sortPropsByAlpha", + "nodeType": "JSXIdentifier", + "ruleId": "react/jsx-sort-props", + "severity": 2, + }, { "column": 1, "endColumn": 16, @@ -1115,6 +2306,42 @@ Here's a YouTube shortcode: ] `; +exports[`fixtures should match all snapshots: blank-lines.mdx 2`] = ` +"import { Box } from '@rebass/emotion' + +# Getting Started + +If you have an existing project you want to integrate MDX with, check out +the installation guides. + + + [Next.js](/getting-started/next) | [Gatsby](/getting-started/gatsby) | [Create + React App](/getting-started/create-react-app) | [React + Static](/getting-started/react-static) | [Webpack](/getting-started/webpack) | + [Parcel](/getting-started/parcel) | [Zero](/getting-started/zero) + + +# Hello, world! + +Here's a Twitter shortcode: + + + +# Here's a text gradient shortcode! + +Here's a YouTube shortcode: + + +" +`; + exports[`fixtures should match all snapshots: code-blocks.md 1`] = ` [ { @@ -1206,6 +2433,59 @@ import React from 'react' ] `; +exports[`fixtures should match all snapshots: code-blocks.md 2`] = ` +"# abc + +# abc + +
Hello World!
+ + + +\`\`\`JavaScript +export var a = 1 == 2 + +export const b = [].concat(a) +\`\`\` + + export var a = 1 == 2 + +\`\`\`log +This is not parsable as JavaScript! +\`\`\` + + + +\`\`\`jsx +export const App = () =>
2 > 1
+\`\`\` + + + +\`\`\`TypeScript +export type Value = 1 | 2 | 3 | 4 | 5 +\`\`\` + +\`\`\`MarkDown +# abc + +# abc +\`\`\` + + + +\`\`\`mdx +import React from 'react' + +
Header
+ +# abc + +# abc +\`\`\` +" +`; + exports[`fixtures should match all snapshots: code-blocks.mdx 1`] = `[]`; exports[`fixtures should match all snapshots: comments.mdx 1`] = ` @@ -1222,6 +2502,8 @@ exports[`fixtures should match all snapshots: comments.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: comments.mdx 2`] = `undefined`; + exports[`fixtures should match all snapshots: details.mdx 1`] = ` [ { @@ -1236,6 +2518,8 @@ exports[`fixtures should match all snapshots: details.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: details.mdx 2`] = `undefined`; + exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = ` [ { @@ -1261,7 +2545,7 @@ exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = ` }, { "column": 46, - "endColumn": 51, + "endColumn": 58, "endLine": 1, "line": 1, "message": "Unknown property 'story' found", @@ -1293,7 +2577,7 @@ exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = ` }, { "column": 46, - "endColumn": 51, + "endColumn": 58, "endLine": 5, "line": 5, "message": "Unknown property 'story' found", @@ -1325,7 +2609,7 @@ exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = ` }, { "column": 46, - "endColumn": 51, + "endColumn": 58, "endLine": 9, "line": 9, "message": "Unknown property 'story' found", @@ -1357,7 +2641,7 @@ exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = ` }, { "column": 46, - "endColumn": 51, + "endColumn": 58, "endLine": 13, "line": 13, "message": "Unknown property 'story' found", @@ -1389,7 +2673,7 @@ exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = ` }, { "column": 46, - "endColumn": 51, + "endColumn": 58, "endLine": 17, "line": 17, "message": "Unknown property 'story' found", @@ -1421,7 +2705,7 @@ exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = ` }, { "column": 46, - "endColumn": 51, + "endColumn": 58, "endLine": 21, "line": 21, "message": "Unknown property 'story' found", @@ -1433,6 +2717,52 @@ exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: jsx-in-list.mdx 2`] = ` +"- -
+ Vuetify preset +
+ : some extra text describing the preset + -
+ Vuetify preset +
+ : some extra text describing the preset + -
+ Vuetify preset +
+ : some extra text describing the preset +- -
+ Vuetify preset +
+ : some extra text describing the preset + -
+ Vuetify preset +
+ : some extra text describing the preset + -
+ Vuetify preset +
+ : some extra text describing the preset +" +`; + exports[`fixtures should match all snapshots: leading-spaces.mdx 1`] = `[]`; exports[`fixtures should match all snapshots: markdown.md 1`] = `[]`; @@ -1462,6 +2792,8 @@ exports[`fixtures should match all snapshots: no-unescaped-entities.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: no-unescaped-entities.mdx 2`] = `undefined`; + exports[`fixtures should match all snapshots: no-unused-expressions.mdx 1`] = ` [ { @@ -1478,6 +2810,8 @@ exports[`fixtures should match all snapshots: no-unused-expressions.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: no-unused-expressions.mdx 2`] = `undefined`; + exports[`fixtures should match all snapshots: processor.mdx 1`] = ` [ { @@ -1503,6 +2837,8 @@ exports[`fixtures should match all snapshots: processor.mdx 1`] = ` ] `; +exports[`fixtures should match all snapshots: processor.mdx 2`] = `undefined`; + exports[`fixtures should match all snapshots: remark.md 1`] = `[]`; exports[`fixtures should match all snapshots: remark.mdx 1`] = `[]`; @@ -1537,6 +2873,10 @@ exports[`fixtures should match all snapshots: test.md 2`] = ` ] `; +exports[`fixtures should match all snapshots: test.md 3`] = `undefined`; + +exports[`fixtures should match all snapshots: test.md 4`] = `undefined`; + exports[`fixtures should match all snapshots: unicorn.jsx 1`] = ` [ { @@ -1587,6 +2927,20 @@ exports[`fixtures should match all snapshots: unicorn.jsx 1`] = ` ] `; +exports[`fixtures should match all snapshots: unicorn.jsx 2`] = ` +"; + {{ + template: /* HTML */ \` +
+
Nested
+ Hello World +
+ \`, + }} +
+" +`; + exports[`fixtures should match all snapshots: unicorn.mdx 1`] = ` [ { @@ -1625,3 +2979,17 @@ exports[`fixtures should match all snapshots: unicorn.mdx 1`] = ` }, ] `; + +exports[`fixtures should match all snapshots: unicorn.mdx 2`] = ` +" + {{ + template: /* HTML */ \` +
+
Nested
+ Hello World +
+ \`, + }} +
+" +`; diff --git a/test/__snapshots__/parser.test.ts.snap b/test/__snapshots__/parser.test.ts.snap index 0b3cb3e..af05862 100644 --- a/test/__snapshots__/parser.test.ts.snap +++ b/test/__snapshots__/parser.test.ts.snap @@ -92,12 +92,12 @@ exports[`parser should match all AST snapshots: 287.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 56, + "end": 94, "loc": { "end": { - "column": 56, + "column": 94, "line": 1, - "offset": 56, + "offset": 94, }, "start": { "column": 52, @@ -130,9 +130,9 @@ exports[`parser should match all AST snapshots: 287.mdx 1`] = ` }, "range": [ 52, - 56, + 94, ], - "raw": "href", + "raw": "href="/blog/2020-10-10-webpack-5-release/"", "start": 52, "type": "JSXAttribute", "value": { @@ -321,12 +321,12 @@ exports[`parser should match all AST snapshots: 287.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 140, + "end": 169, "loc": { "end": { - "column": 140, + "column": 169, "line": 1, - "offset": 140, + "offset": 169, }, "start": { "column": 136, @@ -359,9 +359,9 @@ exports[`parser should match all AST snapshots: 287.mdx 1`] = ` }, "range": [ 136, - 140, + 169, ], - "raw": "href", + "raw": "href="https://v4.webpack.js.org/"", "start": 136, "type": "JSXAttribute", "value": { @@ -1086,12 +1086,12 @@ exports[`parser should match all AST snapshots: 292.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 34, + "end": 40, "loc": { "end": { - "column": 24, + "column": 30, "line": 3, - "offset": 34, + "offset": 40, }, "start": { "column": 15, @@ -1124,9 +1124,9 @@ exports[`parser should match all AST snapshots: 292.mdx 1`] = ` }, "range": [ 25, - 34, + 40, ], - "raw": "className", + "raw": "className="abc"", "start": 25, "type": "JSXAttribute", "value": { @@ -1315,12 +1315,12 @@ exports[`parser should match all AST snapshots: 292.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 69, + "end": 100, "loc": { "end": { - "column": 13, + "column": 44, "line": 5, - "offset": 69, + "offset": 100, }, "start": { "column": 9, @@ -1353,9 +1353,9 @@ exports[`parser should match all AST snapshots: 292.mdx 1`] = ` }, "range": [ 65, - 69, + 100, ], - "raw": "kind", + "raw": "kind="docs-packages-vuetify-preset"", "start": 65, "type": "JSXAttribute", "value": { @@ -1383,12 +1383,12 @@ exports[`parser should match all AST snapshots: 292.mdx 1`] = ` }, }, { - "end": 106, + "end": 113, "loc": { "end": { - "column": 50, + "column": 57, "line": 5, - "offset": 106, + "offset": 113, }, "start": { "column": 45, @@ -1421,9 +1421,9 @@ exports[`parser should match all AST snapshots: 292.mdx 1`] = ` }, "range": [ 101, - 106, + 113, ], - "raw": "story", + "raw": "story="page"", "start": 101, "type": "JSXAttribute", "value": { @@ -5136,12 +5136,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 431, + "end": 438, "loc": { "end": { - "column": 7, + "column": 14, "line": 20, - "offset": 431, + "offset": 438, }, "start": { "column": 2, @@ -5174,9 +5174,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 426, - 431, + 438, ], - "raw": "title", + "raw": "title="Tabs"", "start": 426, "type": "JSXAttribute", "value": { @@ -5204,12 +5204,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 451, + "end": 720, "loc": { "end": { - "column": 12, - "line": 21, - "offset": 451, + "column": 4, + "line": 34, + "offset": 720, }, "start": { "column": 2, @@ -5242,9 +5242,22 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 441, - 451, + 720, ], - "raw": "decorators", + "raw": "decorators={[ + moduleMetadata({ + imports: [ + ButtonModule, + IconModule, + FormsModule, + FormModule, + RadioModule, + TabsModule, + CardModule, + ], + declarations: [ActiveTestComponent, LazyTestComponent], + }), + ]}", "start": 441, "type": "JSXAttribute", "value": { @@ -6188,12 +6201,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 828, + "end": 836, "loc": { "end": { - "column": 8, + "column": 16, "line": 45, - "offset": 828, + "offset": 836, }, "start": { "column": 4, @@ -6226,9 +6239,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 824, - 828, + 836, ], - "raw": "name", + "raw": "name="Basic"", "start": 824, "type": "JSXAttribute", "value": { @@ -6256,12 +6269,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 847, + "end": 855, "loc": { "end": { - "column": 10, + "column": 18, "line": 46, - "offset": 847, + "offset": 855, }, "start": { "column": 4, @@ -6294,9 +6307,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 841, - 847, + 855, ], - "raw": "height", + "raw": "height="100px"", "start": 841, "type": "JSXAttribute", "value": { @@ -6961,12 +6974,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 1503, + "end": 1510, "loc": { "end": { - "column": 8, + "column": 15, "line": 82, - "offset": 1503, + "offset": 1510, }, "start": { "column": 4, @@ -6999,9 +7012,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 1499, - 1503, + 1510, ], - "raw": "name", + "raw": "name="Card"", "start": 1499, "type": "JSXAttribute", "value": { @@ -7029,12 +7042,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 1521, + "end": 1529, "loc": { "end": { - "column": 10, + "column": 18, "line": 83, - "offset": 1521, + "offset": 1529, }, "start": { "column": 4, @@ -7067,9 +7080,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 1515, - 1521, + 1529, ], - "raw": "height", + "raw": "height="200px"", "start": 1515, "type": "JSXAttribute", "value": { @@ -7728,12 +7741,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 1986, + "end": 1993, "loc": { "end": { - "column": 8, + "column": 15, "line": 104, - "offset": 1986, + "offset": 1993, }, "start": { "column": 4, @@ -7766,9 +7779,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 1982, - 1986, + 1993, ], - "raw": "name", + "raw": "name="Size"", "start": 1982, "type": "JSXAttribute", "value": { @@ -7796,12 +7809,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 2004, + "end": 2012, "loc": { "end": { - "column": 10, + "column": 18, "line": 105, - "offset": 2004, + "offset": 2012, }, "start": { "column": 4, @@ -7834,9 +7847,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 1998, - 2004, + 2012, ], - "raw": "height", + "raw": "height="200px"", "start": 1998, "type": "JSXAttribute", "value": { @@ -8702,12 +8715,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 2924, + "end": 2938, "loc": { "end": { - "column": 8, + "column": 22, "line": 138, - "offset": 2924, + "offset": 2938, }, "start": { "column": 4, @@ -8740,9 +8753,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 2920, - 2924, + 2938, ], - "raw": "name", + "raw": "name="CustomLabel"", "start": 2920, "type": "JSXAttribute", "value": { @@ -8770,12 +8783,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 2949, + "end": 2957, "loc": { "end": { - "column": 10, + "column": 18, "line": 139, - "offset": 2949, + "offset": 2957, }, "start": { "column": 4, @@ -8808,9 +8821,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 2943, - 2949, + 2957, ], - "raw": "height", + "raw": "height="200px"", "start": 2943, "type": "JSXAttribute", "value": { @@ -10972,12 +10985,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 3754, + "end": 3765, "loc": { "end": { - "column": 8, + "column": 19, "line": 173, - "offset": 3754, + "offset": 3765, }, "start": { "column": 4, @@ -11010,9 +11023,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 3750, - 3754, + 3765, ], - "raw": "name", + "raw": "name="Editable"", "start": 3750, "type": "JSXAttribute", "value": { @@ -11040,12 +11053,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 3776, + "end": 3784, "loc": { "end": { - "column": 10, + "column": 18, "line": 174, - "offset": 3776, + "offset": 3784, }, "start": { "column": 4, @@ -11078,9 +11091,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 3770, - 3776, + 3784, ], - "raw": "height", + "raw": "height="100px"", "start": 3770, "type": "JSXAttribute", "value": { @@ -11966,12 +11979,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 4792, + "end": 4803, "loc": { "end": { - "column": 8, + "column": 19, "line": 219, - "offset": 4792, + "offset": 4803, }, "start": { "column": 4, @@ -12004,9 +12017,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 4788, - 4792, + 4803, ], - "raw": "name", + "raw": "name="Disabled"", "start": 4788, "type": "JSXAttribute", "value": { @@ -12034,12 +12047,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 4814, + "end": 4822, "loc": { "end": { - "column": 10, + "column": 18, "line": 220, - "offset": 4814, + "offset": 4822, }, "start": { "column": 4, @@ -12072,9 +12085,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 4808, - 4814, + 4822, ], - "raw": "height", + "raw": "height="100px"", "start": 4808, "type": "JSXAttribute", "value": { @@ -13028,12 +13041,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 5585, + "end": 5592, "loc": { "end": { - "column": 8, + "column": 15, "line": 252, - "offset": 5585, + "offset": 5592, }, "start": { "column": 4, @@ -13066,9 +13079,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 5581, - 5585, + 5592, ], - "raw": "name", + "raw": "name="Lazy"", "start": 5581, "type": "JSXAttribute", "value": { @@ -13096,12 +13109,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 5603, + "end": 5611, "loc": { "end": { - "column": 10, + "column": 18, "line": 253, - "offset": 5603, + "offset": 5611, }, "start": { "column": 4, @@ -13134,9 +13147,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 5597, - 5603, + 5611, ], - "raw": "height", + "raw": "height="150px"", "start": 5597, "type": "JSXAttribute", "value": { @@ -13829,12 +13842,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 6796, + "end": 6803, "loc": { "end": { - "column": 8, + "column": 15, "line": 298, - "offset": 6796, + "offset": 6803, }, "start": { "column": 4, @@ -13867,9 +13880,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 6792, - 6796, + 6803, ], - "raw": "name", + "raw": "name="Nest"", "start": 6792, "type": "JSXAttribute", "value": { @@ -13897,12 +13910,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 6814, + "end": 6822, "loc": { "end": { - "column": 10, + "column": 18, "line": 299, - "offset": 6814, + "offset": 6822, }, "start": { "column": 4, @@ -13935,9 +13948,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 6808, - 6814, + 6822, ], - "raw": "height", + "raw": "height="100px"", "start": 6808, "type": "JSXAttribute", "value": { @@ -14446,12 +14459,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 8237, + "end": 8245, "loc": { "end": { - "column": 8, + "column": 16, "line": 347, - "offset": 8237, + "offset": 8245, }, "start": { "column": 4, @@ -14484,9 +14497,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 8233, - 8237, + 8245, ], - "raw": "name", + "raw": "name="Title"", "start": 8233, "type": "JSXAttribute", "value": { @@ -14514,12 +14527,12 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, }, { - "end": 8256, + "end": 8264, "loc": { "end": { - "column": 10, + "column": 18, "line": 348, - "offset": 8256, + "offset": 8264, }, "start": { "column": 4, @@ -14552,9 +14565,9 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, "range": [ 8250, - 8256, + 8264, ], - "raw": "height", + "raw": "height="100px"", "start": 8250, "type": "JSXAttribute", "value": { @@ -14805,28 +14818,6 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` }, ], "comments": [ - { - "end": 893, - "loc": { - "end": { - "column": 26, - "line": 49, - "offset": 893, - }, - "start": { - "column": 16, - "line": 49, - "offset": 883, - }, - }, - "range": [ - 883, - 893, - ], - "start": 883, - "type": "Block", - "value": " HTML ", - }, { "end": 893, "loc": { @@ -14871,50 +14862,6 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "type": "Block", "value": " HTML ", }, - { - "end": 1567, - "loc": { - "end": { - "column": 26, - "line": 86, - "offset": 1567, - }, - "start": { - "column": 16, - "line": 86, - "offset": 1557, - }, - }, - "range": [ - 1557, - 1567, - ], - "start": 1557, - "type": "Block", - "value": " HTML ", - }, - { - "end": 2050, - "loc": { - "end": { - "column": 26, - "line": 108, - "offset": 2050, - }, - "start": { - "column": 16, - "line": 108, - "offset": 2040, - }, - }, - "range": [ - 2040, - 2050, - ], - "start": 2040, - "type": "Block", - "value": " HTML ", - }, { "end": 2050, "loc": { @@ -14959,28 +14906,6 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "type": "Block", "value": " HTML ", }, - { - "end": 2995, - "loc": { - "end": { - "column": 26, - "line": 142, - "offset": 2995, - }, - "start": { - "column": 16, - "line": 142, - "offset": 2985, - }, - }, - "range": [ - 2985, - 2995, - ], - "start": 2985, - "type": "Block", - "value": " HTML ", - }, { "end": 3822, "loc": { @@ -15003,50 +14928,6 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "type": "Block", "value": " HTML ", }, - { - "end": 3822, - "loc": { - "end": { - "column": 26, - "line": 177, - "offset": 3822, - }, - "start": { - "column": 16, - "line": 177, - "offset": 3812, - }, - }, - "range": [ - 3812, - 3822, - ], - "start": 3812, - "type": "Block", - "value": " HTML ", - }, - { - "end": 4860, - "loc": { - "end": { - "column": 26, - "line": 223, - "offset": 4860, - }, - "start": { - "column": 16, - "line": 223, - "offset": 4850, - }, - }, - "range": [ - 4850, - 4860, - ], - "start": 4850, - "type": "Block", - "value": " HTML ", - }, { "end": 4860, "loc": { @@ -15091,50 +14972,6 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "type": "Block", "value": " HTML ", }, - { - "end": 5649, - "loc": { - "end": { - "column": 26, - "line": 256, - "offset": 5649, - }, - "start": { - "column": 16, - "line": 256, - "offset": 5639, - }, - }, - "range": [ - 5639, - 5649, - ], - "start": 5639, - "type": "Block", - "value": " HTML ", - }, - { - "end": 6860, - "loc": { - "end": { - "column": 26, - "line": 302, - "offset": 6860, - }, - "start": { - "column": 16, - "line": 302, - "offset": 6850, - }, - }, - "range": [ - 6850, - 6860, - ], - "start": 6850, - "type": "Block", - "value": " HTML ", - }, { "end": 6860, "loc": { @@ -15179,28 +15016,6 @@ exports[`parser should match all AST snapshots: 380.mdx 1`] = ` "type": "Block", "value": " HTML ", }, - { - "end": 8302, - "loc": { - "end": { - "column": 26, - "line": 351, - "offset": 8302, - }, - "start": { - "column": 16, - "line": 351, - "offset": 8292, - }, - }, - "range": [ - 8292, - 8302, - ], - "start": 8292, - "type": "Block", - "value": " HTML ", - }, ], "end": 10515, "loc": { @@ -30350,12 +30165,12 @@ exports[`parser should match all AST snapshots: 435.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 14, + "end": 69, "loc": { "end": { - "column": 6, - "line": 2, - "offset": 14, + "column": 3, + "line": 5, + "offset": 69, }, "start": { "column": 1, @@ -30388,9 +30203,12 @@ exports[`parser should match all AST snapshots: 435.mdx 1`] = ` }, "range": [ 9, - 14, + 69, ], - "raw": "style", + "raw": "style={{ + background: 'red', + border: '1px solid red', + }}", "start": 9, "type": "JSXAttribute", "value": { @@ -30688,12 +30506,12 @@ exports[`parser should match all AST snapshots: 435.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 120, + "end": 130, "loc": { "end": { - "column": 20, - "line": 12, - "offset": 120, + "column": 6, + "line": 13, + "offset": 130, }, "start": { "column": 16, @@ -30726,9 +30544,10 @@ exports[`parser should match all AST snapshots: 435.mdx 1`] = ` }, "range": [ 116, - 120, + 130, ], - "raw": "data", + "raw": "data={\` + \`}", "start": 116, "type": "JSXAttribute", "value": { @@ -31706,12 +31525,12 @@ exports[`parser should match all AST snapshots: 437.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 9, + "end": 17, "loc": { "end": { - "column": 9, + "column": 17, "line": 1, - "offset": 9, + "offset": 17, }, "start": { "column": 5, @@ -31744,9 +31563,9 @@ exports[`parser should match all AST snapshots: 437.mdx 1`] = ` }, "range": [ 5, - 9, + 17, ], - "raw": "prop", + "raw": "prop={'foo'}", "start": 5, "type": "JSXAttribute", "value": { @@ -34118,12 +33937,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 58, + "end": 65, "loc": { "end": { - "column": 11, + "column": 18, "line": 3, - "offset": 58, + "offset": 65, }, "start": { "column": 6, @@ -34156,9 +33975,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 53, - 58, + 65, ], - "raw": "title", + "raw": "title="Test"", "start": 53, "type": "JSXAttribute", "value": { @@ -34279,12 +34098,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 117, + "end": 155, "loc": { "end": { - "column": 5, + "column": 43, "line": 10, - "offset": 117, + "offset": 155, }, "start": { "column": 2, @@ -34317,9 +34136,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 114, - 117, + 155, ], - "raw": "src", + "raw": "src="https://via.placeholder.com/250x250"", "start": 114, "type": "JSXAttribute", "value": { @@ -34347,12 +34166,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 161, + "end": 164, "loc": { "end": { - "column": 5, + "column": 8, "line": 11, - "offset": 161, + "offset": 164, }, "start": { "column": 2, @@ -34385,9 +34204,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 158, - 161, + 164, ], - "raw": "alt", + "raw": "alt=""", "start": 158, "type": "JSXAttribute", "value": { @@ -34415,12 +34234,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 172, + "end": 175, "loc": { "end": { - "column": 7, + "column": 10, "line": 12, - "offset": 172, + "offset": 175, }, "start": { "column": 2, @@ -34453,9 +34272,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 167, - 172, + 175, ], - "raw": "title", + "raw": "title=""", "start": 167, "type": "JSXAttribute", "value": { @@ -34529,12 +34348,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` "value": null, }, { - "end": 204, + "end": 215, "loc": { "end": { - "column": 11, + "column": 22, "line": 15, - "offset": 204, + "offset": 215, }, "start": { "column": 2, @@ -34567,9 +34386,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 195, - 204, + 215, ], - "raw": "className", + "raw": "className="my-image"", "start": 195, "type": "JSXAttribute", "value": { @@ -34597,12 +34416,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 223, + "end": 229, "loc": { "end": { - "column": 7, + "column": 13, "line": 16, - "offset": 223, + "offset": 229, }, "start": { "column": 2, @@ -34635,9 +34454,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 218, - 223, + 229, ], - "raw": "width", + "raw": "width={250}", "start": 218, "type": "JSXAttribute", "value": { @@ -34687,12 +34506,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 238, + "end": 244, "loc": { "end": { - "column": 8, + "column": 14, "line": 17, - "offset": 238, + "offset": 244, }, "start": { "column": 2, @@ -34725,9 +34544,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 232, - 238, + 244, ], - "raw": "height", + "raw": "height={250}", "start": 232, "type": "JSXAttribute", "value": { @@ -34777,12 +34596,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 254, + "end": 262, "loc": { "end": { - "column": 9, + "column": 17, "line": 18, - "offset": 254, + "offset": 262, }, "start": { "column": 2, @@ -34815,9 +34634,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 247, - 254, + 262, ], - "raw": "loading", + "raw": "loading="eager"", "start": 247, "type": "JSXAttribute", "value": { @@ -34845,12 +34664,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 270, + "end": 293, "loc": { "end": { - "column": 7, + "column": 30, "line": 19, - "offset": 270, + "offset": 293, }, "start": { "column": 2, @@ -34883,9 +34702,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 265, - 270, + 293, ], - "raw": "style", + "raw": "style={{ display: 'block' }}", "start": 265, "type": "JSXAttribute", "value": { @@ -35005,12 +34824,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 302, + "end": 332, "loc": { "end": { - "column": 8, + "column": 38, "line": 20, - "offset": 302, + "offset": 332, }, "start": { "column": 2, @@ -35043,9 +34862,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 296, - 302, + 332, ], - "raw": "onLoad", + "raw": "onLoad={() => console.log('onLoad')}", "start": 296, "type": "JSXAttribute", "value": { @@ -35212,12 +35031,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 342, + "end": 373, "loc": { "end": { - "column": 9, + "column": 40, "line": 21, - "offset": 342, + "offset": 373, }, "start": { "column": 2, @@ -35250,9 +35069,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 335, - 342, + 373, ], - "raw": "onError", + "raw": "onError={() => console.log('onError')}", "start": 335, "type": "JSXAttribute", "value": { @@ -35419,12 +35238,12 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, }, { - "end": 383, + "end": 414, "loc": { "end": { - "column": 9, + "column": 40, "line": 22, - "offset": 383, + "offset": 414, }, "start": { "column": 2, @@ -35457,9 +35276,9 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` }, "range": [ 376, - 383, + 414, ], - "raw": "onClick", + "raw": "onClick={() => console.log('onClick')}", "start": 376, "type": "JSXAttribute", "value": { @@ -37821,6 +37640,899 @@ exports[`parser should match all AST snapshots: 450.mdx 1`] = ` } `; +exports[`parser should match all AST snapshots: 488.mdx 1`] = ` +{ + "body": [ + { + "end": 77, + "expression": { + "children": [], + "closingElement": null, + "end": 77, + "loc": { + "end": { + "column": 2, + "line": 7, + "offset": 77, + }, + "start": { + "column": 0, + "line": 1, + "offset": 0, + }, + }, + "openingElement": { + "attributes": [ + { + "end": 18, + "loc": { + "end": { + "column": 11, + "line": 2, + "offset": 18, + }, + "start": { + "column": 2, + "line": 2, + "offset": 9, + }, + }, + "name": { + "end": 12, + "loc": { + "end": { + "column": 5, + "line": 2, + "offset": 12, + }, + "start": { + "column": 2, + "line": 2, + "offset": 9, + }, + }, + "name": "alt", + "range": [ + 9, + 12, + ], + "raw": "alt", + "start": 9, + "type": "JSXIdentifier", + }, + "range": [ + 9, + 18, + ], + "raw": "alt="alt"", + "start": 9, + "type": "JSXAttribute", + "value": { + "end": 18, + "loc": { + "end": { + "column": 11, + "line": 2, + "offset": 18, + }, + "start": { + "column": 6, + "line": 2, + "offset": 13, + }, + }, + "range": [ + 13, + 18, + ], + "raw": ""alt"", + "start": 13, + "type": "Literal", + "value": "alt", + }, + }, + { + "end": 30, + "loc": { + "end": { + "column": 11, + "line": 3, + "offset": 30, + }, + "start": { + "column": 2, + "line": 3, + "offset": 21, + }, + }, + "name": { + "end": 24, + "loc": { + "end": { + "column": 5, + "line": 3, + "offset": 24, + }, + "start": { + "column": 2, + "line": 3, + "offset": 21, + }, + }, + "name": "src", + "range": [ + 21, + 24, + ], + "raw": "src", + "start": 21, + "type": "JSXIdentifier", + }, + "range": [ + 21, + 30, + ], + "raw": "src="src"", + "start": 21, + "type": "JSXAttribute", + "value": { + "end": 30, + "loc": { + "end": { + "column": 11, + "line": 3, + "offset": 30, + }, + "start": { + "column": 6, + "line": 3, + "offset": 25, + }, + }, + "range": [ + 25, + 30, + ], + "raw": ""src"", + "start": 25, + "type": "Literal", + "value": "src", + }, + }, + { + "end": 44, + "loc": { + "end": { + "column": 13, + "line": 4, + "offset": 44, + }, + "start": { + "column": 2, + "line": 4, + "offset": 33, + }, + }, + "name": { + "end": 38, + "loc": { + "end": { + "column": 7, + "line": 4, + "offset": 38, + }, + "start": { + "column": 2, + "line": 4, + "offset": 33, + }, + }, + "name": "width", + "range": [ + 33, + 38, + ], + "raw": "width", + "start": 33, + "type": "JSXIdentifier", + }, + "range": [ + 33, + 44, + ], + "raw": "width="315"", + "start": 33, + "type": "JSXAttribute", + "value": { + "end": 44, + "loc": { + "end": { + "column": 13, + "line": 4, + "offset": 44, + }, + "start": { + "column": 8, + "line": 4, + "offset": 39, + }, + }, + "range": [ + 39, + 44, + ], + "raw": ""315"", + "start": 39, + "type": "Literal", + "value": "315", + }, + }, + { + "end": 59, + "loc": { + "end": { + "column": 14, + "line": 5, + "offset": 59, + }, + "start": { + "column": 2, + "line": 5, + "offset": 47, + }, + }, + "name": { + "end": 53, + "loc": { + "end": { + "column": 8, + "line": 5, + "offset": 53, + }, + "start": { + "column": 2, + "line": 5, + "offset": 47, + }, + }, + "name": "height", + "range": [ + 47, + 53, + ], + "raw": "height", + "start": 47, + "type": "JSXIdentifier", + }, + "range": [ + 47, + 59, + ], + "raw": "height="100"", + "start": 47, + "type": "JSXAttribute", + "value": { + "end": 59, + "loc": { + "end": { + "column": 14, + "line": 5, + "offset": 59, + }, + "start": { + "column": 9, + "line": 5, + "offset": 54, + }, + }, + "range": [ + 54, + 59, + ], + "raw": ""100"", + "start": 54, + "type": "Literal", + "value": "100", + }, + }, + { + "end": 74, + "loc": { + "end": { + "column": 14, + "line": 6, + "offset": 74, + }, + "start": { + "column": 2, + "line": 6, + "offset": 62, + }, + }, + "name": { + "end": 68, + "loc": { + "end": { + "column": 8, + "line": 6, + "offset": 68, + }, + "start": { + "column": 2, + "line": 6, + "offset": 62, + }, + }, + "name": "format", + "range": [ + 62, + 68, + ], + "raw": "format", + "start": 62, + "type": "JSXIdentifier", + }, + "range": [ + 62, + 74, + ], + "raw": "format="svg"", + "start": 62, + "type": "JSXAttribute", + "value": { + "end": 74, + "loc": { + "end": { + "column": 14, + "line": 6, + "offset": 74, + }, + "start": { + "column": 9, + "line": 6, + "offset": 69, + }, + }, + "range": [ + 69, + 74, + ], + "raw": ""svg"", + "start": 69, + "type": "Literal", + "value": "svg", + }, + }, + ], + "end": 77, + "loc": { + "end": { + "column": 2, + "line": 7, + "offset": 77, + }, + "start": { + "column": 0, + "line": 1, + "offset": 0, + }, + }, + "name": { + "end": 6, + "loc": { + "end": { + "column": 6, + "line": 1, + "offset": 6, + }, + "start": { + "column": 1, + "line": 1, + "offset": 1, + }, + }, + "name": "Image", + "range": [ + 1, + 6, + ], + "raw": "Image", + "start": 1, + "type": "JSXIdentifier", + }, + "range": [ + 0, + 77, + ], + "raw": "alt", + "selfClosing": true, + "start": 0, + "type": "JSXOpeningElement", + }, + "range": [ + 0, + 77, + ], + "raw": "alt", + "start": 0, + "type": "JSXElement", + }, + "loc": { + "end": { + "column": 3, + "line": 7, + "offset": 77, + }, + "start": { + "column": 1, + "line": 1, + "offset": 0, + }, + }, + "range": [ + 0, + 77, + ], + "start": 0, + "type": "ExpressionStatement", + }, + ], + "comments": [], + "end": 78, + "loc": { + "end": { + "column": 1, + "line": 8, + "offset": 78, + }, + "start": { + "column": 1, + "line": 1, + "offset": 0, + }, + }, + "range": [ + 0, + 78, + ], + "sourceType": undefined, + "start": 0, + "tokens": [ + { + "end": 1, + "loc": { + "end": { + "column": 1, + "line": 1, + "offset": 1, + }, + "start": { + "column": 0, + "line": 1, + "offset": 0, + }, + }, + "range": [ + 0, + 1, + ], + "start": 0, + "type": "Punctuator", + "value": "<", + }, + { + "end": 6, + "loc": { + "end": { + "column": 6, + "line": 1, + "offset": 6, + }, + "start": { + "column": 1, + "line": 1, + "offset": 1, + }, + }, + "range": [ + 1, + 6, + ], + "start": 1, + "type": "JSXIdentifier", + "value": "Image", + }, + { + "end": 12, + "loc": { + "end": { + "column": 5, + "line": 2, + "offset": 12, + }, + "start": { + "column": 2, + "line": 2, + "offset": 9, + }, + }, + "range": [ + 9, + 12, + ], + "start": 9, + "type": "JSXIdentifier", + "value": "alt", + }, + { + "end": 13, + "loc": { + "end": { + "column": 6, + "line": 2, + "offset": 13, + }, + "start": { + "column": 5, + "line": 2, + "offset": 12, + }, + }, + "range": [ + 12, + 13, + ], + "start": 12, + "type": "Punctuator", + "value": "=", + }, + { + "end": 18, + "loc": { + "end": { + "column": 11, + "line": 2, + "offset": 18, + }, + "start": { + "column": 6, + "line": 2, + "offset": 13, + }, + }, + "range": [ + 13, + 18, + ], + "start": 13, + "type": "String", + "value": ""alt"", + }, + { + "end": 24, + "loc": { + "end": { + "column": 5, + "line": 3, + "offset": 24, + }, + "start": { + "column": 2, + "line": 3, + "offset": 21, + }, + }, + "range": [ + 21, + 24, + ], + "start": 21, + "type": "JSXIdentifier", + "value": "src", + }, + { + "end": 25, + "loc": { + "end": { + "column": 6, + "line": 3, + "offset": 25, + }, + "start": { + "column": 5, + "line": 3, + "offset": 24, + }, + }, + "range": [ + 24, + 25, + ], + "start": 24, + "type": "Punctuator", + "value": "=", + }, + { + "end": 30, + "loc": { + "end": { + "column": 11, + "line": 3, + "offset": 30, + }, + "start": { + "column": 6, + "line": 3, + "offset": 25, + }, + }, + "range": [ + 25, + 30, + ], + "start": 25, + "type": "String", + "value": ""src"", + }, + { + "end": 38, + "loc": { + "end": { + "column": 7, + "line": 4, + "offset": 38, + }, + "start": { + "column": 2, + "line": 4, + "offset": 33, + }, + }, + "range": [ + 33, + 38, + ], + "start": 33, + "type": "JSXIdentifier", + "value": "width", + }, + { + "end": 39, + "loc": { + "end": { + "column": 8, + "line": 4, + "offset": 39, + }, + "start": { + "column": 7, + "line": 4, + "offset": 38, + }, + }, + "range": [ + 38, + 39, + ], + "start": 38, + "type": "Punctuator", + "value": "=", + }, + { + "end": 44, + "loc": { + "end": { + "column": 13, + "line": 4, + "offset": 44, + }, + "start": { + "column": 8, + "line": 4, + "offset": 39, + }, + }, + "range": [ + 39, + 44, + ], + "start": 39, + "type": "String", + "value": ""315"", + }, + { + "end": 53, + "loc": { + "end": { + "column": 8, + "line": 5, + "offset": 53, + }, + "start": { + "column": 2, + "line": 5, + "offset": 47, + }, + }, + "range": [ + 47, + 53, + ], + "start": 47, + "type": "JSXIdentifier", + "value": "height", + }, + { + "end": 54, + "loc": { + "end": { + "column": 9, + "line": 5, + "offset": 54, + }, + "start": { + "column": 8, + "line": 5, + "offset": 53, + }, + }, + "range": [ + 53, + 54, + ], + "start": 53, + "type": "Punctuator", + "value": "=", + }, + { + "end": 59, + "loc": { + "end": { + "column": 14, + "line": 5, + "offset": 59, + }, + "start": { + "column": 9, + "line": 5, + "offset": 54, + }, + }, + "range": [ + 54, + 59, + ], + "start": 54, + "type": "String", + "value": ""100"", + }, + { + "end": 68, + "loc": { + "end": { + "column": 8, + "line": 6, + "offset": 68, + }, + "start": { + "column": 2, + "line": 6, + "offset": 62, + }, + }, + "range": [ + 62, + 68, + ], + "start": 62, + "type": "JSXIdentifier", + "value": "format", + }, + { + "end": 69, + "loc": { + "end": { + "column": 9, + "line": 6, + "offset": 69, + }, + "start": { + "column": 8, + "line": 6, + "offset": 68, + }, + }, + "range": [ + 68, + 69, + ], + "start": 68, + "type": "Punctuator", + "value": "=", + }, + { + "end": 74, + "loc": { + "end": { + "column": 14, + "line": 6, + "offset": 74, + }, + "start": { + "column": 9, + "line": 6, + "offset": 69, + }, + }, + "range": [ + 69, + 74, + ], + "start": 69, + "type": "String", + "value": ""svg"", + }, + { + "end": 76, + "loc": { + "end": { + "column": 1, + "line": 7, + "offset": 76, + }, + "start": { + "column": 0, + "line": 7, + "offset": 75, + }, + }, + "range": [ + 75, + 76, + ], + "start": 75, + "type": "Punctuator", + "value": "/", + }, + { + "end": 77, + "loc": { + "end": { + "column": 2, + "line": 7, + "offset": 77, + }, + "start": { + "column": 1, + "line": 7, + "offset": 76, + }, + }, + "range": [ + 76, + 77, + ], + "start": 76, + "type": "Punctuator", + "value": ">", + }, + ], + "type": "Program", +} +`; + exports[`parser should match all AST snapshots: acorn.mdx 1`] = `"Unexpected character \`\\\` (U+005C) in name, expected a name character such as letters, digits, \`$\`, or \`_\`; whitespace before attributes; or the end of the tag"`; exports[`parser should match all AST snapshots: adjacent.mdx 1`] = ` @@ -39052,28 +39764,6 @@ exports[`parser should match all AST snapshots: basic.mdx 1`] = ` "type": "Block", "value": " This is a comment ", }, - { - "end": 300, - "loc": { - "end": { - "column": 31, - "line": 19, - "offset": 300, - }, - "start": { - "column": 8, - "line": 19, - "offset": 277, - }, - }, - "range": [ - 277, - 300, - ], - "start": 277, - "type": "Block", - "value": " This is a comment ", - }, ], "end": 405, "loc": { @@ -40268,12 +40958,12 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 164, + "end": 168, "loc": { "end": { - "column": 3, + "column": 7, "line": 9, - "offset": 164, + "offset": 168, }, "start": { "column": 2, @@ -40306,9 +40996,9 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` }, "range": [ 163, - 164, + 168, ], - "raw": "p", + "raw": "p={3}", "start": 163, "type": "JSXAttribute", "value": { @@ -40358,12 +41048,12 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` }, }, { - "end": 173, + "end": 185, "loc": { "end": { - "column": 4, + "column": 16, "line": 10, - "offset": 173, + "offset": 185, }, "start": { "column": 2, @@ -40396,9 +41086,9 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` }, "range": [ 171, - 173, + 185, ], - "raw": "bg", + "raw": "bg='lightgray'", "start": 171, "type": "JSXAttribute", "value": { @@ -40426,12 +41116,12 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` }, }, { - "end": 193, + "end": 250, "loc": { "end": { - "column": 7, - "line": 11, - "offset": 193, + "column": 4, + "line": 14, + "offset": 250, }, "start": { "column": 2, @@ -40464,9 +41154,12 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` }, "range": [ 188, - 193, + 250, ], - "raw": "style", + "raw": "style={{ + textAlign: 'center', + fontWeight: 'bold', + }}", "start": 188, "type": "JSXAttribute", "value": { @@ -40776,12 +41469,12 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 608, + "end": 630, "loc": { "end": { - "column": 14, + "column": 36, "line": 31, - "offset": 608, + "offset": 630, }, "start": { "column": 7, @@ -40814,9 +41507,9 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` }, "range": [ 601, - 608, + 630, ], - "raw": "tweetId", + "raw": "tweetId="1116723357410447360"", "start": 601, "type": "JSXAttribute", "value": { @@ -41126,12 +41819,12 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 750, + "end": 764, "loc": { "end": { - "column": 16, + "column": 30, "line": 41, - "offset": 750, + "offset": 764, }, "start": { "column": 9, @@ -41164,9 +41857,9 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = ` }, "range": [ 743, - 750, + 764, ], - "raw": "videoId", + "raw": "videoId="4fHw4GeW3EU"", "start": 743, "type": "JSXAttribute", "value": { @@ -43075,12 +43768,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 13, + "end": 44, "loc": { "end": { - "column": 13, + "column": 44, "line": 1, - "offset": 13, + "offset": 44, }, "start": { "column": 9, @@ -43113,9 +43806,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 9, - 13, + 44, ], - "raw": "kind", + "raw": "kind="docs-packages-vuetify-preset"", "start": 9, "type": "JSXAttribute", "value": { @@ -43143,12 +43836,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, }, { - "end": 50, + "end": 57, "loc": { "end": { - "column": 50, + "column": 57, "line": 1, - "offset": 50, + "offset": 57, }, "start": { "column": 45, @@ -43181,9 +43874,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 45, - 50, + 57, ], - "raw": "story", + "raw": "story="page"", "start": 45, "type": "JSXAttribute", "value": { @@ -43374,12 +44067,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 148, + "end": 179, "loc": { "end": { - "column": 13, + "column": 44, "line": 5, - "offset": 148, + "offset": 179, }, "start": { "column": 9, @@ -43412,9 +44105,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 144, - 148, + 179, ], - "raw": "kind", + "raw": "kind="docs-packages-vuetify-preset"", "start": 144, "type": "JSXAttribute", "value": { @@ -43442,12 +44135,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, }, { - "end": 185, + "end": 192, "loc": { "end": { - "column": 50, + "column": 57, "line": 5, - "offset": 185, + "offset": 192, }, "start": { "column": 45, @@ -43480,9 +44173,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 180, - 185, + 192, ], - "raw": "story", + "raw": "story="page"", "start": 180, "type": "JSXAttribute", "value": { @@ -43673,12 +44366,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 283, + "end": 314, "loc": { "end": { - "column": 13, + "column": 44, "line": 9, - "offset": 283, + "offset": 314, }, "start": { "column": 9, @@ -43711,9 +44404,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 279, - 283, + 314, ], - "raw": "kind", + "raw": "kind="docs-packages-vuetify-preset"", "start": 279, "type": "JSXAttribute", "value": { @@ -43741,12 +44434,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, }, { - "end": 320, + "end": 327, "loc": { "end": { - "column": 50, + "column": 57, "line": 9, - "offset": 320, + "offset": 327, }, "start": { "column": 45, @@ -43779,9 +44472,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 315, - 320, + 327, ], - "raw": "story", + "raw": "story="page"", "start": 315, "type": "JSXAttribute", "value": { @@ -43972,12 +44665,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 418, + "end": 449, "loc": { "end": { - "column": 13, + "column": 44, "line": 13, - "offset": 418, + "offset": 449, }, "start": { "column": 9, @@ -44010,9 +44703,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 414, - 418, + 449, ], - "raw": "kind", + "raw": "kind="docs-packages-vuetify-preset"", "start": 414, "type": "JSXAttribute", "value": { @@ -44040,12 +44733,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, }, { - "end": 455, + "end": 462, "loc": { "end": { - "column": 50, + "column": 57, "line": 13, - "offset": 455, + "offset": 462, }, "start": { "column": 45, @@ -44078,9 +44771,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 450, - 455, + 462, ], - "raw": "story", + "raw": "story="page"", "start": 450, "type": "JSXAttribute", "value": { @@ -44271,12 +44964,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 553, + "end": 584, "loc": { "end": { - "column": 13, + "column": 44, "line": 17, - "offset": 553, + "offset": 584, }, "start": { "column": 9, @@ -44309,9 +45002,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 549, - 553, + 584, ], - "raw": "kind", + "raw": "kind="docs-packages-vuetify-preset"", "start": 549, "type": "JSXAttribute", "value": { @@ -44339,12 +45032,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, }, { - "end": 590, + "end": 597, "loc": { "end": { - "column": 50, + "column": 57, "line": 17, - "offset": 590, + "offset": 597, }, "start": { "column": 45, @@ -44377,9 +45070,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 585, - 590, + 597, ], - "raw": "story", + "raw": "story="page"", "start": 585, "type": "JSXAttribute", "value": { @@ -44570,12 +45263,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` "openingElement": { "attributes": [ { - "end": 688, + "end": 719, "loc": { "end": { - "column": 13, + "column": 44, "line": 21, - "offset": 688, + "offset": 719, }, "start": { "column": 9, @@ -44608,9 +45301,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 684, - 688, + 719, ], - "raw": "kind", + "raw": "kind="docs-packages-vuetify-preset"", "start": 684, "type": "JSXAttribute", "value": { @@ -44638,12 +45331,12 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, }, { - "end": 725, + "end": 732, "loc": { "end": { - "column": 50, + "column": 57, "line": 21, - "offset": 725, + "offset": 732, }, "start": { "column": 45, @@ -44676,9 +45369,9 @@ exports[`parser should match all AST snapshots: jsx-in-list.mdx 1`] = ` }, "range": [ 720, - 725, + 732, ], - "raw": "story", + "raw": "story="page"", "start": 720, "type": "JSXAttribute", "value": { @@ -49423,28 +50116,6 @@ exports[`parser should match all AST snapshots: no-unused-expressions.mdx 1`] = "type": "Block", "value": " HTML ", }, - { - "end": 54, - "loc": { - "end": { - "column": 24, - "line": 6, - "offset": 54, - }, - "start": { - "column": 14, - "line": 6, - "offset": 44, - }, - }, - "range": [ - 44, - 54, - ], - "start": 44, - "type": "Block", - "value": " HTML ", - }, ], "end": 90, "loc": { @@ -50804,28 +51475,6 @@ exports[`parser should match all AST snapshots: unicorn.mdx 1`] = ` "type": "Block", "value": " HTML ", }, - { - "end": 37, - "loc": { - "end": { - "column": 24, - "line": 3, - "offset": 37, - }, - "start": { - "column": 14, - "line": 3, - "offset": 27, - }, - }, - "range": [ - 27, - 37, - ], - "start": 27, - "type": "Block", - "value": " HTML ", - }, ], "end": 118, "loc": { diff --git a/test/fixtures.test.ts b/test/fixtures.test.ts index 9901762..1267827 100644 --- a/test/fixtures.test.ts +++ b/test/fixtures.test.ts @@ -2,8 +2,9 @@ import path from 'node:path' import { ESLint } from 'eslint' -const getCli = (lintCodeBlocks = false) => +const getCli = (lintCodeBlocks = false, fix?: boolean) => new ESLint({ + fix, ignore: false, useEslintrc: false, baseConfig: { @@ -28,6 +29,7 @@ const getCli = (lintCodeBlocks = false) => }, rules: { 'react/jsx-curly-brace-presence': 'error', + 'react/jsx-sort-props': 'error', 'react/self-closing-comp': 'error', }, overrides: lintCodeBlocks @@ -54,23 +56,42 @@ const getCli = (lintCodeBlocks = false) => describe('fixtures', () => { it('should match all snapshots', async () => { - const results = await getCli().lintFiles([ + let results = await getCli().lintFiles([ 'test/fixtures/*', 'test/fixtures/**/*{md,mdx}', ]) for (const { filePath, messages } of results) { expect(messages).toMatchSnapshot(path.basename(filePath)) } + results = await getCli(false, true).lintFiles([ + 'test/fixtures/*', + 'test/fixtures/**/*{md,mdx}', + ]) + for (const { filePath, source, output } of results) { + if (source !== output) { + // eslint-disable-next-line jest/no-conditional-expect + expect(output).toMatchSnapshot(path.basename(filePath)) + } + } }) describe('lint code blocks', () => { it('should work as expected', async () => { - const results = await getCli(true).lintFiles( + let results = await getCli(true).lintFiles( 'test/fixtures/**/code-blocks.{md,mdx}', ) for (const { filePath, messages } of results) { expect(messages).toMatchSnapshot(path.basename(filePath)) } + results = await getCli(true, true).lintFiles( + 'test/fixtures/**/code-blocks.{md,mdx}', + ) + for (const { filePath, source, output } of results) { + if (source !== output) { + // eslint-disable-next-line jest/no-conditional-expect + expect(output).toMatchSnapshot(path.basename(filePath)) + } + } }) }) }) diff --git a/test/fixtures/488.mdx b/test/fixtures/488.mdx new file mode 100644 index 0000000..f356b66 --- /dev/null +++ b/test/fixtures/488.mdx @@ -0,0 +1,7 @@ +alt