Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.21 KB

no-and-self.md

File metadata and controls

40 lines (30 loc) · 1.21 KB

no-and-self

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.

Rule details

❌ 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() );

Resources