Security News
Python Overtakes JavaScript as Top Programming Language on GitHub
Python becomes GitHub's top language in 2024, driven by AI and data science projects, while AI-powered security tools are gaining adoption.
eslint-plugin-prefer-object-spread
Advanced tools
ESLint rule for suggesting that object spread properties be used instead of Object.assign().
ESLint rule for suggesting that object spread properties be used instead of Object.assign()
.
Install ESLint and eslint-plugin-prefer-object-spread
:
$ npm install --save-dev eslint eslint-plugin-prefer-object-spread
Add prefer-object-spread
to the plugins section of your .eslintrc
configuration file, and configure the rule under the rules section.
{
"plugins": [
"prefer-object-spread"
],
"rules": {
"prefer-object-spread/prefer-object-spread": 2
}
}
This rule suggests that object spread properties be used instead of Object.assign()
. The rule is only applied when Object.assign() is used for cloning; not when it is used to extend an existing object. i.e., it applies when the first argument to Object.assign()
is an object literal. This is because spread properties only iterate over own properties.
When using this rule the following patterns are considered problems:
var a = Object.assign({}, foo); // error Use a spread property instead of Object.assign().
var b = Object.assign({ c: 1 }, bar); // error Use a spread property instead of Object.assign().
The following patterns are considered okay:
var a = { ...foo };
var b = { c: 1, ...bar };
Object.assign(b, { d: 2 });
FAQs
ESLint rule for suggesting that object spread properties be used instead of Object.assign().
We found that eslint-plugin-prefer-object-spread demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Python becomes GitHub's top language in 2024, driven by AI and data science projects, while AI-powered security tools are gaining adoption.
Security News
Dutch National Police and FBI dismantle Redline and Meta infostealer malware-as-a-service operations in Operation Magnus, seizing servers and source code.
Research
Security News
Socket is tracking a new trend where malicious actors are now exploiting the popularity of LLM research to spread malware through seemingly useful open source packages.