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 87 Docker Image Size (tag) Docker Pulls
swift Optimized for SWIFT based projects 39 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

OVERVIEW: A tool to enforce Swift style and conventions.

USAGE: swiftlint <subcommand>

OPTIONS:
  --version               Show the version.
  -h, --help              Show help information.

SUBCOMMANDS:
  analyze                 Run analysis rules
  docs                    Open SwiftLint documentation website in the default
                          web browser
  generate-docs           Generates markdown documentation for all rules
  lint (default)          Print lint warnings and errors
  rules                   Display the list of rules and their identifiers
  version                 Display the current version of SwiftLint

  See 'swiftlint help <subcommand>' for detailed help.

Installation on mega-linter Docker image

None