From d94f90e0883706f06a4762f57bbc88b4969dc726 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 14 May 2020 22:09:33 +0100 Subject: [PATCH] eslint: Code style fixes for upcoming config change Change-Id: Ief44c0bb26c5a1c1773cab5dba51d5e856612bf7 --- .../mediawiki.Title/generateJsToUpperCaseList.js | 4 ++-- .../special.changecredentials.js | 12 ++++++------ .../mw.widgets.UsersMultiselectWidget.js | 1 + tests/api-testing/action/Backlinks.js | 2 +- tests/api-testing/action/Categories.js | 4 ++-- tests/api-testing/action/Links.js | 4 ++-- tests/api-testing/action/PrefixSearch.js | 2 +- tests/selenium/specs/user.js | 2 +- tests/selenium/wdio-mediawiki/RunJobs.js | 4 +--- tests/selenium/wdio-mediawiki/index.js | 5 ++--- 10 files changed, 19 insertions(+), 21 deletions(-) diff --git a/maintenance/mediawiki.Title/generateJsToUpperCaseList.js b/maintenance/mediawiki.Title/generateJsToUpperCaseList.js index 03323694b6b..92b5abec5b1 100644 --- a/maintenance/mediawiki.Title/generateJsToUpperCaseList.js +++ b/maintenance/mediawiki.Title/generateJsToUpperCaseList.js @@ -1,6 +1,6 @@ -var i, chars = []; +const chars = []; -for ( i = 0; i <= 0x10ffff; i++ ) { +for ( let i = 0; i <= 0x10ffff; i++ ) { chars.push( String.fromCodePoint( i ).toUpperCase() ); } console.log( JSON.stringify( chars ) ); diff --git a/resources/src/mediawiki.misc-authed-ooui/special.changecredentials.js b/resources/src/mediawiki.misc-authed-ooui/special.changecredentials.js index 36ad2524412..49d290c794f 100644 --- a/resources/src/mediawiki.misc-authed-ooui/special.changecredentials.js +++ b/resources/src/mediawiki.misc-authed-ooui/special.changecredentials.js @@ -33,18 +33,18 @@ errorsuselocal: true, uselang: mw.config.get( 'wgUserLanguage' ) } ).done( function ( resp ) { - var pwinfo = resp.validatepassword, - good = pwinfo.validity === 'Good', - errors = []; + var errors, + pwinfo = resp.validatepassword, + good = pwinfo.validity === 'Good'; currentApiPromise = undefined; if ( !good ) { - pwinfo.validitymessages.map( function ( m ) { - errors.push( new OO.ui.HtmlSnippet( m.html ) ); + errors = pwinfo.validitymessages.map( function ( m ) { + return new OO.ui.HtmlSnippet( m.html ); } ); } - self.setErrors( errors ); + self.setErrors( errors || [] ); d.resolve( good ); } ).fail( d.reject ); diff --git a/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js index c73e8f7efbe..53319bf66d1 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js @@ -154,6 +154,7 @@ label: user.name } ); } + return undefined; } ).filter( function ( item ) { return item !== undefined; } ); diff --git a/tests/api-testing/action/Backlinks.js b/tests/api-testing/action/Backlinks.js index 4e3732a1b9f..505923a0102 100644 --- a/tests/api-testing/action/Backlinks.js +++ b/tests/api-testing/action/Backlinks.js @@ -24,7 +24,7 @@ describe( 'Backlinks', function () { describe( 'referrers', () => { it( 'can be listed', async () => { const result = await bob.list( 'backlinks', { bltitle: randomPage } ); - const links = result.map( ( p )=>( p.title ) ); + const links = result.map( ( p ) => p.title ); assert.sameMembers( links, [ linksToEsther1, linksToEsther2 ] ); } ); } ); diff --git a/tests/api-testing/action/Categories.js b/tests/api-testing/action/Categories.js index f4872444d99..a4419df5bd7 100644 --- a/tests/api-testing/action/Categories.js +++ b/tests/api-testing/action/Categories.js @@ -25,7 +25,7 @@ describe( 'Categories', function testCategories() { page ); - return result[ page ].categories.map( ( p )=>utils.dbkey( p.title ) ); + return result[ page ].categories.map( ( p ) => utils.dbkey( p.title ) ); }; const listMembers = async ( cat, param = {} ) => { @@ -34,7 +34,7 @@ describe( 'Categories', function testCategories() { { cmtitle: cat, ...param } ); - return result.map( ( p )=>utils.dbkey( p.title ) ); + return result.map( ( p ) => utils.dbkey( p.title ) ); }; it( 'can be added using wikitext syntax', async () => { diff --git a/tests/api-testing/action/Links.js b/tests/api-testing/action/Links.js index 7fd9ff4dcf0..205f3462f4f 100644 --- a/tests/api-testing/action/Links.js +++ b/tests/api-testing/action/Links.js @@ -1,7 +1,7 @@ const { action, assert, utils } = require( 'api-testing' ); describe( 'Links', function testLinks() { - const titles = ( list ) => list.map( ( p )=>utils.dbkey( p.title ) ); + const titles = ( list ) => list.map( ( p ) => utils.dbkey( p.title ) ); const pageX = utils.title( 'LinkTest_X_' ); const pageY = utils.title( 'LinkTest_Y_' ); @@ -54,7 +54,7 @@ describe( 'Links', function testLinks() { describe( 'to external pages', () => { it( 'can be listed', async () => { const result = await alice.prop( 'extlinks', pageX ); - const links = result[ pageX ].extlinks.map( ( p )=>p[ '*' ] ); + const links = result[ pageX ].extlinks.map( ( p ) => p[ '*' ] ); assert.sameMembers( links, [ urlY ] ); } ); diff --git a/tests/api-testing/action/PrefixSearch.js b/tests/api-testing/action/PrefixSearch.js index 981e20a78c4..4e74729046c 100644 --- a/tests/api-testing/action/PrefixSearch.js +++ b/tests/api-testing/action/PrefixSearch.js @@ -20,7 +20,7 @@ describe( 'Prefix Search', function () { it( 'should search for pages with the `${prefix}` prefix', async () => { const result = await alice.list( 'prefixsearch', { pssearch: `${prefix}`, pslimit: 100 } ); - const pageTitles = result.map( ( p )=>utils.dbkey( p.title ) ); + const pageTitles = result.map( ( p ) => utils.dbkey( p.title ) ); assert.sameMembers( pageTitles, [ firstPage, secondPage, thirdPage ] ); } ); } ); diff --git a/tests/selenium/specs/user.js b/tests/selenium/specs/user.js index d4780e434d3..26c8213b3d4 100644 --- a/tests/selenium/specs/user.js +++ b/tests/selenium/specs/user.js @@ -44,7 +44,7 @@ describe( 'User', function () { // Disabled due to flakiness (T199446) it.skip( 'should be able to change preferences', function () { - var realName = Util.getTestString(); + const realName = Util.getTestString(); // create browser.call( async () => { diff --git a/tests/selenium/wdio-mediawiki/RunJobs.js b/tests/selenium/wdio-mediawiki/RunJobs.js index daa7fbd71b1..18b865179a8 100644 --- a/tests/selenium/wdio-mediawiki/RunJobs.js +++ b/tests/selenium/wdio-mediawiki/RunJobs.js @@ -10,9 +10,7 @@ function getJobCount() { action: 'query', meta: 'siteinfo', siprop: 'statistics' - } ).then( ( response ) => { - return response.query.statistics.jobs; - } ); + } ).then( ( response ) => response.query.statistics.jobs ); } function log( message ) { diff --git a/tests/selenium/wdio-mediawiki/index.js b/tests/selenium/wdio-mediawiki/index.js index bfa3b8034a4..0be877dc3a6 100644 --- a/tests/selenium/wdio-mediawiki/index.js +++ b/tests/selenium/wdio-mediawiki/index.js @@ -9,10 +9,9 @@ module.exports = { * @return {string} File path */ saveScreenshot( title ) { - var filename, filePath; // Create sane file name for current test title - filename = encodeURIComponent( title.replace( /\s+/g, '-' ) ); - filePath = `${browser.config.screenshotPath}/${filename}.png`; + const filename = encodeURIComponent( title.replace( /\s+/g, '-' ) ); + const filePath = `${browser.config.screenshotPath}/${filename}.png`; // Ensure directory exists, based on WebDriverIO#saveScreenshotSync() try { fs.statSync( browser.config.screenshotPath );