consider adding more "[no LineTerminator here]" toavoidproblemcaused by omit the semicolon
Claus Reinke
claus.reinke at talk21.com
Sun Jun 24 02:04:50 PDT 2012
>> My own favourite approach would link ASI to layout/indentation,
>> and introduce warnings instead of breaking code:
>>
>> 1 if ASI kicks in, but indentation suggests statement continuation,
>> issue a warning
>> 2 if ASI does not kick in, but indentation suggests new statement,
>> issue a warning
>
> I did once try to implement this, ..
> https://gist.github.com/2973296
I've updated the gist slightly: instead of checking for indentation
mismatches on every multiline statement, it now only checks at
known troublespots.
This means fewer false warnings, but also fewer warnings in general,
so the old mode is still available by option. The new mode's output
makes it clearer that basil tries to match ASI and layout/indentation:
// $ node basil.js sample.js
// ASI at line 5(2), before indented line 6(8)
// no ASI at line 12(2), before non-indented line 13(2)
// ASI at line 25(2) before indented line 26(11)
// no ASI at line 35(2), before non-indented line 36(2)
// no ASI at line 39(2), before non-indented line 40(2)
// ASI at line 43(2), before indented line 44(4)
// no ASI at line 50(2), before non-indented line 51(2)
At the moment, the troublespots are roughly those indicated by the
thread starter, ie, in expressions, before arguments (..) and computed
properties [..].
Should it also check in infix applications? For instance, what about
var a2 = "hi"+
"ho"; // warn here?
var a3 = "hi"
+"ho"; // warn here?
Are there other cases where ASI might wrongly be expected
which should trigger warnings?
Claus
More information about the es-discuss
mailing list