VSC SonarLint plugin steals focus constantly

SonarQube Community edition 8.5 (build 37579)
SonarLint v3.1.0
Latest visual studio code version

Open a file that has an issue in it (or create an issue in an existing file).

Expected behavior:

  • SonarLint unobtrusively scans the file and reports the error and user can continue what they were doing

Actual behavior:

  • A window pops up with every save
    JS/TS analysis failed. Please check the SonarLint Output for more details. The source of the message is the SonarLint extension.
  • Window then opens and forces the SonarLint output open and sets focus on the output window.

I love the SonarLint extension, however in it’s current state it is almost unusable as I am unable to work using my standard workflow. I have even tried closing the output windows and it re-opens them and sets the focus on the output window.

Hello, welcome to the community! And thanks for reporting this issue.

Did you try to have a look at what’s actually logged by the SonarLint output and fix the root cause for the issue?

In its normal behavior, SonarLint is definitely not supposed to interrupt your workflow like this. So if it does, I bet there is something that needs to be fixed in your setup. Please feel free to post here any relevant extract of the SonarLint output so we can help with the troubleshooting.

I am not getting any errors with the SonarLint config or anything (already fixed those). It is finding legit issues with the typescript code like it should… It just keeps popping up and stealing focus when it shouldn’t.

SonarLint only shows this popup when it catches a certain exception from the underlying analyzer. So I would strongly advise that you:

  • set sonarlint.output.showAnalyzerLogs and sonarlint.output.showVerboseLogs to true in your user settings
  • reload the window / restart VSCode
  • open a TS file, wait for the popup to appear
  • go to the SonarLint Output (on Windows: Ctrl+Shift+P, “SonarLint: Show SonarLint Output”)
  • copy the contents of the output pane and paste it here enclosed within a ``` block

Interestingly enough, I remember another old thread where a similar symptom was reported (with some issues reported despite the annoying error popup).

curiously enough, turning those flags on, it no-longer pops up that box and steals focus anymore…

Ok, after using for a bit I did get the error you referenced in the older thread (no tsconfig.json file found)

Thanks for the additional details. Would you be able to share some of your project setup, e.g:

  • Which language(s) are you working with?
  • If you are using TypeScript, are the relevant tsconfig.json files visible in the IDE or only present in a parent folder?