-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add eslint rule for trailing commas #612
Comments
Yes, I think we should do this, and update the coding standards whilst we're at it 👍 Scattered throughout the JavaScript docs numerous times and to paraphrase quite heavily is:
I've created an issue to also update this for |
There're too many places in Javascript where we need trailing commas and we tend to always forget them even if it's our way-to-go preference. I understand the advantages here, but my preference would go for avoiding them. Anyway, I prefer a strict rule one way or another. |
This is one of those rules where I personally prefer without dangling commas, but find myself largely in the minority, so wouldn't fight strongly against them. But I hope we all realize that for the sake of consistency, it doesn't just apply to... return [
'nice',
'simple',
'keys',
]; ...but also... return {
not: {
so: {
simple: {
keys: {},
},
},
},
}; |
Let's add a lint rule for trailing commas:
There are several advantages to this. From the WordPress coding standards for PHP:
In the past, this has been avoided in JavaScript due to lack of support in older versions of IE (this didn't work correctly until IE9). However, we don't have to care about this because we have a build process to handle it for us and because WordPress is dropping support for IE 8-10.
The text was updated successfully, but these errors were encountered: