Additional Code Validation Using JSLint Plugin

Questions and answers regarding the use of eclipse environment as seen in Servoy Developer

Additional Code Validation Using JSLint Plugin

Postby hsummerhays » Fri Mar 25, 2011 5:32 pm

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.

3-17-2011 11-31-52 AM.gif
First Configuration Screen
3-17-2011 11-31-52 AM.gif (27.51 KiB) Viewed 7158 times


3-17-2011 11-56-27 AM.gif
Second Configuration Screen
3-17-2011 11-56-27 AM.gif (12.18 KiB) Viewed 7158 times


3-25-2011 8-57-57 AM.gif
JSLint Problems Found Sample
3-25-2011 8-57-57 AM.gif (7.21 KiB) Viewed 7158 times
Hugh Summerhays
Mainstream Data
hsummerhays
 
Posts: 29
Joined: Tue Mar 01, 2011 6:12 pm
Location: SLC, UT, USA

Re: Additional Code Validation Using JSLint Plugin

Postby hsummerhays » Fri Jul 22, 2011 6:40 pm

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.
Hugh Summerhays
Mainstream Data
hsummerhays
 
Posts: 29
Joined: Tue Mar 01, 2011 6:12 pm
Location: SLC, UT, USA

Re: Additional Code Validation Using JSLint Plugin

Postby hsummerhays » Tue Jan 31, 2012 12:22 am

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.

1. 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.
2. Under Preferences – jslint4java, enable the settings shown here or as desired:
Eclipse jslint4java Options 2012-01-30.png
Eclipse jslint4java Options 2012-01-30.png (52.76 KiB) Viewed 6739 times

3. Enable it for your project by right clicking your project and choosing “Enable jslint4java”.

Notes:
1. It may be necessary to do a Project – Clean to get the new warnings to show up.
2. 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.
3. 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.
Hugh Summerhays
Mainstream Data
hsummerhays
 
Posts: 29
Joined: Tue Mar 01, 2011 6:12 pm
Location: SLC, UT, USA

Re: Additional Code Validation Using JSLint Plugin

Postby japink.m » Sun Jul 12, 2015 9:43 pm

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?
japink.m
 
Posts: 23
Joined: Fri Jun 14, 2013 9:13 pm

Re: Additional Code Validation Using JSLint Plugin

Postby hsummerhays » Mon Jul 13, 2015 5:07 pm

Unfortunately, the only way around it that I know of is to use bracket notation (e.g. instead of foo.bar, use foo[bar]).
Hugh Summerhays
Mainstream Data
hsummerhays
 
Posts: 29
Joined: Tue Mar 01, 2011 6:12 pm
Location: SLC, UT, USA

Re: Additional Code Validation Using JSLint Plugin

Postby japink.m » Mon Jul 13, 2015 9:57 pm

Thanks for your reply. A bit dissapoinitng how many false-warnings are generated, but I'll give it a try.
japink.m
 
Posts: 23
Joined: Fri Jun 14, 2013 9:13 pm


Return to Eclipse Environment

Who is online

Users browsing this forum: No registered users and 4 guests

cron