Make comma at the end of line optional

dante federici c.dante.federici at gmail.com
Tue Sep 12 18:22:56 UTC 2017


In terms of style, and in terms of version control, either of these are
fine:

```js
const obj = {
  x: 10
  y: 23
};
// or
const obj2 = {
  x: 10,
  y: 23,
};
```

The mixed case is the most obnoxious one:
```js
const bad = {
  x: 12,
  y: 7
}
```


However, as pointed out, there is ambiguity with:
```js
const obj = {
  get
  x: 10
  y
  z: 24
  get
  myMethod() {
  }
}
```

I just don't see optional comma in a collection as a useful feature for the
language -- "whitespace matters" always makes me uncomfortable, especially
since there are different standards for line breaks across machines
(looking at you `\r\n`), whereas the `,` token, which is already used to
delineate arguments, is suited exactly for this job.

The one thing I still have a gripe over is the class definition syntax --
where neither `,` or `;` are used at the end of method expressions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170912/09bf82a8/attachment.html>


More information about the es-discuss mailing list