talira

SwiftLint

Linter that enforces Swift style and conventions, with auto-fix

open sourceMITfree

SwiftLint is a linter for Swift that enforces the style rules generally accepted by the Swift community, built mostly on SwiftSyntax, with some rules using SourceKit for type information. It runs from the command line, as Swift Package Manager build tool and command plugins, in an Xcode build phase, through Fastlane, Docker or a Git pre-commit hook. Rules are configured in .swiftlint.yml, opt-in rules and custom rules (Swift or regex) can be added, and many violations can be fixed automatically with --fix.

Problems it solves

  • Enforce a consistent code style across my Swift project
  • Show Swift style warnings in Xcode while I build
  • Fail my iOS CI build when Swift code breaks our style rules

Features

  • Community style rules built on SwiftSyntax
  • Auto-correct with --fix
  • Swift and regex custom rules
  • Swift Package Manager build tool and command plugins
  • Xcode run script phase, Fastlane, Docker and pre-commit hook
  • Nested and remote configuration files

Capabilities

Has a command line toolplan not known

Alternatives

The same job

These do what SwiftLint does.

  1. Airbnb Swift Style Guide Airbnb's Swift style guide, with a SwiftPM plugin that formats and lints to it
  2. Credo Static code analysis for Elixir, with a focus on teaching and code consistency
  3. detekt A static code analyzer for Kotlin
  4. RuboCop A Ruby static code analyzer and formatter, based on the community Ruby style guide.
  5. PHP_CodeSniffer Detect and fix coding standard violations in PHP
  6. stylelint-config-standard The standard shareable config for Stylelint

Compare SwiftLint with the top 3