SonarSource / SonarJS

SonarSource Static Analyzer for JavaScript and TypeScript
https://community.sonarsource.com/
GNU Lesser General Public License v3.0
1.04k stars 185 forks source link

Fix FP S1128 (`unused-imports`): Vue.js imports used in templates #3484

Closed ilia-kebets-sonarsource closed 1 year ago

ilia-kebets-sonarsource commented 1 year ago

The script attribute lang="ts" is necessary for this FP to occur.

<template>
  <Foo />
</template>

<script setup lang="ts">
import Foo from './Foo' // FP
</script>

Reported in:

Zorin95670 commented 1 year ago

Also appear, if we are not on TS script :) Example with no TS script : https://sonarcloud.io/project/issues?resolved=false&sinceLeakPeriod=true&types=CODE_SMELL&id=ditrit_leto-modelizer&open=AYOJrJ45O7ogrcn3JpkB

ilia-kebets-sonarsource commented 1 year ago

Thanks for notifying us @Zorin95670. The current fix does also fix the issue you linked to.

ferferga commented 1 year ago

@ilia-kebets-sonarsource Hello, sorry for necropost, but I've been following this issue since it was created because I'm affected. I've been tracking it until the day of it being closed and since it's not very old, I think it's better than opening a new issue.

The issue it's not solved for me. I've kept waiting and waiting (just to see if Sonar somehow needed to flush its cache or "refresh" itself), but still no luck, even after modifying the affected files directly.

Not sure if it's relevant, but my imports are not default ones, like this: import { Swiper } from 'swiper/vue';

ilia-kebets-sonarsource commented 1 year ago

Hey @ferferga,

Could you provide a more elaborate code example of how you use your component and where is the issue raised?

ferferga commented 1 year ago

@ilia-kebets-sonarsource I can share the full files without issues, since I'm working in a open source project. This code smell is reported 3 times in my repo. I attach the relevant line that SonarCloud highlights and the ID of the detected code smell in the dashboard (obtained from the open query parameter):

Some key things I noticed:

Don't hesitate in contacting me if you need further details to triage this issue or there's something else I can be helpful with to help with this.

ilia-kebets-sonarsource commented 1 year ago

Can you please report this under the relevant product at https://community.sonarsource.com/ ?