mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 14:56:20 +00:00
cf7f2b141d
Let's experiment with this via our local Gruntfile. If it works fine we can install it in Jenkins (similar to node-csslint). Verify through $ npm install && npm test; Fixed all outstanding violations. Also: * Added syntaxhighight to ignore. * Added imetests (which contain unformatted JSON) to ignore. * In ve.dm.ModelRegistry#matchTypeRegExps, removed redundant !! cast from the [+!!withFunc] statement which was hitting a bug in node-jscs. All callers to this local private function pass a literal boolean true/false so no need to cast it. * Removed "/* key .. , value */" from ve.setProp, though this wasn't caught by node-jscs, found it when searching for " , ". * Made npm.devDependencies fixed instead of using tilde-ranges. This too often leads to strange bugs or sudden changes. Fixed them at the version they were currently ranging to. Bug: 54218 Change-Id: Ib2630806f3946874c8b01e58cf171df83a28da29
71 lines
1.9 KiB
JavaScript
71 lines
1.9 KiB
JavaScript
/*!
|
|
* Grunt file
|
|
*
|
|
* @package VisualEditor
|
|
*/
|
|
|
|
/*jshint node:true */
|
|
module.exports = function ( grunt ) {
|
|
var fs = require( 'fs' ),
|
|
exec = require( 'child_process' ).exec;
|
|
|
|
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-csslint' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-qunit' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
|
grunt.loadNpmTasks( 'grunt-jscs-checker' );
|
|
|
|
grunt.initConfig( {
|
|
pkg: grunt.file.readJSON( 'package.json' ),
|
|
jshint: {
|
|
options: JSON.parse( grunt.file.read( '.jshintrc' )
|
|
.replace( /\/\*(?:(?!\*\/)[\s\S])*\*\//g, '' ).replace( /\/\/[^\n\r]*/g, '' ) ),
|
|
all: ['*.js', 'modules/{syntaxhighlight,unicodejs,ve,ve-mw}/**/*.js']
|
|
},
|
|
jscs: {
|
|
src: [
|
|
'<%= jshint.all %>',
|
|
'!modules/syntaxhighlight/**/*.js',
|
|
'!modules/ve/test/ce/imetests/*.js'
|
|
]
|
|
},
|
|
csslint: {
|
|
options: {
|
|
csslintrc: '.csslintrc'
|
|
},
|
|
// TODO: modules/syntaxhighlight should be included, but is failing.
|
|
all: ['demos/**/*.css', 'modules/{ve,ve-mw}/**/*.css'],
|
|
},
|
|
qunit: {
|
|
ve: 'modules/ve/test/index-phantomjs-tmp.html'
|
|
},
|
|
watch: {
|
|
files: ['<%= jshint.all %>', '<%= csslint.all %>', '<%= qunit.ve %>', '.{jshintrc,jshintignore,csslintrc}'],
|
|
tasks: ['test']
|
|
}
|
|
} );
|
|
|
|
grunt.registerTask( 'pre-qunit', function () {
|
|
var done = this.async();
|
|
grunt.file.setBase( __dirname + '/modules/ve/test' );
|
|
exec( 'php index.php > index-phantomjs-tmp.html', function ( err, stdout, stderr ) {
|
|
if ( err || stderr ) {
|
|
grunt.log.error( err || stderr );
|
|
done( false );
|
|
} else {
|
|
grunt.file.setBase( __dirname );
|
|
done( true );
|
|
}
|
|
} );
|
|
} );
|
|
|
|
grunt.event.on( 'qunit.done', function () {
|
|
fs.unlinkSync( __dirname + '/modules/ve/test/index-phantomjs-tmp.html' );
|
|
} );
|
|
|
|
grunt.registerTask( 'lint', ['jshint', 'jscs', 'csslint'] );
|
|
grunt.registerTask( 'unit', ['pre-qunit', 'qunit'] );
|
|
grunt.registerTask( 'test', ['lint', 'unit'] );
|
|
grunt.registerTask( 'default', 'test' );
|
|
};
|