Bug: false positive for unused import in Vue with <script setup> and kebab-case HTML component tag

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube Enterprise Edition Version 9.2.4 (build 50792)

  • what are you trying to achieve
    In an SFC Vue file:

// Foo.vue
<template>
     <my-component title="Foo title" />
</template>

<script setup lang="ts">
import MyComponent from './MyComponent.vue';
</script>

with MyComponent SFC file is

// MyComponent.vue
<template>
    <h1>{{ title }}</h1>
</template>

<script setup lang="ts">
defineProps({
    title: {
         type: String,
         required: true,
    }
})
</script>

Sonar complains about my import MyComponent from './MyComponent.vue'; is unused.

  • what have you tried so far to achieve this

If I switch to PascalCase component tag, e.g <MyComponent title="Foo" />, Sonar is happy with it, but not with kebab-case

Issue Type: Bug
I seems that sonarlint cannot wrap its head around having pascal-case imports but kebab-case html tags and reports imports as unused in the script setup tag of vue while those imports are actively used in the template tag part of the vue sfc

Extension version: 3.1.0
VS Code version: Code - Insiders 1.64.0-insider (753319a08f8e74700b1dba3a29bf0a6af7c2953f, 2022-01-12T05:16:42.486Z)
OS version: Windows_NT x64 10.0.19042
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core™ i7-10700 CPU @ 2.90GHz (16 x 2904)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.75GB (4.14GB free)
Process Argv –crash-reporter-id 5f9e326c-2a01-458b-95a4-f411641d6f56
Screen Reader no
VM 0%
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythontb:30258533
pythonvspyt551cf:30291413
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805cf:30301675
pythonvspyt200:30323110
vsccppwt:30421239
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30404738
wslgetstarted:30421357
vscop804:30404766
vs360cf:30404996
vsclayoutctrc:30405799
py55gd98cf:30408622
azactmsalcf:30409288

Hi @sschneider-ihre-pvs,

Welcome to the community and thanks for your report. I’ve combined it with another report of the same issue.

 
Ann