Formatting and Linting
To maintain a consistent code style across the Untold Engine repo, we use SwiftFormat. SwiftFormat is a code formatter for Swift that helps enforce Swift style conventions and keep the codebase clean. If you don't have SwiftFormat installed, see the Installing SwiftFormat section below.
Quick Formatting & Linting
Navigate to the root directory of Untold Engine and then run the commands below:
🔍 Lint files
To lint (check) all Swift files without making changes:
Or, using the Makefile:
This command runs the same lint configuration as our GitHub Actions workflow and pre-commit hook, ensuring consistent results locally and in CI.
✅ Formatting Files
To format files:
Alternatively, you can use the Makefile shortcut:
💡 Tip If the pre-commit hook blocks your commit due to formatting issues, simply run:
then re-stage your changes and try committing again.
You can bypass the hook temporarily (not recommended) with:
Installing SwiftFormat
The simplest way to install SwiftFormat is through the command line.
- Install SwiftFormat Using Homebrew: Open the terminal and run the following command:
Using SwiftFormat
Format a Single File
To format a specific Swift file:
-
Open the terminal and navigate to your project directory.
-
Run the following command:
Format Multiple Files
To format all Swift files in your project:
-
Navigate to your project directory in the terminal.
-
Run the following command:
This will recursively format all Swift files in the current directory and its subdirectories.