-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[JSON] Trailing comments are not handled #5263
Copy link
Copy link
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentslang:jsonIssues affecting JSONIssues affecting JSONlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!
Milestone
Description
We use the js expression parser (which shares the same printer with JSON) to parse binding syntax in HTML, but the trailing comments are removed (reported by #5259 (comment)).
Prettier 1.14.3
Playground link
--parser jsonInput:
Output:
Error: Comment "TODO: use id when links will be provided by API" was not printed. Please report this error!
at https://prettier.io/lib/standalone.js:10671:13
at Array.forEach (<anonymous>)
at ensureAllCommentsPrinted (https://prettier.io/lib/standalone.js:10669:15)
at coreFormat (https://prettier.io/lib/standalone.js:10719:3)
at format (https://prettier.io/lib/standalone.js:10874:16)
at formatWithCursor (https://prettier.io/lib/standalone.js:10886:12)
at https://prettier.io/lib/standalone.js:21134:15
at Object.format (https://prettier.io/lib/standalone.js:21142:12)
at formatCode (https://prettier.io/worker.js:188:21)
at handleMessage (https://prettier.io/worker.js:139:18)Expected behavior:
Comments are printed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentslang:jsonIssues affecting JSONIssues affecting JSONlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!
index /* TODO: use id when links will be provided by API */