diff --git a/.swift-format b/.swift-format index 9c12fd6..693d879 100644 --- a/.swift-format +++ b/.swift-format @@ -1,41 +1,62 @@ { - "indentation" : { - "spaces" : 4 + "indentConditionalCompilationBlocks": false, + "indentation": { + "spaces": 4 }, - "lineLength" : 120, - "rules" : { - "AllPublicDeclarationsHaveDocumentation" : false, - "AlwaysUseLowerCamelCase" : true, - "AmbiguousTrailingClosureOverload" : true, - "BeginDocumentationCommentWithOneLineSummary" : false, - "DoNotUseSemicolons" : true, - "DontRepeatTypeInStaticProperties" : true, - "FileScopedDeclarationPrivacy" : true, - "FullyIndirectEnum" : true, - "GroupNumericLiterals" : true, - "IdentifiersMustBeASCII" : true, - "NeverForceUnwrap" : false, - "NeverUseForceTry" : false, - "NeverUseImplicitlyUnwrappedOptionals" : false, - "NoAccessLevelOnExtensionDeclaration" : false, - "NoBlockComments" : true, - "NoCasesWithOnlyFallthrough" : true, - "NoEmptyTrailingClosureParentheses" : true, - "NoLabelsInCasePatterns" : true, - "NoLeadingUnderscores" : false, - "NoParensAroundConditions" : true, - "NoVoidReturnOnFunctionSignature" : true, - "OneCasePerLine" : true, - "OneVariableDeclarationPerLine" : true, - "OnlyOneTrailingClosureArgument" : true, - "OrderedImports" : true, - "ReturnVoidInsteadOfEmptyTuple" : true, - "UseLetInEveryBoundCaseVariable" : true, - "UseShorthandTypeNames" : true, - "UseSingleLinePropertyGetter" : true, - "UseSynthesizedInitializer" : true, - "UseTripleSlashForDocumentationComments" : true, - "ValidateDocumentationComments" : false + "lineBreakAroundMultilineExpressionChainComponents": true, + "lineBreakBeforeControlFlowKeywords": false, + "lineBreakBeforeEachArgument": true, + "lineBreakBeforeEachGenericRequirement": true, + "lineBreakBetweenDeclarationAttributes": true, + "lineLength": 120, + "maximumBlankLines": 1, + "multiElementCollectionTrailingCommas": true, + "prioritizeKeepingFunctionOutputTogether": true, + "respectsExistingLineBreaks": true, + "rules": { + "AllPublicDeclarationsHaveDocumentation": true, + "AlwaysUseLiteralForEmptyCollectionInit": true, + "AlwaysUseLowerCamelCase": true, + "AmbiguousTrailingClosureOverload": true, + "BeginDocumentationCommentWithOneLineSummary": true, + "DoNotUseSemicolons": true, + "DontRepeatTypeInStaticProperties": true, + "FileScopedDeclarationPrivacy": true, + "FullyIndirectEnum": true, + "GroupNumericLiterals": true, + "IdentifiersMustBeASCII": true, + "NeverForceUnwrap": true, + "NeverUseForceTry": true, + "NeverUseImplicitlyUnwrappedOptionals": true, + "NoAccessLevelOnExtensionDeclaration": true, + "NoAssignmentInExpressions": true, + "NoBlockComments": true, + "NoCasesWithOnlyFallthrough": true, + "NoEmptyTrailingClosureParentheses": true, + "NoLabelsInCasePatterns": true, + "NoLeadingUnderscores": true, + "NoParensAroundConditions": true, + "NoPlaygroundLiterals": true, + "NoVoidReturnOnFunctionSignature": true, + "OmitExplicitReturns": true, + "OneCasePerLine": true, + "OneVariableDeclarationPerLine": true, + "OnlyOneTrailingClosureArgument": true, + "OrderedImports": true, + "ReplaceForEachWithForLoop": true, + "ReturnVoidInsteadOfEmptyTuple": true, + "TypeNamesShouldBeCapitalized": true, + "UseEarlyExits": true, + "UseLetInEveryBoundCaseVariable": true, + "UseShorthandTypeNames": true, + "UseSingleLinePropertyGetter": true, + "UseSynthesizedInitializer": true, + "UseTripleSlashForDocumentationComments": true, + "UseWhereClausesInForLoops": true, + "ValidateDocumentationComments": true }, - "version" : 1 + "spacesAroundRangeFormationOperators": false, + "spacesBeforeEndOfLineComments": 1, + "TrailingComma": false, + "version": 1 } diff --git a/.swiftformat b/.swiftformat index 9e09924..90ad275 100644 --- a/.swiftformat +++ b/.swiftformat @@ -5,22 +5,33 @@ # https://github.com/nicklockwood/SwiftFormat#config-file # ---exclude docs/ - # Disabled rules ---disable blankLinesAroundMark ---disable consecutiveSpaces --disable hoistAwait --disable hoistPatternLet --disable hoistTry + +# Enable later --disable indent --disable trailingCommas # Enabled rules (disabled by default) ---enable trailingClosures +#--enable acronyms +#--enable blankLinesBetweenImports +--enable blockComments +--enable docComments +--enable isEmpty +--enable noExplicitOwnership +#--enable organizeDeclarations +--enable redundantProperty +--enable sortSwitchCases +--enable wrapConditionalBodies +--enable wrapEnumCases +--enable wrapMultilineConditionalAssignment +--enable wrapSwitchCases # Rule options --commas always --extensionacl on-declarations --importgrouping testable-last +--lineaftermarks false --ranges no-space diff --git a/.swiftlint.yml b/.swiftlint.yml index 1c9c9e3..4897eef 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -5,11 +5,131 @@ # https://github.com/realm/SwiftLint#configuration # --- +opt_in_rules: +- accessibility_label_for_image +- accessibility_trait_for_button +- anonymous_argument_in_multiline_closure +- array_init +- attributes +- closure_end_indentation +- closure_spacing +- collection_alignment +- comma_inheritance +- conditional_returns_on_newline +- contains_over_filter_count +- contains_over_filter_is_empty +- contains_over_first_not_nil +- contains_over_range_nil_comparison +- convenience_type +- direct_return +- discarded_notification_center_observer +- discouraged_assert +- discouraged_none_name +- discouraged_object_literal +- discouraged_optional_boolean +- discouraged_optional_collection +- empty_collection_literal +- empty_count +- empty_string +- empty_xctest_method +- enum_case_associated_values_count +- expiring_todo +- explicit_init +- extension_access_modifier +- fallthrough +- fatal_error_message +- file_name_no_space +- file_types_order +- first_where +- flatmap_over_map_reduce +- function_default_parameter_at_end +- ibinspectable_in_extension +- identical_operands +- implicit_return +- implicitly_unwrapped_optional +- indentation_width +- joined_default_parameter +- last_where +- legacy_multiple +- let_var_whitespace +- literal_expression_end_indentation +- local_doc_comment +- lower_acl_than_parent +- missing_docs +- modifier_order +- multiline_arguments +- multiline_arguments_brackets +- multiline_function_chains +- multiline_literal_brackets +- multiline_parameters +- multiline_parameters_brackets +- nimble_operator +- no_empty_block +- no_extension_access_modifier +- no_magic_numbers +- non_overridable_class_declaration +- nslocalizedstring_key +- nslocalizedstring_require_bundle +- object_literal +- operator_usage_whitespace +- optional_enum_case_matching +- overridden_super_call +- override_in_extension +- pattern_matching_keywords +- period_spacing +- prefer_key_path +- prefer_self_in_static_references +- prefer_self_type_over_type_of_self +- prefer_zero_over_explicit_init +- private_action +- private_outlet +- private_subject +- private_swiftui_state +- prohibited_interface_builder +- prohibited_super_call +- quick_discouraged_focused_test +- raw_value_for_camel_cased_codable_enum +- reduce_into +- redundant_nil_coalescing +- redundant_self_in_closure +- redundant_type_annotation +- required_enum_case +- return_value_from_void_function +- self_binding +- shorthand_argument +- shorthand_optional_binding +- single_test_class +- sorted_first_last +- sorted_imports +- static_operator +- strict_fileprivate +- strong_iboutlet +- superfluous_else +- switch_case_on_newline +- test_case_accessibility +- toggle_bool +- trailing_closure +- type_contents_order +- unavailable_function +- unhandled_throwing_task +- unneeded_parentheses_in_closure_argument +- unowned_variable_capture +- untyped_error_in_catch +- unused_parameter +- vertical_parameter_alignment_on_call +- vertical_whitespace_closing_braces +- vertical_whitespace_opening_braces +- weak_delegate +- xct_specific_matcher +- yoda_condition disabled_rules: -- non_optional_string_data_conversion +- function_body_length - trailing_comma -excluded: -- docs -opening_brace: - ignore_multiline_function_signatures: true - ignore_multiline_statement_conditions: true +file_types_order: + order: [ + [main_type], + [supporting_type], + [extension], + [preview_provider], + [library_content_provider] + ] diff --git a/Sources/mas/AppStore/ISStoreAccount.swift b/Sources/mas/AppStore/ISStoreAccount.swift index f0d27ec..ecb3313 100644 --- a/Sources/mas/AppStore/ISStoreAccount.swift +++ b/Sources/mas/AppStore/ISStoreAccount.swift @@ -33,10 +33,12 @@ extension ISStoreAccount: StoreAccount { } static func signIn(username: String, password: String, systemDialog: Bool) -> Promise { + // swift-format-ignore: UseEarlyExits if #available(macOS 10.13, *) { // Signing in is no longer possible as of High Sierra. // https://github.com/mas-cli/mas/issues/164 return Promise(error: MASError.notSupported) + // swiftlint:disable:next superfluous_else } else { return primaryAccount diff --git a/Tests/masTests/.swift-format b/Tests/masTests/.swift-format new file mode 100644 index 0000000..571f02f --- /dev/null +++ b/Tests/masTests/.swift-format @@ -0,0 +1,62 @@ +{ + "indentConditionalCompilationBlocks": false, + "indentation": { + "spaces": 4 + }, + "lineBreakAroundMultilineExpressionChainComponents": true, + "lineBreakBeforeControlFlowKeywords": false, + "lineBreakBeforeEachArgument": true, + "lineBreakBeforeEachGenericRequirement": true, + "lineBreakBetweenDeclarationAttributes": true, + "lineLength": 120, + "maximumBlankLines": 1, + "multiElementCollectionTrailingCommas": true, + "prioritizeKeepingFunctionOutputTogether": true, + "respectsExistingLineBreaks": true, + "rules": { + "AllPublicDeclarationsHaveDocumentation": false, + "AlwaysUseLiteralForEmptyCollectionInit": true, + "AlwaysUseLowerCamelCase": true, + "AmbiguousTrailingClosureOverload": true, + "BeginDocumentationCommentWithOneLineSummary": true, + "DoNotUseSemicolons": true, + "DontRepeatTypeInStaticProperties": true, + "FileScopedDeclarationPrivacy": true, + "FullyIndirectEnum": true, + "GroupNumericLiterals": true, + "IdentifiersMustBeASCII": true, + "NeverForceUnwrap": false, + "NeverUseForceTry": false, + "NeverUseImplicitlyUnwrappedOptionals": true, + "NoAccessLevelOnExtensionDeclaration": true, + "NoAssignmentInExpressions": true, + "NoBlockComments": true, + "NoCasesWithOnlyFallthrough": true, + "NoEmptyTrailingClosureParentheses": true, + "NoLabelsInCasePatterns": true, + "NoLeadingUnderscores": true, + "NoParensAroundConditions": true, + "NoPlaygroundLiterals": true, + "NoVoidReturnOnFunctionSignature": true, + "OmitExplicitReturns": true, + "OneCasePerLine": true, + "OneVariableDeclarationPerLine": true, + "OnlyOneTrailingClosureArgument": true, + "OrderedImports": true, + "ReplaceForEachWithForLoop": true, + "ReturnVoidInsteadOfEmptyTuple": true, + "TypeNamesShouldBeCapitalized": true, + "UseEarlyExits": true, + "UseLetInEveryBoundCaseVariable": true, + "UseShorthandTypeNames": true, + "UseSingleLinePropertyGetter": true, + "UseSynthesizedInitializer": true, + "UseTripleSlashForDocumentationComments": true, + "UseWhereClausesInForLoops": true, + "ValidateDocumentationComments": true + }, + "spacesAroundRangeFormationOperators": false, + "spacesBeforeEndOfLineComments": 1, + "TrailingComma": false, + "version": 1 +} diff --git a/Tests/masTests/.swiftlint.yml b/Tests/masTests/.swiftlint.yml index d234b91..409fabb 100644 --- a/Tests/masTests/.swiftlint.yml +++ b/Tests/masTests/.swiftlint.yml @@ -9,3 +9,5 @@ disabled_rules: - force_cast - force_try - function_body_length +- implicitly_unwrapped_optional +- no_magic_numbers