Bug: false positive for unused import in vue using <script setup> syntax

  • versions used
    SonarSource 6.3.1.40498

  • error observed
    Unnecessary imports should be removed (Code smell) (javascript:S1128)

  • steps to reproduce
    On Vue 3.2, import and render a component using the new Vue <script setup> syntax. Sonar reports that the component is imported but not used with the new syntax while the component is clearly used. This error was observed on a TypeScript project (so <script lang="ts" setup>), but I suspect it would appear in js projects too.
    Here’s a link to the script setup api: SFC <script setup> | Vue.js

  • potential workaround
    No workaround. Has been needing a bug fix since July, 2021. I figured somebody would have reported it by now.

Hi,

First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

6.3.1 → 6.7.7 → 7.9.6 → 8.9.4 → 9.2.2 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

 
Ann

Hi, I have the same issue and I’m using Enterprise Edition Version 9.2.4 (build 50792)

Hi @ahnpnl,

Welcome to the community!

Can you create a new thread please, and include a code snippet?

 
Thx,
Ann

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

1 Like