Rule to catch trailing commas in function parameters
See original GitHub issueThis construct:
function (a, b, c, ) {
}
Doesn’t appear to be caught by general parsing, or any rule that I could find. It’s not legal at all, though, and should be caught by the parser.
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
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 >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 >10. Trailing commas in function parameter lists and calls
The ECMAScript 2017 feature “Trailing commas in function parameter lists and calls” was proposed by Jeff Morrison. 10.1 Overview #. Trailing commas in...
Read more >Trailing comma in ECMAScript 2017 function parameter list
The comma-dangle allows you to enforce a dangling comma in object and array literals. It doesn't work with function declarations and invocations ...
Read more >Trailing comma in JavaScript function call - Stack Overflow
The rule on trailing commas for function call arguments states: 7.15 Functions with multiline signatures, or invocations, should be indented ...
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 FreeTop 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
Top GitHub Comments
@ilyavolodin why not? Why is object rest/spread an exception but nothing else in stage 3?
Something being in stage 3 means, that barring some massive surprise performance issue discovered by browsers, that it almost certainly will ship. Browsers begin implementing in stage 3, since it’s a stage 4 requirement that 2 browsers support something first. What this policy means is that eslint will be unable to lint code that works in half of the browsers - that doesn’t seem ideal.
@ilyavolodin ES2016 was ratified in June, so it’s complete. However, the “yearly spec” is irrelevant - only what’s on Github matters, which is all the things that are stage 4 (which luckily doesn’t yet include any syntax changes).
As for
babel-eslint
, the creator of this tool (who i won’t mention so as not to bother them) went out of their way to convince eslint-config-airbnb to remove that parser as soon as it was no longer needed by our settings. If eslint core doesn’t support stage 3 features, then we won’t be ever able to rely on that parser moving forward.As a member of TC39, I’m trying to say that the right time to implement parser semantics is stage 3. If eslint chooses not to do this, that’s fine, but that means you will be lagging behind the entire JS community.