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

Using inline comments (/* */) before an element attribute's value in JSX causes document to not be formatted #11242

Closed
edazpotato opened this issue Jul 23, 2021 · 1 comment · Fixed by #14082
Assignees
Labels
area:comments Issues with how Prettier prints comments lang:jsx Issues affecting JSX (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@edazpotato
Copy link

edazpotato commented Jul 23, 2021

Prettier 2.3.2
Playground link

--parser babel

Input:

function MyFunctionComponent() {
	<button label=/*old*/"new">button</button>
}

Output:

Error: Comment "old" was not printed. Please report this error!
    at Object.ensureAllCommentsPrinted (https://prettier.io/lib/standalone.js:36:119166)
    at Sd (https://prettier.io/lib/standalone.js:36:125590)
    at Nd (https://prettier.io/lib/standalone.js:36:128103)
    at Object.formatWithCursor (https://prettier.io/lib/standalone.js:76:38121)
    at formatCode (https://prettier.io/worker.js:141:21)
    at handleMessage (https://prettier.io/worker.js:78:26)
    at self.onmessage (https://prettier.io/worker.js:36:14)

Expected behaviour:
The document should be formatted as usual

@sosukesuzuki sosukesuzuki added area:comments Issues with how Prettier prints comments lang:jsx Issues affecting JSX (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program labels Jul 23, 2021
@sosukesuzuki
Copy link
Member

Workaround
Prettier 2.3.2
Playground link

--parser babel

Input:

function MyFunctionComponent() {
	<button label=/*e*/{"e"}>button</button>
}

Output:

function MyFunctionComponent() {
  <button label=/*e*/ {"e"}>button</button>;
}

@fisker fisker self-assigned this Dec 29, 2022
fisker added a commit that referenced this issue Dec 30, 2022
@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 Nov 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2023
medikoo pushed a commit to medikoo/prettier-elastic that referenced this issue Jan 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:comments Issues with how Prettier prints comments lang:jsx Issues affecting JSX (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants