3

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.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
oyvind
  • 1,429
  • 3
  • 14
  • 24
  • 1
    +1 for "JSLint telling me how my code is bad". – Bojangles Sep 14 '12 at 14:51
  • I've not made an Opera extension, but I have worked with UserScript stuff in Chrome, Firefox and IE. JSHint/JSLint are a great choice, and when that fails I turn my extension/userscript into a regular JS file that I include in the page I'm working on. That way I get regular browser-level debugging tools. – Jeremy J Starcher Sep 14 '12 at 17:33

1 Answers1

0

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.

gray state is coming
  • 2,107
  • 11
  • 20