sweet-js / sweet-core

Sweeten your JavaScript.
https://www.sweetjs.org
BSD 2-Clause "Simplified" License
4.58k stars 208 forks source link

Compile to JavaScript without semi colons #752

Open jochemstoel opened 6 years ago

jochemstoel commented 6 years ago

Please implement an optional parameter to compile JavaScript without semi colons.

vendethiel commented 6 years ago

What? Why?

jochemstoel commented 6 years ago

What do you mean why? A large portion of developers in the world do not use semi colons (anymore), many of them strongly opinionated. I refrain from the debate about this but I don't want semicolons either.

The parser generator and code generator I am currently using do not include this option either. This is enough reason for me to find a replacement that does. I was looking into alternatives that meet the requirements when I stumbled upon sweet.

I completely understand if this is not a priority for you or is too much work. In that case no problem I will find something else.

/* no semi colons needed */
function Droid(name, color) {
  this.name = name
  this.color = color
}
Droid.prototype.rollWithIt = function (it) {
  console.log('rolling just fine.')
  return this.name + " is rolling with " + it
}
vendethiel commented 6 years ago

You're not supposed to edit generated code. It's generated code.

ephetic commented 6 years ago

Wouldn't this substantially increase the complexity of the generator because now it needs to be wary of situations where semicolonless expressions are parsed wrong?