I use a combination of Notepad++, JSHint and Cordova CLI to create my hybrid Android web apps - yes, I am aware that there are more sophisticated ways of doing this but tht is not what this question is about.
One of the issues I run into every now and again is a typographic - as opposed to syntactic which is easily caught by JSHint - error which only manifests itself once I am compiled the APK and tried to run it. For instance
docment instead of document (missing u)
getElmentByID instead of getElementById (missing e, wrong capitalization on ID)
The one thing I really love about Java is that the compiler stops you dead in your tracks and demands that you fix such errors first. That is not the case with JavaScript where the best one can do is test for correct syntax.
However, I am wondering - perhaps there is a way (maybe a NPP plugin that I am unaware of) to check for such errors?
Use typescript or flowtype to catch those, and many more errors. Alternatively, find a decent syntax theme that's set up to highlight DOM methods.
Having used Groovy for many years, I have developed a large node & JS v.6 project without any semicolons with Notepad++. It is a huge time saver and liberating, as, for me at least, semicolons are a complete waste of time and space. I have not yet come across a case where not having them in my Groovy nor js code has caused a single problem in 8 years.
Unfortunately, Eclipse + nodeclipse plugin don't see it that way. It complains about every line missing a semicolon. I tried switching it off in two ways:
window->preferences->Javascript->Validator->Errors/Warnings->Potential programming problems->Optional semi-colon=Ignore.
unticked "Enable javascript semantic validation"
Neither helped, plus I don't want to disable any of the other validation as this is the only benefit Eclipse + nodeclipse offers over Notepad++ (that I can find at least). In fact, Notepad++ offers significantly better completion than eclipse, as it remembers what you typed before, but eclipse does none, it only does highlighting.
Anyone have any ideas on how to stop the semicolon warnings?
Go to Configuration(alt+enter), in JSHint/Configuration , you have to set or edit the following key to tolerate Automatic Semicolon Insertion:
"asi" : true
I am developing an AJAX application and in the process of doing this I am creating many small JS files that will eventually be concatenated and minified in the production release. However in development I will be working with the individual uniminified files.
The issue I have is that I am using Kate in Ubuntu as my editor and when I make small errors like an extra comma in a JSON structure, or an extra parenthesis, colon, semi-colon, or other simple syntax error I have no way of knowing until I see it in Firebug or IE Developer Toolbar (run in a VM). Unfortunately Firebug isn't very good at identifying which line has the syntax error and only IE complains about extra commas. If I could see these mistakes in real-time like a good modern IDE it would be awesome. However, I'll settle for any syntax checking solution that doesn't require me to copy and paste each file from my local machine into a text area.
Also, JSLint goes a bit overboard with it's checking. Half of the things it complains about I do intentionally.
What are my options?
jshint ( http://www.jshint.com/ )is one of the descendants of jslint after several people had also such problems with jslint (being too opinionated).
You could do similar things I guess with jshint as well as it is done by jslint here: http://sergioserra.posterous.com/using-jslint-with-kate
Personally, I used vim with jslint (with a much more permissible configuration than the default), which was checking syntax live.
Another alternative is Closure Linter from Google: https://developers.google.com/closure/utilities/
I'm new to JScript coming from a C++ world.
I'm quite surprised that expressions are evaluated at run-time. What I mean is if I added a function and didn't provide its definition, the program would "crash" (in the debugger) when I run it.
It's also funny how I can just type gibberish anywhere and only at run-time the debugger would complain.
But the "live" page wouldn't!
Is there any JScript add-on tool that checks its syntax while we type? I'm currently using Aptana Studio.
Or is the debug button equivalent to compiling in the web world? But then what if you had million lines of code and some little function was not defined or misspelled? That's a scary thought to me. =S
JSLint is considered by many to be the best syntax checker. I don't know that there is an add-in for your particular situation, but you should be able to add it to your build process pretty easily.
Update: Apparently there are some established techniques for integrating it with Aptana.
Welcome to the world of scripting!
Not sure if there is any Firefox add-on tool for checking JavaScript syntax, var declaration, or even pre-compiling available?
I find out is very difficult to debug JavaScript in a web html page. I have to add some script there. When the scripts get very big or long, it stops working. Basically, there must be some bugs. It is very frustrating even the load event stop working. I do need some good tools to find out the bugs.
I have tried FireBug. It is good but not enough. Maybe I don't know all its features. Anyway, I need any good suggestions.
This page may help you a bit as it also contains a screencast.
Debugging Javascript in Firefox with Firebug
It's not strictly an Add-On (although you can obviously run it in a Firefox web page), but I've found JSLint to be helpful in exposing expression anomalies that might or might not be strictly invalid syntax (although it will catch all those, too.)
My suggestion is to check you javascript with JSLint. JSLint will show you common problems in javascript code and helps you to create strict and compatible code.
YSlow includes JSLint as Tool.
As an alternative to FireBug check this debugger: Venkman JavaScript Debugger, has been out there for a while, and it's not bad at all...
I have always been a firebug fan and it sure is one of the best debuggers out there. Any JS issue Press F12, Enable the console for catching the errors and then you can find the exact line causing the error. Add a breakpoint and you can see the exact values of variables too. Very intuitive UI..just get used to using it and it will save a lot of your time.
I HIGHLY recommend Rainbow. It's still in Beta and only works in FF3, but it offers syntax highlighting. That will get you half-way there when it comes to syntax.
I constantly use firebug with a js file that has some 15000 lines. I've had no problems with it (sometimes I have to wait a few seconds for it to scroll to the breakpoint but even then it works fine).
Unfortunately JSLint does'nt work for us. We use some third party code that while beeing "valid" has unnecessary ";" according to jsLint. The code is in the beginning of our js file and jslint stops analyzing at 3% because it thinks there are too many errors (all of them unnecessary ";".)
You're missing the point on 2 counts:
First, being presented with a gazillion unnecessary error messages will make it impossible to find the problem in the first place.
Secondly, the errors are unnecessary. I used to use JSLint religiously, but now it's become too much of a code Nazi and I can't use it.
I'm aware that many of the things it checks for can be disabled, but I just don't have enough time to research what I'd have to do.
The issue is the usability of the default configuration. I, like the original poster, am just looking for a way to find true JavaScript syntax errors very quickly, including on HTML pages. I'm sure that Firebug can do it, but as in the case with JSLint, I don't have the spare time to find out how.
I do, however, use Firebug for debugging, though the version I'm using (1.10.3) has a bad habit of displaying errors, but reporting an incorrect file and line number.
Hi Gene: you could change one variable option.maxerr inside your jslint.js file into the number you want.
The default value is 50, you could change it to 500 or 1000 to suite your taste.
I use both the following for code validation.
JSHint # http://jshint.com
JSLint FF Plugin. Get at https://addons.mozilla.org/en-us/firefox/addon/jslinter/
Alternatively, jshint and jslint plugins are available for text editors like Notepad ++, sublime etc.