I have a large set of various javascript fragments (several thousand), and some of them have some silly syntax errors (for example, unmatching braces / quotes, HTML inside javascript, typos in variable names).
I need an easy way to check JS syntax. I tried JSLint, but it sends too many warnings about style, how variables are defined, etc. (Even if I turn off all flags). I donโt need to figure out style problems or improve javascript quality, I just need to find obvious syntax errors. Of course, I can just check it in the browser / browser, but I need to do this automatically, since the number of these fragments is large.
Add:
JSLint / JSHint reports many problems in lines that are not โbeautyโ but work (that is, they have problems with potential ones ) and cannot see real problems where a regular compiler simply reports a syntax error and stops execution. For example, try JSLint that code that has syntax errors in line 4 (inconsistent quotes), line 6 (requires a comma) and line 9 (unexpectedly <script>).
document.write('something'); a = 0; if (window.location == 'http://google.com') a = 1; document.write("aaa='andh"+a+"eded"'); a = { something: ['a'] something2: ['a'] }; <script> a = 1;
source share