Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 1.24 KB

no-error-shorthand.md

File metadata and controls

41 lines (31 loc) · 1.24 KB

no-error-shorthand

Disallows the .error method. 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.

Rule details

❌ Examples of incorrect code:

$( 'div' ).error( handler );
$div.error();
$( 'div' ).first().error();
$( 'div' ).append( $( 'input' ).error() );

✔️ Examples of correct code:

error();
[].error();
div.error();
div.error;
$.error();

🔧 Examples of code fixed by this rule:

$( 'div' ).error( handler );               /* → */ $( 'div' ).on( 'error', handler );
$div.error();                              /* → */ $div.trigger( 'error' );
$( 'div' ).first().error();                /* → */ $( 'div' ).first().trigger( 'error' );
$( 'div' ).append( $( 'input' ).error() ); /* → */ $( 'div' ).append( $( 'input' ).trigger( 'error' ) );

Resources