How to enforce semicolons in JavaScript?

1.1k views Asked by At

How best does the developer who's decided he likes semicolons at the end of his JavaScript statements enforce that expectation technically for himself?

I'm using Visual Studio (ASP.NET webapps), but I'd love to hear about solutions for any environment.

2

There are 2 answers

1
kgiannakakis On BEST ANSWER

You could somehow integrate Javascript Lint into the IDE.

1
David Murdoch On

I sometimes run my JS through a handler that strips all new lines, comments, tabs, and extra whitespace automatically. If my JS statements don't end with a semi-colon I'll get an error (in most cases)...doing it this way is a PAIN to debug though (e.g., error on line 1 character 2654).

The other way I use is Firebug + YSlow. You can check it's built in JSLint every once in a while.

Maybe there is a file in Visual Studio for checking javascript syntax you may be able to modify like there is for (X)HTML and XML.