@putout/plugin-convert-object-assign-to-merge-spread
🐊Putout plugin adds ability to convert Object.assign to merge spread
Last updated 4 months ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @putout/plugin-convert-object-assign-to-merge-spread 
SYNC missed versions from official npm registry.

@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. Merged with @putout/plugin-spread.

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

Linter Rule Fix
???? Putout convert-object-assign-to-merge-spread
ESLint prefer-object-spread

License

MIT

Current Tags

  • 7.0.1                                ...           latest (4 months ago)

13 Versions

  • 7.0.1                                ...           4 months ago
  • 7.0.0                                ...           6 months ago
  • 6.0.0                                ...           4 years ago
  • 5.0.0                                ...           5 years ago
  • 4.0.1                                ...           6 years ago
  • 4.0.0                                ...           6 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.0                                ...           7 years ago
  • 1.3.0                                ...           7 years ago
  • 1.2.0                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (7)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |