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

Bug: functions in MDX are not formatted if there is at least one empty line #16241

Open
everdimension opened this issue Apr 29, 2024 · 2 comments

Comments

@everdimension
Copy link

Prettier 3.2.5
Playground link

# Options (if any):
--parser mdx

Input:

export function Example1() {
  /** NOT formatted because has empty line */
  const x =     '42';

  return x;
}

Output:

export function Example1() {
  /** NOT formatted because has empty line */
  const x =     '42';

return x;
}

Expected output:

export function Example1() {
  /** NOT formatted because has empty line */
  const x = "42";

  return x;
}

Why?

Seems to be a bug when there is an empty line. If the line has at least some whitespace, of if there are no lines, the formatting works as expected.

Related: #13934

@obunga99
Copy link

export function Example1() {
/** NOT formatted because has empty line */
const x = '42';

return x;
}

I removed the extra empty line before the return statement and replaced the double quotes around the string constant with single quotes, I thino that's what is in the original cpde.

@obunga99
Copy link

or you can make a function that removes extra spaces based on specific choices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants