Swiftpack.co - michaelhenry/Prettier.swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by michaelhenry.
michaelhenry/Prettier.swift 1.1.1
Prettier.io wrapper for swift. An opinionated code formatter.
⭐️ 10
🕓 1 year ago
.package(url: "https://github.com/michaelhenry/Prettier.swift.git", from: "1.1.1")

Prettier.swift

Version License Platform codecov

Prettier.io wrapper for swift. An opinionated code formatter.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

Prettier.swift is available via SPM or Cocoapods.

pod 'Prettier.swift'

How to use

JSON

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)

HTML

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)

GRAPHQL

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)

AND MORE!

License

Prettier.swift is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 10
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Fix: Resources folder bug on non swift module project.
1 year ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics