-
Notifications
You must be signed in to change notification settings - Fork 634
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
style(macos): cleanup trailing spaces #2129
Conversation
So, adding indentation to blank lines is the default style XCode applies when formatting ( |
Some cursory searching doesn't turn anything up, so perhaps a note should just be made in the README explaining how to enable automatic trimming of trailing whitespace from blank lines. |
Thanks, yeah I'll set that up in the README. I wish we could automate this better but most of these files are edited in Xcode as was pointed out so getting consistency is harder compared to say... Vim where I edit the rest. |
@mitchellh Sure honestly I have no swift experience, I was just browsing through and vscode was doing its thing so I figured I might as well commit it 🤷♂️ |
We could supply a git pre-commit hook that would check files for trailing whitespace before allowing a commit. Would take some evangelizing to get everyone to add the hook client-side and everyone would need to remember to add the hooks every time that they do a fresh checkout. A CI action to check for trailing whitespace could be added too. |
A comprehensive approach could involve something like https://github.com/nicklockwood/SwiftFormat, but that might be more maintenance and onboarding overhead than we want to take on. |
I really dislike pre-commit hooks. I think something like SwiftFormat makes the most sense but I haven't looked at it closely. |
Nix has it packaged, but it only runs on Darwin so it would be difficult for non-macOS users to run. I was curious as to how much it would change but no luck. We do enforce some fairly opinionated code formatters on other languages... |
From the readme SwitFormat can be configured is the xcode build phase. https://github.com/nicklockwood/SwiftFormat?tab=readme-ov-file#xcode-build-phase
@jcollie Since Xcode only runs on macOS this might not be an issue? |
That would be fine, but it should probably be in a CI step too just in case someone edits the Swift code outside of Xcode. |
Timely! Xcode 16 introduces support for EditorConfig (on by default): https://www.polpiella.dev/xcode-editor-config/ ... and I added an initial |
#2142 adds an |
No description provided.