Closed
Description
Right now, if one made a typo in a rule name in .swift-format
and then ran the formatter, it will ignore the typo and, obviously, not apply the rule.
I was working on swiftlang/swift-syntax#2145, and of course, that's precisely what I did. Oh, nice, our imports are already ordered, right?
Proposed solution
Since we know the list of all available rules, we could verify that each string in the Rules block matches an existing rule.
// Config.swift
//
// If the `rules` key is not present at all, default it to the built-in set
// so that the behavior is the same as if the configuration had been
// default-initialized. To get an empty rules dictionary, one can explicitly
// set the `rules` key to `{}`.
self.rules =
try container.decodeIfPresent([String: Bool].self, forKey: .rules)
?? defaults.rules
It should be relatively easy, we could just generate an enum
with all rule names, and use that as the key when decoding the rules.
Should I draft this in a PR?
Metadata
Metadata
Assignees
Labels
No labels