SonarLint is not working in vs code

Hi,

I have installed sonarLint extension of version 1.17.0 in my vscode of version 1.49.2
Mine is windows OS.
I had also set the sonarlint.ls.javaHome variale in my vs code
C:\{user}\{projectName}\.vscode\settings.json

   "sonarlint.ls.javaHome": "C:\\Program Files (x86)\\Java\\jre1.8.0_141",

but sonarLint is not highlighting any errors in my vs code.
I checked in google and read some posts in this community. Still no luck.

I am a QA engineer and my test automation files names are like this in vs code
ex: validation.test.js
I am not sure what types of errors does sonar lint show? I am trying like this

case 1: tempEnv = "www; // i removed the 2nd quote " in this line.

I am expecting a bulb icon to show quote is missing, but not getting sonarlint error or bulb icon

case 2:

                count = json.total;
                if(!count) {
                    console.log (count)
                }

I am expecting a bulb icon to show the similar error like in demo in this website


but not getting sonarlint error or bulb icon

Please someone help me?

Hello, welcome to the community and thank you for your question!

I see several points here.

  • In case 1, removing the 2nd quote will result in a syntax error, and in this case I believe that the JavaScript analyzer will have troubles detecting issues. However, the JS language support of VSCode should underline the syntax error.
  • On my development box, case 2 correctly triggers rule javascript:S2703, so there might be something missing on your machine :slight_smile:

In addition to the JRE, SonarLint requires Node.js 8+ to analyze JavaScript and TypeScript code (see README). You can get e.g the current LTS on Nodejs.org, install it and restart your VS Code.

Finally, to help you troubleshoot the issue, you can set sonarlint.output.showVerboseLogs and sonarlint.output.showAnalyzerLogs to true, and check the SonarLint output for messages (Ctrl+Shift+U on Windows).