Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 1.27 KB

no-html.md

File metadata and controls

55 lines (42 loc) · 1.27 KB

no-html

Disallows the .html method. Prefer Element#innerHTML.

Using this method only as a getter or a setter can be allowed using the allowGetOrSet option:

  • "none" (default) the method can't be used at all
  • "get" the method can only be used as a getter i.e. with no arguments
  • "set" the method can only be used as a setter i.e. with arguments

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

Rule details

❌ Examples of incorrect code:

$( 'div' ).html();
$div.html();
$( 'div' ).first().html();
$( 'div' ).append( $( 'input' ).html() );

✔️ Examples of correct code:

html();
[].html();
div.html();
div.html;

❌ Examples of incorrect code with [{"allowGetOrSet":"get"}] options:

$div.html( '<br>' );

✔️ Examples of correct code with [{"allowGetOrSet":"get"}] options:

$div.html();

❌ Examples of incorrect code with [{"allowGetOrSet":"set"}] options:

$div.html();

✔️ Examples of correct code with [{"allowGetOrSet":"set"}] options:

$div.html( '<br>' );

Resources