Skip to content

Commit acf853a

Browse files
committed
chore: apply linting with updated configs
Run swift-format and swiftlint with updated configuration files. Changes: - Updated .swift-format config - Updated .swiftlint.yml config - Applied formatting to test files All linting now passes cleanly: - SwiftLint: ✅ 0 issues - Swift-format: ✅ 0 warnings
1 parent 6f7820e commit acf853a

File tree

4 files changed

+57
-96
lines changed

4 files changed

+57
-96
lines changed

.spi.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets:
5+
- HTML Standard

.swift-format

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"version": 1,
3-
"lineLength": 120,
3+
"lineLength": 100,
44
"indentation": {
55
"spaces": 4
66
},
7-
"tabWidth": 8,
87
"maximumBlankLines": 1,
98
"respectsExistingLineBreaks": true,
109
"lineBreakBeforeControlFlowKeywords": false,
11-
"lineBreakBeforeEachArgument": false,
12-
"lineBreakBeforeEachGenericRequirement": false,
10+
"lineBreakBeforeEachArgument": true,
11+
"lineBreakBeforeEachGenericRequirement": true,
1312
"prioritizeKeepingFunctionOutputTogether": true,
1413
"indentConditionalCompilationBlocks": true,
15-
"lineBreakAroundMultilineExpressionChainComponents": false,
14+
"indentSwitchCaseLabels": false,
15+
"spacesAroundRangeFormationOperators": false,
1616
"fileScopedDeclarationPrivacy": {
1717
"accessLevel": "private"
1818
},
1919
"rules": {
2020
"AllPublicDeclarationsHaveDocumentation": false,
21-
"AlwaysUseLowerCamelCase": true,
22-
"AmbiguousTrailingClosureOverload": false,
21+
"AlwaysUseLowerCamelCase": false,
22+
"AmbiguousTrailingClosureOverload": true,
2323
"BeginDocumentationCommentWithOneLineSummary": false,
2424
"DoNotUseSemicolons": true,
2525
"DontRepeatTypeInStaticProperties": true,
@@ -31,7 +31,7 @@
3131
"NeverUseForceTry": false,
3232
"NeverUseImplicitlyUnwrappedOptionals": false,
3333
"NoAccessLevelOnExtensionDeclaration": true,
34-
"NoBlockComments": true,
34+
"NoBlockComments": false,
3535
"NoCasesWithOnlyFallthrough": true,
3636
"NoEmptyTrailingClosureParentheses": true,
3737
"NoLabelsInCasePatterns": true,
@@ -43,10 +43,11 @@
4343
"OnlyOneTrailingClosureArgument": true,
4444
"OrderedImports": true,
4545
"ReturnVoidInsteadOfEmptyTuple": true,
46+
"UseEarlyExits": false,
4647
"UseLetInEveryBoundCaseVariable": true,
4748
"UseShorthandTypeNames": true,
4849
"UseSingleLinePropertyGetter": true,
49-
"UseSynthesizedInitializer": true,
50+
"UseSynthesizedInitializer": false,
5051
"UseTripleSlashForDocumentationComments": true,
5152
"UseWhereClausesInForLoops": false,
5253
"ValidateDocumentationComments": false

.swiftlint.yml

Lines changed: 41 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,52 @@
1-
# SwiftLint Configuration for swift-standards
2-
# Shared across all packages in the workspace
3-
# Optimized for library/framework development with Swift Testing
4-
5-
# Disabled rules
61
disabled_rules:
7-
# Type inference & Swift idioms
8-
- explicit_type_interface # Type inference is idiomatic Swift
9-
- explicit_init # Prefer MyType() over MyType.init()
10-
- extension_access_modifier # Prefer access on members, not extensions
11-
- explicit_acl # Don't require `internal` everywhere
12-
13-
# Development flexibility
14-
- todo # TODOs are fine in development
15-
- force_cast # Sometimes needed in tests
16-
- force_try # Sometimes needed in tests
17-
18-
# Length restrictions (swift-format handles line length)
19-
- line_length # HTML attributes can be 300+ chars; swift-format handles this
20-
- file_length # Comprehensive test files are long
21-
22-
# Domain complexity
23-
- cyclomatic_complexity # Lookup tables and parsing logic have inherent complexity
24-
- function_parameter_count # Time/Date/RFC initializers legitimately need many parameters
25-
- large_tuple # Component tuples are acceptable for internal use
2+
- line_length
3+
- identifier_name
4+
- nesting
5+
- type_name
6+
- explicit_enum_raw_value
7+
- file_length
8+
- function_body_length
9+
- function_parameter_count # Allow 6+ parameters for DateTime and Area factory methods
10+
- type_body_length # Comprehensive test suites can be longer than 250 lines
11+
- trailing_comma # Conflicts with swift-format which prefers trailing commas
12+
- redundant_discardable_let # Preserve 'let _ =' in result builder contexts (required for Swift 6.0+)
2613

27-
# Documentation patterns
28-
- file_header # No consistent pattern across packages
29-
- missing_docs # Documentation via code comments, not strictly required
30-
31-
# Swift Testing compatibility
32-
- identifier_name # Swift Testing uses backtick names with spaces
33-
- type_name # @Suite uses descriptive names with spaces
34-
35-
# False positives for our patterns
36-
- optional_data_string_conversion # False positive on [UInt8] -> String conversion
37-
- for_where # Not always clearer than for+if
38-
- contains_over_first_not_nil # False positives on custom firstIndex implementations
39-
- sorted_imports # Handled by swift-format's OrderedImports rule
40-
- trailing_comma # Handled by swift-format (adds trailing commas for better diffs)
41-
42-
# Opt-in rules for code quality
4314
opt_in_rules:
44-
# Bug prevention
45-
- unused_optional_binding # Catch unused let bindings
46-
47-
# Code quality & cleanliness
48-
- implicit_optional_initialization # Don't initialize optionals to nil (formerly redundant_optional_initialization)
49-
- redundant_void_return # Don't write -> Void
50-
- empty_string # Use .isEmpty not == ""
51-
- vertical_whitespace # Consistent spacing
52-
53-
# Analyzer rules (require --analyze flag)
54-
analyzer_rules:
55-
- unused_import # Remove unnecessary imports
56-
57-
# Performance optimizations
58-
- empty_count # Use .isEmpty instead of .count == 0
59-
- first_where # Prefer first(where:) over filter().first
60-
- last_where # Prefer last(where:) over filter().last
61-
- contains_over_range_nil_comparison # Better performance
62-
- sorted_first_last # Prefer sorted().first/last
63-
64-
# Style consistency
65-
- closure_spacing # Consistent closure formatting
66-
- operator_usage_whitespace # Consistent operator spacing
67-
68-
# Safety
69-
- array_init # Safer array initialization
70-
- fatal_error_message # Require messages in fatalError
71-
- legacy_random # Use modern random APIs
72-
- overridden_super_call # Ensure super is called when needed
73-
74-
# Paths
15+
- empty_count
16+
- explicit_init
17+
- sorted_imports
18+
- force_cast
19+
- force_try
20+
- closure_spacing
21+
- operator_usage_whitespace
22+
- private_outlet
23+
- redundant_nil_coalescing
24+
- empty_string
25+
- literal_expression_end_indentation
26+
- single_test_class
27+
- sorted_first_last
28+
- vertical_whitespace
29+
- strict_fileprivate
30+
- legacy_random
31+
- no_extension_access_modifier
32+
- colon
33+
7534
included:
35+
- Package.swift
7636
- Sources
7737
- Tests
7838

7939
excluded:
80-
- .build
81-
- .swiftpm
40+
- Carthage
41+
- Pods
42+
- fastlane
43+
- build
8244

83-
# Rule configurations
84-
85-
# Allow longer functions for complex performance logic
86-
function_body_length:
87-
warning: 60
88-
error: 100
45+
analyzer_rules:
46+
- unused_import
8947

90-
# Allow larger types for comprehensive test suites
91-
type_body_length:
92-
warning: 400
93-
error: 600
48+
colon:
49+
apply_to_dictionaries: true
9450

95-
# Nesting depth
96-
nesting:
97-
type_level: 2
51+
vertical_whitespace:
52+
max_empty_lines: 1

Tests/HTML Standard Tests/HTMLStandardTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// HTMLStandardTests.swift
22
// HTML Standard Tests
33

4-
import Testing
54
@testable import HTML_Standard
5+
import Testing
66

77
@Suite("HTML Standard")
88
struct HTMLStandardTests {

0 commit comments

Comments
 (0)