Take the following code:
var foos = new[]
{
new Foo(),
new Bar()
};
If later a new item is added:
var foos = new[]
{
new Foo(),
new Bar(),
new Baz()
};
This causes the following issues:
- A misleading commit diff of
+2/-1 even though there isn't really any code deletion.
- Polluting git blame.
These issues also occur when deleting/reordering the last item in initializers.
These issues can be fixed by enforcing trailing commas.
Relevant Prettier option: https://prettier.io/docs/en/options.html#trailing-commas
Take the following code:
If later a new item is added:
This causes the following issues:
+2/-1even though there isn't really any code deletion.These issues also occur when deleting/reordering the last item in initializers.
These issues can be fixed by enforcing trailing commas.
Relevant Prettier option: https://prettier.io/docs/en/options.html#trailing-commas