Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use .jshintrc files.

  • Loading branch information...
commit a1665402511eb99e9c1a29a47262763cb3a3ba68 1 parent 33df9b7
Scott González authored April 20, 2012
12  .jshintrc
... ...
@@ -0,0 +1,12 @@
  1
+{
  2
+	"curly": true,
  3
+	"eqnull": true,
  4
+	"eqeqeq": true,
  5
+	"expr": true,
  6
+	"latedef": true,
  7
+	"noarg": true,
  8
+	"onevar": true,
  9
+	"smarttabs": true,
  10
+	"trailing": true,
  11
+	"undef": true
  12
+}
114  grunt.js
... ...
@@ -1,3 +1,4 @@
  1
+/*jshint node: true */
1 2
 module.exports = function( grunt ) {
2 3
 
3 4
 var // modules
@@ -293,104 +294,29 @@ grunt.initConfig({
293 294
 		}
294 295
 	},
295 296
 	jshint: (function() {
296  
-		var defaults = {
297  
-			curly: true,
298  
-			eqnull: true,
299  
-			eqeqeq: true,
300  
-			expr: true,
301  
-			latedef: true,
302  
-			noarg: true,
303  
-			onevar: true,
304  
-			// TODO: limit to multi-line comments https://github.com/jshint/jshint/issues/503
305  
-			smarttabs: true,
306  
-			// TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504
307  
-			// strict: true,
308  
-			trailing: true,
309  
-			undef: true
310  
-		};
  297
+		function parserc( path ) {
  298
+			var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ),
  299
+				settings = {
  300
+					options: rc,
  301
+					globals: {}
  302
+				};
  303
+
  304
+			(rc.predef || []).forEach(function( prop ) {
  305
+				settings.globals[ prop ] = true;
  306
+			});
  307
+			delete rc.predef;
311 308
 
312  
-		function extend( a, b ) {
313  
-			for ( var prop in b ) {
314  
-				a[ prop ] = b[ prop ];
315  
-			}
316  
-			return a;
  309
+			return settings;
317 310
 		}
318 311
 
319 312
 		return {
320  
-			options: defaults,
321  
-			grunt: {
322  
-				options: extend({
323  
-					node: true
324  
-				}, defaults ),
325  
-				globals: {
326  
-					task: true,
327  
-					config: true,
328  
-					file: true,
329  
-					log: true,
330  
-					template: true
331  
-				}
332  
-			},
333  
-			ui: {
334  
-				options: extend({
335  
-					browser: true,
336  
-					jquery: true
337  
-				}, defaults ),
338  
-				globals: {
339  
-					Globalize: true
340  
-				}
341  
-			},
342  
-			tests: {
343  
-				options: extend({
344  
-					browser: true,
345  
-					jquery: true,
346  
-					// TODO: this is only for document.write() https://github.com/jshint/jshint/issues/519
347  
-					evil: true
348  
-				}, defaults ),
349  
-				// TODO: don't create so many globals in tests
350  
-				globals: {
351  
-					addMonths: true,
352  
-					asyncTest: true,
353  
-					container: true,
354  
-					deepEqual: true,
355  
-					d1: true,
356  
-					d2: true,
357  
-					dlg: true,
358  
-					domEqual: true,
359  
-					drag: true,
360  
-					dragged: true,
361  
-					el: true,
362  
-					equal: true,
363  
-					equalsDate: true,
364  
-					expect: true,
365  
-					Globalize: true,
366  
-					heightAfter: true,
367  
-					init: true,
368  
-					isNotOpen: true,
369  
-					isOpen: true,
370  
-					modal: true,
371  
-					module: true,
372  
-					moved: true,
373  
-					notEqual: true,
374  
-					offsetAfter: true,
375  
-					offsetBefore: true,
376  
-					ok: true,
377  
-					PROP_NAME: true,
378  
-					QUnit: true,
379  
-					restoreScroll: true,
380  
-					shouldBeDroppable: true,
381  
-					shouldmove: true,
382  
-					shouldNotBeDroppable: true,
383  
-					shouldnotmove: true,
384  
-					shouldnotresize: true,
385  
-					shouldresize: true,
386  
-					start: true,
387  
-					strictEqual: true,
388  
-					stop: true,
389  
-					test: true,
390  
-					TestHelpers: true,
391  
-					widthAfter: true
392  
-				}
393  
-			}
  313
+			// TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504
  314
+			// TODO: limit `smarttabs` to multi-line comments https://github.com/jshint/jshint/issues/503
  315
+			options: parserc(),
  316
+			ui: parserc( "ui/" ),
  317
+			// TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519
  318
+			// TODO: don't create so many globals in tests
  319
+			tests: parserc( "tests/" )
394 320
 		};
395 321
 	})()
396 322
 });
58  tests/.jshintrc
... ...
@@ -0,0 +1,58 @@
  1
+{
  2
+	"browser": true,
  3
+	"curly": true,
  4
+	"eqnull": true,
  5
+	"eqeqeq": true,
  6
+	"expr": true,
  7
+	"evil": true,
  8
+	"jquery": true,
  9
+	"latedef": true,
  10
+	"noarg": true,
  11
+	"onevar": true,
  12
+	"smarttabs": true,
  13
+	"trailing": true,
  14
+	"undef": true,
  15
+	"predef": [
  16
+		"addMonths",
  17
+		"asyncTest",
  18
+		"container",
  19
+		"deepEqual",
  20
+		"d1",
  21
+		"d2",
  22
+		"dlg",
  23
+		"domEqual",
  24
+		"drag",
  25
+		"dragged",
  26
+		"el",
  27
+		"equal",
  28
+		"equalsDate",
  29
+		"expect",
  30
+		"Globalize",
  31
+		"heightAfter",
  32
+		"init",
  33
+		"isNotOpen",
  34
+		"isOpen",
  35
+		"modal",
  36
+		"module",
  37
+		"moved",
  38
+		"notEqual",
  39
+		"offsetAfter",
  40
+		"offsetBefore",
  41
+		"ok",
  42
+		"PROP_NAME",
  43
+		"QUnit",
  44
+		"restoreScroll",
  45
+		"shouldBeDroppable",
  46
+		"shouldmove",
  47
+		"shouldNotBeDroppable",
  48
+		"shouldnotmove",
  49
+		"shouldnotresize",
  50
+		"shouldresize",
  51
+		"start",
  52
+		"strictEqual",
  53
+		"stop",
  54
+		"test",
  55
+		"TestHelpers",
  56
+		"widthAfter"
  57
+	]
  58
+}
17  ui/.jshintrc
... ...
@@ -0,0 +1,17 @@
  1
+{
  2
+	"browser": true,
  3
+	"curly": true,
  4
+	"eqnull": true,
  5
+	"eqeqeq": true,
  6
+	"expr": true,
  7
+	"jquery": true,
  8
+	"latedef": true,
  9
+	"noarg": true,
  10
+	"onevar": true,
  11
+	"smarttabs": true,
  12
+	"trailing": true,
  13
+	"undef": true,
  14
+	"predef": [
  15
+		"Globalize"
  16
+	]
  17
+}

0 notes on commit a166540

Please sign in to comment.
Something went wrong with that request. Please try again.