Evaluating code quality with JSLint

To check for problems in your script code during builds, you can enable the included version of JSLint. JSLint evaluates code for overall quality, including syntax, structure, and style conventions, which may help avoid runtime errors by finding issues that cause compiler errors.

For more information on the specific checks carried out by JSLint, see the JSLint instructions at www.jslint.com.

Note: Some checks specific to the use of JavaScript with HTML are omitted from LDD. A different comment, described in the following, is used to identify functions defined later in or outside of the script and LDD objects as global variables.

When JSLint is enabled, code is parsed during project builds. Any warnings generated are shown in the Problems view.

Note: If the Problems view does not appear in the Eclipse software, then see the documentation for the Eclipse software.

To enable JSLint during the build, do the following:

  1. In the Eclipse software, click Window > Preferences.

  2. In the category list, expand Lexmark, and then select JSLint > Enable JSLint.

  3. If necessary, configure the checks for JSLint to carry out, and then click OK.

Note: Project builds for large solutions may be noticeably slower when JSLint is enabled. You may want to enable JSLint only while debugging.

Avoiding warnings for functions and LDD objects

To identify LDD objects and indicate functions defined later in or outside of the script to JSLint, use the comment /**jsLint variableName */.

To identify the LDD top-level objects, include this comment in the script. For example,

/**jsLint caller,confirm,confirmTarget,context,credentials,printerIP,taskInfo */