Linting, Formatting, and Auto Correction - powerhome/playbook-swift GitHub Wiki
In addition to the default linting rules, Playbook Swift enforces a indentation width of 2 spaces.
-
SwiftLint, within the
.swiftlint.ymlfile, enforces theindentation_width: 2rule- View all enforced rules via
swiftlint rulesin your Terminal
- View all enforced rules via
-
SwiftFormat, within the
.swiftformatfile, only allows theindentrule and sets it to--indent 2- To run SwiftFormat manually, use the plugin:
- Right click
PlaybookSwiftin 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:
