ESLint rule that flags Object.assign() calls when the target is an object literal, recommending object spread properties instead. Version 1.2.1 is the latest stable release; the package has not been updated since 2016. It applies only when Object.assign() is used for cloning (first argument is an object literal) to avoid false positives when mutating an existing object. Requires ESLint >=0.8.0 and Node >=4.0.0. This plugin is lightweight and has a single rule. It is not actively maintained and may be superseded by built-in ESLint rules or new JavaScript features.
npm install eslint-plugin-prefer-object-spreadVerified import paths — ran on the pinned version, not inferred.
Shows how to install ESLint and the plugin, configure the rule, and see it flag Object.assign usage on an object literal.
No fix needed; this is by design. Use the rule only for cloning patterns.
Consider if you have non-enumerable properties or accessor properties. Otherwise, spread is safe.
Migrate to ESLint's built-in 'prefer-object-spread' rule (since ESLint v5.8.0) by removing the plugin and using `"prefer-object-spread/prefer-object-spread": "error" -> "prefer-object-spread": "error"`.
Run `npm install --save-dev eslint eslint-plugin-prefer-object-spread`
Use 'prefer-object-spread/prefer-object-spread' instead of just 'prefer-object-spread'
Use numbers (0,1,2) or strings ('off','warn','error')