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

Package detail

@putout/plugin-remove-unreachable-code

coderaiser38.6kMIT2.0.0

🐊Putout plugin adds ability to find and remove unreachable code

putout, putout-plugin, plugin, remove, unreachable, code

readme

@putout/plugin-remove-unreachable-code NPM version

The JavaScript warning "unreachable code after return statement" occurs when using an expression after a return statement, or when using a semicolon-less return statement but including an expression directly after.

(c) MDN

🐊Putout plugin adds ability to find and remove unreachable code.

Install

npm i @putout/plugin-remove-unreachable-code

Rule

{
    "rules": {
        "remove-unreachable-code": "on"
    }
}

❌ Example of incorrect code

function hi() {
    return 'world';
    console.log('hello');
}

function log() {
    throw Error('error');

    console.log('hello');
}

✅ Example of correct code

function hi() {
    return 'world';
}

function log() {
    throw Error('error');
}

License

MIT