6.0.0 ā€¢ Published 2 years ago

@putout/plugin-convert-object-assign-to-merge-spread v6.0.0

Weekly downloads
2,988
License
MIT
Repository
github
Last release
2 years ago

@putout/plugin-convert-object-assign-to-merge-spread NPM version

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.

Install

npm i @putout/plugin-convert-object-assign-to-merge-spread -D

Rule

{
    "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

LinterRuleFix
šŸŠ Putoutconvert-object-assign-to-merge-spreadāœ…
šŸ¦• ESLintprefer-object-spreadāœ…

License

MIT

6.0.0

2 years ago

5.0.0

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago