Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.16 KB

no-size.md

File metadata and controls

42 lines (31 loc) · 1.16 KB

no-size

Disallows the .size method. Prefer .length.

📋 This rule is enabled in plugin:no-jquery/deprecated-1.8.

📋 This rule is enabled in plugin:no-jquery/all.

🔧 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' ).size();
$div.size();
$( 'div' ).first().size();
$( 'div' ).append( $( 'input' ).size() );

✔️ Examples of correct code:

size();
[].size();
div.size();
div.size;

🔧 Examples of code fixed by this rule:

$( 'div' ).size();                        /* → */ $( 'div' ).length;
$div.size();                              /* → */ $div.length;
$( 'div' ).first().size();                /* → */ $( 'div' ).first().length;
$( 'div' ).append( $( 'input' ).size() ); /* → */ $( 'div' ).append( $( 'input' ).length );

Resources