comma-dangle = always-multiline and the spread operator
See original GitHub issueThere is a bit of an issue with comma-dangle
set to "always-multiline"
and the spread operator used in a destructuring assignment:
var [
x,
y,
...data // Getting "missing trailing comma" error
] = parsed;
For compliance with spec there should be no comma after the AssignmentRestElement
and I think that "always-multiline"
should treat this as a special case and ignore the missing trailing comma.
For now I’m ignoring the error for this line.
The version I have is 1.2.1.
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (8 by maintainers)
Top 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 you should enforce Dangling Commas for Multiline ...
Fortunately ESLint has the comma-dangle rule which allows you to enforce dangling commas for multiline statements. comma-dangle: “always-multiline”.
Read more >Trailing commas - JavaScript - MDN Web Docs
JavaScript allows trailing commas wherever a comma-separated list of values is accepted and more values may be expected after the last item.
Read more >Are you using Trailing Commas in your JavaScript?
In multi-line objects & arrays in JavaScript, Trailing Comma is can be very useful, being part of ES5 standard, see how it can...
Read more >Airbnb JavaScript Style Guide()
3.8 Prefer the object spread operator over Object.assign to shallow-copy objects. ... with a trailing comma on the last item. eslint: function-paren-newline.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I feel like this case is fundamentally the parser’s job to handle. It seems strange for us to add logic for a new error message just to account for a bug in
babel-eslint
.Updating the documentation sounds good to me, though.
Wouldn’t a better error message be a good solution here?
If so, then I could do that.