Skip to content

Commit c462e66

Browse files
committed
Build: Add jscs task for code style checking
1 parent 0e19297 commit c462e66

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

.jscs.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"requireCurlyBraces": [ "if", "else", "for", "while", "do" ],
3+
"requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return" ],
4+
"requireSpacesInFunctionExpression": {
5+
"beforeOpeningCurlyBrace": true
6+
},
7+
"disallowSpacesInFunctionExpression": {
8+
"beforeOpeningRoundBrace": true
9+
},
10+
"requireMultipleVarDecl": true,
11+
"requireSpacesInsideObjectBrackets": "all",
12+
"requireSpacesInsideArrayBrackets": "all",
13+
"disallowLeftStickedOperators": [ "?", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<=" ],
14+
"disallowRightStickedOperators": [ "?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
15+
"requireRightStickedOperators": [ "!" ],
16+
"requireLeftStickedOperators": [ "," ],
17+
"disallowKeywords": [ "with" ],
18+
"disallowMultipleLineBreaks": true,
19+
"disallowKeywordsOnNewLine": [ "else" ],
20+
"requireLineFeedAtFileEnd": true,
21+
22+
"excludeFiles": [ "src/intro.js", "src/outro.js" ]
23+
}

Gruntfile.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ grunt.loadNpmTasks( "grunt-contrib-uglify" );
105105
grunt.loadNpmTasks( "grunt-contrib-concat" );
106106
grunt.loadNpmTasks( "grunt-contrib-qunit" );
107107
grunt.loadNpmTasks( "grunt-contrib-csslint" );
108+
grunt.loadNpmTasks( "grunt-jscs-checker" );
108109
grunt.loadNpmTasks( "grunt-html" );
109110
grunt.loadNpmTasks( "grunt-compare-size" );
110111
grunt.loadNpmTasks( "grunt-git-authors" );
@@ -161,6 +162,13 @@ grunt.initConfig({
161162
dest: "dist/jquery-ui.css"
162163
}
163164
},
165+
jscs: {
166+
// datepicker, sortable, resizable and draggable are getting rewritten, ignore until that's done
167+
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" ],
168+
// TODO enable this once we have a tool that can help with fixing formatting of existing files
169+
// tests: "tests/unit/**/*.js",
170+
grunt: "Gruntfile.js"
171+
},
164172
uglify: minify,
165173
htmllint: {
166174
// ignore files that contain invalid html, used only for ajax content testing
@@ -197,7 +205,7 @@ grunt.initConfig({
197205
});
198206

199207
grunt.registerTask( "default", [ "lint", "test" ] );
200-
grunt.registerTask( "lint", [ "asciilint", "jshint", "csslint", "htmllint" ] );
208+
grunt.registerTask( "lint", [ "asciilint", "jshint", "jscs", "csslint", "htmllint" ] );
201209
grunt.registerTask( "test", [ "qunit" ] );
202210
grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] );
203211
grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] );

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"grunt-contrib-qunit": "0.2.0",
6464
"grunt-contrib-csslint": "0.1.1",
6565
"grunt-compare-size": "0.4.0-rc.3",
66+
"grunt-jscs-checker": "0.2.0",
6667
"grunt-html": "0.3.3",
6768
"grunt-git-authors": "1.2.0",
6869
"rimraf": "2.1.4",

0 commit comments

Comments
 (0)