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
{{ message }}
This repository was archived by the owner on Mar 7, 2019. It is now read-only.
I propose that we start requiring trailing commas for multiline objects. Currently trailing commas are optional. Single-line object literals will not be affected by this change.
This rule can be auto-fixed by ESLint, therefore no manual changes are required in your code.
Current
constobj={first: 1,second: 2// Here, the comma is optional}
New
constobj={first: 1,second: 2,// Here, the comma is required}
Why?
Every time you want to add a new property to an object, you have to remember to put the trailing comma to the preceding property, otherwise you get a syntax error. Enforcing the comma to already be there, you mitigate this completely.
git diffs will look more clean, because you now do not have to edit an unrelated line to introduce your changes.
It is easier to sort the object's properties with just F5 or similar editor tool
Please vote 👍 or 👎 via reaction or leave a comment if you have questions or suggestions. Thanks!
robertrossmann, viliam-jobko, miryn, dannytce, petrhanak and 6 morePajk, hohy, Milan4e and polacekpavel