github realm/SwiftLint 0.60.0
0.60.0: Fresh Breeze

latest release: 0.61.0-beta
4 days ago

Breaking

  • Remove support for boolean values in the validates_start_with_lowercase option entirely.
    Use the severity levels off, warning or error instead.
    kaseken

  • SwiftLint now requires macOS 13 or higher to run.
    JP Simard

  • In SwiftLintBuildToolPlugin, print the content of the BUILD_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 style always mimics the behavior of the
    redundant_optional_initialization rule by default. redundant_optional_initialization
    is now an alias for implicit_optional_initialization.
    leo-lem
    #1940

  • The swiftlint_linux.zip release archive has been renamed to swiftlint_linux_amd64.zip
    to avoid confusion with the new swiftlint_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 in empty_count rule.
    SimplyDanny
    #5326

  • The private_swiftui_state rule now applies to ViewModifier types.
    mt00chikin

  • Support for ARM64 Linux binaries has been added. The swiftlint_linux.zip release archive
    has been renamed to swiftlint_linux_amd64.zip. Next to it, a new swiftlint_linux_arm64.zip
    archive has been added. The SwiftLintBinary.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 to non_optional_string_data_conversion rule.
    When enabled, the rule will trigger on variables, properties, and function calls in addition
    to string literals. Defaults to false 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
    new excluded_types option which by default excludes extension and protocol types.
    This means the rule now checks struct, class, actor and enum by default. To enable
    checking of extensions and protocols, set excluded_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 as explicit module in their module map.
    SimplyDanny
    #6098

  • Ignore various assignment operators like =, +=, &=, etc. with right-hand side
    ternary expressions otherwise violating the void_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

    JP Simard
    Matt Pennig

  • Add excluded_paths option to the file_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 the excluded 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 when ignore_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 a guard/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 to nesting 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 via style: always | never.
    It replaces the redundant_optional_initialization rule mimicking it with the
    style: always option which is the default.
    leo-lem
    #1940

  • Add new ignore_identity_closures parameter to prefer_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 to true when SwiftLint detects a Swift <6 compiler
    to avoid causing compilation errors.
    p4checo
    #5965

Bug Fixes

  • Fix no_extension_access_modifier rule incorrectly triggering for nonisolated extension.
    The rule now only flags actual access control modifiers (private, public, open,
    internal, fileprivate) and ignores isolation modifiers like nonisolated.
    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 nor error values are configured.
    Ensure especially that the error level is not set to nil when the warning 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

Don't miss a new SwiftLint release

NewReleases is sending notifications on new releases.