From e97fd59a5f9c31e69dd64d1d254d7850bb278dae Mon Sep 17 00:00:00 2001 From: Fomafix Date: Sat, 26 May 2018 14:58:37 +0200 Subject: [PATCH] Remove eslint-disable no-use-before-define mediawiki.js: Reorder setGlobalMapValue() to avoid a forward reference. mediawiki.action.edit.stash.js: Reorder two functions without to avoid forward references. In all other cases add eslint-disable-next-line no-use-before-define. Change-Id: Ic8b2f8cf61dcfb1a215ad3d3dddfd40282e3e836 --- resources/src/mediawiki.Uri/Uri.js | 3 +- .../mediawiki.action.edit.stash.js | 23 +++++----- .../src/mediawiki.page.image.pagination.js | 3 +- resources/src/mediawiki/mediawiki.js | 43 ++++++++++--------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/resources/src/mediawiki.Uri/Uri.js b/resources/src/mediawiki.Uri/Uri.js index 7f12835ec7..7467d50816 100644 --- a/resources/src/mediawiki.Uri/Uri.js +++ b/resources/src/mediawiki.Uri/Uri.js @@ -50,8 +50,6 @@ * @class mw.Uri */ -/* eslint-disable no-use-before-define */ - ( function ( mw, $ ) { var parser, properties; @@ -156,6 +154,7 @@ return uri; } href = hrefCur; + // eslint-disable-next-line no-use-before-define uri = new Uri( href ); return uri; }; diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js index 5ae91e8564..1be0052aa5 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js @@ -1,7 +1,7 @@ /*! * Scripts for pre-emptive edit preparing on action=edit */ -/* eslint-disable no-use-before-define */ + ( function ( mw, $ ) { if ( !mw.config.get( 'wgAjaxEditStash' ) ) { return; @@ -32,6 +32,16 @@ return; } + // Whether the body text content changed since the last stashEdit() + function isTextChanged() { + return lastText !== $text.textSelection( 'getContents' ); + } + + // Whether the edit summary has changed since the last stashEdit() + function isSummaryChanged() { + return lastSummary !== $summary.textSelection( 'getContents' ); + } + // Send a request to stash the edit to the API. // If a request is in progress, abort it since its payload is stale and the API // may limit concurrent stash parses. @@ -43,6 +53,7 @@ if ( stashReq ) { if ( lastPriority > priority ) { // Stash request for summary change should wait on pending text change stash + // eslint-disable-next-line no-use-before-define stashReq.then( checkStash ); return; } @@ -91,16 +102,6 @@ } ); } - // Whether the body text content changed since the last stashEdit() - function isTextChanged() { - return lastText !== $text.textSelection( 'getContents' ); - } - - // Whether the edit summary has changed since the last stashEdit() - function isSummaryChanged() { - return lastSummary !== $summary.textSelection( 'getContents' ); - } - // Check whether text or summary have changed and call stashEdit() function checkStash() { if ( !isTextChanged() && !isSummaryChanged() ) { diff --git a/resources/src/mediawiki.page.image.pagination.js b/resources/src/mediawiki.page.image.pagination.js index 06c34a5083..1823ef0eb5 100644 --- a/resources/src/mediawiki.page.image.pagination.js +++ b/resources/src/mediawiki.page.image.pagination.js @@ -2,8 +2,6 @@ * Implement AJAX navigation for multi-page images so the user may browse without a full page reload. */ -/* eslint-disable no-use-before-define */ - ( function ( mw, $ ) { var jqXhr, $multipageimage, $spinner, cache = {}, @@ -86,6 +84,7 @@ // Replace table contents $multipageimage.empty().append( $contents.clone() ); + // eslint-disable-next-line no-use-before-define bindPageNavigation( $multipageimage ); // Fire hook because the page's content has changed diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 702c18d1bb..2d3f6ad33f 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -9,7 +9,6 @@ */ /* global mwNow */ -/* eslint-disable no-use-before-define */ ( function ( $ ) { 'use strict'; @@ -72,6 +71,27 @@ }() ); } + /** + * Alias property to the global object. + * + * @private + * @static + * @member mw.Map + * @param {mw.Map} map + * @param {string} key + * @param {Mixed} value + */ + function setGlobalMapValue( map, key, value ) { + map.values[ key ] = value; + log.deprecate( + window, + key, + value, + // Deprecation notice for mw.config globals (T58550, T72470) + map === mw.config && 'Use mw.config instead.' + ); + } + /** * Create an object that can be read from or written to via methods that allow * interaction both with single and multiple properties at once. @@ -108,26 +128,6 @@ } } - /** - * Alias property to the global object. - * - * @private - * @static - * @param {mw.Map} map - * @param {string} key - * @param {Mixed} value - */ - function setGlobalMapValue( map, key, value ) { - map.values[ key ] = value; - log.deprecate( - window, - key, - value, - // Deprecation notice for mw.config globals (T58550, T72470) - map === mw.config && 'Use mw.config instead.' - ); - } - Map.prototype = { constructor: Map, @@ -1078,6 +1078,7 @@ mw.loader.store.set( module, registry[ module ] ); for ( m in registry ) { if ( registry[ m ].state === 'loaded' && allReady( registry[ m ].dependencies ) ) { + // eslint-disable-next-line no-use-before-define execute( m ); } } -- 2.20.1