Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>SwiftLintNew to Visual Studio Code? Get it now.

SwiftLint

vknabel

|
7,470 installs
| (4) | Free
VS Code extension to enforce Swift style and conventions via SwiftLint
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

SwiftLint for VS Code

VS Code extension to enforce Swift style and conventions via SwiftLint. You can use SwiftLint installed globally or via the Swift Package Manager.

Global Installation

You can install SwiftLint globally using Homebrew or Mint. For a local setup you can use the Swift Package Manager.

# Using Homebrew
$ brew install swiftlint
# Using Mint
$ mint install realm/SwiftLint
# Manually
$ git clone https://github.com/realm/SwiftLint.git
$ swift build -c release

Local Installation

Add the package to your dependencies in Package.swift:

// swift-tools-version:4.2

import PackageDescription

let package = Package(
    name: "Komondor",
    products: [ ... ],
    dependencies: [
        // My dependencies
        .package(url: "https://github.com/orta/PackageConfig.git", from: "0.0.1"),
        // Dev deps
        .package(url: "https://github.com/orta/Komondor.git", from: "0.0.1"),
+        .package(url: "https://github.com/realm/SwiftLint.git", from: "0.37.0"),
    ],
    targets: [...]
)

Configuration

Config Type Default Description
swiftlint.enable Bool true Whether SwiftLint should actually do something.
swiftlint.onlyEnableOnSwiftPMProjects Bool false Requires and uses a SwiftLint as SwiftPM dependency.
swiftlint.onlyEnableWithConfig Bool false Only lint if config present.
swiftlint.path String /usr/local/bin/swiftlint The location of the globally installed SwiftLint.
swiftlint.additionalParameters [String] [] Additional parameters to pass to SwiftLint.
swiftlint.configSearchPaths [String] [] Possible paths for SwiftLint config. This disables nested configurations!
swiftlint.autoLintWorkspace Bool true Automatically lint the whole project right after start.

Commands

Short Title Command
SwiftLint: Lint workspace swiftlint.lintWorkspace
SwiftLint: Fix workspace swiftlint.fixWorkspace
SwiftLint: Fix document swiftlint.fixDocument

To automatically fix all issues within a document on save, add the following to your .vscode/settings.json:

{
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  }
}

Contributors

  • Valentin Knabel, @vknabel, @vknabel on Twitter

License

vscode-swiftlint is available under the MIT license.

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft