-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rules to discourage #file and #filePath #231
Conversation
@jqsilver, could you also add a lint rule for this to https://github.com/airbnb/swift/blob/master/Sources/AirbnbSwiftFormatTool/swiftlint.yml? |
Co-authored-by: Cal Stephens <cal@calstephens.tech>
Co-authored-by: Cal Stephens <cal@calstephens.tech>
Co-authored-by: Cal Stephens <cal@calstephens.tech>
@calda I added a lint rule for |
We can follow how the |
Summary
Add lint rules to discourage the use of
#file
and#filePath
literals (macros in 5.9).In addition, my editor removed some trailing whitespace - let me know if I should revert that.
Reasoning
#file
's behavior is changing in future Swift versions (https://developer.apple.com/documentation/swift/file), from the problematic behavior of#filePath
to the more ideal behavior of#fileID
. We should just use the literal/macro with explicit and unchanging behavior.#filePath
says "Because #fileID doesn’t embed the full path to the source file, unlike #filePath, it gives you better privacy and reduces the size of the compiled binary. Avoid using #filePath outside of tests, build scripts, or other code that doesn’t become part of the shipping program." https://developer.apple.com/documentation/swift/filepath, so we should reflect this guidance in our lint rules.Please react with 👍/👎 if you agree or disagree with this proposal.