Fixing 'consistent-return' linter issue with simple arrow function

As title, I have an arrow function with the error. How can I refactor it so the error goes away?

Expected to return a value at the end of arrow function consistent-return

This is my code:

// Disable default form submission when user hits enter.
const $facetInput = $('.facet-input');
const $submitButton = $('.facet-submit');

$facetInput.on('keydown', (event) => {
  if ((event.key === 'enter' || event.keyCode === 13) && event.target !== $submitButton) {
    event.preventDefault();
    return false;
  }
});

Thanks!

14 thoughts on “Fixing 'consistent-return' linter issue with simple arrow function”

Leave a Comment