build: Enable and make pass no-prototype-builtins
authorJames D. Forrester <jforrester@wikimedia.org>
Fri, 6 Jul 2018 00:36:01 +0000 (17:36 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Fri, 6 Jul 2018 00:36:01 +0000 (17:36 -0700)
Change-Id: I26a98be16c005c1c864ec592e1a41b44943f8f29

13 files changed:
.eslintrc.json
resources/src/jquery.tablesorter/jquery.tablesorter.js
resources/src/mediawiki.Title/Title.js
resources/src/mediawiki.Uri/Uri.js
resources/src/mediawiki.api/upload.js
resources/src/mediawiki.debug/debug.js
resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js
resources/src/mediawiki.language/mediawiki.language.numbers.js
resources/src/mediawiki.page.watch.ajax.js
resources/src/mediawiki.special.apisandbox/apisandbox.js
resources/src/mediawiki.special.upload/upload.js
resources/src/mediawiki.visibleTimeout.js
resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js

index e369640..844895d 100644 (file)
@@ -12,7 +12,6 @@
        },
        "rules": {
                "dot-notation": 0,
-               "max-len": 0,
-               "no-prototype-builtins": 0
+               "max-len": 0
        }
 }
index 552c0c3..9417669 100644 (file)
                        // Build array of key names
                        for ( key in ts.collationTable ) {
                                // Check hasOwn to be safe
-                               if ( ts.collationTable.hasOwnProperty( key ) ) {
+                               if ( Object.prototype.hasOwnProperty.call( ts.collationTable, key ) ) {
                                        keys.push( mw.RegExp.escape( key ) );
                                }
                        }
index 2b76187..c02af98 100644 (file)
                                tiff: 'tif',
                                ogv: 'ogg'
                        };
-               if ( squish.hasOwnProperty( lower ) ) {
+               if ( Object.prototype.hasOwnProperty.call( squish, lower ) ) {
                        return squish[ lower ];
                } else if ( /^[0-9a-z]+$/.test( lower ) ) {
                        return lower;
index 7467d50..eb7cff0 100644 (file)
                                        // Copy data over from existing URI object
                                        for ( prop in uri ) {
                                                // Only copy direct properties, not inherited ones
-                                               if ( uri.hasOwnProperty( prop ) ) {
+                                               if ( Object.prototype.hasOwnProperty.call( uri, prop ) ) {
                                                        // Deep copy object properties
                                                        if ( Array.isArray( uri[ prop ] ) || $.isPlainObject( uri[ prop ] ) ) {
                                                                this[ prop ] = $.extend( true, {}, uri[ prop ] );
index 29bd59a..a6451ac 100644 (file)
@@ -40,7 +40,7 @@
        function getFirstKey( obj ) {
                var key;
                for ( key in obj ) {
-                       if ( obj.hasOwnProperty( key ) ) {
+                       if ( Object.prototype.hasOwnProperty.call( obj, key ) ) {
                                return key;
                        }
                }
index 3f5a5db..dfb6967 100644 (file)
                        };
 
                        for ( id in panes ) {
-                               if ( !panes.hasOwnProperty( id ) ) {
+                               if ( !Object.prototype.hasOwnProperty.call( panes, id ) ) {
                                        continue;
                                }
 
                                        .appendTo( $table );
 
                                for ( key in data ) {
-                                       if ( !data.hasOwnProperty( key ) ) {
+                                       if ( !Object.prototype.hasOwnProperty.call( data, key ) ) {
                                                continue;
                                        }
 
index 4f9e43a..437800a 100644 (file)
                getAst: function ( key ) {
                        var wikiText;
 
-                       if ( !this.astCache.hasOwnProperty( key ) ) {
+                       if ( !Object.prototype.hasOwnProperty.call( this.astCache, key ) ) {
                                wikiText = this.settings.messages.get( key );
                                if ( typeof wikiText !== 'string' ) {
                                        wikiText = '⧼' + key + '⧽';
                        return oldParser.apply( this );
                }
 
-               if ( !this.map.hasOwnProperty( this.format ) ) {
+               if ( !Object.prototype.hasOwnProperty.call( this.map, this.format ) ) {
                        this.map[ this.format ] = mw.jqueryMsg.getMessageFunction( {
                                messages: this.map,
                                // For format 'escaped', escaping part is handled by mediawiki.js
index 267210c..4360adc 100644 (file)
                for ( i = 0; i < arguments.length; i++ ) {
                        table = arguments[ i ];
                        for ( key in table ) {
-                               if ( table.hasOwnProperty( key ) ) {
+                               if ( Object.prototype.hasOwnProperty.call( table, key ) ) {
                                        // The thousand separator should be deleted
                                        flipped[ table[ key ] ] = key === ',' ? '' : key;
                                }
                        if ( transformTable ) {
                                convertedNumber = '';
                                for ( i = 0; i < numberString.length; i++ ) {
-                                       if ( transformTable.hasOwnProperty( numberString[ i ] ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( transformTable, numberString[ i ] ) ) {
                                                convertedNumber += transformTable[ numberString[ i ] ];
                                        } else {
                                                convertedNumber += numberString[ i ];
index 5b41876..097653d 100644 (file)
@@ -90,7 +90,7 @@
 
                actionPaths = mw.config.get( 'wgActionPaths' );
                for ( key in actionPaths ) {
-                       if ( actionPaths.hasOwnProperty( key ) ) {
+                       if ( Object.prototype.hasOwnProperty.call( actionPaths, key ) ) {
                                parts = actionPaths[ key ].split( '$1' );
                                parts = parts.map( mw.RegExp.escape );
                                m = new RegExp( parts.join( '(.+)' ) ).exec( url );
index f936658..7c0d232 100644 (file)
                        var apiPromise,
                                deferred = $.Deferred();
 
-                       if ( moduleInfoCache.hasOwnProperty( module ) ) {
+                       if ( Object.prototype.hasOwnProperty.call( moduleInfoCache, module ) ) {
                                return deferred
                                        .resolve( moduleInfoCache[ module ] )
                                        .promise( { abort: function () {} } );
 
                                subpages = page.getSubpages();
                                for ( i = 0; i < subpages.length; i++ ) {
-                                       if ( pages.hasOwnProperty( subpages[ i ].key ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( pages, subpages[ i ].key ) ) {
                                                checkPages.push( pages[ subpages[ i ].key ] );
                                        }
                                }
                                        if ( page.getSubpages ) {
                                                subpages = page.getSubpages();
                                                for ( j = 0; j < subpages.length; j++ ) {
-                                                       if ( !pages.hasOwnProperty( subpages[ j ].key ) ) {
+                                                       if ( !Object.prototype.hasOwnProperty.call( pages, subpages[ j ].key ) ) {
                                                                subpages[ j ].indentLevel = page.indentLevel + 1;
                                                                pages[ subpages[ j ].key ] = new ApiSandbox.PageLayout( subpages[ j ] );
                                                        }
                                page.getQueryParams( params, displayParams );
                                subpages = page.getSubpages();
                                for ( i = 0; i < subpages.length; i++ ) {
-                                       if ( pages.hasOwnProperty( subpages[ i ].key ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( pages, subpages[ i ].key ) ) {
                                                checkPages.push( pages[ subpages[ i ].key ] );
                                        }
                                }
 
                                // Force a 'fm' format with wrappedhtml=1, if available
                                if ( params.format !== undefined ) {
-                                       if ( availableFormats.hasOwnProperty( params.format + 'fm' ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( availableFormats, params.format + 'fm' ) ) {
                                                params.format = params.format + 'fm';
                                        }
                                        if ( params.format.substr( -2 ) === 'fm' ) {
 
                                subpages = page.getSubpages();
                                for ( i = 0; i < subpages.length; i++ ) {
-                                       if ( pages.hasOwnProperty( subpages[ i ].key ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( pages, subpages[ i ].key ) ) {
                                                checkPages.push( pages[ subpages[ i ].key ] );
                                        }
                                }
                                page.apiCheckValid();
                                subpages = page.getSubpages();
                                for ( i = 0; i < subpages.length; i++ ) {
-                                       if ( pages.hasOwnProperty( subpages[ i ].key ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( pages, subpages[ i ].key ) ) {
                                                checkPages.push( pages[ subpages[ i ].key ] );
                                        }
                                }
                                                }
                                        }
                                        if ( params ) {
-                                               tmp.widget.setApiValue( params.hasOwnProperty( name ) ? params[ name ] : undefined );
+                                               tmp.widget.setApiValue( Object.prototype.hasOwnProperty.call( params, name ) ? params[ name ] : undefined );
                                        }
                                } else {
                                        newVars = {};
                                        buttons = [],
                                        filterFmModules = function ( v ) {
                                                return v.substr( -2 ) !== 'fm' ||
-                                                       !availableFormats.hasOwnProperty( v.substr( 0, v.length - 2 ) );
+                                                       !Object.prototype.hasOwnProperty.call( availableFormats, v.substr( 0, v.length - 2 ) );
                                        };
 
                                // This is something of a hack. We always want the 'format' and
                        this.loadFromQueryParams = params;
                } else {
                        $.each( this.widgets, function ( name, widget ) {
-                               var v = params.hasOwnProperty( name ) ? params[ name ] : undefined;
+                               var v = Object.prototype.hasOwnProperty.call( params, name ) ? params[ name ] : undefined;
                                widget.setApiValue( v );
                        } );
                        this.updateTemplatedParameters( params );
index 144659a..da54ad2 100644 (file)
@@ -37,7 +37,7 @@
                                clearTimeout( this.timeoutID );
                        }
                        // Check response cache
-                       if ( this.responseCache.hasOwnProperty( this.nameToCheck ) ) {
+                       if ( Object.prototype.hasOwnProperty.call( this.responseCache, this.nameToCheck ) ) {
                                this.setWarning( this.responseCache[ this.nameToCheck ] );
                                return;
                        }
                        var template = $element.val(),
                                $spinner;
 
-                       if ( this.responseCache.hasOwnProperty( template ) ) {
+                       if ( Object.prototype.hasOwnProperty.call( this.responseCache, template ) ) {
                                this.showPreview( this.responseCache[ template ], $previewContainer );
                                return;
                        }
index e2bbd68..bac0674 100644 (file)
                 *  corresponding call to set().
                 */
                clear: function ( visibleTimeoutId ) {
-                       if ( activeTimeouts.hasOwnProperty( visibleTimeoutId ) ) {
+                       if ( Object.prototype.hasOwnProperty.call( activeTimeouts, visibleTimeoutId ) ) {
                                activeTimeouts[ visibleTimeoutId ]();
                        }
                }
index 2340f9c..6ee9595 100644 (file)
                var api = this.getApi(),
                        cache = this.constructor.static.interwikiPrefixesPromiseCache,
                        key = api.defaults.ajax.url;
-               if ( !cache.hasOwnProperty( key ) ) {
+               if ( !Object.prototype.hasOwnProperty.call( cache, key ) ) {
                        cache[ key ] = api.get( {
                                action: 'query',
                                meta: 'siteinfo',