Skip to content

Latest commit

 

History

History

plugin-remove-unreachable-code

@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