Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to stop ASI on Node.js and have it err?

I know automatic semi-colon injection is a contentious issue but I would prefer if I could disable it on my Node.js based server.

Script:

var foo = bar()
var baz = foo+1;

With result:

[Error] Expected ';' before var on line #2

Or anything similar.

like image 698
Nate Avatar asked Aug 06 '13 01:08

Nate


1 Answers

As mentioned in comments, ASI is part of the EMCAScript specification, it can't be disabled.

Also as mentioned JSHint is a good solution, I use sublime text 2 with the "Sublime Linter" plugin, which lints your code as your code as you type.

If you really wanted to lock your server down, you could add an alias to "node" which does something like "lint file && node file", that way node wouldn't run unless lint was successful.

like image 121
jpillora Avatar answered Oct 24 '22 01:10

jpillora