codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.89k stars 356 forks source link

Clean up code to add trailing comma #909

Open ian-bowyer opened 2 years ago

ian-bowyer commented 2 years ago

Environment

Description

It is common that there is a trailing comma at the end of a array of items (I think our stylecop rules picks these up), but it would be nice to not have to always remember to add them and have the cleanup code in codemaid do it.

I'm not sure if I am missing where to set it or if the functionality is not in codemaid or indeed if its in visual studio 2022 and I cant find the setting (or find it in google)

Steps to recreate

  1. Add the following code (which is missing the trailing comma var animals = new List<string>() { "dog", "cat", "mouse" };
  2. when running cleanup (for example on save) it should add the following comma after "mouse". var animals = new List<string>() { "dog", "cat", "mouse", };

Current behavior

It does not add the trailing comma

Expected behavior

To add the trailing comma. I expect there would be some config to turn this on of off to users preference

codecadwallader commented 2 years ago

Thanks for the suggestion. We do not currently have an option to add trailing commas to lists. I'm not sure if there's a native VS option, they've been iterating a lot recently.