S7785 (top level await) Rule breaks browser compatibility

Sorry if this is wrong section. Not sure if I would call this a bug, or a FP.

Then tell us:

  • What language is this for?

    • JavaScript / TypeScript
  • Which rule?

    • javascript:S7785 / typescript:S7785
  • Why do you believe it’s a false-positive/false-negative?

    • Top level await is not a “base line” browser feature. Safari and WebView do not support this yet.
    • await compatibility - JavaScript | MDN
    • This means that implementing this fix will restrict customer browser compatibility. I would expect default rules to only include recommendations that are baseline compatible with all major browsers (at least 5% use). For people who are not concerned with browser cross compatibility, this rule is ok. However, for the Sonar-Way, I would expect it to not be turned on by default until it becomes a Baseline feature.
    • For NPM packages, the project may contain a browsers file or a browsers field in the package indicating what browseres need to be supported. Not sure if this information is parsable since what the value means is a moving target if not listing explicit versions.
  • Are you using

    • SonarQube Cloud?
    • SonarQube Server / Community Build - which version?
      • Community Build v25.10.0.114319
    • SonarQube for IDE - which IDE/version?
      • Does not seem to be in mine, but other say they saw it in VSC.
  • How can we reproduce the problem? Give us a self-contained snippet of code

    See await compatibility - JavaScript | MDN

Hi @Tezra,

thanks for this feedback. We already have planned an effort to enable/disable rules based on ECMAScript versions here. I will add the point about considering the browsers file, that is also information we could rely on.

Right now the only information the JS/TS analyzer checks to disable rules dynamically is the declared dependencies.

In the meantime, given your use case, I recommend you disable this rule in your quality profile.

Cheers