From 041402daa563d98405d206e2ae0a2e73357f8195 Mon Sep 17 00:00:00 2001 From: JounQin Date: Mon, 11 Dec 2023 21:34:37 +0800 Subject: [PATCH] refactor: change MDXJSX* to MDX* nodes --- README.md | 20 ++++++++++---------- packages/eslint-mdx/README.md | 20 ++++++++++---------- packages/eslint-mdx/src/types.ts | 8 ++++---- packages/eslint-mdx/src/worker.ts | 12 ++++++------ packages/eslint-plugin-mdx/README.md | 20 ++++++++++---------- test/__snapshots__/parser.test.ts.snap | 4 ++-- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index cca04b5..338d444 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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
@@ -161,9 +161,9 @@ export function foo() { See also -### `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
@@ -181,8 +181,8 @@ See also 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 @@ -190,8 +190,8 @@ export interface MDXJSXCode extends BaseNode { 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'] } diff --git a/packages/eslint-mdx/README.md b/packages/eslint-mdx/README.md index cca04b5..b8346cb 100644 --- a/packages/eslint-mdx/README.md +++ b/packages/eslint-mdx/README.md @@ -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) @@ -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
@@ -161,9 +161,9 @@ export function foo() { See also -### `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
@@ -181,8 +181,8 @@ See also 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 @@ -190,8 +190,8 @@ export interface MDXJSXCode extends BaseNode { 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'] } diff --git a/packages/eslint-mdx/src/types.ts b/packages/eslint-mdx/src/types.ts index ac1bcc2..51a1bdd 100644 --- a/packages/eslint-mdx/src/types.ts +++ b/packages/eslint-mdx/src/types.ts @@ -49,8 +49,8 @@ type _Arrayable ? U : T> = R | R[] export type Arrayable = _Arrayable -export interface MDXJSXCode extends BaseNode { - type: 'MDXJSXCode' +export interface MDXCode extends BaseNode { + type: 'MDXCode' value: string lang?: string | null meta?: string | null @@ -58,8 +58,8 @@ export interface MDXJSXCode extends BaseNode { 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'] } diff --git a/packages/eslint-mdx/src/worker.ts b/packages/eslint-mdx/src/worker.ts index 69da201..2dd50f5 100644 --- a/packages/eslint-mdx/src/worker.ts +++ b/packages/eslint-mdx/src/worker.ts @@ -51,8 +51,8 @@ import { import { restoreTokens } from './tokens' import type { Arrayable, - MDXJSXCode, - MDXJSXHeading, + MDXCode, + MDXHeading, NormalPosition, WorkerOptions, WorkerResult, @@ -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, @@ -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), } diff --git a/packages/eslint-plugin-mdx/README.md b/packages/eslint-plugin-mdx/README.md index cca04b5..b8346cb 100644 --- a/packages/eslint-plugin-mdx/README.md +++ b/packages/eslint-plugin-mdx/README.md @@ -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) @@ -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
@@ -161,9 +161,9 @@ export function foo() { See also -### `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
@@ -181,8 +181,8 @@ See also 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 @@ -190,8 +190,8 @@ export interface MDXJSXCode extends BaseNode { 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'] } diff --git a/test/__snapshots__/parser.test.ts.snap b/test/__snapshots__/parser.test.ts.snap index e7ac9a3..0b3cb3e 100644 --- a/test/__snapshots__/parser.test.ts.snap +++ b/test/__snapshots__/parser.test.ts.snap @@ -3534,7 +3534,7 @@ function foo() { } \`\`\`", "start": 24, - "type": "MDXJSXCode", + "type": "MDXCode", "value": "function foo() { return 123; }", @@ -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": {