Skip to content

Commit

Permalink
Added JSCS validation to the Grunt testing process
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbenner committed Jan 5, 2017
1 parent 611e544 commit c741ed8
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 3 deletions.
80 changes: 80 additions & 0 deletions .jscsrc
@@ -0,0 +1,80 @@
{
"requireCurlyBraces": [ "if", "else", "for", "while", "do", "try", "catch" ],
"requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return", "try", "catch" ],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": {
"afterTest": true,
"beforeConsequent": true,
"afterConsequent": true,
"beforeAlternate": true
},
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInNamedFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInFunctionDeclaration": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInCallExpression": true,
"requireBlocksOnNewline": true,
"disallowPaddingNewlinesInBlocks": true,
"disallowEmptyBlocks": true,
"disallowSpacesInsideParentheses": true,
"requireSpacesInsideObjectBrackets": "all",
"requireSpacesInsideArrayBrackets": "all",
"disallowQuotedKeysInObjects": true,
"disallowDanglingUnderscores": true,
"disallowSpaceAfterObjectKeys": true,
"requireSpaceBeforeObjectValues": true,
"requireCommaBeforeLineBreak": true,
"requireOperatorBeforeLineBreak": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"requireSpaceBeforeBinaryOperators": [ "=", "+", "-", "/", "*", "==", "===", "!=", "!==" ],
"disallowSpaceBeforeBinaryOperators": [ "," ],
"requireSpaceAfterBinaryOperators": true,
"disallowImplicitTypeConversion": [ "numeric", "boolean", "binary", "string" ],
"requireCamelCaseOrUpperCaseIdentifiers": true,
"disallowKeywords": [ "with" ],
"disallowMultipleLineStrings": true,
"disallowMultipleLineBreaks": true,
"disallowNewlineBeforeBlockStatements": true,
"validateQuoteMarks": {
"mark": "'",
"escape": true
},
"validateIndentation": 2,
"validateParameterSeparator": ", ",
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"disallowKeywordsOnNewLine": [ "else" ],
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"disallowYodaConditions": true,
"requireSpaceAfterLineComment": true,
"jsDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
}
}
21 changes: 18 additions & 3 deletions Gruntfile.js
Expand Up @@ -28,21 +28,36 @@ module.exports = function(grunt) {
}
}
},
jscs: {
options: {
config: '.jscsrc'
},
grunt: {
src: [ 'Gruntfile.js' ]
},
bin: {
src: [ 'bin/*' ]
},
lib: {
src: [ 'lib/*.js' ]
}
},
jsonlint: {
lib: {
src: [ 'lib/*.json' ]
},
project: {
src: [ '.jshintrc', 'package.json' ]
src: [ '.jscsrc', '.jshintrc', 'package.json' ]
}
}
});

// load grunt plugins
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-jsonlint');

// register grunt tasks
grunt.registerTask('default', [ 'jshint', 'jsonlint' ]);
grunt.registerTask('travis', [ 'jshint', 'jsonlint' ]);
grunt.registerTask('default', [ 'jshint', 'jscs', 'jsonlint' ]);
grunt.registerTask('travis', [ 'jshint', 'jscs', 'jsonlint' ]);
};
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -30,6 +30,7 @@
"devDependencies": {
"grunt": "~1.0",
"grunt-contrib-jshint": "~1.1",
"grunt-jscs": "3.0",
"grunt-jsonlint": "~1.1"
},
"keywords": []
Expand Down

0 comments on commit c741ed8

Please sign in to comment.