diff --git a/lib/rules/ensure-matching-remove-event-listener.js b/lib/rules/ensure-matching-remove-event-listener.js index 44cc6ccf79..d31f439b69 100644 --- a/lib/rules/ensure-matching-remove-event-listener.js +++ b/lib/rules/ensure-matching-remove-event-listener.js @@ -95,19 +95,10 @@ module.exports = { } if (hasAddEventListener) { if (!hasRemoveEventListener) { - if (!hasReturnStatement) { - const messageId = 'requiredCleanup'; - - report(context, messages, messageId, { - node, - }); - } else { - const messageId = 'requiredRemoveEventListener'; - - report(context, messages, messageId, { - node, - }); - } + const messageID = hasReturnStatement ? 'requiredRemoveEventListener' : 'requiredCleanup'; + report(context, messages[messageID], messageID, { + node, + }); } } }