heinetz: Funktion mit Parameter aufrufen

Beitrag lesen

Das mit dem Load-Event hat funktioniert.

Nun habe ich die Funktion ausgelagert und lasse sie von eslint überprüfen. Dort werden mir zwei Fehler ausgegeben, die ich nicht wirklich verstehen und so auch nicht lösen kann.

/**
 * Live event binding on document or different context
 *
 * debounceEvent('myFunction', '200', document, 'myArgument');
 *
 *
 * @param   {string} func function to be triggered after timeout
 * @param   {string} wait duration of the timeuot
 * @param   {Object} scope arguments for function
 * @returns {void}
 */

export default (func, wait, scope) => {
  return function() {
    const context = scope || this;
    const args = arguments;
    let timeout;
    const later = function() {
      timeout = null;
      func.apply(context, args);
    };
    clearTimeout(timeout);
    timeout = setTimeout(later, wait);
  };
};

Und so sehen die Fehlermeldungen aus:

  • 13:39 error Unexpected block statement surrounding arrow body; move the returned value immediately after the => arrow-body-style
  • 16:18 error Use the rest parameters instead of 'arguments' prefer-rest-params

Kannst Du mir etwas dazu sagen?

Danke und

gruss, heinetz