Just found this - JSLint

Earlier this week I received a copy of JavaScript Patterns. I've only finished the first two chapters and already I'm finding it to be an incredible book. (I'll be doing a review when I finish.) One of the first things I learned while reading it concerned a tool called JSLint. To quote their FAQ, JSLint is a code quality tool. It can read in JavaScript and report on problems, best practices, anti-patterns, etc. It is very configurable so if you find it too strict you can knock it down a peg or two. I spent a few minutes last night (before my Black Ops session!) working on a ColdFusion Builder Extension. Why? It isn't really needed - there is an eclipse plugin already for JSLint. But it gave me an excuse to write another extension and revel in how darn cool ColdFusion Builder is. Here is a quick example of it in action:

Currently the extension can be used on JavaScript files within the project view and code snippets in open CFM files. (You can't run extensions on editor files that are not CFM or CFCs.) I also took the opportunity to finally begin work on a CFC to make extension writing easier. Here are a few examples of what the CFC can do:

<cfparam name="ideeventinfo"> <cfset builderHelper = new builderHelper(ideeventinfo)> <cfset runAs = builderHelper.getRunType()>

You begin by passing in the XML packet CFBuilder sends on all requests to the CFC. The getRunType returns how the extension was run. Since my JSLint extension runs from both the project explorer and the editor I need to know which was used.

<cfif runAs is "projectView"> <cfset selectedResource = builderHelper.getSelectedResource()> <cffile action="read" file="#selectedResource.path#" variable="contents"> <cfset resource = selectedResource.path> <cfelseif runAs is "editor"> <cfset data = builderHelper.getSelectedText()> <cfset contents = data.text> <cfset resource = data.path> <cfelse> <cfthrow message="JSLint extension run in a way it is not supposed to be run."> </cfif>

If we called the extension via the project view, I ask for the selected resource. This returns a structure of the path of the selection as well as the type (folder versus file). If the editor was used, I simply run getSelectedText. This method will check to see if there was an actual selection. If not, it grabs the entire contents of the file. Finally, here is another method in action:

<script src="#builderHelper.getrooturl()#jquery-1.4.3.min.js"></script> Anyway, I plan on adding to this as time goes on. Click the download link below to get the extension.

Download attached file.

Like This?

If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can also subscribe to the email feed to get notified of new posts.