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 is forced for single arguments #2769

Closed
ptarjan opened this issue Feb 3, 2016 · 8 comments
Closed

Trailing comma is forced for single arguments #2769

ptarjan opened this issue Feb 3, 2016 · 8 comments

Comments

@ptarjan
Copy link
Contributor

ptarjan commented Feb 3, 2016

This shouldn't need a trailing comma

foo({
  bar: 1,
  baz: 2,
})

but it is being corrected to:

foo({
  bar: 1,
  baz: 2,
},)
@alexdowad
Copy link
Contributor

With consistent_comma style, we explicitly require a trailing comma even if there is only one item, and even if it is only on a single line. With comma style, the deciding factor is whether the entire call fits on a single line.

@hackling earlier opened a GH issue, saying that if there was only a single item, it shouldn't require a comma. We did that, and a lot of people didn't like it.

If we are going to do it again, it has to be a separate style this time.

@ptarjan
Copy link
Contributor Author

ptarjan commented Feb 5, 2016

@alexdowad What is this style called? Basically commas are always there where it helps git blame and missing where it is just next to a bracket.

# good
foo(a)
foo(a,b)
foo(a,
  b)
foo(
  a,
  b,
)
foo({
  a: b,
  c: d})
foo({
  a: b,
  c: d,
})
foo({
  a: b,
  c: d,
}, e)
foo(
  {
    a: b,
    c: d,
  },
  e,
)
foo({
  a: b,
  c: d,
}, {
  e: f,
})

@alexdowad
Copy link
Contributor

@ptarjan There is no style like what you show here. It could become a new one, though.

@ptarjan
Copy link
Contributor Author

ptarjan commented Feb 5, 2016

Yay. That would be nice.

@alexdowad
Copy link
Contributor

Do you have a suggestion on what to call this style?

@bbatsov
Copy link
Collaborator

bbatsov commented Feb 5, 2016

There's a separate cop for method args. Just disable it...

@ptarjan
Copy link
Contributor Author

ptarjan commented Feb 5, 2016

ESLint calls it always-multiline.

http://eslint.org/docs/1.10.3/rules/comma-dangle.html

@bbatsov I want it to apply to method args when the ) isn't on the same line. See the second last example.

deivid-rodriguez pushed a commit to nolotiro/nolotiro.org that referenced this issue Apr 5, 2016
These offenses are not properly excluded due to rubocop/rubocop#2769.
Just fix them.
deivid-rodriguez pushed a commit to nolotiro/nolotiro.org that referenced this issue Apr 5, 2016
These offenses are not properly excluded due to rubocop/rubocop#2769.
Just fix them.
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 19, 2018

There hasn't been much activity on this ticket and our Core Team is spread too thin on so many tasks, so I'll just close it for the sake of having a cleaner lists of tasks to focus on. We'd gladly review a PR, but it's unlikely that'd we're going to tackle this ourselves in the foreseeable future.

@bbatsov bbatsov closed this as completed Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants