sindresorhus/eslint-plugin-unicorn

`unicorn/no-invalid-remove-event-listener` does not report when optional chaining

已关闭

#2,253 创建于 2024年1月12日

 (1 条评论) (3 个反应) (0 位负责人)JavaScript (468 个派生)user submission
bughelp wanted

仓库指标

星标
 (5,022 个星标)
PR 合并指标
 (平均合并 1天 16小时) (30 天内合并 399 个 PR)

描述

Similar to #2252 but on unicorn/no-invalid-remove-event-listener

Rule works correctly without optional chaining:

However with optional chaining stops reporting error:

this.input?.removeEventListener(event, this.onInputEvent.bind(this), true)

Can be easily tested by adding ? after el: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/f0ff04d/test/no-invalid-remove-event-listener.mjs#L49

贡献者指南