Prettier.io wrapper for swift. An opinionated code formatter.
To run the example project, clone the repo, and run pod install
from the Example directory first.
Prettier.swift is available via SPM or Cocoapods.
pod 'Prettier.swift'
import Prettier_swift
let prettier = Prettier()
let input = "{\"id\":1,\"name\":\"Michael Henry\"}"
let output = prettier.prettify(input, parser: .jsonStringify)!
let expected_output =
"""
{
"id": 1,
"name": "Michael Henry"
}
"""
XCTAssertEqual(output, expected_output)
import Prettier_swift
let prettier = Prettier()
let input = "<html><body><p>hello</p></body></html>"
let output = prettier.prettify(input, parser: .html)!
let expected_output =
"""
<html>
<body>
<p>hello</p>
</body>
</html>
"""
XCTAssertEqual(output, expected_output)
import Prettier_swift
let prettier = Prettier()
let input = "{human(id:\"1000\"){name height}}"
let output = prettier.prettify(input, parser: .graphql)
let expected_output =
"""
{
human(id: "1000") {
name
height
}
}
"""
XCTAssertEqual(output, expected_output)
Prettier.swift is available under the MIT license. See the LICENSE file for more info.