question-mark
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.

Rule to catch trailing commas in function parameters

See original GitHub issue

This 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:closed
  • Created 8 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
ljharbcommented, Jul 13, 2016

@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.

2reactions
ljharbcommented, Jul 14, 2016

@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.

Read more comments on GitHub >

github_iconTop 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 >

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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found