SonarLint support for Monorepo for VS Code Connected Mode

We often implement monorepos with NX. It would be nice if you can easily config such a monorepo in the connected mode in VS Code.

Current possible solution

If I want to use the connected mode I would have to add each project as an extra project to my VS Code workspace. This is anoying and is not a nice way to set up Sonar.

Current VS Code extension config (.vscode/settings.json):

{
  "sonarlint.connectedMode.project": {
    "connectionId": "my-company",
    "projectKey": "my-company:my-ado-project:my-repo:mono:my-inner-project1"
  }
}

Expected behaviour

In the config of the SonarLint extension it should be possible to config multiple Sonar projects and add a file path which this belongs to. In this way you only have to add a monorepo as a single project in your VS Code workspace which gives the user more overview over his monorepo.

Possible new VS Code extension configs (.vscode/settings.json):

Single Sonar config:

{
  "sonarlint.connectedMode.project": {
    "connectionId": "my-company",
    "projectKey": "my-company:my-ado-project:my-repo:mono:my-inner-project1"
  }
}

Monorepo:
Single Sonar config:

{
  "sonarlint.connectedMode.projects": [
    {
      "connectionId": "my-company",
      "projectKey": "my-company:my-ado-project:my-repo:mono:my-inner-project1",
      "path": "path/to/my-inner-project1"
    },
    {
      "connectionId": "my-company",
      "projectKey": "my-company:my-ado-project:my-repo:mono:my-inner-project2",
      "path": "path/to/my-inner-project2"
    }
  ]
}
1 Like

Hey there.

I think what you’re trying to accomplish can be solved by having a multi-root workspace. Take a look here and let me know!