Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@putout/plugin-remove-useless-push

coderaiser16.2kMIT1.0.3

🐊Putout plugin adds ability to remove useless 'push()'

putout, putout-plugin, plugin, push, putout-plugin-remove, putout-plugin-remove-useless, remove, useless

readme

@putout/plugin-remove-useless-push NPM version

The push() method of Array instances 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-push

Rule

{
    "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