False Positive Web:S6851 Exclude i18n keys

  • What language is this for?
    Javascript (Vue 3, Component api)
  • Which rule?
    Web:S6851
  • Why do you believe it’s a false-positive/false-negative?
    The rule states 'Images should have a non-redundant Image description, if the alt text contains a string with words like ‘image’ or picture. While generally reasonable, we use the vue-18n plugin to internationalize messages, including image texts, and the rule triggers on a piece of code that looks like:
Inside some foo.vue component
<template
    <div class="header-img">
      <img src="@/assets/img/some-image.jpg" :alt="$t('section.start.headerImage')">
    </div>
</template>

that is to say, headerImage is not the actual Text that will be output to the user, but rather the name of the translation key, to be interpreted through the i18n Plugin. As such, the rule should probably not apply here. Perhabs you could include a whitelist of i18n libraries/plugins which are excluded, , generally exclude function arguments that are strings from this rule or find some other heuristic.

  • Are you using
    • SonarLint - which IDE/version?
      SonarLint in IntelliJ IDEA
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
    See code above