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.
❌ 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 );