You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background
Certain config files, including VSCode's config files, support a relaxed JSON syntax where:
comments are allowed
trailing commas are allowed
keys must still be quoted, just like in real JSON
(VSCode calls this syntax "JSON with Comments".)
Example of issue
I'm trying to have prettier-vscode format my VSCode settings.json and keybindings.json files. Sometimes these files are automatically modified by VSCode (for example, when changing UI zoom).
Sometimes these files are modified directly by me.
When VSCode automatically modifies these files, it applies trailing commas, so I'd like have Prettier do the same. But this doesn't seem possible: There is no way to force vscode-prettier to respect my trailingComma setting because #143 force-turns it off when the Prettier parser is json. I can edit prettierrc to change the parser to babylon or flow, but then Prettier will unquote keys, resulting in an invalid config.
Escalate this issue to Prettier -- propose that prettier supports two different JSON parsers, one which is strict and one which is the relaxed style. They can still use the same parser implementation -- the only difference being that when using the strict JSON parser, trailing commas will always be removed. Then Fix json and trailing comma #143, which is sort of a hack, probably won't be needed either.
I'm happy to PR a fix for this, please just let me either of the above solutions seems like a good idea. (Implementation tips would be appreciated too.)
Background
Certain config files, including VSCode's config files, support a relaxed JSON syntax where:
(VSCode calls this syntax "JSON with Comments".)
Example of issue
I'm trying to have
prettier-vscodeformat my VSCodesettings.jsonandkeybindings.jsonfiles. Sometimes these files are automatically modified by VSCode (for example, when changing UI zoom).Sometimes these files are modified directly by me.
When VSCode automatically modifies these files, it applies trailing commas, so I'd like have Prettier do the same. But this doesn't seem possible: There is no way to force
vscode-prettierto respect mytrailingCommasetting because #143 force-turns it off when the Prettier parser isjson. I can editprettierrcto change the parser tobabylonorflow, but then Prettier will unquote keys, resulting in an invalid config.Potential solutions
I'm happy to PR a fix for this, please just let me either of the above solutions seems like a good idea. (Implementation tips would be appreciated too.)