salesforce/eslint-plugin-lwc

Leaky event listeners not flagged by 'no-leaky-event-listeners' eslint rule

ayeshigeta opened this issue · 0 comments

Use lwc-recepies to repro: https://github.com/trailheadapps/lwc-recipes

  • Upgrade to latest eslint config (package.json)
"@salesforce/eslint-config-lwc": "^0.6.0",
  • Add no-leaky-event-listeners eslint rule(.eslintrc.json)
{
    "extends": ["@salesforce/eslint-config-lwc/recommended"],
    "rules": {
        "@lwc/lwc/no-leaky-event-listeners": "error"
    }
}
  • Add a leaky event listener to one of lwc component
    handleTest() {}

    connectedCallback() {
        window.addEventListener('test', this.handleTest.bind(this));
    }
  • run eslint: npm run lint:lwc

Expected:
Leaky event listener gets flagged as error and eslint fails

Actual:
Leaky event listener not get flagged and eslint passes