###Instruction###
Fix error Promise returned in function argument where a void return was expected.

###About issue###

Promises need to be resolved or awaited to return the expected value, otherwise, they return the promise object.

Unresolved promises:

Forgetting to await a promise is a frequent mistake. There are places where the use of a promise object is confusing or unclear because the developer forgot to resolve it.

This rule forbids returning promises where another type is expected such as in:

    conditionals
    void returns
    spread operators

What is the potential impact?

Using a promise instead of its resolved value can have unexpected results leading to bugs.

    In conditionals, it will always return a truthy value.
    In places where the expected type is void, returning a promise is often a mistake.
    Using the spread operator on a promise will raise an exception.

The executor function of a promise can also be an async function. However, this usually denotes a mistake:

    If an async executor function throws an error, the error won’t cause the created promise to reject and will be lost. Therefore, this could make it difficult to debug and handle runtime errors.
    If a promise executor function is using await, this means that it’s not necessary to use the Promise constructor, or the scope of the Promise constructor can be reduced.

Exceptions

This rule can be ignored for promises that you know will always resolve like timers.

await new Promise(resolve => time.setTimeout(1000));

###How to fix it###

If you mistakenly treated a promise as its resolved value, you can ensure it is properly resolved by using await or resolve on the promise. In some cases, you may need to use an "immediately invoked function expression" (IIFE):

(async function foo() {
  const result = await bar();
  // work with result
})();

Noncompliant code example

const promise = new Promise((resolve, reject) => {
  // ...
  resolve(false)
});
if (promise) {
  // ...
}

Compliant solution

const promise = new Promise((resolve, reject) => {
  // ...
  resolve(false)
});
if (await promise) {
  // ...
}

Noncompliant code example

const p = new Promise(async (resolve, reject) => {
  doSomething('Hey, there!', function(error, result) {
    if (error) {
      reject(error);
      return;
    }
    await saveResult(result)
    resolve(result);
  });
});

await p;

Compliant solution

const p = new Promise((resolve, reject) => {
  doSomething('Hey, there!', function(error, result) {
    if (error) {
      reject(error);
      return;
    }
    resolve(result);
  });
});

const result = await p;
await saveResult(result);

Noncompliant code example

apiCalls.forEach(async (apiCall) => {
  await apiCall.send();
});

Compliant solution

for (const apiCall of apiCalls) {
  await apiCall.send();
}

How does this work?

In JavaScript, a promise is a mechanism to perform tasks asynchronously. To this end, the language provides the Promise object which represents the eventual completion or failure of an asynchronous operation and its resulting value. A promise can be created with the Promise constructor accepting an executor function as an argument, which has resolve and reject parameters that are invoked when the promise completes or fails.

The logic of the promise is executed when it is called, however, its result is obtained only when the promise is resolved or awaited.

###Code###

```
  initUIEvents() {
    // VOT Button
    {
      this.votButton.translateButton.addEventListener("click", async () => {
        if (this.audio.src) {
          debug.log("[click translationBtn] audio.src is not empty");
          this.stopTraslate();
          return;
        }

        try {
          debug.log("[click translationBtn] trying execute translation");
          const VIDEO_ID = getVideoId(this.site.host, this.video);

          if (!VIDEO_ID) {
            throw new VOTLocalizedError("VOTNoVideoIDFound");
          }

          await this.translateExecutor(VIDEO_ID);
        } catch (err) {
          console.error("[VOT]", err);
          if (err?.name === "VOTLocalizedError") {
            this.transformBtn("error", err.localizedMessage);
          } else {
            this.transformBtn("error", err);
          }
        }
      });

      this.votButton.pipButton.addEventListener("click", async () => {
        if (this.video !== document.pictureInPictureElement) {
          await this.video.requestPictureInPicture();
        } else {
          await document.exitPictureInPicture();
        }
      });

      this.votButton.menuButton.addEventListener("click", () => {
        this.votMenu.container.hidden = !this.votMenu.container.hidden;
      });
    }

    // VOT Menu
    {
      this.votDownloadButton.addEventListener("click", () => {
        if (this.downloadTranslationUrl) {
          window.open(this.downloadTranslationUrl, "_blank").focus();
        }
      });

      this.votDownloadSubtitlesButton.addEventListener("click", () => {
        console.log(this.downloadSubtitlesUrl);
        if (this.downloadSubtitlesUrl) {
          window.open(this.downloadSubtitlesUrl, "_blank").focus();
        }
      });

      this.votSettingsButton.addEventListener("click", () => {
        this.votSettingsDialog.container.hidden =
          !this.votSettingsDialog.container.hidden;
        if (document.fullscreen === undefined || document.fullscreen) {
          document.webkitExitFullscreen && document.webkitExitFullscreen();
          document.mozCancelFullscreen && document.mozCancelFullscreen();
          document.exitFullscreen && document.exitFullscreen();
        }
      });

      this.votVideoVolumeSlider.input.addEventListener("input", (e) => {
        const value = Number(e.target.value);
        this.votVideoVolumeSlider.label.querySelector("strong").innerHTML =
          `${value}%`;
        this.setVideoVolume(value / 100);
        if (this.data.syncVolume === 1) {
          const translateVolume = Number(
            this.votVideoTranslationVolumeSlider.input.value,
          );
          const finalValue = syncVolume(
            this.audio,
            value,
            translateVolume,
            this.tempOriginalVolume,
          );

          this.votVideoTranslationVolumeSlider.input.value = finalValue;
          this.votVideoTranslationVolumeSlider.label.querySelector(
            "strong",
          ).innerHTML = `${finalValue}%`;
          ui.updateSlider(this.votVideoTranslationVolumeSlider.input);

          this.tempVolume = finalValue;
          this.tempOriginalVolume = value;
        }
      });

      this.votVideoTranslationVolumeSlider.input.addEventListener(
        "input",
        async (e) => {
          this.data.defaultVolume = Number(e.target.value);
          await votStorage.set("defaultVolume", this.data.defaultVolume);
          this.votVideoTranslationVolumeSlider.label.querySelector(
            "strong",
          ).innerHTML = `${this.data.defaultVolume}%`;
          this.audio.volume = this.data.defaultVolume / 100;
          if (this.data.syncVolume === 1) {
            this.syncTranslationWithVideo(this.data.defaultVolume);
          }
        },
      );
    }

    // VOT Settings
    {
      this.votAutoTranslateCheckbox.input.addEventListener(
        "change",
        async (e) => {
          this.data.autoTranslate = Number(e.target.checked);
          await votStorage.set("autoTranslate", this.data.autoTranslate);
          debug.log(
            "autoTranslate value changed. New value: ",
            this.data.autoTranslate,
          );
        },
      );

      this.votDontTranslateYourLangSelect.labelElement.addEventListener(
        "change",
        async (e) => {
          this.data.dontTranslateYourLang = Number(e.target.checked);
          await votStorage.set(
            "dontTranslateYourLang",
            this.data.dontTranslateYourLang,
          );
          debug.log(
            "dontTranslateYourLang value changed. New value: ",
            this.data.dontTranslateYourLang,
          );
        },
      );

      this.votAutoSetVolumeCheckbox.input.addEventListener(
        "change",
        async (e) => {
          this.data.autoSetVolumeYandexStyle = Number(e.target.checked);
          await votStorage.set(
            "autoSetVolumeYandexStyle",
            this.data.autoSetVolumeYandexStyle,
          );
          debug.log(
            "autoSetVolumeYandexStyle value changed. New value: ",
            this.data.autoSetVolumeYandexStyle,
          );
        },
      );

      this.votAutoSetVolumeSlider.input.addEventListener("input", async (e) => {
        const presetAutoVolume = Number(e.target.value);
        this.data.autoVolume = presetAutoVolume / 100;
        await votStorage.set("autoVolume", presetAutoVolume);
        this.votAutoSetVolumeSlider.label.querySelector("strong").innerHTML =
          `${presetAutoVolume}%`;
      });

      this.votShowVideoSliderCheckbox.input.addEventListener(
        "change",
        async (e) => {
          this.data.showVideoSlider = Number(e.target.checked);
          await votStorage.set("showVideoSlider", this.data.showVideoSlider);
          debug.log(
            "showVideoSlider value changed. New value: ",
            this.data.showVideoSlider,
          );
          this.votVideoVolumeSlider.container.hidden =
            this.data.showVideoSlider !== 1 ||
            this.votButton.container.dataset.status !== "success";
        },
      );

      this.votUdemyDataTextfield.input.addEventListener("change", async (e) => {
        this.data.udemyData = {
          accessToken: e.target.value,
          expires: new Date().getTime(),
        };
        await votStorage.set("udemyData", this.data.udemyData);
        debug.log("udemyData value changed. New value: ", this.data.udemyData);
        window.location.reload();
      });

      this.votSyncVolumeCheckbox.input.addEventListener("change", async (e) => {
        this.data.syncVolume = Number(e.target.checked);
        await votStorage.set("syncVolume", this.data.syncVolume);
        debug.log(
          "syncVolume value changed. New value: ",
          this.data.syncVolume,
        );
      });

      this.votTranslationServiceSelect.labelElement.addEventListener(
        "change",
        async (e) => {
          this.data.translateAPIErrors = Number(e.target.checked);
          await votStorage.set(
            "translateAPIErrors",
            this.data.translateAPIErrors,
          );
          debug.log(
            "translateAPIErrors value changed. New value: ",
            this.data.translateAPIErrors,
          );
        },
      );

      // SUBTITLES

      this.votSubtitlesMaxLengthSlider.input.addEventListener(
        "input",
        async (e) => {
          this.data.subtitlesMaxLength = Number(e.target.value);
          await votStorage.set(
            "subtitlesMaxLength",
            this.data.subtitlesMaxLength,
          );
          this.votSubtitlesMaxLengthSlider.label.querySelector(
            "strong",
          ).innerHTML = `${this.data.subtitlesMaxLength}`;
          this.subtitlesWidget.setMaxLength(this.data.subtitlesMaxLength);
        },
      );

      this.votSubtitlesHighlightWordsCheckbox.input.addEventListener(
        "change",
        async (e) => {
          this.data.highlightWords = Number(e.target.checked);
          await votStorage.set("highlightWords", this.data.highlightWords);
          debug.log(
            "highlightWords value changed. New value: ",
            this.data.highlightWords,
          );
          this.subtitlesWidget.setHighlightWords(this.data.highlightWords);
        },
      );

      this.votShowPiPButtonCheckbox.input.addEventListener(
        "change",
        async (e) => {
          this.data.showPiPButton = Number(e.target.checked);
          await votStorage.set("showPiPButton", this.data.showPiPButton);
          debug.log(
            "showPiPButton value changed. New value: ",
            this.data.showPiPButton,
          );
          this.votButton.pipButton.hidden =
            !isPiPAvailable() || !this.data.showPiPButton;
          this.votButton.separator2.hidden =
            !isPiPAvailable() || !this.data.showPiPButton;
        },
      );

      // PROXY

      this.votM3u8ProxyHostTextfield.input.addEventListener(
        "change",
        async (e) => {
          this.data.m3u8ProxyHost = e.target.value || m3u8ProxyHost;
          await votStorage.set("m3u8ProxyHost", this.data.m3u8ProxyHost);
          debug.log(
            "m3u8ProxyHost value changed. New value: ",
            this.data.m3u8ProxyHost,
          );
        },
      );

      this.votProxyWorkerHostTextfield.input.addEventListener(
        "change",
        async (e) => {
          this.data.proxyWorkerHost = e.target.value || proxyWorkerHost;
          await votStorage.set("proxyWorkerHost", this.data.proxyWorkerHost);
          debug.log(
            "proxyWorkerHost value changed. New value: ",
            this.data.proxyWorkerHost,
          );
          window.location.reload();
        },
      );

      this.votAudioProxyCheckbox.input.addEventListener("change", async (e) => {
        this.data.audioProxy = Number(e.target.checked);
        await votStorage.set("audioProxy", this.data.audioProxy);
        debug.log(
          "audioProxy value changed. New value: ",
          this.data.audioProxy,
        );
      });

      this.votResetSettingsButton.addEventListener("click", async () => {
        localizationProvider.reset();
        const valuesForClear = await votStorage.list();
        valuesForClear
          .filter((v) => !localizationProvider.gmValues.includes(v))
          .forEach((v) => votStorage.syncDelete(v));
        window.location.reload();
      });
    }
  }
```