Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.28 KB

no-extend.md

File metadata and controls

51 lines (38 loc) · 1.28 KB

no-extend

Disallows the $.extend utility. Prefer Object.assign or the spread operator.

📋 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:

$.extend( {}, foo );
$.extend( true, {}, foo );

✔️ Examples of correct code:

extend();
myMethod.extend();
myMethod.extend;
$.extend( { myUtil: fn } );

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

$.extend( {}, foo );
$.extend( fooCouldBeNull, doesNotAutofix );

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

$.extend( true, {}, foo );

🔧 Examples of code fixed by this rule:

$.extend( {}, foo ); /* → */ Object.assign( {}, foo );

🔧 Examples of code fixed by this rule with [{"allowDeep":true}] options:

$.extend( {}, foo ); /* → */ Object.assign( {}, foo );

Resources