swiftlint
swiftlint documentation
- Version in MegaLinter: 0.54.0
- Visit Official Web Site
- Docker image: norionomura/swiftlint:latest
- arguments:
-v {{WORKSPACE}}:/tmp/lint:rw
- arguments:
- See How to configure swiftlint rules
- See How to disable swiftlint rules in files
- See Index of problems detected by swiftlint
Configuration in MegaLinter
- Enable swiftlint by adding
SWIFT_SWIFTLINT
in ENABLE_LINTERS variable - Disable swiftlint by adding
SWIFT_SWIFTLINT
in DISABLE_LINTERS variable
- Enable autofixes by adding
SWIFT_SWIFTLINT
in APPLY_FIXES variable
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_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
SWIFT_SWIFTLINT_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".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_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling SWIFT_SWIFTLINT and its pre/post commands | None |
SWIFT_SWIFTLINT_CONFIG_FILE | swiftlint configuration file nameUse 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 |
SWIFT_SWIFTLINT_CLI_EXECUTABLE | Override CLI executable | ['swiftlint'] |
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 | 121 | ||
cupcake | MegaLinter for the most commonly used languages | 83 | ||
swift | Optimized for SWIFT based projects | 50 |
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 (project
CLI lint mode)
- 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
doesn't 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 --fix --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 selected group
of rules
lint (default) Print lint warnings and errors
reporters Display the list of reporters and their identifiers
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