npm.io
7.0.2 • Published 1 year ago

@putout/plugin-remove-useless-return

Licence
MIT
Version
7.0.2
Deps
0
Size
6 kB
Vulns
0
Weekly
0
Stars
797

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

The return statement ends function execution and specifies a value to be returned to the function caller.

(c) MDN

Putout plugin adds ability to find and remove useless return. Merged with @putout/plugin-return.

Install

npm i @putout/plugin-remove-useless-return

Rule

{
    "rules": {
        "remove-useless-return": "on"
    }
}

Example of incorrect code

const traverse = ({push}) => {
    return {
        ObjectExpression(path) {
            push(path);
        },
    };
};

Example of correct code

const traverse = ({push}) => ({
    ObjectExpression(path) {
        push(path);
    },
});

License

MIT

Keywords