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
Change default value for quoteProps option to "preserve" for JSON5 #4639
Comments
IMO we should keep it as-is and fix the bugs in editors. |
@suchipi I would like to put a vote in for keeping It really is surprising/frustrating when the editor and the babel docs, here for example still default to "normal" JSON. |
When people write JSON5 (in a way which makes it invalid JSON), do they tend to omit the quotes? Is there a way that could be assessed? |
Hi, I'm the current maintainer for JSON5. To answer your question, it's a bit of a mixed bag. The official JSON5 library outputs unquoted keys where possible, and single quoted otherwise. When handwriting JSON5, I prefer to keep all of my keys unquoted if possible, but quote all of my keys if at least one of them must be quoted, just for consistency. I would say that most JSON5 documents are able to just use unquoted keys. (i.e. most keys in JSON and JSON5 documents are valid identifiers.) My opinion would be to keep unquoted keys unquoted, and change the quote character for quoted keys according to the config file. For example, with the default config: { a: 1, 'b': 2, "c": 3 } becomes { a: 1, "b": 2, "c": 3 } |
@jordanbtucker In other words, you propose that the default value for the Prettier 2.0.5 --parser json5
--quote-props preserve Input: { a: 1, 'b': 2, "c": 3 } Output: { a: 1, "b": 2, "c": 3 } |
@thorn0 I suppose so. Although I personally wouldn't want that to be the default for my JS files, haha. |
This issue was opened when the |
Changing the default would be a breaking change though. I'm not sure what exactly it can break in this specific case, but usually we consider such changes breaking and suppose that they need a major version bump. So it's probably not worth the trouble. Prettier has the option now, those who need it can use it. |
Makes sense to me. Is there a way to mark this change to be added in the next major version? |
I'm going to postpone this, since it's not been discussed for a long time. |
Context:
#4636 (comment) by @suchipi:
#4636 (comment) by @ikatyang:
Should we change the JSON5 printer to not convert object keys to identifiers?
I'm thinking yes, since JSON5 support in editors is hit or miss- for example, VS Code treats .babelrc as a JSON file instead of JSON5.
Personally, the only JSON5 feature I've ever leveraged was comments. But that's only one data point.
The text was updated successfully, but these errors were encountered: