2.0.0 β’ Published 7 months ago
@putout/plugin-remove-useless-push v2.0.0
@putout/plugin-remove-useless-push 
The
push()method ofArrayinstances adds the specified elements to the end of an array and returns the new length of the array.(c) MDN
πPutout plugin adds ability to remove useless push(). The rule fits good with putout/remove-unused-variables.
Checkout in πPutout Editor.
Install
npm i @putout/plugin-remove-useless-pushRule
{
"rules": {
"remove-useless-push": "on"
}
}β Example of incorrect code
function get() {
const a = [];
const b = [];
a.push(1);
b.push(2);
return b;
}β Example of correct code
function get() {
const a = [];
const b = [];
b.push(2);
return b;
}License
MIT