Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline function arguments with trailing comma - SyntaxError: Unexpected token ) #11258

Closed
davegri opened this issue Feb 9, 2017 · 5 comments

Comments

@davegri
Copy link

davegri commented Feb 9, 2017

  • Version: v7.5.0
  • Platform: Darwin Johns-MacBook-Pro.local 16.1.0 Darwin Kernel Version 16.1.0: Wed Oct 19 20:31:56 PDT 2016; root:xnu-3789.21.4~4/RELEASE_X86_64 x86_64

The following code:

function foo(a, b) { }
foo(
  'a',
  'b',
);

throws a syntax error:

);
^
SyntaxError: Unexpected token )
    at Object.exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

I would like to be able to comply with the airbnb style guide which requires a trailing comma

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Feb 9, 2017

@davegri If I get it right, the airbnb rule imply Bebel transpiling for now. Even the last v8 version (5.7) does not support trailing commas in function parameter lists and calls yet. However, you can use --harmony_trailing_commas flag (v8 comment: "enable "harmony trailing commas in function parameter lists" (in progress)").

@joyeecheung
Copy link
Member

Closing as not a bug. Node core would support trailing comma by default when V8 turns it on by default, right now the --harmony_trailing_commas flag is required.

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Feb 9, 2017

It seems V8 5.8 will support them without a flag: these trailing commas are OK in the current Chrom Canary with V8 5.8.

@DanielRamosAcosta
Copy link

In which version of node is supported?

@vsemozhetbyt
Copy link
Contributor

From Node.js 8 (at least in the last 08.11.1 it is supported).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants