npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@putout/plugin-return

v2.0.0

Published

🐊Putout plugin adds ability to transform code related to return

Readme

@putout/plugin-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 transform to new Node.js API and apply best practices.

Install

npm i putout @putout/plugin-return -D

Rules

Config

{
    "rules": {
        "return/apply-early-return": "on",
        "return/convert-from-continue": "on",
        "return/convert-from-break": "on",
        "return/merge-with-next-sibling": "on",
        "return/remove-useless": "on",
        "return/simplify-boolean": "on"
    }
}

apply-early-return

In short, an early return provides functionality so the result of a conditional statement can be returned as soon as a result is available, rather than wait until the rest of the function is run.

(c) dev.to

❌ Example of incorrect code

function get(a) {
    const b = 0;
    
    {
        if (a > 0)
            return 5;
        
        return 7;
    }
}

✅ Example of correct code

function get(a) {
    if (a > 0)
        return 5;
    
    return 7;
}

convert-from-continue

The continue statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.

(c) MDN

SyntaxError: Illegal continue statement: no surrounding iteration statement

(c) MDN

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

function x() {
    if (a)
        continue;
    
    return b;
}

✅ Example of correct code

function x() {
    if (a)
        return;
    
    return b;
}

convert-from-break

The break statement terminates the current loop or switch statement and transfers program control to the statement following the terminated statement.

(c) MDN

SyntaxError: unlabeled break must be inside loop or switch

(c) MDN

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

function x() {
    if (a)
        break;
    
    return false;
}

✅ Example of correct code

function x() {
    if (a)
        return;
    
    return false;
}

merge-with-next-sibling

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

function x() {
    return;
    {
        hello: 'world';
    }
    
    return;
    5;
    
    return;
    a ? 2 : 3;
}

✅ Example of correct code

function x() {
    return {
        hello: 'world',
    };
    
    return 5;
    
    return a ? 2 : 3;
}

remove-useless

❌ Example of incorrect code

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

✅ Example of correct code

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

simplify-boolean

Check out in 🐊Putout Editor.

❌ Example of incorrect code

function isA(a, b) {
    if (a.length === b.length)
        return true;
    
    return false;
}

✅ Example of correct code

function isA(a, b) {
    return a.length !== b.length;
}

License

MIT