Skip to content

Commit

Permalink
feat(app generator): add coffeelinting to build process
Browse files Browse the repository at this point in the history
  • Loading branch information
cueedee committed Mar 18, 2015
1 parent 69bdec1 commit 4980b07
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 4 deletions.
9 changes: 5 additions & 4 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ module.exports = yeoman.generators.Base.extend(
{
// Setup the config files for git, editor etc.
//
this.copy( "editorconfig", ".editorconfig" );
this.copy( "gitattributes", ".gitattributes" );
this.copy( "gitignore", ".gitignore" );
this.copy( "jshintrc", ".jshintrc" );
this.copy( "editorconfig", ".editorconfig" );
this.copy( "gitattributes", ".gitattributes" );
this.copy( "gitignore", ".gitignore" );
this.copy( "coffeelint.json", "coffeelint.json" );
this.copy( "jshintrc", ".jshintrc" );

// Determine jQuery version
//
Expand Down
48 changes: 48 additions & 0 deletions generators/app/templates/_Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
## Apart from these, there are also:
##
## * Verification and testing:
## * coffeelint
## * mochaTest
##
## * Development support tools:
Expand Down Expand Up @@ -109,6 +110,7 @@ module.exports = ( grunt ) ->
app:
src:
browserify: '<%= build.source %>app.coffee'
lint: '<%= build.source %>**/*.coffee'

## NOTE: <%= npm.main %> should have <%= build.dist %> as its prefix:
##
Expand Down Expand Up @@ -279,6 +281,36 @@ module.exports = ( grunt ) ->
]


##
## Delint your coffeescript - before transpilation to javascript.
##
## https://github.com/vojtajina/grunt-coffeelint#readme
##
## http://www.coffeelint.org/
## file:./coffeelint.json
##

coffeelint:

options:
configFile: 'coffeelint.json'

app:
files: [
src: '<%= build.part.app.src.lint %>'
]

gruntfile:
files: [
src: 'Gruntfile.coffee'
]

test:
files: [
src: '<%= build.test %>**/*.coffee %>'
]


##
## Compile your sass to bundled css.
##
Expand Down Expand Up @@ -487,6 +519,12 @@ module.exports = ( grunt ) ->
##
## The browserify task does its own watching.
##
## But for linting purposes we watch all coffee files here too.
##

app:
files: '<%= build.part.app.src.lint %>'
tasks: 'lint'

bootstrap:
options:
Expand Down Expand Up @@ -573,6 +611,7 @@ module.exports = ( grunt ) ->
## ================================================

grunt.loadNpmTasks( 'grunt-browserify' )
grunt.loadNpmTasks( 'grunt-coffeelint' )
grunt.loadNpmTasks( 'grunt-contrib-clean' )
grunt.loadNpmTasks( 'grunt-contrib-compass' )
grunt.loadNpmTasks( 'grunt-contrib-compress' )
Expand Down Expand Up @@ -631,6 +670,8 @@ module.exports = ( grunt ) ->
'Build the app.'
( debugging ) ->
grunt.task.run(
'lint'

'clean:app'

"browserify:app_#{debugging}"#% if ( i18n ) { %#
Expand Down Expand Up @@ -750,6 +791,13 @@ module.exports = ( grunt ) ->
]
)

grunt.registerTask(
'lint'
[
'coffeelint:app'
]
)

grunt.registerTask(
'test'
[
Expand Down
1 change: 1 addition & 0 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"grunt": "~0.4.5",
"grunt-browserify": "~3.2.1",
"grunt-cli": "~0.1.13",
"grunt-coffeelint": "^0.0.13",
"grunt-contrib-clean": "~0.6.0",
"grunt-contrib-compass": "~1.0.1",
"grunt-contrib-compress": "~0.12.0",
Expand Down
120 changes: 120 additions & 0 deletions generators/app/templates/coffeelint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"arrow_spacing": {
"level": "error"
},
"braces_spacing": {
"level": "ignore",
"spaces": 1
},
"camel_case_classes": {
"level": "error"
},
"coffeescript_error": {
"level": "error"
},
"colon_assignment_spacing": {
"level": "ignore",
"spacing": {
"left": 0,
"right": 0
}
},
"cyclomatic_complexity": {
"value": 10,
"level": "ignore"
},
"duplicate_key": {
"level": "error"
},
"empty_constructor_needs_parens": {
"level": "error"
},
"ensure_comprehensions": {
"level": "error"
},
"indentation": {
"value": 4,
"level": "error"
},
"line_endings": {
"level": "error",
"value": "unix"
},
"max_line_length": {
"value": 160,
"level": "warn",
"limitComments": true
},
"missing_fat_arrows": {
"level": "ignore"
},
"newlines_after_classes": {
"value": 3,
"level": "ignore"
},
"no_backticks": {
"level": "error"
},
"no_debugger": {
"level": "warn"
},
"no_empty_functions": {
"level": "error"
},
"no_empty_param_list": {
"level": "ignore"
},
"no_implicit_braces": {
"level": "ignore",
"strict": true
},
"no_implicit_parens": {
"strict": true,
"level": "error"
},
"no_interpolation_in_single_quotes": {
"level": "error"
},
"no_plusplus": {
"level": "ignore"
},
"no_stand_alone_at": {
"level": "ignore"
},
"no_tabs": {
"level": "error"
},
"no_throwing_strings": {
"level": "error"
},
"no_trailing_semicolons": {
"level": "error"
},
"no_trailing_whitespace": {
"level": "error",
"allowed_in_comments": false,
"allowed_in_empty_lines": false
},
"no_unnecessary_double_quotes": {
"level": "error"
},
"no_unnecessary_fat_arrows": {
"level": "ignore"
},
"non_empty_constructor_needs_parens": {
"level": "error"
},
"prefer_english_operator": {
"level": "error",
"doubleNotLevel": "ignore"
},
"space_operators": {
"level": "error"
},
"space_after_comma": {
"level": "error"
},
"transform_messes_up_line_numbers": {
"level": "warn"
}
}
8 changes: 8 additions & 0 deletions generators/app/templates/demo/views/buildscript.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<a href="https://github.com/gruntjs/grunt-contrib-clean#readme">Clean</a>:
remove your previously built build results from the distribution artifact destination directory ('<code>dist/</code>')
</li>
<li>
<a href="https://github.com/vojtajina/grunt-coffeelint#readme">Coffeelint</a>:
delint your coffeescript - <i>before</i> transpilation to javascript
</li>
<li>
<a href="https://github.com/jmreidy/grunt-browserify#readme">Browserify</a>:
compile and bundle your code
Expand Down Expand Up @@ -63,6 +67,10 @@
<a href="https://github.com/gruntjs/grunt-contrib-clean#readme">Clean</a>:
remove your previously built build results from the distribution artifact destination directory ('<code>dist/</code>')
</li>
<li>
<a href="https://github.com/vojtajina/grunt-coffeelint#readme">Coffeelint</a>:
delint your coffeescript - <i>before</i> transpilation to javascript
</li>
<li>
<a href="https://github.com/jmreidy/grunt-browserify#readme">Browserify</a>:
compile and bundle your code in debugging mode; generates source maps
Expand Down

0 comments on commit 4980b07

Please sign in to comment.