Skip to content

Latest commit

 

History

History

plugin-apply-cause

README.md

@putout/plugin-apply-cause NPM version

The cause data property of an Error instance indicates the specific original cause of the error.:

(c) MDN

🐊Putout plugin adds ability to apply cause

Checkout in 🐊Putout Editor.

Install

npm i @putout/plugin-apply-cause

Rule

{
    "rules": {
        "apply-cause": "on"
    }
}

❌ Example of incorrect code

try {} catch(error) {
    if (controller.signal.aborted)
        throw Error('timeout');
}

✅ Example of correct code

try {} catch(error) {
    if (controller.signal.aborted)
        throw Error('timeout', {
            cause: error,
        });
}

Comparison

Linter Rule Fix
🐊 Putout apply-cause ✅
⏣ ESLint apply-cause ❌

License

MIT