Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
feat(gen): add jscs
Browse files Browse the repository at this point in the history
Added jscs to replace styling rules deprecated by jshint. Details
can be found here regarding the rules that were previously used
by this generator: #1086

Jscs rule descriptions can be found here: http://jscs.info/rules.html

Closes #1109
  • Loading branch information
roaks3 committed Jul 23, 2015
1 parent 7804182 commit f407573
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
3 changes: 3 additions & 0 deletions common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Generator.prototype.setupEnv = function setupEnv() {
this.sourceRoot(join(__dirname, '../templates/common/root'));
this.copy('.editorconfig');
this.copy('.gitattributes');
if (!this.env.options.coffee) {
this.copy('.jscsrc');
}
this.copy('.jshintrc');
this.copy('.yo-rc.json');
this.copy('gitignore', '.gitignore');
Expand Down
6 changes: 6 additions & 0 deletions templates/common/root/.jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"requireCamelCaseOrUpperCaseIdentifiers": true,
"requireCapitalizedConstructors": true,
"requireParenthesesAroundIIFE": true,
"validateQuoteMarks": "'"
}
28 changes: 23 additions & 5 deletions templates/common/root/_Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ module.exports = function (grunt) {
},<% } else { %>
js: {
files: ['<%%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all'],
tasks: ['newer:jshint:all', 'newer:jscs:all'],
options: {
livereload: '<%%= connect.options.livereload %>'
}
},
jsTest: {
files: ['test/spec/{,*/}*.js'],
tasks: ['newer:jshint:test', 'karma']
tasks: ['newer:jshint:test', 'newer:jscs:test', 'karma']
},<% } %><% if (compass) { %>
compass: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
Expand Down Expand Up @@ -131,7 +131,7 @@ module.exports = function (grunt) {
}
},

// Make sure code styles are up to par and there are no obvious mistakes
// Make sure there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
Expand All @@ -151,7 +151,24 @@ module.exports = function (grunt) {
}<% } %>
},

// Empties folders to start fresh
<% if (!coffee) { %>// Make sure code styles are up to par
jscs: {
options: {
config: '.jscsrc',
verbose: true
},
all: {
src: [
'Gruntfile.js',
'<%%= yeoman.app %>/scripts/{,*/}*.js'
]
},
test: {
src: ['test/spec/{,*/}*.js']
}
},

<% } %>// Empties folders to start fresh
clean: {
dist: {
files: [{
Expand Down Expand Up @@ -556,7 +573,8 @@ module.exports = function (grunt) {
]);

grunt.registerTask('default', [
'newer:jshint',
'newer:jshint',<% if (!coffee) { %>
'newer:jscs',<% } %>
'test',
'build'
]);
Expand Down
3 changes: 2 additions & 1 deletion templates/common/root/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"grunt-contrib-uglify": "^0.7.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-filerev": "^2.1.2",
"grunt-google-cdn": "^0.4.3",
"grunt-google-cdn": "^0.4.3",<% if (!coffee) { %>
"grunt-jscs": "^1.8.0",<% } %>
"grunt-newer": "^1.1.0",
"grunt-ng-annotate": "^0.9.2",
"grunt-svgmin": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions test/test-apppath.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe('Angular generator appPath option', function () {
it('creates expected JS files', function (done) {
angular.run({}, function() {
helpers.assertFile([].concat(expected, [
'.jscsrc',
appPath + '/scripts/app.js',
appPath + '/scripts/controllers/main.js',
'test/spec/controllers/main.js'
Expand Down
1 change: 1 addition & 0 deletions test/test-file-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('Angular generator file creation', function () {
it('creates expected JS files', function (done) {
angular.run({}, function() {
helpers.assertFile([].concat(expected, [
'.jscsrc',
'app/scripts/app.js',
'app/scripts/controllers/main.js',
'test/spec/controllers/main.js'
Expand Down

0 comments on commit f407573

Please sign in to comment.