Disallows the .load
method when used as a shorthand for .on( 'load', function )
or .trigger( 'load' )
. Prefer .on
or .trigger
.
📋 This rule is enabled in plugin:no-jquery/deprecated-1.8
.
🔧 The --fix
option on the command line can automatically fix some of the problems reported by this rule.
❌ Examples of incorrect code:
$( 'div' ).load( function () {} );
$div.load( function () {} );
$div.load();
$div.load( () => {} );
$( 'div' ).first().load( function () {} );
$( 'div' ).append( $( 'input' ).load( function () {} ) );
✔️ Examples of correct code:
load();
[].load();
div.load();
div.load;
$.load();
$div.load( 'url' );
$div.load( couldBeUrl );
🔧 Examples of code fixed by this rule:
$( 'div' ).load( function () {} ); /* → */ $( 'div' ).on( 'load', function () {} );
$div.load( function () {} ); /* → */ $div.on( 'load', function () {} );
$div.load(); /* → */ $div.trigger( 'load' );
$div.load( () => {} ); /* → */ $div.on( 'load', () => {} );
$( 'div' ).first().load( function () {} ); /* → */ $( 'div' ).first().on( 'load', function () {} );
$( 'div' ).append( $( 'input' ).load( function () {} ) ); /* → */ $( 'div' ).append( $( 'input' ).on( 'load', function () {} ) );