diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..a1888b5f --- /dev/null +++ b/.jshintrc @@ -0,0 +1,100 @@ +{ + // JSHint Configuration File + // See http://jshint.com/docs/ for more details + + "maxerr" : 200, + + //Enforcing + + "bitwise" : true, + "camelcase" : false, + "curly" : false, + "eqeqeq" : true, + "forin" : true, + "freeze" : true, + "immed" : false, + "indent" : 4, + "latedef" : false, + "newcap" : false, + "noarg" : true, + "noempty" : true, + "nonbsp" : true, + "nonew" : false, + "plusplus" : false, + "quotmark" : false, + "undef" : true, + "unused" : false, + "strict" : true, + "maxparams" : false, + "maxdepth" : false, + "maxstatements" : false, + "maxcomplexity" : false, + "maxlen" : false, + + //Relaxing + + "asi" : false, + "boss" : false, + "debug" : false, + "eqnull" : false, + "es5" : false, + "esnext" : false, + "moz" : false, + "evil" : false, + "expr" : true, + "funcscope" : false, + "globalstrict" : true, + "iterator" : false, + "lastsemic" : false, + "laxbreak" : false, + "laxcomma" : false, + "loopfunc" : false, + "multistr" : false, + "noyield" : false, + "notypeof" : false, + "proto" : false, + "scripturl" : false, + "shadow" : true, + "sub" : false, + "supernew" : false, + "validthis" : false, + + // Environments + + "browser" : true, + "browserify" : false, + "couch" : false, + "devel" : true, + "dojo" : false, + "jasmine" : false, + "jquery" : true, + "mocha" : true, + "mootools" : false, + "node" : false, + "nonstandard" : false, + "phantom" : false, + "prototypejs" : false, + "qunit" : false, + "rhino" : false, + "shelljs" : false, + "typed" : false, + "worker" : false, + "wsh" : false, + "yui" : false, + + // Globals + + "predef" : { + "getEvent" : false, + "addClass" : false, + "getStyle" : false, + "addEvent" : false, + "cancelEvent" : false, + "removeClass" : false, + "removeEvent" : false, + "onTouchClick" : false, + "isMobile" : false, + "L" : false // leaflet library + } + +} diff --git a/Gemfile b/Gemfile index c897ffe4..f8fbca8b 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,7 @@ group :development do gem 'kramdown', '~>1.6.0' gem 'RedCloth' gem 'therubyracer' # required by less + gem 'jshintrb', '~>0.3.0' end ## Not used on build server. Only used by developers and Travis CI, so diff --git a/Gemfile.lock b/Gemfile.lock index 6cdff2c1..2bed22d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,6 +12,7 @@ GEM commonjs (0.2.7) ethon (0.7.3) ffi (>= 1.3.0) + execjs (2.6.0) fast-stemmer (1.0.2) ffi (1.9.3) ffi-icu (0.1.2) @@ -35,6 +36,10 @@ GEM pygments.rb (~> 0.5.0) redcarpet (~> 2.3.0) safe_yaml (~> 0.9.7) + jshintrb (0.3.0) + execjs + multi_json (>= 1.3) + rake json (1.8.1) kramdown (1.6.0) less (2.4.0) @@ -49,6 +54,7 @@ GEM syntax (>= 1.0.0) mercenary (0.3.5) mini_portile (0.6.2) + multi_json (1.11.2) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) parallel (1.4.1) @@ -56,6 +62,7 @@ GEM pygments.rb (0.5.4) posix-spawn (~> 0.3.6) yajl-ruby (~> 1.1.0) + rake (10.4.2) rb-fsevent (0.9.3) rb-inotify (0.9.2) ffi (>= 0.5.0) @@ -81,6 +88,7 @@ DEPENDENCIES ffi-icu html-proofer jekyll (~> 1.3.0) + jshintrb (~> 0.3.0) json kramdown (~> 1.6.0) less diff --git a/Makefile b/Makefile index 384ecb91..6ac9385c 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,8 @@ post-build-tests-fast: check-for-build-errors ensure-each-svg-has-a-png check-fo check-for-missing-anchors check-for-broken-markdown-reference-links \ check-for-broken-kramdown-tables check-for-duplicate-header-ids \ check-for-headers-containing-auto-link check-for-missing-subhead-links \ - check-for-subheading-anchors + check-for-subheading-anchors \ + check-jshint ## All pre-build tests, including those which might take multiple minutes pre-build-tests: pre-build-tests-fast @@ -248,6 +249,9 @@ check-for-broken-bitcoin-core-download-links: check-html-proofer: $S bundle exec ruby _contrib/bco-htmlproof +check-jshint: + $S bundle exec ruby _contrib/jshint | eval $(ERROR_ON_OUTPUT) + check-bundle: ## Ensure all the dependencies are installed. If you build without this ## check, you'll get confusing error messages when your deps aren't up diff --git a/_contrib/jshint b/_contrib/jshint new file mode 100644 index 00000000..571ab13c --- /dev/null +++ b/_contrib/jshint @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby + +# This file is licensed under the MIT License (MIT) available on +# http://opensource.org/licenses/MIT. + +# Print any warning from JSHint for custom javascript code. + +require 'jshintrb' + +if ARGV[0].nil? + path_to_check="./_site/js" +else + path_to_check=ARGV[0] +end + +Dir.foreach(path_to_check) do |file| + next if !/\.js$/.match(file) + res = Jshintrb.report(File.read(path_to_check + '/' + file), :jshintrc) + print path_to_check + '/' + file + "\n" + res if res.length != 0 +end