Breaking
-
Remove support for boolean values in the
validates_start_with_lowercase
option entirely.
Use the severity levelsoff
,warning
orerror
instead.
kaseken -
SwiftLint now requires macOS 13 or higher to run.
JP Simard -
In
SwiftLintBuildToolPlugin
, print the content of theBUILD_WORKSPACE_DIRECTORY
environment variable only in debug builds.
SimplyDanny
#6135 -
The
redundant_optional_initialization
rule has been replaced by the
implicit_optional_initialization
rule that enforces implicit or explicit initialization
of optional variables. Its default stylealways
mimics the behavior of the
redundant_optional_initialization
rule by default.redundant_optional_initialization
is now an alias forimplicit_optional_initialization
.
leo-lem
#1940 -
The
swiftlint_linux.zip
release archive has been renamed toswiftlint_linux_amd64.zip
to avoid confusion with the newswiftlint_linux_arm64.zip
archive.
Bradley Mackey
SimplyDanny
Experimental
- None.
Enhancements
-
Linting got up to 30% faster due to the praiseworthy performance
improvements done in the SwiftSyntax library. -
Ignore locally defined
count
identifiers inempty_count
rule.
SimplyDanny
#5326 -
The
private_swiftui_state
rule now applies toViewModifier
types.
mt00chikin -
Support for ARM64 Linux binaries has been added. The
swiftlint_linux.zip
release archive
has been renamed toswiftlint_linux_amd64.zip
. Next to it, a newswiftlint_linux_arm64.zip
archive has been added. TheSwiftLintBinary.artifactbundle.zip
now contains both versions
of the Linux binary, so that the binary plugins
can now be used on Linux and macOS running both AMD64 and ARM64 architectures.
Bradley Mackey
SimplyDanny -
Add
include_variables
configuration option tonon_optional_string_data_conversion
rule.
When enabled, the rule will trigger on variables, properties, and function calls in addition
to string literals. Defaults tofalse
for backward compatibility.
SimplyDanny
#6094 -
Add Sendable conformance to Rule.Type for building with Swift 6.
erikkerber -
Fix false positives for
Actor
-conforming delegate protocols in the
class_delegate_protocol
rule.
imsonalbajaj
#6054 -
Support extensions and protocols in
type_body_length
rule. They can be configured using the
newexcluded_types
option which by default excludesextension
andprotocol
types.
This means the rule now checksstruct
,class
,actor
andenum
by default. To enable
checking of extensions and protocols, setexcluded_types
to an empty array or exclude other
types as needed.
SimplyDanny -
Exclude explicit system modules from
duplicate_imports
analysis, that is, modules
that are part of the system frameworks but need to be imported explicitly due to being
declared asexplicit module
in their module map.
SimplyDanny
#6098 -
Ignore various assignment operators like
=
,+=
,&=
, etc. with right-hand side
ternary expressions otherwise violating thevoid_function_in_ternary
rule.
SimplyDanny
#5611 -
Rewrite the following rules with SwiftSyntax:
accessibility_label_for_image
accessibility_trait_for_button
closure_end_indentation
expiring_todo
file_header
file_length
line_length
trailing_whitespace
vertical_whitespace
-
Add
excluded_paths
option to thefile_name
rule. It allows to exclude complete file
paths from analysis. All entries are treated as regular expressions. A single match in
its full path is enough to ignore a file. This is different from theexcluded
option
that only accepts and checks against file names.
Ueeek
#6066 -
Fix false positives of
redundant_discardable_let
rule in@ViewBuilder
functions,
#Preview
macro bodies and preview providers whenignore_swiftui_view_bodies
is
enabled.
kaseken
#6063 -
Improve
multiline_parameters
rule to correctly support
max_number_of_single_line_parameters
and detect mixed formatting.
GandaLF2006 -
Add new
prefer_condition_list
rule that triggers when aguard
/if
/while
condition is composed of multiple expressions connected by the&&
operator.
It suggests to use a condition list instead, which is more idiomatic.
SimplyDanny -
Add
ignore_coding_keys
parameter tonesting
rule. Setting this to true prevents
CodingKey
enums from violating the rule.
braker1nine
#5641 -
Support deinitializers and subscripts in
function_body_length
rule.
SimplyDanny -
Extend the
xct_specific_matcher
rule to support identity operators (===
and!==
)
in addition to the existing equality operators (==
and!=
).
SimplyDanny
#5849 -
Add new
implicit_optional_initialization
rule to enforce implicit or explicit
initialization of optional variables, configurable viastyle: always | never
.
It replaces theredundant_optional_initialization
rule mimicking it with the
style: always
option which is the default.
leo-lem
#1940 -
Add new
ignore_identity_closures
parameter toprefer_key_paths
rule to skip
conversion of identity closures ({ $0 }
) to identity key paths (\.self
).
Note that identity key paths are only supported from Swift 6 on, hence this option
will be implicitly ignored/set totrue
when SwiftLint detects a Swift <6 compiler
to avoid causing compilation errors.
p4checo
#5965
Bug Fixes
-
Fix
no_extension_access_modifier
rule incorrectly triggering fornonisolated extension
.
The rule now only flags actual access control modifiers (private
,public
,open
,
internal
,fileprivate
) and ignores isolation modifiers likenonisolated
.
copilot
#6168 -
Improved error reporting when SwiftLint exits, because of an invalid configuration file
or other error.
Martin Redington
#6052 -
Keep the default severity levels when neither
warning
norerror
values are configured.
Ensure especially that theerror
level is not set tonil
when thewarning
level
isn't set either.
SimplyDanny
Using Bazel
With bzlmod:
// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.60.0", repo_name = "SwiftLint")
Without bzlmod, put this in your WORKSPACE
:
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
http_archive(
name = "SwiftLint",
sha256 = "639a2d1719dc3bf63cacf298ac936aece542343155e7847adff5384d4c3807fd",
url = "https://github.com/realm/SwiftLint/releases/download/0.60.0/bazel.tar.gz",
)
load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos")
swiftlint_repos()
load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps")
swiftlint_deps()
Then you can run SwiftLint in the current directory with this command:
bazel run @SwiftLint//:swiftlint -- --help