| OLD | NEW |
| (Empty) |
| 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="event_tracker.js touch_handler.js card_slider.js new_tab.js grabber.js
apps_page.js recently_closed.js" | |
| 14 | |
| 15 # First run the closure compiler looking for syntactic issues. | |
| 16 # Note that we throw away the output from jscompiler since it's use | |
| 17 # is not yet common in Chromium and for now we want it to be an optional | |
| 18 # tool for helping to find bugs, not something that actually changes | |
| 19 # the embedded JavaScript (making it harder to debug, for example). | |
| 20 | |
| 21 # I used to run with '--warning_level VERBOSE' to get full type checking | |
| 22 # but there are enough limitations in the language and compiler that | |
| 23 # it doesn't seem worth the benefit (spent more time trying to apease | |
| 24 # the compiler and reviewers of my code than the compiler saved me). | |
| 25 | |
| 26 # Enable support for property get/set syntax as added in ecmascript5. | |
| 27 # Note that this requires a build of JSCompiler that is newer than | |
| 28 # Feb 2011. | |
| 29 CARGS="--language_in=ECMASCRIPT5_STRICT" | |
| 30 | |
| 31 CARGS+=" --js_output_file /dev/null" | |
| 32 for S in $SOURCES tools/externs.js; do | |
| 33 CARGS+=" --js $S" | |
| 34 done | |
| 35 | |
| 36 cd `dirname $0`/.. | |
| 37 | |
| 38 echo jscompiler $CARGS | |
| 39 jscompiler $CARGS || exit 1 | |
| 40 | |
| 41 # Now run the closure linter looking for style issues. | |
| 42 | |
| 43 # GJSLint can't follow the more concice syntax for prototype members and | |
| 44 # complains about missing @this annotations (filed as bug 4073735). To | |
| 45 # cope for now I just just off all missing-JSDoc warnings. | |
| 46 LARGS="--nojsdoc" | |
| 47 | |
| 48 # Verify extra rules like spacing and indentation | |
| 49 LARGS+=" --strict" | |
| 50 | |
| 51 # Might as well check the bit of JS we have embedded in HTML too | |
| 52 LARGS+=" --check_html new_tab.html" | |
| 53 | |
| 54 LARGS+=" $SOURCES" | |
| 55 | |
| 56 echo gjslint $LARGS | |
| 57 gjslint $LARGS || exit 1 | |
| OLD | NEW |