Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`comma-dangle` incorrectly requires commas after rest properties

See original GitHub issue

What rule do you want to change? comma-dangle

Does this change cause the rule to produce more or fewer warnings? I guess it depends. But probably more warnings.

How will the change be implemented? (New option, new default behavior, etc.)? New option, something like {forbidAfterRest: true}

Please provide some example code that this change will affect:

const {
} = foo;

What does the rule currently do for this code? When using this rule with string option "always-multiline", it will warn about missing trailing comma after ...z.

What will the rule do after it’s changed? No trailing comma after ...z will be correct, and a trailing comma will be incorrect.

Motivation: Seems like the spec doesn’t even allow that kind of trailing comma.

Babel’s Babylon v6.11.3 went so far as to consider that as syntax error.

The rationale for this is that the use case for trailing comma is that you can add something at the end without affecting the line above. Since a RestProperty always has to be the last property it doesn’t make sense.

Babylon v6.11.4 temporary rolled back that behavior.

So for now I guess is up to the user to choose if that trailing comma is incorrect or not with the new forbidAfterRest option.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

ljharbcommented, Oct 6, 2016

… just to clarify, trailing commas are always permitted after spreads, they’re just never permitted after rests - in both iterable or object destructuring, as well as in function argument signatures.

not-an-aardvarkcommented, Oct 6, 2016

Whoops, looks like I was a bit careless about that distinction when renaming the issue. (I think the fix does distinguish between rest and spread correctly, though.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

comma-dangle - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Why does prettier put the trailing comma on its own and give ...
"trailingComma": "es5" says that the trailing comma is invalid after the last property. "airbnb-base" might contain a rule which conflicts with ...
Read more >
Best practices for using trailing commas in JavaScript
A trailing comma, also known as a dangling or terminal comma, is a comma symbol that is typed after the last item of...
Read more >
comma-dangle | typescript-eslint
Require or disallow trailing commas. Some problems reported by this rule are automatically fixable by the --fix ESLint command line option.
Read more >
ESLint v3.8.0 released
comma-dangle … arrays , objects , imports , exports , and functions ... 52da71e Fix: Don't require commas after rest properties (fixes #7297)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found