Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 1.07 KB

no-data.md

File metadata and controls

43 lines (35 loc) · 1.07 KB

no-data

Disallows the .data/.removeData/.hasData methods and $.data/$.removeData/$.hasData utilies. Prefer WeakMap.

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

Rule details

❌ Examples of incorrect code:

$.data( elem, 'foo' );
$( 'div' ).data( 'foo', 'bar' );
$div.data( 'foo' );
$( 'div' ).first().data( 'foo', 'bar' );
$( 'div' ).append( $( 'input' ).data( 'foo' ) );
$.removeData( elem, 'foo' );
$( 'div' ).removeData( 'foo' );
$div.removeData( 'foo' );
$.hasData( elem );

✔️ Examples of correct code:

data();
[].data();
div.data();
div.data;
removeData();
[].removeData();
div.removeData();
div.removeData;
hasData();
[].hasData();
div.hasData();
div.hasData;

Resources