Replace jQuery.inArray with Array.prototype.indexOf.
Also enforce this via eslint rule.
Bug: T200877
Change-Id: Idbd06e6a1681300c4ab9142c7b57e4376f474041
"property": "map",
"message": "Please use Array.prototype.map instead"
},
+ {
+ "object": "$",
+ "property": "inArray",
+ "message": "Please use Array.prototype.indexOf instead"
+ },
{
"object": "$",
"property": "isArray",
*/
getName: function () {
if (
- $.inArray( this.namespace, mw.config.get( 'wgCaseSensitiveNamespaces' ) ) !== -1 ||
+ mw.config.get( 'wgCaseSensitiveNamespaces' ).indexOf( this.namespace ) !== -1 ||
!this.title.length
) {
return this.title;
* @return {boolean}
*/
isCascadeableLevel: function ( level ) {
- return $.inArray( level, mw.config.get( 'wgCascadeableLevels' ) ) !== -1;
+ var cascadeableLevels = mw.config.get( 'wgCascadeableLevels' );
+
+ if ( !Array.isArray( cascadeableLevels ) ) {
+ return false;
+ }
+
+ return cascadeableLevels.indexOf( level ) !== -1;
},
/**
return widget.apiCheckValid();
} );
$.when.apply( $, promises ).then( function () {
- that.apiIsValid = $.inArray( false, arguments ) === -1;
+ that.apiIsValid = Array.prototype.indexOf.call( arguments, false ) === -1;
if ( that.getOutlineItem() ) {
that.getOutlineItem().setIcon( that.apiIsValid || suppressErrors ? null : 'alert' );
that.getOutlineItem().setIconTitle(