Skip to content
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

Enforce trailing comma #1285

Closed
marcospgp opened this issue Jun 8, 2024 · 1 comment
Closed

Enforce trailing comma #1285

marcospgp opened this issue Jun 8, 2024 · 1 comment

Comments

@marcospgp
Copy link

marcospgp commented Jun 8, 2024

Currently both including and not including the last comma in a list is allowed, such as:

            var mesh = new Mesh()
            {
                name = name,
                vertices = vs.ToArray(),
                triangles = ts.ToArray(),
                uv = uvs.ToArray(), // Comma here.
            };
            var mesh = new Mesh()
            {
                name = name,
                vertices = vs.ToArray(),
                triangles = ts.ToArray(),
                uv = uvs.ToArray() // No comma here.
            };

This should not be ambiguous, and in accordance with Prettier the trailing comma should be enforced.

@belav
Copy link
Owner

belav commented Jun 8, 2024

Duplicate of #668

@belav belav marked this as a duplicate of #668 Jun 8, 2024
@belav belav closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2024
belav added a commit that referenced this issue Jun 16, 2024
This pull request addresses the issue described in [Issue
#668](#668) and [Issue #1285
](#1285).
A flag UsePrettierStyleTrailingCommas is introduced which ensures a
trailing comma for anonymous object/collection/initializer/switch
expressions, list patterns and enum declarations in the case a line
break occurs.

I hope the implementation of the feature isn't too invasive. Obviously
it would be easier to implement the feature non-configurable.

I'm not sure how to deal with the tests, for now I enabled the flag and
adjusted the corresponding tests.

Thanks for any feedback!

---------

Co-authored-by: Bela VanderVoort <bela.vandervoort@optimizely.com>
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

No branches or pull requests

2 participants