javascript:S1128 when importing a custom directive in a Vue setup script

Please provide

  • Operating system: Ubuntu 22.04.2
  • SonarLint plugin version: v3.15.1
  • Programming language you’re coding in: JavaScript, Vue
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): No

And a thorough description of the problem / question:

Here are my files:


export const vFocus = {
  mounted: (el) => el.focus()


<script setup>
import { vFocus } from './vFocus' //Remove this unused import of 'vFocus'. sonarlint(javascript:S1128)

  <input v-focus />

sonarLint does not detect correctly that I am in fact using the custom directive a few lines down.

The Vue syntax highlighter detects the usage correctly:

Unused import, vFocus is dimmed:

Used import, vFocus is not dimmed anymore:


Could you update your SonarLint?
We fixed this problem some time ago Fix FP S1128 (`unused-imports`): Vue.js imports used in templates · Issue #3484 · SonarSource/SonarJS · GitHub


I have v3.15.1 of SonarSource.sonarlint-vscode installed which according to VS Code is the current version (“2 wks ago”).

1 Like

Hey Vincent,

I believe this update which will be released in the upcoming version of the JavaScript analyzer will fix your problem: Fix FP S1128 (`unused-import`): Ignore imported symbols used as Vue.j… · SonarSource/SonarJS@3709039 · GitHub


1 Like

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