ASI edits

Isiah Meadows isiahmeadows at
Fri Jan 12 21:09:10 UTC 2018

I know this is probably bad timing (considering [this PR][1] and the
fallout that followed), but I was thinking that it'd be nice if we
could insert a `[no LineTerminator here]` clause in a few places, to
remove some of the ASI hazards for those going semicolon-free, along
with some extras for consistency:

- Before the `[` in the second rule of [`MemberExpression`][2] and the
fourth rule of [`CallExpression`][3]
- Before `Arguments` in the last rule of [`MemberExpression`][2], the
third and sixth rule of [`CallExpression`][3], and
- Before the `(` in [`FunctionDeclaration`][5],
[`FunctionExpression`][6], the first, fourth, and fifth rule of
[`MethodDefinition`][7], [`GeneratorMethod`][8], both rules in
[`GeneratorDeclaration`][9], and [`GeneratorFunction`][10]

One of the practical effects would be this: this source (taken from the spec):

a = b + c
(d + e).print()

is currently interpreted as:

a = b + c(d + e).print();

but would, with this proposal, be interpreted as this, which is a
*lot* more intuitive with what people would expect:

a = b + c;
(d + e).print();

I know there's risk of web compat concerns, but I doubt they'd be
significant for anything that's not minified via the Closure Compiler
(which limits line length by default for reasons of old IE). Also, for
most non-ASI people, they probably just forgot a semicolon anyways,
and [here][11] is a concrete example of this, where ESLint was fixing
a linter violation incorrectly because it wasn't reading it as you'd



Isiah Meadows
me at

Looking for web consulting? Or a new website?
Send me an email and we can get started.

More information about the es-discuss mailing list