ITADN

Extend trailing_comma rule to support function parameters and tuple elements

#6500OpenVentanYu 创建于 2026-02-19
enhancement
V
VentanYucommented
### New Issue Checklist - [x] I've Updated SwiftLint to the latest version. - [x] I've searched for [existing GitHub issues](https://github.com/realm/SwiftLint/issues). ### Feature or Enhancement Proposal Extend the trailing_comma rule to optionally enforce trailing commas in: - Function parameter lists (declarations and calls) - Tuple types and values - Closure parameter lists ### Configuration The rule should maintain backward compatibility while adding these new capabilities: ```yaml trailing_comma: mandatory_comma: true # existing option (default: false) include_function_parameters: true # new option (default: false) include_tuples: true # new option (default: false) include_closures: true # new option (default: false) ``` ### Examples Non Triggering Examples: ```swift // include_function_parameters: true func fetchUser( id: Int, from cache: Cache, ) async throws -> User // include_function_parameters: true fetchUser( id: 42, from: memoryCache, ) // include_tuples: true typealias Pair = ( String, Int, ) // include_tuples: true let person = ( name: "John", age: 30, ) // include_closures: true let handler = { ( success: Bool, error: Error?, ) in // handle } ``` Triggering Examples: ```swift // include_function_parameters: true func fetchUser( id: Int, from cache: Cache↓ ) async throws -> User // include_function_parameters: true fetchUser( id: 42, from: memoryCache↓ ) // include_tuples: true typealias Pair = ( String, Int↓ ) // include_tuples: true let person = ( name: "John", age: 30↓ ) // include_closures: true let handler = { ( success: Bool, error: Error?↓ ) in // handle } ```
0 条评论