Swiftformat: SwiftLint's number_separator rule conflict

Created on 10 Jun 2020  路  3Comments  路  Source: nicklockwood/SwiftFormat

Hello,

I'm unsure if this is a bug, but I can't seem to get swift format to adhere to SwiftLint's number_seperator rule.

SwiftFormat constantly removes the underscore e.g. 1_234 --> 1234

I'm on version 0.44.13

I tried configuring the numberFormatting settings to no avail.

These are my SwiftFormat settings

# format options

--allman false
--binarygrouping 4,8
--commas always
--comments indent
--decimalgrouping 3,6
--elseposition same-line
--empty void
--exponentcase lowercase
--exponentgrouping disabled
--fractiongrouping disabled
--header ignore
--hexgrouping 4,8
--hexliteralcase uppercase
--ifdef indent
--indent 4
--indentcase false
--importgrouping testable-bottom
--linebreaks lf
--maxwidth none
--octalgrouping 4,8
--operatorfunc spaced
--patternlet hoist
--ranges spaced
--self remove
--semicolons inline
--stripunusedargs always
--swiftversion 5.2
--trimwhitespace always
--wraparguments preserve
--wrapcollections preserve
--specifierorder override,public

# rules

--enable isEmpty
enhancement fixed in develop

All 3 comments

@shawnkoh the decimal grouping values are the grouping size (3) and the minimum length a number needs to be before adding grouping (6), so if you want it to apply to a number with only 4 digits you'll need to change it to

--decimalgrouping 3,4

@shawnkoh the decimal grouping values are the grouping size (3) and the minimum length a number needs to be before adding grouping (6), so if you want it to apply to a number with only 4 digits you'll need to change it to

--decimalgrouping 3,4

THANK YOU! This was driving us insane! It would be awesome if Rules.md mentioned what the parameters represented

@shawnkoh I've improved the documentation - hopefully it's a little clearer now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

meherkasam picture meherkasam  路  3Comments

PompeiaPaetenari picture PompeiaPaetenari  路  4Comments

meherkasam picture meherkasam  路  3Comments

igorkulman picture igorkulman  路  3Comments

sebastianfrelle picture sebastianfrelle  路  4Comments