[JSON] Trailing comments are not handled
See original GitHub issueWe 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 https://github.com/prettier/prettier/pull/5259#issuecomment-429571079).
Prettier 1.14.3 Playground link
--parser json
Input:
index /* TODO: use id when links will be provided by API */
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.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Can you use a trailing comma in a JSON object?
No. The JSON spec, as maintained at http://json.org, does not allow trailing commas. From ...
Read more >Allow JSON with trailing commas #5708 - GitHub
I'm looking for a way to support the following style: JSON-based; Always quote keys; Always include trailing commas.
Read more >JSON with Commas and Comments - Hacker News
As JSON is based on JavaScript's syntax prior to ES5, trailing commas are not allowed in JSON. json was largely `eval`d when it...
Read more >How to allow some kinds of invalid JSON with System.Text.Json
By default, comments and trailing commas are not allowed in JSON. To allow comments in the JSON, set the JsonSerializerOptions.
Read more >Why JSON doesn't support comments (Douglas Crockford)
Then you get not only comments, but also lots of other syntax niceties ... The lack of support for trailing commas and the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@michaeljota It’s indeed a
vue
-only issue after we switch to use angular-estree-parser for angular expression.(Angular only allows a single-line comment at the end of the expression, excluding microsyntax.)
@ikatyang hey! I didn’t start it. go ahead 🤘