]> source.dussan.org Git - jquery.git/commitdiff
Fix #12757 - use jscs to check the style guide
authorOleg <markelog@gmail.com>
Thu, 12 Sep 2013 20:51:59 +0000 (00:51 +0400)
committerOleg <markelog@gmail.com>
Thu, 7 Nov 2013 21:09:32 +0000 (22:09 +0100)
Cherry picked from ab63e568f50b5b9823490eda9c184e48cc6440c4 commit

.jscs.json [new file with mode: 0644]
Gruntfile.js
package.json

diff --git a/.jscs.json b/.jscs.json
new file mode 100644 (file)
index 0000000..6540c8f
--- /dev/null
@@ -0,0 +1,23 @@
+{
+    "requireCurlyBraces": [ "if", "else", "for", "while", "do" ],
+    "requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return" ],
+    "requireSpacesInFunctionExpression": {
+        "beforeOpeningCurlyBrace": true
+    },
+    "disallowSpacesInFunctionExpression": {
+        "beforeOpeningRoundBrace": true
+    },
+    "requireMultipleVarDecl": true,
+    "requireSpacesInsideObjectBrackets": "all",
+    "requireSpacesInsideArrayBrackets": "all",
+    "disallowLeftStickedOperators": [ "?", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<=" ],
+    "disallowRightStickedOperators": [ "?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
+    "requireRightStickedOperators": [ "!" ],
+    "requireLeftStickedOperators": [ "," ],
+    "disallowKeywords": [ "with" ],
+    "disallowMultipleLineBreaks": true,
+    "disallowKeywordsOnNewLine": [ "else" ],
+    "requireLineFeedAtFileEnd": true,
+
+    "excludeFiles": [ "src/intro.js", "src/outro.js" ]
+}
index 1f06b4e3420a460a5a42d1948fab0cde92ecf617..d9e94003b5e807ab230c8053a6153c45b2973b70 100644 (file)
@@ -2,14 +2,15 @@ module.exports = function( grunt ) {
 
        "use strict";
 
+       function readOptionalJSON( filepath ) {
+               var data = {};
+               try {
+                       data = grunt.file.readJSON( filepath );
+               } catch(e) {}
+               return data;
+       }
+
        var gzip = require( "gzip-js" ),
-               readOptionalJSON = function( filepath ) {
-                       var data = {};
-                       try {
-                               data = grunt.file.readJSON( filepath );
-                       } catch(e) {}
-                       return data;
-               },
                srcHintOptions = readOptionalJSON( "src/.jshintrc" );
 
        // The concatenated file won't pass onevar
@@ -48,19 +49,24 @@ module.exports = function( grunt ) {
                        pkg: {
                                src: [ "package.json" ]
                        },
+
+                       jscs: {
+                               src: [ ".jscs.json" ]
+                       },
+
                        bower: {
                                src: [ "bower.json" ]
                        }
                },
                jshint: {
                        src: {
-                               src: [ "src/**/*.js" ],
+                               src: "src/**/*.js",
                                options: {
                                        jshintrc: "src/.jshintrc"
                                }
                        },
                        dist: {
-                               src: [ "dist/jquery.js" ],
+                               src: "dist/jquery.js",
                                options: srcHintOptions
                        },
                        grunt: {
@@ -70,12 +76,15 @@ module.exports = function( grunt ) {
                                }
                        },
                        tests: {
-                               src: [ "test/**/*.js" ],
+                               src: "test/**/*.js",
                                options: {
                                        jshintrc: "test/.jshintrc"
                                }
                        }
                },
+               jscs: {
+                       src: "src/**/*.js"
+               },
                testswarm: {
                        tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing Sizzle".split(" ")
                },
@@ -135,12 +144,13 @@ module.exports = function( grunt ) {
        grunt.loadNpmTasks( "grunt-contrib-jshint" );
        grunt.loadNpmTasks( "grunt-contrib-uglify" );
        grunt.loadNpmTasks( "grunt-jsonlint" );
+       grunt.loadNpmTasks( "grunt-jscs-checker" );
 
        // Integrate jQuery specific tasks
        grunt.loadTasks( "build/tasks" );
 
        // Short list as a high frequency watch task
-       grunt.registerTask( "dev", [ "build:*:*", "jshint" ] );
+       grunt.registerTask( "dev", [ "build:*:*", "jshint", "jscs" ] );
 
        // Default grunt
        grunt.registerTask( "default", [ "jsonlint", "dev", "pre-uglify", "uglify", "post-uglify", "dist:*", "compare_size" ] );
index b172dece692b384b2141423863d498a85e2d7390..a4e4425305f05b780c07864e72fd4d15b6178c06 100644 (file)
@@ -1,3 +1,4 @@
+
 {
   "name": "jquery",
   "title": "jQuery",
@@ -35,6 +36,7 @@
     "grunt-contrib-uglify": "~0.2.4",
     "grunt-contrib-watch": "~0.5.3",
     "grunt-git-authors": "~1.2.0",
+    "grunt-jscs-checker": "~0.2.3",
     "grunt-jsonlint": "~1.0.1",
     "gzip-js": "0.3.2",
     "testswarm": "~1.1.0",