Disallows the .andSelf
method. Prefer .addBack
.
📋 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' ).andSelf( '.foo' );
$div.andSelf( '.foo' );
$( 'div' ).first().andSelf();
$( 'div' ).append( $( 'input' ).andSelf() );
✔️ Examples of correct code:
andSelf();
[].andSelf();
div.andSelf();
div.andSelf;
🔧 Examples of code fixed by this rule:
$( 'div' ).andSelf( '.foo' ); /* → */ $( 'div' ).addBack( '.foo' );
$div.andSelf( '.foo' ); /* → */ $div.addBack( '.foo' );
$( 'div' ).first().andSelf(); /* → */ $( 'div' ).first().addBack();
$( 'div' ).append( $( 'input' ).andSelf() ); /* → */ $( 'div' ).append( $( 'input' ).addBack() );