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

Unexpected trailing comma #890

Closed
jcalfee opened this issue May 18, 2017 · 3 comments

Comments

@jcalfee
Copy link

commented May 18, 2017

Would you consider turning off the warning for "Unexpected trailing comma" ??

I save time and mental load when reordering lists by not having to track that last comma. I'm not aware of any issues that could be caused by allowing this extra comma.

module.exports = {
  languages: [
    'chinese_simplified',
    'chinese_traditional',
    'japanese',
    'english',
    'italian',
    'french',
    'spanish', // <= This is good
  ], // <= This is good
}

@dcousens dcousens added the question label May 19, 2017

@Flet

This comment has been minimized.

Copy link
Member

commented May 30, 2017

Hi @jcalfee! Thanks for the thoughtful feedback!

This rule change has been discussed previously, and here was the decision we came to at that time:

If there's two ways to do something and there's no difference in correctness or chance of introducing a bug, then standard tends to 'just pick something'. So, relaxing the rule to allow either style isn't really a viable option.

Given that it's gotta be either 'disallow' or 'enforce', I think disallow is the least controversial option. Enforcing trailing commas would confuse a lot of beginners to programming or JS, IMO.

With the above in mind I'm going to close this issue now, but please feel free to continue the conversation!

@Flet Flet closed this May 30, 2017

@AJamesPhillips

This comment has been minimized.

Copy link

commented Aug 23, 2017

I agree that with only disallow and enforce, it should be disallow. But I'd rather have it be optional. I’m not opinionated enough to say we should have them, but I am opinionated enough to say we should not force people to have/not have them. I understand though that Standard is meant to say 'disallow' or 'enforce'.

Also reordering a list is a common activity and not having a trailing comma would increase chances of introducing a bug, as I well know from occasionally forgetting to delete / insert a comma at the right place. It also increases the commit diff noise.

A good list of these points is also made here: #907

@LinusU

This comment has been minimized.

Copy link
Member

commented Aug 23, 2017

I personally would love to have trailing comma enforced, but I don't think that making this optional is the way to go.

[...] but I am opinionated enough to say we should not force people to have/not have them.

The whole point of standard is to be opinionated and to pick one way. Otherwise, that same argument could be made about semicolons, space vs. tabs, and basically every other rule. I think it's important that standard enforces one of them.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
5 participants
You can’t perform that action at this time.