Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.