Skip to content

Commit

Permalink
Add JSHint checks to the Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
saivann committed Aug 21, 2015
1 parent cf11cc8 commit 41195a9
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 1 deletion.
100 changes: 100 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -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
}

}
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -49,13 +54,15 @@ 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)
posix-spawn (0.3.6)
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)
Expand All @@ -81,6 +88,7 @@ DEPENDENCIES
ffi-icu
html-proofer
jekyll (~> 1.3.0)
jshintrb (~> 0.3.0)
json
kramdown (~> 1.6.0)
less
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions _contrib/jshint
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 41195a9

Please sign in to comment.