Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 904 Bytes

no-attr.md

File metadata and controls

37 lines (29 loc) · 904 Bytes

no-attr

Disallows the .attr/.removeAttr methods and $.attr/$.removeAttr utilies. Prefer Element#getAttribute/setAttribute/removeAttribute.

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

Rule details

❌ Examples of incorrect code:

$.attr();
$( 'div' ).attr();
$div.attr();
$( 'div' ).first().attr();
$( 'div' ).append( $( 'input' ).attr() );
$( 'div' ).attr( 'name' );
$( 'div' ).attr( 'name', 'random' );
$.removeAttr();
$( 'div' ).removeAttr( 'name' );

✔️ Examples of correct code:

attr();
[].attr();
div.attr();
div.attr;
removeAttr();
div.removeAttr;

Resources