- Forward


JSLint
A Static Analysis Tool for ECMAScript/JavaScript


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Introduction
Back SMYC Forward
  • Purpose:
    • Simple static analysis style checking and structure checking
  • Motivation:
    • "Many of the features that were intended to make [JavaScript] easy to use are troublesome when projects become more complicated."
Some Details
Back SMYC Forward
  • Global Variables:
    • Requires all variables and functions to be defined before they are used
  • Semicolons:
    • Every statement except for, function, if, switch, try and while must be followed by a semicolon
  • Commas:
    • Must be used only as a separator not an operator
    • Must not use extra commas
  • Block Scope:
    • Must not declare a variable in a block
  • Block Statements:
    • Requires block statements in conditional statements and loop statements
Controlling JSLint
Back SMYC Forward
  • On-Line (www.jslint.com):
    • Options are selected with checkboxes
  • Off-Line:
    • Can be specified using the /*jslint */ directive (note that there is no space before the j)
    • IDEs often allow you to filter the report
Not Surprisingly
Back SMYC Forward
  • The Controversy:
    • Everyone doesn't agree with JSLint
  • A Fork:
    • JSHint is a fork that allows for customization
There's Always More to Learn
Back -