nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.77k stars 629 forks source link

How do I use the `--funcattributes prev-line` rule in the config file? #1546

Closed everlof closed 10 months ago

everlof commented 10 months ago

I've tried looking at the code and figure out but can't find this.

This is the configuration I'm trying with:

--exclude DerivedData,vendor
--swiftversion 5.9

--rules redundantReturn,          \
        sortImports,              \
        blankLinesAroundMark,     \
        blankLinesAtEndOfScope,   \
        blankLinesAtStartOfScope, \
        blankLinesBetweenScopes,  \
        spaceAroundBraces,        \
        spaceAroundBrackets,      \
        spaceAroundComments,      \
        spaceAroundGenerics,      \
        spaceAroundOperators,     \
        spaceAroundParens,        \
        trailingCommas,           \
        trailingSpace,            \
        void,                     \
        funcattributes prev-line
nicklockwood commented 10 months ago

It's an option rather than a rule, so you literally just need to put this in the config file:

--funcattributes prev-line
everlof commented 10 months ago

Great, thank you. Definitely thought it would be something obvious :) Thank you!