From 689d07b81d7271eeeae95b6508be9dd952399679 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 5 Jul 2019 20:38:29 +0100 Subject: [PATCH] build: Update eslint-config-wikimedia to 0.13.0 Change-Id: I7df5840bc97f8bbcd8cfc875c2b48b3061ef2c9e --- mw-config/config.js | 1 + package-lock.json | 46 +++++++++---------- package.json | 2 +- .../jquery.tablesorter/jquery.tablesorter.js | 5 ++ resources/src/jquery/jquery.confirmable.js | 1 + .../src/jquery/jquery.makeCollapsible.js | 2 + resources/src/jquery/jquery.suggestions.js | 2 + .../mediawiki.action.history.js | 10 +++- .../mediawiki.action.view.metadata.js | 2 + resources/src/mediawiki.htmlform.checker.js | 1 + resources/src/mediawiki.htmlform/cloner.js | 4 ++ resources/src/mediawiki.page.watch.ajax.js | 1 + .../ui/ChangesListWrapperWidget.js | 2 + .../ui/FilterTagMultiselectWidget.js | 1 + .../mediawiki.searchSuggest/searchSuggest.js | 1 + resources/src/mediawiki.special.import.js | 1 + .../confirmClose.js | 1 + .../unwatchedPages.js | 1 + .../mediawiki.special.watchlist/watchlist.js | 1 + resources/src/mediawiki.toc/toc.js | 1 + resources/src/mediawiki.util.js | 1 + .../mw.widgets.MediaSearchWidget.js | 1 + .../mw.widgets.DateInputWidget.js | 1 + .../jquery/jquery.makeCollapsible.test.js | 6 +++ .../jquery/jquery.tablesorter.test.js | 2 + .../mediawiki.special.recentchanges.test.js | 8 ++++ .../resources/mediawiki/mediawiki.toc.test.js | 2 + tests/selenium/.eslintrc.json | 3 +- tests/selenium/pageobjects/history.page.js | 2 +- tests/selenium/specs/page.js | 4 +- tests/selenium/wdio-mediawiki/Api.js | 10 ++-- tests/selenium/wdio-mediawiki/RunJobs.js | 4 +- tests/selenium/wdio.conf.js | 6 +-- 33 files changed, 96 insertions(+), 40 deletions(-) diff --git a/mw-config/config.js b/mw-config/config.js index 235ff4aa0e..6f899f83cd 100644 --- a/mw-config/config.js +++ b/mw-config/config.js @@ -23,6 +23,7 @@ $( '.dbRadio' ).on( 'click', function () { var $checked = $( '.dbRadio:checked' ), $wrapper = $( document.getElementById( $checked.attr( 'rel' ) ) ); + // eslint-disable-next-line no-jquery/no-sizzle if ( $wrapper.is( ':hidden' ) ) { // FIXME: Use CSS transition // eslint-disable-next-line no-jquery/no-animate-toggle diff --git a/package-lock.json b/package-lock.json index bb52c61d18..72868123f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2057,14 +2057,14 @@ } }, "eslint-config-wikimedia": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/eslint-config-wikimedia/-/eslint-config-wikimedia-0.12.0.tgz", - "integrity": "sha512-ZkmGLvwmoEacj55t8Z6VH6wUu4/XTlgkSCerHkj+VU4tmyCD4mlzvTeSaPzOEDmZTVWUoiKnB6mvUx06l7uIbw==", + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/eslint-config-wikimedia/-/eslint-config-wikimedia-0.13.0.tgz", + "integrity": "sha512-l64xMCgPE949H9rfhC0Ir+UaNAh685CE6xSnWkMU5yNryNTdL91lW8KcMFgMqmmH0Q+Jq+7DIdfGaVld6nQ80w==", "dev": true, "requires": { "eslint": "^5.16.0", "eslint-plugin-json": "^1.4.0", - "eslint-plugin-no-jquery": "^2.0.0", + "eslint-plugin-no-jquery": "^2.1.0", "eslint-plugin-qunit": "^4.0.0" }, "dependencies": { @@ -2124,9 +2124,9 @@ } }, "eslint-plugin-no-jquery": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-no-jquery/-/eslint-plugin-no-jquery-2.0.0.tgz", - "integrity": "sha512-aFy3fMBlc630/qeasjocb9uIqmwoyOmmTQiBaDs70Aryqi9uPH0EZLPtIOshDMcGeAkyyAkcc+WuIw6bRsoLuw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-jquery/-/eslint-plugin-no-jquery-2.1.0.tgz", + "integrity": "sha512-5sr5tOJRfuRviyAvFTe/mr80TXWxTteD/JHRuJtDN8q/bxAh16eSKoKLAevLC7wZCRN2iwnEfhQPQV4rp/gYtg==", "dev": true }, "eslint-plugin-qunit": { @@ -7955,33 +7955,33 @@ "dev": true }, "vscode-json-languageservice": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-3.2.1.tgz", - "integrity": "sha512-ee9MJ70/xR55ywvm0bZsDLhA800HCRE27AYgMNTU14RSg20Y+ngHdQnUt6OmiTXrQDI/7sne6QUOtHIN0hPQYA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-3.3.0.tgz", + "integrity": "sha512-upq1PhwDItazdtRJ/R7uU0Fgrf9iaYa1xLK4WFLExR0DgbPojd0YgMpfyknVyXGlxsg3fJQ0H7J++QeByXHh9w==", "dev": true, "requires": { - "jsonc-parser": "^2.0.2", - "vscode-languageserver-types": "^3.13.0", - "vscode-nls": "^4.0.0", - "vscode-uri": "^1.0.6" + "jsonc-parser": "^2.1.0", + "vscode-languageserver-types": "^3.15.0-next.2", + "vscode-nls": "^4.1.1", + "vscode-uri": "^2.0.1" } }, "vscode-languageserver-types": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.14.0.tgz", - "integrity": "sha512-lTmS6AlAlMHOvPQemVwo3CezxBp0sNB95KNPkqp3Nxd5VFEnuG1ByM0zlRWos0zjO3ZWtkvhal0COgiV1xIA4A==", + "version": "3.15.0-next.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.15.0-next.2.tgz", + "integrity": "sha512-2JkrMWWUi2rlVLSo9OFR2PIGUzdiowEM8NgNYiwLKnXTjpwpjjIrJbNNxDik7Rv4oo9KtikcFQZKXbrKilL/MQ==", "dev": true }, "vscode-nls": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-4.1.0.tgz", - "integrity": "sha512-zKsFWVzL1wlCezgaI3XiN42IT8DIPM1Qr+G+RBhiU3U0bJCdC8pPELakRCtuVT4wF3gBZjBrUDQ8mowL7hmgwA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-4.1.1.tgz", + "integrity": "sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==", "dev": true }, "vscode-uri": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.6.tgz", - "integrity": "sha512-sLI2L0uGov3wKVb9EB+vIQBl9tVP90nqRvxSoJ35vI3NjxE8jfsE5DSOhWgSunHSZmKS4OCi2jrtfxK7uyp2ww==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-2.0.2.tgz", + "integrity": "sha512-VebpIxm9tG0fG2sBOhnsSPzDYuNUPP1UQW4K3mwthlca4e4f3d6HKq3HkITC2OPFomOaB7pHTSjcpdFWjfYTzg==", "dev": true }, "wdio-dot-reporter": { diff --git a/package.json b/package.json index 9f14c78b8f..f9fe5cb62e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "selenium-test": "wdio ./tests/selenium/wdio.conf.js" }, "devDependencies": { - "eslint-config-wikimedia": "0.12.0", + "eslint-config-wikimedia": "0.13.0", "grunt": "1.0.4", "grunt-banana-checker": "0.7.0", "grunt-contrib-copy": "1.0.0", diff --git a/resources/src/jquery.tablesorter/jquery.tablesorter.js b/resources/src/jquery.tablesorter/jquery.tablesorter.js index d34b06c605..7a131da48e 100644 --- a/resources/src/jquery.tablesorter/jquery.tablesorter.js +++ b/resources/src/jquery.tablesorter/jquery.tablesorter.js @@ -83,6 +83,7 @@ // eslint-disable-next-line no-jquery/no-map-util return $.map( node.childNodes, function ( elem ) { if ( elem.nodeType === Node.ELEMENT_NODE ) { + // eslint-disable-next-line no-jquery/no-class-state if ( $( elem ).hasClass( 'reference' ) ) { return null; } @@ -112,6 +113,7 @@ while ( i < l ) { // if this is a child row, continue to the next row (as buildCache()) + // eslint-disable-next-line no-jquery/no-class-state if ( rows[ rowIndex ] && !$( rows[ rowIndex ] ).hasClass( config.cssChildRow ) ) { if ( rowIndex !== lastRowIndex ) { lastRowIndex = rowIndex; @@ -216,6 +218,7 @@ // if this is a child row, add it to the last row's children and // continue to the next row + // eslint-disable-next-line no-jquery/no-class-state if ( $row.hasClass( config.cssChildRow ) ) { cache.row[ cache.row.length - 1 ] = cache.row[ cache.row.length - 1 ].add( $row ); // go to the next for loop @@ -378,6 +381,7 @@ $cell = $( this ); columns = []; + // eslint-disable-next-line no-jquery/no-class-state if ( !$cell.hasClass( config.unsortableClass ) ) { $cell .addClass( config.cssHeader ) @@ -715,6 +719,7 @@ $row = $rows.eq( i ); // if this is a child row, continue to the next row (as buildCache()) + // eslint-disable-next-line no-jquery/no-class-state if ( $row.hasClass( config.cssChildRow ) ) { // go to the next for loop continue; diff --git a/resources/src/jquery/jquery.confirmable.js b/resources/src/jquery/jquery.confirmable.js index 08bb601acc..70c32b92b4 100644 --- a/resources/src/jquery/jquery.confirmable.js +++ b/resources/src/jquery/jquery.confirmable.js @@ -88,6 +88,7 @@ sideMargin = 'marginLeft'; } + // eslint-disable-next-line no-jquery/no-class-state if ( $element.hasClass( 'jquery-confirmable-element' ) ) { $wrapper = $element.closest( '.jquery-confirmable-wrapper' ); $interface = $wrapper.find( '.jquery-confirmable-interface' ); diff --git a/resources/src/jquery/jquery.makeCollapsible.js b/resources/src/jquery/jquery.makeCollapsible.js index b9c13f03fd..20bd405038 100644 --- a/resources/src/jquery/jquery.makeCollapsible.js +++ b/resources/src/jquery/jquery.makeCollapsible.js @@ -122,6 +122,7 @@ if ( options.wasCollapsed !== undefined ) { wasCollapsed = options.wasCollapsed; } else { + // eslint-disable-next-line no-jquery/no-class-state wasCollapsed = $collapsible.hasClass( 'mw-collapsed' ); } @@ -338,6 +339,7 @@ } ); // Initial state + // eslint-disable-next-line no-jquery/no-class-state if ( options.collapsed || $collapsible.hasClass( 'mw-collapsed' ) ) { // One toggler can hook to multiple elements, and one element can have // multiple togglers. This is the sanest way to handle that. diff --git a/resources/src/jquery/jquery.suggestions.js b/resources/src/jquery/jquery.suggestions.js index 5111295b27..f4aea727e9 100644 --- a/resources/src/jquery/jquery.suggestions.js +++ b/resources/src/jquery/jquery.suggestions.js @@ -170,6 +170,7 @@ context.data.prevText = ''; } else if ( val !== context.data.prevText || + // eslint-disable-next-line no-jquery/no-sizzle !context.data.$container.is( ':visible' ) ) { context.data.prevText = val; @@ -508,6 +509,7 @@ */ function keypress( e, context, key ) { var selected, + // eslint-disable-next-line no-jquery/no-sizzle wasVisible = context.data.$container.is( ':visible' ), preventDefault = false; diff --git a/resources/src/mediawiki.action/mediawiki.action.history.js b/resources/src/mediawiki.action/mediawiki.action.history.js index e63810805b..5b43847aa0 100644 --- a/resources/src/mediawiki.action/mediawiki.action.history.js +++ b/resources/src/mediawiki.action/mediawiki.action.history.js @@ -80,15 +80,21 @@ $( function () { $copyAction = $copyForm.find( '> [name="action"]' ); // Remove action=historysubmit and ids[..]=.. + // eslint-disable-next-line no-jquery/no-class-state if ( $historySubmitter.hasClass( 'mw-history-compareselectedversions-button' ) ) { $copyAction.remove(); $copyForm.find( 'input[name^="ids["]:checked' ).prop( 'checked', false ); // Remove diff=&oldid=, change action=historysubmit to revisiondelete, remove revisiondelete - } else if ( $historySubmitter.hasClass( 'mw-history-revisiondelete-button' ) || - $historySubmitter.hasClass( 'mw-history-editchangetags-button' ) ) { + } else if ( + // eslint-disable-next-line no-jquery/no-class-state + $historySubmitter.hasClass( 'mw-history-revisiondelete-button' ) || + // eslint-disable-next-line no-jquery/no-class-state + $historySubmitter.hasClass( 'mw-history-editchangetags-button' ) + ) { $copyRadios.remove(); $copyAction.val( $historySubmitter.attr( 'name' ) ); + // eslint-disable-next-line no-jquery/no-sizzle $copyForm.find( ':submit' ).remove(); } diff --git a/resources/src/mediawiki.action/mediawiki.action.view.metadata.js b/resources/src/mediawiki.action/mediawiki.action.view.metadata.js index 393846d07b..4db8445cfb 100644 --- a/resources/src/mediawiki.action/mediawiki.action.view.metadata.js +++ b/resources/src/mediawiki.action/mediawiki.action.view.metadata.js @@ -30,6 +30,7 @@ e.type === 'click' || e.type === 'keypress' && e.which === 13 ) { + // eslint-disable-next-line no-jquery/no-class-state if ( $table.hasClass( 'collapsed' ) ) { // From collapsed to expanded. Button will now collapse. $( this ).text( collapseText ); @@ -37,6 +38,7 @@ // From expanded to collapsed. Button will now expand. $( this ).text( expandText ); } + // eslint-disable-next-line no-jquery/no-class-state $table.toggleClass( 'collapsed' ); } } ); diff --git a/resources/src/mediawiki.htmlform.checker.js b/resources/src/mediawiki.htmlform.checker.js index ecaddd8041..674584b14a 100644 --- a/resources/src/mediawiki.htmlform.checker.js +++ b/resources/src/mediawiki.htmlform.checker.js @@ -171,6 +171,7 @@ }; if ( $oldErrorBox !== $errorBox && + // eslint-disable-next-line no-jquery/no-class-state ( $oldErrorBox.hasClass( 'error' ) || $oldErrorBox.hasClass( 'warning' ) ) ) { // eslint-disable-next-line no-jquery/no-slide diff --git a/resources/src/mediawiki.htmlform/cloner.js b/resources/src/mediawiki.htmlform/cloner.js index 8ead7a4a2c..99eebae30b 100644 --- a/resources/src/mediawiki.htmlform/cloner.js +++ b/resources/src/mediawiki.htmlform/cloner.js @@ -37,12 +37,14 @@ var $element = $( this ), deleteButton; + // eslint-disable-next-line no-jquery/no-class-state if ( $element.hasClass( 'oo-ui-widget' ) ) { deleteButton = OO.ui.infuse( $element ); deleteButton.on( 'click', function () { deleteButton.$element.closest( 'li.mw-htmlform-cloner-li' ).remove(); } ); } else { + // eslint-disable-next-line no-jquery/no-sizzle $element.filter( ':input' ).on( 'click', function ( e ) { e.preventDefault(); $( this ).closest( 'li.mw-htmlform-cloner-li' ).remove(); @@ -50,12 +52,14 @@ } } ); + // eslint-disable-next-line no-jquery/no-class-state if ( $createElement.hasClass( 'oo-ui-widget' ) ) { createButton = OO.ui.infuse( $createElement ); createButton.on( 'click', function () { appendToCloner( createButton.$element ); } ); } else { + // eslint-disable-next-line no-jquery/no-sizzle $createElement.filter( ':input' ).on( 'click', function ( e ) { e.preventDefault(); diff --git a/resources/src/mediawiki.page.watch.ajax.js b/resources/src/mediawiki.page.watch.ajax.js index c56aadac55..f550a91516 100644 --- a/resources/src/mediawiki.page.watch.ajax.js +++ b/resources/src/mediawiki.page.watch.ajax.js @@ -131,6 +131,7 @@ $link = $( this ); + // eslint-disable-next-line no-jquery/no-class-state if ( $link.hasClass( 'loading' ) ) { return; } diff --git a/resources/src/mediawiki.rcfilters/ui/ChangesListWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/ChangesListWrapperWidget.js index 78cd8f4e62..1a5ae6cd3e 100644 --- a/resources/src/mediawiki.rcfilters/ui/ChangesListWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/ChangesListWrapperWidget.js @@ -262,6 +262,7 @@ ChangesListWrapperWidget.prototype.updateEnhancedParentHighlight = function () { // Collect the relevant classes from the first nested child firstChildClasses = activeHighlightClasses.filter( function ( className ) { + // eslint-disable-next-line no-jquery/no-class-state return $table.find( 'tr:nth-child(2)' ).hasClass( className ); } ); // Filter the non-head rows and see if they all have the same classes @@ -271,6 +272,7 @@ ChangesListWrapperWidget.prototype.updateEnhancedParentHighlight = function () { $this = $( this ); classesInThisRow = activeHighlightClasses.filter( function ( className ) { + // eslint-disable-next-line no-jquery/no-class-state return $this.hasClass( className ); } ); diff --git a/resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js b/resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js index ab75653db7..3429590294 100644 --- a/resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js @@ -711,6 +711,7 @@ FilterTagMultiselectWidget.prototype.createTagItemWidget = function ( data ) { FilterTagMultiselectWidget.prototype.emphasize = function () { if ( + // eslint-disable-next-line no-jquery/no-class-state !this.$handle.hasClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-animate' ) ) { this.$handle diff --git a/resources/src/mediawiki.searchSuggest/searchSuggest.js b/resources/src/mediawiki.searchSuggest/searchSuggest.js index df12b2e046..ee70b71b35 100644 --- a/resources/src/mediawiki.searchSuggest/searchSuggest.js +++ b/resources/src/mediawiki.searchSuggest/searchSuggest.js @@ -198,6 +198,7 @@ .text( query ); } + // eslint-disable-next-line no-jquery/no-class-state if ( $el.parent().hasClass( 'mw-searchSuggest-link' ) ) { $el.parent().attr( 'href', formData.baseHref + $.param( formData.linkParams ) + '&fulltext=1' ); } else { diff --git a/resources/src/mediawiki.special.import.js b/resources/src/mediawiki.special.import.js index bc8ca37f96..6a1d66ab34 100644 --- a/resources/src/mediawiki.special.import.js +++ b/resources/src/mediawiki.special.import.js @@ -6,6 +6,7 @@ function updateImportSubprojectList() { var $projectField = $( '#mw-import-table-interwiki #interwiki' ), $subprojectField = $projectField.parent().find( '#subproject' ), + // eslint-disable-next-line no-jquery/no-sizzle $selected = $projectField.find( ':selected' ), oldValue = $subprojectField.val(), option, options; diff --git a/resources/src/mediawiki.special.preferences.ooui/confirmClose.js b/resources/src/mediawiki.special.preferences.ooui/confirmClose.js index 55d7ce93cc..1eeedfbf41 100644 --- a/resources/src/mediawiki.special.preferences.ooui/confirmClose.js +++ b/resources/src/mediawiki.special.preferences.ooui/confirmClose.js @@ -10,6 +10,7 @@ // (This function could be changed to infuse and check OOUI widgets, but that would only make it // slower and more complicated. It works fine to treat them as HTML elements.) function isPrefsChanged() { + // eslint-disable-next-line no-jquery/no-sizzle var inputs = $( '#mw-prefs-form :input[name]' ), input, $input, inputType, index, optIndex, diff --git a/resources/src/mediawiki.special.unwatchedPages/unwatchedPages.js b/resources/src/mediawiki.special.unwatchedPages/unwatchedPages.js index 53617ca494..abc8d7b68f 100644 --- a/resources/src/mediawiki.special.unwatchedPages/unwatchedPages.js +++ b/resources/src/mediawiki.special.unwatchedPages/unwatchedPages.js @@ -17,6 +17,7 @@ mw.loader.load( 'mediawiki.notification' ); // Use the class to determine whether to watch or unwatch + // eslint-disable-next-line no-jquery/no-class-state if ( !$subjectLink.hasClass( 'mw-watched-item' ) ) { $link.text( mw.msg( 'watching' ) ); promise = api.watch( title ).done( function () { diff --git a/resources/src/mediawiki.special.watchlist/watchlist.js b/resources/src/mediawiki.special.watchlist/watchlist.js index 2d60b1db4c..e8373c3d77 100644 --- a/resources/src/mediawiki.special.watchlist/watchlist.js +++ b/resources/src/mediawiki.special.watchlist/watchlist.js @@ -100,6 +100,7 @@ // Depending on whether we are watching or unwatching, for each entry of the page (and its associated page i.e. Talk), // change the text, tooltip, and non-JS href of the (un)watch button, and update the styling of the watchlist entry. + // eslint-disable-next-line no-jquery/no-class-state if ( $unwatchLink.hasClass( 'mw-unwatch-link' ) ) { api.unwatch( pageTitle ) .done( function () { diff --git a/resources/src/mediawiki.toc/toc.js b/resources/src/mediawiki.toc/toc.js index c1066f2c51..8c69047cb8 100644 --- a/resources/src/mediawiki.toc/toc.js +++ b/resources/src/mediawiki.toc/toc.js @@ -13,6 +13,7 @@ // Hide/show the table of contents element function toggleToc() { + // eslint-disable-next-line no-jquery/no-class-state if ( $this.hasClass( 'tochidden' ) ) { // FIXME: Use CSS transitions // eslint-disable-next-line no-jquery/no-slide diff --git a/resources/src/mediawiki.util.js b/resources/src/mediawiki.util.js index 56bfc42668..66c1fe74d1 100644 --- a/resources/src/mediawiki.util.js +++ b/resources/src/mediawiki.util.js @@ -329,6 +329,7 @@ $portlet.removeClass( 'emptyPortlet' ); // Setup the list item (and a span if $portlet is a Vector tab) + // eslint-disable-next-line no-jquery/no-class-state if ( $portlet.hasClass( 'vectorTabs' ) ) { item = $( '
  • ' ).append( $( '' ).append( link )[ 0 ] )[ 0 ]; } else { diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js index 9fc7edb70b..2e78ba7083 100644 --- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js +++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js @@ -431,6 +431,7 @@ mw.widgets.MediaSearchWidget.prototype.runLayoutQueue = function () { var i, len; + // eslint-disable-next-line no-jquery/no-sizzle if ( this.$element.is( ':visible' ) ) { for ( i = 0, len = this.layoutQueue.length; i < len; i++ ) { this.layoutQueue.pop()(); diff --git a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js index c25db2f405..5ca39d5d45 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js @@ -579,6 +579,7 @@ if ( !this.isDisabled() && e.which === 1 && + // eslint-disable-next-line no-jquery/no-class-state $( e.target ).hasClass( targetClass ) ) { this.deactivate( true ); diff --git a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js index e67af10ab5..54f6b4e680 100644 --- a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js @@ -217,6 +217,7 @@ '
    ' + loremIpsum + '
    ' ); + // eslint-disable-next-line no-jquery/no-class-state assert.assertTrue( $collapsible.hasClass( 'mw-collapsible' ), 'mw-collapsible class present' ); } ); @@ -226,6 +227,7 @@ { collapsed: true } ); + // eslint-disable-next-line no-jquery/no-class-state assert.assertTrue( $collapsible.hasClass( 'mw-collapsed' ), 'mw-collapsed class present' ); } ); @@ -388,9 +390,13 @@ .appendTo( '#qunit-fixture' ).makeCollapsible(); $collapsible1.on( 'afterCollapse.mw-collapsible', function () { + // eslint-disable-next-line no-jquery/no-class-state assert.assertTrue( $collapsible1.hasClass( 'mw-collapsed' ), 'after collapsing: parent is collapsed' ); + // eslint-disable-next-line no-jquery/no-class-state assert.assertFalse( $collapsible2.hasClass( 'mw-collapsed' ), 'after collapsing: child is not collapsed' ); + // eslint-disable-next-line no-jquery/no-class-state assert.assertTrue( $collapsible1.find( '> .mw-collapsible-toggle' ).hasClass( 'mw-collapsible-toggle-collapsed' ) ); + // eslint-disable-next-line no-jquery/no-class-state assert.assertFalse( $collapsible2.find( '> .mw-collapsible-toggle' ).hasClass( 'mw-collapsible-toggle-collapsed' ) ); } ).find( '> .mw-collapsible-toggle a' ).trigger( 'click' ); } ); diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js index 2711ddfe4e..476b5058b0 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js @@ -634,6 +634,7 @@ $table.find( 'tr > th' ).eq( 1 ).trigger( 'click' ); assert.strictEqual( + // eslint-disable-next-line no-jquery/no-class-state $cell.hasClass( 'headerSortUp' ) || $cell.hasClass( 'headerSortDown' ), false, 'after sort: no class headerSortUp or headerSortDown' @@ -751,6 +752,7 @@ mw.config.set( 'wgPageContentLanguage', 'sv' ); $table.tablesorter(); + // eslint-disable-next-line no-jquery/no-sizzle $table.find( '.headerSort:eq(0)' ).trigger( 'click' ); } ); diff --git a/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js b/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js index aafcd5b217..738392a65f 100644 --- a/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js +++ b/tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js @@ -33,14 +33,18 @@ // TODO abstract the double strictEquals // At first checkboxes are hidden + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $( '#nsinvert' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true ); + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $( '#nsassociated' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true ); // Initiate the recentchanges module rc.init(); // By default + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $( '#nsinvert' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true ); + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $( '#nsassociated' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true ); // select second option... @@ -50,7 +54,9 @@ $( '#namespace' ).trigger( 'change' ); // ... and checkboxes should be visible again + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $( '#nsinvert' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), false ); + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $( '#nsassociated' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), false ); // select first option ( 'all' namespace)... @@ -59,7 +65,9 @@ $( '#namespace' ).trigger( 'change' ); // ... and checkboxes should now be hidden + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $( '#nsinvert' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true ); + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $( '#nsassociated' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true ); // DOM cleanup diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js index 6dcdb445fe..6dab026b43 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js @@ -26,10 +26,12 @@ assert.strictEqual( $toggleLink.length, 1, 'Toggle link is added to the table of contents' ); + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $toc.hasClass( 'tochidden' ), false, 'The table of contents is now visible' ); $toggleLink.trigger( 'click' ); return $tocList.promise().then( function () { + // eslint-disable-next-line no-jquery/no-class-state assert.strictEqual( $toc.hasClass( 'tochidden' ), true, 'The table of contents is now hidden' ); $toggleLink.trigger( 'click' ); return $tocList.promise(); diff --git a/tests/selenium/.eslintrc.json b/tests/selenium/.eslintrc.json index dd766c85fb..21d230e004 100644 --- a/tests/selenium/.eslintrc.json +++ b/tests/selenium/.eslintrc.json @@ -11,6 +11,7 @@ "mw": false }, "rules": { - "no-console": 0 + "no-console": "off", + "prefer-template": "off" } } diff --git a/tests/selenium/pageobjects/history.page.js b/tests/selenium/pageobjects/history.page.js index 52d614fba7..730eff36c4 100644 --- a/tests/selenium/pageobjects/history.page.js +++ b/tests/selenium/pageobjects/history.page.js @@ -29,7 +29,7 @@ class HistoryPage extends Page { } vandalizePage( name, content ) { - let vandalUsername = 'Evil_' + browser.options.username; + const vandalUsername = 'Evil_' + browser.options.username; browser.call( function () { return Api.edit( name, content ); diff --git a/tests/selenium/specs/page.js b/tests/selenium/specs/page.js index 93e0b87758..148001d2fb 100644 --- a/tests/selenium/specs/page.js +++ b/tests/selenium/specs/page.js @@ -48,7 +48,7 @@ describe( 'Page', function () { } ); it( 'should be re-creatable', function () { - let initialContent = Util.getTestString( 'initialContent-' ); + const initialContent = Util.getTestString( 'initialContent-' ); // create browser.call( function () { @@ -75,7 +75,7 @@ describe( 'Page', function () { } ); // edit - let editContent = Util.getTestString( 'editContent-' ); + const editContent = Util.getTestString( 'editContent-' ); EditPage.edit( name, editContent ); // check diff --git a/tests/selenium/wdio-mediawiki/Api.js b/tests/selenium/wdio-mediawiki/Api.js index 7947ff504c..6b674b99f9 100644 --- a/tests/selenium/wdio-mediawiki/Api.js +++ b/tests/selenium/wdio-mediawiki/Api.js @@ -22,7 +22,7 @@ module.exports = { password = browser.options.password, baseUrl = browser.options.baseUrl ) { - let bot = new MWBot(); + const bot = new MWBot(); return bot.loginGetEditToken( { apiUrl: `${baseUrl}/api.php`, @@ -43,7 +43,7 @@ module.exports = { * @return {Object} Promise for API action=delete response data. */ delete( title, reason ) { - let bot = new MWBot(); + const bot = new MWBot(); return bot.loginGetEditToken( { apiUrl: `${browser.options.baseUrl}/api.php`, @@ -64,7 +64,7 @@ module.exports = { * @return {Object} Promise for API action=createaccount response data. */ createAccount( username, password ) { - let bot = new MWBot(); + const bot = new MWBot(); // Log in as admin return bot.loginGetCreateaccountToken( { @@ -94,7 +94,7 @@ module.exports = { * @return {Object} Promise for API action=block response data. */ blockUser( username, expiry ) { - let bot = new MWBot(); + const bot = new MWBot(); // Log in as admin return bot.loginGetEditToken( { @@ -122,7 +122,7 @@ module.exports = { * @return {Object} Promise for API action=unblock response data. */ unblockUser( username ) { - let bot = new MWBot(); + const bot = new MWBot(); // Log in as admin return bot.loginGetEditToken( { diff --git a/tests/selenium/wdio-mediawiki/RunJobs.js b/tests/selenium/wdio-mediawiki/RunJobs.js index 070ad56498..2e675c027f 100644 --- a/tests/selenium/wdio-mediawiki/RunJobs.js +++ b/tests/selenium/wdio-mediawiki/RunJobs.js @@ -3,7 +3,7 @@ const MWBot = require( 'mwbot' ), MAINPAGE_REQUESTS_MAX_RUNS = 10; // (arbitrary) safe-guard against endless execution function getJobCount() { - let bot = new MWBot( { + const bot = new MWBot( { apiUrl: `${browser.options.baseUrl}/api.php` } ); return bot.request( { @@ -20,7 +20,7 @@ function log( message ) { } function runThroughMainPageRequests( runCount = 1 ) { - let page = new Page(); + const page = new Page(); log( `through requests to the main page (run ${runCount}).` ); page.openTitle( '' ); diff --git a/tests/selenium/wdio.conf.js b/tests/selenium/wdio.conf.js index 56e4934b7c..214c25add9 100644 --- a/tests/selenium/wdio.conf.js +++ b/tests/selenium/wdio.conf.js @@ -160,7 +160,7 @@ exports.config = { beforeTest: function ( test ) { if ( process.env.DISPLAY && process.env.DISPLAY.startsWith( ':' ) ) { var logBuffer; - let videoPath = filePath( test, logPath, 'mp4' ); + const videoPath = filePath( test, logPath, 'mp4' ); const { spawn } = require( 'child_process' ); ffmpeg = spawn( 'ffmpeg', [ '-f', 'x11grab', // grab the X11 display @@ -173,7 +173,7 @@ exports.config = { ] ); logBuffer = function ( buffer, prefix ) { - let lines = buffer.toString().trim().split( '\n' ); + const lines = buffer.toString().trim().split( '\n' ); lines.forEach( function ( line ) { console.log( prefix + line ); } ); @@ -215,7 +215,7 @@ exports.config = { return; } // save screenshot - let screenshotfile = filePath( test, logPath, 'png' ); + const screenshotfile = filePath( test, logPath, 'png' ); browser.saveScreenshot( screenshotfile ); console.log( '\n\tScreenshot location:', screenshotfile, '\n' ); } -- 2.20.1