feat(grunt-jscs): add grunt task jscs lint

Now it's possible to enforce code style linting with jscs automatically when testing or building with grunt
This commit is contained in:
Estevão Soares dos Santos 2015-01-19 15:43:47 +00:00
parent 18ba4e756f
commit 0e99444bb1
3 changed files with 79 additions and 54 deletions

View File

@ -1,4 +1,5 @@
{ {
"validateIndentation": 2,
"requireCurlyBraces": [ "requireCurlyBraces": [
"if", "if",
"else", "else",

View File

@ -5,16 +5,21 @@
module.exports = function (grunt) { module.exports = function (grunt) {
// Project configuration. // Project configuration.
grunt.initConfig({ var config = {
pkg: grunt.file.readJSON('package.json'), pkg: grunt.file.readJSON('package.json'),
concat: { concat: {
options: { options: {
sourceMap: true, sourceMap: true,
banner: ";/*! <%= pkg.name %> <%= grunt.template.today('dd-mm-yyyy') %> */\n(function(){\n", banner: ';/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n(function(){\n',
footer: "}).call(this)" footer: '}).call(this)'
}, },
dist: { dist: {
src: ['src/showdown.js', 'src/helpers.js', 'src/subParsers/*.js', 'src/loader.js'], src: [
'src/showdown.js',
'src/helpers.js',
'src/subParsers/*.js',
'src/loader.js'
],
dest: 'dist/<%= pkg.name %>.js' dest: 'dist/<%= pkg.name %>.js'
} }
}, },
@ -30,7 +35,21 @@ module.exports = function (grunt) {
} }
}, },
jshint: { jshint: {
files: ['Gruntfile.js', 'src/**/*.js'] files: [
'Gruntfile.js',
'src/**/*.js',
'test/**/*.js'
]
},
jscs: {
options: {
config: '.jscs.json',
files: [
'Gruntfile.js',
'src/**/*.js',
'test/**/*.js'
]
}
}, },
simplemocha: { simplemocha: {
node: { node: {
@ -49,16 +68,20 @@ module.exports = function (grunt) {
} }
} }
} }
}); };
grunt.initConfig(config);
grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-simple-mocha'); grunt.loadNpmTasks('grunt-simple-mocha');
grunt.loadNpmTasks('grunt-jscs');
grunt.registerTask('test', ['jshint', 'concat', 'simplemocha']); grunt.registerTask('lint', ['jshint', 'jscs']);
grunt.registerTask('test', ['lint', 'concat', 'simplemocha']);
grunt.registerTask('test-without-building', ['simplemocha']); grunt.registerTask('test-without-building', ['simplemocha']);
grunt.registerTask('build', ['jshint', 'concat', 'test', 'uglify']); grunt.registerTask('build', ['lint', 'test', 'uglify']);
// Default task(s). // Default task(s).
grunt.registerTask('default', []); grunt.registerTask('default', []);

View File

@ -42,6 +42,7 @@
"grunt-contrib-concat": "^0.5.0", "grunt-contrib-concat": "^0.5.0",
"grunt-contrib-jshint": "^0.10.0", "grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.6.0", "grunt-contrib-uglify": "^0.6.0",
"grunt-jscs": "^1.2.0",
"grunt-simple-mocha": "^0.4.0", "grunt-simple-mocha": "^0.4.0",
"jscs": "^1.10.0", "jscs": "^1.10.0",
"mocha": "*", "mocha": "*",