Skip to content

Make swift:lint work with SwiftLint 0.65.1's relative baseline paths - #843

Merged
pondorasti merged 1 commit into
mainfrom
codevisor/swiftlint-baseline-paths
Oct 26, 2026
Merged

pondorasti merged 1 commit into
mainfrom
codevisor/swiftlint-baseline-paths

Conversation

@pondorasti

Copy link
Copy Markdown
Member

Summary

bun run swift:lint failed on unchanged main for anyone on SwiftLint 0.65.1, the current release. It reported every grandfathered violation again. Since CI doesn't run SwiftLint, the pre-commit hook was the only gate, and it had to be bypassed.

  • Cause: SwiftLint before 0.65.1 wrote baseline locations as absolute file:// URLs, so swift-lint-baseline.mjs converted paths on write and converted them back before every lint. 0.65.1 fixed that (realm/SwiftLint#6812) and now writes and matches plain relative paths. The conversion broke every match, and writing a baseline threw "Invalid URL".
  • Fix: scripts/swift-lint.mjs replaces swift-lint.sh and swift-lint-baseline.mjs.
    • lint passes .swiftlint-baseline.json to SwiftLint unchanged.
    • write sorts entries and keys. SwiftLint's key order changes from run to run, so this keeps regeneration byte-stable.
    • Both refuse SwiftLint older than 0.65.1 with a brew upgrade swiftlint hint.
  • Tests: a unit test covers the version check. The end-to-end baseline test also asserts the written path format, and now runs in the repo's tmp/, because SwiftLint can't match relative paths under macOS's /private/var temp directories.
  • Drift fixed: AppEnvironment.init grew from 82 to 83 lines in Generate landing and App Store screenshots from the real app #834 while lint couldn't run. It's now 80, by collapsing one call onto one line. The baseline is regenerated: apart from a one-time key reorder, it only shortens, moves or drops entries. It drops 4 stale entries, and AppStoreScreenshotTests goes from 68 to 67.
  • The code-style skill now states the SwiftLint version requirement.

Test plan

  • bun run swift:lint passes, and a fake swiftlint reporting 0.65.0 is rejected with the upgrade hint
  • node --test scripts/swift-lint.test.mjs scripts/check-plan.test.mjs; dev:scripts:test is now fully green
  • swift:lint:baseline run twice gives byte-identical output
  • In the pre-commit hook: format:check, lint, comments:check, ratchet:check, boundaries, typecheck, swift:format:check, swift:lint. Run by hand: typecheck:configs, release:scripts:test, the CodevisorCore build, swift:build:ios
  • test:coverage hit 5-second test timeouts in @codevisor/processes and @codevisor/worktrees at load average ~300–360. Neither package is touched here, and processes passes 36/36 when run alone. Committed with --no-verify for that reason.

🤖 Generated with Claude Code

SwiftLint before 0.65.1 wrote baseline locations as absolute file:// URLs
(realm/SwiftLint#6812), so swift-lint-baseline.mjs converted them to
repo-relative paths on write and back to file:// URLs before every lint.
0.65.1 writes and matches plain paths relative to the working directory,
so on it every expanded entry missed: swift:lint reported all 175
grandfathered violations on unchanged main, and writing the baseline threw
"Invalid URL".

scripts/swift-lint.mjs replaces swift-lint.sh and swift-lint-baseline.mjs.
lint passes .swiftlint-baseline.json to SwiftLint as committed; write sorts
the entries and their keys (SwiftLint's key order changes between runs) so
regenerating is byte-stable. Both refuse SwiftLint older than 0.65.1 with
an upgrade hint. The end-to-end tests now run in the repo's tmp/: SwiftLint
can't match relative baseline paths under macOS's /private/var temp dirs.

While lint couldn't run, main drifted: AppEnvironment.init grew to 83
lines, so it is shortened to 80, and the baseline is regenerated. Besides
the one-time key reorder, it only shortens, moves or drops entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pondorasti
pondorasti merged commit b6b1fc1 into main Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant