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


Amount funded


Resolve this issue and earn $36.00

Fund this issue

Fund as

Payment method


Please sign in first to fund this issue

Sign in with

Pull requests



    URL of your pull request

    Submit your pull request

    Please sign in first to submit a pull request

    Sign in with