Skip to content

swiftlint GitHub last commit

swiftlint documentation

SwiftLint - GitHub

Configuration in MegaLinter

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_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_PRE_COMMANDS List of bash commands to run before the linter None
SWIFT_SWIFTLINT_POST_COMMANDS List of bash commands to run after the linter None
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 MegaLinter 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 MegaLinter !

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

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 101 Docker Image Size (tag) Docker Pulls
swift Optimized for SWIFT based projects 43 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

How the linting is performed

swiftlint is called once on the whole project directory

  • filtering can not be done using MegaLinter configuration variables,it must be done using swiftlint configuration or ignore file (if existing)
  • VALIDATE_ALL_CODEBASE: false does not make swiftlint analyze only updated files

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