Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format MDX files? #32

Open
karlhorky opened this issue Oct 6, 2024 · 0 comments
Open

Format MDX files? #32

karlhorky opened this issue Oct 6, 2024 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Oct 6, 2024

Is your feature request related to a problem? Please describe.

MDX files are not currently sorted and unused imports and exports are not removed

Describe the solution you'd like

Similar to Vue support, also support MDX files (.mdx extension), which can include import and export statements

Example file from MDX homepage:

index.mdx

import {Chart} from './snowfall.js'
export const year = 2023

# Last year’s snowfall

In {year}, the snowfall was above average.
It was followed by a warm spring which caused
flood conditions in many of the nearby rivers.

<Chart year={year} color="#fcb32c" />

This will probably require:

  1. A custom parser (maybe with @mdx-js/mdx? or maybe something lower level from the unified ecosystem)
  2. Maybe also a custom formatter? Although the imports / exports should be "just JavaScript"...

Describe alternatives you've considered

Avoiding parsing: Match and format only import and export statements at the top of the document (eg. using regular expressions)

But this would be brittle and would fail in many cases.

Additional context

--

@daidodo daidodo added enhancement New feature or request help wanted Extra attention is needed labels Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants