Ignore void-use for promises in sonarlint

  • Operating system: Windows
  • SonarLint plugin version: v4.6.0
  • Programming language you’re coding in: Javascript
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): No

So I have been using void for promises in the code:
void this.router.navigate

Which the sonnar js supports from Ignore promises in S3735 `void-use` · Issue #2629 · SonarSource/SonarJS · GitHub

But still the vs code is giving warning. Need fix for this.

I’ve moved your post to the section on reporting false-positives.

can you please provide a complete code sample?

I’m having the same issue on Community Build v25.7.0.110598. Sonar is unable to detect explicit void keyword on functions that return promises.
This sonar rule conflicts with ESLint rule no-floating-promises | TypeScript ESLint

void asyncFunction(); → This errors as a False-Positive, but is a good practice

This issue is related to this topic Typescript '"void" should not be used' triggers wrongly - #5

The URL for the ticket referenced in this topic is not available

Hey @Costiss

My feedback to you is the exact same as to OP. :slight_smile:

Hi Colin, thanks for the reply.

Here is a code example with more details

async function example() {
  const response = await fetch("https://api.example.com/data");
  const data = await response.json();
  return data;
}

async function main() {
  void example(); // ESLint no-floating-promises compliant but SonarQube error
  example(); // ESLint no-floating-promises error
}

Hey there.

We should have fixed this in a version of our Javascript analyzer that landed in 25.7 :thinking:

In any case I’m not seeing the error raise in 25.9

I suggest updating!