Rule Request: [container_types] Need new rule to require idiomatic container rules
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- [√] Updated SwiftLint to the latest version
- [√] I searched for existing GitHub issues
Rule Request
The "idiomatically-correct" types of containers are ContainerType<ElementType[, ElementType...]>. While the Swift documentation states that the syntactic sugar versions are preferred, there are points in the code where the sugar versions do not work because the idiomatically-correct type is required (Array<Int>.Index is valid, [Int].Index is an error).
The existing rule for syntactic_sugar rule disallows these or simply doesn't check (on/off). There needs to be a new rule (that deprecates syntactic_sugar) that allows checking for idiomatically-correct, syntactic sugar, or off.
container_types **on**- type definitions ofArray<Int>orDictionary<String, Any>would pass,[Int]and[String: Any]would fail.container_types **sugar**- type definitions of[Int]or[String: Any]would pass,Array<Int>andDictionary<String, Any>would fail.container_types **off**- type definitions of[Int], '[String: Any],Array, orDictionary<String, Any>` would pass.
Default would be container_types sugar to match existing syntactic_sugar default of on. This would also require syntactic_sugar to be deprecated or mapped into this new rule as a synonym to 'sugar' or 'off'.
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
The issue does not name files or tests. Start by locating the existing syntactic_sugar rule and its configuration handling, then review how SwiftLint rules are tested. Done means container_types supports on, sugar, and off modes, with the requested default and syntactic_sugar compatibility behavior.
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
- 35/100