sidhant-guliani / script-cover

Automatically exported from code.google.com/p/script-cover
Apache License 2.0
0 stars 0 forks source link

Syntax error in external js file - where it is? #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create application with have page with include java script file with syntax 
error
2. Enter the page
3. I can see similar error in Debug Console
Error in event handler for 'undefined': Unexpected token: name (aaaaaaaa) 
TypeError: object is not a function
    at new JS_Parse_Error (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:235:21)
    at js_error (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:246:15)
    at croak (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:652:17)
    at token_error (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:659:17)
    at unexpected (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:665:17)
    at Object.semicolon (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:685:51)
    at prog1 (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:1202:29)
    at simple_statement (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:816:35)
    at $statement (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:726:35)
    at block_ (chrome-extension://hbbbdijkdplhoejlcodidgcgbnnfcadf/third_party/lib/parse-js.js:900:32) event_bindings:346

4. the 'script cover' don't collect data.

What is the expected output? What do you see instead?
1. I want to collect code cover data.
2. If I Have syntax error I would like to know in which file and in with line I 
have error

What version of the product are you using? On what operating system?
1.0.0.2

Please provide any additional information below.

Exmple html page:

<html>
<head>
<script id="scriptWithError" src="myErrorScript.js"></script>
<script type="text/javascript">
    function onClickTest() {
        syntaxError();
    }
</script>
</head>
<body>
    <button id="test" onclick="onClickTest()">test</button>
</body>
</html>

Example js file:

function syntaxError()
{
    alert("fg sdgfs");
    aaaaaaa aaaaaaaa
}

Original issue reported on code.google.com by Radullus...@gmail.com on 26 Jun 2013 at 1:49

GoogleCodeExporter commented 8 years ago
I think this issue is outside of the program scope of script-cover. There are 
programs online (and offline) that check your code for coding style issues for 
you, these are generally called "lints". Please check out 
http://closure-compiler.appspot.com, http://jshint.com, http://jslint.com.

Closure Compiler: This probably has the least strict syntax parser. If your 
code doesn't use reserved keywords and is valid, it will work and return no 
errors, otherwise it will do its best to parse through the errors (it may even 
be overzealous).  I don't like that the output uses automatic semicolon 
insertion (ASI) as part of its minifcation scheme, even with whitespace + 
prettyprint mode, but as an error checker it's fine.

JSHint: A less strict version of JSLint. Basically if you can get JSHint to 
reach the end of your code without an error stop, your code is syntactically 
valid. The warnings are just that: warnings on code style. I think the parser 
in this program is better than JSLint's because it doesn't hang on valid 
syntax, but it still has the issue of an arbitrarily low limit. As a JS program 
it is available offline with shell integration, most IDE's should have 
integration with this, so look for plugins.  This is probably the best option.  
If there are too many errors, raise the limit with this comment at the start of 
your code: /*jshint maxerr:1000*/

JSLint: A very strict syntax checker. It has a tendency to throw errors on 
valid syntax and ASI. As a JS program it is available offline with shell 
integration, most IDE's should have integration with this, so look for plugins.

Original comment by plngp0ng...@gmail.com on 22 Jul 2013 at 3:09