Jforrester has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370114 )

Change subject: build: Replace jshint and jscs with eslint; drop csslint
......................................................................

build: Replace jshint and jscs with eslint; drop csslint

Removing csslint rather than replacing it with stylelint as there
are no CSS or LESS files in this repo.

Also bumping banana and jsonlint to latest.

Change-Id: I9ffce273f63b061e07c3fa90ab4e82b5e551aa92
---
A .eslintrc.json
M Gruntfile.js
M modules/ext.thanks.flowthank.js
M modules/ext.thanks.mobilediff.js
M modules/ext.thanks.revthank.js
M modules/ext.thanks.thank.js
M package.json
M tests/qunit/test_ext.thanks.mobilediff.js
8 files changed, 110 insertions(+), 106 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Thanks 
refs/changes/14/370114/1

diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..31380ab
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,13 @@
+{
+       "extends": "wikimedia",
+       "env": {
+               "browser": true,
+               "jquery": true,
+               "qunit": true
+       },
+       "globals": {
+               "mediaWiki": false,
+               "OO": false
+       },
+       "rules": {}
+}
diff --git a/Gruntfile.js b/Gruntfile.js
index 0f76c86..7695dc6 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,58 +1,43 @@
 /*!
  * Grunt file
  *
- * @package Flow
+ * @package Thanks
  */
 
-/*jshint node:true */
+/* eslint-env node, es6 */
 module.exports = function ( grunt ) {
-       grunt.loadNpmTasks( 'grunt-contrib-csslint' );
-       grunt.loadNpmTasks( 'grunt-contrib-jshint' );
-       grunt.loadNpmTasks( 'grunt-contrib-watch' );
-       grunt.loadNpmTasks( 'grunt-jsonlint' );
+
        grunt.loadNpmTasks( 'grunt-banana-checker' );
-       grunt.loadNpmTasks( 'grunt-jscs' );
+       grunt.loadNpmTasks( 'grunt-contrib-watch' );
+       grunt.loadNpmTasks( 'grunt-eslint' );
+       grunt.loadNpmTasks( 'grunt-jsonlint' );
 
        grunt.initConfig( {
-               jshint: {
-                       options: {
-                               jshintrc: true
-                       },
+               eslint: {
                        all: [
                                '*.js',
                                'modules/**/*.js',
                                'tests/qunit/**/*.js'
                        ]
                },
-               jscs: {
-                       src: '<%= jshint.all %>'
-               },
-               csslint: {
-                       options: {
-                               csslintrc: '.csslintrc'
-                       },
-                       all: 'modules/**/*.css'
-               },
                banana: {
                        all: 'i18n/'
                },
                watch: {
                        files: [
-                               '.{csslintrc,jscsrc,jshintignore,jshintrc}',
-                               '<%= jshint.all %>',
-                               '<%= csslint.all %>'
+                               '.eslintrc.json',
+                               '<%= eslint.all %>'
                        ],
                        tasks: 'test'
                },
                jsonlint: {
                        all: [
-                               '**/*.json',
-                               '!node_modules/**'
+                               '*.json',
+                               'i18n/*.json'
                        ]
                }
        } );
 
-       grunt.registerTask( 'lint', [ 'jscs', 'jshint', 'csslint', 'jsonlint', 
'banana' ] );
-       grunt.registerTask( 'test', 'lint' );
+       grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana' ] );
        grunt.registerTask( 'default', 'test' );
 };
diff --git a/modules/ext.thanks.flowthank.js b/modules/ext.thanks.flowthank.js
index bf2d203..64f8a0d 100644
--- a/modules/ext.thanks.flowthank.js
+++ b/modules/ext.thanks.flowthank.js
@@ -38,33 +38,33 @@
                        action: 'flowthank',
                        postid: $thankLink.closest( '.flow-post' ).attr( 
mw.thanks.thanked.attrName )
                } )
-               .then(
-                       // Success
-                       function ( data ) {
-                               var author = findPostAuthorFromThankLink( 
$thankLink );
-                               // Get the user who was thanked (for gender 
purposes)
-                               return mw.thanks.getUserGender( author );
-                       },
-                       // Failure
-                       function ( errorCode, details ) {
-                               switch ( errorCode ) {
-                                       case 'ratelimited':
-                                               OO.ui.alert( mw.msg( 
'thanks-error-ratelimited', mw.user ) );
-                                               break;
-                                       default:
-                                               OO.ui.alert( mw.msg( 
'thanks-error-undefined', errorCode ) );
+                       .then(
+                               // Success
+                               function () {
+                                       var author = 
findPostAuthorFromThankLink( $thankLink );
+                                       // Get the user who was thanked (for 
gender purposes)
+                                       return mw.thanks.getUserGender( author 
);
+                               },
+                               // Failure
+                               function ( errorCode ) {
+                                       switch ( errorCode ) {
+                                               case 'ratelimited':
+                                                       OO.ui.alert( mw.msg( 
'thanks-error-ratelimited', mw.user ) );
+                                                       break;
+                                               default:
+                                                       OO.ui.alert( mw.msg( 
'thanks-error-undefined', errorCode ) );
+                                       }
                                }
-                       }
-               )
-               .then( function ( recipientGender ) {
-                       var $thankUserLabel = $thankedLabel.clone();
-                       $thankUserLabel.append(
-                               mw.msg( 'thanks-button-thanked', mw.user, 
recipientGender )
-                       );
-                       mw.thanks.thanked.push( $thankLink.closest( 
'.flow-post' ) );
-                       $thankLink.before( $thankUserLabel );
-                       $thankLink.remove();
-               } );
+                       )
+                       .then( function ( recipientGender ) {
+                               var $thankUserLabel = $thankedLabel.clone();
+                               $thankUserLabel.append(
+                                       mw.msg( 'thanks-button-thanked', 
mw.user, recipientGender )
+                               );
+                               mw.thanks.thanked.push( $thankLink.closest( 
'.flow-post' ) );
+                               $thankLink.before( $thankUserLabel );
+                               $thankLink.remove();
+                       } );
        }
 
        if ( $.isReady ) {
@@ -82,4 +82,4 @@
                sendFlowThanks( $thankLink );
        } );
 
-} )( jQuery, mediaWiki, OO );
+}( jQuery, mediaWiki, OO ) );
diff --git a/modules/ext.thanks.mobilediff.js b/modules/ext.thanks.mobilediff.js
index 1b9139c..f6f76d0 100644
--- a/modules/ext.thanks.mobilediff.js
+++ b/modules/ext.thanks.mobilediff.js
@@ -1,10 +1,11 @@
 ( function ( mw, $ ) {
        /**
-        * Create a thank button for a given edit
+        * Attempt to execute a thank operation for a given edit
         *
         * @param {string} name The username of the user who made the edit
         * @param {string} revision The revision the user created
         * @param {string} recipientGender The gender of the user who made the 
edit
+        * @return {Promise} The thank operation's status.
         */
        function thankUser( name, revision, recipientGender ) {
                var d = $.Deferred();
@@ -16,19 +17,22 @@
                        mw.notify( mw.msg( 'thanks-thanked-notice', name, 
recipientGender, mw.user ) );
                        d.resolve();
                } )
-               .fail( function ( errorCode ) {
-                       switch ( errorCode ) {
-                               case 'invalidrevision':
-                                       popup.show( mw.msg( 
'thanks-error-invalidrevision' ) );
-                                       break;
-                               case 'ratelimited':
-                                       popup.show( mw.msg( 
'thanks-error-ratelimited', recipientGender ) );
-                                       break;
-                               default:
-                                       popup.show( mw.msg( 
'thanks-error-undefined', errorCode ) );
-                       }
-                       d.reject();
-               } );
+                       .fail( function ( errorCode ) {
+                               // FIXME: What is "popup" and where is it 
defined?
+                               /* eslint-disable no-undef */
+                               switch ( errorCode ) {
+                                       case 'invalidrevision':
+                                               popup.show( mw.msg( 
'thanks-error-invalidrevision' ) );
+                                               break;
+                                       case 'ratelimited':
+                                               popup.show( mw.msg( 
'thanks-error-ratelimited', recipientGender ) );
+                                               break;
+                                       default:
+                                               popup.show( mw.msg( 
'thanks-error-undefined', errorCode ) );
+                               }
+                               /* eslint-enable no-undef */
+                               d.reject();
+                       } );
                return d;
        }
 
@@ -38,11 +42,13 @@
         * @param {string} name The username of the user who made the edit
         * @param {string} rev The revision the user created
         * @param {string} gender The gender of the user who made the edit
+        * @return {html} The HTML of the button.
         */
        function createThankLink( name, rev, gender ) {
                var thankImg = mw.config.get( 'wgExtensionAssetsPath' ) + 
'/Thanks/WhiteSmiley.png',
                        thankImgTag = '<img width="25" height="20" src="' + 
thankImg + '" class="mw-mf-action-button-icon"/>',
                        $thankBtn;
+
                // Don't make thank button for self
                if ( name !== mw.config.get( 'wgUserName' ) ) {
                        // See if user has already been thanked for this edit
@@ -95,4 +101,4 @@
        mw.thanks = $.extend( {}, mw.thanks || {}, {
                _mobileDiffInit: init
        } );
-} )( mediaWiki, jQuery );
+}( mediaWiki, jQuery ) );
diff --git a/modules/ext.thanks.revthank.js b/modules/ext.thanks.revthank.js
index ee72406..872703d 100644
--- a/modules/ext.thanks.revthank.js
+++ b/modules/ext.thanks.revthank.js
@@ -28,41 +28,41 @@
                        source = 'diff';
                }
 
-               ( new mw.Api ).postWithToken( 'csrf', {
+               ( new mw.Api() ).postWithToken( 'csrf', {
                        action: 'thank',
                        rev: $thankLink.attr( 'data-revision-id' ),
                        source: source
                } )
-               .then(
-                       // Success
-                       function ( data ) {
-                               var username = $thankLink.closest(
+                       .then(
+                               // Success
+                               function () {
+                                       var username = $thankLink.closest(
                                                source === 'history' ? 'li' : 
'td'
                                        ).find( 'a.mw-userlink' ).text();
-                               // Get the user who was thanked (for gender 
purposes)
-                               return mw.thanks.getUserGender( username );
-                       },
-                       // Fail
-                       function ( errorCode, details ) {
-                               // If error occured, enable attempting to thank 
again
-                               $thankLink.data( 'clickDisabled', false );
-                               switch ( errorCode ) {
-                                       case 'invalidrevision':
-                                               OO.ui.alert( mw.msg( 
'thanks-error-invalidrevision' ) );
-                                               break;
-                                       case 'ratelimited':
-                                               OO.ui.alert( mw.msg( 
'thanks-error-ratelimited', mw.user ) );
-                                               break;
-                                       default:
-                                               OO.ui.alert( mw.msg( 
'thanks-error-undefined', errorCode ) );
+                                       // Get the user who was thanked (for 
gender purposes)
+                                       return mw.thanks.getUserGender( 
username );
+                               },
+                               // Fail
+                               function ( errorCode ) {
+                                       // If error occured, enable attempting 
to thank again
+                                       $thankLink.data( 'clickDisabled', false 
);
+                                       switch ( errorCode ) {
+                                               case 'invalidrevision':
+                                                       OO.ui.alert( mw.msg( 
'thanks-error-invalidrevision' ) );
+                                                       break;
+                                               case 'ratelimited':
+                                                       OO.ui.alert( mw.msg( 
'thanks-error-ratelimited', mw.user ) );
+                                                       break;
+                                               default:
+                                                       OO.ui.alert( mw.msg( 
'thanks-error-undefined', errorCode ) );
+                                       }
                                }
-                       }
-               )
-               .then( function ( recipientGender ) {
-                       $thankElement.before( mw.message( 'thanks-thanked', 
mw.user, recipientGender ).escaped() );
-                       $thankElement.remove();
-                       mw.thanks.thanked.push( $thankLink );
-               } );
+                       )
+                       .then( function ( recipientGender ) {
+                               $thankElement.before( mw.message( 
'thanks-thanked', mw.user, recipientGender ).escaped() );
+                               $thankElement.remove();
+                               mw.thanks.thanked.push( $thankLink );
+                       } );
        }
 
        function addActionToLinks( $content ) {
@@ -103,4 +103,4 @@
        mw.hook( 'wikipage.diff' ).add( function ( $content ) {
                addActionToLinks( $content );
        } );
-} )( jQuery, mediaWiki, OO );
+}( jQuery, mediaWiki, OO ) );
diff --git a/modules/ext.thanks.thank.js b/modules/ext.thanks.thank.js
index 7eb5fec..2a0deb5 100644
--- a/modules/ext.thanks.thank.js
+++ b/modules/ext.thanks.thank.js
@@ -62,4 +62,4 @@
                }
        };
 
-} )( jQuery, mediaWiki );
+}( jQuery, mediaWiki ) );
diff --git a/package.json b/package.json
index b49b599..6aa4f14 100644
--- a/package.json
+++ b/package.json
@@ -7,12 +7,11 @@
                "test": "grunt test"
        },
        "devDependencies": {
+               "eslint-config-wikimedia": "0.4.0",
                "grunt": "1.0.1",
-               "grunt-banana-checker": "0.5.0",
-               "grunt-contrib-csslint": "1.0.0",
-               "grunt-contrib-jshint": "1.0.0",
+               "grunt-banana-checker": "0.6.0",
                "grunt-contrib-watch": "1.0.0",
-               "grunt-jscs": "2.8.0",
-               "grunt-jsonlint": "1.0.7"
+               "grunt-eslint": "20.0.0",
+               "grunt-jsonlint": "1.1.0"
        }
 }
diff --git a/tests/qunit/test_ext.thanks.mobilediff.js 
b/tests/qunit/test_ext.thanks.mobilediff.js
index f588cec..bb3f2d8 100644
--- a/tests/qunit/test_ext.thanks.mobilediff.js
+++ b/tests/qunit/test_ext.thanks.mobilediff.js
@@ -1,4 +1,4 @@
-( function ( $ ) {
+( function ( $, mw ) {
        QUnit.module( 'Thanks mobilediff' );
 
        QUnit.test( 'render button for logged in users', 1, function ( assert ) 
{
@@ -7,8 +7,9 @@
                                .data( 'revision-id', 1 )
                                .data( 'user-gender', 'male' );
 
+               // eslint-disable-next-line no-underscore-dangle
                mw.thanks._mobileDiffInit( $user, $container );
                assert.strictEqual( $container.find( 'button' ).length, 1, 
'Thanks button was created.' );
        } );
 
-}( jQuery ) );
+}( jQuery, mediaWiki ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/370114
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ffce273f63b061e07c3fa90ab4e82b5e551aa92
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Thanks
Gerrit-Branch: master
Gerrit-Owner: Jforrester <jforres...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to