]> source.dussan.org Git - jquery-ui.git/commitdiff
Build: Add jscs task for code style checking 1109/head
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 10 Oct 2013 16:42:21 +0000 (18:42 +0200)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Wed, 13 Nov 2013 18:20:16 +0000 (19:20 +0100)
.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 e5ee423f1c34b6da32d78af5ddcd6e2d2a5d83be..63ff1cf3965db8142c64a6cfeb40060ab8a7ce93 100644 (file)
@@ -105,6 +105,7 @@ grunt.loadNpmTasks( "grunt-contrib-uglify" );
 grunt.loadNpmTasks( "grunt-contrib-concat" );
 grunt.loadNpmTasks( "grunt-contrib-qunit" );
 grunt.loadNpmTasks( "grunt-contrib-csslint" );
+grunt.loadNpmTasks( "grunt-jscs-checker" );
 grunt.loadNpmTasks( "grunt-html" );
 grunt.loadNpmTasks( "grunt-compare-size" );
 grunt.loadNpmTasks( "grunt-git-authors" );
@@ -161,6 +162,13 @@ grunt.initConfig({
                        dest: "dist/jquery-ui.css"
                }
        },
+       jscs: {
+               // datepicker, sortable, resizable and draggable are getting rewritten, ignore until that's done
+               ui: [ "ui/jquery.ui.*.js", "!ui/jquery.ui.datepicker.js", "!ui/jquery.ui.sortable.js", "!ui/jquery.ui.resizable.js", "!ui/jquery.ui.draggable.js" ],
+               // TODO enable this once we have a tool that can help with fixing formatting of existing files
+               // tests: "tests/unit/**/*.js",
+               grunt: "Gruntfile.js"
+       },
        uglify: minify,
        htmllint: {
                // ignore files that contain invalid html, used only for ajax content testing
@@ -197,7 +205,7 @@ grunt.initConfig({
 });
 
 grunt.registerTask( "default", [ "lint", "test" ] );
-grunt.registerTask( "lint", [ "asciilint", "jshint", "csslint", "htmllint" ] );
+grunt.registerTask( "lint", [ "asciilint", "jshint", "jscs", "csslint", "htmllint" ] );
 grunt.registerTask( "test", [ "qunit" ] );
 grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] );
 grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] );
index 02fbf7c5a2eea32eccea6849bbbcaf0c15398714..a802617b18a5b86364c47bf920386e33925a16f4 100644 (file)
@@ -63,6 +63,7 @@
                "grunt-contrib-qunit": "0.2.0",
                "grunt-contrib-csslint": "0.1.1",
                "grunt-compare-size": "0.4.0-rc.3",
+               "grunt-jscs-checker": "0.2.0",
                "grunt-html": "0.3.3",
                "grunt-git-authors": "1.2.0",
                "rimraf": "2.1.4",