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
# Ignore main branch builds
/dist-module
/external
/node_modules

View File

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

View File

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

View File

@ -24,7 +24,7 @@ async function runTests() {
spawn(
command,
[ 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
ignores: [
"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-unused-vars": [
"error",
{ caughtErrorsIgnorePattern: "^_" }
],
"one-var": [ "error", { var: "always" } ],
strict: [ "error", "function" ]
}
@ -105,7 +114,6 @@ module.exports = [
"test/unit/**"
],
ignores: [
"test/data/jquery-3.7.1.js",
"test/data/badcall.js",
"test/data/badjson.js",
"test/data/support/csp.js",
@ -149,7 +157,11 @@ module.exports = [
"no-unused-vars": [
"error",
{ args: "after-used", argsIgnorePattern: "^_" }
{
args: "after-used",
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_"
}
],
// Too many errors
@ -197,7 +209,9 @@ module.exports = [
},
{
files: [ "test/runner/listeners.js" ],
files: [
"test/runner/listeners.js"
],
languageOptions: {
ecmaVersion: 5,
sourceType: "script",
@ -268,6 +282,10 @@ module.exports = [
rules: {
...jqueryConfig.rules,
"no-implicit-globals": "error",
"no-unused-vars": [
"error",
{ caughtErrorsIgnorePattern: "^_" }
],
strict: [ "error", "global" ]
}
},
@ -302,6 +320,11 @@ module.exports = [
// That is okay for the built version
"no-multiple-empty-lines": "off",
"no-unused-vars": [
"error",
{ caughtErrorsIgnorePattern: "^_" }
],
// When custom compilation is used, the version string
// can get large. Accept that in the built version.
"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",
"devDependencies": {
"@babel/cli": "7.23.9",
"@babel/core": "7.24.0",
"@babel/plugin-transform-for-of": "7.23.6",
"@babel/cli": "7.24.7",
"@babel/core": "7.24.7",
"@babel/plugin-transform-for-of": "7.24.7",
"@prantlf/jsonlint": "14.0.3",
"@types/selenium-webdriver": "4.1.22",
"@types/selenium-webdriver": "4.1.23",
"body-parser": "1.20.2",
"bootstrap": "5.3.3",
"browserstack-local": "1.5.5",
@ -66,26 +66,26 @@
"colors": "1.4.0",
"commitplease": "3.2.0",
"concurrently": "8.2.2",
"core-js-bundle": "3.36.0",
"core-js-bundle": "3.37.1",
"diff": "5.2.0",
"eslint": "8.57.0",
"eslint": "9.4.0",
"eslint-config-jquery": "3.0.2",
"exit-hook": "4.0.0",
"express": "4.18.3",
"express": "4.19.2",
"express-body-parser-error-handler": "1.0.7",
"globals": "14.0.0",
"globals": "15.4.0",
"husky": "9.0.11",
"jsdom": "24.0.0",
"jsdom": "24.1.0",
"native-promise-only": "0.8.1",
"nodemon": "3.1.0",
"nodemon": "3.1.3",
"promises-aplus-tests": "2.1.2",
"q": "1.5.1",
"qunit": "2.20.1",
"qunit": "2.21.0",
"raw-body": "2.5.2",
"requirejs": "2.3.6",
"selenium-webdriver": "4.18.1",
"selenium-webdriver": "4.21.0",
"sinon": "7.5.0",
"uglify-js": "3.4.7",
"uglify-js": "3.7.7",
"yargs": "17.7.2"
},
"commitplease": {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -318,7 +318,7 @@ QUnit.test( "css(String, Object)", function( assert ) {
success = true;
try {
jQuery( "#foo" ).css( "backgroundColor", "rgba(0, 0, 0, 0.1)" );
} catch ( e ) {
} catch ( _ ) {
success = false;
}
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 {
jQuery( "#foo" ).css( { "width": "0%" } ).css( "width" );
} catch ( e ) {
} catch ( _ ) {
result = false;
}

View File

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

View File

@ -12,12 +12,12 @@ QUnit.test( "null or undefined handler", function( assert ) {
try {
jQuery( "#firstp" ).on( "click", null );
assert.ok( true, "Passing a null handler will not throw an exception" );
} catch ( e ) {}
} catch ( _ ) {}
try {
jQuery( "#firstp" ).on( "click", undefined );
assert.ok( true, "Passing an undefined handler will not throw an exception" );
} catch ( e ) {}
} catch ( _ ) {}
var expectedElem = jQuery( "#firstp" );
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.get( 0 ).style.display = "none";
elem2.trigger( "focus" );
} catch ( e ) {
} catch ( _ ) {
pass = false;
}
assert.ok( pass, "Trigger focus on hidden element" );
@ -1058,7 +1058,7 @@ QUnit.test( "trigger(type, [data], [fn])", function( assert ) {
pass = true;
try {
jQuery( "#qunit-fixture table" ).eq( 0 ).on( "test:test", function() {} ).trigger( "test:test" );
} catch ( e ) {
} catch ( _ ) {
pass = false;
}
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;
done();
}
} catch ( e ) {
} catch ( _ ) {
// Messages may come from other sources, like browser extensions;
// 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 {
tab.trigger( "back:forth" );
assert.ok( true, "colon events don't throw" );
} catch ( e ) {
} catch ( _ ) {
assert.ok( false, "colon events die" );
}
tab.remove();
@ -2945,7 +2945,7 @@ QUnit.test( "String.prototype.namespace does not cause trigger() to throw (trac-
try {
jQuery( "<p>" ).trigger( "foo.bar" );
} catch ( e ) {
} catch ( _ ) {
errored = true;
}
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 );
// But don't break on a non-Sizzle build
} catch ( e ) {
} catch ( _ ) {
$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++ ) {
try {
$f.append( bad[ i ] );
} catch ( e ) {}
} catch ( _ ) {}
}
assert.equal( $f.text(), bad.join( "" ), "Cached strings that match Object properties" );
$f.remove();
@ -2478,7 +2478,7 @@ QUnit.test( "Guard against exceptions when clearing safeChildNodes", function( a
try {
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 ]" );
} );