Home | History | Annotate | Download | only in tools
      1 #!/bin/bash
      2 
      3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 # This script checks the touch_ntp code for common errors and style
      8 # problems using the closure compiler (jscompiler) and closure linter
      9 # (gjslint) - both of which must be on the path.
     10 # See http://code.google.com/closure/compiler/ and
     11 # http://code.google.com/closure/utilities/ for details on these tools.
     12 
     13 SOURCES="touchhandler.js slider.js newtab.js grabber.js "
     14 SOURCES+="standalone/standalone_hack.js"
     15 
     16 # First run the closure compiler looking for syntactic issues.
     17 # Note that we throw away the output from jscompiler since it's use
     18 # is not yet common in Chromium and for now we want it to be an optional
     19 # tool for helping to find bugs, not something that actually changes
     20 # the embedded JavaScript (making it harder to debug, for example).
     21 
     22 # I used to run with '--warning_level VERBOSE' to get full type checking
     23 # but there are enough limitations in the language and compiler that
     24 # it doesn't seem worth the benefit (spent more time trying to apease
     25 # the compiler and reviewers of my code than the compiler saved me).
     26 
     27 # Enable support for property get/set syntax as added in ecmascript5.
     28 # Note that this requires a build of JSCompiler that is newer than
     29 # Feb 2011.
     30 CARGS="--language_in=ECMASCRIPT5_STRICT"
     31 
     32 CARGS+=" --js_output_file /dev/null"
     33 for S in $SOURCES tools/externs.js; do
     34     CARGS+=" --js $S"
     35 done
     36 
     37 cd `dirname $0`/..
     38 
     39 echo jscompiler $CARGS
     40 jscompiler $CARGS || exit 1
     41 
     42 # Now run the closure linter looking for style issues.
     43 
     44 # GJSLint can't follow the more concice syntax for prototype members and
     45 # complains about missing @this annotations (filed as bug 4073735).  To
     46 # cope for now I just just off all missing-JSDoc warnings.
     47 LARGS="--nojsdoc"
     48 
     49 # Verify extra rules like spacing and indentation
     50 LARGS+=" --strict"
     51 
     52 # Might as well check the bit of JS we have embedded in HTML too
     53 LARGS+=" --check_html newtab.html"
     54 
     55 LARGS+=" $SOURCES"
     56 
     57 echo gjslint $LARGS
     58 gjslint $LARGS || exit 1
     59