Closed karol-brejna-i closed 2 years ago
Yes, that's one of the few configuration options prettier provides. See https://prettier.io/docs/en/options.html
If you're only using prettier inside of vscode, you can just go to settings, type "Trailing Comma" into the search box, and the option should appear. Set it to "none".
But note that generally, the preferred way to set prettier's options is via a config file (see https://prettier.io/docs/en/configuration.html), so that prettier behaves the same whether you run it from inside vscode, or from the command line.
By the way, the main reason for adding the trailing commas is source control: if you add more items at the end of the list, and you always have trailing commas, then the only affected lines are the new ones. If you don't add the trailing comma, then the last existing line is also modified, making it look like more lines were changed than was really the case. Similarly for deleting lines.
This makes me realize there is a potential problem though... setting trailing-comma to "all" would add trailing commas at the end of function call parameter lists - which wouldn't compile. And worse, my parser wouldn't accept it either, so it wouldn't be able to undo the change, even after switching the option back. There's a similar problem with the "semicolon" option. I'll fix those...
I pushed version 1.0.8 which doesn't allow options.trailingComma=all
or options.semi=false
, and which can fix the effects of using options.trailingComma=all
with an earlier version of the plugin.
When formating monkey C array, the following:
becomes:
Similarly, for dict:
becomes:
Is there a way to disable this feature?