Hello all,
The other day I was wishing I had a tool that would help me make sure my JavaScript code was formatted cleanly and correctly. Servoy 6 helps find all kinds of JavaScript problems, but still I wanted more (because I have used Stylecop for C#
). The answer I found was the free JSLint Eclipse Plugin from Rock Star Apps. It was easy to install - simply went to Help - Install Software - Input http://update.rockstarapps.com - and Selected Rockstar JsLint. The settings I used are shown below. You just have to right-click your code and then select Rockstarapps - Validate with JSLint. I don’t know if anyone else will find this useful, but I thought I’d share anyway.
JSLint helps you to: format your code consistently, find coding mistakes that Servoy 6 misses (e.g. improper use of “for (myElement in myArray)”), etc.
[attachment=2]3-17-2011 11-31-52 AM.gif[/attachment]
[attachment=1]3-17-2011 11-56-27 AM.gif[/attachment]
[attachment=0]3-25-2011 8-57-57 AM.gif[/attachment]
When using object[“method”] notation (instead of object.method) to hide errors when calling protoype methods in Servoy 6, you must set JsLint to “Tolerate inefficient subscripting”, otherwise it will tell you to change the notation back to object.method.
Hello all,
I noticed recently that rockstarapps.com is out of commission. If you want to use jslint with Servoy, here are some new instructions for doing so.
- Install “Javascript Development Tools” and jslint4java in Eclipse using Help – Install New Software from the following site: https://svn.codespot.com/a/eclipselabs. … 1/download. See http://www.andyjamesdavies.com/javascri … clipse-ide for detailed instructions.
- Under Preferences – jslint4java, enable the settings shown here or as desired:
[attachment=0]Eclipse jslint4java Options 2012-01-30.png[/attachment]
- Enable it for your project by right clicking your project and choosing “Enable jslint4java”.
Notes:
- It may be necessary to do a Project – Clean to get the new warnings to show up.
- Be aware that the “Empty Block” warning shows up on the line after an empty block. It can be confusing if you don’t know this.
- The first time I installed this, I may have done something wrong because none of the Servoy code completion functionality was working. However, uninstalling and reinstalling “Javascript Development Tools” and jslint4java in Eclipse fixed the problem.
I installed JSLint in Servoy (Eclips). Installation was pretty straight forward, thanks for your post.
I still have a question about configuring JSLint.
JSLint is complaining about all Servoy keywords, like ‘scopes’, ‘globals’, ‘databaseManager’, ‘utils’, etc and relations.
Most keywords can be excluded by the “Names of predefined global variables” field in the preferences as you showed,
But how can I make JSLInt understand relations?
Unfortunately, the only way around it that I know of is to use bracket notation (e.g. instead of foo.bar, use foo[bar]).
Thanks for your reply. A bit dissapoinitng how many false-warnings are generated, but I’ll give it a try.