|
35 | 35 | - [Classic](#classic)
|
36 | 36 | - [Flat Config](#flat-config)
|
37 | 37 | - [Parser Options](#parser-options)
|
| 38 | +- [Parser API](#parser-api) |
| 39 | + - [`MDXCode`](#mdxcode) |
| 40 | + - [`MDXHeading`](#mdxheading) |
| 41 | + - [Typings](#typings) |
38 | 42 | - [Rules](#rules)
|
39 | 43 | - [mdx/remark](#mdxremark)
|
40 | 44 | - [Prettier Integration](#prettier-integration)
|
|
47 | 51 |
|
48 | 52 | [](https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx)
|
49 | 53 |
|
50 |
| -[VSCode MDX][]\: Integrates with [VSCode ESLint][], syntaxes highlighting and error reporting. |
| 54 | +[VSCode MDX][]: Integrates with [VSCode ESLint][], syntaxes highlighting and error reporting. |
51 | 55 |
|
52 | 56 | ## Packages
|
53 | 57 |
|
@@ -137,6 +141,56 @@ eslint . --ext js,md,mdx
|
137 | 141 |
|
138 | 142 | 3. `ignoreRemarkConfig` (`boolean`): Ignore the `remark` configuration defined in the project.
|
139 | 143 |
|
| 144 | +## Parser API |
| 145 | + |
| 146 | +### `MDXCode` |
| 147 | + |
| 148 | +A new `MDXCode` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following: |
| 149 | + |
| 150 | +````mdx |
| 151 | +<div> |
| 152 | + ```js |
| 153 | + export function foo() { |
| 154 | + return 'bar' |
| 155 | + } |
| 156 | + ``` |
| 157 | +</div> |
| 158 | +```` |
| 159 | + |
| 160 | +See also <https://github.com/syntax-tree/mdast#code> |
| 161 | + |
| 162 | +### `MDXHeading` |
| 163 | + |
| 164 | +A new `MDXHeading` estree node type is exported from `eslint-mdx` which represents markdown heading in `mdx` like the following: |
| 165 | + |
| 166 | +```mdx |
| 167 | +<div># Here's a text gradient short code!</div> |
| 168 | +``` |
| 169 | + |
| 170 | +See also <https://github.com/syntax-tree/mdast#heading> |
| 171 | + |
| 172 | +### Typings |
| 173 | + |
| 174 | +```ts |
| 175 | +import type { BaseNode } from 'estree' |
| 176 | +import type { JSXElement } from 'estree-jsx' |
| 177 | + |
| 178 | +export interface MDXCode extends BaseNode { |
| 179 | + type: 'MDXCode' |
| 180 | + value: string |
| 181 | + lang?: string | null |
| 182 | + meta?: string | null |
| 183 | +} |
| 184 | + |
| 185 | +export type HeadingDepth = 1 | 2 | 3 | 4 | 5 | 6 |
| 186 | + |
| 187 | +export interface MDXHeading extends BaseNode { |
| 188 | + type: 'MDXHeading' |
| 189 | + depth: HeadingDepth |
| 190 | + children: JSXElement['children'] |
| 191 | +} |
| 192 | +``` |
| 193 | + |
140 | 194 | ## Rules
|
141 | 195 |
|
142 | 196 | ### mdx/remark
|
|
0 commit comments