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

Trailing Comma #400

Closed
aakashsigdel opened this issue Feb 4, 2016 · 8 comments

Comments

@aakashsigdel
Copy link

commented Feb 4, 2016

It would be good if there was a rule for ending a object entry with comma.

  let abc = {
    def: 'xyz',
    ghi: 'mno',
}

This would be helpful as we won't accidentally forget to add a comma before adding a new property while editing the object later in time.

@aakashsigdel aakashsigdel changed the title [feature request] Trailing Comma Trailing Comma Feb 4, 2016

@feross feross added the question label Feb 4, 2016

@feross

This comment has been minimized.

Copy link
Member

commented Feb 4, 2016

Sorry, we can't even consider this change because it would break 100% of the packages that use standard today.

If you're using standard, you can't even make this error, because it's invalid JavaScript, so you'll get a parse error when you run the tool, and probably the first time you try to run your app.

@feross feross closed this Feb 4, 2016

@garex

This comment has been minimized.

Copy link

commented Mar 20, 2016

Standards should respect comma-first rule.

Then this feature will not be needed:

var magicWords = [ 'abracadabra'
                 , 'gesundheit'
                 , 'ventrilo'
                 ]
  , spells = { 'fireball' : function () { setOnFire() }
             , 'water' : function () { putOut() }
             }
  , a = 1
  , b = 'abc'
  , etc
  , somethingElse
@feross

This comment has been minimized.

Copy link
Member

commented Mar 20, 2016

@garex Sorry, no.

@channprj

This comment has been minimized.

Copy link

commented Apr 5, 2018

How can I turn it off temporarily?

@feross

This comment has been minimized.

Copy link
Member

commented May 15, 2018

@lehelk

This comment has been minimized.

Copy link

commented Jun 22, 2018

Ok, I can understand the need for a standard/set of rules to follow and once setting these rules to not deviate from them. It feels like this specific rule was pushed due to IE8 & below bug. This should also not be an issue when using compilers. I would really appreciate knowing the reasoning behind this choice.

@qqtrend

This comment has been minimized.

Copy link

commented Aug 13, 2018

Is there a way to change this project-wide? (Because we are blessed with not having to support IE8 ever again, and don't want ugly diffs, not even in the name of standards!)

This works if put at the top of each js file:

 /* eslint comma-dangle: ["error", "always-multiline"] */

But each of these package.json edits were ignored: (the "babel-eslint" config is working; I left that in these examples to show I am editing the correct part of package.json)

  "standard": {
    "parser": "babel-eslint"
  },
  "eslintConfig": {
    "rules":{
      "comma-dangle": ["error", "always-multiline"]
    }
  },

and

  "standard": {
    "parser": "babel-eslint",
    "rules":{
      "comma-dangle": ["error", "always-multiline"]
    }
  },

For completeness, I also tried:

  "standard": {
    "parser": "babel-eslint",
    "eslintConfig": {
      "rules":{
      "comma-dangle": ["error", "always-multiline"]
      }
    }
  },
@LinusU

This comment has been minimized.

Copy link
Member

commented Aug 13, 2018

@qqtrend you can use standardx

@lock lock bot locked as resolved and limited conversation to collaborators Nov 11, 2018

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