Thursday, May 14, 2015

How to Check Your jQuery Application on JSLint

JSLint is a browser application developed by Mr Douglas Crockford as JavaScript code quality test tool.

Let's get right on it
This is the error shown if we didn't declare the global variable option.
Undeclared '$'.
JSLint error - jQuery
The list of options can be found on the bottom of the JSLint's user interface.

Find the Global variables... part, then type $.
global variables option on JSLint
Test your jQuery coding once more...
Fix some things...
repeat...

...And have yourself a neat progrum

External script
This option is also useful for declaring a (custom) global variable from your own (custom) external script, which is not "there" on that particular application-depended-on-that-external-script you check.

Intended for browser
Remember to tick the a browser option if your script uses the document object keyword.

Window, console, and others
There are few object keywords which aren't "included" in JSLint, like:
  • window
  • console
  • And maybe others...
Include those keywords in the Global variables..., and bam!

BAM!

No comments:

Post a Comment

Tell me what you think...