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
TL;DR: The new Dart formatter (3.7.0) automatically removes trailing commas, which changes code formatting in an undesirable way. This contradicts the require_trailing_commas linter rule and removes the ability to force line breaks. A workaround exists (adding // comments), but it's inconvenient. A setting to restore the old behavior or prevent automatic comma removal would be greatly appreciated.
Could there be an option to preserve the trailing commas, so they are not automatically removed? That way, developers who rely on them for readability or structure would still be able to use them without the formatter interfering. This would give us more control over the formatting style while still maintaining some level of automation.
I really liked the ability to force a line wrap by placing a comma at the end of a line. However, with the new formatter, this trailing comma is automatically removed.
This feels awkward and changes the code style in a way that I really don’t like.
It would be great if there were an option to prevent the automatic removal of trailing commas.
As jamesderlin pointed out, there’s an annoying workaround:
I think I'm going to have to resign myself to adding a superfluous empty // comment at every site where I don't want the formatter to remove an explicit trailing comma.
Sure, this keeps the comma, but having to do this for every line? That’s just monkey business... 🐵🍌
In some cases, the new formatting even contradicts the require_trailing_commas linter rule.
I completely agree require_trailing_commas should take precedence over this new change. It would be great if this behavior could be reconsidered.
Oneother example:
Old way:
New way (BAD):
My IDE even shows errors because it says a trailing comma is required. 🤕
Sure, the new approach removes seven lines, but the formatting is much harder to read.
👍 Yes, I like the proposal.
👎 No, I don't like the proposal.
The text was updated successfully, but these errors were encountered:
The formatter should not remove trailing commas, but it should add them.
The formatter would have nothing to remove (reversibility) if it didn't add anything in the first place.
Therefore, it shouldn't add anything. Instead...
Let the formatter format and only format (not to be confused with adding/removing text).
Let the formatter acknowledge developer intent, rather than steal it from us.
Code actions are probably more suitable for removing or adding text.
TL;DR: The new Dart formatter (3.7.0) automatically removes trailing commas, which changes code formatting in an undesirable way. This contradicts the
require_trailing_commas
linter rule and removes the ability to force line breaks. A workaround exists (adding//
comments), but it's inconvenient. A setting to restore the old behavior or prevent automatic comma removal would be greatly appreciated.Could there be an option to preserve the trailing commas, so they are not automatically removed? That way, developers who rely on them for readability or structure would still be able to use them without the formatter interfering. This would give us more control over the formatting style while still maintaining some level of automation.
I really liked the ability to force a line wrap by placing a comma at the end of a line. However, with the new formatter, this trailing comma is automatically removed.
This feels awkward and changes the code style in a way that I really don’t like.
It would be great if there were an option to prevent the automatic removal of trailing commas.
I'm not the only one raising concerns about this:
Reddit discussion
GitHub issue comment 1
GitHub issue comment 2
As jamesderlin pointed out, there’s an annoying workaround:
I think I'm going to have to resign myself to adding a superfluous empty // comment at every site where I don't want the formatter to remove an explicit trailing comma.
Sure, this keeps the comma, but having to do this for every line? That’s just monkey business... 🐵🍌
As intraector mentioned:
The formatter should not remove trailing commas, but it should add them.
Consider the following example:
Old style:
New style:
In some cases, the new formatting even contradicts the
require_trailing_commas
linter rule.I completely agree
require_trailing_commas
should take precedence over this new change. It would be great if this behavior could be reconsidered.Oneother example:
Old way:
New way (BAD):

My IDE even shows errors because it says a trailing comma is required. 🤕
Sure, the new approach removes seven lines, but the formatting is much harder to read.
👍 Yes, I like the proposal.
👎 No, I don't like the proposal.
The text was updated successfully, but these errors were encountered: