Skip to content

swiftlint

swiftlint documentation

SwiftLint - GitHub

Configuration in Mega-Linter

Variable Description Default value
SWIFT_SWIFTLINT_DOCKER_IMAGE_VERSION Docker image version latest
SWIFT_SWIFTLINT_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
SWIFT_SWIFTLINT_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src|lib)
Include every file
SWIFT_SWIFTLINT_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test|examples)
Exclude no file
SWIFT_SWIFTLINT_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".swift"]
SWIFT_SWIFTLINT_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
SWIFT_SWIFTLINT_CONFIG_FILE swiftlint configuration file name
Use LINTER_DEFAULT to let the linter find it
.swiftlint.yml
SWIFT_SWIFTLINT_RULES_PATH Path where to find linter configuration file Workspace folder, then Mega-Linter default rules
SWIFT_SWIFTLINT_DISABLE_ERRORS Run linter but consider errors as warnings false
SWIFT_SWIFTLINT_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0

IDE Integration

Use swiftlint in your favorite IDE to catch errors before Mega-Linter !

IDE Extension Name Install
Atom linter-swiftlint Visit Web Site
IDEA swiftlint
xcode Configure manually Visit Web Site

Mega-Linter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default Mega-Linter Flavor 84 Docker Image Size (tag) Docker Pulls
swift Optimized for SWIFT based projects 38 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • Activated only if one of these files is found: .swiftlint.yml
  • File extensions: .swift

Example calls

docker run -v /tmp/lint:/tmp/lint:rw norionomura/swiftlint:latest swiftlint lint --path /tmp/lint --strict
docker run -v /tmp/lint:/tmp/lint:rw norionomura/swiftlint:latest swiftlint autocorrect --path /tmp/lint --strict

Help content

Available commands:

   analyze         [Experimental] Run analysis rules
   autocorrect     Automatically correct warnings and errors
   docs            Open SwiftLint Docs on web browser
   generate-docs   Generates markdown documentation for all rules
   help            Display general or command-specific help
   lint            Print lint warnings and errors (default command)
   rules           Display the list of rules and their identifiers
   version         Display the current version of SwiftLint

Installation on mega-linter Docker image

None