How to enable all Typescript rules (code smells) in VS code?

Hi,

I recently installed Sonarlint extension in VS Code.
But it doesn’t flag any ‘code smell’ issues as per the ruleset - https://rules.sonarsource.com/typescript
It does work as I do get some errors (although I haven’t been able to identify exactly which rules), but it is definitely not as complete as the ruleset describes.

Is it something that can, or needs to be configured? I would like it to match better with the default, recommended ruleset that we have on Sonarqube.

Setup:

  • MacOS Catalina
  • VS Code 1.44.2
  • Sonarlint 1.15.0

Thanks

Hello @wslyvh,

If you’re using or familiar with SonarQube, the ruleset enabled in SonarLint by default is equivalent to our default “Sonar way” quality profile in SonarQube. In case you’re not familiar with SonarQube or Quality Profiles, this means it’s a recommended starting point that activates what we think are the most useful rules: enough to help, not so much as to be overwhelming.

You can certainly work on activating additional rules if you’re not seeing what you expect. To do so, look for the SonarLint rules pane within the Explorer area in VS Code. There you can expand to see the rules available for each language, which are active or not, and click to toggle them on or off. In case you don’t know the rule based on its brief description, you can click to open the full description in a separate pane.

Here’s a screenshot with arrows pointing at what I’m talking about:

Hope this helps!

2 Likes

Additionally, if you are using the recommended ruleset in SonarQube, you might want to synchronize it with SonarLint’s connected mode; this way you will benefit from the exact same quality profile as the one configured for your project on SonarQube.

Thanks Jeff, Jean-Baptiste,

I see now that we were using ’ Sonar way Recommended ’ on SonarQube. So that probably explains the difference.
Do you know I quality profiles can be configured on Sonarlint locally as well? Or does that require to set up connected mode?

Will look into that.

I would recommend that you configure connected mode, which will synchronize all relevant settings from your SonarQube server: quality profile, issues silenced as “false positive” or “won’t fix”, analyzer version and analysis settings like file inclusion/exclusion patterns.

That being said, if connected mode poses any issue, you can configure rules like accurately described by @Jeff_Zapotoczny :slight_smile:

2 Likes