diff --git a/modules/.eslintrc.json b/modules/.eslintrc.json index 3b0938e4d..536b9c31e 100644 --- a/modules/.eslintrc.json +++ b/modules/.eslintrc.json @@ -9,6 +9,9 @@ "commonjs": true }, "rules": { - "max-len": "off" + "max-len": "off", + "prefer-arrow-callback": "error", + "implicit-arrow-linebreak": "error", + "arrow-body-style": "error" } } diff --git a/modules/api/mw.echo.api.APIHandler.js b/modules/api/mw.echo.api.APIHandler.js index c3a412094..17ff0efe9 100644 --- a/modules/api/mw.echo.api.APIHandler.js +++ b/modules/api/mw.echo.api.APIHandler.js @@ -158,7 +158,7 @@ } return fetchNotifPromise - .fail( function () { + .fail( () => { // Mark API error state me.apiErrorState[ type ][ fetchingSource ] = true; } ); diff --git a/modules/api/mw.echo.api.EchoApi.js b/modules/api/mw.echo.api.EchoApi.js index c9ff29ba5..3225da040 100644 --- a/modules/api/mw.echo.api.EchoApi.js +++ b/modules/api/mw.echo.api.EchoApi.js @@ -61,9 +61,7 @@ */ mw.echo.api.EchoApi.prototype.fetchUnreadNotificationPages = function ( sources ) { return this.network.getApiHandler( 'local' ).fetchUnreadNotificationPages( sources ) - .then( function ( data ) { - return OO.getProp( data, 'query', 'unreadnotificationpages' ); - } ); + .then( ( data ) => OO.getProp( data, 'query', 'unreadnotificationpages' ) ); }; /** @@ -162,9 +160,7 @@ !!isForced, this.convertFiltersToAPIParams( filters ) ) ) - .then( function ( result ) { - return OO.getProp( result.query, 'notifications' ); - } ); + .then( ( result ) => OO.getProp( result.query, 'notifications' ) ); }; /** @@ -191,9 +187,7 @@ isForced, this.convertFiltersToAPIParams( filters ) ) ) - .then( function ( result ) { - return OO.getProp( result.query, 'notifications' ); - } ); + .then( ( result ) => OO.getProp( result.query, 'notifications' ) ); }; /** @@ -208,7 +202,7 @@ mw.echo.api.EchoApi.prototype.fetchNotificationGroups = function ( sourceArray, type, bundle ) { const overrideParams = { notcrosswikisummary: false, notbundle: bundle }; return this.network.getApiHandler( 'local' ).fetchNotifications( type, sourceArray, true, overrideParams ) - .then( function ( result ) { + .then( ( result ) => { const items = OO.getProp( result, 'query', 'notifications', 'list' ), groups = {}; diff --git a/modules/api/mw.echo.api.LocalAPIHandler.js b/modules/api/mw.echo.api.LocalAPIHandler.js index c812bc02b..eb4689020 100644 --- a/modules/api/mw.echo.api.LocalAPIHandler.js +++ b/modules/api/mw.echo.api.LocalAPIHandler.js @@ -46,9 +46,7 @@ type: type.length === 1 ? type[ 0 ] : 'all', timestampFormat: 'ISO_8601' } ) - .then( function ( data ) { - return data.query.echomarkseen.timestamp; - } ); + .then( ( data ) => data.query.echomarkseen.timestamp ); }; /** @@ -72,9 +70,7 @@ } return this.api.postWithToken( 'csrf', data ) - .then( function ( result ) { - return OO.getProp( result.query, 'echomarkread', type, 'rawcount' ) || 0; - } ); + .then( ( result ) => OO.getProp( result.query, 'echomarkread', type, 'rawcount' ) || 0 ); }; /** @@ -124,7 +120,7 @@ } return this.api.get( apiData ) - .then( function ( result ) { + .then( ( result ) => { if ( type === 'message' || type === 'alert' ) { return OO.getProp( result.query, 'notifications', normalizedType, 'rawcount' ) || 0; } else { diff --git a/modules/controller/mw.echo.Controller.js b/modules/controller/mw.echo.Controller.js index 4b3c2fe13..2577d8e1b 100644 --- a/modules/controller/mw.echo.Controller.js +++ b/modules/controller/mw.echo.Controller.js @@ -85,7 +85,7 @@ sourcePageModel = filterModel.getSourcePagesModel(); return this.api.fetchUnreadNotificationPages() - .then( function ( data ) { + .then( ( data ) => { const result = {}, foreignSources = {}; @@ -132,7 +132,7 @@ titles: filters.getSourcePagesModel().getGroupedPagesForCurrentTitle() } ) - .then( function ( data ) { + .then( ( data ) => { const dateItemIds = {}, dateItems = {}, models = {}; @@ -223,12 +223,10 @@ } ) .then( null, - function ( errCode, errObj ) { - return { - errCode: errCode, - errInfo: OO.getProp( errObj, 'error', 'info' ) - }; - } + ( errCode, errObj ) => ( { + errCode: errCode, + errInfo: OO.getProp( errObj, 'error', 'info' ) + } ) ); }; /** @@ -259,7 +257,7 @@ return this.api.fetchNotifications( this.manager.getTypeString(), 'local', !!isForced, { unreadFirst: true, bundle: true } /* filters */ ) .then( // Success - function ( data ) { + ( data ) => { const allModels = { local: localListModel }, createBundledNotification = function ( modelName, rawBundledNotifData ) { const bundleNotifData = controller.createNotificationData( rawBundledNotifData ); @@ -346,7 +344,7 @@ return idArray; }, // Failure - function ( errCode, errObj ) { + ( errCode, errObj ) => { if ( !controller.manager.getNotificationModel( 'local' ) ) { // Update the controller controller.manager.setNotificationModels( { local: localListModel } ); @@ -457,7 +455,7 @@ source = source || this.manager.getFiltersModel().getSourcePagesModel().getCurrentSource(); - this.manager.getNotificationsBySource( source ).forEach( function ( notification ) { + this.manager.getNotificationsBySource( source ).forEach( ( notification ) => { if ( !notification.isRead() ) { itemIds.push( ...notification.getAllIds() ); notification.toggleRead( true ); @@ -494,7 +492,7 @@ const readState = this.manager.getFiltersModel().getReadState(), modelItems = {}; - this.manager.getLocalNotifications().forEach( function ( notification ) { + this.manager.getLocalNotifications().forEach( ( notification ) => { if ( !notification.isRead() ) { notification.toggleRead( true ); @@ -538,7 +536,7 @@ return this.api.fetchNotificationGroups( xwikiModel.getSourceNames(), this.manager.getTypeString(), true ) .then( - function ( groupList ) { + ( groupList ) => { for ( const group in groupList ) { const listModel = xwikiModel.getItemBySource( group ); const groupItems = groupList[ group ]; @@ -559,14 +557,12 @@ listModel.setItems( items ); } }, - function ( errCode, errObj ) { - return { - errCode: errCode, - errInfo: errCode === 'http' ? - mw.msg( 'echo-api-failure-cross-wiki' ) : - OO.getProp( errObj, 'error', 'info' ) - }; - } + ( errCode, errObj ) => ( { + errCode: errCode, + errInfo: errCode === 'http' ? + mw.msg( 'echo-api-failure-cross-wiki' ) : + OO.getProp( errObj, 'error', 'info' ) + } ) ); }; @@ -608,7 +604,7 @@ // to reflect the new pagination? etc. } - items.forEach( function ( notification ) { + items.forEach( ( notification ) => { allIds.push( ...notification.getAllIds() ); if ( readState === 'all' ) { notification.toggleRead( isRead ); @@ -652,7 +648,7 @@ // Update pagination count this.manager.updateCurrentPageItemCount(); - notifs.forEach( function ( notif ) { + notifs.forEach( ( notif ) => { allIds.push( ...notif.getAllIds() ); } ); this.manager.getUnreadCounter().estimateChange( -allIds.length ); @@ -677,7 +673,7 @@ this.manager.getUnreadCounter().estimateChange( -xwikiModel.getCount() ); return this.api.fetchNotificationGroups( xwikiModel.getSourceNames(), this.manager.getTypeString() ) - .then( function ( groupList ) { + .then( ( groupList ) => { const promises = []; for ( const group in groupList ) { @@ -736,7 +732,7 @@ // will be updated globally this.manager.getFiltersModel().getSourcePagesModel().getCurrentSource() ) - .then( function ( time ) { + .then( ( time ) => { controller.manager.getSeenTimeModel().setSeenTime( time ); } ); }; diff --git a/modules/ext.echo.centralauth.js b/modules/ext.echo.centralauth.js index a1e50658e..6b467e365 100644 --- a/modules/ext.echo.centralauth.js +++ b/modules/ext.echo.centralauth.js @@ -1,7 +1,7 @@ /* * Loads Echo on CentralAuth autologin */ -mw.hook( 'centralauth-p-personal-reset' ).add( function () { +mw.hook( 'centralauth-p-personal-reset' ).add( () => { mw.loader.using( [ 'ext.echo.init', 'ext.echo.styles.badge', diff --git a/modules/ext.echo.init.js b/modules/ext.echo.init.js index 89ec47b85..90c1ebcd9 100644 --- a/modules/ext.echo.init.js +++ b/modules/ext.echo.init.js @@ -23,7 +23,7 @@ function initDesktop() { } // Activate OOUI - $( function () { + $( () => { const maxNotificationCount = require( './config.json' ).EchoMaxNotificationCount, pollingRate = require( './config.json' ).EchoPollForUpdates, documentTitle = document.title, @@ -73,7 +73,7 @@ function initDesktop() { */ function showNotificationSnippet( modelManager, highestNotifTime ) { let highestTime = highestNotifTime; - modelManager.getLocalNotifications().forEach( function ( notificationItem ) { + modelManager.getLocalNotifications().forEach( ( notificationItem ) => { const timestampAsDate = new Date( notificationItem.timestamp ); if ( timestampAsDate > highestNotifTime ) { if ( timestampAsDate > highestTime ) { @@ -95,7 +95,7 @@ function initDesktop() { * @param {mw.echo.ui.NotificationBadgeWidget} badgeWidget */ function updateBadgeState( modelManager, badgeWidget ) { - modelManager.getLocalNotifications().forEach( function ( notificationItem ) { + modelManager.getLocalNotifications().forEach( ( notificationItem ) => { if ( !notificationItem.isSeen() ) { badgeWidget.updateBadgeSeenState( true ); } @@ -129,7 +129,7 @@ function initDesktop() { // This part executes only once, either when header icons are clicked or after completion of 60secs whichever occur first. const echoApi = new mw.echo.api.EchoApi(); - loadingPromise = mw.loader.using( 'ext.echo.ui.desktop' ).then( function () { + loadingPromise = mw.loader.using( 'ext.echo.ui.desktop' ).then( () => { // Overlay mw.echo.ui.$overlay.appendTo( document.body ); @@ -155,15 +155,15 @@ function initDesktop() { // Replace the link button with the ooui button $existingAlertLink.parent().replaceWith( mw.echo.ui.alertWidget.$element ); - alertModelManager.on( 'allTalkRead', function () { + alertModelManager.on( 'allTalkRead', () => { // If there was a talk page notification, get rid of it $( '#pt-talk-alert' ).remove(); } ); // listen to event countChange and change title only if polling rate is non-zero if ( isLivePollingFeatureEnabledOnWiki() ) { - alertModelManager.getUnreadCounter().on( 'countChange', function ( count ) { - alertController.fetchLocalNotifications().then( function () { + alertModelManager.getUnreadCounter().on( 'countChange', ( count ) => { + alertController.fetchLocalNotifications().then( () => { updateBadgeState( alertModelManager, mw.echo.ui.alertWidget ); if ( userHasOptedInToLiveNotifications() ) { latestAlertNotifTime = showNotificationSnippet( alertModelManager, latestAlertNotifTime ); @@ -199,8 +199,8 @@ function initDesktop() { // listen to event countChange and change title only if polling rate is non-zero if ( isLivePollingFeatureEnabledOnWiki() ) { - messageModelManager.getUnreadCounter().on( 'countChange', function ( count ) { - messageController.fetchLocalNotifications().then( function () { + messageModelManager.getUnreadCounter().on( 'countChange', ( count ) => { + messageController.fetchLocalNotifications().then( () => { updateBadgeState( messageModelManager, mw.echo.ui.messageWidget ); if ( userHasOptedInToLiveNotifications() ) { latestMessageNotifTime = showNotificationSnippet( messageModelManager, latestMessageNotifTime ); @@ -234,15 +234,15 @@ function initDesktop() { // Fire the notification API requests const echoApi = new mw.echo.api.EchoApi(); echoApi.fetchNotifications( clickedSection ) - .then( function ( data ) { + .then( ( data ) => { mw.track( 'timing.MediaWiki.echo.overlay.api', mw.now() - timeOfClick ); return data; } ); - loadEcho().then( function () { + loadEcho().then( () => { // Now that the module loaded, show the popup const selectedWidget = clickedSection === 'alert' ? mw.echo.ui.alertWidget : mw.echo.ui.messageWidget; - selectedWidget.once( 'finishLoading', function () { + selectedWidget.once( 'finishLoading', () => { // Log timing after notifications are shown mw.track( 'timing.MediaWiki.echo.overlay', mw.now() - timeOfClick ); } ); @@ -255,7 +255,7 @@ function initDesktop() { // The other part is the 'echo.unseen' counter, see EchoHooks::onSkinTemplateNavigationUniversal(). mw.track( 'counter.MediaWiki.echo.unseen.click' ); } - }, function () { + }, () => { // Un-dim badge if loading failed $badge.removeClass( 'mw-echo-notifications-badge-dimmed' ); } ); @@ -288,13 +288,13 @@ function initDesktop() { */ function initMobile() { if ( !mw.user.isAnon() ) { - mw.loader.using( [ 'ext.echo.mobile', 'mobile.startup' ] ).then( function ( require ) { + mw.loader.using( [ 'ext.echo.mobile', 'mobile.startup' ] ).then( ( require ) => { require( 'ext.echo.mobile' ).init(); } ); } } -$( function () { +$( () => { if ( mw.config.get( 'wgMFMode' ) ) { initMobile(); } else { diff --git a/modules/mobile/list.js b/modules/mobile/list.js index 4ad7f72a3..52f8527bc 100644 --- a/modules/mobile/list.js +++ b/modules/mobile/list.js @@ -53,27 +53,27 @@ function notificationsList( echo, markAllReadButton, onCountChange ) { } ); // Events - unreadCounter.on( 'countChange', function ( count ) { + unreadCounter.on( 'countChange', ( count ) => { onCountChange( controller.manager.getUnreadCounter().getCappedNotificationCount( count ) ); markAsReadHandler(); } ); - markAllReadButton.on( 'click', function () { + markAllReadButton.on( 'click', () => { const numNotifications = controller.manager.getLocalUnread().length; controller.markLocalNotificationsRead() - .then( function () { + .then( () => { mw.notify( mw.msg( 'echo-mark-all-as-read-confirmation', numNotifications ) ); markAllReadButton.toggle( false ); - }, function () { + }, () => { markAllReadButton.toggle( false ); } ); } ); return promisedView( // Populate notifications - wrapperWidget.populate().then( function () { + wrapperWidget.populate().then( () => { controller.updateSeenTime(); markAsReadHandler(); // Connect event here as we know that everything loaded correctly diff --git a/modules/mobile/notifications.js b/modules/mobile/notifications.js index acc1ceb97..70bad056d 100644 --- a/modules/mobile/notifications.js +++ b/modules/mobile/notifications.js @@ -29,7 +29,7 @@ function init() { function showNotificationOverlay() { const overlay = notificationsOverlay( - function ( exit ) { + ( exit ) => { onCloseNotificationsOverlay(); exit(); } ); @@ -41,7 +41,7 @@ function init() { let initialized = false; // Once the DOM is loaded add the overlay and overlay manager. Minerva will handle the // notification button that will link to Special:Notifications. - $( function () { + $( () => { overlayManager.add( /^\/notifications$/, showNotificationOverlay ); /** @@ -73,7 +73,7 @@ function init() { // The code is bundled here since it makes use of loadModuleScript. This also allows // the possibility of invoking the filter from outside the Special page in future. // Once the 'ext.echo.special.onInitialize' hook has fired, load notification filter. - mw.hook( 'ext.echo.special.onInitialize' ).add( function () { + mw.hook( 'ext.echo.special.onInitialize' ).add( () => { // eslint-disable-next-line no-jquery/no-global-selector const $crossWikiUnreadFilter = $( '.mw-echo-ui-crossWikiUnreadFilterWidget' ), // eslint-disable-next-line no-jquery/no-global-selector @@ -90,7 +90,7 @@ function init() { addFilterButton(); // setup route - overlayManager.add( /^\/notifications-filter$/, function () { + overlayManager.add( /^\/notifications-filter$/, () => { onOpenNotificationsOverlay(); return notificationsFilterOverlay( { onBeforeExit: function ( exit ) { diff --git a/modules/mobile/overlay.js b/modules/mobile/overlay.js index ccff7b6d3..b890ee8bf 100644 --- a/modules/mobile/overlay.js +++ b/modules/mobile/overlay.js @@ -45,7 +45,7 @@ function onCountChange( count ) { */ function notificationsOverlay( onBeforeExit ) { let markAllReadButton; - const oouiPromise = mw.loader.using( 'oojs-ui' ).then( function () { + const oouiPromise = mw.loader.using( 'oojs-ui' ).then( () => { markAllReadButton = new OO.ui.ButtonWidget( { icon: 'checkAll' } ); @@ -71,15 +71,13 @@ function notificationsOverlay( onBeforeExit ) { isBorderBox: false, className: 'overlay notifications-overlay navigation-drawer', onBeforeExit: function ( exit ) { - onBeforeExit( function () { + onBeforeExit( () => { onBeforeExitAnimation( overlay, exit ); } ); } }, promisedView( - oouiPromise.then( function () { - return list( mw.echo, markAllReadButton, onCountChange ); - } ) + oouiPromise.then( () => list( mw.echo, markAllReadButton, onCountChange ) ) ) ); return overlay; diff --git a/modules/model/mw.echo.dm.BundleNotificationItem.js b/modules/model/mw.echo.dm.BundleNotificationItem.js index 66e6f7cbe..a5a8d00fb 100644 --- a/modules/model/mw.echo.dm.BundleNotificationItem.js +++ b/modules/model/mw.echo.dm.BundleNotificationItem.js @@ -15,7 +15,7 @@ // Parent constructor mw.echo.dm.BundleNotificationItem.super.call( this, id, config ); - this.getSecondaryUrls().forEach( function ( link ) { + this.getSecondaryUrls().forEach( ( link ) => { // hack: put all secondary actions in the menu for now // this is a temporary fix for // - alignment of the labels @@ -27,7 +27,7 @@ this.count = bundledNotificationModels.length; // bundled notifications use the compact header and do not have icons - bundledNotificationModels.forEach( function ( bundled ) { + bundledNotificationModels.forEach( ( bundled ) => { bundled.content.header = bundled.content.compactHeader; delete bundled.iconURL; } ); @@ -59,9 +59,7 @@ * @return {boolean} Whether this bundle is completely read */ mw.echo.dm.BundleNotificationItem.prototype.isRead = function () { - return this.list.getItems().every( function ( item ) { - return item.isRead(); - } ); + return this.list.getItems().every( ( item ) => item.isRead() ); }; /** @@ -102,7 +100,7 @@ * @param {number} timestamp New seen timestamp */ mw.echo.dm.BundleNotificationItem.prototype.updateSeenState = function ( timestamp ) { - this.list.getItems().forEach( function ( notification ) { + this.list.getItems().forEach( ( notification ) => { notification.toggleSeen( notification.isRead() || notification.getTimestamp() < timestamp ); @@ -126,9 +124,7 @@ * @return {number[]} */ mw.echo.dm.BundleNotificationItem.prototype.getAllIds = function () { - return this.list.getItems().map( function ( item ) { - return item.getId(); - } ); + return this.list.getItems().map( ( item ) => item.getId() ); }; /** diff --git a/modules/model/mw.echo.dm.CrossWikiNotificationItem.js b/modules/model/mw.echo.dm.CrossWikiNotificationItem.js index f2373758e..289d957e2 100644 --- a/modules/model/mw.echo.dm.CrossWikiNotificationItem.js +++ b/modules/model/mw.echo.dm.CrossWikiNotificationItem.js @@ -122,8 +122,8 @@ * @param {number} timestamp New seen timestamp */ mw.echo.dm.CrossWikiNotificationItem.prototype.updateSeenState = function ( timestamp ) { - this.getList().getItems().forEach( function ( source ) { - source.getItems().forEach( function ( notification ) { + this.getList().getItems().forEach( ( source ) => { + source.getItems().forEach( ( notification ) => { notification.toggleSeen( notification.isRead() || notification.getTimestamp() < timestamp ); @@ -138,7 +138,7 @@ */ mw.echo.dm.CrossWikiNotificationItem.prototype.getItems = function () { let notifications = []; - this.list.getItems().forEach( function ( sourceList ) { + this.list.getItems().forEach( ( sourceList ) => { notifications = notifications.concat( sourceList.getItems() ); } ); diff --git a/modules/model/mw.echo.dm.ModelManager.js b/modules/model/mw.echo.dm.ModelManager.js index 34400e3c5..46cc8c901 100644 --- a/modules/model/mw.echo.dm.ModelManager.js +++ b/modules/model/mw.echo.dm.ModelManager.js @@ -433,7 +433,7 @@ source = source || 'local'; const notifications = []; - Object.keys( this.getAllNotificationModels() ).forEach( function ( modelName ) { + Object.keys( this.getAllNotificationModels() ).forEach( ( modelName ) => { const model = manager.getNotificationModel( modelName ); if ( model.getSource() === source ) { notifications.push( ...model.getItems() ); @@ -454,7 +454,7 @@ source = source || 'local'; - Object.keys( this.getAllNotificationModels() ).forEach( function ( modelName ) { + Object.keys( this.getAllNotificationModels() ).forEach( ( modelName ) => { const model = manager.getNotificationModel( modelName ); if ( model.getSource() === source ) { modelIds.push( modelName ); diff --git a/modules/model/mw.echo.dm.NotificationGroupsList.js b/modules/model/mw.echo.dm.NotificationGroupsList.js index a2b1fc61d..fef059aab 100644 --- a/modules/model/mw.echo.dm.NotificationGroupsList.js +++ b/modules/model/mw.echo.dm.NotificationGroupsList.js @@ -21,7 +21,7 @@ mw.echo.dm.NotificationGroupsList.super.call( this ); // Sorting callback - this.setSortingCallback( function ( a, b ) { + this.setSortingCallback( ( a, b ) => { // Reverse sorting if ( b.getTimestamp() < a.getTimestamp() ) { return -1; diff --git a/modules/model/mw.echo.dm.NotificationsList.js b/modules/model/mw.echo.dm.NotificationsList.js index ff6c8ea73..b5f633e88 100644 --- a/modules/model/mw.echo.dm.NotificationsList.js +++ b/modules/model/mw.echo.dm.NotificationsList.js @@ -35,7 +35,7 @@ this.fallbackTimestamp = config.timestamp || 0; // Sorting callback - this.setSortingCallback( config.sortingCallback || function ( a, b ) { + this.setSortingCallback( config.sortingCallback || ( ( a, b ) => { if ( !a.isRead() && b.isRead() ) { return -1; // Unread items are always above read items } else if ( a.isRead() && !b.isRead() ) { @@ -55,7 +55,7 @@ // Fallback on IDs return b.getId() - a.getId(); - } ); + } ) ); // Events this.aggregate( { update: 'itemUpdate' } ); @@ -215,9 +215,7 @@ * @return {mw.echo.dm.NotificationItem[]} An array of matching items */ mw.echo.dm.NotificationsList.prototype.findByIds = function ( ids ) { - return this.getItems().filter( function ( item ) { - return ids.indexOf( item.getId() ) !== -1; - } ); + return this.getItems().filter( ( item ) => ids.indexOf( item.getId() ) !== -1 ); }; /** @@ -249,7 +247,7 @@ * @param {string} timestamp New seen timestamp */ mw.echo.dm.NotificationsList.prototype.updateSeenState = function ( timestamp ) { - this.getItems().forEach( function ( notification ) { + this.getItems().forEach( ( notification ) => { notification.toggleSeen( notification.isRead() || notification.getTimestamp() < timestamp ); diff --git a/modules/model/mw.echo.dm.SeenTimeModel.js b/modules/model/mw.echo.dm.SeenTimeModel.js index 07c235044..613098b30 100644 --- a/modules/model/mw.echo.dm.SeenTimeModel.js +++ b/modules/model/mw.echo.dm.SeenTimeModel.js @@ -56,7 +56,7 @@ const model = this; let hasChanged = false; - this.getTypes().forEach( function ( type ) { + this.getTypes().forEach( ( type ) => { if ( model.seenTime[ type ] !== time ) { model.seenTime[ type ] = time; hasChanged = true; diff --git a/modules/model/mw.echo.dm.UnreadNotificationCounter.js b/modules/model/mw.echo.dm.UnreadNotificationCounter.js index d16c5d269..a789a4872 100644 --- a/modules/model/mw.echo.dm.UnreadNotificationCounter.js +++ b/modules/model/mw.echo.dm.UnreadNotificationCounter.js @@ -129,7 +129,7 @@ this.source, this.type, this.localOnly - ) ).then( function ( actualCount ) { + ) ).then( ( actualCount ) => { model.setCount( actualCount, false ); return actualCount; diff --git a/modules/special/ext.echo.special.js b/modules/special/ext.echo.special.js index 2ab6a9c1a..986b8352c 100644 --- a/modules/special/ext.echo.special.js +++ b/modules/special/ext.echo.special.js @@ -4,7 +4,7 @@ /*! * Echo Special:Notifications page initialization */ - $( function () { + $( () => { const limitNotifications = 50, links = mw.config.get( 'wgNotificationsSpecialPageLinks' ), // FIXME: Use CSS transition diff --git a/modules/ui/mw.echo.ui.BundleNotificationItemWidget.js b/modules/ui/mw.echo.ui.BundleNotificationItemWidget.js index 7b8f650a9..8440b9530 100644 --- a/modules/ui/mw.echo.ui.BundleNotificationItemWidget.js +++ b/modules/ui/mw.echo.ui.BundleNotificationItemWidget.js @@ -23,7 +23,7 @@ this.listWidget = new mw.echo.ui.SortedListWidget( // Sorting callback - function ( a, b ) { + ( ( a, b ) => { // Reverse sorting if ( b.getTimestamp() < a.getTimestamp() ) { return -1; @@ -33,7 +33,7 @@ // Fallback on IDs return b.getId() - a.getId(); - }, + } ), // Config { classes: [ 'mw-echo-ui-bundleNotificationItemWidget-group' ], @@ -50,11 +50,11 @@ .css( 'display', 'none' ); // Prevent clicks on the list padding area from activating the primary link - this.listWidget.$element.on( 'click', function ( e ) { + this.listWidget.$element.on( 'click', ( e ) => { if ( e.target.closest( 'a' ) === this.$element[ 0 ] ) { e.preventDefault(); } - }.bind( this ) ); + } ); // Initialize closed this.expanded = false; @@ -115,16 +115,14 @@ */ mw.echo.ui.BundleNotificationItemWidget.prototype.populateFromModel = function () { const widget = this; - this.getList().addItems( this.model.getList().getItems().map( function ( singleNotifModel ) { - return new mw.echo.ui.SingleNotificationItemWidget( - widget.controller, - singleNotifModel, - { - $overlay: widget.$overlay, - bundle: true - } - ); - } ) ); + this.getList().addItems( this.model.getList().getItems().map( ( singleNotifModel ) => new mw.echo.ui.SingleNotificationItemWidget( + widget.controller, + singleNotifModel, + { + $overlay: widget.$overlay, + bundle: true + } + ) ) ); }; /** diff --git a/modules/ui/mw.echo.ui.CrossWikiNotificationItemWidget.js b/modules/ui/mw.echo.ui.CrossWikiNotificationItemWidget.js index c3e981de0..337957774 100644 --- a/modules/ui/mw.echo.ui.CrossWikiNotificationItemWidget.js +++ b/modules/ui/mw.echo.ui.CrossWikiNotificationItemWidget.js @@ -31,7 +31,7 @@ this.listWidget = new mw.echo.ui.SortedListWidget( // Sorting callback - function ( a, b ) { + ( ( a, b ) => { // Define the sorting order. // This will go by the lists' timestamp, which in turn // take the latest timestamp in their items @@ -43,7 +43,7 @@ // Fallback on IDs return b.getSource() - a.getSource(); - }, + } ), // Config { classes: [ 'mw-echo-ui-crossWikiNotificationItemWidget-group' ], @@ -232,7 +232,7 @@ // Query all sources this.controller.fetchCrossWikiNotifications() .catch( - function ( result ) { + ( result ) => { const loginPageTitle = mw.Title.newFromText( 'Special:UserLogin' ); // If failure, check if the failure is due to login // so we can display a more comprehensive error diff --git a/modules/ui/mw.echo.ui.CrossWikiUnreadFilterWidget.js b/modules/ui/mw.echo.ui.CrossWikiUnreadFilterWidget.js index a70aac3a9..b6b0ca65d 100644 --- a/modules/ui/mw.echo.ui.CrossWikiUnreadFilterWidget.js +++ b/modules/ui/mw.echo.ui.CrossWikiUnreadFilterWidget.js @@ -17,7 +17,7 @@ // Parent constructor mw.echo.ui.CrossWikiUnreadFilterWidget.super.call( this, // Sorting callback - function ( a, b ) { + ( a, b ) => { // Local source is always first if ( a.getSource() === 'local' ) { return -1; diff --git a/modules/ui/mw.echo.ui.DatedNotificationsWidget.js b/modules/ui/mw.echo.ui.DatedNotificationsWidget.js index 4f80d0e02..a54247acb 100644 --- a/modules/ui/mw.echo.ui.DatedNotificationsWidget.js +++ b/modules/ui/mw.echo.ui.DatedNotificationsWidget.js @@ -30,14 +30,14 @@ this.listWidget = new mw.echo.ui.SortedListWidget( // Sorting callback - function ( a, b ) { + ( ( a, b ) => { // Reverse sorting if ( b.getTimestamp() < a.getTimestamp() ) { return -1; } else if ( b.getTimestamp() > a.getTimestamp() ) { return 1; } - }, + } ), // Config { classes: [ 'mw-echo-ui-datedNotificationsWidget-group' ], @@ -118,7 +118,7 @@ groupWidgets.push( subgroupWidget ); } - this.getList().getItems().forEach( function ( widget ) { + this.getList().getItems().forEach( ( widget ) => { // Destroy all available widgets widget.destroy(); } ); diff --git a/modules/ui/mw.echo.ui.NotificationBadgeWidget.js b/modules/ui/mw.echo.ui.NotificationBadgeWidget.js index a314178bd..9d1b7f41a 100644 --- a/modules/ui/mw.echo.ui.NotificationBadgeWidget.js +++ b/modules/ui/mw.echo.ui.NotificationBadgeWidget.js @@ -307,7 +307,7 @@ this.controller.fetchLocalNotifications( this.hasRunFirstTime ) .then( // Success - function () { + () => { if ( widget.popup.isVisible() ) { // Fire initialization hook mw.hook( 'ext.echo.popup.onInitialize' ).fire( widget.manager.getTypeString(), widget.controller ); @@ -317,7 +317,7 @@ } }, // Failure - function ( errorObj ) { + ( errorObj ) => { if ( errorObj.errCode === 'notlogin-required' ) { // Login required message widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-notification-loginrequired' ) ); @@ -328,7 +328,7 @@ } ) .then( this.emit.bind( this, 'finishLoading' ) ) - .always( function () { + .always( () => { widget.popup.clip(); // Pop pending widget.popPending(); diff --git a/modules/ui/mw.echo.ui.NotificationItemWidget.js b/modules/ui/mw.echo.ui.NotificationItemWidget.js index 00417cfcb..d5e1f5c15 100644 --- a/modules/ui/mw.echo.ui.NotificationItemWidget.js +++ b/modules/ui/mw.echo.ui.NotificationItemWidget.js @@ -243,7 +243,7 @@ // Send to controller item.pushPending(); this.controller.performDynamicAction( actionData, this.getModel().getSource() ) - .then( function () { + .then( () => { const $title = $( '

' ) .addClass( 'mw-echo-ui-notificationItemWidget-notify-title' ) .append( $.parseHTML( messages.title ) ), diff --git a/modules/ui/mw.echo.ui.NotificationsInboxWidget.js b/modules/ui/mw.echo.ui.NotificationsInboxWidget.js index f05e0e34a..98ad77800 100644 --- a/modules/ui/mw.echo.ui.NotificationsInboxWidget.js +++ b/modules/ui/mw.echo.ui.NotificationsInboxWidget.js @@ -238,7 +238,7 @@ return fetchPromise .then( // Success - function () { + () => { // Fire initialization hook mw.hook( 'ext.echo.special.onInitialize' ).fire( widget.controller.manager.getTypeString(), widget.controller ); @@ -247,7 +247,7 @@ widget.controller.updateSeenTime(); }, // Failure - function ( errObj ) { + ( errObj ) => { let msg; if ( errObj.errCode === 'notlogin-required' ) { // Login required message diff --git a/modules/ui/mw.echo.ui.NotificationsListWidget.js b/modules/ui/mw.echo.ui.NotificationsListWidget.js index 31c19e8d8..ddf00997a 100644 --- a/modules/ui/mw.echo.ui.NotificationsListWidget.js +++ b/modules/ui/mw.echo.ui.NotificationsListWidget.js @@ -22,7 +22,7 @@ mw.echo.ui.NotificationsListWidget.super.call( this, // Sorting callback - function ( a, b ) { + ( a, b ) => { if ( !a.isRead() && b.isRead() ) { return -1; // Unread items are always above read items } else if ( a.isRead() && !b.isRead() ) { diff --git a/modules/ui/mw.echo.ui.NotificationsWrapper.js b/modules/ui/mw.echo.ui.NotificationsWrapper.js index 545f32029..f5fa276cc 100644 --- a/modules/ui/mw.echo.ui.NotificationsWrapper.js +++ b/modules/ui/mw.echo.ui.NotificationsWrapper.js @@ -69,7 +69,7 @@ this.pushPending(); return this.controller.fetchLocalNotifications( true ) - .catch( function ( errorObj ) { + .catch( ( errorObj ) => { if ( errorObj.errCode === 'notlogin-required' ) { // Login required message widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-notification-loginrequired' ) ); @@ -78,7 +78,7 @@ widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-api-failure' ) ); } } ) - .always( function () { + .always( () => { widget.popPending(); widget.emit( 'finishLoading' ); widget.promiseRunning = false; diff --git a/modules/ui/mw.echo.ui.PageFilterWidget.js b/modules/ui/mw.echo.ui.PageFilterWidget.js index 887114f16..0e288b2f4 100644 --- a/modules/ui/mw.echo.ui.PageFilterWidget.js +++ b/modules/ui/mw.echo.ui.PageFilterWidget.js @@ -133,9 +133,7 @@ return OO.binarySearch( this.items, - function ( otherItem ) { - return widget.sortingFunction( item, otherItem ); - }, + ( otherItem ) => widget.sortingFunction( item, otherItem ), true ); }; diff --git a/modules/ui/mw.echo.ui.SortedListWidget.js b/modules/ui/mw.echo.ui.SortedListWidget.js index 28b8b1640..58ed87f43 100644 --- a/modules/ui/mw.echo.ui.SortedListWidget.js +++ b/modules/ui/mw.echo.ui.SortedListWidget.js @@ -83,7 +83,7 @@ // fade out fake // FIXME: Use CSS transition // eslint-disable-next-line no-jquery/no-fade - fakeWidget.$element.fadeOut( 400, function () { + fakeWidget.$element.fadeOut( 400, () => { // remove fake widget.removeItems( [ fakeWidget ] ); // fade-in real item diff --git a/modules/ui/mw.echo.ui.SubGroupListWidget.js b/modules/ui/mw.echo.ui.SubGroupListWidget.js index f8551483e..c54c21356 100644 --- a/modules/ui/mw.echo.ui.SubGroupListWidget.js +++ b/modules/ui/mw.echo.ui.SubGroupListWidget.js @@ -31,7 +31,7 @@ this.listWidget = new mw.echo.ui.SortedListWidget( // Sorting callback - config.sortingCallback || function ( a, b ) { + config.sortingCallback || ( ( a, b ) => { // Reverse sorting if ( b.getTimestamp() < a.getTimestamp() ) { return -1; @@ -41,7 +41,7 @@ // Fallback on IDs return b.getId() - a.getId(); - }, + } ), // Config { $overlay: this.$overlay, diff --git a/tests/qunit/model/test_mw.echo.dm.BundleNotificationItem.js b/tests/qunit/model/test_mw.echo.dm.BundleNotificationItem.js index 3df643884..08803fc53 100644 --- a/tests/qunit/model/test_mw.echo.dm.BundleNotificationItem.js +++ b/tests/qunit/model/test_mw.echo.dm.BundleNotificationItem.js @@ -1,6 +1,6 @@ QUnit.module( 'ext.echo.dm - BundleNotificationItem' ); -QUnit.test( 'Constructing the model', function ( assert ) { +QUnit.test( 'Constructing the model', ( assert ) => { const bundledItems = [ new mw.echo.dm.NotificationItem( 0, { read: false, seen: false, timestamp: '201601010000' } ), new mw.echo.dm.NotificationItem( 1, { read: false, seen: false, timestamp: '201601010100' } ), @@ -44,9 +44,7 @@ QUnit.test( 'Constructing the model', function ( assert ) { 'Bundle has unseen items' ); - const findItems = bundle.findByIds( [ 1, 4 ] ).map( function ( item ) { - return item.getId(); - } ); + const findItems = bundle.findByIds( [ 1, 4 ] ).map( ( item ) => item.getId() ); assert.deepEqual( findItems, [ 4, 1 ], @@ -54,7 +52,7 @@ QUnit.test( 'Constructing the model', function ( assert ) { ); } ); -QUnit.test( 'Managing a list of items', function ( assert ) { +QUnit.test( 'Managing a list of items', ( assert ) => { const bundledItems = [ new mw.echo.dm.NotificationItem( 0, { read: false, seen: false, timestamp: '201601010000' } ), new mw.echo.dm.NotificationItem( 1, { read: false, seen: false, timestamp: '201601010100' } ), @@ -77,7 +75,7 @@ QUnit.test( 'Managing a list of items', function ( assert ) { ); // Mark all items as seen - bundledItems.forEach( function ( item ) { + bundledItems.forEach( ( item ) => { item.toggleSeen( true ); } ); @@ -101,7 +99,7 @@ QUnit.test( 'Managing a list of items', function ( assert ) { ); // Mark all items as read - bundledItems.forEach( function ( item ) { + bundledItems.forEach( ( item ) => { item.toggleRead( true ); } ); assert.strictEqual( diff --git a/tests/qunit/model/test_mw.echo.dm.CrossWikiNotificationItem.js b/tests/qunit/model/test_mw.echo.dm.CrossWikiNotificationItem.js index ee93ab589..7f08160a4 100644 --- a/tests/qunit/model/test_mw.echo.dm.CrossWikiNotificationItem.js +++ b/tests/qunit/model/test_mw.echo.dm.CrossWikiNotificationItem.js @@ -26,7 +26,7 @@ QUnit.test.each( 'Constructing the model', { getCount: 10 } } -}, function ( assert, data ) { +}, ( assert, data ) => { const defaults = { getModelName: 'xwiki', getSourceNames: [], @@ -54,7 +54,7 @@ QUnit.test.each( 'Constructing the model', { } } ); -QUnit.test( 'Managing notification lists', function ( assert ) { +QUnit.test( 'Managing notification lists', ( assert ) => { const model = new mw.echo.dm.CrossWikiNotificationItem( 1 ); const groupDefinitions = [ { @@ -95,7 +95,7 @@ QUnit.test( 'Managing notification lists', function ( assert ) { ]; // Add groups to model - groupDefinitions.forEach( function ( def ) { + groupDefinitions.forEach( ( def ) => { model.getList().addGroup( def.name, def.sourceData, @@ -115,8 +115,8 @@ QUnit.test( 'Managing notification lists', function ( assert ) { ); // Mark all items as seen except one - groupDefinitions.forEach( function ( def ) { - def.items.forEach( function ( item ) { + groupDefinitions.forEach( ( def ) => { + def.items.forEach( ( item ) => { item.toggleSeen( true ); } ); } ); @@ -143,7 +143,7 @@ QUnit.test( 'Managing notification lists', function ( assert ) { ); } ); -QUnit.test( 'Update seen state', function ( assert ) { +QUnit.test( 'Update seen state', ( assert ) => { const model = new mw.echo.dm.CrossWikiNotificationItem( 1 ); const groupDefinitions = [ { @@ -184,9 +184,7 @@ QUnit.test( 'Update seen state', function ( assert ) { ]; // Count all actual items - const numAllItems = groupDefinitions.reduce( function ( prev, curr ) { - return prev + curr.items.length; - }, 0 ); + const numAllItems = groupDefinitions.reduce( ( prev, curr ) => prev + curr.items.length, 0 ); // Add groups to model for ( let i = 0; i < groupDefinitions.length; i++ ) { @@ -197,9 +195,7 @@ QUnit.test( 'Update seen state', function ( assert ) { ); } - let numUnseenItems = model.getItems().filter( function ( item ) { - return !item.isSeen(); - } ).length; + let numUnseenItems = model.getItems().filter( ( item ) => !item.isSeen() ).length; assert.strictEqual( numUnseenItems, numAllItems, @@ -209,9 +205,7 @@ QUnit.test( 'Update seen state', function ( assert ) { // Update seen time to be bigger than 'foo' but smaller than the other groups model.updateSeenState( '201601010400' ); - numUnseenItems = model.getItems().filter( function ( item ) { - return !item.isSeen(); - } ).length; + numUnseenItems = model.getItems().filter( ( item ) => !item.isSeen() ).length; assert.strictEqual( numUnseenItems, numAllItems - groupDefinitions[ 0 ].items.length, @@ -221,9 +215,7 @@ QUnit.test( 'Update seen state', function ( assert ) { // Update seen time to be bigger than all model.updateSeenState( '201701010000' ); - numUnseenItems = model.getItems().filter( function ( item ) { - return !item.isSeen(); - } ).length; + numUnseenItems = model.getItems().filter( ( item ) => !item.isSeen() ).length; assert.strictEqual( numUnseenItems, 0, @@ -231,7 +223,7 @@ QUnit.test( 'Update seen state', function ( assert ) { ); } ); -QUnit.test( 'Emit discard event', function ( assert ) { +QUnit.test( 'Emit discard event', ( assert ) => { const results = []; const model = new mw.echo.dm.CrossWikiNotificationItem( -1 ); const groupDefinitions = [ @@ -282,7 +274,7 @@ QUnit.test( 'Emit discard event', function ( assert ) { } // Listen to event - model.on( 'discard', function ( name ) { + model.on( 'discard', ( name ) => { results.push( name ); } ); diff --git a/tests/qunit/model/test_mw.echo.dm.FiltersModel.js b/tests/qunit/model/test_mw.echo.dm.FiltersModel.js index d09c62a67..2e622641b 100644 --- a/tests/qunit/model/test_mw.echo.dm.FiltersModel.js +++ b/tests/qunit/model/test_mw.echo.dm.FiltersModel.js @@ -21,7 +21,7 @@ QUnit.test.each( 'Constructing the model', { getReadState: 'read' } } -}, function ( assert, data ) { +}, ( assert, data ) => { const defaultValues = { getReadState: 'all' }; @@ -41,7 +41,7 @@ QUnit.test.each( 'Constructing the model', { } } ); -QUnit.test( 'Changing filters', function ( assert ) { +QUnit.test( 'Changing filters', ( assert ) => { const model = new mw.echo.dm.FiltersModel(); assert.strictEqual( @@ -72,12 +72,12 @@ QUnit.test( 'Changing filters', function ( assert ) { ); } ); -QUnit.test( '.setReadState() events', function ( assert ) { +QUnit.test( '.setReadState() events', ( assert ) => { const results = []; const model = new mw.echo.dm.FiltersModel(); // Listen to update event - model.on( 'update', function () { + model.on( 'update', () => { results.push( model.getReadState() ); } ); diff --git a/tests/qunit/model/test_mw.echo.dm.NotificationGroupsList.js b/tests/qunit/model/test_mw.echo.dm.NotificationGroupsList.js index 1d06dae67..51eb5a2a0 100644 --- a/tests/qunit/model/test_mw.echo.dm.NotificationGroupsList.js +++ b/tests/qunit/model/test_mw.echo.dm.NotificationGroupsList.js @@ -1,6 +1,6 @@ QUnit.module( 'ext.echo.dm - NotificationGroupsList' ); -QUnit.test( 'Constructing the model', function ( assert ) { +QUnit.test( 'Constructing the model', ( assert ) => { const model = new mw.echo.dm.NotificationGroupsList(); assert.strictEqual( @@ -10,7 +10,7 @@ QUnit.test( 'Constructing the model', function ( assert ) { ); } ); -QUnit.test( 'Managing lists', function ( assert ) { +QUnit.test( 'Managing lists', ( assert ) => { const model = new mw.echo.dm.NotificationGroupsList(); const groupDefinitions = [ { @@ -50,7 +50,7 @@ QUnit.test( 'Managing lists', function ( assert ) { } ]; - groupDefinitions.forEach( function ( def, i ) { + groupDefinitions.forEach( ( def, i ) => { model.addGroup( def.name, def.sourceData, @@ -95,7 +95,7 @@ QUnit.test( 'Managing lists', function ( assert ) { ); } ); -QUnit.test( 'Emitting discard event', function ( assert ) { +QUnit.test( 'Emitting discard event', ( assert ) => { const results = []; const model = new mw.echo.dm.NotificationGroupsList(); const groups = { @@ -121,7 +121,7 @@ QUnit.test( 'Emitting discard event', function ( assert ) { // Listen to the event model - .on( 'discard', function ( g ) { + .on( 'discard', ( g ) => { results.push( g.getName() ); } ); diff --git a/tests/qunit/model/test_mw.echo.dm.NotificationItem.js b/tests/qunit/model/test_mw.echo.dm.NotificationItem.js index 4a0b4768f..af3d2cca9 100644 --- a/tests/qunit/model/test_mw.echo.dm.NotificationItem.js +++ b/tests/qunit/model/test_mw.echo.dm.NotificationItem.js @@ -1,4 +1,4 @@ -QUnit.module( 'ext.echo.dm - NotificationItem', function ( hooks ) { +QUnit.module( 'ext.echo.dm - NotificationItem', ( hooks ) => { const fakeData = { type: 'alert', read: true, @@ -67,7 +67,7 @@ QUnit.module( 'ext.echo.dm - NotificationItem', function ( hooks ) { ] } } - }, function ( assert, data ) { + }, ( assert, data ) => { const defaultValues = { getId: undefined, getContentHeader: '', @@ -94,7 +94,7 @@ QUnit.module( 'ext.echo.dm - NotificationItem', function ( hooks ) { ); const methods = ( data.methods === 'all' ? Object.keys( expected ) : data.methods ); - methods.forEach( function ( method ) { + methods.forEach( ( method ) => { assert.deepEqual( // Run the method itemModel[ method ](), @@ -106,12 +106,12 @@ QUnit.module( 'ext.echo.dm - NotificationItem', function ( hooks ) { } ); } ); - QUnit.test( 'Emitting update event', function ( assert ) { + QUnit.test( 'Emitting update event', ( assert ) => { const results = []; const itemModel = new mw.echo.dm.NotificationItem( 0, $.extend( true, {}, fakeData, { seen: false, read: false } ) ); // Listen to update event - itemModel.on( 'update', function () { + itemModel.on( 'update', () => { results.push( [ itemModel.isRead(), itemModel.isSeen() diff --git a/tests/qunit/model/test_mw.echo.dm.NotificationsList.js b/tests/qunit/model/test_mw.echo.dm.NotificationsList.js index 519011c6e..84ec6465b 100644 --- a/tests/qunit/model/test_mw.echo.dm.NotificationsList.js +++ b/tests/qunit/model/test_mw.echo.dm.NotificationsList.js @@ -22,7 +22,7 @@ QUnit.test.each( 'Constructing the model', { isForeign: true } } -}, function ( assert, data ) { +}, ( assert, data ) => { const defaultValues = { getAllItemIds: [], getAllItemIdsByType: [], @@ -50,7 +50,7 @@ QUnit.test.each( 'Constructing the model', { } } ); -QUnit.test( 'Handling notification items', function ( assert ) { +QUnit.test( 'Handling notification items', ( assert ) => { const model = new mw.echo.dm.NotificationsList( { timestamp: '200101010000' } ); const items = [ new mw.echo.dm.NotificationItem( 0, { type: 'alert', timestamp: '201609190000', read: false, seen: false } ), @@ -137,7 +137,7 @@ QUnit.test( 'Handling notification items', function ( assert ) { } ); -QUnit.test( 'Intercepting events', function ( assert ) { +QUnit.test( 'Intercepting events', ( assert ) => { const model = new mw.echo.dm.NotificationsList(); const result = []; const items = [ @@ -151,13 +151,13 @@ QUnit.test( 'Intercepting events', function ( assert ) { // Listen to events model - .on( 'update', function ( itms ) { + .on( 'update', ( itms ) => { result.push( 'update:' + itms.length ); } ) - .on( 'discard', function ( item ) { + .on( 'discard', ( item ) => { result.push( 'discard:' + item.getId() ); } ) - .on( 'itemUpdate', function ( item ) { + .on( 'itemUpdate', ( item ) => { result.push( 'itemUpdate:' + item.getId() ); } ); diff --git a/tests/qunit/model/test_mw.echo.dm.PaginationModel.js b/tests/qunit/model/test_mw.echo.dm.PaginationModel.js index a1c2bbbda..085bde7a1 100644 --- a/tests/qunit/model/test_mw.echo.dm.PaginationModel.js +++ b/tests/qunit/model/test_mw.echo.dm.PaginationModel.js @@ -17,7 +17,7 @@ QUnit.test.each( 'Constructing the model', { getCurrentPageItemCount: 10 } } -}, function ( assert, data ) { +}, ( assert, data ) => { const defaultValues = { getPageContinue: undefined, getCurrPageIndex: 0, @@ -45,12 +45,12 @@ QUnit.test.each( 'Constructing the model', { } } ); -QUnit.test( 'Emitting update event', function ( assert ) { +QUnit.test( 'Emitting update event', ( assert ) => { const results = []; const model = new mw.echo.dm.PaginationModel(); // Listen to update event - model.on( 'update', function () { + model.on( 'update', () => { results.push( [ model.getCurrPageIndex(), model.hasNextPage() diff --git a/tests/qunit/model/test_mw.echo.dm.SeenTimeModel.js b/tests/qunit/model/test_mw.echo.dm.SeenTimeModel.js index 4c5abcc8d..0ad606130 100644 --- a/tests/qunit/model/test_mw.echo.dm.SeenTimeModel.js +++ b/tests/qunit/model/test_mw.echo.dm.SeenTimeModel.js @@ -1,6 +1,6 @@ QUnit.module( 'ext.echo.dm - SeenTimeModel' ); -QUnit.test( '.getTypes()', function ( assert ) { +QUnit.test( '.getTypes()', ( assert ) => { const model = new mw.echo.dm.SeenTimeModel(); assert.deepEqual( @@ -10,7 +10,7 @@ QUnit.test( '.getTypes()', function ( assert ) { ); } ); -QUnit.test( '.setSeenTime() reflected', function ( assert ) { +QUnit.test( '.setSeenTime() reflected', ( assert ) => { let model; model = new mw.echo.dm.SeenTimeModel(); @@ -32,12 +32,12 @@ QUnit.test( '.setSeenTime() reflected', function ( assert ) { ); } ); -QUnit.test( '.setSeenTime() events', function ( assert ) { +QUnit.test( '.setSeenTime() events', ( assert ) => { const results = []; const model = new mw.echo.dm.SeenTimeModel(); // Attach a listener - model.on( 'update', function ( time ) { + model.on( 'update', ( time ) => { results.push( time ); } ); diff --git a/tests/qunit/model/test_mw.echo.dm.SourcePagesModel.js b/tests/qunit/model/test_mw.echo.dm.SourcePagesModel.js index 6fe1fdec7..28938e4dc 100644 --- a/tests/qunit/model/test_mw.echo.dm.SourcePagesModel.js +++ b/tests/qunit/model/test_mw.echo.dm.SourcePagesModel.js @@ -1,4 +1,4 @@ -QUnit.module( 'ext.echo.dm - SourcePagesModel', function () { +QUnit.module( 'ext.echo.dm - SourcePagesModel', () => { // Mock partial API response we feed into the model const sources = { local: { @@ -75,7 +75,7 @@ QUnit.module( 'ext.echo.dm - SourcePagesModel', function () { } }; - QUnit.test( 'Creating source-page map', function ( assert ) { + QUnit.test( 'Creating source-page map', ( assert ) => { const model = new mw.echo.dm.SourcePagesModel(); model.setAllSources( sources ); diff --git a/tests/qunit/model/test_mw.echo.dm.UnreadNotificationCounter.js b/tests/qunit/model/test_mw.echo.dm.UnreadNotificationCounter.js index dde2e71dd..f85b97dd4 100644 --- a/tests/qunit/model/test_mw.echo.dm.UnreadNotificationCounter.js +++ b/tests/qunit/model/test_mw.echo.dm.UnreadNotificationCounter.js @@ -4,7 +4,7 @@ QUnit.test.each( '.getCappedNotificationCount()', [ { input: 5, output: 5 }, { input: 20, output: 11 }, { input: 10, output: 10 } -], function ( assert, data ) { +], ( assert, data ) => { const model = new mw.echo.dm.UnreadNotificationCounter( null, 'all', // type @@ -17,7 +17,7 @@ QUnit.test.each( '.getCappedNotificationCount()', [ ); } ); -QUnit.test( '.estimateChange()', function ( assert ) { +QUnit.test( '.estimateChange()', ( assert ) => { const model = new mw.echo.dm.UnreadNotificationCounter( null, 'all', // type @@ -48,7 +48,7 @@ QUnit.test( '.estimateChange()', function ( assert ) { ); } ); -QUnit.test( '.setCount()', function ( assert ) { +QUnit.test( '.setCount()', ( assert ) => { const results = []; const model = new mw.echo.dm.UnreadNotificationCounter( null, @@ -57,7 +57,7 @@ QUnit.test( '.setCount()', function ( assert ) { ); // Listen to event - model.on( 'countChange', function ( count ) { + model.on( 'countChange', ( count ) => { results.push( count ); } );