From 42fe11a2e6b40a6e2e8cfe4b58b31d5ed91821d5 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Thu, 3 Sep 2015 13:13:33 -0700 Subject: [PATCH] build: Enable jscs rule 'requireSpacesInsideParentheses' and make pass Change-Id: Ie88c89344e54657f007e5101472e667be5408319 --- .jscsrc | 1 - Gruntfile.js | 2 +- mw-config/config.js | 18 +- resources/src/jquery/jquery.color.js | 8 +- resources/src/jquery/jquery.colorUtil.js | 36 ++-- resources/src/jquery/jquery.placeholder.js | 162 +++++++++--------- .../src/mediawiki.api/mediawiki.api.upload.js | 2 +- .../src/mediawiki.language/languages/la.js | 4 +- .../src/mediawiki.language/languages/uk.js | 14 +- .../mediawiki.language.numbers.js | 2 +- .../mediawiki.special.preferences.js | 2 +- tests/qunit/data/testrunner.js | 4 +- .../jquery/jquery.mwExtension.test.js | 2 +- .../jquery/jquery.placeholder.test.js | 162 +++++++++--------- .../jquery/jquery.tablesorter.parsers.test.js | 2 +- .../jquery/jquery.tablesorter.test.js | 2 +- .../mediawiki/mediawiki.Title.test.js | 2 +- .../mediawiki/mediawiki.errorLogger.test.js | 2 +- .../mediawiki/mediawiki.jscompat.test.js | 2 +- .../resources/mediawiki/mediawiki.test.js | 2 +- 20 files changed, 215 insertions(+), 216 deletions(-) diff --git a/.jscsrc b/.jscsrc index c9f9a4608a..1031f048a5 100644 --- a/.jscsrc +++ b/.jscsrc @@ -2,7 +2,6 @@ "preset": "wikimedia", "disallowQuotedKeysInObjects": null, - "requireSpacesInsideParentheses": null, "requireSpacesInsideArrayBrackets": null, "requireVarDeclFirst": null, "requireSpacesInsideBrackets": null, diff --git a/Gruntfile.js b/Gruntfile.js index e1e5e4ab01..4d713f2a58 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -87,7 +87,7 @@ module.exports = function ( grunt ) { } if ( !process.env.MW_SCRIPT_PATH ) { grunt.log.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' + - 'Set this like $wgScriptPath, e.g. "/w"'); + 'Set this like $wgScriptPath, e.g. "/w"' ); } return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH ); } ); diff --git a/mw-config/config.js b/mw-config/config.js index cf17aef77c..d2dc213213 100644 --- a/mw-config/config.js +++ b/mw-config/config.js @@ -3,7 +3,7 @@ var $label, labelText; function syncText() { - var value = $(this).val() + var value = $( this ).val() .replace( /[\[\]\{\}|#<>%+? ]/g, '_' ) .replace( /&/, '&' ) .replace( /__+/g, '_' ) @@ -20,7 +20,7 @@ .find( '.mw-help-field-hint' ) .show() .click( function () { - $(this) + $( this ) .closest( '.mw-help-field-container' ) .find( '.mw-help-field-data' ) .slideToggle( 'fast' ); @@ -29,7 +29,7 @@ // Show/hide code for DB-specific options // FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here? $( '.dbRadio' ).each( function () { - $( document.getElementById( $(this).attr( 'rel' ) ) ).hide(); + $( document.getElementById( $( this ).attr( 'rel' ) ) ).hide(); } ); $( document.getElementById( $( '.dbRadio:checked' ).attr( 'rel' ) ) ).show(); $( '.dbRadio' ).click( function () { @@ -58,16 +58,16 @@ // Show/hide random stuff (email, upload) $( '.showHideRadio' ).click( function () { - var $wrapper = $( '#' + $(this).attr( 'rel' ) ); - if ( $(this).is( ':checked' ) ) { + var $wrapper = $( '#' + $( this ).attr( 'rel' ) ); + if ( $( this ).is( ':checked' ) ) { $wrapper.show( 'slow' ); } else { $wrapper.hide( 'slow' ); } } ); $( '.hideShowRadio' ).click( function () { - var $wrapper = $( '#' + $(this).attr( 'rel' ) ); - if ( $(this).is( ':checked' ) ) { + var $wrapper = $( '#' + $( this ).attr( 'rel' ) ); + if ( $( this ).is( ':checked' ) ) { $wrapper.hide( 'slow' ); } else { $wrapper.show( 'slow' ); @@ -80,9 +80,9 @@ // Enable/disable "other" textboxes $( '.enableForOther' ).click( function () { - var $textbox = $( document.getElementById( $(this).attr( 'rel' ) ) ); + var $textbox = $( document.getElementById( $( this ).attr( 'rel' ) ) ); // FIXME: Ugh, this is ugly - if ( $(this).val() === 'other' ) { + if ( $( this ).val() === 'other' ) { $textbox.removeProp( 'readonly' ).closest( '.config-block' ).slideDown( 'fast' ); } else { $textbox.prop( 'readonly', true ).closest( '.config-block' ).slideUp( 'fast' ); diff --git a/resources/src/jquery/jquery.color.js b/resources/src/jquery/jquery.color.js index 04f8047b8e..5357a85874 100644 --- a/resources/src/jquery/jquery.color.js +++ b/resources/src/jquery/jquery.color.js @@ -28,7 +28,7 @@ } // We override the animation for all of these color styles - $.each([ + $.each( [ 'backgroundColor', 'borderBottomColor', 'borderLeftColor', @@ -45,9 +45,9 @@ } fx.elem.style[attr] = 'rgb(' + [ - Math.max( Math.min( parseInt( (fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10 ), 255 ), 0 ), - Math.max( Math.min( parseInt( (fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10 ), 255 ), 0 ), - Math.max( Math.min( parseInt( (fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10 ), 255 ), 0 ) + Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[0] - fx.start[0] ) ) + fx.start[0], 10 ), 255 ), 0 ), + Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[1] - fx.start[1] ) ) + fx.start[1], 10 ), 255 ), 0 ), + Math.max( Math.min( parseInt( ( fx.pos * ( fx.end[2] - fx.start[2] ) ) + fx.start[2], 10 ), 255 ), 0 ) ].join( ',' ) + ')'; }; } ); diff --git a/resources/src/jquery/jquery.colorUtil.js b/resources/src/jquery/jquery.colorUtil.js index a6ff8bc8bc..d5bb051be2 100644 --- a/resources/src/jquery/jquery.colorUtil.js +++ b/resources/src/jquery/jquery.colorUtil.js @@ -32,7 +32,7 @@ } // Look for rgb(num,num,num) - if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) { + if ( result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec( color ) ) { return [ parseInt( result[1], 10 ), parseInt( result[2], 10 ), @@ -41,7 +41,7 @@ } // Look for rgb(num%,num%,num%) - if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) { + if ( result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec( color ) ) { return [ parseFloat( result[1] ) * 2.55, parseFloat( result[2] ) * 2.55, @@ -50,7 +50,7 @@ } // Look for #a0b1c2 - if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) { + if ( result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec( color ) ) { return [ parseInt( result[1], 16 ), parseInt( result[2], 16 ), @@ -59,21 +59,21 @@ } // Look for #fff - if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) { + if ( result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec( color ) ) { return [ parseInt( result[1] + result[1], 16 ), parseInt( result[2] + result[2], 16 ), - parseInt( result[3] + result[3], 16) + parseInt( result[3] + result[3], 16 ) ]; } // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 - if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) { + if ( result = /rgba\(0, 0, 0, 0\)/.exec( color ) ) { return $.colorUtil.colors.transparent; } // Otherwise, we're most likely dealing with a named color - return $.colorUtil.colors[$.trim(color).toLowerCase()]; + return $.colorUtil.colors[$.trim( color ).toLowerCase()]; }, /** @@ -157,23 +157,23 @@ min = Math.min( r, g, b ), h, s, - l = (max + min) / 2; + l = ( max + min ) / 2; if ( max === min ) { // achromatic h = s = 0; } else { d = max - min; - s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + s = l > 0.5 ? d / ( 2 - max - min ) : d / ( max + min ); switch ( max ) { case r: - h = (g - b) / d + (g < b ? 6 : 0); + h = ( g - b ) / d + ( g < b ? 6 : 0 ); break; case g: - h = (b - r) / d + 2; + h = ( b - r ) / d + 2; break; case b: - h = (r - g) / d + 4; + h = ( r - g ) / d + 4; break; } h /= 6; @@ -212,18 +212,18 @@ t -= 1; } if ( t < 1 / 6 ) { - return p + (q - p) * 6 * t; + return p + ( q - p ) * 6 * t; } if ( t < 1 / 2 ) { return q; } if ( t < 2 / 3 ) { - return p + (q - p) * (2 / 3 - t) * 6; + return p + ( q - p ) * ( 2 / 3 - t ) * 6; } return p; }; - q = l < 0.5 ? l * (1 + s) : l + s - l * s; + q = l < 0.5 ? l * ( 1 + s ) : l + s - l * s; p = 2 * l - q; r = hue2rgb( p, q, h + 1 / 3 ); g = hue2rgb( p, q, h ); @@ -249,11 +249,11 @@ */ getColorBrightness: function ( currentColor, mod ) { var rgbArr = $.colorUtil.getRGB( currentColor ), - hslArr = $.colorUtil.rgbToHsl(rgbArr[0], rgbArr[1], rgbArr[2] ); - rgbArr = $.colorUtil.hslToRgb(hslArr[0], hslArr[1], hslArr[2] + mod); + hslArr = $.colorUtil.rgbToHsl( rgbArr[0], rgbArr[1], rgbArr[2] ); + rgbArr = $.colorUtil.hslToRgb( hslArr[0], hslArr[1], hslArr[2] + mod ); return 'rgb(' + - [parseInt( rgbArr[0], 10), parseInt( rgbArr[1], 10 ), parseInt( rgbArr[2], 10 )].join( ',' ) + + [parseInt( rgbArr[0], 10 ), parseInt( rgbArr[1], 10 ), parseInt( rgbArr[2], 10 )].join( ',' ) + ')'; } diff --git a/resources/src/jquery/jquery.placeholder.js b/resources/src/jquery/jquery.placeholder.js index 3d25a93c25..bdd2cefad4 100644 --- a/resources/src/jquery/jquery.placeholder.js +++ b/resources/src/jquery/jquery.placeholder.js @@ -13,10 +13,10 @@ * @version 2.1.0 * @license MIT */ -( function ($) { +( function ( $ ) { - var isInputSupported = 'placeholder' in document.createElement('input'), - isTextareaSupported = 'placeholder' in document.createElement('textarea'), + var isInputSupported = 'placeholder' in document.createElement( 'input' ), + isTextareaSupported = 'placeholder' in document.createElement( 'textarea' ), prototype = $.fn, valHooks = $.valHooks, propHooks = $.propHooks, @@ -28,37 +28,37 @@ // https://github.com/mathiasbynens/jquery-placeholder/pull/99 try { return document.activeElement; - } catch (err) {} + } catch ( err ) {} } - function args(elem) { + function args( elem ) { // Return an object of element attributes var newAttrs = {}, rinlinejQuery = /^jQuery\d+$/; - $.each(elem.attributes, function (i, attr) { - if (attr.specified && !rinlinejQuery.test(attr.name)) { + $.each( elem.attributes, function ( i, attr ) { + if ( attr.specified && !rinlinejQuery.test( attr.name ) ) { newAttrs[attr.name] = attr.value; } - }); + } ); return newAttrs; } - function clearPlaceholder(event, value) { + function clearPlaceholder( event, value ) { var input = this, - $input = $(input); - if (input.value === $input.attr('placeholder') && $input.hasClass('placeholder')) { - if ($input.data('placeholder-password')) { - $input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id')); + $input = $( input ); + if ( input.value === $input.attr( 'placeholder' ) && $input.hasClass( 'placeholder' ) ) { + if ( $input.data( 'placeholder-password' ) ) { + $input = $input.hide().next().show().attr( 'id', $input.removeAttr( 'id' ).data( 'placeholder-id' ) ); // If `clearPlaceholder` was called from `$.valHooks.input.set` - if (event === true) { + if ( event === true ) { $input[0].value = value; return value; } $input.focus(); } else { input.value = ''; - $input.removeClass('placeholder'); - if (input === safeActiveElement()) { + $input.removeClass( 'placeholder' ); + if ( input === safeActiveElement() ) { input.select(); } } @@ -68,60 +68,60 @@ function setPlaceholder() { var $replacement, input = this, - $input = $(input), + $input = $( input ), id = this.id; - if (!input.value) { - if (input.type === 'password') { - if (!$input.data('placeholder-textinput')) { + if ( !input.value ) { + if ( input.type === 'password' ) { + if ( !$input.data( 'placeholder-textinput' ) ) { try { - $replacement = $input.clone().attr({ 'type': 'text' }); - } catch (e) { - $replacement = $('').attr($.extend(args(this), { 'type': 'text' })); + $replacement = $input.clone().attr( { 'type': 'text' } ); + } catch ( e ) { + $replacement = $( '' ).attr( $.extend( args( this ), { 'type': 'text' } ) ); } $replacement - .removeAttr('name') - .data({ + .removeAttr( 'name' ) + .data( { 'placeholder-password': $input, 'placeholder-id': id - }) - .bind('focus.placeholder drop.placeholder', clearPlaceholder); + } ) + .bind( 'focus.placeholder drop.placeholder', clearPlaceholder ); $input - .data({ + .data( { 'placeholder-textinput': $replacement, 'placeholder-id': id - }) - .before($replacement); + } ) + .before( $replacement ); } - $input = $input.removeAttr('id').hide().prev().attr('id', id).show(); + $input = $input.removeAttr( 'id' ).hide().prev().attr( 'id', id ).show(); // Note: `$input[0] != input` now! } - $input.addClass('placeholder'); - $input[0].value = $input.attr('placeholder'); + $input.addClass( 'placeholder' ); + $input[0].value = $input.attr( 'placeholder' ); } else { - $input.removeClass('placeholder'); + $input.removeClass( 'placeholder' ); } } - function changePlaceholder(text) { + function changePlaceholder( text ) { var hasArgs = arguments.length, $input = this; - if (hasArgs) { - if ($input.attr('placeholder') !== text) { - $input.prop('placeholder', text); - if ($input.hasClass('placeholder')) { + if ( hasArgs ) { + if ( $input.attr( 'placeholder' ) !== text ) { + $input.prop( 'placeholder', text ); + if ( $input.hasClass( 'placeholder' ) ) { $input[0].value = text; } } } } - if (isInputSupported && isTextareaSupported) { + if ( isInputSupported && isTextareaSupported ) { - placeholder = prototype.placeholder = function (text) { + placeholder = prototype.placeholder = function ( text ) { var hasArgs = arguments.length; - if (hasArgs) { - changePlaceholder.call(this, text); + if ( hasArgs ) { + changePlaceholder.call( this, text ); } return this; @@ -131,25 +131,25 @@ } else { - placeholder = prototype.placeholder = function (text) { + placeholder = prototype.placeholder = function ( text ) { var $this = this, hasArgs = arguments.length; - if (hasArgs) { - changePlaceholder.call(this, text); + if ( hasArgs ) { + changePlaceholder.call( this, text ); } $this - .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]') + .filter( ( isInputSupported ? 'textarea' : ':input' ) + '[placeholder]' ) .filter( function () { - return !$(this).data('placeholder-enabled'); - }) - .bind({ + return !$( this ).data( 'placeholder-enabled' ); + } ) + .bind( { 'focus.placeholder drop.placeholder': clearPlaceholder, 'blur.placeholder': setPlaceholder - }) - .data('placeholder-enabled', true) - .trigger('blur.placeholder'); + } ) + .data( 'placeholder-enabled', true ) + .trigger( 'blur.placeholder' ); return $this; }; @@ -157,36 +157,36 @@ placeholder.textarea = isTextareaSupported; hooks = { - 'get': function (element) { - var $element = $(element), - $passwordInput = $element.data('placeholder-password'); - if ($passwordInput) { + 'get': function ( element ) { + var $element = $( element ), + $passwordInput = $element.data( 'placeholder-password' ); + if ( $passwordInput ) { return $passwordInput[0].value; } - return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value; + return $element.data( 'placeholder-enabled' ) && $element.hasClass( 'placeholder' ) ? '' : element.value; }, - 'set': function (element, value) { - var $element = $(element), - $passwordInput = $element.data('placeholder-password'); - if ($passwordInput) { + 'set': function ( element, value ) { + var $element = $( element ), + $passwordInput = $element.data( 'placeholder-password' ); + if ( $passwordInput ) { $passwordInput[0].value = value; return value; } - if (!$element.data('placeholder-enabled')) { + if ( !$element.data( 'placeholder-enabled' ) ) { element.value = value; return value; } - if (!value) { + if ( !value ) { element.value = value; // Issue #56: Setting the placeholder causes problems if the element continues to have focus. - if (element !== safeActiveElement()) { + if ( element !== safeActiveElement() ) { // We can't use `triggerHandler` here because of dummy text/password inputs :( - setPlaceholder.call(element); + setPlaceholder.call( element ); } - } else if ($element.hasClass('placeholder')) { - if (!clearPlaceholder.call(element, true, value)) { + } else if ( $element.hasClass( 'placeholder' ) ) { + if ( !clearPlaceholder.call( element, true, value ) ) { element.value = value; } } else { @@ -197,32 +197,32 @@ } }; - if (!isInputSupported) { + if ( !isInputSupported ) { valHooks.input = hooks; propHooks.value = hooks; } - if (!isTextareaSupported) { + if ( !isTextareaSupported ) { valHooks.textarea = hooks; propHooks.value = hooks; } $( function () { // Look for forms - $(document).delegate('form', 'submit.placeholder', function () { + $( document ).delegate( 'form', 'submit.placeholder', function () { // Clear the placeholder values so they don't get submitted - var $inputs = $('.placeholder', this).each(clearPlaceholder); + var $inputs = $( '.placeholder', this ).each( clearPlaceholder ); setTimeout( function () { - $inputs.each(setPlaceholder); - }, 10); - }); - }); + $inputs.each( setPlaceholder ); + }, 10 ); + } ); + } ); // Clear placeholder values upon page reload - $(window).bind('beforeunload.placeholder', function () { - $('.placeholder').each( function () { + $( window ).bind( 'beforeunload.placeholder', function () { + $( '.placeholder' ).each( function () { this.value = ''; - }); - }); + } ); + } ); } -}(jQuery)); +}( jQuery ) ); diff --git a/resources/src/mediawiki.api/mediawiki.api.upload.js b/resources/src/mediawiki.api/mediawiki.api.upload.js index d05ba57809..76df7c8957 100644 --- a/resources/src/mediawiki.api/mediawiki.api.upload.js +++ b/resources/src/mediawiki.api/mediawiki.api.upload.js @@ -42,7 +42,7 @@ * @return {jQuery} */ function getHiddenInput( name, val ) { - return $( '') + return $( '' ) .attr( 'name', name ) .val( val ); } diff --git a/resources/src/mediawiki.language/languages/la.js b/resources/src/mediawiki.language/languages/la.js index 52e8dd4429..8dc589e5bc 100644 --- a/resources/src/mediawiki.language/languages/la.js +++ b/resources/src/mediawiki.language/languages/la.js @@ -30,7 +30,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) { word = word.replace( /nuntii$/i, 'nuntios' );// 2nd declension plural (partly) word = word.replace( /tio$/i, 'tionem' ); // 3rd declension singular (partly) word = word.replace( /ns$/i, 'ntem' ); - word = word.replace( /as$/i, 'atem'); + word = word.replace( /as$/i, 'atem' ); word = word.replace( /es$/i, 'em' ); // 5th declension singular break; case 'ablative': @@ -42,7 +42,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) { word = word.replace( /nuntii$/i, 'nuntiis' ); // 2nd declension plural (partly) word = word.replace( /tio$/i, 'tione' ); // 3rd declension singular (partly) word = word.replace( /ns$/i, 'nte' ); - word = word.replace( /as$/i, 'ate'); + word = word.replace( /as$/i, 'ate' ); word = word.replace( /es$/i, 'e' ); // 5th declension singular break; } diff --git a/resources/src/mediawiki.language/languages/uk.js b/resources/src/mediawiki.language/languages/uk.js index 550a388c25..a0215333c3 100644 --- a/resources/src/mediawiki.language/languages/uk.js +++ b/resources/src/mediawiki.language/languages/uk.js @@ -11,24 +11,24 @@ mediaWiki.language.convertGrammar = function ( word, form ) { case 'genitive': // родовий відмінок if ( word.slice( -4 ) !== 'вікі' && word.slice( -4 ) !== 'Вікі' ) { if ( word.slice( -1 ) === 'ь' ) { - word = word.slice(0, -1 ) + 'я'; + word = word.slice( 0, -1 ) + 'я'; } else if ( word.slice( -2 ) === 'ія' ) { - word = word.slice(0, -2 ) + 'ії'; + word = word.slice( 0, -2 ) + 'ії'; } else if ( word.slice( -2 ) === 'ка' ) { - word = word.slice(0, -2 ) + 'ки'; + word = word.slice( 0, -2 ) + 'ки'; } else if ( word.slice( -2 ) === 'ти' ) { - word = word.slice(0, -2 ) + 'тей'; + word = word.slice( 0, -2 ) + 'тей'; } else if ( word.slice( -2 ) === 'ды' ) { - word = word.slice(0, -2 ) + 'дов'; + word = word.slice( 0, -2 ) + 'дов'; } else if ( word.slice( -3 ) === 'ник' ) { - word = word.slice(0, -3 ) + 'ника'; + word = word.slice( 0, -3 ) + 'ника'; } } break; case 'accusative': // знахідний відмінок if ( word.slice( -4 ) !== 'вікі' && word.slice( -4 ) !== 'Вікі' ) { if ( word.slice( -2 ) === 'ія' ) { - word = word.slice(0, -2 ) + 'ію'; + word = word.slice( 0, -2 ) + 'ію'; } } break; diff --git a/resources/src/mediawiki.language/mediawiki.language.numbers.js b/resources/src/mediawiki.language/mediawiki.language.numbers.js index 1481d2aafd..36c281c357 100644 --- a/resources/src/mediawiki.language/mediawiki.language.numbers.js +++ b/resources/src/mediawiki.language/mediawiki.language.numbers.js @@ -74,7 +74,7 @@ decimal: '.' }; - if ( isNaN( value) ) { + if ( isNaN( value ) ) { return value; } diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.js b/resources/src/mediawiki.special/mediawiki.special.preferences.js index 893db9827e..113f8fb4cf 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.js +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.js @@ -130,7 +130,7 @@ jQuery( function ( $ ) { // Disable the button to save preferences unless preferences have changed $( '#prefcontrol' ).prop( 'disabled', true ); $( '.prefsection' ).one( 'change keydown mousedown', function () { - $( '#prefcontrol' ).prop( 'disabled', false); + $( '#prefcontrol' ).prop( 'disabled', false ); } ); // Enable keyboard users to use left and right keys to switch tabs diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index 78771decd0..ab5229ec40 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -13,7 +13,7 @@ * @return {String} Such as 'data/foo.js?131031765087663960' */ QUnit.fixurl = function ( value ) { - return value + (/\?/.test( value ) ? '&' : '?') + return value + ( /\?/.test( value ) ? '&' : '?' ) + String( new Date().getTime() ) + String( parseInt( Math.random() * 100000, 10 ) ); }; @@ -268,7 +268,7 @@ $.each( $.timers, function ( i, timer ) { var node = timer.elem; mw.log.warn( 'Unfinished animation #' + i + ' in ' + timer.queue + ' queue on ' + - mw.html.element( node.nodeName.toLowerCase(), $(node).getAttrs() ) + mw.html.element( node.nodeName.toLowerCase(), $( node ).getAttrs() ) ); } ); // Force animations to stop to give the next test a clean start diff --git a/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js b/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js index 911e9d01ca..1be8e0c8f1 100644 --- a/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js @@ -8,7 +8,7 @@ teardown: function () { this.restoreWarnings(); } - }) ); + } ) ); QUnit.test( 'String functions', 7, function ( assert ) { assert.equal( $.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' ); diff --git a/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js b/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js index 78c185f108..23ad9d989c 100644 --- a/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js @@ -1,13 +1,13 @@ -( function ($) { +( function ( $ ) { - QUnit.module('jquery.placeholder', QUnit.newMwEnvironment()); + QUnit.module( 'jquery.placeholder', QUnit.newMwEnvironment() ); - QUnit.test('caches results of feature tests', 2, function (assert) { - assert.strictEqual( typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input'); - assert.strictEqual( typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea'); - }); + QUnit.test( 'caches results of feature tests', 2, function ( assert ) { + assert.strictEqual( typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input' ); + assert.strictEqual( typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea' ); + } ); - if ($.fn.placeholder.input && $.fn.placeholder.textarea) { + if ( $.fn.placeholder.input && $.fn.placeholder.textarea ) { return; } @@ -20,126 +20,126 @@ '' + '' + '', - testElement = function ($el, assert) { + testElement = function ( $el, assert ) { var el = $el[0], - placeholder = el.getAttribute('placeholder'); + placeholder = el.getAttribute( 'placeholder' ); - assert.strictEqual($el.placeholder(), $el, 'should be chainable'); + assert.strictEqual( $el.placeholder(), $el, 'should be chainable' ); - assert.strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok($el.hasClass('placeholder'), 'should have `placeholder` class'); + assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( $el.hasClass( 'placeholder' ), 'should have `placeholder` class' ); // test on focus $el.focus(); - assert.strictEqual(el.value, '', '`value` should be the empty string on focus'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok(!$el.hasClass('placeholder'), 'should not have `placeholder` class on focus'); + assert.strictEqual( el.value, '', '`value` should be the empty string on focus' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( !$el.hasClass( 'placeholder' ), 'should not have `placeholder` class on focus' ); // and unfocus (blur) again $el.blur(); - assert.strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok($el.hasClass('placeholder'), 'should have `placeholder` class'); + assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( $el.hasClass( 'placeholder' ), 'should have `placeholder` class' ); // change the value - $el.val('lorem ipsum'); - assert.strictEqual($el.prop('value'), 'lorem ipsum', '`$el.val(string)` should change the `value` property'); - assert.strictEqual(el.value, 'lorem ipsum', '`$el.val(string)` should change the `value` attribute'); - assert.ok(!$el.hasClass('placeholder'), '`$el.val(string)` should remove `placeholder` class'); + $el.val( 'lorem ipsum' ); + assert.strictEqual( $el.prop( 'value' ), 'lorem ipsum', '`$el.val(string)` should change the `value` property' ); + assert.strictEqual( el.value, 'lorem ipsum', '`$el.val(string)` should change the `value` attribute' ); + assert.ok( !$el.hasClass( 'placeholder' ), '`$el.val(string)` should remove `placeholder` class' ); // and clear it again - $el.val(''); - assert.strictEqual($el.prop('value'), '', '`$el.val("")` should change the `value` property'); - assert.strictEqual(el.value, placeholder, '`$el.val("")` should change the `value` attribute'); - assert.ok($el.hasClass('placeholder'), '`$el.val("")` should re-enable `placeholder` class'); + $el.val( '' ); + assert.strictEqual( $el.prop( 'value' ), '', '`$el.val("")` should change the `value` property' ); + assert.strictEqual( el.value, placeholder, '`$el.val("")` should change the `value` attribute' ); + assert.ok( $el.hasClass( 'placeholder' ), '`$el.val("")` should re-enable `placeholder` class' ); // make sure the placeholder property works as expected. - assert.strictEqual($el.prop('placeholder'), placeholder, '$el.prop(`placeholder`) should return the placeholder value'); - $el.placeholder('new placeholder'); - assert.strictEqual(el.getAttribute('placeholder'), 'new placeholder', '$el.placeholder() should set the placeholder value'); - assert.strictEqual(el.value, 'new placeholder', '$el.placeholder() should update the displayed placeholder value'); - $el.placeholder(placeholder); + assert.strictEqual( $el.prop( 'placeholder' ), placeholder, '$el.prop(`placeholder`) should return the placeholder value' ); + $el.placeholder( 'new placeholder' ); + assert.strictEqual( el.getAttribute( 'placeholder' ), 'new placeholder', '$el.placeholder() should set the placeholder value' ); + assert.strictEqual( el.value, 'new placeholder', '$el.placeholder() should update the displayed placeholder value' ); + $el.placeholder( placeholder ); }; - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-text'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-text' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-search'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-search' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-email'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-email' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-url'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-url' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#input-type-tel'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#input-type-tel' ), assert ); + } ); - QUnit.test('emulates placeholder for ', 13, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); + QUnit.test( 'emulates placeholder for ', 13, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); var selector = '#input-type-password', - $el = $(selector), + $el = $( selector ), el = $el[0], - placeholder = el.getAttribute('placeholder'); + placeholder = el.getAttribute( 'placeholder' ); - assert.strictEqual($el.placeholder(), $el, 'should be chainable'); + assert.strictEqual( $el.placeholder(), $el, 'should be chainable' ); // Re-select the element, as it gets replaced by another one in some browsers - $el = $(selector); + $el = $( selector ); el = $el[0]; - assert.strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok($el.hasClass('placeholder'), 'should have `placeholder` class'); + assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( $el.hasClass( 'placeholder' ), 'should have `placeholder` class' ); // test on focus $el.focus(); // Re-select the element, as it gets replaced by another one in some browsers - $el = $(selector); + $el = $( selector ); el = $el[0]; - assert.strictEqual(el.value, '', '`value` should be the empty string on focus'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok(!$el.hasClass('placeholder'), 'should not have `placeholder` class on focus'); + assert.strictEqual( el.value, '', '`value` should be the empty string on focus' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( !$el.hasClass( 'placeholder' ), 'should not have `placeholder` class on focus' ); // and unfocus (blur) again $el.blur(); // Re-select the element, as it gets replaced by another one in some browsers - $el = $(selector); + $el = $( selector ); el = $el[0]; - assert.strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`'); - assert.strictEqual($el.prop('value'), '', 'propHooks works properly'); - assert.strictEqual($el.val(), '', 'valHooks works properly'); - assert.ok($el.hasClass('placeholder'), 'should have `placeholder` class'); + assert.strictEqual( el.value, placeholder, 'should set `placeholder` text as `value`' ); + assert.strictEqual( $el.prop( 'value' ), '', 'propHooks works properly' ); + assert.strictEqual( $el.val(), '', 'valHooks works properly' ); + assert.ok( $el.hasClass( 'placeholder' ), 'should have `placeholder` class' ); - }); + } ); - QUnit.test('emulates placeholder for ', 22, function (assert) { - $('
').html(html).appendTo($('#qunit-fixture')); - testElement($('#textarea'), assert); - }); + QUnit.test( 'emulates placeholder for ', 22, function ( assert ) { + $( '
' ).html( html ).appendTo( $( '#qunit-fixture' ) ); + testElement( $( '#textarea' ), assert ); + } ); -}(jQuery)); +}( jQuery ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js index 00d4a08ed0..cc1e6df8a7 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js @@ -57,7 +57,7 @@ QUnit.test( msg, data.length * 2, function ( assert ) { var extractedR, extractedF, parser; - if (callback !== undefined ) { + if ( callback !== undefined ) { callback(); } diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js index acd98a66b4..480e12723c 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js @@ -1238,7 +1238,7 @@ '' ); $table.tablesorter(); - assert.equal( $table.find( 'tr:eq(1) th:eq(1)').data('headerIndex'), + assert.equal( $table.find( 'tr:eq(1) th:eq(1)' ).data( 'headerIndex' ), 2, 'Incorrect index of sort header' ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js index 284f21af87..253ac39bb5 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js @@ -338,7 +338,7 @@ title = new mw.Title( 'Foobar' ); assert.equal( title.getUrl(), '/wiki/Foobar', 'Basic functionality, getUrl uses mw.util.getUrl' ); - assert.equal( title.getUrl({ action: 'edit' }), '/wiki/Foobar?action=edit', 'Basic functionality, \'params\' parameter' ); + assert.equal( title.getUrl( { action: 'edit' } ), '/wiki/Foobar?action=edit', 'Basic functionality, \'params\' parameter' ); title = new mw.Title( 'John Doe', 3 ); assert.equal( title.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.errorLogger.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.errorLogger.test.js index 7c3f1ecb3b..587c893167 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.errorLogger.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.errorLogger.test.js @@ -7,7 +7,7 @@ errorUrl = 'http://example.com', errorLine = '123', errorColumn = '45', - errorObject = new Error( 'Foo'), + errorObject = new Error( 'Foo' ), oldHandler = this.sandbox.stub(); this.sandbox.stub( mw, 'track' ); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js index 3328ce3f1a..3b5915ac28 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js @@ -61,7 +61,7 @@ expected = repeat( '\n', n ) + 'some text'; $textarea = $( '' ); - assert.equal( $textarea.val(), expected, 'Expecting ' + n + ' newlines (HTML contained ' + (n + 1) + ')' ); + assert.equal( $textarea.val(), expected, 'Expecting ' + n + ' newlines (HTML contained ' + ( n + 1 ) + ')' ); $textarea = $( '