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

Extra spaces and backslashes in MDX v2+ JSDoc comments #16457

Closed
karlhorky opened this issue Jul 7, 2024 · 3 comments
Closed

Extra spaces and backslashes in MDX v2+ JSDoc comments #16457

karlhorky opened this issue Jul 7, 2024 · 3 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:duplicate Issues that are a duplicate of a previous issue

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Jul 7, 2024

Prettier 3.3.2
Playground link

--parser mdx

Input:

{/**
  * @typedef Props
  * @property {string} name
  *   Who to greet.
  */}

{/** @typedef Props @property {string} name2 Who to greet. */}

# Hello {props.name} and {props.name2}

Output:

{/\*\*

- @typedef Props
- @property {string} name
- Who to greet.
  \*/}

{/* * @typedef Props @property {string} name2 Who to greet. */}

# Hello {props.name} and {props.name2}

Expected output:

{/**
  * @typedef Props
  * @property {string} name
  *   Who to greet.
  */}

{/** @typedef Props @property {string} name2 Who to greet. */}

# Hello {props.name} and {props.name2}

(no formatting change from Input)

Why?

JSDoc has meaning and functionality in MDX documents (see the Props section of MDX Analyzer docs), which is broken by the extra spaces and backslashes added above.

As an extension to the MDX v2 comments feature by @wooorm, it would be great to support:

  1. JSDoc in MDX v2+ multi-line comments
  2. JSDoc in MDX v2+ single-line comments

Related

@karlhorky karlhorky changed the title Extra spaces and backslashes in MDX v2+ JSDoc Comments Extra spaces and backslashes in MDX v2+ JSDoc comments Jul 7, 2024
@kachkaev
Copy link
Member

kachkaev commented Jul 7, 2024

👋 @karlhorky! I believe that this particular issue is a part of this one:

Not sure we can do much until we upgrade the parser, and when it’s done, the problem will probably self-resolve. If that’s not the case here, let me know and I’ll re-open the issue.

@kachkaev kachkaev closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2024
@kachkaev kachkaev added the type:duplicate Issues that are a duplicate of a previous issue label Jul 7, 2024
@karlhorky
Copy link
Contributor Author

karlhorky commented Jul 8, 2024

Yeah, I thought so at first too. But since MDX v2/v3 comments support was already implemented by @wooorm before that issue was opened, I thought JSDoc support may be able to be a natural extension of that:

(especially the single-line comment variant, number 2 in the PR description above)

@karlhorky
Copy link
Contributor Author

Workaround

Ignore any JSDoc comments until MDX v2+ comments w. JSDoc support added:

{/* prettier-ignore-start */}

{/**
  * @typedef Props
  * @property {string} name
  *   Who to greet.
  */}

{/* prettier-ignore-end */}

# Hello {props.name}

Also added an MDX Analyzer PR here:

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Oct 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:duplicate Issues that are a duplicate of a previous issue
Projects
None yet
Development

No branches or pull requests

2 participants