Search code examples
javascriptdebuggingsyntax-erroroperaopera-extension

Syntax errors in hard to reach JS environments


I'm making an Opera Extension. It includes a background script which fails very silently. It runs in a unique environment, so I can't take it just anywhere to check if it works (it needs predefined variables). Is there a way to debug scripts without running them. That is, checking if the syntax is correct. I want something like JSLint, that instead of telling me how my code is bad tells me where the syntax errors are.


Solution

  • If you only want a quick search for SyntaxErrors, you could drop the code into Closure Compiler, and just choose the "Whitespace Only" option.

    It'll notify you of invalid code without any code styling analysis to clutter things up.

    http://closure-compiler.appspot.com/home

    If you choose the "Pretty Print" option, it'll also give you a well indented result in case the original code needed some cleanup.