Eclipse Javascript how to switch off missing semicolon warning? - javascript

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

Related

Chrome dev tools lose syntax highlighting for TypeScript

I'm not sure if there if a way around this, or if maybe there is an issue when using mapped TypeScript files, but in many cases (larger files), I seem to lose the syntax highlighting..
As can be seen on the above image, it is ok until line 102, and from then on the rest of the file is just in red.
The above is from an Ionic 2 / Angular 2 project.
Appears to happen after the use of backtick string (but not always after the use of these)
It is not the end of the world, but the highlighting does make it easier to read. Anyone else experience this, and perhaps know a work around?
experiencing this problem all the time working with TS sourcemaps.
that's chromium engine trouble, there is also bug report about this problem
(link to report)
I gave up for this and using oldschool string concatenation.

What is the most effective JavaScript syntax checking solution?

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/

Is there a good javascript plugin for visual studio?

I think that Visual Studio's biggest let down is the Javascript editor. I have been told to use Aptana as an editor for my javascript files, but I would prefer to stick with visual studio if possible.
I have read other similar plugin posts, but none focus specifically on Javascript.
VS2010 may offer some improvements, but will they be up to Apatana standards? I have briefly tested the beta, but I'm not overly impressed.
Is there anything out there that will bring Javascript closer to c# development? Considering the wide spread use of Javascript I think there must be something....... I hope! :)
Many thanks in advance... this is something that has always bugged me!
There's a couple recent plugins that may be helpful :
From Microsoft :
JScript Editor Extensions
Brace Matching
Outlining / Cold-folding
Current Word Highlighting
IntelliSense Doc-Comments Support
JSEnhancements
Outlining and matching braces highlighting
(I wouldn't think installing both of these is a good idea - and the Microsoft plugin has more features so try that one first)
VS is a pretty good IDE (especially when coupled with Resharper) but not so hot with Javascript. The debugger is good and there's the JSLint plugin but other than that I'm not sure. Aptana (based on Eclipse) is an excellent javascript IDE but it doesn't like it much when the javascript is embedded in aspx files (unless they updated the support recently). So far I'm not sure there's an ideal .net platform IDE for both client and server side stuff just yet.
Update: Resharper 6 added pretty good JavaScript support - so now I'd recommend that combination if you're doing a lot of debugging across client and server at the same time. If you're focussing on pure client code then I find WebStorm to be an excellent JavaScript/HTML IDE - even better than Aptana.
I'd really like to recommend Webstorm. It does not! treat your JS as text files.
Its a full blown JS editor and has become my favourite JS editor working in parallel with VS to handle my server side stuff.
WS has actual object intellisense across JS files. That means when I press . (dot) it shows me the functions on that objects, even if its located physically in another file.
It will recognize my objects (or their type if you will) created in other JS files referred to in the file I'm working on.
I have 'Find usages' on JS functions
I have 'find all references' on JS object / function / class / variable or whatever you want to search on. In the end its all objects but Webstorm knows this.
If I change the short/cut to F12, I can press F12 on my function call and it will jump to the implementation of that JS functon. Even if its located in another file.
Ofc. you have code folding and colouring, extract method and other neat code re factoring, overview creating tools.
Oh. And by the way.
I'd like to kill off a rumour going around in the cloud on forums I come across from time to time, looking for better ways to handle JS.
reSharper DO NOT SUPPORT JAVASCRIPT! A little piece of me dies every time I read some guy repeating what he saw on the reSharper site. It may have a some poor intellisense and some low level syntax check, but that has nothing to do with support.
Notepad++ supports JS better than VS in my opinion.
Münster
Don't forget to grab Chirpy to handle minifying your scripts in VS.
If you use Visual Studio, add the
/// <reference path="myOtherJsFile.js" />
directive at top of your js files and install Web Essentials you get pretty decent (but not perfect) intellisense, go to definition by using F12 and find all references (sort of..) by using SHIFT+F12

How to enforce semicolons in JavaScript?

How best does the developer who's decided he likes semicolons at the end of his JavaScript statements enforce that expectation technically for himself?
I'm using Visual Studio (ASP.NET webapps), but I'd love to hear about solutions for any environment.
You could somehow integrate Javascript Lint into the IDE.
I sometimes run my JS through a handler that strips all new lines, comments, tabs, and extra whitespace automatically. If my JS statements don't end with a semi-colon I'll get an error (in most cases)...doing it this way is a PAIN to debug though (e.g., error on line 1 character 2654).
The other way I use is Firebug + YSlow. You can check it's built in JSLint every once in a while.
Maybe there is a file in Visual Studio for checking javascript syntax you may be able to modify like there is for (X)HTML and XML.

Firefox add-on tools for checking JavaScript syntax?

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.

Categories

Resources