From 83663fd428bef6d45a406ca05c2db49f647ced5a Mon Sep 17 00:00:00 2001 From: pk1a Date: Wed, 12 Mar 2014 15:07:25 +0100 Subject: [PATCH] build: introduce jscs checks infrastructure Closes #99 --- .jscs.json | 5 +++++ .jscs.json.todo | 41 +++++++++++++++++++++++++++++++++++++++++ gruntfile.js | 10 ++++++++-- package.json | 3 ++- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 .jscs.json create mode 100644 .jscs.json.todo diff --git a/.jscs.json b/.jscs.json new file mode 100644 index 0000000..dc33fd0 --- /dev/null +++ b/.jscs.json @@ -0,0 +1,5 @@ +{ + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "disallowYodaConditions": true +} \ No newline at end of file diff --git a/.jscs.json.todo b/.jscs.json.todo new file mode 100644 index 0000000..5810e0f --- /dev/null +++ b/.jscs.json.todo @@ -0,0 +1,41 @@ +{ + "maximumLineLength": 140, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "requireDotNotation": true, + "requireLeftStickedOperators": [","], + "requireSpaceAfterBinaryOperators": [ + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==" + ], + "requireCapitalizedConstructors": true, + "safeContextKeyword": "self", + "requireCurlyBraces": [ + "if", + "else", + "for", + "while", + "do", + "try", + "catch", + "case", + "default" + ], + "requireSpaceAfterKeywords": [ + "if", + "else", + "for", + "while", + "do", + "switch", + "return", + "try", + "catch" + ] +} \ No newline at end of file diff --git a/gruntfile.js b/gruntfile.js index 9279e66..635e833 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -147,6 +147,12 @@ module.exports = function (grunt) { reporters: ['dots', 'saucelabs'] } }, + jscs: { + src: ['hsp/**/*.js', 'public/**/*.js', '!public/**/markdown.js'], + options: { + config: '.jscs.json' + } + }, hspserver: { port: 8000, base: __dirname, @@ -258,7 +264,7 @@ module.exports = function (grunt) { grunt.registerTask('prepublish', ['peg']); grunt.registerTask('package', ['prepublish', 'browserify', 'atpackager', 'uglify']); grunt.registerTask('mocha', ['peg', 'mochaTest']); - grunt.registerTask('test', ['checkStyle', 'mocha', 'karma:unit']); - grunt.registerTask('ci', ['checkStyle', 'mocha', 'karma:ci', 'package']); + grunt.registerTask('test', ['checkStyle', 'jscs', 'mocha', 'karma:unit']); + grunt.registerTask('ci', ['checkStyle', 'jscs', 'mocha', 'karma:ci', 'package']); grunt.registerTask('default', ['hspserver']); }; \ No newline at end of file diff --git a/package.json b/package.json index 9aec119..5718983 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "load-grunt-tasks": "~0.2.1", "expect.js": "0.2.0", "noder-js": "~1.2.0", - "jquery": "~1.11.0" + "jquery": "~1.11.0", + "grunt-jscs-checker": "~0.4.0" }, "scripts": { "test": "grunt test",