Skip to content

Support for monorepo/workspace-level configuration in VSCode extension #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fatbobman opened this issue Apr 14, 2025 · 3 comments
Closed

Comments

@fatbobman
Copy link

Current Setup

I'm working with a monorepo structure using VSCode workspace:

MyProject.code-workspce

{
  "folders": [
    { "path": "Domain" },    // Swift Package
    { "path": "Persistent" } // Swift Package
  ],
"settings": {
    "swiftlint.configSearchPaths": ["${workspaceFolder}"],
  },
}

The workspace directory structure:

MyProject/
├── .swiftlint.yml          // Workspace-level config
├── MyProject.code-workspace
├── Domain/
│   └── Package.swift
│   └── .vscode/settings.json
└── Persistent/
    └── Package.swift
│   └── .vscode/settings.json

Current Behavior

The VSCode SwiftLint extension doesn't seem to recognize the workspace-level .swiftlint.yml configuration. Currently, we have to:

  • Either duplicate the config file in each package directory

Expected Behavior

When using a workspace:

  1. The extension should recognize a workspace-level .swiftlint.yml
  2. This config should apply to all Swift files in the workspace unless overridden by package-specific configs
  3. Ideally, the extension's configSearchPaths setting in workspace settings should work relative to the workspace root

Question

What's the recommended way to maintain a single SwiftLint configuration in a monorepo/workspace setup? Is this a feature that could be supported in the extension?

@fatbobman
Copy link
Author

I found the way to set it up.

@SimplyDanny
Copy link
Collaborator

I found the way to set it up.

Great! Would you like to share your solution in case others are interested, too?

@fatbobman
Copy link
Author

fatbobman commented Apr 14, 2025

@SimplyDanny

MyProject.code-workspace

"swiftlint.configSearchPaths": ["../.swiftlint.yml", ".swiftlint.yml"]

in each Package .vscode/settings.json

"swiftlint.configSearchPaths": ["../.swiftlint.yml", ".swiftlint.yml"]

in .swiftlint.yml

A path (Package) name must be used, and wildcards cannot be used.

included:
  - Domain/Sources
  - Persistent/Sources

excluded:
  - .build
  - .swiftpm
  - Generated
  - Domain/Tests
  - Persistent/Test

Now whether you open workspace or package directly, lint is easy to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants