Skip to content

Commit

Permalink
Fix #12757 - use jscs to check the style guide
Browse files Browse the repository at this point in the history
Close gh-1396
  • Loading branch information
markelog committed Nov 7, 2013
1 parent ee0d0e6 commit 5ce0b34
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
23 changes: 23 additions & 0 deletions .jscs.json
@@ -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" ]
}
32 changes: 21 additions & 11 deletions Gruntfile.js
Expand Up @@ -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
Expand Down Expand Up @@ -50,19 +51,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: {
Expand All @@ -72,12 +78,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(" ")
},
Expand Down Expand Up @@ -137,12 +146,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" ] );
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -35,6 +35,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",
Expand Down

0 comments on commit 5ce0b34

Please sign in to comment.