2 module.exports = function ( grunt ) {
3 grunt.loadNpmTasks( 'grunt-contrib-jshint' );
4 grunt.loadNpmTasks( 'grunt-contrib-watch' );
5 grunt.loadNpmTasks( 'grunt-banana-checker' );
6 grunt.loadNpmTasks( 'grunt-jscs' );
7 grunt.loadNpmTasks( 'grunt-jsonlint' );
8 grunt.loadNpmTasks( 'grunt-karma' );
10 var wgServer = process.env.MW_SERVER,
11 wgScriptPath = process.env.MW_SCRIPT_PATH,
14 karmaProxy[wgScriptPath] = wgServer + wgScriptPath;
17 pkg: grunt.file.readJSON( 'package.json' ),
24 '{includes,languages,resources,tests}/**/*.js'
30 // Auto-generated file with JSON (double quotes)
31 '!tests/qunit/data/mediawiki.jqueryMsg.data.js',
32 // Skip functions are stored as script files but wrapped in a function when
33 // executed. node-jscs trips on the would-be "Illegal return statement".
34 '!resources/src/*-skip.js'
36 // Exclude all files ignored by jshint
37 ].concat( grunt.file.read( '.jshintignore' ).split( '\n' ).reduce( function ( patterns, pattern ) {
38 // Filter out empty lines
39 if ( pattern.length && pattern[0] !== '#' ) {
40 patterns.push( '!' + pattern );
48 '{languages,maintenance,resources}/**/*.json',
53 core: 'languages/i18n/',
54 api: 'includes/api/i18n/',
55 installer: 'includes/installer/i18n/'
60 '<%= jsonlint.all %>',
70 pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export',
75 frameworks: [ 'qunit' ],
76 reporters: [ 'dots' ],
81 browsers: [ 'Chrome' ]
84 browsers: [ 'Chrome', 'Firefox' ]
89 grunt.registerTask( 'lint', ['jshint', 'jscs', 'jsonlint', 'banana'] );
90 grunt.registerTask( 'qunit', 'karma:main' );
92 grunt.registerTask( 'test', ['lint'] );
93 grunt.registerTask( 'default', 'test' );