SwiftLint
SwiftLint copied to clipboard
`number_separator`: allow ignoring certain types of numbers
New Issue Checklist
- [x] I've Updated SwiftLint to the latest version.
- [x] I've searched for existing GitHub issues.
Feature or Enhancement Proposal
number_separator should be able to be configured to ignore/exclude certain types / typealiases of numbers like:
number_separator:
ignore: [pid_t]
So any literal used for a pid_t is ignored by this rule.
In which regard would this be helpful? Why would numbers used for pid_ts not benefit from separators?
There are some typealiases that I'd prefer to see without underscores. Mainly if they're IDs instead of counts. It's just a personal preference. Not the most necessary option, but figured I'd document it here in case others would like it, too.
Note, that this only works well for declarations with initializations such as let id: ID = 1234 or let id = ID(123). Otherwise there's no way to know the type of a literal to be ignored.
A cast or the type of a function parameter can also indicate the type of the literal.
Cast yes, function parameters only for default values. At the call side, there is no way to know the type of the argument, at least not for fast lint rules like number_separator.