Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
0969e1c
Initial implementation of allowed_types option for `one-declaration-p…
snofla May 19, 2025
ea3c327
Add unit test, add changelog entry
snofla May 20, 2025
dc0a57f
Minor fixes
snofla May 21, 2025
f72f195
Fix error reporting (#6061)
mildm8nnered May 21, 2025
a3aec89
Add test case for trailing comma in multiline arguments (#6085)
SimplyDanny May 21, 2025
0338af7
Fix default rules
snofla May 21, 2025
9a54239
Run tests on Xcode 16.4
SimplyDanny Jun 15, 2025
125dd16
Support latest Swift versions
SimplyDanny Jun 15, 2025
348800b
Update SwiftSyntax to 601.0.1 (#6093)
scottrhoyt Jun 15, 2025
e2ef7ed
Treat actors as classes in `class_delegate_protocol` rule (#6067)
imsonalbajaj Jun 15, 2025
f961ad1
Prefer string blocks (#6090)
SimplyDanny Jun 15, 2025
44f0cbb
Fix markdownlint violations
SimplyDanny Jun 15, 2025
d3768ef
Bump DavidAnson/markdownlint-cli2-action (#6083)
dependabot[bot] Jun 15, 2025
bf935b0
Support rules_swift 3.0 (#6096)
luispadron Jun 16, 2025
6693072
Update dependencies and harmonize Bazel build modes (#6097)
SimplyDanny Jun 17, 2025
d168785
Migrate FileLengthRule from SourceKit to SwiftSyntax (#6100)
jpsim Jun 18, 2025
6d5af5f
Enable `async_without_await` rule (#6104)
SimplyDanny Jun 19, 2025
1e25cf6
Migrate VerticalWhitespaceRule from SourceKit to SwiftSyntax (#6103)
pennig Jun 19, 2025
b6ebbcf
Format changelog (#6105)
jpsim Jun 19, 2025
3c2f4e3
Shard GeneratedTests into parallel targets and refactor code generati…
jpsim Jun 19, 2025
8767bb6
Add `build --incompatible_strict_action_env` to `.bazelrc` (#6106)
jpsim Jun 20, 2025
775174b
[CI] Use Bazel for "Register" job (#6110)
jpsim Jun 20, 2025
614c002
Prepare for Swift 6.2 (#6115)
SimplyDanny Jun 20, 2025
873b2b6
Require macOS 13 (#6114)
jpsim Jun 20, 2025
81474e3
Enforce SourceKitFreeRule contract with fatal error (#6107)
jpsim Jun 20, 2025
7e0ea59
Let `large_tuple` rule adhere to common style (#6120)
SimplyDanny Jun 20, 2025
573ac4d
Report warning threshold (#6122)
SimplyDanny Jun 20, 2025
5a3c8c9
Inline rule-specific parts of BodyLengthVisitor (#6121)
SimplyDanny Jun 21, 2025
5eac9be
Migrate AccessibilityTraitForButtonRule from SourceKit to SwiftSyntax…
jpsim Jun 21, 2025
cc03c83
Migrate ClosureEndIndentationRule from SourceKit to SwiftSyntax (#6109)
jpsim Jun 21, 2025
18403e8
Harmonize violation positions (#6124)
SimplyDanny Jun 21, 2025
286e67f
Report more specific target types (#6123)
SimplyDanny Jun 21, 2025
45c4766
Migrate AccessibilityLabelForImageRule from SourceKit to SwiftSyntax …
jpsim Jun 21, 2025
6650ebd
Put contributors on a new line
SimplyDanny Jun 21, 2025
4ecae5b
Migrate LineLengthRule from SourceKit to SwiftSyntax (#6111)
jpsim Jun 21, 2025
5a2cf4b
Remove dead code (#6125)
jpsim Jun 21, 2025
d22e733
Add `SwiftSyntaxKindBridge` to help migrate custom rules to SwiftSynt…
jpsim Jun 21, 2025
3a922d4
Add `ConditionallySourceKitFree` to migrate custom rules to SwiftSynt…
jpsim Jun 21, 2025
c22de52
Respect `ignore_swiftui_view_bodies` option in view builders and prev…
kaseken Jun 21, 2025
f6c9633
Add `RegexConfiguration.ExecutionMode` (#6128)
jpsim Jun 22, 2025
ac476aa
Run Swift linting job with Bazel for better caching (#6130)
SimplyDanny Jun 22, 2025
388d452
Migrate ExpiringTodoRule from SourceKit to SwiftSyntax (#6113)
jpsim Jun 23, 2025
4b9208a
Ignore various assignment operators in `void_function_in_ternary` (#6…
SimplyDanny Jun 24, 2025
d14e22a
Migrate Linux builds from Azure to GitHub Actions (#6132)
SimplyDanny Jun 24, 2025
ab7d117
Migrate FileHeaderRule from SourceKit to SwiftSyntax (#6112)
jpsim Jun 24, 2025
f7f3caa
Migrate TrailingWhitespaceRule from SourceKit to SwiftSyntax (#6117)
jpsim Jun 25, 2025
e65767b
Add new `excluded_paths` option to `file_name` rule (#6092)
Ueeek Jun 25, 2025
17c77cd
Print workspace directory only in debug builds (#6137)
SimplyDanny Jun 25, 2025
2443722
Use path pattern to exclude generated tests in config (#6138)
SimplyDanny Jun 25, 2025
d4fbe69
Report remaining fixed and new violations (#6140)
SimplyDanny Jun 26, 2025
546f71b
Add additional newline to first token in file (#6141)
SimplyDanny Jun 27, 2025
929f0fc
Add warmup step to OSS check (#6134)
SimplyDanny Jun 27, 2025
de613ba
Prepare rule for SwiftSyntax 6.2 (#6144)
SimplyDanny Jun 29, 2025
fa61ea7
Fix test expectation (#6147)
SimplyDanny Jul 1, 2025
14edabd
Enable unnecessarily disabled rule (#6150)
SimplyDanny Jul 1, 2025
097bef2
Fix configuration handling in `multiline_parameters` for stricter val…
GandaLF2006 Jul 2, 2025
599e51a
Format code (#6151)
SimplyDanny Jul 2, 2025
c97cf24
Add `ignore_codingkeys` parameter in `nesting` rule (#5650)
braker1nine Jul 9, 2025
6af2aed
Ensure that `closure_end_indentation` doesn't drop comments (#6158)
SimplyDanny Jul 9, 2025
df96466
Support deinitializers and subscripts in function body length checkin…
SimplyDanny Jul 9, 2025
571e6c1
Run remaining Azure build jobs on GitHub Actions (#6149)
SimplyDanny Jul 9, 2025
4efdcc7
Base visitors on rule configuration (#6159)
SimplyDanny Jul 10, 2025
092d0c3
Keep severity levels unchanged when no options are configured (#6160)
SimplyDanny Jul 11, 2025
a321566
Support protocols and extensions in type body length checking (#6143)
SimplyDanny Jul 11, 2025
8229f45
Update dependencies (#6162)
SimplyDanny Jul 11, 2025
cb214d5
Add new `prefer_condition_list` rule (#6157)
SimplyDanny Jul 12, 2025
c1ffdfe
Enable `prefer_condition_list` rule (#6163)
SimplyDanny Jul 12, 2025
532e661
Disable background indexing in Swift extension
SimplyDanny Jul 14, 2025
69c9e29
Add Sendable conformance to Rule.Type for building with Swift 6 (#6169)
erikkerber Jul 30, 2025
aac3289
Exclude variable from concurrency analysis (#6170)
SimplyDanny Jul 30, 2025
00f2d21
Add config schema
SimplyDanny Aug 1, 2025
deb3678
Add setup steps for coding agent
SimplyDanny Aug 1, 2025
5738a61
Revert "Add setup steps for coding agent"
SimplyDanny Aug 1, 2025
7395ead
Add basic Copilot instructions
SimplyDanny Aug 1, 2025
8bb69b0
Add `include_variables` option to `non_optional_string_data_conversio…
Copilot Aug 2, 2025
201b90a
Initial implementation of allowed_types option for `one-declaration-p…
snofla May 19, 2025
5e8e92a
Add unit test, add changelog entry
snofla May 20, 2025
0b12003
Minor fixes
snofla May 21, 2025
fe356c7
Fix default rules
snofla May 21, 2025
6475db6
Rename type spec config setting
snofla Aug 3, 2025
6a7f26c
Merge branch 'one-decl-per-file' of https://github.com/snofla/SwiftLi…
snofla Aug 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .azure/templates/run-make.yml

This file was deleted.

1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build --disk_cache=~/.bazel_cache
build --experimental_remote_cache_compression
build --remote_build_event_upload=minimal
build --nolegacy_important_outputs
build --incompatible_strict_action_env

build:release \
--compilation_mode=opt \
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.0
7.6.1
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ steps:
- label: "Registration"
commands:
- echo "+++ Register Rules and Reporters"
- make --always-make register
- make --always-make bazel_register
- echo "+++ Diff Files"
- git diff --quiet HEAD
24 changes: 24 additions & 0 deletions .github/actions/bazel-linux-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Bazel Linux Build
description: Common steps to build SwiftLint with Bazel on GitHub Linux runners
inputs:
target:
description: The Bazel target to build
default: //:swiftlint
runs:
using: composite
steps:
- name: Create ci.bazelrc file
shell: bash
run: echo "$CI_BAZELRC_FILE_CONTENT" | base64 -d > ci.bazelrc
env:
CI_BAZELRC_FILE_CONTENT: ${{ env.CI_BAZELRC_FILE_CONTENT }}
- name: Apply patch
shell: bash
run: git apply --ignore-whitespace .bcr/patches/no-warnings-as-errors.patch
- name: Build SwiftLint with Bazel
shell: bash
run: |
export PATH="/usr/share/swift/usr/bin:$PATH"
bazel build --config release ${{ inputs.target }}
env:
CC: clang
19 changes: 19 additions & 0 deletions .github/actions/run-make/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run Make Rule
description: Runs a specified Makefile rule
inputs:
rule:
description: The Makefile rule to run
required: true
default: build
runs:
using: composite
steps:
- run: |
awk '
$0 ~ "${{ inputs.rule }}:" { in_rule = 1; next }
in_rule && /^\t/ { print $0 }
in_rule && !/^\t/ { in_rule = 0 }
' Makefile | while IFS= read -r command; do
eval "$command"
done
shell: bash
7 changes: 7 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
You are working on SwiftLint, a linter for Swift code that enforces coding style and conventions. It helps maintain a clean and consistent codebase by identifying and reporting issues in Swift files. It can even automatically fix some of these issues.

Linting rules are defined in `Source/SwiftLintBuiltInRules/Rules`. If someone mentions a rule by its identifier that is in "snake_case" (e.g., `rule_name`), you can usually find the rule's implementation file named "UpperCamelCaseRule.swift" (e.g., `<RuleName>Rule.swift`) in one of the sub-folders depending on the rule's kind. Specific configurations for rules are located in the `RuleConfigurations` folder, which contains files named as `<RuleName>Configuration.swift` (e.g., `IdentifierNameConfiguration.swift`).

User-facing changes must be documented in the `CHANGELOG.md` file, which is organized by version. New entries always go into the "Main" section. They give credit to the person who has made the change and they reference the issue which has been fixed by the change.

All changes need to pass `swift test` as well as running SwiftLint on itself. This is done by running `swift run swiftlint` in the root directory of the project.
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
bazel_linux:
name: Bazel, Linux, Swift 6.1 # pre-installed
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/bazel-linux-build
name: Build SwiftLint with Bazel
env:
CI_BAZELRC_FILE_CONTENT: ${{ secrets.CI_BAZELRC_FILE_CONTENT }}

plugins_linux:
name: SPM plugins, Linux, Swift ${{ matrix.version }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- image: swift:5.9-focal
version: '5.9'
- image: swift:5.10-noble
version: '5.10'
- image: swift:6.0-noble
version: '6.0'
- image: swift:6.1-noble
version: '6.1'
container: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4
- name: Build plugins
uses: ./.github/actions/run-make
with:
rule: spm_build_plugins
61 changes: 61 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Documentation

on:
push:
branches: [main]
pull_request:

jobs:
create-docs:
name: Create
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build SwiftLint and SourceKitten
uses: ./.github/actions/bazel-linux-build
with:
target: "//:swiftlint @com_github_jpsim_sourcekitten//:sourcekitten"
env:
CI_BAZELRC_FILE_CONTENT: ${{ secrets.CI_BAZELRC_FILE_CONTENT }}
- uses: actions/cache@v4
with:
key: ${{ runner.os }}-swift-spm-${{ hashFiles('Package.resolved') }}
restore-keys: ${{ runner.os }}-swift-spm-
path: .build
- name: Generate documentation
run: |
export PATH="/usr/share/swift/usr/bin:$PATH"
make docs_linux
- name: Validate documentation coverage
run: |
if ruby -rjson -e "j = JSON.parse(File.read('docs/undocumented.json')); exit j['warnings'].length != 0"; then
echo "Undocumented declarations:"
cat docs/undocumented.json
exit 1
fi
- name: Upload documentation
if: github.event_name == 'push'
uses: actions/upload-pages-artifact@v3
with:
path: docs

deploy-docs:
name: Deploy
runs-on: ubuntu-24.04
needs: create-docs
if: github.event_name == 'push'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy documentation
id: deployment
uses: actions/deploy-pages@v4
17 changes: 9 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,37 @@ name: Lint

on:
pull_request:
branches:
- '*'

permissions:
contents: read
pull-requests: write

jobs:
lint-swift:
name: Lint Swift
name: Swift
runs-on: ubuntu-24.04 # "Noble Numbat"
container: swift:6.1-noble
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/bazel-linux-build
name: Build SwiftLint with Bazel
env:
CI_BAZELRC_FILE_CONTENT: ${{ secrets.CI_BAZELRC_FILE_CONTENT }}
- name: Lint
run: swift run swiftlint --reporter github-actions-logging --strict 2> /dev/null
run: ./bazel-bin/swiftlint lint --reporter github-actions-logging --strict 2> /dev/null
lint-markdown:
name: Lint Markdown
name: Markdown
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Lint
uses: DavidAnson/markdownlint-cli2-action@v19
uses: DavidAnson/markdownlint-cli2-action@v20
with:
globs: |
CHANGELOG.md
CONTRIBUTING.md
README.md
lint-actions:
name: Lint Actions
name: Actions
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
run: |
sed 's/__VERSION__/${{ inputs.version }}/g' tools/Version.swift.template > Source/SwiftLintFramework/Models/Version.swift
sed -i -e '3s/.*/ version = "${{ inputs.version }}",/' MODULE.bazel
sed -i -e "s/^\(\s*s\.version\s*=\s*'\)[^']*'/\1${{ inputs.version }}'/" SwiftLint.podspec
- name: Configure Git author
uses: Homebrew/actions/git-user-config@master
with:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

env:
SKIP_INTEGRATION_TESTS: 'true'

jobs:
spm_linux:
name: SPM, Linux, Swift 6.1
runs-on: ubuntu-24.04
container: swift:6.1-noble
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
key: ${{ runner.os }}-swift-spm-${{ hashFiles('Package.resolved') }}
restore-keys: ${{ runner.os }}-swift-spm-
path: .build
- name: Run tests
uses: ./.github/actions/run-make
with:
rule: spm_test

spm_macos:
name: SPM, macOS ${{ matrix.macOS }}, Xcode ${{ matrix.xcode }}
runs-on: macos-${{ matrix.macOS }}
strategy:
matrix:
include:
- macOS: '14'
xcode: '15.4'
- macOS: '15'
xcode: '16.4'
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
key: ${{ runner.os }}-xcode-spm-${{ matrix.xcode }}-${{ hashFiles('Package.resolved') }}
restore-keys: ${{ runner.os }}-xcode-spm-${{ matrix.xcode }}-
path: .build
- name: Run tests
run: make spm_test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ Packages/
# Bundler
.bundle/
bundle/
bin/

# Bazel
bazel-*
/bazel-*
/MODULE.bazel.lock

# Danger
Expand Down
4 changes: 4 additions & 0 deletions .sourcekit-lsp/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/swiftlang/sourcekit-lsp/refs/heads/release/6.1/config.schema.json",
"backgroundIndexing": false
}
7 changes: 5 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ opt_in_rules:
- all
disabled_rules:
- anonymous_argument_in_multiline_closure
- async_without_await
- conditional_returns_on_newline
- contrasted_opening_brace
- convenience_type
Expand Down Expand Up @@ -75,6 +74,8 @@ file_name:
- RuleConfigurationMacros.swift
- SwiftSyntax+SwiftLint.swift
- TestHelpers.swift
excluded_paths:
- Tests/GeneratedTests/GeneratedTests_\d\d\.swift
final_test_case: *unit_test_configuration
function_body_length: 60
identifier_name:
Expand All @@ -88,7 +89,9 @@ redundant_type_annotation:
single_test_class: *unit_test_configuration
trailing_comma:
mandatory_comma: true
type_body_length: 400
type_body_length:
warning: 400
excluded_types: []
unneeded_override:
affect_initializers: true
unused_import:
Expand Down
Loading