diff options
author | Timmy Willison <timmywil@users.noreply.github.com> | 2024-06-06 09:56:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-06 09:56:44 -0400 |
commit | 74970524e5e164c72ec0415267b1e057280c9455 (patch) | |
tree | b21a18d0e7f3bdab610cf3cc0a0bacc673ccc046 /test | |
parent | 46b9e4803ec3506e830ea6b49541ea29717ed460 (diff) | |
download | jquery-74970524e5e164c72ec0415267b1e057280c9455.tar.gz jquery-74970524e5e164c72ec0415267b1e057280c9455.zip |
Build: improve specificity of eslint config; add ecma versions
Closes gh-5501
Diffstat (limited to 'test')
-rw-r--r-- | test/bundler_smoke_tests/run-jsdom-tests.js | 2 | ||||
-rw-r--r-- | test/data/csp-nonce-external.js | 2 | ||||
-rw-r--r-- | test/data/csp-nonce-globaleval.js | 2 | ||||
-rw-r--r-- | test/data/csp-nonce.js | 2 | ||||
-rw-r--r-- | test/jquery.js | 2 | ||||
-rw-r--r-- | test/unit/attributes.js | 3 | ||||
-rw-r--r-- | test/unit/css.js | 7 | ||||
-rw-r--r-- | test/unit/data.js | 1 | ||||
-rw-r--r-- | test/unit/deferred.js | 4 | ||||
-rw-r--r-- | test/unit/effects.js | 7 | ||||
-rw-r--r-- | test/unit/event.js | 8 | ||||
-rw-r--r-- | test/unit/manipulation.js | 14 | ||||
-rw-r--r-- | test/unit/offset.js | 4 | ||||
-rw-r--r-- | test/unit/traversing.js | 2 |
14 files changed, 20 insertions, 40 deletions
diff --git a/test/bundler_smoke_tests/run-jsdom-tests.js b/test/bundler_smoke_tests/run-jsdom-tests.js index ba7100c44..f4eb54806 100644 --- a/test/bundler_smoke_tests/run-jsdom-tests.js +++ b/test/bundler_smoke_tests/run-jsdom-tests.js @@ -21,7 +21,7 @@ async function runJSDOMTest( { title, folder } ) { const virtualConsole = new jsdom.VirtualConsole(); virtualConsole.sendTo( console ); - virtualConsole.on( "assert", ( success, message ) => { + virtualConsole.on( "assert", ( success ) => { if ( !success ) { process.exitCode = 1; } diff --git a/test/data/csp-nonce-external.js b/test/data/csp-nonce-external.js index efedd5a9a..27132b3fb 100644 --- a/test/data/csp-nonce-external.js +++ b/test/data/csp-nonce-external.js @@ -1,5 +1,3 @@ -/* global startIframeTest */ - jQuery( function() { $( "body" ).append( "<script nonce='jquery+hardcoded+nonce' src='csp-nonce.js'></script>" ); } ); diff --git a/test/data/csp-nonce-globaleval.js b/test/data/csp-nonce-globaleval.js index 23d549fd6..8c6cb6346 100644 --- a/test/data/csp-nonce-globaleval.js +++ b/test/data/csp-nonce-globaleval.js @@ -1,5 +1,3 @@ -/* global startIframeTest */ - jQuery( function() { $.globalEval( "startIframeTest()", { nonce: "jquery+hardcoded+nonce" } ); } ); diff --git a/test/data/csp-nonce.js b/test/data/csp-nonce.js index 507e87e68..547891df5 100644 --- a/test/data/csp-nonce.js +++ b/test/data/csp-nonce.js @@ -1,5 +1,3 @@ -/* global startIframeTest */ - jQuery( function() { var script = document.createElement( "script" ); script.setAttribute( "nonce", "jquery+hardcoded+nonce" ); diff --git a/test/jquery.js b/test/jquery.js index a8a800d24..cd9c490b1 100644 --- a/test/jquery.js +++ b/test/jquery.js @@ -1,7 +1,5 @@ // Use the right jQuery source on the test page (and iframes) ( function() { - /* global loadTests: false */ - var dynamicImportSource, config, src, parentUrl = window.location.protocol + "//" + window.location.host, QUnit = window.QUnit; diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 477f3464a..b02e99e87 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -261,7 +261,7 @@ QUnit.test( "attr(String, Object)", function( assert ) { var $input, $text, $details, attributeNode, commentNode, textNode, obj, - table, td, j, type, + table, td, j, check, thrown, button, $radio, $radios, $svg, div = jQuery( "#qunit-fixture div" ).attr( "foo", "bar" ), i = 0, @@ -418,7 +418,6 @@ QUnit.test( "attr(String, Object)", function( assert ) { j.removeAttr( "name" ); // Type - type = jQuery( "#check2" ).attr( "type" ); try { jQuery( "#check2" ).attr( "type", "hidden" ); assert.ok( true, "No exception thrown on input type change" ); diff --git a/test/unit/css.js b/test/unit/css.js index a8b7d8e89..d872e52bb 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -7,7 +7,7 @@ QUnit.test( "css(String|Hash)", function( assert ) { assert.equal( jQuery( "#qunit-fixture" ).css( "display" ), "block", "Check for css property \"display\"" ); - var $child, div, div2, width, height, child, prctval, checkval, old; + var $child, div, div2, child, prctval, checkval, old; $child = jQuery( "#nothiddendivchild" ).css( { "width": "20%", "height": "20%" } ); assert.notEqual( $child.css( "width" ), "20px", "Retrieving a width percentage on the child of a hidden div returns percentage" ); @@ -36,8 +36,6 @@ QUnit.test( "css(String|Hash)", function( assert ) { // handle negative numbers by setting to zero trac-11604 jQuery( "#nothiddendiv" ).css( { "width": 1, "height": 1 } ); - width = parseFloat( jQuery( "#nothiddendiv" ).css( "width" ) ); - height = parseFloat( jQuery( "#nothiddendiv" ).css( "height" ) ); jQuery( "#nothiddendiv" ).css( { "overflow": "hidden", "width": -1, "height": -1 } ); assert.equal( parseFloat( jQuery( "#nothiddendiv" ).css( "width" ) ), 0, "Test negative width set to 0" ); assert.equal( parseFloat( jQuery( "#nothiddendiv" ).css( "height" ) ), 0, "Test negative height set to 0" ); @@ -274,8 +272,7 @@ QUnit.test( "css() non-px relative values (gh-1711)", function( assert ) { QUnit.test( "css() mismatched relative values with bounded styles (gh-2144)", function( assert ) { assert.expect( 1 ); - var right, - $container = jQuery( "<div></div>" ) + var $container = jQuery( "<div></div>" ) .css( { position: "absolute", width: "400px", fontSize: "4px" } ) .appendTo( "#qunit-fixture" ), $el = jQuery( "<div></div>" ) diff --git a/test/unit/data.js b/test/unit/data.js index 98973c6ed..d4a0f7b12 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -317,6 +317,7 @@ QUnit.test( "data-* attributes", function( assert ) { assert.equal( num, check.length, "Make sure that the right number of properties came through." ); + /* eslint-disable-next-line no-unused-vars */ for ( prop in obj2 ) { num2++; } diff --git a/test/unit/deferred.js b/test/unit/deferred.js index 45c94fd1d..1ff0e5618 100644 --- a/test/unit/deferred.js +++ b/test/unit/deferred.js @@ -823,11 +823,11 @@ QUnit.test( "jQuery.when(nonThenable) - like Promise.resolve", function( assert done = assert.async( 20 ); jQuery.when() - .done( function( resolveValue ) { + .done( function() { assert.strictEqual( arguments.length, 0, "Resolved .done with no arguments" ); assert.strictEqual( this, defaultContext, "Default .done context with no arguments" ); } ) - .then( function( resolveValue ) { + .then( function() { assert.strictEqual( arguments.length, 0, "Resolved .then with no arguments" ); assert.strictEqual( this, defaultContext, "Default .then context with no arguments" ); } ); diff --git a/test/unit/effects.js b/test/unit/effects.js index 8f6492124..2ba9ee686 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -1138,18 +1138,13 @@ QUnit.test( "interrupt toggle", function( assert ) { var longDuration = fxInterval * 200, shortDuration = fxInterval * 50, - remaining = 0, $elems = jQuery( ".chain-test" ), clock = this.clock, - finish = function() { - }; + finish = function() {}; jQuery.each( { slideToggle: "height", fadeToggle: "opacity", toggle: "width" }, function( method, prop ) { var $methodElems = $elems.filter( "[id^='" + method.toLowerCase() + "']" ).each( function() { - // Don't end test until we're done with this element - remaining++; - // Save original property value for comparison jQuery.data( this, "startVal", jQuery( this ).css( prop ) ); } ); diff --git a/test/unit/event.js b/test/unit/event.js index 111b1a18b..89d48c420 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2698,7 +2698,6 @@ testIframe( assert.expect( 1 ); var done = assert.async(), - focus = false, input = jQuery( frameDoc ).find( "#frame-input" ); // Create a focusin handler on the parent; shouldn't affect the iframe's fate @@ -3113,11 +3112,11 @@ QUnit.test( spy.immediate = sinon.stub( event.originalEvent, "stopImmediatePropagation" ); event.stopImmediatePropagation(); } ) - .on( "simulated", function( event ) { + .on( "simulated", function() { assert.ok( false, "simulated event immediate propagation stopped" ); } ); outer - .on( "simulated", function( event ) { + .on( "simulated", function() { assert.ok( false, "simulated event propagation stopped" ); } ); @@ -3180,8 +3179,7 @@ QUnit.test( "trigger('click') on radio passes extra params", function( assert ) QUnit.test( "focusout/focusin support", function( assert ) { assert.expect( 6 ); - var focus, - parent = jQuery( "<div>" ), + var parent = jQuery( "<div>" ), input = jQuery( "<input>" ), inputExternal = jQuery( "<input>" ); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index a3ac18eef..b91d72b29 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1329,7 +1329,7 @@ QUnit.test( "Empty replaceWith (trac-13401; trac-13596; gh-2204)", function( ass return input; } ); assert.strictEqual( $el.html(), "", "replaceWith(function returning " + label + ")" ); - $el.html( "<i></i>" ).children().replaceWith( function( i ) { + $el.html( "<i></i>" ).children().replaceWith( function() { return input; } ); assert.strictEqual( $el.html(), "", "replaceWith(other function returning " + label + ")" ); @@ -2661,8 +2661,6 @@ QUnit.test( "insertAfter, insertBefore, etc do not work when destination is orig assert.expect( 10 ); - var elems; - jQuery.each( [ "appendTo", "prependTo", @@ -2670,7 +2668,7 @@ QUnit.test( "insertAfter, insertBefore, etc do not work when destination is orig "insertAfter", "replaceAll" ], function( index, name ) { - elems = jQuery( [ + jQuery( [ "<ul id='test4087-complex'><li class='test4087'><div>c1</div>h1</li><li><div>c2</div>h2</li></ul>", "<div id='test4087-simple'><div class='test4087-1'>1<div class='test4087-2'>2</div><div class='test4087-3'>3</div></div></div>", "<div id='test4087-multiple'><div class='test4087-multiple'>1</div><div class='test4087-multiple'>2</div></div>" @@ -2955,7 +2953,7 @@ QUnit.test( "Ignore content from unsuccessful responses (gh-4126)", function( as assert.expect( 1 ); var globalEval = jQuery.globalEval; - jQuery.globalEval = function( code ) { + jQuery.globalEval = function( _code ) { assert.ok( false, "no attempt to evaluate code from an unsuccessful response" ); }; @@ -2973,7 +2971,7 @@ QUnit.test( "Ignore content from unsuccessful responses (gh-4126)", function( as testIframe( "Check if CSP nonce is preserved", "mock.php?action=cspNonce", - function( assert, jQuery, window, document ) { + function( assert ) { var done = assert.async(); assert.expect( 1 ); @@ -2988,7 +2986,7 @@ testIframe( testIframe( "Check if CSP nonce is preserved for external scripts with src attribute", "mock.php?action=cspNonce&test=external", - function( assert, jQuery, window, document ) { + function( assert ) { var done = assert.async(); assert.expect( 1 ); @@ -3006,7 +3004,7 @@ testIframe( testIframe( "jQuery.globalEval supports nonce", "mock.php?action=cspNonce&test=globaleval", - function( assert, jQuery, window, document ) { + function( assert ) { var done = assert.async(); assert.expect( 1 ); diff --git a/test/unit/offset.js b/test/unit/offset.js index 50eee3dd5..a62ebde5b 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -4,7 +4,7 @@ if ( !includesModule( "offset" ) ) { return; } -var supportsScroll, alwaysScrollable, +var alwaysScrollable, forceScroll = supportjQuery( "<div></div>" ).css( { width: 2000, height: 2000 } ), checkSupport = function( assert ) { @@ -14,7 +14,7 @@ var supportsScroll, alwaysScrollable, // Append forceScroll to the body instead of #qunit-fixture because the latter is hidden forceScroll.appendTo( "body" ); window.scrollTo( 200, 200 ); - supportsScroll = document.documentElement.scrollTop || document.body.scrollTop; + window.supportsScroll = document.documentElement.scrollTop || document.body.scrollTop; forceScroll.detach(); // Support: iOS <=7 - 12+ diff --git a/test/unit/traversing.js b/test/unit/traversing.js index acc9c732d..d3f69db81 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -857,7 +857,7 @@ QUnit.testUnlessIE( "contents() for <template /> remains inert", function( asser "</template>" ); - var content = jQuery( "#template" ).contents(); + jQuery( "#template" ).contents(); assert.strictEqual( window.testScript, true, "script in template isn't executed" ); assert.strictEqual( window.testImgOnload, true, "onload of image in template isn't executed" ); |