Rule Request: `allowed_prefix_symbols` configuration in `identifier_name`
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
New rule request
When validates_start_with_lowercase is true, all identifier names must start with a lowercase character.
This will trigger a violation even if the name starts with a symbol, for example and underscore _.
The only way to achieve this now is to disable validates_start_with_lowercase, but it would be nice to have to option to allow certain prefix symbols, eg:
identifier_name:
allowed_prefix_symbols: ["_"]
validates_start_with_lowercase: true
The above would trigger a violation for:
var MyVar: String
...but would not trigger a violation for:
private var _myVar: String
While naming properties this way shouldn't be the norm, sometimes it can serve as raw value storage for a computed property of the same name. For example:
private var _myVar: Int?
@objc
public var myVar: Int {
get {
_myVar ?? -1
}
set {
_myVar = newValue < 0 ? nil : newValue
}
}
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 by locating SwiftLint’s identifier_name rule and its configuration handling, then trace how validates_start_with_lowercase checks the first character. Add coverage for allowed_prefix_symbols using the shown _myVar and MyVar cases, and confirm the option’s behavior in the rule’s existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100