|
|
|
|
Setting Up JavaScript LintYou can run JavaScript Lint several ways:
Additionally, if you are a software developer, you may want to integrate into your Windows program or run it from your PHP website to take advantage of the full power of JavaScript Lint. Disable Warnings with Control CommentJavaScript Lint has limited support for control comments. To disable warnings in part of your JavaScript file, you can add the following comments:
To ignore all warnings in a file, simply place /*jsl:ignoreall*/ at the top of the file. Note that this should only be used as a short-term solution for code that you maintain. If this is caused by a bug or missing feature in JavaScript Lint, please report the problem to Info<at>JavaScriptLint.com. Option ExplicitJavaScript Lint can optionally check for variables, functions, and objects that don't exist, much like Visual Basic's "option explicit." In the interest of making JavaScript Lint accessible to the average programmer, this powerful feature is disabled by default. Although this feature requires more work to understand and implement, it provides a higher level of protection against coding errors. A variable that is not explicitly declared has a global scope. For example, if a function uses a counter variable and calls another function that uses a counter variable by the same name, unless these functions use the var keyword to declare the variable, the two functions will be accessing and modifying the same variable. This almost never produces the expected behavior. Here's what it takes to set up this feature:
JavaScript Lint does not validate object properties. They do not use the var keyword and cannot be validated without executing the script. The warnings for undeclared identifiers will appear after other warnings that may occur in the script. This is by design, since the entire script must be examined before identifiers can be called undefined. Switches and BreaksBy default, JavaScript Lint warns against missing break's in switch statements. Sometimes, however, break statements are intentionally excluded. To indicate this, use the /*jsl:fallthru*/ control comment:
Empty StatementsBy default, JavaScript Lint warns against empty statements. However, empty statements are sometimes intention. To indicate this, use the /*jsl:pass*/ control comment:
Advanced Output FormatThe following output formats may also be used:
If the output format is prefixed with "encode:", all backslashes, single and double quotes, tabs, carriage returns, and line breaks will be escaped as \\, \' and \", \t, \r, and \n (respectively). Syntax Note: In addition to the /*jsl:keyword*/ syntax, control
comments can also use the traditional /*@keyword@*/ syntax. However,
the
jsl syntax is recommended for interoperability with JScript
conditional compilation.
|
|
|