Socket
Socket
Sign inDemoInstall

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

Package Overview
Dependencies
389
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

putout plugin adds ability to convert Object.assign to merge spead


Version published
Weekly downloads
16K
decreased by-12.96%
Maintainers
1
Install size
5.25 kB
Created
Weekly downloads
 

Readme

Source

@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

Keywords

FAQs

Last updated on 02 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc