Set up node-jscs via Grunt (and pass it)
[lhc/web/wiklou.git] / tests / frontend / Gruntfile.js
1 /*!
2 * Grunt file
3 */
4
5 /*jshint node:true */
6 module.exports = function ( grunt ) {
7 grunt.loadNpmTasks( 'grunt-contrib-jshint' );
8 grunt.loadNpmTasks( 'grunt-contrib-watch' );
9 grunt.loadNpmTasks( 'grunt-jscs-checker' );
10
11 grunt.file.setBase( __dirname + '/../..' );
12
13 grunt.initConfig( {
14 pkg: grunt.file.readJSON( __dirname + '/package.json' ),
15 jshint: {
16 options: {
17 jshintrc: '.jshintrc'
18 },
19 all: [ '*.js', '{includes,languages,resources,skins,tests}/**/*.js' ]
20 },
21 jscs: {
22 // Known issues:
23 // - https://github.com/mdevils/node-jscs/issues/277
24 // - https://github.com/mdevils/node-jscs/issues/278
25 all: [
26 '<%= jshint.all %>',
27 // Auto-generated file with JSON (double quotes)
28 '!tests/qunit/data/mediawiki.jqueryMsg.data.js'
29
30 // Exclude all files ignored by jshint
31 ].concat( grunt.file.read( '.jshintignore' ).split( '\n' ).reduce( function ( patterns, pattern ) {
32 // Filter out empty lines
33 if ( pattern.length && pattern[0] !== '#' ) {
34 patterns.push( '!' + pattern );
35 }
36 return patterns;
37 }, [] ) )
38 },
39 watch: {
40 files: [
41 '.{jshintrc,jscs.json,jshintignore,csslintrc}',
42 '<%= jshint.all %>'
43 ],
44 tasks: ['test']
45 }
46 } );
47
48 grunt.registerTask( 'lint', ['jshint', 'jscs'] );
49 grunt.registerTask( 'test', ['lint'] );
50 grunt.registerTask( 'default', ['test'] );
51 };