From: Daniel Brooks Date: Mon, 21 Feb 2011 16:29:12 +0000 (-0600) Subject: [#354] pass a list of files to lint from the Makefile to jslint-check.js, and fix... X-Git-Tag: v0.4~33^2~1^2~3 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=bf499e73b912f80cf08092f4d36edc8d6331402d;p=popcorn-js.git [#354] pass a list of files to lint from the Makefile to jslint-check.js, and fix a few sources of error within jslint-check.js --- diff --git a/Makefile b/Makefile index 69b6e05..eca8f0a 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ ${POPCORN_MIN}: ${POPCORN_DIST} lint: ${POPCORN_DIST} @@echo "Checking Popcorn against JSLint..." - @@${RHINO} build/jslint-check.js + @@${RHINO} build/jslint-check.js popcorn.js ${PLUGINS_SRC} clean: @@echo "Removing Distribution directory:" ${DIST_DIR} @@ -109,6 +109,3 @@ ${PLUGINS_MIN}: ${PLUGINS_DIST} @@${MINJAR} --js ${PLUGINS_DIST} --warning_level QUIET --js_output_file ${PLUGINS_MIN}.tmp @@cat ${PLUGINS_MIN}.tmp >> ${PLUGINS_MIN} @@rm -f ${PLUGINS_MIN}.tmp - - - diff --git a/build/jslint-check.js b/build/jslint-check.js index 162a802..7afb7a4 100644 --- a/build/jslint-check.js +++ b/build/jslint-check.js @@ -1,9 +1,5 @@ load("build/jslint.js"); -var src = readFile("popcorn.js"); - -JSLINT(src, { evil: true, forin: true, maxerr: 100 }); - // All of the following are known issues that we think are 'ok' // (in contradiction with JSLint) more information here: // http://docs.jquery.com/JQuery_Core_Style_Guidelines @@ -16,21 +12,31 @@ var ok = { "'e' is already defined.": true }; -var e = JSLINT.errors, found = 0, w; +function check(src) +{ + var e = JSLINT.errors, found = 0, w; + + JSLINT(src, { evil: true, forin: true, maxerr: 100 }); -for ( var i = 0; i < e.length; i++ ) { - w = e[i]; + for ( var i = 0; e && i < e.length; i++ ) { + w = e[i]; - if ( !ok[ w.reason ] ) { - found++; - print( "\n" + w.evidence + "\n" ); - print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason ); + if ( w && !ok[ w.reason ] ) { + found++; + print( "\n" + w.evidence + "\n" ); + print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason ); + } + } + + if ( found > 0 ) { + print( "\n" + found + " Error(s) found." ); + } else { + print( "JSLint check passed." ); } } -if ( found > 0 ) { - print( "\n" + found + " Error(s) found." ); - -} else { - print( "JSLint check passed." ); +for each (var f in arguments) +{ + print( "Linting "+ f ); + check(readFile(f)); }