Change from jshint to eslint

Change-Id: I9d8a31c8048f9d80e8395a637573272ca5f9fea5
This commit is contained in:
Fomafix 2017-04-30 10:15:57 +02:00
parent a04950b638
commit 19d698b422
5 changed files with 21 additions and 35 deletions

10
.eslintrc.json Normal file
View file

@ -0,0 +1,10 @@
{
"extends": "wikimedia",
"env": {
"browser": true,
"jquery": true
},
"globals": {
"mediaWiki": false
}
}

View file

@ -1,25 +0,0 @@
{
// Enforcing
"bitwise": true,
"eqeqeq": true,
"es3": true,
"freeze": true,
"latedef": true,
"noarg": true,
"nonew": true,
"undef": true,
"unused": true,
"strict": false,
// Relaxing
"laxbreak": true,
"multistr": true,
// Environment
"browser": true,
"globals": {
"mediaWiki": true,
"jQuery": false
}
}

View file

@ -4,22 +4,21 @@
* @package CategoryTree * @package CategoryTree
*/ */
/*jshint node:true */ /* eslint-env node */
module.exports = function ( grunt ) { module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' ); grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-stylelint' ); grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.initConfig( { grunt.initConfig( {
banana: { banana: {
all: ['i18n/'] all: [ 'i18n/' ]
}, },
jshint: { eslint: {
all: [ all: [
'**/*.js', '**/*.js',
'!node_modules/**', '!node_modules/**'
'!vendor/**'
] ]
}, },
jsonlint: { jsonlint: {
@ -37,6 +36,6 @@ module.exports = function ( grunt ) {
} }
} ); } );
grunt.registerTask( 'test', [ 'jsonlint', 'banana', 'jshint', 'stylelint' ] ); grunt.registerTask( 'test', [ 'jsonlint', 'banana', 'eslint', 'stylelint' ] );
grunt.registerTask( 'default', 'test' ); grunt.registerTask( 'default', 'test' );
}; };

View file

@ -8,6 +8,8 @@
* @licence GNU General Public Licence 2.0 or later * @licence GNU General Public Licence 2.0 or later
*/ */
/* eslint no-use-before-define: ["error", { "functions": false }] */
( function ( $, mw ) { ( function ( $, mw ) {
mw.hook( 'wikipage.content' ).add( function ( $content ) { mw.hook( 'wikipage.content' ).add( function ( $content ) {
@ -23,9 +25,8 @@
* Handles clicks on the expand buttons, and calls the appropriate function * Handles clicks on the expand buttons, and calls the appropriate function
* *
* @context {Element} CategoryTreeToggle * @context {Element} CategoryTreeToggle
* @param e {jQuery.Event}
*/ */
function handleNode( /*e*/ ) { function handleNode() {
var $link = $( this ); var $link = $( this );
if ( $link.data( 'ct-state' ) === 'collapsed' ) { if ( $link.data( 'ct-state' ) === 'collapsed' ) {
expandNode( $link ); expandNode( $link );

View file

@ -4,9 +4,10 @@
"test": "grunt test" "test": "grunt test"
}, },
"devDependencies": { "devDependencies": {
"eslint-config-wikimedia": "0.3.0",
"grunt": "1.0.1", "grunt": "1.0.1",
"grunt-banana-checker": "0.4.0", "grunt-banana-checker": "0.4.0",
"grunt-contrib-jshint": "1.1.0", "grunt-eslint": "19.0.0",
"grunt-jsonlint": "1.0.7", "grunt-jsonlint": "1.0.7",
"grunt-stylelint": "0.6.0", "grunt-stylelint": "0.6.0",
"stylelint-config-wikimedia": "0.4.1" "stylelint-config-wikimedia": "0.4.1"