Skip to content

Commit

Permalink
refactor: change MDXJSX* to MDX* nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Dec 11, 2023
1 parent 65b3946 commit 041402d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
- [Flat Config](#flat-config)
- [Parser Options](#parser-options)
- [Parser API](#parser-api)
- [`MDXJSXCode`](#mdxjsxcode)
- [`MDXJSXHeading`](#mdxjsxheading)
- [`MDXCode`](#mdxcode)
- [`MDXHeading`](#mdxheading)
- [Typings](#typings)
- [Rules](#rules)
- [mdx/remark](#mdxremark)
Expand Down Expand Up @@ -143,9 +143,9 @@ eslint . --ext js,md,mdx

## Parser API

### `MDXJSXCode`
### `MDXCode`

A new `MDXJSXCode` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:
A new `MDXCode` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:

````mdx
<div>
Expand All @@ -161,9 +161,9 @@ export function foo() {

See also <https://github.com/syntax-tree/mdast#code>

### `MDXJSXHeading`
### `MDXHeading`

A new `MDXJSXHeading` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:
A new `MDXHeading` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:

```mdx
<div>
Expand All @@ -181,17 +181,17 @@ See also <https://github.com/syntax-tree/mdast#heading>
import type { BaseNode } from 'estree'
import type { JSXElement } from 'estree-jsx'

export interface MDXJSXCode extends BaseNode {
type: 'MDXJSXCode'
export interface MDXCode extends BaseNode {
type: 'MDXCode'
value: string
lang?: string | null
meta?: string | null
}

export type HeadingDepth = 1 | 2 | 3 | 4 | 5 | 6

export interface MDXJSXHeading extends BaseNode {
type: 'MDXJSXHeading'
export interface MDXHeading extends BaseNode {
type: 'MDXHeading'
depth: HeadingDepth
children: JSXElement['children']
}
Expand Down
20 changes: 10 additions & 10 deletions packages/eslint-mdx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
- [Flat Config](#flat-config)
- [Parser Options](#parser-options)
- [Parser API](#parser-api)
- [`MDXJSXCode`](#mdxjsxcode)
- [`MDXJSXHeading`](#mdxjsxheading)
- [`MDXCode`](#mdxjsxcode)
- [`MDXHeading`](#mdxjsxheading)
- [Typings](#typings)
- [Rules](#rules)
- [mdx/remark](#mdxremark)
Expand Down Expand Up @@ -143,9 +143,9 @@ eslint . --ext js,md,mdx

## Parser API

### `MDXJSXCode`
### `MDXCode`

A new `MDXJSXCode` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:
A new `MDXCode` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:

````mdx
<div>
Expand All @@ -161,9 +161,9 @@ export function foo() {

See also <https://github.com/syntax-tree/mdast#code>

### `MDXJSXHeading`
### `MDXHeading`

A new `MDXJSXHeading` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:
A new `MDXHeading` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:

```mdx
<div>
Expand All @@ -181,17 +181,17 @@ See also <https://github.com/syntax-tree/mdast#heading>
import type { BaseNode } from 'estree'
import type { JSXElement } from 'estree-jsx'

export interface MDXJSXCode extends BaseNode {
type: 'MDXJSXCode'
export interface MDXCode extends BaseNode {
type: 'MDXCode'
value: string
lang?: string | null
meta?: string | null
}

export type HeadingDepth = 1 | 2 | 3 | 4 | 5 | 6

export interface MDXJSXHeading extends BaseNode {
type: 'MDXJSXHeading'
export interface MDXHeading extends BaseNode {
type: 'MDXHeading'
depth: HeadingDepth
children: JSXElement['children']
}
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-mdx/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ type _Arrayable<T, R = T extends Array<infer U> ? U : T> = R | R[]

export type Arrayable<T> = _Arrayable<T>

export interface MDXJSXCode extends BaseNode {
type: 'MDXJSXCode'
export interface MDXCode extends BaseNode {
type: 'MDXCode'
value: string
lang?: string | null
meta?: string | null
}

export type HeadingDepth = 1 | 2 | 3 | 4 | 5 | 6

export interface MDXJSXHeading extends BaseNode {
type: 'MDXJSXHeading'
export interface MDXHeading extends BaseNode {
type: 'MDXHeading'
depth: HeadingDepth
children: JSXElement['children']
}
12 changes: 6 additions & 6 deletions packages/eslint-mdx/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import {
import { restoreTokens } from './tokens'
import type {
Arrayable,
MDXJSXCode,
MDXJSXHeading,
MDXCode,
MDXHeading,
NormalPosition,
WorkerOptions,
WorkerResult,
Expand Down Expand Up @@ -450,9 +450,9 @@ runAsWorker(

if (node.type === 'code') {
const { lang, meta, value } = node as Code
const mdxJsxCode: MDXJSXCode = {
const mdxJsxCode: MDXCode = {
...normalizeNode(start, end),
type: 'MDXJSXCode',
type: 'MDXCode',
lang,
meta,
value,
Expand All @@ -462,9 +462,9 @@ runAsWorker(

if (node.type === 'heading') {
const { depth } = node as Heading
const mdxJsxHeading: MDXJSXHeading = {
const mdxJsxHeading: MDXHeading = {
...normalizeNode(start, end),
type: 'MDXJSXHeading',
type: 'MDXHeading',
depth,
children: handleChildren(node),
}
Expand Down
20 changes: 10 additions & 10 deletions packages/eslint-plugin-mdx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
- [Flat Config](#flat-config)
- [Parser Options](#parser-options)
- [Parser API](#parser-api)
- [`MDXJSXCode`](#mdxjsxcode)
- [`MDXJSXHeading`](#mdxjsxheading)
- [`MDXCode`](#mdxjsxcode)
- [`MDXHeading`](#mdxjsxheading)
- [Typings](#typings)
- [Rules](#rules)
- [mdx/remark](#mdxremark)
Expand Down Expand Up @@ -143,9 +143,9 @@ eslint . --ext js,md,mdx

## Parser API

### `MDXJSXCode`
### `MDXCode`

A new `MDXJSXCode` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:
A new `MDXCode` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:

````mdx
<div>
Expand All @@ -161,9 +161,9 @@ export function foo() {

See also <https://github.com/syntax-tree/mdast#code>

### `MDXJSXHeading`
### `MDXHeading`

A new `MDXJSXHeading` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:
A new `MDXHeading` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:

```mdx
<div>
Expand All @@ -181,17 +181,17 @@ See also <https://github.com/syntax-tree/mdast#heading>
import type { BaseNode } from 'estree'
import type { JSXElement } from 'estree-jsx'

export interface MDXJSXCode extends BaseNode {
type: 'MDXJSXCode'
export interface MDXCode extends BaseNode {
type: 'MDXCode'
value: string
lang?: string | null
meta?: string | null
}

export type HeadingDepth = 1 | 2 | 3 | 4 | 5 | 6

export interface MDXJSXHeading extends BaseNode {
type: 'MDXJSXHeading'
export interface MDXHeading extends BaseNode {
type: 'MDXHeading'
depth: HeadingDepth
children: JSXElement['children']
}
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/parser.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3534,7 +3534,7 @@ function foo() {
}
\`\`\`",
"start": 24,
"type": "MDXJSXCode",
"type": "MDXCode",
"value": "function foo() {
return 123;
}",
Expand Down Expand Up @@ -40966,7 +40966,7 @@ exports[`parser should match all AST snapshots: blank-lines.mdx 1`] = `
],
"raw": "# Here's a text gradient shortcode!",
"start": 651,
"type": "MDXJSXHeading",
"type": "MDXHeading",
},
],
"closingElement": {
Expand Down

0 comments on commit 041402d

Please sign in to comment.