Skip to content

Commit 7987e25

Browse files
authored
Merge pull request #59 from krmorse/master
Improve jshint support
2 parents 59036a3 + b1a5a02 commit 7987e25

4 files changed

Lines changed: 108 additions & 25 deletions

File tree

lib/build/get-script.coffee

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,25 @@ module.exports =
3939
@getScripts {appPath, scripts: configJson.html}, htmlFilesCallback
4040
callback
4141

42-
getJavaScripts: ({appPath, scripts,compress}, callback)->
43-
@getScripts {appPath, scripts}, (err, results) =>
44-
if err then callback(err)
45-
else
46-
for key,code of results
47-
fileName = scripts[key]
48-
@hintJavaScriptFile(code, fileName)
49-
if compress
50-
try
51-
results[key] = @compressJavaScript code
52-
catch e
53-
callback new Error()
54-
return
55-
else
56-
results[key] = code
57-
callback(null, results)
42+
getJavaScripts: ({appPath, scripts, compress}, callback) ->
43+
jshintrc = path.resolve appPath, '.jshintrc'
44+
@readFile jshintrc, (e, jshintConfig) =>
45+
jshintOptions = JSON.parse jshintConfig || "{}"
46+
@getScripts {appPath, scripts}, (err, results) =>
47+
if err then callback(err)
48+
else
49+
for key,code of results
50+
fileName = scripts[key]
51+
@hintJavaScriptFile(code, jshintOptions, fileName) unless compress
52+
if compress
53+
try
54+
results[key] = @compressJavaScript code
55+
catch e
56+
callback new Error()
57+
return
58+
else
59+
results[key] = code
60+
callback(null, results)
5861

5962
getStylesheets: ({appPath, scripts, compress}, callback)->
6063
@getScripts {appPath, scripts}, (err, results) =>
@@ -87,7 +90,9 @@ module.exports =
8790
callback(error, fileContents)
8891
fs.readFile(file, "utf-8", wrapper)
8992

90-
hintJavaScriptFile: (code, fileName)->
91-
if(!JSHINT(code, undef: false))
93+
hintJavaScriptFile: (code, jshintOptions, fileName) ->
94+
if(!JSHINT(code, jshintOptions))
95+
console.error()
9296
for error in JSHINT.errors
93-
console.log "Error in #{fileName} on line #{error.line}: #{error.reason}" unless !error
97+
console.error "Error in #{fileName} on line #{error.line}: #{error.reason}" unless !error
98+
console.error()

lib/init.coffee

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ files =
1111
".travis.yml": ".travis.yml"
1212
"LICENSE": "LICENSE"
1313
"README.md": "README.md"
14-
"Gruntfile.js":"Gruntfile.js"
15-
"package.json":"package.json"
16-
"specs.tmpl":"test/specs.tmpl"
17-
"AppSpec.js":"test/AppSpec.js"
14+
"Gruntfile.js": "Gruntfile.js"
15+
"package.json": "package.json"
16+
"specs.tmpl": "test/specs.tmpl"
17+
"AppSpec.js": "test/AppSpec.js"
18+
".jshintrc": ".jshintrc"
1819

1920
directories = ["test"]
2021

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Kyle Morse <kyle.morse@ca.com>",
33
"name": "rally-app-builder",
44
"description": "A node module that assists in the building of Rally Apps",
5-
"version": "1.2.8",
5+
"version": "1.2.9",
66
"homepage": "https://github.com/rallyapps/rally-app-builder",
77
"repository": {
88
"type": "git",
@@ -27,7 +27,7 @@
2727
"grunt-contrib-jasmine": "0.4.x",
2828
"grunt-contrib-watch": "~0.4.4",
2929
"handlebars": "~1.0.11",
30-
"jshint": "~0.9.1",
30+
"jshint": "~2.9.2",
3131
"less": "~1.7.0",
3232
"lodash": "~3.0.0",
3333
"mustache": "0.7.x",

templates/.jshintrc

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"maxerr" : 50,
3+
4+
"bitwise" : true,
5+
"camelcase" : false,
6+
"curly" : true,
7+
"eqeqeq" : true,
8+
"forin" : true,
9+
"freeze" : true,
10+
"immed" : false,
11+
"latedef" : false,
12+
"newcap" : false,
13+
"noarg" : true,
14+
"noempty" : true,
15+
"nonbsp" : true,
16+
"nonew" : false,
17+
"plusplus" : false,
18+
"quotmark" : false,
19+
"undef" : true,
20+
"unused" : true,
21+
"strict" : false,
22+
"maxparams" : false,
23+
"maxdepth" : false,
24+
"maxstatements" : false,
25+
"maxcomplexity" : false,
26+
"maxlen" : false,
27+
"varstmt" : false,
28+
29+
"asi" : false,
30+
"boss" : false,
31+
"debug" : false,
32+
"eqnull" : false,
33+
"esversion" : 5,
34+
"moz" : false,
35+
"evil" : false,
36+
"expr" : false,
37+
"funcscope" : false,
38+
"globalstrict" : false,
39+
"iterator" : false,
40+
"lastsemic" : false,
41+
"laxbreak" : false,
42+
"laxcomma" : false,
43+
"loopfunc" : false,
44+
"multistr" : false,
45+
"noyield" : false,
46+
"notypeof" : false,
47+
"proto" : false,
48+
"scripturl" : false,
49+
"shadow" : false,
50+
"sub" : true,
51+
"supernew" : false,
52+
"validthis" : false,
53+
54+
"browser" : true,
55+
"browserify" : false,
56+
"couch" : false,
57+
"devel" : true,
58+
"dojo" : false,
59+
"jasmine" : false,
60+
"jquery" : false,
61+
"mocha" : true,
62+
"mootools" : false,
63+
"node" : false,
64+
"nonstandard" : false,
65+
"phantom" : false,
66+
"prototypejs" : false,
67+
"qunit" : false,
68+
"rhino" : false,
69+
"shelljs" : false,
70+
"typed" : false,
71+
"worker" : false,
72+
"wsh" : false,
73+
"yui" : false,
74+
75+
"globals" : {},
76+
"predef" : ["Ext", "Deft", "_", "moment"]
77+
}

0 commit comments

Comments
 (0)