JavaScript code validation is provided anywhere JavaScript is recognized in a structured editor, such as HTML or JSP files, or standalone JavaScript. Two types of validation are provided: "as-you-type" and batch. Like validation in the JDT, markers will appear underneath offending code as it is typed, and markers will appear in the margins when the code is loaded or saved in a batch mode. These markers can also be seen in the Problems view or as overlay markers in the Package Explorer or other places where a file icon represents the code buffer.
For each of these types of validation, two validators have been implemented for JavaScript. A syntax checker, based on the Mozilla Rhino engine, version 1.5, scans the code. It will find illegal uses of JavaScript keywords, syntax or structures. Rhino reports most problems as errors (red) but may also report some warnings (yellow). Note that the syntax checker will not flag runtime errors such as undefined variable references. These must be observed in the Browser Console at runtime, and may only be triggered under certain execution paths.
The second validator is based on a popular program called JSLint, itself written in JavaScript. JSLint looks for a variety of coding errors, including undesirable or ambiguous constructs which it considers to be bad practice. JSLint will report only the first error it finds, and because it makes no distinction between blocking errors and complaints about coding style, JSLint errors are reported as warnings in yellow. Sometimes these warnings will be redundant with Rhino errors and may even provide additional hints as to the origin of the problem.
Related concepts