Skip to content

Conversation

iangmaia
Copy link
Contributor

Related to https://github.com/Automattic/buildkite-ci/pull/707, this PR updates the run_swiftlint script to allow the --config parameter specifying a SwiftLint config file.


  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.

@iangmaia iangmaia self-assigned this Aug 22, 2025
@iangmaia iangmaia added the enhancement New feature or request label Aug 22, 2025
@iangmaia iangmaia marked this pull request as ready for review August 22, 2025 13:24
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock, with an open question

echo "Usage: $0 [--strict | --lenient] [--config CONFIG_FILE]"
exit 1
fi
CONFIG_FILE="$2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow multiple occurrences of the --config flag like the SwiftLint binary does?

I.e. make CONFIG_FILE=() be initialized as an array and do CONFIG_FILE+= here?

Otherwise invoking run_SwiftLint with multiple --config A --config B, while valid with swiftlint, will make run_SwiftLint only consider the last one and ignore the other ones, which might be a confusing discrepancy with the official swiftlint call…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't considering SwiftLint could deal with multiple --config -- nice one, added support for it on 0b5fdc8

# If no config files specified, use default
if [[ ${#CONFIG_FILES[@]} -eq 0 ]]; then
CONFIG_FILES=(".swiftlint.yml")
SWIFTLINT_ARGUMENTS+=(--config ".swiftlint.yml")
Copy link
Contributor

@AliSoftware AliSoftware Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if that SWIFTLINT_ARGUMENTS+=(--config ".swiftlint.yml") is strictly necessary, since that's already handled by swiftlint itself that if no --config … is passed it uses .swiftlint.yml by default… so might as well not pass that --config argument in those cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not necessary indeed 🤔 updated on aaa2860

@iangmaia iangmaia enabled auto-merge (squash) August 22, 2025 14:58
@iangmaia iangmaia merged commit af66702 into trunk Aug 22, 2025
26 checks passed
@iangmaia iangmaia deleted the iangmaia/allow-custom-config-files branch August 22, 2025 15:05
iangmaia added a commit that referenced this pull request Aug 22, 2025
- Add `--config` argument to `run_swiftlint` script to allow specifying custom `.swiftlint.yml` config files and allowing for multiple `--config` arguments [#189]
iangmaia added a commit that referenced this pull request Aug 22, 2025
- Add `--config` argument to `run_swiftlint` script to allow specifying custom `.swiftlint.yml` config files and allowing for multiple `--config` arguments [#189]
iangmaia added a commit that referenced this pull request Aug 22, 2025
- Add `--config` argument to `run_swiftlint` script to allow specifying custom `.swiftlint.yml` config files and allowing for multiple `--config` arguments [#189]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants