Use "legend" option with "follow" value. Hide legend on deselect.
[dygraphs.git] / lint.sh
CommitLineData
758a629f 1#!/bin/bash
fefe0bfe
DV
2#
3# Usage:
4# ./lint.sh [file.js]
5#
6# The zero-argument form lints everything.
7
42a9ebb8
DV
8# See jshint/build/jshint-rhino.js for documentation on these parameters.
9# devel defines logging globals (i.e. "console.log")
10# browser defines standard web browser globals (i.e. "document")
11# shadow disables warnings on multiple var definitions in one scope (i.e. two
12# loops with "var i")
13jsc_opts='maxerr:10000,devel:true,browser:true,shadow:true'
14rhino_opts='maxerr=10000,devel=true,browser=true,shadow=true'
758a629f 15
d3b49430
RK
16RETURN_VALUE=0
17
fefe0bfe 18if [ $# -eq 0 ]; then
e1e80cce 19 files=$(ls dygraph*.js plugins/*.js datahandler/*.js gallery/*.js | grep -v combined | grep -v dev.js| grep -v externs)
fefe0bfe 20else
e1e80cce 21 files=$@
fefe0bfe 22fi
758a629f
DV
23
24if [ -e /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc ]; then
25 # use JSC (Safari/JavaScriptCore) to run JSHint -- much faster than Rhino.
26 echo 'Running JSHint w/ JavaScriptCore (jsc)...'
27 for file in $files; do
d3b49430 28 ./jshint/env/jsc.sh $file $jsc_opts || RETURN_VALUE=1
758a629f
DV
29 done
30else
31 # fall back to Rhino.
32 echo 'Running JSHint w/ Rhino...'
33
34 for FILE in $files; do
35 LINT_RESULT=$(java -jar ./jsdoc-toolkit/java/classes/js.jar ./jshint/build/jshint-rhino.js $rhino_opts $FILE)
36 ERRORS=$(echo ${LINT_RESULT} | egrep [^\s] -c)
37 if [[ ${ERRORS} -ne 0 ]]; then
38 echo "[jshint] Error(s) in ${FILE}:"
39 printf "%s\n" "${LINT_RESULT}"
d3b49430 40 RETURN_VALUE=1
758a629f
DV
41 else
42 echo "[jshint] ${FILE} passed!"
43 fi
44 done
45fi
d3b49430
RK
46
47exit $RETURN_VALUE