-
Notifications
You must be signed in to change notification settings - Fork 0
Linting, Formatting, and Auto Correction
Gavin Huang edited this page Mar 30, 2023
·
4 revisions
In addition to the default linting rules, Playbook Swift enforces a indentation width of 2 spaces.
-
SwiftLint, within the
.swiftlint.yml
file, enforces theindentation_width: 2
rule- View all enforced rules via
swiftlint rules
in your Terminal
- View all enforced rules via
-
SwiftFormat, within the
.swiftformat
file, only allows theindent
rule and sets it to--indent 2
- To run SwiftFormat manually, use the plugin:
- Right click
PlaybookSwift
in the Project Navigator - Click SwiftFormatPlugin
- Click Run
- Right click
- To run SwiftFormat manually, use the plugin:
These rules will also be enforced before you commit via pre-commit.
-
After installing pre-commit via
brew install pre-commit && pre-commit install
, the first time you try to commit, it will take some time to install the hooks: -
pre-commit will check for several rules and auto-corrects any violations. You will have to commit again if it finds an error. In the example below, one file did not have proper indentation which SwiftFormat detected and corrected: