typescript:S4822 yield keyword should be accepted

I’m using sonarlint on vscode and in a function generator :

 @(task(function* (this: CryptoCurrenciesDashboardExchangeAccountController, uuid: string, file: File) {
    const exchangeAccountfile = this.store.createRecord('crypto-currency-exchange-account-file');
    exchangeAccountfile.exchangeAccount = this.exchangeAccount;
    const extension = '.csv';
    const originalName = file.name;
    const nameWithoutExtension = originalName.substring(0, originalName.lastIndexOf(extension));
    exchangeAccountfile.name = nameWithoutExtension
      .substring(0, Math.min(nameWithoutExtension.length, 252))
      .concat(extension);
    exchangeAccountfile.type = ExchangeAccountFileType.FUNDINGS;
    exchangeAccountfile.uuid = uuid;
    try {
      yield exchangeAccountfile.save();
    } catch (e) {
      exchangeAccountfile.rolledBack();
      throw e;
    }
  }).drop())
  importTransactionsFile!: Task;

exchangeAccountfile.save() returns a promise.

sonarlint says try is not good “Consider using ‘await’ for the promise inside this ‘try’ or replace it with ‘Promise.prototype.catch(…)’ usage.sonarlint(typescript:S4822)”

but in function generator, yield is equivalent to await.

1 Like

We have faced with the same problem, too. Any news on that?