Build: upgrade dependencies, including eslint 9.4.0 and uglify 3.7.7

- Sinon is already at the latest version that supports IE9.
- Upgraded uglify to 3.7.7, which is the latest that worked with IE9.
  I tried 3.9.4, which we are using in jquery-migrate, and 3.8.1,
  but there were failures in traversing ("Permission denied" errors).
- Upgraded eslint to version 9, which required some changes.
  Mainly, unused arguments in catch expressions error by default in 9+.
  The config now makes use of `caughtErrorsIgnorePattern`,
  which is set to `"^_"`, the same as unused function params.
- Ignored main branch dist files when switching branches.

Closes gh-5508
This commit is contained in:
Timmy Willison 2024-06-15 09:10:59 -04:00 committed by GitHub
parent 8eb35e8513
commit fc864c83c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 501 additions and 630 deletions

3
.gitignore vendored
View File

@ -14,6 +14,9 @@ npm-debug.log*
/dist /dist
# Ignore main branch builds
/dist-module
/external /external
/node_modules /node_modules

View File

@ -57,7 +57,7 @@ async function readdirRecursive( dir, all = [] ) {
files = await fs.readdir( path.join( srcFolder, dir ), { files = await fs.readdir( path.join( srcFolder, dir ), {
withFileTypes: true withFileTypes: true
} ); } );
} catch ( e ) { } catch ( _ ) {
return all; return all;
} }
for ( const file of files ) { for ( const file of files ) {

View File

@ -36,7 +36,7 @@ async function getCache( loc ) {
try { try {
const contents = await fs.readFile( loc, "utf8" ); const contents = await fs.readFile( loc, "utf8" );
cache = JSON.parse( contents ); cache = JSON.parse( contents );
} catch ( err ) { } catch ( _ ) {
return {}; return {};
} }

View File

@ -24,7 +24,7 @@ async function runTests() {
spawn( spawn(
command, command,
[ test ].concat( args ), [ test ].concat( args ),
{ stdio: "inherit" } { shell: true, stdio: "inherit" }
); );
} ); } );
} }

View File

@ -11,7 +11,12 @@ module.exports = [
// See https://github.com/eslint/eslint/discussions/17412 // See https://github.com/eslint/eslint/discussions/17412
ignores: [ ignores: [
"external", "external",
"test/data/json_obj.js" "test/data/json_obj.js",
"test/data/jquery-*.js",
// This avoids parsing local main branch builds
"dist/jquery.factory.*",
"dist-module"
] ]
}, },
@ -47,6 +52,10 @@ module.exports = [
} }
], ],
"no-implicit-globals": "error", "no-implicit-globals": "error",
"no-unused-vars": [
"error",
{ caughtErrorsIgnorePattern: "^_" }
],
"one-var": [ "error", { var: "always" } ], "one-var": [ "error", { var: "always" } ],
strict: [ "error", "function" ] strict: [ "error", "function" ]
} }
@ -105,7 +114,6 @@ module.exports = [
"test/unit/**" "test/unit/**"
], ],
ignores: [ ignores: [
"test/data/jquery-3.7.1.js",
"test/data/badcall.js", "test/data/badcall.js",
"test/data/badjson.js", "test/data/badjson.js",
"test/data/support/csp.js", "test/data/support/csp.js",
@ -149,7 +157,11 @@ module.exports = [
"no-unused-vars": [ "no-unused-vars": [
"error", "error",
{ args: "after-used", argsIgnorePattern: "^_" } {
args: "after-used",
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_"
}
], ],
// Too many errors // Too many errors
@ -197,7 +209,9 @@ module.exports = [
}, },
{ {
files: [ "test/runner/listeners.js" ], files: [
"test/runner/listeners.js"
],
languageOptions: { languageOptions: {
ecmaVersion: 5, ecmaVersion: 5,
sourceType: "script", sourceType: "script",
@ -268,6 +282,10 @@ module.exports = [
rules: { rules: {
...jqueryConfig.rules, ...jqueryConfig.rules,
"no-implicit-globals": "error", "no-implicit-globals": "error",
"no-unused-vars": [
"error",
{ caughtErrorsIgnorePattern: "^_" }
],
strict: [ "error", "global" ] strict: [ "error", "global" ]
} }
}, },
@ -302,6 +320,11 @@ module.exports = [
// That is okay for the built version // That is okay for the built version
"no-multiple-empty-lines": "off", "no-multiple-empty-lines": "off",
"no-unused-vars": [
"error",
{ caughtErrorsIgnorePattern: "^_" }
],
// When custom compilation is used, the version string // When custom compilation is used, the version string
// can get large. Accept that in the built version. // can get large. Accept that in the built version.
"max-len": "off", "max-len": "off",

996
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -54,11 +54,11 @@
}, },
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@babel/cli": "7.23.9", "@babel/cli": "7.24.7",
"@babel/core": "7.24.0", "@babel/core": "7.24.7",
"@babel/plugin-transform-for-of": "7.23.6", "@babel/plugin-transform-for-of": "7.24.7",
"@prantlf/jsonlint": "14.0.3", "@prantlf/jsonlint": "14.0.3",
"@types/selenium-webdriver": "4.1.22", "@types/selenium-webdriver": "4.1.23",
"body-parser": "1.20.2", "body-parser": "1.20.2",
"bootstrap": "5.3.3", "bootstrap": "5.3.3",
"browserstack-local": "1.5.5", "browserstack-local": "1.5.5",
@ -66,26 +66,26 @@
"colors": "1.4.0", "colors": "1.4.0",
"commitplease": "3.2.0", "commitplease": "3.2.0",
"concurrently": "8.2.2", "concurrently": "8.2.2",
"core-js-bundle": "3.36.0", "core-js-bundle": "3.37.1",
"diff": "5.2.0", "diff": "5.2.0",
"eslint": "8.57.0", "eslint": "9.4.0",
"eslint-config-jquery": "3.0.2", "eslint-config-jquery": "3.0.2",
"exit-hook": "4.0.0", "exit-hook": "4.0.0",
"express": "4.18.3", "express": "4.19.2",
"express-body-parser-error-handler": "1.0.7", "express-body-parser-error-handler": "1.0.7",
"globals": "14.0.0", "globals": "15.4.0",
"husky": "9.0.11", "husky": "9.0.11",
"jsdom": "24.0.0", "jsdom": "24.1.0",
"native-promise-only": "0.8.1", "native-promise-only": "0.8.1",
"nodemon": "3.1.0", "nodemon": "3.1.3",
"promises-aplus-tests": "2.1.2", "promises-aplus-tests": "2.1.2",
"q": "1.5.1", "q": "1.5.1",
"qunit": "2.20.1", "qunit": "2.21.0",
"raw-body": "2.5.2", "raw-body": "2.5.2",
"requirejs": "2.3.6", "requirejs": "2.3.6",
"selenium-webdriver": "4.18.1", "selenium-webdriver": "4.21.0",
"sinon": "7.5.0", "sinon": "7.5.0",
"uglify-js": "3.4.7", "uglify-js": "3.7.7",
"yargs": "17.7.2" "yargs": "17.7.2"
}, },
"commitplease": { "commitplease": {

View File

@ -553,7 +553,7 @@ jQuery.extend( {
urlAnchor.href = urlAnchor.href; urlAnchor.href = urlAnchor.href;
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
urlAnchor.protocol + "//" + urlAnchor.host; urlAnchor.protocol + "//" + urlAnchor.host;
} catch ( e ) { } catch ( _ ) {
// If there is an error parsing the URL, assume it is crossDomain, // If there is an error parsing the URL, assume it is crossDomain,
// it can be rejected by the transport if it is invalid // it can be rejected by the transport if it is invalid

View File

@ -9,7 +9,7 @@ define( [
jQuery.ajaxSettings.xhr = function() { jQuery.ajaxSettings.xhr = function() {
try { try {
return new window.XMLHttpRequest(); return new window.XMLHttpRequest();
} catch ( e ) {} } catch ( _ ) {}
}; };
var xhrSuccessStatus = { var xhrSuccessStatus = {

View File

@ -96,12 +96,11 @@ jQuery.extend( {
// when in an optgroup // when in an optgroup
// eslint rule "no-unused-expressions" is disabled for this code // eslint rule "no-unused-expressions" is disabled for this code
// since it considers such accessions noop // since it considers such accessions noop
/* eslint-disable no-unused-expressions */
if ( !support.optSelected ) { if ( !support.optSelected ) {
jQuery.propHooks.selected = { jQuery.propHooks.selected = {
get: function( elem ) { get: function( elem ) {
/* eslint no-unused-expressions: "off" */
var parent = elem.parentNode; var parent = elem.parentNode;
if ( parent && parent.parentNode ) { if ( parent && parent.parentNode ) {
parent.parentNode.selectedIndex; parent.parentNode.selectedIndex;
@ -110,8 +109,6 @@ if ( !support.optSelected ) {
}, },
set: function( elem ) { set: function( elem ) {
/* eslint no-unused-expressions: "off" */
var parent = elem.parentNode; var parent = elem.parentNode;
if ( parent ) { if ( parent ) {
parent.selectedIndex; parent.selectedIndex;
@ -123,6 +120,7 @@ if ( !support.optSelected ) {
} }
}; };
} }
/* eslint-enable no-unused-expressions */
jQuery.each( [ jQuery.each( [
"tabIndex", "tabIndex",

View File

@ -15,7 +15,7 @@ jQuery.parseXML = function( data ) {
// IE throws on parseFromString with invalid input. // IE throws on parseFromString with invalid input.
try { try {
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
} catch ( e ) {} } catch ( _ ) {}
parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ]; parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
if ( !xml || parserErrorElem ) { if ( !xml || parserErrorElem ) {

View File

@ -58,7 +58,7 @@ function dataAttr( elem, key, data ) {
if ( typeof data === "string" ) { if ( typeof data === "string" ) {
try { try {
data = getData( data ); data = getData( data );
} catch ( e ) {} } catch ( _ ) {}
// Make sure we set the data so it isn't changed later // Make sure we set the data so it isn't changed later
dataUser.set( elem, key, data ); dataUser.set( elem, key, data );

View File

@ -429,7 +429,7 @@ jQuery.fn.extend( {
elem = 0; elem = 0;
// If using innerHTML throws an exception, use the fallback method // If using innerHTML throws an exception, use the fallback method
} catch ( e ) {} } catch ( _ ) {}
} }
if ( elem ) { if ( elem ) {

View File

@ -169,7 +169,7 @@ var i,
function safeActiveElement() { function safeActiveElement() {
try { try {
return document.activeElement; return document.activeElement;
} catch ( err ) { } } catch ( _ ) { }
} }
// Optimize for push.apply( _, NodeList ) // Optimize for push.apply( _, NodeList )
@ -183,7 +183,7 @@ try {
// Detect silently failing push.apply // Detect silently failing push.apply
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions
arr[ preferredDoc.childNodes.length ].nodeType; arr[ preferredDoc.childNodes.length ].nodeType;
} catch ( e ) { } catch ( _ ) {
push = { push = {
apply: function( target, els ) { apply: function( target, els ) {
pushNative.apply( target, slice.call( els ) ); pushNative.apply( target, slice.call( els ) );
@ -316,7 +316,7 @@ function find( selector, context, results, seed ) {
newContext.querySelectorAll( newSelector ) newContext.querySelectorAll( newSelector )
); );
return results; return results;
} catch ( qsaError ) { } catch ( _ ) {
nonnativeSelectorCache( selector, true ); nonnativeSelectorCache( selector, true );
} finally { } finally {
if ( nid === expando ) { if ( nid === expando ) {
@ -372,7 +372,7 @@ function assert( fn ) {
try { try {
return !!fn( el ); return !!fn( el );
} catch ( e ) { } catch ( _ ) {
return false; return false;
} finally { } finally {
@ -576,7 +576,7 @@ function setDocument( node ) {
try { try {
document.querySelector( ":has(*,:jqfake)" ); document.querySelector( ":has(*,:jqfake)" );
return false; return false;
} catch ( e ) { } catch ( _ ) {
return true; return true;
} }
} ); } );
@ -828,7 +828,7 @@ find.matchesSelector = function( elem, expr ) {
elem.document && elem.document.nodeType !== 11 ) { elem.document && elem.document.nodeType !== 11 ) {
return ret; return ret;
} }
} catch ( e ) { } catch ( _ ) {
nonnativeSelectorCache( expr, true ); nonnativeSelectorCache( expr, true );
} }
} }
@ -2110,7 +2110,6 @@ find.selectors = jQuery.expr;
find.support = jQuery.support; find.support = jQuery.support;
find.uniqueSort = jQuery.uniqueSort; find.uniqueSort = jQuery.uniqueSort;
/* eslint-enable */
} )(); } )();

View File

@ -2001,9 +2001,7 @@ QUnit.module( "ajax", {
} ); } );
success = true; success = true;
xhr.abort(); xhr.abort();
} catch ( e ) { } catch ( _ ) {}
}
assert.ok( success, "document.location did not generate exception" ); assert.ok( success, "document.location did not generate exception" );
} ); } );

View File

@ -429,7 +429,7 @@ QUnit.test( "attr(String, Object)", function( assert ) {
thrown = true; thrown = true;
try { try {
jQuery( check ).attr( "type", "checkbox" ); jQuery( check ).attr( "type", "checkbox" );
} catch ( e ) { } catch ( _ ) {
thrown = false; thrown = false;
} }
assert.ok( thrown, "Exception thrown when trying to change type property" ); assert.ok( thrown, "Exception thrown when trying to change type property" );
@ -439,7 +439,7 @@ QUnit.test( "attr(String, Object)", function( assert ) {
thrown = true; thrown = true;
try { try {
check.attr( "type", "checkbox" ); check.attr( "type", "checkbox" );
} catch ( e ) { } catch ( _ ) {
thrown = false; thrown = false;
} }
assert.ok( thrown, "Exception thrown when trying to change type property" ); assert.ok( thrown, "Exception thrown when trying to change type property" );
@ -610,7 +610,7 @@ QUnit.test( "removeAttr(String)", function( assert ) {
try { try {
$first = jQuery( "#first" ).attr( "contenteditable", "true" ).removeAttr( "contenteditable" ); $first = jQuery( "#first" ).attr( "contenteditable", "true" ).removeAttr( "contenteditable" );
assert.equal( $first.attr( "contenteditable" ), undefined, "Remove the contenteditable attribute" ); assert.equal( $first.attr( "contenteditable" ), undefined, "Remove the contenteditable attribute" );
} catch ( e ) { } catch ( _ ) {
assert.ok( false, "Removing contenteditable threw an error (trac-10429)" ); assert.ok( false, "Removing contenteditable threw an error (trac-10429)" );
} }
@ -1006,7 +1006,7 @@ if ( "value" in document.createElement( "meter" ) &&
assert.equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" ); assert.equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" );
assert.equal( $progress.val(), $progress[ 0 ].value, "progress, api matches host and does not throw exception" ); assert.equal( $progress.val(), $progress[ 0 ].value, "progress, api matches host and does not throw exception" );
} catch ( e ) {} } catch ( _ ) {}
$meter.remove(); $meter.remove();
$progress.remove(); $progress.remove();
@ -1780,7 +1780,7 @@ QUnit.test( "non-lowercase boolean attribute getters should not crash", function
try { try {
assert.strictEqual( elem.attr( original ), lowercased, assert.strictEqual( elem.attr( original ), lowercased,
"The '" + this + "' attribute getter should return the lowercased name" ); "The '" + this + "' attribute getter should return the lowercased name" );
} catch ( e ) { } catch ( _ ) {
assert.ok( false, "The '" + this + "' attribute getter threw" ); assert.ok( false, "The '" + this + "' attribute getter threw" );
} }
} ); } );

View File

@ -318,7 +318,7 @@ QUnit.test( "css(String, Object)", function( assert ) {
success = true; success = true;
try { try {
jQuery( "#foo" ).css( "backgroundColor", "rgba(0, 0, 0, 0.1)" ); jQuery( "#foo" ).css( "backgroundColor", "rgba(0, 0, 0, 0.1)" );
} catch ( e ) { } catch ( _ ) {
success = false; success = false;
} }
assert.ok( success, "Setting RGBA values does not throw Error (trac-5509)" ); assert.ok( success, "Setting RGBA values does not throw Error (trac-5509)" );
@ -1065,7 +1065,7 @@ QUnit.test( "internal ref to elem.runtimeStyle (bug trac-7608)", function( asser
try { try {
jQuery( "#foo" ).css( { "width": "0%" } ).css( "width" ); jQuery( "#foo" ).css( { "width": "0%" } ).css( "width" );
} catch ( e ) { } catch ( _ ) {
result = false; result = false;
} }

View File

@ -448,7 +448,7 @@ supportjQuery.each(
var fn; var fn;
try { try {
fn = Function( "return " + source )(); fn = Function( "return " + source )();
} catch ( e ) {} } catch ( _ ) {}
QUnit[ jQuery.isFunction && fn ? "test" : "skip" ]( "isFunction(" + subclass + ")", QUnit[ jQuery.isFunction && fn ? "test" : "skip" ]( "isFunction(" + subclass + ")",
function( assert ) { function( assert ) {

View File

@ -12,12 +12,12 @@ QUnit.test( "null or undefined handler", function( assert ) {
try { try {
jQuery( "#firstp" ).on( "click", null ); jQuery( "#firstp" ).on( "click", null );
assert.ok( true, "Passing a null handler will not throw an exception" ); assert.ok( true, "Passing a null handler will not throw an exception" );
} catch ( e ) {} } catch ( _ ) {}
try { try {
jQuery( "#firstp" ).on( "click", undefined ); jQuery( "#firstp" ).on( "click", undefined );
assert.ok( true, "Passing an undefined handler will not throw an exception" ); assert.ok( true, "Passing an undefined handler will not throw an exception" );
} catch ( e ) {} } catch ( _ ) {}
var expectedElem = jQuery( "#firstp" ); var expectedElem = jQuery( "#firstp" );
var actualElem = expectedElem.on( "click", null ); var actualElem = expectedElem.on( "click", null );
@ -1050,7 +1050,7 @@ QUnit.test( "trigger(type, [data], [fn])", function( assert ) {
elem2 = jQuery( "#form input" ).eq( 0 ); elem2 = jQuery( "#form input" ).eq( 0 );
elem2.get( 0 ).style.display = "none"; elem2.get( 0 ).style.display = "none";
elem2.trigger( "focus" ); elem2.trigger( "focus" );
} catch ( e ) { } catch ( _ ) {
pass = false; pass = false;
} }
assert.ok( pass, "Trigger focus on hidden element" ); assert.ok( pass, "Trigger focus on hidden element" );
@ -1058,7 +1058,7 @@ QUnit.test( "trigger(type, [data], [fn])", function( assert ) {
pass = true; pass = true;
try { try {
jQuery( "#qunit-fixture table" ).eq( 0 ).on( "test:test", function() {} ).trigger( "test:test" ); jQuery( "#qunit-fixture table" ).eq( 0 ).on( "test:test", function() {} ).trigger( "test:test" );
} catch ( e ) { } catch ( _ ) {
pass = false; pass = false;
} }
assert.ok( pass, "Trigger on a table with a colon in the even type, see trac-3533" ); assert.ok( pass, "Trigger on a table with a colon in the even type, see trac-3533" );
@ -1459,7 +1459,7 @@ QUnit[ /(ipad|iphone|ipod)/i.test( navigator.userAgent ) ? "skip" : "test" ](
window.onmessage = null; window.onmessage = null;
done(); done();
} }
} catch ( e ) { } catch ( _ ) {
// Messages may come from other sources, like browser extensions; // Messages may come from other sources, like browser extensions;
// some may not be valid JSONs and thus cannot be `JSON.parse`d. // some may not be valid JSONs and thus cannot be `JSON.parse`d.
@ -2307,7 +2307,7 @@ QUnit.test( "custom events with colons (trac-3533, trac-8272)", function( assert
try { try {
tab.trigger( "back:forth" ); tab.trigger( "back:forth" );
assert.ok( true, "colon events don't throw" ); assert.ok( true, "colon events don't throw" );
} catch ( e ) { } catch ( _ ) {
assert.ok( false, "colon events die" ); assert.ok( false, "colon events die" );
} }
tab.remove(); tab.remove();
@ -2945,7 +2945,7 @@ QUnit.test( "String.prototype.namespace does not cause trigger() to throw (trac-
try { try {
jQuery( "<p>" ).trigger( "foo.bar" ); jQuery( "<p>" ).trigger( "foo.bar" );
} catch ( e ) { } catch ( _ ) {
errored = true; errored = true;
} }
assert.equal( errored, false, "trigger() did not throw exception" ); assert.equal( errored, false, "trigger() did not throw exception" );

View File

@ -1990,7 +1990,7 @@ QUnit.test( "clone()/html() don't expose jQuery/Sizzle expandos (trac-12858)", f
$content.find( ":nth-child(1):lt(4)" ).data( "test", true ); $content.find( ":nth-child(1):lt(4)" ).data( "test", true );
// But don't break on a non-Sizzle build // But don't break on a non-Sizzle build
} catch ( e ) { } catch ( _ ) {
$content.find( "*" ).data( "test", true ); $content.find( "*" ).data( "test", true );
} }
@ -2304,7 +2304,7 @@ QUnit.test( "domManip plain-text caching (trac-6779)", function( assert ) {
for ( i = 0; i < bad.length; i++ ) { for ( i = 0; i < bad.length; i++ ) {
try { try {
$f.append( bad[ i ] ); $f.append( bad[ i ] );
} catch ( e ) {} } catch ( _ ) {}
} }
assert.equal( $f.text(), bad.join( "" ), "Cached strings that match Object properties" ); assert.equal( $f.text(), bad.join( "" ), "Cached strings that match Object properties" );
$f.remove(); $f.remove();
@ -2478,7 +2478,7 @@ QUnit.test( "Guard against exceptions when clearing safeChildNodes", function( a
try { try {
div = jQuery( "<div></div><hr/><code></code><b></b>" ); div = jQuery( "<div></div><hr/><code></code><b></b>" );
} catch ( e ) {} } catch ( _ ) {}
assert.ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" ); assert.ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" );
} ); } );