https://github.com/sindresorhus/eslint-plugin-unicorn/issues/158Go to Github

FundedView inThe `prefer-add-event-listener` rule should not apply to `onbeforeunload` that returns something#158

sindresorhuscreated this issue 13 days ago

Meaning inline arrow functions or ones with a return statement.

This is because returning something changes the behavior:

window.onbeforeunload = () => 'Custom message';

window.onbeforeunload = () => {
    return 'Custom message';
};

The above cannot be easily auto-converted to addEventListener as it would need to be turned into:

window.addEventListener('beforeunload', event => {
    event.returnValue = 'Custom message';
});

Easier to just skip it then.

// @johnwu93

Logs

Amount funded

$40.00

Resolve this issue and earn $36.00

Fund this issue

Fund as

Payment method

Amount(USD)

Please sign in first to fund this issue

Sign in with

Pull requests

0

    Submit

    URL of your pull request

    Submit your pull request

    Please sign in first to submit a pull request

    Sign in with