diff options
47 files changed, 110 insertions, 114 deletions
diff --git a/resources/src/.eslintrc.json b/resources/src/.eslintrc.json index d7947909902c..65809919efb7 100644 --- a/resources/src/.eslintrc.json +++ b/resources/src/.eslintrc.json @@ -10,15 +10,14 @@ "module": "readonly" }, "rules": { - "es-x/no-promise-prototype-finally": "off", "max-len": "off", + "es-x/no-promise-prototype-finally": "off", "no-jquery/no-done-fail": "off", "no-jquery/no-global-selector": "off", "jsdoc/no-undefined-types": [ 1, { "definedTypes": [ "Hooks" ] - } ], - "unicorn/prefer-includes": "off" + } ] } } diff --git a/resources/src/jquery.tablesorter/jquery.tablesorter.js b/resources/src/jquery.tablesorter/jquery.tablesorter.js index 868e4e1950b2..a961ee29fb8d 100644 --- a/resources/src/jquery.tablesorter/jquery.tablesorter.js +++ b/resources/src/jquery.tablesorter/jquery.tablesorter.js @@ -307,7 +307,7 @@ function uniqueElements( array ) { const uniques = []; array.forEach( ( elem ) => { - if ( elem !== undefined && uniques.indexOf( elem ) === -1 ) { + if ( elem !== undefined && !uniques.includes( elem ) ) { uniques.push( elem ); } } ); diff --git a/resources/src/jquery/jquery.suggestions.js b/resources/src/jquery/jquery.suggestions.js index d8f780ecc695..2586f407b1ea 100644 --- a/resources/src/jquery/jquery.suggestions.js +++ b/resources/src/jquery/jquery.suggestions.js @@ -279,7 +279,7 @@ expandFrom = 'left'; // Catch invalid values, default to 'auto' - } else if ( [ 'left', 'right', 'start', 'end', 'auto' ].indexOf( expandFrom ) === -1 ) { + } else if ( ![ 'left', 'right', 'start', 'end', 'auto' ].includes( expandFrom ) ) { expandFrom = 'auto'; } @@ -754,7 +754,7 @@ ]; if ( context.data.keypressedCount === 0 && e.which === context.data.keypressed && - allowed.indexOf( e.which ) !== -1 + allowed.includes( e.which ) ) { keypress( e, context, context.data.keypressed ); } diff --git a/resources/src/jquery/jquery.textSelection.js b/resources/src/jquery/jquery.textSelection.js index 3ef27b31ad97..623d30e35eff 100644 --- a/resources/src/jquery/jquery.textSelection.js +++ b/resources/src/jquery/jquery.textSelection.js @@ -272,7 +272,7 @@ } else { $( this ).textSelection( 'replaceSelection', insertText ); } - if ( isSample && options.selectPeri && ( !options.splitlines || ( options.splitlines && selText.indexOf( '\n' ) === -1 ) ) ) { + if ( isSample && options.selectPeri && ( !options.splitlines || ( options.splitlines && !selText.includes( '\n' ) ) ) ) { $( this ).textSelection( 'setSelection', { start: startPos + pre.length, end: startPos + pre.length + selText.length diff --git a/resources/src/mediawiki.ForeignApi/mediawiki.ForeignApi.core.js b/resources/src/mediawiki.ForeignApi/mediawiki.ForeignApi.core.js index f2437d7705e6..b4625f182e59 100644 --- a/resources/src/mediawiki.ForeignApi/mediawiki.ForeignApi.core.js +++ b/resources/src/mediawiki.ForeignApi/mediawiki.ForeignApi.core.js @@ -112,7 +112,7 @@ module.exports = ( function () { let url = ( ajaxOptions && ajaxOptions.url ) || this.defaults.ajax.url; const origin = ( parameters && parameters.origin ) || this.defaults.parameters.origin; if ( origin !== undefined ) { - url += ( url.indexOf( '?' ) !== -1 ? '&' : '?' ) + + url += ( url.includes( '?' ) ? '&' : '?' ) + 'origin=' + encodeURIComponent( origin ); } newAjaxOptions = Object.assign( {}, ajaxOptions, { url: url } ); diff --git a/resources/src/mediawiki.Title/Title.js b/resources/src/mediawiki.Title/Title.js index 85742234b269..33e36cca8d69 100644 --- a/resources/src/mediawiki.Title/Title.js +++ b/resources/src/mediawiki.Title/Title.js @@ -224,7 +224,7 @@ const mwString = require( 'mediawiki.String' ), // Trim underscores .replace( rUnderscoreTrim, '' ); - if ( title.indexOf( '\uFFFD' ) !== -1 ) { + if ( title.includes( '\uFFFD' ) ) { // Contained illegal UTF-8 sequences or forbidden Unicode chars. // Commonly occurs when the text was obtained using the `URL` API, and the 'title' parameter // was using a legacy 8-bit encoding, for example: @@ -293,12 +293,12 @@ const mwString = require( 'mediawiki.String' ), // Disallow titles that browsers or servers might resolve as directory navigation if ( - title.indexOf( '.' ) !== -1 && ( + title.includes( '.' ) && ( title === '.' || title === '..' || title.indexOf( './' ) === 0 || title.indexOf( '../' ) === 0 || - title.indexOf( '/./' ) !== -1 || - title.indexOf( '/../' ) !== -1 || + title.includes( '/./' ) || + title.includes( '/../' ) || title.slice( -2 ) === '/.' || title.slice( -3 ) === '/..' ) @@ -307,7 +307,7 @@ const mwString = require( 'mediawiki.String' ), } // Disallow magic tilde sequence - if ( title.indexOf( '~~~' ) !== -1 ) { + if ( title.includes( '~~~' ) ) { return false; } @@ -656,7 +656,7 @@ Title.isTalkNamespace = function ( namespaceId ) { */ Title.wantSignaturesNamespace = function ( namespaceId ) { return Title.isTalkNamespace( namespaceId ) || - mw.config.get( 'wgExtraSignatureNamespaces' ).indexOf( namespaceId ) !== -1; + mw.config.get( 'wgExtraSignatureNamespaces' ).includes( namespaceId ); }; /** @@ -885,7 +885,7 @@ Title.prototype = /** @lends mw.Title.prototype */ { */ getMain: function () { if ( - mw.config.get( 'wgCaseSensitiveNamespaces' ).indexOf( this.namespace ) !== -1 || + mw.config.get( 'wgCaseSensitiveNamespaces' ).includes( this.namespace ) || !this.title.length ) { return this.title; diff --git a/resources/src/mediawiki.Upload.BookletLayout/BookletLayout.js b/resources/src/mediawiki.Upload.BookletLayout/BookletLayout.js index d4acf316a3e7..508dc80d520d 100644 --- a/resources/src/mediawiki.Upload.BookletLayout/BookletLayout.js +++ b/resources/src/mediawiki.Upload.BookletLayout/BookletLayout.js @@ -190,7 +190,7 @@ ( api ) => api.getUserInfo().then( ( userInfo ) => { this.setPage( 'upload' ); - if ( userInfo.rights.indexOf( 'upload' ) === -1 ) { + if ( !userInfo.rights.includes( 'upload' ) ) { if ( !mw.user.isNamed() ) { this.getPage( 'upload' ).$element.msg( 'apierror-mustbeloggedin', mw.msg( 'action-upload' ) ); } else { diff --git a/resources/src/mediawiki.action.edit/stash.js b/resources/src/mediawiki.action.edit/stash.js index c292c04053c0..43430c8d37dc 100644 --- a/resources/src/mediawiki.action.edit/stash.js +++ b/resources/src/mediawiki.action.edit/stash.js @@ -152,7 +152,7 @@ $( () => { mw.util.getParamValue( 'undo' ) !== null || // Pressing "show changes" and "preview" also signify that the user will // probably save the page soon - [ 'preview', 'diff' ].indexOf( $form.find( '#mw-edit-mode' ).val() ) > -1 + [ 'preview', 'diff' ].includes( $form.find( '#mw-edit-mode' ).val() ) ) { checkStash(); } diff --git a/resources/src/mediawiki.action/mediawiki.action.protect.js b/resources/src/mediawiki.action/mediawiki.action.protect.js index 8edcd4322b2b..d56f1410c020 100644 --- a/resources/src/mediawiki.action/mediawiki.action.protect.js +++ b/resources/src/mediawiki.action/mediawiki.action.protect.js @@ -106,7 +106,7 @@ } ); if ( cascadeCheckbox ) { levelSelectors.some( ( widget ) => { - if ( cascadeableLevels.indexOf( widget.getValue() ) === -1 ) { + if ( !cascadeableLevels.includes( widget.getValue() ) ) { cascadeCheckbox.setSelected( false ).setDisabled( true ); return true; } diff --git a/resources/src/mediawiki.api/index.js b/resources/src/mediawiki.api/index.js index 34d1eb2b4e45..3579e88781e4 100644 --- a/resources/src/mediawiki.api/index.js +++ b/resources/src/mediawiki.api/index.js @@ -101,7 +101,7 @@ 'import', 'options' ]; - if ( csrfActions.indexOf( type ) !== -1 ) { + if ( csrfActions.includes( type ) ) { return 'csrf'; } return type; @@ -188,7 +188,7 @@ for ( key in parameters ) { // Multiple values are pipe-separated if ( Array.isArray( parameters[ key ] ) ) { - if ( !useUS || parameters[ key ].join( '' ).indexOf( '|' ) === -1 ) { + if ( !useUS || !parameters[ key ].join( '' ).includes( '|' ) ) { parameters[ key ] = parameters[ key ].join( '|' ); } else { parameters[ key ] = '\x1f' + parameters[ key ].join( '\x1f' ); @@ -297,7 +297,7 @@ ajaxOptions.headers = ajaxOptions.headers || {}; const lowercaseHeaders = Object.keys( ajaxOptions.headers || {} ).map( ( k ) => k.toLowerCase() ); - if ( lowercaseHeaders.indexOf( 'api-user-agent' ) === -1 ) { + if ( !lowercaseHeaders.includes( 'api-user-agent' ) ) { ajaxOptions.headers[ 'Api-User-Agent' ] = this.defaults.userAgent; } diff --git a/resources/src/mediawiki.api/options.js b/resources/src/mediawiki.api/options.js index 4ef4ecd82b4f..8958e7e8ce2e 100644 --- a/resources/src/mediawiki.api/options.js +++ b/resources/src/mediawiki.api/options.js @@ -68,11 +68,11 @@ let bundleable; // Can we bundle this option, or does it need a separate request? if ( this.defaults.useUS ) { - bundleable = name.indexOf( '=' ) === -1; + bundleable = !name.includes( '=' ); } else { bundleable = - ( value === null || value.indexOf( '|' ) === -1 ) && - ( name.indexOf( '|' ) === -1 && name.indexOf( '=' ) === -1 ); + ( value === null || !value.includes( '|' ) ) && + ( !name.includes( '|' ) && !name.includes( '=' ) ); } if ( bundleable ) { diff --git a/resources/src/mediawiki.base/mediawiki.base.js b/resources/src/mediawiki.base/mediawiki.base.js index 3f3bca331f95..d3041288b928 100644 --- a/resources/src/mediawiki.base/mediawiki.base.js +++ b/resources/src/mediawiki.base/mediawiki.base.js @@ -261,7 +261,7 @@ mw.inspect = function ( ...reports ) { * @return {string} Transformed format string */ mw.internalDoTransformFormatForQqx = function ( formatString, parameters ) { - if ( formatString.indexOf( '$*' ) !== -1 ) { + if ( formatString.includes( '$*' ) ) { let replacement = ''; if ( parameters.length ) { replacement = ': ' + parameters.map( ( _, i ) => '$' + ( i + 1 ) ).join( ', ' ); diff --git a/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js b/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js index 8c297e48bc69..77baea345c63 100644 --- a/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js +++ b/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js @@ -715,7 +715,7 @@ Parser.prototype = { function isAllowedHtml( startTagName, endTagName, attributes ) { startTagName = startTagName.toLowerCase(); endTagName = endTagName.toLowerCase(); - if ( startTagName !== endTagName || settings.allowedHtmlElements.indexOf( startTagName ) === -1 ) { + if ( startTagName !== endTagName || !settings.allowedHtmlElements.includes( startTagName ) ) { return false; } @@ -724,8 +724,8 @@ Parser.prototype = { let attributeName; for ( let i = 0, len = attributes.length; i < len; i += 2 ) { attributeName = attributes[ i ]; - if ( settings.allowedHtmlCommonAttributes.indexOf( attributeName ) === -1 && - ( settings.allowedHtmlAttributesByElement[ startTagName ] || [] ).indexOf( attributeName ) === -1 ) { + if ( !settings.allowedHtmlCommonAttributes.includes( attributeName ) && + !( settings.allowedHtmlAttributesByElement[ startTagName ] || [] ).includes( attributeName ) ) { return false; } if ( attributeName === 'style' && attributes[ i + 1 ].search( badStyle ) !== -1 ) { diff --git a/resources/src/mediawiki.language/mediawiki.language.numbers.js b/resources/src/mediawiki.language/mediawiki.language.numbers.js index d3671e4403f9..6706c2ed54cb 100644 --- a/resources/src/mediawiki.language/mediawiki.language.numbers.js +++ b/resources/src/mediawiki.language/mediawiki.language.numbers.js @@ -97,7 +97,7 @@ } // Truncate whole - if ( patternDigits.indexOf( '#' ) === -1 && padLength ) { + if ( !patternDigits.includes( '#' ) && padLength ) { valueParts[ 0 ] = valueParts[ 0 ].slice( -padLength ); } } diff --git a/resources/src/mediawiki.messagePoster/WikitextMessagePoster.js b/resources/src/mediawiki.messagePoster/WikitextMessagePoster.js index 788113f11b32..41bc008e0e2d 100644 --- a/resources/src/mediawiki.messagePoster/WikitextMessagePoster.js +++ b/resources/src/mediawiki.messagePoster/WikitextMessagePoster.js @@ -33,7 +33,7 @@ mw.messagePoster.WikitextMessagePoster.super.prototype.post.call( this, subject, body, options ); // Add signature if needed - if ( body.indexOf( '~~~' ) === -1 ) { + if ( !body.includes( '~~~' ) ) { body += '\n\n~~~~'; } diff --git a/resources/src/mediawiki.page.ready/ready.js b/resources/src/mediawiki.page.ready/ready.js index b7f88fc19d3b..999230f66ce4 100644 --- a/resources/src/mediawiki.page.ready/ready.js +++ b/resources/src/mediawiki.page.ready/ready.js @@ -76,7 +76,7 @@ $( () => { // (these values correspond to @min-width-breakpoint-tablet and @min-width-breakpoint-desktop // See https://doc.wikimedia.org/codex/main/design-tokens/breakpoint.html if ( window.innerWidth >= 640 && window.innerWidth < 1120 && - content && content.indexOf( 'initial-scale' ) === -1 + content && !content.includes( 'initial-scale' ) ) { // Note: // - The `width` value must be equal to @min-width-breakpoint-desktop above diff --git a/resources/src/mediawiki.rcfilters/Controller.js b/resources/src/mediawiki.rcfilters/Controller.js index b5e29bd1724d..0af01dc29876 100644 --- a/resources/src/mediawiki.rcfilters/Controller.js +++ b/resources/src/mediawiki.rcfilters/Controller.js @@ -431,9 +431,9 @@ Controller.prototype.addNumberValuesToGroup = function ( groupData, arbitraryVal // the data ( !groupData.validate || groupData.validate( val ) ) && // but if that value isn't already in the definition - groupData.filters + !groupData.filters .map( ( filterData ) => String( filterData.name ) ) - .indexOf( String( val ) ) === -1 + .includes( String( val ) ) ) { // Add the filter information groupData.filters.push( this._createFilterDataFromNumber( diff --git a/resources/src/mediawiki.rcfilters/UriProcessor.js b/resources/src/mediawiki.rcfilters/UriProcessor.js index ae4f25d5f0e1..979bc7119fab 100644 --- a/resources/src/mediawiki.rcfilters/UriProcessor.js +++ b/resources/src/mediawiki.rcfilters/UriProcessor.js @@ -148,7 +148,7 @@ UriProcessor.prototype.getUnrecognizedParams = function ( params ) { // Extract unrecognized parameters for ( const paramName in this.filtersModel.getEmptyParameterState() ) { // Remove recognized params - if ( givenParamNames.indexOf( paramName ) > -1 ) { + if ( givenParamNames.includes( paramName ) ) { delete unrecognizedParams[ paramName ]; } } diff --git a/resources/src/mediawiki.rcfilters/dm/FilterGroup.js b/resources/src/mediawiki.rcfilters/dm/FilterGroup.js index 7e41aeff3c2a..c36e8dfbd2e6 100644 --- a/resources/src/mediawiki.rcfilters/dm/FilterGroup.js +++ b/resources/src/mediawiki.rcfilters/dm/FilterGroup.js @@ -700,7 +700,7 @@ FilterGroup.prototype.getFilterRepresentation = function ( paramRepresentation ) ) ? true : // Otherwise, the filter is selected only if it appears in the parameter values - paramValues.indexOf( filterItem.getParamName() ) > -1; + paramValues.includes( filterItem.getParamName() ); } ); } else if ( this.getType() === 'single_option' ) { // There is parameter that fits a single filter and if not, get the default @@ -951,7 +951,7 @@ FilterGroup.prototype.isVisible = function () { */ FilterGroup.prototype.setVisibleItems = function ( visibleItems ) { this.getItems().forEach( ( itemModel ) => { - itemModel.toggleVisible( visibleItems.indexOf( itemModel ) !== -1 ); + itemModel.toggleVisible( visibleItems.includes( itemModel ) ); } ); }; diff --git a/resources/src/mediawiki.rcfilters/dm/FilterItem.js b/resources/src/mediawiki.rcfilters/dm/FilterItem.js index 2f0ab6557540..1bd61a02f5b5 100644 --- a/resources/src/mediawiki.rcfilters/dm/FilterItem.js +++ b/resources/src/mediawiki.rcfilters/dm/FilterItem.js @@ -142,7 +142,7 @@ FilterItem.prototype.getStateMessage = function () { superset = this.getSuperset(); // For this message we need to collect the affecting superset affectingItems = this.getGroupModel().findSelectedItems( this ) - .filter( ( item ) => superset.indexOf( item.getName() ) !== -1 ) + .filter( ( item ) => superset.includes( item.getName() ) ) .map( ( item ) => mw.msg( 'quotation-marks', item.getLabel() ) ); messageKey = 'rcfilters-state-message-subset'; @@ -310,7 +310,7 @@ FilterItem.prototype.setSubset = function ( subset ) { * @return {boolean} Filter name is in the subset list */ FilterItem.prototype.existsInSubset = function ( filterName ) { - return this.subset.indexOf( filterName ) > -1; + return this.subset.includes( filterName ); }; /** diff --git a/resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js b/resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js index 639b82257391..d0f55396cbb8 100644 --- a/resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js +++ b/resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js @@ -858,7 +858,7 @@ FiltersViewModel.prototype.getCurrentlyUsedHighlightColors = function () { this.getHighlightedItems().forEach( ( filterItem ) => { const color = filterItem.getHighlightColor(); - if ( result.indexOf( color ) === -1 ) { + if ( !result.includes( color ) ) { result.push( color ); } } ); @@ -1039,7 +1039,7 @@ FiltersViewModel.prototype.findMatches = function ( query, returnFlat ) { ( // For tags, we want the parameter name to be included in the search view === 'tags' && - items[ i ].getParamName().toLowerCase().indexOf( query ) > -1 + items[ i ].getParamName().toLowerCase().includes( query ) ) ) { result[ items[ i ].getGroupName() ] = result[ items[ i ].getGroupName() ] || []; @@ -1054,13 +1054,13 @@ FiltersViewModel.prototype.findMatches = function ( query, returnFlat ) { const groupTitle = items[ i ].getGroupModel().getTitle(); if ( searchIsEmpty || - items[ i ].getLabel().toLowerCase().indexOf( query ) > -1 || - items[ i ].getDescription().toLowerCase().indexOf( query ) > -1 || - groupTitle.toLowerCase().indexOf( query ) > -1 || + items[ i ].getLabel().toLowerCase().includes( query ) || + items[ i ].getDescription().toLowerCase().includes( query ) || + groupTitle.toLowerCase().includes( query ) || ( // For tags, we want the parameter name to be included in the search view === 'tags' && - items[ i ].getParamName().toLowerCase().indexOf( query ) > -1 + items[ i ].getParamName().toLowerCase().includes( query ) ) ) { result[ items[ i ].getGroupName() ] = result[ items[ i ].getGroupName() ] || []; @@ -1198,7 +1198,7 @@ FiltersViewModel.prototype.setSearch = function ( searchQuery ) { // eslint-disable-next-line no-jquery/no-each-util $.each( this.getFilterGroups(), ( groupName, groupModel ) => { // Check if the group is visible at all - groupModel.toggleVisible( visibleGroupNames.indexOf( groupName ) !== -1 ); + groupModel.toggleVisible( visibleGroupNames.includes( groupName ) ); groupModel.setVisibleItems( visibleGroups[ groupName ] || [] ); } ); diff --git a/resources/src/mediawiki.rcfilters/dm/SavedQueriesModel.js b/resources/src/mediawiki.rcfilters/dm/SavedQueriesModel.js index 6276dd6e11c8..592e884a2637 100644 --- a/resources/src/mediawiki.rcfilters/dm/SavedQueriesModel.js +++ b/resources/src/mediawiki.rcfilters/dm/SavedQueriesModel.js @@ -230,7 +230,7 @@ SavedQueriesModel.prototype.addNewQuery = function ( label, fulldata, isDefault, // Split highlight/params // eslint-disable-next-line no-jquery/no-each-util $.each( data, ( param, value ) => { - if ( param !== 'highlight' && highlightParamNames.indexOf( param ) > -1 ) { + if ( param !== 'highlight' && highlightParamNames.includes( param ) ) { normalizedData.highlights[ param ] = value; } else { normalizedData.params[ param ] = value; diff --git a/resources/src/mediawiki.rcfilters/ui/ChangesListWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/ChangesListWrapperWidget.js index 4a9e17151e0f..41717c2a03ff 100644 --- a/resources/src/mediawiki.rcfilters/ui/ChangesListWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/ChangesListWrapperWidget.js @@ -327,7 +327,7 @@ ChangesListWrapperWidget.prototype.applyHighlight = function () { filters = []; $( this ).data( 'highlightedFilters', filters ); } - if ( filters.indexOf( filterItem.getLabel() ) === -1 ) { + if ( !filters.includes( filterItem.getLabel() ) ) { filters.push( filterItem.getLabel() ); } } ); diff --git a/resources/src/mediawiki.rcfilters/ui/MenuSelectWidget.js b/resources/src/mediawiki.rcfilters/ui/MenuSelectWidget.js index 49dfba27fc18..caf7e788dddf 100644 --- a/resources/src/mediawiki.rcfilters/ui/MenuSelectWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/MenuSelectWidget.js @@ -268,7 +268,7 @@ MenuSelectWidget.prototype.updateFooterVisibility = function ( currentView ) { data.$element.toggle( // This footer should only be shown if it is configured // for all views or for this specific view - !data.views || data.views.length === 0 || data.views.indexOf( currentView ) > -1 + !data.views || data.views.length === 0 || data.views.includes( currentView ) ); } ); }; diff --git a/resources/src/mediawiki.rcfilters/utils.js b/resources/src/mediawiki.rcfilters/utils.js index f53db4f9f522..89cf5dc6076e 100644 --- a/resources/src/mediawiki.rcfilters/utils.js +++ b/resources/src/mediawiki.rcfilters/utils.js @@ -14,7 +14,7 @@ module.exports = { elements = Array.isArray( elements ) ? elements : [ elements ]; elements.forEach( ( element ) => { - if ( arr.indexOf( element ) === -1 ) { + if ( !arr.includes( element ) ) { arr.push( element ); } } ); @@ -31,7 +31,7 @@ module.exports = { const result = []; supportsAll = supportsAll === undefined ? true : !!supportsAll; - if ( supportsAll && givenOptions.indexOf( 'all' ) > -1 ) { + if ( supportsAll && givenOptions.includes( 'all' ) ) { // If anywhere in the values there's 'all', we // treat it as if only 'all' was selected. // Example: param=valid1,valid2,all @@ -45,8 +45,8 @@ module.exports = { // Result: param=valid1,valid2 givenOptions.forEach( ( value ) => { if ( - legalOptions.indexOf( value ) > -1 && - result.indexOf( value ) === -1 + legalOptions.includes( value ) && + !result.includes( value ) ) { result.push( value ); } diff --git a/resources/src/mediawiki.searchSuggest/searchSuggest.js b/resources/src/mediawiki.searchSuggest/searchSuggest.js index 4d09439d8c7e..a890f4395059 100644 --- a/resources/src/mediawiki.searchSuggest/searchSuggest.js +++ b/resources/src/mediawiki.searchSuggest/searchSuggest.js @@ -92,7 +92,7 @@ const $form = context.config.$region.closest( 'form' ); let baseHref = $form.attr( 'action' ) || ''; - baseHref += baseHref.indexOf( '?' ) > -1 ? '&' : '?'; + baseHref += baseHref.includes( '?' ) ? '&' : '?'; const linkParams = serializeObject( $form.serializeArray() ); diff --git a/resources/src/mediawiki.special.apisandbox/ApiSandboxLayout.js b/resources/src/mediawiki.special.apisandbox/ApiSandboxLayout.js index 9a21adf5a88e..5c35487295c3 100644 --- a/resources/src/mediawiki.special.apisandbox/ApiSandboxLayout.js +++ b/resources/src/mediawiki.special.apisandbox/ApiSandboxLayout.js @@ -661,7 +661,7 @@ ApiSandboxLayout.prototype.apiCheckValid = function () { // eslint-disable-next-line no-jquery/no-map-util const promises = $.map( this.widgets, ( widget ) => widget.apiCheckValid( ApiSandbox.suppressErrors ) ); $.when( ...promises ).then( ( ...results ) => { - this.apiIsValid = results.indexOf( false ) === -1; + this.apiIsValid = !results.includes( false ); if ( this.getOutlineItem() ) { this.getOutlineItem().setIcon( this.apiIsValid || ApiSandbox.suppressErrors ? null : 'alert' ); this.getOutlineItem().setTitle( diff --git a/resources/src/mediawiki.special.apisandbox/Util.js b/resources/src/mediawiki.special.apisandbox/Util.js index 61b3e72d8325..306a6a5c2263 100644 --- a/resources/src/mediawiki.special.apisandbox/Util.js +++ b/resources/src/mediawiki.special.apisandbox/Util.js @@ -107,7 +107,7 @@ const WidgetMethods = { }, getApiValue: function () { const items = this.getValue(); - if ( items.join( '' ).indexOf( '|' ) === -1 ) { + if ( !items.join( '' ).includes( '|' ) ) { return items.join( '|' ); } else { return '\x1f' + items.join( '\x1f' ); @@ -126,7 +126,7 @@ const WidgetMethods = { ok = this.getApiValue() !== undefined && !( pi.allspecifier !== undefined && this.getValue().length > 1 && - this.getValue().indexOf( pi.allspecifier ) !== -1 + this.getValue().includes( pi.allspecifier ) ); } @@ -137,12 +137,12 @@ const WidgetMethods = { createTagItemWidget: function ( data, label ) { const item = OO.ui.TagMultiselectWidget.prototype.createTagItemWidget.call( this, data, label ); if ( this.paramInfo.deprecatedvalues && - this.paramInfo.deprecatedvalues.indexOf( data ) >= 0 + this.paramInfo.deprecatedvalues.includes( data ) ) { item.$element.addClass( 'mw-apisandbox-deprecated-value' ); } if ( this.paramInfo.internalvalues && - this.paramInfo.internalvalues.indexOf( data ) >= 0 + this.paramInfo.internalvalues.includes( data ) ) { item.$element.addClass( 'mw-apisandbox-internal-value' ); } @@ -443,13 +443,13 @@ Util = { data: String( v ), label: String( v ) } ); - if ( pi.deprecatedvalues && pi.deprecatedvalues.indexOf( v ) >= 0 ) { + if ( pi.deprecatedvalues && pi.deprecatedvalues.includes( v ) ) { optionWidget.$element.addClass( 'mw-apisandbox-deprecated-value' ); optionWidget.$label.before( $( '<span>' ).addClass( 'mw-apisandbox-flag' ).text( mw.msg( 'api-help-param-deprecated-label' ) ) ); } - if ( pi.internalvalues && pi.internalvalues.indexOf( v ) >= 0 ) { + if ( pi.internalvalues && pi.internalvalues.includes( v ) ) { optionWidget.$element.addClass( 'mw-apisandbox-internal-value' ); optionWidget.$label.before( $( '<span>' ).addClass( 'mw-apisandbox-flag' ).text( mw.msg( 'api-help-param-internal-label' ) ) @@ -490,7 +490,7 @@ Util = { widget.getMenu().on( 'select', ( item ) => { widget.$element.toggleClass( 'mw-apisandbox-deprecated-value', - pi.deprecatedvalues.indexOf( item.data ) >= 0 + pi.deprecatedvalues.includes( item.data ) ); } ); } @@ -498,7 +498,7 @@ Util = { widget.getMenu().on( 'select', ( item ) => { widget.$element.toggleClass( 'mw-apisandbox-internal-value', - pi.internalvalues.indexOf( item.data ) >= 0 + pi.internalvalues.includes( item.data ) ); } ); } diff --git a/resources/src/mediawiki.special.block.js b/resources/src/mediawiki.special.block.js index fd904f978fe7..16f87951800b 100644 --- a/resources/src/mediawiki.special.block.js +++ b/resources/src/mediawiki.special.block.js @@ -69,9 +69,7 @@ // Partial block that blocks editing and doesn't block the User_talk namespace ( editingRestrictionValue === 'partial' && - namespaceRestrictionsWidget.getValue().indexOf( - String( mw.config.get( 'wgNamespaceIds' ).user_talk ) - ) === -1 + !namespaceRestrictionsWidget.getValue().includes( String( mw.config.get( 'wgNamespaceIds' ).user_talk ) ) ) ); } diff --git a/resources/src/mediawiki.special.block/components/NamespacesField.vue b/resources/src/mediawiki.special.block/components/NamespacesField.vue index c044fa77bcf7..e607dffdb1eb 100644 --- a/resources/src/mediawiki.special.block/components/NamespacesField.vue +++ b/resources/src/mediawiki.special.block/components/NamespacesField.vue @@ -60,7 +60,7 @@ module.exports = exports = defineComponent( { if ( value ) { // eslint-disable-next-line arrow-body-style menuItems.value = initialMenuItems.filter( ( item ) => { - return item.label.toLowerCase().indexOf( value.toLowerCase() ) !== -1; + return item.label.toLowerCase().includes( value.toLowerCase() ); } ); } else { menuItems.value = initialMenuItems; @@ -75,7 +75,7 @@ module.exports = exports = defineComponent( { function onUpdateChips( newChips ) { // NOTE: This is to avoid recursive updates since namespaces is bound to MultiselectLookup with v-model const uniqueChipValues = newChips.map( ( item ) => item.value ); - const uniqueNewValues = uniqueChipValues.filter( ( chipValue ) => namespaces.value.indexOf( chipValue ) === -1 ); + const uniqueNewValues = uniqueChipValues.filter( ( chipValue ) => !namespaces.value.includes( chipValue ) ); if ( uniqueNewValues.length !== 0 || namespaces.value.length > uniqueChipValues.length ) { namespaces.value = newChips.map( ( chip ) => chip.value ); } diff --git a/resources/src/mediawiki.special.block/components/PagesField.vue b/resources/src/mediawiki.special.block/components/PagesField.vue index e6ab801a0abf..1d1f31757d0f 100644 --- a/resources/src/mediawiki.special.block/components/PagesField.vue +++ b/resources/src/mediawiki.special.block/components/PagesField.vue @@ -126,7 +126,7 @@ module.exports = exports = defineComponent( { function onUpdateChips( newChips ) { // NOTE: This is to avoid recursive updates since pages is bound to MultiselectLookup with v-model const uniqueChipValues = newChips.map( ( item ) => item.value ); - const uniqueNewValues = uniqueChipValues.filter( ( chipValue ) => pages.value.indexOf( chipValue ) === -1 ); + const uniqueNewValues = uniqueChipValues.filter( ( chipValue ) => !pages.value.includes( chipValue ) ); if ( uniqueNewValues.length !== 0 || pages.value.length > uniqueChipValues.length ) { pages.value = newChips.map( ( chip ) => chip.value ); } diff --git a/resources/src/mediawiki.special.block/stores/block.js b/resources/src/mediawiki.special.block/stores/block.js index fa9d79d8cf50..20fc74963834 100644 --- a/resources/src/mediawiki.special.block/stores/block.js +++ b/resources/src/mediawiki.special.block/stores/block.js @@ -95,19 +95,19 @@ module.exports = exports = defineStore( 'block', () => { * * @type {Ref<boolean>} */ - const createAccount = ref( details.indexOf( 'wpCreateAccount' ) !== -1 ); + const createAccount = ref( details.includes( 'wpCreateAccount' ) ); /** * Whether to disable the target's ability to send email via Special:EmailUser. * * @type {Ref<boolean>} */ - const disableEmail = ref( details.indexOf( 'wpDisableEmail' ) !== -1 ); + const disableEmail = ref( details.includes( 'wpDisableEmail' ) ); /** * Whether to disable the target's ability to edit their own user talk page. * * @type {Ref<boolean>} */ - const disableUTEdit = ref( details.indexOf( 'wpDisableUTEdit' ) !== -1 ); + const disableUTEdit = ref( details.includes( 'wpDisableUTEdit' ) ); const additionalDetails = mw.config.get( 'blockAdditionalDetailsPreset' ) || []; /** * Whether to autoblock IP addresses used by the target. @@ -115,26 +115,26 @@ module.exports = exports = defineStore( 'block', () => { * @type {Ref<boolean>} * @see https://www.mediawiki.org/wiki/Autoblock */ - const autoBlock = ref( additionalDetails.indexOf( 'wpAutoBlock' ) !== -1 ); + const autoBlock = ref( additionalDetails.includes( 'wpAutoBlock' ) ); /** * Whether to impose a "suppressed" block, hiding the target's username * from block log, the active block list, and the user list. * * @type {Ref<boolean>} */ - const hideUser = ref( additionalDetails.indexOf( 'wpHideUser' ) !== -1 ); + const hideUser = ref( additionalDetails.includes( 'wpHideUser' ) ); /** * Whether to watch the target's user page and talk page. * * @type {Ref<boolean>} */ - const watchUser = ref( additionalDetails.indexOf( 'wpWatch' ) !== -1 ); + const watchUser = ref( additionalDetails.includes( 'wpWatch' ) ); /** * Whether to apply a hard block, blocking accounts using the same IP address. * * @type {Ref<boolean>} */ - const hardBlock = ref( additionalDetails.indexOf( 'wpHardBlock' ) !== -1 ); + const hardBlock = ref( additionalDetails.includes( 'wpHardBlock' ) ); /* * The removal reason, used in the remove-block confirmation dialog. * Note that the target and watchuser values in that form are shared with the main form. @@ -230,7 +230,7 @@ module.exports = exports = defineStore( 'block', () => { const disableUTEditVisible = computed( () => { const isVisibleByConfig = mw.config.get( 'blockDisableUTEditVisible' ) || false; const isPartial = type.value === 'partial'; - const blocksUT = namespaces.value.indexOf( mw.config.get( 'wgNamespaceIds' ).user_talk ) !== -1; + const blocksUT = namespaces.value.includes( mw.config.get( 'wgNamespaceIds' ).user_talk ); return isVisibleByConfig && ( !isPartial || ( isPartial && blocksUT ) ); } ); /** diff --git a/resources/src/mediawiki.special.preferences.ooui/tabs.js b/resources/src/mediawiki.special.preferences.ooui/tabs.js index f97ab627d4b9..0c4682b486de 100644 --- a/resources/src/mediawiki.special.preferences.ooui/tabs.js +++ b/resources/src/mediawiki.special.preferences.ooui/tabs.js @@ -15,7 +15,7 @@ // which causes the :target selector (used in mediawiki.special.preferences.styles.ooui.less) // not to match anything inside the tabs in Chrome. Twiddling location.href makes it work. // Only do it when a fragment is present, otherwise the page would be reloaded. - if ( location.href.indexOf( '#' ) !== -1 ) { + if ( location.href.includes( '#' ) ) { // eslint-disable-next-line no-self-assign location.href = location.href; } @@ -166,7 +166,7 @@ texts.forEach( ( text ) => { // TODO: Could use Intl.Collator.prototype.compare like OO.ui.mixin.LabelElement.static.highlightQuery // but might be too slow. - if ( text.indexOf( val ) !== -1 ) { + if ( text.includes( val ) ) { index[ text ].forEach( ( item ) => { // eslint-disable-next-line no-jquery/no-class-state if ( !item.$field.hasClass( 'mw-prefs-search-matched' ) ) { diff --git a/resources/src/mediawiki.special.search/search.js b/resources/src/mediawiki.special.search/search.js index 5e9487e1607e..020f01eaf74d 100644 --- a/resources/src/mediawiki.special.search/search.js +++ b/resources/src/mediawiki.special.search/search.js @@ -25,7 +25,7 @@ const parts = $( this ).attr( 'href' ).split( 'search=' ); let lastpart = '', prefix = 'search='; - if ( parts.length > 1 && parts[ 1 ].indexOf( '&' ) !== -1 ) { + if ( parts.length > 1 && parts[ 1 ].includes( '&' ) ) { lastpart = parts[ 1 ].slice( parts[ 1 ].indexOf( '&' ) ); } else { prefix = '&search='; diff --git a/resources/src/mediawiki.special.upload/upload.js b/resources/src/mediawiki.special.upload/upload.js index f6a8c9995ab6..1b1919827b57 100644 --- a/resources/src/mediawiki.special.upload/upload.js +++ b/resources/src/mediawiki.special.upload/upload.js @@ -175,7 +175,7 @@ ) { if ( fname.lastIndexOf( '.' ) === -1 || - mw.config.get( 'wgFileExtensions' ).map( ( element ) => element.toLowerCase() ).indexOf( fname.slice( fname.lastIndexOf( '.' ) + 1 ).toLowerCase() ) === -1 + !mw.config.get( 'wgFileExtensions' ).map( ( element ) => element.toLowerCase() ).includes( fname.slice( fname.lastIndexOf( '.' ) + 1 ).toLowerCase() ) ) { // Not a valid extension // Clear the upload and set mw-upload-permitted to error @@ -236,7 +236,7 @@ function fileIsPreviewable( file ) { const known = [ 'image/png', 'image/gif', 'image/jpeg', 'image/svg+xml', 'image/webp' ], tooHuge = 10 * 1024 * 1024; - return ( known.indexOf( file.type ) !== -1 ) && file.size > 0 && file.size < tooHuge; + return ( known.includes( file.type ) ) && file.size > 0 && file.size < tooHuge; } /** diff --git a/resources/src/mediawiki.special.userrights.js b/resources/src/mediawiki.special.userrights.js index 43e71aae0a0d..da817b49da3c 100644 --- a/resources/src/mediawiki.special.userrights.js +++ b/resources/src/mediawiki.special.userrights.js @@ -15,6 +15,6 @@ $( () => { // Disable the watch field for cross-wiki userright changes const userrightsInterwikiDelimiter = require( './config.json' ).UserrightsInterwikiDelimiter; $( '#username' ).on( 'change', ( e ) => { - $( '#wpWatch' ).prop( 'disabled', e.target.value.indexOf( userrightsInterwikiDelimiter ) !== -1 ); + $( '#wpWatch' ).prop( 'disabled', e.target.value.includes( userrightsInterwikiDelimiter ) ); } ).trigger( 'change' ); } ); diff --git a/resources/src/mediawiki.util/util.js b/resources/src/mediawiki.util/util.js index b03d157069f6..1fa4036ad858 100644 --- a/resources/src/mediawiki.util/util.js +++ b/resources/src/mediawiki.util/util.js @@ -514,7 +514,7 @@ const util = { const msgBoxElement = document.createElement( 'div' ); msgBoxElement.classList.add( 'cdx-message' ); - if ( [ 'error', 'warning', 'success', 'notice' ].indexOf( type ) > -1 ) { + if ( [ 'error', 'warning', 'success', 'notice' ].includes( type ) ) { // The following CSS classes are used here: // * cdx-message--notice // * cdx-message--warning @@ -1159,7 +1159,7 @@ const util = { } if ( this.isIPv6Address( ip, true ) ) { let cidr, replaceZeros; - if ( ip.indexOf( '/' ) !== -1 ) { + if ( ip.includes( '/' ) ) { const ipCidrSplit = ip.split( '/', 2 ); ip = ipCidrSplit[ 0 ]; cidr = ipCidrSplit[ 1 ]; @@ -1246,7 +1246,7 @@ const util = { * @stable */ isInfinity: function ( str ) { - return infinityValues.indexOf( str ) !== -1; + return infinityValues.includes( str ); } }; diff --git a/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js index 1e5687e8d10b..caf84491f06d 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js @@ -100,7 +100,7 @@ const existingItems = menu.getItems().map( ( item ) => item.data ); // Remove if items' data already exists - let filteredItems = items.filter( ( item ) => existingItems.indexOf( item ) === -1 ); + let filteredItems = items.filter( ( item ) => !existingItems.includes( item ) ); // Map to an array of OO.ui.MenuOptionWidgets filteredItems = filteredItems.map( ( item ) => new OO.ui.MenuOptionWidget( { @@ -223,7 +223,7 @@ // If the searchTypes has mw.widgets.CategoryMultiselectWidget.SearchType.SubCategories // it can be the only search type. - if ( this.searchTypes.indexOf( mw.widgets.CategoryMultiselectWidget.SearchType.SubCategories ) > -1 && + if ( this.searchTypes.includes( mw.widgets.CategoryMultiselectWidget.SearchType.SubCategories ) && this.searchTypes.length > 1 ) { throw new Error( 'Can\'t have additional search types with mw.widgets.CategoryMultiselectWidget.SearchType.SubCategories' ); @@ -231,7 +231,7 @@ // If the searchTypes has mw.widgets.CategoryMultiselectWidget.SearchType.ParentCategories // it can be the only search type. - if ( this.searchTypes.indexOf( mw.widgets.CategoryMultiselectWidget.SearchType.ParentCategories ) > -1 && + if ( this.searchTypes.includes( mw.widgets.CategoryMultiselectWidget.SearchType.ParentCategories ) && this.searchTypes.length > 1 ) { throw new Error( 'Can\'t have additional search types with mw.widgets.CategoryMultiselectWidget.SearchType.ParentCategories' ); @@ -298,7 +298,7 @@ break; case mw.widgets.CategoryMultiselectWidget.SearchType.Exists: - if ( input.indexOf( '|' ) > -1 ) { + if ( input.includes( '|' ) ) { deferred.resolve( [] ); break; } @@ -322,7 +322,7 @@ break; case mw.widgets.CategoryMultiselectWidget.SearchType.SubCategories: - if ( input.indexOf( '|' ) > -1 ) { + if ( input.includes( '|' ) ) { deferred.resolve( [] ); break; } @@ -341,7 +341,7 @@ break; case mw.widgets.CategoryMultiselectWidget.SearchType.ParentCategories: - if ( input.indexOf( '|' ) > -1 ) { + if ( input.includes( '|' ) ) { deferred.resolve( [] ); break; } diff --git a/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js index 00e2b7eed246..d028762e6132 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js @@ -110,12 +110,12 @@ mw.widgets.CheckMatrixWidget.prototype.isTagSelected = function ( tagName ) { return ( // If tag is not forced off - this.forcedOff.indexOf( tagName ) === -1 && + !this.forcedOff.includes( tagName ) && ( // If tag is in values - this.values.indexOf( tagName ) > -1 || + this.values.includes( tagName ) || // If tag is forced on - this.forcedOn.indexOf( tagName ) > -1 + this.forcedOn.includes( tagName ) ) ); }; @@ -131,8 +131,8 @@ // If the entire widget is disabled this.isDisabled() || // If tag is forced off or forced on - this.forcedOff.indexOf( tagName ) > -1 || - this.forcedOn.indexOf( tagName ) > -1 + this.forcedOff.includes( tagName ) || + this.forcedOn.includes( tagName ) ); }; /** diff --git a/resources/src/mediawiki.widgets/mw.widgets.MenuTagMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.MenuTagMultiselectWidget.js index cbae5262ed7e..d913c9c59ef2 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.MenuTagMultiselectWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.MenuTagMultiselectWidget.js @@ -47,7 +47,7 @@ .attr( 'type', 'checkbox' ) .attr( 'value', option.data ) .attr( 'name', config.name + '[]' ) - .prop( 'defaultChecked', selected.indexOf( option.data ) >= 0 ) + .prop( 'defaultChecked', selected.includes( option.data ) ) .appendTo( $container ); } ); $container.appendTo( this.$element ); @@ -67,7 +67,7 @@ const values = this.getValue(); for ( const name in this.$hiddenInputs ) { const $input = this.$hiddenInputs[ name ]; - $input.prop( 'checked', values.indexOf( $input.attr( 'value' ) ) >= 0 ); + $input.prop( 'checked', values.includes( $input.attr( 'value' ) ) ); } } diff --git a/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js index 7d545ae75093..15a1fc62ac6a 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js @@ -66,8 +66,8 @@ const options = $.map( namespaces, ( name, ns ) => { if ( ns < mainNamespace || - exclude.indexOf( Number( ns ) ) !== -1 || - ( Array.isArray( include ) && include.indexOf( Number( ns ) ) === -1 ) + exclude.includes( Number( ns ) ) || + ( Array.isArray( include ) && !include.includes( Number( ns ) ) ) ) { return null; // skip } diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js index 4e26ecc10e5b..c45001ac2c0f 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js @@ -167,7 +167,7 @@ return this.sectionsCache[ normalizedTitleText ].then( ( response ) => { const sections = OO.getProp( response, 'parse', 'sections' ) || []; const normalizedFragmentQuery = normalizeFragment( fragmentQuery ); - const results = sections.filter( ( section ) => normalizeFragment( section.line ).indexOf( normalizedFragmentQuery ) !== -1 ).map( ( section ) => { + const results = sections.filter( ( section ) => normalizeFragment( section.line ).includes( normalizedFragmentQuery ) ).map( ( section ) => { const fragment = section.linkAnchor.replace( /_/g, ' ' ); // TODO: Make promise abortable return { @@ -222,7 +222,7 @@ const interwiki = query.slice( 0, Math.max( 0, query.indexOf( ':' ) ) ); if ( interwiki !== '' && - interwikiPrefixes.indexOf( interwiki ) !== -1 + interwikiPrefixes.includes( interwiki ) ) { // Interwiki prefix is valid: return the original query as a valid title // NB: This doesn't check if the title actually exists on the other wiki diff --git a/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js index 72db6d96df69..29eecd0020d2 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js @@ -154,7 +154,7 @@ // Remove usernames, which are already selected from suggestions suggestions = suggestions.map( ( user ) => { - if ( selected.indexOf( user.name ) === -1 ) { + if ( !selected.includes( user.name ) ) { return new OO.ui.MenuOptionWidget( { data: user.name, label: user.name, diff --git a/resources/src/moment/moment-locale-overrides.js b/resources/src/moment/moment-locale-overrides.js index cf1dfb6208b0..719da5e70d8a 100644 --- a/resources/src/moment/moment-locale-overrides.js +++ b/resources/src/moment/moment-locale-overrides.js @@ -25,7 +25,7 @@ // HACK: momentjs replaces commas in some languages, which is the only other use of preparse // aside from digit transformation. We can only override preparse, not extend it, so we // have to replicate the comma replacement functionality here. - if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) { + if ( [ 'ar', 'ar-sa', 'fa' ].includes( mw.config.get( 'wgUserLanguage' ) ) ) { s = s.replace( /،/g, ',' ); } return s; @@ -43,7 +43,7 @@ // HACK: momentjs replaces commas in some languages, which is the only other use of postformat // aside from digit transformation. We can only override postformat, not extend it, so we // have to replicate the comma replacement functionality here. - if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) { + if ( [ 'ar', 'ar-sa', 'fa' ].includes( mw.config.get( 'wgUserLanguage' ) ) ) { s = s.replace( /,/g, '،' ); } return s; diff --git a/resources/src/startup/.eslintrc.json b/resources/src/startup/.eslintrc.json index 060d3fb62c67..2868a11744ee 100644 --- a/resources/src/startup/.eslintrc.json +++ b/resources/src/startup/.eslintrc.json @@ -9,7 +9,6 @@ "rules": { "max-len": "off", "no-var": "off", - "prefer-arrow-callback": "off", - "unicorn/prefer-includes": "off" + "prefer-arrow-callback": "off" } } diff --git a/resources/src/startup/mediawiki.loader.js b/resources/src/startup/mediawiki.loader.js index 8776ec7e1ad4..3c8a6411a742 100644 --- a/resources/src/startup/mediawiki.loader.js +++ b/resources/src/startup/mediawiki.loader.js @@ -293,7 +293,7 @@ */ function allWithImplicitReady( module ) { return allReady( registry[ module ].dependencies ) && - ( baseModules.indexOf( module ) !== -1 || allReady( baseModules ) ); + ( baseModules.includes( module ) || allReady( baseModules ) ); } /** @@ -340,14 +340,14 @@ // Stage 1: Propagate failures while ( errorModules.length ) { var errorModule = errorModules.shift(), - baseModuleError = baseModules.indexOf( errorModule ) !== -1; + baseModuleError = baseModules.includes( errorModule ); for ( module in registry ) { if ( registry[ module ].state !== 'error' && registry[ module ].state !== 'missing' ) { - if ( baseModuleError && baseModules.indexOf( module ) === -1 ) { + if ( baseModuleError && !baseModules.includes( module ) ) { // Propate error from base module to all regular (non-base) modules registry[ module ].state = 'error'; didPropagate = true; - } else if ( registry[ module ].dependencies.indexOf( errorModule ) !== -1 ) { + } else if ( registry[ module ].dependencies.includes( errorModule ) ) { // Propagate error from dependency to depending module registry[ module ].state = 'error'; // .. and propagate it further @@ -479,7 +479,7 @@ var deps = registry[ module ].dependencies; unresolved.add( module ); for ( var i = 0; i < deps.length; i++ ) { - if ( resolved.indexOf( deps[ i ] ) === -1 ) { + if ( !resolved.includes( deps[ i ] ) ) { if ( unresolved.has( deps[ i ] ) ) { throw new Error( 'Circular reference detected: ' + module + ' -> ' + deps[ i ] @@ -831,7 +831,7 @@ dependencies.forEach( function ( module ) { // Only queue modules that are still in the initial 'registered' state // (e.g. not ones already loading or loaded etc.). - if ( registry[ module ].state === 'registered' && queue.indexOf( module ) === -1 ) { + if ( registry[ module ].state === 'registered' && !queue.includes( module ) ) { queue.push( module ); } } ); diff --git a/tests/qunit/.eslintrc.json b/tests/qunit/.eslintrc.json index c0d2f1212a4c..607e2818f4c9 100644 --- a/tests/qunit/.eslintrc.json +++ b/tests/qunit/.eslintrc.json @@ -13,10 +13,10 @@ "rules": { "compat/compat": [ "error", "last 2 chrome versions, last 2 firefox versions" ], "max-len": "off", + "no-shadow": [ "error", { "allow": [ "hooks" ] } ], "no-jquery/no-done-fail": "off", "no-jquery/no-global-selector": "off", "no-jquery/no-parse-html-literal": "off", - "no-shadow": [ "error", { "allow": [ "hooks" ] } ], "qunit/resolve-async": "off" } } |