Polish SwiftLint and SwiftFormat configurations

This commit is contained in:
Danny Moesch 2020-09-06 19:02:29 +02:00 committed by Mingshen Sun
parent 8459af4196
commit 2b7b378e12
2 changed files with 218 additions and 52 deletions

View file

@ -1,96 +1,257 @@
# Exclude folders # SwiftFormat Configuration
--exclude Carthage,go,Pods ## Excluded folders
# Enabled rules --exclude \
Carthage, \
go, \
Pods
--rules andOperator, anyObjectProtocol, blankLinesAroundMark, blankLinesAtEndOfScope, blankLinesAtStartOfScope, blankLinesBetweenScopes, braces, consecutiveBlankLines, consecutiveSpaces, duplicateImports, elseOnSameLine, emptyBraces, fileHeader, hoistPatternLet, indent, isEmpty, initCoderUnavailable, leadingDelimiters, linebreakAtEndOfFile, linebreaks, modifierOrder, numberFormatting, preferKeyPath, redundantBackticks, redundantBreak, redundantExtensionACL, redundantFileprivate, redundantGet, redundantInit, redundantLet, redundantLetError, redundantNilInit, redundantObjc, redundantParens, redundantPattern, redundantRawValues, redundantReturn, redundantSelf, redundantType, redundantVoidReturnType, semicolons, sortedImports, spaceAroundBraces, spaceAroundBrackets, spaceAroundComments, spaceAroundGenerics, spaceAroundOperators, spaceAroundParens, spaceInsideBraces, spaceInsideBrackets, spaceInsideComments, spaceInsideGenerics, spaceInsideParens, strongOutlets, strongifiedSelf, todos, trailingClosures, trailingCommas, trailingSpace, typeSugar, unusedArguments, void, wrap, wrapArguments, wrapAttributes, yodaConditions ## Enabled rules
# Formatting options --rules \
andOperator, \
anyObjectProtocol, \
blankLinesAroundMark, \
blankLinesAtEndOfScope, \
blankLinesAtStartOfScope, \
blankLinesBetweenScopes, \
braces, \
consecutiveBlankLines, \
consecutiveSpaces, \
duplicateImports, \
elseOnSameLine, \
emptyBraces, \
fileHeader, \
hoistPatternLet, \
indent, \
initCoderUnavailable, \
isEmpty, \
leadingDelimiters, \
linebreakAtEndOfFile, \
linebreaks, \
modifierOrder, \
numberFormatting, \
# organizeDeclarations, \
preferKeyPath, \
redundantBackticks, \
redundantBreak, \
redundantExtensionACL, \
redundantFileprivate, \
redundantGet, \
redundantInit, \
redundantLet, \
redundantLetError, \
redundantNilInit, \
redundantObjc, \
redundantParens, \
redundantPattern, \
redundantRawValues, \
redundantReturn, \
redundantSelf, \
redundantType, \
redundantVoidReturnType, \
semicolons, \
sortedImports, \
spaceAroundBraces, \
spaceAroundBrackets, \
spaceAroundComments, \
spaceAroundGenerics, \
spaceAroundOperators, \
spaceAroundParens, \
spaceInsideBraces, \
spaceInsideBrackets, \
spaceInsideComments, \
spaceInsideGenerics, \
spaceInsideParens, \
# specifiers, \
strongOutlets, \
strongifiedSelf, \
todos, \
trailingClosures, \
trailingCommas, \
trailingSpace, \
typeSugar, \
unusedArguments, \
void, \
wrap, \
wrapArguments, \
wrapAttributes, \
# wrapEnumCases, \
# wrapMultilineStatementBraces, \
# wrapSwitchCases, \
yodaConditions
## Formatting options
### Use allman indentation style: "true" or "false" (default)
## Use allman indentation style: "true" or "false" (default)
--allman false --allman false
## Binary grouping,threshold (default: 4,8) or "none", "ignore"
### Binary grouping,threshold (default: 4,8) or "none", "ignore"
--binarygrouping 4,8 --binarygrouping 4,8
## Closing paren position: "balanced" (default) or "same-line"
### Closing paren position: "balanced" (default) or "same-line"
--closingparen balanced --closingparen balanced
## Commas in collection literals: "always" (default) or "inline"
### Commas in collection literals: "always" (default) or "inline"
--commas always --commas always
## Decimal grouping,threshold (default: 3,6) or "none", "ignore"
### Decimal grouping,threshold (default: 3,6) or "none", "ignore"
--decimalgrouping 3,6 --decimalgrouping 3,6
## Placement of else/catch: "same-line" (default) or "next-line"
### Placement of else/catch: "same-line" (default) or "next-line"
--elseposition same-line --elseposition same-line
## Case of 'e' in numbers: "lowercase" or "uppercase" (default)
### Case of 'e' in numbers: "lowercase" or "uppercase" (default)
--exponentcase lowercase --exponentcase lowercase
## Group exponent digits: "enabled" or "disabled" (default)
### Group exponent digits: "enabled" or "disabled" (default)
--exponentgrouping disabled --exponentgrouping disabled
## Group digits after '.': "enabled" or "disabled" (default)
### Group digits after '.': "enabled" or "disabled" (default)
--fractiongrouping disabled --fractiongrouping disabled
## Function @attributes: "preserve", "prev-line", or "same-line"
### Function @attributes: "preserve", "prev-line", or "same-line"
--funcattributes prev-line --funcattributes prev-line
## Guard else: "same-line", "next-line" or "auto" (default)
### Guard else: "same-line", "next-line" or "auto" (default)
--guardelse auto --guardelse auto
## Header comments: "strip", "ignore", or the text you wish use
### Header comments: "strip", "ignore", or the text you wish use
--header ignore --header ignore
## Hex grouping,threshold (default: 4,8) or "none", "ignore"
### Hex grouping,threshold (default: 4,8) or "none", "ignore"
--hexgrouping 4,8 --hexgrouping 4,8
## Casing for hex literals: "uppercase" (default) or "lowercase"
### Casing for hex literals: "uppercase" (default) or "lowercase"
--hexliteralcase uppercase --hexliteralcase uppercase
## #if indenting: "indent" (default), "no-indent" or "outdent"
### #if indenting: "indent" (default), "no-indent" or "outdent"
--ifdef indent --ifdef indent
## "testable-top", "testable-bottom" or "alphabetized" (default)
### "testable-top", "testable-bottom" or "alphabetized" (default)
--importgrouping testable-bottom --importgrouping testable-bottom
## Number of spaces to indent, or "tab" to use tabs
### Number of spaces to indent, or "tab" to use tabs
--indent 4 --indent 4
## Indent cases inside a switch: "true" or "false" (default)
### Indent cases inside a switch: "true" or "false" (default)
--indentcase false --indentcase false
## Linebreak character to use: "cr", "crlf" or "lf" (default)
### Linebreak character to use: "cr", "crlf" or "lf" (default)
--linebreaks lf --linebreaks lf
## Maximum length of a line before wrapping. defaults to "none"
### Maximum length of a line before wrapping. defaults to "none"
--maxwidth none --maxwidth none
## Comma-delimited list of modifiers in preferred order
### Comma-delimited list of modifiers in preferred order
--modifierorder --modifierorder
## Comma-delimited list of operators without surrounding space
### Comma-delimited list of operators without surrounding space
--nospaceoperators --nospaceoperators
## Comma-delimited list of operators that shouldn't be wrapped
### Comma-delimited list of operators that shouldn't be wrapped
--nowrapoperators --nowrapoperators
## Octal grouping,threshold (default: 4,8) or "none", "ignore"
### Octal grouping,threshold (default: 4,8) or "none", "ignore"
--octalgrouping 4,8 --octalgrouping 4,8
## Spacing for operator funcs: "spaced" (default) or "no-space"
### Spacing for operator funcs: "spaced" (default) or "no-space"
--operatorfunc spaced --operatorfunc spaced
## let/var placement in patterns: "hoist" (default) or "inline"
### let/var placement in patterns: "hoist" (default) or "inline"
--patternlet hoist --patternlet hoist
## Explicit self: "insert", "remove" (default) or "init-only"
### Explicit self: "insert", "remove" (default) or "init-only"
--self init-only --self init-only
## Comma-delimited list of functions with @autoclosure arguments
### Comma-delimited list of functions with @autoclosure arguments
--selfrequired --selfrequired
## Allow semicolons: "never" or "inline" (default)
### Allow semicolons: "never" or "inline" (default)
--semicolons inline --semicolons inline
## Use ? for Optionals "always" (default) or "except-properties"
### Use ? for Optionals "always" (default) or "except-properties"
--shortoptionals always --shortoptionals always
## Align code independently of tab width. defaults to "enabled"
### Align code independently of tab width. defaults to "enabled"
--smarttabs enabled --smarttabs enabled
## "closure-only", "unnamed-only" or "always" (default)
### "closure-only", "unnamed-only" or "always" (default)
--stripunusedargs always --stripunusedargs always
## The width of a tab character. Defaults to "unspecified"
### The width of a tab character. Defaults to "unspecified"
--tabwidth 4 --tabwidth 4
## Comma-delimited list of functions that use trailing closures
### Comma-delimited list of functions that use trailing closures
--trailingclosures --trailingclosures
## Trim trailing space: "always" (default) or "nonblank-lines"
### Trim trailing space: "always" (default) or "nonblank-lines"
--trimwhitespace always --trimwhitespace always
## Type @attributes: "preserve", "prev-line", or "same-line"
### Type @attributes: "preserve", "prev-line", or "same-line"
--typeattributes preserve --typeattributes preserve
## Property @attributes: "preserve", "prev-line", or "same-line"
### Property @attributes: "preserve", "prev-line", or "same-line"
--varattributes same-line --varattributes same-line
## How Void types are represented: "void" (default) or "tuple"
### How Void types are represented: "void" (default) or "tuple"
--voidtype void --voidtype void
## Wrap all arguments: "before-first", "after-first", "preserve"
### Wrap all arguments: "before-first", "after-first", "preserve"
--wraparguments preserve --wraparguments preserve
## Wrap array/dict: "before-first", "after-first", "preserve"
### Wrap array/dict: "before-first", "after-first", "preserve"
--wrapcollections preserve --wrapcollections preserve
## Wrap func params: "before-first", "after-first", "preserve"
### Wrap func params: "before-first", "after-first", "preserve"
--wrapparameters preserve --wrapparameters preserve
## Xcode indent guard/enum: "enabled" or "disabled" (default)
### Xcode indent guard/enum: "enabled" or "disabled" (default)
--xcodeindentation disabled --xcodeindentation disabled
## Swap yoda values: "always" (default) or "literals-only"
### Swap yoda values: "always" (default) or "literals-only"
--yodaswap always --yodaswap always

View file

@ -1,10 +1,14 @@
# Folders to exclude from linting # SwiftLint Configuration
## Folders to exclude from linting
excluded: excluded:
- Carthage - Carthage
- go - go
- Pods - Pods
# Active rules ## Active rules
whitelist_rules: whitelist_rules:
- anyobject_protocol - anyobject_protocol
- array_init - array_init
@ -201,7 +205,8 @@ whitelist_rules:
- xctfail_message - xctfail_message
- yoda_condition - yoda_condition
# Configuration for specific rules ## Configuration for specific rules
closure_body_length: closure_body_length:
warning: 40 warning: 40
error: 60 error: 60