SwiftLint#

Paid feature

SwiftLint is mostly a code linter and analyzer, with basic support for formatting and correcting Swift files.

Code Linting#

Violations returned by swiftlint lint are displayed in the editor. Violations on empty lines are highlighted at the end of those lines, so the warnings stay visible in the editor.

Configuring SwiftLint#

By default, SwiftLint is executed if a .swiftlint.yml file is found in the context of a file and a swiftlint executable is found in $PATH.

To change the path to swiftlint, or when SwiftLint is executed, update the settings at Preferences… → Languages & Frameworks → Swift (Noctule).

Fixing SwiftLint Violations#

Noctule provides a “Fix all” quick fix for violations that swiftlint lint --fix can correct. Running this quick fix executes SwiftLint and updates the file with the corrected content.

Format on Save#

Format on Save is supported for SwiftLint.

Even though SwiftLint is a linter, it provides limited support for reformatting Swift files. Because some developers prefer to use it as a formatter, Noctule integrates it with “Format on Save”.

With Noctule, you can configure your IDE to reformat a file with SwiftLint when you save it. Please refer to External Code Formatters to learn how to set up your IDE.

.swiftlint.yml Configuration Files#

SwiftLint uses YAML files named .swiftlint.yml for its configuration. The syntax of these files is documented on SwiftLint/README.md.

Noctule provides a JSON schema to help edit these files:

  • Code completion for rules and syntax properties
  • Quick documentation for most properties
  • Validation of properties