Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 7f4edaf

Browse files
committed
chore(build): add jscs code style check to our build
Closes #6062
1 parent 6dcfccb commit 7f4edaf

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

.jscs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"disallowKeywords": ["with"]
3+
}

.jscs.json.todo

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This is an incomplete TODO list of checks we want to start enforcing
2+
//
3+
// The goal is to enable these checks one by one by moving them to .jscs.json along with commits
4+
// that correct the existing code base issues and make the new check pass.
5+
6+
{
7+
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
8+
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
9+
"disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
10+
"disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
11+
"requireRightStickedOperators": ["!"],
12+
"requireLeftStickedOperators": [","],
13+
"disallowImplicitTypeConversion": ["string"],
14+
"disallowMultipleLineBreaks": true,
15+
"disallowKeywordsOnNewLine": ["else"],
16+
"disallowTrailingWhitespace": true,
17+
"requireLineFeedAtFileEnd": true,
18+
"validateJSDoc": {
19+
"checkParamNames": true,
20+
"requireParamTypes": true
21+
}
22+
}

Gruntfile.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = function(grunt) {
1212
grunt.loadNpmTasks('grunt-contrib-jshint');
1313
grunt.loadNpmTasks('grunt-ddescribe-iit');
1414
grunt.loadNpmTasks('grunt-jasmine-node');
15+
grunt.loadNpmTasks("grunt-jscs-checker");
1516
grunt.loadNpmTasks('grunt-merge-conflict');
1617
grunt.loadNpmTasks('grunt-parallel');
1718
grunt.loadNpmTasks('grunt-shell');
@@ -145,6 +146,13 @@ module.exports = function(grunt) {
145146
}
146147
},
147148

149+
jscs: {
150+
src: ['src/**/*.js', 'test/**/*.js'],
151+
options: {
152+
config: ".jscs.json"
153+
}
154+
},
155+
148156
build: {
149157
scenario: {
150158
dest: 'build/angular-scenario.js',
@@ -301,6 +309,6 @@ module.exports = function(grunt) {
301309
grunt.registerTask('webserver', ['connect:devserver']);
302310
grunt.registerTask('package', ['bower','clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']);
303311
grunt.registerTask('package-without-bower', ['clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']);
304-
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint']);
312+
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint', 'jscs']);
305313
grunt.registerTask('default', ['package']);
306314
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "https://github.com/angular/angular.js.git"
99
},
1010
"devDependencies": {
11-
"grunt": "~0.4.1",
11+
"grunt": "~0.4.2",
1212
"bower": "~1.2.2",
1313
"grunt-bump": "~0.0.13",
1414
"grunt-contrib-clean": "~0.5.0",
@@ -41,7 +41,8 @@
4141
"grunt-shell": "~0.4.0",
4242
"semver": "~2.1.0",
4343
"lodash": "~2.1.0",
44-
"browserstacktunnel-wrapper": "~1.1.1"
44+
"browserstacktunnel-wrapper": "~1.1.1",
45+
"grunt-jscs-checker": "~0.3.2"
4546
},
4647
"licenses": [
4748
{

0 commit comments

Comments
 (0)