Javascript: Trailing commas in function arguments

Created on 13 Jul 2016  路  5Comments  路  Source: airbnb/javascript

What about trailing commas here?

const hero = (
  firstName,
  lastName,
  birthYear,
  superPower, // <-- this one
) => {
  // ....
};

It needs http://babeljs.io/docs/plugins/syntax-trailing-function-commas/ and it's based on this proposal

Does AirBnB encourages the use of trailing commas here?

needs eslint rule changaddition question

Most helpful comment

eslint v3.6.0 now supports this, but the comma-dangle rule does not, just yet. This is now waiting on https://github.com/eslint/eslint/pull/7181.

All 5 comments

Not yet. In general terms, we recommend stage 3 proposals only, case-by-case.

In this specific case (which is recently stage 3), eslint can not yet parse it, so we do not yet recommend it.

I'm going to leave this open until eslint can parse trailing function commas in core, and then we can update the guide and resulting linter plugins.

What's the most up-to-date upstream issue to track here? Is it https://github.com/ternjs/acorn/issues/441?

That's probably the best one, yes.

eslint v3.6.0 now supports this, but the comma-dangle rule does not, just yet. This is now waiting on https://github.com/eslint/eslint/pull/7181.

@ljharb fyi this is now available

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryankask picture ryankask  路  3Comments

stephenkingsley picture stephenkingsley  路  3Comments

ar
mbifulco picture mbifulco  路  3Comments

mismith picture mismith  路  3Comments

olalonde picture olalonde  路  3Comments