diff --git a/.jscs.json b/.jscs.json new file mode 100644 index 000000000000..e2307d167704 --- /dev/null +++ b/.jscs.json @@ -0,0 +1,3 @@ +{ + "disallowKeywords": ["with"] +} diff --git a/.jscs.json.todo b/.jscs.json.todo new file mode 100644 index 000000000000..6f6f041672c2 --- /dev/null +++ b/.jscs.json.todo @@ -0,0 +1,22 @@ +// This is an incomplete TODO list of checks we want to start enforcing +// +// The goal is to enable these checks one by one by moving them to .jscs.json along with commits +// that correct the existing code base issues and make the new check pass. + +{ + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], + "disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "requireRightStickedOperators": ["!"], + "requireLeftStickedOperators": [","], + "disallowImplicitTypeConversion": ["string"], + "disallowMultipleLineBreaks": true, + "disallowKeywordsOnNewLine": ["else"], + "disallowTrailingWhitespace": true, + "requireLineFeedAtFileEnd": true, + "validateJSDoc": { + "checkParamNames": true, + "requireParamTypes": true + } +} diff --git a/Gruntfile.js b/Gruntfile.js index 1ec4d66a6afa..d66f66207ee7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,15 +6,16 @@ module.exports = function(grunt) { //grunt plugins grunt.loadNpmTasks('grunt-bump'); grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-compress'); - grunt.loadNpmTasks('grunt-jasmine-node'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-ddescribe-iit'); + grunt.loadNpmTasks('grunt-jasmine-node'); + grunt.loadNpmTasks("grunt-jscs-checker"); grunt.loadNpmTasks('grunt-merge-conflict'); grunt.loadNpmTasks('grunt-parallel'); grunt.loadNpmTasks('grunt-shell'); - grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadTasks('lib/grunt'); var NG_VERSION = util.getVersion(); @@ -145,6 +146,13 @@ module.exports = function(grunt) { } }, + jscs: { + src: ['src/**/*.js', 'test/**/*.js'], + options: { + config: ".jscs.json" + } + }, + build: { scenario: { dest: 'build/angular-scenario.js', @@ -301,6 +309,6 @@ module.exports = function(grunt) { grunt.registerTask('webserver', ['connect:devserver']); grunt.registerTask('package', ['bower','clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']); grunt.registerTask('package-without-bower', ['clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']); - grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint']); + grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint', 'jscs']); grunt.registerTask('default', ['package']); }; diff --git a/package.json b/package.json index eeec930e7f03..591cf8583554 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/angular/angular.js.git" }, "devDependencies": { - "grunt": "~0.4.1", + "grunt": "~0.4.2", "bower": "~1.2.2", "grunt-bump": "~0.0.13", "grunt-contrib-clean": "~0.5.0", @@ -41,7 +41,9 @@ "grunt-shell": "~0.4.0", "semver": "~2.1.0", "lodash": "~2.1.0", - "browserstacktunnel-wrapper": "~1.1.1" + "browserstacktunnel-wrapper": "~1.1.1", + "jscs": "~1.2.4", + "grunt-jscs-checker": "~0.3.2" }, "licenses": [ {