SonarLint console.log rule hint resolves to incorrect setting

VS Code

When SonarLint detects usage of console.log and the user clicks to disable the rule, the rule which is disabled in settings.json is S106. This has no effect and the usage of console.log is still marked. The rule which needs disabling is S2228.

Hello, welcome to the community! And thank you for reporting this.

As far as I can tell, javascript:S2228 does not exist anymore in recent versions of the JavaScript analyzer (it has been deprecated and superseded by S106 about 2 years ago).

Out of the box in recent versions of SonarLint, uses of console.log should be flagged by javascript:S106, and this is why this is the rule that gets disabled by the “Deactivate rule” code action.

Please note that this rule is not enabled by default, so my guess is that you might have enabled S2228 a long time ago, and now that it has been superseded by S106, the latter is enabled (through backward compatibility), but if you want to disable it, you have to do it manually in your user settings, by deleting any entry that looks like this:

  "sonarlint.rules": {
    // Start delete below
    "javascript:S2228": {
      "level": "on"
    // End delete above