github realm/SwiftLint 0.61.0
0.61.0: Even Fresher Breeze

2 days ago

Breaking

  • If SWIFTLINT_DISABLE_SOURCEKIT is set to prohibit loading libsourcekitdInProc at runtime,
    rules requiring SourceKit will be disabled and a warning will be printed once per rule.
    SimplyDanny

  • The operator_whitespace rule has been removed and its functionality merged into the
    function_name_whitespace rule. The latter now also checks spacing around the func
    keyword, the function name/operator and its generic parameters while respecting comments.
    On top of that, it supports autocorrection.
    SimplyDanny

  • Expose only TestHelpers and ExtraRulesTests as part of Bazel releases.
    SimplyDanny

Experimental

  • Both Linux release archives (for AMD64 and ARM64) now contain two binaries:
    • A dynamically linked binary that requires libsourcekitdInProc.so together with its
      transitive dependencies to be present on the system at runtime. It is named swiftlint
      and the same binary as before. It supports all built-in rules.
    • A fully statically linked binary named swiftlint-static that does not require
      any dynamic libraries at runtime. Rules requiring SourceKit will be disabled and
      reported to the console when running this binary.
    SimplyDanny

Enhancements

  • A fully statically linked Linux binary can now be built with the Swift SDK and
    the compiler options -Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT. This binary does not
    require libsourcekitdInProc.so or any other dynamic libraries to be present on the
    system at runtime. Rules requiring SourceKit will be disabled and reported to the console
    when running this binary.
    SimplyDanny

  • Add function_name_whitespace rule to enforce consistent spacing between the func
    keyword, function name, and its generic parameters. Ensures exactly one space between
    func and the function name, and configurable spacing around generics via
    generic_spacing:

    • no_space (default): func name<T>()
    • leading_space: func name <T>()
    • trailing_space: func name<T> ()
    • leading_trailing_space: func name <T> ()

    Supports autocorrection.
    GandaLF2006

  • The operator_whitespace rule now supports autocorrection and better respects comments in
    function declarations. The rule has been deprecated in favor of the new function_name_whitespace
    rule. You can still refer to it by its identifier, but get checking for normal function names
    on top.
    SimplyDanny

  • In line_length rule, treat strings with opening and closing quotes in the same line as
    single-line strings no matter if they are enclosed by triple quotes or not. Furthermore,
    improve detection of comment-only lines.
    SimplyDanny
    #6220
    #6219

  • Improve detection of comment-only lines in file_length rule.
    SimplyDanny
    #6219

  • Rewrite quick_discouraged_call rule with SwiftSyntax.
    SimplyDanny

Bug Fixes

  • Ensure that header matched against always end in a newline in file_header rule.
    SimplyDanny
    #6227

  • Fix closure_end_indentation rule reporting violations when the called base
    involves chained optional expressions.
    SimplyDanny
    #6216


Using Bazel

With bzlmod:

// Pending BCR update
bazel_dep(name = "swiftlint", version = "0.61.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 = "ee8ca2eeb93b8f294a8ca2d76fead1a6510b4d40421b39b0bf88b73f7182c313",
    url = "https://github.com/realm/SwiftLint/releases/download/0.61.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.