False Positive Web:S4645 A </script> was found without a relating opening <script> tag

Product Used: SonarLint in Visual Studio Code, v3.11.0
Language used: Vue.js 3 / Javascript

Affected Rule: Web:S4645
A </script> was found without a relating opening <script> tag. This may be caused by nested script tags.

Code Sample:
This started as a sample of actual code that I pruned as much as possible with trial and error while still raising the false positive. The resulting code is thus quite nonsensical.

filename errorDemonstration.vue

<template>
  {{  (3 < 5 ? "foo" : "bar") }}
</template>

<script>
export default {
 mounted() {
   //5 > 0 ? foo : bar;
 },
}
</script>

And yes, that commented out terniary is necessary, removing it removes the sonarlint warning. It seems to be related to the presence of ternaries with < followed by one with a > in them, since if I remove those the error disappears as well. So the error does not occur if I were to do:

<template>
  {{  (3 > 5 ? "foo" : "bar") }}
</template>

<script>
export default {
 mounted() {
   //5 < 0 ? foo : bar;
 },
}
</script> // No warning

Hello and welcome to our community forum @wnmzzzz !

Thanks a lot for reporting this issue and for the concise and clear reproducer you’ve provided! That was super helpful.

This is definitely an unwanted behavior, and I have created a corresponding ticket to fix this issue.

Thanks again!

Best,
-Christophe

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.