"property": "inArray",
"message": "Please use Array.prototype.indexOf instead"
},
+ {
+ "object": "$",
+ "property": "each",
+ "message": "Please consider different approaches to $.each, especially when using Array's. You can override this warning if necessary with eslint-disable-next-line."
+ },
{
"object": "$",
"property": "isArray",
// Loop through all the dom cells of the thead
$tableRows.each( function ( rowIndex, row ) {
+ // eslint-disable-next-line no-restricted-properties
$.each( row.cells, function ( columnIndex, cell ) {
var matrixRowIndex,
matrixColumnIndex;
function convertSortList( sortObjects ) {
var sortList = [];
sortObjects.forEach( function ( sortObject ) {
+ // eslint-disable-next-line no-restricted-properties
$.each( sortObject, function ( columnIndex, order ) {
var orderIndex = ( order === 'desc' ) ? 1 : 0;
sortList.push( [ parseInt( columnIndex, 10 ), orderIndex ] );
*/
getQueryString: function () {
var args = [];
+ // eslint-disable-next-line no-restricted-properties
$.each( this.query, function ( key, val ) {
var k = Uri.encode( key ),
vals = Array.isArray( val ) ? val : [ val ];
}
newList = [];
+ // eslint-disable-next-line no-restricted-properties
$.each( response.parse.indicators, function ( name, indicator ) {
newList.push(
$( '<div>' )
// Pre-populate with fake ajax promises to save http requests for tokens
// we already have on the page via the user.tokens module (T36733).
promises[ defaultOptions.ajax.url ] = {};
+ // eslint-disable-next-line no-restricted-properties
$.each( mw.user.tokens.get(), function ( key, value ) {
// This requires #getToken to use the same key as user.tokens.
// Format: token-type + "Token" (eg. csrfToken, patrolToken, watchToken).
file.name = 'file';
+ // eslint-disable-next-line no-restricted-properties
$.each( data, function ( key, val ) {
$form.append( getHiddenInput( key, val ) );
} );
style.textContent = css;
document.body.appendChild( style );
+ // eslint-disable-next-line no-restricted-properties
$.each( style.sheet.cssRules, function ( index, rule ) {
selectors.total++;
// document.querySelector() on prefixed pseudo-elements can throw exceptions
mw.jqueryMsg.HtmlEmitter = function ( language, magic ) {
var jmsg = this;
this.language = language;
+ // eslint-disable-next-line no-restricted-properties
$.each( magic, function ( key, val ) {
jmsg[ key.toLowerCase() ] = function () {
return val;
*/
concat: function ( nodes ) {
var $span = $( '<span>' ).addClass( 'mediaWiki_htmlEmitter' );
+ // eslint-disable-next-line no-restricted-properties
$.each( nodes, function ( i, node ) {
// Let jQuery append nodes, arrays of nodes and jQuery objects
// other things (strings, numbers, ..) are appended as text nodes (not as HTML strings)
+/* eslint-disable no-restricted-properties */
( function ( mw ) {
/**
* View model for a filter group
key = key || 'contextDescription';
+ // eslint-disable-next-line no-restricted-properties
$.each( conflicts, function ( filterName, conflict ) {
if ( !conflict.item.isSelected() ) {
return;
+/* eslint-disable no-restricted-properties */
( function ( mw, $ ) {
/**
* View model for the filters selection and display
+/* eslint-disable no-restricted-properties */
( function ( mw, $ ) {
/**
* View model for saved queries
+/* eslint-disable no-restricted-properties */
( function ( mw, $ ) {
var byteLength = require( 'mediawiki.String' ).byteLength;
if ( config.events ) {
// Aggregate events
+ // eslint-disable-next-line no-restricted-properties
$.each( config.events, function ( eventName, eventEmit ) {
aggregate[ eventName ] = eventEmit;
} );
this.$overlay.append( this.highlightPopup.$element );
// Count groups per view
+ // eslint-disable-next-line no-restricted-properties
$.each( groups, function ( groupName, groupModel ) {
if ( !groupModel.isHidden() ) {
viewGroupCount[ groupModel.getView() ] = viewGroupCount[ groupModel.getView() ] || 0;
}
} );
+ // eslint-disable-next-line no-restricted-properties
$.each( groups, function ( groupName, groupModel ) {
var currentItems = [],
view = groupModel.getView();
}
toRemove = {};
+ // eslint-disable-next-line no-restricted-properties
$.each( this.templatedItemsCache, function ( k, el ) {
if ( el.widget.isElementAttached() ) {
toRemove[ k ] = el;
render: function ( data, partialTemplates ) {
var partials = {};
if ( partialTemplates ) {
+ /* eslint-disable-next-line no-restricted-properties */
$.each( partialTemplates, function ( name, template ) {
partials[ name ] = template.getSource();
} );
} else {
maxlength = spec.size;
if ( spec.intercalarySize ) {
+ // eslint-disable-next-line no-restricted-properties
$.each( spec.intercalarySize, reduceFunc );
}
$field = $( '<input>' ).attr( 'type', 'text' )
} ).done( function ( res ) {
var categories = [];
- $.each( res.query.pages, function ( index, page ) {
+ res.query.pages.forEach( function ( page ) {
if ( !page.missing ) {
categories.push( page.title );
}
} ).done( function ( res ) {
var categories = [];
- $.each( res.query.pages, function ( index, page ) {
+ res.query.pages.forEach( function ( page ) {
if ( !page.missing && Array.isArray( page.categories ) ) {
categories.push.apply( categories, page.categories.map( function ( category ) {
return category.title;
var
normalized = {},
pages = {};
- $.each( response.query.normalized || [], function ( index, data ) {
+ ( response.query.normalized || [] ).forEach( function ( data ) {
normalized[ data.fromencoded ? decodeURIComponent( data.from ) : data.from ] = data.to;
} );
- $.each( response.query.pages, function ( index, page ) {
+ response.query.pages.forEach( function ( page ) {
pages[ page.title ] = !page.missing;
} );
titles.forEach( function ( title ) {
$headRow.append( $( '<td>' ).text( '\u00A0' ) );
// Iterate over the columns object (ignore the value)
+ // eslint-disable-next-line no-restricted-properties
$.each( this.columns, function ( columnLabel ) {
$headRow.append( $( '<td>' ).html( columnLabel ) );
} );
$table.append( $headRow );
// Build table
+ // eslint-disable-next-line no-restricted-properties
$.each( this.rows, function ( rowLabel, rowTag ) {
var $row = $( '<tr>' ),
labelField = new OO.ui.FieldLayout(
$row.append( $( '<td>' ).append( labelField.$element ) );
// Columns
+ // eslint-disable-next-line no-restricted-properties
$.each( widget.columns, function ( columnLabel, columnTag ) {
var thisTag = columnTag + '-' + rowTag,
checkbox = new OO.ui.CheckboxInputWidget( {
// setDisabled sometimes gets called before the widget is ready
if ( this.checkboxes && Object.keys( this.checkboxes ).length > 0 ) {
// Propagate to all checkboxes and update their disabled state
+ // eslint-disable-next-line no-restricted-properties
$.each( this.checkboxes, function ( name, checkbox ) {
checkbox.setDisabled( widget.isTagDisabled( name ) );
} );
urls = data.data[ 3 ],
self = this;
+ // eslint-disable-next-line no-restricted-properties
$.each( titles, function ( i, result ) {
items.push( new mw.widgets.TitleOptionWidget(
self.getOptionWidgetData(
// Check for incomplete animations/requests/etc and throw if there are any.
if ( $.timers && $.timers.length !== 0 ) {
timers = $.timers.length;
+ // eslint-disable-next-line no-restricted-properties
$.each( $.timers, function ( i, timer ) {
var node = timer.elem;
mw.log.warn( 'Unfinished animation #' + i + ' in ' + timer.queue + ' queue on ' +
QUnit.whenPromisesComplete = function () {
var altPromises = [];
+ // When we have ES6 support we'll be able to use Array.from here
+ // eslint-disable-next-line no-restricted-properties
$.each( arguments, function ( i, arg ) {
var alt = $.Deferred();
altPromises.push( alt );
} );
}
+ // eslint-disable-next-line no-restricted-properties
$.each( pluralTestcases, function ( langCode, tests ) {
if ( langCode === mw.config.get( 'wgUserLanguage' ) ) {
pluralTest( langCode, tests );
]
};
+ // eslint-disable-next-line no-restricted-properties
$.each( grammarTests, function ( langCode, test ) {
if ( langCode === mw.config.get( 'wgUserLanguage' ) ) {
grammarTest( langCode, test );
QUnit.test( 'wikiUrlencode', function ( assert ) {
assert.strictEqual( util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
// See also wfUrlencodeTest.php#provideURLS
+ // eslint-disable-next-line no-restricted-properties
$.each( {
'+': '%2B',
'&': '%26',