jenkins-bot has submitted this change and it was merged. Change subject: Add .jshintrc ......................................................................
Add .jshintrc Per https://www.mediawiki.org/wiki/CC/JS#Linting. Update a few files to bring the tests closer to passing. Change-Id: I08b190e8b44dbdbeb56de5c380d0ed4a8394aca2 --- A .jshintrc M modules/base/ext.echo.base.js M modules/overlay/ext.echo.overlay.js M modules/special/ext.echo.special.js 4 files changed, 70 insertions(+), 31 deletions(-) Approvals: Krinkle: Looks good to me, approved Siebrand: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..dfe6f43 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,31 @@ +{ + /* Common */ + + // Enforcing + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "noempty": true, + "nonew": true, + "quotmark": "single", + "trailing": true, + "undef": true, + "unused": true, + // Legacy + "onevar": true, + + /* Local */ + + // Environment + "browser": true, + + "predef": [ + "jQuery", + "QUnit", + "mediaWiki" + ] +} diff --git a/modules/base/ext.echo.base.js b/modules/base/ext.echo.base.js index 8f82d06..bda5b40 100644 --- a/modules/base/ext.echo.base.js +++ b/modules/base/ext.echo.base.js @@ -1,4 +1,5 @@ ( function ( $, mw ) { + /*global alert */ 'use strict'; mw.echo = { @@ -12,8 +13,7 @@ * reload the page. */ 'dismiss': function( notification ) { - var _this = this, - $notification = $( notification ), + var $notification = $( notification ), eventCategory = $notification.attr( 'data-notification-category' ), prefName = '', prefs = [], @@ -26,21 +26,21 @@ } } ); prefRequest = { - 'action': 'options', - 'change': prefs.join( '|' ), - 'token': mw.echo.optionsToken, - 'format': 'json' - }; + action: 'options', + change: prefs.join( '|' ), + token: mw.echo.optionsToken, + format: 'json' + }; $.ajax( { type: 'post', url: mw.util.wikiScript( 'api' ), data: prefRequest, dataType: 'json', - success: function( data ) { + success: function () { // If we're on the Notifications archive page, just refresh the page - if ( mw.config.get( 'wgCanonicalNamespace' ) === 'Special' - && mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Notifications' ) - { + if ( mw.config.get( 'wgCanonicalNamespace' ) === 'Special' && + mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Notifications' + ) { window.location.reload(); } else { eventCategory = $notification.attr( 'data-notification-category' ); @@ -59,8 +59,10 @@ * First we have to retrieve the options token. */ 'setOptionsToken': function( callback, notification ) { - var _this = this; - var tokenRequest = { + var tokenRequest, + _this = this; + + tokenRequest = { 'action': 'tokens', 'type' : 'options', 'format': 'json' @@ -74,7 +76,7 @@ data: tokenRequest, dataType: 'json', success: function( data ) { - if ( typeof data.tokens.optionstoken === 'undefined' ) { + if ( data.tokens.optionstoken === undefined ) { alert( mw.msg( 'echo-error-token' ) ); } else { _this.optionsToken = data.tokens.optionstoken; @@ -111,11 +113,12 @@ 'setUpDismissability' : function( notification ) { var $dismissButton, $cancelButton, + $closebox, _this = this, $notification = $( notification ); // Add dismiss box - var $closebox = $( '<div/>' ) + $closebox = $( '<div/>' ) .addClass( 'mw-echo-close-box' ) .css( 'display', 'none' ) .click( function() { @@ -129,7 +132,7 @@ .addClass( 'mw-echo-dismiss-button' ) .addClass( 'ui-button-blue' ) .button( { - icons: { primary: "ui-icon-closethick" } + icons: { primary: 'ui-icon-closethick' } } ) .click( function () { _this.setOptionsToken( _this.dismiss, $notification ); diff --git a/modules/overlay/ext.echo.overlay.js b/modules/overlay/ext.echo.overlay.js index 6bc512d..cfbd589 100644 --- a/modules/overlay/ext.echo.overlay.js +++ b/modules/overlay/ext.echo.overlay.js @@ -22,19 +22,21 @@ .badge( newCount, true, true ); } - mw.echo.overlay.notification_count = newCount; + mw.echo.overlay.notificationCount = newCount; }, 'configuration' : mw.config.get( 'wgEchoOverlayConfiguration' ), 'buildOverlay' : function( callback ) { - var $overlay = $( '<div></div>' ).addClass( 'mw-echo-overlay' ), + var notificationLimit, + $overlay = $( '<div></div>' ).addClass( 'mw-echo-overlay' ), $link = $( '#pt-notifications a' ), $prefLink = $( '#pt-preferences a' ), - count = 0; - var Api = new mw.Api(); + count = 0, + Api = new mw.Api(); + // Set notification limit based on height of the window - var notificationLimit = Math.floor( ( $( window ).height() - 134 ) / 90 ); + notificationLimit = Math.floor( ( $( window ).height() - 134 ) / 90 ); if ( notificationLimit < 1 ) { notificationLimit = 1; @@ -55,12 +57,13 @@ unreadTotalCount = result.query.notifications.count, $title = $( '<div class="mw-echo-overlay-title"></div>' ), $ul = $( '<ul class="mw-echo-notifications"></ul>' ), - titleText = ''; + titleText = '', + $overlayFooter; $ul.css( 'max-height', notificationLimit * 95 + 'px' ); $.each( notifications.index, function( index, id ) { - var data = notifications.list[id]; - var $li = $( '<li></li>' ) + var data = notifications.list[id], + $li = $( '<li></li>' ) .data( 'details', data ) .data( 'id', id ) .attr( 'data-notification-category', data.category ) @@ -96,7 +99,7 @@ $ul.appendTo( $overlay ); } - var $overlayFooter = $( '<div/>' ) + $overlayFooter = $( '<div/>' ) .attr( 'id', 'mw-echo-overlay-footer' ); // add link to notifications archive @@ -143,10 +146,10 @@ } }; - mw.echo.overlay.notification_count = mw.echo.overlay.configuration['notification-count']; + mw.echo.overlay.notificationCount = mw.echo.overlay.configuration['notification-count']; $( function() { - mw.echo.overlay.updateCount( mw.echo.overlay.notification_count ); + mw.echo.overlay.updateCount( mw.echo.overlay.notificationCount ); var $link = $( '#pt-notifications a' ); if ( ! $link.length ) { @@ -154,8 +157,10 @@ } $link.click( function( e ) { + var $target, $overlay; + e.preventDefault(); - var $target = $( e.target ); + $target = $( e.target ); // If the user clicked on the overlay or any child, // ignore the click if ( $target.hasClass( 'mw-echo-overlay' ) || @@ -164,7 +169,7 @@ return; } - var $overlay = $( '.mw-echo-overlay' ); + $overlay = $( '.mw-echo-overlay' ); if ( $overlay.length ) { $overlay.fadeOut( 'fast', @@ -172,7 +177,7 @@ ); return; } - + $overlay = mw.echo.overlay.buildOverlay( function( $overlay ) { $overlay diff --git a/modules/special/ext.echo.special.js b/modules/special/ext.echo.special.js index b817efe..034d711 100644 --- a/modules/special/ext.echo.special.js +++ b/modules/special/ext.echo.special.js @@ -161,7 +161,7 @@ }, 'onSuccess': function() { - if ( this.moreData == '0' ) { + if ( this.moreData === '0' ) { $( '#mw-echo-more' ).hide(); } this.processing = false; -- To view, visit https://gerrit.wikimedia.org/r/59607 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I08b190e8b44dbdbeb56de5c380d0ed4a8394aca2 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Siebrand <[email protected]> Gerrit-Reviewer: Bsitu <[email protected]> Gerrit-Reviewer: Kaldari <[email protected]> Gerrit-Reviewer: Krinkle <[email protected]> Gerrit-Reviewer: Lwelling <[email protected]> Gerrit-Reviewer: Siebrand <[email protected]> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
