Skip to content

Commit

Permalink
Merge 6a391e4 into 2f1d164
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Mar 26, 2020
2 parents 2f1d164 + 6a391e4 commit 4767473
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Rules.swift
Expand Up @@ -2014,7 +2014,7 @@ public struct _FormatRules {
}), let quoteIndex = formatter.index(of: .nonSpaceOrLinebreak, after: equalsIndex, if: {
$0 == .startOfScope("\"")
}), formatter.token(at: quoteIndex + 2) == .endOfScope("\"") {
if formatter.tokens[nameIndex].string == formatter.token(at: quoteIndex + 1)?.string {
if formatter.tokens[nameIndex].unescaped() == formatter.token(at: quoteIndex + 1)?.string {
formatter.removeTokens(inRange: nameIndex + 1 ... quoteIndex + 2)
index = nameIndex
} else {
Expand Down
6 changes: 6 additions & 0 deletions Tests/RulesTests.swift
Expand Up @@ -5168,6 +5168,12 @@ class RulesTests: XCTestCase {
testFormatting(for: input, output, rule: FormatRules.redundantRawValues)
}

func testRemoveBacktickCaseRawStringCases() {
let input = "enum Foo: String { case `as` = \"as\", `let` = \"let\" }"
let output = "enum Foo: String { case `as`, `let` }"
testFormatting(for: input, output, rule: FormatRules.redundantRawValues)
}

func testNoRemoveRawStringIfNameDoesntMatch() {
let input = "enum Foo: String {\n case bar = \"foo\"\n}"
testFormatting(for: input, rule: FormatRules.redundantRawValues)
Expand Down

0 comments on commit 4767473

Please sign in to comment.