From a1665402511eb99e9c1a29a47262763cb3a3ba68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 20 Apr 2012 09:38:04 -0400 Subject: [PATCH] Use .jshintrc files. --- .jshintrc | 12 +++++ grunt.js | 114 +++++++++--------------------------------------- tests/.jshintrc | 58 ++++++++++++++++++++++++ ui/.jshintrc | 17 ++++++++ 4 files changed, 107 insertions(+), 94 deletions(-) create mode 100644 .jshintrc create mode 100644 tests/.jshintrc create mode 100644 ui/.jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..99161bd4e --- /dev/null +++ b/.jshintrc @@ -0,0 +1,12 @@ +{ + "curly": true, + "eqnull": true, + "eqeqeq": true, + "expr": true, + "latedef": true, + "noarg": true, + "onevar": true, + "smarttabs": true, + "trailing": true, + "undef": true +} diff --git a/grunt.js b/grunt.js index 7827961da..bbe6323ba 100644 --- a/grunt.js +++ b/grunt.js @@ -1,3 +1,4 @@ +/*jshint node: true */ module.exports = function( grunt ) { var // modules @@ -293,104 +294,29 @@ grunt.initConfig({ } }, jshint: (function() { - var defaults = { - curly: true, - eqnull: true, - eqeqeq: true, - expr: true, - latedef: true, - noarg: true, - onevar: true, - // TODO: limit to multi-line comments https://github.com/jshint/jshint/issues/503 - smarttabs: true, - // TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504 - // strict: true, - trailing: true, - undef: true - }; + function parserc( path ) { + var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ), + settings = { + options: rc, + globals: {} + }; - function extend( a, b ) { - for ( var prop in b ) { - a[ prop ] = b[ prop ]; - } - return a; + (rc.predef || []).forEach(function( prop ) { + settings.globals[ prop ] = true; + }); + delete rc.predef; + + return settings; } return { - options: defaults, - grunt: { - options: extend({ - node: true - }, defaults ), - globals: { - task: true, - config: true, - file: true, - log: true, - template: true - } - }, - ui: { - options: extend({ - browser: true, - jquery: true - }, defaults ), - globals: { - Globalize: true - } - }, - tests: { - options: extend({ - browser: true, - jquery: true, - // TODO: this is only for document.write() https://github.com/jshint/jshint/issues/519 - evil: true - }, defaults ), - // TODO: don't create so many globals in tests - globals: { - addMonths: true, - asyncTest: true, - container: true, - deepEqual: true, - d1: true, - d2: true, - dlg: true, - domEqual: true, - drag: true, - dragged: true, - el: true, - equal: true, - equalsDate: true, - expect: true, - Globalize: true, - heightAfter: true, - init: true, - isNotOpen: true, - isOpen: true, - modal: true, - module: true, - moved: true, - notEqual: true, - offsetAfter: true, - offsetBefore: true, - ok: true, - PROP_NAME: true, - QUnit: true, - restoreScroll: true, - shouldBeDroppable: true, - shouldmove: true, - shouldNotBeDroppable: true, - shouldnotmove: true, - shouldnotresize: true, - shouldresize: true, - start: true, - strictEqual: true, - stop: true, - test: true, - TestHelpers: true, - widthAfter: true - } - } + // TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504 + // TODO: limit `smarttabs` to multi-line comments https://github.com/jshint/jshint/issues/503 + options: parserc(), + ui: parserc( "ui/" ), + // TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519 + // TODO: don't create so many globals in tests + tests: parserc( "tests/" ) }; })() }); diff --git a/tests/.jshintrc b/tests/.jshintrc new file mode 100644 index 000000000..2db023452 --- /dev/null +++ b/tests/.jshintrc @@ -0,0 +1,58 @@ +{ + "browser": true, + "curly": true, + "eqnull": true, + "eqeqeq": true, + "expr": true, + "evil": true, + "jquery": true, + "latedef": true, + "noarg": true, + "onevar": true, + "smarttabs": true, + "trailing": true, + "undef": true, + "predef": [ + "addMonths", + "asyncTest", + "container", + "deepEqual", + "d1", + "d2", + "dlg", + "domEqual", + "drag", + "dragged", + "el", + "equal", + "equalsDate", + "expect", + "Globalize", + "heightAfter", + "init", + "isNotOpen", + "isOpen", + "modal", + "module", + "moved", + "notEqual", + "offsetAfter", + "offsetBefore", + "ok", + "PROP_NAME", + "QUnit", + "restoreScroll", + "shouldBeDroppable", + "shouldmove", + "shouldNotBeDroppable", + "shouldnotmove", + "shouldnotresize", + "shouldresize", + "start", + "strictEqual", + "stop", + "test", + "TestHelpers", + "widthAfter" + ] +} \ No newline at end of file diff --git a/ui/.jshintrc b/ui/.jshintrc new file mode 100644 index 000000000..415d69e90 --- /dev/null +++ b/ui/.jshintrc @@ -0,0 +1,17 @@ +{ + "browser": true, + "curly": true, + "eqnull": true, + "eqeqeq": true, + "expr": true, + "jquery": true, + "latedef": true, + "noarg": true, + "onevar": true, + "smarttabs": true, + "trailing": true, + "undef": true, + "predef": [ + "Globalize" + ] +}