Format JSON.parse string literals #7043
Labels
area:multiparser
Issues with printing one language inside another, like CSS-in-JS
lang:javascript
Issues affecting JS
locked-due-to-inactivity
Please open a new issue and fill out the template instead of commenting.
status:needs discussion
Issues needing discussion and a decision to be made before action can be taken
Prettier 1.19.1
Playground link
Input:
Output:
Expected behavior:
For more complex JavaScript objects, it can be faster and more reliable to use
JSON.parse
with an inline string rather than just using an object literal (explanation). It would be useful if Prettier could format strings passed directly toJSON.parse
as embedded JSON, so they look like what would happen if you loaded and parsed a separate JSON file formatted with Prettier. Note that template strings work withJSON.parse
in JavaScript, but we'd have to handle edge cases when formatting template variables.The text was updated successfully, but these errors were encountered: