diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..48432407 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "extends": "wikimedia", + "env": { + "browser": true, + "jquery": true + }, + "globals": { + "mediaWiki": false + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 1dad4f0f..00000000 --- a/.jshintrc +++ /dev/null @@ -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 - } -} diff --git a/Gruntfile.js b/Gruntfile.js index 6f3befcd..d985906d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,22 +4,21 @@ * @package CategoryTree */ -/*jshint node:true */ +/* eslint-env node */ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-jsonlint' ); - grunt.loadNpmTasks( 'grunt-contrib-jshint' ); + grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-stylelint' ); grunt.initConfig( { banana: { - all: ['i18n/'] + all: [ 'i18n/' ] }, - jshint: { + eslint: { all: [ '**/*.js', - '!node_modules/**', - '!vendor/**' + '!node_modules/**' ] }, 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' ); }; diff --git a/modules/ext.categoryTree.js b/modules/ext.categoryTree.js index f3fb56f8..fa3c4b6c 100644 --- a/modules/ext.categoryTree.js +++ b/modules/ext.categoryTree.js @@ -8,6 +8,8 @@ * @licence GNU General Public Licence 2.0 or later */ +/* eslint no-use-before-define: ["error", { "functions": false }] */ + ( function ( $, mw ) { mw.hook( 'wikipage.content' ).add( function ( $content ) { @@ -23,9 +25,8 @@ * Handles clicks on the expand buttons, and calls the appropriate function * * @context {Element} CategoryTreeToggle - * @param e {jQuery.Event} */ - function handleNode( /*e*/ ) { + function handleNode() { var $link = $( this ); if ( $link.data( 'ct-state' ) === 'collapsed' ) { expandNode( $link ); diff --git a/package.json b/package.json index 359909b6..8552d1ca 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,10 @@ "test": "grunt test" }, "devDependencies": { + "eslint-config-wikimedia": "0.3.0", "grunt": "1.0.1", "grunt-banana-checker": "0.4.0", - "grunt-contrib-jshint": "1.1.0", + "grunt-eslint": "19.0.0", "grunt-jsonlint": "1.0.7", "grunt-stylelint": "0.6.0", "stylelint-config-wikimedia": "0.4.1"