Skip to content

Latest commit

 

History

History
130 lines (118 loc) · 3.13 KB

no-sizzle.md

File metadata and controls

130 lines (118 loc) · 3.13 KB

no-sizzle

Disallows selector extensions provided by Sizzle. Use the allowPositional option to allow positional selectors. Use the allowOther option to allow all other selectors. These options are used in the deprecated-3.4 ruleset as only positional selectors were deprecated in that version.

📋 This rule is enabled in plugin:no-jquery/deprecated-3.4 with [{"allowPositional":false,"allowOther":true}] options.

Rule details

❌ Examples of incorrect code:

$( ':animated' );
$( ':button' );
$( ':checkbox' );
$( ':eq(2)' );
$( ':even' );
$( ':file' );
$( ':first' );
$( ':gt(2)' );
$( 'div' ).find( ':gt(' + n + ')' );
$( ':has(.foo)' );
$( ':header' );
$( ':hidden' );
$( '.' + className + ':hidden' );
$( ':image' );
$( ':input' );
$( ':last' );
$( ':lt(2)' );
$( ':nth(2)' );
$( ':odd' );
$( ':parent' );
$( ':password' );
$( ':radio' );
$( ':reset' );
$( ':selected' );
$( ':submit' );
$( ':text' );
$( ':visible' );
$( 'div' ).children( ':visible' );
$( 'div' ).closest( ':visible' );
$( 'div' ).filter( ':visible' );
$( 'div' ).find( ':visible' );
$( 'div' ).has( ':visible' );
$( 'div' ).is( ':visible' );
$( 'div' ).next( ':visible' );
$( 'div' ).nextAll( ':visible' );
$( 'div' ).nextUntil( ':visible' );
$( 'div' ).not( ':visible' );
$( 'div' ).parent( ':visible' );
$( 'div' ).parents( ':visible' );
$( 'div' ).parentsUntil( ':visible' );
$( 'div' ).prev( ':visible' );
$( 'div' ).prevAll( ':visible' );
$( 'div' ).prevUntil( ':visible' );
$( 'div' ).siblings( ':visible' );
$( 'div:visible' );
$( 'div:visible' ).find( 'p' );
$( 'div' ).find( 'p:visible' ).addClass( 'test' ).find( 'p' );
$( 'div' ).find( 'div:animated' );
$div.find( 'form input:checkbox' );

✔️ Examples of correct code:

find( ':input' );
div.find( ':input' );
$( 'div' ).on( 'custom:input' );
$( 'div' ).on( 'custom:selected' );
$( 'div' ).find( '.selected' );
$( 'div' ).find( ':checked' );
$( 'div' ).find( 'input' );
$( 'div' ).find( ':first-child' );
$( 'div' ).find( ':first-child div' );
$( 'div' ).find( ':last-child' );
$( 'div' ).find( ':last-child div' );
$( 'div' ).find( ':nth-child(2)' );
$( 'div' ).find( ':nth-child(2) div' );
$( 'div' ).find( $() );
$( 'div' ).find( function () {} );
$( 'div' ).find();
$( function () {} );

❌ Examples of incorrect code with [{"allowOther":true}] options:

$( ':eq(2)' );
$( ':even' );
$( ':first' );
$( ':gt(2)' );
$( ':last' );
$( ':lt(2)' );
$( ':nth(2)' );
$( ':odd' );

✔️ Examples of correct code with [{"allowOther":true}] options:

$( ':animated' );
$( ':button' );
$( ':checkbox' );
$( ':file' );
$( ':has(.foo)' );
$( ':header' );
$( ':hidden' );
$( ':image' );
$( ':input' );
$( ':parent' );
$( ':password' );
$( ':radio' );
$( ':reset' );
$( ':submit' );
$( ':text' );
$( ':visible' );

❌ Examples of incorrect code with [{"allowPositional":true}] options:

$( ':animated' );

✔️ Examples of correct code with [{"allowPositional":true}] options:

$( ':checked' );

Resources