Extend trailing_comma rule to support function parameters and tuple elements
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub 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:
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:
// 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:
// 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
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing trailing_comma rule and its configuration handling. Extend the rule to cover function parameter lists, tuple types and values, and closure parameter lists while preserving current defaults; done means the proposed options and triggering/non-triggering examples behave as specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100