I have a lot of Expected '{' and instead saw 'blah' errors that spit out when I run my scripts through jslint. Is there an option that ignores this error?
There are no options to ignore this unless you edit the source of jslint and remove this particular warning. However, it is highly recommended not to ignore this rule.
no. crocky is a curmudgeon js nazi.;-) there is a vs addin on codeplex that i added an ignore feature to though. the addin is still kinda buggy but works well enough. I haven't been able to get contact with the owner to get on the project so havent put a lot more time into it. anyway see here and get the patch from the patches tab
Actually, with the latest version of sublime-jslint, I just told it to ignore these errors by adding to the "ignore_errors" option:
"ignore_errors":
[
"Expected '{' and instead saw"
],
Now whenever I run sublime-jslint on my files, I get:
jslint: ignored 5 errors.
Related
I keep getting this error whenever I try to console log any code.
I think you might need some form of an extension like Javascript debugger(It's available on the vscode extension store ). You do need to check if it does the job for you or not. Sharing your main code here might also help in better understanding the problem.
If you are using node.js , this is a good fix for your problem
Fatal JavaScript invalid size error 169220804
Otherwise, reinstalling vscode from scratch might be another good option for you if everything else fails.
I found the solution. It was an error in my code in a for loop iteration :(.
Apparently the for loop had no break point.
I fixed it and the console worked with no issues.
I'm having trouble setting up a JavaScript project in my VSCode.
What I currently have technically "works", but it wont do proper syntax highlighting and syntax error detection. For example, the following code on a fresh file won't show any error:
woosh();
The thing is, there is no function called woosh anywhere (not even in other files). The error is caught only when I try to actually run this code. Does anyone know what I might have done wrong?
VSCode does not highlight JS mistakes like this, because it's not a syntax error; The code above would cause a runtime error.
Install addons like eslint, jshint. If that doesn't work then I recommend learning typescript. It's a superset of javascript with strict type checking. It helps us to catch silly bugs like these.
Actually I've two questions, because the common workaround for my initial problem does not work :)
I'm trying to build an Emscripten based library which calls JavaScript functions as described here: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#implement-a-c-api-in-javascript
Simply put I just implement my C/C++ code against a C-Function, implement that function in a .js file and 'link' that file using --js-library.
Basically things are working for me except with version EMSDK version 1.38.12 I got a warning when linking the final library:
warning: undefined symbol: foo_
.. which I don't understand but I could just ignore it. In newer versions of EMSDK the behavior changed and the warnings become errors.
Searching for this error you find you can just add -s ERROR_ON_UNDEFINED_SYMBOLS=0 when linking, but this doesn't work (for me) - I still get this error despite I can see this option being added to the linker.
So my questions are:
how do I make -s ERROR_ON_UNDEFINED_SYMBOLS=0 work for me?
and why do I get this warning in the first place? how do I get rid of it?
I'm using JSHint for Visual Studio. It's not uncommon for JSHint to issue a warning about an issue that I know it safe to ignore. I have been putting // ignore jslint on the relevant line, but I see that we can also ignore specific error codes. From the 1.0.0 rc1 release notes:
This version adds a unique numeric code to every warning and error
message produced by JSHint. That means that you can now ignore any
warning produced by JSHint even when there is no corresponding option
for it. You can do that using the special minus (-) operator. For
example, here’s how you ignore all messages about trailing decimal
points (W047):
/*jshint -W047 */
Seems cool, but try as I might, I cannot find a list of all the error codes. Visual Studio's warning list doesn't provide you with the numeric error code, just the error text.
Surely this list is out there somewhere, right? I've literally spent an hour Googling for this. But no success so far.
The best place to look for things like that is the source (which is available on GitHub). The file you're looking for is messages.js (versions: current release (2.9.5, 2017-06-22), master branch, 2.1.4 (source for the code below)):
var warnings = {
W001: "'hasOwnProperty' is a really bad name.",
W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",
W003: "'{a}' was used before it was defined.",
W004: "'{a}' is already defined.",
// ...
};
Not So Final Edit: Looks like a new site has been stood up that covers all the previous functionality: http://linterrors.com/js
I would recommend: http://jslinterrors.com/
This isn't a side-by-side list of all the errors, but it has each error (broken out by JSLint, JSHint, and ESLint) which include the specific error code per item.
For just JSHint, you can scope the view: http://jslinterrors.com/?linter=jshint
Final Edit: Looks like the site has gone under and is up for sale.
Edit: The codes can be found at the bottom of each section, if it relates to a fatal syntax the code cannot be suppressed.
Edit 2: Looks like they've added ESLint as well.
I have this code:
function A(){}
A.prototype = {
set a(v){},
get a(){return}
};
Aptana detects an error at this line set a(v){}, but it works on modern browsers.
How can I fix this ?
Aptana currently does not recognize the get and set keywords used to define getters and setters in JavaScript. There is no way for you to fix this, however, there is a way you can work around it. Aptana natively uses JSLint for JavaScript validation, and allows you filter out warnings and errors that you may not care about.
The errors that it is picking up on that line are:
Expected an operator and instead saw '{'.
Expected ':' and instead saw 'a'.
You can tell Aptana to ignore these by going to Preferences -> Aptana Studio -> Validation, selecting the JSLint validator, and adding those errors to the list of errors and warnings to be filtered from validation (you can use the entire error string or some regex).
Warning: You may not want to ignore these errors, as they are Syntax Errors and will cause your JavaScript to bomb out when it loads if you miss them.