🐊Putout plugin adds ability to convert Object.assign to merge spread
npm install @putout/plugin-convert-object-assign-to-merge-spread[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-convert-object-assign-to-merge-spread.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-convert-object-assign-to-merge-spread "npm"
> The Object.assign() method copies all enumerable own properties from one or more source objects to a target object and returns the modified target object.
>
> Spread syntax (...) allows an object expression to be expanded in places where zero or more key-value pairs are expected.
>
> (c) MDN
🐊Putout plugin adds ability to convert Object.assign() to merge spread since it shorter but does (mostly) the same. Merged with @putout/plugin-spread.
```
npm i @putout/plugin-convert-object-assign-to-merge-spread -D
`json`
{
"rules": {
"convert-object-assign-to-merge-spread": "on"
}
}
`js`
function merge(a) {
return Object.assign({}, a, {
hello: 'world',
});
}
`js`
function merge(a) {
return {
...a,
hello: 'world',
};
}
Linter | Rule | Fix
--------|-------|------------|
🐊 Putout | convert-object-assign-to-merge-spread | ✅
⏣ ESLint | prefer-object-spread` | ✅
MIT