From 96246332f723b0f83e465d0f9f580741c8272f80 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Mon, 25 Jun 2012 10:49:21 -0400 Subject: [PATCH] Adds .jshintrc files for: grunt (default set), src, tests; Adapts jQuery-UI loading method --- .jshintrc | 11 +++++++ grunt.js | 80 +++++++++++++------------------------------------- src/.jshintrc | 27 +++++++++++++++++ test/.jshintrc | 56 +++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 60 deletions(-) create mode 100644 .jshintrc create mode 100644 src/.jshintrc create mode 100644 test/.jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..fd498d83b --- /dev/null +++ b/.jshintrc @@ -0,0 +1,11 @@ +{ + "curly": true, + "eqnull": true, + "eqeqeq": true, + "expr": true, + "latedef": true, + "noarg": true, + "smarttabs": true, + "trailing": true, + "undef": true +} diff --git a/grunt.js b/grunt.js index cde713c04..ab693def5 100644 --- a/grunt.js +++ b/grunt.js @@ -5,6 +5,7 @@ * */ +/*jshint node: true */ /*global config:true, task:true, process:true*/ module.exports = function( grunt ) { @@ -14,8 +15,8 @@ module.exports = function( grunt ) { function readOptionalJSON( filepath ) { var data = {}; try { - data = grunt.file.readJSON(filepath); - grunt.log.write( "Reading data from " + filepath + "..." ).ok(); + data = grunt.file.readJSON( filepath ); + grunt.verbose.write( "Reading " + filepath + "..." ).ok(); } catch(e) {} return data; } @@ -81,9 +82,25 @@ module.exports = function( grunt ) { min: { "dist/jquery.min.js": [ "", "dist/jquery.js" ] }, + lint: { - files: [ "test/unit/**/*.js", "grunt.js", "dist/jquery.js" ] + dist: "dist/jquery.js", + grunt: "grunt.js", + tests: "tests/unit/**/*.js" }, + + jshint: (function() { + function jshintrc( path ) { + return readOptionalJSON( (path || "") + ".jshintrc" ) || {}; + } + + return { + options: jshintrc(), + dist: jshintrc( "src/" ), + tests: jshintrc( "test/" ) + }; + })(), + qunit: { files: "test/index.html" }, @@ -91,63 +108,6 @@ module.exports = function( grunt ) { files: [ "", "src/**/*.js" ], tasks: "dev" }, - jshint: { - options: { - evil: true, - browser: true, - wsh: true, - eqnull: true, - expr: true, - curly: true, - trailing: true, - undef: true, - smarttabs: true, - maxerr: 100 - }, - globals: { - define: true, - DOMParser: true, - __dirname: true, - jQuery: true, - global: true, - module: true, - exports: true, - require: true, - file: true, - log: true, - console: true, - QUnit: true, - ok: true, - equal: true, - test: true, - asyncTest: true, - notEqual: true, - deepEqual: true, - strictEqual: true, - notStrictEqual: true, - start: true, - stop: true, - expect: true, - raises: true, - testIframe: true, - testIframeWithCallback: true, - createDashboardXML: true, - moduleTeardown: true, - testFoo: true, - foobar: true, - url: true, - t: true, - q: true, - amdDefined: true, - fireNative: true, - hasPHP: true, - isLocal: true, - originaljQuery: true, - "$": true, - "original$": true - - } - }, uglify: {} }); diff --git a/src/.jshintrc b/src/.jshintrc new file mode 100644 index 000000000..faf031dfd --- /dev/null +++ b/src/.jshintrc @@ -0,0 +1,27 @@ +{ + "options": { + "evil": true, + "browser": true, + "wsh": true, + "eqnull": true, + "expr": true, + "curly": true, + "trailing": true, + "undef": true, + "smarttabs": true, + "maxerr": 100 + }, + "globals": { + "define": true, + "DOMParser": true, + "__dirname": true, + "jQuery": true, + "global": true, + "module": true, + "exports": true, + "require": true, + "file": true, + "log": true, + "console": true + } +} diff --git a/test/.jshintrc b/test/.jshintrc new file mode 100644 index 000000000..13039f827 --- /dev/null +++ b/test/.jshintrc @@ -0,0 +1,56 @@ +{ + "options": { + "evil": true, + "browser": true, + "wsh": true, + "eqnull": true, + "expr": true, + "curly": true, + "trailing": true, + "undef": true, + "smarttabs": true, + "maxerr": 100 + }, + "globals": { + "define": true, + "DOMParser": true, + "__dirname": true, + "jQuery": true, + "global": true, + "module": true, + "exports": true, + "require": true, + "file": true, + "log": true, + "console": true, + "QUnit": true, + "ok": true, + "equal": true, + "test": true, + "asyncTest": true, + "notEqual": true, + "deepEqual": true, + "strictEqual": true, + "notStrictEqual": true, + "start": true, + "stop": true, + "expect": true, + "raises": true, + "testIframe": true, + "testIframeWithCallback": true, + "createDashboardXML": true, + "moduleTeardown": true, + "testFoo": true, + "foobar": true, + "url": true, + "t": true, + "q": true, + "amdDefined": true, + "fireNative": true, + "hasPHP": true, + "isLocal": true, + "originaljQuery": true, + "$": true, + "original$": true + } +}