Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@putout/plugin-remove-useless-functions
Advanced tools
Readme
🐊Putout plugin adds ability to find and remove useless functions
.
npm i @putout/plugin-remove-useless-functions -D
{
"rules": {
"remove-useless-functions": "on"
}
}
const y = (...a) => {
alert(...a);
};
[].filter((a) => a);
const y = alert;
[].filter(Boolean);
Why there is no transform for such case:
const f = (a) => alert(a);
Isn't is the same as:
const f = alert;
Actually it is the same, and this example can be converted without an issue, but there is also cases like:
const one = (f) => (a) => f(a);
[
1,
2,
3,
4,
].map(one(console.log));
// output
1;
2;
3;
And if it will be simplified:
const one = (f) => f;
[
1,
2,
3,
4,
].map(one(console.log));
// output
'1 0 [1, 2, 3]';
'2 1 [1, 2, 3]';
'3 2 [1, 2, 3]';
So behaviour is totally different. The same result for:
[
1,
2,
3,
4,
].map(console.log);
Because map
calls a function with 3 arguments, and console.log
receives any count of arguments,
to cut redundant args there is a need to use something like:
const one = (f) => (a) => f(a);
There is a lot such cases in the wild. While we have no syntax to set the count of arguments
we are going to receive,
and a way to avoid returning result we don't want function to return, there is no need in such a dengerous transform.
MIT
FAQs
🐊Putout plugin adds ability to find and remove useless functions
The npm package @putout/plugin-remove-useless-functions receives a total of 15,877 weekly downloads. As such, @putout/plugin-remove-useless-functions popularity was classified as popular.
We found that @putout/plugin-remove-useless-functions demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.