@putout/plugin-convert-object-assign-to-merge-spread
v7.0.1
Published
šPutout plugin adds ability to convert Object.assign to merge spread
Maintainers
Readme
@putout/plugin-convert-object-assign-to-merge-spread 
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.
Install
npm i @putout/plugin-convert-object-assign-to-merge-spread -DRule
{
"rules": {
"convert-object-assign-to-merge-spread": "on"
}
}ā Example of incorrect code
function merge(a) {
return Object.assign({}, a, {
hello: 'world',
});
}ā Example of correct code
function merge(a) {
return {
...a,
hello: 'world',
};
}Comparison
Linter | Rule | Fix
--------|-------|------------|
š Putout | convert-object-assign-to-merge-spread | ā
⣠ESLint | prefer-object-spread | ā
License
MIT
