build: Test JS code with jshint and jscs via npm

Change-Id: I4d20af87b900d10c20f1a2c3fff09dc3425d2e55
This commit is contained in:
James D. Forrester 2015-11-18 16:54:43 -08:00
parent bd9f58c00b
commit 549e95ee5f
5 changed files with 54 additions and 10 deletions

21
.jscsrc Normal file
View file

@ -0,0 +1,21 @@
{
"preset": "wikimedia",
"jsDoc": {
"checkAnnotations": {
"preset": "jsduck5",
"extra": {
"this": true,
"source": true,
"see": true
}
},
"checkTypes": "strictNativeCase",
"checkParamNames": true,
"checkRedundantAccess": true,
"checkRedundantReturns": true,
"requireNewlineAfterDescription": true,
"requireParamTypes": true,
"requireReturnTypes": true
}
}

View file

@ -20,15 +20,13 @@
"bitwise": false,
"forin": false,
"regexp": false,
"strict": true,
"scripturl": true,
// Environment
"browser": true,
"jquery": true,
// Globals
"predef": [
"jQuery",
"mediaWiki"
]
"globals": {
"mw": false
}
}

View file

@ -7,11 +7,34 @@
/*jshint node:true */
module.exports = function ( grunt ) {
'use strict';
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-jscs' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.initConfig( {
jshint: {
options: {
jshintrc: true
},
all: [
'*.js',
'{.jsduck,build}/**/*.js',
'modules/**/*.js'
]
},
banana: {
all: ['i18n/']
core: [ 'i18n/' ]
},
jscs: {
fix: {
options: {
fix: true
},
src: '<%= jshint.all %>'
},
main: {
src: '<%= jshint.all %>'
}
},
jsonlint: {
all: [
@ -21,6 +44,6 @@ module.exports = function ( grunt ) {
}
} );
grunt.registerTask( 'test', [ 'jsonlint', 'banana' ] );
grunt.registerTask( 'test', [ 'jshint', 'jscs:main', 'jsonlint', 'banana' ] );
grunt.registerTask( 'default', 'test' );
};

View file

@ -35,4 +35,4 @@
);
} );
} );
} )( mediaWiki, jQuery );
} )( mw, jQuery );

View file

@ -10,6 +10,8 @@
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
"grunt-banana-checker": "0.2.2",
"grunt-jsonlint": "1.0.4"
"grunt-contrib-jshint": "0.11.3",
"grunt-jsonlint": "1.0.4",
"grunt-jscs": "2.1.0"
}
}