Skip to content

Introduce trailingCommasInMultilineLists configuration #1044

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TTOzzi
Copy link
Member

@TTOzzi TTOzzi commented Jul 15, 2025

Resolve #946

Added a configuration to support the use of trailing commas extended by SE-0439.

This configuration supports three values:

  • always: always insert trailing commas in multiline lists
  • never: always remove trailing commas
  • ignore: preserve existing commas as-is

The default value is ignore.

The main concern was how to integrate this with the existing multiElementCollectionTrailingCommas configuration.
For now, trailingCommasInMultilineLists takes higher precedence, but to minimize its impact on multiElementCollectionTrailingCommas, it is implemented so that when set to the default value ignore, the behavior of multiElementCollectionTrailingCommas is preserved.

I’d appreciate any suggestions or feedback you may have.

Copy link
Member

@allevato allevato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an abstraction we can come up to reduce the repetition in the individual visitors? Something like a helper function that accepts a generic parameter constrained to a collection of WithTrailingCommaSyntax elements and does the actual work.

@TTOzzi TTOzzi force-pushed the trailingCommasInLists branch from c5fb5d2 to a3de557 Compare August 9, 2025 16:46
@TTOzzi
Copy link
Member Author

TTOzzi commented Aug 9, 2025

Is there an abstraction we can come up to reduce the repetition in the individual visitors? Something like a helper function that accepts a generic parameter constrained to a collection of WithTrailingCommaSyntax elements and does the actual work.

I was struggling because the point where a comma needs to be inserted differs for each syntax, but as I came to know about WithTrailingCommaSyntax, I came up with an idea!
I defined an abstract type and refactored the code accordingly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Support for trailing commas in lists (SE-0439)
2 participants