Skip to content

Fix broken #file / #filePath custom SwiftLint rules - #398

Merged
calda merged 1 commit into
masterfrom
copilot/remove-filepath-rule-update-file-rule
Jul 21, 2026
Merged

Fix broken #file / #filePath custom SwiftLint rules#398
calda merged 1 commit into
masterfrom
copilot/remove-filepath-rule-update-file-rule

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

The no_file_literal and no_filepath_literal custom rules used match_kinds: identifier, but SourceKit tokenizes #file / #filePath as keyword — so neither rule ever matched anything.

  • Remove no_filepath_literal: No production/non-production distinction in this repo, so blocking #filePath isn't meaningful here
  • Fix no_file_literal: Change match_kinds to keyword, fix regex (\b before # is a no-op since # isn't a word character), update message to recommend #fileID by default or #filePath when the exact path is needed

Copilot AI changed the title Remove broken #filePath lint rule and fix #file rule in swiftlint.yml Fix broken #file / #filePath custom SwiftLint rules Jul 21, 2026
Copilot finished work on behalf of calda July 21, 2026 20:31
Copilot AI requested a review from calda July 21, 2026 20:31
no_file_literal:
name: "#file is disallowed"
regex: "(\\b#file\\b)"
regex: "(#file\\b)"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This regex previously didn't actually match anything:

Before

Image

After

Image

Comment on lines -41 to -46
no_filepath_literal:
name: "#filePath is disallowed"
regex: "(\\b#filePath\\b)"
match_kinds:
- identifier
message: "Instead of #filePath, use #fileID."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In Airbnb we only use this lint rule for production code (excluding tests), which isn't a use case supported by the package plugin

Copilot finished work on behalf of calda July 21, 2026 20:39
Copilot AI requested a review from calda July 21, 2026 20:39
@calda
calda force-pushed the copilot/remove-filepath-rule-update-file-rule branch from 8d89c57 to 2aa9006 Compare July 21, 2026 20:40
@calda
calda marked this pull request as ready for review July 21, 2026 20:41
@calda
calda merged commit 3bdaeff into master Jul 21, 2026
13 checks passed
@calda
calda deleted the copilot/remove-filepath-rule-update-file-rule branch July 21, 2026 20:42
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.

2 participants