Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

Use .jshtinrc files for linting
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Sun, 30 Sep 2012 16:31:26 +0000 (18:31 +0200)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Sun, 30 Sep 2012 16:31:26 +0000 (18:31 +0200)
.jshintrc [deleted file]
addons/.jshintrc [new file with mode: 0644]
grunt.js
qunit/.jshintrc [new file with mode: 0644]
test/.jshintrc [new file with mode: 0644]

diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644 (file)
index 7edcc8f..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-       "predef": [
-               "QUnit"
-       ],
-       "browser": true,
-       "smarttabs": true
-}
diff --git a/addons/.jshintrc b/addons/.jshintrc
new file mode 100644 (file)
index 0000000..9399d0f
--- /dev/null
@@ -0,0 +1,24 @@
+{
+       "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": [
+               "module",
+               "test",
+               "asyncTest",
+               "expect",
+               "start",
+               "stop",
+               "QUnit"
+       ]
+}
\ No newline at end of file
index 448cbf2..cb5f95d 100644 (file)
--- a/grunt.js
+++ b/grunt.js
@@ -16,65 +16,34 @@ grunt.initConfig({
        },
        lint: {
                qunit: 'qunit/qunit.js',
-               // addons: 'addons/**/*.js',
+               addons: 'addons/**.js',
                grunt: 'grunt.js'
-               // TODO need to figure out which warnings to fix and which to disable
-               // tests: 'test/test.js'
+               // TODO fix remaining warnings
+               // tests: 'test/**.js'
        },
-       jshint: {
-               qunit: {
-                       options: {
-                               onevar: true,
-                               browser: true,
-                               bitwise: true,
-                               curly: true,
-                               trailing: true,
-                               immed: true,
-                               latedef: false,
-                               newcap: true,
-                               noarg: false,
-                               noempty: true,
-                               nonew: true,
-                               sub: true,
-                               undef: true,
-                               eqnull: true,
-                               proto: true,
-                               smarttabs: true
-                       },
-                       globals: {
-                               jQuery: true,
-                               exports: true
-                       }
-               },
-               addons: {
-                       options: {
-                               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
-                       },
-                       globals: {
-                               module: true,
-                               test: true,
-                               asyncTest: true,
-                               expect: true,
-                               start: true,
-                               stop: true,
-                               QUnit: true
-                       }
-               },
-               tests: {
+       // TODO rmeove this one grunt 0.4 is out, see jquery-ui for other details
+       jshint: (function() {
+               function parserc( path ) {
+                       var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ),
+                               settings = {
+                                       options: rc,
+                                       globals: {}
+                               };
+
+                       (rc.predef || []).forEach(function( prop ) {
+                               settings.globals[ prop ] = true;
+                       });
+                       delete rc.predef;
+
+                       return settings;
                }
-       }
+
+               return {
+                       addons: parserc( "addons/" ),
+                       qunit: parserc( "qunit/" ),
+                       tests: parserc( "test/" )
+               };
+       })()
 });
 
 grunt.registerTask( "build-git", function( sha ) {
diff --git a/qunit/.jshintrc b/qunit/.jshintrc
new file mode 100644 (file)
index 0000000..04aa9de
--- /dev/null
@@ -0,0 +1,22 @@
+{
+       "onevar": true,
+       "browser": true,
+       "bitwise": true,
+       "curly": true,
+       "trailing": true,
+       "immed": true,
+       "latedef": false,
+       "newcap": true,
+       "noarg": false,
+       "noempty": true,
+       "nonew": true,
+       "sub": true,
+       "undef": true,
+       "eqnull": true,
+       "proto": true,
+       "smarttabs": true,
+       "predef": [
+               "jQuery",
+               "exports"
+       ]
+}
diff --git a/test/.jshintrc b/test/.jshintrc
new file mode 100644 (file)
index 0000000..7edcc8f
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       "predef": [
+               "QUnit"
+       ],
+       "browser": true,
+       "smarttabs": true
+}

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf