Skip to content

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

@edazpotato

Description

@edazpotato

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

Metadata

Metadata

Assignees

Labels

area:commentsIssues with how Prettier prints commentslang:jsxIssues affecting JSX (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions